From 4061d0ff3e8ed72ecb83ef1026492511a0afb9fa Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 7 Apr 2010 17:18:04 +0200 Subject: Fix EGLImage & re-enable its use in QtOpenGL Make sure we set the EGL_KHR_image_base define when we define the reset of the extension defines. This also makes eglCreateImageKHR get defined when previously it wasn't. Reviewed-By: TrustMe (cherry picked from commit 99c17c0efb1331f5d11260b08614c9dff9bbf2e1) --- src/gui/egl/qegl_p.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index 540cd3d..f81add6 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -139,6 +139,12 @@ QT_BEGIN_NAMESPACE typedef void *EGLImageKHR; #define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) #define EGL_IMAGE_PRESERVED_KHR 0x30D2 +#define EGL_KHR_image_base +#endif + +#if !defined(EGL_KHR_image) && !defined(EGL_KHR_image_pixmap) +#define EGL_NATIVE_PIXMAP_KHR 0x30B0 +#define EGL_KHR_image_pixmap #endif // It is possible that something has included eglext.h (like Symbian 10.1's broken egl.h), in @@ -154,9 +160,6 @@ extern Q_GUI_EXPORT _eglCreateImageKHR eglCreateImageKHR; extern Q_GUI_EXPORT _eglDestroyImageKHR eglDestroyImageKHR; #endif // (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES) -#if !defined(EGL_KHR_image) && !defined(EGL_KHR_image_pixmap) -#define EGL_NATIVE_PIXMAP_KHR 0x30B0 -#endif class QEglProperties; -- cgit v0.12 From 1c9cde4d2b9cc588890be7445ab4248cbd8f58aa Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 14 Apr 2010 09:30:03 +1000 Subject: Ensure view position is correct for highlight range modes that have a static highlight Task-number: QTBUG-9791 (cherry picked from commit 9416f29a3ee7511c182eaa68f5523132ff64921d) --- .../graphicsitems/qdeclarativegridview.cpp | 4 +-- .../graphicsitems/qdeclarativelistview.cpp | 4 +-- .../data/strictlyenforcerange.qml | 29 ++++++++++++++++ .../tst_qdeclarativelistview.cpp | 39 ++++++++++++++++++++++ 4 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativelistview/data/strictlyenforcerange.qml diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 9be025a..5cd6de4 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -613,8 +613,6 @@ void QDeclarativeGridViewPrivate::updateTrackedItem() if (highlight) item = highlight; - FxGridItem *oldTracked = trackedItem; - if (trackedItem && item != trackedItem) { QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); @@ -626,7 +624,7 @@ void QDeclarativeGridViewPrivate::updateTrackedItem() QObject::connect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); QObject::connect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); } - if (trackedItem && trackedItem != oldTracked) + if (trackedItem) q->trackedPositionChanged(); } diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index b4506ef..622da5b 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -770,8 +770,6 @@ void QDeclarativeListViewPrivate::updateTrackedItem() if (highlight) item = highlight; - FxListItem *oldTracked = trackedItem; - const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); @@ -786,7 +784,7 @@ void QDeclarativeListViewPrivate::updateTrackedItem() QObject::connect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged())); QObject::connect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged())); } - if (trackedItem && trackedItem != oldTracked) + if (trackedItem) q->trackedPositionChanged(); } diff --git a/tests/auto/declarative/qdeclarativelistview/data/strictlyenforcerange.qml b/tests/auto/declarative/qdeclarativelistview/data/strictlyenforcerange.qml new file mode 100644 index 0000000..6fc41fa --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistview/data/strictlyenforcerange.qml @@ -0,0 +1,29 @@ +import Qt 4.7 + +ListView { + id: list + objectName: "list" + width: 320 + height: 480 + + function fillModel() { + list.model.append({"col": "red"}); + list.currentIndex = list.count-1 + list.model.append({"col": "blue"}); + list.currentIndex = list.count-1 + list.model.append({"col": "green"}); + list.currentIndex = list.count-1 + } + + model: ListModel { id: listModel } // empty model + delegate: Rectangle { id: wrapper; objectName: "wrapper"; color: col; width: 300; height: 400 } + orientation: "Horizontal" + snapMode: "SnapToItem" + cacheBuffer: 1000 + + preferredHighlightBegin: 10 + preferredHighlightEnd: 10 + + highlightRangeMode: "StrictlyEnforceRange" + focus: true +} diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 8d94804..5b81d75 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -88,6 +88,7 @@ private slots: void propertyChanges(); void componentChanges(); void modelChanges(); + void QTBUG_9791(); private: template void items(); @@ -1472,6 +1473,44 @@ void tst_QDeclarativeListView::modelChanges() delete canvas; } +void tst_QDeclarativeListView::QTBUG_9791() +{ + QDeclarativeView *canvas = createView(); + + QDeclarativeContext *ctxt = canvas->rootContext(); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/strictlyenforcerange.qml")); + qApp->processEvents(); + + QDeclarativeListView *listview = qobject_cast(canvas->rootObject()); + QTRY_VERIFY(listview != 0); + + QDeclarativeItem *viewport = listview->viewport(); + QTRY_VERIFY(viewport != 0); + QTRY_VERIFY(listview->delegate() != 0); + QTRY_VERIFY(listview->model() != 0); + + QMetaObject::invokeMethod(listview, "fillModel"); + qApp->processEvents(); + + // Confirm items positioned correctly + int itemCount = findItems(viewport, "wrapper").count(); + QVERIFY(itemCount == 3); + + for (int i = 0; i < itemCount; ++i) { + QDeclarativeItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), i*300.0); + } + + // check that view is positioned correctly + QTRY_COMPARE(listview->contentX(), 590.0); + + delete canvas; +} + + void tst_QDeclarativeListView::qListModelInterface_items() { items(); -- cgit v0.12 From 7d9621652528fe292b2b3599ba389be61d916db4 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 14 Apr 2010 11:06:49 +1000 Subject: Complete item creation after its initial properties have been initialized. Task-number: QTBUG-9800 (cherry picked from commit 955daf47a350ad9eb84b30f50431482b16ecf22f) --- src/declarative/graphicsitems/qdeclarativepathview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 06e3540..4aaa28d 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -1102,7 +1102,6 @@ void QDeclarativePathView::refill() // 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)) @@ -1115,6 +1114,7 @@ void QDeclarativePathView::refill() d->firstIndex = idx; d->items.append(item); d->updateItem(item, pos); + d->model->completeItem(); ++idx; if (idx >= d->model->count()) idx = 0; @@ -1129,7 +1129,6 @@ void QDeclarativePathView::refill() // 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)) @@ -1140,6 +1139,7 @@ void QDeclarativePathView::refill() } d->items.prepend(item); d->updateItem(item, pos); + d->model->completeItem(); d->firstIndex = idx; idx = d->firstIndex - 1; if (idx < 0) -- cgit v0.12 From 0ff9f2480e7337f5a9685f602c786614973ab7e9 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 14 Apr 2010 11:29:35 +1000 Subject: emit onMovementStarted/Ended/Changed on wheel events Task-number: QTBUG-9804 (cherry picked from commit d44b7f2faa8cdc3832eac40bc45102acc3e3146a) --- src/declarative/graphicsitems/qdeclarativeflickable.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index fc7a87b..951b171 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -816,6 +816,8 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event) d->vData.velocity = qMin(event->delta() - d->vData.smoothVelocity.value(), qreal(-250.0)); d->flicked = false; d->flickY(d->vData.velocity); + if (d->flicked) + movementStarting(); event->accept(); } else if (xflick()) { if (event->delta() > 0) @@ -824,6 +826,8 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event) d->hData.velocity = qMin(event->delta() - d->hData.smoothVelocity.value(), qreal(-250.0)); d->flicked = false; d->flickX(d->hData.velocity); + if (d->flicked) + movementStarting(); event->accept(); } else { QDeclarativeItem::wheelEvent(event); -- cgit v0.12 From b3d9d6e81cfafcc01a23ec0c524f91ba6db4536b Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 14 Apr 2010 10:16:41 +1000 Subject: Don't crash when columns == 0 Task-number: QTBUG-9805 (cherry picked from commit 3469fe05e4b04567598202fecc16c1decfb3ab63) --- .../graphicsitems/qdeclarativepositioners.cpp | 9 ++--- .../data/gridzerocolumns.qml | 40 ++++++++++++++++++++++ .../tst_qdeclarativepositioners.cpp | 33 ++++++++++++++++++ 3 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativepositioners/data/gridzerocolumns.qml diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index d33a8be..f436471 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -700,14 +700,15 @@ void QDeclarativeGrid::setRows(const int rows) void QDeclarativeGrid::doPositioning(QSizeF *contentSize) { - int c=_columns,r=_rows;//Actual number of rows/columns + int c = _columns; + int r = _rows; int numVisible = positionedItems.count(); - if (_columns==-1 && _rows==-1){ + if (_columns <= 0 && _rows <= 0){ c = 4; r = (numVisible+3)/4; - }else if (_rows==-1){ + } else if (_rows <= 0){ r = (numVisible+(_columns-1))/_columns; - }else if (_columns==-1){ + } else if (_columns <= 0){ c = (numVisible+(_rows-1))/_rows; } diff --git a/tests/auto/declarative/qdeclarativepositioners/data/gridzerocolumns.qml b/tests/auto/declarative/qdeclarativepositioners/data/gridzerocolumns.qml new file mode 100644 index 0000000..052d96b --- /dev/null +++ b/tests/auto/declarative/qdeclarativepositioners/data/gridzerocolumns.qml @@ -0,0 +1,40 @@ +import Qt 4.6 + +Item { + width: 640 + height: 480 + Grid { + objectName: "grid" + columns: 0 + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 08eac0a..8692596 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -63,6 +63,7 @@ private slots: void test_grid(); void test_grid_spacing(); void test_grid_animated(); + void test_grid_zero_columns(); void test_propertychanges(); void test_repeater(); void test_flow(); @@ -414,6 +415,38 @@ void tst_QDeclarativePositioners::test_grid_animated() QTRY_COMPARE(five->y(), 50.0); } + +void tst_QDeclarativePositioners::test_grid_zero_columns() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/gridzerocolumns.qml"); + + QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 70.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 120.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(five->x(), 0.0); + QCOMPARE(five->y(), 50.0); + + QDeclarativeItem *grid = canvas->rootObject()->findChild("grid"); + QCOMPARE(grid->width(), 170.0); + QCOMPARE(grid->height(), 60.0); +} + void tst_QDeclarativePositioners::test_propertychanges() { QDeclarativeView *canvas = createView(SRCDIR "/data/propertychangestest.qml"); -- cgit v0.12 From 8a4474d66550bddf71b5a447435d37999772079f Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Tue, 13 Apr 2010 17:01:54 +1000 Subject: Add 'runtime' property to the rootContext of DeclarativeViewer The 'runtime' property is a singleton object that contains various info about the execution environment for the qml application. Currently it contains just one property 'isActiveWindow', which tells if the window of the declarative viewer is active or not. Task-number: QTBUG-8902 Reviewed-by: Martin Jones (cherry picked from commit ffd45093795e9481505af0ae9bf5df7b6c704c72) --- tools/qml/qmlruntime.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ tools/qml/qmlruntime.h | 1 + 2 files changed, 45 insertions(+) diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index c4ebd80..40de100 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -134,6 +134,38 @@ signals: void orientationChanged(); }; +class Runtime : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool isActiveWindow READ isActiveWindow NOTIFY isActiveWindowChanged) + +public: + static Runtime* instance() + { + static Runtime *instance = 0; + if (!instance) + instance = new Runtime; + return instance; + } + + bool isActiveWindow() const { return activeWindow; } + void setActiveWindow(bool active) + { + if (active == activeWindow) + return; + activeWindow = active; + emit isActiveWindowChanged(); + } + +signals: + void isActiveWindowChanged(); + +private: + Runtime(QObject *parent=0) : QObject(parent), activeWindow(false) {} + + bool activeWindow; +}; + QT_END_NAMESPACE QML_DECLARE_TYPE(Screen) @@ -1048,6 +1080,8 @@ void QDeclarativeViewer::openQml(const QString& file_or_url) ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath()); #endif + ctxt->setContextProperty("runtime", Runtime::instance()); + QString fileName = url.toLocalFile(); if (!fileName.isEmpty()) { QFileInfo fi(fileName); @@ -1249,6 +1283,16 @@ void QDeclarativeViewer::keyPressEvent(QKeyEvent *event) QWidget::keyPressEvent(event); } +bool QDeclarativeViewer::event(QEvent *event) +{ + if (event->type() == QEvent::WindowActivate) { + Runtime::instance()->setActiveWindow(true); + } else if (event->type() == QEvent::WindowDeactivate) { + Runtime::instance()->setActiveWindow(false); + } + return QWidget::event(event); +} + void QDeclarativeViewer::senseImageMagick() { QProcess proc; diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 6f1e425..74a0f07 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -125,6 +125,7 @@ public slots: protected: virtual void keyPressEvent(QKeyEvent *); + virtual bool event(QEvent *); void createMenu(QMenuBar *menu, QMenu *flatmenu); -- cgit v0.12 From b85d0a69c909e65f97908d64a4a8caef55e6391a Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Wed, 14 Apr 2010 12:15:26 +1000 Subject: Reduce QML runtime capabilities to NetworkServices and ReadUserData Task-number: Reviewed-by: Martin Jones (cherry picked from commit 5a1a3ab59e96bb5b2968883160564eb24d011859) --- demos/declarative/minehunt/minehunt.pro | 2 +- tools/qml/qml.pro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro index 8a5667d..095fa42 100644 --- a/demos/declarative/minehunt/minehunt.pro +++ b/demos/declarative/minehunt/minehunt.pro @@ -26,7 +26,7 @@ symbian:{ load(data_caging_paths) TARGET.EPOCALLOWDLLDATA = 1 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - + TARGET.CAPABILITY = NetworkServices ReadUserData importFiles.sources = minehunt.dll \ MinehuntCore/Explosion.qml \ MinehuntCore/pics \ diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index bc6d032..1ed8b2c 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -56,7 +56,7 @@ symbian { INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 LIBS += -lesock -lcommdb -lconnmon -linsock - TARGET.CAPABILITY = "All -TCB" + TARGET.CAPABILITY = NetworkServices ReadUserData } mac { QMAKE_INFO_PLIST=Info_mac.plist -- cgit v0.12 From d005553b64db9a22d143ce1f43f30b58b1e81bc5 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 14 Apr 2010 21:45:36 +0200 Subject: Update to def files for 4.7.0-beta1 Frozen against qt-releases/4.7.0-beta1 commit 4061d0ff3e8ed72ecb83ef1026492511a0afb9fa Task-number: QTBUG-9892 Reviewed-by: Trust Me (cherry picked from commit e40fea6a052f172d3eb3c0901ee502d1747c3817) --- src/s60installs/bwins/QtCoreu.def | 7 +- src/s60installs/bwins/QtDeclarativeu.def | 129 ++++++++++++++++++++++------- src/s60installs/bwins/QtGuiu.def | 5 +- src/s60installs/bwins/QtMultimediau.def | 2 + src/s60installs/eabi/QtCoreu.def | 13 +-- src/s60installs/eabi/QtDeclarativeu.def | 135 ++++++++++++++++++++++++------- src/s60installs/eabi/QtGuiu.def | 5 +- src/s60installs/eabi/QtMultimediau.def | 3 + 8 files changed, 234 insertions(+), 65 deletions(-) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index cf7fe6f..c2692f6 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -382,7 +382,7 @@ EXPORTS ??1QDateTime@@QAE@XZ @ 381 NONAME ; QDateTime::~QDateTime(void) ??1QDateTimeParser@@UAE@XZ @ 382 NONAME ; QDateTimeParser::~QDateTimeParser(void) ??1QDebug@@QAE@XZ @ 383 NONAME ; QDebug::~QDebug(void) - ??1QDeclarativeData@@UAE@XZ @ 384 NONAME ; QDeclarativeData::~QDeclarativeData(void) + ??1QDeclarativeData@@UAE@XZ @ 384 NONAME ABSENT ; QDeclarativeData::~QDeclarativeData(void) ??1QDir@@QAE@XZ @ 385 NONAME ; QDir::~QDir(void) ??1QDirIterator@@UAE@XZ @ 386 NONAME ; QDirIterator::~QDirIterator(void) ??1QDynamicPropertyChangeEvent@@UAE@XZ @ 387 NONAME ; QDynamicPropertyChangeEvent::~QDynamicPropertyChangeEvent(void) @@ -885,7 +885,7 @@ EXPORTS ??_EQCoreApplicationPrivate@@UAE@I@Z @ 884 NONAME ; QCoreApplicationPrivate::~QCoreApplicationPrivate(unsigned int) ??_EQDataStream@@UAE@I@Z @ 885 NONAME ; QDataStream::~QDataStream(unsigned int) ??_EQDateTimeParser@@UAE@I@Z @ 886 NONAME ; QDateTimeParser::~QDateTimeParser(unsigned int) - ??_EQDeclarativeData@@UAE@I@Z @ 887 NONAME ; QDeclarativeData::~QDeclarativeData(unsigned int) + ??_EQDeclarativeData@@UAE@I@Z @ 887 NONAME ABSENT ; QDeclarativeData::~QDeclarativeData(unsigned int) ??_EQDirIterator@@UAE@I@Z @ 888 NONAME ; QDirIterator::~QDirIterator(unsigned int) ??_EQDynamicPropertyChangeEvent@@UAE@I@Z @ 889 NONAME ; QDynamicPropertyChangeEvent::~QDynamicPropertyChangeEvent(unsigned int) ??_EQEvent@@UAE@I@Z @ 890 NONAME ; QEvent::~QEvent(unsigned int) @@ -4457,4 +4457,7 @@ EXPORTS ?toEasingCurve@QVariant@@QBE?AVQEasingCurve@@XZ @ 4456 NONAME ; class QEasingCurve QVariant::toEasingCurve(void) const ?toMSecsSinceEpoch@QDateTime@@QBE_JXZ @ 4457 NONAME ; long long QDateTime::toMSecsSinceEpoch(void) const ?transitions@QState@@QBE?AV?$QList@PAVQAbstractTransition@@@@XZ @ 4458 NONAME ; class QList QState::transitions(void) const + ?validCodecs@QTextCodec@@CA_NXZ @ 4459 NONAME ; bool QTextCodec::validCodecs(void) + ?destroyed@QDeclarativeData@@2P6AXPAV1@PAVQObject@@@ZA @ 4460 NONAME ; void (*QDeclarativeData::destroyed)(class QDeclarativeData *, class QObject *) + ?parentChanged@QDeclarativeData@@2P6AXPAV1@PAVQObject@@1@ZA @ 4461 NONAME ; void (*QDeclarativeData::parentChanged)(class QDeclarativeData *, class QObject *, class QObject *) diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def index 89049a9..3eba5e7 100644 --- a/src/s60installs/bwins/QtDeclarativeu.def +++ b/src/s60installs/bwins/QtDeclarativeu.def @@ -98,7 +98,7 @@ EXPORTS ??0QDeclarativeFontLoader@@QAE@PAVQObject@@@Z @ 97 NONAME ; QDeclarativeFontLoader::QDeclarativeFontLoader(class QObject *) ??0QDeclarativeGradient@@QAE@PAVQObject@@@Z @ 98 NONAME ; QDeclarativeGradient::QDeclarativeGradient(class QObject *) ??0QDeclarativeGradientStop@@QAE@PAVQObject@@@Z @ 99 NONAME ; QDeclarativeGradientStop::QDeclarativeGradientStop(class QObject *) - ??0QDeclarativeGraphicsObjectContainer@@QAE@PAVQDeclarativeItem@@@Z @ 100 NONAME ; QDeclarativeGraphicsObjectContainer::QDeclarativeGraphicsObjectContainer(class QDeclarativeItem *) + ??0QDeclarativeGraphicsObjectContainer@@QAE@PAVQDeclarativeItem@@@Z @ 100 NONAME ABSENT ; QDeclarativeGraphicsObjectContainer::QDeclarativeGraphicsObjectContainer(class QDeclarativeItem *) ??0QDeclarativeGrid@@QAE@PAVQDeclarativeItem@@@Z @ 101 NONAME ; QDeclarativeGrid::QDeclarativeGrid(class QDeclarativeItem *) ??0QDeclarativeGridScaledImage@@QAE@ABV0@@Z @ 102 NONAME ; QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(class QDeclarativeGridScaledImage const &) ??0QDeclarativeGridScaledImage@@QAE@PAVQIODevice@@@Z @ 103 NONAME ; QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(class QIODevice *) @@ -268,7 +268,7 @@ EXPORTS ??1QDeclarativeFontLoader@@UAE@XZ @ 267 NONAME ; QDeclarativeFontLoader::~QDeclarativeFontLoader(void) ??1QDeclarativeGradient@@UAE@XZ @ 268 NONAME ; QDeclarativeGradient::~QDeclarativeGradient(void) ??1QDeclarativeGradientStop@@UAE@XZ @ 269 NONAME ; QDeclarativeGradientStop::~QDeclarativeGradientStop(void) - ??1QDeclarativeGraphicsObjectContainer@@UAE@XZ @ 270 NONAME ; QDeclarativeGraphicsObjectContainer::~QDeclarativeGraphicsObjectContainer(void) + ??1QDeclarativeGraphicsObjectContainer@@UAE@XZ @ 270 NONAME ABSENT ; QDeclarativeGraphicsObjectContainer::~QDeclarativeGraphicsObjectContainer(void) ??1QDeclarativeGrid@@UAE@XZ @ 271 NONAME ; QDeclarativeGrid::~QDeclarativeGrid(void) ??1QDeclarativeGridScaledImage@@QAE@XZ @ 272 NONAME ; QDeclarativeGridScaledImage::~QDeclarativeGridScaledImage(void) ??1QDeclarativeGridView@@UAE@XZ @ 273 NONAME ; QDeclarativeGridView::~QDeclarativeGridView(void) @@ -449,7 +449,7 @@ EXPORTS ??_EQDeclarativeFontLoader@@UAE@I@Z @ 448 NONAME ; QDeclarativeFontLoader::~QDeclarativeFontLoader(unsigned int) ??_EQDeclarativeGradient@@UAE@I@Z @ 449 NONAME ; QDeclarativeGradient::~QDeclarativeGradient(unsigned int) ??_EQDeclarativeGradientStop@@UAE@I@Z @ 450 NONAME ; QDeclarativeGradientStop::~QDeclarativeGradientStop(unsigned int) - ??_EQDeclarativeGraphicsObjectContainer@@UAE@I@Z @ 451 NONAME ; QDeclarativeGraphicsObjectContainer::~QDeclarativeGraphicsObjectContainer(unsigned int) + ??_EQDeclarativeGraphicsObjectContainer@@UAE@I@Z @ 451 NONAME ABSENT ; QDeclarativeGraphicsObjectContainer::~QDeclarativeGraphicsObjectContainer(unsigned int) ??_EQDeclarativeGrid@@UAE@I@Z @ 452 NONAME ; QDeclarativeGrid::~QDeclarativeGrid(unsigned int) ??_EQDeclarativeGridView@@UAE@I@Z @ 453 NONAME ; QDeclarativeGridView::~QDeclarativeGridView(unsigned int) ??_EQDeclarativeImage@@UAE@I@Z @ 454 NONAME ; QDeclarativeImage::~QDeclarativeImage(unsigned int) @@ -910,8 +910,8 @@ EXPORTS ?d_func@QDeclarativeFlow@@ABEPBVQDeclarativeFlowPrivate@@XZ @ 909 NONAME ; class QDeclarativeFlowPrivate const * QDeclarativeFlow::d_func(void) const ?d_func@QDeclarativeFontLoader@@AAEPAVQDeclarativeFontLoaderPrivate@@XZ @ 910 NONAME ; class QDeclarativeFontLoaderPrivate * QDeclarativeFontLoader::d_func(void) ?d_func@QDeclarativeFontLoader@@ABEPBVQDeclarativeFontLoaderPrivate@@XZ @ 911 NONAME ; class QDeclarativeFontLoaderPrivate const * QDeclarativeFontLoader::d_func(void) const - ?d_func@QDeclarativeGraphicsObjectContainer@@AAEPAVQDeclarativeGraphicsObjectContainerPrivate@@XZ @ 912 NONAME ; class QDeclarativeGraphicsObjectContainerPrivate * QDeclarativeGraphicsObjectContainer::d_func(void) - ?d_func@QDeclarativeGraphicsObjectContainer@@ABEPBVQDeclarativeGraphicsObjectContainerPrivate@@XZ @ 913 NONAME ; class QDeclarativeGraphicsObjectContainerPrivate const * QDeclarativeGraphicsObjectContainer::d_func(void) const + ?d_func@QDeclarativeGraphicsObjectContainer@@AAEPAVQDeclarativeGraphicsObjectContainerPrivate@@XZ @ 912 NONAME ABSENT ; class QDeclarativeGraphicsObjectContainerPrivate * QDeclarativeGraphicsObjectContainer::d_func(void) + ?d_func@QDeclarativeGraphicsObjectContainer@@ABEPBVQDeclarativeGraphicsObjectContainerPrivate@@XZ @ 913 NONAME ABSENT ; class QDeclarativeGraphicsObjectContainerPrivate const * QDeclarativeGraphicsObjectContainer::d_func(void) const ?d_func@QDeclarativeGridView@@AAEPAVQDeclarativeGridViewPrivate@@XZ @ 914 NONAME ; class QDeclarativeGridViewPrivate * QDeclarativeGridView::d_func(void) ?d_func@QDeclarativeGridView@@ABEPBVQDeclarativeGridViewPrivate@@XZ @ 915 NONAME ; class QDeclarativeGridViewPrivate const * QDeclarativeGridView::d_func(void) const ?d_func@QDeclarativeImage@@AAEPAVQDeclarativeImagePrivate@@XZ @ 916 NONAME ; class QDeclarativeImagePrivate * QDeclarativeImage::d_func(void) @@ -1096,7 +1096,7 @@ EXPORTS ?event@QDeclarativeSystemPalette@@EAE_NPAVQEvent@@@Z @ 1095 NONAME ; bool QDeclarativeSystemPalette::event(class QEvent *) ?event@QDeclarativeTextEdit@@MAE_NPAVQEvent@@@Z @ 1096 NONAME ; bool QDeclarativeTextEdit::event(class QEvent *) ?event@QDeclarativeTextInput@@MAE_NPAVQEvent@@@Z @ 1097 NONAME ; bool QDeclarativeTextInput::event(class QEvent *) - ?eventFilter@QDeclarativeGraphicsObjectContainer@@MAE_NPAVQObject@@PAVQEvent@@@Z @ 1098 NONAME ; bool QDeclarativeGraphicsObjectContainer::eventFilter(class QObject *, class QEvent *) + ?eventFilter@QDeclarativeGraphicsObjectContainer@@MAE_NPAVQObject@@PAVQEvent@@@Z @ 1098 NONAME ABSENT ; bool QDeclarativeGraphicsObjectContainer::eventFilter(class QObject *, class QEvent *) ?eventFilter@QDeclarativeLoader@@MAE_NPAVQObject@@PAVQEvent@@@Z @ 1099 NONAME ; bool QDeclarativeLoader::eventFilter(class QObject *, class QEvent *) ?eventFilter@QDeclarativeSystemPalette@@EAE_NPAVQObject@@PAVQEvent@@@Z @ 1100 NONAME ; bool QDeclarativeSystemPalette::eventFilter(class QObject *, class QEvent *) ?execute@QDeclarativeAnchorChanges@@UAEXXZ @ 1101 NONAME ; void QDeclarativeAnchorChanges::execute(void) @@ -1223,7 +1223,7 @@ EXPORTS ?getStaticMetaObject@QDeclarativeFontLoader@@SAABUQMetaObject@@XZ @ 1222 NONAME ; struct QMetaObject const & QDeclarativeFontLoader::getStaticMetaObject(void) ?getStaticMetaObject@QDeclarativeGradient@@SAABUQMetaObject@@XZ @ 1223 NONAME ; struct QMetaObject const & QDeclarativeGradient::getStaticMetaObject(void) ?getStaticMetaObject@QDeclarativeGradientStop@@SAABUQMetaObject@@XZ @ 1224 NONAME ; struct QMetaObject const & QDeclarativeGradientStop::getStaticMetaObject(void) - ?getStaticMetaObject@QDeclarativeGraphicsObjectContainer@@SAABUQMetaObject@@XZ @ 1225 NONAME ; struct QMetaObject const & QDeclarativeGraphicsObjectContainer::getStaticMetaObject(void) + ?getStaticMetaObject@QDeclarativeGraphicsObjectContainer@@SAABUQMetaObject@@XZ @ 1225 NONAME ABSENT ; struct QMetaObject const & QDeclarativeGraphicsObjectContainer::getStaticMetaObject(void) ?getStaticMetaObject@QDeclarativeGrid@@SAABUQMetaObject@@XZ @ 1226 NONAME ; struct QMetaObject const & QDeclarativeGrid::getStaticMetaObject(void) ?getStaticMetaObject@QDeclarativeGridView@@SAABUQMetaObject@@XZ @ 1227 NONAME ; struct QMetaObject const & QDeclarativeGridView::getStaticMetaObject(void) ?getStaticMetaObject@QDeclarativeImage@@SAABUQMetaObject@@XZ @ 1228 NONAME ; struct QMetaObject const & QDeclarativeImage::getStaticMetaObject(void) @@ -1282,7 +1282,7 @@ EXPORTS ?getStaticMetaObject@QPacketProtocol@@SAABUQMetaObject@@XZ @ 1281 NONAME ; struct QMetaObject const & QPacketProtocol::getStaticMetaObject(void) ?gradient@QDeclarativeGradient@@QBEPBVQGradient@@XZ @ 1282 NONAME ; class QGradient const * QDeclarativeGradient::gradient(void) const ?gradient@QDeclarativeRectangle@@QBEPAVQDeclarativeGradient@@XZ @ 1283 NONAME ; class QDeclarativeGradient * QDeclarativeRectangle::gradient(void) const - ?graphicsObject@QDeclarativeGraphicsObjectContainer@@QBEPAVQGraphicsObject@@XZ @ 1284 NONAME ; class QGraphicsObject * QDeclarativeGraphicsObjectContainer::graphicsObject(void) const + ?graphicsObject@QDeclarativeGraphicsObjectContainer@@QBEPAVQGraphicsObject@@XZ @ 1284 NONAME ABSENT ; class QGraphicsObject * QDeclarativeGraphicsObjectContainer::graphicsObject(void) const ?gridBottom@QDeclarativeGridScaledImage@@QBEHXZ @ 1285 NONAME ; int QDeclarativeGridScaledImage::gridBottom(void) const ?gridLeft@QDeclarativeGridScaledImage@@QBEHXZ @ 1286 NONAME ; int QDeclarativeGridScaledImage::gridLeft(void) const ?gridRight@QDeclarativeGridScaledImage@@QBEHXZ @ 1287 NONAME ; int QDeclarativeGridScaledImage::gridRight(void) const @@ -1350,7 +1350,7 @@ EXPORTS ?imageProvider@QDeclarativeEngine@@QBEPAVQDeclarativeImageProvider@@ABVQString@@@Z @ 1349 NONAME ; class QDeclarativeImageProvider * QDeclarativeEngine::imageProvider(class QString const &) const ?implicitHeight@QDeclarativeItem@@QBEMXZ @ 1350 NONAME ; float QDeclarativeItem::implicitHeight(void) const ?implicitWidth@QDeclarativeItem@@QBEMXZ @ 1351 NONAME ; float QDeclarativeItem::implicitWidth(void) const - ?importExtension@QDeclarativeEngine@@QAE_NABVQString@@0@Z @ 1352 NONAME ; bool QDeclarativeEngine::importExtension(class QString const &, class QString const &) + ?importExtension@QDeclarativeEngine@@QAE_NABVQString@@0@Z @ 1352 NONAME ABSENT ; bool QDeclarativeEngine::importExtension(class QString const &, class QString const &) ?imports@QDeclarativeDomDocument@@QBE?AV?$QList@VQDeclarativeDomImport@@@@XZ @ 1353 NONAME ; class QList QDeclarativeDomDocument::imports(void) const ?inSync@QDeclarativeSpringFollow@@QBE_NXZ @ 1354 NONAME ; bool QDeclarativeSpringFollow::inSync(void) const ?incrementCurrentIndex@QDeclarativeListView@@QAEXXZ @ 1355 NONAME ; void QDeclarativeListView::incrementCurrentIndex(void) @@ -1484,7 +1484,7 @@ EXPORTS ?item@QDeclarativeVisualDataModel@@UAEPAVQDeclarativeItem@@H_N@Z @ 1483 NONAME ; class QDeclarativeItem * QDeclarativeVisualDataModel::item(int, bool) ?item@QDeclarativeVisualItemModel@@UAEPAVQDeclarativeItem@@H_N@Z @ 1484 NONAME ; class QDeclarativeItem * QDeclarativeVisualItemModel::item(int, bool) ?itemChange@QDeclarativeBasePositioner@@MAE?AVQVariant@@W4GraphicsItemChange@QGraphicsItem@@ABV2@@Z @ 1485 NONAME ; class QVariant QDeclarativeBasePositioner::itemChange(enum QGraphicsItem::GraphicsItemChange, class QVariant const &) - ?itemChange@QDeclarativeGraphicsObjectContainer@@MAE?AVQVariant@@W4GraphicsItemChange@QGraphicsItem@@ABV2@@Z @ 1486 NONAME ; class QVariant QDeclarativeGraphicsObjectContainer::itemChange(enum QGraphicsItem::GraphicsItemChange, class QVariant const &) + ?itemChange@QDeclarativeGraphicsObjectContainer@@MAE?AVQVariant@@W4GraphicsItemChange@QGraphicsItem@@ABV2@@Z @ 1486 NONAME ABSENT ; class QVariant QDeclarativeGraphicsObjectContainer::itemChange(enum QGraphicsItem::GraphicsItemChange, class QVariant const &) ?itemChange@QDeclarativeItem@@MAE?AVQVariant@@W4GraphicsItemChange@QGraphicsItem@@ABV2@@Z @ 1487 NONAME ; class QVariant QDeclarativeItem::itemChange(enum QGraphicsItem::GraphicsItemChange, class QVariant const &) ?itemChange@QDeclarativeLoader@@MAE?AVQVariant@@W4GraphicsItemChange@QGraphicsItem@@ABV2@@Z @ 1488 NONAME ; class QVariant QDeclarativeLoader::itemChange(enum QGraphicsItem::GraphicsItemChange, class QVariant const &) ?itemChange@QDeclarativeRepeater@@MAE?AVQVariant@@W4GraphicsItemChange@QGraphicsItem@@ABV2@@Z @ 1489 NONAME ; class QVariant QDeclarativeRepeater::itemChange(enum QGraphicsItem::GraphicsItemChange, class QVariant const &) @@ -1625,7 +1625,7 @@ EXPORTS ?metaObject@QDeclarativeFontLoader@@UBEPBUQMetaObject@@XZ @ 1624 NONAME ; struct QMetaObject const * QDeclarativeFontLoader::metaObject(void) const ?metaObject@QDeclarativeGradient@@UBEPBUQMetaObject@@XZ @ 1625 NONAME ; struct QMetaObject const * QDeclarativeGradient::metaObject(void) const ?metaObject@QDeclarativeGradientStop@@UBEPBUQMetaObject@@XZ @ 1626 NONAME ; struct QMetaObject const * QDeclarativeGradientStop::metaObject(void) const - ?metaObject@QDeclarativeGraphicsObjectContainer@@UBEPBUQMetaObject@@XZ @ 1627 NONAME ; struct QMetaObject const * QDeclarativeGraphicsObjectContainer::metaObject(void) const + ?metaObject@QDeclarativeGraphicsObjectContainer@@UBEPBUQMetaObject@@XZ @ 1627 NONAME ABSENT ; struct QMetaObject const * QDeclarativeGraphicsObjectContainer::metaObject(void) const ?metaObject@QDeclarativeGrid@@UBEPBUQMetaObject@@XZ @ 1628 NONAME ; struct QMetaObject const * QDeclarativeGrid::metaObject(void) const ?metaObject@QDeclarativeGridView@@UBEPBUQMetaObject@@XZ @ 1629 NONAME ; struct QMetaObject const * QDeclarativeGridView::metaObject(void) const ?metaObject@QDeclarativeImage@@UBEPBUQMetaObject@@XZ @ 1630 NONAME ; struct QMetaObject const * QDeclarativeImage::metaObject(void) const @@ -1988,7 +1988,7 @@ EXPORTS ?qt_metacall@QDeclarativeFontLoader@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1987 NONAME ; int QDeclarativeFontLoader::qt_metacall(enum QMetaObject::Call, int, void * *) ?qt_metacall@QDeclarativeGradient@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1988 NONAME ; int QDeclarativeGradient::qt_metacall(enum QMetaObject::Call, int, void * *) ?qt_metacall@QDeclarativeGradientStop@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1989 NONAME ; int QDeclarativeGradientStop::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QDeclarativeGraphicsObjectContainer@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1990 NONAME ; int QDeclarativeGraphicsObjectContainer::qt_metacall(enum QMetaObject::Call, int, void * *) + ?qt_metacall@QDeclarativeGraphicsObjectContainer@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1990 NONAME ABSENT ; int QDeclarativeGraphicsObjectContainer::qt_metacall(enum QMetaObject::Call, int, void * *) ?qt_metacall@QDeclarativeGrid@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1991 NONAME ; int QDeclarativeGrid::qt_metacall(enum QMetaObject::Call, int, void * *) ?qt_metacall@QDeclarativeGridView@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1992 NONAME ; int QDeclarativeGridView::qt_metacall(enum QMetaObject::Call, int, void * *) ?qt_metacall@QDeclarativeImage@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1993 NONAME ; int QDeclarativeImage::qt_metacall(enum QMetaObject::Call, int, void * *) @@ -2083,7 +2083,7 @@ EXPORTS ?qt_metacast@QDeclarativeFontLoader@@UAEPAXPBD@Z @ 2082 NONAME ; void * QDeclarativeFontLoader::qt_metacast(char const *) ?qt_metacast@QDeclarativeGradient@@UAEPAXPBD@Z @ 2083 NONAME ; void * QDeclarativeGradient::qt_metacast(char const *) ?qt_metacast@QDeclarativeGradientStop@@UAEPAXPBD@Z @ 2084 NONAME ; void * QDeclarativeGradientStop::qt_metacast(char const *) - ?qt_metacast@QDeclarativeGraphicsObjectContainer@@UAEPAXPBD@Z @ 2085 NONAME ; void * QDeclarativeGraphicsObjectContainer::qt_metacast(char const *) + ?qt_metacast@QDeclarativeGraphicsObjectContainer@@UAEPAXPBD@Z @ 2085 NONAME ABSENT ; void * QDeclarativeGraphicsObjectContainer::qt_metacast(char const *) ?qt_metacast@QDeclarativeGrid@@UAEPAXPBD@Z @ 2086 NONAME ; void * QDeclarativeGrid::qt_metacast(char const *) ?qt_metacast@QDeclarativeGridView@@UAEPAXPBD@Z @ 2087 NONAME ; void * QDeclarativeGridView::qt_metacast(char const *) ?qt_metacast@QDeclarativeImage@@UAEPAXPBD@Z @ 2088 NONAME ; void * QDeclarativeImage::qt_metacast(char const *) @@ -2430,7 +2430,7 @@ EXPORTS ?setFromState@QDeclarativeTransition@@QAEXABVQString@@@Z @ 2429 NONAME ; void QDeclarativeTransition::setFromState(class QString const &) ?setFront@QDeclarativeFlipable@@QAEXPAVQDeclarativeItem@@@Z @ 2430 NONAME ABSENT ; void QDeclarativeFlipable::setFront(class QDeclarativeItem *) ?setGradient@QDeclarativeRectangle@@QAEXPAVQDeclarativeGradient@@@Z @ 2431 NONAME ; void QDeclarativeRectangle::setGradient(class QDeclarativeGradient *) - ?setGraphicsObject@QDeclarativeGraphicsObjectContainer@@QAEXPAVQGraphicsObject@@@Z @ 2432 NONAME ; void QDeclarativeGraphicsObjectContainer::setGraphicsObject(class QGraphicsObject *) + ?setGraphicsObject@QDeclarativeGraphicsObjectContainer@@QAEXPAVQGraphicsObject@@@Z @ 2432 NONAME ABSENT ; void QDeclarativeGraphicsObjectContainer::setGraphicsObject(class QGraphicsObject *) ?setGridScaledImage@QDeclarativeBorderImage@@AAEXABVQDeclarativeGridScaledImage@@@Z @ 2433 NONAME ; void QDeclarativeBorderImage::setGridScaledImage(class QDeclarativeGridScaledImage const &) ?setHAlign@QDeclarativeText@@QAEXW4HAlignment@1@@Z @ 2434 NONAME ; void QDeclarativeText::setHAlign(enum QDeclarativeText::HAlignment) ?setHAlign@QDeclarativeTextEdit@@QAEXW4HAlignment@1@@Z @ 2435 NONAME ; void QDeclarativeTextEdit::setHAlign(enum QDeclarativeTextEdit::HAlignment) @@ -2587,7 +2587,7 @@ EXPORTS ?setSourceComponent@QDeclarativeLoader@@QAEXPAVQDeclarativeComponent@@@Z @ 2586 NONAME ; void QDeclarativeLoader::setSourceComponent(class QDeclarativeComponent *) ?setSourceLocation@QDeclarativeExpression@@QAEXABVQString@@H@Z @ 2587 NONAME ; void QDeclarativeExpression::setSourceLocation(class QString const &, int) ?setSourceValue@QDeclarativeEaseFollow@@QAEXM@Z @ 2588 NONAME ABSENT ; void QDeclarativeEaseFollow::setSourceValue(float) - ?setSourceValue@QDeclarativeSpringFollow@@QAEXM@Z @ 2589 NONAME ; void QDeclarativeSpringFollow::setSourceValue(float) + ?setSourceValue@QDeclarativeSpringFollow@@QAEXM@Z @ 2589 NONAME ABSENT ; void QDeclarativeSpringFollow::setSourceValue(float) ?setSpacing@QDeclarativeBasePositioner@@QAEXH@Z @ 2590 NONAME ; void QDeclarativeBasePositioner::setSpacing(int) ?setSpacing@QDeclarativeListView@@QAEXM@Z @ 2591 NONAME ; void QDeclarativeListView::setSpacing(float) ?setSpring@QDeclarativeSpringFollow@@QAEXM@Z @ 2592 NONAME ; void QDeclarativeSpringFollow::setSpring(float) @@ -2605,7 +2605,7 @@ EXPORTS ?setStyle@QDeclarativeText@@QAEXW4TextStyle@1@@Z @ 2604 NONAME ; void QDeclarativeText::setStyle(enum QDeclarativeText::TextStyle) ?setStyleColor@QDeclarativeText@@QAEXABVQColor@@@Z @ 2605 NONAME ; void QDeclarativeText::setStyleColor(class QColor const &) ?setSuperClass@QMetaObjectBuilder@@QAEXPBUQMetaObject@@@Z @ 2606 NONAME ; void QMetaObjectBuilder::setSuperClass(struct QMetaObject const *) - ?setSynchronizedResizing@QDeclarativeGraphicsObjectContainer@@QAEX_N@Z @ 2607 NONAME ; void QDeclarativeGraphicsObjectContainer::setSynchronizedResizing(bool) + ?setSynchronizedResizing@QDeclarativeGraphicsObjectContainer@@QAEX_N@Z @ 2607 NONAME ABSENT ; void QDeclarativeGraphicsObjectContainer::setSynchronizedResizing(bool) ?setTag@QMetaMethodBuilder@@QAEXABVQByteArray@@@Z @ 2608 NONAME ; void QMetaMethodBuilder::setTag(class QByteArray const &) ?setTarget@QDeclarativeBehavior@@UAEXABVQDeclarativeProperty@@@Z @ 2609 NONAME ; void QDeclarativeBehavior::setTarget(class QDeclarativeProperty const &) ?setTarget@QDeclarativeConnections@@QAEXPAVQObject@@@Z @ 2610 NONAME ; void QDeclarativeConnections::setTarget(class QObject *) @@ -2703,7 +2703,7 @@ EXPORTS ?sourceComponent@QDeclarativeLoader@@QBEPAVQDeclarativeComponent@@XZ @ 2702 NONAME ; class QDeclarativeComponent * QDeclarativeLoader::sourceComponent(void) const ?sourceFile@QDeclarativeExpression@@QBE?AVQString@@XZ @ 2703 NONAME ; class QString QDeclarativeExpression::sourceFile(void) const ?sourceValue@QDeclarativeEaseFollow@@QBEMXZ @ 2704 NONAME ABSENT ; float QDeclarativeEaseFollow::sourceValue(void) const - ?sourceValue@QDeclarativeSpringFollow@@QBEMXZ @ 2705 NONAME ; float QDeclarativeSpringFollow::sourceValue(void) const + ?sourceValue@QDeclarativeSpringFollow@@QBEMXZ @ 2705 NONAME ABSENT ; float QDeclarativeSpringFollow::sourceValue(void) const ?spacing@QDeclarativeBasePositioner@@QBEHXZ @ 2706 NONAME ; int QDeclarativeBasePositioner::spacing(void) const ?spacing@QDeclarativeListView@@QBEMXZ @ 2707 NONAME ; float QDeclarativeListView::spacing(void) const ?spacingChanged@QDeclarativeBasePositioner@@IAEXXZ @ 2708 NONAME ; void QDeclarativeBasePositioner::spacingChanged(void) @@ -2756,7 +2756,7 @@ EXPORTS ?styleColorChanged@QDeclarativeText@@IAEXABVQColor@@@Z @ 2755 NONAME ; void QDeclarativeText::styleColorChanged(class QColor const &) ?superClass@QMetaObjectBuilder@@QBEPBUQMetaObject@@XZ @ 2756 NONAME ; struct QMetaObject const * QMetaObjectBuilder::superClass(void) const ?syncChanged@QDeclarativeSpringFollow@@IAEXXZ @ 2757 NONAME ; void QDeclarativeSpringFollow::syncChanged(void) - ?synchronizedResizing@QDeclarativeGraphicsObjectContainer@@QBE_NXZ @ 2758 NONAME ; bool QDeclarativeGraphicsObjectContainer::synchronizedResizing(void) const + ?synchronizedResizing@QDeclarativeGraphicsObjectContainer@@QBE_NXZ @ 2758 NONAME ABSENT ; bool QDeclarativeGraphicsObjectContainer::synchronizedResizing(void) const ?tag@QMetaMethodBuilder@@QBE?AVQByteArray@@XZ @ 2759 NONAME ; class QByteArray QMetaMethodBuilder::tag(void) const ?target@QDeclarativeConnections@@QBEPAVQObject@@XZ @ 2760 NONAME ; class QObject * QDeclarativeConnections::target(void) const ?target@QDeclarativeDrag@@QBEPAVQDeclarativeItem@@XZ @ 2761 NONAME ABSENT ; class QDeclarativeItem * QDeclarativeDrag::target(void) const @@ -2892,8 +2892,8 @@ EXPORTS ?tr@QDeclarativeGradient@@SA?AVQString@@PBD0H@Z @ 2891 NONAME ; class QString QDeclarativeGradient::tr(char const *, char const *, int) ?tr@QDeclarativeGradientStop@@SA?AVQString@@PBD0@Z @ 2892 NONAME ; class QString QDeclarativeGradientStop::tr(char const *, char const *) ?tr@QDeclarativeGradientStop@@SA?AVQString@@PBD0H@Z @ 2893 NONAME ; class QString QDeclarativeGradientStop::tr(char const *, char const *, int) - ?tr@QDeclarativeGraphicsObjectContainer@@SA?AVQString@@PBD0@Z @ 2894 NONAME ; class QString QDeclarativeGraphicsObjectContainer::tr(char const *, char const *) - ?tr@QDeclarativeGraphicsObjectContainer@@SA?AVQString@@PBD0H@Z @ 2895 NONAME ; class QString QDeclarativeGraphicsObjectContainer::tr(char const *, char const *, int) + ?tr@QDeclarativeGraphicsObjectContainer@@SA?AVQString@@PBD0@Z @ 2894 NONAME ABSENT ; class QString QDeclarativeGraphicsObjectContainer::tr(char const *, char const *) + ?tr@QDeclarativeGraphicsObjectContainer@@SA?AVQString@@PBD0H@Z @ 2895 NONAME ABSENT ; class QString QDeclarativeGraphicsObjectContainer::tr(char const *, char const *, int) ?tr@QDeclarativeGrid@@SA?AVQString@@PBD0@Z @ 2896 NONAME ; class QString QDeclarativeGrid::tr(char const *, char const *) ?tr@QDeclarativeGrid@@SA?AVQString@@PBD0H@Z @ 2897 NONAME ; class QString QDeclarativeGrid::tr(char const *, char const *, int) ?tr@QDeclarativeGridView@@SA?AVQString@@PBD0@Z @ 2898 NONAME ; class QString QDeclarativeGridView::tr(char const *, char const *) @@ -3082,8 +3082,8 @@ EXPORTS ?trUtf8@QDeclarativeGradient@@SA?AVQString@@PBD0H@Z @ 3081 NONAME ; class QString QDeclarativeGradient::trUtf8(char const *, char const *, int) ?trUtf8@QDeclarativeGradientStop@@SA?AVQString@@PBD0@Z @ 3082 NONAME ; class QString QDeclarativeGradientStop::trUtf8(char const *, char const *) ?trUtf8@QDeclarativeGradientStop@@SA?AVQString@@PBD0H@Z @ 3083 NONAME ; class QString QDeclarativeGradientStop::trUtf8(char const *, char const *, int) - ?trUtf8@QDeclarativeGraphicsObjectContainer@@SA?AVQString@@PBD0@Z @ 3084 NONAME ; class QString QDeclarativeGraphicsObjectContainer::trUtf8(char const *, char const *) - ?trUtf8@QDeclarativeGraphicsObjectContainer@@SA?AVQString@@PBD0H@Z @ 3085 NONAME ; class QString QDeclarativeGraphicsObjectContainer::trUtf8(char const *, char const *, int) + ?trUtf8@QDeclarativeGraphicsObjectContainer@@SA?AVQString@@PBD0@Z @ 3084 NONAME ABSENT ; class QString QDeclarativeGraphicsObjectContainer::trUtf8(char const *, char const *) + ?trUtf8@QDeclarativeGraphicsObjectContainer@@SA?AVQString@@PBD0H@Z @ 3085 NONAME ABSENT ; class QString QDeclarativeGraphicsObjectContainer::trUtf8(char const *, char const *, int) ?trUtf8@QDeclarativeGrid@@SA?AVQString@@PBD0@Z @ 3086 NONAME ; class QString QDeclarativeGrid::trUtf8(char const *, char const *) ?trUtf8@QDeclarativeGrid@@SA?AVQString@@PBD0H@Z @ 3087 NONAME ; class QString QDeclarativeGrid::trUtf8(char const *, char const *, int) ?trUtf8@QDeclarativeGridView@@SA?AVQString@@PBD0@Z @ 3088 NONAME ; class QString QDeclarativeGridView::trUtf8(char const *, char const *) @@ -3309,8 +3309,8 @@ EXPORTS ?windowText@QDeclarativeSystemPalette@@QBE?AVQColor@@XZ @ 3308 NONAME ; class QColor QDeclarativeSystemPalette::windowText(void) const ?wrap@QDeclarativeText@@QBE_NXZ @ 3309 NONAME ; bool QDeclarativeText::wrap(void) const ?wrap@QDeclarativeTextEdit@@QBE_NXZ @ 3310 NONAME ; bool QDeclarativeTextEdit::wrap(void) const - ?wrapChanged@QDeclarativeText@@IAEX_N@Z @ 3311 NONAME ; void QDeclarativeText::wrapChanged(bool) - ?wrapChanged@QDeclarativeTextEdit@@IAEX_N@Z @ 3312 NONAME ; void QDeclarativeTextEdit::wrapChanged(bool) + ?wrapChanged@QDeclarativeText@@IAEX_N@Z @ 3311 NONAME ABSENT ; void QDeclarativeText::wrapChanged(bool) + ?wrapChanged@QDeclarativeTextEdit@@IAEX_N@Z @ 3312 NONAME ABSENT ; void QDeclarativeTextEdit::wrapChanged(bool) ?write@QDeclarativeBehavior@@UAEXABVQVariant@@@Z @ 3313 NONAME ; void QDeclarativeBehavior::write(class QVariant const &) ?write@QDeclarativeProperty@@QBE_NABVQVariant@@@Z @ 3314 NONAME ; bool QDeclarativeProperty::write(class QVariant const &) const ?write@QDeclarativeProperty@@SA_NPAVQObject@@ABVQString@@ABVQVariant@@@Z @ 3315 NONAME ; bool QDeclarativeProperty::write(class QObject *, class QString const &, class QVariant const &) @@ -3320,7 +3320,7 @@ EXPORTS ?x@QDeclarativeParentChange@@QBEMXZ @ 3319 NONAME ; float QDeclarativeParentChange::x(void) const ?xAttractor@QDeclarativeParticleMotionGravity@@QBEMXZ @ 3320 NONAME ABSENT ; float QDeclarativeParticleMotionGravity::xAttractor(void) const ?xIsSet@QDeclarativeParentChange@@QBE_NXZ @ 3321 NONAME ; bool QDeclarativeParentChange::xIsSet(void) const - ?xToPos@QDeclarativeTextInput@@QAEHH@Z @ 3322 NONAME ; int QDeclarativeTextInput::xToPos(int) + ?xToPos@QDeclarativeTextInput@@QAEHH@Z @ 3322 NONAME ABSENT ; int QDeclarativeTextInput::xToPos(int) ?xVariance@QDeclarativeParticleMotionWander@@QBEMXZ @ 3323 NONAME ABSENT ; float QDeclarativeParticleMotionWander::xVariance(void) const ?xattractorChanged@QDeclarativeParticleMotionGravity@@IAEXXZ @ 3324 NONAME ABSENT ; void QDeclarativeParticleMotionGravity::xattractorChanged(void) ?xflick@QDeclarativeFlickable@@IBE_NXZ @ 3325 NONAME ; bool QDeclarativeFlickable::xflick(void) const @@ -3351,7 +3351,7 @@ EXPORTS ?staticMetaObject@QDeclarativeItem@@2UQMetaObject@@B @ 3350 NONAME ; struct QMetaObject const QDeclarativeItem::staticMetaObject ?staticMetaObject@QDeclarativeColumn@@2UQMetaObject@@B @ 3351 NONAME ; struct QMetaObject const QDeclarativeColumn::staticMetaObject ?staticMetaObject@QDeclarativeGradient@@2UQMetaObject@@B @ 3352 NONAME ; struct QMetaObject const QDeclarativeGradient::staticMetaObject - ?staticMetaObject@QDeclarativeGraphicsObjectContainer@@2UQMetaObject@@B @ 3353 NONAME ; struct QMetaObject const QDeclarativeGraphicsObjectContainer::staticMetaObject + ?staticMetaObject@QDeclarativeGraphicsObjectContainer@@2UQMetaObject@@B @ 3353 NONAME ABSENT ; struct QMetaObject const QDeclarativeGraphicsObjectContainer::staticMetaObject ?staticMetaObject@QDeclarativeDebugWatch@@2UQMetaObject@@B @ 3354 NONAME ; struct QMetaObject const QDeclarativeDebugWatch::staticMetaObject ?staticMetaObject@QDeclarativeStateGroup@@2UQMetaObject@@B @ 3355 NONAME ; struct QMetaObject const QDeclarativeStateGroup::staticMetaObject ?staticMetaObject@QPacketProtocol@@2UQMetaObject@@B @ 3356 NONAME ; struct QMetaObject const QPacketProtocol::staticMetaObject @@ -3749,7 +3749,7 @@ EXPORTS ?setSize@QDeclarativeItem@@QAEXABVQSizeF@@@Z @ 3748 NONAME ; void QDeclarativeItem::setSize(class QSizeF const &) ?setSnapMode@QDeclarativeGridView@@QAEXW4SnapMode@1@@Z @ 3749 NONAME ; void QDeclarativeGridView::setSnapMode(enum QDeclarativeGridView::SnapMode) ?setSource@QDeclarativeWorkerScript@@QAEXABVQUrl@@@Z @ 3750 NONAME ; void QDeclarativeWorkerScript::setSource(class QUrl const &) - ?setSourceSize@QDeclarativeImageBase@@QAEXABVQSize@@@Z @ 3751 NONAME ; void QDeclarativeImageBase::setSourceSize(class QSize const &) + ?setSourceSize@QDeclarativeImageBase@@QAEXABVQSize@@@Z @ 3751 NONAME ABSENT ; void QDeclarativeImageBase::setSourceSize(class QSize const &) ?setTarget@QDeclarativeDrag@@QAEXPAVQGraphicsObject@@@Z @ 3752 NONAME ; void QDeclarativeDrag::setTarget(class QGraphicsObject *) ?setTop@QDeclarativeAnchors@@QAEXABUQDeclarativeAnchorLine@@@Z @ 3753 NONAME ; void QDeclarativeAnchors::setTop(struct QDeclarativeAnchorLine const &) ?setVelocity@QDeclarativeSmoothedAnimation@@QAEXM@Z @ 3754 NONAME ; void QDeclarativeSmoothedAnimation::setVelocity(float) @@ -3818,4 +3818,79 @@ EXPORTS ?staticMetaObject@QDeclarativeSmoothedAnimation@@2UQMetaObject@@B @ 3817 NONAME ; struct QMetaObject const QDeclarativeSmoothedAnimation::staticMetaObject ?staticMetaObject@QDeclarativeTranslate@@2UQMetaObject@@B @ 3818 NONAME ; struct QMetaObject const QDeclarativeTranslate::staticMetaObject ?consistentTime@QDeclarativeItemPrivate@@2HA @ 3819 NONAME ; int QDeclarativeItemPrivate::consistentTime + ??0QDeclarativeAction@@QAE@PAVQObject@@ABVQString@@PAVQDeclarativeContext@@ABVQVariant@@@Z @ 3820 NONAME ; QDeclarativeAction::QDeclarativeAction(class QObject *, class QString const &, class QDeclarativeContext *, class QVariant const &) + ??0QDeclarativeSmoothedFollow@@QAE@PAVQObject@@@Z @ 3821 NONAME ; QDeclarativeSmoothedFollow::QDeclarativeSmoothedFollow(class QObject *) + ??1QDeclarativeSmoothedFollow@@UAE@XZ @ 3822 NONAME ; QDeclarativeSmoothedFollow::~QDeclarativeSmoothedFollow(void) + ??_EQDeclarativeSmoothedFollow@@UAE@I@Z @ 3823 NONAME ; QDeclarativeSmoothedFollow::~QDeclarativeSmoothedFollow(unsigned int) + ?addPluginPath@QDeclarativeEngine@@QAEXABVQString@@@Z @ 3824 NONAME ; void QDeclarativeEngine::addPluginPath(class QString const &) + ?autoScroll@QDeclarativeTextInput@@QBE_NXZ @ 3825 NONAME ; bool QDeclarativeTextInput::autoScroll(void) const + ?autoScrollChanged@QDeclarativeTextInput@@IAEX_N@Z @ 3826 NONAME ; void QDeclarativeTextInput::autoScrollChanged(bool) + ?createFunction@QDeclarativeType@@QBEP6AXPAX@ZXZ @ 3827 NONAME ; void (*)(void *) QDeclarativeType::createFunction(void) const + ?createSize@QDeclarativeType@@QBEHXZ @ 3828 NONAME ; int QDeclarativeType::createSize(void) const + ?d_func@QDeclarativeSmoothedFollow@@AAEPAVQDeclarativeSmoothedFollowPrivate@@XZ @ 3829 NONAME ; class QDeclarativeSmoothedFollowPrivate * QDeclarativeSmoothedFollow::d_func(void) + ?d_func@QDeclarativeSmoothedFollow@@ABEPBVQDeclarativeSmoothedFollowPrivate@@XZ @ 3830 NONAME ; class QDeclarativeSmoothedFollowPrivate const * QDeclarativeSmoothedFollow::d_func(void) const + ?displayText@QDeclarativeTextInput@@QBE?AVQString@@XZ @ 3831 NONAME ; class QString QDeclarativeTextInput::displayText(void) const + ?displayTextChanged@QDeclarativeTextInput@@IAEXABVQString@@@Z @ 3832 NONAME ; void QDeclarativeTextInput::displayTextChanged(class QString const &) + ?duration@QDeclarativeSmoothedFollow@@QBEHXZ @ 3833 NONAME ; int QDeclarativeSmoothedFollow::duration(void) const + ?durationChanged@QDeclarativeSmoothedFollow@@IAEXXZ @ 3834 NONAME ; void QDeclarativeSmoothedFollow::durationChanged(void) + ?enabled@QDeclarativeSmoothedFollow@@QBE_NXZ @ 3835 NONAME ; bool QDeclarativeSmoothedFollow::enabled(void) const + ?enabledChanged@QDeclarativeSmoothedFollow@@IAEXXZ @ 3836 NONAME ; void QDeclarativeSmoothedFollow::enabledChanged(void) + ?getStaticMetaObject@QDeclarativeSmoothedFollow@@SAABUQMetaObject@@XZ @ 3837 NONAME ; struct QMetaObject const & QDeclarativeSmoothedFollow::getStaticMetaObject(void) + ?highlightMoveDuration@QDeclarativeGridView@@QBEHXZ @ 3838 NONAME ; int QDeclarativeGridView::highlightMoveDuration(void) const + ?highlightMoveDuration@QDeclarativeListView@@QBEHXZ @ 3839 NONAME ; int QDeclarativeListView::highlightMoveDuration(void) const + ?highlightMoveDuration@QDeclarativePathView@@QBEHXZ @ 3840 NONAME ; int QDeclarativePathView::highlightMoveDuration(void) const + ?highlightMoveDurationChanged@QDeclarativeGridView@@IAEXXZ @ 3841 NONAME ; void QDeclarativeGridView::highlightMoveDurationChanged(void) + ?highlightMoveDurationChanged@QDeclarativeListView@@IAEXXZ @ 3842 NONAME ; void QDeclarativeListView::highlightMoveDurationChanged(void) + ?highlightMoveDurationChanged@QDeclarativePathView@@IAEXXZ @ 3843 NONAME ; void QDeclarativePathView::highlightMoveDurationChanged(void) + ?highlightResizeDuration@QDeclarativeListView@@QBEHXZ @ 3844 NONAME ; int QDeclarativeListView::highlightResizeDuration(void) const + ?highlightResizeDurationChanged@QDeclarativeListView@@IAEXXZ @ 3845 NONAME ; void QDeclarativeListView::highlightResizeDurationChanged(void) + ?importPlugin@QDeclarativeEngine@@QAE_NABVQString@@0@Z @ 3846 NONAME ; bool QDeclarativeEngine::importPlugin(class QString const &, class QString const &) + ?isExtendedType@QDeclarativeType@@QBE_NXZ @ 3847 NONAME ; bool QDeclarativeType::isExtendedType(void) const + ?maximumEasingTime@QDeclarativeSmoothedFollow@@QBEHXZ @ 3848 NONAME ; int QDeclarativeSmoothedFollow::maximumEasingTime(void) const + ?maximumEasingTimeChanged@QDeclarativeSmoothedFollow@@IAEXXZ @ 3849 NONAME ; void QDeclarativeSmoothedFollow::maximumEasingTimeChanged(void) + ?metaObject@QDeclarativeSmoothedFollow@@UBEPBUQMetaObject@@XZ @ 3850 NONAME ; struct QMetaObject const * QDeclarativeSmoothedFollow::metaObject(void) const + ?mouseMoveEvent@QDeclarativeTextInput@@MAEXPAVQGraphicsSceneMouseEvent@@@Z @ 3851 NONAME ; void QDeclarativeTextInput::mouseMoveEvent(class QGraphicsSceneMouseEvent *) + ?moveCursorSelection@QDeclarativeTextInput@@QAEXH@Z @ 3852 NONAME ; void QDeclarativeTextInput::moveCursorSelection(int) + ?passwordCharacter@QDeclarativeTextInput@@QBE?AVQString@@XZ @ 3853 NONAME ; class QString QDeclarativeTextInput::passwordCharacter(void) const + ?passwordCharacterChanged@QDeclarativeTextInput@@IAEXXZ @ 3854 NONAME ; void QDeclarativeTextInput::passwordCharacterChanged(void) + ?pluginPathList@QDeclarativeEngine@@QBE?AVQStringList@@XZ @ 3855 NONAME ; class QStringList QDeclarativeEngine::pluginPathList(void) const + ?qt_metacall@QDeclarativeSmoothedFollow@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 3856 NONAME ; int QDeclarativeSmoothedFollow::qt_metacall(enum QMetaObject::Call, int, void * *) + ?qt_metacast@QDeclarativeSmoothedFollow@@UAEPAXPBD@Z @ 3857 NONAME ; void * QDeclarativeSmoothedFollow::qt_metacast(char const *) + ?resetTarget@QDeclarativeDrag@@QAEXXZ @ 3858 NONAME ; void QDeclarativeDrag::resetTarget(void) + ?reversingMode@QDeclarativeSmoothedFollow@@QBE?AW4ReversingMode@1@XZ @ 3859 NONAME ; enum QDeclarativeSmoothedFollow::ReversingMode QDeclarativeSmoothedFollow::reversingMode(void) const + ?reversingModeChanged@QDeclarativeSmoothedFollow@@IAEXXZ @ 3860 NONAME ; void QDeclarativeSmoothedFollow::reversingModeChanged(void) + ?setAutoScroll@QDeclarativeTextInput@@QAEX_N@Z @ 3861 NONAME ; void QDeclarativeTextInput::setAutoScroll(bool) + ?setDuration@QDeclarativeSmoothedFollow@@QAEXH@Z @ 3862 NONAME ; void QDeclarativeSmoothedFollow::setDuration(int) + ?setEnabled@QDeclarativeSmoothedFollow@@QAEX_N@Z @ 3863 NONAME ; void QDeclarativeSmoothedFollow::setEnabled(bool) + ?setHighlightMoveDuration@QDeclarativeGridView@@QAEXH@Z @ 3864 NONAME ; void QDeclarativeGridView::setHighlightMoveDuration(int) + ?setHighlightMoveDuration@QDeclarativeListView@@QAEXH@Z @ 3865 NONAME ; void QDeclarativeListView::setHighlightMoveDuration(int) + ?setHighlightMoveDuration@QDeclarativePathView@@QAEXH@Z @ 3866 NONAME ; void QDeclarativePathView::setHighlightMoveDuration(int) + ?setHighlightResizeDuration@QDeclarativeListView@@QAEXH@Z @ 3867 NONAME ; void QDeclarativeListView::setHighlightResizeDuration(int) + ?setMaximumEasingTime@QDeclarativeSmoothedFollow@@QAEXH@Z @ 3868 NONAME ; void QDeclarativeSmoothedFollow::setMaximumEasingTime(int) + ?setPasswordCharacter@QDeclarativeTextInput@@QAEXABVQString@@@Z @ 3869 NONAME ; void QDeclarativeTextInput::setPasswordCharacter(class QString const &) + ?setPluginPathList@QDeclarativeEngine@@QAEXABVQStringList@@@Z @ 3870 NONAME ; void QDeclarativeEngine::setPluginPathList(class QStringList const &) + ?setReversingMode@QDeclarativeSmoothedFollow@@QAEXW4ReversingMode@1@@Z @ 3871 NONAME ; void QDeclarativeSmoothedFollow::setReversingMode(enum QDeclarativeSmoothedFollow::ReversingMode) + ?setSourceSize@QDeclarativeImageBase@@UAEXABVQSize@@@Z @ 3872 NONAME ; void QDeclarativeImageBase::setSourceSize(class QSize const &) + ?setTarget@QDeclarativeSmoothedFollow@@UAEXABVQDeclarativeProperty@@@Z @ 3873 NONAME ; void QDeclarativeSmoothedFollow::setTarget(class QDeclarativeProperty const &) + ?setTo@QDeclarativeSmoothedFollow@@QAEXM@Z @ 3874 NONAME ; void QDeclarativeSmoothedFollow::setTo(float) + ?setTo@QDeclarativeSpringFollow@@QAEXM@Z @ 3875 NONAME ; void QDeclarativeSpringFollow::setTo(float) + ?setVelocity@QDeclarativeSmoothedFollow@@QAEXM@Z @ 3876 NONAME ; void QDeclarativeSmoothedFollow::setVelocity(float) + ?setWrapMode@QDeclarativeText@@QAEXW4WrapMode@1@@Z @ 3877 NONAME ; void QDeclarativeText::setWrapMode(enum QDeclarativeText::WrapMode) + ?setWrapMode@QDeclarativeTextEdit@@QAEXW4WrapMode@1@@Z @ 3878 NONAME ; void QDeclarativeTextEdit::setWrapMode(enum QDeclarativeTextEdit::WrapMode) + ?sourceSizeChanged@QDeclarativeAnimatedImage@@IAEXXZ @ 3879 NONAME ; void QDeclarativeAnimatedImage::sourceSizeChanged(void) + ?to@QDeclarativeSmoothedFollow@@QBEMXZ @ 3880 NONAME ; float QDeclarativeSmoothedFollow::to(void) const + ?to@QDeclarativeSpringFollow@@QBEMXZ @ 3881 NONAME ; float QDeclarativeSpringFollow::to(void) const + ?tr@QDeclarativeCompiler@@AAE?AVQString@@PBD@Z @ 3882 NONAME ; class QString QDeclarativeCompiler::tr(char const *) + ?tr@QDeclarativeSmoothedFollow@@SA?AVQString@@PBD0@Z @ 3883 NONAME ; class QString QDeclarativeSmoothedFollow::tr(char const *, char const *) + ?tr@QDeclarativeSmoothedFollow@@SA?AVQString@@PBD0H@Z @ 3884 NONAME ; class QString QDeclarativeSmoothedFollow::tr(char const *, char const *, int) + ?trUtf8@QDeclarativeSmoothedFollow@@SA?AVQString@@PBD0@Z @ 3885 NONAME ; class QString QDeclarativeSmoothedFollow::trUtf8(char const *, char const *) + ?trUtf8@QDeclarativeSmoothedFollow@@SA?AVQString@@PBD0H@Z @ 3886 NONAME ; class QString QDeclarativeSmoothedFollow::trUtf8(char const *, char const *, int) + ?velocity@QDeclarativeSmoothedFollow@@QBEMXZ @ 3887 NONAME ; float QDeclarativeSmoothedFollow::velocity(void) const + ?velocityChanged@QDeclarativeSmoothedFollow@@IAEXXZ @ 3888 NONAME ; void QDeclarativeSmoothedFollow::velocityChanged(void) + ?wrapMode@QDeclarativeText@@QBE?AW4WrapMode@1@XZ @ 3889 NONAME ; enum QDeclarativeText::WrapMode QDeclarativeText::wrapMode(void) const + ?wrapMode@QDeclarativeTextEdit@@QBE?AW4WrapMode@1@XZ @ 3890 NONAME ; enum QDeclarativeTextEdit::WrapMode QDeclarativeTextEdit::wrapMode(void) const + ?wrapModeChanged@QDeclarativeText@@IAEXXZ @ 3891 NONAME ; void QDeclarativeText::wrapModeChanged(void) + ?wrapModeChanged@QDeclarativeTextEdit@@IAEXXZ @ 3892 NONAME ; void QDeclarativeTextEdit::wrapModeChanged(void) + ?xToPosition@QDeclarativeTextInput@@QAEHH@Z @ 3893 NONAME ; int QDeclarativeTextInput::xToPosition(int) + ?staticMetaObject@QDeclarativeSmoothedFollow@@2UQMetaObject@@B @ 3894 NONAME ; struct QMetaObject const QDeclarativeSmoothedFollow::staticMetaObject diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 1c33477..c34690e 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -12724,7 +12724,7 @@ EXPORTS ?visibilityChanged@QToolBar@@IAEX_N@Z @ 12723 NONAME ; void QToolBar::visibilityChanged(bool) ??0FileInfo@QZipReader@@QAE@ABU01@@Z @ 12724 NONAME ; QZipReader::FileInfo::FileInfo(struct QZipReader::FileInfo const &) ??0QStaticText@@QAE@ABVQString@@@Z @ 12725 NONAME ; QStaticText::QStaticText(class QString const &) - ?append@QGraphicsItemPrivate@@SAXPAV?$QDeclarativeListProperty@VQGraphicsObject@@@@PAVQGraphicsObject@@@Z @ 12726 NONAME ; void QGraphicsItemPrivate::append(class QDeclarativeListProperty *, class QGraphicsObject *) + ?append@QGraphicsItemPrivate@@SAXPAV?$QDeclarativeListProperty@VQGraphicsObject@@@@PAVQGraphicsObject@@@Z @ 12726 NONAME ABSENT ; void QGraphicsItemPrivate::append(class QDeclarativeListProperty *, class QGraphicsObject *) ?bitPlaneCount@QImage@@QBEHXZ @ 12727 NONAME ; int QImage::bitPlaneCount(void) const ?childrenChanged@QGraphicsObject@@IAEXXZ @ 12728 NONAME ; void QGraphicsObject::childrenChanged(void) ?childrenList@QGraphicsItemPrivate@@QAE?AV?$QDeclarativeListProperty@VQGraphicsObject@@@@XZ @ 12729 NONAME ; class QDeclarativeListProperty QGraphicsItemPrivate::childrenList(void) @@ -12767,4 +12767,7 @@ EXPORTS ?updateMicroFocus@QGraphicsObject@@IAEXXZ @ 12766 NONAME ; void QGraphicsObject::updateMicroFocus(void) ?width@QGraphicsItemPrivate@@UBEMXZ @ 12767 NONAME ; float QGraphicsItemPrivate::width(void) const ?widthChanged@QGraphicsObject@@IAEXXZ @ 12768 NONAME ; void QGraphicsObject::widthChanged(void) + ?children_append@QGraphicsItemPrivate@@SAXPAV?$QDeclarativeListProperty@VQGraphicsObject@@@@PAVQGraphicsObject@@@Z @ 12769 NONAME ; void QGraphicsItemPrivate::children_append(class QDeclarativeListProperty *, class QGraphicsObject *) + ?children_at@QGraphicsItemPrivate@@SAPAVQGraphicsObject@@PAV?$QDeclarativeListProperty@VQGraphicsObject@@@@H@Z @ 12770 NONAME ; class QGraphicsObject * QGraphicsItemPrivate::children_at(class QDeclarativeListProperty *, int) + ?children_count@QGraphicsItemPrivate@@SAHPAV?$QDeclarativeListProperty@VQGraphicsObject@@@@@Z @ 12771 NONAME ; int QGraphicsItemPrivate::children_count(class QDeclarativeListProperty *) diff --git a/src/s60installs/bwins/QtMultimediau.def b/src/s60installs/bwins/QtMultimediau.def index 6c98fdf..ad33993 100644 --- a/src/s60installs/bwins/QtMultimediau.def +++ b/src/s60installs/bwins/QtMultimediau.def @@ -946,4 +946,6 @@ EXPORTS ?volume@QSoundEffect@@QBEHXZ @ 945 NONAME ; int QSoundEffect::volume(void) const ?volumeChanged@QSoundEffect@@IAEXXZ @ 946 NONAME ; void QSoundEffect::volumeChanged(void) ?staticMetaObject@QSoundEffect@@2UQMetaObject@@B @ 947 NONAME ; struct QMetaObject const QSoundEffect::staticMetaObject + ?event@QGraphicsVideoItem@@MAE_NPAVQEvent@@@Z @ 948 NONAME ; bool QGraphicsVideoItem::event(class QEvent *) + ?sceneEvent@QGraphicsVideoItem@@MAE_NPAVQEvent@@@Z @ 949 NONAME ; bool QGraphicsVideoItem::sceneEvent(class QEvent *) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index 79fd0ce..e54e03f 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -803,9 +803,9 @@ EXPORTS _ZN16QCoreApplicationD0Ev @ 802 NONAME _ZN16QCoreApplicationD1Ev @ 803 NONAME _ZN16QCoreApplicationD2Ev @ 804 NONAME - _ZN16QDeclarativeDataD0Ev @ 805 NONAME - _ZN16QDeclarativeDataD1Ev @ 806 NONAME - _ZN16QDeclarativeDataD2Ev @ 807 NONAME + _ZN16QDeclarativeDataD0Ev @ 805 NONAME ABSENT + _ZN16QDeclarativeDataD1Ev @ 806 NONAME ABSENT + _ZN16QDeclarativeDataD2Ev @ 807 NONAME ABSENT _ZN16QEventTransition11qt_metacallEN11QMetaObject4CallEiPPv @ 808 NONAME _ZN16QEventTransition11qt_metacastEPKc @ 809 NONAME _ZN16QEventTransition12onTransitionEP6QEvent @ 810 NONAME @@ -3332,7 +3332,7 @@ EXPORTS _ZTI15QPauseAnimation @ 3331 NONAME _ZTI15QSocketNotifier @ 3332 NONAME _ZTI16QCoreApplication @ 3333 NONAME - _ZTI16QDeclarativeData @ 3334 NONAME + _ZTI16QDeclarativeData @ 3334 NONAME ABSENT _ZTI16QEventTransition @ 3335 NONAME _ZTI16QIODevicePrivate @ 3336 NONAME _ZTI16QTextCodecPlugin @ 3337 NONAME @@ -3407,7 +3407,7 @@ EXPORTS _ZTV15QPauseAnimation @ 3406 NONAME _ZTV15QSocketNotifier @ 3407 NONAME _ZTV16QCoreApplication @ 3408 NONAME - _ZTV16QDeclarativeData @ 3409 NONAME + _ZTV16QDeclarativeData @ 3409 NONAME ABSENT _ZTV16QEventTransition @ 3410 NONAME _ZTV16QIODevicePrivate @ 3411 NONAME _ZTV16QTextCodecPlugin @ 3412 NONAME @@ -3692,4 +3692,7 @@ EXPORTS _ZN9QDateTime18setMSecsSinceEpochEx @ 3691 NONAME _ZN9QDateTime19fromMSecsSinceEpochEx @ 3692 NONAME _ZNK9QDateTime17toMSecsSinceEpochEv @ 3693 NONAME + _ZN10QTextCodec11validCodecsEv @ 3694 NONAME + _ZN16QDeclarativeData13parentChangedE @ 3695 NONAME DATA 4 + _ZN16QDeclarativeData9destroyedE @ 3696 NONAME DATA 4 diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index 17a57d0..0f0e886 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -179,7 +179,7 @@ EXPORTS _ZN16QDeclarativeText11qt_metacallEN11QMetaObject4CallEiPPv @ 178 NONAME _ZN16QDeclarativeText11qt_metacastEPKc @ 179 NONAME _ZN16QDeclarativeText11textChangedERK7QString @ 180 NONAME - _ZN16QDeclarativeText11wrapChangedEb @ 181 NONAME + _ZN16QDeclarativeText11wrapChangedEb @ 181 NONAME ABSENT _ZN16QDeclarativeText12colorChangedERK6QColor @ 182 NONAME _ZN16QDeclarativeText12setElideModeENS_13TextElideModeE @ 183 NONAME _ZN16QDeclarativeText12styleChangedENS_9TextStyleE @ 184 NONAME @@ -337,7 +337,7 @@ EXPORTS _ZN18QDeclarativeEngine11qt_metacastEPKc @ 336 NONAME _ZN18QDeclarativeEngine11rootContextEv @ 337 NONAME _ZN18QDeclarativeEngine13addImportPathERK7QString @ 338 NONAME - _ZN18QDeclarativeEngine15importExtensionERK7QStringS2_ @ 339 NONAME + _ZN18QDeclarativeEngine15importExtensionERK7QStringS2_ @ 339 NONAME ABSENT _ZN18QDeclarativeEngine15objectOwnershipEP7QObject @ 340 NONAME _ZN18QDeclarativeEngine16addImageProviderERK7QStringP25QDeclarativeImageProvider @ 341 NONAME _ZN18QDeclarativeEngine16contextForObjectEPK7QObject @ 342 NONAME @@ -897,7 +897,7 @@ EXPORTS _ZN20QDeclarativeTextEdit11qt_metacastEPKc @ 896 NONAME _ZN20QDeclarativeTextEdit11setReadOnlyEb @ 897 NONAME _ZN20QDeclarativeTextEdit11textChangedERK7QString @ 898 NONAME - _ZN20QDeclarativeTextEdit11wrapChangedEb @ 899 NONAME + _ZN20QDeclarativeTextEdit11wrapChangedEb @ 899 NONAME ABSENT _ZN20QDeclarativeTextEdit12colorChangedERK6QColor @ 900 NONAME _ZN20QDeclarativeTextEdit12drawContentsEP8QPainterRK5QRect @ 901 NONAME _ZN20QDeclarativeTextEdit13keyPressEventEP9QKeyEvent @ 902 NONAME @@ -1234,7 +1234,7 @@ EXPORTS _ZN21QDeclarativeTextInput24selectedTextColorChangedERK6QColor @ 1233 NONAME _ZN21QDeclarativeTextInput26horizontalAlignmentChangedENS_10HAlignmentE @ 1234 NONAME _ZN21QDeclarativeTextInput5eventEP6QEvent @ 1235 NONAME - _ZN21QDeclarativeTextInput6xToPosEi @ 1236 NONAME + _ZN21QDeclarativeTextInput6xToPosEi @ 1236 NONAME ABSENT _ZN21QDeclarativeTextInput7setFontERK5QFont @ 1237 NONAME _ZN21QDeclarativeTextInput7setTextERK7QString @ 1238 NONAME _ZN21QDeclarativeTextInput8acceptedEv @ 1239 NONAME @@ -1652,7 +1652,7 @@ EXPORTS _ZN24QDeclarativeSpringFollow11syncChangedEv @ 1651 NONAME _ZN24QDeclarativeSpringFollow12valueChangedEf @ 1652 NONAME _ZN24QDeclarativeSpringFollow14modulusChangedEv @ 1653 NONAME - _ZN24QDeclarativeSpringFollow14setSourceValueEf @ 1654 NONAME + _ZN24QDeclarativeSpringFollow14setSourceValueEf @ 1654 NONAME ABSENT _ZN24QDeclarativeSpringFollow16staticMetaObjectE @ 1655 NONAME DATA 16 _ZN24QDeclarativeSpringFollow19getStaticMetaObjectEv @ 1656 NONAME _ZN24QDeclarativeSpringFollow7setMassEf @ 1657 NONAME @@ -2130,19 +2130,19 @@ EXPORTS _ZN34QDeclarativeDebugPropertyReferenceC2ERKS_ @ 2129 NONAME _ZN34QDeclarativeDebugPropertyReferenceC2Ev @ 2130 NONAME _ZN34QDeclarativeDebugPropertyReferenceaSERKS_ @ 2131 NONAME - _ZN35QDeclarativeGraphicsObjectContainer10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 2132 NONAME - _ZN35QDeclarativeGraphicsObjectContainer11eventFilterEP7QObjectP6QEvent @ 2133 NONAME - _ZN35QDeclarativeGraphicsObjectContainer11qt_metacallEN11QMetaObject4CallEiPPv @ 2134 NONAME - _ZN35QDeclarativeGraphicsObjectContainer11qt_metacastEPKc @ 2135 NONAME - _ZN35QDeclarativeGraphicsObjectContainer16staticMetaObjectE @ 2136 NONAME DATA 16 - _ZN35QDeclarativeGraphicsObjectContainer17setGraphicsObjectEP15QGraphicsObject @ 2137 NONAME - _ZN35QDeclarativeGraphicsObjectContainer19getStaticMetaObjectEv @ 2138 NONAME - _ZN35QDeclarativeGraphicsObjectContainer23setSynchronizedResizingEb @ 2139 NONAME - _ZN35QDeclarativeGraphicsObjectContainerC1EP16QDeclarativeItem @ 2140 NONAME - _ZN35QDeclarativeGraphicsObjectContainerC2EP16QDeclarativeItem @ 2141 NONAME - _ZN35QDeclarativeGraphicsObjectContainerD0Ev @ 2142 NONAME - _ZN35QDeclarativeGraphicsObjectContainerD1Ev @ 2143 NONAME - _ZN35QDeclarativeGraphicsObjectContainerD2Ev @ 2144 NONAME + _ZN35QDeclarativeGraphicsObjectContainer10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 2132 NONAME ABSENT + _ZN35QDeclarativeGraphicsObjectContainer11eventFilterEP7QObjectP6QEvent @ 2133 NONAME ABSENT + _ZN35QDeclarativeGraphicsObjectContainer11qt_metacallEN11QMetaObject4CallEiPPv @ 2134 NONAME ABSENT + _ZN35QDeclarativeGraphicsObjectContainer11qt_metacastEPKc @ 2135 NONAME ABSENT + _ZN35QDeclarativeGraphicsObjectContainer16staticMetaObjectE @ 2136 NONAME DATA 16 ABSENT + _ZN35QDeclarativeGraphicsObjectContainer17setGraphicsObjectEP15QGraphicsObject @ 2137 NONAME ABSENT + _ZN35QDeclarativeGraphicsObjectContainer19getStaticMetaObjectEv @ 2138 NONAME ABSENT + _ZN35QDeclarativeGraphicsObjectContainer23setSynchronizedResizingEb @ 2139 NONAME ABSENT + _ZN35QDeclarativeGraphicsObjectContainerC1EP16QDeclarativeItem @ 2140 NONAME ABSENT + _ZN35QDeclarativeGraphicsObjectContainerC2EP16QDeclarativeItem @ 2141 NONAME ABSENT + _ZN35QDeclarativeGraphicsObjectContainerD0Ev @ 2142 NONAME ABSENT + _ZN35QDeclarativeGraphicsObjectContainerD1Ev @ 2143 NONAME ABSENT + _ZN35QDeclarativeGraphicsObjectContainerD2Ev @ 2144 NONAME ABSENT _ZN36QDeclarativeDomValueValueInterceptorC1ERKS_ @ 2145 NONAME _ZN36QDeclarativeDomValueValueInterceptorC1Ev @ 2146 NONAME _ZN36QDeclarativeDomValueValueInterceptorC2ERKS_ @ 2147 NONAME @@ -2765,7 +2765,7 @@ EXPORTS _ZNK24QDeclarativeScriptString6scriptEv @ 2764 NONAME _ZNK24QDeclarativeScriptString7contextEv @ 2765 NONAME _ZNK24QDeclarativeSpringFollow10metaObjectEv @ 2766 NONAME - _ZNK24QDeclarativeSpringFollow11sourceValueEv @ 2767 NONAME + _ZNK24QDeclarativeSpringFollow11sourceValueEv @ 2767 NONAME ABSENT _ZNK24QDeclarativeSpringFollow4massEv @ 2768 NONAME _ZNK24QDeclarativeSpringFollow5valueEv @ 2769 NONAME _ZNK24QDeclarativeSpringFollow6inSyncEv @ 2770 NONAME @@ -2933,9 +2933,9 @@ EXPORTS _ZNK34QDeclarativeDebugPropertyReference4nameEv @ 2932 NONAME _ZNK34QDeclarativeDebugPropertyReference5valueEv @ 2933 NONAME _ZNK34QDeclarativeDebugPropertyReference7bindingEv @ 2934 NONAME - _ZNK35QDeclarativeGraphicsObjectContainer10metaObjectEv @ 2935 NONAME - _ZNK35QDeclarativeGraphicsObjectContainer14graphicsObjectEv @ 2936 NONAME - _ZNK35QDeclarativeGraphicsObjectContainer20synchronizedResizingEv @ 2937 NONAME + _ZNK35QDeclarativeGraphicsObjectContainer10metaObjectEv @ 2935 NONAME ABSENT + _ZNK35QDeclarativeGraphicsObjectContainer14graphicsObjectEv @ 2936 NONAME ABSENT + _ZNK35QDeclarativeGraphicsObjectContainer20synchronizedResizingEv @ 2937 NONAME ABSENT _ZNK36QDeclarativeDomValueValueInterceptor6objectEv @ 2938 NONAME _ZNK38QDeclarativeDebugObjectExpressionWatch10expressionEv @ 2939 NONAME _ZNK38QDeclarativeDebugObjectExpressionWatch10metaObjectEv @ 2940 NONAME @@ -3039,7 +3039,7 @@ EXPORTS _ZTI31QDeclarativePropertyValueSource @ 3038 NONAME _ZTI32QDeclarativeDebugExpressionQuery @ 3039 NONAME _ZTI33QDeclarativeDebugRootContextQuery @ 3040 NONAME - _ZTI35QDeclarativeGraphicsObjectContainer @ 3041 NONAME + _ZTI35QDeclarativeGraphicsObjectContainer @ 3041 NONAME ABSENT _ZTI36QDeclarativePropertyValueInterceptor @ 3042 NONAME _ZTI38QDeclarativeDebugObjectExpressionWatch @ 3043 NONAME _ZTI39QDeclarativeNetworkAccessManagerFactory @ 3044 NONAME @@ -3142,7 +3142,7 @@ EXPORTS _ZTV31QDeclarativePropertyValueSource @ 3141 NONAME _ZTV32QDeclarativeDebugExpressionQuery @ 3142 NONAME _ZTV33QDeclarativeDebugRootContextQuery @ 3143 NONAME - _ZTV35QDeclarativeGraphicsObjectContainer @ 3144 NONAME + _ZTV35QDeclarativeGraphicsObjectContainer @ 3144 NONAME ABSENT _ZTV36QDeclarativePropertyValueInterceptor @ 3145 NONAME _ZTV38QDeclarativeDebugObjectExpressionWatch @ 3146 NONAME _ZTV39QDeclarativeNetworkAccessManagerFactory @ 3147 NONAME @@ -3198,8 +3198,8 @@ EXPORTS _ZThn16_N26QDeclarativeBasePositioner17componentCompleteEv @ 3197 NONAME _ZThn16_N26QDeclarativeBasePositionerD0Ev @ 3198 NONAME _ZThn16_N26QDeclarativeBasePositionerD1Ev @ 3199 NONAME - _ZThn16_N35QDeclarativeGraphicsObjectContainerD0Ev @ 3200 NONAME - _ZThn16_N35QDeclarativeGraphicsObjectContainerD1Ev @ 3201 NONAME + _ZThn16_N35QDeclarativeGraphicsObjectContainerD0Ev @ 3200 NONAME ABSENT + _ZThn16_N35QDeclarativeGraphicsObjectContainerD1Ev @ 3201 NONAME ABSENT _ZThn8_N16QDeclarativeBind17componentCompleteEv @ 3202 NONAME _ZThn8_N16QDeclarativeBindD0Ev @ 3203 NONAME _ZThn8_N16QDeclarativeBindD1Ev @ 3204 NONAME @@ -3351,9 +3351,9 @@ EXPORTS _ZThn8_N29QDeclarativeStateChangeScript7executeEv @ 3350 NONAME _ZThn8_N29QDeclarativeStateChangeScriptD0Ev @ 3351 NONAME _ZThn8_N29QDeclarativeStateChangeScriptD1Ev @ 3352 NONAME - _ZThn8_N35QDeclarativeGraphicsObjectContainer10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 3353 NONAME - _ZThn8_N35QDeclarativeGraphicsObjectContainerD0Ev @ 3354 NONAME - _ZThn8_N35QDeclarativeGraphicsObjectContainerD1Ev @ 3355 NONAME + _ZThn8_N35QDeclarativeGraphicsObjectContainer10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 3353 NONAME ABSENT + _ZThn8_N35QDeclarativeGraphicsObjectContainerD0Ev @ 3354 NONAME ABSENT + _ZThn8_N35QDeclarativeGraphicsObjectContainerD1Ev @ 3355 NONAME ABSENT _ZThn8_NK16QDeclarativeItem12boundingRectEv @ 3356 NONAME _ZThn8_NK16QDeclarativeItem16inputMethodQueryEN2Qt16InputMethodQueryE @ 3357 NONAME _ZThn8_NK19QDeclarativeBinding10expressionEv @ 3358 NONAME @@ -3394,4 +3394,81 @@ EXPORTS _ZNK18QDeclarativeParser7Variant8asScriptEv @ 3393 NONAME _ZNK18QDeclarativeParser7Variant8asStringEv @ 3394 NONAME _ZNK18QDeclarativeParser7Variant9asBooleanEv @ 3395 NONAME + _ZN16QDeclarativeDrag11resetTargetEv @ 3396 NONAME + _ZN16QDeclarativeText11setWrapModeENS_8WrapModeE @ 3397 NONAME + _ZN16QDeclarativeText15wrapModeChangedEv @ 3398 NONAME + _ZN18QDeclarativeActionC1EP7QObjectRK7QStringP19QDeclarativeContextRK8QVariant @ 3399 NONAME + _ZN18QDeclarativeActionC2EP7QObjectRK7QStringP19QDeclarativeContextRK8QVariant @ 3400 NONAME + _ZN18QDeclarativeEngine12importPluginERK7QStringS2_ @ 3401 NONAME + _ZN18QDeclarativeEngine13addPluginPathERK7QString @ 3402 NONAME + _ZN18QDeclarativeEngine17setPluginPathListERK11QStringList @ 3403 NONAME + _ZN20QDeclarativeCompiler2trEPKc @ 3404 NONAME + _ZN20QDeclarativeGridView24setHighlightMoveDurationEi @ 3405 NONAME + _ZN20QDeclarativeGridView28highlightMoveDurationChangedEv @ 3406 NONAME + _ZN20QDeclarativeListView24setHighlightMoveDurationEi @ 3407 NONAME + _ZN20QDeclarativeListView26setHighlightResizeDurationEi @ 3408 NONAME + _ZN20QDeclarativeListView28highlightMoveDurationChangedEv @ 3409 NONAME + _ZN20QDeclarativeListView30highlightResizeDurationChangedEv @ 3410 NONAME + _ZN20QDeclarativePathView24setHighlightMoveDurationEi @ 3411 NONAME + _ZN20QDeclarativePathView28highlightMoveDurationChangedEv @ 3412 NONAME + _ZN20QDeclarativeTextEdit11setWrapModeENS_8WrapModeE @ 3413 NONAME + _ZN20QDeclarativeTextEdit15wrapModeChangedEv @ 3414 NONAME + _ZN21QDeclarativeTextInput11xToPositionEi @ 3415 NONAME + _ZN21QDeclarativeTextInput13setAutoScrollEb @ 3416 NONAME + _ZN21QDeclarativeTextInput14mouseMoveEventEP24QGraphicsSceneMouseEvent @ 3417 NONAME + _ZN21QDeclarativeTextInput17autoScrollChangedEb @ 3418 NONAME + _ZN21QDeclarativeTextInput18displayTextChangedERK7QString @ 3419 NONAME + _ZN21QDeclarativeTextInput19moveCursorSelectionEi @ 3420 NONAME + _ZN21QDeclarativeTextInput20setPasswordCharacterERK7QString @ 3421 NONAME + _ZN21QDeclarativeTextInput24passwordCharacterChangedEv @ 3422 NONAME + _ZN24QDeclarativeSpringFollow5setToEf @ 3423 NONAME + _ZN25QDeclarativeAnimatedImage17sourceSizeChangedEv @ 3424 NONAME + _ZN26QDeclarativeSmoothedFollow10setEnabledEb @ 3425 NONAME + _ZN26QDeclarativeSmoothedFollow11qt_metacallEN11QMetaObject4CallEiPPv @ 3426 NONAME + _ZN26QDeclarativeSmoothedFollow11qt_metacastEPKc @ 3427 NONAME + _ZN26QDeclarativeSmoothedFollow11setDurationEi @ 3428 NONAME + _ZN26QDeclarativeSmoothedFollow11setVelocityEf @ 3429 NONAME + _ZN26QDeclarativeSmoothedFollow14enabledChangedEv @ 3430 NONAME + _ZN26QDeclarativeSmoothedFollow15durationChangedEv @ 3431 NONAME + _ZN26QDeclarativeSmoothedFollow15velocityChangedEv @ 3432 NONAME + _ZN26QDeclarativeSmoothedFollow16setReversingModeENS_13ReversingModeE @ 3433 NONAME + _ZN26QDeclarativeSmoothedFollow16staticMetaObjectE @ 3434 NONAME DATA 16 + _ZN26QDeclarativeSmoothedFollow19getStaticMetaObjectEv @ 3435 NONAME + _ZN26QDeclarativeSmoothedFollow20reversingModeChangedEv @ 3436 NONAME + _ZN26QDeclarativeSmoothedFollow20setMaximumEasingTimeEi @ 3437 NONAME + _ZN26QDeclarativeSmoothedFollow24maximumEasingTimeChangedEv @ 3438 NONAME + _ZN26QDeclarativeSmoothedFollow5setToEf @ 3439 NONAME + _ZN26QDeclarativeSmoothedFollow9setTargetERK20QDeclarativeProperty @ 3440 NONAME + _ZN26QDeclarativeSmoothedFollowC1EP7QObject @ 3441 NONAME + _ZN26QDeclarativeSmoothedFollowC2EP7QObject @ 3442 NONAME + _ZN26QDeclarativeSmoothedFollowD0Ev @ 3443 NONAME + _ZN26QDeclarativeSmoothedFollowD1Ev @ 3444 NONAME + _ZN26QDeclarativeSmoothedFollowD2Ev @ 3445 NONAME + _ZNK16QDeclarativeText8wrapModeEv @ 3446 NONAME + _ZNK16QDeclarativeType10createSizeEv @ 3447 NONAME + _ZNK16QDeclarativeType14createFunctionEv @ 3448 NONAME + _ZNK16QDeclarativeType14isExtendedTypeEv @ 3449 NONAME + _ZNK18QDeclarativeEngine14pluginPathListEv @ 3450 NONAME + _ZNK20QDeclarativeGridView21highlightMoveDurationEv @ 3451 NONAME + _ZNK20QDeclarativeListView21highlightMoveDurationEv @ 3452 NONAME + _ZNK20QDeclarativeListView23highlightResizeDurationEv @ 3453 NONAME + _ZNK20QDeclarativePathView21highlightMoveDurationEv @ 3454 NONAME + _ZNK20QDeclarativeTextEdit8wrapModeEv @ 3455 NONAME + _ZNK21QDeclarativeTextInput10autoScrollEv @ 3456 NONAME + _ZNK21QDeclarativeTextInput11displayTextEv @ 3457 NONAME + _ZNK21QDeclarativeTextInput17passwordCharacterEv @ 3458 NONAME + _ZNK24QDeclarativeSpringFollow2toEv @ 3459 NONAME + _ZNK26QDeclarativeSmoothedFollow10metaObjectEv @ 3460 NONAME + _ZNK26QDeclarativeSmoothedFollow13reversingModeEv @ 3461 NONAME + _ZNK26QDeclarativeSmoothedFollow17maximumEasingTimeEv @ 3462 NONAME + _ZNK26QDeclarativeSmoothedFollow2toEv @ 3463 NONAME + _ZNK26QDeclarativeSmoothedFollow7enabledEv @ 3464 NONAME + _ZNK26QDeclarativeSmoothedFollow8durationEv @ 3465 NONAME + _ZNK26QDeclarativeSmoothedFollow8velocityEv @ 3466 NONAME + _ZTI26QDeclarativeSmoothedFollow @ 3467 NONAME + _ZTV26QDeclarativeSmoothedFollow @ 3468 NONAME + _ZThn8_N21QDeclarativeTextInput14mouseMoveEventEP24QGraphicsSceneMouseEvent @ 3469 NONAME + _ZThn8_N26QDeclarativeSmoothedFollow9setTargetERK20QDeclarativeProperty @ 3470 NONAME + _ZThn8_N26QDeclarativeSmoothedFollowD0Ev @ 3471 NONAME + _ZThn8_N26QDeclarativeSmoothedFollowD1Ev @ 3472 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 59e63ea..353603e 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -11943,7 +11943,7 @@ EXPORTS _ZN20QGraphicsItemPrivate14setFocusHelperEN2Qt11FocusReasonEbb @ 11942 NONAME _ZN20QGraphicsItemPrivate16clearFocusHelperEb @ 11943 NONAME _ZN20QGraphicsItemPrivate24prependGraphicsTransformEP18QGraphicsTransform @ 11944 NONAME - _ZN20QGraphicsItemPrivate6appendEP24QDeclarativeListPropertyI15QGraphicsObjectEPS1_ @ 11945 NONAME + _ZN20QGraphicsItemPrivate6appendEP24QDeclarativeListPropertyI15QGraphicsObjectEPS1_ @ 11945 NONAME ABSENT _ZN20QGraphicsItemPrivate8setWidthEf @ 11946 NONAME _ZN20QGraphicsItemPrivate9setHeightEf @ 11947 NONAME _ZN7QWizard11pageRemovedEi @ 11948 NONAME @@ -11970,4 +11970,7 @@ EXPORTS _ZNK12QPaintBuffer15frameStartIndexEi @ 11969 NONAME _ZNK12QPaintBuffer15processCommandsEP8QPainterii @ 11970 NONAME _ZNK12QPaintBuffer18commandDescriptionEi @ 11971 NONAME + _ZN20QGraphicsItemPrivate11children_atEP24QDeclarativeListPropertyI15QGraphicsObjectEi @ 11972 NONAME + _ZN20QGraphicsItemPrivate14children_countEP24QDeclarativeListPropertyI15QGraphicsObjectE @ 11973 NONAME + _ZN20QGraphicsItemPrivate15children_appendEP24QDeclarativeListPropertyI15QGraphicsObjectEPS1_ @ 11974 NONAME diff --git a/src/s60installs/eabi/QtMultimediau.def b/src/s60installs/eabi/QtMultimediau.def index 384796d..64a6dc6 100644 --- a/src/s60installs/eabi/QtMultimediau.def +++ b/src/s60installs/eabi/QtMultimediau.def @@ -972,4 +972,7 @@ EXPORTS _ZNK12QSoundEffect7isMutedEv @ 971 NONAME _ZTI12QSoundEffect @ 972 NONAME _ZTV12QSoundEffect @ 973 NONAME + _ZN18QGraphicsVideoItem10sceneEventEP6QEvent @ 974 NONAME + _ZN18QGraphicsVideoItem5eventEP6QEvent @ 975 NONAME + _ZThn8_N18QGraphicsVideoItem10sceneEventEP6QEvent @ 976 NONAME -- cgit v0.12 From 1d267f33d179abbac753a72c2235e7fb07c4def7 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 15 Apr 2010 20:31:07 +1000 Subject: Revert "Update Phonon ds9 backend to 4.4.0." This reverts commit 19a3fc3bd817628070e5637caf158b0be79eee82. The phonon backend in 4.4.0 is outdated. Qt has the most recent one. Conflicts: src/3rdparty/phonon/ds9/iodevicereader.cpp (cherry picked from commit 6253ced81bcd60c04803f1a52bc59a239022b9c4) Conflicts: src/3rdparty/phonon/ds9/mediaobject.cpp --- 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 | 94 +++------- src/3rdparty/phonon/ds9/iodevicereader.h | 1 - src/3rdparty/phonon/ds9/mediagraph.cpp | 38 ++-- src/3rdparty/phonon/ds9/mediaobject.cpp | 205 +++++++++------------ 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 +- src/plugins/phonon/ds9/ds9.pro | 2 + 34 files changed, 1001 insertions(+), 624 deletions(-) create mode 100644 src/3rdparty/phonon/ds9/qevr9.h create mode 100644 src/3rdparty/phonon/ds9/videorenderer_default.cpp create mode 100644 src/3rdparty/phonon/ds9/videorenderer_default.h create mode 100644 src/3rdparty/phonon/ds9/videorenderer_evr.cpp create 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 e932e70..a9d0694 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 2c56af7..fbc4bdc 100644 --- a/src/3rdparty/phonon/ds9/backend.cpp +++ b/src/3rdparty/phonon/ds9/backend.cpp @@ -41,6 +41,8 @@ namespace Phonon { namespace DS9 { + QMutex *Backend::directShowMutex = 0; + bool Backend::AudioMoniker::operator==(const AudioMoniker &other) { return other->IsEqual(*this) == S_OK; @@ -50,6 +52,8 @@ namespace Phonon Backend::Backend(QObject *parent, const QVariantList &) : QObject(parent) { + directShowMutex = &m_directShowMutex; + ::CoInitialize(0); //registering meta types @@ -62,6 +66,8 @@ namespace Phonon m_audioOutputs.clear(); m_audioEffects.clear(); ::CoUninitialize(); + + directShowMutex = 0; } QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &args) @@ -131,6 +137,7 @@ namespace Phonon QList Backend::objectDescriptionIndexes(Phonon::ObjectDescriptionType type) const { + QMutexLocker locker(&m_directShowMutex); QList ret; switch(type) @@ -157,7 +164,7 @@ namespace Phonon while (S_OK == enumMon->Next(1, mon.pparam(), 0)) { LPOLESTR str = 0; mon->GetDisplayName(0,0,&str); - const QString name = QString::fromUtf16((unsigned short*)str); + const QString name = QString::fromWCharArray(str); ComPointer alloc; ::CoGetMalloc(1, alloc.pparam()); alloc->Free(str); @@ -204,6 +211,7 @@ namespace Phonon QHash Backend::objectDescriptionProperties(Phonon::ObjectDescriptionType type, int index) const { + QMutexLocker locker(&m_directShowMutex); QHash ret; switch (type) { @@ -216,7 +224,7 @@ namespace Phonon LPOLESTR str = 0; HRESULT hr = mon->GetDisplayName(0,0, &str); if (SUCCEEDED(hr)) { - QString name = QString::fromUtf16((unsigned short*)str); + QString name = QString::fromWCharArray(str); ComPointer alloc; ::CoGetMalloc(1, alloc.pparam()); alloc->Free(str); @@ -231,7 +239,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::fromUtf16((unsigned short*)name); + ret["name"] = QString::fromWCharArray(name); } } break; diff --git a/src/3rdparty/phonon/ds9/backend.h b/src/3rdparty/phonon/ds9/backend.h index ad638f2..7c3c109 100644 --- a/src/3rdparty/phonon/ds9/backend.h +++ b/src/3rdparty/phonon/ds9/backend.h @@ -23,6 +23,7 @@ along with this library. If not, see . #include #include +#include #include "compointer.h" #include "backendnode.h" @@ -63,6 +64,8 @@ namespace Phonon Filter getAudioOutputFilter(int index) const; + static QMutex *directShowMutex; + Q_SIGNALS: void objectDescriptionChanged(ObjectDescriptionType); @@ -74,6 +77,7 @@ 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 7e0b3cd..737ab7b 100644 --- a/src/3rdparty/phonon/ds9/backendnode.cpp +++ b/src/3rdparty/phonon/ds9/backendnode.cpp @@ -57,6 +57,25 @@ 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 1bc3451..764390e 100644 --- a/src/3rdparty/phonon/ds9/ds9.desktop +++ b/src/3rdparty/phonon/ds9/ds9.desktop @@ -5,13 +5,12 @@ 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://www.trolltech.com/ +X-KDE-PhononBackendInfo-Website=http://qt.nokia.com/ InitialPreference=15 Name=DirectShow9 Name[bg]=DirectShow9 Name[ca]=DirectShow9 -Name[ca@valencia]=DirectShow9 Name[cs]=DirectShow9 Name[da]=DirectShow9 Name[de]=DirectShow9 @@ -20,14 +19,11 @@ 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 @@ -35,7 +31,6 @@ Name[ko]=DirectShow9 Name[ku]=DirectShow9 Name[lt]=DirectShow9 Name[lv]=DirectShow9 -Name[nb]=DirectShow9 Name[nds]=DirectShow9 Name[nl]=DirectShow9 Name[nn]=DirectShow9 @@ -43,13 +38,10 @@ 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 @@ -61,7 +53,6 @@ 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 @@ -70,13 +61,11 @@ 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 ãƒãƒƒã‚¯ã‚¨ãƒ³ãƒ‰ @@ -84,7 +73,6 @@ 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 @@ -92,13 +80,10 @@ 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 104a3c1..ebe976b 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::fromUtf16((unsigned short*)current) ); + values.append( QString::fromWCharArray(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::fromUtf16((unsigned short*)name); + const QString n = QString::fromWCharArray(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 9a61a2e..4dce138 100644 --- a/src/3rdparty/phonon/ds9/fakesource.cpp +++ b/src/3rdparty/phonon/ds9/fakesource.cpp @@ -29,8 +29,10 @@ namespace Phonon namespace DS9 { static WAVEFORMATEX g_defaultWaveFormat = {WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0}; - 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}; + 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)}; class FakePin : public QPin { @@ -128,36 +130,12 @@ namespace Phonon void FakeSource::createFakeAudioPin() { - 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); + new FakePin(this, g_fakeAudioType); } void FakeSource::createFakeVideoPin() { - 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); + new FakePin(this, g_fakeVideoType); } } diff --git a/src/3rdparty/phonon/ds9/iodevicereader.cpp b/src/3rdparty/phonon/ds9/iodevicereader.cpp index 9152712..ba4ae5c 100644 --- a/src/3rdparty/phonon/ds9/iodevicereader.cpp +++ b/src/3rdparty/phonon/ds9/iodevicereader.cpp @@ -36,18 +36,20 @@ namespace Phonon //these mediatypes define a stream, its type will be autodetected by DirectShow static QVector getMediaTypes() { - AM_MEDIA_TYPE mt = { MEDIATYPE_Stream, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; + //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}; 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; } @@ -64,7 +66,6 @@ namespace Phonon //for Phonon::StreamInterface void writeData(const QByteArray &data) { - QWriteLocker locker(&m_lock); m_pos += data.size(); m_buffer += data; } @@ -75,54 +76,22 @@ namespace Phonon void setStreamSize(qint64 newSize) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_size = newSize; } - qint64 streamSize() const - { - QReadLocker locker(&m_lock); - return m_size; - } - void setStreamSeekable(bool s) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); 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) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (total) { *total = m_size; } @@ -137,37 +106,39 @@ namespace Phonon HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual) { - QMutexLocker locker(&m_mutexRead); + Q_ASSERT(!m_mutex.tryLock()); + if (m_mediaGraph->isStopping()) { + return VFW_E_WRONG_STATE; + } - if(streamSize() != 1 && pos + length > streamSize()) { + if(m_size != 1 && pos + length > m_size) { //it tries to read outside of the boundaries return E_FAIL; } - if (currentPos() - currentBufferSize() != pos) { - if (!streamSeekable()) { + if (m_pos - m_buffer.size() != pos) { + if (!m_seekable) { return S_FALSE; } - setCurrentPos(pos); + m_pos = pos; + seekStream(pos); + m_buffer.clear(); } - int oldSize = currentBufferSize(); - while (currentBufferSize() < int(length)) { + int oldSize = m_buffer.size(); + while (m_buffer.size() < int(length)) { needData(); - if (oldSize == currentBufferSize()) { + if (oldSize == m_buffer.size()) { break; //we didn't get any data } - oldSize = currentBufferSize(); + oldSize = m_buffer.size(); } - 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); - } + int bytesRead = qMin(m_buffer.size(), int(length)); + qMemCopy(buffer, m_buffer.data(), bytesRead); + //truncate the buffer + m_buffer = m_buffer.mid(bytesRead); if (actual) { *actual = bytesRead; //initialization @@ -183,7 +154,6 @@ namespace Phonon qint64 m_pos; qint64 m_size; - QMutex m_mutexRead; const MediaGraph *m_mediaGraph; }; @@ -197,14 +167,6 @@ 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 af4b271..c8b91c3 100644 --- a/src/3rdparty/phonon/ds9/iodevicereader.h +++ b/src/3rdparty/phonon/ds9/iodevicereader.h @@ -41,7 +41,6 @@ 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 db0ec84..3e7a68b 100644 --- a/src/3rdparty/phonon/ds9/mediagraph.cpp +++ b/src/3rdparty/phonon/ds9/mediagraph.cpp @@ -68,6 +68,8 @@ namespace Phonon return ret; } + +/* static HRESULT saveToFile(Graph graph, const QString &filepath) { const WCHAR wszStreamName[] = L"ActiveMovieGraph"; @@ -103,7 +105,7 @@ namespace Phonon return hr; } - +*/ MediaGraph::MediaGraph(MediaObject *mo, short index) : m_graph(CLSID_FilterGraph, IID_IGraphBuilder), @@ -377,11 +379,12 @@ namespace Phonon FILTER_INFO info; filter->QueryFilterInfo(&info); #ifdef GRAPH_DEBUG - qDebug() << "removeFilter" << QString::fromUtf16(info.achName); + qDebug() << "removeFilter" << QString((const QChar *)info.achName); #endif if (info.pGraph) { info.pGraph->Release(); - return m_graph->RemoveFilter(filter); + if (info.pGraph == m_graph) + return m_graph->RemoveFilter(filter); } //already removed @@ -537,11 +540,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 (VFW_E_NOT_CONNECTED == pin->ConnectedTo(inPin.pparam())) { + if (HRESULT(VFW_E_NOT_CONNECTED) == pin->ConnectedTo(inPin.pparam())) { return SUCCEEDED(pin->Connect(newIn, 0)); } } - //we should never go here + //we shoud never go here return false; } else { QAMMediaType type; @@ -679,7 +682,6 @@ 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 { @@ -809,7 +811,7 @@ namespace Phonon for (int i = 0; i < outputs.count(); ++i) { const OutputPin &out = outputs.at(i); InputPin pin; - if (out->ConnectedTo(pin.pparam()) == VFW_E_NOT_CONNECTED) { + if (out->ConnectedTo(pin.pparam()) == HRESULT(VFW_E_NOT_CONNECTED)) { m_decoderPins += out; //unconnected outputs can be decoded outputs } } @@ -820,7 +822,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 should transfer the sink node + //check if we shoud transfer the sink node grabFilter(connection.input); grabFilter(connection.output); @@ -873,7 +875,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName); + qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -919,7 +921,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << "found a decoder filter" << QString::fromUtf16(info.achName); + qDebug() << "found a decoder filter" << QString((const QChar *)info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -935,7 +937,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName); + qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -954,7 +956,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName); + qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -988,7 +990,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << "found a demuxer filter" << QString::fromUtf16(info.achName); + qDebug() << "found a demuxer filter" << QString((const QChar *)info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -1006,27 +1008,27 @@ namespace Phonon BSTR str; HRESULT hr = mediaContent->get_AuthorName(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("ARTIST"), QString::fromUtf16((const unsigned short*)str)); + ret.insert(QLatin1String("ARTIST"), QString::fromWCharArray(str)); SysFreeString(str); } hr = mediaContent->get_Title(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("TITLE"), QString::fromUtf16((const unsigned short*)str)); + ret.insert(QLatin1String("TITLE"), QString::fromWCharArray(str)); SysFreeString(str); } hr = mediaContent->get_Description(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("DESCRIPTION"), QString::fromUtf16((const unsigned short*)str)); + ret.insert(QLatin1String("DESCRIPTION"), QString::fromWCharArray(str)); SysFreeString(str); } hr = mediaContent->get_Copyright(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("COPYRIGHT"), QString::fromUtf16((const unsigned short*)str)); + ret.insert(QLatin1String("COPYRIGHT"), QString::fromWCharArray(str)); SysFreeString(str); } hr = mediaContent->get_MoreInfoText(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("MOREINFO"), QString::fromUtf16((const unsigned short*)str)); + ret.insert(QLatin1String("MOREINFO"), QString::fromWCharArray(str)); SysFreeString(str); } } diff --git a/src/3rdparty/phonon/ds9/mediaobject.cpp b/src/3rdparty/phonon/ds9/mediaobject.cpp index b9a8713..34f92c2 100644 --- a/src/3rdparty/phonon/ds9/mediaobject.cpp +++ b/src/3rdparty/phonon/ds9/mediaobject.cpp @@ -23,13 +23,10 @@ along with this library. If not, see . #ifndef Q_CC_MSVC #include -#endif //Q_CC_MSVC +#endif #include #include #include -#ifdef Q_CC_MSVC -# include -#endif #include #include "mediaobject.h" @@ -52,7 +49,7 @@ namespace Phonon //first the definition of the WorkerThread class WorkerThread::WorkerThread() - : QThread(), m_currentRenderId(0), m_finished(false), m_currentWorkId(1) + : QThread(), m_finished(false), m_currentWorkId(1) { } @@ -60,24 +57,6 @@ 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) { @@ -91,11 +70,6 @@ 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 @@ -183,6 +157,7 @@ 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(); @@ -202,23 +177,29 @@ namespace Phonon void WorkerThread::handleTask() { - const Work w = dequeueWork(); + QMutexLocker locker(Backend::directShowMutex); + { + QMutexLocker locker(&m_mutex); + if (m_finished || m_queue.isEmpty()) { + return; + } - if (m_finished) { - return; + m_currentWork = 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(); + } } HRESULT hr = S_OK; - m_currentRender = w.graph; - m_currentRenderId = w.id; - if (w.task == ReplaceGraph) { - QMutexLocker locker(&m_mutex); - HANDLE h; - + if (m_currentWork.task == ReplaceGraph) { int index = -1; for(int i = 0; i < FILTER_COUNT; ++i) { - if (m_graphHandle[i].graph == w.oldGraph) { + if (m_graphHandle[i].graph == m_currentWork.oldGraph) { m_graphHandle[i].graph = Graph(); index = i; break; @@ -231,51 +212,40 @@ namespace Phonon Q_ASSERT(index != -1); //add the new graph - if (SUCCEEDED(ComPointer(w.graph, IID_IMediaEvent) + HANDLE h; + if (SUCCEEDED(ComPointer(m_currentWork.graph, IID_IMediaEvent) ->GetEventHandle(reinterpret_cast(&h)))) { - m_graphHandle[index].graph = w.graph; + m_graphHandle[index].graph = m_currentWork.graph; m_graphHandle[index].handle = h; } - } else if (w.task == Render) { - if (w.filter) { + } else if (m_currentWork.task == Render) { + if (m_currentWork.filter) { //let's render pins - 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; - } + 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)); } - } else if (!w.url.isEmpty()) { + } else if (!m_currentWork.url.isEmpty()) { //let's render a url (blocking call) - hr = w.graph->RenderFile(reinterpret_cast(w.url.utf16()), 0); + hr = m_currentWork.graph->RenderFile(reinterpret_cast(m_currentWork.url.utf16()), 0); } if (hr != E_ABORT) { - emit asyncRenderFinished(w.id, hr, w.graph); + emit asyncRenderFinished(m_currentWork.id, hr, m_currentWork.graph); } - } else if (w.task == Seek) { + } else if (m_currentWork.task == Seek) { //that's a seekrequest - ComPointer mediaSeeking(w.graph, IID_IMediaSeeking); - qint64 newtime = w.time * 10000; + ComPointer mediaSeeking(m_currentWork.graph, IID_IMediaSeeking); + qint64 newtime = m_currentWork.time * 10000; hr = mediaSeeking->SetPositions(&newtime, AM_SEEKING_AbsolutePositioning, 0, AM_SEEKING_NoPositioning); - qint64 currentTime = -1; - if (SUCCEEDED(hr)) { - hr = mediaSeeking->GetCurrentPosition(¤tTime); - if (SUCCEEDED(hr)) { - currentTime /= 10000; //convert to ms - } - } - emit asyncSeekingFinished(w.id, currentTime); + emit asyncSeekingFinished(m_currentWork.id, newtime / 10000); hr = E_ABORT; //to avoid emitting asyncRenderFinished - } else if (w.task == ChangeState) { + } else if (m_currentWork.task == ChangeState) { //remove useless decoders QList unused; - for (int i = 0; i < w.decoders.count(); ++i) { - const Filter &filter = w.decoders.at(i); + for (int i = 0; i < m_currentWork.decoders.count(); ++i) { + const Filter &filter = m_currentWork.decoders.at(i); bool used = false; const QList pins = BackendNode::pins(filter, PINDIR_OUTPUT); for( int i = 0; i < pins.count(); ++i) { @@ -292,15 +262,15 @@ namespace Phonon //we can get the state for (int i = 0; i < unused.count(); ++i) { //we should remove this filter from the graph - w.graph->RemoveFilter(unused.at(i)); + m_currentWork.graph->RemoveFilter(unused.at(i)); } //we can get the state - ComPointer mc(w.graph, IID_IMediaControl); + ComPointer mc(m_currentWork.graph, IID_IMediaControl); //we change the state here - switch(w.state) + switch(m_currentWork.state) { case State_Stopped: mc->Stop(); @@ -318,36 +288,38 @@ namespace Phonon if (SUCCEEDED(hr)) { if (s == State_Stopped) { - emit stateReady(w.graph, Phonon::StoppedState); + emit stateReady(m_currentWork.graph, Phonon::StoppedState); } else if (s == State_Paused) { - emit stateReady(w.graph, Phonon::PausedState); + emit stateReady(m_currentWork.graph, Phonon::PausedState); } else /*if (s == State_Running)*/ { - emit stateReady(w.graph, Phonon::PlayingState); + emit stateReady(m_currentWork.graph, Phonon::PlayingState); } } } - m_currentRender = Graph(); - m_currentRenderId = 0; - + { + QMutexLocker locker(&m_mutex); + m_currentWork = Work(); //reinitialize + } } - 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 @@ -355,9 +327,9 @@ namespace Phonon { QMutexLocker locker(&m_mutex); m_queue.clear(); - if (m_currentRender) { + if (m_currentWork.graph) { //in case we're currently rendering something - m_currentRender->Abort(); + m_currentWork.graph->Abort(); } @@ -389,17 +361,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(); @@ -522,6 +494,18 @@ 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) { @@ -530,15 +514,6 @@ 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()) { @@ -551,15 +526,6 @@ 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 @@ -794,15 +760,16 @@ 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; } } } @@ -850,13 +817,11 @@ namespace Phonon #endif LPAMGETERRORTEXT getErrorText = (LPAMGETERRORTEXT)QLibrary::resolve(QLatin1String("quartz"), "AMGetErrorTextW"); - ushort buffer[MAX_ERROR_TEXT_LEN]; - if (getErrorText && getErrorText(hr, (WCHAR*)buffer, MAX_ERROR_TEXT_LEN)) { - m_errorString = QString::fromUtf16(buffer); -#ifdef Q_CC_MSVC + WCHAR buffer[MAX_ERROR_TEXT_LEN]; + if (getErrorText && getErrorText(hr, buffer, MAX_ERROR_TEXT_LEN)) { + m_errorString = QString::fromWCharArray(buffer); } else { - m_errorString = QString::fromUtf16((ushort*)_com_error(hr).ErrorMessage()); -#endif + m_errorString = QString::fromLatin1("Unknown error"); } 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 2c34ffc..34aa666 100644 --- a/src/3rdparty/phonon/ds9/mediaobject.h +++ b/src/3rdparty/phonon/ds9/mediaobject.h @@ -114,6 +114,7 @@ namespace Phonon enum Task { + None, Render, Seek, ChangeState, @@ -122,6 +123,7 @@ namespace Phonon struct Work { + Work() : task(None), id(0), time(0) { } Task task; quint16 id; Graph graph; @@ -135,16 +137,14 @@ namespace Phonon }; QList decoders; //for the state change requests }; - Work dequeueWork(); void handleTask(); - Graph m_currentRender; - qint16 m_currentRenderId; + Work m_currentWork; QQueue m_queue; bool m_finished; quint16 m_currentWorkId; QWinWaitCondition m_waitCondition; - QMutex m_mutex; + QMutex m_mutex; // mutex for the m_queue, m_finished and m_currentWorkId //this is for WaitForMultipleObjects struct diff --git a/src/3rdparty/phonon/ds9/qasyncreader.cpp b/src/3rdparty/phonon/ds9/qasyncreader.cpp index 68ec1f8..a3f9cda 100644 --- a/src/3rdparty/phonon/ds9/qasyncreader.cpp +++ b/src/3rdparty/phonon/ds9/qasyncreader.cpp @@ -15,8 +15,6 @@ 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" @@ -80,8 +78,7 @@ namespace Phonon STDMETHODIMP QAsyncReader::Request(IMediaSample *sample,DWORD_PTR user) { - QMutexLocker mutexLocker(&m_mutexWait); - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (m_flushing) { return VFW_E_WRONG_STATE; } @@ -93,33 +90,28 @@ namespace Phonon STDMETHODIMP QAsyncReader::WaitForNext(DWORD timeout, IMediaSample **sample, DWORD_PTR *user) { - QMutexLocker locker(&m_mutexWait); + QMutexLocker locker(&m_mutex); 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; - AsyncRequest r = getNextRequest(); - - if (r.sample == 0) { - //there is no request in the queue - if (isFlushing()) { + if (m_requestQueue.isEmpty()) { + if (m_requestWait.wait(&m_mutex, timeout) == false) { + return VFW_E_TIMEOUT; + } + if (m_requestQueue.isEmpty()) { 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; @@ -127,14 +119,12 @@ namespace Phonon *sample = r.sample; *user = r.user; - - return SyncReadAligned(r.sample); + return syncReadAlignedUnlocked(r.sample); } STDMETHODIMP QAsyncReader::BeginFlush() { - QMutexLocker mutexLocker(&m_mutexWait); - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_flushing = true; m_requestWait.wakeOne(); return S_OK; @@ -142,13 +132,28 @@ namespace Phonon STDMETHODIMP QAsyncReader::EndFlush() { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); 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; } @@ -175,23 +180,6 @@ 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 cb789ee..95872f9 100644 --- a/src/3rdparty/phonon/ds9/qasyncreader.h +++ b/src/3rdparty/phonon/ds9/qasyncreader.h @@ -48,11 +48,12 @@ namespace Phonon STDMETHODIMP WaitForNext(DWORD,IMediaSample **,DWORD_PTR *); STDMETHODIMP SyncReadAligned(IMediaSample *); STDMETHODIMP SyncRead(LONGLONG,LONG,BYTE *); - virtual STDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0; + 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: @@ -62,9 +63,6 @@ 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 b9f9fd6..6d0f335 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,19 +112,8 @@ namespace Phonon #define SECTOR_SIZE 2352 #define NB_SECTORS_READ 20 - 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; - } - + static const AM_MEDIA_TYPE audioCDMediaType = { MEDIATYPE_Stream, MEDIASUBTYPE_WAVE, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; + int addressToSectors(UCHAR address[4]) { return ((address[0] * 60 + address[1]) * 60 + address[2]) * 75 + address[3] - 150; @@ -141,11 +130,8 @@ namespace Phonon } - QAudioCDReader::QAudioCDReader(QBaseFilter *parent, QChar drive) : QAsyncReader(parent, QVector() << getAudioCDMediaType()) + QAudioCDReader::QAudioCDReader(QBaseFilter *parent, QChar drive) : QAsyncReader(parent, QVector() << audioCDMediaType) { - m_toc = new CDROM_TOC; - m_waveHeader = new WaveStructure; - //now open the cd-drive QString path; if (drive.isNull()) { @@ -154,36 +140,30 @@ namespace Phonon path = QString::fromLatin1("\\\\.\\%1:").arg(drive); } - 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 ) - ); + m_cddrive = ::CreateFile((const wchar_t *)path.utf16(), 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() @@ -199,7 +179,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; } @@ -238,11 +218,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) { @@ -297,8 +277,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 9049b66..eff845d 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 const IID IID_ITitleInterface; + EXTERN_C 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 95cab92..78b8b8f 100644 --- a/src/3rdparty/phonon/ds9/qbasefilter.cpp +++ b/src/3rdparty/phonon/ds9/qbasefilter.cpp @@ -92,8 +92,8 @@ namespace Phonon return E_POINTER; } - int nbfetched = 0; - while (nbfetched < int(count) && m_index < m_pins.count()) { + uint nbfetched = 0; + while (nbfetched < 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 { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); return m_pins; } void QBaseFilter::addPin(QPin *pin) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_pins.append(pin); } void QBaseFilter::removePin(QPin *pin) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_pins.removeAll(pin); } @@ -211,7 +211,8 @@ namespace Phonon } else if (iid == IID_IMediaPosition || iid == IID_IMediaSeeking) { if (inputPins().isEmpty()) { - if (*out = getUpStreamInterface(iid)) { + *out = getUpStreamInterface(iid); + if (*out) { return S_OK; //we return here to avoid adding a reference } else { hr = E_NOINTERFACE; @@ -250,35 +251,35 @@ namespace Phonon STDMETHODIMP QBaseFilter::GetClassID(CLSID *clsid) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); *clsid = m_clsid; return S_OK; } STDMETHODIMP QBaseFilter::Stop() { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_state = State_Stopped; return S_OK; } STDMETHODIMP QBaseFilter::Pause() { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_state = State_Paused; return S_OK; } STDMETHODIMP QBaseFilter::Run(REFERENCE_TIME) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_state = State_Running; return S_OK; } STDMETHODIMP QBaseFilter::GetState(DWORD, FILTER_STATE *state) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (!state) { return E_POINTER; } @@ -289,7 +290,7 @@ namespace Phonon STDMETHODIMP QBaseFilter::SetSyncSource(IReferenceClock *clock) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (clock) { clock->AddRef(); } @@ -302,7 +303,7 @@ namespace Phonon STDMETHODIMP QBaseFilter::GetSyncSource(IReferenceClock **clock) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (!clock) { return E_POINTER; } @@ -341,7 +342,7 @@ namespace Phonon STDMETHODIMP QBaseFilter::QueryFilterInfo(FILTER_INFO *info ) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (!info) { return E_POINTER; } @@ -355,9 +356,9 @@ namespace Phonon STDMETHODIMP QBaseFilter::JoinFilterGraph(IFilterGraph *graph, LPCWSTR name) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_graph = graph; - m_name = QString::fromUtf16((const unsigned short*)name); + m_name = QString::fromWCharArray(name); return S_OK; } diff --git a/src/3rdparty/phonon/ds9/qbasefilter.h b/src/3rdparty/phonon/ds9/qbasefilter.h index 85f1431..a72d6fe 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 QReadWriteLock m_lock; + mutable QMutex m_mutex; }; } } diff --git a/src/3rdparty/phonon/ds9/qevr9.h b/src/3rdparty/phonon/ds9/qevr9.h new file mode 100644 index 0000000..8599fce --- /dev/null +++ b/src/3rdparty/phonon/ds9/qevr9.h @@ -0,0 +1,143 @@ +/* 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 dca99db..a21fbe7 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(parent, PINDIR_INPUT, mt), m_shouldDuplicateSamples(true), m_transform(transform) + 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) { } @@ -66,11 +66,9 @@ namespace Phonon { //this allows to serialize with Receive calls QMutexLocker locker(&m_mutexReceive); - for(int i = 0; i < m_outputs.count(); ++i) { - IPin *conn = m_outputs.at(i)->connected(); - if (conn) { - conn->EndOfStream(); - } + IPin *conn = m_output ? m_output->connected() : 0; + if (conn) { + conn->EndOfStream(); } return S_OK; } @@ -78,13 +76,11 @@ namespace Phonon STDMETHODIMP QMemInputPin::BeginFlush() { //pass downstream - for(int i = 0; i < m_outputs.count(); ++i) { - IPin *conn = m_outputs.at(i)->connected(); - if (conn) { - conn->BeginFlush(); - } + IPin *conn = m_output ? m_output->connected() : 0; + if (conn) { + conn->BeginFlush(); } - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_flushing = true; return S_OK; } @@ -92,22 +88,19 @@ namespace Phonon STDMETHODIMP QMemInputPin::EndFlush() { //pass downstream - for(int i = 0; i < m_outputs.count(); ++i) { - IPin *conn = m_outputs.at(i)->connected(); - if (conn) { - conn->EndFlush(); - } + IPin *conn = m_output ? m_output->connected() : 0; + if (conn) { + conn->EndFlush(); } - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_flushing = false; return S_OK; } STDMETHODIMP QMemInputPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate) { - for(int i = 0; i < m_outputs.count(); ++i) { - m_outputs.at(i)->NewSegment(start, stop, rate); - } + if (m_output) + m_output->NewSegment(start, stop, rate); return S_OK; } @@ -119,14 +112,9 @@ namespace Phonon if (hr == S_OK && mt->majortype != MEDIATYPE_NULL && mt->subtype != MEDIASUBTYPE_NULL && - 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; - } - } + mt->formattype != GUID_NULL && m_output) { + //we tell the output pin that it should connect with this type + hr = m_output->setAcceptedMediaType(connectedType()); } return hr; } @@ -137,7 +125,8 @@ namespace Phonon return E_POINTER; } - if (*alloc = memoryAllocator(true)) { + *alloc = memoryAllocator(true); + if (*alloc) { return S_OK; } @@ -151,18 +140,15 @@ namespace Phonon } { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_shouldDuplicateSamples = m_transform && readonly; } setMemoryAllocator(alloc); - 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); - } + if (m_output) { + ComPointer input(m_output, IID_IMemInputPin); + input->NotifyAllocator(alloc, m_shouldDuplicateSamples); } return S_OK; @@ -201,22 +187,18 @@ namespace Phonon } } - for (int i = 0; i < m_outputs.count(); ++i) { - QPin *current = m_outputs.at(i); + if (m_output) { IMediaSample *outSample = m_shouldDuplicateSamples ? - duplicateSampleForOutput(sample, current->memoryAllocator()) + duplicateSampleForOutput(sample, m_output->memoryAllocator()) : sample; if (m_shouldDuplicateSamples) { m_parent->processSample(outSample); } - IPin *pin = current->connected(); - if (pin) { - ComPointer input(pin, IID_IMemInputPin); - if (input) { - input->Receive(outSample); - } + ComPointer input(m_output->connected(), IID_IMemInputPin); + if (input) { + input->Receive(outSample); } if (m_shouldDuplicateSamples) { @@ -247,39 +229,16 @@ namespace Phonon STDMETHODIMP QMemInputPin::ReceiveCanBlock() { - //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; - } + //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; } } 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 { @@ -294,7 +253,7 @@ namespace Phonon LONG length = sample->GetActualDataLength(); HRESULT hr = alloc->Commit(); - if (hr == VFW_E_SIZENOTSET) { + if (hr == HRESULT(VFW_E_SIZENOTSET)) { ALLOCATOR_PROPERTIES prop = getDefaultAllocatorProperties(); prop.cbBuffer = qMax(prop.cbBuffer, length); ALLOCATOR_PROPERTIES actual; @@ -324,7 +283,7 @@ namespace Phonon { LONGLONG start, end; hr = sample->GetMediaTime(&start, &end); - if (hr != VFW_E_MEDIA_TIME_NOT_SET) { + if (hr != HRESULT(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 c449721..d74c451 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); + QMemInputPin(QBaseFilter *, const QVector &, bool transform, QPin *output); ~QMemInputPin(); //reimplementation from IUnknown @@ -60,18 +60,13 @@ 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 - QList m_outputs; + QPin* const m_output; QMutex m_mutexReceive; }; } diff --git a/src/3rdparty/phonon/ds9/qpin.cpp b/src/3rdparty/phonon/ds9/qpin.cpp index 37fe48d..b4afd10 100644 --- a/src/3rdparty/phonon/ds9/qpin.cpp +++ b/src/3rdparty/phonon/ds9/qpin.cpp @@ -28,20 +28,7 @@ namespace Phonon namespace DS9 { - 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; - } + static const AM_MEDIA_TYPE defaultMediaType = { MEDIATYPE_NULL, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; class QEnumMediaTypes : public IEnumMediaTypes { @@ -104,8 +91,8 @@ namespace Phonon return E_INVALIDARG; } - int nbFetched = 0; - while (nbFetched < int(count) && m_index < m_pin->mediaTypes().count()) { + uint nbFetched = 0; + while (nbFetched < 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); @@ -158,9 +145,9 @@ namespace Phonon QPin::QPin(QBaseFilter *parent, PIN_DIRECTION dir, const QVector &mt) : - m_memAlloc(0), m_parent(parent), m_refCount(1), m_connected(0), - m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType()), - m_flushing(false) + m_parent(parent), m_flushing(false), m_refCount(1), m_connected(0), + m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType), + m_memAlloc(0) { Q_ASSERT(m_parent); m_parent->addPin(this); @@ -273,7 +260,7 @@ namespace Phonon if (FAILED(hr)) { setConnected(0); - setConnectedType(defaultMediaType()); + setConnectedType(defaultMediaType); } else { ComPointer input(pin, IID_IMemInputPin); if (input) { @@ -315,10 +302,8 @@ namespace Phonon } setConnected(0); - setConnectedType(defaultMediaType()); - if (m_direction == PINDIR_INPUT) { - setMemoryAllocator(0); - } + setConnectedType(defaultMediaType); + setMemoryAllocator(0); return S_OK; } @@ -338,7 +323,7 @@ namespace Phonon STDMETHODIMP QPin::ConnectionMediaType(AM_MEDIA_TYPE *type) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (!type) { return E_POINTER; } @@ -353,7 +338,6 @@ namespace Phonon STDMETHODIMP QPin::QueryPinInfo(PIN_INFO *info) { - QReadLocker locker(&m_lock); if (!info) { return E_POINTER; } @@ -361,14 +345,12 @@ namespace Phonon info->dir = m_direction; info->pFilter = m_parent; m_parent->AddRef(); - qMemCopy(info->achName, m_name.utf16(), qMin(MAX_FILTER_NAME, m_name.length()+1) *2); - + info->achName[0] = 0; return S_OK; } STDMETHODIMP QPin::QueryDirection(PIN_DIRECTION *dir) { - QReadLocker locker(&m_lock); if (!dir) { return E_POINTER; } @@ -379,20 +361,18 @@ namespace Phonon STDMETHODIMP QPin::QueryId(LPWSTR *id) { - QReadLocker locker(&m_lock); if (!id) { return E_POINTER; } - int nbBytes = (m_name.length()+1)*2; - *id = static_cast(::CoTaskMemAlloc(nbBytes)); - qMemCopy(*id, m_name.utf16(), nbBytes); + *id = static_cast(::CoTaskMemAlloc(2)); + *id[0] = 0; return S_OK; } STDMETHODIMP QPin::QueryAccept(const AM_MEDIA_TYPE *type) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (!type) { return E_POINTER; } @@ -439,7 +419,7 @@ namespace Phonon STDMETHODIMP QPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (m_direction == PINDIR_OUTPUT && m_connected) { //we deliver this downstream m_connected->NewSegment(start, stop, rate); @@ -456,8 +436,8 @@ namespace Phonon HRESULT QPin::checkOutputMediaTypesConnection(IPin *pin) { - IEnumMediaTypes *emt = 0; - HRESULT hr = pin->EnumMediaTypes(&emt); + ComPointer emt; + HRESULT hr = pin->EnumMediaTypes(emt.pparam()); if (hr != S_OK) { return hr; } @@ -470,7 +450,7 @@ namespace Phonon freeMediaType(type); return S_OK; } else { - setConnectedType(defaultMediaType()); + setConnectedType(defaultMediaType); freeMediaType(type); } } @@ -520,7 +500,7 @@ namespace Phonon void QPin::setConnectedType(const AM_MEDIA_TYPE &type) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); //1st we free memory freeMediaType(m_connectedType); @@ -530,13 +510,13 @@ namespace Phonon const AM_MEDIA_TYPE &QPin::connectedType() const { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); return m_connectedType; } void QPin::setConnected(IPin *pin) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (pin) { pin->AddRef(); } @@ -548,7 +528,7 @@ namespace Phonon IPin *QPin::connected(bool addref) const { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (addref && m_connected) { m_connected->AddRef(); } @@ -557,13 +537,12 @@ namespace Phonon bool QPin::isFlushing() const { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); return m_flushing; } FILTER_STATE QPin::filterState() const { - QReadLocker locker(&m_lock); FILTER_STATE fstate = State_Stopped; m_parent->GetState(0, &fstate); return fstate; @@ -571,7 +550,7 @@ namespace Phonon QVector QPin::mediaTypes() const { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); return m_mediaTypes; } @@ -607,7 +586,7 @@ namespace Phonon void QPin::setMemoryAllocator(IMemAllocator *alloc) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (alloc) { alloc->AddRef(); } @@ -619,7 +598,7 @@ namespace Phonon IMemAllocator *QPin::memoryAllocator(bool addref) const { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (addref && m_memAlloc) { m_memAlloc->AddRef(); } diff --git a/src/3rdparty/phonon/ds9/qpin.h b/src/3rdparty/phonon/ds9/qpin.h index a3287c4..280ad61 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 QReadWriteLock m_lock; - QBaseFilter *m_parent; + mutable QMutex m_mutex; + QBaseFilter * const m_parent; bool m_flushing; private: @@ -98,7 +98,6 @@ 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 new file mode 100644 index 0000000..0045a49 --- /dev/null +++ b/src/3rdparty/phonon/ds9/videorenderer_default.cpp @@ -0,0 +1,153 @@ +/* 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 new file mode 100644 index 0000000..43768d9 --- /dev/null +++ b/src/3rdparty/phonon/ds9/videorenderer_default.h @@ -0,0 +1,55 @@ +/* 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 new file mode 100644 index 0000000..d23d9ce --- /dev/null +++ b/src/3rdparty/phonon/ds9/videorenderer_evr.cpp @@ -0,0 +1,215 @@ +/* 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 new file mode 100644 index 0000000..229c36d --- /dev/null +++ b/src/3rdparty/phonon/ds9/videorenderer_evr.h @@ -0,0 +1,56 @@ +/* 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 491d1bd..9c7993c 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(); -#endif // QT_NO_OPENGL m_textureUploaded = false; +#endif // QT_NO_OPENGL } void endOfStream() @@ -314,7 +314,6 @@ 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, @@ -356,6 +355,7 @@ 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*/), + QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/, 0), 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_usingOpenGL(false), m_checkedPrograms(false), m_textureUploaded(false) + , m_checkedPrograms(false), m_usingOpenGL(false), m_textureUploaded(false) #endif { m_renderEvent = ::CreateEvent(0, 0, 0, 0); @@ -661,7 +661,10 @@ namespace Phonon #ifndef QT_NO_OPENGL - if (painter.paintEngine() && painter.paintEngine()->type() == QPaintEngine::OpenGL && checkGLPrograms()) { + if (painter.paintEngine() && + (painter.paintEngine()->type() == QPaintEngine::OpenGL || painter.paintEngine()->type() == QPaintEngine::OpenGL2) + && checkGLPrograms()) { + //for now we only support YUV (both YV12 and YUY2) updateTexture(); @@ -673,6 +676,7 @@ 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; @@ -722,6 +726,7 @@ 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 298e9fa..545b31e 100644 --- a/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp +++ b/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp @@ -22,14 +22,9 @@ along with this library. If not, see . #include #include -#include -#ifndef Q_OS_WINCE #include #include -#else -#include -#endif QT_BEGIN_NAMESPACE @@ -48,116 +43,10 @@ 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; } @@ -169,6 +58,7 @@ 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 @@ -324,7 +214,6 @@ 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 4eb237e..516d79d 100644 --- a/src/3rdparty/phonon/ds9/videorenderer_vmr9.h +++ b/src/3rdparty/phonon/ds9/videorenderer_vmr9.h @@ -19,7 +19,6 @@ 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 de7ce5f..09d42a4 100644 --- a/src/3rdparty/phonon/ds9/videowidget.cpp +++ b/src/3rdparty/phonon/ds9/videowidget.cpp @@ -24,7 +24,12 @@ 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 @@ -84,7 +89,19 @@ namespace Phonon void setCurrentRenderer(AbstractVideoRenderer *renderer) { m_currentRenderer = renderer; - update(); + //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); } QSize sizeHint() const @@ -106,6 +123,8 @@ namespace Phonon void paintEvent(QPaintEvent *e) { + if (!updatesEnabled()) + return; //this avoids repaint from native events checkCurrentRenderingMode(); m_currentRenderer->repaintCurrentFrame(this, e->rect()); } @@ -153,13 +172,14 @@ namespace Phonon } } else if (!isEmbedded()) { m_currentRenderer = m_node->switchRendering(m_currentRenderer); - setAttribute(Qt::WA_PaintOnScreen, true); + setAttribute(Qt::WA_PaintOnScreen, false); } } VideoWidget *m_node; AbstractVideoRenderer *m_currentRenderer; QVariant m_restoreScreenSaverActive; + QBasicTimer m_flickerFreeTimer; }; VideoWidget::VideoWidget(QWidget *parent) @@ -203,6 +223,9 @@ 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) { @@ -261,6 +284,7 @@ namespace Phonon { m_aspectRatio = aspectRatio; updateVideoSize(); + m_widget->update(); } Phonon::VideoWidget::ScaleMode VideoWidget::scaleMode() const @@ -279,6 +303,7 @@ namespace Phonon { m_scaleMode = scaleMode; updateVideoSize(); + m_widget->update(); } void VideoWidget::setBrightness(qreal b) @@ -332,14 +357,29 @@ namespace Phonon int index = graphIndex * 2 + type; if (m_renderers[index] == 0 && autoCreate) { AbstractVideoRenderer *renderer = 0; - if (type == Native) { - renderer = new VideoRendererVMR9(m_widget); + 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 (renderer->getFilter() == 0) { - //instanciating the renderer might fail with error VFW_E_DDRAW_CAPS_NOT_SUITABLE (0x80040273) + //instanciating the renderer might fail 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 b9a5fce..a93b074 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) : QMemInputPin(parent, mt, true /*transform*/) + VolumeMemInputPin(QBaseFilter *parent, const QVector &mt, QPin *output) : QMemInputPin(parent, mt, true /*transform*/, output) { } @@ -139,8 +139,7 @@ namespace Phonon //then creating the input mt << audioMediaType(); - m_input = new VolumeMemInputPin(this, mt); - m_input->addOutput(m_output); //make the connection here + m_input = new VolumeMemInputPin(this, mt, m_output); } 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 39b20d0..d1b0186 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; - //parameters used to fade + //paramaters used to fade Phonon::VolumeFaderEffect::FadeCurve m_fadeCurve; bool m_fading; //determines if we should be fading. diff --git a/src/plugins/phonon/ds9/ds9.pro b/src/plugins/phonon/ds9/ds9.pro index f40c561..dab5116 100644 --- a/src/plugins/phonon/ds9/ds9.pro +++ b/src/plugins/phonon/ds9/ds9.pro @@ -23,6 +23,7 @@ HEADERS += \ $$PHONON_DS9_DIR/videowidget.h \ $$PHONON_DS9_DIR/videorenderer_soft.h \ $$PHONON_DS9_DIR/videorenderer_vmr9.h \ + $$PHONON_DS9_DIR/videorenderer_evr.h \ $$PHONON_DS9_DIR/volumeeffect.h \ $$PHONON_DS9_DIR/qbasefilter.h \ $$PHONON_DS9_DIR/qpin.h \ @@ -46,6 +47,7 @@ SOURCES += \ $$PHONON_DS9_DIR/videowidget.cpp \ $$PHONON_DS9_DIR/videorenderer_soft.cpp \ $$PHONON_DS9_DIR/videorenderer_vmr9.cpp \ + $$PHONON_DS9_DIR/videorenderer_evr.cpp \ $$PHONON_DS9_DIR/volumeeffect.cpp \ $$PHONON_DS9_DIR/qbasefilter.cpp \ $$PHONON_DS9_DIR/qpin.cpp \ -- cgit v0.12 From ab31654127d7a6e9a06a2c75bc8b2832d68cdfc0 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 15 Apr 2010 20:32:27 +1000 Subject: Fix previous merge commit. --- src/3rdparty/phonon/ds9/mediaobject.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/3rdparty/phonon/ds9/mediaobject.cpp b/src/3rdparty/phonon/ds9/mediaobject.cpp index 34f92c2..d640956 100644 --- a/src/3rdparty/phonon/ds9/mediaobject.cpp +++ b/src/3rdparty/phonon/ds9/mediaobject.cpp @@ -27,6 +27,9 @@ along with this library. If not, see . #include #include #include +#ifdef Q_CC_MSVC +# include +#endif #include #include "mediaobject.h" -- cgit v0.12 From f2f5184d4a1c1bb0dd4816a13918a67ae0435d3d Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 15 Apr 2010 12:23:19 +0200 Subject: qdoc: Fixed .qdocconf files for assistant. (cherry picked from commit 114cb018c088570ff0640eeb0d57594905ff9fcf) --- tools/qdoc3/test/qt-build-docs.qdocconf | 30 ++++++++++++++++++++++++++- tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf | 29 +++++++++++++++++++++++++- tools/qdoc3/test/qt.qdocconf | 29 +++++++++++++++++++++++++- tools/qdoc3/test/qt_zh_CN.qdocconf | 29 +++++++++++++++++++++++++- 4 files changed, 113 insertions(+), 4 deletions(-) diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf index c9392c0..900c7c3 100644 --- a/tools/qdoc3/test/qt-build-docs.qdocconf +++ b/tools/qdoc3/test/qt-build-docs.qdocconf @@ -22,13 +22,41 @@ qhp.Qt.indexRoot = # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML -qhp.Qt.extraFiles = classic.css \ +qhp.Qt.extraFiles = style/style.css \ + scripts/functions.js \ + scripts/jquery.js \ + images/api_examples.png \ + images/api_lookup.png \ + images/api_topcs.png \ + images/bg_11.png \ + images/bg_1_blank.png \ + images/bg_1.png \ + images/bg_1r.png \ + images/bg_r.png \ + images/bg_ul_blank.png \ + images/bg_ul.png \ + images/bg_ur_blank.png \ + images/bg_ur.png \ + images/breadcrumb.png \ + images/bullet_dn.png \ + images/bullet_gt.png \ + images/feedbackground.png \ + images/form_bg.png \ + images/horBar.png \ + images/page_bg.png \ + images/print.png \ + images/qt_guide.png \ images/qt-logo.png \ + images/qt_ref_doc.png \ + images/qt_tools.png \ + images/sep.png \ + images/sprites-combined.png \ images/taskmenuextension-example.png \ images/coloreditorfactoryimage.png \ images/dynamiclayouts-example.png \ images/stylesheet-coffee-plastique.png + qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc qhp.Qt.customFilters.Qt.name = Qt 4.7.0 qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 diff --git a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf index 19db8a9..93c5e3e 100644 --- a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf @@ -29,8 +29,35 @@ qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML -qhp.Qt.extraFiles = classic.css \ +qhp.Qt.extraFiles = style/style.css \ + scripts/functions.js \ + scripts/jquery.js \ + images/api_examples.png \ + images/api_lookup.png \ + images/api_topcs.png \ + images/bg_11.png \ + images/bg_1_blank.png \ + images/bg_1.png \ + images/bg_1r.png \ + images/bg_r.png \ + images/bg_ul_blank.png \ + images/bg_ul.png \ + images/bg_ur_blank.png \ + images/bg_ur.png \ + images/breadcrumb.png \ + images/bullet_dn.png \ + images/bullet_gt.png \ + images/feedbackground.png \ + images/form_bg.png \ + images/horBar.png \ + images/page_bg.png \ + images/print.png \ + images/qt_guide.png \ images/qt-logo.png \ + images/qt_ref_doc.png \ + images/qt_tools.png \ + images/sep.png \ + images/sprites-combined.png \ images/taskmenuextension-example.png \ images/coloreditorfactoryimage.png \ images/dynamiclayouts-example.png \ diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf index 29b49e2..91f9525 100644 --- a/tools/qdoc3/test/qt.qdocconf +++ b/tools/qdoc3/test/qt.qdocconf @@ -24,8 +24,35 @@ qhp.Qt.indexRoot = # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML -qhp.Qt.extraFiles = classic.css \ +qhp.Qt.extraFiles = style/style.css \ + scripts/functions.js \ + scripts/jquery.js \ + images/api_examples.png \ + images/api_lookup.png \ + images/api_topcs.png \ + images/bg_11.png \ + images/bg_1_blank.png \ + images/bg_1.png \ + images/bg_1r.png \ + images/bg_r.png \ + images/bg_ul_blank.png \ + images/bg_ul.png \ + images/bg_ur_blank.png \ + images/bg_ur.png \ + images/breadcrumb.png \ + images/bullet_dn.png \ + images/bullet_gt.png \ + images/feedbackground.png \ + images/form_bg.png \ + images/horBar.png \ + images/page_bg.png \ + images/print.png \ + images/qt_guide.png \ images/qt-logo.png \ + images/qt_ref_doc.png \ + images/qt_tools.png \ + images/sep.png \ + images/sprites-combined.png \ images/taskmenuextension-example.png \ images/coloreditorfactoryimage.png \ images/dynamiclayouts-example.png \ diff --git a/tools/qdoc3/test/qt_zh_CN.qdocconf b/tools/qdoc3/test/qt_zh_CN.qdocconf index 980c542..925edec 100644 --- a/tools/qdoc3/test/qt_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt_zh_CN.qdocconf @@ -31,8 +31,35 @@ qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML -qhp.Qt.extraFiles = classic.css \ +qhp.Qt.extraFiles = style/style.css \ + scripts/functions.js \ + scripts/jquery.js \ + images/api_examples.png \ + images/api_lookup.png \ + images/api_topcs.png \ + images/bg_11.png \ + images/bg_1_blank.png \ + images/bg_1.png \ + images/bg_1r.png \ + images/bg_r.png \ + images/bg_ul_blank.png \ + images/bg_ul.png \ + images/bg_ur_blank.png \ + images/bg_ur.png \ + images/breadcrumb.png \ + images/bullet_dn.png \ + images/bullet_gt.png \ + images/feedbackground.png \ + images/form_bg.png \ + images/horBar.png \ + images/page_bg.png \ + images/print.png \ + images/qt_guide.png \ images/qt-logo.png \ + images/qt_ref_doc.png \ + images/qt_tools.png \ + images/sep.png \ + images/sprites-combined.png \ images/taskmenuextension-example.png \ images/coloreditorfactoryimage.png \ images/dynamiclayouts-example.png \ -- cgit v0.12 From 3764acbd211b97cf48908d90697d16e43c116836 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Tue, 13 Apr 2010 15:15:33 +0200 Subject: Doc: Fixing design bugs. Updating the index page and script/style files. Adding some image files. Reveiwed-by: trustme (cherry picked from commit c0d02030333c9f96188b5a425f2552472ab53325) --- doc/src/index.qdoc | 2 - doc/src/template/images/bullet_dn.png | Bin 0 -> 230 bytes doc/src/template/images/bullet_up.png | Bin 0 -> 253 bytes doc/src/template/images/header.png | Bin 0 -> 2600 bytes doc/src/template/scripts/functions.js | 11 +- doc/src/template/style/style.css | 817 +++++++++--------------- tools/qdoc3/test/qt-defines.qdocconf | 2 + tools/qdoc3/test/qt-html-templates.qdocconf | 26 +- tools/qdoc3/test/scripts/functions.js | 60 ++ tools/qdoc3/test/scripts/jquery.js | 152 +++++ tools/qdoc3/test/style/style.css | 946 ++++++++++++++++++++++++++++ tools/qdoc3/test/style/style_ie6.css | 54 ++ tools/qdoc3/test/style/style_ie7.css | 19 + tools/qdoc3/test/style/style_ie8.css | 0 14 files changed, 1562 insertions(+), 527 deletions(-) create mode 100644 doc/src/template/images/bullet_dn.png create mode 100644 doc/src/template/images/bullet_up.png create mode 100644 doc/src/template/images/header.png create mode 100644 tools/qdoc3/test/scripts/functions.js create mode 100644 tools/qdoc3/test/scripts/jquery.js create mode 100644 tools/qdoc3/test/style/style.css create mode 100644 tools/qdoc3/test/style/style_ie6.css create mode 100644 tools/qdoc3/test/style/style_ie7.css create mode 100644 tools/qdoc3/test/style/style_ie8.css diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 71060f8..2f23e6e 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -43,8 +43,6 @@ \page index.html \keyword Qt Reference Documentation - \title Qt Reference Documentation - \raw HTML
diff --git a/doc/src/template/images/bullet_dn.png b/doc/src/template/images/bullet_dn.png new file mode 100644 index 0000000..f776247 Binary files /dev/null and b/doc/src/template/images/bullet_dn.png differ diff --git a/doc/src/template/images/bullet_up.png b/doc/src/template/images/bullet_up.png new file mode 100644 index 0000000..285e741 Binary files /dev/null and b/doc/src/template/images/bullet_up.png differ diff --git a/doc/src/template/images/header.png b/doc/src/template/images/header.png new file mode 100644 index 0000000..141488b Binary files /dev/null and b/doc/src/template/images/header.png differ diff --git a/doc/src/template/scripts/functions.js b/doc/src/template/scripts/functions.js index c510410..329b910 100755 --- a/doc/src/template/scripts/functions.js +++ b/doc/src/template/scripts/functions.js @@ -1,7 +1,7 @@ /* START non link areas where cursor should change to pointing hand */ $('.t_button').mouseover(function() { - $(this).css('cursor','pointer'); + $('.t_button').css('cursor','pointer'); /*document.getElementById(this.id).style.cursor='pointer';*/ }); @@ -17,17 +17,20 @@ $('#medA').click(function() { $('.content h1').css('font','600 18px/1.2 Arial'); $('.content h2').css('font','600 16px/1.2 Arial'); $('.content h3').css('font','600 14px/1.2 Arial'); - $('.content p').css('font','13px/1.2 Verdana'); - $('.content li').css('font','600 10pt/1 Verdana'); + $('.content p').css('font','13px/20px Verdana'); + $('.content li').css('font','400 13px/1 Verdana'); $('.content li').css('line-height','14px'); + $('.content .toc li').css('font', 'normal 10px/1.2 Verdana'); $('.content table').css('font','13px/1.2 Verdana'); + $('.content .heading').css('font','600 16px/1 Arial'); + $('.content .indexboxcont li').css('font','600 13px/1 Verdana'); $('.t_button').removeClass('active') $(this).addClass('active') }); $('#bigA').click(function() { $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('font-size','large'); - $('.content li').css('line-height','14px'); + $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('line-height','25px'); $('.t_button').removeClass('active') $(this).addClass('active') }); diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index 4668c23..c46e875 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -73,6 +73,7 @@ { font-size: 100%; } + /* Page style */ html { background-color: #e5e5e5; @@ -101,7 +102,6 @@ { background: url(../images/bg_r.png) repeat-y 100% 0; } - .wrapper .hd { padding-left: 216px; @@ -109,12 +109,10 @@ background: url(../images/bg_ul.png) no-repeat 0 0; overflow: hidden; } - .offline .wrapper .hd { background: url(../images/bg_ul_blank.png) no-repeat 0 0; } - .wrapper .hd span { height: 15px; @@ -122,23 +120,19 @@ background: url(../images/bg_ur.png) no-repeat 100% 0; overflow: hidden; } - .offline .wrapper .hd span { /* background: url(../images/bg_ur_blank.png) no-repeat 100% 0; */ } - .wrapper .bd { background: url(../images/bg_l.png) repeat-y 0 0; position: relative; } - .offline .wrapper .bd { background: url(../images/bg_l_blank.png) repeat-y 0 0; } - .wrapper .ft { padding-left: 216px; @@ -146,12 +140,10 @@ background: url(../images/bg_ll.png) no-repeat 0 0; overflow: hidden; } - .offline .wrapper .ft { background: url(../images/bg_ll_blank.png) no-repeat 0 0; } - .wrapper .ft span { height: 15px; @@ -159,34 +151,23 @@ background: url(../images/bg_lr.png) no-repeat 100% 0; overflow: hidden; } - .header, .footer { display: block; clear: both; overflow: hidden; } - - /* .header - { - height: 130px; - position: relative; - } - */ - .header { height: 115px; position: relative; } - .header .icon { position: absolute; top: 13px; left: 0; } - .header .qtref { position: absolute; @@ -195,7 +176,6 @@ width: 302px; height: 22px; } - .header .qtref span { display: block; @@ -204,7 +184,184 @@ text-indent: -999em; background: url(../images/qt_ref_doc.png) no-repeat 0 0; } + /* header elements */ + #nav-topright + { + height: 70px; + } + + #nav-topright ul + { + list-style-type: none; + float: right; + width: 370px; + margin-top: 11px; + } + + #nav-topright li + { + display: inline-block; + margin-right: 20px; + float: left; + } + + #nav-topright li.nav-topright-last + { + margin-right: 0; + } + + #nav-topright li a + { + background: transparent url(../images/sprites-combined.png) no-repeat; + height: 18px; + display: block; + overflow: hidden; + text-indent: -9999px; + } + + #nav-topright li.nav-topright-home a + { + width: 65px; + background-position: -2px -91px; + } + + #nav-topright li.nav-topright-home a:hover + { + background-position: -2px -117px; + } + + + #nav-topright li.nav-topright-dev a + { + width: 30px; + background-position: -76px -91px; + } + + #nav-topright li.nav-topright-dev a:hover + { + background-position: -76px -117px; + } + + + #nav-topright li.nav-topright-labs a + { + width: 40px; + background-position: -114px -91px; + } + + #nav-topright li.nav-topright-labs a:hover + { + background-position: -114px -117px; + } + + #nav-topright li.nav-topright-doc a + { + width: 32px; + background-position: -162px -91px; + } + + #nav-topright li.nav-topright-doc a:hover, #nav-topright li.nav-topright-doc-active a + { + background-position: -162px -117px; + } + + #nav-topright li.nav-topright-blog a + { + width: 40px; + background-position: -203px -91px; + } + + #nav-topright li.nav-topright-blog a:hover, #nav-topright li.nav-topright-blog-active a + { + background-position: -203px -117px; + } + + #nav-topright li.nav-topright-shop a + { + width: 40px; + background-position: -252px -91px; + } + + #nav-topright li.nav-topright-shop a:hover, #nav-topright li.nav-topright-shop-active a + { + background-position: -252px -117px; + } + + #nav-logo + { + background: transparent url( "../images/sprites-combined.png" ) no-repeat 0 -225px; + left: -3px; + position: absolute; + width: 75px; + height: 75px; + top: 13px; + } + #nav-logo a + { + width: 75px; + height: 75px; + display: block; + text-indent: -9999px; + overflow: hidden; + } + /* Clearing */ + .header:after, .footer:after, .breadcrumb:after, .wrap .content:after, .group:after + { + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; + } + /* ^ Clearing */ + + + + .shortCut-topleft-inactive + { + padding-left: 3px; + background: transparent url( "../images/sprites-combined.png" ) no-repeat 0px -58px; + height: 20px; + width: 93px; + } + .shortCut-topleft-inactive span + { + font-variant: normal; + } + #shortCut + { + padding-top: 10px; + font-weight: bolder; + color: #b0adab; + } + #shortCut ul + { + list-style-type: none; + float: left; + width: 347px; + margin-left: 100px; + } + #shortCut li + { + display: inline-block; + margin-right: 25px; + float: left; + white-space: nowrap; + } + #shortCut li a + { + color: #b0adab; + text-decoration: none; + } + #shortCut li a:hover + { + color: #44a51c; + text-decoration: none; + } + /* end of header elements */ + + /* menu element */ .sidebar { float: left; @@ -212,7 +369,6 @@ width: 200px; font-size: 11px; } - .sidebar a { color: #00732f; @@ -222,19 +378,15 @@ { display: none; } - .sidebar .searchlabel { padding: 0 0 2px 17px; font: normal bold 11px/1.2 Verdana; } - .sidebar .search { padding: 0 15px 0 16px; } - - .sidebar .search form { width: 167px; @@ -242,7 +394,6 @@ padding: 2px 0 0 5px; background: url(../images/form_bg.png) no-repeat 0 0; } - .sidebar .search form fieldset input#searchstring { width: 158px; @@ -252,84 +403,66 @@ outline: none; font: 13px/1.2 Verdana; } - .sidebar .box { padding: 17px 15px 5px 16px; } - .sidebar .box .first { background-image: none; } - .sidebar .box h2 { font: normal 18px/1.2 Arial; padding: 15px 0 0 40px; min-height: 32px; } - .sidebar .box#lookup h2 { background: url(../images/api_lookup.png) no-repeat 0 0; } - .sidebar .box#topics h2 { background: url(../images/api_topics.png) no-repeat 0 0; } - .sidebar .box#examples h2 { background: url(../images/api_examples.png) no-repeat 0 0; } - .sidebar .box .list { display: block; } - .sidebar .box .live { display: none; height: 100px; overflow: auto; } - .list li a:hover, .live li a:hover { text-decoration: underline; } - - - .sidebar .box ul - { - } - .sidebar .box ul li { padding-left: 12px; background: url(../images/bullet_gt.png) no-repeat 0 5px; margin-bottom: 15px; } - .sidebar .bottombar { background: url(../images/box_bg.png) repeat-x 0 bottom; } - + /* content elements */ .wrap { - /* margin: 0 5px 0 0px;*/ overflow: hidden; } - .offline .wrap { margin: 0 5px 0 5px; } - + /* tool bar */ .wrap .toolbar { background-color: #fafafa; @@ -339,12 +472,10 @@ margin-right: 5px; position: relative; } - .wrap .toolbar .toolblock { position: absolute; } - .wrap .toolbar .breadcrumb { font-size: 11px; @@ -359,12 +490,10 @@ vertical-align: top; overflow: hidden; } - .wrap .toolbar .toolbuttons .active { color: #00732F; } - .wrap .toolbar .toolbuttons ul { float: right; @@ -378,7 +507,6 @@ font-weight: bold; color: #B0ADAB; } - #smallA { font-size: 10pt; @@ -391,31 +519,20 @@ { font-size: 14pt; } - #smallA:hover, #medA:hover, #bigA:hover { color: #00732F; } - #print { font-size: 14pt; line-height: 20pt; } - #printIcon { margin-left: 5px; } - - .offline .wrap .breadcrumb - { - } - - .wrap .breadcrumb ul - { - } - + /* bread crumbs */ .wrap .breadcrumb ul li { float: left; @@ -424,105 +541,87 @@ margin-left: 15px; font-weight: bold; } - .wrap .breadcrumb ul li.last { font-weight: normal; } - - .wrap .breadcrumb ul li a - { - } - .wrap .breadcrumb ul li.first { background-image: none; padding-left: 0; margin-left: 0; } - .wrap .content { - /* left 30 top 27*/ padding: 30px; position: relative; } - + /* text elements */ .heading { font: normal 600 16px/1.0 Arial; padding-bottom: 15px; } + .subtitle + { + font-size: 13px; + } + + .small-subtitle + { + font-size: 13px; + } + .wrap .content h1 { font: 600 18px/1.2 Arial; padding-bottom: 15px; } - .wrap .content h2 { font: 600 16px/1.2 Arial; } - .wrap .content h3 { font: 600 14px/1.2 Arial; } - - - .wrap .content p { - padding-bottom: 10px; + line-height:20px; + padding:10px 5px 10px 5px; } - .wrap .content ul { - padding-left: 15px; + padding-left: 25px; } .wrap .content li { padding-left: 12px; background: url(../images/bullet_sq.png) no-repeat 0 5px; - font: normal 600 10pt/1 Verdana; + font: normal 400 10pt/1 Verdana; margin-bottom: 10px; line-height: 14px; } - - .content li:hover + a { + color: #00732F; text-decoration: none; } - - .content li + a:hover { - text-decoration: none; + color: #4c0033; + text-decoration: underline; } - - /*.content*/ a - { - color: #00732F; - text-decoration: none; - } - - .content a:hover - { - color: #4c0033; - text-decoration: underline; - } - .content a:visited { color: #4c0033; + text-decoration: none; } - .offline .wrap .content { padding-top: 15px; } - - .footer { min-height: 100px; @@ -531,7 +630,6 @@ text-align: center; padding-top: 40px; } - .feedback { float: right; @@ -539,7 +637,6 @@ font: normal 8px/1 Verdana; color: #B0ADAB; } - .feedback:hover { float: right; @@ -547,196 +644,6 @@ color: #00732F; text-decoration: underline; } - - - - /* Clearing */ - .header:after, .footer:after, .breadcrumb:after, .wrap .content:after, .group:after - { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; - } - /* ^ Clearing */ - - - /* header elements */ - - - #nav-topright - { - height: 70px; - } - - #nav-topright ul - { - list-style-type: none; - float: right; - width: 347px; - margin-top: 11px; - } - - #nav-topright li - { - display: inline-block; - margin-right: 20px; - float: left; - } - - #nav-topright li.nav-topright-last - { - margin-right: 0; - } - - #nav-topright li a - { - background: transparent url(../images/sprites-combined.png) no-repeat; - height: 18px; - display: block; - overflow: hidden; - text-indent: -9999px; - } - - #nav-topright li.nav-topright-home a - { - width: 65px; - background-position: -2px -91px; - } - - #nav-topright li.nav-topright-home a:hover - { - background-position: -2px -117px; - } - - - #nav-topright li.nav-topright-dev a - { - width: 30px; - background-position: -76px -91px; - } - - #nav-topright li.nav-topright-dev a:hover - { - background-position: -76px -117px; - } - - - #nav-topright li.nav-topright-labs a - { - width: 40px; - background-position: -114px -91px; - } - - #nav-topright li.nav-topright-labs a:hover - { - background-position: -114px -117px; - } - - #nav-topright li.nav-topright-doc a - { - width: 32px; - background-position: -162px -91px; - } - - #nav-topright li.nav-topright-doc a:hover, #nav-topright li.nav-topright-doc-active a - { - background-position: -162px -117px; - } - - #nav-topright li.nav-topright-blog a - { - width: 40px; - background-position: -203px -91px; - } - - #nav-topright li.nav-topright-blog a:hover, #nav-topright li.nav-topright-blog-active a - { - background-position: -203px -117px; - } - - #nav-topright li.nav-topright-shop a - { - width: 40px; - background-position: -252px -91px; - } - - #nav-topright li.nav-topright-shop a:hover, #nav-topright li.nav-topright-shop-active a - { - background-position: -252px -117px; - } - - #nav-logo - { - background: transparent url( "../images/sprites-combined.png" ) no-repeat 0 -225px; - left: -3px; - position: absolute; - width: 75px; - height: 75px; - top: 13px; - } - #nav-logo a - { - width: 75px; - height: 75px; - display: block; - text-indent: -9999px; - overflow: hidden; - } - - - .shortCut-topleft-inactive - { - padding-left: 3px; - background: transparent url( "../images/sprites-combined.png" ) no-repeat 0px -58px; - height: 20px; - width: 93px; - } - - .shortCut-topleft-inactive span - { - font-variant: normal; - } - - #shortCut - { - padding-top: 10px; - font-weight: bolder; - color: #b0adab; - } - - #shortCut ul - { - list-style-type: none; - float: left; - width: 347px; - margin-left: 100px; - } - - #shortCut li - { - display: inline-block; - margin-right: 25px; - float: left; - white-space: nowrap; - } - - #shortCut li a - { - color: #b0adab; - text-decoration: none; - } - - #shortCut li a:hover - { - color: #44a51c; - text-decoration: none; - } - - - /* end of header elements */ - hr { background-color: #e0e0e0; @@ -745,228 +652,111 @@ text-align: left; margin: 15px 0px 15px 0px; } + .content .alignedsummary { margin: 15px; } - - table.valuelist - { - border-width: 0px 0px 1px 0px; - border-style: solid; - border-color: #b0adab; - border-collapse: collapse; - background-color: #f0f0f0; /* border-bottom: solid 1px #b0adab;*/ - } - - table.valuelist th - { - border-width: 0px 0px 0px 0px; - padding: 4px; - color: #00732F; - font: 600 10pt/1 Verdana; - } - - table.generic, table.annotated + /* tables */ + table, pre { - border: none; - padding-left: 15px; - padding-right: 15px; - margin-bottom: 15px; - } - - - table td.memItemLeft - { - width: 180px; - padding: 2px 0px 0px 8px; - margin: 4px; - border-width: 1px; - border-color: #b0adab; - border-style: none; - font-size: 100%; - white-space: nowrap; - } - - table td.memItemRight - { - padding: 2px 8px 0px 8px; - margin: 4px; - border-width: 1px; - border-color: #b0adab; - border-style: none; - font-size: 100%; + -moz-border-radius: 7px 7px 7px 7px; + background-color: #F6F6F6; + border: 1px solid #E6E6E6; + border-collapse: separate; + font-size: 11px; + min-width: 395px; + margin-bottom: 25px; } - + thead{margin-top: 5px;} + th{ padding: 3px 15px 3px 15px;} + td{padding: 3px 15px 3px 20px;} table tr.odd { - background: #EBEBEB; + border-left: 1px solid #E6E6E6; + background-color: #F6F6F6; color: #66666E; } - table tr.even { - background: #F4F4F4; + border-left: 1px solid #E6E6E6; + background-color: #ffffff; color: #66666E; } - - table.annotated th + table tr.odd:hover { - padding: 3px; - text-align: left; + background-color: #E6E6E6; } - - table td, table th + table tr.even:hover { - padding: 3px; /* border:solid 1px #FFFFFF;*/ + background-color: #E6E6E6; } - - table tr pre - { - padding-top: 0px; - padding-bottom: 0px; - padding-left: 0px; - padding-right: 0px; - border: none; - background: none; - } - - tr.qt-style /* change me - widgets-sliders.html*/ - { - background: #BCBCBC; - border-bottom: solid 1px #b0adab; - } - - table tr.qt-code pre /* investigate */ - { - padding: 0.2em; - border: #e7e7e7 1px solid; - background: #f1f1f1; - color: black; - } - - span.preprocessor, span.preprocessor a - { - color: darkblue; - } - span.comment { - color: darkred; + color: #8B0000; font-style: italic; } - span.string, span.char { - color: darkgreen; + color: #254117; } - - .subtitle + pre { - font-size: 13px; + -moz-border-radius:7px 7px 7px 7px; + background-color:#F6F6F6; + border:1px solid #DDDDDD; + margin:0 20px 10px 10px; + padding:20px 15px 20px 20px; + overflow-x:auto; } - - .small-subtitle - { - font-size: 13px; - } - - .qmlitem - { - padding: 0; - } - - .qmlname - { - white-space: nowrap; - } - .qmltype { text-align: center; font-size: 160%; } - - .qmlproto - { - background-color: #eee; - border-width: 1px; - border-style: solid; - border-color: #ddd; - font-weight: bold; - padding: 6px 10px 6px 10px; - margin: 42px 0px 0px 0px; - } - .qmlreadonly { float: right; - color: red; - } - - .qmldoc - { + color: #254117; } - - *.qmlitem p - { - } - - - thead - { - margin-top: 5px; - } - - td - { - padding: 5px; - } - th - { - padding: 5px; - } - - #feedbackBox { - display: none; - position: fixed; + display:none; + -moz-border-radius:7px 7px 7px 7px; + border:1px solid #DDDDDD; + position:fixed; + top:100px; left: 33%; - bottom: 200px; height: 190px; width: 400px; padding: 5px; background-color: #e6e7e8; z-index: 4; } - #feedcloseX a { - padding-top: 5px; - padding-right: 5px; - color: #333333; + display:inline; + padding: 5px 5px 0 0; + margin-bottom:3px; + color: #363534; + font-weight:600; float: right; text-decoration: none; } - #feedbox + /* here */ { - float: none; - width: 350px; + display:inline; + width: 370px; height: 120px; - margin-top: 5px; - margin-left: 25px; - margin-right: 25px; + margin:0px 25px 10px 15px; } - #feedsubmit { - float: right; - margin-top: 4px; - margin-right: 22px; + display:inline; + float:right; + margin:4px 32px 0 0; } - #blurpage { display: none; @@ -979,74 +769,83 @@ background: transparent url(../images/feedbackground.png) 0 0; z-index: 3; } - /* page elements */ .toc { - float: right; - border: solid 1px #666600; - background-color: #FFFFCC; - margin: 15px; + float: right; + -moz-border-radius:7px 7px 7px 7px; + background-color:#F6F6F6; + border:1px solid #DDDDDD; + margin:0 20px 10px 10px; + padding:20px 15px 20px 20px; height: auto; width: 200px; } + .toc h3 + { + font:600 12px/1.2 Arial; + } + .toc ul { float: left; padding: 15px; + } + .content .toc li { - font: normal 13px/1.2 Verdana; + font: normal 10px/1.2 Verdana; + background: url(../images/bullet_dn.png) no-repeat 0 5px; } - - .relpage /* edit */ + + .relpage { + -moz-border-radius: 7px 7px 7px 7px; + border: 1px solid #DDDDDD; + padding: 25px 25px; clear:both; - border: solid 1px #666600; - background-color: #FFFFCC; - height: auto; - width: 100%; - } - .relpage ul - { - float:none; + } + .relpage ul + { + float: none; padding: 15px; - - } - .relpage li - { - font: normal 13px/1.2 Verdana; - - } -/* edit */ + } + .content .relpage li + { + font: normal 11px/1.2 Verdana; + } + /* edit */ h3.fn, span.fn { - background-color: #eee; + background-color: #F6F6F6; border-width: 1px; border-style: solid; - border-color: #ddd; - font-weight: bold; - /* padding: 6px 0px 6px 10px;*/ - /* margin: 42px 0px 0px 0px;*/ + border-color: #E6E6E6; + font-weight: bold; + /* padding: 6px 0px 6px 10px;*/ + /* margin: 42px 0px 0px 0px;*/ } /* edit */ .indexbox { - /* max-width:785px;*/ - width: 100%; /* margin-bottom: 30px;*/ + width: 100%; + } + .content .indexboxcont li + { + font: normal 600 13px/1 Verdana; } - .indexbox a + /* .indexbox a { color: #00732f; text-decoration: none; - } - .indexbox a:hover + }*/ + .indexbox a:hover, .indexbox a:visited:hover { - color: #00732f; + color: #4c0033; text-decoration: underline; } .indexbox a:visited @@ -1062,14 +861,14 @@ .indexboxbar { - background: transparent url( "../images/horBar.png" ) repeat-x left bottom; + background: transparent url( "../images/horBar.png" ) repeat-x left bottom; margin-bottom: 25px; } .indexboxcont .section { - display: inline-block; /*Pål padding-right: 20px; padding-left: 10px; */ - width: 49%; + display: inline-block; + width: 49%; *width:42%; _width:42%; padding:0 2% 0 1%; @@ -1078,14 +877,13 @@ .indexboxcont .indexIcon { - /*PÅL width: 115px;*/ - width: 13%; + width: 11%; *width:18%; _width:18%; overflow:hidden; } .indexboxcont .section p - { /*PÅL max-width: 350px;*/ + { padding-top: 20px; padding-bottom: 20px; } @@ -1093,37 +891,40 @@ .indexboxcont .sectionlist { display: inline-block; - width: 34%; - margin-right:-2px; - vertical-align:top; + width: 33%; + margin-right: -2px; + vertical-align: top; padding: 0; } .tricol { - /* margin-left: 10px; *//*PÅL padding-right:76px;*/ + } .indexboxcont .sectionlist ul { + padding-left: 15px; margin-bottom: 20px; } - +/* .indexboxcont .sectionlist ul li { line-height: 12px; } - +*/ .lastcol { display: inline-block; - vertical-align:top; + vertical-align: top; padding: 0; max-width: 25%; } .tricol .lastcol { + margin-left:-6px; } + /*.toc ul*/ /* end page elements */ } diff --git a/tools/qdoc3/test/qt-defines.qdocconf b/tools/qdoc3/test/qt-defines.qdocconf index e1a008e..faf3906 100644 --- a/tools/qdoc3/test/qt-defines.qdocconf +++ b/tools/qdoc3/test/qt-defines.qdocconf @@ -29,6 +29,8 @@ extraimages.HTML = qt-logo \ bg_ll_blank.png \ bg_ur.png \ bullet_sq.png \ + bullet_dn.png \ + bullet_up.png \ page_bg.png \ qt_tools.png \ api_topics.png \ diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 5bb4382..67a25f3 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -103,7 +103,7 @@ HTML.postheader = "
\n" \ "
\n" HTML.footer = "
\n" \ - "
\n" \ + "
\n" \ " [+] Documentation Feedback
\n" \ "
\n" \ "
\n" \ @@ -113,20 +113,20 @@ HTML.footer = "
\n" \ "
\n" \ "
\n" \ "

\n" \ - " © 2008-2010 Nokia Corporation and/or its>\n" \ + " © 2008-2010 Nokia Corporation and/or its\n" \ " subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation>\n" \ " in Finland and/or other countries worldwide.

\n" \ "

\n" \ - " All other trademarks are property of their respective owners. \n" \ + " All other trademarks are property of their respective owners. Privacy Policy

\n" \ "
\n" \ "
\n" \ "
\n" \ "
\n" \ - " X\n" \ + " X\n" \ "
\n" \ " \n" \ - " \n" \ + " \n" \ "
\n" \ "
\n" \ @@ -134,12 +134,12 @@ HTML.footer = " \n" \ " \n" \ " \n" \ "\n" diff --git a/tools/qdoc3/test/scripts/functions.js b/tools/qdoc3/test/scripts/functions.js new file mode 100644 index 0000000..0135427 --- /dev/null +++ b/tools/qdoc3/test/scripts/functions.js @@ -0,0 +1,60 @@ + +/* START non link areas where cursor should change to pointing hand */ +$('.t_button').mouseover(function() { + $('.t_button').css('cursor','pointer'); + /*document.getElementById(this.id).style.cursor='pointer';*/ +}); + +/* END non link areas */ +$('#smallA').click(function() { + $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('font-size','smaller'); + $('.t_button').removeClass('active') + $(this).addClass('active') +}); + +$('#medA').click(function() { + $('.content .heading').css('font','600 16px/1 Arial'); + $('.content h1').css('font','600 18px/1.2 Arial'); + $('.content h2').css('font','600 16px/1.2 Arial'); + $('.content h3').css('font','600 14px/1.2 Arial'); + $('.content p').css('font','13px/20px Verdana'); + $('.content li').css('font','400 13px/1 Verdana'); + $('.content li').css('line-height','14px'); + $('.content table').css('font','13px/1.2 Verdana'); + $('.content .heading').css('font','600 16px/1 Arial'); + $('.content .indexboxcont li').css('font','600 13px/1 Verdana'); + $('.t_button').removeClass('active') + $(this).addClass('active') +}); + +$('#bigA').click(function() { + $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('font-size','large'); + $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('line-height','25px'); + $('.t_button').removeClass('active') + $(this).addClass('active') +}); + +function doSearch(str){ + +if (str.length>3) + { + alert('start search'); + // document.getElementById("refWrapper").innerHTML=""; + return; + } + else + return; + +// var url="indexSearch.php"; +// url=url+"?q="+str; + // url=url+"&sid="+Math.random(); + // var url="http://localhost:8983/solr/select?"; + // url=url+"&q="+str; + // url=url+"&fq=&start=0&rows=10&fl=&qt=&wt=&explainOther=&hl.fl="; + + // $.get(url, function(data){ + // alert(data); + // document.getElementById("refWrapper").innerHTML=data; + //}); + +} \ No newline at end of file diff --git a/tools/qdoc3/test/scripts/jquery.js b/tools/qdoc3/test/scripts/jquery.js new file mode 100644 index 0000000..0c7294c --- /dev/null +++ b/tools/qdoc3/test/scripts/jquery.js @@ -0,0 +1,152 @@ +/*! + * jQuery JavaScript Library v1.4.1 + * http://jquery.com/ + * + * Copyright 2010, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2010, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Mon Jan 25 19:43:33 2010 -0500 + */ +(function(z,v){function la(){if(!c.isReady){try{r.documentElement.doScroll("left")}catch(a){setTimeout(la,1);return}c.ready()}}function Ma(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,i){var j=a.length;if(typeof b==="object"){for(var n in b)X(a,n,b[n],f,e,d);return a}if(d!==v){f=!i&&f&&c.isFunction(d);for(n=0;n-1){i=j.data;i.beforeFilter&&i.beforeFilter[a.type]&&!i.beforeFilter[a.type](a)||f.push(j.selector)}else delete x[o]}i=c(a.target).closest(f, +a.currentTarget);m=0;for(s=i.length;m)[^>]*$|^#([\w-]+)$/,Qa=/^.[^:#\[\.,]*$/,Ra=/\S/,Sa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Ta=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,O=navigator.userAgent, +va=false,P=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,Q=Array.prototype.slice,wa=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(typeof a==="string")if((d=Pa.exec(a))&&(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:r;if(a=Ta.exec(a))if(c.isPlainObject(b)){a=[r.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=ra([d[1]], +[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}}else{if(b=r.getElementById(d[2])){if(b.id!==d[2])return S.find(a);this.length=1;this[0]=b}this.context=r;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=r;a=r.getElementsByTagName(a)}else return!b||b.jquery?(b||S).find(a):c(b).find(a);else if(c.isFunction(a))return S.ready(a);if(a.selector!==v){this.selector=a.selector;this.context=a.context}return c.isArray(a)?this.setArray(a):c.makeArray(a, +this)},selector:"",jquery:"1.4.1",length:0,size:function(){return this.length},toArray:function(){return Q.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){a=c(a||null);a.prevObject=this;a.context=this.context;if(b==="find")a.selector=this.selector+(this.selector?" ":"")+d;else if(b)a.selector=this.selector+"."+b+"("+d+")";return a},setArray:function(a){this.length=0;ba.apply(this,a);return this},each:function(a,b){return c.each(this, +a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(r,c);else P&&P.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(Q.apply(this,arguments),"slice",Q.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice}; +c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,i,j,n;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b
a";var e=d.getElementsByTagName("*"),i=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!i)){c.support= +{leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(i.getAttribute("style")),hrefNormalized:i.getAttribute("href")==="/a",opacity:/^0.55$/.test(i.style.opacity),cssFloat:!!i.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:r.createElement("select").appendChild(r.createElement("option")).selected,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null}; +b.type="text/javascript";try{b.appendChild(r.createTextNode("window."+f+"=1;"))}catch(j){}a.insertBefore(b,a.firstChild);if(z[f]){c.support.scriptEval=true;delete z[f]}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function n(){c.support.noCloneEvent=false;d.detachEvent("onclick",n)});d.cloneNode(true).fireEvent("onclick")}d=r.createElement("div");d.innerHTML="";a=r.createDocumentFragment();a.appendChild(d.firstChild); +c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var n=r.createElement("div");n.style.width=n.style.paddingLeft="1px";r.body.appendChild(n);c.boxModel=c.support.boxModel=n.offsetWidth===2;r.body.removeChild(n).style.display="none"});a=function(n){var o=r.createElement("div");n="on"+n;var m=n in o;if(!m){o.setAttribute(n,"return;");m=typeof o[n]==="function"}return m};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=i=null}})();c.props= +{"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ua=0,xa={},Va={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==z?xa:a;var f=a[G],e=c.cache;if(!b&&!f)return null;f||(f=++Ua);if(typeof b==="object"){a[G]=f;e=e[f]=c.extend(true, +{},b)}else e=e[f]?e[f]:typeof d==="undefined"?Va:(e[f]={});if(d!==v){a[G]=f;e[b]=d}return typeof b==="string"?e[b]:e}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==z?xa:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{try{delete a[G]}catch(i){a.removeAttribute&&a.removeAttribute(G)}delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this, +a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===v){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===v&&this.length)f=c.data(this[0],a);return f===v&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d); +return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===v)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]|| +a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var ya=/[\n\t]/g,ca=/\s+/,Wa=/\r/g,Xa=/href|src|style/,Ya=/(button|input)/i,Za=/(button|input|object|select|textarea)/i,$a=/^(a|area)$/i,za=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(o){var m= +c(this);m.addClass(a.call(this,o,m.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d-1)return true;return false},val:function(a){if(a===v){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value|| +{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var i=b?d:0;for(d=b?d+1:e.length;i=0;else if(c.nodeName(this,"select")){var x=c.makeArray(s);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),x)>=0});if(!x.length)this.selectedIndex=-1}else this.value=s}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return v;if(f&&b in c.attrFn)return c(a)[b](d); +f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==v;b=f&&c.props[b]||b;if(a.nodeType===1){var i=Xa.test(b);if(b in a&&f&&!i){if(e){b==="type"&&Ya.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:Za.test(a.nodeName)||$a.test(a.nodeName)&&a.href?0:v;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText= +""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&i?a.getAttribute(b,2):a.getAttribute(b);return a===null?v:a}return c.style(a,b,d)}});var ab=function(a){return a.replace(/[^\w\s\.\|`]/g,function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==z&&!a.frameElement)a=z;if(!d.guid)d.guid=c.guid++;if(f!==v){d=c.proxy(d);d.data=f}var e=c.data(a,"events")||c.data(a,"events",{}),i=c.data(a,"handle"),j;if(!i){j= +function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(j.elem,arguments):v};i=c.data(a,"handle",j)}if(i){i.elem=a;b=b.split(/\s+/);for(var n,o=0;n=b[o++];){var m=n.split(".");n=m.shift();if(o>1){d=c.proxy(d);if(f!==v)d.data=f}d.type=m.slice(0).sort().join(".");var s=e[n],x=this.special[n]||{};if(!s){s=e[n]={};if(!x.setup||x.setup.call(a,f,m,d)===false)if(a.addEventListener)a.addEventListener(n,i,false);else a.attachEvent&&a.attachEvent("on"+n,i)}if(x.add)if((m=x.add.call(a, +d,f,m,s))&&c.isFunction(m)){m.guid=m.guid||d.guid;m.data=m.data||d.data;m.type=m.type||d.type;d=m}s[d.guid]=d;this.global[n]=true}a=null}}},global:{},remove:function(a,b,d){if(!(a.nodeType===3||a.nodeType===8)){var f=c.data(a,"events"),e,i,j;if(f){if(b===v||typeof b==="string"&&b.charAt(0)===".")for(i in f)this.remove(a,i+(b||""));else{if(b.type){d=b.handler;b=b.type}b=b.split(/\s+/);for(var n=0;i=b[n++];){var o=i.split(".");i=o.shift();var m=!o.length,s=c.map(o.slice(0).sort(),ab);s=new RegExp("(^|\\.)"+ +s.join("\\.(?:.*\\.)?")+"(\\.|$)");var x=this.special[i]||{};if(f[i]){if(d){j=f[i][d.guid];delete f[i][d.guid]}else for(var A in f[i])if(m||s.test(f[i][A].type))delete f[i][A];x.remove&&x.remove.call(a,o,j);for(e in f[i])break;if(!e){if(!x.teardown||x.teardown.call(a,o)===false)if(a.removeEventListener)a.removeEventListener(i,c.data(a,"handle"),false);else a.detachEvent&&a.detachEvent("on"+i,c.data(a,"handle"));e=null;delete f[i]}}}}for(e in f)break;if(!e){if(A=c.data(a,"handle"))A.elem=null;c.removeData(a, +"events");c.removeData(a,"handle")}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();this.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return v;a.result=v;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d, +b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(i){}if(!a.isPropagationStopped()&&f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){d=a.target;var j;if(!(c.nodeName(d,"a")&&e==="click")&&!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()])){try{if(d[e]){if(j=d["on"+e])d["on"+e]=null;this.triggered=true;d[e]()}}catch(n){}if(j)d["on"+e]=j;this.triggered=false}}},handle:function(a){var b, +d;a=arguments[0]=c.event.fix(a||z.event);a.currentTarget=this;d=a.type.split(".");a.type=d.shift();b=!d.length&&!a.exclusive;var f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)");d=(c.data(this,"events")||{})[a.type];for(var e in d){var i=d[e];if(b||f.test(i.type)){a.handler=i;a.data=i.data;i=i.apply(this,arguments);if(i!==v){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), +fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||r;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=r.documentElement;d=r.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop|| +d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==v)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a,b){c.extend(a,b||{});a.guid+=b.selector+b.live;b.liveProxy=a;c.event.add(this,b.live,na,b)},remove:function(a){if(a.length){var b= +0,d=new RegExp("(^|\\.)"+a[0]+"(\\.|$)");c.each(c.data(this,"events").live||{},function(){d.test(this.type)&&b++});b<1&&c.event.remove(this,a[0],na)}},special:{}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true}; +c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,isImmediatePropagationStopped:Y};var Aa=function(a){for(var b= +a.relatedTarget;b&&b!==this;)try{b=b.parentNode}catch(d){break}if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}},Ba=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ba:Aa,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ba:Aa)}}});if(!c.support.submitBubbles)c.event.special.submit={setup:function(a,b,d){if(this.nodeName.toLowerCase()!== +"form"){c.event.add(this,"click.specialSubmit."+d.guid,function(f){var e=f.target,i=e.type;if((i==="submit"||i==="image")&&c(e).closest("form").length)return ma("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit."+d.guid,function(f){var e=f.target,i=e.type;if((i==="text"||i==="password")&&c(e).closest("form").length&&f.keyCode===13)return ma("submit",this,arguments)})}else return false},remove:function(a,b){c.event.remove(this,"click.specialSubmit"+(b?"."+b.guid:""));c.event.remove(this, +"keypress.specialSubmit"+(b?"."+b.guid:""))}};if(!c.support.changeBubbles){var da=/textarea|input|select/i;function Ca(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d}function ea(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Ca(d);if(a.type!=="focusout"|| +d.type!=="radio")c.data(d,"_change_data",e);if(!(f===v||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}}c.event.special.change={filters:{focusout:ea,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return ea.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return ea.call(this,a)},beforeactivate:function(a){a= +a.target;a.nodeName.toLowerCase()==="input"&&a.type==="radio"&&c.data(a,"_change_data",Ca(a))}},setup:function(a,b,d){for(var f in T)c.event.add(this,f+".specialChange."+d.guid,T[f]);return da.test(this.nodeName)},remove:function(a,b){for(var d in T)c.event.remove(this,d+".specialChange"+(b?"."+b.guid:""),T[d]);return da.test(this.nodeName)}};var T=c.event.special.change.filters}r.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this, +f)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var i in d)this[b](i,f,d[i],e);return this}if(c.isFunction(f)){e=f;f=v}var j=b==="one"?c.proxy(e,function(n){c(this).unbind(n,j);return e.apply(this,arguments)}):e;return d==="unload"&&b!=="one"?this.one(d,f,e):this.each(function(){c.event.add(this,d,j,f)})}});c.fn.extend({unbind:function(a, +b){if(typeof a==="object"&&!a.preventDefault){for(var d in a)this.unbind(d,a[d]);return this}return this.each(function(){c.event.remove(this,a,b)})},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},toggle:function(a){for(var b=arguments,d=1;d0){y=t;break}}t=t[g]}l[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,i=Object.prototype.toString,j=false,n=true;[0,0].sort(function(){n=false;return 0});var o=function(g,h,k,l){k=k||[];var q=h=h||r;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g|| +typeof g!=="string")return k;for(var p=[],u,t,y,R,H=true,M=w(h),I=g;(f.exec(""),u=f.exec(I))!==null;){I=u[3];p.push(u[1]);if(u[2]){R=u[3];break}}if(p.length>1&&s.exec(g))if(p.length===2&&m.relative[p[0]])t=fa(p[0]+p[1],h);else for(t=m.relative[p[0]]?[h]:o(p.shift(),h);p.length;){g=p.shift();if(m.relative[g])g+=p.shift();t=fa(g,t)}else{if(!l&&p.length>1&&h.nodeType===9&&!M&&m.match.ID.test(p[0])&&!m.match.ID.test(p[p.length-1])){u=o.find(p.shift(),h,M);h=u.expr?o.filter(u.expr,u.set)[0]:u.set[0]}if(h){u= +l?{expr:p.pop(),set:A(l)}:o.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=u.expr?o.filter(u.expr,u.set):u.set;if(p.length>0)y=A(t);else H=false;for(;p.length;){var D=p.pop();u=D;if(m.relative[D])u=p.pop();else D="";if(u==null)u=h;m.relative[D](y,u,M)}}else y=[]}y||(y=t);y||o.error(D||g);if(i.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))k.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&& +y[g].nodeType===1&&k.push(t[g]);else k.push.apply(k,y);else A(y,k);if(R){o(R,q,k,l);o.uniqueSort(k)}return k};o.uniqueSort=function(g){if(C){j=n;g.sort(C);if(j)for(var h=1;h":function(g,h){var k=typeof h==="string";if(k&&!/\W/.test(h)){h=h.toLowerCase();for(var l=0,q=g.length;l=0))k||l.push(u);else if(k)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&& +"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,k,l,q,p){h=g[1].replace(/\\/g,"");if(!p&&m.attrMap[h])g[1]=m.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,k,l,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=o(g[3],null,null,h);else{g=o.filter(g[3],h,k,true^q);k||l.push.apply(l,g);return false}else if(m.match.POS.test(g[0])||m.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true); +return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,k){return!!o(k[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"=== +g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,h){return h===0},last:function(g,h,k,l){return h===l.length-1},even:function(g,h){return h%2=== +0},odd:function(g,h){return h%2===1},lt:function(g,h,k){return hk[3]-0},nth:function(g,h,k){return k[3]-0===h},eq:function(g,h,k){return k[3]-0===h}},filter:{PSEUDO:function(g,h,k,l){var q=h[1],p=m.filters[q];if(p)return p(g,k,h,l);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=h[3];k=0;for(l=h.length;k= +0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var k=h[1];g=m.attrHandle[k]?m.attrHandle[k](g):g[k]!=null?g[k]:g.getAttribute(k);k=g+"";var l=h[2];h=h[4];return g==null?l==="!=":l==="="?k===h:l==="*="?k.indexOf(h)>=0:l==="~="?(" "+k+" ").indexOf(h)>=0:!h?k&&g!==false:l==="!="?k!==h:l==="^="? +k.indexOf(h)===0:l==="$="?k.substr(k.length-h.length)===h:l==="|="?k===h||k.substr(0,h.length+1)===h+"-":false},POS:function(g,h,k,l){var q=m.setFilters[h[2]];if(q)return q(g,k,h,l)}}},s=m.match.POS;for(var x in m.match){m.match[x]=new RegExp(m.match[x].source+/(?![^\[]*\])(?![^\(]*\))/.source);m.leftMatch[x]=new RegExp(/(^(?:.|\r|\n)*?)/.source+m.match[x].source.replace(/\\(\d+)/g,function(g,h){return"\\"+(h-0+1)}))}var A=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g}; +try{Array.prototype.slice.call(r.documentElement.childNodes,0)}catch(B){A=function(g,h){h=h||[];if(i.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var k=0,l=g.length;k";var k=r.documentElement;k.insertBefore(g,k.firstChild);if(r.getElementById(h)){m.find.ID=function(l,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(l[1]))?q.id===l[1]||typeof q.getAttributeNode!=="undefined"&&q.getAttributeNode("id").nodeValue===l[1]?[q]:v:[]};m.filter.ID=function(l,q){var p=typeof l.getAttributeNode!=="undefined"&&l.getAttributeNode("id"); +return l.nodeType===1&&p&&p.nodeValue===q}}k.removeChild(g);k=g=null})();(function(){var g=r.createElement("div");g.appendChild(r.createComment(""));if(g.getElementsByTagName("*").length>0)m.find.TAG=function(h,k){k=k.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var l=0;k[l];l++)k[l].nodeType===1&&h.push(k[l]);k=h}return k};g.innerHTML="";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")m.attrHandle.href=function(h){return h.getAttribute("href", +2)};g=null})();r.querySelectorAll&&function(){var g=o,h=r.createElement("div");h.innerHTML="

";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){o=function(l,q,p,u){q=q||r;if(!u&&q.nodeType===9&&!w(q))try{return A(q.querySelectorAll(l),p)}catch(t){}return g(l,q,p,u)};for(var k in g)o[k]=g[k];h=null}}();(function(){var g=r.createElement("div");g.innerHTML="
";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length=== +0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){m.order.splice(1,0,"CLASS");m.find.CLASS=function(h,k,l){if(typeof k.getElementsByClassName!=="undefined"&&!l)return k.getElementsByClassName(h[1])};g=null}}})();var E=r.compareDocumentPosition?function(g,h){return g.compareDocumentPosition(h)&16}:function(g,h){return g!==h&&(g.contains?g.contains(h):true)},w=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},fa=function(g,h){var k=[], +l="",q;for(h=h.nodeType?[h]:h;q=m.match.PSEUDO.exec(g);){l+=q[0];g=g.replace(m.match.PSEUDO,"")}g=m.relative[g]?g+"*":g;q=0;for(var p=h.length;q=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f0)for(var i=d;i0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,i={},j;if(f&&a.length){e=0;for(var n=a.length;e +-1:c(f).is(e)){d.push({selector:j,elem:f});delete i[j]}}f=f.parentNode}}return d}var o=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(m,s){for(;s&&s.ownerDocument&&s!==b;){if(o?o.index(s)>-1:c(s).is(a))return s;s=s.parentNode}return null})},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(), +a);return this.pushStack(pa(a[0])||pa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")}, +nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);bb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e): +e;if((this.length>1||db.test(f))&&cb.test(a))e=e.reverse();return this.pushStack(e,a,Q.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===v||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!== +b&&d.push(a);return d}});var Fa=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ga=/(<([\w:]+)[^>]*?)\/>/g,eb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,Ha=/<([\w:]+)/,fb=/"},F={option:[1,""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"], +col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div
","
"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==v)return this.empty().append((this[0]&&this[0].ownerDocument||r).createTextNode(a));return c.getText(this)}, +wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length? +d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments, +false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&& +!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Fa,"").replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){qa(this,b);qa(this.find("*"),b.find("*"))}return b},html:function(a){if(a===v)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Fa,""):null;else if(typeof a==="string"&&!/\n"; out() << " \n"; out() << "\n"; - -#if 0 - out() << "\n"; - out() << QString("\n").arg(naturalLanguage); - - QString shortVersion; - if ((project != "Qtopia") && (project != "Qt Extended")) { - shortVersion = project + " " + shortVersion + ": "; - if (node && !node->doc().location().isEmpty()) - out() << "\n"; - - shortVersion = myTree->version(); - if (shortVersion.count(QChar('.')) == 2) - shortVersion.truncate(shortVersion.lastIndexOf(QChar('.'))); - if (!shortVersion.isEmpty()) { - if (project == "QSA") - shortVersion = "QSA " + shortVersion + ": "; - else - shortVersion = "Qt " + shortVersion + ": "; - } - } - - out() << "\n" - " " << shortVersion << protectEnc(title) << "\n"; - out() << QString("").arg(outputEncoding); - - if (!style.isEmpty()) - out() << " \n"; - - const QMap &metaMap = node->doc().metaTagMap(); - if (!metaMap.isEmpty()) { - QMapIterator i(metaMap); - while (i.hasNext()) { - i.next(); - out() << " \n"; - } - } - - navigationLinks.clear(); - - if (node && !node->links().empty()) { - QPair linkPair; - QPair anchorPair; - const Node *linkNode; - - if (node->links().contains(Node::PreviousLink)) { - linkPair = node->links()[Node::PreviousLink]; - linkNode = findNodeForTarget(linkPair.first, node, marker); - if (!linkNode || linkNode == node) - anchorPair = linkPair; - else - anchorPair = anchorForNode(linkNode); - - out() << " \n"; - - navigationLinks += "[Previous: "; - if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty()) - navigationLinks += protectEnc(anchorPair.second); - else - navigationLinks += protectEnc(linkPair.second); - navigationLinks += "]\n"; - } - if (node->links().contains(Node::ContentsLink)) { - linkPair = node->links()[Node::ContentsLink]; - linkNode = findNodeForTarget(linkPair.first, node, marker); - if (!linkNode || linkNode == node) - anchorPair = linkPair; - else - anchorPair = anchorForNode(linkNode); - - out() << " \n"; - - navigationLinks += "["; - if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty()) - navigationLinks += protectEnc(anchorPair.second); - else - navigationLinks += protectEnc(linkPair.second); - navigationLinks += "]\n"; - } - if (node->links().contains(Node::NextLink)) { - linkPair = node->links()[Node::NextLink]; - linkNode = findNodeForTarget(linkPair.first, node, marker); - if (!linkNode || linkNode == node) - anchorPair = linkPair; - else - anchorPair = anchorForNode(linkNode); - - out() << " \n"; - - navigationLinks += "[Next: "; - if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty()) - navigationLinks += protectEnc(anchorPair.second); - else - navigationLinks += protectEnc(linkPair.second); - navigationLinks += "]\n"; - } - if (node->links().contains(Node::IndexLink)) { - linkPair = node->links()[Node::IndexLink]; - linkNode = findNodeForTarget(linkPair.first, node, marker); - if (!linkNode || linkNode == node) - anchorPair = linkPair; - else - anchorPair = anchorForNode(linkNode); - out() << " \n"; - } - if (node->links().contains(Node::StartLink)) { - linkPair = node->links()[Node::StartLink]; - linkNode = findNodeForTarget(linkPair.first, node, marker); - if (!linkNode || linkNode == node) - anchorPair = linkPair; - else - anchorPair = anchorForNode(linkNode); - out() << " \n"; - } - } - - foreach (const QString &stylesheet, stylesheets) { - out() << " \n"; - } - foreach (const QString &customHeadElement, customHeadElements) { - out() << " " << customHeadElement << "\n"; - } - - out() << "\n" - #endif + if (offlineDocs) + out() << "\n"; + else out() << "\n"; + if (mainPage) generateMacRef(node, marker); out() << QString(postHeader).replace("\\" + COMMAND_VERSION, myTree->version()); -#if 0 +#if 0 // Removed for new docf format. MWS if (node && !node->links().empty()) out() << "

\n" << navigationLinks << "

\n"; #endif @@ -4375,8 +4254,6 @@ void HtmlGenerator::endLink() inObsoleteLink = false; } -QT_END_NAMESPACE - #ifdef QDOC_QML /*! @@ -4728,3 +4605,139 @@ void HtmlGenerator::generatePageIndex(const QString& fileName, CodeMarker* marke } #endif + +#if 0 // fossil removed for new doc format MWS 19/04/2010 + out() << "\n"; + out() << QString("\n").arg(naturalLanguage); + + QString shortVersion; + if ((project != "Qtopia") && (project != "Qt Extended")) { + shortVersion = project + " " + shortVersion + ": "; + if (node && !node->doc().location().isEmpty()) + out() << "\n"; + + shortVersion = myTree->version(); + if (shortVersion.count(QChar('.')) == 2) + shortVersion.truncate(shortVersion.lastIndexOf(QChar('.'))); + if (!shortVersion.isEmpty()) { + if (project == "QSA") + shortVersion = "QSA " + shortVersion + ": "; + else + shortVersion = "Qt " + shortVersion + ": "; + } + } + + out() << "\n" + " " << shortVersion << protectEnc(title) << "\n"; + out() << QString("").arg(outputEncoding); + + if (!style.isEmpty()) + out() << " \n"; + + const QMap &metaMap = node->doc().metaTagMap(); + if (!metaMap.isEmpty()) { + QMapIterator i(metaMap); + while (i.hasNext()) { + i.next(); + out() << " \n"; + } + } + + navigationLinks.clear(); + + if (node && !node->links().empty()) { + QPair linkPair; + QPair anchorPair; + const Node *linkNode; + + if (node->links().contains(Node::PreviousLink)) { + linkPair = node->links()[Node::PreviousLink]; + linkNode = findNodeForTarget(linkPair.first, node, marker); + if (!linkNode || linkNode == node) + anchorPair = linkPair; + else + anchorPair = anchorForNode(linkNode); + + out() << " \n"; + + navigationLinks += "[Previous: "; + if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty()) + navigationLinks += protectEnc(anchorPair.second); + else + navigationLinks += protectEnc(linkPair.second); + navigationLinks += "]\n"; + } + if (node->links().contains(Node::ContentsLink)) { + linkPair = node->links()[Node::ContentsLink]; + linkNode = findNodeForTarget(linkPair.first, node, marker); + if (!linkNode || linkNode == node) + anchorPair = linkPair; + else + anchorPair = anchorForNode(linkNode); + + out() << " \n"; + + navigationLinks += "["; + if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty()) + navigationLinks += protectEnc(anchorPair.second); + else + navigationLinks += protectEnc(linkPair.second); + navigationLinks += "]\n"; + } + if (node->links().contains(Node::NextLink)) { + linkPair = node->links()[Node::NextLink]; + linkNode = findNodeForTarget(linkPair.first, node, marker); + if (!linkNode || linkNode == node) + anchorPair = linkPair; + else + anchorPair = anchorForNode(linkNode); + + out() << " \n"; + + navigationLinks += "[Next: "; + if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty()) + navigationLinks += protectEnc(anchorPair.second); + else + navigationLinks += protectEnc(linkPair.second); + navigationLinks += "]\n"; + } + if (node->links().contains(Node::IndexLink)) { + linkPair = node->links()[Node::IndexLink]; + linkNode = findNodeForTarget(linkPair.first, node, marker); + if (!linkNode || linkNode == node) + anchorPair = linkPair; + else + anchorPair = anchorForNode(linkNode); + out() << " \n"; + } + if (node->links().contains(Node::StartLink)) { + linkPair = node->links()[Node::StartLink]; + linkNode = findNodeForTarget(linkPair.first, node, marker); + if (!linkNode || linkNode == node) + anchorPair = linkPair; + else + anchorPair = anchorForNode(linkNode); + out() << " \n"; + } + } + + foreach (const QString &stylesheet, stylesheets) { + out() << " \n"; + } + + foreach (const QString &customHeadElement, customHeadElements) { + out() << " " << customHeadElement << "\n"; + } + + out() << "\n" + #endif + + QT_END_NAMESPACE diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index 559c968..2a365e9 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -297,6 +297,7 @@ class HtmlGenerator : public PageGenerator bool inTableHeader; int numTableRows; bool threeColumnEnumValueTable; + bool offlineDocs; QString link; QStringList sectionNumber; QRegExp funcLeftParen; diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf index cc3e436..ef6fe97 100644 --- a/tools/qdoc3/test/qt.qdocconf +++ b/tools/qdoc3/test/qt.qdocconf @@ -9,6 +9,7 @@ versionsym = version = %VERSION% description = Qt Reference Documentation url = http://qt.nokia.com/doc/4.7 +online = true sourceencoding = UTF-8 outputencoding = UTF-8 -- cgit v0.12 From d66a6da84af01f1a6d4fd52d9b1cbec72a4fae3c Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 20 Apr 2010 13:02:51 +1000 Subject: Make offline docs the default for package generation. Acked-by: Martin Smith --- tools/qdoc3/test/qt.qdocconf | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf index ef6fe97..cc3e436 100644 --- a/tools/qdoc3/test/qt.qdocconf +++ b/tools/qdoc3/test/qt.qdocconf @@ -9,7 +9,6 @@ versionsym = version = %VERSION% description = Qt Reference Documentation url = http://qt.nokia.com/doc/4.7 -online = true sourceencoding = UTF-8 outputencoding = UTF-8 -- cgit v0.12 From bb0aa3c61e8c443ec4207381ca10c85f6c4b6665 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 20 Apr 2010 10:34:03 +0200 Subject: Fix crash on startup on Symbian OS The changes to QThread introduced by commit 9aa4538b219ed759a47e8d1f93c2797bf07b5e2f mean that the QThread constructor calls into the event dispatcher. The Symbian event dispatcher owns a QThread, so it crashed when the code re-entered the partially constructed event dispatcher and used an uninitialised pointer. This change delays construction of the QThread until the point of use, so that the event dispatcher is fully constructed. Task-number: QTBUG-10029 Reviewed-by: Jason Barron (cherry picked from commit 2b55d52669beb72396f94e449fdf172735349b3b) --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 20 +++++++++++++++----- src/corelib/kernel/qeventdispatcher_symbian_p.h | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index ca44264..f811361 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -632,6 +632,7 @@ void QSocketActiveObject::deleteLater() QEventDispatcherSymbian::QEventDispatcherSymbian(QObject *parent) : QAbstractEventDispatcher(parent), + m_selectThread(0), m_activeScheduler(0), m_wakeUpAO(0), m_completeDeferredAOs(0), @@ -659,11 +660,19 @@ void QEventDispatcherSymbian::startingUp() wakeUp(); } +QSelectThread& QEventDispatcherSymbian::selectThread() { + if (!m_selectThread) + m_selectThread = new QSelectThread; + return *m_selectThread; +} + void QEventDispatcherSymbian::closingDown() { - if (m_selectThread.isRunning()) { - m_selectThread.stop(); + if (m_selectThread && m_selectThread->isRunning()) { + m_selectThread->stop(); } + delete m_selectThread; + m_selectThread = 0; delete m_completeDeferredAOs; delete m_wakeUpAO; @@ -935,12 +944,13 @@ void QEventDispatcherSymbian::registerSocketNotifier ( QSocketNotifier * notifie { QSocketActiveObject *socketAO = q_check_ptr(new QSocketActiveObject(this, notifier)); m_notifiers.insert(notifier, socketAO); - m_selectThread.requestSocketEvents(notifier, &socketAO->iStatus); + selectThread().requestSocketEvents(notifier, &socketAO->iStatus); } void QEventDispatcherSymbian::unregisterSocketNotifier ( QSocketNotifier * notifier ) { - m_selectThread.cancelSocketEvents(notifier); + if (m_selectThread) + m_selectThread->cancelSocketEvents(notifier); if (m_notifiers.contains(notifier)) { QSocketActiveObject *sockObj = *m_notifiers.find(notifier); m_deferredSocketEvents.removeAll(sockObj); @@ -951,7 +961,7 @@ void QEventDispatcherSymbian::unregisterSocketNotifier ( QSocketNotifier * notif void QEventDispatcherSymbian::reactivateSocketNotifier(QSocketNotifier *notifier) { - m_selectThread.requestSocketEvents(notifier, &m_notifiers[notifier]->iStatus); + selectThread().requestSocketEvents(notifier, &m_notifiers[notifier]->iStatus); } void QEventDispatcherSymbian::registerTimer ( int timerId, int interval, QObject * object ) diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 1ab31cc..5281199 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -259,8 +259,9 @@ private: bool sendPostedEvents(); bool sendDeferredSocketEvents(); + QSelectThread& selectThread(); private: - QSelectThread m_selectThread; + QSelectThread *m_selectThread; CQtActiveScheduler *m_activeScheduler; -- cgit v0.12 From c6cb0de12b9bbb71690a0b6d5c53b2329767f2a4 Mon Sep 17 00:00:00 2001 From: kh1 Date: Mon, 19 Apr 2010 18:59:32 +0200 Subject: Quick fix to make the documentation work, needs a proper solution though. Reviewed-by: kh (cherry picked from commit 0fd81e81a357edb9f9e615cff28a1876bd363b2e) --- tools/assistant/tools/assistant/helpviewer.cpp | 4 ++++ tools/assistant/tools/assistant/helpviewer.h | 1 + tools/assistant/tools/assistant/helpviewer_qwv.cpp | 22 ++++++++++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 0c51a02..85e4e71 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -52,6 +52,10 @@ QT_BEGIN_NAMESPACE +QString AbstractHelpViewer::DocPath = QString::fromLatin1("qthelp://com." + "trolltech.qt.%1/").arg(QString(QLatin1String(QT_VERSION_STR)) + .replace(QLatin1String("."), QLatin1String(""))); + QString AbstractHelpViewer::AboutBlank = QCoreApplication::translate("HelpViewer", "about:blank"); diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index 6f1f48d..9c3971f 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -67,6 +67,7 @@ public: virtual bool handleForwardBackwardMouseButtons(QMouseEvent *e) = 0; + static QString DocPath; static QString AboutBlank; static QString LocalHelpFile; static QString PageNotFoundMessage; diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index db1cd58..a19b29a 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -129,13 +129,27 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, const QNetworkRequest &request, QIODevice* /*outgoingData*/) { TRACE_OBJ - const QUrl &url = request.url(); - const QString &mimeType = AbstractHelpViewer::mimeFromUrl(url.toString()); - + QString url = request.url().toString(); HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + + // TODO: For some reason the url to load is already wrong (passed from webkit) + // though the css file and the references inside should work that way. One + // possible problem might be that the css is loaded at the same level as the + // html, thus a path inside the css like (../images/foo.png) might cd out of + // the virtual folder + if (!helpEngine.findFile(url).isValid()) { + if (url.startsWith(AbstractHelpViewer::DocPath)) { + if (!url.startsWith(AbstractHelpViewer::DocPath + QLatin1String("qdoc/"))) { + url = url.replace(AbstractHelpViewer::DocPath, + AbstractHelpViewer::DocPath + QLatin1String("qdoc/")); + } + } + } + + const QString &mimeType = AbstractHelpViewer::mimeFromUrl(url); const QByteArray &data = helpEngine.findFile(url).isValid() ? helpEngine.fileData(url) - : AbstractHelpViewer::PageNotFoundMessage.arg(url.toString()).toUtf8(); + : AbstractHelpViewer::PageNotFoundMessage.arg(url).toUtf8(); return new HelpNetworkReply(request, data, mimeType.isEmpty() ? QLatin1String("application/octet-stream") : mimeType); } -- cgit v0.12 From 0c3411c051e1f59e050fcf40fd55fa2feb585d6b Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Tue, 20 Apr 2010 11:51:35 +0200 Subject: Doc: Correcting qdocconf files for assistant Linking correct files to the qdocconf files Reviewed-by: Daniel Molkentin (cherry picked from commit 84eadc0bc232d8196e08f5aa5614ce9a17ea93bd) --- tools/qdoc3/test/qt-build-docs.qdocconf | 21 ++++++++++++++------- tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf | 20 +++++++++++++------- tools/qdoc3/test/qt.qdocconf | 20 +++++++++++++------- tools/qdoc3/test/qt_zh_CN.qdocconf | 20 +++++++++++++------- 4 files changed, 53 insertions(+), 28 deletions(-) diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf index dbff4e2..0694748 100644 --- a/tools/qdoc3/test/qt-build-docs.qdocconf +++ b/tools/qdoc3/test/qt-build-docs.qdocconf @@ -22,14 +22,12 @@ qhp.Qt.indexTitle = Qt Reference Documentation # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - style/style.css \ - scripts/functions.js \ - scripts/jquery.js \ images/api_examples.png \ images/api_lookup.png \ images/api_topics.png \ - images/bg_ll.png \ images/bg_l_blank.png \ + images/bg_ll_blank.png \ + images/bg_ll.png \ images/bg_l.png \ images/bg_lr.png \ images/bg_r.png \ @@ -37,24 +35,33 @@ qhp.Qt.extraFiles = index.html \ images/bg_ul.png \ images/bg_ur_blank.png \ images/bg_ur.png \ + images/box_bg.png \ images/breadcrumb.png \ images/bullet_dn.png \ images/bullet_gt.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/coloreditorfactoryimage.png \ + images/content_bg.png \ + images/dynamiclayouts-example.png \ images/feedbackground.png \ images/form_bg.png \ images/horBar.png \ images/page_bg.png \ images/print.png \ images/qt_guide.png \ + images/qt_icon.png \ images/qt-logo.png \ images/qt_ref_doc.png \ images/qt_tools.png \ images/sep.png \ images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ images/taskmenuextension-example.png \ - images/coloreditorfactoryimage.png \ - images/dynamiclayouts-example.png \ - images/stylesheet-coffee-plastique.png + scripts/functions.js \ + scripts/jquery.js \ + style/style.css + qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc diff --git a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf index 461c069..5a3d726 100644 --- a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf @@ -30,14 +30,12 @@ qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - style/style.css \ - scripts/functions.js \ - scripts/jquery.js \ images/api_examples.png \ images/api_lookup.png \ images/api_topics.png \ - images/bg_ll.png \ images/bg_l_blank.png \ + images/bg_ll_blank.png \ + images/bg_ll.png \ images/bg_l.png \ images/bg_lr.png \ images/bg_r.png \ @@ -45,24 +43,32 @@ qhp.Qt.extraFiles = index.html \ images/bg_ul.png \ images/bg_ur_blank.png \ images/bg_ur.png \ + images/box_bg.png \ images/breadcrumb.png \ images/bullet_dn.png \ images/bullet_gt.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/coloreditorfactoryimage.png \ + images/content_bg.png \ + images/dynamiclayouts-example.png \ images/feedbackground.png \ images/form_bg.png \ images/horBar.png \ images/page_bg.png \ images/print.png \ images/qt_guide.png \ + images/qt_icon.png \ images/qt-logo.png \ images/qt_ref_doc.png \ images/qt_tools.png \ images/sep.png \ images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ images/taskmenuextension-example.png \ - images/coloreditorfactoryimage.png \ - images/dynamiclayouts-example.png \ - images/stylesheet-coffee-plastique.png + scripts/functions.js \ + scripts/jquery.js \ + style/style.css language = Cpp diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf index cc3e436..92ce9a3 100644 --- a/tools/qdoc3/test/qt.qdocconf +++ b/tools/qdoc3/test/qt.qdocconf @@ -25,14 +25,12 @@ qhp.Qt.indexRoot = # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - style/style.css \ - scripts/functions.js \ - scripts/jquery.js \ images/api_examples.png \ images/api_lookup.png \ images/api_topics.png \ - images/bg_ll.png \ images/bg_l_blank.png \ + images/bg_ll_blank.png \ + images/bg_ll.png \ images/bg_l.png \ images/bg_lr.png \ images/bg_r.png \ @@ -40,24 +38,32 @@ qhp.Qt.extraFiles = index.html \ images/bg_ul.png \ images/bg_ur_blank.png \ images/bg_ur.png \ + images/box_bg.png \ images/breadcrumb.png \ images/bullet_dn.png \ images/bullet_gt.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/coloreditorfactoryimage.png \ + images/content_bg.png \ + images/dynamiclayouts-example.png \ images/feedbackground.png \ images/form_bg.png \ images/horBar.png \ images/page_bg.png \ images/print.png \ images/qt_guide.png \ + images/qt_icon.png \ images/qt-logo.png \ images/qt_ref_doc.png \ images/qt_tools.png \ images/sep.png \ images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ images/taskmenuextension-example.png \ - images/coloreditorfactoryimage.png \ - images/dynamiclayouts-example.png \ - images/stylesheet-coffee-plastique.png + scripts/functions.js \ + scripts/jquery.js \ + style/style.css qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc qhp.Qt.customFilters.Qt.name = Qt 4.7.0 diff --git a/tools/qdoc3/test/qt_zh_CN.qdocconf b/tools/qdoc3/test/qt_zh_CN.qdocconf index c5d2c88..a5a65d8 100644 --- a/tools/qdoc3/test/qt_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt_zh_CN.qdocconf @@ -32,14 +32,12 @@ qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - style/style.css \ - scripts/functions.js \ - scripts/jquery.js \ images/api_examples.png \ images/api_lookup.png \ images/api_topics.png \ - images/bg_ll.png \ images/bg_l_blank.png \ + images/bg_ll_blank.png \ + images/bg_ll.png \ images/bg_l.png \ images/bg_lr.png \ images/bg_r.png \ @@ -47,24 +45,32 @@ qhp.Qt.extraFiles = index.html \ images/bg_ul.png \ images/bg_ur_blank.png \ images/bg_ur.png \ + images/box_bg.png \ images/breadcrumb.png \ images/bullet_dn.png \ images/bullet_gt.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/coloreditorfactoryimage.png \ + images/content_bg.png \ + images/dynamiclayouts-example.png \ images/feedbackground.png \ images/form_bg.png \ images/horBar.png \ images/page_bg.png \ images/print.png \ images/qt_guide.png \ + images/qt_icon.png \ images/qt-logo.png \ images/qt_ref_doc.png \ images/qt_tools.png \ images/sep.png \ images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ images/taskmenuextension-example.png \ - images/coloreditorfactoryimage.png \ - images/dynamiclayouts-example.png \ - images/stylesheet-coffee-plastique.png + scripts/functions.js \ + scripts/jquery.js \ + style/style.css language = Cpp -- cgit v0.12 From 034e13e765874b25b56d16c9487efd2e98fe4518 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Tue, 20 Apr 2010 15:51:04 +0200 Subject: Doc: Cleaning HTML generator and updating index.qdoc Adding links to the index page and removing HTML attributes like align and valing form the HTML generator Reviewed-by: Martin Smith (cherry picked from commit 019af5ecb5dbc9c173109ba670180177713a51ad) --- tools/qdoc3/htmlgenerator.cpp | 123 ++++++++++++++-------------- tools/qdoc3/test/qt-html-templates.qdocconf | 18 ++-- 2 files changed, 68 insertions(+), 73 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 1192daf..68c27db 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -514,14 +514,14 @@ int HtmlGenerator::generateAtom(const Atom *atom, out() << formattingRightMap()[ATOM_FORMATTING_TELETYPE]; break; case Atom::Code: - out() << "
"
+	out() << "
"
               << trimmedTrailing(highlightedCode(indent(codeIndent,atom->string()),
                                                  marker,relative))
               << "
\n"; break; #ifdef QDOC_QML case Atom::Qml: - out() << "
"
+	out() << "
"
               << trimmedTrailing(highlightedCode(indent(codeIndent,atom->string()),
                                                  marker,relative))
               << "
\n"; @@ -529,7 +529,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, #endif case Atom::CodeNew: out() << "

you can rewrite it as

\n" - << "
"
+              << "
"
               << trimmedTrailing(highlightedCode(indent(codeIndent,atom->string()),
                                                  marker,relative))
               << "
\n"; @@ -538,9 +538,9 @@ int HtmlGenerator::generateAtom(const Atom *atom, out() << "

For example, if you have code like

\n"; // fallthrough case Atom::CodeBad: - out() << "
"
+        out() << "
"
               << trimmedTrailing(protectEnc(plainCode(indent(codeIndent,atom->string()))))
-              << "
\n"; + << "
\n"; break; case Atom::FootnoteLeft: // ### For now @@ -849,7 +849,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, if (atom->next() != 0) text = atom->next()->string(); if (atom->type() == Atom::Image) - out() << "

"; + out() << "

"; if (fileName.isEmpty()) { out() << "[Missing image " << protectEnc(atom->string()) << "]"; @@ -868,7 +868,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, case Atom::ImageText: break; case Atom::LegaleseLeft: - out() << "

"; + out() << "
"; break; case Atom::LegaleseRight: out() << "
"; @@ -910,13 +910,13 @@ int HtmlGenerator::generateAtom(const Atom *atom, else if (atom->string() == ATOM_LIST_VALUE) { threeColumnEnumValueTable = isThreeColumnEnumValueTable(atom); if (threeColumnEnumValueTable) { - out() << "

" + out() << "
" << "" << "" << "\n"; } else { - out() << "

ConstantValueDescription
" + out() << "
" << "\n"; } } @@ -951,10 +951,10 @@ int HtmlGenerator::generateAtom(const Atom *atom, else { // (atom->string() == ATOM_LIST_VALUE) // ### Trenton - out() << "
ConstantValue
" + out() << "
" << protectEnc(plainCode(marker->markedUpEnumValue(atom->next()->string(), relative))) - << ""; + << ""; QString itemValue; if (relative->type() == Node::Enum) { @@ -980,7 +980,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, } else if (atom->string() == ATOM_LIST_VALUE) { if (threeColumnEnumValueTable) { - out() << ""; + out() << ""; if (matchAhead(atom, Atom::ListItemRight)) out() << " "; } @@ -1010,7 +1010,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, out() << "\n"; } else if (atom->string() == ATOM_LIST_VALUE) { - out() << "

\n"; + out() << "\n"; } else { out() << "\n"; @@ -1091,29 +1091,28 @@ int HtmlGenerator::generateAtom(const Atom *atom, } if (!atom->string().isEmpty()) { if (atom->string().contains("%")) - out() << "

string() << "\" " - << "align=\"center\">\n"; + out() << "
string() << "\">\n "; else { - out() << "

\n"; + out() << "
\n"; } } else { - out() << "

\n"; + out() << "
\n"; } numTableRows = 0; break; case Atom::TableRight: - out() << "

\n"; + out() << "\n"; break; case Atom::TableHeaderLeft: - out() << ""; + out() << ""; inTableHeader = true; break; case Atom::TableHeaderRight: out() << ""; if (matchAhead(atom, Atom::TableHeaderLeft)) { skipAhead = 1; - out() << "\n"; + out() << "\n"; } else { out() << "\n"; @@ -1122,9 +1121,9 @@ int HtmlGenerator::generateAtom(const Atom *atom, break; case Atom::TableRowLeft: if (++numTableRows % 2 == 1) - out() << ""; + out() << ""; else - out() << ""; + out() << ""; break; case Atom::TableRowRight: out() << "\n"; @@ -1189,11 +1188,11 @@ int HtmlGenerator::generateAtom(const Atom *atom, out() << "string()) << "\">"; break; case Atom::UnhandledFormat: - out() << "<Missing HTML>"; + out() << "<Missing HTML>"; break; case Atom::UnknownCommand: - out() << "\\" << protectEnc(atom->string()) - << ""; + out() << "\\" << protectEnc(atom->string()) + << ""; break; #ifdef QDOC_QML case Atom::QmlText: @@ -1811,7 +1810,7 @@ void HtmlGenerator::generateBrief(const Node *node, CodeMarker *marker, void HtmlGenerator::generateIncludes(const InnerNode *inner, CodeMarker *marker) { if (!inner->includes().isEmpty()) { - out() << "
"
+        out() << "
"
               << trimmedTrailing(highlightedCode(indent(codeIndent,
                                                         marker->markedUpIncludes(inner->includes())),
                                                  marker,inner))
@@ -1845,8 +1844,8 @@ void HtmlGenerator::generateTableOfContents(const Node *node,
 
     QString tdTag;
     if (numColumns > 1) {
-        tdTag = "";
-        out() << "

\n" + tdTag = "
"; /* width=\"" + QString::number((100 + numColumns - 1) / numColumns) + "%\">";*/ + out() << "\n" << tdTag << "\n"; } @@ -1898,7 +1897,7 @@ void HtmlGenerator::generateTableOfContents(const Node *node, } if (numColumns > 1) - out() << "

\n"; + out() << "
\n"; inContents = false; inLink = false; @@ -2011,7 +2010,7 @@ void HtmlGenerator::generateNavigationBar(const NavigationBar& bar, { if (bar.prev.begin() != 0 || bar.current.begin() != 0 || bar.next.begin() != 0) { - out() << "

"; + out() << "

"; if (bar.prev.begin() != 0) { #if 0 out() << "[\n"; + out() << "
\n"; int row = 0; foreach (const QString &name, nodeMap.keys()) { @@ -2197,9 +2196,9 @@ void HtmlGenerator::generateAnnotatedList(const Node *relative, continue; if (++row % 2 == 1) - out() << ""; + out() << ""; else - out() << ""; + out() << ""; out() << ""; @@ -2219,7 +2218,7 @@ void HtmlGenerator::generateAnnotatedList(const Node *relative, } out() << "\n"; } - out() << "
"; generateFullName(node, relative, marker); out() << "

\n"; + out() << "\n"; } /*! @@ -2372,7 +2371,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, } firstOffset[NumColumns] = classMap.count(); - out() << "

\n"; + out() << "
\n"; for (k = 0; k < numRows; k++) { out() << "\n"; for (i = 0; i < NumColumns; i++) { @@ -2393,7 +2392,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, currentParagraphNo[i] = NumParagraphs - 1; } #endif - out() << "\n"; } - out() << "
"; + out() << ""; if (currentOffsetInParagraph[i] == 0) { // start a new paragraph out() << "" @@ -2436,18 +2435,18 @@ void HtmlGenerator::generateCompactList(const Node *relative, } out() << "

\n"; + out() << "\n"; } void HtmlGenerator::generateFunctionIndex(const Node *relative, CodeMarker *marker) { - out() << "

"; + out() << "

"; for (int i = 0; i < 26; i++) { QChar ch('a' + i); out() << QString("%2 ").arg(ch).arg(ch.toUpper()); } - out() << "

\n"; + out() << "

\n"; char nextLetter = 'a'; char currentLetter; @@ -2715,8 +2714,8 @@ void HtmlGenerator::generateSection(const NodeList& nl, } else { if (twoColumn) - out() << "

\n" - << "\n
"; + out() << "\n" + << "\n
"; out() << "
    \n"; } @@ -2729,12 +2728,11 @@ void HtmlGenerator::generateSection(const NodeList& nl, } if (name_alignment) { - out() << "
"; + out() << "
"; } else { if (twoColumn && i == (int) (nl.count() + 1) / 2) - out() << "
    \n"; + out() << "
    \n"; out() << "
  • "; } @@ -2751,7 +2749,7 @@ void HtmlGenerator::generateSection(const NodeList& nl, else { out() << "
\n"; if (twoColumn) - out() << "

\n"; + out() << "
\n"; } } } @@ -2777,8 +2775,8 @@ void HtmlGenerator::generateSectionList(const Section& section, } else { if (twoColumn) - out() << "

\n" - << "\n
"; + out() << "\n" + << "\n
"; out() << "
    \n"; } @@ -2791,12 +2789,11 @@ void HtmlGenerator::generateSectionList(const Section& section, } if (name_alignment) { - out() << "
"; + out() << "
"; } else { if (twoColumn && i == (int) (section.members.count() + 1) / 2) - out() << "
    \n"; + out() << "
    \n"; out() << "
  • "; } @@ -2813,7 +2810,7 @@ void HtmlGenerator::generateSectionList(const Section& section, else { out() << "
\n"; if (twoColumn) - out() << "

\n"; + out() << "
\n"; } } @@ -2910,7 +2907,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, for (int i = 0, n = src.size(); i < n;) { if (src.at(i) == charLangle && src.at(i + 1).unicode() == '@') { if (nameAlignment && !done) {// && (i != 0)) Why was this here? - html += ""; + html += ""; done = true; } i += 2; @@ -3075,8 +3072,8 @@ void HtmlGenerator::generateSectionList(const Section& section, twoColumn = (section.members.count() >= 5); } if (twoColumn) - out() << "

\n" - << "\n
"; + out() << "\n" + << "\n
"; out() << "
    \n"; int i = 0; @@ -3088,7 +3085,7 @@ void HtmlGenerator::generateSectionList(const Section& section, } if (twoColumn && i == (int) (section.members.count() + 1) / 2) - out() << "
    \n"; + out() << "
    \n"; out() << "
  • "; if (style == CodeMarker::Accessors) @@ -3102,7 +3099,7 @@ void HtmlGenerator::generateSectionList(const Section& section, } out() << "
\n"; if (twoColumn) - out() << "

\n"; + out() << "
\n"; } if (style == CodeMarker::Summary && !section.inherited.isEmpty()) { @@ -4274,15 +4271,15 @@ void HtmlGenerator::generateQmlSummary(const Section& section, twoColumn = (count >= 5); } if (twoColumn) - out() << "

\n" - << "\n
"; + out() << "\n" + << "\n
"; out() << "
    \n"; int row = 0; m = section.members.begin(); while (m != section.members.end()) { if (twoColumn && row == (int) (count + 1) / 2) - out() << "
    \n"; + out() << "
    \n"; out() << "
  • "; generateQmlItem(*m,relative,marker,true); out() << "
  • \n"; @@ -4291,7 +4288,7 @@ void HtmlGenerator::generateQmlSummary(const Section& section, } out() << "
\n"; if (twoColumn) - out() << "

\n"; + out() << "
\n"; } } @@ -4383,7 +4380,7 @@ void HtmlGenerator::generateQmlInherits(const QmlClassNode* cn, const Node* n = myTree->findNode(strList,Node::Fake); if (n && n->subType() == Node::QmlClass) { const QmlClassNode* qcn = static_cast(n); - out() << "

"; + out() << "

"; Text text; text << "[Inherits "; text << Atom(Atom::LinkNode,CodeMarker::stringForNode(qcn)); @@ -4430,7 +4427,7 @@ void HtmlGenerator::generateQmlInstantiates(const QmlClassNode* qcn, { const ClassNode* cn = qcn->classNode(); if (cn && (cn->status() != Node::Internal)) { - out() << "

"; + out() << "

"; Text text; text << "["; text << Atom(Atom::LinkNode,CodeMarker::stringForNode(qcn)); @@ -4461,7 +4458,7 @@ void HtmlGenerator::generateInstantiatedBy(const ClassNode* cn, if (cn && cn->status() != Node::Internal && !cn->qmlElement().isEmpty()) { const Node* n = myTree->root()->findNode(cn->qmlElement(),Node::Fake); if (n && n->subType() == Node::QmlClass) { - out() << "

"; + out() << "

"; Text text; text << "["; text << Atom(Atom::LinkNode,CodeMarker::stringForNode(cn)); diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 67a25f3..158aef3 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -2,7 +2,7 @@ HTML.stylesheets = style/style.css HTML.postheader = "

\n" \ "
\n" \ " Home
\n" \ - " Qt Reference Documentation\n" \ + " Qt Reference Documentation\n" \ "
\n" \ " \n" \ "
\n" \ "
\n" \ @@ -110,7 +110,6 @@ HTML.footer = "
\n" \ "
\n" \ " \n" \ "
\n" \ - " \n" \ "
\n" \ "

\n" \ " © 2008-2010 Nokia Corporation and/or its\n" \ @@ -121,10 +120,10 @@ HTML.footer = "

\n" \ " href=\"http://qt.nokia.com/about/privacy-policy\">Privacy Policy

\n" \ " \n" \ "
\n" \ - "
\n" \ "
\n" \ " X\n" \ "
\n" \ + " \n" \ " \n" \ " \n" \ @@ -132,7 +131,6 @@ HTML.footer = "
\n" \ " \n" \ "
\n" \ "
\n" \ - " \n" \ "\n"; - out() << " \n"; + out() << " \n"; out() << "\n"; if (offlineDocs) - out() << "\n"; + out() << "\n"; else - out() << "\n"; + out() << "\n"; #ifdef GENERATE_MAC_REFS if (mainPage) @@ -1833,18 +1845,16 @@ void HtmlGenerator::generateTitle(const QString& title, CodeMarker *marker) { if (!title.isEmpty()) - out() << "

" << protectEnc(title); + out() << "

" << protectEnc(title) << "

\n"; if (!subTitle.isEmpty()) { - out() << "
"; - if (subTitleSize == SmallSubTitle) - out() << ""; + out() << ""; else - out() << ""; + out() << " class=\"subtitle\">"; generateText(subTitle, relative, marker); out() << "\n"; } - if (!title.isEmpty()) - out() << "\n"; } void HtmlGenerator::generateFooter(const Node *node) @@ -1853,9 +1863,10 @@ void HtmlGenerator::generateFooter(const Node *node) out() << "

\n" << navigationLinks << "

\n"; out() << QString(footer).replace("\\" + COMMAND_VERSION, myTree->version()) - << QString(address).replace("\\" + COMMAND_VERSION, myTree->version()) - << "\n" - "\n"; + << QString(address).replace("\\" + COMMAND_VERSION, myTree->version()); + out() << " \n"; + out() << "\n"; + out() << "\n"; } void HtmlGenerator::generateBrief(const Node *node, CodeMarker *marker, @@ -1876,7 +1887,7 @@ void HtmlGenerator::generateBrief(const Node *node, CodeMarker *marker, void HtmlGenerator::generateIncludes(const InnerNode *inner, CodeMarker *marker) { if (!inner->includes().isEmpty()) { - out() << "
"
+        out() << "
"
               << trimmedTrailing(highlightedCode(indent(codeIndent,
                                                         marker->markedUpIncludes(inner->includes())),
                                                  marker,inner))
@@ -3766,7 +3777,7 @@ void HtmlGenerator::generateDetailedMember(const Node *node,
         out() << "

"; out() << ""; generateSynopsis(enume, relative, marker, CodeMarker::Detailed); - out() << "
"; + out() << "
"; generateSynopsis(enume->flagsType(), relative, marker, diff --git a/tools/qdoc3/test/assistant.qdocconf b/tools/qdoc3/test/assistant.qdocconf index 1deefce..112b1b2 100644 --- a/tools/qdoc3/test/assistant.qdocconf +++ b/tools/qdoc3/test/assistant.qdocconf @@ -16,45 +16,28 @@ qhp.Assistant.file = assistant.qhp qhp.Assistant.namespace = com.trolltech.assistant.470 qhp.Assistant.virtualFolder = qdoc qhp.Assistant.indexTitle = Qt Assistant Manual -qhp.Assistant.extraFiles = images/api_examples.png \ - images/api_lookup.png \ - images/api_topics.png \ +qhp.Assistant.extraFiles = images/bg_l.png \ images/bg_l_blank.png \ - images/bg_ll_blank.png \ - images/bg_ll.png \ - images/bg_l.png \ - images/bg_lr.png \ images/bg_r.png \ - images/bg_ul_blank.png \ - images/bg_ul.png \ - images/bg_ur_blank.png \ - images/bg_ur.png \ - images/box_bg.png \ - images/breadcrumb.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ images/bullet_dn.png \ - images/bullet_gt.png \ - images/bullet_sq.png \ + images/bullet_sq.png \ images/bullet_up.png \ - images/coloreditorfactoryimage.png \ - images/content_bg.png \ - images/dynamiclayouts-example.png \ images/feedbackground.png \ - images/form_bg.png \ images/horBar.png \ - images/page_bg.png \ - images/print.png \ - images/qt_guide.png \ - images/qt_icon.png \ - images/qt-logo.png \ - images/qt_ref_doc.png \ - images/qt_tools.png \ - images/sep.png \ - images/sprites-combined.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ images/stylesheet-coffee-plastique.png \ images/taskmenuextension-example.png \ - scripts/functions.js \ - scripts/jquery.js \ + images/coloreditorfactoryimage.png \ + images/dynamiclayouts-example.png \ + scripts/functions.js \ + scripts/jquery.js \ style/style.css + qhp.Assistant.filterAttributes = qt 4.7.0 tools assistant qhp.Assistant.customFilters.Assistant.name = Qt Assistant Manual qhp.Assistant.customFilters.Assistant.filterAttributes = qt tools assistant diff --git a/tools/qdoc3/test/designer.qdocconf b/tools/qdoc3/test/designer.qdocconf index 513801a..d4da292 100644 --- a/tools/qdoc3/test/designer.qdocconf +++ b/tools/qdoc3/test/designer.qdocconf @@ -16,45 +16,28 @@ qhp.Designer.file = designer.qhp qhp.Designer.namespace = com.trolltech.designer.470 qhp.Designer.virtualFolder = qdoc qhp.Designer.indexTitle = Qt Designer Manual -qhp.Designer.extraFiles = images/api_examples.png \ - images/api_lookup.png \ - images/api_topics.png \ - images/bg_l_blank.png \ - images/bg_ll_blank.png \ - images/bg_ll.png \ - images/bg_l.png \ - images/bg_lr.png \ - images/bg_r.png \ - images/bg_ul_blank.png \ - images/bg_ul.png \ - images/bg_ur_blank.png \ - images/bg_ur.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_dn.png \ - images/bullet_gt.png \ - images/bullet_sq.png \ - images/bullet_up.png \ +qhp.Designer.extraFiles = images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_r.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ images/coloreditorfactoryimage.png \ - images/content_bg.png \ images/dynamiclayouts-example.png \ - images/feedbackground.png \ - images/form_bg.png \ - images/horBar.png \ - images/page_bg.png \ - images/print.png \ - images/qt_guide.png \ - images/qt_icon.png \ - images/qt-logo.png \ - images/qt_ref_doc.png \ - images/qt_tools.png \ - images/sep.png \ - images/sprites-combined.png \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - style/style.css + scripts/functions.js \ + scripts/jquery.js \ + style/style.css + qhp.Designer.filterAttributes = qt 4.7.0 tools designer qhp.Designer.customFilters.Designer.name = Qt Designer Manual qhp.Designer.customFilters.Designer.filterAttributes = qt tools designer diff --git a/tools/qdoc3/test/linguist.qdocconf b/tools/qdoc3/test/linguist.qdocconf index a3f4f00..7420b4f 100644 --- a/tools/qdoc3/test/linguist.qdocconf +++ b/tools/qdoc3/test/linguist.qdocconf @@ -16,45 +16,28 @@ qhp.Linguist.file = linguist.qhp qhp.Linguist.namespace = com.trolltech.linguist.470 qhp.Linguist.virtualFolder = qdoc qhp.Linguist.indexTitle = Qt Linguist Manual -qhp.Linguist.extraFiles = images/api_examples.png \ - images/api_lookup.png \ - images/api_topics.png \ - images/bg_l_blank.png \ - images/bg_ll_blank.png \ - images/bg_ll.png \ - images/bg_l.png \ - images/bg_lr.png \ - images/bg_r.png \ - images/bg_ul_blank.png \ - images/bg_ul.png \ - images/bg_ur_blank.png \ - images/bg_ur.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_dn.png \ - images/bullet_gt.png \ - images/bullet_sq.png \ - images/bullet_up.png \ +qhp.Linguist.extraFiles = images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_r.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ images/coloreditorfactoryimage.png \ - images/content_bg.png \ images/dynamiclayouts-example.png \ - images/feedbackground.png \ - images/form_bg.png \ - images/horBar.png \ - images/page_bg.png \ - images/print.png \ - images/qt_guide.png \ - images/qt_icon.png \ - images/qt-logo.png \ - images/qt_ref_doc.png \ - images/qt_tools.png \ - images/sep.png \ - images/sprites-combined.png \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - style/style.css + scripts/functions.js \ + scripts/jquery.js \ + style/style.css + qhp.Linguist.filterAttributes = qt 4.7.0 tools linguist qhp.Linguist.customFilters.Linguist.name = Qt Linguist Manual qhp.Linguist.customFilters.Linguist.filterAttributes = qt tools linguist diff --git a/tools/qdoc3/test/qdeclarative.qdocconf b/tools/qdoc3/test/qdeclarative.qdocconf index 80050e3..8015f57 100644 --- a/tools/qdoc3/test/qdeclarative.qdocconf +++ b/tools/qdoc3/test/qdeclarative.qdocconf @@ -27,45 +27,27 @@ qhp.Qml.indexTitle = Qml Reference # Files not referenced in any qdoc file # See also extraimages.HTML -qhp.Qml.extraFiles = images/api_examples.png \ - images/api_lookup.png \ - images/api_topics.png \ - images/bg_l_blank.png \ - images/bg_ll_blank.png \ - images/bg_ll.png \ - images/bg_l.png \ - images/bg_lr.png \ - images/bg_r.png \ - images/bg_ul_blank.png \ - images/bg_ul.png \ - images/bg_ur_blank.png \ - images/bg_ur.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_dn.png \ - images/bullet_gt.png \ - images/bullet_sq.png \ - images/bullet_up.png \ - images/coloreditorfactoryimage.png \ - images/content_bg.png \ - images/dynamiclayouts-example.png \ - images/feedbackground.png \ - images/form_bg.png \ - images/horBar.png \ - images/page_bg.png \ - images/print.png \ - images/qt_guide.png \ - images/qt_icon.png \ - images/qt-logo.png \ - images/qt_ref_doc.png \ - images/qt_tools.png \ - images/sep.png \ - images/sprites-combined.png \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - style/style.css +qhp.Qml.extraFiles = images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_r.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ + images/coloreditorfactoryimage.png \ + images/dynamiclayouts-example.png \ + scripts/functions.js \ + scripts/jquery.js \ + style/style.css qhp.Qml.filterAttributes = qt 4.6.0 qtrefdoc qhp.Qml.customFilters.Qt.name = Qt 4.6.0 diff --git a/tools/qdoc3/test/qmake.qdocconf b/tools/qdoc3/test/qmake.qdocconf index f38a2a4..49d088e 100644 --- a/tools/qdoc3/test/qmake.qdocconf +++ b/tools/qdoc3/test/qmake.qdocconf @@ -16,45 +16,28 @@ qhp.qmake.file = qmake.qhp qhp.qmake.namespace = com.trolltech.qmake.470 qhp.qmake.virtualFolder = qdoc qhp.qmake.indexTitle = QMake Manual -qhp.qmake.extraFiles = images/api_examples.png \ - images/api_lookup.png \ - images/api_topics.png \ - images/bg_l_blank.png \ - images/bg_ll_blank.png \ - images/bg_ll.png \ - images/bg_l.png \ - images/bg_lr.png \ - images/bg_r.png \ - images/bg_ul_blank.png \ - images/bg_ul.png \ - images/bg_ur_blank.png \ - images/bg_ur.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_dn.png \ - images/bullet_gt.png \ - images/bullet_sq.png \ - images/bullet_up.png \ - images/coloreditorfactoryimage.png \ - images/content_bg.png \ - images/dynamiclayouts-example.png \ - images/feedbackground.png \ - images/form_bg.png \ - images/horBar.png \ - images/page_bg.png \ - images/print.png \ - images/qt_guide.png \ - images/qt_icon.png \ - images/qt-logo.png \ - images/qt_ref_doc.png \ - images/qt_tools.png \ - images/sep.png \ - images/sprites-combined.png \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - style/style.css +qhp.qmake.extraFiles = images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_r.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ + images/coloreditorfactoryimage.png \ + images/dynamiclayouts-example.png \ + scripts/functions.js \ + scripts/jquery.js \ + style/style.css + qhp.qmake.filterAttributes = qt 4.7.0 tools qmake qhp.qmake.customFilters.qmake.name = qmake Manual qhp.qmake.customFilters.qmake.filterAttributes = qt tools qmake diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf index 0694748..f0c2535 100644 --- a/tools/qdoc3/test/qt-build-docs.qdocconf +++ b/tools/qdoc3/test/qt-build-docs.qdocconf @@ -22,45 +22,27 @@ qhp.Qt.indexTitle = Qt Reference Documentation # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - images/api_examples.png \ - images/api_lookup.png \ - images/api_topics.png \ - images/bg_l_blank.png \ - images/bg_ll_blank.png \ - images/bg_ll.png \ - images/bg_l.png \ - images/bg_lr.png \ - images/bg_r.png \ - images/bg_ul_blank.png \ - images/bg_ul.png \ - images/bg_ur_blank.png \ - images/bg_ur.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_dn.png \ - images/bullet_gt.png \ - images/bullet_sq.png \ - images/bullet_up.png \ - images/coloreditorfactoryimage.png \ - images/content_bg.png \ - images/dynamiclayouts-example.png \ - images/feedbackground.png \ - images/form_bg.png \ - images/horBar.png \ - images/page_bg.png \ - images/print.png \ - images/qt_guide.png \ - images/qt_icon.png \ - images/qt-logo.png \ - images/qt_ref_doc.png \ - images/qt_tools.png \ - images/sep.png \ - images/sprites-combined.png \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - style/style.css + images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_r.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ + images/coloreditorfactoryimage.png \ + images/dynamiclayouts-example.png \ + scripts/functions.js \ + scripts/jquery.js \ + style/style.css diff --git a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf index 5a3d726..a00d5a1 100644 --- a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf @@ -30,45 +30,27 @@ qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - images/api_examples.png \ - images/api_lookup.png \ - images/api_topics.png \ - images/bg_l_blank.png \ - images/bg_ll_blank.png \ - images/bg_ll.png \ - images/bg_l.png \ - images/bg_lr.png \ - images/bg_r.png \ - images/bg_ul_blank.png \ - images/bg_ul.png \ - images/bg_ur_blank.png \ - images/bg_ur.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_dn.png \ - images/bullet_gt.png \ - images/bullet_sq.png \ - images/bullet_up.png \ - images/coloreditorfactoryimage.png \ - images/content_bg.png \ - images/dynamiclayouts-example.png \ - images/feedbackground.png \ - images/form_bg.png \ - images/horBar.png \ - images/page_bg.png \ - images/print.png \ - images/qt_guide.png \ - images/qt_icon.png \ - images/qt-logo.png \ - images/qt_ref_doc.png \ - images/qt_tools.png \ - images/sep.png \ - images/sprites-combined.png \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - style/style.css + images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_r.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ + images/coloreditorfactoryimage.png \ + images/dynamiclayouts-example.png \ + scripts/functions.js \ + scripts/jquery.js \ + style/style.css language = Cpp diff --git a/tools/qdoc3/test/qt-defines.qdocconf b/tools/qdoc3/test/qt-defines.qdocconf index 0426f4d..dc81757 100644 --- a/tools/qdoc3/test/qt-defines.qdocconf +++ b/tools/qdoc3/test/qt-defines.qdocconf @@ -20,37 +20,20 @@ codeindent = 1 # See also qhp.Qt.extraFiles extraimages.HTML = qt-logo \ trolltech-logo \ - api_examples.png \ - bg_ll.png \ - bg_ul_blank.png \ - bullet_gt.png \ - horBar.png \ - qt_ref_doc.png \ - api_lookup.png \ - bg_ll_blank.png \ - bg_ur.png \ - bullet_sq.png \ - bullet_dn.png \ - bullet_up.png \ - page_bg.png \ - qt_tools.png \ - api_topics.png \ - bg_lr.png \ - bg_ur_blank.png \ - content_bg.png \ - print.png \ - sep.png \ - bg_l.png \ - bg_r.png \ - box_bg.png \ - feedbackground.png \ - qt_guide.png \ - sprites-combined.png \ - bg_l_blank.png \ - bg_ul.png \ - breadcrumb.png \ - form_bg.png \ - qt_icon.png \ + bg_l.png \ + bg_l_blank.png \ + bg_r.png \ + box_bg.png \ + breadcrumb.png \ + bullet_gt.png \ + bullet_dn.png \ + bullet_sq.png \ + bullet_up.png \ + feedbackground.png \ + horBar.png \ + page.png \ + page_bg.png \ + sprites-combined.png \ taskmenuextension-example.png \ coloreditorfactoryimage.png \ dynamiclayouts-example.png \ diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 0651176..00af376 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -33,30 +33,38 @@ HTML.postheader = "
\n" \ "
\n" \ " \n" \ "
\n" \ - " \n" \ + " \n" \ "
\n" \ " \n" \ "
\n" \ "
\n" \ - "

\n" \ + "

\n" \ " API Lookup

\n" \ - "
\n" \ - " \n" \ "
\n" \ - "
\n" \ + "
\n" \ "
\n" \ "
\n" \ "
\n" \ - "

\n" \ + "

\n" \ " API Topics

\n" \ - "
\n" \ - " \n" \ "
\n" \ - "
\n" \ + "
\n" \ "
\n" \ "
\n" \ "
\n" \ - "

\n" \ + "

\n" \ " API Examples

\n" \ - "
\n" \ - " \n" \ "
\n" \ - "
\n" \ + "
\n" \ "
\n" \ "
\n" \ "
\n" \ @@ -103,13 +116,13 @@ HTML.postpostheader = " \n" \ "
  • A
  • \n" \ "
  • A
  • \n" \ "
  • \n" \ - " \"\"\"Print
  • \n" \ + " Print\n" \ " \n" \ "
    \n" \ "
    \n" \ "
    \n" -HTML.footer = "
    \n" \ +HTML.footer = " \n" \ "
    \n" \ " [+] Documentation Feedback
    \n" \ "
    \n" \ @@ -117,6 +130,7 @@ HTML.footer = " \n" \ "
    \n" \ " \n" \ "
    \n" \ + " \n" \ "
    \n" \ "

    \n" \ " © 2008-2010 Nokia Corporation and/or its\n" \ @@ -131,14 +145,14 @@ HTML.footer = "

    \n" \ " X\n" \ " \n" \ "
    \n" \ - " \n" \ - " \n" \ + "

    \n" \ + "

    \n" \ "
    \n" \ " \n" \ "
    \n" \ "
    \n" \ - " -->\n" diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf index 69ab4e1..59dd855 100644 --- a/tools/qdoc3/test/qt.qdocconf +++ b/tools/qdoc3/test/qt.qdocconf @@ -26,45 +26,27 @@ qhp.Qt.indexRoot = # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - images/api_examples.png \ - images/api_lookup.png \ - images/api_topics.png \ - images/bg_l_blank.png \ - images/bg_ll_blank.png \ - images/bg_ll.png \ - images/bg_l.png \ - images/bg_lr.png \ - images/bg_r.png \ - images/bg_ul_blank.png \ - images/bg_ul.png \ - images/bg_ur_blank.png \ - images/bg_ur.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_dn.png \ - images/bullet_gt.png \ - images/bullet_sq.png \ - images/bullet_up.png \ - images/coloreditorfactoryimage.png \ - images/content_bg.png \ - images/dynamiclayouts-example.png \ - images/feedbackground.png \ - images/form_bg.png \ - images/horBar.png \ - images/page_bg.png \ - images/print.png \ - images/qt_guide.png \ - images/qt_icon.png \ - images/qt-logo.png \ - images/qt_ref_doc.png \ - images/qt_tools.png \ - images/sep.png \ - images/sprites-combined.png \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - style/style.css + images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_r.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ + images/coloreditorfactoryimage.png \ + images/dynamiclayouts-example.png \ + scripts/functions.js \ + scripts/jquery.js \ + style/style.css qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc qhp.Qt.customFilters.Qt.name = Qt 4.7.0 diff --git a/tools/qdoc3/test/qt_zh_CN.qdocconf b/tools/qdoc3/test/qt_zh_CN.qdocconf index a5a65d8..9275b5c 100644 --- a/tools/qdoc3/test/qt_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt_zh_CN.qdocconf @@ -32,45 +32,27 @@ qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - images/api_examples.png \ - images/api_lookup.png \ - images/api_topics.png \ - images/bg_l_blank.png \ - images/bg_ll_blank.png \ - images/bg_ll.png \ - images/bg_l.png \ - images/bg_lr.png \ - images/bg_r.png \ - images/bg_ul_blank.png \ - images/bg_ul.png \ - images/bg_ur_blank.png \ - images/bg_ur.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_dn.png \ - images/bullet_gt.png \ - images/bullet_sq.png \ - images/bullet_up.png \ - images/coloreditorfactoryimage.png \ - images/content_bg.png \ - images/dynamiclayouts-example.png \ - images/feedbackground.png \ - images/form_bg.png \ - images/horBar.png \ - images/page_bg.png \ - images/print.png \ - images/qt_guide.png \ - images/qt_icon.png \ - images/qt-logo.png \ - images/qt_ref_doc.png \ - images/qt_tools.png \ - images/sep.png \ - images/sprites-combined.png \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - style/style.css + images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_r.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ + images/coloreditorfactoryimage.png \ + images/dynamiclayouts-example.png \ + scripts/functions.js \ + scripts/jquery.js \ + style/style.css language = Cpp diff --git a/tools/qdoc3/test/style/style.css b/tools/qdoc3/test/style/style.css index 1ed49fa..9c290f5 100644 --- a/tools/qdoc3/test/style/style.css +++ b/tools/qdoc3/test/style/style.css @@ -58,6 +58,19 @@ { vertical-align: baseline; } + .heading + { + font: normal 600 16px/1.0 Arial; + padding-bottom: 15px; + } + .subtitle + { + font-size: 13px; + } + .small-subtitle + { + font-size: 13px; + } legend { color: #000000; @@ -73,7 +86,6 @@ { font-size: 100%; } - /* Page style */ html { background-color: #e5e5e5; @@ -92,6 +104,11 @@ { font-style: italic; } + a + { + color: #00732f; + text-decoration: none; + } .header, .footer, .wrapper { min-width: 600px; @@ -106,23 +123,19 @@ { padding-left: 216px; height: 15px; - background: url(../images/bg_ul.png) no-repeat 0 0; + background: url(../images/page.png) no-repeat 0 0; overflow: hidden; } .offline .wrapper .hd { - background: url(../images/bg_ul_blank.png) no-repeat 0 0; + background: url(../images/page.png) no-repeat 0 -15px; } .wrapper .hd span { height: 15px; display: block; - background: url(../images/bg_ur.png) no-repeat 100% 0; overflow: hidden; - } - .offline .wrapper .hd span - { - /* background: url(../images/bg_ur_blank.png) no-repeat 100% 0; */ + background: url(../images/page.png) no-repeat 100% -30px; } .wrapper .bd { @@ -137,18 +150,18 @@ { padding-left: 216px; height: 15px; - background: url(../images/bg_ll.png) no-repeat 0 0; + background: url(../images/page.png) no-repeat 0 -75px; overflow: hidden; } .offline .wrapper .ft { - background: url(../images/bg_ll_blank.png) no-repeat 0 0; + background: url(../images/page.png) no-repeat 0 -90px; } .wrapper .ft span { height: 15px; display: block; - background: url(../images/bg_lr.png) no-repeat 100% 0; + background: url(../images/page.png) no-repeat 100% -60px; overflow: hidden; } .header, .footer @@ -182,186 +195,9 @@ width: 302px; height: 22px; text-indent: -999em; - background: url(../images/header.png) no-repeat 0 0; - } - /* header elements */ - #nav-topright - { - height: 70px; - } - - #nav-topright ul - { - list-style-type: none; - float: right; - width: 370px; - margin-top: 11px; - } - - #nav-topright li - { - display: inline-block; - margin-right: 20px; - float: left; - } - - #nav-topright li.nav-topright-last - { - margin-right: 0; - } - - #nav-topright li a - { - background: transparent url(../images/sprites-combined.png) no-repeat; - height: 18px; - display: block; - overflow: hidden; - text-indent: -9999px; - } - - #nav-topright li.nav-topright-home a - { - width: 65px; - background-position: -2px -91px; - } - - #nav-topright li.nav-topright-home a:hover - { - background-position: -2px -117px; - } - - - #nav-topright li.nav-topright-dev a - { - width: 30px; - background-position: -76px -91px; - } - - #nav-topright li.nav-topright-dev a:hover - { - background-position: -76px -117px; - } - - - #nav-topright li.nav-topright-labs a - { - width: 40px; - background-position: -114px -91px; - } - - #nav-topright li.nav-topright-labs a:hover - { - background-position: -114px -117px; - } - - #nav-topright li.nav-topright-doc a - { - width: 32px; - background-position: -162px -91px; - } - - #nav-topright li.nav-topright-doc a:hover, #nav-topright li.nav-topright-doc-active a - { - background-position: -162px -117px; - } - - #nav-topright li.nav-topright-blog a - { - width: 40px; - background-position: -203px -91px; - } - - #nav-topright li.nav-topright-blog a:hover, #nav-topright li.nav-topright-blog-active a - { - background-position: -203px -117px; - } - - #nav-topright li.nav-topright-shop a - { - width: 40px; - background-position: -252px -91px; - } - - #nav-topright li.nav-topright-shop a:hover, #nav-topright li.nav-topright-shop-active a - { - background-position: -252px -117px; - } - - #nav-logo - { - background: transparent url( "../images/sprites-combined.png" ) no-repeat 0 -225px; - left: -3px; - position: absolute; - width: 75px; - height: 75px; - top: 13px; - } - #nav-logo a - { - width: 75px; - height: 75px; - display: block; - text-indent: -9999px; - overflow: hidden; - } - /* Clearing */ - .header:after, .footer:after, .breadcrumb:after, .wrap .content:after, .group:after - { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; - } - /* ^ Clearing */ - - - - .shortCut-topleft-inactive - { - padding-left: 3px; - background: transparent url( "../images/sprites-combined.png" ) no-repeat 0px -58px; - height: 20px; - width: 93px; - } - .shortCut-topleft-inactive span - { - font-variant: normal; - } - #shortCut - { - padding-top: 10px; - font-weight: bolder; - color: #b0adab; - } - #shortCut ul - { - list-style-type: none; - float: left; - width: 347px; - margin-left: 100px; - } - #shortCut li - { - display: inline-block; - margin-right: 25px; - float: left; - white-space: nowrap; - } - #shortCut li a - { - color: #b0adab; - text-decoration: none; - } - #shortCut li a:hover - { - color: #44a51c; - text-decoration: none; + background: url(../images/sprites-combined.png) no-repeat -78px -235px; } - /* end of header elements */ - - /* menu element */ .sidebar { float: left; @@ -369,32 +205,32 @@ width: 200px; font-size: 11px; } - .sidebar a - { - color: #00732f; - text-decoration: none; - } - .offline .sidebar, .offline .feedback + + .offline .sidebar, .offline .feedback, .offline .t_button { display: none; } + .sidebar .searchlabel { padding: 0 0 2px 17px; font: normal bold 11px/1.2 Verdana; } + .sidebar .search { padding: 0 15px 0 16px; } + .sidebar .search form { - width: 167px; - height: 21px; - padding: 2px 0 0 5px; - background: url(../images/form_bg.png) no-repeat 0 0; + background: url(../images/sprites-combined.png) no-repeat -6px -348px; + height:21px; + padding:2px 0 0 5px; + width:167px; } - .sidebar .search form fieldset input#searchstring + + .sidebar .search form input#pageType { width: 158px; height: 19px; @@ -403,32 +239,62 @@ outline: none; font: 13px/1.2 Verdana; } + .sidebar .box { padding: 17px 15px 5px 16px; } + .sidebar .box .first { background-image: none; } + .sidebar .box h2 { font: normal 18px/1.2 Arial; - padding: 15px 0 0 40px; + padding: 0; min-height: 32px; } + .sidebar .box h2 span + { + overflow: hidden; + display: inline-block; + } .sidebar .box#lookup h2 { - background: url(../images/api_lookup.png) no-repeat 0 0; + background-image: none; + } + .sidebar #lookup.box h2 span + { + background: url(../images/sprites-combined.png) no-repeat -6px -311px; + width: 27px; + height: 35px; + margin-right: 13px; } .sidebar .box#topics h2 { - background: url(../images/api_topics.png) no-repeat 0 0; + background-image: none; + } + .sidebar #topics.box h2 span + { + background: url(../images/sprites-combined.png) no-repeat -94px -311px; + width: 27px; + height: 32px; + margin-right: 13px; } .sidebar .box#examples h2 { - background: url(../images/api_examples.png) no-repeat 0 0; + background-image: none; + } + .sidebar #examples.box h2 span + { + background: url(../images/sprites-combined.png) no-repeat -48px -311px; + width: 30px; + height: 31px; + margin-right: 9px; } + .sidebar .box .list { display: block; @@ -443,6 +309,9 @@ { text-decoration: underline; } + .sidebar .box ul + { + } .sidebar .box ul li { padding-left: 12px; @@ -453,23 +322,20 @@ { background: url(../images/box_bg.png) repeat-x 0 bottom; } - /* content elements */ .wrap { - overflow: hidden; + margin: 0 5px 0 208px; + overflow: visible; } .offline .wrap { margin: 0 5px 0 5px; } - /* tool bar */ .wrap .toolbar { background-color: #fafafa; border-bottom: 1px solid #d1d1d1; - height: 20px; - margin-left: 3px; - margin-right: 5px; + height: 20px; position: relative; } .wrap .toolbar .toolblock @@ -487,7 +353,7 @@ { padding: 0 0 10px 21px; right: 5px; - vertical-align: top; + vertical-align: middle; overflow: hidden; } .wrap .toolbar .toolbuttons .active @@ -507,32 +373,56 @@ font-weight: bold; color: #B0ADAB; } - #smallA + + .toolbuttons #print + { + border-left: 1px solid #c5c4c4; + margin-top: 0; + padding-left: 7px; + text-indent: 0; + } + .toolbuttons #print a + { + width: 16px; + height: 16px; + } + + .toolbuttons #print a span + { + width: 16px; + height: 16px; + text-indent: -999em; + display: block; + overflow: hidden; + background: url(../images/sprites-combined.png) no-repeat -137px -311px; + } + + .toolbuttons #smallA { font-size: 10pt; } - #medA + .toolbuttons #medA { font-size: 12pt; } - #bigA + .toolbuttons #bigA { font-size: 14pt; + margin-right: 7px; } + #smallA:hover, #medA:hover, #bigA:hover { color: #00732F; } - #print + + .offline .wrap .breadcrumb { - font-size: 14pt; - line-height: 20pt; } - #printIcon + + .wrap .breadcrumb ul { - margin-left: 5px; } - /* bread crumbs */ .wrap .breadcrumb ul li { float: left; @@ -545,6 +435,10 @@ { font-weight: normal; } + .wrap .breadcrumb ul li a + { + color: #363534; + } .wrap .breadcrumb ul li.first { background-image: none; @@ -554,29 +448,29 @@ .wrap .content { padding: 30px; - position: relative; } - /* text elements */ - .heading + + .wrap .content li { - font: normal 600 16px/1.0 Arial; - padding-bottom: 15px; + padding-left: 12px; + background: url(../images/bullet_sq.png) no-repeat 0 5px; + font: normal 400 10pt/1 Verdana; + color: #44a51c; + margin-bottom: 10px; } - - .subtitle + .content li:hover { - font-size: 13px; + text-decoration: underline; } - .small-subtitle + .offline .wrap .content { - font-size: 13px; + padding-top: 15px; } - + .wrap .content h1 { font: 600 18px/1.2 Arial; - padding-bottom: 15px; } .wrap .content h2 { @@ -588,26 +482,13 @@ } .wrap .content p { - line-height:20px; - padding:10px 5px 10px 5px; + line-height: 20px; + padding: 10px 5px 10px 5px; } .wrap .content ul { padding-left: 25px; } - .wrap .content li - { - padding-left: 12px; - background: url(../images/bullet_sq.png) no-repeat 0 5px; - font: normal 400 10pt/1 Verdana; - margin-bottom: 10px; - line-height: 14px; - } - a - { - color: #00732F; - text-decoration: none; - } a:hover { color: #4c0033; @@ -618,10 +499,6 @@ color: #4c0033; text-decoration: none; } - .offline .wrap .content - { - padding-top: 15px; - } .footer { min-height: 100px; @@ -629,11 +506,15 @@ font: normal 9px/1 Verdana; text-align: center; padding-top: 40px; + background-color: #E6E7E8; + margin: 0; } .feedback { - float: right; - padding-right: 10px; + float: none; + position: absolute; + right: 15px; + bottom: 10px; font: normal 8px/1 Verdana; color: #B0ADAB; } @@ -644,37 +525,223 @@ color: #00732F; text-decoration: underline; } + .header:after, .footer:after, .breadcrumb:after, .wrap .content:after, .group:after + { + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; + } + #nav-topright + { + height: 70px; + } + + #nav-topright ul + { + list-style-type: none; + float: right; + width: 370px; + margin-top: 11px; + } + + #nav-topright li + { + display: inline-block; + margin-right: 20px; + float: left; + } + + #nav-topright li.nav-topright-last + { + margin-right: 0; + } + + #nav-topright li a + { + background: transparent url(../images/sprites-combined.png) no-repeat; + height: 18px; + display: block; + overflow: hidden; + text-indent: -9999px; + } + + #nav-topright li.nav-topright-home a + { + width: 65px; + background-position: -2px -91px; + } + + #nav-topright li.nav-topright-home a:hover + { + background-position: -2px -117px; + } + + + #nav-topright li.nav-topright-dev a + { + width: 30px; + background-position: -76px -91px; + } + + #nav-topright li.nav-topright-dev a:hover + { + background-position: -76px -117px; + } + + + #nav-topright li.nav-topright-labs a + { + width: 40px; + background-position: -114px -91px; + } + + #nav-topright li.nav-topright-labs a:hover + { + background-position: -114px -117px; + } + + #nav-topright li.nav-topright-doc a + { + width: 32px; + background-position: -162px -91px; + } + + #nav-topright li.nav-topright-doc a:hover, #nav-topright li.nav-topright-doc-active a + { + background-position: -162px -117px; + } + + #nav-topright li.nav-topright-blog a + { + width: 40px; + background-position: -203px -91px; + } + + #nav-topright li.nav-topright-blog a:hover, #nav-topright li.nav-topright-blog-active a + { + background-position: -203px -117px; + } + + #nav-topright li.nav-topright-shop a + { + width: 40px; + background-position: -252px -91px; + } + + #nav-topright li.nav-topright-shop a:hover, #nav-topright li.nav-topright-shop-active a + { + background-position: -252px -117px; + } + + #nav-logo + { + background: transparent url(../images/sprites-combined.png ) no-repeat 0 -225px; + left: -3px; + position: absolute; + width: 75px; + height: 75px; + top: 13px; + } + #nav-logo a + { + width: 75px; + height: 75px; + display: block; + text-indent: -9999px; + overflow: hidden; + } + + + .shortCut-topleft-inactive + { + padding-left: 3px; + background: transparent url( ../images/sprites-combined.png) no-repeat 0px -58px; + height: 20px; + width: 47px; + } + .shortCut-topleft-inactive span + { + font-variant: normal; + } + #shortCut + { + padding-top: 10px; + font-weight: bolder; + color: #b0adab; + } + #shortCut ul + { + list-style-type: none; + float: left; + width: 347px; + margin-left: 100px; + } + #shortCut li + { + display: inline-block; + margin-right: 25px; + float: left; + white-space: nowrap; + } + #shortCut li a + { + color: #b0adab; + } + #shortCut li a:hover + { + color: #44a51c; + } + hr { - background-color: #e0e0e0; + background-color: #E6E6E6; + border: 1px solid #E6E6E6; height: 1px; width: 100%; text-align: left; margin: 15px 0px 15px 0px; } - + .content .alignedsummary { margin: 15px; } - /* tables */ + pre + { + border: 1px solid #DDDDDD; + margin: 0 20px 10px 10px; + padding: 20px 15px 20px 20px; + overflow-x: auto; + } table, pre { -moz-border-radius: 7px 7px 7px 7px; background-color: #F6F6F6; border: 1px solid #E6E6E6; border-collapse: separate; - font-size: 11px; - min-width: 395px; + font-size: 11px; + /*min-width: 395px;*/ margin-bottom: 25px; + display: inline-block; + } + thead + { + margin-top: 5px; + } + th + { + padding: 3px 15px 3px 15px; + } + td + { + padding: 3px 15px 3px 20px; } - thead{margin-top: 5px;} - th{ padding: 3px 15px 3px 15px;} - td{padding: 3px 15px 3px 20px;} table tr.odd { border-left: 1px solid #E6E6E6; - background-color: #F6F6F6; + background-color: #F6F6F6; color: #66666E; } table tr.even @@ -685,12 +752,13 @@ } table tr.odd:hover { - background-color: #E6E6E6; + background-color: #E6E6E6; } table tr.even:hover { background-color: #E6E6E6; } + span.comment { color: #8B0000; @@ -700,15 +768,7 @@ { color: #254117; } - pre - { - -moz-border-radius:7px 7px 7px 7px; - background-color:#F6F6F6; - border:1px solid #DDDDDD; - margin:0 20px 10px 10px; - padding:20px 15px 20px 20px; - overflow-x:auto; - } + .qmltype { text-align: center; @@ -719,13 +779,28 @@ float: right; color: #254117; } + + .qmldefault + { + float: right; + color: red; + } + + .qmldoc + { + } + + *.qmlitem p + { + } + #feedbackBox { - display:none; - -moz-border-radius:7px 7px 7px 7px; - border:1px solid #DDDDDD; - position:fixed; - top:100px; + display: none; + -moz-border-radius: 7px 7px 7px 7px; + border: 1px solid #DDDDDD; + position: fixed; + top: 100px; left: 33%; height: 190px; width: 400px; @@ -735,27 +810,27 @@ } #feedcloseX a { - display:inline; + display: inline; padding: 5px 5px 0 0; - margin-bottom:3px; + margin-bottom: 3px; color: #363534; - font-weight:600; + font-weight: 600; float: right; text-decoration: none; } + #feedbox - /* here */ { - display:inline; + display: inline; width: 370px; height: 120px; - margin:0px 25px 10px 15px; + margin: 0px 25px 10px 15px; } #feedsubmit { - display:inline; - float:right; - margin:4px 32px 0 0; + display: inline; + float: right; + margin: 4px 32px 0 0; } #blurpage { @@ -771,141 +846,172 @@ } .toc { - float: right; - -moz-border-radius:7px 7px 7px 7px; - background-color:#F6F6F6; - border:1px solid #DDDDDD; - margin:0 20px 10px 10px; - padding:20px 15px 20px 20px; + float: right; + -moz-border-radius: 7px 7px 7px 7px; + background-color: #F6F6F6; + border: 1px solid #DDDDDD; + margin: 0 20px 10px 10px; + padding: 20px 15px 20px 20px; height: auto; width: 200px; } - .toc ul + .toc h3 { - float: left; - padding: 15px; - + font: 600 12px/1.2 Arial; + } + + .wrap .content .toc ul + { + padding-left: 0px; + } + + + .wrap .content .toc .level2 + { + margin-left: 15px; } - .content .toc li { - font: normal 12px/1.2 Verdana; + font: normal 10px/1.2 Verdana; background: url(../images/bullet_dn.png) no-repeat 0 5px; } - .relpage + .relpage { -moz-border-radius: 7px 7px 7px 7px; border: 1px solid #DDDDDD; padding: 25px 25px; - clear:both; + clear: both; } .relpage ul { float: none; padding: 15px; } - .content .relpage li + .content .relpage li { font: normal 11px/1.2 Verdana; } - /* edit */ h3.fn, span.fn { background-color: #F6F6F6; border-width: 1px; border-style: solid; border-color: #E6E6E6; - font-weight: bold; - /* padding: 6px 0px 6px 10px;*/ - /* margin: 42px 0px 0px 0px;*/ + font-weight: bold; } - /* edit */ - .indexbox - { - width: 100%; - } - .content .indexboxcont li - { - font: normal 600 13px/1 Verdana; - } - /* .indexbox a - { - color: #00732f; - text-decoration: none; - }*/ - .indexbox a:hover, .indexbox a:visited:hover - { - color: #4c0033; - text-decoration: underline; - } - .indexbox a:visited + /* start index box */ + .indexbox { - color: #00732f; - text-decoration: none; + width: 100%; + display:inline-block; } .indexboxcont { display: block; + /* overflow: hidden;*/ } .indexboxbar { - background: transparent url( "../images/horBar.png" ) repeat-x left bottom; + background: transparent url(../images/horBar.png ) repeat-x left bottom; margin-bottom: 25px; + /* background-image: none; + border-bottom: 1px solid #e2e2e2;*/ } .indexboxcont .section { - display: inline-block; + display: inline-block; width: 49%; *width:42%; _width:42%; padding:0 2% 0 1%; vertical-align:top; + } .indexboxcont .indexIcon - { + { width: 11%; *width:18%; _width:18%; overflow:hidden; + } .indexboxcont .section p - { + { padding-top: 20px; padding-bottom: 20px; } - .indexboxcont .sectionlist { display: inline-block; width: 33%; - margin-right: -2px; - vertical-align: top; padding: 0; } - .tricol - { - - } .indexboxcont .sectionlist ul { - padding-left: 15px; margin-bottom: 20px; } -/* + .indexboxcont .sectionlist ul li { line-height: 12px; } -*/ + + .content .indexboxcont li + { + font: normal 600 13px/1 Verdana; + } + + .indexbox a:hover, .indexbox a:visited:hover + { + color: #4c0033; + text-decoration: underline; + } + + .indexbox a:visited + { + color: #00732f; + text-decoration: none; + } + + .indexboxcont:after + { + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; + } + + .indexbox .indexIcon span + { + display: block; + } + + .indexbox.guide .indexIcon span + { + width: 96px; + height: 137px; + background: url(../images/sprites-combined.png) no-repeat -5px -376px; + padding: 0; + } + + .indexbox.tools .indexIcon span + { + width: 115px; + height: 137px; + background: url(../images/sprites-combined.png) no-repeat -111px -376px; + padding: 0; + } + .lastcol { display: inline-block; @@ -916,12 +1022,9 @@ .tricol .lastcol { - margin-left:-6px; + margin-left: -6px; } - - /*.toc ul*/ - - /* end page elements */ + /* end indexbox */ } /* end of screen media */ @@ -929,7 +1032,7 @@ @media print { - .header, .footer, .toolbar, .feedback, .wrapper .hd, .wrapper .bd .sidebar, .wrapper .ft + input, textarea, .header, .footer, .toolbar, .feedback, .wrapper .hd, .wrapper .bd .sidebar, .wrapper .ft { display: none; background: none; -- cgit v0.12 From e98459fd11180c24ba9e549b96908cb33a68c714 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 4 May 2010 14:38:20 +0200 Subject: doc: Edited the intro. --- doc/src/declarative/declarativeui.qdoc | 60 ++++++++++++++++------------------ 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index d79c4d2..6a1f5c5 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -40,46 +40,42 @@ ****************************************************************************/ /*! -\title Declarative UI Using QML +\title Qt Quick \page declarativeui.html -\brief The Qt Declarative module provides a declarative framework for building -highly dynamic, custom user interfaces. +\brief Qt Quick provides a declarative framework for building highly +dynamic, custom user interfaces. -\section1 \l{QML Elements}{Fast QML Elements Reference Page} +Qt Quick provides a declarative framework for building highly dynamic, +custom user interfaces from a rich set of \l {QML Elements}{QML elements}. +Qt Quick helps programmers and designers collaborate to +build the fluid user interfaces that are becoming common in portable +consumer devices, such as mobile phones, media players, set-top boxes +and netbooks. -\raw HTML -
    -\endraw +QML is an extension to \l +{http://www.ecma-international.org/publications/standards/Ecma-262.htm} +{JavaScript}, that provides a mechanism to declaratively build an +object tree of \l {QML Elements}{QML elements}. QML improves the +integration between JavaScript and Qt's existing QObject based type +system, adds support for automatic \l {Property Binding}{property +bindings} and provides \l {Network Transparency}{network transparency} +at the language level. -\section1 Preamble +The \l {QML Elements}{QML elements} are a sophisticated set of +graphical and behavioral building blocks. These different elements +are combined together in \l {QML Documents}{QML documents} to build +components ranging in complexity from simple buttons and sliders, to +complete internet-enabled applications like a \l +{http://www.flickr.com}{Flickr} photo browser. -Qt Declarative UI provides a declarative framework for building highly dynamic, custom -user interfaces. Declarative UI helps programmers and designers collaborate to build -the animation rich, fluid user interfaces that are becoming common in portable -consumer devices, such as mobile phones, media players, set-top boxes and netbooks. - -The Qt Declarative module provides an engine for interpreting the declarative -QML language, and a rich set of \bold { \l {QML Elements}{QML elements} } -that can be used from QML. - -QML is an extension to \l {http://www.ecma-international.org/publications/standards/Ecma-262.htm} -{JavaScript}, that provides a mechanism to declaratively build an object tree -of QML elements. QML improves the integration between JavaScript and Qt's -existing QObject based type system, adds support for automatic -\l {Property Binding}{property bindings} and provides \l {Network Transparency}{network transparency} at the language -level. - -The QML elements are a sophisticated set of graphical and behavioral building -blocks. These different elements are combined together in \l {QML Documents}{QML documents} to build components -ranging in complexity from simple buttons and sliders, to complete -internet-enabled applications like a \l {http://www.flickr.com}{Flickr} photo browser. - -Qt Declarative builds on \l {QML for Qt programmers}{Qt's existing strengths}. -QML can be be used to incrementally extend an existing application or to build -completely new applications. QML is fully \l {Extending QML in C++}{extensible from C++}. +Qt Quick builds on \l {QML for Qt programmers}{Qt's existing +strengths}. QML can be be used to incrementally extend an existing +application or to build completely new applications. QML is fully \l +{Extending QML in C++}{extensible from C++}. \section1 Getting Started: + \list \o \l {Introduction to the QML language} \o \l {QML Tutorial}{Tutorial: 'Hello World'} -- cgit v0.12 From 3ff7825c6427d9b87f6eecf56e9b5e89e62f9056 Mon Sep 17 00:00:00 2001 From: Thomas Sondergaard Date: Tue, 4 May 2010 14:58:49 +0200 Subject: Allow QtDBus to be compiled as a static library on Windows. Merge-request: 569 Reviewed-by: Thiago Macieira --- src/dbus/qdbusmacros.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dbus/qdbusmacros.h b/src/dbus/qdbusmacros.h index 5447c33..144e44e 100644 --- a/src/dbus/qdbusmacros.h +++ b/src/dbus/qdbusmacros.h @@ -48,8 +48,10 @@ #if defined(QDBUS_MAKEDLL) # define QDBUS_EXPORT Q_DECL_EXPORT -#else +#elif defined(QT_SHARED) # define QDBUS_EXPORT Q_DECL_IMPORT +#else +# define QDBUS_EXPORT #endif #ifndef Q_MOC_RUN -- cgit v0.12 From 855bbe53b69fa12a9daec49e6326a6bbe4483342 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 4 May 2010 15:00:10 +0200 Subject: Doc: Fixed up the diagrams, aligning items with a grid. Reviewed-by: Trust Me --- doc/src/diagrams/modelview-move-rows-1.sk | 62 +++++++++++++++---------------- doc/src/diagrams/modelview-move-rows-2.sk | 46 +++++++++++------------ doc/src/diagrams/modelview-move-rows-3.sk | 54 +++++++++++++-------------- doc/src/diagrams/modelview-move-rows-4.sk | 40 ++++++++++---------- 4 files changed, 101 insertions(+), 101 deletions(-) diff --git a/doc/src/diagrams/modelview-move-rows-1.sk b/doc/src/diagrams/modelview-move-rows-1.sk index 3679dc7..dc90cfb 100644 --- a/doc/src/diagrams/modelview-move-rows-1.sk +++ b/doc/src/diagrams/modelview-move-rows-1.sk @@ -14,10 +14,10 @@ lw(1) r(30,0,0,-30,415.038,664.044) fp((1,1,1)) lw(1) -r(30,0,0,-30,219.351,425.18) +r(30,0,0,-30,220,425) fp((1,1,1)) lw(1) -r(30,0,0,-30,414.389,337.792) +r(30,0,0,-30,415,337.5) fp((1,1,1)) lw(1) r(30,0,0,-30,220,605) @@ -35,19 +35,19 @@ lw(1) r(30,0,0,-30,277.5,575) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,219.351,335.18) +r(30,0,0,-30,220,335) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,414.389,574.044) +r(30,0,0,-30,415,575) fp((1,1,1)) lw(1) r(30,0,0,-30,220,545) fp((1,1,1)) lw(1) -r(30.6087,0,0,-30,218.435,305.442) +r(30,0,0,-30.262,220,305.262) fp((1,1,1)) lw(1) -r(31.2174,0,0,-30,414.082,306.92) +r(30,0,0,-30,415,307.5) fp((1,1,1)) lw(1) r(30,0,0,-30,415.038,455.177) @@ -62,31 +62,31 @@ lw(1) r(30,0,0,-30,220,695) fp((1,1,1)) lw(1) -r(30,0,0,-30,415.038,694.044) +r(30,0,0,-30.956,415.038,695) fp((1,1,1)) lw(1) -r(30,0,0,-30,219.351,455.18) +r(30,0,0,-30,220,455) fp((1,1,1)) lw(1) -r(30,0,0,-30,414.389,367.792) +r(30,0,0,-30,415,367.5) fp((0.753,0.753,1)) lw(1) r(30,0,0,-30,277.5,605) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,219.351,365.18) +r(30,0,0,-30,220,365) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,414.389,604.044) +r(30,0,0,-30,415,605) fp((0.753,0.753,1)) lw(1) r(30,0,0,-30,277.5,635) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,219.351,395.18) +r(30,0,0,-30,220,395) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,414.389,634.044) +r(30,0,0,-30,415,635) le() lw(1) r(165,0,0,-230,210,705) @@ -107,13 +107,13 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('0',(228.791,433.32)) +txt('0',(229.44,433.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('0',(423.829,345.932)) +txt('0',(424.44,345.64)) fp((0,0,0)) le() lw(1) @@ -131,13 +131,13 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('1',(228.791,403.32)) +txt('1',(229.44,403.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('1',(423.829,315.932)) +txt('1',(424.44,315.64)) fp((0,0,0)) le() lw(1) @@ -161,13 +161,13 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('2',(228.791,373.32)) +txt('2',(229.44,373.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('2',(423.829,612.184)) +txt('2',(424.44,613.14)) fp((0,0,0)) le() lw(1) @@ -191,13 +191,13 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('3',(228.791,343.32)) +txt('3',(229.44,343.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('3',(423.829,582.184)) +txt('3',(424.44,583.14)) fp((0,0,0)) le() lw(1) @@ -221,13 +221,13 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('4',(228.791,313.32)) +txt('4',(229.44,313.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('4',(423.829,552.184)) +txt('4',(424.44,553.14)) fp((0,0,0)) le() lw(1) @@ -239,13 +239,13 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('5',(228.484,283.582)) +txt('5',(229.133,283.402)) fp((0.503,0.503,0.503)) le() lw(1) Fn('Helvetica') Fs(20) -txt('5',(423.522,285.06)) +txt('5',(424.44,285.64)) fp((0.503,0.503,0.503)) le() lw(1) @@ -255,17 +255,17 @@ txt('5',(424.478,433.317)) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(275,635,0) -bs(255,635,0) +bs(277.5,635,0) +bs(252.5,635,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(294.508,380.772,0) -bs(293.986,545.115,0) +bs(292.5,380,0) +bs(292.5,542.5,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(249.466,380.772,0) -bs(291.551,380.772,0) +bs(250,380,0) +bs(290,380,0) guidelayer('Guide Lines',1,0,0,1,(0,0,1)) grid((0,0,2.5,2.5),1,(0,0,1),'Grid') diff --git a/doc/src/diagrams/modelview-move-rows-2.sk b/doc/src/diagrams/modelview-move-rows-2.sk index c453a78..7ddb95e 100644 --- a/doc/src/diagrams/modelview-move-rows-2.sk +++ b/doc/src/diagrams/modelview-move-rows-2.sk @@ -14,10 +14,10 @@ lw(1) r(30,0,0,-30,415.038,664.044) fp((1,1,1)) lw(1) -r(30,0,0,-30,219.351,425.18) +r(30,0,0,-30,220,425) fp((1,1,1)) lw(1) -r(30,0,0,-30,414.389,337.792) +r(30,0,0,-30,415,337.5) fp((1,1,1)) lw(1) r(30,0,0,-30,220,605) @@ -35,7 +35,7 @@ lw(1) r(30,0,0,-30,275,455) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,219.351,335.18) +r(30,0,0,-30,220,335) fp((0.753,0.753,1)) lw(1) r(30,0,0,-30,415,455) @@ -47,10 +47,10 @@ lw(1) r(30,0,0,-30,415,545) fp((1,1,1)) lw(1) -r(30.6087,0,0,-30,218.435,305.442) +r(29.6927,0,0,-30,220,305.262) fp((1,1,1)) lw(1) -r(31.2174,0,0,-30,414.082,306.92) +r(30,0,0,-30,415,307.5) fp((1,1,1)) lw(1) r(30,0,0,-30,220,635) @@ -65,16 +65,16 @@ lw(1) r(30,0,0,-30,415.038,694.044) fp((1,1,1)) lw(1) -r(30,0,0,-30,219.351,455.18) +r(30,0,0,-30,220,455) fp((1,1,1)) lw(1) -r(30,0,0,-30,414.389,367.792) +r(30,0,0,-30,415,367.5) fp((0.753,0.753,1)) lw(1) r(30,0,0,-30,275,485) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,219.351,365.18) +r(30,0,0,-30,220,365) fp((0.753,0.753,1)) lw(1) r(30,0,0,-30,415,485) @@ -83,7 +83,7 @@ lw(1) r(30,0,0,-30,275,515) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,219.351,395.18) +r(30,0,0,-30,220,395) fp((0.753,0.753,1)) lw(1) r(30,0,0,-30,415,515) @@ -107,13 +107,13 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('0',(228.791,433.32)) +txt('0',(229.44,433.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('0',(423.829,345.932)) +txt('0',(424.44,345.64)) fp((0,0,0)) le() lw(1) @@ -131,13 +131,13 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('1',(228.791,403.32)) +txt('1',(229.44,403.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('1',(423.829,315.932)) +txt('1',(424.44,315.64)) fp((0,0,0)) le() lw(1) @@ -161,7 +161,7 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('2',(228.791,373.32)) +txt('2',(229.44,373.14)) fp((0,0,0)) le() lw(1) @@ -191,7 +191,7 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('3',(228.791,343.32)) +txt('3',(229.44,343.14)) fp((0,0,0)) le() lw(1) @@ -221,7 +221,7 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('4',(228.791,313.32)) +txt('4',(229.44,313.14)) fp((0,0,0)) le() lw(1) @@ -245,27 +245,27 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('5',(228.484,283.582)) +txt('5',(229.133,283.402)) fp((0.503,0.503,0.503)) le() lw(1) Fn('Helvetica') Fs(20) -txt('5',(423.522,285.06)) +txt('5',(424.44,285.64)) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(272.5,515,0) +bs(275,515,0) bs(252.5,515,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(294.508,380.772,0) -bs(295,425,0) +bs(292.5,380,0) +bs(292.5,422.5,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(249.466,380.772,0) -bs(291.551,380.772,0) +bs(250,380,0) +bs(290,380,0) guidelayer('Guide Lines',1,0,0,1,(0,0,1)) grid((0,0,2.5,2.5),1,(0,0,1),'Grid') diff --git a/doc/src/diagrams/modelview-move-rows-3.sk b/doc/src/diagrams/modelview-move-rows-3.sk index d320900..33a9ad1 100644 --- a/doc/src/diagrams/modelview-move-rows-3.sk +++ b/doc/src/diagrams/modelview-move-rows-3.sk @@ -4,30 +4,30 @@ layout('A4',0) layer('Layer 1',1,1,0,0,(0,0,0)) fp((1,1,1)) lw(1) -r(30,0,0,-30,219.351,425.18) +r(30,0,0,-30,220,425) fp((1,1,1)) lw(1) -r(30,0,0,-30,345.913,400) +r(30,0,0,-30,344.997,400) lw(1) -r(30,0,0,-30,219.351,335.18) +r(30,0,0,-30,220,335) lw(1) -r(30,0,0,-30,345.916,339.739) +r(30,0,0,-30,345,339.739) fp((1,1,1)) lw(1) -r(30.6087,0,0,-30,218.435,305.442) +r(30,0,0,-30,220,305.262) fp((1,1,1)) lw(1) -r(30.6087,0,0,-30,345,310) +r(30,0,0,-30,345,310) fp((1,1,1)) lw(1) -r(30,0,0,-30,219.351,455.18) +r(30,0,0,-30,220,455) fp((1,1,1)) lw(1) -r(30,0,0,-30,345.913,430) +r(30,0,0,-30,344.997,430) lw(1) -r(30,0,0,-30,219.351,365.18) +r(30,0,0,-30,220,365) lw(1) -r(30,0,0,-30,345.916,369.739) +r(30,0,0,-30,345,369.739) fp((0.753,0.753,1)) lw(1) r(30,0,0,-30,272.5,455) @@ -36,7 +36,7 @@ lw(1) r(30,0,0,-30,345,460) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,219.351,395.18) +r(30,0,0,-30,220,395) le() lw(1) r(165,0,0,-230,210,705) @@ -45,25 +45,25 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('0',(228.791,433.32)) +txt('0',(229.44,433.14)) fp((0.503,0.503,0.503)) le() lw(1) Fn('Helvetica') Fs(20) -txt('0',(355.353,408.14)) +txt('0',(354.437,408.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('1',(228.791,403.32)) +txt('1',(229.44,403.14)) fp((0.503,0.503,0.503)) le() lw(1) Fn('Helvetica') Fs(20) -txt('1',(355.353,378.14)) +txt('1',(354.437,378.14)) fp((0,0,0)) le() lw(1) @@ -81,37 +81,37 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('2',(228.791,373.32)) +txt('2',(229.44,373.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('3',(228.791,343.32)) +txt('3',(229.44,343.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('3',(355.356,347.879)) +txt('3',(354.44,347.879)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('4',(228.791,313.32)) +txt('4',(229.44,313.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('4',(355.356,317.879)) +txt('4',(354.44,317.879)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('5',(228.484,283.582)) +txt('5',(229.133,283.402)) fp((0,0,0)) le() lw(1) @@ -121,17 +121,17 @@ txt('5',(355.049,288.14)) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(270,455,0) -bs(250,455,0) +bs(272.5,455,0) +bs(252.5,455,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(294.508,380.772,0) -bs(295,425,0) +bs(287.5,380,0) +bs(287.5,422.5,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(249.466,380.772,0) -bs(291.551,380.772,0) +bs(250,380,0) +bs(285,380,0) guidelayer('Guide Lines',1,0,0,1,(0,0,1)) grid((0,0,2.5,2.5),1,(0,0,1),'Grid') diff --git a/doc/src/diagrams/modelview-move-rows-4.sk b/doc/src/diagrams/modelview-move-rows-4.sk index a8a1157..0531749 100644 --- a/doc/src/diagrams/modelview-move-rows-4.sk +++ b/doc/src/diagrams/modelview-move-rows-4.sk @@ -4,28 +4,28 @@ layout('A4',0) layer('Layer 1',1,1,0,0,(0,0,0)) fp((1,1,1)) lw(1) -r(30,0,0,-30,219.351,425.18) +r(30,0,0,-30,220,425) fp((1,1,1)) lw(1) r(30,0,0,-30,345,430) lw(1) -r(30,0,0,-30,219.351,335.18) +r(30,0,0,-30,220,335.18) lw(1) r(30,0,0,-30,345,339.739) fp((1,1,1)) lw(1) -r(30.6087,0,0,-30,218.435,305.442) +r(30,0,0,-30.442,220,305.442) fp((1,1,1)) lw(1) -r(30.6087,0,0,-30,344.084,310) +r(30,0,0,-30,345,310) fp((1,1,1)) lw(1) -r(30,0,0,-30,219.351,455.18) +r(30,0,0,-30,220,455) fp((1,1,1)) lw(1) r(30,0,0,-30,345,460) lw(1) -r(30,0,0,-30,219.351,365.18) +r(30,0,0,-30,220,365) lw(1) r(30,0,0,-30,345,400) fp((0.753,0.753,1)) @@ -36,7 +36,7 @@ lw(1) r(30,0,0,-30,345,370) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,219.351,395.18) +r(30,0,0,-30,220,395) le() lw(1) r(165,0,0,-230,210,705) @@ -45,7 +45,7 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('0',(228.791,433.32)) +txt('0',(229.44,433.14)) fp((0,0,0)) le() lw(1) @@ -57,7 +57,7 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('1',(228.791,403.32)) +txt('1',(229.44,403.14)) fp((0,0,0)) le() lw(1) @@ -81,13 +81,13 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('2',(228.791,373.32)) +txt('2',(229.44,373.14)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('3',(228.791,343.32)) +txt('3',(229.44,343.14)) fp((0.503,0.503,0.503)) le() lw(1) @@ -99,7 +99,7 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('4',(228.791,313.32)) +txt('4',(229.44,313.14)) fp((0,0,0)) le() lw(1) @@ -111,27 +111,27 @@ le() lw(1) Fn('Helvetica') Fs(20) -txt('5',(228.484,283.582)) +txt('5',(229.44,283.582)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('5',(354.133,288.14)) +txt('5',(354.44,288.14)) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(270,335,0) -bs(250,335,0) +bs(272.5,335,0) +bs(252.5,335,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(294.508,380.772,0) -bs(295,335,0) +bs(287.5,380,0) +bs(287.5,337.5,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(249.466,380.772,0) -bs(291.551,380.772,0) +bs(250,380,0) +bs(285,380,0) guidelayer('Guide Lines',1,0,0,1,(0,0,1)) grid((0,0,2.5,2.5),1,(0,0,1),'Grid') -- cgit v0.12 From d52cc1ded5f30a6da0d11b9c3f7de66b2d3e9ee9 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 4 May 2010 15:14:56 +0200 Subject: Fix rtl issues with sliders in GTK style Sliders that draw groove decorations did not invert appearance correctly in vertical or rtl cases. With this fix we will flip the rectangles of the respective decorations and tell gtk if we are using an rtl widget or not. Task-number: QTBUG-8986 Reviewed-yb: thorbjorn --- src/gui/styles/qgtkstyle.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index e3ca8b2..0988fd8 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -1937,14 +1937,11 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); - QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); bool horizontal = slider->orientation == Qt::Horizontal; bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; bool ticksBelow = slider->tickPosition & QSlider::TicksBelow; - QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight); - QPixmap cache; QBrush oldBrush = painter->brush(); QPen oldPen = painter->pen(); @@ -1953,6 +1950,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QColor highlightAlpha(Qt::white); highlightAlpha.setAlpha(80); + QGtkStylePrivate::gtk_widget_set_direction(hScaleWidget, slider->upsideDown ? + GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); GtkWidget *scaleWidget = horizontal ? hScaleWidget : vScaleWidget; style = scaleWidget->style; @@ -1986,11 +1985,21 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QRect lowerGroove = grooveRect; if (horizontal) { - upperGroove.setLeft(handle.center().x()); - lowerGroove.setRight(handle.center().x()); + if (slider->upsideDown) { + lowerGroove.setLeft(handle.center().x()); + upperGroove.setRight(handle.center().x()); + } else { + upperGroove.setLeft(handle.center().x()); + lowerGroove.setRight(handle.center().x()); + } } else { - upperGroove.setBottom(handle.center().y()); - lowerGroove.setTop(handle.center().y()); + if (!slider->upsideDown) { + lowerGroove.setBottom(handle.center().y()); + upperGroove.setTop(handle.center().y()); + } else { + upperGroove.setBottom(handle.center().y()); + lowerGroove.setTop(handle.center().y()); + } } gtkPainter.paintBox( scaleWidget, "trough-upper", upperGroove, state, -- cgit v0.12 From 409ced7dc098438e185b9a6db6b3f53b1472839d Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 4 May 2010 15:33:02 +0200 Subject: qdoc: Fixed the alphabet index in the compact list. Now it leaves out any letter that doesn't appear in the list. i.e. If there are no classes that begin with QJ... J does not appear in the alphabet index. --- doc/src/declarative/declarativeui.qdoc | 8 ++++---- tools/qdoc3/htmlgenerator.cpp | 13 ++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index 6a1f5c5..5283ba8 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -74,7 +74,7 @@ strengths}. QML can be be used to incrementally extend an existing application or to build completely new applications. QML is fully \l {Extending QML in C++}{extensible from C++}. -\section1 Getting Started: +\section1 Getting Started \list \o \l {Introduction to the QML language} @@ -84,7 +84,7 @@ application or to build completely new applications. QML is fully \l \o \l {QML for Qt programmers} \endlist -\section1 Core QML Features: +\section1 Core QML Features \list \o \l {QML Documents} \o \l {Property Binding} @@ -102,7 +102,7 @@ application or to build completely new applications. QML is fully \l \o \l {qmlruntime.html}{The Qt Declarative Runtime} \endlist -\section1 Using QML with C++: +\section1 Using QML with C++ \list \o \l {Tutorial: Writing QML extensions with C++} \o \l {Extending QML in C++} @@ -110,7 +110,7 @@ application or to build completely new applications. QML is fully \l \o \l {Integrating QML with existing Qt UI code} \endlist -\section1 Reference: +\section1 Reference \list \o \l {QML Elements} \o \l {QML Global Object} diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 569d1cd..d32ae99 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -2399,6 +2399,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, */ NodeMap paragraph[NumParagraphs+1]; QString paragraphName[NumParagraphs+1]; + QSet usedParagraphNames; NodeMap::ConstIterator c = classMap.begin(); while (c != classMap.end()) { @@ -2422,6 +2423,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, } paragraphName[paragraphNo] = key[0].toUpper(); + usedParagraphNames.insert(key[0].toLower().cell()); paragraph[paragraphNo].insert(key, c.value()); ++c; } @@ -2469,12 +2471,12 @@ void HtmlGenerator::generateCompactList(const Node *relative, out() << "

    "; for (int i = 0; i < 26; i++) { QChar ch('a' + i); - out() << QString("%2 ").arg(ch).arg(ch.toUpper()); + if (usedParagraphNames.contains(char('a' + i))) + out() << QString("%2 ").arg(ch).arg(ch.toUpper()); } out() << "

    \n"; } - QSet used; out() << "\n"; for (k = 0; k < numRows; k++) { out() << "\n"; @@ -2502,7 +2504,6 @@ void HtmlGenerator::generateCompactList(const Node *relative, if (includeAlphabet) { QChar c = paragraphName[currentParagraphNo[i]][0].toLower(); out() << QString("").arg(c); - used.insert(c.cell()); } out() << "" << paragraphName[currentParagraphNo[i]] @@ -2545,12 +2546,6 @@ void HtmlGenerator::generateCompactList(const Node *relative, out() << "\n"; } out() << "
    \n"; - char C = 'a'; - while (C <= 'z') { - if (!used.contains(C)) - out() << QString("").arg(C); - ++C; - } } void HtmlGenerator::generateFunctionIndex(const Node *relative, -- cgit v0.12 From 8737df24cd58359dacd3d0cb7f856cb7484f03c8 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Tue, 4 May 2010 15:53:33 +0200 Subject: Doc: Updating style and HTML in CSS and qdoc Adding all classnames generated in qdoc to the CSS and removing redundant   from htmlgenerator. Reviewed-by: Trust Me --- doc/src/template/style/style.css | 96 +++++++++++++++++++++++++++++++++++----- tools/qdoc3/htmlgenerator.cpp | 12 ++--- 2 files changed, 91 insertions(+), 17 deletions(-) diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index 9c290f5..2da91f3 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -58,6 +58,10 @@ { vertical-align: baseline; } + tt, .qmlreadonly span, .qmldefault span + { + word-spacing:5px; + } .heading { font: normal 600 16px/1.0 Arial; @@ -483,7 +487,7 @@ .wrap .content p { line-height: 20px; - padding: 10px 5px 10px 5px; + padding: 5px 5px 5px 5px; } .wrap .content ul { @@ -499,7 +503,11 @@ color: #4c0033; text-decoration: none; } - .footer + .content a:visited:hover + { + color: #4c0033; + text-decoration: underline; + } .footer { min-height: 100px; color: #797775; @@ -665,6 +673,10 @@ { font-variant: normal; } + .shortCut-topleft-inactive span a:hover, .shortCut-topleft-active a:hover + { + text-decoration:none; + } #shortCut { padding-top: 10px; @@ -732,12 +744,16 @@ } th { - padding: 3px 15px 3px 15px; + padding: 5px 15px 5px 15px; } td { padding: 3px 15px 3px 20px; } + td.rightAlign + { + padding: 3px 15px 3px 10px; + } table tr.odd { border-left: 1px solid #E6E6E6; @@ -758,7 +774,7 @@ { background-color: #E6E6E6; } - + span.comment { color: #8B0000; @@ -856,11 +872,35 @@ width: 200px; } - .toc h3 + .toc h3, .generic a { font: 600 12px/1.2 Arial; } + .generic{} + .alignedsummary{} + .propsummary{} + .memItemLeft{} + .memItemRight{} + .bottomAlign{} + .highlightedCode{} + .LegaleseLeft{} + .valuelist{} + .annotated{} + .obsolete{} + .compat{} + .flags{} + .qmlsummary{} + .qmlitem{} + .qmlproto{} + .qmlname{} + .qmlreadonly{} + .qmldefault{} + .qmldoc{} + .qt-style{} + .redFont{} + code{} + .wrap .content .toc ul { padding-left: 0px; @@ -901,8 +941,42 @@ border-style: solid; border-color: #E6E6E6; font-weight: bold; - } - + word-spacing:3px; + } + + .functionIndex { + font-size:12pt; + word-spacing:10px; + margin-bottom:10px; + background-color: #F6F6F6; + border-width: 1px; + border-style: solid; + border-color: #E6E6E6; + } + + .centerAlign + { + text-align:center; + } + + .rightAlign + { + text-align:right; + } + + + .leftAlign + { + text-align:left; + } + + .topAlign{ + vertical-align:top + } + + .functionIndex a{ + display:inline-block; + } /* start index box */ .indexbox @@ -929,8 +1003,8 @@ { display: inline-block; width: 49%; - *width:42%; - _width:42%; + /* *width:42%; + _width:42%;*/ padding:0 2% 0 1%; vertical-align:top; @@ -939,8 +1013,8 @@ .indexboxcont .indexIcon { width: 11%; - *width:18%; - _width:18%; + /* *width:18%; + _width:18%;*/ overflow:hidden; } diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index d32ae99..801e199 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -2507,7 +2507,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, } out() << "" << paragraphName[currentParagraphNo[i]] - << " "; + << ""; } out() << "\n"; @@ -2677,7 +2677,7 @@ void HtmlGenerator::generateQmlItem(const Node *node, if (summary) marked.replace("@name>", "b>"); - marked.replace("<@extra>", "  "); + marked.replace("<@extra>", ""); marked.replace("", ""); if (summary) { @@ -2986,7 +2986,7 @@ void HtmlGenerator::generateSynopsis(const Node *node, extraRegExp.setMinimal(true); marked.replace(extraRegExp, ""); } else { - marked.replace("<@extra>", "  "); + marked.replace("<@extra>", ""); marked.replace("", ""); } @@ -3265,7 +3265,7 @@ void HtmlGenerator::generateSynopsis(const Node *node, extraRegExp.setMinimal(true); marked.replace(extraRegExp, ""); } else { - marked.replace("<@extra>", "  "); + marked.replace("<@extra>", ""); marked.replace("", ""); } @@ -4436,9 +4436,9 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, out() << ""; out() << ""; if (!qpn->isWritable()) - out() << "read-only "; + out() << "read-only"; if (qpgn->isDefault()) - out() << "default "; + out() << "default"; generateQmlItem(qpn, relative, marker, false); out() << ""; if (qpgn->isDefault()) { -- cgit v0.12 From 62201af6fd7a704e936692231b35342ce051bb08 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 12 May 2010 10:49:07 +0200 Subject: REG 4.7: Edit widgets icon no longer in toolbar. Task-number: QTBUG-10626 Reviewed-by: Daniel Molkentin --- tools/designer/src/designer/qdesigner_actions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/designer/src/designer/qdesigner_actions.cpp b/tools/designer/src/designer/qdesigner_actions.cpp index a593a76..86b6214 100644 --- a/tools/designer/src/designer/qdesigner_actions.cpp +++ b/tools/designer/src/designer/qdesigner_actions.cpp @@ -347,6 +347,7 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) connect(m_editWidgetsAction, SIGNAL(triggered()), this, SLOT(editWidgetsSlot())); m_editWidgetsAction->setChecked(true); m_editWidgetsAction->setEnabled(false); + m_editWidgetsAction->setProperty(QDesignerActions::defaultToolbarPropertyName, true); m_toolActions->addAction(m_editWidgetsAction); connect(formWindowManager, SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)), -- cgit v0.12 From 0ebc9783d8ca0c4b27208bbc002c53c52c19ab4c Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 4 May 2010 16:25:18 +0200 Subject: Use qrand() instead of rand() This only affects X11 code, and are the only 2 places in Qt where rand() is used instead of qrand(). Task-number: QTBUG-9793 Reviewed-by: TrustMe --- src/gui/kernel/qwidget_x11.cpp | 2 +- src/gui/painting/qpaintengine_x11.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 37ac6bf..43f510c 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -3000,7 +3000,7 @@ Picture QX11Data::getSolidFill(int screen, const QColor &c) return X11->solid_fills[i].picture; } // none found, replace one - int i = rand() % 16; + int i = qrand() % 16; if (X11->solid_fills[i].screen != screen && X11->solid_fills[i].picture) { XRenderFreePicture (X11->display, X11->solid_fills[i].picture); diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index da48fcb..aef8b80 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -315,7 +315,7 @@ static Picture getPatternFill(int screen, const QBrush &b) return X11->pattern_fills[i].picture; } // none found, replace one - int i = rand() % 16; + int i = qrand() % 16; if (X11->pattern_fills[i].screen != screen && X11->pattern_fills[i].picture) { XRenderFreePicture (X11->display, X11->pattern_fills[i].picture); -- cgit v0.12 From 08d1eb4f79b9d633b97987cc55f618e6dd05e291 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 4 May 2010 16:27:57 +0200 Subject: Fix combobox backgroundrole not respected in some styles The issue was a regression in 4.5 since we introduced styling. We now set the background role as the menuoption palette when available. Reviewed-by: ogoffart Task-number: QTBUG-10403 --- src/gui/widgets/qcombobox.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 12b1c4a..664bb46 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -143,7 +143,10 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt menuOption.icon = qvariant_cast(variant); break; } - + if (qVariantCanConvert(index.data(Qt::BackgroundRole))) { + menuOption.palette.setBrush(QPalette::All, QPalette::Background, + qvariant_cast(index.data(Qt::BackgroundRole))); + } menuOption.text = index.model()->data(index, Qt::DisplayRole).toString() .replace(QLatin1Char('&'), QLatin1String("&&")); menuOption.tabWidth = 0; -- cgit v0.12 From d59ef5d00b6c07c3a1c332ebdd0fac060538940c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 4 May 2010 18:48:36 +0200 Subject: QtDeclarative: remove spurious semi-colons from the source code --- src/declarative/graphicsitems/qdeclarativegridview_p.h | 2 +- src/declarative/graphicsitems/qdeclarativelistview_p.h | 2 +- src/declarative/qml/qdeclarativebinding_p.h | 2 +- src/declarative/qml/qdeclarativecompiledbindings_p.h | 4 ++-- src/declarative/qml/qdeclarativecomponent_p.h | 2 +- src/declarative/qml/qdeclarativecontext.h | 2 +- src/declarative/qml/qdeclarativeguard_p.h | 2 +- src/declarative/qml/qdeclarativepropertycache.cpp | 2 +- src/declarative/qml/qdeclarativescriptstring.h | 2 +- src/declarative/qml/qdeclarativestringconverters_p.h | 2 +- src/declarative/qml/qdeclarativeworkerscript_p.h | 2 +- src/declarative/qml/qdeclarativexmlhttprequest.cpp | 6 +++--- src/declarative/util/qdeclarativelistmodelworkeragent_p.h | 2 +- src/declarative/util/qdeclarativesmoothedanimation_p.h | 2 +- src/declarative/util/qdeclarativesmoothedfollow_p.h | 2 +- src/declarative/util/qdeclarativetransitionmanager_p_p.h | 2 +- 16 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h index c06879e..f5d061d 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview_p.h +++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h @@ -142,7 +142,7 @@ public: void setSnapMode(SnapMode mode); enum PositionMode { Beginning, Center, End, Visible, Contain }; - Q_ENUMS(PositionMode); + Q_ENUMS(PositionMode) Q_INVOKABLE void positionViewAtIndex(int index, int mode); Q_INVOKABLE int indexAt(int x, int y) const; diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h index 9c0b7dd..051455c 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview_p.h +++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h @@ -200,7 +200,7 @@ public: static QDeclarativeListViewAttached *qmlAttachedProperties(QObject *); enum PositionMode { Beginning, Center, End, Visible, Contain }; - Q_ENUMS(PositionMode); + Q_ENUMS(PositionMode) Q_INVOKABLE void positionViewAtIndex(int index, int mode); Q_INVOKABLE int indexAt(int x, int y) const; diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h index 2d3acf5..598f09f 100644 --- a/src/declarative/qml/qdeclarativebinding_p.h +++ b/src/declarative/qml/qdeclarativebinding_p.h @@ -164,6 +164,6 @@ private: QT_END_NAMESPACE -Q_DECLARE_METATYPE(QDeclarativeBinding*); +Q_DECLARE_METATYPE(QDeclarativeBinding*) #endif // QDECLARATIVEBINDING_P_H diff --git a/src/declarative/qml/qdeclarativecompiledbindings_p.h b/src/declarative/qml/qdeclarativecompiledbindings_p.h index a17bc84..d5c6a02 100644 --- a/src/declarative/qml/qdeclarativecompiledbindings_p.h +++ b/src/declarative/qml/qdeclarativecompiledbindings_p.h @@ -104,8 +104,8 @@ protected: int qt_metacall(QMetaObject::Call, int, void **); private: - Q_DISABLE_COPY(QDeclarativeCompiledBindings); - Q_DECLARE_PRIVATE(QDeclarativeCompiledBindings); + Q_DISABLE_COPY(QDeclarativeCompiledBindings) + Q_DECLARE_PRIVATE(QDeclarativeCompiledBindings) }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h index 24e5386..8b95945 100644 --- a/src/declarative/qml/qdeclarativecomponent_p.h +++ b/src/declarative/qml/qdeclarativecomponent_p.h @@ -149,7 +149,7 @@ Q_SIGNALS: void destruction(); private: - friend class QDeclarativeContextData;; + friend class QDeclarativeContextData; friend class QDeclarativeComponentPrivate; }; diff --git a/src/declarative/qml/qdeclarativecontext.h b/src/declarative/qml/qdeclarativecontext.h index 548869c..d87123a 100644 --- a/src/declarative/qml/qdeclarativecontext.h +++ b/src/declarative/qml/qdeclarativecontext.h @@ -107,7 +107,7 @@ private: }; QT_END_NAMESPACE -Q_DECLARE_METATYPE(QList); +Q_DECLARE_METATYPE(QList) QT_END_HEADER diff --git a/src/declarative/qml/qdeclarativeguard_p.h b/src/declarative/qml/qdeclarativeguard_p.h index be60ce4..02fed0b 100644 --- a/src/declarative/qml/qdeclarativeguard_p.h +++ b/src/declarative/qml/qdeclarativeguard_p.h @@ -97,7 +97,7 @@ private: QT_END_NAMESPACE -Q_DECLARE_METATYPE(QDeclarativeGuard); +Q_DECLARE_METATYPE(QDeclarativeGuard) #include "private/qdeclarativedata_p.h" diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index 888945b..26bddde 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -45,7 +45,7 @@ #include "private/qdeclarativebinding_p.h" #include -Q_DECLARE_METATYPE(QScriptValue); +Q_DECLARE_METATYPE(QScriptValue) QT_BEGIN_NAMESPACE diff --git a/src/declarative/qml/qdeclarativescriptstring.h b/src/declarative/qml/qdeclarativescriptstring.h index 43bef44..fc92a9b 100644 --- a/src/declarative/qml/qdeclarativescriptstring.h +++ b/src/declarative/qml/qdeclarativescriptstring.h @@ -79,7 +79,7 @@ private: QT_END_NAMESPACE -Q_DECLARE_METATYPE(QDeclarativeScriptString); +Q_DECLARE_METATYPE(QDeclarativeScriptString) QT_END_HEADER diff --git a/src/declarative/qml/qdeclarativestringconverters_p.h b/src/declarative/qml/qdeclarativestringconverters_p.h index 7afdfd3..97f72fc 100644 --- a/src/declarative/qml/qdeclarativestringconverters_p.h +++ b/src/declarative/qml/qdeclarativestringconverters_p.h @@ -80,7 +80,7 @@ namespace QDeclarativeStringConverters QSizeF Q_DECLARATIVE_EXPORT sizeFFromString(const QString &, bool *ok = 0); QRectF Q_DECLARATIVE_EXPORT rectFFromString(const QString &, bool *ok = 0); QVector3D Q_DECLARATIVE_EXPORT vector3DFromString(const QString &, bool *ok = 0); -}; +} QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeworkerscript_p.h b/src/declarative/qml/qdeclarativeworkerscript_p.h index 6cce799..4019d13 100644 --- a/src/declarative/qml/qdeclarativeworkerscript_p.h +++ b/src/declarative/qml/qdeclarativeworkerscript_p.h @@ -119,7 +119,7 @@ private: QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeWorkerScript); +QML_DECLARE_TYPE(QDeclarativeWorkerScript) QT_END_HEADER diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp index b7e1832..e034165 100644 --- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp +++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp @@ -318,9 +318,9 @@ public: QT_END_NAMESPACE -Q_DECLARE_METATYPE(Node); -Q_DECLARE_METATYPE(NodeList); -Q_DECLARE_METATYPE(NamedNodeMap); +Q_DECLARE_METATYPE(Node) +Q_DECLARE_METATYPE(NodeList) +Q_DECLARE_METATYPE(NamedNodeMap) QT_BEGIN_NAMESPACE diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent_p.h b/src/declarative/util/qdeclarativelistmodelworkeragent_p.h index 53d30c2..1622144 100644 --- a/src/declarative/util/qdeclarativelistmodelworkeragent_p.h +++ b/src/declarative/util/qdeclarativelistmodelworkeragent_p.h @@ -146,7 +146,7 @@ private: QT_END_NAMESPACE -Q_DECLARE_METATYPE(QDeclarativeListModelWorkerAgent::VariantRef); +Q_DECLARE_METATYPE(QDeclarativeListModelWorkerAgent::VariantRef) QT_END_HEADER diff --git a/src/declarative/util/qdeclarativesmoothedanimation_p.h b/src/declarative/util/qdeclarativesmoothedanimation_p.h index 17aafa4..f45d19f 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation_p.h +++ b/src/declarative/util/qdeclarativesmoothedanimation_p.h @@ -96,7 +96,7 @@ Q_SIGNALS: QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeSmoothedAnimation); +QML_DECLARE_TYPE(QDeclarativeSmoothedAnimation) QT_END_HEADER diff --git a/src/declarative/util/qdeclarativesmoothedfollow_p.h b/src/declarative/util/qdeclarativesmoothedfollow_p.h index d860052..6319192 100644 --- a/src/declarative/util/qdeclarativesmoothedfollow_p.h +++ b/src/declarative/util/qdeclarativesmoothedfollow_p.h @@ -106,7 +106,7 @@ Q_SIGNALS: QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeSmoothedFollow); +QML_DECLARE_TYPE(QDeclarativeSmoothedFollow) QT_END_HEADER diff --git a/src/declarative/util/qdeclarativetransitionmanager_p_p.h b/src/declarative/util/qdeclarativetransitionmanager_p_p.h index 4131391..2e23898 100644 --- a/src/declarative/util/qdeclarativetransitionmanager_p_p.h +++ b/src/declarative/util/qdeclarativetransitionmanager_p_p.h @@ -70,7 +70,7 @@ public: void cancel(); private: - Q_DISABLE_COPY(QDeclarativeTransitionManager); + Q_DISABLE_COPY(QDeclarativeTransitionManager) QDeclarativeTransitionManagerPrivate *d; void complete(); -- cgit v0.12 From 395e00552802024cb41335bc87675441ff119d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 4 May 2010 18:43:42 +0200 Subject: Skip tst_LargeFile::mapOffsetOverflow on Mac On this platform mmap'ing beyond EOF may succeed, even beyond filesystem capabilities, but generate Bus Errors on access. Skipping this failing test and accepting the underlying undefined behavior is the right thing to do, until QFile offers proper guarantees. Reviewed-by: Thiago Macieira --- tests/auto/qfile/largefile/tst_largefile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index 041e5f2..60c5f89 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -523,6 +523,10 @@ void tst_LargeFile::mapFile() void tst_LargeFile::mapOffsetOverflow() { +#if defined(Q_OS_MAC) + QSKIP("mmap'ping beyond EOF may succeed; generate bus error on access", SkipAll); +#endif + // Out-of-range mappings should fail, and not silently clip the offset for (int i = 50; i < 63; ++i) { uchar *address = 0; -- cgit v0.12 From 36e6c652bc087a6adcef1fad9f899b787e67e9af Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 5 May 2010 10:06:52 +1000 Subject: Update changelog. --- dist/changes-4.7.0 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0 index 4fd7fdb..d156bd7 100644 --- a/dist/changes-4.7.0 +++ b/dist/changes-4.7.0 @@ -27,6 +27,13 @@ General Improvements - Support for the GL_EXT_geometry_shader4, aka Geometry Shaders, was added to QGLShaderProgram. +New features +------------ + + - QNetworkSession, QNetworkConfiguration, QNetworkConfigurationManager + * New bearer management classes added. + + Third party components ---------------------- -- cgit v0.12 From 44144cf60e978f7d5d70aec49d114d57832a78c3 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 5 May 2010 09:37:01 +0200 Subject: Fix a bug in QGraphicsItem::scroll. If the rect argument is null, well we should not do the scrolling with an null rectangle but rather with the boundingRect like the documentation says. Task-number:QTBUG-10400 Reviewed-by:janarve --- src/gui/graphicsview/qgraphicsitem.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 326f130..81138d9 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -5635,8 +5635,9 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect) // Adjust with 2 pixel margin. Notice the loss of precision // when converting to QRect. int adjust = 2; + QRectF scrollRect = !rect.isNull() ? rect : boundingRect(); QRectF br = boundingRect().adjusted(-adjust, -adjust, adjust, adjust); - QRect irect = rect.toRect().translated(-br.x(), -br.y()); + QRect irect = scrollRect.toRect().translated(-br.x(), -br.y()); pix.scroll(dx, dy, irect); @@ -5644,11 +5645,11 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect) // Translate the existing expose. foreach (QRectF exposedRect, c->exposed) - c->exposed += exposedRect.translated(dx, dy) & rect; + c->exposed += exposedRect.translated(dx, dy) & scrollRect; // Calculate exposure. QRegion exposed; - QRect r = rect.toRect(); + QRect r = scrollRect.toRect(); exposed += r; exposed -= r.translated(dx, dy); foreach (QRect rect, exposed.rects()) -- cgit v0.12 From 87f7444d2af1299460bdbfc1cbfa903ea504b7e3 Mon Sep 17 00:00:00 2001 From: aavit Date: Wed, 5 May 2010 10:20:03 +0200 Subject: Fixes regression: SVG image loading would fail from QBuffer with pos!=0 Was introduced with 2fe059c. Also now updates pos() as expected after reading in these cases. Autotest added to catch issues where pos != 0, or wrong pos after read. Reviewed-by: Kim --- src/plugins/imageformats/svg/qsvgiohandler.cpp | 10 ++-- tests/auto/qimagereader/tst_qimagereader.cpp | 63 +++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp index 8155569..7b8463d 100644 --- a/src/plugins/imageformats/svg/qsvgiohandler.cpp +++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp @@ -82,15 +82,19 @@ bool QSvgIOHandlerPrivate::load(QIODevice *device) if (q->format().isEmpty()) q->canRead(); + // # The SVG renderer doesn't handle trailing, unrelated data, so we must + // assume that all available data in the device is to be read. bool res = false; QBuffer *buf = qobject_cast(device); if (buf) { - res = r.load(buf->data()); + const QByteArray &ba = buf->data(); + res = r.load(QByteArray::fromRawData(ba.constData() + buf->pos(), ba.size() - buf->pos())); + buf->seek(ba.size()); } else if (q->format() == "svgz") { - res = r.load(device->readAll()); // ### can't stream svgz + res = r.load(device->readAll()); } else { xmlReader.setDevice(device); - res = r.load(&xmlReader); //### doesn't leave pos() correctly + res = r.load(&xmlReader); } if (res) { diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 1b4c502..aadee5b 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -114,6 +114,9 @@ private slots: void readFromFileAfterJunk_data(); void readFromFileAfterJunk(); + void devicePosition_data(); + void devicePosition(); + void setBackgroundColor_data(); void setBackgroundColor(); @@ -1117,7 +1120,7 @@ void tst_QImageReader::readFromFileAfterJunk() QByteArray imageData = imageFile.readAll(); QVERIFY(!imageData.isNull()); - int iterations = 10; + int iterations = 3; if (format == "ppm" || format == "pbm" || format == "pgm" || format == "svg" || format == "svgz") iterations = 1; @@ -1147,6 +1150,64 @@ void tst_QImageReader::readFromFileAfterJunk() } } +void tst_QImageReader::devicePosition_data() +{ + QTest::addColumn("fileName"); + QTest::addColumn("format"); + + QTest::newRow("pbm") << QString("image.pbm") << QByteArray("pbm"); + QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm"); + QTest::newRow("ppm-1") << QString("image.ppm") << QByteArray("ppm"); +#ifdef QTEST_HAVE_JPEG + QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg"); + QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg"); + QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg"); +#endif +#if defined QTEST_HAVE_GIF + QTest::newRow("gif-1") << QString("earth.gif") << QByteArray("gif"); +#endif + QTest::newRow("xbm") << QString("gnus.xbm") << QByteArray("xbm"); + QTest::newRow("xpm") << QString("marble.xpm") << QByteArray("xpm"); + QTest::newRow("bmp-1") << QString("colorful.bmp") << QByteArray("bmp"); + QTest::newRow("bmp-2") << QString("font.bmp") << QByteArray("bmp"); + QTest::newRow("png") << QString("kollada.png") << QByteArray("png"); +// QTest::newRow("mng-1") << QString("images/ball.mng") << QByteArray("mng"); +// QTest::newRow("mng-2") << QString("images/fire.mng") << QByteArray("mng"); +#if defined QTEST_HAVE_SVG + QTest::newRow("svg") << QString("rect.svg") << QByteArray("svg"); + QTest::newRow("svgz") << QString("rect.svgz") << QByteArray("svgz"); +#endif +} + +void tst_QImageReader::devicePosition() +{ + QFETCH(QString, fileName); + QFETCH(QByteArray, format); + + QImage expected(prefix + fileName); + QVERIFY(!expected.isNull()); + + QFile imageFile(prefix + fileName); + QVERIFY(imageFile.open(QFile::ReadOnly)); + QByteArray imageData = imageFile.readAll(); + QVERIFY(!imageData.isNull()); + int imageDataSize = imageData.size(); + + const char *preStr = "prebeef\n"; + int preLen = qstrlen(preStr); + imageData.prepend(preStr); + if (format != "svg" && format != "svgz") // Doesn't handle trailing data + imageData.append("\npostbeef"); + QBuffer buf(&imageData); + buf.open(QIODevice::ReadOnly); + buf.seek(preLen); + QImageReader reader(&buf, format); + QCOMPARE(expected, reader.read()); + if (format != "ppm" && format != "gif") // Known not to work + QCOMPARE(buf.pos(), qint64(preLen+imageDataSize)); +} + + void tst_QImageReader::description_data() { QTest::addColumn("fileName"); -- cgit v0.12 From 0e5924bc207d7de29b28fb223a2027d5d2d694fa Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 5 May 2010 10:37:08 +0200 Subject: qdoc: Removed [module name] from class ref pages. The module name is now a breadcrumb. --- tools/qdoc3/htmlgenerator.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 801e199..3120473 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1243,6 +1243,8 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, subtitleText << "(" << Atom(Atom::AutoLink, fullTitle) << ")" << Atom(Atom::LineBreak); +#if 0 + // No longer used because the modeule name is a breadcrumb. QString fixedModule = inner->moduleName(); if (fixedModule == "Qt3SupportLight") fixedModule = "Qt3Support"; @@ -1263,6 +1265,7 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, subtitleText << "]"; } } +#endif generateHeader(title, inner, marker); sections = marker->sections(inner, CodeMarker::Summary, CodeMarker::Okay); -- cgit v0.12 From a976ba471d35fd57857b05cee5fdb4d6aa64c961 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 5 May 2010 10:15:20 +0200 Subject: correct misleading note in configure on Windows the option given in the note would not work if used as described. Reviewed-by: Zeno Albisser Task-number: QTBUG-2089 --- configure.exe | Bin 1319424 -> 1318912 bytes tools/configure/configureapp.cpp | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.exe b/configure.exe index 35116ff..161fa1d 100755 Binary files a/configure.exe and b/configure.exe differ diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index bfa7445..79864f8 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -3457,7 +3457,7 @@ void Configure::displayConfig() cout << "NOTE: When linking against OpenSSL, you can override the default" << endl; cout << "library names through OPENSSL_LIBS." << endl; cout << "For example:" << endl; - cout << " configure -openssl-linked OPENSSL_LIBS='-lssleay32 -llibeay32'" << endl; + cout << " configure -openssl-linked OPENSSL_LIBS=\"-lssleay32 -llibeay32\"" << endl; } if( dictionary[ "ZLIB_FORCED" ] == "yes" ) { QString which_zlib = "supplied"; -- cgit v0.12 From 6b02a101cb96dee4bc574ebec1f91c9243f278fb Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 5 May 2010 11:19:00 +0200 Subject: Some minor code cleanup Removes unused code from gkt and cleanlooks. Reviewed-by: Trust Me --- src/gui/styles/qcleanlooksstyle.cpp | 3 --- src/gui/styles/qgtkstyle.cpp | 17 ----------------- 2 files changed, 20 deletions(-) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index ba24d97..d9f7df0 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -1397,7 +1397,6 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o dark.lighter(135), 60); QColor highlight = option->palette.highlight().color(); - QColor highlightText = option->palette.highlightedText().color(); switch(element) { case CE_RadioButton: //fall through @@ -2723,7 +2722,6 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp { // Fill title bar gradient QColor titlebarColor = QColor(active ? highlight: palette.background().color()); - QColor titleBarGradientStop(active ? highlight.darker(150): palette.background().color().darker(120)); QLinearGradient gradient(option->rect.center().x(), option->rect.top(), option->rect.center().x(), option->rect.bottom()); @@ -2986,7 +2984,6 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->fillRect(option->rect, option->palette.background()); - QRect rect = scrollBar->rect; QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 0988fd8..6c8d561 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -1163,7 +1163,6 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, if (const QStyleOptionTabBarBase *tbb = qstyleoption_cast(option)) { QRect tabRect = tbb->rect; - QRegion region(tabRect); painter->save(); painter->setPen(QPen(option->palette.dark().color().dark(110), 0)); switch (tbb->shape) { @@ -1245,8 +1244,6 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom else alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline); - QPalette palette = option->palette; - switch (control) { case CC_TitleBar: @@ -1333,11 +1330,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom bool isEnabled = (comboBox->state & State_Enabled); bool focus = isEnabled && (comboBox->state & State_HasFocus); - QColor buttonShadow = option->palette.dark().color(); GtkStateType state = gtkPainter.gtkState(option); int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget); - QPixmap cache; - QString pixmapName; QStyleOptionComboBox comboBoxCopy = *comboBox; comboBoxCopy.rect = option->rect; @@ -1345,8 +1339,6 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QRect rect = option->rect; QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxArrow, widget); - QRect editRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, - SC_ComboBoxEditField, widget); GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ? GTK_SHADOW_IN : GTK_SHADOW_OUT; @@ -1414,9 +1406,6 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom else if (option->state & State_MouseOver && comboBox->activeSubControls & SC_ComboBoxArrow) buttonState = GTK_STATE_PRELIGHT; - QRect buttonrect = QRect(gtkToggleButton->allocation.x, gtkToggleButton->allocation.y, - gtkToggleButton->allocation.width, gtkToggleButton->allocation.height); - Q_ASSERT(gtkToggleButton); gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState, shadow, gtkToggleButton->style, buttonPath.toString() + @@ -1436,8 +1425,6 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom if (focus) GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); - QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") - : QHashableLatin1Literal("GtkComboBox.GtkToggleButton"); // Draw the separator between label and arrows QHashableLatin1Literal vSeparatorPath = comboBox->editable @@ -2557,7 +2544,6 @@ void QGtkStyle::drawControl(ControlElement element, d->gtkWidget("GtkMenu.GtkMenuItem"); style = gtkPainter.getStyle(gtkMenuItem); - QColor borderColor = option->palette.background().color().darker(160); QColor shadow = option->palette.dark().color(); if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { @@ -2782,8 +2768,6 @@ void QGtkStyle::drawControl(ControlElement element, // Arrow if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow - QPoint buttonShift(pixelMetric(PM_ButtonShiftHorizontal, option, widget), - proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget)); QFontMetrics fm(menuitem->font); int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness; @@ -3130,7 +3114,6 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple case CC_ComboBox: if (const QStyleOptionComboBox *box = qstyleoption_cast(option)) { // We employ the gtk widget to position arrows and separators for us - QString comboBoxPath = box->editable ? QLS("GtkComboBoxEntry") : QLS("GtkComboBox"); GtkWidget *gtkCombo = box->editable ? d->gtkWidget("GtkComboBoxEntry") : d->gtkWidget("GtkComboBox"); d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); -- cgit v0.12 From e9dda3cabdcfdeb5d659b94640410b486ad58921 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 29 Apr 2010 17:30:16 +0100 Subject: Add spectrum analyzer demo app This application is a demo which uses the QtMultimedia APIs to capture and play back PCM audio. While either recording or playback is ongoing, the application performs real-time level and frequency spectrum analysis. Reviewed-by: Alessandro Portale --- .gitignore | 2 + demos/demos.pro | 2 + demos/embedded/fluidlauncher/config_s60/config.xml | 1 + demos/embedded/fluidlauncher/fluidlauncher.pro | 11 + .../fluidlauncher/screenshots/spectrum.png | Bin 0 -> 21771 bytes demos/qtdemo/xml/examples.xml | 1 + demos/spectrum/README.txt | 103 +++ demos/spectrum/TODO.txt | 34 + demos/spectrum/app/app.pro | 119 +++ demos/spectrum/app/engine.cpp | 752 +++++++++++++++++ demos/spectrum/app/engine.h | 309 +++++++ demos/spectrum/app/frequencyspectrum.cpp | 90 ++ demos/spectrum/app/frequencyspectrum.h | 93 +++ demos/spectrum/app/images/record.png | Bin 0 -> 670 bytes demos/spectrum/app/images/settings.png | Bin 0 -> 3649 bytes demos/spectrum/app/levelmeter.cpp | 143 ++++ demos/spectrum/app/levelmeter.h | 111 +++ demos/spectrum/app/main.cpp | 58 ++ demos/spectrum/app/mainwidget.cpp | 455 ++++++++++ demos/spectrum/app/mainwidget.h | 136 +++ demos/spectrum/app/progressbar.cpp | 141 ++++ demos/spectrum/app/progressbar.h | 69 ++ demos/spectrum/app/settingsdialog.cpp | 149 ++++ demos/spectrum/app/settingsdialog.h | 82 ++ demos/spectrum/app/spectrograph.cpp | 242 ++++++ demos/spectrum/app/spectrograph.h | 94 +++ demos/spectrum/app/spectrum.h | 139 ++++ demos/spectrum/app/spectrum.qrc | 7 + demos/spectrum/app/spectrum.sh | 9 + demos/spectrum/app/spectrumanalyser.cpp | 280 +++++++ demos/spectrum/app/spectrumanalyser.h | 188 +++++ demos/spectrum/app/tonegenerator.cpp | 92 +++ demos/spectrum/app/tonegenerator.h | 51 ++ demos/spectrum/app/tonegeneratordialog.cpp | 148 ++++ demos/spectrum/app/tonegeneratordialog.h | 76 ++ demos/spectrum/app/utils.cpp | 138 ++++ demos/spectrum/app/utils.h | 107 +++ demos/spectrum/app/waveform.cpp | 419 ++++++++++ demos/spectrum/app/waveform.h | 196 +++++ demos/spectrum/app/wavfile.cpp | 247 ++++++ demos/spectrum/app/wavfile.h | 78 ++ demos/spectrum/fftreal/Array.h | 97 +++ demos/spectrum/fftreal/Array.hpp | 98 +++ demos/spectrum/fftreal/DynArray.h | 100 +++ demos/spectrum/fftreal/DynArray.hpp | 143 ++++ demos/spectrum/fftreal/FFTReal.dsp | 273 ++++++ demos/spectrum/fftreal/FFTReal.dsw | 29 + demos/spectrum/fftreal/FFTReal.h | 142 ++++ demos/spectrum/fftreal/FFTReal.hpp | 916 +++++++++++++++++++++ demos/spectrum/fftreal/FFTRealFixLen.h | 130 +++ demos/spectrum/fftreal/FFTRealFixLen.hpp | 322 ++++++++ demos/spectrum/fftreal/FFTRealFixLenParam.h | 93 +++ demos/spectrum/fftreal/FFTRealPassDirect.h | 96 +++ demos/spectrum/fftreal/FFTRealPassDirect.hpp | 204 +++++ demos/spectrum/fftreal/FFTRealPassInverse.h | 101 +++ demos/spectrum/fftreal/FFTRealPassInverse.hpp | 229 ++++++ demos/spectrum/fftreal/FFTRealSelect.h | 77 ++ demos/spectrum/fftreal/FFTRealSelect.hpp | 62 ++ demos/spectrum/fftreal/FFTRealUseTrigo.h | 101 +++ demos/spectrum/fftreal/FFTRealUseTrigo.hpp | 91 ++ demos/spectrum/fftreal/OscSinCos.h | 106 +++ demos/spectrum/fftreal/OscSinCos.hpp | 122 +++ demos/spectrum/fftreal/TestAccuracy.h | 105 +++ demos/spectrum/fftreal/TestAccuracy.hpp | 472 +++++++++++ demos/spectrum/fftreal/TestHelperFixLen.h | 93 +++ demos/spectrum/fftreal/TestHelperFixLen.hpp | 93 +++ demos/spectrum/fftreal/TestHelperNormal.h | 94 +++ demos/spectrum/fftreal/TestHelperNormal.hpp | 99 +++ demos/spectrum/fftreal/TestSpeed.h | 95 +++ demos/spectrum/fftreal/TestSpeed.hpp | 223 +++++ demos/spectrum/fftreal/TestWhiteNoiseGen.h | 95 +++ demos/spectrum/fftreal/TestWhiteNoiseGen.hpp | 91 ++ demos/spectrum/fftreal/bwins/fftrealu.def | 5 + demos/spectrum/fftreal/def.h | 60 ++ demos/spectrum/fftreal/eabi/fftrealu.def | 7 + demos/spectrum/fftreal/fftreal.pas | 661 +++++++++++++++ demos/spectrum/fftreal/fftreal.pro | 41 + demos/spectrum/fftreal/fftreal_wrapper.cpp | 54 ++ demos/spectrum/fftreal/fftreal_wrapper.h | 63 ++ demos/spectrum/fftreal/license.txt | 459 +++++++++++ demos/spectrum/fftreal/readme.txt | 242 ++++++ .../fftreal/stopwatch/ClockCycleCounter.cpp | 285 +++++++ .../spectrum/fftreal/stopwatch/ClockCycleCounter.h | 124 +++ .../fftreal/stopwatch/ClockCycleCounter.hpp | 150 ++++ demos/spectrum/fftreal/stopwatch/Int64.h | 71 ++ demos/spectrum/fftreal/stopwatch/StopWatch.cpp | 101 +++ demos/spectrum/fftreal/stopwatch/StopWatch.h | 110 +++ demos/spectrum/fftreal/stopwatch/StopWatch.hpp | 83 ++ demos/spectrum/fftreal/stopwatch/def.h | 65 ++ demos/spectrum/fftreal/stopwatch/fnc.h | 67 ++ demos/spectrum/fftreal/stopwatch/fnc.hpp | 85 ++ demos/spectrum/fftreal/test.cpp | 267 ++++++ demos/spectrum/fftreal/test_fnc.h | 53 ++ demos/spectrum/fftreal/test_fnc.hpp | 56 ++ demos/spectrum/fftreal/test_settings.h | 45 + demos/spectrum/fftreal/testapp.dpr | 150 ++++ demos/spectrum/spectrum.pri | 37 + demos/spectrum/spectrum.pro | 39 + 98 files changed, 13744 insertions(+) create mode 100644 demos/embedded/fluidlauncher/screenshots/spectrum.png create mode 100644 demos/spectrum/README.txt create mode 100644 demos/spectrum/TODO.txt create mode 100644 demos/spectrum/app/app.pro create mode 100644 demos/spectrum/app/engine.cpp create mode 100644 demos/spectrum/app/engine.h create mode 100644 demos/spectrum/app/frequencyspectrum.cpp create mode 100644 demos/spectrum/app/frequencyspectrum.h create mode 100644 demos/spectrum/app/images/record.png create mode 100644 demos/spectrum/app/images/settings.png create mode 100644 demos/spectrum/app/levelmeter.cpp create mode 100644 demos/spectrum/app/levelmeter.h create mode 100644 demos/spectrum/app/main.cpp create mode 100644 demos/spectrum/app/mainwidget.cpp create mode 100644 demos/spectrum/app/mainwidget.h create mode 100644 demos/spectrum/app/progressbar.cpp create mode 100644 demos/spectrum/app/progressbar.h create mode 100644 demos/spectrum/app/settingsdialog.cpp create mode 100644 demos/spectrum/app/settingsdialog.h create mode 100644 demos/spectrum/app/spectrograph.cpp create mode 100644 demos/spectrum/app/spectrograph.h create mode 100644 demos/spectrum/app/spectrum.h create mode 100644 demos/spectrum/app/spectrum.qrc create mode 100644 demos/spectrum/app/spectrum.sh create mode 100644 demos/spectrum/app/spectrumanalyser.cpp create mode 100644 demos/spectrum/app/spectrumanalyser.h create mode 100644 demos/spectrum/app/tonegenerator.cpp create mode 100644 demos/spectrum/app/tonegenerator.h create mode 100644 demos/spectrum/app/tonegeneratordialog.cpp create mode 100644 demos/spectrum/app/tonegeneratordialog.h create mode 100644 demos/spectrum/app/utils.cpp create mode 100644 demos/spectrum/app/utils.h create mode 100644 demos/spectrum/app/waveform.cpp create mode 100644 demos/spectrum/app/waveform.h create mode 100644 demos/spectrum/app/wavfile.cpp create mode 100644 demos/spectrum/app/wavfile.h create mode 100644 demos/spectrum/fftreal/Array.h create mode 100644 demos/spectrum/fftreal/Array.hpp create mode 100644 demos/spectrum/fftreal/DynArray.h create mode 100644 demos/spectrum/fftreal/DynArray.hpp create mode 100644 demos/spectrum/fftreal/FFTReal.dsp create mode 100644 demos/spectrum/fftreal/FFTReal.dsw create mode 100644 demos/spectrum/fftreal/FFTReal.h create mode 100644 demos/spectrum/fftreal/FFTReal.hpp create mode 100644 demos/spectrum/fftreal/FFTRealFixLen.h create mode 100644 demos/spectrum/fftreal/FFTRealFixLen.hpp create mode 100644 demos/spectrum/fftreal/FFTRealFixLenParam.h create mode 100644 demos/spectrum/fftreal/FFTRealPassDirect.h create mode 100644 demos/spectrum/fftreal/FFTRealPassDirect.hpp create mode 100644 demos/spectrum/fftreal/FFTRealPassInverse.h create mode 100644 demos/spectrum/fftreal/FFTRealPassInverse.hpp create mode 100644 demos/spectrum/fftreal/FFTRealSelect.h create mode 100644 demos/spectrum/fftreal/FFTRealSelect.hpp create mode 100644 demos/spectrum/fftreal/FFTRealUseTrigo.h create mode 100644 demos/spectrum/fftreal/FFTRealUseTrigo.hpp create mode 100644 demos/spectrum/fftreal/OscSinCos.h create mode 100644 demos/spectrum/fftreal/OscSinCos.hpp create mode 100644 demos/spectrum/fftreal/TestAccuracy.h create mode 100644 demos/spectrum/fftreal/TestAccuracy.hpp create mode 100644 demos/spectrum/fftreal/TestHelperFixLen.h create mode 100644 demos/spectrum/fftreal/TestHelperFixLen.hpp create mode 100644 demos/spectrum/fftreal/TestHelperNormal.h create mode 100644 demos/spectrum/fftreal/TestHelperNormal.hpp create mode 100644 demos/spectrum/fftreal/TestSpeed.h create mode 100644 demos/spectrum/fftreal/TestSpeed.hpp create mode 100644 demos/spectrum/fftreal/TestWhiteNoiseGen.h create mode 100644 demos/spectrum/fftreal/TestWhiteNoiseGen.hpp create mode 100644 demos/spectrum/fftreal/bwins/fftrealu.def create mode 100644 demos/spectrum/fftreal/def.h create mode 100644 demos/spectrum/fftreal/eabi/fftrealu.def create mode 100644 demos/spectrum/fftreal/fftreal.pas create mode 100644 demos/spectrum/fftreal/fftreal.pro create mode 100644 demos/spectrum/fftreal/fftreal_wrapper.cpp create mode 100644 demos/spectrum/fftreal/fftreal_wrapper.h create mode 100644 demos/spectrum/fftreal/license.txt create mode 100644 demos/spectrum/fftreal/readme.txt create mode 100644 demos/spectrum/fftreal/stopwatch/ClockCycleCounter.cpp create mode 100644 demos/spectrum/fftreal/stopwatch/ClockCycleCounter.h create mode 100644 demos/spectrum/fftreal/stopwatch/ClockCycleCounter.hpp create mode 100644 demos/spectrum/fftreal/stopwatch/Int64.h create mode 100644 demos/spectrum/fftreal/stopwatch/StopWatch.cpp create mode 100644 demos/spectrum/fftreal/stopwatch/StopWatch.h create mode 100644 demos/spectrum/fftreal/stopwatch/StopWatch.hpp create mode 100644 demos/spectrum/fftreal/stopwatch/def.h create mode 100644 demos/spectrum/fftreal/stopwatch/fnc.h create mode 100644 demos/spectrum/fftreal/stopwatch/fnc.hpp create mode 100644 demos/spectrum/fftreal/test.cpp create mode 100644 demos/spectrum/fftreal/test_fnc.h create mode 100644 demos/spectrum/fftreal/test_fnc.hpp create mode 100644 demos/spectrum/fftreal/test_settings.h create mode 100644 demos/spectrum/fftreal/testapp.dpr create mode 100644 demos/spectrum/spectrum.pri create mode 100644 demos/spectrum/spectrum.pro diff --git a/.gitignore b/.gitignore index c8153fc..c720d97 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ examples/*/*/* !examples/*/*/README examples/*/*/*[.]app demos/*/* +!demos/spectrum/* +demos/spectrum/bin !demos/*/*[.]* demos/*/*[.]app config.tests/*/*/* diff --git a/demos/demos.pro b/demos/demos.pro index 5a9b6db..00092d9 100644 --- a/demos/demos.pro +++ b/demos/demos.pro @@ -55,6 +55,7 @@ wince*:SUBDIRS += demos_sqlbrowser } contains(QT_CONFIG, phonon):!static:SUBDIRS += demos_mediaplayer contains(QT_CONFIG, webkit):contains(QT_CONFIG, svg):!symbian:SUBDIRS += demos_browser +contains(QT_CONFIG, multimedia):SUBDIRS += demos_spectrum # install sources.files = README *.pro @@ -87,6 +88,7 @@ demos_browser.subdir = browser demos_boxes.subdir = boxes demos_sub-attaq.subdir = sub-attaq +demos_spectrum.subdir = spectrum #CONFIG += ordered !ordered { diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index 176f52e..d926a4b 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -20,6 +20,7 @@ + diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro index 535b5bf..4cc73bf 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.pro +++ b/demos/embedded/fluidlauncher/fluidlauncher.pro @@ -99,6 +99,10 @@ symbian { reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/qmediaplayer_reg.rsc } + contains(QT_CONFIG, multimedia) { + reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/spectrum_reg.rsc + } + reg_resource.path = $$REG_RESOURCE_IMPORT_DIR @@ -179,6 +183,13 @@ symbian { $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/qmediaplayer.mif } + contains(QT_CONFIG, multimedia) { + executables.sources += spectrum.exe fftreal.dll + resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/spectrum.rsc + mifs.sources += \ + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/spectrum.mif + } + contains(QT_CONFIG, script) { executables.sources += context2d.exe reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/context2d_reg.rsc diff --git a/demos/embedded/fluidlauncher/screenshots/spectrum.png b/demos/embedded/fluidlauncher/screenshots/spectrum.png new file mode 100644 index 0000000..7f4938f Binary files /dev/null and b/demos/embedded/fluidlauncher/screenshots/spectrum.png differ diff --git a/demos/qtdemo/xml/examples.xml b/demos/qtdemo/xml/examples.xml index e3240ab..9121861 100644 --- a/demos/qtdemo/xml/examples.xml +++ b/demos/qtdemo/xml/examples.xml @@ -19,6 +19,7 @@ + diff --git a/demos/spectrum/README.txt b/demos/spectrum/README.txt new file mode 100644 index 0000000..c39d4a7 --- /dev/null +++ b/demos/spectrum/README.txt @@ -0,0 +1,103 @@ +Spectrum analyser demo app +========================== + +Introduction +------------ + +This application is a demo which uses the QtMultimedia APIs to capture and play back PCM audio. While either recording or playback is ongoing, the application performs real-time level and frequency spectrum analysis, displaying the results in its main window. + + +Acknowledgments +--------------- + +The application uses the FFTReal v2.00 library by Laurent de Soras to perform frequency analysis of the audio signal. For further information, see the project home page: + http://ldesoras.free.fr/prod.html + + +Quick start +----------- + +Play generated tone +1. Select 'Play generated tone' from the mode menu +2. Ensure that the 'Frequency sweep' box is checked +3. Press 'OK' +4. Press the play button +You should hear a rising tone, and see progressively higher frequencies indicated by the spectrograph. + +Record and playback +1. Select 'Record and play back audio' from the mode menu +2. Press the record button, and speak into the microphone +3. Wait until the buffer is full (shown as a full blue bar in the top widget) +4. Press play, and wait until playback of the buffer is complete + +Play file +1. Select 'Play file' from the mode menu +2. Select a WAV file +3. Press the play button +You should hear the first few seconds of the file being played. The waveform, spectrograph and level meter should be updated as the file is played. + + +Things to play with +------------------- + +Try repeating the 'Play generated tone' sequence using different window functions. These can be selected from the settings dialog - launch it by pressing the spanner icon. The window function is applied to the audio signal before performing the frequency analysis; different windows should have a visible effect on the resulting frequency spectrum. + +Try clicking on one of the spectrograph bars while the tone is being played. The frequency range for that bar will be displayed at the top of the application window. + + +Troubleshooting +--------------- + +If either recording or playback do not work, you may need to select a different input / output audio device. This can be done in the settings dialog - launch it by pressing the spanner icon. + +If that doesn't work, there may be a problem either in the application or in Qt. Report a bug in the usual way. + + +Application interface +--------------------- + +The main window of the application contains the following widgets, starting at the top: + +Message box +This shows various messages during execution, such as the current audio format. + +Progress bar / waveform display +- While recording or playback is ongoing, the audio waveform is displayed, sliding from right to left. +- Superimposed on the waveform, the amount of data currently in the buffer is showed as a blue bar. When recording, this blue bar fills up from left to right; when playing, the bar gets consumed from left to right. +- A green window shows which part of the buffer has most recently been analysed. This window should be close to the 'leading edge' of recording or playback, i.e. the most recently recorded / played data, although it will lag slightly depending on the performance of the machine on which the application is running. + +Frequency spectrograph (on the left) +The spectrograph shows 10 bars, each representing a frequency range. The frequency range of each bar is displayed in the message box when the bar is clicked. The height of the bar shows the maximum amplitude of freqencies within its range. + +Level meter (on the right) +The current peak audio level is shown as a pink bar; the current RMS level is shown as a red bar. The 'high water mark' during a recent period is shown as a thin red line. + +Button panel +- The mode menu allows switching between the three operation modes - 'Play generated tone', 'Record and play back' and 'Play file'. +- The record button starts or resumes audio capture from the current input device. +- The pause button suspends either capture or recording. +- The play button starts or resumes audio playback to the current output device. +- The settings button launches the settings dialog. + + +Hacking +------- + +If you want to hack the application, here are some pointers to get started. + +The spectrum.pri file contains several macros which you can enable by uncommenting: +- LOG_FOO Enable logging from class Foo via qDebug() +- DUMP_FOO Dump data from class Foo to the file system + e.g. DUMP_SPECTRUMANALYSER writes files containing the raw FFT input and output. + Be aware that this can generate a *lot* of data and may slow the app down considerably. +- DISABLE_FOO Disable specified functionality + +If you don't like the combination of the waveform and progress bar in a single widget, separate them by commenting out SUPERIMPOSE_PROGRESS_ON_WAVEFORM. + +The spectrum.h file defines a number of parameters which can be played with. These control things such as the number of audio samples analysed per FFT calculation, the range and number of bands displayed by the spectrograph, and so on. + +The part of the application which interacts with QtMultimedia is in the Engine class. + +Some ideas for enhancements to the app are listed in TODO.txt. Feel free to start work on any of them :) + + diff --git a/demos/spectrum/TODO.txt b/demos/spectrum/TODO.txt new file mode 100644 index 0000000..dc3d8f3 --- /dev/null +++ b/demos/spectrum/TODO.txt @@ -0,0 +1,34 @@ +TODO list for spectrum analyser +=============================== + +Bug fixes +--------- + + +New features +------------ + +* Wrap user-visible strings in tr() + +* Allow user to set frequency range +There should be some constraints on this, e.g. + - Maximum frequency must not be greater than Nyquist frequency + - Range is divisible by number of bars? + +* Add more visualizers other than bar spectrogram +e.g. Funky OpenGL visualizers, particle effects etc + + +Non-functional stuff +-------------------- + +* Improve robustness of QComboBox -> enum mapping +At the moment, SettingsDialog relies on casting the combobox item index directly to the enumerated type. This is clearly a bit fragile... + +* For functions which take or return qint64 values, make a clear distinction between duration (microseconds) and length (bytes). +A sensible convention would be that the default is bytes - i.e. microseconds must be indicated by adding a Us suffix, where not already obvious from the function name. + + + + + diff --git a/demos/spectrum/app/app.pro b/demos/spectrum/app/app.pro new file mode 100644 index 0000000..9964d14 --- /dev/null +++ b/demos/spectrum/app/app.pro @@ -0,0 +1,119 @@ +include(../spectrum.pri) + +TEMPLATE = app + +TARGET = spectrum +unix: !macx: !symbian: TARGET = spectrum.bin + +QT += multimedia + +SOURCES += main.cpp \ + engine.cpp \ + frequencyspectrum.cpp \ + levelmeter.cpp \ + mainwidget.cpp \ + progressbar.cpp \ + settingsdialog.cpp \ + spectrograph.cpp \ + spectrumanalyser.cpp \ + tonegenerator.cpp \ + tonegeneratordialog.cpp \ + utils.cpp \ + waveform.cpp \ + wavfile.cpp + +HEADERS += engine.h \ + frequencyspectrum.h \ + levelmeter.h \ + mainwidget.h \ + progressbar.h \ + settingsdialog.h \ + spectrograph.h \ + spectrum.h \ + spectrumanalyser.h \ + tonegenerator.h \ + tonegeneratordialog.h \ + utils.h \ + waveform.h \ + wavfile.h + +INCLUDEPATH += ../fftreal + +RESOURCES = spectrum.qrc + +symbian { + # Platform security capability required to record audio on Symbian + TARGET.CAPABILITY += UserEnvironment + + # Provide unique ID for the generated binary, required by Symbian OS + TARGET.UID3 = 0xA000E3FA +} + + +# Dynamic linkage against FFTReal DLL +!contains(DEFINES, DISABLE_FFT) { + symbian { + # Must explicitly add the .dll suffix to ensure dynamic linkage + LIBS += -lfftreal.dll + } else { + macx { + # Link to fftreal framework + LIBS += -F../fftreal + LIBS += -framework fftreal + } else { + # Link to dynamic library which is written to ../bin + LIBS += -L../bin + LIBS += -lfftreal + } + } +} + + +# Deployment + +symbian { + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + !contains(DEFINES, DISABLE_FFT) { + # Include FFTReal DLL in the SIS file + fftreal.sources = $${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/fftreal.dll + fftreal.path = !:/sys/bin + DEPLOYMENT += fftreal + } +} else { + macx { + # Specify directory in which to create spectrum.app bundle + DESTDIR = .. + + !contains(DEFINES, DISABLE_FFT) { + # Relocate fftreal.framework into spectrum.app bundle + framework_dir = ../spectrum.app/Contents/Frameworks + framework_name = fftreal.framework/Versions/1/fftreal + QMAKE_POST_LINK = \ + mkdir -p $${framework_dir} &&\ + rm -rf $${framework_dir}/fftreal.framework &&\ + cp -R ../fftreal/fftreal.framework $${framework_dir} &&\ + install_name_tool -id @executable_path/../Frameworks/$${framework_name} \ + $${framework_dir}/$${framework_name} &&\ + install_name_tool -change $${framework_name} \ + @executable_path/../Frameworks/$${framework_name} \ + ../spectrum.app/Contents/MacOS/spectrum + } + } else { + # Specify directory in which to create spectrum application + DESTDIR = ../bin + + unix: !symbian { + # On unices other than Mac OSX, we copy a shell script into the bin directory. + # This script takes care of correctly setting the LD_LIBRARY_PATH so that + # the dynamic library can be located. + copy_launch_script.target = copy_launch_script + copy_launch_script.commands = \ + install -m 0555 spectrum.sh ../bin/spectrum + QMAKE_EXTRA_TARGETS += copy_launch_script + POST_TARGETDEPS += copy_launch_script + } + } +} + + diff --git a/demos/spectrum/app/engine.cpp b/demos/spectrum/app/engine.cpp new file mode 100644 index 0000000..5cdfb6d --- /dev/null +++ b/demos/spectrum/app/engine.cpp @@ -0,0 +1,752 @@ +/**************************************************************************** +** +** 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 examples 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 "engine.h" +#include "tonegenerator.h" +#include "utils.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const qint64 BufferDurationUs = 10 * 1000000; +const int NotifyIntervalMs = 100; + +// Size of the level calculation window in microseconds +const int LevelWindowUs = 0.1 * 1000000; + + +//----------------------------------------------------------------------------- +// Helper functions +//----------------------------------------------------------------------------- + +QDebug& operator<<(QDebug &debug, const QAudioFormat &format) +{ + debug << format.frequency() << "Hz" + << format.channels() << "channels"; + return debug; +} + +//----------------------------------------------------------------------------- +// Constructor and destructor +//----------------------------------------------------------------------------- + +Engine::Engine(QObject *parent) + : QObject(parent) + , m_mode(QAudio::AudioInput) + , m_state(QAudio::StoppedState) + , m_generateTone(false) + , m_file(0) + , m_availableAudioInputDevices + (QAudioDeviceInfo::availableDevices(QAudio::AudioInput)) + , m_audioInputDevice(QAudioDeviceInfo::defaultInputDevice()) + , m_audioInput(0) + , m_audioInputIODevice(0) + , m_recordPosition(0) + , m_availableAudioOutputDevices + (QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) + , m_audioOutputDevice(QAudioDeviceInfo::defaultOutputDevice()) + , m_audioOutput(0) + , m_playPosition(0) + , m_dataLength(0) + , m_rmsLevel(0.0) + , m_peakLevel(0.0) + , m_spectrumLengthBytes(0) + , m_spectrumAnalyser() + , m_spectrumPosition(0) + , m_count(0) +{ + qRegisterMetaType("FrequencySpectrum"); + CHECKED_CONNECT(&m_spectrumAnalyser, + SIGNAL(spectrumChanged(FrequencySpectrum)), + this, + SLOT(spectrumChanged(FrequencySpectrum))); + + initialize(); + +#ifdef DUMP_DATA + createOutputDir(); +#endif + +#ifdef DUMP_SPECTRUM + m_spectrumAnalyser.setOutputPath(outputPath()); +#endif +} + +Engine::~Engine() +{ + +} + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +bool Engine::loadFile(const QString &fileName) +{ + bool result = false; + m_generateTone = false; + + Q_ASSERT(!fileName.isEmpty()); + Q_ASSERT(!m_file); + m_file = new QFile(fileName, this); + m_file->setFileName(fileName); + Q_ASSERT(m_file->exists()); + if (m_file->open(QFile::ReadOnly)) { + m_wavFile.readHeader(*m_file); + if (isPCMS16LE(m_wavFile.format())) { + result = initialize(); + } else { + emit errorMessage(tr("Audio format not supported"), + formatToString(m_wavFile.format())); + } + } else { + emit errorMessage(tr("Could not open file"), fileName); + } + + delete m_file; + m_file = 0; + + return result; +} + +bool Engine::generateTone(const Tone &tone) +{ + Q_ASSERT(!m_file); + m_generateTone = true; + m_tone = tone; + ENGINE_DEBUG << "Engine::generateTone" + << "startFreq" << m_tone.startFreq + << "endFreq" << m_tone.endFreq + << "amp" << m_tone.amplitude; + return initialize(); +} + +bool Engine::generateSweptTone(qreal amplitude) +{ + Q_ASSERT(!m_file); + m_generateTone = true; + m_tone.startFreq = 1; + m_tone.endFreq = 0; + m_tone.amplitude = amplitude; + ENGINE_DEBUG << "Engine::generateSweptTone" + << "startFreq" << m_tone.startFreq + << "amp" << m_tone.amplitude; + return initialize(); +} + +bool Engine::initializeRecord() +{ + ENGINE_DEBUG << "Engine::initializeRecord"; + Q_ASSERT(!m_file); + m_generateTone = false; + m_tone = SweptTone(); + return initialize(); +} + +qint64 Engine::bufferDuration() const +{ + return BufferDurationUs; +} + +qint64 Engine::dataDuration() const +{ + qint64 result = 0; + if (QAudioFormat() != m_format) + result = audioDuration(m_format, m_dataLength); + return result; +} + +qint64 Engine::audioBufferLength() const +{ + qint64 length = 0; + if (QAudio::ActiveState == m_state || QAudio::IdleState == m_state) { + Q_ASSERT(QAudioFormat() != m_format); + switch (m_mode) { + case QAudio::AudioInput: + length = m_audioInput->bufferSize(); + break; + case QAudio::AudioOutput: + length = m_audioOutput->bufferSize(); + break; + } + } + return length; +} + +void Engine::setWindowFunction(WindowFunction type) +{ + m_spectrumAnalyser.setWindowFunction(type); +} + + +//----------------------------------------------------------------------------- +// Public slots +//----------------------------------------------------------------------------- + +void Engine::startRecording() +{ + if (m_audioInput) { + if (QAudio::AudioInput == m_mode && + QAudio::SuspendedState == m_state) { + m_audioInput->resume(); + } else { + m_spectrumAnalyser.cancelCalculation(); + spectrumChanged(0, 0, FrequencySpectrum()); + + m_buffer.fill(0); + setRecordPosition(0, true); + stopPlayback(); + m_mode = QAudio::AudioInput; + CHECKED_CONNECT(m_audioInput, SIGNAL(stateChanged(QAudio::State)), + this, SLOT(audioStateChanged(QAudio::State))); + CHECKED_CONNECT(m_audioInput, SIGNAL(notify()), + this, SLOT(audioNotify())); + m_count = 0; + m_dataLength = 0; + emit dataDurationChanged(0); + m_audioInputIODevice = m_audioInput->start(); + CHECKED_CONNECT(m_audioInputIODevice, SIGNAL(readyRead()), + this, SLOT(audioDataReady())); + } + } +} + +void Engine::startPlayback() +{ + if (m_audioOutput) { + if (QAudio::AudioOutput == m_mode && + QAudio::SuspendedState == m_state) { +#ifdef Q_OS_WIN + // The Windows backend seems to internally go back into ActiveState + // while still returning SuspendedState, so to ensure that it doesn't + // ignore the resume() call, we first re-suspend + m_audioOutput->suspend(); +#endif + m_audioOutput->resume(); + } else { + m_spectrumAnalyser.cancelCalculation(); + spectrumChanged(0, 0, FrequencySpectrum()); + + setPlayPosition(0, true); + stopRecording(); + m_mode = QAudio::AudioOutput; + CHECKED_CONNECT(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), + this, SLOT(audioStateChanged(QAudio::State))); + CHECKED_CONNECT(m_audioOutput, SIGNAL(notify()), + this, SLOT(audioNotify())); + m_count = 0; + m_audioOutputIODevice.close(); + m_audioOutputIODevice.setBuffer(&m_buffer); + m_audioOutputIODevice.open(QIODevice::ReadOnly); + m_audioOutput->start(&m_audioOutputIODevice); + } + } +} + +void Engine::suspend() +{ + if (QAudio::ActiveState == m_state || + QAudio::IdleState == m_state) { + switch (m_mode) { + case QAudio::AudioInput: + m_audioInput->suspend(); + break; + case QAudio::AudioOutput: + m_audioOutput->suspend(); + break; + } + } +} + +void Engine::setAudioInputDevice(const QAudioDeviceInfo &device) +{ + if (device.deviceName() != m_audioInputDevice.deviceName()) { + m_audioInputDevice = device; + initialize(); + } +} + +void Engine::setAudioOutputDevice(const QAudioDeviceInfo &device) +{ + if (device.deviceName() != m_audioOutputDevice.deviceName()) { + m_audioOutputDevice = device; + initialize(); + } +} + + +//----------------------------------------------------------------------------- +// Private slots +//----------------------------------------------------------------------------- + +void Engine::audioNotify() +{ + switch (m_mode) { + case QAudio::AudioInput: { + const qint64 recordPosition = + qMin(BufferDurationUs, m_audioInput->processedUSecs()); + setRecordPosition(recordPosition); + + // Calculate level of most recently captured data + qint64 levelLength = audioLength(m_format, LevelWindowUs); + levelLength = qMin(m_dataLength, levelLength); + const qint64 levelPosition = m_dataLength - levelLength; + calculateLevel(levelPosition, levelLength); + + // Calculate spectrum of most recently captured data + if (m_dataLength >= m_spectrumLengthBytes) { + const qint64 spectrumPosition = m_dataLength - m_spectrumLengthBytes; + calculateSpectrum(spectrumPosition); + } + } + break; + case QAudio::AudioOutput: { + const qint64 playPosition = + qMin(dataDuration(), m_audioOutput->processedUSecs()); + setPlayPosition(playPosition); + + qint64 analysisPosition = audioLength(m_format, playPosition); + + // Calculate level of data starting at current playback position + const qint64 levelLength = audioLength(m_format, LevelWindowUs); + if (analysisPosition + levelLength < m_dataLength) + calculateLevel(analysisPosition, levelLength); + + if (analysisPosition + m_spectrumLengthBytes < m_dataLength) + calculateSpectrum(analysisPosition); + + if (dataDuration() == playPosition) + stopPlayback(); + } + break; + } +} + +void Engine::audioStateChanged(QAudio::State state) +{ + ENGINE_DEBUG << "Engine::audioStateChanged from" << m_state + << "to" << state; + + if (QAudio::StoppedState == state) { + // Check error + QAudio::Error error = QAudio::NoError; + switch (m_mode) { + case QAudio::AudioInput: + error = m_audioInput->error(); + break; + case QAudio::AudioOutput: + error = m_audioOutput->error(); + break; + } + if (QAudio::NoError != error) { + reset(); + return; + } + } + setState(state); +} + +void Engine::audioDataReady() +{ + const qint64 bytesReady = m_audioInput->bytesReady(); + const qint64 bytesSpace = m_buffer.size() - m_dataLength; + const qint64 bytesToRead = qMin(bytesReady, bytesSpace); + + const qint64 bytesRead = m_audioInputIODevice->read( + m_buffer.data() + m_dataLength, + bytesToRead); + + if (bytesRead) { + m_dataLength += bytesRead; + + const qint64 duration = audioDuration(m_format, m_dataLength); + emit dataDurationChanged(duration); + } + + if (m_buffer.size() == m_dataLength) + stopRecording(); +} + +void Engine::spectrumChanged(const FrequencySpectrum &spectrum) +{ + ENGINE_DEBUG << "Engine::spectrumChanged" << "pos" << m_spectrumPosition; + const qint64 positionUs = audioDuration(m_format, m_spectrumPosition); + const qint64 lengthUs = audioDuration(m_format, m_spectrumLengthBytes); + emit spectrumChanged(positionUs, lengthUs, spectrum); +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void Engine::reset() +{ + stopRecording(); + stopPlayback(); + setState(QAudio::AudioInput, QAudio::StoppedState); + setFormat(QAudioFormat()); + delete m_audioInput; + m_audioInput = 0; + m_audioInputIODevice = 0; + setRecordPosition(0); + delete m_audioOutput; + m_audioOutput = 0; + setPlayPosition(0); + m_buffer.clear(); + m_dataLength = 0; + m_spectrumPosition = 0; + emit dataDurationChanged(0); + setLevel(0.0, 0.0, 0); +} + +bool Engine::initialize() +{ + bool result = false; + + reset(); + + if (selectFormat()) { + const qint64 bufferLength = audioLength(m_format, BufferDurationUs); + m_buffer.resize(bufferLength); + m_buffer.fill(0); + emit bufferDurationChanged(BufferDurationUs); + + if (m_generateTone) { + if (0 == m_tone.endFreq) { + const qreal nyquist = nyquistFrequency(m_format); + m_tone.endFreq = qMin(qreal(SpectrumHighFreq), nyquist); + } + + // Call function defined in utils.h, at global scope + ::generateTone(m_tone, m_format, m_buffer); + m_dataLength = m_buffer.size(); + emit dataDurationChanged(bufferDuration()); + setRecordPosition(bufferDuration()); + result = true; + } else if (m_file) { + const qint64 length = m_wavFile.readData(*m_file, m_buffer, m_format); + if (length) { + m_dataLength = length; + emit dataDurationChanged(dataDuration()); + setRecordPosition(dataDuration()); + result = true; + } + } else { + m_audioInput = new QAudioInput(m_audioInputDevice, m_format, this); + m_audioInput->setNotifyInterval(NotifyIntervalMs); + result = true; + } + + m_audioOutput = new QAudioOutput(m_audioOutputDevice, m_format, this); + m_audioOutput->setNotifyInterval(NotifyIntervalMs); + m_spectrumLengthBytes = SpectrumLengthSamples * + (m_format.sampleSize() / 8) * m_format.channels(); + } else { + if (m_file) + emit errorMessage(tr("Audio format not supported"), + formatToString(m_format)); + else if (m_generateTone) + emit errorMessage(tr("No suitable format found"), ""); + else + emit errorMessage(tr("No common input / output format found"), ""); + } + + ENGINE_DEBUG << "Engine::initialize" << "format" << m_format; + + return result; +} + +bool Engine::selectFormat() +{ + bool foundSupportedFormat = false; + + if (m_file) { + // Header is read from the WAV file; just need to check whether + // it is supported by the audio output device + QAudioFormat format = m_wavFile.format(); + if (m_audioOutputDevice.isFormatSupported(m_wavFile.format())) { + setFormat(m_wavFile.format()); + foundSupportedFormat = true; + } else { + // Try flipping mono <-> stereo + const int channels = (format.channels() == 1) ? 2 : 1; + format.setChannels(channels); + if (m_audioOutputDevice.isFormatSupported(format)) { + setFormat(format); + foundSupportedFormat = true; + } + } + } else { + + QList frequenciesList; + #ifdef Q_OS_WIN + // The Windows audio backend does not correctly report format support + // (see QTBUG-9100). Furthermore, although the audio subsystem captures + // at 11025Hz, the resulting audio is corrupted. + frequenciesList += 8000; + #endif + + if (!m_generateTone) + frequenciesList += m_audioInputDevice.supportedFrequencies(); + + frequenciesList += m_audioOutputDevice.supportedFrequencies(); + frequenciesList = frequenciesList.toSet().toList(); // remove duplicates + qSort(frequenciesList); + ENGINE_DEBUG << "Engine::initialize frequenciesList" << frequenciesList; + + QList channelsList; + channelsList += m_audioInputDevice.supportedChannels(); + channelsList += m_audioOutputDevice.supportedChannels(); + channelsList = channelsList.toSet().toList(); + qSort(channelsList); + ENGINE_DEBUG << "Engine::initialize channelsList" << channelsList; + + QAudioFormat format; + format.setByteOrder(QAudioFormat::LittleEndian); + format.setCodec("audio/pcm"); + format.setSampleSize(16); + format.setSampleType(QAudioFormat::SignedInt); + int frequency, channels; + foreach (frequency, frequenciesList) { + if (foundSupportedFormat) + break; + format.setFrequency(frequency); + foreach (channels, channelsList) { + format.setChannels(channels); + const bool inputSupport = m_generateTone || + m_audioInputDevice.isFormatSupported(format); + const bool outputSupport = m_audioOutputDevice.isFormatSupported(format); + ENGINE_DEBUG << "Engine::initialize checking " << format + << "input" << inputSupport + << "output" << outputSupport; + if (inputSupport && outputSupport) { + foundSupportedFormat = true; + break; + } + } + } + + if (!foundSupportedFormat) + format = QAudioFormat(); + + setFormat(format); + } + + return foundSupportedFormat; +} + +void Engine::stopRecording() +{ + if (m_audioInput) { + m_audioInput->stop(); + QCoreApplication::instance()->processEvents(); + m_audioInput->disconnect(); + } + m_audioInputIODevice = 0; + +#ifdef DUMP_AUDIO + dumpData(); +#endif +} + +void Engine::stopPlayback() +{ + if (m_audioOutput) { + m_audioOutput->stop(); + QCoreApplication::instance()->processEvents(); + m_audioOutput->disconnect(); + setPlayPosition(0); + } +} + +void Engine::setState(QAudio::State state) +{ + const bool changed = (m_state != state); + m_state = state; + if (changed) + emit stateChanged(m_mode, m_state); +} + +void Engine::setState(QAudio::Mode mode, QAudio::State state) +{ + const bool changed = (m_mode != mode || m_state != state); + m_mode = mode; + m_state = state; + if (changed) + emit stateChanged(m_mode, m_state); +} + +void Engine::setRecordPosition(qint64 position, bool forceEmit) +{ + const bool changed = (m_recordPosition != position); + m_recordPosition = position; + if (changed || forceEmit) + emit recordPositionChanged(m_recordPosition); +} + +void Engine::setPlayPosition(qint64 position, bool forceEmit) +{ + const bool changed = (m_playPosition != position); + m_playPosition = position; + if (changed || forceEmit) + emit playPositionChanged(m_playPosition); +} + +void Engine::calculateLevel(qint64 position, qint64 length) +{ +#ifdef DISABLE_LEVEL + Q_UNUSED(position) + Q_UNUSED(length) +#else + Q_ASSERT(position + length <= m_dataLength); + + qreal peakLevel = 0.0; + + qreal sum = 0.0; + const char *ptr = m_buffer.constData() + position; + const char *const end = ptr + length; + while (ptr < end) { + const qint16 value = *reinterpret_cast(ptr); + const qreal fracValue = pcmToReal(value); + peakLevel = qMax(peakLevel, fracValue); + sum += fracValue * fracValue; + ptr += 2; + } + const int numSamples = length / 2; + qreal rmsLevel = sqrt(sum / numSamples); + + rmsLevel = qMax(qreal(0.0), rmsLevel); + rmsLevel = qMin(qreal(1.0), rmsLevel); + setLevel(rmsLevel, peakLevel, numSamples); + + ENGINE_DEBUG << "Engine::calculateLevel" << "pos" << position << "len" << length + << "rms" << rmsLevel << "peak" << peakLevel; +#endif +} + +void Engine::calculateSpectrum(qint64 position) +{ +#ifdef DISABLE_SPECTRUM + Q_UNUSED(position) +#else + Q_ASSERT(position + m_spectrumLengthBytes <= m_dataLength); + Q_ASSERT(0 == m_spectrumLengthBytes % 2); // constraint of FFT algorithm + + // QThread::currentThread is marked 'for internal use only', but + // we're only using it for debug output here, so it's probably OK :) + ENGINE_DEBUG << "Engine::calculateSpectrum" << QThread::currentThread() + << "count" << m_count << "pos" << position << "len" << m_spectrumLengthBytes + << "spectrumAnalyser.isReady" << m_spectrumAnalyser.isReady(); + + if(m_spectrumAnalyser.isReady()) { + m_spectrumBuffer = QByteArray::fromRawData(m_buffer.constData() + position, + m_spectrumLengthBytes); + m_spectrumPosition = position; + m_spectrumAnalyser.calculate(m_spectrumBuffer, m_format); + } +#endif +} + +void Engine::setFormat(const QAudioFormat &format) +{ + const bool changed = (format != m_format); + m_format = format; + if (changed) + emit formatChanged(m_format); +} + +void Engine::setLevel(qreal rmsLevel, qreal peakLevel, int numSamples) +{ + m_rmsLevel = rmsLevel; + m_peakLevel = peakLevel; + emit levelChanged(m_rmsLevel, m_peakLevel, numSamples); +} + +#ifdef DUMP_DATA +void Engine::createOutputDir() +{ + m_outputDir.setPath("output"); + + // Ensure output directory exists and is empty + if (m_outputDir.exists()) { + const QStringList files = m_outputDir.entryList(QDir::Files); + QString file; + foreach (file, files) + m_outputDir.remove(file); + } else { + QDir::current().mkdir("output"); + } +} +#endif // DUMP_DATA + +#ifdef DUMP_AUDIO +void Engine::dumpData() +{ + const QString txtFileName = m_outputDir.filePath("data.txt"); + QFile txtFile(txtFileName); + txtFile.open(QFile::WriteOnly | QFile::Text); + QTextStream stream(&txtFile); + const qint16 *ptr = reinterpret_cast(m_buffer.constData()); + const int numSamples = m_dataLength / (2 * m_format.channels()); + for (int i=0; i +#include +#include +#include +#include +#include + +#ifdef DUMP_CAPTURED_AUDIO +#define DUMP_DATA +#endif + +#ifdef DUMP_SPECTRUM +#define DUMP_DATA +#endif + +#ifdef DUMP_DATA +#include +#endif + +class QAudioInput; +class QAudioOutput; +class FrequencySpectrum; +class QFile; + +/** + * This class interfaces with the QtMultimedia audio classes, and also with + * the SpectrumAnalyser class. Its role is to manage the capture and playback + * of audio data, meanwhile performing real-time analysis of the audio level + * and frequency spectrum. + */ +class Engine : public QObject { + Q_OBJECT +public: + Engine(QObject *parent = 0); + ~Engine(); + + const QList& availableAudioInputDevices() const + { return m_availableAudioInputDevices; } + + const QList& availableAudioOutputDevices() const + { return m_availableAudioOutputDevices; } + + QAudio::Mode mode() const { return m_mode; } + QAudio::State state() const { return m_state; } + + /** + * \return Reference to internal audio buffer + * \note This reference is valid for the lifetime of the Engine + */ + const QByteArray& buffer() const { return m_buffer; } + + /** + * \return Current audio format + * \note May be QAudioFormat() if engine is not initialized + */ + const QAudioFormat& format() const { return m_format; } + + /** + * Stop any ongoing recording or playback, and reset to ground state. + */ + void reset(); + + /** + * Load data from WAV file + */ + bool loadFile(const QString &fileName); + + /** + * Generate tone + */ + bool generateTone(const Tone &tone); + + /** + * Generate tone + */ + bool generateSweptTone(qreal amplitude); + + /** + * Initialize for recording + */ + bool initializeRecord(); + + /** + * Position of the audio input device. + * \return Position in microseconds. + */ + qint64 recordPosition() const { return m_recordPosition; } + + /** + * RMS level of the most recently processed set of audio samples. + * \return Level in range (0.0, 1.0) + */ + qreal rmsLevel() const { return m_rmsLevel; } + + /** + * Peak level of the most recently processed set of audio samples. + * \return Level in range (0.0, 1.0) + */ + qreal peakLevel() const { return m_peakLevel; } + + /** + * Position of the audio output device. + * \return Position in microseconds. + */ + qint64 playPosition() const { return m_playPosition; } + + /** + * Length of the internal engine buffer. + * \return Buffer length in microseconds. + */ + qint64 bufferDuration() const; + + /** + * Amount of data held in the buffer. + * \return Data duration in microseconds. + */ + qint64 dataDuration() const; + + /** + * Returns the size of the underlying audio buffer in bytes. + * This should be an approximation of the capture latency. + */ + qint64 audioBufferLength() const; + + /** + * Set window function applied to audio data before spectral analysis. + */ + void setWindowFunction(WindowFunction type); + +public slots: + void startRecording(); + void startPlayback(); + void suspend(); + void setAudioInputDevice(const QAudioDeviceInfo &device); + void setAudioOutputDevice(const QAudioDeviceInfo &device); + +signals: + void stateChanged(QAudio::Mode mode, QAudio::State state); + + /** + * Informational message for non-modal display + */ + void infoMessage(const QString &message, int durationMs); + + /** + * Error message for modal display + */ + void errorMessage(const QString &heading, const QString &detail); + + /** + * Format of audio data has changed + */ + void formatChanged(const QAudioFormat &format); + + /** + * Length of buffer has changed. + * \param duration Duration in microseconds + */ + void bufferDurationChanged(qint64 duration); + + /** + * Amount of data in buffer has changed. + * \param duration Duration of data in microseconds + */ + void dataDurationChanged(qint64 duration); + + /** + * Position of the audio input device has changed. + * \param position Position in microseconds + */ + void recordPositionChanged(qint64 position); + + /** + * Position of the audio output device has changed. + * \param position Position in microseconds + */ + void playPositionChanged(qint64 position); + + /** + * Level changed + * \param rmsLevel RMS level in range 0.0 - 1.0 + * \param peakLevel Peak level in range 0.0 - 1.0 + * \param numSamples Number of audio samples analysed + */ + void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples); + + /** + * Spectrum has changed. + * \param position Position of start of window in microseconds + * \param length Length of window in microseconds + * \param spectrum Resulting frequency spectrum + */ + void spectrumChanged(qint64 position, qint64 length, const FrequencySpectrum &spectrum); + +private slots: + void audioNotify(); + void audioStateChanged(QAudio::State state); + void audioDataReady(); + void spectrumChanged(const FrequencySpectrum &spectrum); + +private: + bool initialize(); + bool selectFormat(); + void stopRecording(); + void stopPlayback(); + void setState(QAudio::State state); + void setState(QAudio::Mode mode, QAudio::State state); + void setFormat(const QAudioFormat &format); + void setRecordPosition(qint64 position, bool forceEmit = false); + void setPlayPosition(qint64 position, bool forceEmit = false); + void calculateLevel(qint64 position, qint64 length); + void calculateSpectrum(qint64 position); + void setLevel(qreal rmsLevel, qreal peakLevel, int numSamples); + +#ifdef DUMP_DATA + void createOutputDir(); + QString outputPath() const { return m_outputDir.path(); } +#endif + +#ifdef DUMP_CAPTURED_AUDIO + void dumpData(); +#endif + +private: + QAudio::Mode m_mode; + QAudio::State m_state; + + bool m_generateTone; + SweptTone m_tone; + + QFile* m_file; + WavFile m_wavFile; + + QAudioFormat m_format; + + const QList m_availableAudioInputDevices; + QAudioDeviceInfo m_audioInputDevice; + QAudioInput* m_audioInput; + QIODevice* m_audioInputIODevice; + qint64 m_recordPosition; + + const QList m_availableAudioOutputDevices; + QAudioDeviceInfo m_audioOutputDevice; + QAudioOutput* m_audioOutput; + qint64 m_playPosition; + QBuffer m_audioOutputIODevice; + + QByteArray m_buffer; + qint64 m_dataLength; + + qreal m_rmsLevel; + qreal m_peakLevel; + + int m_spectrumLengthBytes; + QByteArray m_spectrumBuffer; + SpectrumAnalyser m_spectrumAnalyser; + qint64 m_spectrumPosition; + + int m_count; + +#ifdef DUMP_DATA + QDir m_outputDir; +#endif + +}; + +#endif // ENGINE_H diff --git a/demos/spectrum/app/frequencyspectrum.cpp b/demos/spectrum/app/frequencyspectrum.cpp new file mode 100644 index 0000000..6ab80c2 --- /dev/null +++ b/demos/spectrum/app/frequencyspectrum.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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 examples 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 "frequencyspectrum.h" + +FrequencySpectrum::FrequencySpectrum(int numPoints) + : m_elements(numPoints) +{ + +} + +void FrequencySpectrum::reset() +{ + iterator i = begin(); + for ( ; i != end(); ++i) + *i = Element(); +} + +int FrequencySpectrum::count() const +{ + return m_elements.count(); +} + +FrequencySpectrum::Element& FrequencySpectrum::operator[](int index) +{ + return m_elements[index]; +} + +const FrequencySpectrum::Element& FrequencySpectrum::operator[](int index) const +{ + return m_elements[index]; +} + +FrequencySpectrum::iterator FrequencySpectrum::begin() +{ + return m_elements.begin(); +} + +FrequencySpectrum::iterator FrequencySpectrum::end() +{ + return m_elements.end(); +} + +FrequencySpectrum::const_iterator FrequencySpectrum::begin() const +{ + return m_elements.begin(); +} + +FrequencySpectrum::const_iterator FrequencySpectrum::end() const +{ + return m_elements.end(); +} diff --git a/demos/spectrum/app/frequencyspectrum.h b/demos/spectrum/app/frequencyspectrum.h new file mode 100644 index 0000000..610ed6e --- /dev/null +++ b/demos/spectrum/app/frequencyspectrum.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef FREQUENCYSPECTRUM_H +#define FREQUENCYSPECTRUM_H + +#include + +/** + * Represents a frequency spectrum as a series of elements, each of which + * consists of a frequency, an amplitude and a phase. + */ +class FrequencySpectrum { +public: + FrequencySpectrum(int numPoints = 0); + + struct Element { + Element() + : frequency(0.0), amplitude(0.0), phase(0.0), clipped(false) + { } + + /** + * Frequency in Hertz + */ + qreal frequency; + + /** + * Amplitude in range [0.0, 1.0] + */ + qreal amplitude; + + /** + * Phase in range [0.0, 2*PI] + */ + qreal phase; + + /** + * Indicates whether value has been clipped during spectrum analysis + */ + bool clipped; + }; + + typedef QVector::iterator iterator; + typedef QVector::const_iterator const_iterator; + + void reset(); + + int count() const; + Element& operator[](int index); + const Element& operator[](int index) const; + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + +private: + QVector m_elements; + +}; + +#endif // FREQUENCYSPECTRUM_H diff --git a/demos/spectrum/app/images/record.png b/demos/spectrum/app/images/record.png new file mode 100644 index 0000000..e7493aa Binary files /dev/null and b/demos/spectrum/app/images/record.png differ diff --git a/demos/spectrum/app/images/settings.png b/demos/spectrum/app/images/settings.png new file mode 100644 index 0000000..12179dc Binary files /dev/null and b/demos/spectrum/app/images/settings.png differ diff --git a/demos/spectrum/app/levelmeter.cpp b/demos/spectrum/app/levelmeter.cpp new file mode 100644 index 0000000..eb37684 --- /dev/null +++ b/demos/spectrum/app/levelmeter.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** 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 examples 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 "levelmeter.h" + +#include + +#include +#include +#include + + +// Constants +const int RedrawInterval = 100; // ms +const qreal PeakDecayRate = 0.001; +const int PeakHoldLevelDuration = 2000; // ms + + +LevelMeter::LevelMeter(QWidget *parent) + : QWidget(parent) + , m_rmsLevel(0.0) + , m_peakLevel(0.0) + , m_decayedPeakLevel(0.0) + , m_peakDecayRate(PeakDecayRate) + , m_peakHoldLevel(0.0) + , m_redrawTimer(new QTimer(this)) + , m_rmsColor(Qt::red) + , m_peakColor(255, 200, 200, 255) +{ + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + setMinimumWidth(30); + + connect(m_redrawTimer, SIGNAL(timeout()), this, SLOT(redrawTimerExpired())); + m_redrawTimer->start(RedrawInterval); +} + +LevelMeter::~LevelMeter() +{ + +} + +void LevelMeter::reset() +{ + m_rmsLevel = 0.0; + m_peakLevel = 0.0; + update(); +} + +void LevelMeter::levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples) +{ + // Smooth the RMS signal + const qreal smooth = pow(0.9, static_cast(numSamples) / 256); // TODO: remove this magic number + m_rmsLevel = (m_rmsLevel * smooth) + (rmsLevel * (1.0 - smooth)); + + if (peakLevel > m_decayedPeakLevel) { + m_peakLevel = peakLevel; + m_decayedPeakLevel = peakLevel; + m_peakLevelChanged.start(); + } + + if (peakLevel > m_peakHoldLevel) { + m_peakHoldLevel = peakLevel; + m_peakHoldLevelChanged.start(); + } + + update(); +} + +void LevelMeter::redrawTimerExpired() +{ + // Decay the peak signal + const int elapsedMs = m_peakLevelChanged.elapsed(); + const qreal decayAmount = m_peakDecayRate * elapsedMs; + if (decayAmount < m_peakLevel) + m_decayedPeakLevel = m_peakLevel - decayAmount; + else + m_decayedPeakLevel = 0.0; + + // Check whether to clear the peak hold level + if (m_peakHoldLevelChanged.elapsed() > PeakHoldLevelDuration) + m_peakHoldLevel = 0.0; + + update(); +} + +void LevelMeter::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event) + + QPainter painter(this); + painter.fillRect(rect(), Qt::black); + + QRect bar = rect(); + + bar.setTop(rect().top() + (1.0 - m_peakHoldLevel) * rect().height()); + bar.setBottom(bar.top() + 5); + painter.fillRect(bar, m_rmsColor); + bar.setBottom(rect().bottom()); + + bar.setTop(rect().top() + (1.0 - m_decayedPeakLevel) * rect().height()); + painter.fillRect(bar, m_peakColor); + + bar.setTop(rect().top() + (1.0 - m_rmsLevel) * rect().height()); + painter.fillRect(bar, m_rmsColor); +} diff --git a/demos/spectrum/app/levelmeter.h b/demos/spectrum/app/levelmeter.h new file mode 100644 index 0000000..7d4238d --- /dev/null +++ b/demos/spectrum/app/levelmeter.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef LEVELMETER_H +#define LEVELMETER_H + +#include +#include + +/** + * Widget which displays a vertical audio level meter, indicating the + * RMS and peak levels of the window of audio samples most recently analysed + * by the Engine. + */ +class LevelMeter : public QWidget { + Q_OBJECT +public: + LevelMeter(QWidget *parent = 0); + ~LevelMeter(); + + void paintEvent(QPaintEvent *event); + +public slots: + void reset(); + void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples); + +private slots: + void redrawTimerExpired(); + +private: + /** + * Height of RMS level bar. + * Range 0.0 - 1.0. + */ + qreal m_rmsLevel; + + /** + * Most recent peak level. + * Range 0.0 - 1.0. + */ + qreal m_peakLevel; + + /** + * Height of peak level bar. + * This is calculated by decaying m_peakLevel depending on the + * elapsed time since m_peakLevelChanged, and the value of m_decayRate. + */ + qreal m_decayedPeakLevel; + + /** + * Time at which m_peakLevel was last changed. + */ + QTime m_peakLevelChanged; + + /** + * Rate at which peak level bar decays. + * Expressed in level units / millisecond. + */ + qreal m_peakDecayRate; + + /** + * High watermark of peak level. + * Range 0.0 - 1.0. + */ + qreal m_peakHoldLevel; + + /** + * Time at which m_peakHoldLevel was last changed. + */ + QTime m_peakHoldLevelChanged; + + QTimer *m_redrawTimer; + + QColor m_rmsColor; + QColor m_peakColor; + +}; + +#endif // LEVELMETER_H diff --git a/demos/spectrum/app/main.cpp b/demos/spectrum/app/main.cpp new file mode 100644 index 0000000..6e2b6fc --- /dev/null +++ b/demos/spectrum/app/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** 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 examples 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 "mainwidget.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + app.setApplicationName("QtMultimedia spectrum analyser"); + MainWidget w; + +#ifdef Q_OS_SYMBIAN + w.showMaximized(); +#else + w.show(); +#endif + + return app.exec(); +} diff --git a/demos/spectrum/app/mainwidget.cpp b/demos/spectrum/app/mainwidget.cpp new file mode 100644 index 0000000..3b7c306 --- /dev/null +++ b/demos/spectrum/app/mainwidget.cpp @@ -0,0 +1,455 @@ +/**************************************************************************** +** +** 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 examples 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 "engine.h" +#include "levelmeter.h" +#include "mainwidget.h" +#include "waveform.h" +#include "progressbar.h" +#include "settingsdialog.h" +#include "spectrograph.h" +#include "tonegeneratordialog.h" +#include "utils.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const int NullTimerId = -1; + +MainWidget::MainWidget(QWidget *parent) + : QWidget(parent) + , m_mode(NoMode) + , m_engine(new Engine(this)) +#ifndef DISABLE_WAVEFORM + , m_waveform(new Waveform(m_engine->buffer(), this)) +#endif + , m_progressBar(new ProgressBar(this)) + , m_spectrograph(new Spectrograph(this)) + , m_levelMeter(new LevelMeter(this)) + , m_modeButton(new QPushButton(this)) + , m_recordButton(new QPushButton(this)) + , m_pauseButton(new QPushButton(this)) + , m_playButton(new QPushButton(this)) + , m_settingsButton(new QPushButton(this)) + , m_infoMessage(new QLabel(tr("Select a mode to begin"), this)) + , m_infoMessageTimerId(NullTimerId) + , m_settingsDialog(new SettingsDialog( + m_engine->availableAudioInputDevices(), + m_engine->availableAudioOutputDevices(), + this)) + , m_toneGeneratorDialog(new ToneGeneratorDialog(this)) + , m_modeMenu(new QMenu(this)) + , m_loadFileAction(0) + , m_generateToneAction(0) + , m_recordAction(0) +{ + m_spectrograph->setParams(SpectrumNumBands, SpectrumLowFreq, SpectrumHighFreq); + + createUi(); + connectUi(); +} + +MainWidget::~MainWidget() +{ + +} + + +//----------------------------------------------------------------------------- +// Public slots +//----------------------------------------------------------------------------- + +void MainWidget::stateChanged(QAudio::Mode mode, QAudio::State state) +{ + Q_UNUSED(mode); + + updateButtonStates(); + + if (QAudio::ActiveState != state && QAudio::SuspendedState != state) { + m_levelMeter->reset(); + m_spectrograph->reset(); + } +} + +void MainWidget::formatChanged(const QAudioFormat &format) +{ + infoMessage(formatToString(format), NullMessageTimeout); + +#ifndef DISABLE_WAVEFORM + if (QAudioFormat() != format) { + m_waveform->initialize(format, WaveformTileLength, + WaveformWindowDuration); + } +#endif +} + +void MainWidget::spectrumChanged(qint64 position, qint64 length, + const FrequencySpectrum &spectrum) +{ + m_progressBar->windowChanged(position, length); + m_spectrograph->spectrumChanged(spectrum); +} + +void MainWidget::infoMessage(const QString &message, int timeoutMs) +{ + m_infoMessage->setText(message); + + if (NullTimerId != m_infoMessageTimerId) { + killTimer(m_infoMessageTimerId); + m_infoMessageTimerId = NullTimerId; + } + + if (NullMessageTimeout != timeoutMs) + m_infoMessageTimerId = startTimer(timeoutMs); +} + +void MainWidget::errorMessage(const QString &heading, const QString &detail) +{ +#ifdef Q_OS_SYMBIAN + const QString message = heading + "\n" + detail; + QMessageBox::warning(this, "", message, QMessageBox::Close); +#else + QMessageBox::warning(this, heading, detail, QMessageBox::Close); +#endif +} + +void MainWidget::timerEvent(QTimerEvent *event) +{ + Q_ASSERT(event->timerId() == m_infoMessageTimerId); + Q_UNUSED(event) // suppress warnings in release builds + killTimer(m_infoMessageTimerId); + m_infoMessageTimerId = NullTimerId; + m_infoMessage->setText(""); +} + +void MainWidget::positionChanged(qint64 positionUs) +{ +#ifndef DISABLE_WAVEFORM + qint64 positionBytes = audioLength(m_engine->format(), positionUs); + m_waveform->positionChanged(positionBytes); +#else + Q_UNUSED(positionUs) +#endif +} + +void MainWidget::bufferDurationChanged(qint64 durationUs) +{ + m_progressBar->bufferDurationChanged(durationUs); +} + + +//----------------------------------------------------------------------------- +// Private slots +//----------------------------------------------------------------------------- + +void MainWidget::dataDurationChanged(qint64 duration) +{ +#ifndef DISABLE_WAVEFORM + const qint64 dataLength = audioLength(m_engine->format(), duration); + m_waveform->dataLengthChanged(dataLength); +#else + Q_UNUSED(duration) +#endif + + updateButtonStates(); +} + +void MainWidget::showFileDialog() +{ + reset(); + const QString dir; + const QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open WAV file"), dir, "*.wav"); + if (fileNames.count()) { + setMode(LoadFileMode); + m_engine->loadFile(fileNames.front()); + updateButtonStates(); + } +} + +void MainWidget::showSettingsDialog() +{ + reset(); + m_settingsDialog->exec(); + if (m_settingsDialog->result() == QDialog::Accepted) { + m_engine->setAudioInputDevice(m_settingsDialog->inputDevice()); + m_engine->setAudioOutputDevice(m_settingsDialog->outputDevice()); + m_engine->setWindowFunction(m_settingsDialog->windowFunction()); + } +} + +void MainWidget::showToneGeneratorDialog() +{ + reset(); + m_toneGeneratorDialog->exec(); + if (m_toneGeneratorDialog->result() == QDialog::Accepted) { + setMode(GenerateToneMode); + const qreal amplitude = m_toneGeneratorDialog->amplitude(); + if (m_toneGeneratorDialog->isFrequencySweepEnabled()) { + m_engine->generateSweptTone(amplitude); + } else { + const qreal frequency = m_toneGeneratorDialog->frequency(); + const Tone tone(frequency, amplitude); + m_engine->generateTone(tone); + updateButtonStates(); + } + } +} + +void MainWidget::initializeRecord() +{ + reset(); + setMode(RecordMode); + if (m_engine->initializeRecord()) + updateButtonStates(); +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void MainWidget::createUi() +{ + createMenus(); + + setWindowTitle(tr("Spectrum Analyser")); + + QVBoxLayout *windowLayout = new QVBoxLayout(this); + + m_infoMessage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + m_infoMessage->setAlignment(Qt::AlignHCenter); + windowLayout->addWidget(m_infoMessage); + +#ifdef SUPERIMPOSE_PROGRESS_ON_WAVEFORM + QScopedPointer waveformLayout(new QHBoxLayout); + waveformLayout->addWidget(m_progressBar); + m_progressBar->setMinimumHeight(m_waveform->minimumHeight()); + waveformLayout->setMargin(0); + m_waveform->setLayout(waveformLayout.data()); + waveformLayout.take(); + windowLayout->addWidget(m_waveform); +#else +#ifndef DISABLE_WAVEFORM + windowLayout->addWidget(m_waveform); +#endif // DISABLE_WAVEFORM + windowLayout->addWidget(m_progressBar); +#endif // SUPERIMPOSE_PROGRESS_ON_WAVEFORM + + // Spectrograph and level meter + + QScopedPointer analysisLayout(new QHBoxLayout); + analysisLayout->addWidget(m_spectrograph); + analysisLayout->addWidget(m_levelMeter); + windowLayout->addLayout(analysisLayout.data()); + analysisLayout.take(); + + // Button panel + + const QSize buttonSize(30, 30); + + m_modeButton->setText(tr("Mode")); + + m_recordIcon = QIcon(":/images/record.png"); + m_recordButton->setIcon(m_recordIcon); + m_recordButton->setEnabled(false); + m_recordButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_recordButton->setMinimumSize(buttonSize); + + m_pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); + m_pauseButton->setIcon(m_pauseIcon); + m_pauseButton->setEnabled(false); + m_pauseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_pauseButton->setMinimumSize(buttonSize); + + m_playIcon = style()->standardIcon(QStyle::SP_MediaPlay); + m_playButton->setIcon(m_playIcon); + m_playButton->setEnabled(false); + m_playButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_playButton->setMinimumSize(buttonSize); + + m_settingsIcon = QIcon(":/images/settings.png"); + m_settingsButton->setIcon(m_settingsIcon); + m_settingsButton->setEnabled(true); + m_settingsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_settingsButton->setMinimumSize(buttonSize); + + QScopedPointer buttonPanelLayout(new QHBoxLayout); + buttonPanelLayout->addStretch(); + buttonPanelLayout->addWidget(m_modeButton); + buttonPanelLayout->addWidget(m_recordButton); + buttonPanelLayout->addWidget(m_pauseButton); + buttonPanelLayout->addWidget(m_playButton); + buttonPanelLayout->addWidget(m_settingsButton); + + QWidget *buttonPanel = new QWidget(this); + buttonPanel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + buttonPanel->setLayout(buttonPanelLayout.data()); + buttonPanelLayout.take(); // ownership transferred to buttonPanel + + QScopedPointer bottomPaneLayout(new QHBoxLayout); + bottomPaneLayout->addWidget(buttonPanel); + windowLayout->addLayout(bottomPaneLayout.data()); + bottomPaneLayout.take(); // ownership transferred to windowLayout + + // Apply layout + + setLayout(windowLayout); +} + +void MainWidget::connectUi() +{ + CHECKED_CONNECT(m_recordButton, SIGNAL(clicked()), + m_engine, SLOT(startRecording())); + + CHECKED_CONNECT(m_pauseButton, SIGNAL(clicked()), + m_engine, SLOT(suspend())); + + CHECKED_CONNECT(m_playButton, SIGNAL(clicked()), + m_engine, SLOT(startPlayback())); + + CHECKED_CONNECT(m_settingsButton, SIGNAL(clicked()), + this, SLOT(showSettingsDialog())); + + CHECKED_CONNECT(m_engine, SIGNAL(stateChanged(QAudio::Mode,QAudio::State)), + this, SLOT(stateChanged(QAudio::Mode,QAudio::State))); + + CHECKED_CONNECT(m_engine, SIGNAL(formatChanged(const QAudioFormat &)), + this, SLOT(formatChanged(const QAudioFormat &))); + + m_progressBar->bufferDurationChanged(m_engine->bufferDuration()); + + CHECKED_CONNECT(m_engine, SIGNAL(bufferDurationChanged(qint64)), + this, SLOT(bufferDurationChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(dataDurationChanged(qint64)), + this, SLOT(dataDurationChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(recordPositionChanged(qint64)), + m_progressBar, SLOT(recordPositionChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(playPositionChanged(qint64)), + m_progressBar, SLOT(playPositionChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(recordPositionChanged(qint64)), + this, SLOT(positionChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(playPositionChanged(qint64)), + this, SLOT(positionChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(levelChanged(qreal, qreal, int)), + m_levelMeter, SLOT(levelChanged(qreal, qreal, int))); + + CHECKED_CONNECT(m_engine, SIGNAL(spectrumChanged(qint64, qint64, const FrequencySpectrum &)), + this, SLOT(spectrumChanged(qint64, qint64, const FrequencySpectrum &))); + + CHECKED_CONNECT(m_engine, SIGNAL(infoMessage(QString, int)), + this, SLOT(infoMessage(QString, int))); + + CHECKED_CONNECT(m_engine, SIGNAL(errorMessage(QString, QString)), + this, SLOT(errorMessage(QString, QString))); + + CHECKED_CONNECT(m_spectrograph, SIGNAL(infoMessage(QString, int)), + this, SLOT(infoMessage(QString, int))); +} + +void MainWidget::createMenus() +{ + m_modeButton->setMenu(m_modeMenu); + + m_generateToneAction = m_modeMenu->addAction(tr("Play generated tone")); + m_recordAction = m_modeMenu->addAction(tr("Record and play back")); + m_loadFileAction = m_modeMenu->addAction(tr("Play file")); + + m_loadFileAction->setCheckable(true); + m_generateToneAction->setCheckable(true); + m_recordAction->setCheckable(true); + + connect(m_loadFileAction, SIGNAL(triggered(bool)), this, SLOT(showFileDialog())); + connect(m_generateToneAction, SIGNAL(triggered(bool)), this, SLOT(showToneGeneratorDialog())); + connect(m_recordAction, SIGNAL(triggered(bool)), this, SLOT(initializeRecord())); +} + +void MainWidget::updateButtonStates() +{ + const bool recordEnabled = ((QAudio::AudioOutput == m_engine->mode() || + (QAudio::ActiveState != m_engine->state() && + QAudio::IdleState != m_engine->state())) && + RecordMode == m_mode); + m_recordButton->setEnabled(recordEnabled); + + const bool pauseEnabled = (QAudio::ActiveState == m_engine->state() || + QAudio::IdleState == m_engine->state()); + m_pauseButton->setEnabled(pauseEnabled); + + const bool playEnabled = (m_engine->dataDuration() && + (QAudio::AudioOutput != m_engine->mode() || + (QAudio::ActiveState != m_engine->state() && + QAudio::IdleState != m_engine->state()))); + m_playButton->setEnabled(playEnabled); +} + +void MainWidget::reset() +{ +#ifndef DISABLE_WAVEFORM + m_waveform->reset(); +#endif + m_engine->reset(); + m_levelMeter->reset(); + m_spectrograph->reset(); + m_progressBar->reset(); +} + +void MainWidget::setMode(Mode mode) +{ + + m_mode = mode; + m_loadFileAction->setChecked(LoadFileMode == mode); + m_generateToneAction->setChecked(GenerateToneMode == mode); + m_recordAction->setChecked(RecordMode == mode); +} + diff --git a/demos/spectrum/app/mainwidget.h b/demos/spectrum/app/mainwidget.h new file mode 100644 index 0000000..8e24f4a --- /dev/null +++ b/demos/spectrum/app/mainwidget.h @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef MAINWIDGET_H +#define MAINWIDGET_H + +#include +#include +#include + +class Engine; +class FrequencySpectrum; +class ProgressBar; +class Spectrograph; +class Waveform; +class LevelMeter; +class SettingsDialog; +class ToneGeneratorDialog; +class QAudioFormat; +class QLabel; +class QPushButton; +class QMenu; +class QAction; + +/** + * Main application widget, responsible for connecting the various UI + * elements to the Engine. + */ +class MainWidget : public QWidget { + Q_OBJECT +public: + MainWidget(QWidget *parent = 0); + ~MainWidget(); + + // QObject + void timerEvent(QTimerEvent *event); + +public slots: + void stateChanged(QAudio::Mode mode, QAudio::State state); + void formatChanged(const QAudioFormat &format); + void spectrumChanged(qint64 position, qint64 length, + const FrequencySpectrum &spectrum); + void infoMessage(const QString &message, int timeoutMs); + void errorMessage(const QString &heading, const QString &detail); + void positionChanged(qint64 position); + void bufferDurationChanged(qint64 duration); + +private slots: + void showFileDialog(); + void showSettingsDialog(); + void showToneGeneratorDialog(); + void initializeRecord(); + void dataDurationChanged(qint64 duration); + +private: + void createUi(); + void createMenus(); + void connectUi(); + void updateButtonStates(); + void reset(); + + enum Mode { + NoMode, + RecordMode, + GenerateToneMode, + LoadFileMode + }; + + void setMode(Mode mode); + +private: + Mode m_mode; + + Engine* m_engine; + + Waveform* m_waveform; + ProgressBar* m_progressBar; + Spectrograph* m_spectrograph; + LevelMeter* m_levelMeter; + + QPushButton* m_modeButton; + QPushButton* m_recordButton; + QIcon m_recordIcon; + QPushButton* m_pauseButton; + QIcon m_pauseIcon; + QPushButton* m_playButton; + QIcon m_playIcon; + QPushButton* m_settingsButton; + QIcon m_settingsIcon; + + QLabel* m_infoMessage; + int m_infoMessageTimerId; + + SettingsDialog* m_settingsDialog; + ToneGeneratorDialog* m_toneGeneratorDialog; + + QMenu* m_modeMenu; + QAction* m_loadFileAction; + QAction* m_generateToneAction; + QAction* m_recordAction; + +}; + +#endif // MAINWIDGET_H diff --git a/demos/spectrum/app/progressbar.cpp b/demos/spectrum/app/progressbar.cpp new file mode 100644 index 0000000..256acf0 --- /dev/null +++ b/demos/spectrum/app/progressbar.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** 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 examples 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 "progressbar.h" +#include "spectrum.h" +#include + +ProgressBar::ProgressBar(QWidget *parent) + : QWidget(parent) + , m_bufferDuration(0) + , m_recordPosition(0) + , m_playPosition(0) + , m_windowPosition(0) + , m_windowLength(0) +{ + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + setMinimumHeight(30); +#ifdef SUPERIMPOSE_PROGRESS_ON_WAVEFORM + setAutoFillBackground(false); +#endif +} + +ProgressBar::~ProgressBar() +{ + +} + +void ProgressBar::reset() +{ + m_bufferDuration = 0; + m_recordPosition = 0; + m_playPosition = 0; + m_windowPosition = 0; + m_windowLength = 0; + update(); +} + +void ProgressBar::paintEvent(QPaintEvent * /*event*/) +{ + QPainter painter(this); + + QColor bufferColor(0, 0, 255); + QColor windowColor(0, 255, 0); + +#ifdef SUPERIMPOSE_PROGRESS_ON_WAVEFORM + bufferColor.setAlphaF(0.5); + windowColor.setAlphaF(0.5); +#else + painter.fillRect(rect(), Qt::black); +#endif + + if (m_bufferDuration) { + QRect bar = rect(); + const qreal play = qreal(m_playPosition) / m_bufferDuration; + bar.setLeft(rect().left() + play * rect().width()); + const qreal record = qreal(m_recordPosition) / m_bufferDuration; + bar.setRight(rect().left() + record * rect().width()); + painter.fillRect(bar, bufferColor); + + QRect window = rect(); + const qreal windowLeft = qreal(m_windowPosition) / m_bufferDuration; + window.setLeft(rect().left() + windowLeft * rect().width()); + const qreal windowWidth = qreal(m_windowLength) / m_bufferDuration; + window.setWidth(windowWidth * rect().width()); + painter.fillRect(window, windowColor); + } +} + +void ProgressBar::bufferDurationChanged(qint64 bufferSize) +{ + m_bufferDuration = bufferSize; + m_recordPosition = 0; + m_playPosition = 0; + m_windowPosition = 0; + m_windowLength = 0; + repaint(); +} + +void ProgressBar::recordPositionChanged(qint64 recordPosition) +{ + Q_ASSERT(recordPosition >= 0); + Q_ASSERT(recordPosition <= m_bufferDuration); + m_recordPosition = recordPosition; + repaint(); +} + +void ProgressBar::playPositionChanged(qint64 playPosition) +{ + Q_ASSERT(playPosition >= 0); + Q_ASSERT(playPosition <= m_bufferDuration); + m_playPosition = playPosition; + repaint(); +} + +void ProgressBar::windowChanged(qint64 position, qint64 length) +{ + Q_ASSERT(position >= 0); + Q_ASSERT(position <= m_bufferDuration); + Q_ASSERT(position + length <= m_bufferDuration); + m_windowPosition = position; + m_windowLength = length; + repaint(); +} diff --git a/demos/spectrum/app/progressbar.h b/demos/spectrum/app/progressbar.h new file mode 100644 index 0000000..8dc4765 --- /dev/null +++ b/demos/spectrum/app/progressbar.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef PROGRESSBAR_H +#define PROGRESSBAR_H + +#include + +/** + * Widget which displays a the current fill state of the Engine's internal + * buffer, and the current play/record position within that buffer. + */ +class ProgressBar : public QWidget { + Q_OBJECT +public: + ProgressBar(QWidget *parent = 0); + ~ProgressBar(); + + void reset(); + void paintEvent(QPaintEvent *event); + +public slots: + void bufferDurationChanged(qint64 bufferSize); + void recordPositionChanged(qint64 recordPosition); + void playPositionChanged(qint64 playPosition); + void windowChanged(qint64 position, qint64 length); + +private: + qint64 m_bufferDuration; + qint64 m_recordPosition; + qint64 m_playPosition; + qint64 m_windowPosition; + qint64 m_windowLength; + +}; + +#endif // PROGRESSBAR_H diff --git a/demos/spectrum/app/settingsdialog.cpp b/demos/spectrum/app/settingsdialog.cpp new file mode 100644 index 0000000..204b43f --- /dev/null +++ b/demos/spectrum/app/settingsdialog.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** 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 examples 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 "settingsdialog.h" +#include +#include +#include +#include +#include +#include +#include +#include + +SettingsDialog::SettingsDialog( + const QList &availableInputDevices, + const QList &availableOutputDevices, + QWidget *parent) + : QDialog(parent) + , m_windowFunction(DefaultWindowFunction) + , m_inputDeviceComboBox(new QComboBox(this)) + , m_outputDeviceComboBox(new QComboBox(this)) + , m_windowFunctionComboBox(new QComboBox(this)) +{ + QVBoxLayout *dialogLayout = new QVBoxLayout(this); + + // Populate combo boxes + + QAudioDeviceInfo device; + foreach (device, availableInputDevices) + m_inputDeviceComboBox->addItem(device.deviceName(), + qVariantFromValue(device)); + foreach (device, availableOutputDevices) + m_outputDeviceComboBox->addItem(device.deviceName(), + qVariantFromValue(device)); + + m_windowFunctionComboBox->addItem(tr("None"), qVariantFromValue(int(NoWindow))); + m_windowFunctionComboBox->addItem("Hann", qVariantFromValue(int(HannWindow))); + m_windowFunctionComboBox->setCurrentIndex(m_windowFunction); + + // Initialize default devices + if (!availableInputDevices.empty()) + m_inputDevice = availableInputDevices.front(); + if (!availableOutputDevices.empty()) + m_outputDevice = availableOutputDevices.front(); + + // Add widgets to layout + + QScopedPointer inputDeviceLayout(new QHBoxLayout); + QLabel *inputDeviceLabel = new QLabel(tr("Input device"), this); + inputDeviceLayout->addWidget(inputDeviceLabel); + inputDeviceLayout->addWidget(m_inputDeviceComboBox); + dialogLayout->addLayout(inputDeviceLayout.data()); + inputDeviceLayout.take(); // ownership transferred to dialogLayout + + QScopedPointer outputDeviceLayout(new QHBoxLayout); + QLabel *outputDeviceLabel = new QLabel(tr("Output device"), this); + outputDeviceLayout->addWidget(outputDeviceLabel); + outputDeviceLayout->addWidget(m_outputDeviceComboBox); + dialogLayout->addLayout(outputDeviceLayout.data()); + outputDeviceLayout.take(); // ownership transferred to dialogLayout + + QScopedPointer windowFunctionLayout(new QHBoxLayout); + QLabel *windowFunctionLabel = new QLabel(tr("Window function"), this); + windowFunctionLayout->addWidget(windowFunctionLabel); + windowFunctionLayout->addWidget(m_windowFunctionComboBox); + dialogLayout->addLayout(windowFunctionLayout.data()); + windowFunctionLayout.take(); // ownership transferred to dialogLayout + + // Connect + CHECKED_CONNECT(m_inputDeviceComboBox, SIGNAL(activated(int)), + this, SLOT(inputDeviceChanged(int))); + CHECKED_CONNECT(m_outputDeviceComboBox, SIGNAL(activated(int)), + this, SLOT(outputDeviceChanged(int))); + CHECKED_CONNECT(m_windowFunctionComboBox, SIGNAL(activated(int)), + this, SLOT(windowFunctionChanged(int))); + + // Add standard buttons to layout + QDialogButtonBox *buttonBox = new QDialogButtonBox(this); + buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + dialogLayout->addWidget(buttonBox); + + // Connect standard buttons + CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), + this, SLOT(accept())); + CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), + this, SLOT(reject())); + + setLayout(dialogLayout); +} + +SettingsDialog::~SettingsDialog() +{ + +} + +void SettingsDialog::windowFunctionChanged(int index) +{ + m_windowFunction = static_cast( + m_windowFunctionComboBox->itemData(index).value()); +} + +void SettingsDialog::inputDeviceChanged(int index) +{ + m_inputDevice = m_inputDeviceComboBox->itemData(index).value(); +} + +void SettingsDialog::outputDeviceChanged(int index) +{ + m_outputDevice = m_outputDeviceComboBox->itemData(index).value(); +} + diff --git a/demos/spectrum/app/settingsdialog.h b/demos/spectrum/app/settingsdialog.h new file mode 100644 index 0000000..5f613c0 --- /dev/null +++ b/demos/spectrum/app/settingsdialog.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef SETTINGSDIALOG_H +#define SETTINGSDIALOG_H + +#include "spectrum.h" +#include +#include + +class QComboBox; +class QCheckBox; +class QSlider; +class QSpinBox; +class QGridLayout; + +/** + * Dialog used to control settings such as the audio input / output device + * and the windowing function. + */ +class SettingsDialog : public QDialog { + Q_OBJECT +public: + SettingsDialog(const QList &availableInputDevices, + const QList &availableOutputDevices, + QWidget *parent = 0); + ~SettingsDialog(); + + WindowFunction windowFunction() const { return m_windowFunction; } + const QAudioDeviceInfo& inputDevice() const { return m_inputDevice; } + const QAudioDeviceInfo& outputDevice() const { return m_outputDevice; } + +private slots: + void windowFunctionChanged(int index); + void inputDeviceChanged(int index); + void outputDeviceChanged(int index); + +private: + WindowFunction m_windowFunction; + QAudioDeviceInfo m_inputDevice; + QAudioDeviceInfo m_outputDevice; + + QComboBox* m_inputDeviceComboBox; + QComboBox* m_outputDeviceComboBox; + + QComboBox* m_windowFunctionComboBox; + +}; + +#endif // SETTINGSDIALOG_H diff --git a/demos/spectrum/app/spectrograph.cpp b/demos/spectrum/app/spectrograph.cpp new file mode 100644 index 0000000..1fcf434 --- /dev/null +++ b/demos/spectrum/app/spectrograph.cpp @@ -0,0 +1,242 @@ +/**************************************************************************** +** +** 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 examples 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 "spectrograph.h" +#include +#include +#include +#include + +const int NullTimerId = -1; +const int NullIndex = -1; +const int BarSelectionInterval = 2000; + +Spectrograph::Spectrograph(QWidget *parent) + : QWidget(parent) + , m_barSelected(NullIndex) + , m_timerId(NullTimerId) + , m_lowFreq(0.0) + , m_highFreq(0.0) +{ + setMinimumHeight(100); +} + +Spectrograph::~Spectrograph() +{ + +} + +void Spectrograph::setParams(int numBars, qreal lowFreq, qreal highFreq) +{ + Q_ASSERT(numBars > 0); + Q_ASSERT(highFreq > lowFreq); + m_bars.resize(numBars); + m_lowFreq = lowFreq; + m_highFreq = highFreq; + updateBars(); +} + +void Spectrograph::timerEvent(QTimerEvent *event) +{ + Q_ASSERT(event->timerId() == m_timerId); + Q_UNUSED(event) // suppress warnings in release builds + killTimer(m_timerId); + m_timerId = NullTimerId; + m_barSelected = NullIndex; + update(); +} + +void Spectrograph::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event) + + QPainter painter(this); + painter.fillRect(rect(), Qt::black); + + const int numBars = m_bars.count(); + + // Highlight region of selected bar + if (m_barSelected != NullIndex && numBars) { + QRect regionRect = rect(); + regionRect.setLeft(m_barSelected * rect().width() / numBars); + regionRect.setWidth(rect().width() / numBars); + QColor regionColor(202, 202, 64); + painter.setBrush(Qt::DiagCrossPattern); + painter.fillRect(regionRect, regionColor); + painter.setBrush(Qt::NoBrush); + } + + QColor barColor(51, 204, 102); + QColor clipColor(255, 255, 0); + + // Draw the outline + const QColor gridColor = barColor.darker(); + QPen gridPen(gridColor); + painter.setPen(gridPen); + painter.drawLine(rect().topLeft(), rect().topRight()); + painter.drawLine(rect().topRight(), rect().bottomRight()); + painter.drawLine(rect().bottomRight(), rect().bottomLeft()); + painter.drawLine(rect().bottomLeft(), rect().topLeft()); + + QVector dashes; + dashes << 2 << 2; + gridPen.setDashPattern(dashes); + painter.setPen(gridPen); + + // Draw vertical lines between bars + if (numBars) { + const int numHorizontalSections = numBars; + QLine line(rect().topLeft(), rect().bottomLeft()); + for (int i=1; i= 0.0 && value <= 1.0); + QRect bar = rect(); + bar.setLeft(rect().left() + leftPaddingWidth + (i * (gapWidth + barWidth))); + bar.setWidth(barWidth); + bar.setTop(rect().top() + gapWidth + (1.0 - value) * barHeight); + bar.setBottom(rect().bottom() - gapWidth); + + QColor color = barColor; + if (m_bars[i].clipped) + color = clipColor; + + painter.fillRect(bar, color); + } + } +} + +void Spectrograph::mousePressEvent(QMouseEvent *event) +{ + const QPoint pos = event->pos(); + const int index = m_bars.count() * (pos.x() - rect().left()) / rect().width(); + selectBar(index); +} + +void Spectrograph::reset() +{ + m_spectrum.reset(); + spectrumChanged(m_spectrum); +} + +void Spectrograph::spectrumChanged(const FrequencySpectrum &spectrum) +{ + m_spectrum = spectrum; + updateBars(); +} + +int Spectrograph::barIndex(qreal frequency) const +{ + Q_ASSERT(frequency >= m_lowFreq && frequency < m_highFreq); + const qreal bandWidth = (m_highFreq - m_lowFreq) / m_bars.count(); + const int index = (frequency - m_lowFreq) / bandWidth; + if(index <0 || index >= m_bars.count()) + Q_ASSERT(false); + return index; +} + +QPair Spectrograph::barRange(int index) const +{ + Q_ASSERT(index >= 0 && index < m_bars.count()); + const qreal bandWidth = (m_highFreq - m_lowFreq) / m_bars.count(); + return QPair(index * bandWidth, (index+1) * bandWidth); +} + +void Spectrograph::updateBars() +{ + m_bars.fill(Bar()); + FrequencySpectrum::const_iterator i = m_spectrum.begin(); + const FrequencySpectrum::const_iterator end = m_spectrum.end(); + for ( ; i != end; ++i) { + const FrequencySpectrum::Element e = *i; + if (e.frequency >= m_lowFreq && e.frequency < m_highFreq) { + Bar &bar = m_bars[barIndex(e.frequency)]; + bar.value = qMax(bar.value, e.amplitude); + bar.clipped |= e.clipped; + } + } + update(); +} + +void Spectrograph::selectBar(int index) { + const QPair frequencyRange = barRange(index); + const QString message = QString("%1 - %2 Hz") + .arg(frequencyRange.first) + .arg(frequencyRange.second); + emit infoMessage(message, BarSelectionInterval); + + if (NullTimerId != m_timerId) + killTimer(m_timerId); + m_timerId = startTimer(BarSelectionInterval); + + m_barSelected = index; + update(); +} + + diff --git a/demos/spectrum/app/spectrograph.h b/demos/spectrum/app/spectrograph.h new file mode 100644 index 0000000..837a1a5 --- /dev/null +++ b/demos/spectrum/app/spectrograph.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef SPECTROGRAPH_H +#define SPECTROGRAPH_H + +#include +#include "frequencyspectrum.h" + +class QMouseEvent; + +/** + * Widget which displays a spectrograph showing the frequency spectrum + * of the window of audio samples most recently analysed by the Engine. + */ +class Spectrograph : public QWidget { + Q_OBJECT +public: + Spectrograph(QWidget *parent = 0); + ~Spectrograph(); + + void setParams(int numBars, qreal lowFreq, qreal highFreq); + + // QObject + void timerEvent(QTimerEvent *event); + + // QWidget + void paintEvent(QPaintEvent *event); + void mousePressEvent(QMouseEvent *event); + +signals: + void infoMessage(const QString &message, int intervalMs); + +public slots: + void reset(); + void spectrumChanged(const FrequencySpectrum &spectrum); + +private: + int barIndex(qreal frequency) const; + QPair barRange(int barIndex) const; + void updateBars(); + + void selectBar(int index); + +private: + struct Bar { + Bar() : value(0.0), clipped(false) { } + qreal value; + bool clipped; + }; + + QVector m_bars; + int m_barSelected; + int m_timerId; + qreal m_lowFreq; + qreal m_highFreq; + FrequencySpectrum m_spectrum; + + +}; + +#endif // SPECTROGRAPH_H diff --git a/demos/spectrum/app/spectrum.h b/demos/spectrum/app/spectrum.h new file mode 100644 index 0000000..47b88ae --- /dev/null +++ b/demos/spectrum/app/spectrum.h @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef SPECTRUM_H +#define SPECTRUM_H + +#include +#include "utils.h" +#include "fftreal_wrapper.h" // For FFTLengthPowerOfTwo + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +// Number of audio samples used to calculate the frequency spectrum +const int SpectrumLengthSamples = PowerOfTwo::Result; + +// Number of bands in the frequency spectrum +const int SpectrumNumBands = 10; + +// Lower bound of first band in the spectrum +const qreal SpectrumLowFreq = 0.0; // Hz + +// Upper band of last band in the spectrum +const qreal SpectrumHighFreq = 1000.0; // Hz + +// Waveform window size in microseconds +const qint64 WaveformWindowDuration = 500 * 1000; + +// Length of waveform tiles in bytes +// Ideally, these would match the QAudio*::bufferSize(), but that isn't +// available until some time after QAudio*::start() has been called, and we +// need this value in order to initialize the waveform display. +// We therefore just choose a sensible value. +const int WaveformTileLength = 4096; + +// Fudge factor used to calculate the spectrum bar heights +const qreal SpectrumAnalyserMultiplier = 0.15; + +// Disable message timeout +const int NullMessageTimeout = -1; + + +//----------------------------------------------------------------------------- +// Types and data structures +//----------------------------------------------------------------------------- + +enum WindowFunction { + NoWindow, + HannWindow +}; + +const WindowFunction DefaultWindowFunction = HannWindow; + +struct Tone { + Tone(qreal freq = 0.0, qreal amp = 0.0) + : frequency(freq), amplitude(amp) + { } + + // Start and end frequencies for swept tone generation + qreal frequency; + + // Amplitude in range [0.0, 1.0] + qreal amplitude; +}; + +struct SweptTone { + SweptTone(qreal start = 0.0, qreal end = 0.0, qreal amp = 0.0) + : startFreq(start), endFreq(end), amplitude(amp) + { Q_ASSERT(end >= start); } + + SweptTone(const Tone &tone) + : startFreq(tone.frequency), endFreq(tone.frequency), amplitude(tone.amplitude) + { } + + // Start and end frequencies for swept tone generation + qreal startFreq; + qreal endFreq; + + // Amplitude in range [0.0, 1.0] + qreal amplitude; +}; + + +//----------------------------------------------------------------------------- +// Macros +//----------------------------------------------------------------------------- + +// Macro which connects a signal to a slot, and which causes application to +// abort if the connection fails. This is intended to catch programming errors +// such as mis-typing a signal or slot name. It is necessary to write our own +// macro to do this - the following idiom +// Q_ASSERT(connect(source, signal, receiver, slot)); +// will not work because Q_ASSERT compiles to a no-op in release builds. + +#define CHECKED_CONNECT(source, signal, receiver, slot) \ + if(!connect(source, signal, receiver, slot)) \ + qt_assert_x(Q_FUNC_INFO, "CHECKED_CONNECT failed", __FILE__, __LINE__); + +// Handle some dependencies between macros defined in the .pro file + +#ifdef DISABLE_WAVEFORM +#undef SUPERIMPOSE_PROGRESS_ON_WAVEFORM +#endif + +#endif // SPECTRUM_H + diff --git a/demos/spectrum/app/spectrum.qrc b/demos/spectrum/app/spectrum.qrc new file mode 100644 index 0000000..6100479 --- /dev/null +++ b/demos/spectrum/app/spectrum.qrc @@ -0,0 +1,7 @@ + + + images/record.png + images/settings.png + + + diff --git a/demos/spectrum/app/spectrum.sh b/demos/spectrum/app/spectrum.sh new file mode 100644 index 0000000..75ad6c2 --- /dev/null +++ b/demos/spectrum/app/spectrum.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Shell script for launching spectrum application on Unix systems other than Mac OSX + +bindir=`dirname "$0"` +LD_LIBRARY_PATH="${bindir}:${LD_LIBRARY_PATH}" +export LD_LIBRARY_PATH +exec "${bindir}/spectrum.bin" ${1+"$@"} + diff --git a/demos/spectrum/app/spectrumanalyser.cpp b/demos/spectrum/app/spectrumanalyser.cpp new file mode 100644 index 0000000..54d3f5e --- /dev/null +++ b/demos/spectrum/app/spectrumanalyser.cpp @@ -0,0 +1,280 @@ +/**************************************************************************** +** +** 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 examples 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 "spectrumanalyser.h" +#include "utils.h" + +#include +#include +#include +#include + +#include "fftreal_wrapper.h" + +SpectrumAnalyserThread::SpectrumAnalyserThread(QObject *parent) + : QObject(parent) +#ifndef DISABLE_FFT + , m_fft(new FFTRealWrapper) +#endif + , m_numSamples(SpectrumLengthSamples) + , m_windowFunction(DefaultWindowFunction) + , m_window(SpectrumLengthSamples, 0.0) + , m_input(SpectrumLengthSamples, 0.0) + , m_output(SpectrumLengthSamples, 0.0) + , m_spectrum(SpectrumLengthSamples) +#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD + , m_thread(new QThread(this)) +#endif +{ +#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD + moveToThread(m_thread); + m_thread->start(); +#endif + calculateWindow(); +} + +SpectrumAnalyserThread::~SpectrumAnalyserThread() +{ +#ifndef DISABLE_FFT + delete m_fft; +#endif +} + +void SpectrumAnalyserThread::setWindowFunction(WindowFunction type) +{ + m_windowFunction = type; + calculateWindow(); +} + +void SpectrumAnalyserThread::calculateWindow() +{ + for (int i=0; i(ptr); + // Scale down to range [-1.0, 1.0] + const DataType realSample = pcmToReal(pcmSample); + const DataType windowedSample = realSample * m_window[i]; + m_input[i] = windowedSample; + ptr += bytesPerSample; + } + + // Calculate the FFT + m_fft->calculateFFT(m_output.data(), m_input.data()); + + // Analyse output to obtain amplitude and phase for each frequency + for (int i=2; i<=m_numSamples/2; ++i) { + // Calculate frequency of this complex sample + m_spectrum[i].frequency = qreal(i * inputFrequency) / (m_numSamples); + + const qreal real = m_output[i]; + qreal imag = 0.0; + if (i>0 && i 1.0); + amplitude = qMax(qreal(0.0), amplitude); + amplitude = qMin(qreal(1.0), amplitude); + m_spectrum[i].amplitude = amplitude; + } +#endif + + emit calculationComplete(m_spectrum); +} + + +//============================================================================= +// SpectrumAnalyser +//============================================================================= + +SpectrumAnalyser::SpectrumAnalyser(QObject *parent) + : QObject(parent) + , m_thread(new SpectrumAnalyserThread(this)) + , m_state(Idle) +#ifdef DUMP_SPECTRUMANALYSER + , m_count(0) +#endif +{ + CHECKED_CONNECT(m_thread, SIGNAL(calculationComplete(FrequencySpectrum)), + this, SLOT(calculationComplete(FrequencySpectrum))); +} + +SpectrumAnalyser::~SpectrumAnalyser() +{ + +} + +#ifdef DUMP_SPECTRUMANALYSER +void SpectrumAnalyser::setOutputPath(const QString &outputDir) +{ + m_outputDir.setPath(outputDir); + m_textFile.setFileName(m_outputDir.filePath("spectrum.txt")); + m_textFile.open(QIODevice::WriteOnly | QIODevice::Text); + m_textStream.setDevice(&m_textFile); +} +#endif + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +void SpectrumAnalyser::setWindowFunction(WindowFunction type) +{ + const bool b = QMetaObject::invokeMethod(m_thread, "setWindowFunction", + Qt::AutoConnection, + Q_ARG(WindowFunction, type)); + Q_ASSERT(b); + Q_UNUSED(b) // suppress warnings in release builds +} + +void SpectrumAnalyser::calculate(const QByteArray &buffer, + const QAudioFormat &format) +{ + // QThread::currentThread is marked 'for internal use only', but + // we're only using it for debug output here, so it's probably OK :) + SPECTRUMANALYSER_DEBUG << "SpectrumAnalyser::calculate" + << QThread::currentThread() + << "state" << m_state; + + if (isReady()) { + Q_ASSERT(isPCMS16LE(format)); + + const int bytesPerSample = format.sampleSize() * format.channels() / 8; + +#ifdef DUMP_SPECTRUMANALYSER + m_count++; + const QString pcmFileName = m_outputDir.filePath(QString("spectrum_%1.pcm").arg(m_count, 4, 10, QChar('0'))); + QFile pcmFile(pcmFileName); + pcmFile.open(QIODevice::WriteOnly); + const int bufferLength = m_numSamples * bytesPerSample; + pcmFile.write(buffer, bufferLength); + + m_textStream << "TimeDomain " << m_count << "\n"; + const qint16* input = reinterpret_cast(buffer); + for (int i=0; ifrequency << "\t" + << x->amplitude<< "\t" + << x->phase << "\n"; +#endif + } +} + +bool SpectrumAnalyser::isReady() const +{ + return (Idle == m_state); +} + +void SpectrumAnalyser::cancelCalculation() +{ + if (Busy == m_state) + m_state = Cancelled; +} + + +//----------------------------------------------------------------------------- +// Private slots +//----------------------------------------------------------------------------- + +void SpectrumAnalyser::calculationComplete(const FrequencySpectrum &spectrum) +{ + Q_ASSERT(Idle != m_state); + if (Busy == m_state) + emit spectrumChanged(spectrum); + m_state = Idle; +} + + + + diff --git a/demos/spectrum/app/spectrumanalyser.h b/demos/spectrum/app/spectrumanalyser.h new file mode 100644 index 0000000..9d7684a --- /dev/null +++ b/demos/spectrum/app/spectrumanalyser.h @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef SPECTRUMANALYSER_H +#define SPECTRUMANALYSER_H + +#include +#include +#include + +#ifdef DUMP_SPECTRUMANALYSER +#include +#include +#include +#endif + +#include "frequencyspectrum.h" +#include "spectrum.h" + +#ifndef DISABLE_FFT +#include "FFTRealFixLenParam.h" +#endif + +class QAudioFormat; +class QThread; +class FFTRealWrapper; + +class SpectrumAnalyserThreadPrivate; + +/** + * Implementation of the spectrum analysis which can be run in a + * separate thread. + */ +class SpectrumAnalyserThread : public QObject +{ + Q_OBJECT +public: + SpectrumAnalyserThread(QObject *parent); + ~SpectrumAnalyserThread(); + +public slots: + void setWindowFunction(WindowFunction type); + void calculateSpectrum(const QByteArray &buffer, + int inputFrequency, + int bytesPerSample); + +signals: + void calculationComplete(const FrequencySpectrum &spectrum); + +private: + void calculateWindow(); + +private: +#ifndef DISABLE_FFT + FFTRealWrapper* m_fft; +#endif + + const int m_numSamples; + + WindowFunction m_windowFunction; + +#ifdef DISABLE_FFT + typedef qreal DataType; +#else + typedef FFTRealFixLenParam::DataType DataType; +#endif + QVector m_window; + + QVector m_input; + QVector m_output; + + FrequencySpectrum m_spectrum; + +#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD + QThread* m_thread; +#endif +}; + +/** + * Class which performs frequency spectrum analysis on a window of + * audio samples, provided to it by the Engine. + */ +class SpectrumAnalyser : public QObject +{ + Q_OBJECT +public: + SpectrumAnalyser(QObject *parent = 0); + ~SpectrumAnalyser(); + +#ifdef DUMP_SPECTRUMANALYSER + void setOutputPath(const QString &outputPath); +#endif + +public: + /* + * Set the windowing function which is applied before calculating the FFT + */ + void setWindowFunction(WindowFunction type); + + /* + * Calculate a frequency spectrum + * + * \param buffer Audio data + * \param format Format of audio data + * + * Frequency spectrum is calculated asynchronously. The result is returned + * via the spectrumChanged signal. + * + * An ongoing calculation can be cancelled by calling cancelCalculation(). + * + */ + void calculate(const QByteArray &buffer, const QAudioFormat &format); + + /* + * Check whether the object is ready to perform another calculation + */ + bool isReady() const; + + /* + * Cancel an ongoing calculation + * + * Note that cancelling is asynchronous. + */ + void cancelCalculation(); + +signals: + void spectrumChanged(const FrequencySpectrum &spectrum); + +private slots: + void calculationComplete(const FrequencySpectrum &spectrum); + +private: + void calculateWindow(); + +private: + + SpectrumAnalyserThread* m_thread; + + enum State { + Idle, + Busy, + Cancelled + }; + + State m_state; + +#ifdef DUMP_SPECTRUMANALYSER + QDir m_outputDir; + int m_count; + QFile m_textFile; + QTextStream m_textStream; +#endif +}; + +#endif // SPECTRUMANALYSER_H + diff --git a/demos/spectrum/app/tonegenerator.cpp b/demos/spectrum/app/tonegenerator.cpp new file mode 100644 index 0000000..6458a7d --- /dev/null +++ b/demos/spectrum/app/tonegenerator.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 examples 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 "spectrum.h" +#include "utils.h" +#include +#include +#include +#include + +void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer) +{ + Q_ASSERT(isPCMS16LE(format)); + + const int channelBytes = format.sampleSize() / 8; + const int sampleBytes = format.channels() * channelBytes; + int length = buffer.size(); + const int numSamples = buffer.size() / sampleBytes; + + Q_ASSERT(length % sampleBytes == 0); + Q_UNUSED(sampleBytes) // suppress warning in release builds + + unsigned char *ptr = reinterpret_cast(buffer.data()); + + qreal phase = 0.0; + + const qreal d = 2 * M_PI / format.frequency(); + + // We can't generate a zero-frequency sine wave + const qreal startFreq = tone.startFreq ? tone.startFreq : 1.0; + + // Amount by which phase increases on each sample + qreal phaseStep = d * startFreq; + + // Amount by which phaseStep increases on each sample + // If this is non-zero, the output is a frequency-swept tone + const qreal phaseStepStep = d * (tone.endFreq - startFreq) / numSamples; + + while (length) { + const qreal x = tone.amplitude * qSin(phase); + const qint16 value = realToPcm(x); + for (int i=0; i(value, ptr); + ptr += channelBytes; + length -= channelBytes; + } + + phase += phaseStep; + while (phase > 2 * M_PI) + phase -= 2 * M_PI; + phaseStep += phaseStepStep; + } +} + diff --git a/demos/spectrum/app/tonegenerator.h b/demos/spectrum/app/tonegenerator.h new file mode 100644 index 0000000..05d4c17 --- /dev/null +++ b/demos/spectrum/app/tonegenerator.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef TONEGENERATOR_H +#define TONEGENERATOR_H + +#include +#include "spectrum.h" + +class QAudioFormat; +class QByteArray; + +/** + * Generate a sine wave + */ +void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer); + +#endif // TONEGENERATOR_H + diff --git a/demos/spectrum/app/tonegeneratordialog.cpp b/demos/spectrum/app/tonegeneratordialog.cpp new file mode 100644 index 0000000..06e453c --- /dev/null +++ b/demos/spectrum/app/tonegeneratordialog.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** 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 examples 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 "tonegeneratordialog.h" +#include +#include +#include +#include +#include +#include +#include +#include + +const int ToneGeneratorFreqMin = 1; +const int ToneGeneratorFreqMax = 1000; +const int ToneGeneratorFreqDefault = 440; +const int ToneGeneratorAmplitudeDefault = 75; + +ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent) + : QDialog(parent) + , m_toneGeneratorSweepCheckBox(new QCheckBox(tr("Frequency sweep"), this)) + , m_frequencySweepEnabled(true) + , m_toneGeneratorControl(new QWidget(this)) + , m_toneGeneratorFrequencyControl(new QWidget(this)) + , m_frequencySlider(new QSlider(Qt::Horizontal, this)) + , m_frequencySpinBox(new QSpinBox(this)) + , m_frequency(ToneGeneratorFreqDefault) + , m_amplitudeSlider(new QSlider(Qt::Horizontal, this)) +{ + QVBoxLayout *dialogLayout = new QVBoxLayout(this); + + m_toneGeneratorSweepCheckBox->setChecked(true); + + // Configure tone generator controls + m_frequencySlider->setRange(ToneGeneratorFreqMin, ToneGeneratorFreqMax); + m_frequencySlider->setValue(ToneGeneratorFreqDefault); + m_frequencySpinBox->setRange(ToneGeneratorFreqMin, ToneGeneratorFreqMax); + m_frequencySpinBox->setValue(ToneGeneratorFreqDefault); + m_amplitudeSlider->setRange(0, 100); + m_amplitudeSlider->setValue(ToneGeneratorAmplitudeDefault); + + // Add widgets to layout + + QScopedPointer frequencyControlLayout(new QGridLayout); + QLabel *frequencyLabel = new QLabel(tr("Frequency (Hz)"), this); + frequencyControlLayout->addWidget(frequencyLabel, 0, 0, 2, 1); + frequencyControlLayout->addWidget(m_frequencySlider, 0, 1); + frequencyControlLayout->addWidget(m_frequencySpinBox, 1, 1); + m_toneGeneratorFrequencyControl->setLayout(frequencyControlLayout.data()); + frequencyControlLayout.take(); // ownership transferred to m_toneGeneratorFrequencyControl + m_toneGeneratorFrequencyControl->setEnabled(false); + + QScopedPointer toneGeneratorLayout(new QGridLayout); + QLabel *amplitudeLabel = new QLabel(tr("Amplitude"), this); + toneGeneratorLayout->addWidget(m_toneGeneratorSweepCheckBox, 0, 1); + toneGeneratorLayout->addWidget(m_toneGeneratorFrequencyControl, 1, 0, 1, 2); + toneGeneratorLayout->addWidget(amplitudeLabel, 2, 0); + toneGeneratorLayout->addWidget(m_amplitudeSlider, 2, 1); + m_toneGeneratorControl->setLayout(toneGeneratorLayout.data()); + m_toneGeneratorControl->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + dialogLayout->addWidget(m_toneGeneratorControl); + toneGeneratorLayout.take(); // ownership transferred + + // Connect + CHECKED_CONNECT(m_toneGeneratorSweepCheckBox, SIGNAL(toggled(bool)), + this, SLOT(frequencySweepEnabled(bool))); + CHECKED_CONNECT(m_frequencySlider, SIGNAL(valueChanged(int)), + m_frequencySpinBox, SLOT(setValue(int))); + CHECKED_CONNECT(m_frequencySpinBox, SIGNAL(valueChanged(int)), + m_frequencySlider, SLOT(setValue(int))); + + // Add standard buttons to layout + QDialogButtonBox *buttonBox = new QDialogButtonBox(this); + buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + dialogLayout->addWidget(buttonBox); + + // Connect standard buttons + CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), + this, SLOT(accept())); + CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), + this, SLOT(reject())); + + setLayout(dialogLayout); +} + +ToneGeneratorDialog::~ToneGeneratorDialog() +{ + +} + +bool ToneGeneratorDialog::isFrequencySweepEnabled() const +{ + return m_toneGeneratorSweepCheckBox->isChecked(); +} + +qreal ToneGeneratorDialog::frequency() const +{ + return qreal(m_frequencySlider->value()); +} + +qreal ToneGeneratorDialog::amplitude() const +{ + return qreal(m_amplitudeSlider->value()) / 100.0; +} + +void ToneGeneratorDialog::frequencySweepEnabled(bool enabled) +{ + m_frequencySweepEnabled = enabled; + m_toneGeneratorFrequencyControl->setEnabled(!enabled); +} diff --git a/demos/spectrum/app/tonegeneratordialog.h b/demos/spectrum/app/tonegeneratordialog.h new file mode 100644 index 0000000..33b608d --- /dev/null +++ b/demos/spectrum/app/tonegeneratordialog.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef TONEGENERATORDIALOG_H +#define TONEGENERATORDIALOG_H + +#include "spectrum.h" +#include +#include + +class QCheckBox; +class QSlider; +class QSpinBox; +class QGridLayout; + +/** + * Dialog which controls the parameters of the tone generator. + */ +class ToneGeneratorDialog : public QDialog { + Q_OBJECT +public: + ToneGeneratorDialog(QWidget *parent = 0); + ~ToneGeneratorDialog(); + + bool isFrequencySweepEnabled() const; + qreal frequency() const; + qreal amplitude() const; + +private slots: + void frequencySweepEnabled(bool enabled); + +private: + QCheckBox* m_toneGeneratorSweepCheckBox; + bool m_frequencySweepEnabled; + QWidget* m_toneGeneratorControl; + QWidget* m_toneGeneratorFrequencyControl; + QSlider* m_frequencySlider; + QSpinBox* m_frequencySpinBox; + qreal m_frequency; + QSlider* m_amplitudeSlider; + +}; + +#endif // TONEGENERATORDIALOG_H diff --git a/demos/spectrum/app/utils.cpp b/demos/spectrum/app/utils.cpp new file mode 100644 index 0000000..97dc6e3 --- /dev/null +++ b/demos/spectrum/app/utils.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** 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 examples 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 "utils.h" + +qint64 audioDuration(const QAudioFormat &format, qint64 bytes) +{ + return (bytes * 1000000) / + (format.frequency() * format.channels() * (format.sampleSize() / 8)); +} + +qint64 audioLength(const QAudioFormat &format, qint64 microSeconds) +{ + return (format.frequency() * format.channels() * (format.sampleSize() / 8)) + * microSeconds / 1000000; +} + +qreal nyquistFrequency(const QAudioFormat &format) +{ + return format.frequency() / 2; +} + +QString formatToString(const QAudioFormat &format) +{ + QString result; + + if (QAudioFormat() != format) { + if (format.codec() == "audio/pcm") { + Q_ASSERT(format.sampleType() == QAudioFormat::SignedInt); + + const QString formatEndian = (format.byteOrder() == QAudioFormat::LittleEndian) + ? QString("LE") : QString("BE"); + + QString formatType; + switch(format.sampleType()) { + case QAudioFormat::SignedInt: + formatType = "signed"; + break; + case QAudioFormat::UnSignedInt: + formatType = "unsigned"; + break; + case QAudioFormat::Float: + formatType = "float"; + break; + case QAudioFormat::Unknown: + formatType = "unknown"; + break; + } + + QString formatChannels = QString("%1 channels").arg(format.channels()); + switch (format.channels()) { + case 1: + formatChannels = "mono"; + break; + case 2: + formatChannels = "stereo"; + break; + } + + result = QString("%1 Hz %2 bit %3 %4 %5") + .arg(format.frequency()) + .arg(format.sampleSize()) + .arg(formatType) + .arg(formatEndian) + .arg(formatChannels); + } else { + result = format.codec(); + } + } + + return result; +} + +bool isPCM(const QAudioFormat &format) +{ + return (format.codec() == "audio/pcm"); +} + + +bool isPCMS16LE(const QAudioFormat &format) +{ + return (isPCM(format) && + format.sampleType() == QAudioFormat::SignedInt && + format.sampleSize() == 16 && + format.byteOrder() == QAudioFormat::LittleEndian); +} + +const qint16 PCMS16MaxValue = 32767; +const quint16 PCMS16MaxAmplitude = 32768; // because minimum is -32768 + +qreal pcmToReal(qint16 pcm) +{ + return qreal(pcm) / PCMS16MaxAmplitude; +} + +qint16 realToPcm(qreal real) +{ + return real * PCMS16MaxValue; +} diff --git a/demos/spectrum/app/utils.h b/demos/spectrum/app/utils.h new file mode 100644 index 0000000..cfa3633 --- /dev/null +++ b/demos/spectrum/app/utils.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef UTILS_H +#define UTILS_H + +#include +#include + +class QAudioFormat; + +//----------------------------------------------------------------------------- +// Miscellaneous utility functions +//----------------------------------------------------------------------------- + +qint64 audioDuration(const QAudioFormat &format, qint64 bytes); +qint64 audioLength(const QAudioFormat &format, qint64 microSeconds); + +QString formatToString(const QAudioFormat &format); + +qreal nyquistFrequency(const QAudioFormat &format); + +// Scale PCM value to [-1.0, 1.0] +qreal pcmToReal(qint16 pcm); + +// Scale real value in [-1.0, 1.0] to PCM +qint16 realToPcm(qreal real); + +// Check whether the audio format is PCM +bool isPCM(const QAudioFormat &format); + +// Check whether the audio format is signed, little-endian, 16-bit PCM +bool isPCMS16LE(const QAudioFormat &format); + +// Compile-time calculation of powers of two + +template class PowerOfTwo +{ public: static const int Result = PowerOfTwo::Result * 2; }; + +template<> class PowerOfTwo<0> +{ public: static const int Result = 1; }; + + +//----------------------------------------------------------------------------- +// Debug output +//----------------------------------------------------------------------------- + +class NullDebug +{ +public: + template + NullDebug& operator<<(const T&) { return *this; } +}; + +inline NullDebug nullDebug() { return NullDebug(); } + +#ifdef LOG_ENGINE +# define ENGINE_DEBUG qDebug() +#else +# define ENGINE_DEBUG nullDebug() +#endif + +#ifdef LOG_SPECTRUMANALYSER +# define SPECTRUMANALYSER_DEBUG qDebug() +#else +# define SPECTRUMANALYSER_DEBUG nullDebug() +#endif + +#ifdef LOG_WAVEFORM +# define WAVEFORM_DEBUG qDebug() +#else +# define WAVEFORM_DEBUG nullDebug() +#endif + +#endif // UTILS_H diff --git a/demos/spectrum/app/waveform.cpp b/demos/spectrum/app/waveform.cpp new file mode 100644 index 0000000..3fc4f76 --- /dev/null +++ b/demos/spectrum/app/waveform.cpp @@ -0,0 +1,419 @@ +/**************************************************************************** +** +** 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 examples 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 "waveform.h" +#include "utils.h" +#include +#include +#include + + +Waveform::Waveform(const QByteArray &buffer, QWidget *parent) + : QWidget(parent) + , m_buffer(buffer) + , m_dataLength(0) + , m_position(0) + , m_active(false) + , m_tileLength(0) + , m_tileArrayStart(0) + , m_windowPosition(0) + , m_windowLength(0) +{ + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + setMinimumHeight(50); +} + +Waveform::~Waveform() +{ + deletePixmaps(); +} + +void Waveform::paintEvent(QPaintEvent * /*event*/) +{ + QPainter painter(this); + + painter.fillRect(rect(), Qt::black); + + if (m_active) { + WAVEFORM_DEBUG << "Waveform::paintEvent" + << "windowPosition" << m_windowPosition + << "windowLength" << m_windowLength; + qint64 pos = m_windowPosition; + const qint64 windowEnd = m_windowPosition + m_windowLength; + int destLeft = 0; + int destRight = 0; + while (pos < windowEnd) { + const TilePoint point = tilePoint(pos); + WAVEFORM_DEBUG << "Waveform::paintEvent" << "pos" << pos + << "tileIndex" << point.index + << "positionOffset" << point.positionOffset + << "pixelOffset" << point.pixelOffset; + + if (point.index != NullIndex) { + const Tile &tile = m_tiles[point.index]; + if (tile.painted) { + const qint64 sectionLength = qMin((m_tileLength - point.positionOffset), + (windowEnd - pos)); + Q_ASSERT(sectionLength > 0); + + const int sourceRight = tilePixelOffset(point.positionOffset + sectionLength); + destRight = windowPixelOffset(pos - m_windowPosition + sectionLength); + + QRect destRect = rect(); + destRect.setLeft(destLeft); + destRect.setRight(destRight); + + QRect sourceRect(QPoint(), m_pixmapSize); + sourceRect.setLeft(point.pixelOffset); + sourceRect.setRight(sourceRight); + + WAVEFORM_DEBUG << "Waveform::paintEvent" << "tileIndex" << point.index + << "source" << point.pixelOffset << sourceRight + << "dest" << destLeft << destRight; + + painter.drawPixmap(destRect, *tile.pixmap, sourceRect); + + destLeft = destRight; + + if (point.index < m_tiles.count()) { + pos = tilePosition(point.index + 1); + WAVEFORM_DEBUG << "Waveform::paintEvent" << "pos ->" << pos; + } else { + // Reached end of tile array + WAVEFORM_DEBUG << "Waveform::paintEvent" << "reached end of tile array"; + break; + } + } else { + // Passed last tile which is painted + WAVEFORM_DEBUG << "Waveform::paintEvent" << "tile" << point.index << "not painted"; + break; + } + } else { + // pos is past end of tile array + WAVEFORM_DEBUG << "Waveform::paintEvent" << "pos" << pos << "past end of tile array"; + break; + } + } + + WAVEFORM_DEBUG << "Waveform::paintEvent" << "final pos" << pos << "final x" << destRight; + } +} + +void Waveform::resizeEvent(QResizeEvent *event) +{ + if (event->size() != event->oldSize()) + createPixmaps(event->size()); +} + +void Waveform::initialize(const QAudioFormat &format, qint64 audioBufferSize, qint64 windowDurationUs) +{ + WAVEFORM_DEBUG << "Waveform::initialize" + << "audioBufferSize" << audioBufferSize + << "m_buffer.size()" << m_buffer.size() + << "windowDurationUs" << windowDurationUs; + + reset(); + + m_format = format; + + // Calculate tile size + m_tileLength = audioBufferSize; + + // Calculate window size + m_windowLength = audioLength(m_format, windowDurationUs); + + // Calculate number of tiles required + int nTiles; + if (m_tileLength > m_windowLength) { + nTiles = 2; + } else { + nTiles = m_windowLength / m_tileLength + 1; + if (m_windowLength % m_tileLength) + ++nTiles; + } + + WAVEFORM_DEBUG << "Waveform::initialize" + << "tileLength" << m_tileLength + << "windowLength" << m_windowLength + << "nTiles" << nTiles; + + m_pixmaps.fill(0, nTiles); + m_tiles.resize(nTiles); + + createPixmaps(rect().size()); + + m_active = true; +} + +void Waveform::reset() +{ + WAVEFORM_DEBUG << "Waveform::reset"; + + m_dataLength = 0; + m_position = 0; + m_format = QAudioFormat(); + m_active = false; + deletePixmaps(); + m_tiles.clear(); + m_tileLength = 0; + m_tileArrayStart = 0; + m_windowPosition = 0; + m_windowLength = 0; +} + +void Waveform::dataLengthChanged(qint64 length) +{ + WAVEFORM_DEBUG << "Waveform::dataLengthChanged" << length; + const qint64 oldLength = m_dataLength; + m_dataLength = length; + + if (m_active) { + if (m_dataLength < oldLength) + positionChanged(m_dataLength); + else + paintTiles(); + } +} + +void Waveform::positionChanged(qint64 position) +{ + WAVEFORM_DEBUG << "Waveform::positionChanged" << position; + + if (position + m_windowLength > m_dataLength) + position = m_dataLength - m_windowLength; + + m_position = position; + + setWindowPosition(position); +} + +void Waveform::deletePixmaps() +{ + QPixmap *pixmap; + foreach (pixmap, m_pixmaps) + delete pixmap; + m_pixmaps.clear(); +} + +void Waveform::createPixmaps(const QSize &widgetSize) +{ + m_pixmapSize = widgetSize; + m_pixmapSize.setWidth(qreal(widgetSize.width()) * m_tileLength / m_windowLength); + + WAVEFORM_DEBUG << "Waveform::createPixmaps" + << "widgetSize" << widgetSize + << "pixmapSize" << m_pixmapSize; + + Q_ASSERT(m_tiles.count() == m_pixmaps.count()); + + // (Re)create pixmaps + for (int i=0; i= oldPosition) && + (m_windowPosition - m_tileArrayStart < (m_tiles.count() * m_tileLength))) { + // Work out how many tiles need to be shuffled + const qint64 offset = m_windowPosition - m_tileArrayStart; + const int nTiles = offset / m_tileLength; + shuffleTiles(nTiles); + } else { + resetTiles(m_windowPosition); + } + + if(!paintTiles() && m_windowPosition != oldPosition) + update(); +} + +qint64 Waveform::tilePosition(int index) const +{ + return m_tileArrayStart + index * m_tileLength; +} + +Waveform::TilePoint Waveform::tilePoint(qint64 position) const +{ + TilePoint result; + if (position >= m_tileArrayStart) { + const qint64 tileArrayEnd = m_tileArrayStart + m_tiles.count() * m_tileLength; + if (position < tileArrayEnd) { + const qint64 offsetIntoTileArray = position - m_tileArrayStart; + result.index = offsetIntoTileArray / m_tileLength; + Q_ASSERT(result.index >= 0 && result.index <= m_tiles.count()); + result.positionOffset = offsetIntoTileArray % m_tileLength; + result.pixelOffset = tilePixelOffset(result.positionOffset); + Q_ASSERT(result.pixelOffset >= 0 && result.pixelOffset <= m_pixmapSize.width()); + } + } + + return result; +} + +int Waveform::tilePixelOffset(qint64 positionOffset) const +{ + Q_ASSERT(positionOffset >= 0 && positionOffset <= m_tileLength); + const int result = (qreal(positionOffset) / m_tileLength) * m_pixmapSize.width(); + return result; +} + +int Waveform::windowPixelOffset(qint64 positionOffset) const +{ + Q_ASSERT(positionOffset >= 0 && positionOffset <= m_windowLength); + const int result = (qreal(positionOffset) / m_windowLength) * rect().width(); + return result; +} + +bool Waveform::paintTiles() +{ + WAVEFORM_DEBUG << "Waveform::paintTiles"; + bool updateRequired = false; + + for (int i=0; i= tileEnd) { + paintTile(i); + updateRequired = true; + } + } + } + + if (updateRequired) + update(); + + return updateRequired; +} + +void Waveform::paintTile(int index) +{ + WAVEFORM_DEBUG << "Waveform::paintTile" << "index" << index; + + const qint64 tileStart = m_tileArrayStart + index * m_tileLength; + Q_ASSERT(m_dataLength >= tileStart + m_tileLength); + + Tile &tile = m_tiles[index]; + Q_ASSERT(!tile.painted); + + const qint16* base = reinterpret_cast(m_buffer.constData()); + const qint16* buffer = base + (tileStart / 2); + const int numSamples = m_tileLength / (2 * m_format.channels()); + + QPainter painter(tile.pixmap); + + painter.fillRect(tile.pixmap->rect(), Qt::black); + + QPen pen(Qt::white); + painter.setPen(pen); + + // Calculate initial PCM value + qint16 previousPcmValue = 0; + if (buffer > base) + previousPcmValue = *(buffer - m_format.channels()); + + // Calculate initial point + const qreal previousRealValue = pcmToReal(previousPcmValue); + const int originY = ((previousRealValue + 1.0) / 2) * m_pixmapSize.height(); + const QPoint origin(0, originY); + + QLine line(origin, origin); + + for (int i=0; i::iterator i = m_tiles.begin(); + for ( ; i != m_tiles.end(); ++i) + i->painted = false; + + m_tileArrayStart = newStartPos; +} + diff --git a/demos/spectrum/app/waveform.h b/demos/spectrum/app/waveform.h new file mode 100644 index 0000000..e5cde5c --- /dev/null +++ b/demos/spectrum/app/waveform.h @@ -0,0 +1,196 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + +#ifndef WAVEFORM_H +#define WAVEFORM_H + +#include +#include +#include +#include + +class QByteArray; + +/** + * Widget which displays a section of the audio waveform. + * + * The waveform is rendered on a set of QPixmaps which form a group of tiles + * whose extent covers the widget. As the audio position is updated, these + * tiles are scrolled from left to right; when the left-most tile scrolls + * outside the widget, it is moved to the right end of the tile array and + * painted with the next section of the waveform. + */ +class Waveform : public QWidget { + Q_OBJECT +public: + Waveform(const QByteArray &buffer, QWidget *parent = 0); + ~Waveform(); + + // QWidget + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); + + void initialize(const QAudioFormat &format, qint64 audioBufferSize, qint64 windowDurationUs); + void reset(); + + void setAutoUpdatePosition(bool enabled); + +public slots: + void dataLengthChanged(qint64 length); + void positionChanged(qint64 position); + +private: + static const int NullIndex = -1; + + void deletePixmaps(); + + /* + * (Re)create all pixmaps, repaint and update the display. + * Triggers an update(); + */ + void createPixmaps(const QSize &newSize); + + /* + * Update window position. + * Triggers an update(). + */ + void setWindowPosition(qint64 position); + + /* + * Base position of tile + */ + qint64 tilePosition(int index) const; + + /* + * Structure which identifies a point within a given + * tile. + */ + struct TilePoint + { + TilePoint(int idx = 0, qint64 pos = 0, qint64 pix = 0) + : index(idx), positionOffset(pos), pixelOffset(pix) + { } + + // Index of tile + int index; + + // Number of bytes from start of tile + qint64 positionOffset; + + // Number of pixels from left of corresponding pixmap + int pixelOffset; + }; + + /* + * Convert position in m_buffer into a tile index and an offset in pixels + * into the corresponding pixmap. + * + * \param position Offset into m_buffer, in bytes + + * If position is outside the tile array, index is NullIndex and + * offset is zero. + */ + TilePoint tilePoint(qint64 position) const; + + /* + * Convert offset in bytes into a tile into an offset in pixels + * within that tile. + */ + int tilePixelOffset(qint64 positionOffset) const; + + /* + * Convert offset in bytes into the window into an offset in pixels + * within the widget rect(). + */ + int windowPixelOffset(qint64 positionOffset) const; + + /* + * Paint all tiles which can be painted. + * \return true iff update() was called + */ + bool paintTiles(); + + /* + * Paint the specified tile + * + * \pre Sufficient data is available to completely paint the tile, i.e. + * m_dataLength is greater than the upper bound of the tile. + */ + void paintTile(int index); + + /* + * Move the first n tiles to the end of the array, and mark them as not + * painted. + */ + void shuffleTiles(int n); + + /* + * Reset tile array + */ + void resetTiles(qint64 newStartPos); + +private: + const QByteArray& m_buffer; + qint64 m_dataLength; + qint64 m_position; + QAudioFormat m_format; + + bool m_active; + + QSize m_pixmapSize; + QVector m_pixmaps; + + struct Tile { + // Pointer into parent m_pixmaps array + QPixmap* pixmap; + + // Flag indicating whether this tile has been painted + bool painted; + }; + + QVector m_tiles; + + // Length of audio data in bytes depicted by each tile + qint64 m_tileLength; + + // Position in bytes of the first tile, relative to m_buffer + qint64 m_tileArrayStart; + + qint64 m_windowPosition; + qint64 m_windowLength; + +}; + +#endif // WAVEFORM_H diff --git a/demos/spectrum/app/wavfile.cpp b/demos/spectrum/app/wavfile.cpp new file mode 100644 index 0000000..163e5ee --- /dev/null +++ b/demos/spectrum/app/wavfile.cpp @@ -0,0 +1,247 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This device is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This device contains pre-release code and may not be distributed. +** You may use this device 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 device 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 device LICENSE.LGPL included in the +** packaging of this device. 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 device LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this device, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "utils.h" +#include "wavfile.h" + +struct chunk +{ + char id[4]; + quint32 size; +}; + +struct RIFFHeader +{ + chunk descriptor; // "RIFF" + char type[4]; // "WAVE" +}; + +struct WAVEHeader +{ + chunk descriptor; + quint16 audioFormat; + quint16 numChannels; + quint32 sampleRate; + quint32 byteRate; + quint16 blockAlign; + quint16 bitsPerSample; +}; + +struct DATAHeader +{ + chunk descriptor; +}; + +struct CombinedHeader +{ + RIFFHeader riff; + WAVEHeader wave; + DATAHeader data; +}; + +static const int HeaderLength = sizeof(CombinedHeader); + + +WavFile::WavFile(const QAudioFormat &format, qint64 dataLength) + : m_format(format) + , m_dataLength(dataLength) +{ + +} + +bool WavFile::readHeader(QIODevice &device) +{ + bool result = true; + + if (!device.isSequential()) + result = device.seek(0); + // else, assume that current position is the start of the header + + if (result) { + CombinedHeader header; + result = (device.read(reinterpret_cast(&header), HeaderLength) == HeaderLength); + if (result) { + if ((memcmp(&header.riff.descriptor.id, "RIFF", 4) == 0 + || memcmp(&header.riff.descriptor.id, "RIFX", 4) == 0) + && memcmp(&header.riff.type, "WAVE", 4) == 0 + && memcmp(&header.wave.descriptor.id, "fmt ", 4) == 0 + && header.wave.audioFormat == 1 // PCM + ) { + if (memcmp(&header.riff.descriptor.id, "RIFF", 4) == 0) + m_format.setByteOrder(QAudioFormat::LittleEndian); + else + m_format.setByteOrder(QAudioFormat::BigEndian); + + m_format.setChannels(qFromLittleEndian(header.wave.numChannels)); + m_format.setCodec("audio/pcm"); + m_format.setFrequency(qFromLittleEndian(header.wave.sampleRate)); + m_format.setSampleSize(qFromLittleEndian(header.wave.bitsPerSample)); + + switch(header.wave.bitsPerSample) { + case 8: + m_format.setSampleType(QAudioFormat::UnSignedInt); + break; + case 16: + m_format.setSampleType(QAudioFormat::SignedInt); + break; + default: + result = false; + } + + m_dataLength = device.size() - HeaderLength; + } else { + result = false; + } + } + } + + return result; +} + +bool WavFile::writeHeader(QIODevice &device) +{ + CombinedHeader header; + + memset(&header, 0, HeaderLength); + + // RIFF header + if (m_format.byteOrder() == QAudioFormat::LittleEndian) + strncpy(&header.riff.descriptor.id[0], "RIFF", 4); + else + strncpy(&header.riff.descriptor.id[0], "RIFX", 4); + qToLittleEndian(quint32(m_dataLength + HeaderLength - 8), + reinterpret_cast(&header.riff.descriptor.size)); + strncpy(&header.riff.type[0], "WAVE", 4); + + // WAVE header + strncpy(&header.wave.descriptor.id[0], "fmt ", 4); + qToLittleEndian(quint32(16), + reinterpret_cast(&header.wave.descriptor.size)); + qToLittleEndian(quint16(1), + reinterpret_cast(&header.wave.audioFormat)); + qToLittleEndian(quint16(m_format.channels()), + reinterpret_cast(&header.wave.numChannels)); + qToLittleEndian(quint32(m_format.frequency()), + reinterpret_cast(&header.wave.sampleRate)); + qToLittleEndian(quint32(m_format.frequency() * m_format.channels() * m_format.sampleSize() / 8), + reinterpret_cast(&header.wave.byteRate)); + qToLittleEndian(quint16(m_format.channels() * m_format.sampleSize() / 8), + reinterpret_cast(&header.wave.blockAlign)); + qToLittleEndian(quint16(m_format.sampleSize()), + reinterpret_cast(&header.wave.bitsPerSample)); + + // DATA header + strncpy(&header.data.descriptor.id[0], "data", 4); + qToLittleEndian(quint32(m_dataLength), + reinterpret_cast(&header.data.descriptor.size)); + + return (device.write(reinterpret_cast(&header), HeaderLength) == HeaderLength); +} + +const QAudioFormat& WavFile::format() const +{ + return m_format; +} + +qint64 WavFile::dataLength() const +{ + return m_dataLength; +} + +qint64 WavFile::headerLength() +{ + return HeaderLength; +} + +bool WavFile::writeDataLength(QIODevice &device, qint64 dataLength) +{ + bool result = false; + if (!device.isSequential()) { + device.seek(40); + unsigned char dataLengthLE[4]; + qToLittleEndian(quint32(dataLength), dataLengthLE); + result = (device.write(reinterpret_cast(dataLengthLE), 4) == 4); + } + return result; +} + +#include +#include + +qint64 WavFile::readData(QIODevice &device, QByteArray &buffer, + QAudioFormat outputFormat) +{ + if (QAudioFormat() == outputFormat) + outputFormat = m_format; + + qint64 result = 0; + + QFile file("wav.txt"); + file.open(QIODevice::WriteOnly | QIODevice::Text); + QTextStream stream; + stream.setDevice(&file); + + if (isPCMS16LE(outputFormat) && isPCMS16LE(m_format)) { + QVector inputSample(2 * m_format.channels()); + + qint16 *output = reinterpret_cast(buffer.data()); + + while (result < buffer.size()) { + if (device.read(inputSample.data(), inputSample.count())) { + int inputIdx = 0; + for (int outputIdx = 0; outputIdx < outputFormat.channels(); ++outputIdx) { + const qint16* input = reinterpret_cast(inputSample.data() + 2 * inputIdx); + *output++ = qFromLittleEndian(*input); + result += 2; + if (inputIdx < m_format.channels()) + ++inputIdx; + } + } else { + break; + } + } + } + return result; +} + diff --git a/demos/spectrum/app/wavfile.h b/demos/spectrum/app/wavfile.h new file mode 100644 index 0000000..d8c54fa --- /dev/null +++ b/demos/spectrum/app/wavfile.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** +*****************************************************************************/ + + +#ifndef WAVFILE_H +#define WAVFILE_H + +#include +#include +#include + +/** + * Helper class for reading WAV files + * + * See https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ + */ +class WavFile +{ +public: + WavFile(const QAudioFormat &format = QAudioFormat(), + qint64 dataLength = 0); + + // Reads WAV header and seeks to start of data + bool readHeader(QIODevice &device); + + // Writes WAV header + bool writeHeader(QIODevice &device); + + // Read PCM data + qint64 readData(QIODevice &device, QByteArray &buffer, + QAudioFormat outputFormat = QAudioFormat()); + + const QAudioFormat& format() const; + qint64 dataLength() const; + + static qint64 headerLength(); + + static bool writeDataLength(QIODevice &device, qint64 dataLength); + +private: + QAudioFormat m_format; + qint64 m_dataLength; +}; + +#endif + diff --git a/demos/spectrum/fftreal/Array.h b/demos/spectrum/fftreal/Array.h new file mode 100644 index 0000000..a08e3cf --- /dev/null +++ b/demos/spectrum/fftreal/Array.h @@ -0,0 +1,97 @@ +/***************************************************************************** + + Array.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (Array_HEADER_INCLUDED) +#define Array_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +class Array +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef T DataType; + + Array (); + + inline const DataType & + operator [] (long pos) const; + inline DataType & + operator [] (long pos); + + static inline long + size (); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DataType _data_arr [LEN]; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + Array (const Array &other); + Array & operator = (const Array &other); + bool operator == (const Array &other); + bool operator != (const Array &other); + +}; // class Array + + + +#include "Array.hpp" + + + +#endif // Array_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/Array.hpp b/demos/spectrum/fftreal/Array.hpp new file mode 100644 index 0000000..8300077 --- /dev/null +++ b/demos/spectrum/fftreal/Array.hpp @@ -0,0 +1,98 @@ +/***************************************************************************** + + Array.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (Array_CURRENT_CODEHEADER) + #error Recursive inclusion of Array code header. +#endif +#define Array_CURRENT_CODEHEADER + +#if ! defined (Array_CODEHEADER_INCLUDED) +#define Array_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +Array ::Array () +{ + // Nothing +} + + + +template +const typename Array ::DataType & Array ::operator [] (long pos) const +{ + assert (pos >= 0); + assert (pos < LEN); + + return (_data_arr [pos]); +} + + + +template +typename Array ::DataType & Array ::operator [] (long pos) +{ + assert (pos >= 0); + assert (pos < LEN); + + return (_data_arr [pos]); +} + + + +template +long Array ::size () +{ + return (LEN); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // Array_CODEHEADER_INCLUDED + +#undef Array_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/DynArray.h b/demos/spectrum/fftreal/DynArray.h new file mode 100644 index 0000000..8041a0c --- /dev/null +++ b/demos/spectrum/fftreal/DynArray.h @@ -0,0 +1,100 @@ +/***************************************************************************** + + DynArray.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (DynArray_HEADER_INCLUDED) +#define DynArray_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +class DynArray +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef T DataType; + + DynArray (); + explicit DynArray (long size); + ~DynArray (); + + inline long size () const; + inline void resize (long size); + + inline const DataType & + operator [] (long pos) const; + inline DataType & + operator [] (long pos); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DataType * _data_ptr; + long _len; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DynArray (const DynArray &other); + DynArray & operator = (const DynArray &other); + bool operator == (const DynArray &other); + bool operator != (const DynArray &other); + +}; // class DynArray + + + +#include "DynArray.hpp" + + + +#endif // DynArray_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/DynArray.hpp b/demos/spectrum/fftreal/DynArray.hpp new file mode 100644 index 0000000..e62b10f --- /dev/null +++ b/demos/spectrum/fftreal/DynArray.hpp @@ -0,0 +1,143 @@ +/***************************************************************************** + + DynArray.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (DynArray_CURRENT_CODEHEADER) + #error Recursive inclusion of DynArray code header. +#endif +#define DynArray_CURRENT_CODEHEADER + +#if ! defined (DynArray_CODEHEADER_INCLUDED) +#define DynArray_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +DynArray ::DynArray () +: _data_ptr (0) +, _len (0) +{ + // Nothing +} + + + +template +DynArray ::DynArray (long size) +: _data_ptr (0) +, _len (0) +{ + assert (size >= 0); + if (size > 0) + { + _data_ptr = new DataType [size]; + _len = size; + } +} + + + +template +DynArray ::~DynArray () +{ + delete [] _data_ptr; + _data_ptr = 0; + _len = 0; +} + + + +template +long DynArray ::size () const +{ + return (_len); +} + + + +template +void DynArray ::resize (long size) +{ + assert (size >= 0); + if (size > 0) + { + DataType * old_data_ptr = _data_ptr; + DataType * tmp_data_ptr = new DataType [size]; + + _data_ptr = tmp_data_ptr; + _len = size; + + delete [] old_data_ptr; + } +} + + + +template +const typename DynArray ::DataType & DynArray ::operator [] (long pos) const +{ + assert (pos >= 0); + assert (pos < _len); + + return (_data_ptr [pos]); +} + + + +template +typename DynArray ::DataType & DynArray ::operator [] (long pos) +{ + assert (pos >= 0); + assert (pos < _len); + + return (_data_ptr [pos]); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // DynArray_CODEHEADER_INCLUDED + +#undef DynArray_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTReal.dsp b/demos/spectrum/fftreal/FFTReal.dsp new file mode 100644 index 0000000..fe970db --- /dev/null +++ b/demos/spectrum/fftreal/FFTReal.dsp @@ -0,0 +1,273 @@ +# Microsoft Developer Studio Project File - Name="FFTReal" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=FFTReal - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "FFTReal.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "FFTReal.mak" CFG="FFTReal - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "FFTReal - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "FFTReal - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "FFTReal - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GR /GX /O2 /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x40c /d "NDEBUG" +# ADD RSC /l 0x40c /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "FFTReal - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Gm /GR /GX /Zi /Od /Gf /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c +# ADD BASE RSC /l 0x40c /d "_DEBUG" +# ADD RSC /l 0x40c /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "FFTReal - Win32 Release" +# Name "FFTReal - Win32 Debug" +# Begin Group "Library" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\Array.h +# End Source File +# Begin Source File + +SOURCE=.\Array.hpp +# End Source File +# Begin Source File + +SOURCE=.\def.h +# End Source File +# Begin Source File + +SOURCE=.\DynArray.h +# End Source File +# Begin Source File + +SOURCE=.\DynArray.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTReal.h +# End Source File +# Begin Source File + +SOURCE=.\FFTReal.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealFixLen.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealFixLen.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealFixLenParam.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassDirect.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassDirect.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassInverse.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassInverse.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealSelect.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealSelect.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealUseTrigo.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealUseTrigo.hpp +# End Source File +# Begin Source File + +SOURCE=.\OscSinCos.h +# End Source File +# Begin Source File + +SOURCE=.\OscSinCos.hpp +# End Source File +# End Group +# Begin Group "Test" + +# PROP Default_Filter "" +# Begin Group "stopwatch" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\stopwatch\ClockCycleCounter.cpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\ClockCycleCounter.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\ClockCycleCounter.hpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\def.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\fnc.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\fnc.hpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\Int64.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\StopWatch.cpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\StopWatch.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\StopWatch.hpp +# End Source File +# End Group +# Begin Source File + +SOURCE=.\test.cpp +# End Source File +# Begin Source File + +SOURCE=.\test_fnc.h +# End Source File +# Begin Source File + +SOURCE=.\test_fnc.hpp +# End Source File +# Begin Source File + +SOURCE=.\test_settings.h +# End Source File +# Begin Source File + +SOURCE=.\TestAccuracy.h +# End Source File +# Begin Source File + +SOURCE=.\TestAccuracy.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestHelperFixLen.h +# End Source File +# Begin Source File + +SOURCE=.\TestHelperFixLen.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestHelperNormal.h +# End Source File +# Begin Source File + +SOURCE=.\TestHelperNormal.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestSpeed.h +# End Source File +# Begin Source File + +SOURCE=.\TestSpeed.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestWhiteNoiseGen.h +# End Source File +# Begin Source File + +SOURCE=.\TestWhiteNoiseGen.hpp +# End Source File +# End Group +# End Target +# End Project diff --git a/demos/spectrum/fftreal/FFTReal.dsw b/demos/spectrum/fftreal/FFTReal.dsw new file mode 100644 index 0000000..076b0ae --- /dev/null +++ b/demos/spectrum/fftreal/FFTReal.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "FFTReal"=.\FFTReal.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/demos/spectrum/fftreal/FFTReal.h b/demos/spectrum/fftreal/FFTReal.h new file mode 100644 index 0000000..9fb2725 --- /dev/null +++ b/demos/spectrum/fftreal/FFTReal.h @@ -0,0 +1,142 @@ +/***************************************************************************** + + FFTReal.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTReal_HEADER_INCLUDED) +#define FFTReal_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "DynArray.h" +#include "OscSinCos.h" + + + +template +class FFTReal +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + enum { MAX_BIT_DEPTH = 30 }; // So length can be represented as long int + + typedef DT DataType; + + explicit FFTReal (long length); + virtual ~FFTReal () {} + + long get_length () const; + void do_fft (DataType f [], const DataType x []) const; + void do_ifft (const DataType f [], DataType x []) const; + void rescale (DataType x []) const; + DataType * use_buffer () const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + // Over this bit depth, we use direct calculation for sin/cos + enum { TRIGO_BD_LIMIT = 12 }; + + typedef OscSinCos OscType; + + void init_br_lut (); + void init_trigo_lut (); + void init_trigo_osc (); + + FORCEINLINE const long * + get_br_ptr () const; + FORCEINLINE const DataType * + get_trigo_ptr (int level) const; + FORCEINLINE long + get_trigo_level_index (int level) const; + + inline void compute_fft_general (DataType f [], const DataType x []) const; + inline void compute_direct_pass_1_2 (DataType df [], const DataType x []) const; + inline void compute_direct_pass_3 (DataType df [], const DataType sf []) const; + inline void compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const; + inline void compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const; + inline void compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const; + + inline void compute_ifft_general (const DataType f [], DataType x []) const; + inline void compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const; + inline void compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const; + inline void compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const; + inline void compute_inverse_pass_3 (DataType df [], const DataType sf []) const; + inline void compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const; + + const long _length; + const int _nbr_bits; + DynArray + _br_lut; + DynArray + _trigo_lut; + mutable DynArray + _buffer; + mutable DynArray + _trigo_osc; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTReal (); + FFTReal (const FFTReal &other); + FFTReal & operator = (const FFTReal &other); + bool operator == (const FFTReal &other); + bool operator != (const FFTReal &other); + +}; // class FFTReal + + + +#include "FFTReal.hpp" + + + +#endif // FFTReal_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTReal.hpp b/demos/spectrum/fftreal/FFTReal.hpp new file mode 100644 index 0000000..335d771 --- /dev/null +++ b/demos/spectrum/fftreal/FFTReal.hpp @@ -0,0 +1,916 @@ +/***************************************************************************** + + FFTReal.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTReal_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTReal code header. +#endif +#define FFTReal_CURRENT_CODEHEADER + +#if ! defined (FFTReal_CODEHEADER_INCLUDED) +#define FFTReal_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include +#include + + + +static inline bool FFTReal_is_pow2 (long x) +{ + assert (x > 0); + + return ((x & -x) == x); +} + + + +static inline int FFTReal_get_next_pow2 (long x) +{ + --x; + + int p = 0; + while ((x & ~0xFFFFL) != 0) + { + p += 16; + x >>= 16; + } + while ((x & ~0xFL) != 0) + { + p += 4; + x >>= 4; + } + while (x > 0) + { + ++p; + x >>= 1; + } + + return (p); +} + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/* +============================================================================== +Name: ctor +Input parameters: + - length: length of the array on which we want to do a FFT. Range: power of + 2 only, > 0. +Throws: std::bad_alloc +============================================================================== +*/ + +template +FFTReal
    ::FFTReal (long length) +: _length (length) +, _nbr_bits (FFTReal_get_next_pow2 (length)) +, _br_lut () +, _trigo_lut () +, _buffer (length) +, _trigo_osc () +{ + assert (FFTReal_is_pow2 (length)); + assert (_nbr_bits <= MAX_BIT_DEPTH); + + init_br_lut (); + init_trigo_lut (); + init_trigo_osc (); +} + + + +/* +============================================================================== +Name: get_length +Description: + Returns the number of points processed by this FFT object. +Returns: The number of points, power of 2, > 0. +Throws: Nothing +============================================================================== +*/ + +template +long FFTReal
    ::get_length () const +{ + return (_length); +} + + + +/* +============================================================================== +Name: do_fft +Description: + Compute the FFT of the array. +Input parameters: + - x: pointer on the source array (time). +Output parameters: + - f: pointer on the destination array (frequencies). + f [0...length(x)/2] = real values, + f [length(x)/2+1...length(x)-1] = negative imaginary values of + coefficents 1...length(x)/2-1. +Throws: Nothing +============================================================================== +*/ + +template +void FFTReal
    ::do_fft (DataType f [], const DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + // General case + if (_nbr_bits > 2) + { + compute_fft_general (f, x); + } + + // 4-point FFT + else if (_nbr_bits == 2) + { + f [1] = x [0] - x [2]; + f [3] = x [1] - x [3]; + + const DataType b_0 = x [0] + x [2]; + const DataType b_2 = x [1] + x [3]; + + f [0] = b_0 + b_2; + f [2] = b_0 - b_2; + } + + // 2-point FFT + else if (_nbr_bits == 1) + { + f [0] = x [0] + x [1]; + f [1] = x [0] - x [1]; + } + + // 1-point FFT + else + { + f [0] = x [0]; + } +} + + + +/* +============================================================================== +Name: do_ifft +Description: + Compute the inverse FFT of the array. Note that data must be post-scaled: + IFFT (FFT (x)) = x * length (x). +Input parameters: + - f: pointer on the source array (frequencies). + f [0...length(x)/2] = real values + f [length(x)/2+1...length(x)-1] = negative imaginary values of + coefficents 1...length(x)/2-1. +Output parameters: + - x: pointer on the destination array (time). +Throws: Nothing +============================================================================== +*/ + +template +void FFTReal
    ::do_ifft (const DataType f [], DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + // General case + if (_nbr_bits > 2) + { + compute_ifft_general (f, x); + } + + // 4-point IFFT + else if (_nbr_bits == 2) + { + const DataType b_0 = f [0] + f [2]; + const DataType b_2 = f [0] - f [2]; + + x [0] = b_0 + f [1] * 2; + x [2] = b_0 - f [1] * 2; + x [1] = b_2 + f [3] * 2; + x [3] = b_2 - f [3] * 2; + } + + // 2-point IFFT + else if (_nbr_bits == 1) + { + x [0] = f [0] + f [1]; + x [1] = f [0] - f [1]; + } + + // 1-point IFFT + else + { + x [0] = f [0]; + } +} + + + +/* +============================================================================== +Name: rescale +Description: + Scale an array by divide each element by its length. This function should + be called after FFT + IFFT. +Input parameters: + - x: pointer on array to rescale (time or frequency). +Throws: Nothing +============================================================================== +*/ + +template +void FFTReal
    ::rescale (DataType x []) const +{ + const DataType mul = DataType (1.0 / _length); + + if (_length < 4) + { + long i = _length - 1; + do + { + x [i] *= mul; + --i; + } + while (i >= 0); + } + + else + { + assert ((_length & 3) == 0); + + // Could be optimized with SIMD instruction sets (needs alignment check) + long i = _length - 4; + do + { + x [i + 0] *= mul; + x [i + 1] *= mul; + x [i + 2] *= mul; + x [i + 3] *= mul; + i -= 4; + } + while (i >= 0); + } +} + + + +/* +============================================================================== +Name: use_buffer +Description: + Access the internal buffer, whose length is the FFT one. + Buffer content will be erased at each do_fft() / do_ifft() call! + This buffer cannot be used as: + - source for FFT or IFFT done with this object + - destination for FFT or IFFT done with this object +Returns: + Buffer start address +Throws: Nothing +============================================================================== +*/ + +template +typename FFTReal
    ::DataType * FFTReal
    ::use_buffer () const +{ + return (&_buffer [0]); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void FFTReal
    ::init_br_lut () +{ + const long length = 1L << _nbr_bits; + _br_lut.resize (length); + + _br_lut [0] = 0; + long br_index = 0; + for (long cnt = 1; cnt < length; ++cnt) + { + // ++br_index (bit reversed) + long bit = length >> 1; + while (((br_index ^= bit) & bit) == 0) + { + bit >>= 1; + } + + _br_lut [cnt] = br_index; + } +} + + + +template +void FFTReal
    ::init_trigo_lut () +{ + using namespace std; + + if (_nbr_bits > 3) + { + const long total_len = (1L << (_nbr_bits - 1)) - 4; + _trigo_lut.resize (total_len); + + for (int level = 3; level < _nbr_bits; ++level) + { + const long level_len = 1L << (level - 1); + DataType * const level_ptr = + &_trigo_lut [get_trigo_level_index (level)]; + const double mul = PI / (level_len << 1); + + for (long i = 0; i < level_len; ++ i) + { + level_ptr [i] = static_cast (cos (i * mul)); + } + } + } +} + + + +template +void FFTReal
    ::init_trigo_osc () +{ + const int nbr_osc = _nbr_bits - TRIGO_BD_LIMIT; + if (nbr_osc > 0) + { + _trigo_osc.resize (nbr_osc); + + for (int osc_cnt = 0; osc_cnt < nbr_osc; ++osc_cnt) + { + OscType & osc = _trigo_osc [osc_cnt]; + + const long len = 1L << (TRIGO_BD_LIMIT + osc_cnt); + const double mul = (0.5 * PI) / len; + osc.set_step (mul); + } + } +} + + + +template +const long * FFTReal
    ::get_br_ptr () const +{ + return (&_br_lut [0]); +} + + + +template +const typename FFTReal
    ::DataType * FFTReal
    ::get_trigo_ptr (int level) const +{ + assert (level >= 3); + + return (&_trigo_lut [get_trigo_level_index (level)]); +} + + + +template +long FFTReal
    ::get_trigo_level_index (int level) const +{ + assert (level >= 3); + + return ((1L << (level - 1)) - 4); +} + + + +// Transform in several passes +template +void FFTReal
    ::compute_fft_general (DataType f [], const DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + DataType * sf; + DataType * df; + + if ((_nbr_bits & 1) != 0) + { + df = use_buffer (); + sf = f; + } + else + { + df = f; + sf = use_buffer (); + } + + compute_direct_pass_1_2 (df, x); + compute_direct_pass_3 (sf, df); + + for (int pass = 3; pass < _nbr_bits; ++ pass) + { + compute_direct_pass_n (df, sf, pass); + + DataType * const temp_ptr = df; + df = sf; + sf = temp_ptr; + } +} + + + +template +void FFTReal
    ::compute_direct_pass_1_2 (DataType df [], const DataType x []) const +{ + assert (df != 0); + assert (x != 0); + assert (df != x); + + const long * const bit_rev_lut_ptr = get_br_ptr (); + long coef_index = 0; + do + { + const long rev_index_0 = bit_rev_lut_ptr [coef_index]; + const long rev_index_1 = bit_rev_lut_ptr [coef_index + 1]; + const long rev_index_2 = bit_rev_lut_ptr [coef_index + 2]; + const long rev_index_3 = bit_rev_lut_ptr [coef_index + 3]; + + DataType * const df2 = df + coef_index; + df2 [1] = x [rev_index_0] - x [rev_index_1]; + df2 [3] = x [rev_index_2] - x [rev_index_3]; + + const DataType sf_0 = x [rev_index_0] + x [rev_index_1]; + const DataType sf_2 = x [rev_index_2] + x [rev_index_3]; + + df2 [0] = sf_0 + sf_2; + df2 [2] = sf_0 - sf_2; + + coef_index += 4; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_direct_pass_3 (DataType df [], const DataType sf []) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + long coef_index = 0; + do + { + DataType v; + + df [coef_index] = sf [coef_index] + sf [coef_index + 4]; + df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; + df [coef_index + 2] = sf [coef_index + 2]; + df [coef_index + 6] = sf [coef_index + 6]; + + v = (sf [coef_index + 5] - sf [coef_index + 7]) * sqrt2_2; + df [coef_index + 1] = sf [coef_index + 1] + v; + df [coef_index + 3] = sf [coef_index + 1] - v; + + v = (sf [coef_index + 5] + sf [coef_index + 7]) * sqrt2_2; + df [coef_index + 5] = v + sf [coef_index + 3]; + df [coef_index + 7] = v - sf [coef_index + 3]; + + coef_index += 8; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + if (pass <= TRIGO_BD_LIMIT) + { + compute_direct_pass_n_lut (df, sf, pass); + } + else + { + compute_direct_pass_n_osc (df, sf, pass); + } +} + + + +template +void FFTReal
    ::compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + const DataType * const cos_ptr = get_trigo_ptr (pass); + do + { + const DataType * const sf1r = sf + coef_index; + const DataType * const sf2r = sf1r + nbr_coef; + DataType * const dfr = df + coef_index; + DataType * const dfi = dfr + nbr_coef; + + // Extreme coefficients are always real + dfr [0] = sf1r [0] + sf2r [0]; + dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = + dfr [h_nbr_coef] = sf1r [h_nbr_coef]; + dfi [h_nbr_coef] = sf2r [h_nbr_coef]; + + // Others are conjugate complex numbers + const DataType * const sf1i = sf1r + h_nbr_coef; + const DataType * const sf2i = sf1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); + const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); + DataType v; + + v = sf2r [i] * c - sf2i [i] * s; + dfr [i] = sf1r [i] + v; + dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = + + v = sf2r [i] * s + sf2i [i] * c; + dfi [i] = v + sf1i [i]; + dfi [nbr_coef - i] = v - sf1i [i]; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass > TRIGO_BD_LIMIT); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; + do + { + const DataType * const sf1r = sf + coef_index; + const DataType * const sf2r = sf1r + nbr_coef; + DataType * const dfr = df + coef_index; + DataType * const dfi = dfr + nbr_coef; + + osc.clear_buffers (); + + // Extreme coefficients are always real + dfr [0] = sf1r [0] + sf2r [0]; + dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = + dfr [h_nbr_coef] = sf1r [h_nbr_coef]; + dfi [h_nbr_coef] = sf2r [h_nbr_coef]; + + // Others are conjugate complex numbers + const DataType * const sf1i = sf1r + h_nbr_coef; + const DataType * const sf2i = sf1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + osc.step (); + const DataType c = osc.get_cos (); + const DataType s = osc.get_sin (); + DataType v; + + v = sf2r [i] * c - sf2i [i] * s; + dfr [i] = sf1r [i] + v; + dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = + + v = sf2r [i] * s + sf2i [i] * c; + dfi [i] = v + sf1i [i]; + dfi [nbr_coef - i] = v - sf1i [i]; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +// Transform in several pass +template +void FFTReal
    ::compute_ifft_general (const DataType f [], DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + DataType * sf = const_cast (f); + DataType * df; + DataType * df_temp; + + if (_nbr_bits & 1) + { + df = use_buffer (); + df_temp = x; + } + else + { + df = x; + df_temp = use_buffer (); + } + + for (int pass = _nbr_bits - 1; pass >= 3; -- pass) + { + compute_inverse_pass_n (df, sf, pass); + + if (pass < _nbr_bits - 1) + { + DataType * const temp_ptr = df; + df = sf; + sf = temp_ptr; + } + else + { + sf = df; + df = df_temp; + } + } + + compute_inverse_pass_3 (df, sf); + compute_inverse_pass_1_2 (x, df); +} + + + +template +void FFTReal
    ::compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + if (pass <= TRIGO_BD_LIMIT) + { + compute_inverse_pass_n_lut (df, sf, pass); + } + else + { + compute_inverse_pass_n_osc (df, sf, pass); + } +} + + + +template +void FFTReal
    ::compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + const DataType * const cos_ptr = get_trigo_ptr (pass); + do + { + const DataType * const sfr = sf + coef_index; + const DataType * const sfi = sfr + nbr_coef; + DataType * const df1r = df + coef_index; + DataType * const df2r = df1r + nbr_coef; + + // Extreme coefficients are always real + df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] + df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] + df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; + df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; + + // Others are conjugate complex numbers + DataType * const df1i = df1r + h_nbr_coef; + DataType * const df2i = df1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] + df1i [i] = sfi [i] - sfi [nbr_coef - i]; + + const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); + const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); + const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] + const DataType vi = sfi [i] + sfi [nbr_coef - i]; + + df2r [i] = vr * c + vi * s; + df2i [i] = vi * c - vr * s; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass > TRIGO_BD_LIMIT); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; + do + { + const DataType * const sfr = sf + coef_index; + const DataType * const sfi = sfr + nbr_coef; + DataType * const df1r = df + coef_index; + DataType * const df2r = df1r + nbr_coef; + + osc.clear_buffers (); + + // Extreme coefficients are always real + df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] + df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] + df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; + df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; + + // Others are conjugate complex numbers + DataType * const df1i = df1r + h_nbr_coef; + DataType * const df2i = df1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] + df1i [i] = sfi [i] - sfi [nbr_coef - i]; + + osc.step (); + const DataType c = osc.get_cos (); + const DataType s = osc.get_sin (); + const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] + const DataType vi = sfi [i] + sfi [nbr_coef - i]; + + df2r [i] = vr * c + vi * s; + df2i [i] = vi * c - vr * s; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_inverse_pass_3 (DataType df [], const DataType sf []) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + long coef_index = 0; + do + { + df [coef_index] = sf [coef_index] + sf [coef_index + 4]; + df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; + df [coef_index + 2] = sf [coef_index + 2] * 2; + df [coef_index + 6] = sf [coef_index + 6] * 2; + + df [coef_index + 1] = sf [coef_index + 1] + sf [coef_index + 3]; + df [coef_index + 3] = sf [coef_index + 5] - sf [coef_index + 7]; + + const DataType vr = sf [coef_index + 1] - sf [coef_index + 3]; + const DataType vi = sf [coef_index + 5] + sf [coef_index + 7]; + + df [coef_index + 5] = (vr + vi) * sqrt2_2; + df [coef_index + 7] = (vi - vr) * sqrt2_2; + + coef_index += 8; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const +{ + assert (x != 0); + assert (sf != 0); + assert (x != sf); + + const long * bit_rev_lut_ptr = get_br_ptr (); + const DataType * sf2 = sf; + long coef_index = 0; + do + { + { + const DataType b_0 = sf2 [0] + sf2 [2]; + const DataType b_2 = sf2 [0] - sf2 [2]; + const DataType b_1 = sf2 [1] * 2; + const DataType b_3 = sf2 [3] * 2; + + x [bit_rev_lut_ptr [0]] = b_0 + b_1; + x [bit_rev_lut_ptr [1]] = b_0 - b_1; + x [bit_rev_lut_ptr [2]] = b_2 + b_3; + x [bit_rev_lut_ptr [3]] = b_2 - b_3; + } + { + const DataType b_0 = sf2 [4] + sf2 [6]; + const DataType b_2 = sf2 [4] - sf2 [6]; + const DataType b_1 = sf2 [5] * 2; + const DataType b_3 = sf2 [7] * 2; + + x [bit_rev_lut_ptr [4]] = b_0 + b_1; + x [bit_rev_lut_ptr [5]] = b_0 - b_1; + x [bit_rev_lut_ptr [6]] = b_2 + b_3; + x [bit_rev_lut_ptr [7]] = b_2 - b_3; + } + + sf2 += 8; + coef_index += 8; + bit_rev_lut_ptr += 8; + } + while (coef_index < _length); +} + + + +#endif // FFTReal_CODEHEADER_INCLUDED + +#undef FFTReal_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealFixLen.h b/demos/spectrum/fftreal/FFTRealFixLen.h new file mode 100644 index 0000000..0b80266 --- /dev/null +++ b/demos/spectrum/fftreal/FFTRealFixLen.h @@ -0,0 +1,130 @@ +/***************************************************************************** + + FFTRealFixLen.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealFixLen_HEADER_INCLUDED) +#define FFTRealFixLen_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "Array.h" +#include "DynArray.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + +template +class FFTRealFixLen +{ + typedef int CompileTimeCheck1 [(LL2 >= 0) ? 1 : -1]; + typedef int CompileTimeCheck2 [(LL2 <= 30) ? 1 : -1]; + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; + + enum { FFT_LEN_L2 = LL2 }; + enum { FFT_LEN = 1 << FFT_LEN_L2 }; + + FFTRealFixLen (); + + inline long get_length () const; + void do_fft (DataType f [], const DataType x []); + void do_ifft (const DataType f [], DataType x []); + void rescale (DataType x []) const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + enum { TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT }; + + enum { BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) }; + enum { BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 }; + + enum { TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0) + ? (int)FFT_LEN_L2 + : (int)TRIGO_BD_LIMIT }; + enum { TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) }; + enum { TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 }; + + enum { NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD }; + enum { TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 }; + + void build_br_lut (); + void build_trigo_lut (); + void build_trigo_osc (); + + DynArray + _buffer; + DynArray + _br_data; + DynArray + _trigo_data; + Array + _trigo_osc; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealFixLen (const FFTRealFixLen &other); + FFTRealFixLen& operator = (const FFTRealFixLen &other); + bool operator == (const FFTRealFixLen &other); + bool operator != (const FFTRealFixLen &other); + +}; // class FFTRealFixLen + + + +#include "FFTRealFixLen.hpp" + + + +#endif // FFTRealFixLen_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealFixLen.hpp b/demos/spectrum/fftreal/FFTRealFixLen.hpp new file mode 100644 index 0000000..6defb00 --- /dev/null +++ b/demos/spectrum/fftreal/FFTRealFixLen.hpp @@ -0,0 +1,322 @@ +/***************************************************************************** + + FFTRealFixLen.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealFixLen_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealFixLen code header. +#endif +#define FFTRealFixLen_CURRENT_CODEHEADER + +#if ! defined (FFTRealFixLen_CODEHEADER_INCLUDED) +#define FFTRealFixLen_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealPassDirect.h" +#include "FFTRealPassInverse.h" +#include "FFTRealSelect.h" + +#include +#include + +namespace std { } + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +FFTRealFixLen ::FFTRealFixLen () +: _buffer (FFT_LEN) +, _br_data (BR_ARR_SIZE) +, _trigo_data (TRIGO_TABLE_ARR_SIZE) +, _trigo_osc () +{ + build_br_lut (); + build_trigo_lut (); + build_trigo_osc (); +} + + + +template +long FFTRealFixLen ::get_length () const +{ + return (FFT_LEN); +} + + + +// General case +template +void FFTRealFixLen ::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + assert (FFT_LEN_L2 >= 3); + + // Do the transform in several passes + const DataType * cos_ptr = &_trigo_data [0]; + const long * br_ptr = &_br_data [0]; + + FFTRealPassDirect ::process ( + FFT_LEN, + f, + &_buffer [0], + x, + cos_ptr, + TRIGO_TABLE_ARR_SIZE, + br_ptr, + &_trigo_osc [0] + ); +} + +// 4-point FFT +template <> +void FFTRealFixLen <2>::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + f [1] = x [0] - x [2]; + f [3] = x [1] - x [3]; + + const DataType b_0 = x [0] + x [2]; + const DataType b_2 = x [1] + x [3]; + + f [0] = b_0 + b_2; + f [2] = b_0 - b_2; +} + +// 2-point FFT +template <> +void FFTRealFixLen <1>::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + f [0] = x [0] + x [1]; + f [1] = x [0] - x [1]; +} + +// 1-point FFT +template <> +void FFTRealFixLen <0>::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + + f [0] = x [0]; +} + + + +// General case +template +void FFTRealFixLen ::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + assert (FFT_LEN_L2 >= 3); + + // Do the transform in several passes + DataType * s_ptr = + FFTRealSelect ::sel_bin (&_buffer [0], x); + DataType * d_ptr = + FFTRealSelect ::sel_bin (x, &_buffer [0]); + const DataType * cos_ptr = &_trigo_data [0]; + const long * br_ptr = &_br_data [0]; + + FFTRealPassInverse ::process ( + FFT_LEN, + d_ptr, + s_ptr, + f, + cos_ptr, + TRIGO_TABLE_ARR_SIZE, + br_ptr, + &_trigo_osc [0] + ); +} + +// 4-point IFFT +template <> +void FFTRealFixLen <2>::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + const DataType b_0 = f [0] + f [2]; + const DataType b_2 = f [0] - f [2]; + + x [0] = b_0 + f [1] * 2; + x [2] = b_0 - f [1] * 2; + x [1] = b_2 + f [3] * 2; + x [3] = b_2 - f [3] * 2; +} + +// 2-point IFFT +template <> +void FFTRealFixLen <1>::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + x [0] = f [0] + f [1]; + x [1] = f [0] - f [1]; +} + +// 1-point IFFT +template <> +void FFTRealFixLen <0>::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + x [0] = f [0]; +} + + + + +template +void FFTRealFixLen ::rescale (DataType x []) const +{ + assert (x != 0); + + const DataType mul = DataType (1.0 / FFT_LEN); + + if (FFT_LEN < 4) + { + long i = FFT_LEN - 1; + do + { + x [i] *= mul; + --i; + } + while (i >= 0); + } + + else + { + assert ((FFT_LEN & 3) == 0); + + // Could be optimized with SIMD instruction sets (needs alignment check) + long i = FFT_LEN - 4; + do + { + x [i + 0] *= mul; + x [i + 1] *= mul; + x [i + 2] *= mul; + x [i + 3] *= mul; + i -= 4; + } + while (i >= 0); + } +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void FFTRealFixLen ::build_br_lut () +{ + _br_data [0] = 0; + for (long cnt = 1; cnt < BR_ARR_SIZE; ++cnt) + { + long index = cnt << 2; + long br_index = 0; + + int bit_cnt = FFT_LEN_L2; + do + { + br_index <<= 1; + br_index += (index & 1); + index >>= 1; + + -- bit_cnt; + } + while (bit_cnt > 0); + + _br_data [cnt] = br_index; + } +} + + + +template +void FFTRealFixLen ::build_trigo_lut () +{ + const double mul = (0.5 * PI) / TRIGO_TABLE_ARR_SIZE; + for (long i = 0; i < TRIGO_TABLE_ARR_SIZE; ++ i) + { + using namespace std; + + _trigo_data [i] = DataType (cos (i * mul)); + } +} + + + +template +void FFTRealFixLen ::build_trigo_osc () +{ + for (int i = 0; i < NBR_TRIGO_OSC; ++i) + { + OscType & osc = _trigo_osc [i]; + + const long len = static_cast (TRIGO_TABLE_ARR_SIZE) << (i + 1); + const double mul = (0.5 * PI) / len; + osc.set_step (mul); + } +} + + + +#endif // FFTRealFixLen_CODEHEADER_INCLUDED + +#undef FFTRealFixLen_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealFixLenParam.h b/demos/spectrum/fftreal/FFTRealFixLenParam.h new file mode 100644 index 0000000..163c083 --- /dev/null +++ b/demos/spectrum/fftreal/FFTRealFixLenParam.h @@ -0,0 +1,93 @@ +/***************************************************************************** + + FFTRealFixLenParam.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealFixLenParam_HEADER_INCLUDED) +#define FFTRealFixLenParam_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +class FFTRealFixLenParam +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + // Over this bit depth, we use direct calculation for sin/cos + enum { TRIGO_BD_LIMIT = 12 }; + + typedef float DataType; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + +#if 0 // To avoid GCC warning: + // All member functions in class 'FFTRealFixLenParam' are private + FFTRealFixLenParam (); + ~FFTRealFixLenParam (); + FFTRealFixLenParam (const FFTRealFixLenParam &other); + FFTRealFixLenParam & + operator = (const FFTRealFixLenParam &other); + bool operator == (const FFTRealFixLenParam &other); + bool operator != (const FFTRealFixLenParam &other); +#endif + +}; // class FFTRealFixLenParam + + + +//#include "FFTRealFixLenParam.hpp" + + + +#endif // FFTRealFixLenParam_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealPassDirect.h b/demos/spectrum/fftreal/FFTRealPassDirect.h new file mode 100644 index 0000000..7d19c02 --- /dev/null +++ b/demos/spectrum/fftreal/FFTRealPassDirect.h @@ -0,0 +1,96 @@ +/***************************************************************************** + + FFTRealPassDirect.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealPassDirect_HEADER_INCLUDED) +#define FFTRealPassDirect_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + +template +class FFTRealPassDirect +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; + + FORCEINLINE static void + process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealPassDirect (); + ~FFTRealPassDirect (); + FFTRealPassDirect (const FFTRealPassDirect &other); + FFTRealPassDirect & + operator = (const FFTRealPassDirect &other); + bool operator == (const FFTRealPassDirect &other); + bool operator != (const FFTRealPassDirect &other); + +}; // class FFTRealPassDirect + + + +#include "FFTRealPassDirect.hpp" + + + +#endif // FFTRealPassDirect_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealPassDirect.hpp b/demos/spectrum/fftreal/FFTRealPassDirect.hpp new file mode 100644 index 0000000..db9d568 --- /dev/null +++ b/demos/spectrum/fftreal/FFTRealPassDirect.hpp @@ -0,0 +1,204 @@ +/***************************************************************************** + + FFTRealPassDirect.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealPassDirect_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealPassDirect code header. +#endif +#define FFTRealPassDirect_CURRENT_CODEHEADER + +#if ! defined (FFTRealPassDirect_CODEHEADER_INCLUDED) +#define FFTRealPassDirect_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTRealUseTrigo.h" + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <> +void FFTRealPassDirect <1>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // First and second pass at once + const long qlen = len >> 2; + + long coef_index = 0; + do + { + // To do: unroll the loop (2x). + const long ri_0 = br_ptr [coef_index >> 2]; + const long ri_1 = ri_0 + 2 * qlen; // bit_rev_lut_ptr [coef_index + 1]; + const long ri_2 = ri_0 + 1 * qlen; // bit_rev_lut_ptr [coef_index + 2]; + const long ri_3 = ri_0 + 3 * qlen; // bit_rev_lut_ptr [coef_index + 3]; + + DataType * const df2 = dest_ptr + coef_index; + df2 [1] = x_ptr [ri_0] - x_ptr [ri_1]; + df2 [3] = x_ptr [ri_2] - x_ptr [ri_3]; + + const DataType sf_0 = x_ptr [ri_0] + x_ptr [ri_1]; + const DataType sf_2 = x_ptr [ri_2] + x_ptr [ri_3]; + + df2 [0] = sf_0 + sf_2; + df2 [2] = sf_0 - sf_2; + + coef_index += 4; + } + while (coef_index < len); +} + +template <> +void FFTRealPassDirect <2>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Executes "previous" passes first. Inverts source and destination buffers + FFTRealPassDirect <1>::process ( + len, + src_ptr, + dest_ptr, + x_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + + // Third pass + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + + long coef_index = 0; + do + { + dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; + dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; + dest_ptr [coef_index + 2] = src_ptr [coef_index + 2]; + dest_ptr [coef_index + 6] = src_ptr [coef_index + 6]; + + DataType v; + + v = (src_ptr [coef_index + 5] - src_ptr [coef_index + 7]) * sqrt2_2; + dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + v; + dest_ptr [coef_index + 3] = src_ptr [coef_index + 1] - v; + + v = (src_ptr [coef_index + 5] + src_ptr [coef_index + 7]) * sqrt2_2; + dest_ptr [coef_index + 5] = v + src_ptr [coef_index + 3]; + dest_ptr [coef_index + 7] = v - src_ptr [coef_index + 3]; + + coef_index += 8; + } + while (coef_index < len); +} + +template +void FFTRealPassDirect ::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Executes "previous" passes first. Inverts source and destination buffers + FFTRealPassDirect ::process ( + len, + src_ptr, + dest_ptr, + x_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + + const long dist = 1L << (PASS - 1); + const long c1_r = 0; + const long c1_i = dist; + const long c2_r = dist * 2; + const long c2_i = dist * 3; + const long cend = dist * 4; + const long table_step = cos_len >> (PASS - 1); + + enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; + enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; + + long coef_index = 0; + do + { + const DataType * const sf = src_ptr + coef_index; + DataType * const df = dest_ptr + coef_index; + + // Extreme coefficients are always real + df [c1_r] = sf [c1_r] + sf [c2_r]; + df [c2_r] = sf [c1_r] - sf [c2_r]; + df [c1_i] = sf [c1_i]; + df [c2_i] = sf [c2_i]; + + FFTRealUseTrigo ::prepare (osc_list [TRIGO_OSC]); + + // Others are conjugate complex numbers + for (long i = 1; i < dist; ++ i) + { + DataType c; + DataType s; + FFTRealUseTrigo ::iterate ( + osc_list [TRIGO_OSC], + c, + s, + cos_ptr, + i * table_step, + (dist - i) * table_step + ); + + const DataType sf_r_i = sf [c1_r + i]; + const DataType sf_i_i = sf [c1_i + i]; + + const DataType v1 = sf [c2_r + i] * c - sf [c2_i + i] * s; + df [c1_r + i] = sf_r_i + v1; + df [c2_r - i] = sf_r_i - v1; + + const DataType v2 = sf [c2_r + i] * s + sf [c2_i + i] * c; + df [c2_r + i] = v2 + sf_i_i; + df [cend - i] = v2 - sf_i_i; + } + + coef_index += cend; + } + while (coef_index < len); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // FFTRealPassDirect_CODEHEADER_INCLUDED + +#undef FFTRealPassDirect_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealPassInverse.h b/demos/spectrum/fftreal/FFTRealPassInverse.h new file mode 100644 index 0000000..2de8952 --- /dev/null +++ b/demos/spectrum/fftreal/FFTRealPassInverse.h @@ -0,0 +1,101 @@ +/***************************************************************************** + + FFTRealPassInverse.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealPassInverse_HEADER_INCLUDED) +#define FFTRealPassInverse_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + + +template +class FFTRealPassInverse +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; + + FORCEINLINE static void + process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + FORCEINLINE static void + process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + FORCEINLINE static void + process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealPassInverse (); + ~FFTRealPassInverse (); + FFTRealPassInverse (const FFTRealPassInverse &other); + FFTRealPassInverse & + operator = (const FFTRealPassInverse &other); + bool operator == (const FFTRealPassInverse &other); + bool operator != (const FFTRealPassInverse &other); + +}; // class FFTRealPassInverse + + + +#include "FFTRealPassInverse.hpp" + + + +#endif // FFTRealPassInverse_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealPassInverse.hpp b/demos/spectrum/fftreal/FFTRealPassInverse.hpp new file mode 100644 index 0000000..5737546 --- /dev/null +++ b/demos/spectrum/fftreal/FFTRealPassInverse.hpp @@ -0,0 +1,229 @@ +/***************************************************************************** + + FFTRealPassInverse.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealPassInverse_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealPassInverse code header. +#endif +#define FFTRealPassInverse_CURRENT_CODEHEADER + +#if ! defined (FFTRealPassInverse_CODEHEADER_INCLUDED) +#define FFTRealPassInverse_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTRealUseTrigo.h" + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void FFTRealPassInverse ::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + process_internal ( + len, + dest_ptr, + f_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + FFTRealPassInverse ::process_rec ( + len, + src_ptr, + dest_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); +} + + + +template +void FFTRealPassInverse ::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + process_internal ( + len, + dest_ptr, + src_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + FFTRealPassInverse ::process_rec ( + len, + src_ptr, + dest_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); +} + +template <> +void FFTRealPassInverse <0>::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Stops recursion +} + + + +template +void FFTRealPassInverse ::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + const long dist = 1L << (PASS - 1); + const long c1_r = 0; + const long c1_i = dist; + const long c2_r = dist * 2; + const long c2_i = dist * 3; + const long cend = dist * 4; + const long table_step = cos_len >> (PASS - 1); + + enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; + enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; + + long coef_index = 0; + do + { + const DataType * const sf = src_ptr + coef_index; + DataType * const df = dest_ptr + coef_index; + + // Extreme coefficients are always real + df [c1_r] = sf [c1_r] + sf [c2_r]; + df [c2_r] = sf [c1_r] - sf [c2_r]; + df [c1_i] = sf [c1_i] * 2; + df [c2_i] = sf [c2_i] * 2; + + FFTRealUseTrigo ::prepare (osc_list [TRIGO_OSC]); + + // Others are conjugate complex numbers + for (long i = 1; i < dist; ++ i) + { + df [c1_r + i] = sf [c1_r + i] + sf [c2_r - i]; + df [c1_i + i] = sf [c2_r + i] - sf [cend - i]; + + DataType c; + DataType s; + FFTRealUseTrigo ::iterate ( + osc_list [TRIGO_OSC], + c, + s, + cos_ptr, + i * table_step, + (dist - i) * table_step + ); + + const DataType vr = sf [c1_r + i] - sf [c2_r - i]; + const DataType vi = sf [c2_r + i] + sf [cend - i]; + + df [c2_r + i] = vr * c + vi * s; + df [c2_i + i] = vi * c - vr * s; + } + + coef_index += cend; + } + while (coef_index < len); +} + +template <> +void FFTRealPassInverse <2>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Antepenultimate pass + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + + long coef_index = 0; + do + { + dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; + dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; + dest_ptr [coef_index + 2] = src_ptr [coef_index + 2] * 2; + dest_ptr [coef_index + 6] = src_ptr [coef_index + 6] * 2; + + dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + src_ptr [coef_index + 3]; + dest_ptr [coef_index + 3] = src_ptr [coef_index + 5] - src_ptr [coef_index + 7]; + + const DataType vr = src_ptr [coef_index + 1] - src_ptr [coef_index + 3]; + const DataType vi = src_ptr [coef_index + 5] + src_ptr [coef_index + 7]; + + dest_ptr [coef_index + 5] = (vr + vi) * sqrt2_2; + dest_ptr [coef_index + 7] = (vi - vr) * sqrt2_2; + + coef_index += 8; + } + while (coef_index < len); +} + +template <> +void FFTRealPassInverse <1>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Penultimate and last pass at once + const long qlen = len >> 2; + + long coef_index = 0; + do + { + const long ri_0 = br_ptr [coef_index >> 2]; + + const DataType b_0 = src_ptr [coef_index ] + src_ptr [coef_index + 2]; + const DataType b_2 = src_ptr [coef_index ] - src_ptr [coef_index + 2]; + const DataType b_1 = src_ptr [coef_index + 1] * 2; + const DataType b_3 = src_ptr [coef_index + 3] * 2; + + dest_ptr [ri_0 ] = b_0 + b_1; + dest_ptr [ri_0 + 2 * qlen] = b_0 - b_1; + dest_ptr [ri_0 + 1 * qlen] = b_2 + b_3; + dest_ptr [ri_0 + 3 * qlen] = b_2 - b_3; + + coef_index += 4; + } + while (coef_index < len); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // FFTRealPassInverse_CODEHEADER_INCLUDED + +#undef FFTRealPassInverse_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealSelect.h b/demos/spectrum/fftreal/FFTRealSelect.h new file mode 100644 index 0000000..bd722d4 --- /dev/null +++ b/demos/spectrum/fftreal/FFTRealSelect.h @@ -0,0 +1,77 @@ +/***************************************************************************** + + FFTRealSelect.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealSelect_HEADER_INCLUDED) +#define FFTRealSelect_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" + + + +template +class FFTRealSelect +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + FORCEINLINE static float * + sel_bin (float *e_ptr, float *o_ptr); + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealSelect (); + ~FFTRealSelect (); + FFTRealSelect (const FFTRealSelect &other); + FFTRealSelect& operator = (const FFTRealSelect &other); + bool operator == (const FFTRealSelect &other); + bool operator != (const FFTRealSelect &other); + +}; // class FFTRealSelect + + + +#include "FFTRealSelect.hpp" + + + +#endif // FFTRealSelect_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealSelect.hpp b/demos/spectrum/fftreal/FFTRealSelect.hpp new file mode 100644 index 0000000..9ddf586 --- /dev/null +++ b/demos/spectrum/fftreal/FFTRealSelect.hpp @@ -0,0 +1,62 @@ +/***************************************************************************** + + FFTRealSelect.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealSelect_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealSelect code header. +#endif +#define FFTRealSelect_CURRENT_CODEHEADER + +#if ! defined (FFTRealSelect_CODEHEADER_INCLUDED) +#define FFTRealSelect_CODEHEADER_INCLUDED + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +float * FFTRealSelect

    ::sel_bin (float *e_ptr, float *o_ptr) +{ + return (o_ptr); +} + + + +template <> +float * FFTRealSelect <0>::sel_bin (float *e_ptr, float *o_ptr) +{ + return (e_ptr); +} + + + +#endif // FFTRealSelect_CODEHEADER_INCLUDED + +#undef FFTRealSelect_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealUseTrigo.h b/demos/spectrum/fftreal/FFTRealUseTrigo.h new file mode 100644 index 0000000..c4368ee --- /dev/null +++ b/demos/spectrum/fftreal/FFTRealUseTrigo.h @@ -0,0 +1,101 @@ +/***************************************************************************** + + FFTRealUseTrigo.h + Copyright (c) 2005 Laurent de Soras + +Template parameters: + - ALGO: algorithm choice. 0 = table, other = oscillator + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealUseTrigo_HEADER_INCLUDED) +#define FFTRealUseTrigo_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + +template +class FFTRealUseTrigo +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; + + FORCEINLINE static void + prepare (OscType &osc); + FORCEINLINE static void + iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealUseTrigo (); + ~FFTRealUseTrigo (); + FFTRealUseTrigo (const FFTRealUseTrigo &other); + FFTRealUseTrigo & + operator = (const FFTRealUseTrigo &other); + bool operator == (const FFTRealUseTrigo &other); + bool operator != (const FFTRealUseTrigo &other); + +}; // class FFTRealUseTrigo + + + +#include "FFTRealUseTrigo.hpp" + + + +#endif // FFTRealUseTrigo_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealUseTrigo.hpp b/demos/spectrum/fftreal/FFTRealUseTrigo.hpp new file mode 100644 index 0000000..aa968b8 --- /dev/null +++ b/demos/spectrum/fftreal/FFTRealUseTrigo.hpp @@ -0,0 +1,91 @@ +/***************************************************************************** + + FFTRealUseTrigo.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealUseTrigo_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealUseTrigo code header. +#endif +#define FFTRealUseTrigo_CURRENT_CODEHEADER + +#if ! defined (FFTRealUseTrigo_CODEHEADER_INCLUDED) +#define FFTRealUseTrigo_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "OscSinCos.h" + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void FFTRealUseTrigo ::prepare (OscType &osc) +{ + osc.clear_buffers (); +} + +template <> +void FFTRealUseTrigo <0>::prepare (OscType &osc) +{ + // Nothing +} + + + +template +void FFTRealUseTrigo ::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) +{ + osc.step (); + c = osc.get_cos (); + s = osc.get_sin (); +} + +template <> +void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) +{ + c = cos_ptr [index_c]; + s = cos_ptr [index_s]; +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // FFTRealUseTrigo_CODEHEADER_INCLUDED + +#undef FFTRealUseTrigo_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/OscSinCos.h b/demos/spectrum/fftreal/OscSinCos.h new file mode 100644 index 0000000..775fc14 --- /dev/null +++ b/demos/spectrum/fftreal/OscSinCos.h @@ -0,0 +1,106 @@ +/***************************************************************************** + + OscSinCos.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (OscSinCos_HEADER_INCLUDED) +#define OscSinCos_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" + + + +template +class OscSinCos +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef T DataType; + + OscSinCos (); + + FORCEINLINE void + set_step (double angle_rad); + + FORCEINLINE DataType + get_cos () const; + FORCEINLINE DataType + get_sin () const; + FORCEINLINE void + step (); + FORCEINLINE void + clear_buffers (); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1] + DataType _pos_sin; // - + DataType _step_cos; // Phase increment per step, [-1 ; 1] + DataType _step_sin; // - + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + OscSinCos (const OscSinCos &other); + OscSinCos & operator = (const OscSinCos &other); + bool operator == (const OscSinCos &other); + bool operator != (const OscSinCos &other); + +}; // class OscSinCos + + + +#include "OscSinCos.hpp" + + + +#endif // OscSinCos_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/OscSinCos.hpp b/demos/spectrum/fftreal/OscSinCos.hpp new file mode 100644 index 0000000..749aef0 --- /dev/null +++ b/demos/spectrum/fftreal/OscSinCos.hpp @@ -0,0 +1,122 @@ +/***************************************************************************** + + OscSinCos.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (OscSinCos_CURRENT_CODEHEADER) + #error Recursive inclusion of OscSinCos code header. +#endif +#define OscSinCos_CURRENT_CODEHEADER + +#if ! defined (OscSinCos_CODEHEADER_INCLUDED) +#define OscSinCos_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include + +namespace std { } + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +OscSinCos ::OscSinCos () +: _pos_cos (1) +, _pos_sin (0) +, _step_cos (1) +, _step_sin (0) +{ + // Nothing +} + + + +template +void OscSinCos ::set_step (double angle_rad) +{ + using namespace std; + + _step_cos = static_cast (cos (angle_rad)); + _step_sin = static_cast (sin (angle_rad)); +} + + + +template +typename OscSinCos ::DataType OscSinCos ::get_cos () const +{ + return (_pos_cos); +} + + + +template +typename OscSinCos ::DataType OscSinCos ::get_sin () const +{ + return (_pos_sin); +} + + + +template +void OscSinCos ::step () +{ + const DataType old_cos = _pos_cos; + const DataType old_sin = _pos_sin; + + _pos_cos = old_cos * _step_cos - old_sin * _step_sin; + _pos_sin = old_cos * _step_sin + old_sin * _step_cos; +} + + + +template +void OscSinCos ::clear_buffers () +{ + _pos_cos = static_cast (1); + _pos_sin = static_cast (0); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // OscSinCos_CODEHEADER_INCLUDED + +#undef OscSinCos_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestAccuracy.h b/demos/spectrum/fftreal/TestAccuracy.h new file mode 100644 index 0000000..4b07a6b --- /dev/null +++ b/demos/spectrum/fftreal/TestAccuracy.h @@ -0,0 +1,105 @@ +/***************************************************************************** + + TestAccuracy.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestAccuracy_HEADER_INCLUDED) +#define TestAccuracy_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +class TestAccuracy +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef typename FO::DataType DataType; + typedef long double BigFloat; // To get maximum accuracy during intermediate calculations + + static int perform_test_single_object (FO &fft); + static int perform_test_d (FO &fft, const char *class_name_0); + static int perform_test_i (FO &fft, const char *class_name_0); + static int perform_test_di (FO &fft, const char *class_name_0); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + enum { NBR_ACC_TESTS = 10 * 1000 * 1000 }; + enum { MAX_NBR_TESTS = 10000 }; + + static void compute_tf (DataType s [], const DataType x [], long length); + static void compute_itf (DataType x [], const DataType s [], long length); + static int compare_vect_display (const DataType x_ptr [], const DataType y_ptr [], long len, BigFloat &max_err_rel); + static BigFloat + compute_power (const DataType x_ptr [], long len); + static BigFloat + compute_power (const DataType x_ptr [], const DataType y_ptr [], long len); + static void compare_vect (const DataType x_ptr [], const DataType y_ptr [], BigFloat &power, long &max_err_pos, long len); + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestAccuracy (); + ~TestAccuracy (); + TestAccuracy (const TestAccuracy &other); + TestAccuracy & operator = (const TestAccuracy &other); + bool operator == (const TestAccuracy &other); + bool operator != (const TestAccuracy &other); + +}; // class TestAccuracy + + + +#include "TestAccuracy.hpp" + + + +#endif // TestAccuracy_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestAccuracy.hpp b/demos/spectrum/fftreal/TestAccuracy.hpp new file mode 100644 index 0000000..5c794f7 --- /dev/null +++ b/demos/spectrum/fftreal/TestAccuracy.hpp @@ -0,0 +1,472 @@ +/***************************************************************************** + + TestAccuracy.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestAccuracy_CURRENT_CODEHEADER) + #error Recursive inclusion of TestAccuracy code header. +#endif +#define TestAccuracy_CURRENT_CODEHEADER + +#if ! defined (TestAccuracy_CODEHEADER_INCLUDED) +#define TestAccuracy_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "test_fnc.h" +#include "TestWhiteNoiseGen.h" + +#include +#include + +#include +#include + + + +static const double TestAccuracy_LN10 = 2.3025850929940456840179914546844; + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +int TestAccuracy ::perform_test_single_object (FO &fft) +{ + assert (&fft != 0); + + using namespace std; + + int ret_val = 0; + + const std::type_info & ti = typeid (fft); + const char * class_name_0 = ti.name (); + + if (ret_val == 0) + { + ret_val = perform_test_d (fft, class_name_0); + } + if (ret_val == 0) + { + ret_val = perform_test_i (fft, class_name_0); + } + if (ret_val == 0) + { + ret_val = perform_test_di (fft, class_name_0); + } + + if (ret_val == 0) + { + printf ("\n"); + } + + return (ret_val); +} + + + +template +int TestAccuracy ::perform_test_d (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + using namespace std; + + int ret_val = 0; + const long len = fft.get_length (); + const long nbr_tests = limit ( + NBR_ACC_TESTS / len / len, + 1L, + static_cast (MAX_NBR_TESTS) + ); + + printf ("Testing %s::do_fft () [%ld samples]... ", class_name_0, len); + fflush (stdout); + TestWhiteNoiseGen noise; + std::vector x (len); + std::vector s1 (len); + std::vector s2 (len); + BigFloat err_avg = 0; + + for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) + { + noise.generate (&x [0], len); + fft.do_fft (&s1 [0], &x [0]); + compute_tf (&s2 [0], &x [0], len); + + BigFloat max_err; + compare_vect_display (&s1 [0], &s2 [0], len, max_err); + err_avg += max_err; + } + err_avg /= NBR_ACC_TESTS; + + printf ("done.\n"); + printf ( + "Average maximum error: %.6f %% (%f dB)\n", + static_cast (err_avg * 100), + static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) + ); + + return (ret_val); +} + + + +template +int TestAccuracy ::perform_test_i (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + using namespace std; + + int ret_val = 0; + const long len = fft.get_length (); + const long nbr_tests = limit ( + NBR_ACC_TESTS / len / len, + 10L, + static_cast (MAX_NBR_TESTS) + ); + + printf ("Testing %s::do_ifft () [%ld samples]... ", class_name_0, len); + fflush (stdout); + TestWhiteNoiseGen noise; + std::vector s (len); + std::vector x1 (len); + std::vector x2 (len); + BigFloat err_avg = 0; + + for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) + { + noise.generate (&s [0], len); + fft.do_ifft (&s [0], &x1 [0]); + compute_itf (&x2 [0], &s [0], len); + + BigFloat max_err; + compare_vect_display (&x1 [0], &x2 [0], len, max_err); + err_avg += max_err; + } + err_avg /= NBR_ACC_TESTS; + + printf ("done.\n"); + printf ( + "Average maximum error: %.6f %% (%f dB)\n", + static_cast (err_avg * 100), + static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) + ); + + return (ret_val); +} + + + +template +int TestAccuracy ::perform_test_di (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + using namespace std; + + int ret_val = 0; + const long len = fft.get_length (); + const long nbr_tests = limit ( + NBR_ACC_TESTS / len / len, + 1L, + static_cast (MAX_NBR_TESTS) + ); + + printf ( + "Testing %s::do_fft () / do_ifft () / rescale () [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + TestWhiteNoiseGen noise; + std::vector x (len); + std::vector s (len); + std::vector y (len); + BigFloat err_avg = 0; + + for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) + { + noise.generate (&x [0], len); + fft.do_fft (&s [0], &x [0]); + fft.do_ifft (&s [0], &y [0]); + fft.rescale (&y [0]); + + BigFloat max_err; + compare_vect_display (&x [0], &y [0], len, max_err); + err_avg += max_err; + } + err_avg /= NBR_ACC_TESTS; + + printf ("done.\n"); + printf ( + "Average maximum error: %.6f %% (%f dB)\n", + static_cast (err_avg * 100), + static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) + ); + + return (ret_val); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +// Positive transform +template +void TestAccuracy ::compute_tf (DataType s [], const DataType x [], long length) +{ + assert (s != 0); + assert (x != 0); + assert (length >= 2); + assert ((length & 1) == 0); + + const long nbr_bins = length >> 1; + + // DC and Nyquist + BigFloat dc = 0; + BigFloat ny = 0; + for (long pos = 0; pos < length; pos += 2) + { + const BigFloat even = x [pos ]; + const BigFloat odd = x [pos + 1]; + dc += even + odd; + ny += even - odd; + } + s [0 ] = static_cast (dc); + s [nbr_bins] = static_cast (ny); + + // Regular bins + for (long bin = 1; bin < nbr_bins; ++ bin) + { + BigFloat sum_r = 0; + BigFloat sum_i = 0; + + const BigFloat m = bin * static_cast (2 * PI) / length; + + for (long pos = 0; pos < length; ++pos) + { + using namespace std; + + const BigFloat phase = pos * m; + const BigFloat e_r = cos (phase); + const BigFloat e_i = sin (phase); + + sum_r += x [pos] * e_r; + sum_i += x [pos] * e_i; + } + + s [ bin] = static_cast (sum_r); + s [nbr_bins + bin] = static_cast (sum_i); + } +} + + + +// Negative transform +template +void TestAccuracy ::compute_itf (DataType x [], const DataType s [], long length) +{ + assert (s != 0); + assert (x != 0); + assert (length >= 2); + assert ((length & 1) == 0); + + const long nbr_bins = length >> 1; + + // DC and Nyquist + BigFloat dc = s [0 ]; + BigFloat ny = s [nbr_bins]; + + // Regular bins + for (long pos = 0; pos < length; ++pos) + { + BigFloat sum = dc + ny * (1 - 2 * (pos & 1)); + + const BigFloat m = pos * static_cast (-2 * PI) / length; + + for (long bin = 1; bin < nbr_bins; ++ bin) + { + using namespace std; + + const BigFloat phase = bin * m; + const BigFloat e_r = cos (phase); + const BigFloat e_i = sin (phase); + + sum += 2 * ( e_r * s [bin ] + - e_i * s [bin + nbr_bins]); + } + + x [pos] = static_cast (sum); + } +} + + + +template +int TestAccuracy ::compare_vect_display (const DataType x_ptr [], const DataType y_ptr [], long len, BigFloat &max_err_rel) +{ + assert (x_ptr != 0); + assert (y_ptr != 0); + assert (len > 0); + assert (&max_err_rel != 0); + + using namespace std; + + int ret_val = 0; + + BigFloat power = compute_power (&x_ptr [0], &y_ptr [0], len); + BigFloat power_dif; + long max_err_pos; + compare_vect (&x_ptr [0], &y_ptr [0], power_dif, max_err_pos, len); + + if (power == 0) + { + power = power_dif; + } + const BigFloat power_err_rel = power_dif / power; + + BigFloat max_err = 0; + max_err_rel = 0; + if (max_err_pos >= 0) + { + max_err = y_ptr [max_err_pos] - x_ptr [max_err_pos]; + max_err_rel = 2 * fabs (max_err) / ( fabs (y_ptr [max_err_pos]) + + fabs (x_ptr [max_err_pos])); + } + + if (power_err_rel > 0.001) + { + printf ("Power error : %f (%.6f %%)\n", + static_cast (power_err_rel), + static_cast (power_err_rel * 100) + ); + if (max_err_pos >= 0) + { + printf ( + "Maximum error: %f - %f = %f (%f)\n", + static_cast (y_ptr [max_err_pos]), + static_cast (x_ptr [max_err_pos]), + static_cast (max_err), + static_cast (max_err_pos) + ); + } + } + + return (ret_val); +} + + + +template +typename TestAccuracy ::BigFloat TestAccuracy ::compute_power (const DataType x_ptr [], long len) +{ + assert (x_ptr != 0); + assert (len > 0); + + BigFloat power = 0; + for (long pos = 0; pos < len; ++pos) + { + const BigFloat val = x_ptr [pos]; + + power += val * val; + } + + using namespace std; + + power = sqrt (power) / len; + + return (power); +} + + + +template +typename TestAccuracy ::BigFloat TestAccuracy ::compute_power (const DataType x_ptr [], const DataType y_ptr [], long len) +{ + assert (x_ptr != 0); + assert (y_ptr != 0); + assert (len > 0); + + return ((compute_power (x_ptr, len) + compute_power (y_ptr, len)) * 0.5); +} + + + +template +void TestAccuracy ::compare_vect (const DataType x_ptr [], const DataType y_ptr [], BigFloat &power, long &max_err_pos, long len) +{ + assert (x_ptr != 0); + assert (y_ptr != 0); + assert (len > 0); + assert (&power != 0); + assert (&max_err_pos != 0); + + power = 0; + BigFloat max_dif2 = 0; + max_err_pos = -1; + + for (long pos = 0; pos < len; ++pos) + { + const BigFloat x = x_ptr [pos]; + const BigFloat y = y_ptr [pos]; + const BigFloat dif = y - x; + const BigFloat dif2 = dif * dif; + + power += dif2; + if (dif2 > max_dif2) + { + max_err_pos = pos; + max_dif2 = dif2; + } + } + + using namespace std; + + power = sqrt (power) / len; +} + + + +#endif // TestAccuracy_CODEHEADER_INCLUDED + +#undef TestAccuracy_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestHelperFixLen.h b/demos/spectrum/fftreal/TestHelperFixLen.h new file mode 100644 index 0000000..ecff96d --- /dev/null +++ b/demos/spectrum/fftreal/TestHelperFixLen.h @@ -0,0 +1,93 @@ +/***************************************************************************** + + TestHelperFixLen.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestHelperFixLen_HEADER_INCLUDED) +#define TestHelperFixLen_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTRealFixLen.h" + + + +template +class TestHelperFixLen +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLen FftType; + + static void perform_test_accuracy (int &ret_val); + static void perform_test_speed (int &ret_val); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestHelperFixLen (); + ~TestHelperFixLen (); + TestHelperFixLen (const TestHelperFixLen &other); + TestHelperFixLen & + operator = (const TestHelperFixLen &other); + bool operator == (const TestHelperFixLen &other); + bool operator != (const TestHelperFixLen &other); + +}; // class TestHelperFixLen + + + +#include "TestHelperFixLen.hpp" + + + +#endif // TestHelperFixLen_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestHelperFixLen.hpp b/demos/spectrum/fftreal/TestHelperFixLen.hpp new file mode 100644 index 0000000..25048b9 --- /dev/null +++ b/demos/spectrum/fftreal/TestHelperFixLen.hpp @@ -0,0 +1,93 @@ +/***************************************************************************** + + TestHelperFixLen.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestHelperFixLen_CURRENT_CODEHEADER) + #error Recursive inclusion of TestHelperFixLen code header. +#endif +#define TestHelperFixLen_CURRENT_CODEHEADER + +#if ! defined (TestHelperFixLen_CODEHEADER_INCLUDED) +#define TestHelperFixLen_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_settings.h" + +#include "TestAccuracy.h" +#if defined (test_settings_SPEED_TEST_ENABLED) + #include "TestSpeed.h" +#endif + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void TestHelperFixLen ::perform_test_accuracy (int &ret_val) +{ + if (ret_val == 0) + { + FftType fft; + ret_val = TestAccuracy ::perform_test_single_object (fft); + } +} + + + +template +void TestHelperFixLen ::perform_test_speed (int &ret_val) +{ +#if defined (test_settings_SPEED_TEST_ENABLED) + + if (ret_val == 0) + { + FftType fft; + ret_val = TestSpeed ::perform_test_single_object (fft); + } + +#endif +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestHelperFixLen_CODEHEADER_INCLUDED + +#undef TestHelperFixLen_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestHelperNormal.h b/demos/spectrum/fftreal/TestHelperNormal.h new file mode 100644 index 0000000..a7bff5c --- /dev/null +++ b/demos/spectrum/fftreal/TestHelperNormal.h @@ -0,0 +1,94 @@ +/***************************************************************************** + + TestHelperNormal.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestHelperNormal_HEADER_INCLUDED) +#define TestHelperNormal_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTReal.h" + + + +template +class TestHelperNormal +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef DT DataType; + typedef FFTReal FftType; + + static void perform_test_accuracy (int &ret_val); + static void perform_test_speed (int &ret_val); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestHelperNormal (); + ~TestHelperNormal (); + TestHelperNormal (const TestHelperNormal &other); + TestHelperNormal & + operator = (const TestHelperNormal &other); + bool operator == (const TestHelperNormal &other); + bool operator != (const TestHelperNormal &other); + +}; // class TestHelperNormal + + + +#include "TestHelperNormal.hpp" + + + +#endif // TestHelperNormal_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestHelperNormal.hpp b/demos/spectrum/fftreal/TestHelperNormal.hpp new file mode 100644 index 0000000..e037696 --- /dev/null +++ b/demos/spectrum/fftreal/TestHelperNormal.hpp @@ -0,0 +1,99 @@ +/***************************************************************************** + + TestHelperNormal.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestHelperNormal_CURRENT_CODEHEADER) + #error Recursive inclusion of TestHelperNormal code header. +#endif +#define TestHelperNormal_CURRENT_CODEHEADER + +#if ! defined (TestHelperNormal_CODEHEADER_INCLUDED) +#define TestHelperNormal_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_settings.h" + +#include "TestAccuracy.h" +#if defined (test_settings_SPEED_TEST_ENABLED) + #include "TestSpeed.h" +#endif + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void TestHelperNormal

    ::perform_test_accuracy (int &ret_val) +{ + const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12 }; + const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); + for (int k = 0; k < nbr_len && ret_val == 0; ++k) + { + const long len = 1L << (len_arr [k]); + FftType fft (len); + ret_val = TestAccuracy ::perform_test_single_object (fft); + } +} + + + +template +void TestHelperNormal
    ::perform_test_speed (int &ret_val) +{ +#if defined (test_settings_SPEED_TEST_ENABLED) + + const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12, 14, 16, 18, 20, 22 }; + const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); + for (int k = 0; k < nbr_len && ret_val == 0; ++k) + { + const long len = 1L << (len_arr [k]); + FftType fft (len); + ret_val = TestSpeed ::perform_test_single_object (fft); + } + +#endif +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestHelperNormal_CODEHEADER_INCLUDED + +#undef TestHelperNormal_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestSpeed.h b/demos/spectrum/fftreal/TestSpeed.h new file mode 100644 index 0000000..2295781 --- /dev/null +++ b/demos/spectrum/fftreal/TestSpeed.h @@ -0,0 +1,95 @@ +/***************************************************************************** + + TestSpeed.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestSpeed_HEADER_INCLUDED) +#define TestSpeed_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +class TestSpeed +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef typename FO::DataType DataType; + + static int perform_test_single_object (FO &fft); + static int perform_test_d (FO &fft, const char *class_name_0); + static int perform_test_i (FO &fft, const char *class_name_0); + static int perform_test_di (FO &fft, const char *class_name_0); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + enum { NBR_SPD_TESTS = 10 * 1000 * 1000 }; + enum { MAX_NBR_TESTS = 10000 }; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestSpeed (); + ~TestSpeed (); + TestSpeed (const TestSpeed &other); + TestSpeed & operator = (const TestSpeed &other); + bool operator == (const TestSpeed &other); + bool operator != (const TestSpeed &other); + +}; // class TestSpeed + + + +#include "TestSpeed.hpp" + + + +#endif // TestSpeed_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestSpeed.hpp b/demos/spectrum/fftreal/TestSpeed.hpp new file mode 100644 index 0000000..e716b2a --- /dev/null +++ b/demos/spectrum/fftreal/TestSpeed.hpp @@ -0,0 +1,223 @@ +/***************************************************************************** + + TestSpeed.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestSpeed_CURRENT_CODEHEADER) + #error Recursive inclusion of TestSpeed code header. +#endif +#define TestSpeed_CURRENT_CODEHEADER + +#if ! defined (TestSpeed_CODEHEADER_INCLUDED) +#define TestSpeed_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_fnc.h" +#include "stopwatch/StopWatch.h" +#include "TestWhiteNoiseGen.h" + +#include + +#include + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +int TestSpeed ::perform_test_single_object (FO &fft) +{ + assert (&fft != 0); + + int ret_val = 0; + + const std::type_info & ti = typeid (fft); + const char * class_name_0 = ti.name (); + + if (ret_val == 0) + { + perform_test_d (fft, class_name_0); + } + if (ret_val == 0) + { + perform_test_i (fft, class_name_0); + } + if (ret_val == 0) + { + perform_test_di (fft, class_name_0); + } + + if (ret_val == 0) + { + printf ("\n"); + } + + return (ret_val); +} + + + +template +int TestSpeed ::perform_test_d (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + const long len = fft.get_length (); + const long nbr_tests = limit ( + static_cast (NBR_SPD_TESTS / len / len), + 1L, + static_cast (MAX_NBR_TESTS) + ); + + TestWhiteNoiseGen noise; + std::vector x (len, 0); + std::vector s (len); + noise.generate (&x [0], len); + + printf ( + "%s::do_fft () speed test [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + + stopwatch::StopWatch chrono; + chrono.start (); + for (long test = 0; test < nbr_tests; ++ test) + { + fft.do_fft (&s [0], &x [0]); + chrono.stop_lap (); + } + + printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); + + return (0); +} + + + +template +int TestSpeed ::perform_test_i (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + const long len = fft.get_length (); + const long nbr_tests = limit ( + static_cast (NBR_SPD_TESTS / len / len), + 1L, + static_cast (MAX_NBR_TESTS) + ); + + TestWhiteNoiseGen noise; + std::vector x (len); + std::vector s (len, 0); + noise.generate (&s [0], len); + + printf ( + "%s::do_ifft () speed test [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + + stopwatch::StopWatch chrono; + chrono.start (); + for (long test = 0; test < nbr_tests; ++ test) + { + fft.do_ifft (&s [0], &x [0]); + chrono.stop_lap (); + } + + printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); + + return (0); +} + + + +template +int TestSpeed ::perform_test_di (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + const long len = fft.get_length (); + const long nbr_tests = limit ( + static_cast (NBR_SPD_TESTS / len / len), + 1L, + static_cast (MAX_NBR_TESTS) + ); + + TestWhiteNoiseGen noise; + std::vector x (len, 0); + std::vector s (len); + std::vector y (len); + noise.generate (&x [0], len); + + printf ( + "%s::do_fft () / do_ifft () / rescale () speed test [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + + stopwatch::StopWatch chrono; + + chrono.start (); + for (long test = 0; test < nbr_tests; ++ test) + { + fft.do_fft (&s [0], &x [0]); + fft.do_ifft (&s [0], &y [0]); + fft.rescale (&y [0]); + chrono.stop_lap (); + } + + printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); + + return (0); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestSpeed_CODEHEADER_INCLUDED + +#undef TestSpeed_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestWhiteNoiseGen.h b/demos/spectrum/fftreal/TestWhiteNoiseGen.h new file mode 100644 index 0000000..d815f8e --- /dev/null +++ b/demos/spectrum/fftreal/TestWhiteNoiseGen.h @@ -0,0 +1,95 @@ +/***************************************************************************** + + TestWhiteNoiseGen.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestWhiteNoiseGen_HEADER_INCLUDED) +#define TestWhiteNoiseGen_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +class TestWhiteNoiseGen +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef DT DataType; + + TestWhiteNoiseGen (); + virtual ~TestWhiteNoiseGen () {} + + void generate (DataType data_ptr [], long len); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + typedef unsigned long StateType; + + StateType _rand_state; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestWhiteNoiseGen (const TestWhiteNoiseGen &other); + TestWhiteNoiseGen & + operator = (const TestWhiteNoiseGen &other); + bool operator == (const TestWhiteNoiseGen &other); + bool operator != (const TestWhiteNoiseGen &other); + +}; // class TestWhiteNoiseGen + + + +#include "TestWhiteNoiseGen.hpp" + + + +#endif // TestWhiteNoiseGen_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestWhiteNoiseGen.hpp b/demos/spectrum/fftreal/TestWhiteNoiseGen.hpp new file mode 100644 index 0000000..13b7eb3 --- /dev/null +++ b/demos/spectrum/fftreal/TestWhiteNoiseGen.hpp @@ -0,0 +1,91 @@ +/***************************************************************************** + + TestWhiteNoiseGen.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestWhiteNoiseGen_CURRENT_CODEHEADER) + #error Recursive inclusion of TestWhiteNoiseGen code header. +#endif +#define TestWhiteNoiseGen_CURRENT_CODEHEADER + +#if ! defined (TestWhiteNoiseGen_CODEHEADER_INCLUDED) +#define TestWhiteNoiseGen_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +TestWhiteNoiseGen
    ::TestWhiteNoiseGen () +: _rand_state (0) +{ + _rand_state = reinterpret_cast (this); +} + + + +template +void TestWhiteNoiseGen
    ::generate (DataType data_ptr [], long len) +{ + assert (data_ptr != 0); + assert (len > 0); + + const DataType one = static_cast (1); + const DataType mul = one / static_cast (0x80000000UL); + + long pos = 0; + do + { + const DataType x = static_cast (_rand_state & 0xFFFFFFFFUL); + data_ptr [pos] = x * mul - one; + + _rand_state = _rand_state * 1234567UL + 890123UL; + + ++ pos; + } + while (pos < len); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestWhiteNoiseGen_CODEHEADER_INCLUDED + +#undef TestWhiteNoiseGen_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/bwins/fftrealu.def b/demos/spectrum/fftreal/bwins/fftrealu.def new file mode 100644 index 0000000..7a79397 --- /dev/null +++ b/demos/spectrum/fftreal/bwins/fftrealu.def @@ -0,0 +1,5 @@ +EXPORTS + ??0FFTRealWrapper@@QAE@XZ @ 1 NONAME ; FFTRealWrapper::FFTRealWrapper(void) + ??1FFTRealWrapper@@QAE@XZ @ 2 NONAME ; FFTRealWrapper::~FFTRealWrapper(void) + ?calculateFFT@FFTRealWrapper@@QAEXQAMQBM@Z @ 3 NONAME ; void FFTRealWrapper::calculateFFT(float * const, float const * const) + diff --git a/demos/spectrum/fftreal/def.h b/demos/spectrum/fftreal/def.h new file mode 100644 index 0000000..99c545f --- /dev/null +++ b/demos/spectrum/fftreal/def.h @@ -0,0 +1,60 @@ +/***************************************************************************** + + def.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (def_HEADER_INCLUDED) +#define def_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + + +const double PI = 3.1415926535897932384626433832795; +const double SQRT2 = 1.41421356237309514547462185873883; + +#if defined (_MSC_VER) + + #define FORCEINLINE __forceinline + +#else + + #define FORCEINLINE inline + +#endif + + + +#endif // def_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/eabi/fftrealu.def b/demos/spectrum/fftreal/eabi/fftrealu.def new file mode 100644 index 0000000..f95a441 --- /dev/null +++ b/demos/spectrum/fftreal/eabi/fftrealu.def @@ -0,0 +1,7 @@ +EXPORTS + _ZN14FFTRealWrapper12calculateFFTEPfPKf @ 1 NONAME + _ZN14FFTRealWrapperC1Ev @ 2 NONAME + _ZN14FFTRealWrapperC2Ev @ 3 NONAME + _ZN14FFTRealWrapperD1Ev @ 4 NONAME + _ZN14FFTRealWrapperD2Ev @ 5 NONAME + diff --git a/demos/spectrum/fftreal/fftreal.pas b/demos/spectrum/fftreal/fftreal.pas new file mode 100644 index 0000000..ea63754 --- /dev/null +++ b/demos/spectrum/fftreal/fftreal.pas @@ -0,0 +1,661 @@ +(***************************************************************************** + + DIGITAL SIGNAL PROCESSING TOOLS + Version 1.03, 2001/06/15 + (c) 1999 - Laurent de Soras + + FFTReal.h + Fourier transformation of real number arrays. + Portable ISO C++ + +------------------------------------------------------------------------------ + + LEGAL + + Source code may be freely used for any purpose, including commercial + applications. Programs must display in their "About" dialog-box (or + documentation) a text telling they use these routines by Laurent de Soras. + Modified source code can be distributed, but modifications must be clearly + indicated. + + CONTACT + + Laurent de Soras + 92 avenue Albert 1er + 92500 Rueil-Malmaison + France + + ldesoras@club-internet.fr + +------------------------------------------------------------------------------ + + Translation to ObjectPascal by : + Frederic Vanmol + frederic@axiworld.be + +*****************************************************************************) + + +unit + FFTReal; + +interface + +uses + Windows; + +(* Change this typedef to use a different floating point type in your FFTs + (i.e. float, double or long double). *) +type + pflt_t = ^flt_t; + flt_t = single; + + pflt_array = ^flt_array; + flt_array = array[0..0] of flt_t; + + plongarray = ^longarray; + longarray = array[0..0] of longint; + +const + sizeof_flt : longint = SizeOf(flt_t); + + + +type + // Bit reversed look-up table nested class + TBitReversedLUT = class + private + _ptr : plongint; + public + constructor Create(const nbr_bits: integer); + destructor Destroy; override; + function get_ptr: plongint; + end; + + // Trigonometric look-up table nested class + TTrigoLUT = class + private + _ptr : pflt_t; + public + constructor Create(const nbr_bits: integer); + destructor Destroy; override; + function get_ptr(const level: integer): pflt_t; + end; + + TFFTReal = class + private + _bit_rev_lut : TBitReversedLUT; + _trigo_lut : TTrigoLUT; + _sqrt2_2 : flt_t; + _length : longint; + _nbr_bits : integer; + _buffer_ptr : pflt_t; + public + constructor Create(const length: longint); + destructor Destroy; override; + + procedure do_fft(f: pflt_array; const x: pflt_array); + procedure do_ifft(const f: pflt_array; x: pflt_array); + procedure rescale(x: pflt_array); + end; + + + + + + + +implementation + +uses + Math; + +{ TBitReversedLUT } + +constructor TBitReversedLUT.Create(const nbr_bits: integer); +var + length : longint; + cnt : longint; + br_index : longint; + bit : longint; +begin + inherited Create; + + length := 1 shl nbr_bits; + GetMem(_ptr, length*SizeOf(longint)); + + br_index := 0; + plongarray(_ptr)^[0] := 0; + for cnt := 1 to length-1 do + begin + // ++br_index (bit reversed) + bit := length shr 1; + br_index := br_index xor bit; + while br_index and bit = 0 do + begin + bit := bit shr 1; + br_index := br_index xor bit; + end; + + plongarray(_ptr)^[cnt] := br_index; + end; +end; + +destructor TBitReversedLUT.Destroy; +begin + FreeMem(_ptr); + _ptr := nil; + inherited; +end; + +function TBitReversedLUT.get_ptr: plongint; +begin + Result := _ptr; +end; + +{ TTrigLUT } + +constructor TTrigoLUT.Create(const nbr_bits: integer); +var + total_len : longint; + PI : double; + level : integer; + level_len : longint; + level_ptr : pflt_array; + mul : double; + i : longint; +begin + inherited Create; + + _ptr := nil; + + if (nbr_bits > 3) then + begin + total_len := (1 shl (nbr_bits - 1)) - 4; + GetMem(_ptr, total_len * sizeof_flt); + + PI := ArcTan(1) * 4; + for level := 3 to nbr_bits-1 do + begin + level_len := 1 shl (level - 1); + level_ptr := pointer(get_ptr(level)); + mul := PI / (level_len shl 1); + + for i := 0 to level_len-1 do + level_ptr^[i] := cos(i * mul); + end; + end; +end; + +destructor TTrigoLUT.Destroy; +begin + FreeMem(_ptr); + _ptr := nil; + inherited; +end; + +function TTrigoLUT.get_ptr(const level: integer): pflt_t; +var + tempp : pflt_t; +begin + tempp := _ptr; + inc(tempp, (1 shl (level-1)) - 4); + Result := tempp; +end; + +{ TFFTReal } + +constructor TFFTReal.Create(const length: longint); +begin + inherited Create; + + _length := length; + _nbr_bits := Floor(Ln(length) / Ln(2) + 0.5); + _bit_rev_lut := TBitReversedLUT.Create(Floor(Ln(length) / Ln(2) + 0.5)); + _trigo_lut := TTrigoLUT.Create(Floor(Ln(length) / Ln(2) + 0.05)); + _sqrt2_2 := Sqrt(2) * 0.5; + + _buffer_ptr := nil; + if _nbr_bits > 2 then + GetMem(_buffer_ptr, _length * sizeof_flt); +end; + +destructor TFFTReal.Destroy; +begin + if _buffer_ptr <> nil then + begin + FreeMem(_buffer_ptr); + _buffer_ptr := nil; + end; + + _bit_rev_lut.Free; + _bit_rev_lut := nil; + _trigo_lut.Free; + _trigo_lut := nil; + + inherited; +end; + +(*==========================================================================*/ +/* Name: do_fft */ +/* Description: Compute the FFT of the array. */ +/* Input parameters: */ +/* - x: pointer on the source array (time). */ +/* Output parameters: */ +/* - f: pointer on the destination array (frequencies). */ +/* f [0...length(x)/2] = real values, */ +/* f [length(x)/2+1...length(x)-1] = imaginary values of */ +/* coefficents 1...length(x)/2-1. */ +/*==========================================================================*) +procedure TFFTReal.do_fft(f: pflt_array; const x: pflt_array); +var + sf, df : pflt_array; + pass : integer; + nbr_coef : longint; + h_nbr_coef : longint; + d_nbr_coef : longint; + coef_index : longint; + bit_rev_lut_ptr : plongarray; + rev_index_0 : longint; + rev_index_1 : longint; + rev_index_2 : longint; + rev_index_3 : longint; + df2 : pflt_array; + n1, n2, n3 : integer; + sf_0, sf_2 : flt_t; + sqrt2_2 : flt_t; + v : flt_t; + cos_ptr : pflt_array; + i : longint; + sf1r, sf2r : pflt_array; + dfr, dfi : pflt_array; + sf1i, sf2i : pflt_array; + c, s : flt_t; + temp_ptr : pflt_array; + b_0, b_2 : flt_t; +begin + n1 := 1; + n2 := 2; + n3 := 3; + + (*______________________________________________ + * + * General case + *______________________________________________ + *) + + if _nbr_bits > 2 then + begin + if _nbr_bits and 1 <> 0 then + begin + df := pointer(_buffer_ptr); + sf := f; + end + else + begin + df := f; + sf := pointer(_buffer_ptr); + end; + + // + // Do the transformation in several passes + // + + // First and second pass at once + bit_rev_lut_ptr := pointer(_bit_rev_lut.get_ptr); + coef_index := 0; + + repeat + rev_index_0 := bit_rev_lut_ptr^[coef_index]; + rev_index_1 := bit_rev_lut_ptr^[coef_index + 1]; + rev_index_2 := bit_rev_lut_ptr^[coef_index + 2]; + rev_index_3 := bit_rev_lut_ptr^[coef_index + 3]; + + df2 := pointer(longint(df) + (coef_index*sizeof_flt)); + df2^[n1] := x^[rev_index_0] - x^[rev_index_1]; + df2^[n3] := x^[rev_index_2] - x^[rev_index_3]; + + sf_0 := x^[rev_index_0] + x^[rev_index_1]; + sf_2 := x^[rev_index_2] + x^[rev_index_3]; + + df2^[0] := sf_0 + sf_2; + df2^[n2] := sf_0 - sf_2; + + inc(coef_index, 4); + until (coef_index >= _length); + + + // Third pass + coef_index := 0; + sqrt2_2 := _sqrt2_2; + + repeat + sf^[coef_index] := df^[coef_index] + df^[coef_index + 4]; + sf^[coef_index + 4] := df^[coef_index] - df^[coef_index + 4]; + sf^[coef_index + 2] := df^[coef_index + 2]; + sf^[coef_index + 6] := df^[coef_index + 6]; + + v := (df [coef_index + 5] - df^[coef_index + 7]) * sqrt2_2; + sf^[coef_index + 1] := df^[coef_index + 1] + v; + sf^[coef_index + 3] := df^[coef_index + 1] - v; + + v := (df^[coef_index + 5] + df^[coef_index + 7]) * sqrt2_2; + sf [coef_index + 5] := v + df^[coef_index + 3]; + sf [coef_index + 7] := v - df^[coef_index + 3]; + + inc(coef_index, 8); + until (coef_index >= _length); + + + // Next pass + for pass := 3 to _nbr_bits-1 do + begin + coef_index := 0; + nbr_coef := 1 shl pass; + h_nbr_coef := nbr_coef shr 1; + d_nbr_coef := nbr_coef shl 1; + + cos_ptr := pointer(_trigo_lut.get_ptr(pass)); + repeat + sf1r := pointer(longint(sf) + (coef_index * sizeof_flt)); + sf2r := pointer(longint(sf1r) + (nbr_coef * sizeof_flt)); + dfr := pointer(longint(df) + (coef_index * sizeof_flt)); + dfi := pointer(longint(dfr) + (nbr_coef * sizeof_flt)); + + // Extreme coefficients are always real + dfr^[0] := sf1r^[0] + sf2r^[0]; + dfi^[0] := sf1r^[0] - sf2r^[0]; // dfr [nbr_coef] = + dfr^[h_nbr_coef] := sf1r^[h_nbr_coef]; + dfi^[h_nbr_coef] := sf2r^[h_nbr_coef]; + + // Others are conjugate complex numbers + sf1i := pointer(longint(sf1r) + (h_nbr_coef * sizeof_flt)); + sf2i := pointer(longint(sf1i) + (nbr_coef * sizeof_flt)); + + for i := 1 to h_nbr_coef-1 do + begin + c := cos_ptr^[i]; // cos (i*PI/nbr_coef); + s := cos_ptr^[h_nbr_coef - i]; // sin (i*PI/nbr_coef); + + v := sf2r^[i] * c - sf2i^[i] * s; + dfr^[i] := sf1r^[i] + v; + dfi^[-i] := sf1r^[i] - v; // dfr [nbr_coef - i] = + + v := sf2r^[i] * s + sf2i^[i] * c; + dfi^[i] := v + sf1i^[i]; + dfi^[nbr_coef - i] := v - sf1i^[i]; + end; + + inc(coef_index, d_nbr_coef); + until (coef_index >= _length); + + // Prepare to the next pass + temp_ptr := df; + df := sf; + sf := temp_ptr; + end; + end + + (*______________________________________________ + * + * Special cases + *______________________________________________ + *) + + // 4-point FFT + else if _nbr_bits = 2 then + begin + f^[n1] := x^[0] - x^[n2]; + f^[n3] := x^[n1] - x^[n3]; + + b_0 := x^[0] + x^[n2]; + b_2 := x^[n1] + x^[n3]; + + f^[0] := b_0 + b_2; + f^[n2] := b_0 - b_2; + end + + // 2-point FFT + else if _nbr_bits = 1 then + begin + f^[0] := x^[0] + x^[n1]; + f^[n1] := x^[0] - x^[n1]; + end + + // 1-point FFT + else + f^[0] := x^[0]; +end; + + +(*==========================================================================*/ +/* Name: do_ifft */ +/* Description: Compute the inverse FFT of the array. Notice that */ +/* IFFT (FFT (x)) = x * length (x). Data must be */ +/* post-scaled. */ +/* Input parameters: */ +/* - f: pointer on the source array (frequencies). */ +/* f [0...length(x)/2] = real values, */ +/* f [length(x)/2+1...length(x)-1] = imaginary values of */ +/* coefficents 1...length(x)/2-1. */ +/* Output parameters: */ +/* - x: pointer on the destination array (time). */ +/*==========================================================================*) +procedure TFFTReal.do_ifft(const f: pflt_array; x: pflt_array); +var + n1, n2, n3 : integer; + n4, n5, n6, n7 : integer; + sf, df, df_temp : pflt_array; + pass : integer; + nbr_coef : longint; + h_nbr_coef : longint; + d_nbr_coef : longint; + coef_index : longint; + cos_ptr : pflt_array; + i : longint; + sfr, sfi : pflt_array; + df1r, df2r : pflt_array; + df1i, df2i : pflt_array; + c, s, vr, vi : flt_t; + temp_ptr : pflt_array; + sqrt2_2 : flt_t; + bit_rev_lut_ptr : plongarray; + sf2 : pflt_array; + b_0, b_1, b_2, b_3 : flt_t; +begin + n1 := 1; + n2 := 2; + n3 := 3; + n4 := 4; + n5 := 5; + n6 := 6; + n7 := 7; + + (*______________________________________________ + * + * General case + *______________________________________________ + *) + + if _nbr_bits > 2 then + begin + sf := f; + + if _nbr_bits and 1 <> 0 then + begin + df := pointer(_buffer_ptr); + df_temp := x; + end + else + begin + df := x; + df_temp := pointer(_buffer_ptr); + end; + + // Do the transformation in several pass + + // First pass + for pass := _nbr_bits-1 downto 3 do + begin + coef_index := 0; + nbr_coef := 1 shl pass; + h_nbr_coef := nbr_coef shr 1; + d_nbr_coef := nbr_coef shl 1; + + cos_ptr := pointer(_trigo_lut.get_ptr(pass)); + + repeat + sfr := pointer(longint(sf) + (coef_index*sizeof_flt)); + sfi := pointer(longint(sfr) + (nbr_coef*sizeof_flt)); + df1r := pointer(longint(df) + (coef_index*sizeof_flt)); + df2r := pointer(longint(df1r) + (nbr_coef*sizeof_flt)); + + // Extreme coefficients are always real + df1r^[0] := sfr^[0] + sfi^[0]; // + sfr [nbr_coef] + df2r^[0] := sfr^[0] - sfi^[0]; // - sfr [nbr_coef] + df1r^[h_nbr_coef] := sfr^[h_nbr_coef] * 2; + df2r^[h_nbr_coef] := sfi^[h_nbr_coef] * 2; + + // Others are conjugate complex numbers + df1i := pointer(longint(df1r) + (h_nbr_coef*sizeof_flt)); + df2i := pointer(longint(df1i) + (nbr_coef*sizeof_flt)); + + for i := 1 to h_nbr_coef-1 do + begin + df1r^[i] := sfr^[i] + sfi^[-i]; // + sfr [nbr_coef - i] + df1i^[i] := sfi^[i] - sfi^[nbr_coef - i]; + + c := cos_ptr^[i]; // cos (i*PI/nbr_coef); + s := cos_ptr^[h_nbr_coef - i]; // sin (i*PI/nbr_coef); + vr := sfr^[i] - sfi^[-i]; // - sfr [nbr_coef - i] + vi := sfi^[i] + sfi^[nbr_coef - i]; + + df2r^[i] := vr * c + vi * s; + df2i^[i] := vi * c - vr * s; + end; + + inc(coef_index, d_nbr_coef); + until (coef_index >= _length); + + + // Prepare to the next pass + if (pass < _nbr_bits - 1) then + begin + temp_ptr := df; + df := sf; + sf := temp_ptr; + end + else + begin + sf := df; + df := df_temp; + end + end; + + // Antepenultimate pass + sqrt2_2 := _sqrt2_2; + coef_index := 0; + + repeat + df^[coef_index] := sf^[coef_index] + sf^[coef_index + 4]; + df^[coef_index + 4] := sf^[coef_index] - sf^[coef_index + 4]; + df^[coef_index + 2] := sf^[coef_index + 2] * 2; + df^[coef_index + 6] := sf^[coef_index + 6] * 2; + + df^[coef_index + 1] := sf^[coef_index + 1] + sf^[coef_index + 3]; + df^[coef_index + 3] := sf^[coef_index + 5] - sf^[coef_index + 7]; + + vr := sf^[coef_index + 1] - sf^[coef_index + 3]; + vi := sf^[coef_index + 5] + sf^[coef_index + 7]; + + df^[coef_index + 5] := (vr + vi) * sqrt2_2; + df^[coef_index + 7] := (vi - vr) * sqrt2_2; + + inc(coef_index, 8); + until (coef_index >= _length); + + + // Penultimate and last pass at once + coef_index := 0; + bit_rev_lut_ptr := pointer(_bit_rev_lut.get_ptr); + sf2 := df; + + repeat + b_0 := sf2^[0] + sf2^[n2]; + b_2 := sf2^[0] - sf2^[n2]; + b_1 := sf2^[n1] * 2; + b_3 := sf2^[n3] * 2; + + x^[bit_rev_lut_ptr^[0]] := b_0 + b_1; + x^[bit_rev_lut_ptr^[n1]] := b_0 - b_1; + x^[bit_rev_lut_ptr^[n2]] := b_2 + b_3; + x^[bit_rev_lut_ptr^[n3]] := b_2 - b_3; + + b_0 := sf2^[n4] + sf2^[n6]; + b_2 := sf2^[n4] - sf2^[n6]; + b_1 := sf2^[n5] * 2; + b_3 := sf2^[n7] * 2; + + x^[bit_rev_lut_ptr^[n4]] := b_0 + b_1; + x^[bit_rev_lut_ptr^[n5]] := b_0 - b_1; + x^[bit_rev_lut_ptr^[n6]] := b_2 + b_3; + x^[bit_rev_lut_ptr^[n7]] := b_2 - b_3; + + inc(sf2, 8); + inc(coef_index, 8); + inc(bit_rev_lut_ptr, 8); + until (coef_index >= _length); + end + + (*______________________________________________ + * + * Special cases + *______________________________________________ + *) + + // 4-point IFFT + else if _nbr_bits = 2 then + begin + b_0 := f^[0] + f [n2]; + b_2 := f^[0] - f [n2]; + + x^[0] := b_0 + f [n1] * 2; + x^[n2] := b_0 - f [n1] * 2; + x^[n1] := b_2 + f [n3] * 2; + x^[n3] := b_2 - f [n3] * 2; + end + + // 2-point IFFT + else if _nbr_bits = 1 then + begin + x^[0] := f^[0] + f^[n1]; + x^[n1] := f^[0] - f^[n1]; + end + + // 1-point IFFT + else + x^[0] := f^[0]; +end; + +(*==========================================================================*/ +/* Name: rescale */ +/* Description: Scale an array by divide each element by its length. */ +/* This function should be called after FFT + IFFT. */ +/* Input/Output parameters: */ +/* - x: pointer on array to rescale (time or frequency). */ +/*==========================================================================*) +procedure TFFTReal.rescale(x: pflt_array); +var + mul : flt_t; + i : longint; +begin + mul := 1.0 / _length; + i := _length - 1; + + repeat + x^[i] := x^[i] * mul; + dec(i); + until (i < 0); +end; + +end. diff --git a/demos/spectrum/fftreal/fftreal.pro b/demos/spectrum/fftreal/fftreal.pro new file mode 100644 index 0000000..786a962 --- /dev/null +++ b/demos/spectrum/fftreal/fftreal.pro @@ -0,0 +1,41 @@ +TEMPLATE = lib +TARGET = fftreal + +# FFTReal +HEADERS += Array.h \ + Array.hpp \ + DynArray.h \ + DynArray.hpp \ + FFTRealFixLen.h \ + FFTRealFixLen.hpp \ + FFTRealFixLenParam.h \ + FFTRealPassDirect.h \ + FFTRealPassDirect.hpp \ + FFTRealPassInverse.h \ + FFTRealPassInverse.hpp \ + FFTRealSelect.h \ + FFTRealSelect.hpp \ + FFTRealUseTrigo.h \ + FFTRealUseTrigo.hpp \ + OscSinCos.h \ + OscSinCos.hpp \ + def.h + +# Wrapper used to export the required instantiation of the FFTRealFixLen template +HEADERS += fftreal_wrapper.h +SOURCES += fftreal_wrapper.cpp + +DEFINES += FFTREAL_LIBRARY + +symbian { + # Provide unique ID for the generated binary, required by Symbian OS + TARGET.UID3 = 0xA000E3FB +} else { + macx { + CONFIG += lib_bundle + } else { + DESTDIR = ../bin + } +} + + diff --git a/demos/spectrum/fftreal/fftreal_wrapper.cpp b/demos/spectrum/fftreal/fftreal_wrapper.cpp new file mode 100644 index 0000000..50ab36d --- /dev/null +++ b/demos/spectrum/fftreal/fftreal_wrapper.cpp @@ -0,0 +1,54 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** This program 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. This +** program 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 General Public License +** for more details. You should have received a copy of the GNU General +** Public License along with this program. If not, see +** . +** +***************************************************************************/ + +#include "fftreal_wrapper.h" + +// FFTReal code generates quite a lot of 'unused parameter' compiler warnings, +// which we suppress here in order to get a clean build output. +#if defined Q_CC_MSVC +# pragma warning(disable:4100) +#elif defined Q_CC_GNU +# pragma GCC diagnostic ignored "-Wunused-parameter" +#elif defined Q_CC_MWERKS +# pragma warning off (10182) +#endif + +#include "FFTRealFixLen.h" + +class FFTRealWrapperPrivate { +public: + FFTRealFixLen m_fft; +}; + + +FFTRealWrapper::FFTRealWrapper() + : m_private(new FFTRealWrapperPrivate) +{ + +} + +FFTRealWrapper::~FFTRealWrapper() +{ + delete m_private; +} + +void FFTRealWrapper::calculateFFT(DataType in[], const DataType out[]) +{ + m_private->m_fft.do_fft(in, out); +} diff --git a/demos/spectrum/fftreal/fftreal_wrapper.h b/demos/spectrum/fftreal/fftreal_wrapper.h new file mode 100644 index 0000000..48d614e --- /dev/null +++ b/demos/spectrum/fftreal/fftreal_wrapper.h @@ -0,0 +1,63 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** This program 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. This +** program 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 General Public License +** for more details. You should have received a copy of the GNU General +** Public License along with this program. If not, see +** . +** +***************************************************************************/ + +#ifndef FFTREAL_WRAPPER_H +#define FFTREAL_WRAPPER_H + +#include + +#if defined(FFTREAL_LIBRARY) +# define FFTREAL_EXPORT Q_DECL_EXPORT +#else +# define FFTREAL_EXPORT Q_DECL_IMPORT +#endif + +class FFTRealWrapperPrivate; + +// Each pass of the FFT processes 2^X samples, where X is the +// number below. +static const int FFTLengthPowerOfTwo = 12; + +/** + * Wrapper around the FFTRealFixLen template provided by the FFTReal + * library + * + * This class instantiates a single instance of FFTRealFixLen, using + * FFTLengthPowerOfTwo as the template parameter. It then exposes + * FFTRealFixLen::do_fft via the calculateFFT + * function, thereby allowing an application to dynamically link + * against the FFTReal implementation. + * + * See http://ldesoras.free.fr/prod.html + */ +class FFTREAL_EXPORT FFTRealWrapper +{ +public: + FFTRealWrapper(); + ~FFTRealWrapper(); + + typedef float DataType; + void calculateFFT(DataType in[], const DataType out[]); + +private: + FFTRealWrapperPrivate* m_private; +}; + +#endif // FFTREAL_WRAPPER_H + diff --git a/demos/spectrum/fftreal/license.txt b/demos/spectrum/fftreal/license.txt new file mode 100644 index 0000000..918fe68 --- /dev/null +++ b/demos/spectrum/fftreal/license.txt @@ -0,0 +1,459 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + diff --git a/demos/spectrum/fftreal/readme.txt b/demos/spectrum/fftreal/readme.txt new file mode 100644 index 0000000..0c5ce16 --- /dev/null +++ b/demos/spectrum/fftreal/readme.txt @@ -0,0 +1,242 @@ +============================================================================== + + FFTReal + Version 2.00, 2005/10/18 + + Fourier transformation (FFT, IFFT) library specialised for real data + Portable ISO C++ + + (c) Laurent de Soras + Object Pascal port (c) Frederic Vanmol + +============================================================================== + + + +1. Legal +-------- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Check the file license.txt to get full information about the license. + + + +2. Content +---------- + +FFTReal is a library to compute Discrete Fourier Transforms (DFT) with the +FFT algorithm (Fast Fourier Transform) on arrays of real numbers. It can +also compute the inverse transform. + +You should find in this package a lot of files ; some of them are of interest: +- readme.txt: you are reading it +- FFTReal.h: FFT, length fixed at run-time +- FFTRealFixLen.h: FFT, length fixed at compile-time +- FFTReal.pas: Pascal implementation (working but not up-to-date) +- stopwatch directory + + + +3. Using FFTReal +---------------- + +Important - if you were using older versions of FFTReal (up to 1.03), some +things have changed. FFTReal is now a template. Therefore use FFTReal +or FFTReal in your code depending on the application datatype. The +flt_t typedef has been removed. + +You have two ways to use FFTReal. In the first way, the FFT has its length +fixed at run-time, when the object is instanciated. It means that you have +not to know the length when you write the code. This is the usual way of +proceeding. + + +3.1 FFTReal - Length fixed at run-time +-------------------------------------- + +Just instanciate one time a FFTReal object. Specify the data type you want +as template parameter (only floating point: float, double, long double or +custom type). The constructor precompute a lot of things, so it may be a bit +long. The parameter is the number of points used for the next FFTs. It must +be a power of 2: + + #include "FFTReal.h" + ... + long len = 1024; + ... + FFTReal fft_object (len); // 1024-point FFT object constructed. + +Then you can use this object to compute as many FFTs and IFFTs as you want. +They will be computed very quickly because a lot of work has been done in the +object construction. + + float x [1024]; + float f [1024]; + + ... + fft_object.do_fft (f, x); // x (real) --FFT---> f (complex) + ... + fft_object.do_ifft (f, x); // f (complex) --IFFT--> x (real) + fft_object.rescale (x); // Post-scaling should be done after FFT+IFFT + ... + +x [] and f [] are floating point number arrays. x [] is the real number +sequence which we want to compute the FFT. f [] is the result, in the +"frequency" domain. f has the same number of elements as x [], but f [] +elements are complex numbers. The routine uses some FFT properties to +optimize memory and to reduce calculations: the transformaton of a real +number sequence is a conjugate complex number sequence: F [k] = F [-k]*. + + +3.2 FFTRealFixLen - Length fixed at compile-time +------------------------------------------------ + +This class is significantly faster than the previous one, giving a speed +gain between 50 and 100 %. The template parameter is the base-2 logarithm of +the FFT length. The datatype is float; it can be changed by modifying the +DataType typedef in FFTRealFixLenParam.h. As FFTReal class, it supports +only floating-point types or equivalent. + +To instanciate the object, just proceed as below: + + #include "FFTRealFixLen.h" + ... + FFTRealFixLen <10> fft_object; // 1024-point (2^10) FFT object constructed. + +Use is similar as the one of FFTReal. + + +3.3 Data organisation +--------------------- + +Mathematically speaking, the formulas below show what does FFTReal: + +do_fft() : f(k) = sum (p = 0, N-1, x(p) * exp (+j*2*pi*k*p/N)) +do_ifft(): x(k) = sum (p = 0, N-1, f(p) * exp (-j*2*pi*k*p/N)) + +Where j is the square root of -1. The formulas differ only by the sign of +the exponential. When the sign is positive, the transform is called positive. +Common formulas for Fourier transform are negative for the direct tranform and +positive for the inverse one. + +However in these formulas, f is an array of complex numbers and doesn't +correspound exactly to the f[] array taken as function parameter. The +following table shows how the f[] sequence is mapped onto the usable FFT +coefficients (called bins): + + FFTReal output | Positive FFT equiv. | Negative FFT equiv. + ---------------+-----------------------+----------------------- + f [0] | Real (bin 0) | Real (bin 0) + f [...] | Real (bin ...) | Real (bin ...) + f [length/2] | Real (bin length/2) | Real (bin length/2) + f [length/2+1] | Imag (bin 1) | -Imag (bin 1) + f [...] | Imag (bin ...) | -Imag (bin ...) + f [length-1] | Imag (bin length/2-1) | -Imag (bin length/2-1) + +And FFT bins are distributed in f [] as above: + + | | Positive FFT | Negative FFT + Bin | Real part | imaginary part | imaginary part + ------------+----------------+-----------------+--------------- + 0 | f [0] | 0 | 0 + 1 | f [1] | f [length/2+1] | -f [length/2+1] + ... | f [...], | f [...] | -f [...] + length/2-1 | f [length/2-1] | f [length-1] | -f [length-1] + length/2 | f [length/2] | 0 | 0 + length/2+1 | f [length/2-1] | -f [length-1] | f [length-1] + ... | f [...] | -f [...] | f [...] + length-1 | f [1] | -f [length/2+1] | f [length/2+1] + +f [] coefficients have the same layout for FFT and IFFT functions. You may +notice that scaling must be done if you want to retrieve x after FFT and IFFT. +Actually, IFFT (FFT (x)) = x * length(x). This is a not a problem because +most of the applications don't care about absolute values. Thus, the operation +requires less calculation. If you want to use the FFT and IFFT to transform a +signal, you have to apply post- (or pre-) processing yourself. Multiplying +or dividing floating point numbers by a power of 2 doesn't generate extra +computation noise. + + + +4. Compilation and testing +-------------------------- + +Drop the following files into your project or makefile: + +Array.* +def.h +DynArray.* +FFTReal*.cpp +FFTReal*.h* +OscSinCos.* + +Other files are for testing purpose only, do not include them if you just need +to use the library ; they are not needed to use FFTReal in your own programs. + +FFTReal may be compiled in two versions: release and debug. Debug version +has checks that could slow down the code. Define NDEBUG to set the Release +mode. For example, the command line to compile the test bench on GCC would +look like: + +Debug mode: +g++ -Wall -o fftreal_debug.exe *.cpp stopwatch/*.cpp + +Release mode: +g++ -Wall -o fftreal_release.exe -DNDEBUG -O3 *.cpp stopwatch/*.cpp + +It may be tricky to compile the test bench because the speed tests use the +stopwatch sub-library, which is not that cross-platform. If you encounter +any problem that you cannot easily fix while compiling it, edit the file +test_settings.h and un-define the speed test macro. Remove the stopwatch +directory from your source file list, too. + +If it's not done by default, you should activate the exception handling +of your compiler to get the class memory-leak-safe. Thus, when a memory +allocation fails (in the constructor), an exception is thrown and the entire +object is safely destructed. It reduces the permanent error checking overhead +in the client code. Also, the test bench requires Run-Time Type Information +(RTTI) to be enabled in order to display the names of the tested classes - +sometimes mangled, depending on the compiler. + +The test bench may take a long time to compile, especially in Release mode, +because a lot of recursive templates are instanciated. + + + +5. History +---------- + +v2.00 (2005.10.18) +- Turned FFTReal class into template (data type as parameter) +- Added FFTRealFixLen +- Trigonometric tables are size-limited in order to preserve cache memory; +over a given size, sin/cos functions are computed on the fly. +- Better test bench for accuracy and speed + +v1.03 (2001.06.15) +- Thanks to Frederic Vanmol for the Pascal port (works with Delphi). +- Documentation improvement + +v1.02 (2001.03.25) +- sqrt() is now precomputed when the object FFTReal is constructed, resulting +in speed impovement for small size FFT. + +v1.01 (2000) +- Small modifications, I don't remember what. + +v1.00 (1999.08.14) +- First version released + diff --git a/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.cpp b/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.cpp new file mode 100644 index 0000000..fe1d424 --- /dev/null +++ b/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.cpp @@ -0,0 +1,285 @@ +/***************************************************************************** + + ClockCycleCounter.cpp + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (_MSC_VER) + #pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant" + #pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer" + #pragma warning (1 : 4705) // "statement has no effect" + #pragma warning (1 : 4706) // "assignment within conditional expression" + #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" + #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" + #pragma warning (4 : 4355) // "'this' : used in base member initializer list" +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "ClockCycleCounter.h" + +#include + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/* +============================================================================== +Name: ctor +Description: + The first object constructed initialise global data. This first + construction may be a bit slow. +Throws: Nothing +============================================================================== +*/ + +ClockCycleCounter::ClockCycleCounter () +: _start_time (0) +, _state (0) +, _best_score (-1) +{ + if (! _init_flag) + { + // Should be executed in this order + compute_clk_mul (); + compute_measure_time_total (); + compute_measure_time_lap (); + + // Restores object state + _start_time = 0; + _state = 0; + _best_score = -1; + + _init_flag = true; + } +} + + + +/* +============================================================================== +Name: get_time_total +Description: + Gives the time elapsed between the latest stop_lap() and start() calls. +Returns: + The duration, in clock cycles. +Throws: Nothing +============================================================================== +*/ + +Int64 ClockCycleCounter::get_time_total () const +{ + const Int64 duration = _state - _start_time; + assert (duration >= 0); + + const Int64 t = max ( + duration - _measure_time_total, + static_cast (0) + ); + + return (t * _clk_mul); +} + + + +/* +============================================================================== +Name: get_time_best_lap +Description: + Gives the smallest time between two consecutive stop_lap() or between + the stop_lap() and start(). The value is reset by a call to start(). + Call this function only after a stop_lap(). + The time is amputed from the duration of the stop_lap() call itself. +Returns: + The smallest duration, in clock cycles. +Throws: Nothing +============================================================================== +*/ + +Int64 ClockCycleCounter::get_time_best_lap () const +{ + assert (_best_score >= 0); + + const Int64 t1 = max ( + _best_score - _measure_time_lap, + static_cast (0) + ); + const Int64 t = min (t1, get_time_total ()); + + return (t * _clk_mul); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#if defined (__MACOS__) + +static inline double stopwatch_ClockCycleCounter_get_time_s () +{ + const Nanoseconds ns = AbsoluteToNanoseconds (UpTime ()); + + return (ns.hi * 4294967296e-9 + ns.lo * 1e-9); +} + +#endif // __MACOS__ + + + +/* +============================================================================== +Name: compute_clk_mul +Description: + This function, only for PowerPC/MacOS computers, computes the multiplier + required to deduce clock cycles from the internal counter. +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::compute_clk_mul () +{ + assert (! _init_flag); + +#if defined (__MACOS__) + + long clk_speed_mhz = CurrentProcessorSpeed (); + const Int64 clk_speed = + static_cast (clk_speed_mhz) * (1000L*1000L); + + const double start_time_s = stopwatch_ClockCycleCounter_get_time_s (); + start (); + + const double duration = 0.01; // Seconds + while (stopwatch_ClockCycleCounter_get_time_s () - start_time_s < duration) + { + continue; + } + + const double stop_time_s = stopwatch_ClockCycleCounter_get_time_s (); + stop (); + + const double diff_time_s = stop_time_s - start_time_s; + const double nbr_cycles = diff_time_s * static_cast (clk_speed); + + const Int64 diff_time_c = _state - _start_time; + const double clk_mul = nbr_cycles / static_cast (diff_time_c); + + _clk_mul = round_int (clk_mul); + +#endif // __MACOS__ +} + + + +void ClockCycleCounter::compute_measure_time_total () +{ + start (); + spend_time (); + + Int64 best_result = 0x7FFFFFFFL; // Should be enough + long nbr_tests = 100; + for (long cnt = 0; cnt < nbr_tests; ++cnt) + { + start (); + stop_lap (); + const Int64 duration = _state - _start_time; + best_result = min (best_result, duration); + } + + _measure_time_total = best_result; +} + + + +/* +============================================================================== +Name: compute_measure_time_lap +Description: + Computes the duration of one stop_lap() call and store it. It will be used + later to get the real duration of the measured operation (by substracting + the measurement duration). +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::compute_measure_time_lap () +{ + start (); + spend_time (); + + long nbr_tests = 10; + for (long cnt = 0; cnt < nbr_tests; ++cnt) + { + stop_lap (); + stop_lap (); + stop_lap (); + stop_lap (); + } + + _measure_time_lap = _best_score; +} + + + +void ClockCycleCounter::spend_time () +{ + const Int64 nbr_clocks = 500; // Number of clock cycles to spend + + const Int64 start = read_clock_counter (); + Int64 current; + + do + { + current = read_clock_counter (); + } + while ((current - start) * _clk_mul < nbr_clocks); +} + + + +Int64 ClockCycleCounter::_measure_time_total = 0; +Int64 ClockCycleCounter::_measure_time_lap = 0; +int ClockCycleCounter::_clk_mul = 1; +bool ClockCycleCounter::_init_flag = false; + + +} // namespace stopwatch + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.h b/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.h new file mode 100644 index 0000000..ba7a99a --- /dev/null +++ b/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.h @@ -0,0 +1,124 @@ +/***************************************************************************** + + ClockCycleCounter.h + Copyright (c) 2003 Laurent de Soras + +Instrumentation class, for accurate time interval measurement. You may have +to modify the implementation to adapt it to your system and/or compiler. + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_ClockCycleCounter_HEADER_INCLUDED) +#define stopwatch_ClockCycleCounter_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "Int64.h" + + + +namespace stopwatch +{ + + + +class ClockCycleCounter +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + ClockCycleCounter (); + + stopwatch_FORCEINLINE void + start (); + stopwatch_FORCEINLINE void + stop_lap (); + Int64 get_time_total () const; + Int64 get_time_best_lap () const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + void compute_clk_mul (); + void compute_measure_time_total (); + void compute_measure_time_lap (); + + static void spend_time (); + static stopwatch_FORCEINLINE Int64 + read_clock_counter (); + + Int64 _start_time; + Int64 _state; + Int64 _best_score; + + static Int64 _measure_time_total; + static Int64 _measure_time_lap; + static int _clk_mul; + static bool _init_flag; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + ClockCycleCounter (const ClockCycleCounter &other); + ClockCycleCounter & + operator = (const ClockCycleCounter &other); + bool operator == (const ClockCycleCounter &other); + bool operator != (const ClockCycleCounter &other); + +}; // class ClockCycleCounter + + + +} // namespace stopwatch + + + +#include "ClockCycleCounter.hpp" + + + +#endif // stopwatch_ClockCycleCounter_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.hpp b/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.hpp new file mode 100644 index 0000000..fbd511e --- /dev/null +++ b/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.hpp @@ -0,0 +1,150 @@ +/***************************************************************************** + + ClockCycleCounter.hpp + Copyright (c) 2003 Laurent de Soras + +Please complete the definitions according to your compiler/architecture. +It's not a big deal if it's not possible to get the clock count... + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (stopwatch_ClockCycleCounter_CURRENT_CODEHEADER) + #error Recursive inclusion of ClockCycleCounter code header. +#endif +#define stopwatch_ClockCycleCounter_CURRENT_CODEHEADER + +#if ! defined (stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED) +#define stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "fnc.h" + +#include + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/* +============================================================================== +Name: start +Description: + Starts the counter. +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::start () +{ + _best_score = (static_cast (1) << (sizeof (Int64) * CHAR_BIT - 2)); + const Int64 start_clock = read_clock_counter (); + _start_time = start_clock; + _state = start_clock - _best_score; +} + + + +/* +============================================================================== +Name: stop_lap +Description: + Captures the current time and updates the smallest duration between two + consecutive calls to stop_lap() or the latest start(). + start() must have been called at least once before calling this function. +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::stop_lap () +{ + const Int64 end_clock = read_clock_counter (); + _best_score = min (end_clock - _state, _best_score); + _state = end_clock; +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +Int64 ClockCycleCounter::read_clock_counter () +{ + register Int64 clock_cnt; + +#if defined (_MSC_VER) + + __asm + { + lea edi, clock_cnt + rdtsc + mov [edi ], eax + mov [edi + 4], edx + } + +#elif defined (__GNUC__) && defined (__i386__) + + __asm__ __volatile__ ("rdtsc" : "=A" (clock_cnt)); + +#elif (__MWERKS__) && defined (__POWERPC__) + + asm + { + loop: + mftbu clock_cnt@hiword + mftb clock_cnt@loword + mftbu r5 + cmpw clock_cnt@hiword,r5 + bne loop + } + +#endif + + return (clock_cnt); +} + + + +} // namespace stopwatch + + + +#endif // stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED + +#undef stopwatch_ClockCycleCounter_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/Int64.h b/demos/spectrum/fftreal/stopwatch/Int64.h new file mode 100644 index 0000000..1e786e2 --- /dev/null +++ b/demos/spectrum/fftreal/stopwatch/Int64.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + Int64.h + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_Int64_HEADER_INCLUDED) +#define stopwatch_Int64_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + +#if defined (_MSC_VER) + + typedef __int64 Int64; + +#elif defined (__MWERKS__) || defined (__GNUC__) + + typedef long long Int64; + +#elif defined (__BEOS__) + + typedef int64 Int64; + +#else + + #error No 64-bit integer type defined for this compiler ! + +#endif + + +} // namespace stopwatch + + + +#endif // stopwatch_Int64_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/StopWatch.cpp b/demos/spectrum/fftreal/stopwatch/StopWatch.cpp new file mode 100644 index 0000000..7795d86 --- /dev/null +++ b/demos/spectrum/fftreal/stopwatch/StopWatch.cpp @@ -0,0 +1,101 @@ +/***************************************************************************** + + StopWatch.cpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (_MSC_VER) + #pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant" + #pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer" + #pragma warning (1 : 4705) // "statement has no effect" + #pragma warning (1 : 4706) // "assignment within conditional expression" + #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" + #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" + #pragma warning (4 : 4355) // "'this' : used in base member initializer list" +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "StopWatch.h" + +#include + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +StopWatch::StopWatch () +: _ccc () +, _nbr_laps (0) +{ + // Nothing +} + + + +double StopWatch::get_time_total (Int64 nbr_op) const +{ + assert (_nbr_laps > 0); + assert (nbr_op > 0); + + return ( + static_cast (_ccc.get_time_total ()) + / (static_cast (nbr_op) * static_cast (_nbr_laps)) + ); +} + + + +double StopWatch::get_time_best_lap (Int64 nbr_op) const +{ + assert (nbr_op > 0); + + return ( + static_cast (_ccc.get_time_best_lap ()) + / static_cast (nbr_op) + ); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +} // namespace stopwatch + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/StopWatch.h b/demos/spectrum/fftreal/stopwatch/StopWatch.h new file mode 100644 index 0000000..9cc47e5 --- /dev/null +++ b/demos/spectrum/fftreal/stopwatch/StopWatch.h @@ -0,0 +1,110 @@ +/***************************************************************************** + + StopWatch.h + Copyright (c) 2005 Laurent de Soras + +Utility class based on ClockCycleCounter to measure the unit time of a +repeated operation. + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_StopWatch_HEADER_INCLUDED) +#define stopwatch_StopWatch_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "ClockCycleCounter.h" + + + +namespace stopwatch +{ + + + +class StopWatch +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + StopWatch (); + + stopwatch_FORCEINLINE void + start (); + stopwatch_FORCEINLINE void + stop_lap (); + + double get_time_total (Int64 nbr_op) const; + double get_time_best_lap (Int64 nbr_op) const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + ClockCycleCounter + _ccc; + Int64 _nbr_laps; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + StopWatch (const StopWatch &other); + StopWatch & operator = (const StopWatch &other); + bool operator == (const StopWatch &other); + bool operator != (const StopWatch &other); + +}; // class StopWatch + + + +} // namespace stopwatch + + + +#include "StopWatch.hpp" + + + +#endif // stopwatch_StopWatch_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/StopWatch.hpp b/demos/spectrum/fftreal/stopwatch/StopWatch.hpp new file mode 100644 index 0000000..74482a7 --- /dev/null +++ b/demos/spectrum/fftreal/stopwatch/StopWatch.hpp @@ -0,0 +1,83 @@ +/***************************************************************************** + + StopWatch.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (stopwatch_StopWatch_CURRENT_CODEHEADER) + #error Recursive inclusion of StopWatch code header. +#endif +#define stopwatch_StopWatch_CURRENT_CODEHEADER + +#if ! defined (stopwatch_StopWatch_CODEHEADER_INCLUDED) +#define stopwatch_StopWatch_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +void StopWatch::start () +{ + _nbr_laps = 0; + _ccc.start (); +} + + + +void StopWatch::stop_lap () +{ + _ccc.stop_lap (); + ++ _nbr_laps; +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +} // namespace stopwatch + + + +#endif // stopwatch_StopWatch_CODEHEADER_INCLUDED + +#undef stopwatch_StopWatch_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/def.h b/demos/spectrum/fftreal/stopwatch/def.h new file mode 100644 index 0000000..81ee6aa --- /dev/null +++ b/demos/spectrum/fftreal/stopwatch/def.h @@ -0,0 +1,65 @@ +/***************************************************************************** + + def.h + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_def_HEADER_INCLUDED) +#define stopwatch_def_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + + +#if defined (_MSC_VER) + + #define stopwatch_FORCEINLINE __forceinline + +#else + + #define stopwatch_FORCEINLINE inline + +#endif + + + +} // namespace stopwatch + + + +#endif // stopwatch_def_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/fnc.h b/demos/spectrum/fftreal/stopwatch/fnc.h new file mode 100644 index 0000000..0554535 --- /dev/null +++ b/demos/spectrum/fftreal/stopwatch/fnc.h @@ -0,0 +1,67 @@ +/***************************************************************************** + + fnc.h + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_fnc_HEADER_INCLUDED) +#define stopwatch_fnc_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + + +template +inline T min (T a, T b); + +template +inline T max (T a, T b); + +inline int round_int (double x); + + + +} // namespace rsp + + + +#include "fnc.hpp" + + + +#endif // stopwatch_fnc_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/fnc.hpp b/demos/spectrum/fftreal/stopwatch/fnc.hpp new file mode 100644 index 0000000..0ab5949 --- /dev/null +++ b/demos/spectrum/fftreal/stopwatch/fnc.hpp @@ -0,0 +1,85 @@ +/***************************************************************************** + + fnc.hpp + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (stopwatch_fnc_CURRENT_CODEHEADER) + #error Recursive inclusion of fnc code header. +#endif +#define stopwatch_fnc_CURRENT_CODEHEADER + +#if ! defined (stopwatch_fnc_CODEHEADER_INCLUDED) +#define stopwatch_fnc_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include +#include + +namespace std {} + + + +namespace stopwatch +{ + + + +template +inline T min (T a, T b) +{ + return ((a < b) ? a : b); +} + + + +template +inline T max (T a, T b) +{ + return ((b < a) ? a : b); +} + + + +int round_int (double x) +{ + using namespace std; + + return (static_cast (floor (x + 0.5))); +} + + + +} // namespace stopwatch + + + +#endif // stopwatch_fnc_CODEHEADER_INCLUDED + +#undef stopwatch_fnc_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/test.cpp b/demos/spectrum/fftreal/test.cpp new file mode 100644 index 0000000..7b6ed2c --- /dev/null +++ b/demos/spectrum/fftreal/test.cpp @@ -0,0 +1,267 @@ +/***************************************************************************** + + test.cpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (_MSC_VER) + #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" + #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_settings.h" +#include "TestHelperFixLen.h" +#include "TestHelperNormal.h" + +#if defined (_MSC_VER) +#include +#include +#endif // _MSC_VER + +#include + +#include +#include + + + +#define TEST_ + + +/*\\\ FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +static int TEST_perform_test_accuracy_all (); +static int TEST_perform_test_speed_all (); + +static void TEST_prog_init (); +static void TEST_prog_end (); + + + +int main (int argc, char *argv []) +{ + using namespace std; + + int ret_val = 0; + + TEST_prog_init (); + + try + { + if (ret_val == 0) + { + ret_val = TEST_perform_test_accuracy_all (); + } + + if (ret_val == 0) + { + ret_val = TEST_perform_test_speed_all (); + } + } + + catch (std::exception &e) + { + printf ("\n*** main(): Exception (std::exception) : %s\n", e.what ()); + ret_val = -1; + } + + catch (...) + { + printf ("\n*** main(): Undefined exception\n"); + ret_val = -1; + } + + TEST_prog_end (); + + return (ret_val); +} + + + +int TEST_perform_test_accuracy_all () +{ + int ret_val = 0; + + TestHelperNormal ::perform_test_accuracy (ret_val); + TestHelperNormal ::perform_test_accuracy (ret_val); + + TestHelperFixLen < 1>::perform_test_accuracy (ret_val); + TestHelperFixLen < 2>::perform_test_accuracy (ret_val); + TestHelperFixLen < 3>::perform_test_accuracy (ret_val); + TestHelperFixLen < 4>::perform_test_accuracy (ret_val); + TestHelperFixLen < 7>::perform_test_accuracy (ret_val); + TestHelperFixLen < 8>::perform_test_accuracy (ret_val); + TestHelperFixLen <10>::perform_test_accuracy (ret_val); + TestHelperFixLen <12>::perform_test_accuracy (ret_val); + TestHelperFixLen <13>::perform_test_accuracy (ret_val); + + return (ret_val); +} + + + +int TEST_perform_test_speed_all () +{ + int ret_val = 0; + +#if defined (test_settings_SPEED_TEST_ENABLED) + + TestHelperNormal ::perform_test_speed (ret_val); + TestHelperNormal ::perform_test_speed (ret_val); + + TestHelperFixLen < 1>::perform_test_speed (ret_val); + TestHelperFixLen < 2>::perform_test_speed (ret_val); + TestHelperFixLen < 3>::perform_test_speed (ret_val); + TestHelperFixLen < 4>::perform_test_speed (ret_val); + TestHelperFixLen < 7>::perform_test_speed (ret_val); + TestHelperFixLen < 8>::perform_test_speed (ret_val); + TestHelperFixLen <10>::perform_test_speed (ret_val); + TestHelperFixLen <12>::perform_test_speed (ret_val); + TestHelperFixLen <14>::perform_test_speed (ret_val); + TestHelperFixLen <16>::perform_test_speed (ret_val); + TestHelperFixLen <20>::perform_test_speed (ret_val); + +#endif + + return (ret_val); +} + + + +#if defined (_MSC_VER) +static int __cdecl TEST_new_handler_cb (size_t dummy) +{ + throw std::bad_alloc (); + return (0); +} +#endif // _MSC_VER + + + +#if defined (_MSC_VER) && ! defined (NDEBUG) +static int __cdecl TEST_debug_alloc_hook_cb (int alloc_type, void *user_data_ptr, size_t size, int block_type, long request_nbr, const unsigned char *filename_0, int line_nbr) +{ + if (block_type != _CRT_BLOCK) // Ignore CRT blocks to prevent infinite recursion + { + switch (alloc_type) + { + case _HOOK_ALLOC: + case _HOOK_REALLOC: + case _HOOK_FREE: + + // Put some debug code here + + break; + + default: + assert (false); // Undefined allocation type + break; + } + } + + return (1); +} +#endif + + + +#if defined (_MSC_VER) && ! defined (NDEBUG) +static int __cdecl TEST_debug_report_hook_cb (int report_type, char *user_msg_0, int *ret_val_ptr) +{ + *ret_val_ptr = 0; // 1 to override the CRT default reporting mode + + switch (report_type) + { + case _CRT_WARN: + case _CRT_ERROR: + case _CRT_ASSERT: + +// Put some debug code here + + break; + } + + return (*ret_val_ptr); +} +#endif + + + +static void TEST_prog_init () +{ +#if defined (_MSC_VER) + ::_set_new_handler (::TEST_new_handler_cb); +#endif // _MSC_VER + +#if defined (_MSC_VER) && ! defined (NDEBUG) + { + const int mode = (1 * _CRTDBG_MODE_DEBUG) + | (1 * _CRTDBG_MODE_WNDW); + ::_CrtSetReportMode (_CRT_WARN, mode); + ::_CrtSetReportMode (_CRT_ERROR, mode); + ::_CrtSetReportMode (_CRT_ASSERT, mode); + + const int old_flags = ::_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG); + ::_CrtSetDbgFlag ( old_flags + | (1 * _CRTDBG_LEAK_CHECK_DF) + | (1 * _CRTDBG_CHECK_ALWAYS_DF)); + ::_CrtSetBreakAlloc (-1); // Specify here a memory bloc number + ::_CrtSetAllocHook (TEST_debug_alloc_hook_cb); + ::_CrtSetReportHook (TEST_debug_report_hook_cb); + + // Speed up I/O but breaks C stdio compatibility +// std::cout.sync_with_stdio (false); +// std::cin.sync_with_stdio (false); +// std::cerr.sync_with_stdio (false); +// std::clog.sync_with_stdio (false); + } +#endif // _MSC_VER, NDEBUG +} + + + +static void TEST_prog_end () +{ +#if defined (_MSC_VER) && ! defined (NDEBUG) + { + const int mode = (1 * _CRTDBG_MODE_DEBUG) + | (0 * _CRTDBG_MODE_WNDW); + ::_CrtSetReportMode (_CRT_WARN, mode); + ::_CrtSetReportMode (_CRT_ERROR, mode); + ::_CrtSetReportMode (_CRT_ASSERT, mode); + + ::_CrtMemState mem_state; + ::_CrtMemCheckpoint (&mem_state); + ::_CrtMemDumpStatistics (&mem_state); + } +#endif // _MSC_VER, NDEBUG +} + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/test_fnc.h b/demos/spectrum/fftreal/test_fnc.h new file mode 100644 index 0000000..2622156 --- /dev/null +++ b/demos/spectrum/fftreal/test_fnc.h @@ -0,0 +1,53 @@ +/***************************************************************************** + + test_fnc.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (test_fnc_HEADER_INCLUDED) +#define test_fnc_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +inline T limit (const T &x, const T &inf, const T &sup); + + + +#include "test_fnc.hpp" + + + +#endif // test_fnc_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/test_fnc.hpp b/demos/spectrum/fftreal/test_fnc.hpp new file mode 100644 index 0000000..4b5f9f5 --- /dev/null +++ b/demos/spectrum/fftreal/test_fnc.hpp @@ -0,0 +1,56 @@ +/***************************************************************************** + + test_fnc.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (test_fnc_CURRENT_CODEHEADER) + #error Recursive inclusion of test_fnc code header. +#endif +#define test_fnc_CURRENT_CODEHEADER + +#if ! defined (test_fnc_CODEHEADER_INCLUDED) +#define test_fnc_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +T limit (const T &x, const T &inf, const T &sup) +{ + assert (! (sup < inf)); + + return ((x < inf) ? inf : ((sup < x) ? sup : x)); +} + + + +#endif // test_fnc_CODEHEADER_INCLUDED + +#undef test_fnc_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/test_settings.h b/demos/spectrum/fftreal/test_settings.h new file mode 100644 index 0000000..b893afc --- /dev/null +++ b/demos/spectrum/fftreal/test_settings.h @@ -0,0 +1,45 @@ +/***************************************************************************** + + test_settings.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (test_settings_HEADER_INCLUDED) +#define test_settings_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +// #undef this label to avoid speed test compilation. +#define test_settings_SPEED_TEST_ENABLED + + + +#endif // test_settings_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/testapp.dpr b/demos/spectrum/fftreal/testapp.dpr new file mode 100644 index 0000000..54f2eb9 --- /dev/null +++ b/demos/spectrum/fftreal/testapp.dpr @@ -0,0 +1,150 @@ +program testapp; +{$APPTYPE CONSOLE} +uses + SysUtils, + fftreal in 'fftreal.pas', + Math, + Windows; + +var + nbr_points : longint; + x, f : pflt_array; + fft : TFFTReal; + i : longint; + PI : double; + areal, img : double; + f_abs : double; + buffer_size : longint; + nbr_tests : longint; + time0, time1, time2 : int64; + timereso : int64; + offset : longint; + t0, t1 : double; + nbr_s_chn : longint; + tempp1, tempp2 : pflt_array; + +begin + (*______________________________________________ + * + * Exactness test + *______________________________________________ + *) + + WriteLn('Accuracy test:'); + WriteLn; + + nbr_points := 16; // Power of 2 + GetMem(x, nbr_points * sizeof_flt); + GetMem(f, nbr_points * sizeof_flt); + fft := TFFTReal.Create(nbr_points); // FFT object initialized here + + // Test signal + PI := ArcTan(1) * 4; + for i := 0 to nbr_points-1 do + begin + x^[i] := -1 + sin (3*2*PI*i/nbr_points) + + cos (5*2*PI*i/nbr_points) * 2 + - sin (7*2*PI*i/nbr_points) * 3 + + cos (8*2*PI*i/nbr_points) * 5; + end; + + // Compute FFT and IFFT + fft.do_fft(f, x); + fft.do_ifft(f, x); + fft.rescale(x); + + // Display the result + WriteLn('FFT:'); + for i := 0 to nbr_points div 2 do + begin + areal := f^[i]; + if (i > 0) and (i < nbr_points div 2) then + img := f^[i + nbr_points div 2] + else + img := 0; + + f_abs := Sqrt(areal * areal + img * img); + WriteLn(Format('%5d: %12.6f %12.6f (%12.6f)', [i, areal, img, f_abs])); + end; + + WriteLn; + WriteLn('IFFT:'); + for i := 0 to nbr_points-1 do + WriteLn(Format('%5d: %f', [i, x^[i]])); + + WriteLn; + + FreeMem(x); + FreeMem(f); + fft.Free; + + + (*______________________________________________ + * + * Speed test + *______________________________________________ + *) + + WriteLn('Speed test:'); + WriteLn('Please wait...'); + WriteLn; + + nbr_points := 1024; // Power of 2 + buffer_size := 256*nbr_points; // Number of flt_t (float or double) + nbr_tests := 10000; + + assert(nbr_points <= buffer_size); + GetMem(x, buffer_size * sizeof_flt); + GetMem(f, buffer_size * sizeof_flt); + fft := TFFTReal.Create(nbr_points); // FFT object initialized here + + // Test signal: noise + for i := 0 to nbr_points-1 do + x^[i] := Random($7fff) - ($7fff shr 1); + + // timing + QueryPerformanceFrequency(timereso); + QueryPerformanceCounter(time0); + + for i := 0 to nbr_tests-1 do + begin + offset := (i * nbr_points) and (buffer_size - 1); + tempp1 := f; + inc(tempp1, offset); + tempp2 := x; + inc(tempp2, offset); + fft.do_fft(tempp1, tempp2); + end; + + QueryPerformanceCounter(time1); + + for i := 0 to nbr_tests-1 do + begin + offset := (i * nbr_points) and (buffer_size - 1); + tempp1 := f; + inc(tempp1, offset); + tempp2 := x; + inc(tempp2, offset); + fft.do_ifft(tempp1, tempp2); + fft.rescale(x); + end; + + QueryPerformanceCounter(time2); + + t0 := ((time1-time0) / timereso) / nbr_tests; + t1 := ((time2-time1) / timereso) / nbr_tests; + + WriteLn(Format('%d-points FFT : %.0f us.', [nbr_points, t0 * 1000000])); + WriteLn(Format('%d-points IFFT + scaling: %.0f us.', [nbr_points, t1 * 1000000])); + + nbr_s_chn := Floor(nbr_points / ((t0 + t1) * 44100 * 2)); + WriteLn(Format('Peak performance: FFT+IFFT on %d mono channels at 44.1 KHz (with overlapping)', [nbr_s_chn])); + WriteLn; + + FreeMem(x); + FreeMem(f); + fft.Free; + + WriteLn('Press [Return] key to terminate...'); + ReadLn; +end. diff --git a/demos/spectrum/spectrum.pri b/demos/spectrum/spectrum.pri new file mode 100644 index 0000000..c09aa0d --- /dev/null +++ b/demos/spectrum/spectrum.pri @@ -0,0 +1,37 @@ +# The following macros allow certain features and debugging output +# to be disabled / enabled at compile time. + +# Debug output from spectrum calculation +DEFINES += LOG_SPECTRUMANALYSER + +# Debug output from waveform generation +#DEFINES += LOG_WAVEFORM + +# Debug output from engine +DEFINES += LOG_ENGINE + +# Dump input data to spectrum analyer, plus artefact data files +#DEFINES += DUMP_SPECTRUMANALYSER + +# Dump captured audio data +#DEFINES += DUMP_CAPTURED_AUDIO + +# Disable calculation of level +#DEFINES += DISABLE_LEVEL + +# Disable calculation of frequency spectrum +# If this macro is defined, the FFTReal DLL will not be built +#DEFINES += DISABLE_FFT + +# Disables rendering of the waveform +#DEFINES += DISABLE_WAVEFORM + +# If defined, superimpose the progress bar on the waveform +DEFINES += SUPERIMPOSE_PROGRESS_ON_WAVEFORM + +# Perform spectrum analysis calculation in a separate thread +DEFINES += SPECTRUM_ANALYSER_SEPARATE_THREAD + +# Suppress warnings about strncpy potentially being unsafe, emitted by MSVC +win32: DEFINES += _CRT_SECURE_NO_WARNINGS + diff --git a/demos/spectrum/spectrum.pro b/demos/spectrum/spectrum.pro new file mode 100644 index 0000000..823f610 --- /dev/null +++ b/demos/spectrum/spectrum.pro @@ -0,0 +1,39 @@ +include(spectrum.pri) + +TEMPLATE = subdirs + +# Ensure that library is built before application +CONFIG += ordered + +!contains(DEFINES, DISABLE_FFT) { + SUBDIRS += fftreal +} + +SUBDIRS += app + +TARGET = spectrum + +symbian { + # Create a 'make sis' rule which can be run from the top-level + + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + # UID for the SIS file + TARGET.UID3 = 0xA000E3FA + + epoc32_dir = $${EPOCROOT}epoc32 + release_dir = $${epoc32_dir}/release/$(PLATFORM)/$(TARGET) + + bin.sources = $${release_dir}/spectrum.exe + !contains(DEFINES, DISABLE_FFT) { + bin.sources += $${release_dir}/fftreal.dll + } + bin.path = !:/sys/bin + rsc.sources = $${epoc32_dir}/data/z/resource/apps/spectrum.rsc + rsc.path = !:/resource/apps + mif.sources = $${epoc32_dir}/data/z/resource/apps/spectrum.mif + mif.path = !:/resource/apps + reg_rsc.sources = $${epoc32_dir}/data/z/private/10003a3f/import/apps/spectrum_reg.rsc + reg_rsc.path = !:/private/10003a3f/import/apps + DEPLOYMENT += bin rsc mif reg_rsc +} -- cgit v0.12 From 74a0f7526c5df992c2f2b7882d355f77076c33bd Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 5 May 2010 11:47:08 +0200 Subject: coding style changes in qmenu_wince.cpp --- src/gui/widgets/qmenu_wince.cpp | 127 +++++++++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 48 deletions(-) diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp index 1577f0a..ea313f1 100644 --- a/src/gui/widgets/qmenu_wince.cpp +++ b/src/gui/widgets/qmenu_wince.cpp @@ -133,7 +133,8 @@ static void qt_wce_disable_soft_key(HWND handle, uint command) ptrEnableSoftKey(handle, command, false, false); } -static void qt_wce_delete_action_list(QList *list) { +static void qt_wce_delete_action_list(QList *list) +{ for(QList::Iterator it = list->begin(); it != list->end(); ++it) { QWceMenuAction *action = (*it); delete action; @@ -143,7 +144,8 @@ static void qt_wce_delete_action_list(QList *list) { } //search for first QuitRole in QMenuBar -static QAction* qt_wce_get_quit_action(QList actionItems) { +static QAction* qt_wce_get_quit_action(QList actionItems) +{ QAction *returnAction = 0; for (int i = 0; i < actionItems.size(); ++i) { QAction *action = actionItems.at(i); @@ -158,7 +160,8 @@ static QAction* qt_wce_get_quit_action(QList actionItems) { return 0; //nothing found; } -static QAction* qt_wce_get_quit_action(QList actionItems) { +static QAction* qt_wce_get_quit_action(QList actionItems) +{ for (int i = 0; i < actionItems.size(); ++i) { if (actionItems.at(i)->action->menuRole() == QAction::QuitRole) return actionItems.at(i)->action; @@ -171,7 +174,8 @@ static QAction* qt_wce_get_quit_action(QList actionItems) { return 0; } -static HMODULE qt_wce_get_module_handle() { +static HMODULE qt_wce_get_module_handle() +{ HMODULE module = 0; //handle to resources if (!(module = GetModuleHandle(L"QtGui4"))) //release dynamic if (!(module = GetModuleHandle(L"QtGuid4"))) //debug dynamic @@ -180,7 +184,8 @@ static HMODULE qt_wce_get_module_handle() { return module; } -static void qt_wce_change_command(HWND menuHandle, int item, int command) { +static void qt_wce_change_command(HWND menuHandle, int item, int command) +{ TBBUTTONINFOA tbbi; memset(&tbbi,0,sizeof(tbbi)); tbbi.cbSize = sizeof(tbbi); @@ -189,7 +194,8 @@ TBBUTTONINFOA tbbi; SendMessage(menuHandle, TB_SETBUTTONINFO, item, (LPARAM)&tbbi); } -static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &newText) { +static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &newText) +{ TBBUTTONINFOA tbbi; memset(&tbbi,0,sizeof(tbbi)); tbbi.cbSize = sizeof(tbbi); @@ -200,7 +206,8 @@ static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &ne SendMessage(menuHandle, TB_SETBUTTONINFO, item, (LPARAM)&tbbi); } -static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, int toolbarID, int flags = 0) { +static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, int toolbarID, int flags = 0) +{ resolveAygLibs(); if (ptrCreateMenuBar) { @@ -225,8 +232,8 @@ static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, i return 0; } -static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action, bool created) { - +static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action, bool created) +{ Q_ASSERT_X(menu, "AppendMenu", "menu is 0"); if (action->action->isVisible()) { int flags; @@ -265,12 +272,14 @@ static void qt_wce_clear_menu(HMENU hMenu) This function refreshes the native Windows CE menu. */ -void QMenuBar::wceRefresh() { +void QMenuBar::wceRefresh() +{ for (int i = 0; i < nativeMenuBars.size(); ++i) nativeMenuBars.at(i)->d_func()->wceRefresh(); } -void QMenuBarPrivate::wceRefresh() { +void QMenuBarPrivate::wceRefresh() +{ DrawMenuBar(wce_menubar->menubarHandle); } @@ -280,7 +289,8 @@ void QMenuBarPrivate::wceRefresh() { This function sends native Windows CE commands to Qt menus. */ -QAction* QMenu::wceCommands(uint command) { +QAction* QMenu::wceCommands(uint command) +{ Q_D(QMenu); return d->wceCommands(command); } @@ -292,12 +302,14 @@ QAction* QMenu::wceCommands(uint command) { and all their child menus. */ -void QMenuBar::wceCommands(uint command, HWND) { +void QMenuBar::wceCommands(uint command, HWND) +{ for (int i = 0; i < nativeMenuBars.size(); ++i) nativeMenuBars.at(i)->d_func()->wceCommands(command); } -bool QMenuBarPrivate::wceEmitSignals(QList actions, uint command) { +bool QMenuBarPrivate::wceEmitSignals(QList actions, uint command) +{ QAction *foundAction = 0; for (int i = 0; i < actions.size(); ++i) { if (foundAction) @@ -319,13 +331,14 @@ bool QMenuBarPrivate::wceEmitSignals(QList actions, uint comman return false; } -void QMenuBarPrivate::wceCommands(uint command) { +void QMenuBarPrivate::wceCommands(uint command) +{ if (wceClassicMenu) { for (int i = 0; i < wce_menubar->actionItemsClassic.size(); ++i) wceEmitSignals(wce_menubar->actionItemsClassic.at(i), command); } else { if (wceEmitSignals(wce_menubar->actionItems, command)) { - return ; + return; } else if (wce_menubar->leftButtonIsMenu) {//check if command is on the left quick button wceEmitSignals(wce_menubar->actionItemsLeftButton, command); @@ -337,7 +350,8 @@ void QMenuBarPrivate::wceCommands(uint command) { } } -QAction *QMenuPrivate::wceCommands(uint command) { +QAction *QMenuPrivate::wceCommands(uint command) +{ QAction *foundAction = 0; for (int i = 0; i < wce_menu->actionItems.size(); ++i) { if (foundAction) @@ -356,8 +370,8 @@ QAction *QMenuPrivate::wceCommands(uint command) { return foundAction; } -void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent) { - +void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent) +{ Q_Q(QMenuBar); wce_menubar = new QWceMenuBarPrivate(this); @@ -371,21 +385,25 @@ void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent) { wceClassicMenu = (!qt_wince_is_smartphone() && !qt_wince_is_pocket_pc()); } -void QMenuBarPrivate::wceDestroyMenuBar() { +void QMenuBarPrivate::wceDestroyMenuBar() +{ Q_Q(QMenuBar); int index = nativeMenuBars.indexOf(q); nativeMenuBars.removeAt(index); - if (wce_menubar) - delete wce_menubar; - wce_menubar = 0; + if (wce_menubar) { + delete wce_menubar; + wce_menubar = 0; + } } -QMenuBarPrivate::QWceMenuBarPrivate::QWceMenuBarPrivate(QMenuBarPrivate *menubar) : - menubarHandle(0), menuHandle(0),leftButtonMenuHandle(0) , - leftButtonAction(0), leftButtonIsMenu(false), d(menubar) { +QMenuBarPrivate::QWceMenuBarPrivate::QWceMenuBarPrivate(QMenuBarPrivate *menubar) +: menubarHandle(0), menuHandle(0), leftButtonMenuHandle(0), + leftButtonAction(0), leftButtonIsMenu(false), d(menubar) +{ } -QMenuBarPrivate::QWceMenuBarPrivate::~QWceMenuBarPrivate() { +QMenuBarPrivate::QWceMenuBarPrivate::~QWceMenuBarPrivate() +{ if (menubarHandle) DestroyWindow(menubarHandle); qt_wce_delete_action_list(&actionItems); @@ -403,24 +421,28 @@ QMenuBarPrivate::QWceMenuBarPrivate::~QWceMenuBarPrivate() { QMenuBar::wceRefresh(); } -QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate() { - menuHandle = 0; +QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate() +: menuHandle(0) +{ } -QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate() { +QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate() +{ qt_wce_delete_action_list(&actionItems); if (menuHandle) DestroyMenu(menuHandle); } -void QMenuPrivate::QWceMenuPrivate::addAction(QAction *a, QWceMenuAction *before) { +void QMenuPrivate::QWceMenuPrivate::addAction(QAction *a, QWceMenuAction *before) +{ QWceMenuAction *action = new QWceMenuAction; action->action = a; action->command = qt_wce_menu_static_cmd_id++; addAction(action, before); } -void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) { +void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) +{ if (!action) return; int before_index = actionItems.indexOf(before); @@ -439,9 +461,13 @@ void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAc Windows CE menu bar bindings. */ -HMENU QMenu::wceMenu(bool create) { return d_func()->wceMenu(create); } +HMENU QMenu::wceMenu(bool create) +{ + return d_func()->wceMenu(create); +} -HMENU QMenuPrivate::wceMenu(bool create) { +HMENU QMenuPrivate::wceMenu(bool create) +{ if (!wce_menu) wce_menu = new QWceMenuPrivate; if (!wce_menu->menuHandle || create) @@ -464,25 +490,28 @@ void QMenuPrivate::QWceMenuPrivate::rebuild() QMenuBar::wceRefresh(); } -void QMenuPrivate::QWceMenuPrivate::syncAction(QWceMenuAction *) { +void QMenuPrivate::QWceMenuPrivate::syncAction(QWceMenuAction *) +{ rebuild(); } -void QMenuPrivate::QWceMenuPrivate::removeAction(QWceMenuAction *action) { - actionItems.removeAll(action); - delete action; - action = 0; - rebuild(); +void QMenuPrivate::QWceMenuPrivate::removeAction(QWceMenuAction *action) +{ + actionItems.removeAll(action); + delete action; + rebuild(); } -void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QWceMenuAction *before) { +void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QWceMenuAction *before) +{ QWceMenuAction *action = new QWceMenuAction; action->action = a; action->command = qt_wce_menu_static_cmd_id++; addAction(action, before); } -void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) { +void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) +{ if (!action) return; int before_index = actionItems.indexOf(before); @@ -494,25 +523,27 @@ void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWce rebuild(); } -void QMenuBarPrivate::QWceMenuBarPrivate::syncAction(QWceMenuAction*) { +void QMenuBarPrivate::QWceMenuBarPrivate::syncAction(QWceMenuAction*) +{ QMenuBar::wceRefresh(); rebuild(); } -void QMenuBarPrivate::QWceMenuBarPrivate::removeAction(QWceMenuAction *action) { +void QMenuBarPrivate::QWceMenuBarPrivate::removeAction(QWceMenuAction *action) +{ actionItems.removeAll(action); delete action; - action = 0; rebuild(); } -void QMenuBarPrivate::_q_updateDefaultAction() { +void QMenuBarPrivate::_q_updateDefaultAction() +{ if (wce_menubar) wce_menubar->rebuild(); } -void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() { - +void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() +{ d->q_func()->resize(0,0); parentWindowHandle = d->q_func()->parentWidget() ? d->q_func()->parentWidget()->winId() : d->q_func()->winId(); if (d->wceClassicMenu) { -- cgit v0.12 From 1e10fced4ceb59455b19f5e054b480f91aad273d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 5 May 2010 12:16:53 +0200 Subject: WinCE: QMenuBar::triggered(QAction*) was emitted too often Calling QMenuPrivate::activateAction instead of QAction::activate makes use of the internal recursion guard and fixes this problem. Also emitting QMenuBar::triggered in the command-in-menu-bar case will QAction::activate do for us. Task-number: QTBUG-10358 Reviewed-by: thartman --- src/gui/widgets/qmenu_wince.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp index ea313f1..37ff4c4 100644 --- a/src/gui/widgets/qmenu_wince.cpp +++ b/src/gui/widgets/qmenu_wince.cpp @@ -312,14 +312,13 @@ bool QMenuBarPrivate::wceEmitSignals(QList actions, uint comman { QAction *foundAction = 0; for (int i = 0; i < actions.size(); ++i) { - if (foundAction) - break; QWceMenuAction *action = actions.at(i); if (action->action->menu()) { foundAction = action->action->menu()->wceCommands(command); + if (foundAction) + break; } else if (action->command == command) { - emit q_func()->triggered(action->action); action->action->activate(QAction::Trigger); return true; } @@ -361,7 +360,7 @@ QAction *QMenuPrivate::wceCommands(uint command) foundAction = action->action->menu()->d_func()->wceCommands(command); } else if (action->command == command) { - action->action->activate(QAction::Trigger); + activateAction(action->action, QAction::Trigger); return action->action; } } -- cgit v0.12 From 3fb8a253c0f7823c07dc2f716c12540ff421cabb Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Wed, 5 May 2010 14:07:01 +0300 Subject: QS60Style: QCalendarWidget draws only one-digit dates Due to largish pixel metrics values for text margins, content does not fit into QCalendarWidget date-cells. To fix this, the failing pixel metric values are halved for QTableViews and its derivatives. This matches native margins almost perfectly (depending on native layout 1-2 pixel offset). Task-number: QTBUG-10417 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 20297ae..f32bd5e 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -653,6 +653,8 @@ void QS60StylePrivate::setFont(QWidget *widget) const fontCategory = QS60StyleEnums::FC_Primary; } else if (qobject_cast(widget)){ fontCategory = QS60StyleEnums::FC_Primary; + } else if (qobject_cast(widget)){ + fontCategory = QS60StyleEnums::FC_Secondary; } if (fontCategory != QS60StyleEnums::FC_Undefined) { const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) @@ -2478,6 +2480,12 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const //double the top layout margin for dialogs, it is very close to real value //without having to define custom pixel metric metricValue *= 2; + + if (widget && (metric == PM_FocusFrameHMargin)) + if (qobject_cast(widget)) + //Halve the focus frame margin for table items + metricValue /= 2; + return metricValue; } -- cgit v0.12 From 95a69f37ec156a2506b140e5e349bb7f68e112a5 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 26 Apr 2010 14:33:05 +0200 Subject: QHostInfo: Immediately delete aborted lookup requests. Reviewed-by: Thiago --- src/network/kernel/qhostinfo.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index f287630..fd39347 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -596,6 +596,23 @@ void QHostInfoLookupManager::abortLookup(int id) return; QMutexLocker locker(&this->mutex); + + // is postponed? delete and return + for (int i = 0; i < postponedLookups.length(); i++) { + if (postponedLookups.at(i)->id == id) { + delete postponedLookups.takeAt(i); + return; + } + } + + // is scheduled? delete and return + for (int i = 0; i < scheduledLookups.length(); i++) { + if (scheduledLookups.at(i)->id == id) { + delete scheduledLookups.takeAt(i); + return; + } + } + if (!abortedLookups.contains(id)) abortedLookups.append(id); } -- cgit v0.12 From ff2b6ddfd2763b6b365c7466d51a1e2374e4bd4b Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 5 May 2010 12:37:21 +0200 Subject: QHostInfo: Emit postponed lookup results when finishing current Reviewed-by: Thiago --- src/network/kernel/qhostinfo.cpp | 12 ++++++++++++ src/network/kernel/qhostinfo_p.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index fd39347..28a6c84 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -471,6 +471,18 @@ void QHostInfoRunnable::run() hostInfo.setLookupId(id); resultEmitter.emitResultsReady(hostInfo); + // now also iterate through the postponed ones + QMutableListIterator iterator(manager->postponedLookups); + while (iterator.hasNext()) { + QHostInfoRunnable* postponed = iterator.next(); + if (toBeLookedUp == postponed->toBeLookedUp) { + // we can now emit + iterator.remove(); + hostInfo.setLookupId(postponed->id); + postponed->resultEmitter.emitResultsReady(hostInfo); + } + } + manager->lookupFinished(this); // thread goes back to QThreadPool diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index e11766b..af270d8 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -173,6 +173,8 @@ public: bool wasAborted(int id); QHostInfoCache cache; + + friend class QHostInfoRunnable; protected: QList currentLookups; // in progress QList postponedLookups; // postponed because in progress for same host -- cgit v0.12 From 260212083c19e76e8e53dfe2ae44de70003769d7 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 5 May 2010 14:13:24 +0200 Subject: QHostInfo: Avoid one tiny copy of QHostInfo object when emitting Thanks rittk! Reviewed-by: Olivier --- src/network/kernel/qhostinfo_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index af270d8..85d14c2 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -84,7 +84,7 @@ public Q_SLOTS: } Q_SIGNALS: - void resultsReady(const QHostInfo info); + void resultsReady(const QHostInfo &info); }; // needs to be QObject because fromName calls tr() -- cgit v0.12 From 6bc32600d2367e78ddc39dd93694e01d4d75958d Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 5 May 2010 13:59:31 +0200 Subject: Don't leak QVistaHelper from QWizard The default QObject constructor was not called, meaning the vista helper was never registered as a child of the QWizard (and therefore never deleted when the QWizard was destructed). Task-number: QTBUG-10203 Reviewed-by: olivier --- src/gui/dialogs/qwizard_win.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp index 1390b21..e406cba 100644 --- a/src/gui/dialogs/qwizard_win.cpp +++ b/src/gui/dialogs/qwizard_win.cpp @@ -237,7 +237,8 @@ void QVistaBackButton::paintEvent(QPaintEvent *) */ QVistaHelper::QVistaHelper(QWizard *wizard) - : pressed(false) + : QObject(wizard) + , pressed(false) , wizard(wizard) , backButton_(0) { -- cgit v0.12 From c7ba0460fe21647181d2ff8c812ddea0e74a2768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 4 May 2010 15:41:42 +0200 Subject: Pack Graphics View booleans in quint32 bit fields. Reduces the memory footprint of a typical GV application by 27 * sizeof(bool). Nothing revolutionary, but you know, every byte counts :-) Reviewed-by: Jan-Arve --- src/gui/graphicsview/qgraphicsscene.cpp | 16 ++++++------- src/gui/graphicsview/qgraphicsscene_p.h | 40 ++++++++++++++++----------------- src/gui/graphicsview/qgraphicsview.cpp | 17 +++++++------- src/gui/graphicsview/qgraphicsview_p.h | 29 +++++++++++++----------- 4 files changed, 53 insertions(+), 49 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 0d4e48a..36fd5c8 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -290,13 +290,19 @@ QGraphicsScenePrivate::QGraphicsScenePrivate() updateAll(false), calledEmitUpdated(false), processDirtyItemsEmitted(false), - selectionChanging(0), needSortTopLevelItems(true), holesInTopLevelSiblingIndex(false), topLevelSequentialOrdering(true), scenePosDescendantsUpdatePending(false), stickyFocus(false), hasFocus(false), + lastMouseGrabberItemHasImplicitMouseGrab(false), + allItemsIgnoreHoverEvents(true), + allItemsUseDefaultCursor(true), + painterStateProtection(true), + sortCacheEnabled(false), + allItemsIgnoreTouchEvents(true), + selectionChanging(0), rectAdjust(2), focusItem(0), lastFocusItem(0), @@ -306,16 +312,10 @@ QGraphicsScenePrivate::QGraphicsScenePrivate() activationRefCount(0), childExplicitActivation(0), lastMouseGrabberItem(0), - lastMouseGrabberItemHasImplicitMouseGrab(false), dragDropItem(0), enterWidget(0), lastDropAction(Qt::IgnoreAction), - allItemsIgnoreHoverEvents(true), - allItemsUseDefaultCursor(true), - painterStateProtection(true), - sortCacheEnabled(false), - style(0), - allItemsIgnoreTouchEvents(true) + style(0) { } diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 0a85f0e..77bf450 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -97,24 +97,36 @@ public: int lastItemCount; QRectF sceneRect; - bool hasSceneRect; - bool dirtyGrowingItemsBoundingRect; + + quint32 hasSceneRect : 1; + quint32 dirtyGrowingItemsBoundingRect : 1; + quint32 updateAll : 1; + quint32 calledEmitUpdated : 1; + quint32 processDirtyItemsEmitted : 1; + quint32 needSortTopLevelItems : 1; + quint32 holesInTopLevelSiblingIndex : 1; + quint32 topLevelSequentialOrdering : 1; + quint32 scenePosDescendantsUpdatePending : 1; + quint32 stickyFocus : 1; + quint32 hasFocus : 1; + quint32 lastMouseGrabberItemHasImplicitMouseGrab : 1; + quint32 allItemsIgnoreHoverEvents : 1; + quint32 allItemsUseDefaultCursor : 1; + quint32 painterStateProtection : 1; + quint32 sortCacheEnabled : 1; // for compatibility + quint32 allItemsIgnoreTouchEvents : 1; + quint32 padding : 15; + QRectF growingItemsBoundingRect; void _q_emitUpdated(); QList updatedRects; - bool updateAll; - bool calledEmitUpdated; - bool processDirtyItemsEmitted; QPainterPath selectionArea; int selectionChanging; QSet selectedItems; QVector unpolishedItems; QList topLevelItems; - bool needSortTopLevelItems; - bool holesInTopLevelSiblingIndex; - bool topLevelSequentialOrdering; QMap movingItemsInitialPositions; void registerTopLevelItem(QGraphicsItem *item); @@ -125,7 +137,6 @@ public: void _q_processDirtyItems(); QSet scenePosItems; - bool scenePosDescendantsUpdatePending; void setScenePosItemEnabled(QGraphicsItem *item, bool enabled); void registerScenePosItem(QGraphicsItem *item); void unregisterScenePosItem(QGraphicsItem *item); @@ -136,9 +147,6 @@ public: QBrush backgroundBrush; QBrush foregroundBrush; - quint32 stickyFocus : 1; - quint32 hasFocus : 1; - quint32 padding : 30; quint32 rectAdjust; QGraphicsItem *focusItem; QGraphicsItem *lastFocusItem; @@ -155,7 +163,6 @@ public: void removePopup(QGraphicsWidget *widget, bool itemIsDying = false); QGraphicsItem *lastMouseGrabberItem; - bool lastMouseGrabberItemHasImplicitMouseGrab; QList mouseGrabberItems; void grabMouse(QGraphicsItem *item, bool implicit = false); void ungrabMouse(QGraphicsItem *item, bool itemIsDying = false); @@ -172,8 +179,6 @@ public: QList cachedItemsUnderMouse; QList hoverItems; QPointF lastSceneMousePos; - bool allItemsIgnoreHoverEvents; - bool allItemsUseDefaultCursor; void enableMouseTrackingOnViews(); QMap mouseGrabberButtonDownPos; QMap mouseGrabberButtonDownScenePos; @@ -187,8 +192,6 @@ public: void addView(QGraphicsView *view); void removeView(QGraphicsView *view); - bool painterStateProtection; - QMultiMap sceneEventFilters; void installSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter); void removeSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter); @@ -210,8 +213,6 @@ public: void mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent); QGraphicsWidget *windowForItem(const QGraphicsItem *item) const; - bool sortCacheEnabled; // for compatibility - void drawItemHelper(QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget, bool painterStateProtection); @@ -295,7 +296,6 @@ public: int findClosestTouchPointId(const QPointF &scenePos); void touchEventHandler(QTouchEvent *touchEvent); bool sendTouchBeginEvent(QGraphicsItem *item, QTouchEvent *touchEvent); - bool allItemsIgnoreTouchEvents; void enableTouchEventsOnViews(); QList cachedTargetItems; diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 0bba7e9..96d5ba1 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -327,16 +327,20 @@ QGraphicsViewPrivate::QGraphicsViewPrivate() dragMode(QGraphicsView::NoDrag), sceneInteractionAllowed(true), hasSceneRect(false), connectedToScene(false), - mousePressButton(Qt::NoButton), + useLastMouseEvent(false), identityMatrix(true), dirtyScroll(true), accelerateScrolling(true), + keepLastCenterPoint(true), + transforming(false), + handScrolling(false), + mustAllocateStyleOptions(false), + mustResizeBackgroundPixmap(true), + fullUpdatePending(true), + mousePressButton(Qt::NoButton), leftIndent(0), topIndent(0), lastMouseEvent(QEvent::None, QPoint(), Qt::NoButton, 0, 0), - useLastMouseEvent(false), - keepLastCenterPoint(true), alignment(Qt::AlignCenter), - transforming(false), transformationAnchor(QGraphicsView::AnchorViewCenter), resizeAnchor(QGraphicsView::NoAnchor), viewportUpdateMode(QGraphicsView::MinimalViewportUpdate), optimizationFlags(0), @@ -345,14 +349,11 @@ QGraphicsViewPrivate::QGraphicsViewPrivate() rubberBanding(false), rubberBandSelectionMode(Qt::IntersectsItemShape), #endif - handScrolling(false), handScrollMotions(0), cacheMode(0), - mustAllocateStyleOptions(false), - mustResizeBackgroundPixmap(true), + handScrollMotions(0), cacheMode(0), #ifndef QT_NO_CURSOR hasStoredOriginalCursor(false), #endif lastDragDropEvent(0), - fullUpdatePending(true), updateSceneSlotReimplementedChecked(false) { styleOptions.reserve(QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS); diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h index aeff28a..1239ca4 100644 --- a/src/gui/graphicsview/qgraphicsview_p.h +++ b/src/gui/graphicsview/qgraphicsview_p.h @@ -77,11 +77,24 @@ public: QPainter::RenderHints renderHints; QGraphicsView::DragMode dragMode; - bool sceneInteractionAllowed; + + quint32 sceneInteractionAllowed : 1; + quint32 hasSceneRect : 1; + quint32 connectedToScene : 1; + quint32 useLastMouseEvent : 1; + quint32 identityMatrix : 1; + quint32 dirtyScroll : 1; + quint32 accelerateScrolling : 1; + quint32 keepLastCenterPoint : 1; + quint32 transforming : 1; + quint32 handScrolling : 1; + quint32 mustAllocateStyleOptions : 1; + quint32 mustResizeBackgroundPixmap : 1; + quint32 fullUpdatePending : 1; + quint32 padding : 19; + QRectF sceneRect; - bool hasSceneRect; void updateLastCenterPoint(); - bool connectedToScene; qint64 horizontalScroll() const; qint64 verticalScroll() const; @@ -98,26 +111,20 @@ public: QPoint dirtyScrollOffset; Qt::MouseButton mousePressButton; QTransform matrix; - bool identityMatrix; qint64 scrollX, scrollY; - bool dirtyScroll; void updateScroll(); - bool accelerateScrolling; qreal leftIndent; qreal topIndent; // Replaying mouse events QMouseEvent lastMouseEvent; - bool useLastMouseEvent; void replayLastMouseEvent(); void storeMouseEvent(QMouseEvent *event); void mouseMoveEventHandler(QMouseEvent *event); QPointF lastCenterPoint; - bool keepLastCenterPoint; Qt::Alignment alignment; - bool transforming; QGraphicsView::ViewportAnchor transformationAnchor; QGraphicsView::ViewportAnchor resizeAnchor; @@ -131,20 +138,17 @@ public: bool rubberBanding; Qt::ItemSelectionMode rubberBandSelectionMode; #endif - bool handScrolling; int handScrollMotions; QGraphicsView::CacheMode cacheMode; QVector styleOptions; - bool mustAllocateStyleOptions; QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems); void freeStyleOptionsArray(QStyleOptionGraphicsItem *array); QBrush backgroundBrush; QBrush foregroundBrush; QPixmap backgroundPixmap; - bool mustResizeBackgroundPixmap; QRegion backgroundPixmapExposed; #ifndef QT_NO_CURSOR @@ -161,7 +165,6 @@ public: QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const; QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const; - bool fullUpdatePending; QRegion dirtyRegion; QRect dirtyBoundingRect; void processPendingUpdates(); -- cgit v0.12 From 66f1a007291209781801a2d3d5f4009bb1963955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 5 May 2010 14:02:54 +0200 Subject: Fixes crash in QGraphicsItem::mouseMove for untransformable items. Caused by: 253b87180e0a6c5db0feaaed7e321139c4ff1643 Reviewed-by: Yoann --- src/gui/graphicsview/qgraphicsitem.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 81138d9..b8c240a 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7132,7 +7132,11 @@ void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) // calculate their diff by mapping viewport coordinates // directly to parent coordinates. // COMBINE - QTransform viewToParentTransform = (item->d_func()->transformData->computedFullTransform().translate(item->d_ptr->pos.x(), item->d_ptr->pos.y())) + QTransform itemTransform; + if (item->d_ptr->transformData) + itemTransform = item->d_ptr->transformData->computedFullTransform(); + itemTransform.translate(item->d_ptr->pos.x(), item->d_ptr->pos.y()); + QTransform viewToParentTransform = itemTransform * (item->sceneTransform() * view->viewportTransform()).inverted(); currentParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->screenPos()))); buttonDownParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton)))); -- cgit v0.12 From c1c7dbf2a066868503dfabcd7113856fa6d2e457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 4 May 2010 13:14:10 +0200 Subject: Performance issue with QGraphicsItem::ItemClipsChildrenToShape. If the child rect is bigger than the parent rect and parent has the ItemClipsChildrenToShape flag set, then by updating the child, the whole child rect is marked as dirty, resulting in a much larger update area than required. This has a major impact on performance in Orbit/HB, where e.g. item-views typically consist of a container item that clips its children/items to shape. See attached video in QTBUG-9024. Auto test included. Task-number: QTBUG-9024 --- src/gui/graphicsview/qgraphicsitem.cpp | 20 ++++++++- src/gui/graphicsview/qgraphicsitem_p.h | 1 + src/gui/graphicsview/qgraphicsscene.cpp | 14 +++++- src/gui/graphicsview/qgraphicsview.cpp | 59 +++++++++++++++++++++++++- src/gui/graphicsview/qgraphicsview_p.h | 6 ++- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 57 +++++++++++++++++++++++++ 6 files changed, 152 insertions(+), 5 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index b8c240a..65edb2a 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1812,7 +1812,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable); bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask); if (fullUpdate) - d_ptr->paintedViewBoundingRectsNeedRepaint = 1; + d_ptr->updatePaintedViewBoundingRects(/*children=*/true); // Keep the old flags to compare the diff. GraphicsItemFlags oldFlags = GraphicsItemFlags(d_ptr->flags); @@ -5432,6 +5432,24 @@ void QGraphicsItemPrivate::removeExtraItemCache() unsetExtra(ExtraCacheData); } +void QGraphicsItemPrivate::updatePaintedViewBoundingRects(bool updateChildren) +{ + if (!scene) + return; + + for (int i = 0; i < scene->d_func()->views.size(); ++i) { + QGraphicsViewPrivate *viewPrivate = scene->d_func()->views.at(i)->d_func(); + QRect rect = paintedViewBoundingRects.value(viewPrivate->viewport); + rect.translate(viewPrivate->dirtyScrollOffset); + viewPrivate->updateRect(rect); + } + + if (updateChildren) { + for (int i = 0; i < children.size(); ++i) + children.at(i)->d_ptr->updatePaintedViewBoundingRects(true); + } +} + // Traverses all the ancestors up to the top-level and updates the pointer to // always point to the top-most item that has a dirty scene transform. // It then backtracks to the top-most dirty item and start calculating the diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 569a329..e812f29 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -377,6 +377,7 @@ public: QGraphicsItemCache *extraItemCache() const; void removeExtraItemCache(); + void updatePaintedViewBoundingRects(bool updateChildren); void ensureSceneTransformRecursive(QGraphicsItem **topMostDirtyItem); inline void ensureSceneTransform() { diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 36fd5c8..dfba7c9 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5116,9 +5116,15 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool // Process children. if (itemHasChildren && item->d_ptr->dirtyChildren) { + const bool itemClipsChildrenToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape; + if (itemClipsChildrenToShape) { + // Make sure child updates are clipped to the item's bounding rect. + for (int i = 0; i < views.size(); ++i) + views.at(i)->d_func()->setUpdateClip(item); + } if (!dirtyAncestorContainsChildren) { dirtyAncestorContainsChildren = item->d_ptr->fullUpdatePending - && (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape); + && itemClipsChildrenToShape; } const bool allChildrenDirty = item->d_ptr->allChildrenDirty; const bool parentIgnoresVisible = item->d_ptr->ignoreVisible; @@ -5141,6 +5147,12 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool } processDirtyItemsRecursive(child, dirtyAncestorContainsChildren, opacity); } + + if (itemClipsChildrenToShape) { + // Reset updateClip. + for (int i = 0; i < views.size(); ++i) + views.at(i)->d_func()->setUpdateClip(0); + } } else if (wasDirtyParentSceneTransform) { item->d_ptr->invalidateChildrenSceneTransform(); } diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 96d5ba1..0f951ef 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -337,6 +337,7 @@ QGraphicsViewPrivate::QGraphicsViewPrivate() mustAllocateStyleOptions(false), mustResizeBackgroundPixmap(true), fullUpdatePending(true), + hasUpdateClip(false), mousePressButton(Qt::NoButton), leftIndent(0), topIndent(0), lastMouseEvent(QEvent::None, QPoint(), Qt::NoButton, 0, 0), @@ -880,6 +881,52 @@ static inline void QRect_unite(QRect *rect, const QRect &other) } } +/* + Calling this function results in update rects being clipped to the item's + bounding rect. Note that updates prior to this function call is not clipped. + The clip is removed by passing 0. +*/ +void QGraphicsViewPrivate::setUpdateClip(QGraphicsItem *item) +{ + Q_Q(QGraphicsView); + // We simply ignore the request if the update mode is either FullViewportUpdate + // or NoViewportUpdate; in that case there's no point in clipping anything. + if (!item || viewportUpdateMode == QGraphicsView::NoViewportUpdate + || viewportUpdateMode == QGraphicsView::FullViewportUpdate) { + hasUpdateClip = false; + return; + } + + // Calculate the clip (item's bounding rect in view coordinates). + // Optimized version of: + // QRect clip = item->deviceTransform(q->viewportTransform()) + // .mapRect(item->boundingRect()).toAlignedRect(); + QRect clip; + if (item->d_ptr->itemIsUntransformable()) { + QTransform xform = item->deviceTransform(q->viewportTransform()); + clip = xform.mapRect(item->boundingRect()).toAlignedRect(); + } else if (item->d_ptr->sceneTransformTranslateOnly && identityMatrix) { + QRectF r(item->boundingRect()); + r.translate(item->d_ptr->sceneTransform.dx() - horizontalScroll(), + item->d_ptr->sceneTransform.dy() - verticalScroll()); + clip = r.toAlignedRect(); + } else if (!q->isTransformed()) { + clip = item->d_ptr->sceneTransform.mapRect(item->boundingRect()).toAlignedRect(); + } else { + QTransform xform = item->d_ptr->sceneTransform; + xform *= q->viewportTransform(); + clip = xform.mapRect(item->boundingRect()).toAlignedRect(); + } + + if (hasUpdateClip) { + // Intersect with old clip. + updateClip &= clip; + } else { + updateClip = clip; + hasUpdateClip = true; + } +} + bool QGraphicsViewPrivate::updateRegion(const QRectF &rect, const QTransform &xform) { if (rect.isEmpty()) @@ -910,6 +957,8 @@ bool QGraphicsViewPrivate::updateRegion(const QRectF &rect, const QTransform &xf viewRect.adjust(-1, -1, 1, 1); else viewRect.adjust(-2, -2, 2, 2); + if (hasUpdateClip) + viewRect &= updateClip; dirtyRegion += viewRect; } @@ -931,7 +980,10 @@ bool QGraphicsViewPrivate::updateRect(const QRect &r) viewport->update(); break; case QGraphicsView::BoundingRectViewportUpdate: - QRect_unite(&dirtyBoundingRect, r); + if (hasUpdateClip) + QRect_unite(&dirtyBoundingRect, r & updateClip); + else + QRect_unite(&dirtyBoundingRect, r); if (containsViewport(dirtyBoundingRect, viewport->width(), viewport->height())) { fullUpdatePending = true; viewport->update(); @@ -939,7 +991,10 @@ bool QGraphicsViewPrivate::updateRect(const QRect &r) break; case QGraphicsView::SmartViewportUpdate: // ### DEPRECATE case QGraphicsView::MinimalViewportUpdate: - dirtyRegion += r; + if (hasUpdateClip) + dirtyRegion += r & updateClip; + else + dirtyRegion += r; break; default: break; diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h index 1239ca4..7bd9ecb 100644 --- a/src/gui/graphicsview/qgraphicsview_p.h +++ b/src/gui/graphicsview/qgraphicsview_p.h @@ -91,7 +91,8 @@ public: quint32 mustAllocateStyleOptions : 1; quint32 mustResizeBackgroundPixmap : 1; quint32 fullUpdatePending : 1; - quint32 padding : 19; + quint32 hasUpdateClip : 1; + quint32 padding : 18; QRectF sceneRect; void updateLastCenterPoint(); @@ -102,6 +103,7 @@ public: QRectF mapRectToScene(const QRect &rect) const; QRectF mapRectFromScene(const QRectF &rect) const; + QRect updateClip; QPointF mousePressItemPoint; QPointF mousePressScenePoint; QPoint mousePressViewPoint; @@ -195,6 +197,8 @@ public: #endif } + void setUpdateClip(QGraphicsItem *); + inline bool updateRectF(const QRectF &rect) { if (rect.isEmpty()) diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 1df9a37..b8df7f6 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -218,6 +218,7 @@ private slots: void update(); void update2_data(); void update2(); + void update_ancestorClipsChildrenToShape(); void inputMethodSensitivity(); void inputContextReset(); void indirectPainting(); @@ -3758,6 +3759,62 @@ void tst_QGraphicsView::update2() #endif } +void tst_QGraphicsView::update_ancestorClipsChildrenToShape() +{ + QGraphicsScene scene(-150, -150, 300, 300); + + /* + Add three rects: + + +------------------+ + | child | + | +--------------+ | + | | parent | | + | | +-----------+ | + | | |grandParent| | + | | +-----------+ | + | +--------------+ | + +------------------+ + + ... where both the parent and the grand parent clips children to shape. + */ + QApplication::processEvents(); // Get rid of pending update. + + QGraphicsRectItem *grandParent = static_cast(scene.addRect(0, 0, 50, 50)); + grandParent->setBrush(Qt::black); + grandParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + + QGraphicsRectItem *parent = static_cast(scene.addRect(-50, -50, 100, 100)); + parent->setBrush(QColor(0, 0, 255, 125)); + parent->setParentItem(grandParent); + parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + + QGraphicsRectItem *child = static_cast(scene.addRect(-100, -100, 200, 200)); + child->setBrush(QColor(255, 0, 0, 125)); + child->setParentItem(parent); + + CustomView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(view.painted); + + view.lastUpdateRegions.clear(); + view.painted = false; + + // Call child->update() and make sure the updated area is within the ancestors' clip. + QRectF expected = child->deviceTransform(view.viewportTransform()).mapRect(child->boundingRect()); + expected &= grandParent->deviceTransform(view.viewportTransform()).mapRect(grandParent->boundingRect()); + + child->update(); + QTRY_VERIFY(view.painted); + +#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions + QTRY_VERIFY(view.painted); + QCOMPARE(view.lastUpdateRegions.size(), 1); + QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect())); +#endif +} + class FocusItem : public QGraphicsRectItem { public: -- cgit v0.12 From bfbf4d4ccdfb4cf35592c61674f6bffc28932787 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Wed, 5 May 2010 13:57:29 +0200 Subject: Fix build key on Windows with MinGW. Also, rebuilt configure.exe Reviewed-by: Thiago Macieira --- configure.exe | Bin 1318912 -> 1318912 bytes tools/configure/configureapp.cpp | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.exe b/configure.exe index 161fa1d..69e98dd 100755 Binary files a/configure.exe and b/configure.exe differ diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 79864f8..e264426 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2373,7 +2373,7 @@ void Configure::generateBuildKey() + buildSymbianKey + "\"\n" "#else\n" // Debug builds - "# if (defined(_DEBUG) || defined(DEBUG))\n" + "# if (!QT_NO_DEBUG)\n" "# if (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))\n" + build64Key.arg("debug") + "\"\n" "# else\n" -- cgit v0.12 From e52e699dc2ac01270daf8650c99659e251a88c38 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 5 May 2010 14:42:34 +0200 Subject: document that QMenuBar::setDefaultAction is only available on Win Mobile Task-number: QTBUG-8393 --- src/gui/widgets/qmenubar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index e368d3d..734ed70 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -1957,7 +1957,7 @@ bool QMenuBar::isNativeMenuBar() const to the right soft key. Currently there is only support for the default action on Windows - Mobile. All other platforms ignore the default action. + Mobile. On all other platforms this method is not available. \sa defaultAction() */ -- cgit v0.12 From 77f0d22d38ce188e75147237cc2f4dfff1aab5cb Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 5 May 2010 14:27:12 +0200 Subject: QNAM HTTP: Start more requests in once function call Reviewed-by: Peter Hartmann --- src/network/access/qhttpnetworkconnection.cpp | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 559124f..def4c34 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -716,6 +716,7 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) // This function must be called from the event loop. The only // exception is documented in QHttpNetworkConnectionPrivate::queueRequest +// although it is called _q_startNextRequest, it will actually start multiple requests when possible void QHttpNetworkConnectionPrivate::_q_startNextRequest() { //resend the necessary ones. @@ -733,26 +734,23 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest() // dequeue new ones - QAbstractSocket *socket = 0; + // return fast if there is nothing to do + if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty()) + return; + // try to get a free AND connected socket for (int i = 0; i < channelCount; ++i) { - QAbstractSocket *chSocket = channels[i].socket; - // try to get a free AND connected socket if (!channels[i].isSocketBusy() && channels[i].socket->state() == QAbstractSocket::ConnectedState) { - socket = chSocket; - dequeueAndSendRequest(socket); - break; + dequeueAndSendRequest(channels[i].socket); } } - if (!socket) { - for (int i = 0; i < channelCount; ++i) { - QAbstractSocket *chSocket = channels[i].socket; - // try to get a free unconnected socket - if (!channels[i].isSocketBusy()) { - socket = chSocket; - dequeueAndSendRequest(socket); - break; - } + // return fast if there is nothing to do + if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty()) + return; + // try to get a free unconnected socket + for (int i = 0; i < channelCount; ++i) { + if (!channels[i].isSocketBusy()) { + dequeueAndSendRequest(channels[i].socket); } } -- cgit v0.12 From b4bbb3d79a59c1225e1de58b6625f24de7df2013 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 5 May 2010 15:26:47 +0200 Subject: doc: Began reorganization of the top doc page. Much more to come. --- doc/src/frameworks-technologies/animation.qdoc | 1 + .../frameworks-technologies/eventsandfilters.qdoc | 3 ++- doc/src/frameworks-technologies/graphicsview.qdoc | 1 + .../model-view-programming.qdoc | 1 + doc/src/frameworks-technologies/threads.qdoc | 1 + doc/src/objectmodel/metaobjects.qdoc | 3 ++- doc/src/objectmodel/object.qdoc | 3 ++- doc/src/objectmodel/objecttrees.qdoc | 3 ++- doc/src/objectmodel/properties.qdoc | 3 ++- doc/src/objectmodel/signalsandslots.qdoc | 3 ++- doc/src/overviews.qdoc | 23 ++++++++++++++++++++++ doc/src/painting-and-printing/paintsystem.qdoc | 1 + doc/src/widgets-and-layouts/layout.qdoc | 1 + doc/src/widgets-and-layouts/styles.qdoc | 1 + doc/src/widgets-and-layouts/widgets.qdoc | 1 + doc/src/windows-and-dialogs/dialogs.qdoc | 1 + doc/src/windows-and-dialogs/mainwindow.qdoc | 1 + tools/qdoc3/test/qt-html-templates.qdocconf | 19 ++++++------------ 18 files changed, 51 insertions(+), 19 deletions(-) diff --git a/doc/src/frameworks-technologies/animation.qdoc b/doc/src/frameworks-technologies/animation.qdoc index 5548b57..dc705ba 100644 --- a/doc/src/frameworks-technologies/animation.qdoc +++ b/doc/src/frameworks-technologies/animation.qdoc @@ -47,6 +47,7 @@ /*! \page animation-overview.html \title The Animation Framework + \ingroup qt-gui-concepts \brief An overview of the Animation Framework diff --git a/doc/src/frameworks-technologies/eventsandfilters.qdoc b/doc/src/frameworks-technologies/eventsandfilters.qdoc index 96ee18c..0cd60b8 100644 --- a/doc/src/frameworks-technologies/eventsandfilters.qdoc +++ b/doc/src/frameworks-technologies/eventsandfilters.qdoc @@ -54,7 +54,8 @@ /*! \page eventsandfilters.html - \title Events and Event Filters + \title The Event System + \ingroup qt-basic-concepts \brief A guide to event handling in Qt. \ingroup frameworks-technologies diff --git a/doc/src/frameworks-technologies/graphicsview.qdoc b/doc/src/frameworks-technologies/graphicsview.qdoc index 6844aed..95b3182 100644 --- a/doc/src/frameworks-technologies/graphicsview.qdoc +++ b/doc/src/frameworks-technologies/graphicsview.qdoc @@ -47,6 +47,7 @@ /*! \page graphicsview.html \title The Graphics View Framework + \ingroup qt-gui-concepts \brief An overview of the Graphics View framework for interactive 2D graphics. diff --git a/doc/src/frameworks-technologies/model-view-programming.qdoc b/doc/src/frameworks-technologies/model-view-programming.qdoc index 7568981..e02f1eb 100644 --- a/doc/src/frameworks-technologies/model-view-programming.qdoc +++ b/doc/src/frameworks-technologies/model-view-programming.qdoc @@ -50,6 +50,7 @@ \startpage index.html Qt Reference Documentation \title Model/View Programming + \ingroup qt-gui-concepts \brief A guide to the extensible model/view architecture used by Qt's item view classes. diff --git a/doc/src/frameworks-technologies/threads.qdoc b/doc/src/frameworks-technologies/threads.qdoc index fd6bebb..f7dde59 100644 --- a/doc/src/frameworks-technologies/threads.qdoc +++ b/doc/src/frameworks-technologies/threads.qdoc @@ -47,6 +47,7 @@ /*! \page threads.html \title Thread Support in Qt + \ingroup qt-basic-concepts \brief A detailed discussion of thread handling in Qt. \ingroup frameworks-technologies diff --git a/doc/src/objectmodel/metaobjects.qdoc b/doc/src/objectmodel/metaobjects.qdoc index c1b0ea6..e891183 100644 --- a/doc/src/objectmodel/metaobjects.qdoc +++ b/doc/src/objectmodel/metaobjects.qdoc @@ -41,7 +41,8 @@ /*! \page metaobjects.html - \title Meta-Object System + \title The Meta-Object System + \ingroup qt-basic-concepts \brief An overview of Qt's meta-object system and introspection capabilities. \keyword meta-object diff --git a/doc/src/objectmodel/object.qdoc b/doc/src/objectmodel/object.qdoc index 2f06004..e0ba6ed 100644 --- a/doc/src/objectmodel/object.qdoc +++ b/doc/src/objectmodel/object.qdoc @@ -41,7 +41,8 @@ /*! \page object.html - \title Qt Object Model + \title Object Model + \ingroup qt-basic-concepts \brief A description of the powerful features made possible by Qt's dynamic object model. \ingroup frameworks-technologies diff --git a/doc/src/objectmodel/objecttrees.qdoc b/doc/src/objectmodel/objecttrees.qdoc index 11824ae..97d646a 100644 --- a/doc/src/objectmodel/objecttrees.qdoc +++ b/doc/src/objectmodel/objecttrees.qdoc @@ -41,7 +41,8 @@ /*! \page objecttrees.html - \title Object Trees and Object Ownership + \title Object Trees & Ownership + \ingroup qt-basic-concepts \brief Information about the parent-child pattern used to describe object ownership in Qt. diff --git a/doc/src/objectmodel/properties.qdoc b/doc/src/objectmodel/properties.qdoc index a807caf..bc9554c 100644 --- a/doc/src/objectmodel/properties.qdoc +++ b/doc/src/objectmodel/properties.qdoc @@ -41,7 +41,8 @@ /*! \page properties.html - \title Qt's Property System + \title The Property System + \ingroup qt-basic-concepts \brief An overview of Qt's property system. Qt provides a sophisticated property system similar to the ones diff --git a/doc/src/objectmodel/signalsandslots.qdoc b/doc/src/objectmodel/signalsandslots.qdoc index 0f3f618..f33badf 100644 --- a/doc/src/objectmodel/signalsandslots.qdoc +++ b/doc/src/objectmodel/signalsandslots.qdoc @@ -41,7 +41,8 @@ /*! \page signalsandslots.html - \title Signals and Slots + \title Signals & Slots + \ingroup qt-basic-concepts \brief An overview of Qt's signals and slots inter-object communication mechanism. diff --git a/doc/src/overviews.qdoc b/doc/src/overviews.qdoc index 7302e30..bc994af 100644 --- a/doc/src/overviews.qdoc +++ b/doc/src/overviews.qdoc @@ -48,6 +48,29 @@ */ /*! + \group qt-basic-concepts + \title Qt Basic Concepts + + \brief The basic concepts of the Qt cross-platform application and UI framework. + + Qt is a cross-platform application and UI framework for writing + web-enabled applications for desktop, mobile, and embedded + operating systems. These pages explain basic architectural + concepts of Qt: + + \generatelist {related} + */ + +/*! + \group qt-gui-concepts + \title Qt GUI Components + + \brief The Qt components for constructing graphical user intefaces. + + \generatelist {related} + */ + +/*! \group frameworks-technologies \title Frameworks and Technologies diff --git a/doc/src/painting-and-printing/paintsystem.qdoc b/doc/src/painting-and-printing/paintsystem.qdoc index 802751f..56b638c 100644 --- a/doc/src/painting-and-printing/paintsystem.qdoc +++ b/doc/src/painting-and-printing/paintsystem.qdoc @@ -61,6 +61,7 @@ /*! \page paintsystem.html \title The Paint System + \ingroup qt-gui-concepts \ingroup frameworks-technologies Qt's paint system enables painting on screen and print devices diff --git a/doc/src/widgets-and-layouts/layout.qdoc b/doc/src/widgets-and-layouts/layout.qdoc index 0cfde22..2ca202f 100644 --- a/doc/src/widgets-and-layouts/layout.qdoc +++ b/doc/src/widgets-and-layouts/layout.qdoc @@ -47,6 +47,7 @@ /*! \page layout.html \title Layout Management + \ingroup qt-gui-concepts \brief A tour of the standard layout managers and an introduction to custom layouts. diff --git a/doc/src/widgets-and-layouts/styles.qdoc b/doc/src/widgets-and-layouts/styles.qdoc index 9a28715..b4bec8c 100644 --- a/doc/src/widgets-and-layouts/styles.qdoc +++ b/doc/src/widgets-and-layouts/styles.qdoc @@ -48,6 +48,7 @@ /*! \page style-reference.html \title Implementing Styles and Style Aware Widgets + \ingroup qt-gui-concepts \brief An overview of styles and the styling of widgets. \ingroup frameworks-technologies diff --git a/doc/src/widgets-and-layouts/widgets.qdoc b/doc/src/widgets-and-layouts/widgets.qdoc index 7bd27b6..ac0bf77 100644 --- a/doc/src/widgets-and-layouts/widgets.qdoc +++ b/doc/src/widgets-and-layouts/widgets.qdoc @@ -42,6 +42,7 @@ /*! \page widgets-and-layouts.html \title Widgets and Layouts + \ingroup qt-gui-concepts \ingroup frameworks-technologies diff --git a/doc/src/windows-and-dialogs/dialogs.qdoc b/doc/src/windows-and-dialogs/dialogs.qdoc index acee0c5..0b0a842 100644 --- a/doc/src/windows-and-dialogs/dialogs.qdoc +++ b/doc/src/windows-and-dialogs/dialogs.qdoc @@ -52,6 +52,7 @@ /*! \page dialogs.html \title Dialog Windows + \ingroup qt-gui-concepts \brief An overview over dialog windows. \previouspage The Application Main Window diff --git a/doc/src/windows-and-dialogs/mainwindow.qdoc b/doc/src/windows-and-dialogs/mainwindow.qdoc index 6adfa75..b282dab 100644 --- a/doc/src/windows-and-dialogs/mainwindow.qdoc +++ b/doc/src/windows-and-dialogs/mainwindow.qdoc @@ -47,6 +47,7 @@ /*! \page application-windows.html \title Application Windows and Dialogs + \ingroup qt-gui-concepts \ingroup frameworks-technologies \nextpage The Application Main Window diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 00af376..48ecd2c 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -50,7 +50,7 @@ HTML.postheader = "
    \n" \ "
  • All classes
  • \n" \ "
  • All functions
  • \n" \ "
  • All namespaces
  • \n" \ - "
  • Platform specifics
  • \n" \ + "
  • QML elements
  • \n" \ " \n" \ "
    \n" \ "
    \n" \ @@ -58,24 +58,17 @@ HTML.postheader = "
    \n" \ "
    \n" \ "
    \n" \ "

    \n" \ - " API Topics

    \n" \ + " Qt Topics

    \n" \ "
    \n" \ " \n " \ " " \ " \n" \ "
    \n" \ "
    \n" \ @@ -83,7 +76,7 @@ HTML.postheader = "
    \n" \ "
    \n" \ "
    \n" \ "

    \n" \ - " API Examples

    \n" \ + " Qt Examples\n" \ "
    \n" \ " \n " \ - " " \ - "
    \n" \ "
    \n" \ @@ -58,17 +54,20 @@ HTML.postheader = "
    \n" \ "
    \n" \ "
    \n" \ "

    \n" \ - " Qt Topics

    \n" \ + " API Topics\n" \ "
    \n" \ - " \n " \ - " " \ - "
    \n" \ "
    \n" \ @@ -76,18 +75,14 @@ HTML.postheader = "
    \n" \ "
    \n" \ "
    \n" \ "

    \n" \ - " Qt Examples

    \n" \ + " API Examples\n" \ "
    \n" \ - " \n " \ - " " \ - "
    \n" \ "
    \n" \ -- cgit v0.12 From 2479f19ce1df19380dc1fea451b8eb01ab3766dc Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 29 Apr 2010 06:18:25 +0400 Subject: QHostInfo: Remove unused includes Reviewed-by: Markus Goetz --- src/network/kernel/qhostinfo.cpp | 4 ---- src/network/kernel/qhostinfo_unix.cpp | 1 + src/network/kernel/qhostinfo_win.cpp | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 2dd6485..311ee70 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -44,14 +44,10 @@ #include "QtCore/qscopedpointer.h" #include -#include #include #include -#include -#include #include #include -#include #include #ifdef Q_OS_UNIX diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index be06b6e..df98d5d 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -44,6 +44,7 @@ #include "qplatformdefs.h" #include "qhostinfo_p.h" +#include "private/qnativesocketengine_p.h" #include "qiodevice.h" #include #include diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp index 4264f60..b30204b 100644 --- a/src/network/kernel/qhostinfo_win.cpp +++ b/src/network/kernel/qhostinfo_win.cpp @@ -50,7 +50,6 @@ #include "private/qnativesocketengine_p.h" #include #include -#include #include #include #include -- cgit v0.12 From 93c2e88ee31b989e44a17da99a9d256a9bf1b28a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 5 May 2010 16:53:18 +0200 Subject: WindowsMobileStyle: fix QTreeView indicator size Task-number: QTBUG-7364 Reviewed-by: thartman --- src/gui/styles/qwindowsmobilestyle.cpp | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp index 5f939d0..67eb1ef 100644 --- a/src/gui/styles/qwindowsmobilestyle.cpp +++ b/src/gui/styles/qwindowsmobilestyle.cpp @@ -5356,6 +5356,50 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp painter->setPen(option->palette.text().color()); painter->drawLines(a); break; } + case PE_IndicatorBranch: { + // Copied from the Windows style. + static const int decoration_size = d->doubleControls ? 18 : 9; + static const int ofsA = d->doubleControls ? 4 : 2; + static const int ofsB = d->doubleControls ? 8 : 4; + static const int ofsC = d->doubleControls ? 12 : 6; + static const int ofsD = d->doubleControls ? 1 : 0; + int mid_h = option->rect.x() + option->rect.width() / 2; + int mid_v = option->rect.y() + option->rect.height() / 2; + int bef_h = mid_h; + int bef_v = mid_v; + int aft_h = mid_h; + int aft_v = mid_v; + if (option->state & State_Children) { + int delta = decoration_size / 2; + bef_h -= delta; + bef_v -= delta; + aft_h += delta; + aft_v += delta; + QPen oldPen = painter->pen(); + QPen crossPen = oldPen; + crossPen.setWidth(2); + painter->setPen(crossPen); + painter->drawLine(bef_h + ofsA + ofsD, bef_v + ofsB + ofsD, bef_h + ofsC + ofsD, bef_v + ofsB + ofsD); + if (!(option->state & State_Open)) + painter->drawLine(bef_h + ofsB + ofsD, bef_v + ofsA + ofsD, bef_h + ofsB + ofsD, bef_v + ofsC + ofsD); + painter->setPen(option->palette.dark().color()); + painter->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1); + if (d->doubleControls) + painter->drawRect(bef_h + 1, bef_v + 1, decoration_size - 3, decoration_size - 3); + painter->setPen(oldPen); + } + QBrush brush(option->palette.dark().color(), Qt::Dense4Pattern); + if (option->state & State_Item) { + if (option->direction == Qt::RightToLeft) + painter->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush); + else + painter->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush); + } + if (option->state & State_Sibling) + painter->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush); + if (option->state & (State_Open | State_Children | State_Item | State_Sibling)) + painter->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush); + break; } case PE_Frame: qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), d->doubleControls ? 2 : 1, &option->palette.background()); -- cgit v0.12 From db64d17f233f92ce7a425271ee60586bd846705d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 May 2010 16:34:38 +0200 Subject: whitespace fixes --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index ff79c09..db8548d 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -522,8 +522,8 @@ public: active->connectToHost("127.0.0.1", server.serverPort()); #ifndef Q_OS_SYMBIAN // need more time as working with embedded - // device and testing from emualtor - // things tend to get slower + // device and testing from emualtor + // things tend to get slower if (!active->waitForConnected(1000)) return false; @@ -929,7 +929,7 @@ void tst_QNetworkReply::invalidProtocol() void tst_QNetworkReply::getFromData_data() { - QTest::addColumn("request"); + QTest::addColumn("request"); QTest::addColumn("expected"); QTest::addColumn("mimeType"); @@ -1025,7 +1025,7 @@ void tst_QNetworkReply::getFromData() void tst_QNetworkReply::getFromFile() { - // create the file: + // create the file: QTemporaryFile file(QDir::currentPath() + "/temp-XXXXXX"); file.setAutoRemove(true); QVERIFY(file.open()); @@ -1077,7 +1077,7 @@ void tst_QNetworkReply::getFromFileSpecial_data() void tst_QNetworkReply::getFromFileSpecial() { - QFETCH(QString, fileName); + QFETCH(QString, fileName); QFETCH(QString, url); // open the resource so we can find out its size @@ -1107,7 +1107,7 @@ void tst_QNetworkReply::getFromFtp_data() void tst_QNetworkReply::getFromFtp() { - QFETCH(QString, referenceName); + QFETCH(QString, referenceName); QFETCH(QString, url); QFile reference(referenceName); @@ -1136,7 +1136,7 @@ void tst_QNetworkReply::getFromHttp_data() void tst_QNetworkReply::getFromHttp() { - QFETCH(QString, referenceName); + QFETCH(QString, referenceName); QFETCH(QString, url); QFile reference(referenceName); @@ -3456,8 +3456,8 @@ void tst_QNetworkReply::downloadProgress_data() QTest::newRow("big") << 4096; #else // it can run even with 4096 - // but it takes lot time - //especially on emulator + // but it takes lot time + //especially on emulator QTest::newRow("big") << 1024; #endif } @@ -3646,7 +3646,7 @@ void tst_QNetworkReply::receiveCookiesFromHttp_data() void tst_QNetworkReply::receiveCookiesFromHttp() { - QFETCH(QString, cookieString); + QFETCH(QString, cookieString); QByteArray data = cookieString.toLatin1() + '\n'; QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/set-cookie.cgi"); -- cgit v0.12 From e41217d6d2e592e79a9a8a83c9e49491d66ad18e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 May 2010 16:36:10 +0200 Subject: tst_qnetworkreply: add a test for getting from SMB Reviewed-By: Markus Goetz --- tests/auto/qnetworkreply/smb-file.txt | 1 + tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 tests/auto/qnetworkreply/smb-file.txt diff --git a/tests/auto/qnetworkreply/smb-file.txt b/tests/auto/qnetworkreply/smb-file.txt new file mode 100644 index 0000000..73c3ac2 --- /dev/null +++ b/tests/auto/qnetworkreply/smb-file.txt @@ -0,0 +1 @@ +This is 34 bytes. Do not change... \ No newline at end of file diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index db8548d..9d942bf 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -1073,6 +1073,9 @@ void tst_QNetworkReply::getFromFileSpecial_data() QTest::newRow("resource") << ":/resource" << "qrc:/resource"; QTest::newRow("search-path") << "srcdir:/rfc3252.txt" << "srcdir:/rfc3252.txt"; QTest::newRow("bigfile-path") << "srcdir:/bigfile" << "srcdir:/bigfile"; +#ifdef Q_OS_WIN + QTest::newRow("smb-path") << "srcdir:/smb-file.txt" << "file://" + QtNetworkSettings::winServerName() + "/testshare/test.pri"; +#endif } void tst_QNetworkReply::getFromFileSpecial() -- cgit v0.12 From a2f797b52c4274a62a7cf1f0939aca1429afe211 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 May 2010 16:48:21 +0200 Subject: Improve QUrl handling of local file paths Add QUrl::isLocalFile for a faster and more consistent checking of whether the URL is local or not. Improve the documentation to indicate that QUrl always treats SMB-like file paths as local, even if the system cannot open them (non-Windows). Add a test to ensure that "FILE:/a.txt" is considered local too (RFC 3986 requires schemes to be interpreted in case-insensitive fashion). Remove broken code that supported empty schemes as local file paths. Reviewed-by: Markus Goetz --- src/corelib/io/qurl.cpp | 73 +++++++++++++++++++++++++++++++------------- src/corelib/io/qurl.h | 1 + tests/auto/qurl/tst_qurl.cpp | 11 ++++++- 3 files changed, 62 insertions(+), 23 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 4e580dd..7b5bfed 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5970,19 +5970,22 @@ bool QUrl::isDetached() const /*! - Returns a QUrl representation of \a localFile, interpreted as a - local file. + Returns a QUrl representation of \a localFile, interpreted as a local + file. This function accepts paths separated by slashes as well as the + native separator for this platform. - \sa toLocalFile() + This function also accepts paths with a doubled leading slash (or + backslash) to indicate a remote file, as in + "//servername/path/to/file.txt". Note that only certain platforms can + actually open this file using QFile::open(). + + \sa toLocalFile(), isLocalFile(), QDir::toNativeSeparators */ QUrl QUrl::fromLocalFile(const QString &localFile) { QUrl url; url.setScheme(QLatin1String("file")); - QString deslashified = localFile; - deslashified.replace(QLatin1Char('\\'), QLatin1Char('/')); - - + QString deslashified = QDir::toNativeSeparators(localFile); // magic for drives on windows if (deslashified.length() > 1 && deslashified.at(1) == QLatin1Char(':') && deslashified.at(0) != QLatin1Char('/')) { @@ -6001,35 +6004,61 @@ QUrl QUrl::fromLocalFile(const QString &localFile) } /*! - Returns the path of this URL formatted as a local file path. + Returns the path of this URL formatted as a local file path. The path + returned will use forward slashes, even if it was originally created + from one with backslashes. - \sa fromLocalFile() + If this URL contains a non-empty hostname, it will be encoded in the + returned value in the form found on SMB networks (for example, + "//servername/path/to/file.txt"). + + \sa fromLocalFile(), isLocalFile() */ QString QUrl::toLocalFile() const { - if (!d) return QString(); - if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); + // the call to isLocalFile() also ensures that we're parsed + if (!isLocalFile()) + return QString(); QString tmp; QString ourPath = path(); - if (d->scheme.isEmpty() || QString::compare(d->scheme, QLatin1String("file"), Qt::CaseInsensitive) == 0) { - // magic for shared drive on windows - if (!d->host.isEmpty()) { - tmp = QLatin1String("//") + d->host + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/') - ? QLatin1Char('/') + ourPath : ourPath); - } else { - tmp = ourPath; - // magic for drives on windows - if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':')) - tmp.remove(0, 1); - } + // magic for shared drive on windows + if (!d->host.isEmpty()) { + tmp = QLatin1String("//") + d->host + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/') + ? QLatin1Char('/') + ourPath : ourPath); + } else { + tmp = ourPath; + // magic for drives on windows + if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':')) + tmp.remove(0, 1); } return tmp; } /*! + \since 4.7 + Returns true if this URL is pointing to a local file path. A URL is a + local file path if the scheme is "file". + + Note that this function considers URLs with hostnames to be local file + paths, even if the eventual file path cannot be opened with + QFile::open(). + + \sa fromLocalFile(), toLocalFile() +*/ +bool QUrl::isLocalFile() const +{ + if (!d) return false; + if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); + + if (d->scheme.compare(QLatin1String("file"), Qt::CaseInsensitive) != 0) + return false; // not file + return true; +} + +/*! Returns true if this URL is a parent of \a childUrl. \a childUrl is a child of this URL if the two URLs share the same scheme and authority, and this URL's path is a parent of the path of \a childUrl. diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 6f8331a..162aa7c 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -183,6 +183,7 @@ public: static QUrl fromLocalFile(const QString &localfile); QString toLocalFile() const; + bool isLocalFile() const; QString toString(FormattingOptions options = None) const; diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index fa42adc..67bf0c1 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -314,6 +314,7 @@ void tst_QUrl::constructing() QUrl buildUNC; + buildUNC.setScheme(QString::fromLatin1("file")); buildUNC.setHost(QString::fromLatin1("somehost")); buildUNC.setPath(QString::fromLatin1("somepath")); QCOMPARE(buildUNC.toLocalFile(), QString::fromLatin1("//somehost/somepath")); @@ -1757,7 +1758,15 @@ void tst_QUrl::toLocalFile_data() QTest::newRow("data7") << QString::fromLatin1("file://somehost/") << QString::fromLatin1("//somehost/"); QTest::newRow("data8") << QString::fromLatin1("file://somehost") << QString::fromLatin1("//somehost"); QTest::newRow("data9") << QString::fromLatin1("file:////somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile"); - + QTest::newRow("data10") << QString::fromLatin1("FILE:/a.txt") << QString::fromLatin1("/a.txt"); + + // and some that result in empty (i.e., not local) + QTest::newRow("xdata0") << QString::fromLatin1("/a.txt") << QString(); + QTest::newRow("xdata1") << QString::fromLatin1("//a.txt") << QString(); + QTest::newRow("xdata2") << QString::fromLatin1("///a.txt") << QString(); + QTest::newRow("xdata3") << QString::fromLatin1("foo:/a.txt") << QString(); + QTest::newRow("xdata4") << QString::fromLatin1("foo://a.txt") << QString(); + QTest::newRow("xdata5") << QString::fromLatin1("foo:///a.txt") << QString(); } void tst_QUrl::toLocalFile() -- cgit v0.12 From ebddf7a8739d7f4aaa7d9cb8a41a14eebb65e4f4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 May 2010 16:51:41 +0200 Subject: Use QUrl::isLocalFile and fix the scheme checking in local URLs. RFC 3986 requires that schemes be compared case-insensitively, so "QRC:/" is allowed for Qt resources. Also document the use of file engines and search paths. Reviewed-by: Markus Goetz --- src/network/access/qnetworkaccessfilebackend.cpp | 11 ++++++++--- src/network/access/qnetworkaccessmanager.cpp | 11 +++++------ tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 6 ++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp index 4560153..710c258 100644 --- a/src/network/access/qnetworkaccessfilebackend.cpp +++ b/src/network/access/qnetworkaccessfilebackend.cpp @@ -65,10 +65,15 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op, } QUrl url = request.url(); - if (url.scheme() == QLatin1String("qrc") || !url.toLocalFile().isEmpty()) + if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0 || url.isLocalFile()) { return new QNetworkAccessFileBackend; - else if (!url.isEmpty() && url.authority().isEmpty()) { - // check if QFile could, in theory, open this URL + } else if (!url.scheme().isEmpty() && url.authority().isEmpty()) { + // check if QFile could, in theory, open this URL via the file engines + // it has to be in the format: + // prefix:path/to/file + // or prefix:/path/to/file + // + // this construct here must match the one below in open() QFileInfo fi(url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery)); if (fi.exists() || (op == QNetworkAccessManager::PutOperation && fi.dir().exists())) return new QNetworkAccessFileBackend; diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 1c7661d..10fdc6f 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -907,21 +907,20 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera { Q_D(QNetworkAccessManager); + bool isLocalFile = req.url().isLocalFile(); + // fast path for GET on file:// URLs - // Also if the scheme is empty we consider it a file. // The QNetworkAccessFileBackend will right now only be used // for PUT or qrc:// if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation) - && (req.url().scheme() == QLatin1String("file") - || req.url().scheme().isEmpty())) { + && isLocalFile) { return new QFileNetworkReply(this, req, op); } #ifndef QT_NO_BEARERMANAGEMENT // Return a disabled network reply if network access is disabled. // Except if the scheme is empty or file://. - if (!d->networkAccessible && !(req.url().scheme() == QLatin1String("file") || - req.url().scheme().isEmpty())) { + if (!d->networkAccessible && !isLocalFile) { return new QDisabledNetworkReply(this, req, op); } @@ -963,7 +962,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera QUrl url = request.url(); QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); #ifndef QT_NO_BEARERMANAGEMENT - if (req.url().scheme() != QLatin1String("file") && !req.url().scheme().isEmpty()) { + if (!isLocalFile) { connect(this, SIGNAL(networkSessionConnected()), reply, SLOT(_q_networkSessionConnected())); } diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 9d942bf..c4d458f 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -1166,6 +1166,12 @@ void tst_QNetworkReply::getErrors_data() QTest::addColumn("httpStatusCode"); QTest::addColumn("dataIsEmpty"); + // empties + QTest::newRow("empty-url") << QString() << int(QNetworkReply::ProtocolUnknownError) << 0 << true; + QTest::newRow("empty-scheme-host") << SRCDIR "/rfc3252.txt" << int(QNetworkReply::ProtocolUnknownError) << 0 << true; + QTest::newRow("empty-scheme") << "//" + QtNetworkSettings::winServerName() + "/testshare/test.pri" + << int(QNetworkReply::ProtocolUnknownError) << 0 << true; + // file: errors QTest::newRow("file-host") << "file://this-host-doesnt-exist.troll.no/foo.txt" #if !defined Q_OS_WIN -- cgit v0.12 From a9fb306a1cf1308a3f8b9bb12ed01aed1f6f6f8d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 May 2010 16:55:02 +0200 Subject: [QNAM FTP] Check for the "ftp" scheme case-insensitively --- src/network/access/qnetworkaccessftpbackend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index 1a59011..da336d0 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -77,7 +77,7 @@ QNetworkAccessFtpBackendFactory::create(QNetworkAccessManager::Operation op, } QUrl url = request.url(); - if (url.scheme() == QLatin1String("ftp")) + if (url.scheme().compare(QLatin1String("ftp"), Qt::CaseInsensitive) == 0) return new QNetworkAccessFtpBackend; return 0; } -- cgit v0.12 From 2cc7a785eff228f414faa09ff882c2f0a2092cfd Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 5 May 2010 17:42:54 +0200 Subject: fix qt_wince_bsearch for low nonexistent key values Task-number: QTBUG-10043 Reviewed-by: thartman --- src/corelib/kernel/qfunctions_wince.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp index 8ad6126..e58feb3 100644 --- a/src/corelib/kernel/qfunctions_wince.cpp +++ b/src/corelib/kernel/qfunctions_wince.cpp @@ -352,16 +352,18 @@ void *qt_wince_bsearch(const void *key, size_t low = 0; size_t high = num - 1; while (low <= high) { - unsigned int mid = ((unsigned) (low + high)) >> 1; + size_t mid = (low + high) >> 1; int c = compare(key, (char*)base + mid * size); - if (c < 0) + if (c < 0) { + if (!mid) + break; high = mid - 1; - else if (c > 0) + } else if (c > 0) low = mid + 1; else return (char*) base + mid * size; } - return (NULL); + return 0; } void *lfind(const void* key, const void* base, size_t* elements, size_t size, -- cgit v0.12 From 8f53bf1b99d32caaebe8cbd1d9bd3a7381821988 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 5 May 2010 17:41:20 +0200 Subject: Fixed the sizing of the dock area with fixed size dock widgets It could happen that a dock area could be too wide. The problem was that we didn't really care whether or not the tab bar was visible. We would always take its minimum sizehint into account. Task-Number: QTBUG-10391 Reviewed-By: gabi --- src/gui/widgets/qdockarealayout.cpp | 46 +++++++++++++++---------------------- src/gui/widgets/qdockarealayout_p.h | 4 +--- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 806654c..171000b 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -225,7 +225,7 @@ static const int zero = 0; QDockAreaLayoutInfo::QDockAreaLayoutInfo() : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0) #ifndef QT_NO_TABBAR - , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth), tabBarVisible(false) + , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth) #endif { } @@ -235,7 +235,7 @@ QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPositio QMainWindow *window) : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window) #ifndef QT_NO_TABBAR - , tabbed(false), tabBar(0), tabBarShape(static_cast(tbshape)), tabBarVisible(false) + , tabbed(false), tabBar(0), tabBarShape(static_cast(tbshape)) #endif { #ifdef QT_NO_TABBAR @@ -296,8 +296,8 @@ QSize QDockAreaLayoutInfo::minimumSize() const rperp(o, result) = b; #ifndef QT_NO_TABBAR - if (tabbed) { - QSize tbm = tabBarMinimumSize(); + QSize tbm = tabBarMinimumSize(); + if (!tbm.isNull()) { switch (tabBarShape) { case QTabBar::RoundedNorth: case QTabBar::RoundedSouth: @@ -369,8 +369,8 @@ QSize QDockAreaLayoutInfo::maximumSize() const rperp(o, result) = b; #ifndef QT_NO_TABBAR - if (tabbed) { - QSize tbh = tabBarSizeHint(); + QSize tbh = tabBarSizeHint(); + if (!tbh.isNull()) { switch (tabBarShape) { case QTabBar::RoundedNorth: case QTabBar::RoundedSouth: @@ -1500,7 +1500,7 @@ void QDockAreaLayoutInfo::apply(bool animate) QRect tab_rect; QSize tbh = tabBarSizeHint(); - if (tabBarVisible) { + if (!tbh.isNull()) { switch (tabBarShape) { case QTabBar::RoundedNorth: case QTabBar::TriangularNorth: @@ -2079,10 +2079,11 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const #endif //QT_NO_TABBAR #ifndef QT_NO_TABBAR -void QDockAreaLayoutInfo::updateTabBar() const +//returns whether the tabbar is visible or not +bool QDockAreaLayoutInfo::updateTabBar() const { if (!tabbed) - return; + return false; QDockAreaLayoutInfo *that = const_cast(this); @@ -2150,12 +2151,8 @@ void QDockAreaLayoutInfo::updateTabBar() const tabBar->blockSignals(blocked); - that->tabBarVisible = ( (gap ? 1 : 0) + tabBar->count()) > 1; - - if (changed || !tabBarMin.isValid() | !tabBarHint.isValid()) { - that->tabBarMin = tabBar->minimumSizeHint(); - that->tabBarHint = tabBar->sizeHint(); - } + //returns if the tabbar is visible or not + return ( (gap ? 1 : 0) + tabBar->count()) > 1; } void QDockAreaLayoutInfo::setTabBarShape(int shape) @@ -2163,11 +2160,8 @@ void QDockAreaLayoutInfo::setTabBarShape(int shape) if (shape == tabBarShape) return; tabBarShape = shape; - if (tabBar != 0) { + if (tabBar != 0) tabBar->setShape(static_cast(shape)); - tabBarMin = QSize(); - tabBarHint = QSize(); - } for (int i = 0; i < item_list.count(); ++i) { QDockAreaLayoutItem &item = item_list[i]; @@ -2178,22 +2172,18 @@ void QDockAreaLayoutInfo::setTabBarShape(int shape) QSize QDockAreaLayoutInfo::tabBarMinimumSize() const { - if (!tabbed) + if (!updateTabBar()) return QSize(0, 0); - updateTabBar(); - - return tabBarMin; + return tabBar->minimumSizeHint(); } QSize QDockAreaLayoutInfo::tabBarSizeHint() const { - if (!tabbed) + if (!updateTabBar()) return QSize(0, 0); - updateTabBar(); - - return tabBarHint; + return tabBar->sizeHint(); } QSet QDockAreaLayoutInfo::usedTabBars() const @@ -2240,7 +2230,7 @@ QRect QDockAreaLayoutInfo::tabContentRect() const QRect result = rect; QSize tbh = tabBarSizeHint(); - if (tabBarVisible) { + if (!tbh.isNull()) { switch (tabBarShape) { case QTabBar::RoundedNorth: case QTabBar::TriangularNorth: diff --git a/src/gui/widgets/qdockarealayout_p.h b/src/gui/widgets/qdockarealayout_p.h index 0088f00..9cb77ba 100644 --- a/src/gui/widgets/qdockarealayout_p.h +++ b/src/gui/widgets/qdockarealayout_p.h @@ -208,11 +208,9 @@ public: QRect tabContentRect() const; bool tabbed; QTabBar *tabBar; - QSize tabBarMin, tabBarHint; int tabBarShape; - bool tabBarVisible; - void updateTabBar() const; + bool updateTabBar() const; void setTabBarShape(int shape); QSize tabBarMinimumSize() const; QSize tabBarSizeHint() const; -- cgit v0.12 From 3c4d3a65bbce6b1f9e649412f141ee8890a7b6cd Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 5 May 2010 06:57:26 +0200 Subject: QGraphicsWidget was not working properly when ItemSendsPositionChanges is false The geometry was not properly set because QGraphicsWidget rely on itemChange to update its own geometry. Now when calling setPos we also ensure that for a widget the geometry will be up to date. Setting the flag ItemSendsPositionChanges to false for a given widget will give a small performance boost. Reviewed-by:janarve Reviewed-by:bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 2 ++ src/gui/graphicsview/qgraphicswidget.cpp | 8 +----- src/gui/graphicsview/qgraphicswidget_p.cpp | 12 +++++++++ src/gui/graphicsview/qgraphicswidget_p.h | 2 ++ tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 29 ++++++++++++++++++++++ 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 42abe59..074e571 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3578,6 +3578,8 @@ void QGraphicsItem::setPos(const QPointF &pos) // Update and repositition. if (!(d_ptr->flags & ItemSendsGeometryChanges)) { d_ptr->setPosHelper(pos); + if (d_ptr->isWidget) + static_cast(this)->d_func()->setGeometryFromSetPos(); return; } diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 8b80bc8..3151e76 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -1044,13 +1044,7 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant & } break; case ItemPositionHasChanged: - if (!d->inSetGeometry) { - d->inSetPos = 1; - // Ensure setGeometry is called (avoid recursion when setPos is - // called from within setGeometry). - setGeometry(QRectF(pos(), size())); - d->inSetPos = 0 ; - } + d->setGeometryFromSetPos(); break; case ItemParentChange: { QGraphicsItem *parent = qVariantValue(value); diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index 1835c74..daa007f 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -825,6 +825,18 @@ void QGraphicsWidgetPrivate::setLayout_helper(QGraphicsLayout *l) } } +void QGraphicsWidgetPrivate::setGeometryFromSetPos() +{ + if (inSetGeometry) + return; + Q_Q(QGraphicsWidget); + inSetPos = 1; + // Ensure setGeometry is called (avoid recursion when setPos is + // called from within setGeometry). + q->setGeometry(QRectF(pos, q->size())); + inSetPos = 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..140bc0e 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.h +++ b/src/gui/graphicsview/qgraphicswidget_p.h @@ -130,6 +130,8 @@ public: void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event); bool hasDecoration() const; + void setGeometryFromSetPos(); + // 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 1930a6f..1a56e6b 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -166,6 +166,7 @@ private slots: void initialShow(); void initialShow2(); void itemChangeEvents(); + void itemSendGeometryPosChangesDeactivated(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2972,6 +2973,34 @@ void tst_QGraphicsWidget::itemChangeEvents() QTRY_VERIFY(!item->valueDuringEvents.value(QEvent::EnabledChange).toBool()); } +void tst_QGraphicsWidget::itemSendGeometryPosChangesDeactivated() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsWidget *item = new QGraphicsWidget; + scene.addItem(item); + view.show(); + QTest::qWaitForWindowShown(&view); + item->setGeometry(QRectF(0, 0, 50, 50)); + QTRY_COMPARE(item->geometry(), QRectF(0, 0, 50, 50)); + + item->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); + item->setGeometry(QRectF(0, 0, 60, 60)); + QCOMPARE(item->geometry(), QRectF(0, 0, 60, 60)); + QCOMPARE(item->pos(), QPointF(0, 0)); + item->setPos(QPointF(10, 10)); + QCOMPARE(item->pos(), QPointF(10, 10)); + QCOMPARE(item->geometry(), QRectF(10, 10, 60, 60)); + + item->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false); + item->setGeometry(QRectF(0, 0, 60, 60)); + QCOMPARE(item->geometry(), QRectF(0, 0, 60, 60)); + QCOMPARE(item->pos(), QPointF(0, 0)); + item->setPos(QPointF(10, 10)); + QCOMPARE(item->pos(), QPointF(10, 10)); + QCOMPARE(item->geometry(), QRectF(10, 10, 60, 60)); +} + void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() { QGraphicsScene scene; -- cgit v0.12 From 4620b0fc7a48c643400a42eb9e9cc0a82ad0be9a Mon Sep 17 00:00:00 2001 From: Robin Helgelin Date: Wed, 21 Apr 2010 12:14:02 +0200 Subject: Keep support for maximum pending connections in derived QTcpServer By adding a new function to the class QTcpServer it's now possible to extend QTcpserver functionality with for instance SSL capabilities and still keep the support for maximum pending connections. Task-number: QTBUG-1875 Reviewed-by: Peter Hartmann Reviewed-by: Markus Goetz Merge-Request: 568 --- src/network/socket/qtcpserver.cpp | 15 +++++++++++++++ src/network/socket/qtcpserver.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp index 932126d..a259eee 100644 --- a/src/network/socket/qtcpserver.cpp +++ b/src/network/socket/qtcpserver.cpp @@ -572,6 +572,21 @@ void QTcpServer::incomingConnection(int socketDescriptor) QTcpSocket *socket = new QTcpSocket(this); socket->setSocketDescriptor(socketDescriptor); + addPendingConnection(socket); +} + +/*! + This function is called by QTcpServer::incomingConnection() + to add a socket to the list of pending incoming connections. + + \note Don't forget to call this member from reimplemented + incomingConnection() if you do not want to break the + Pending Connections mechanism. + + \sa incomingConnection() +*/ +void QTcpServer::addPendingConnection(QTcpSocket* socket) +{ d_func()->pendingConnections.append(socket); } diff --git a/src/network/socket/qtcpserver.h b/src/network/socket/qtcpserver.h index 7aebffe..b206678 100644 --- a/src/network/socket/qtcpserver.h +++ b/src/network/socket/qtcpserver.h @@ -93,6 +93,7 @@ public: protected: virtual void incomingConnection(int handle); + void addPendingConnection(QTcpSocket* socket); Q_SIGNALS: void newConnection(); -- cgit v0.12 From efb26a325dcea5e60d7801fef00e650bd028c16d Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 6 May 2010 09:57:19 +0200 Subject: QTcpServer: Fix documentation for previous commit --- src/network/socket/qtcpserver.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp index a259eee..55f926d 100644 --- a/src/network/socket/qtcpserver.cpp +++ b/src/network/socket/qtcpserver.cpp @@ -562,7 +562,7 @@ QTcpSocket *QTcpServer::nextPendingConnection() to the other thread and create the QTcpSocket object there and use its setSocketDescriptor() method. - \sa newConnection(), nextPendingConnection() + \sa newConnection(), nextPendingConnection(), addPendingConnection() */ void QTcpServer::incomingConnection(int socketDescriptor) { @@ -584,6 +584,7 @@ void QTcpServer::incomingConnection(int socketDescriptor) Pending Connections mechanism. \sa incomingConnection() + \since 4.7 */ void QTcpServer::addPendingConnection(QTcpSocket* socket) { -- cgit v0.12 From ae786d63683db1aea1a4ad7eea2c4e20d5c1752d Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Tue, 4 May 2010 16:03:27 +0200 Subject: isOnActiveSpace is available from 10.6. The fix for qtcreatorbug-827 included a call to isOnActiveSpace, which is only available from 10.6 so this patch adds a runtime check for it. Since it is a runtime check there is no need for multiple builds. Notice that the fix for qtcreatorbug-827 will work only on 10.6+ Task-number: QTCREATORBUG-827 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qwidget_mac.mm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 81dd746..f12c956 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3835,13 +3835,20 @@ void QWidgetPrivate::raise_sys() // required we will introduce special handling for some of them. if (!q->testAttribute(Qt::WA_DontShowOnScreen) && q->isVisible()) { OSWindowRef window = qt_mac_window_for(q); - if(![window isOnActiveSpace]) { - QWidget *parentWidget = q->parentWidget(); - if(parentWidget) { - OSWindowRef parentWindow = qt_mac_window_for(parentWidget); - if(parentWindow && [parentWindow isOnActiveSpace]) { - recreateMacWindow(); - window = qt_mac_window_for(q); + // isOnActiveSpace is available only from 10.6 onwards, so we need to check if it is + // available before calling it. + if([window respondsToSelector:@selector(isOnActiveSpace)]) { + if(![window performSelector:@selector(isOnActiveSpace)]) { + QWidget *parentWidget = q->parentWidget(); + if(parentWidget) { + OSWindowRef parentWindow = qt_mac_window_for(parentWidget); + if(parentWindow && [parentWindow isOnActiveSpace]) { + // The window was created in a different space. Therefore if we want + // to show it in the current space we need to recreate it in the new + // space. + recreateMacWindow(); + window = qt_mac_window_for(q); + } } } } -- cgit v0.12 From 1bdd2553b744de425b5952d2e9ab31753cd5b110 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 6 May 2010 11:15:31 +0200 Subject: Recalculate script item widths when forcing justification When going through the special WebKit code path for text drawing and forcing justification for text, we would set the justification in the text engine, but never actually update the widths of the script items. Since the width of the script item is used to position the text, the text would be drawn with the correct justification, but the position would be set based on the non-justified text width. The result was overlapping text whenever the script of the text changed. The fix goes through the justified glyphs and sets the width and position based on the new effective advance. Task-number: QTBUG-10421 Reviewed-by: Simon Hausmann --- src/gui/painting/qpainter.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 075c457..96981af 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5773,12 +5773,17 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif gf.glyphs = engine.shapedGlyphs(&si); gf.chars = engine.layoutData->string.unicode() + si.position; gf.num_chars = engine.length(item); - gf.width = si.width; + if (engine.forceJustification) { + for (int j=0; j Date: Thu, 6 May 2010 10:37:26 +0100 Subject: Corrected headers for spectrum analyzer demo - Added /3rdparty/ to directory path for FFTReal code - Added missing $QT_BEGIN_LICENSE$, $QT_END_LICENSE$ - Fixed incorrect license in app/wavfile.cpp Reviewed-by: trustme --- demos/spectrum/3rdparty/fftreal/Array.h | 97 +++ demos/spectrum/3rdparty/fftreal/Array.hpp | 98 +++ demos/spectrum/3rdparty/fftreal/DynArray.h | 100 +++ demos/spectrum/3rdparty/fftreal/DynArray.hpp | 143 ++++ demos/spectrum/3rdparty/fftreal/FFTReal.dsp | 273 ++++++ demos/spectrum/3rdparty/fftreal/FFTReal.dsw | 29 + demos/spectrum/3rdparty/fftreal/FFTReal.h | 142 ++++ demos/spectrum/3rdparty/fftreal/FFTReal.hpp | 916 +++++++++++++++++++++ demos/spectrum/3rdparty/fftreal/FFTRealFixLen.h | 130 +++ demos/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp | 322 ++++++++ .../spectrum/3rdparty/fftreal/FFTRealFixLenParam.h | 93 +++ .../spectrum/3rdparty/fftreal/FFTRealPassDirect.h | 96 +++ .../3rdparty/fftreal/FFTRealPassDirect.hpp | 204 +++++ .../spectrum/3rdparty/fftreal/FFTRealPassInverse.h | 101 +++ .../3rdparty/fftreal/FFTRealPassInverse.hpp | 229 ++++++ demos/spectrum/3rdparty/fftreal/FFTRealSelect.h | 77 ++ demos/spectrum/3rdparty/fftreal/FFTRealSelect.hpp | 62 ++ demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h | 101 +++ .../spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp | 91 ++ demos/spectrum/3rdparty/fftreal/OscSinCos.h | 106 +++ demos/spectrum/3rdparty/fftreal/OscSinCos.hpp | 122 +++ demos/spectrum/3rdparty/fftreal/TestAccuracy.h | 105 +++ demos/spectrum/3rdparty/fftreal/TestAccuracy.hpp | 472 +++++++++++ demos/spectrum/3rdparty/fftreal/TestHelperFixLen.h | 93 +++ .../spectrum/3rdparty/fftreal/TestHelperFixLen.hpp | 93 +++ demos/spectrum/3rdparty/fftreal/TestHelperNormal.h | 94 +++ .../spectrum/3rdparty/fftreal/TestHelperNormal.hpp | 99 +++ demos/spectrum/3rdparty/fftreal/TestSpeed.h | 95 +++ demos/spectrum/3rdparty/fftreal/TestSpeed.hpp | 223 +++++ .../spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h | 95 +++ .../3rdparty/fftreal/TestWhiteNoiseGen.hpp | 91 ++ demos/spectrum/3rdparty/fftreal/bwins/fftrealu.def | 5 + demos/spectrum/3rdparty/fftreal/def.h | 60 ++ demos/spectrum/3rdparty/fftreal/eabi/fftrealu.def | 7 + demos/spectrum/3rdparty/fftreal/fftreal.pas | 661 +++++++++++++++ demos/spectrum/3rdparty/fftreal/fftreal.pro | 41 + .../spectrum/3rdparty/fftreal/fftreal_wrapper.cpp | 54 ++ demos/spectrum/3rdparty/fftreal/fftreal_wrapper.h | 63 ++ demos/spectrum/3rdparty/fftreal/license.txt | 459 +++++++++++ demos/spectrum/3rdparty/fftreal/readme.txt | 242 ++++++ .../fftreal/stopwatch/ClockCycleCounter.cpp | 285 +++++++ .../3rdparty/fftreal/stopwatch/ClockCycleCounter.h | 124 +++ .../fftreal/stopwatch/ClockCycleCounter.hpp | 150 ++++ demos/spectrum/3rdparty/fftreal/stopwatch/Int64.h | 71 ++ .../3rdparty/fftreal/stopwatch/StopWatch.cpp | 101 +++ .../3rdparty/fftreal/stopwatch/StopWatch.h | 110 +++ .../3rdparty/fftreal/stopwatch/StopWatch.hpp | 83 ++ demos/spectrum/3rdparty/fftreal/stopwatch/def.h | 65 ++ demos/spectrum/3rdparty/fftreal/stopwatch/fnc.h | 67 ++ demos/spectrum/3rdparty/fftreal/stopwatch/fnc.hpp | 85 ++ demos/spectrum/3rdparty/fftreal/test.cpp | 267 ++++++ demos/spectrum/3rdparty/fftreal/test_fnc.h | 53 ++ demos/spectrum/3rdparty/fftreal/test_fnc.hpp | 56 ++ demos/spectrum/3rdparty/fftreal/test_settings.h | 45 + demos/spectrum/3rdparty/fftreal/testapp.dpr | 150 ++++ demos/spectrum/app/app.pro | 8 +- demos/spectrum/app/engine.h | 2 + demos/spectrum/app/frequencyspectrum.h | 2 + demos/spectrum/app/levelmeter.h | 2 + demos/spectrum/app/mainwidget.h | 2 + demos/spectrum/app/progressbar.h | 2 + demos/spectrum/app/settingsdialog.h | 2 + demos/spectrum/app/spectrograph.h | 2 + demos/spectrum/app/spectrum.h | 2 + demos/spectrum/app/spectrumanalyser.h | 2 + demos/spectrum/app/tonegenerator.h | 2 + demos/spectrum/app/tonegeneratordialog.h | 2 + demos/spectrum/app/utils.h | 2 + demos/spectrum/app/waveform.h | 2 + demos/spectrum/app/wavfile.cpp | 18 +- demos/spectrum/app/wavfile.h | 2 + demos/spectrum/fftreal/Array.h | 97 --- demos/spectrum/fftreal/Array.hpp | 98 --- demos/spectrum/fftreal/DynArray.h | 100 --- demos/spectrum/fftreal/DynArray.hpp | 143 ---- demos/spectrum/fftreal/FFTReal.dsp | 273 ------ demos/spectrum/fftreal/FFTReal.dsw | 29 - demos/spectrum/fftreal/FFTReal.h | 142 ---- demos/spectrum/fftreal/FFTReal.hpp | 916 --------------------- demos/spectrum/fftreal/FFTRealFixLen.h | 130 --- demos/spectrum/fftreal/FFTRealFixLen.hpp | 322 -------- demos/spectrum/fftreal/FFTRealFixLenParam.h | 93 --- demos/spectrum/fftreal/FFTRealPassDirect.h | 96 --- demos/spectrum/fftreal/FFTRealPassDirect.hpp | 204 ----- demos/spectrum/fftreal/FFTRealPassInverse.h | 101 --- demos/spectrum/fftreal/FFTRealPassInverse.hpp | 229 ------ demos/spectrum/fftreal/FFTRealSelect.h | 77 -- demos/spectrum/fftreal/FFTRealSelect.hpp | 62 -- demos/spectrum/fftreal/FFTRealUseTrigo.h | 101 --- demos/spectrum/fftreal/FFTRealUseTrigo.hpp | 91 -- demos/spectrum/fftreal/OscSinCos.h | 106 --- demos/spectrum/fftreal/OscSinCos.hpp | 122 --- demos/spectrum/fftreal/TestAccuracy.h | 105 --- demos/spectrum/fftreal/TestAccuracy.hpp | 472 ----------- demos/spectrum/fftreal/TestHelperFixLen.h | 93 --- demos/spectrum/fftreal/TestHelperFixLen.hpp | 93 --- demos/spectrum/fftreal/TestHelperNormal.h | 94 --- demos/spectrum/fftreal/TestHelperNormal.hpp | 99 --- demos/spectrum/fftreal/TestSpeed.h | 95 --- demos/spectrum/fftreal/TestSpeed.hpp | 223 ----- demos/spectrum/fftreal/TestWhiteNoiseGen.h | 95 --- demos/spectrum/fftreal/TestWhiteNoiseGen.hpp | 91 -- demos/spectrum/fftreal/bwins/fftrealu.def | 5 - demos/spectrum/fftreal/def.h | 60 -- demos/spectrum/fftreal/eabi/fftrealu.def | 7 - demos/spectrum/fftreal/fftreal.pas | 661 --------------- demos/spectrum/fftreal/fftreal.pro | 41 - demos/spectrum/fftreal/fftreal_wrapper.cpp | 54 -- demos/spectrum/fftreal/fftreal_wrapper.h | 63 -- demos/spectrum/fftreal/license.txt | 459 ----------- demos/spectrum/fftreal/readme.txt | 242 ------ .../fftreal/stopwatch/ClockCycleCounter.cpp | 285 ------- .../spectrum/fftreal/stopwatch/ClockCycleCounter.h | 124 --- .../fftreal/stopwatch/ClockCycleCounter.hpp | 150 ---- demos/spectrum/fftreal/stopwatch/Int64.h | 71 -- demos/spectrum/fftreal/stopwatch/StopWatch.cpp | 101 --- demos/spectrum/fftreal/stopwatch/StopWatch.h | 110 --- demos/spectrum/fftreal/stopwatch/StopWatch.hpp | 83 -- demos/spectrum/fftreal/stopwatch/def.h | 65 -- demos/spectrum/fftreal/stopwatch/fnc.h | 67 -- demos/spectrum/fftreal/stopwatch/fnc.hpp | 85 -- demos/spectrum/fftreal/test.cpp | 267 ------ demos/spectrum/fftreal/test_fnc.h | 53 -- demos/spectrum/fftreal/test_fnc.hpp | 56 -- demos/spectrum/fftreal/test_settings.h | 45 - demos/spectrum/fftreal/testapp.dpr | 150 ---- demos/spectrum/spectrum.pro | 2 +- 127 files changed, 8339 insertions(+), 8309 deletions(-) create mode 100644 demos/spectrum/3rdparty/fftreal/Array.h create mode 100644 demos/spectrum/3rdparty/fftreal/Array.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/DynArray.h create mode 100644 demos/spectrum/3rdparty/fftreal/DynArray.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/FFTReal.dsp create mode 100644 demos/spectrum/3rdparty/fftreal/FFTReal.dsw create mode 100644 demos/spectrum/3rdparty/fftreal/FFTReal.h create mode 100644 demos/spectrum/3rdparty/fftreal/FFTReal.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/FFTRealFixLen.h create mode 100644 demos/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/FFTRealFixLenParam.h create mode 100644 demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.h create mode 100644 demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.h create mode 100644 demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/FFTRealSelect.h create mode 100644 demos/spectrum/3rdparty/fftreal/FFTRealSelect.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h create mode 100644 demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/OscSinCos.h create mode 100644 demos/spectrum/3rdparty/fftreal/OscSinCos.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/TestAccuracy.h create mode 100644 demos/spectrum/3rdparty/fftreal/TestAccuracy.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/TestHelperFixLen.h create mode 100644 demos/spectrum/3rdparty/fftreal/TestHelperFixLen.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/TestHelperNormal.h create mode 100644 demos/spectrum/3rdparty/fftreal/TestHelperNormal.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/TestSpeed.h create mode 100644 demos/spectrum/3rdparty/fftreal/TestSpeed.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h create mode 100644 demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/bwins/fftrealu.def create mode 100644 demos/spectrum/3rdparty/fftreal/def.h create mode 100644 demos/spectrum/3rdparty/fftreal/eabi/fftrealu.def create mode 100644 demos/spectrum/3rdparty/fftreal/fftreal.pas create mode 100644 demos/spectrum/3rdparty/fftreal/fftreal.pro create mode 100644 demos/spectrum/3rdparty/fftreal/fftreal_wrapper.cpp create mode 100644 demos/spectrum/3rdparty/fftreal/fftreal_wrapper.h create mode 100644 demos/spectrum/3rdparty/fftreal/license.txt create mode 100644 demos/spectrum/3rdparty/fftreal/readme.txt create mode 100644 demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.cpp create mode 100644 demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.h create mode 100644 demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/stopwatch/Int64.h create mode 100644 demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.cpp create mode 100644 demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.h create mode 100644 demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/stopwatch/def.h create mode 100644 demos/spectrum/3rdparty/fftreal/stopwatch/fnc.h create mode 100644 demos/spectrum/3rdparty/fftreal/stopwatch/fnc.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/test.cpp create mode 100644 demos/spectrum/3rdparty/fftreal/test_fnc.h create mode 100644 demos/spectrum/3rdparty/fftreal/test_fnc.hpp create mode 100644 demos/spectrum/3rdparty/fftreal/test_settings.h create mode 100644 demos/spectrum/3rdparty/fftreal/testapp.dpr delete mode 100644 demos/spectrum/fftreal/Array.h delete mode 100644 demos/spectrum/fftreal/Array.hpp delete mode 100644 demos/spectrum/fftreal/DynArray.h delete mode 100644 demos/spectrum/fftreal/DynArray.hpp delete mode 100644 demos/spectrum/fftreal/FFTReal.dsp delete mode 100644 demos/spectrum/fftreal/FFTReal.dsw delete mode 100644 demos/spectrum/fftreal/FFTReal.h delete mode 100644 demos/spectrum/fftreal/FFTReal.hpp delete mode 100644 demos/spectrum/fftreal/FFTRealFixLen.h delete mode 100644 demos/spectrum/fftreal/FFTRealFixLen.hpp delete mode 100644 demos/spectrum/fftreal/FFTRealFixLenParam.h delete mode 100644 demos/spectrum/fftreal/FFTRealPassDirect.h delete mode 100644 demos/spectrum/fftreal/FFTRealPassDirect.hpp delete mode 100644 demos/spectrum/fftreal/FFTRealPassInverse.h delete mode 100644 demos/spectrum/fftreal/FFTRealPassInverse.hpp delete mode 100644 demos/spectrum/fftreal/FFTRealSelect.h delete mode 100644 demos/spectrum/fftreal/FFTRealSelect.hpp delete mode 100644 demos/spectrum/fftreal/FFTRealUseTrigo.h delete mode 100644 demos/spectrum/fftreal/FFTRealUseTrigo.hpp delete mode 100644 demos/spectrum/fftreal/OscSinCos.h delete mode 100644 demos/spectrum/fftreal/OscSinCos.hpp delete mode 100644 demos/spectrum/fftreal/TestAccuracy.h delete mode 100644 demos/spectrum/fftreal/TestAccuracy.hpp delete mode 100644 demos/spectrum/fftreal/TestHelperFixLen.h delete mode 100644 demos/spectrum/fftreal/TestHelperFixLen.hpp delete mode 100644 demos/spectrum/fftreal/TestHelperNormal.h delete mode 100644 demos/spectrum/fftreal/TestHelperNormal.hpp delete mode 100644 demos/spectrum/fftreal/TestSpeed.h delete mode 100644 demos/spectrum/fftreal/TestSpeed.hpp delete mode 100644 demos/spectrum/fftreal/TestWhiteNoiseGen.h delete mode 100644 demos/spectrum/fftreal/TestWhiteNoiseGen.hpp delete mode 100644 demos/spectrum/fftreal/bwins/fftrealu.def delete mode 100644 demos/spectrum/fftreal/def.h delete mode 100644 demos/spectrum/fftreal/eabi/fftrealu.def delete mode 100644 demos/spectrum/fftreal/fftreal.pas delete mode 100644 demos/spectrum/fftreal/fftreal.pro delete mode 100644 demos/spectrum/fftreal/fftreal_wrapper.cpp delete mode 100644 demos/spectrum/fftreal/fftreal_wrapper.h delete mode 100644 demos/spectrum/fftreal/license.txt delete mode 100644 demos/spectrum/fftreal/readme.txt delete mode 100644 demos/spectrum/fftreal/stopwatch/ClockCycleCounter.cpp delete mode 100644 demos/spectrum/fftreal/stopwatch/ClockCycleCounter.h delete mode 100644 demos/spectrum/fftreal/stopwatch/ClockCycleCounter.hpp delete mode 100644 demos/spectrum/fftreal/stopwatch/Int64.h delete mode 100644 demos/spectrum/fftreal/stopwatch/StopWatch.cpp delete mode 100644 demos/spectrum/fftreal/stopwatch/StopWatch.h delete mode 100644 demos/spectrum/fftreal/stopwatch/StopWatch.hpp delete mode 100644 demos/spectrum/fftreal/stopwatch/def.h delete mode 100644 demos/spectrum/fftreal/stopwatch/fnc.h delete mode 100644 demos/spectrum/fftreal/stopwatch/fnc.hpp delete mode 100644 demos/spectrum/fftreal/test.cpp delete mode 100644 demos/spectrum/fftreal/test_fnc.h delete mode 100644 demos/spectrum/fftreal/test_fnc.hpp delete mode 100644 demos/spectrum/fftreal/test_settings.h delete mode 100644 demos/spectrum/fftreal/testapp.dpr diff --git a/demos/spectrum/3rdparty/fftreal/Array.h b/demos/spectrum/3rdparty/fftreal/Array.h new file mode 100644 index 0000000..a08e3cf --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/Array.h @@ -0,0 +1,97 @@ +/***************************************************************************** + + Array.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (Array_HEADER_INCLUDED) +#define Array_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +class Array +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef T DataType; + + Array (); + + inline const DataType & + operator [] (long pos) const; + inline DataType & + operator [] (long pos); + + static inline long + size (); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DataType _data_arr [LEN]; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + Array (const Array &other); + Array & operator = (const Array &other); + bool operator == (const Array &other); + bool operator != (const Array &other); + +}; // class Array + + + +#include "Array.hpp" + + + +#endif // Array_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/Array.hpp b/demos/spectrum/3rdparty/fftreal/Array.hpp new file mode 100644 index 0000000..8300077 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/Array.hpp @@ -0,0 +1,98 @@ +/***************************************************************************** + + Array.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (Array_CURRENT_CODEHEADER) + #error Recursive inclusion of Array code header. +#endif +#define Array_CURRENT_CODEHEADER + +#if ! defined (Array_CODEHEADER_INCLUDED) +#define Array_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +Array ::Array () +{ + // Nothing +} + + + +template +const typename Array ::DataType & Array ::operator [] (long pos) const +{ + assert (pos >= 0); + assert (pos < LEN); + + return (_data_arr [pos]); +} + + + +template +typename Array ::DataType & Array ::operator [] (long pos) +{ + assert (pos >= 0); + assert (pos < LEN); + + return (_data_arr [pos]); +} + + + +template +long Array ::size () +{ + return (LEN); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // Array_CODEHEADER_INCLUDED + +#undef Array_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/DynArray.h b/demos/spectrum/3rdparty/fftreal/DynArray.h new file mode 100644 index 0000000..8041a0c --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/DynArray.h @@ -0,0 +1,100 @@ +/***************************************************************************** + + DynArray.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (DynArray_HEADER_INCLUDED) +#define DynArray_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +class DynArray +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef T DataType; + + DynArray (); + explicit DynArray (long size); + ~DynArray (); + + inline long size () const; + inline void resize (long size); + + inline const DataType & + operator [] (long pos) const; + inline DataType & + operator [] (long pos); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DataType * _data_ptr; + long _len; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DynArray (const DynArray &other); + DynArray & operator = (const DynArray &other); + bool operator == (const DynArray &other); + bool operator != (const DynArray &other); + +}; // class DynArray + + + +#include "DynArray.hpp" + + + +#endif // DynArray_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/DynArray.hpp b/demos/spectrum/3rdparty/fftreal/DynArray.hpp new file mode 100644 index 0000000..e62b10f --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/DynArray.hpp @@ -0,0 +1,143 @@ +/***************************************************************************** + + DynArray.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (DynArray_CURRENT_CODEHEADER) + #error Recursive inclusion of DynArray code header. +#endif +#define DynArray_CURRENT_CODEHEADER + +#if ! defined (DynArray_CODEHEADER_INCLUDED) +#define DynArray_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +DynArray ::DynArray () +: _data_ptr (0) +, _len (0) +{ + // Nothing +} + + + +template +DynArray ::DynArray (long size) +: _data_ptr (0) +, _len (0) +{ + assert (size >= 0); + if (size > 0) + { + _data_ptr = new DataType [size]; + _len = size; + } +} + + + +template +DynArray ::~DynArray () +{ + delete [] _data_ptr; + _data_ptr = 0; + _len = 0; +} + + + +template +long DynArray ::size () const +{ + return (_len); +} + + + +template +void DynArray ::resize (long size) +{ + assert (size >= 0); + if (size > 0) + { + DataType * old_data_ptr = _data_ptr; + DataType * tmp_data_ptr = new DataType [size]; + + _data_ptr = tmp_data_ptr; + _len = size; + + delete [] old_data_ptr; + } +} + + + +template +const typename DynArray ::DataType & DynArray ::operator [] (long pos) const +{ + assert (pos >= 0); + assert (pos < _len); + + return (_data_ptr [pos]); +} + + + +template +typename DynArray ::DataType & DynArray ::operator [] (long pos) +{ + assert (pos >= 0); + assert (pos < _len); + + return (_data_ptr [pos]); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // DynArray_CODEHEADER_INCLUDED + +#undef DynArray_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTReal.dsp b/demos/spectrum/3rdparty/fftreal/FFTReal.dsp new file mode 100644 index 0000000..fe970db --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTReal.dsp @@ -0,0 +1,273 @@ +# Microsoft Developer Studio Project File - Name="FFTReal" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=FFTReal - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "FFTReal.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "FFTReal.mak" CFG="FFTReal - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "FFTReal - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "FFTReal - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "FFTReal - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GR /GX /O2 /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x40c /d "NDEBUG" +# ADD RSC /l 0x40c /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "FFTReal - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Gm /GR /GX /Zi /Od /Gf /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c +# ADD BASE RSC /l 0x40c /d "_DEBUG" +# ADD RSC /l 0x40c /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "FFTReal - Win32 Release" +# Name "FFTReal - Win32 Debug" +# Begin Group "Library" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\Array.h +# End Source File +# Begin Source File + +SOURCE=.\Array.hpp +# End Source File +# Begin Source File + +SOURCE=.\def.h +# End Source File +# Begin Source File + +SOURCE=.\DynArray.h +# End Source File +# Begin Source File + +SOURCE=.\DynArray.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTReal.h +# End Source File +# Begin Source File + +SOURCE=.\FFTReal.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealFixLen.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealFixLen.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealFixLenParam.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassDirect.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassDirect.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassInverse.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassInverse.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealSelect.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealSelect.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealUseTrigo.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealUseTrigo.hpp +# End Source File +# Begin Source File + +SOURCE=.\OscSinCos.h +# End Source File +# Begin Source File + +SOURCE=.\OscSinCos.hpp +# End Source File +# End Group +# Begin Group "Test" + +# PROP Default_Filter "" +# Begin Group "stopwatch" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\stopwatch\ClockCycleCounter.cpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\ClockCycleCounter.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\ClockCycleCounter.hpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\def.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\fnc.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\fnc.hpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\Int64.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\StopWatch.cpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\StopWatch.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\StopWatch.hpp +# End Source File +# End Group +# Begin Source File + +SOURCE=.\test.cpp +# End Source File +# Begin Source File + +SOURCE=.\test_fnc.h +# End Source File +# Begin Source File + +SOURCE=.\test_fnc.hpp +# End Source File +# Begin Source File + +SOURCE=.\test_settings.h +# End Source File +# Begin Source File + +SOURCE=.\TestAccuracy.h +# End Source File +# Begin Source File + +SOURCE=.\TestAccuracy.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestHelperFixLen.h +# End Source File +# Begin Source File + +SOURCE=.\TestHelperFixLen.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestHelperNormal.h +# End Source File +# Begin Source File + +SOURCE=.\TestHelperNormal.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestSpeed.h +# End Source File +# Begin Source File + +SOURCE=.\TestSpeed.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestWhiteNoiseGen.h +# End Source File +# Begin Source File + +SOURCE=.\TestWhiteNoiseGen.hpp +# End Source File +# End Group +# End Target +# End Project diff --git a/demos/spectrum/3rdparty/fftreal/FFTReal.dsw b/demos/spectrum/3rdparty/fftreal/FFTReal.dsw new file mode 100644 index 0000000..076b0ae --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTReal.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "FFTReal"=.\FFTReal.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/demos/spectrum/3rdparty/fftreal/FFTReal.h b/demos/spectrum/3rdparty/fftreal/FFTReal.h new file mode 100644 index 0000000..9fb2725 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTReal.h @@ -0,0 +1,142 @@ +/***************************************************************************** + + FFTReal.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTReal_HEADER_INCLUDED) +#define FFTReal_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "DynArray.h" +#include "OscSinCos.h" + + + +template +class FFTReal +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + enum { MAX_BIT_DEPTH = 30 }; // So length can be represented as long int + + typedef DT DataType; + + explicit FFTReal (long length); + virtual ~FFTReal () {} + + long get_length () const; + void do_fft (DataType f [], const DataType x []) const; + void do_ifft (const DataType f [], DataType x []) const; + void rescale (DataType x []) const; + DataType * use_buffer () const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + // Over this bit depth, we use direct calculation for sin/cos + enum { TRIGO_BD_LIMIT = 12 }; + + typedef OscSinCos OscType; + + void init_br_lut (); + void init_trigo_lut (); + void init_trigo_osc (); + + FORCEINLINE const long * + get_br_ptr () const; + FORCEINLINE const DataType * + get_trigo_ptr (int level) const; + FORCEINLINE long + get_trigo_level_index (int level) const; + + inline void compute_fft_general (DataType f [], const DataType x []) const; + inline void compute_direct_pass_1_2 (DataType df [], const DataType x []) const; + inline void compute_direct_pass_3 (DataType df [], const DataType sf []) const; + inline void compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const; + inline void compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const; + inline void compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const; + + inline void compute_ifft_general (const DataType f [], DataType x []) const; + inline void compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const; + inline void compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const; + inline void compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const; + inline void compute_inverse_pass_3 (DataType df [], const DataType sf []) const; + inline void compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const; + + const long _length; + const int _nbr_bits; + DynArray + _br_lut; + DynArray + _trigo_lut; + mutable DynArray + _buffer; + mutable DynArray + _trigo_osc; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTReal (); + FFTReal (const FFTReal &other); + FFTReal & operator = (const FFTReal &other); + bool operator == (const FFTReal &other); + bool operator != (const FFTReal &other); + +}; // class FFTReal + + + +#include "FFTReal.hpp" + + + +#endif // FFTReal_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTReal.hpp b/demos/spectrum/3rdparty/fftreal/FFTReal.hpp new file mode 100644 index 0000000..335d771 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTReal.hpp @@ -0,0 +1,916 @@ +/***************************************************************************** + + FFTReal.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTReal_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTReal code header. +#endif +#define FFTReal_CURRENT_CODEHEADER + +#if ! defined (FFTReal_CODEHEADER_INCLUDED) +#define FFTReal_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include +#include + + + +static inline bool FFTReal_is_pow2 (long x) +{ + assert (x > 0); + + return ((x & -x) == x); +} + + + +static inline int FFTReal_get_next_pow2 (long x) +{ + --x; + + int p = 0; + while ((x & ~0xFFFFL) != 0) + { + p += 16; + x >>= 16; + } + while ((x & ~0xFL) != 0) + { + p += 4; + x >>= 4; + } + while (x > 0) + { + ++p; + x >>= 1; + } + + return (p); +} + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/* +============================================================================== +Name: ctor +Input parameters: + - length: length of the array on which we want to do a FFT. Range: power of + 2 only, > 0. +Throws: std::bad_alloc +============================================================================== +*/ + +template +FFTReal
    ::FFTReal (long length) +: _length (length) +, _nbr_bits (FFTReal_get_next_pow2 (length)) +, _br_lut () +, _trigo_lut () +, _buffer (length) +, _trigo_osc () +{ + assert (FFTReal_is_pow2 (length)); + assert (_nbr_bits <= MAX_BIT_DEPTH); + + init_br_lut (); + init_trigo_lut (); + init_trigo_osc (); +} + + + +/* +============================================================================== +Name: get_length +Description: + Returns the number of points processed by this FFT object. +Returns: The number of points, power of 2, > 0. +Throws: Nothing +============================================================================== +*/ + +template +long FFTReal
    ::get_length () const +{ + return (_length); +} + + + +/* +============================================================================== +Name: do_fft +Description: + Compute the FFT of the array. +Input parameters: + - x: pointer on the source array (time). +Output parameters: + - f: pointer on the destination array (frequencies). + f [0...length(x)/2] = real values, + f [length(x)/2+1...length(x)-1] = negative imaginary values of + coefficents 1...length(x)/2-1. +Throws: Nothing +============================================================================== +*/ + +template +void FFTReal
    ::do_fft (DataType f [], const DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + // General case + if (_nbr_bits > 2) + { + compute_fft_general (f, x); + } + + // 4-point FFT + else if (_nbr_bits == 2) + { + f [1] = x [0] - x [2]; + f [3] = x [1] - x [3]; + + const DataType b_0 = x [0] + x [2]; + const DataType b_2 = x [1] + x [3]; + + f [0] = b_0 + b_2; + f [2] = b_0 - b_2; + } + + // 2-point FFT + else if (_nbr_bits == 1) + { + f [0] = x [0] + x [1]; + f [1] = x [0] - x [1]; + } + + // 1-point FFT + else + { + f [0] = x [0]; + } +} + + + +/* +============================================================================== +Name: do_ifft +Description: + Compute the inverse FFT of the array. Note that data must be post-scaled: + IFFT (FFT (x)) = x * length (x). +Input parameters: + - f: pointer on the source array (frequencies). + f [0...length(x)/2] = real values + f [length(x)/2+1...length(x)-1] = negative imaginary values of + coefficents 1...length(x)/2-1. +Output parameters: + - x: pointer on the destination array (time). +Throws: Nothing +============================================================================== +*/ + +template +void FFTReal
    ::do_ifft (const DataType f [], DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + // General case + if (_nbr_bits > 2) + { + compute_ifft_general (f, x); + } + + // 4-point IFFT + else if (_nbr_bits == 2) + { + const DataType b_0 = f [0] + f [2]; + const DataType b_2 = f [0] - f [2]; + + x [0] = b_0 + f [1] * 2; + x [2] = b_0 - f [1] * 2; + x [1] = b_2 + f [3] * 2; + x [3] = b_2 - f [3] * 2; + } + + // 2-point IFFT + else if (_nbr_bits == 1) + { + x [0] = f [0] + f [1]; + x [1] = f [0] - f [1]; + } + + // 1-point IFFT + else + { + x [0] = f [0]; + } +} + + + +/* +============================================================================== +Name: rescale +Description: + Scale an array by divide each element by its length. This function should + be called after FFT + IFFT. +Input parameters: + - x: pointer on array to rescale (time or frequency). +Throws: Nothing +============================================================================== +*/ + +template +void FFTReal
    ::rescale (DataType x []) const +{ + const DataType mul = DataType (1.0 / _length); + + if (_length < 4) + { + long i = _length - 1; + do + { + x [i] *= mul; + --i; + } + while (i >= 0); + } + + else + { + assert ((_length & 3) == 0); + + // Could be optimized with SIMD instruction sets (needs alignment check) + long i = _length - 4; + do + { + x [i + 0] *= mul; + x [i + 1] *= mul; + x [i + 2] *= mul; + x [i + 3] *= mul; + i -= 4; + } + while (i >= 0); + } +} + + + +/* +============================================================================== +Name: use_buffer +Description: + Access the internal buffer, whose length is the FFT one. + Buffer content will be erased at each do_fft() / do_ifft() call! + This buffer cannot be used as: + - source for FFT or IFFT done with this object + - destination for FFT or IFFT done with this object +Returns: + Buffer start address +Throws: Nothing +============================================================================== +*/ + +template +typename FFTReal
    ::DataType * FFTReal
    ::use_buffer () const +{ + return (&_buffer [0]); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void FFTReal
    ::init_br_lut () +{ + const long length = 1L << _nbr_bits; + _br_lut.resize (length); + + _br_lut [0] = 0; + long br_index = 0; + for (long cnt = 1; cnt < length; ++cnt) + { + // ++br_index (bit reversed) + long bit = length >> 1; + while (((br_index ^= bit) & bit) == 0) + { + bit >>= 1; + } + + _br_lut [cnt] = br_index; + } +} + + + +template +void FFTReal
    ::init_trigo_lut () +{ + using namespace std; + + if (_nbr_bits > 3) + { + const long total_len = (1L << (_nbr_bits - 1)) - 4; + _trigo_lut.resize (total_len); + + for (int level = 3; level < _nbr_bits; ++level) + { + const long level_len = 1L << (level - 1); + DataType * const level_ptr = + &_trigo_lut [get_trigo_level_index (level)]; + const double mul = PI / (level_len << 1); + + for (long i = 0; i < level_len; ++ i) + { + level_ptr [i] = static_cast (cos (i * mul)); + } + } + } +} + + + +template +void FFTReal
    ::init_trigo_osc () +{ + const int nbr_osc = _nbr_bits - TRIGO_BD_LIMIT; + if (nbr_osc > 0) + { + _trigo_osc.resize (nbr_osc); + + for (int osc_cnt = 0; osc_cnt < nbr_osc; ++osc_cnt) + { + OscType & osc = _trigo_osc [osc_cnt]; + + const long len = 1L << (TRIGO_BD_LIMIT + osc_cnt); + const double mul = (0.5 * PI) / len; + osc.set_step (mul); + } + } +} + + + +template +const long * FFTReal
    ::get_br_ptr () const +{ + return (&_br_lut [0]); +} + + + +template +const typename FFTReal
    ::DataType * FFTReal
    ::get_trigo_ptr (int level) const +{ + assert (level >= 3); + + return (&_trigo_lut [get_trigo_level_index (level)]); +} + + + +template +long FFTReal
    ::get_trigo_level_index (int level) const +{ + assert (level >= 3); + + return ((1L << (level - 1)) - 4); +} + + + +// Transform in several passes +template +void FFTReal
    ::compute_fft_general (DataType f [], const DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + DataType * sf; + DataType * df; + + if ((_nbr_bits & 1) != 0) + { + df = use_buffer (); + sf = f; + } + else + { + df = f; + sf = use_buffer (); + } + + compute_direct_pass_1_2 (df, x); + compute_direct_pass_3 (sf, df); + + for (int pass = 3; pass < _nbr_bits; ++ pass) + { + compute_direct_pass_n (df, sf, pass); + + DataType * const temp_ptr = df; + df = sf; + sf = temp_ptr; + } +} + + + +template +void FFTReal
    ::compute_direct_pass_1_2 (DataType df [], const DataType x []) const +{ + assert (df != 0); + assert (x != 0); + assert (df != x); + + const long * const bit_rev_lut_ptr = get_br_ptr (); + long coef_index = 0; + do + { + const long rev_index_0 = bit_rev_lut_ptr [coef_index]; + const long rev_index_1 = bit_rev_lut_ptr [coef_index + 1]; + const long rev_index_2 = bit_rev_lut_ptr [coef_index + 2]; + const long rev_index_3 = bit_rev_lut_ptr [coef_index + 3]; + + DataType * const df2 = df + coef_index; + df2 [1] = x [rev_index_0] - x [rev_index_1]; + df2 [3] = x [rev_index_2] - x [rev_index_3]; + + const DataType sf_0 = x [rev_index_0] + x [rev_index_1]; + const DataType sf_2 = x [rev_index_2] + x [rev_index_3]; + + df2 [0] = sf_0 + sf_2; + df2 [2] = sf_0 - sf_2; + + coef_index += 4; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_direct_pass_3 (DataType df [], const DataType sf []) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + long coef_index = 0; + do + { + DataType v; + + df [coef_index] = sf [coef_index] + sf [coef_index + 4]; + df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; + df [coef_index + 2] = sf [coef_index + 2]; + df [coef_index + 6] = sf [coef_index + 6]; + + v = (sf [coef_index + 5] - sf [coef_index + 7]) * sqrt2_2; + df [coef_index + 1] = sf [coef_index + 1] + v; + df [coef_index + 3] = sf [coef_index + 1] - v; + + v = (sf [coef_index + 5] + sf [coef_index + 7]) * sqrt2_2; + df [coef_index + 5] = v + sf [coef_index + 3]; + df [coef_index + 7] = v - sf [coef_index + 3]; + + coef_index += 8; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + if (pass <= TRIGO_BD_LIMIT) + { + compute_direct_pass_n_lut (df, sf, pass); + } + else + { + compute_direct_pass_n_osc (df, sf, pass); + } +} + + + +template +void FFTReal
    ::compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + const DataType * const cos_ptr = get_trigo_ptr (pass); + do + { + const DataType * const sf1r = sf + coef_index; + const DataType * const sf2r = sf1r + nbr_coef; + DataType * const dfr = df + coef_index; + DataType * const dfi = dfr + nbr_coef; + + // Extreme coefficients are always real + dfr [0] = sf1r [0] + sf2r [0]; + dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = + dfr [h_nbr_coef] = sf1r [h_nbr_coef]; + dfi [h_nbr_coef] = sf2r [h_nbr_coef]; + + // Others are conjugate complex numbers + const DataType * const sf1i = sf1r + h_nbr_coef; + const DataType * const sf2i = sf1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); + const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); + DataType v; + + v = sf2r [i] * c - sf2i [i] * s; + dfr [i] = sf1r [i] + v; + dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = + + v = sf2r [i] * s + sf2i [i] * c; + dfi [i] = v + sf1i [i]; + dfi [nbr_coef - i] = v - sf1i [i]; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass > TRIGO_BD_LIMIT); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; + do + { + const DataType * const sf1r = sf + coef_index; + const DataType * const sf2r = sf1r + nbr_coef; + DataType * const dfr = df + coef_index; + DataType * const dfi = dfr + nbr_coef; + + osc.clear_buffers (); + + // Extreme coefficients are always real + dfr [0] = sf1r [0] + sf2r [0]; + dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = + dfr [h_nbr_coef] = sf1r [h_nbr_coef]; + dfi [h_nbr_coef] = sf2r [h_nbr_coef]; + + // Others are conjugate complex numbers + const DataType * const sf1i = sf1r + h_nbr_coef; + const DataType * const sf2i = sf1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + osc.step (); + const DataType c = osc.get_cos (); + const DataType s = osc.get_sin (); + DataType v; + + v = sf2r [i] * c - sf2i [i] * s; + dfr [i] = sf1r [i] + v; + dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = + + v = sf2r [i] * s + sf2i [i] * c; + dfi [i] = v + sf1i [i]; + dfi [nbr_coef - i] = v - sf1i [i]; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +// Transform in several pass +template +void FFTReal
    ::compute_ifft_general (const DataType f [], DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + DataType * sf = const_cast (f); + DataType * df; + DataType * df_temp; + + if (_nbr_bits & 1) + { + df = use_buffer (); + df_temp = x; + } + else + { + df = x; + df_temp = use_buffer (); + } + + for (int pass = _nbr_bits - 1; pass >= 3; -- pass) + { + compute_inverse_pass_n (df, sf, pass); + + if (pass < _nbr_bits - 1) + { + DataType * const temp_ptr = df; + df = sf; + sf = temp_ptr; + } + else + { + sf = df; + df = df_temp; + } + } + + compute_inverse_pass_3 (df, sf); + compute_inverse_pass_1_2 (x, df); +} + + + +template +void FFTReal
    ::compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + if (pass <= TRIGO_BD_LIMIT) + { + compute_inverse_pass_n_lut (df, sf, pass); + } + else + { + compute_inverse_pass_n_osc (df, sf, pass); + } +} + + + +template +void FFTReal
    ::compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + const DataType * const cos_ptr = get_trigo_ptr (pass); + do + { + const DataType * const sfr = sf + coef_index; + const DataType * const sfi = sfr + nbr_coef; + DataType * const df1r = df + coef_index; + DataType * const df2r = df1r + nbr_coef; + + // Extreme coefficients are always real + df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] + df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] + df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; + df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; + + // Others are conjugate complex numbers + DataType * const df1i = df1r + h_nbr_coef; + DataType * const df2i = df1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] + df1i [i] = sfi [i] - sfi [nbr_coef - i]; + + const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); + const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); + const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] + const DataType vi = sfi [i] + sfi [nbr_coef - i]; + + df2r [i] = vr * c + vi * s; + df2i [i] = vi * c - vr * s; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass > TRIGO_BD_LIMIT); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; + do + { + const DataType * const sfr = sf + coef_index; + const DataType * const sfi = sfr + nbr_coef; + DataType * const df1r = df + coef_index; + DataType * const df2r = df1r + nbr_coef; + + osc.clear_buffers (); + + // Extreme coefficients are always real + df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] + df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] + df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; + df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; + + // Others are conjugate complex numbers + DataType * const df1i = df1r + h_nbr_coef; + DataType * const df2i = df1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] + df1i [i] = sfi [i] - sfi [nbr_coef - i]; + + osc.step (); + const DataType c = osc.get_cos (); + const DataType s = osc.get_sin (); + const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] + const DataType vi = sfi [i] + sfi [nbr_coef - i]; + + df2r [i] = vr * c + vi * s; + df2i [i] = vi * c - vr * s; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_inverse_pass_3 (DataType df [], const DataType sf []) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + long coef_index = 0; + do + { + df [coef_index] = sf [coef_index] + sf [coef_index + 4]; + df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; + df [coef_index + 2] = sf [coef_index + 2] * 2; + df [coef_index + 6] = sf [coef_index + 6] * 2; + + df [coef_index + 1] = sf [coef_index + 1] + sf [coef_index + 3]; + df [coef_index + 3] = sf [coef_index + 5] - sf [coef_index + 7]; + + const DataType vr = sf [coef_index + 1] - sf [coef_index + 3]; + const DataType vi = sf [coef_index + 5] + sf [coef_index + 7]; + + df [coef_index + 5] = (vr + vi) * sqrt2_2; + df [coef_index + 7] = (vi - vr) * sqrt2_2; + + coef_index += 8; + } + while (coef_index < _length); +} + + + +template +void FFTReal
    ::compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const +{ + assert (x != 0); + assert (sf != 0); + assert (x != sf); + + const long * bit_rev_lut_ptr = get_br_ptr (); + const DataType * sf2 = sf; + long coef_index = 0; + do + { + { + const DataType b_0 = sf2 [0] + sf2 [2]; + const DataType b_2 = sf2 [0] - sf2 [2]; + const DataType b_1 = sf2 [1] * 2; + const DataType b_3 = sf2 [3] * 2; + + x [bit_rev_lut_ptr [0]] = b_0 + b_1; + x [bit_rev_lut_ptr [1]] = b_0 - b_1; + x [bit_rev_lut_ptr [2]] = b_2 + b_3; + x [bit_rev_lut_ptr [3]] = b_2 - b_3; + } + { + const DataType b_0 = sf2 [4] + sf2 [6]; + const DataType b_2 = sf2 [4] - sf2 [6]; + const DataType b_1 = sf2 [5] * 2; + const DataType b_3 = sf2 [7] * 2; + + x [bit_rev_lut_ptr [4]] = b_0 + b_1; + x [bit_rev_lut_ptr [5]] = b_0 - b_1; + x [bit_rev_lut_ptr [6]] = b_2 + b_3; + x [bit_rev_lut_ptr [7]] = b_2 - b_3; + } + + sf2 += 8; + coef_index += 8; + bit_rev_lut_ptr += 8; + } + while (coef_index < _length); +} + + + +#endif // FFTReal_CODEHEADER_INCLUDED + +#undef FFTReal_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.h b/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.h new file mode 100644 index 0000000..0b80266 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.h @@ -0,0 +1,130 @@ +/***************************************************************************** + + FFTRealFixLen.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealFixLen_HEADER_INCLUDED) +#define FFTRealFixLen_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "Array.h" +#include "DynArray.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + +template +class FFTRealFixLen +{ + typedef int CompileTimeCheck1 [(LL2 >= 0) ? 1 : -1]; + typedef int CompileTimeCheck2 [(LL2 <= 30) ? 1 : -1]; + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; + + enum { FFT_LEN_L2 = LL2 }; + enum { FFT_LEN = 1 << FFT_LEN_L2 }; + + FFTRealFixLen (); + + inline long get_length () const; + void do_fft (DataType f [], const DataType x []); + void do_ifft (const DataType f [], DataType x []); + void rescale (DataType x []) const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + enum { TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT }; + + enum { BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) }; + enum { BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 }; + + enum { TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0) + ? (int)FFT_LEN_L2 + : (int)TRIGO_BD_LIMIT }; + enum { TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) }; + enum { TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 }; + + enum { NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD }; + enum { TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 }; + + void build_br_lut (); + void build_trigo_lut (); + void build_trigo_osc (); + + DynArray + _buffer; + DynArray + _br_data; + DynArray + _trigo_data; + Array + _trigo_osc; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealFixLen (const FFTRealFixLen &other); + FFTRealFixLen& operator = (const FFTRealFixLen &other); + bool operator == (const FFTRealFixLen &other); + bool operator != (const FFTRealFixLen &other); + +}; // class FFTRealFixLen + + + +#include "FFTRealFixLen.hpp" + + + +#endif // FFTRealFixLen_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp b/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp new file mode 100644 index 0000000..6defb00 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp @@ -0,0 +1,322 @@ +/***************************************************************************** + + FFTRealFixLen.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealFixLen_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealFixLen code header. +#endif +#define FFTRealFixLen_CURRENT_CODEHEADER + +#if ! defined (FFTRealFixLen_CODEHEADER_INCLUDED) +#define FFTRealFixLen_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealPassDirect.h" +#include "FFTRealPassInverse.h" +#include "FFTRealSelect.h" + +#include +#include + +namespace std { } + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +FFTRealFixLen ::FFTRealFixLen () +: _buffer (FFT_LEN) +, _br_data (BR_ARR_SIZE) +, _trigo_data (TRIGO_TABLE_ARR_SIZE) +, _trigo_osc () +{ + build_br_lut (); + build_trigo_lut (); + build_trigo_osc (); +} + + + +template +long FFTRealFixLen ::get_length () const +{ + return (FFT_LEN); +} + + + +// General case +template +void FFTRealFixLen ::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + assert (FFT_LEN_L2 >= 3); + + // Do the transform in several passes + const DataType * cos_ptr = &_trigo_data [0]; + const long * br_ptr = &_br_data [0]; + + FFTRealPassDirect ::process ( + FFT_LEN, + f, + &_buffer [0], + x, + cos_ptr, + TRIGO_TABLE_ARR_SIZE, + br_ptr, + &_trigo_osc [0] + ); +} + +// 4-point FFT +template <> +void FFTRealFixLen <2>::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + f [1] = x [0] - x [2]; + f [3] = x [1] - x [3]; + + const DataType b_0 = x [0] + x [2]; + const DataType b_2 = x [1] + x [3]; + + f [0] = b_0 + b_2; + f [2] = b_0 - b_2; +} + +// 2-point FFT +template <> +void FFTRealFixLen <1>::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + f [0] = x [0] + x [1]; + f [1] = x [0] - x [1]; +} + +// 1-point FFT +template <> +void FFTRealFixLen <0>::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + + f [0] = x [0]; +} + + + +// General case +template +void FFTRealFixLen ::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + assert (FFT_LEN_L2 >= 3); + + // Do the transform in several passes + DataType * s_ptr = + FFTRealSelect ::sel_bin (&_buffer [0], x); + DataType * d_ptr = + FFTRealSelect ::sel_bin (x, &_buffer [0]); + const DataType * cos_ptr = &_trigo_data [0]; + const long * br_ptr = &_br_data [0]; + + FFTRealPassInverse ::process ( + FFT_LEN, + d_ptr, + s_ptr, + f, + cos_ptr, + TRIGO_TABLE_ARR_SIZE, + br_ptr, + &_trigo_osc [0] + ); +} + +// 4-point IFFT +template <> +void FFTRealFixLen <2>::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + const DataType b_0 = f [0] + f [2]; + const DataType b_2 = f [0] - f [2]; + + x [0] = b_0 + f [1] * 2; + x [2] = b_0 - f [1] * 2; + x [1] = b_2 + f [3] * 2; + x [3] = b_2 - f [3] * 2; +} + +// 2-point IFFT +template <> +void FFTRealFixLen <1>::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + x [0] = f [0] + f [1]; + x [1] = f [0] - f [1]; +} + +// 1-point IFFT +template <> +void FFTRealFixLen <0>::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + x [0] = f [0]; +} + + + + +template +void FFTRealFixLen ::rescale (DataType x []) const +{ + assert (x != 0); + + const DataType mul = DataType (1.0 / FFT_LEN); + + if (FFT_LEN < 4) + { + long i = FFT_LEN - 1; + do + { + x [i] *= mul; + --i; + } + while (i >= 0); + } + + else + { + assert ((FFT_LEN & 3) == 0); + + // Could be optimized with SIMD instruction sets (needs alignment check) + long i = FFT_LEN - 4; + do + { + x [i + 0] *= mul; + x [i + 1] *= mul; + x [i + 2] *= mul; + x [i + 3] *= mul; + i -= 4; + } + while (i >= 0); + } +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void FFTRealFixLen ::build_br_lut () +{ + _br_data [0] = 0; + for (long cnt = 1; cnt < BR_ARR_SIZE; ++cnt) + { + long index = cnt << 2; + long br_index = 0; + + int bit_cnt = FFT_LEN_L2; + do + { + br_index <<= 1; + br_index += (index & 1); + index >>= 1; + + -- bit_cnt; + } + while (bit_cnt > 0); + + _br_data [cnt] = br_index; + } +} + + + +template +void FFTRealFixLen ::build_trigo_lut () +{ + const double mul = (0.5 * PI) / TRIGO_TABLE_ARR_SIZE; + for (long i = 0; i < TRIGO_TABLE_ARR_SIZE; ++ i) + { + using namespace std; + + _trigo_data [i] = DataType (cos (i * mul)); + } +} + + + +template +void FFTRealFixLen ::build_trigo_osc () +{ + for (int i = 0; i < NBR_TRIGO_OSC; ++i) + { + OscType & osc = _trigo_osc [i]; + + const long len = static_cast (TRIGO_TABLE_ARR_SIZE) << (i + 1); + const double mul = (0.5 * PI) / len; + osc.set_step (mul); + } +} + + + +#endif // FFTRealFixLen_CODEHEADER_INCLUDED + +#undef FFTRealFixLen_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealFixLenParam.h b/demos/spectrum/3rdparty/fftreal/FFTRealFixLenParam.h new file mode 100644 index 0000000..163c083 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealFixLenParam.h @@ -0,0 +1,93 @@ +/***************************************************************************** + + FFTRealFixLenParam.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealFixLenParam_HEADER_INCLUDED) +#define FFTRealFixLenParam_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +class FFTRealFixLenParam +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + // Over this bit depth, we use direct calculation for sin/cos + enum { TRIGO_BD_LIMIT = 12 }; + + typedef float DataType; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + +#if 0 // To avoid GCC warning: + // All member functions in class 'FFTRealFixLenParam' are private + FFTRealFixLenParam (); + ~FFTRealFixLenParam (); + FFTRealFixLenParam (const FFTRealFixLenParam &other); + FFTRealFixLenParam & + operator = (const FFTRealFixLenParam &other); + bool operator == (const FFTRealFixLenParam &other); + bool operator != (const FFTRealFixLenParam &other); +#endif + +}; // class FFTRealFixLenParam + + + +//#include "FFTRealFixLenParam.hpp" + + + +#endif // FFTRealFixLenParam_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.h b/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.h new file mode 100644 index 0000000..7d19c02 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.h @@ -0,0 +1,96 @@ +/***************************************************************************** + + FFTRealPassDirect.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealPassDirect_HEADER_INCLUDED) +#define FFTRealPassDirect_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + +template +class FFTRealPassDirect +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; + + FORCEINLINE static void + process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealPassDirect (); + ~FFTRealPassDirect (); + FFTRealPassDirect (const FFTRealPassDirect &other); + FFTRealPassDirect & + operator = (const FFTRealPassDirect &other); + bool operator == (const FFTRealPassDirect &other); + bool operator != (const FFTRealPassDirect &other); + +}; // class FFTRealPassDirect + + + +#include "FFTRealPassDirect.hpp" + + + +#endif // FFTRealPassDirect_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.hpp b/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.hpp new file mode 100644 index 0000000..db9d568 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.hpp @@ -0,0 +1,204 @@ +/***************************************************************************** + + FFTRealPassDirect.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealPassDirect_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealPassDirect code header. +#endif +#define FFTRealPassDirect_CURRENT_CODEHEADER + +#if ! defined (FFTRealPassDirect_CODEHEADER_INCLUDED) +#define FFTRealPassDirect_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTRealUseTrigo.h" + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <> +void FFTRealPassDirect <1>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // First and second pass at once + const long qlen = len >> 2; + + long coef_index = 0; + do + { + // To do: unroll the loop (2x). + const long ri_0 = br_ptr [coef_index >> 2]; + const long ri_1 = ri_0 + 2 * qlen; // bit_rev_lut_ptr [coef_index + 1]; + const long ri_2 = ri_0 + 1 * qlen; // bit_rev_lut_ptr [coef_index + 2]; + const long ri_3 = ri_0 + 3 * qlen; // bit_rev_lut_ptr [coef_index + 3]; + + DataType * const df2 = dest_ptr + coef_index; + df2 [1] = x_ptr [ri_0] - x_ptr [ri_1]; + df2 [3] = x_ptr [ri_2] - x_ptr [ri_3]; + + const DataType sf_0 = x_ptr [ri_0] + x_ptr [ri_1]; + const DataType sf_2 = x_ptr [ri_2] + x_ptr [ri_3]; + + df2 [0] = sf_0 + sf_2; + df2 [2] = sf_0 - sf_2; + + coef_index += 4; + } + while (coef_index < len); +} + +template <> +void FFTRealPassDirect <2>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Executes "previous" passes first. Inverts source and destination buffers + FFTRealPassDirect <1>::process ( + len, + src_ptr, + dest_ptr, + x_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + + // Third pass + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + + long coef_index = 0; + do + { + dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; + dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; + dest_ptr [coef_index + 2] = src_ptr [coef_index + 2]; + dest_ptr [coef_index + 6] = src_ptr [coef_index + 6]; + + DataType v; + + v = (src_ptr [coef_index + 5] - src_ptr [coef_index + 7]) * sqrt2_2; + dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + v; + dest_ptr [coef_index + 3] = src_ptr [coef_index + 1] - v; + + v = (src_ptr [coef_index + 5] + src_ptr [coef_index + 7]) * sqrt2_2; + dest_ptr [coef_index + 5] = v + src_ptr [coef_index + 3]; + dest_ptr [coef_index + 7] = v - src_ptr [coef_index + 3]; + + coef_index += 8; + } + while (coef_index < len); +} + +template +void FFTRealPassDirect ::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Executes "previous" passes first. Inverts source and destination buffers + FFTRealPassDirect ::process ( + len, + src_ptr, + dest_ptr, + x_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + + const long dist = 1L << (PASS - 1); + const long c1_r = 0; + const long c1_i = dist; + const long c2_r = dist * 2; + const long c2_i = dist * 3; + const long cend = dist * 4; + const long table_step = cos_len >> (PASS - 1); + + enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; + enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; + + long coef_index = 0; + do + { + const DataType * const sf = src_ptr + coef_index; + DataType * const df = dest_ptr + coef_index; + + // Extreme coefficients are always real + df [c1_r] = sf [c1_r] + sf [c2_r]; + df [c2_r] = sf [c1_r] - sf [c2_r]; + df [c1_i] = sf [c1_i]; + df [c2_i] = sf [c2_i]; + + FFTRealUseTrigo ::prepare (osc_list [TRIGO_OSC]); + + // Others are conjugate complex numbers + for (long i = 1; i < dist; ++ i) + { + DataType c; + DataType s; + FFTRealUseTrigo ::iterate ( + osc_list [TRIGO_OSC], + c, + s, + cos_ptr, + i * table_step, + (dist - i) * table_step + ); + + const DataType sf_r_i = sf [c1_r + i]; + const DataType sf_i_i = sf [c1_i + i]; + + const DataType v1 = sf [c2_r + i] * c - sf [c2_i + i] * s; + df [c1_r + i] = sf_r_i + v1; + df [c2_r - i] = sf_r_i - v1; + + const DataType v2 = sf [c2_r + i] * s + sf [c2_i + i] * c; + df [c2_r + i] = v2 + sf_i_i; + df [cend - i] = v2 - sf_i_i; + } + + coef_index += cend; + } + while (coef_index < len); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // FFTRealPassDirect_CODEHEADER_INCLUDED + +#undef FFTRealPassDirect_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.h b/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.h new file mode 100644 index 0000000..2de8952 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.h @@ -0,0 +1,101 @@ +/***************************************************************************** + + FFTRealPassInverse.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealPassInverse_HEADER_INCLUDED) +#define FFTRealPassInverse_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + + +template +class FFTRealPassInverse +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; + + FORCEINLINE static void + process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + FORCEINLINE static void + process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + FORCEINLINE static void + process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealPassInverse (); + ~FFTRealPassInverse (); + FFTRealPassInverse (const FFTRealPassInverse &other); + FFTRealPassInverse & + operator = (const FFTRealPassInverse &other); + bool operator == (const FFTRealPassInverse &other); + bool operator != (const FFTRealPassInverse &other); + +}; // class FFTRealPassInverse + + + +#include "FFTRealPassInverse.hpp" + + + +#endif // FFTRealPassInverse_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.hpp b/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.hpp new file mode 100644 index 0000000..5737546 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.hpp @@ -0,0 +1,229 @@ +/***************************************************************************** + + FFTRealPassInverse.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealPassInverse_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealPassInverse code header. +#endif +#define FFTRealPassInverse_CURRENT_CODEHEADER + +#if ! defined (FFTRealPassInverse_CODEHEADER_INCLUDED) +#define FFTRealPassInverse_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTRealUseTrigo.h" + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void FFTRealPassInverse ::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + process_internal ( + len, + dest_ptr, + f_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + FFTRealPassInverse ::process_rec ( + len, + src_ptr, + dest_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); +} + + + +template +void FFTRealPassInverse ::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + process_internal ( + len, + dest_ptr, + src_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + FFTRealPassInverse ::process_rec ( + len, + src_ptr, + dest_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); +} + +template <> +void FFTRealPassInverse <0>::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Stops recursion +} + + + +template +void FFTRealPassInverse ::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + const long dist = 1L << (PASS - 1); + const long c1_r = 0; + const long c1_i = dist; + const long c2_r = dist * 2; + const long c2_i = dist * 3; + const long cend = dist * 4; + const long table_step = cos_len >> (PASS - 1); + + enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; + enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; + + long coef_index = 0; + do + { + const DataType * const sf = src_ptr + coef_index; + DataType * const df = dest_ptr + coef_index; + + // Extreme coefficients are always real + df [c1_r] = sf [c1_r] + sf [c2_r]; + df [c2_r] = sf [c1_r] - sf [c2_r]; + df [c1_i] = sf [c1_i] * 2; + df [c2_i] = sf [c2_i] * 2; + + FFTRealUseTrigo ::prepare (osc_list [TRIGO_OSC]); + + // Others are conjugate complex numbers + for (long i = 1; i < dist; ++ i) + { + df [c1_r + i] = sf [c1_r + i] + sf [c2_r - i]; + df [c1_i + i] = sf [c2_r + i] - sf [cend - i]; + + DataType c; + DataType s; + FFTRealUseTrigo ::iterate ( + osc_list [TRIGO_OSC], + c, + s, + cos_ptr, + i * table_step, + (dist - i) * table_step + ); + + const DataType vr = sf [c1_r + i] - sf [c2_r - i]; + const DataType vi = sf [c2_r + i] + sf [cend - i]; + + df [c2_r + i] = vr * c + vi * s; + df [c2_i + i] = vi * c - vr * s; + } + + coef_index += cend; + } + while (coef_index < len); +} + +template <> +void FFTRealPassInverse <2>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Antepenultimate pass + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + + long coef_index = 0; + do + { + dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; + dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; + dest_ptr [coef_index + 2] = src_ptr [coef_index + 2] * 2; + dest_ptr [coef_index + 6] = src_ptr [coef_index + 6] * 2; + + dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + src_ptr [coef_index + 3]; + dest_ptr [coef_index + 3] = src_ptr [coef_index + 5] - src_ptr [coef_index + 7]; + + const DataType vr = src_ptr [coef_index + 1] - src_ptr [coef_index + 3]; + const DataType vi = src_ptr [coef_index + 5] + src_ptr [coef_index + 7]; + + dest_ptr [coef_index + 5] = (vr + vi) * sqrt2_2; + dest_ptr [coef_index + 7] = (vi - vr) * sqrt2_2; + + coef_index += 8; + } + while (coef_index < len); +} + +template <> +void FFTRealPassInverse <1>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Penultimate and last pass at once + const long qlen = len >> 2; + + long coef_index = 0; + do + { + const long ri_0 = br_ptr [coef_index >> 2]; + + const DataType b_0 = src_ptr [coef_index ] + src_ptr [coef_index + 2]; + const DataType b_2 = src_ptr [coef_index ] - src_ptr [coef_index + 2]; + const DataType b_1 = src_ptr [coef_index + 1] * 2; + const DataType b_3 = src_ptr [coef_index + 3] * 2; + + dest_ptr [ri_0 ] = b_0 + b_1; + dest_ptr [ri_0 + 2 * qlen] = b_0 - b_1; + dest_ptr [ri_0 + 1 * qlen] = b_2 + b_3; + dest_ptr [ri_0 + 3 * qlen] = b_2 - b_3; + + coef_index += 4; + } + while (coef_index < len); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // FFTRealPassInverse_CODEHEADER_INCLUDED + +#undef FFTRealPassInverse_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealSelect.h b/demos/spectrum/3rdparty/fftreal/FFTRealSelect.h new file mode 100644 index 0000000..bd722d4 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealSelect.h @@ -0,0 +1,77 @@ +/***************************************************************************** + + FFTRealSelect.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealSelect_HEADER_INCLUDED) +#define FFTRealSelect_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" + + + +template +class FFTRealSelect +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + FORCEINLINE static float * + sel_bin (float *e_ptr, float *o_ptr); + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealSelect (); + ~FFTRealSelect (); + FFTRealSelect (const FFTRealSelect &other); + FFTRealSelect& operator = (const FFTRealSelect &other); + bool operator == (const FFTRealSelect &other); + bool operator != (const FFTRealSelect &other); + +}; // class FFTRealSelect + + + +#include "FFTRealSelect.hpp" + + + +#endif // FFTRealSelect_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealSelect.hpp b/demos/spectrum/3rdparty/fftreal/FFTRealSelect.hpp new file mode 100644 index 0000000..9ddf586 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealSelect.hpp @@ -0,0 +1,62 @@ +/***************************************************************************** + + FFTRealSelect.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealSelect_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealSelect code header. +#endif +#define FFTRealSelect_CURRENT_CODEHEADER + +#if ! defined (FFTRealSelect_CODEHEADER_INCLUDED) +#define FFTRealSelect_CODEHEADER_INCLUDED + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +float * FFTRealSelect

    ::sel_bin (float *e_ptr, float *o_ptr) +{ + return (o_ptr); +} + + + +template <> +float * FFTRealSelect <0>::sel_bin (float *e_ptr, float *o_ptr) +{ + return (e_ptr); +} + + + +#endif // FFTRealSelect_CODEHEADER_INCLUDED + +#undef FFTRealSelect_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h b/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h new file mode 100644 index 0000000..c4368ee --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h @@ -0,0 +1,101 @@ +/***************************************************************************** + + FFTRealUseTrigo.h + Copyright (c) 2005 Laurent de Soras + +Template parameters: + - ALGO: algorithm choice. 0 = table, other = oscillator + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealUseTrigo_HEADER_INCLUDED) +#define FFTRealUseTrigo_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + +template +class FFTRealUseTrigo +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; + + FORCEINLINE static void + prepare (OscType &osc); + FORCEINLINE static void + iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealUseTrigo (); + ~FFTRealUseTrigo (); + FFTRealUseTrigo (const FFTRealUseTrigo &other); + FFTRealUseTrigo & + operator = (const FFTRealUseTrigo &other); + bool operator == (const FFTRealUseTrigo &other); + bool operator != (const FFTRealUseTrigo &other); + +}; // class FFTRealUseTrigo + + + +#include "FFTRealUseTrigo.hpp" + + + +#endif // FFTRealUseTrigo_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp b/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp new file mode 100644 index 0000000..aa968b8 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp @@ -0,0 +1,91 @@ +/***************************************************************************** + + FFTRealUseTrigo.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealUseTrigo_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealUseTrigo code header. +#endif +#define FFTRealUseTrigo_CURRENT_CODEHEADER + +#if ! defined (FFTRealUseTrigo_CODEHEADER_INCLUDED) +#define FFTRealUseTrigo_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "OscSinCos.h" + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void FFTRealUseTrigo ::prepare (OscType &osc) +{ + osc.clear_buffers (); +} + +template <> +void FFTRealUseTrigo <0>::prepare (OscType &osc) +{ + // Nothing +} + + + +template +void FFTRealUseTrigo ::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) +{ + osc.step (); + c = osc.get_cos (); + s = osc.get_sin (); +} + +template <> +void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) +{ + c = cos_ptr [index_c]; + s = cos_ptr [index_s]; +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // FFTRealUseTrigo_CODEHEADER_INCLUDED + +#undef FFTRealUseTrigo_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/OscSinCos.h b/demos/spectrum/3rdparty/fftreal/OscSinCos.h new file mode 100644 index 0000000..775fc14 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/OscSinCos.h @@ -0,0 +1,106 @@ +/***************************************************************************** + + OscSinCos.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (OscSinCos_HEADER_INCLUDED) +#define OscSinCos_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" + + + +template +class OscSinCos +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef T DataType; + + OscSinCos (); + + FORCEINLINE void + set_step (double angle_rad); + + FORCEINLINE DataType + get_cos () const; + FORCEINLINE DataType + get_sin () const; + FORCEINLINE void + step (); + FORCEINLINE void + clear_buffers (); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1] + DataType _pos_sin; // - + DataType _step_cos; // Phase increment per step, [-1 ; 1] + DataType _step_sin; // - + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + OscSinCos (const OscSinCos &other); + OscSinCos & operator = (const OscSinCos &other); + bool operator == (const OscSinCos &other); + bool operator != (const OscSinCos &other); + +}; // class OscSinCos + + + +#include "OscSinCos.hpp" + + + +#endif // OscSinCos_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/OscSinCos.hpp b/demos/spectrum/3rdparty/fftreal/OscSinCos.hpp new file mode 100644 index 0000000..749aef0 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/OscSinCos.hpp @@ -0,0 +1,122 @@ +/***************************************************************************** + + OscSinCos.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (OscSinCos_CURRENT_CODEHEADER) + #error Recursive inclusion of OscSinCos code header. +#endif +#define OscSinCos_CURRENT_CODEHEADER + +#if ! defined (OscSinCos_CODEHEADER_INCLUDED) +#define OscSinCos_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include + +namespace std { } + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +OscSinCos ::OscSinCos () +: _pos_cos (1) +, _pos_sin (0) +, _step_cos (1) +, _step_sin (0) +{ + // Nothing +} + + + +template +void OscSinCos ::set_step (double angle_rad) +{ + using namespace std; + + _step_cos = static_cast (cos (angle_rad)); + _step_sin = static_cast (sin (angle_rad)); +} + + + +template +typename OscSinCos ::DataType OscSinCos ::get_cos () const +{ + return (_pos_cos); +} + + + +template +typename OscSinCos ::DataType OscSinCos ::get_sin () const +{ + return (_pos_sin); +} + + + +template +void OscSinCos ::step () +{ + const DataType old_cos = _pos_cos; + const DataType old_sin = _pos_sin; + + _pos_cos = old_cos * _step_cos - old_sin * _step_sin; + _pos_sin = old_cos * _step_sin + old_sin * _step_cos; +} + + + +template +void OscSinCos ::clear_buffers () +{ + _pos_cos = static_cast (1); + _pos_sin = static_cast (0); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // OscSinCos_CODEHEADER_INCLUDED + +#undef OscSinCos_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestAccuracy.h b/demos/spectrum/3rdparty/fftreal/TestAccuracy.h new file mode 100644 index 0000000..4b07a6b --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestAccuracy.h @@ -0,0 +1,105 @@ +/***************************************************************************** + + TestAccuracy.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestAccuracy_HEADER_INCLUDED) +#define TestAccuracy_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +class TestAccuracy +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef typename FO::DataType DataType; + typedef long double BigFloat; // To get maximum accuracy during intermediate calculations + + static int perform_test_single_object (FO &fft); + static int perform_test_d (FO &fft, const char *class_name_0); + static int perform_test_i (FO &fft, const char *class_name_0); + static int perform_test_di (FO &fft, const char *class_name_0); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + enum { NBR_ACC_TESTS = 10 * 1000 * 1000 }; + enum { MAX_NBR_TESTS = 10000 }; + + static void compute_tf (DataType s [], const DataType x [], long length); + static void compute_itf (DataType x [], const DataType s [], long length); + static int compare_vect_display (const DataType x_ptr [], const DataType y_ptr [], long len, BigFloat &max_err_rel); + static BigFloat + compute_power (const DataType x_ptr [], long len); + static BigFloat + compute_power (const DataType x_ptr [], const DataType y_ptr [], long len); + static void compare_vect (const DataType x_ptr [], const DataType y_ptr [], BigFloat &power, long &max_err_pos, long len); + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestAccuracy (); + ~TestAccuracy (); + TestAccuracy (const TestAccuracy &other); + TestAccuracy & operator = (const TestAccuracy &other); + bool operator == (const TestAccuracy &other); + bool operator != (const TestAccuracy &other); + +}; // class TestAccuracy + + + +#include "TestAccuracy.hpp" + + + +#endif // TestAccuracy_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestAccuracy.hpp b/demos/spectrum/3rdparty/fftreal/TestAccuracy.hpp new file mode 100644 index 0000000..5c794f7 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestAccuracy.hpp @@ -0,0 +1,472 @@ +/***************************************************************************** + + TestAccuracy.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestAccuracy_CURRENT_CODEHEADER) + #error Recursive inclusion of TestAccuracy code header. +#endif +#define TestAccuracy_CURRENT_CODEHEADER + +#if ! defined (TestAccuracy_CODEHEADER_INCLUDED) +#define TestAccuracy_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "test_fnc.h" +#include "TestWhiteNoiseGen.h" + +#include +#include + +#include +#include + + + +static const double TestAccuracy_LN10 = 2.3025850929940456840179914546844; + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +int TestAccuracy ::perform_test_single_object (FO &fft) +{ + assert (&fft != 0); + + using namespace std; + + int ret_val = 0; + + const std::type_info & ti = typeid (fft); + const char * class_name_0 = ti.name (); + + if (ret_val == 0) + { + ret_val = perform_test_d (fft, class_name_0); + } + if (ret_val == 0) + { + ret_val = perform_test_i (fft, class_name_0); + } + if (ret_val == 0) + { + ret_val = perform_test_di (fft, class_name_0); + } + + if (ret_val == 0) + { + printf ("\n"); + } + + return (ret_val); +} + + + +template +int TestAccuracy ::perform_test_d (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + using namespace std; + + int ret_val = 0; + const long len = fft.get_length (); + const long nbr_tests = limit ( + NBR_ACC_TESTS / len / len, + 1L, + static_cast (MAX_NBR_TESTS) + ); + + printf ("Testing %s::do_fft () [%ld samples]... ", class_name_0, len); + fflush (stdout); + TestWhiteNoiseGen noise; + std::vector x (len); + std::vector s1 (len); + std::vector s2 (len); + BigFloat err_avg = 0; + + for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) + { + noise.generate (&x [0], len); + fft.do_fft (&s1 [0], &x [0]); + compute_tf (&s2 [0], &x [0], len); + + BigFloat max_err; + compare_vect_display (&s1 [0], &s2 [0], len, max_err); + err_avg += max_err; + } + err_avg /= NBR_ACC_TESTS; + + printf ("done.\n"); + printf ( + "Average maximum error: %.6f %% (%f dB)\n", + static_cast (err_avg * 100), + static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) + ); + + return (ret_val); +} + + + +template +int TestAccuracy ::perform_test_i (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + using namespace std; + + int ret_val = 0; + const long len = fft.get_length (); + const long nbr_tests = limit ( + NBR_ACC_TESTS / len / len, + 10L, + static_cast (MAX_NBR_TESTS) + ); + + printf ("Testing %s::do_ifft () [%ld samples]... ", class_name_0, len); + fflush (stdout); + TestWhiteNoiseGen noise; + std::vector s (len); + std::vector x1 (len); + std::vector x2 (len); + BigFloat err_avg = 0; + + for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) + { + noise.generate (&s [0], len); + fft.do_ifft (&s [0], &x1 [0]); + compute_itf (&x2 [0], &s [0], len); + + BigFloat max_err; + compare_vect_display (&x1 [0], &x2 [0], len, max_err); + err_avg += max_err; + } + err_avg /= NBR_ACC_TESTS; + + printf ("done.\n"); + printf ( + "Average maximum error: %.6f %% (%f dB)\n", + static_cast (err_avg * 100), + static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) + ); + + return (ret_val); +} + + + +template +int TestAccuracy ::perform_test_di (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + using namespace std; + + int ret_val = 0; + const long len = fft.get_length (); + const long nbr_tests = limit ( + NBR_ACC_TESTS / len / len, + 1L, + static_cast (MAX_NBR_TESTS) + ); + + printf ( + "Testing %s::do_fft () / do_ifft () / rescale () [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + TestWhiteNoiseGen noise; + std::vector x (len); + std::vector s (len); + std::vector y (len); + BigFloat err_avg = 0; + + for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) + { + noise.generate (&x [0], len); + fft.do_fft (&s [0], &x [0]); + fft.do_ifft (&s [0], &y [0]); + fft.rescale (&y [0]); + + BigFloat max_err; + compare_vect_display (&x [0], &y [0], len, max_err); + err_avg += max_err; + } + err_avg /= NBR_ACC_TESTS; + + printf ("done.\n"); + printf ( + "Average maximum error: %.6f %% (%f dB)\n", + static_cast (err_avg * 100), + static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) + ); + + return (ret_val); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +// Positive transform +template +void TestAccuracy ::compute_tf (DataType s [], const DataType x [], long length) +{ + assert (s != 0); + assert (x != 0); + assert (length >= 2); + assert ((length & 1) == 0); + + const long nbr_bins = length >> 1; + + // DC and Nyquist + BigFloat dc = 0; + BigFloat ny = 0; + for (long pos = 0; pos < length; pos += 2) + { + const BigFloat even = x [pos ]; + const BigFloat odd = x [pos + 1]; + dc += even + odd; + ny += even - odd; + } + s [0 ] = static_cast (dc); + s [nbr_bins] = static_cast (ny); + + // Regular bins + for (long bin = 1; bin < nbr_bins; ++ bin) + { + BigFloat sum_r = 0; + BigFloat sum_i = 0; + + const BigFloat m = bin * static_cast (2 * PI) / length; + + for (long pos = 0; pos < length; ++pos) + { + using namespace std; + + const BigFloat phase = pos * m; + const BigFloat e_r = cos (phase); + const BigFloat e_i = sin (phase); + + sum_r += x [pos] * e_r; + sum_i += x [pos] * e_i; + } + + s [ bin] = static_cast (sum_r); + s [nbr_bins + bin] = static_cast (sum_i); + } +} + + + +// Negative transform +template +void TestAccuracy ::compute_itf (DataType x [], const DataType s [], long length) +{ + assert (s != 0); + assert (x != 0); + assert (length >= 2); + assert ((length & 1) == 0); + + const long nbr_bins = length >> 1; + + // DC and Nyquist + BigFloat dc = s [0 ]; + BigFloat ny = s [nbr_bins]; + + // Regular bins + for (long pos = 0; pos < length; ++pos) + { + BigFloat sum = dc + ny * (1 - 2 * (pos & 1)); + + const BigFloat m = pos * static_cast (-2 * PI) / length; + + for (long bin = 1; bin < nbr_bins; ++ bin) + { + using namespace std; + + const BigFloat phase = bin * m; + const BigFloat e_r = cos (phase); + const BigFloat e_i = sin (phase); + + sum += 2 * ( e_r * s [bin ] + - e_i * s [bin + nbr_bins]); + } + + x [pos] = static_cast (sum); + } +} + + + +template +int TestAccuracy ::compare_vect_display (const DataType x_ptr [], const DataType y_ptr [], long len, BigFloat &max_err_rel) +{ + assert (x_ptr != 0); + assert (y_ptr != 0); + assert (len > 0); + assert (&max_err_rel != 0); + + using namespace std; + + int ret_val = 0; + + BigFloat power = compute_power (&x_ptr [0], &y_ptr [0], len); + BigFloat power_dif; + long max_err_pos; + compare_vect (&x_ptr [0], &y_ptr [0], power_dif, max_err_pos, len); + + if (power == 0) + { + power = power_dif; + } + const BigFloat power_err_rel = power_dif / power; + + BigFloat max_err = 0; + max_err_rel = 0; + if (max_err_pos >= 0) + { + max_err = y_ptr [max_err_pos] - x_ptr [max_err_pos]; + max_err_rel = 2 * fabs (max_err) / ( fabs (y_ptr [max_err_pos]) + + fabs (x_ptr [max_err_pos])); + } + + if (power_err_rel > 0.001) + { + printf ("Power error : %f (%.6f %%)\n", + static_cast (power_err_rel), + static_cast (power_err_rel * 100) + ); + if (max_err_pos >= 0) + { + printf ( + "Maximum error: %f - %f = %f (%f)\n", + static_cast (y_ptr [max_err_pos]), + static_cast (x_ptr [max_err_pos]), + static_cast (max_err), + static_cast (max_err_pos) + ); + } + } + + return (ret_val); +} + + + +template +typename TestAccuracy ::BigFloat TestAccuracy ::compute_power (const DataType x_ptr [], long len) +{ + assert (x_ptr != 0); + assert (len > 0); + + BigFloat power = 0; + for (long pos = 0; pos < len; ++pos) + { + const BigFloat val = x_ptr [pos]; + + power += val * val; + } + + using namespace std; + + power = sqrt (power) / len; + + return (power); +} + + + +template +typename TestAccuracy ::BigFloat TestAccuracy ::compute_power (const DataType x_ptr [], const DataType y_ptr [], long len) +{ + assert (x_ptr != 0); + assert (y_ptr != 0); + assert (len > 0); + + return ((compute_power (x_ptr, len) + compute_power (y_ptr, len)) * 0.5); +} + + + +template +void TestAccuracy ::compare_vect (const DataType x_ptr [], const DataType y_ptr [], BigFloat &power, long &max_err_pos, long len) +{ + assert (x_ptr != 0); + assert (y_ptr != 0); + assert (len > 0); + assert (&power != 0); + assert (&max_err_pos != 0); + + power = 0; + BigFloat max_dif2 = 0; + max_err_pos = -1; + + for (long pos = 0; pos < len; ++pos) + { + const BigFloat x = x_ptr [pos]; + const BigFloat y = y_ptr [pos]; + const BigFloat dif = y - x; + const BigFloat dif2 = dif * dif; + + power += dif2; + if (dif2 > max_dif2) + { + max_err_pos = pos; + max_dif2 = dif2; + } + } + + using namespace std; + + power = sqrt (power) / len; +} + + + +#endif // TestAccuracy_CODEHEADER_INCLUDED + +#undef TestAccuracy_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.h b/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.h new file mode 100644 index 0000000..ecff96d --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.h @@ -0,0 +1,93 @@ +/***************************************************************************** + + TestHelperFixLen.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestHelperFixLen_HEADER_INCLUDED) +#define TestHelperFixLen_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTRealFixLen.h" + + + +template +class TestHelperFixLen +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLen FftType; + + static void perform_test_accuracy (int &ret_val); + static void perform_test_speed (int &ret_val); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestHelperFixLen (); + ~TestHelperFixLen (); + TestHelperFixLen (const TestHelperFixLen &other); + TestHelperFixLen & + operator = (const TestHelperFixLen &other); + bool operator == (const TestHelperFixLen &other); + bool operator != (const TestHelperFixLen &other); + +}; // class TestHelperFixLen + + + +#include "TestHelperFixLen.hpp" + + + +#endif // TestHelperFixLen_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.hpp b/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.hpp new file mode 100644 index 0000000..25048b9 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.hpp @@ -0,0 +1,93 @@ +/***************************************************************************** + + TestHelperFixLen.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestHelperFixLen_CURRENT_CODEHEADER) + #error Recursive inclusion of TestHelperFixLen code header. +#endif +#define TestHelperFixLen_CURRENT_CODEHEADER + +#if ! defined (TestHelperFixLen_CODEHEADER_INCLUDED) +#define TestHelperFixLen_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_settings.h" + +#include "TestAccuracy.h" +#if defined (test_settings_SPEED_TEST_ENABLED) + #include "TestSpeed.h" +#endif + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void TestHelperFixLen ::perform_test_accuracy (int &ret_val) +{ + if (ret_val == 0) + { + FftType fft; + ret_val = TestAccuracy ::perform_test_single_object (fft); + } +} + + + +template +void TestHelperFixLen ::perform_test_speed (int &ret_val) +{ +#if defined (test_settings_SPEED_TEST_ENABLED) + + if (ret_val == 0) + { + FftType fft; + ret_val = TestSpeed ::perform_test_single_object (fft); + } + +#endif +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestHelperFixLen_CODEHEADER_INCLUDED + +#undef TestHelperFixLen_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestHelperNormal.h b/demos/spectrum/3rdparty/fftreal/TestHelperNormal.h new file mode 100644 index 0000000..a7bff5c --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestHelperNormal.h @@ -0,0 +1,94 @@ +/***************************************************************************** + + TestHelperNormal.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestHelperNormal_HEADER_INCLUDED) +#define TestHelperNormal_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTReal.h" + + + +template +class TestHelperNormal +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef DT DataType; + typedef FFTReal FftType; + + static void perform_test_accuracy (int &ret_val); + static void perform_test_speed (int &ret_val); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestHelperNormal (); + ~TestHelperNormal (); + TestHelperNormal (const TestHelperNormal &other); + TestHelperNormal & + operator = (const TestHelperNormal &other); + bool operator == (const TestHelperNormal &other); + bool operator != (const TestHelperNormal &other); + +}; // class TestHelperNormal + + + +#include "TestHelperNormal.hpp" + + + +#endif // TestHelperNormal_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestHelperNormal.hpp b/demos/spectrum/3rdparty/fftreal/TestHelperNormal.hpp new file mode 100644 index 0000000..e037696 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestHelperNormal.hpp @@ -0,0 +1,99 @@ +/***************************************************************************** + + TestHelperNormal.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestHelperNormal_CURRENT_CODEHEADER) + #error Recursive inclusion of TestHelperNormal code header. +#endif +#define TestHelperNormal_CURRENT_CODEHEADER + +#if ! defined (TestHelperNormal_CODEHEADER_INCLUDED) +#define TestHelperNormal_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_settings.h" + +#include "TestAccuracy.h" +#if defined (test_settings_SPEED_TEST_ENABLED) + #include "TestSpeed.h" +#endif + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +void TestHelperNormal

    ::perform_test_accuracy (int &ret_val) +{ + const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12 }; + const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); + for (int k = 0; k < nbr_len && ret_val == 0; ++k) + { + const long len = 1L << (len_arr [k]); + FftType fft (len); + ret_val = TestAccuracy ::perform_test_single_object (fft); + } +} + + + +template +void TestHelperNormal
    ::perform_test_speed (int &ret_val) +{ +#if defined (test_settings_SPEED_TEST_ENABLED) + + const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12, 14, 16, 18, 20, 22 }; + const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); + for (int k = 0; k < nbr_len && ret_val == 0; ++k) + { + const long len = 1L << (len_arr [k]); + FftType fft (len); + ret_val = TestSpeed ::perform_test_single_object (fft); + } + +#endif +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestHelperNormal_CODEHEADER_INCLUDED + +#undef TestHelperNormal_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestSpeed.h b/demos/spectrum/3rdparty/fftreal/TestSpeed.h new file mode 100644 index 0000000..2295781 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestSpeed.h @@ -0,0 +1,95 @@ +/***************************************************************************** + + TestSpeed.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestSpeed_HEADER_INCLUDED) +#define TestSpeed_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +class TestSpeed +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef typename FO::DataType DataType; + + static int perform_test_single_object (FO &fft); + static int perform_test_d (FO &fft, const char *class_name_0); + static int perform_test_i (FO &fft, const char *class_name_0); + static int perform_test_di (FO &fft, const char *class_name_0); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + enum { NBR_SPD_TESTS = 10 * 1000 * 1000 }; + enum { MAX_NBR_TESTS = 10000 }; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestSpeed (); + ~TestSpeed (); + TestSpeed (const TestSpeed &other); + TestSpeed & operator = (const TestSpeed &other); + bool operator == (const TestSpeed &other); + bool operator != (const TestSpeed &other); + +}; // class TestSpeed + + + +#include "TestSpeed.hpp" + + + +#endif // TestSpeed_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestSpeed.hpp b/demos/spectrum/3rdparty/fftreal/TestSpeed.hpp new file mode 100644 index 0000000..e716b2a --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestSpeed.hpp @@ -0,0 +1,223 @@ +/***************************************************************************** + + TestSpeed.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestSpeed_CURRENT_CODEHEADER) + #error Recursive inclusion of TestSpeed code header. +#endif +#define TestSpeed_CURRENT_CODEHEADER + +#if ! defined (TestSpeed_CODEHEADER_INCLUDED) +#define TestSpeed_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_fnc.h" +#include "stopwatch/StopWatch.h" +#include "TestWhiteNoiseGen.h" + +#include + +#include + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +int TestSpeed ::perform_test_single_object (FO &fft) +{ + assert (&fft != 0); + + int ret_val = 0; + + const std::type_info & ti = typeid (fft); + const char * class_name_0 = ti.name (); + + if (ret_val == 0) + { + perform_test_d (fft, class_name_0); + } + if (ret_val == 0) + { + perform_test_i (fft, class_name_0); + } + if (ret_val == 0) + { + perform_test_di (fft, class_name_0); + } + + if (ret_val == 0) + { + printf ("\n"); + } + + return (ret_val); +} + + + +template +int TestSpeed ::perform_test_d (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + const long len = fft.get_length (); + const long nbr_tests = limit ( + static_cast (NBR_SPD_TESTS / len / len), + 1L, + static_cast (MAX_NBR_TESTS) + ); + + TestWhiteNoiseGen noise; + std::vector x (len, 0); + std::vector s (len); + noise.generate (&x [0], len); + + printf ( + "%s::do_fft () speed test [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + + stopwatch::StopWatch chrono; + chrono.start (); + for (long test = 0; test < nbr_tests; ++ test) + { + fft.do_fft (&s [0], &x [0]); + chrono.stop_lap (); + } + + printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); + + return (0); +} + + + +template +int TestSpeed ::perform_test_i (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + const long len = fft.get_length (); + const long nbr_tests = limit ( + static_cast (NBR_SPD_TESTS / len / len), + 1L, + static_cast (MAX_NBR_TESTS) + ); + + TestWhiteNoiseGen noise; + std::vector x (len); + std::vector s (len, 0); + noise.generate (&s [0], len); + + printf ( + "%s::do_ifft () speed test [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + + stopwatch::StopWatch chrono; + chrono.start (); + for (long test = 0; test < nbr_tests; ++ test) + { + fft.do_ifft (&s [0], &x [0]); + chrono.stop_lap (); + } + + printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); + + return (0); +} + + + +template +int TestSpeed ::perform_test_di (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + const long len = fft.get_length (); + const long nbr_tests = limit ( + static_cast (NBR_SPD_TESTS / len / len), + 1L, + static_cast (MAX_NBR_TESTS) + ); + + TestWhiteNoiseGen noise; + std::vector x (len, 0); + std::vector s (len); + std::vector y (len); + noise.generate (&x [0], len); + + printf ( + "%s::do_fft () / do_ifft () / rescale () speed test [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + + stopwatch::StopWatch chrono; + + chrono.start (); + for (long test = 0; test < nbr_tests; ++ test) + { + fft.do_fft (&s [0], &x [0]); + fft.do_ifft (&s [0], &y [0]); + fft.rescale (&y [0]); + chrono.stop_lap (); + } + + printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); + + return (0); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestSpeed_CODEHEADER_INCLUDED + +#undef TestSpeed_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h b/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h new file mode 100644 index 0000000..d815f8e --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h @@ -0,0 +1,95 @@ +/***************************************************************************** + + TestWhiteNoiseGen.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestWhiteNoiseGen_HEADER_INCLUDED) +#define TestWhiteNoiseGen_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +class TestWhiteNoiseGen +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef DT DataType; + + TestWhiteNoiseGen (); + virtual ~TestWhiteNoiseGen () {} + + void generate (DataType data_ptr [], long len); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + typedef unsigned long StateType; + + StateType _rand_state; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestWhiteNoiseGen (const TestWhiteNoiseGen &other); + TestWhiteNoiseGen & + operator = (const TestWhiteNoiseGen &other); + bool operator == (const TestWhiteNoiseGen &other); + bool operator != (const TestWhiteNoiseGen &other); + +}; // class TestWhiteNoiseGen + + + +#include "TestWhiteNoiseGen.hpp" + + + +#endif // TestWhiteNoiseGen_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.hpp b/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.hpp new file mode 100644 index 0000000..13b7eb3 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.hpp @@ -0,0 +1,91 @@ +/***************************************************************************** + + TestWhiteNoiseGen.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestWhiteNoiseGen_CURRENT_CODEHEADER) + #error Recursive inclusion of TestWhiteNoiseGen code header. +#endif +#define TestWhiteNoiseGen_CURRENT_CODEHEADER + +#if ! defined (TestWhiteNoiseGen_CODEHEADER_INCLUDED) +#define TestWhiteNoiseGen_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +TestWhiteNoiseGen
    ::TestWhiteNoiseGen () +: _rand_state (0) +{ + _rand_state = reinterpret_cast (this); +} + + + +template +void TestWhiteNoiseGen
    ::generate (DataType data_ptr [], long len) +{ + assert (data_ptr != 0); + assert (len > 0); + + const DataType one = static_cast (1); + const DataType mul = one / static_cast (0x80000000UL); + + long pos = 0; + do + { + const DataType x = static_cast (_rand_state & 0xFFFFFFFFUL); + data_ptr [pos] = x * mul - one; + + _rand_state = _rand_state * 1234567UL + 890123UL; + + ++ pos; + } + while (pos < len); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestWhiteNoiseGen_CODEHEADER_INCLUDED + +#undef TestWhiteNoiseGen_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/bwins/fftrealu.def b/demos/spectrum/3rdparty/fftreal/bwins/fftrealu.def new file mode 100644 index 0000000..7a79397 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/bwins/fftrealu.def @@ -0,0 +1,5 @@ +EXPORTS + ??0FFTRealWrapper@@QAE@XZ @ 1 NONAME ; FFTRealWrapper::FFTRealWrapper(void) + ??1FFTRealWrapper@@QAE@XZ @ 2 NONAME ; FFTRealWrapper::~FFTRealWrapper(void) + ?calculateFFT@FFTRealWrapper@@QAEXQAMQBM@Z @ 3 NONAME ; void FFTRealWrapper::calculateFFT(float * const, float const * const) + diff --git a/demos/spectrum/3rdparty/fftreal/def.h b/demos/spectrum/3rdparty/fftreal/def.h new file mode 100644 index 0000000..99c545f --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/def.h @@ -0,0 +1,60 @@ +/***************************************************************************** + + def.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (def_HEADER_INCLUDED) +#define def_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + + +const double PI = 3.1415926535897932384626433832795; +const double SQRT2 = 1.41421356237309514547462185873883; + +#if defined (_MSC_VER) + + #define FORCEINLINE __forceinline + +#else + + #define FORCEINLINE inline + +#endif + + + +#endif // def_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/eabi/fftrealu.def b/demos/spectrum/3rdparty/fftreal/eabi/fftrealu.def new file mode 100644 index 0000000..f95a441 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/eabi/fftrealu.def @@ -0,0 +1,7 @@ +EXPORTS + _ZN14FFTRealWrapper12calculateFFTEPfPKf @ 1 NONAME + _ZN14FFTRealWrapperC1Ev @ 2 NONAME + _ZN14FFTRealWrapperC2Ev @ 3 NONAME + _ZN14FFTRealWrapperD1Ev @ 4 NONAME + _ZN14FFTRealWrapperD2Ev @ 5 NONAME + diff --git a/demos/spectrum/3rdparty/fftreal/fftreal.pas b/demos/spectrum/3rdparty/fftreal/fftreal.pas new file mode 100644 index 0000000..ea63754 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/fftreal.pas @@ -0,0 +1,661 @@ +(***************************************************************************** + + DIGITAL SIGNAL PROCESSING TOOLS + Version 1.03, 2001/06/15 + (c) 1999 - Laurent de Soras + + FFTReal.h + Fourier transformation of real number arrays. + Portable ISO C++ + +------------------------------------------------------------------------------ + + LEGAL + + Source code may be freely used for any purpose, including commercial + applications. Programs must display in their "About" dialog-box (or + documentation) a text telling they use these routines by Laurent de Soras. + Modified source code can be distributed, but modifications must be clearly + indicated. + + CONTACT + + Laurent de Soras + 92 avenue Albert 1er + 92500 Rueil-Malmaison + France + + ldesoras@club-internet.fr + +------------------------------------------------------------------------------ + + Translation to ObjectPascal by : + Frederic Vanmol + frederic@axiworld.be + +*****************************************************************************) + + +unit + FFTReal; + +interface + +uses + Windows; + +(* Change this typedef to use a different floating point type in your FFTs + (i.e. float, double or long double). *) +type + pflt_t = ^flt_t; + flt_t = single; + + pflt_array = ^flt_array; + flt_array = array[0..0] of flt_t; + + plongarray = ^longarray; + longarray = array[0..0] of longint; + +const + sizeof_flt : longint = SizeOf(flt_t); + + + +type + // Bit reversed look-up table nested class + TBitReversedLUT = class + private + _ptr : plongint; + public + constructor Create(const nbr_bits: integer); + destructor Destroy; override; + function get_ptr: plongint; + end; + + // Trigonometric look-up table nested class + TTrigoLUT = class + private + _ptr : pflt_t; + public + constructor Create(const nbr_bits: integer); + destructor Destroy; override; + function get_ptr(const level: integer): pflt_t; + end; + + TFFTReal = class + private + _bit_rev_lut : TBitReversedLUT; + _trigo_lut : TTrigoLUT; + _sqrt2_2 : flt_t; + _length : longint; + _nbr_bits : integer; + _buffer_ptr : pflt_t; + public + constructor Create(const length: longint); + destructor Destroy; override; + + procedure do_fft(f: pflt_array; const x: pflt_array); + procedure do_ifft(const f: pflt_array; x: pflt_array); + procedure rescale(x: pflt_array); + end; + + + + + + + +implementation + +uses + Math; + +{ TBitReversedLUT } + +constructor TBitReversedLUT.Create(const nbr_bits: integer); +var + length : longint; + cnt : longint; + br_index : longint; + bit : longint; +begin + inherited Create; + + length := 1 shl nbr_bits; + GetMem(_ptr, length*SizeOf(longint)); + + br_index := 0; + plongarray(_ptr)^[0] := 0; + for cnt := 1 to length-1 do + begin + // ++br_index (bit reversed) + bit := length shr 1; + br_index := br_index xor bit; + while br_index and bit = 0 do + begin + bit := bit shr 1; + br_index := br_index xor bit; + end; + + plongarray(_ptr)^[cnt] := br_index; + end; +end; + +destructor TBitReversedLUT.Destroy; +begin + FreeMem(_ptr); + _ptr := nil; + inherited; +end; + +function TBitReversedLUT.get_ptr: plongint; +begin + Result := _ptr; +end; + +{ TTrigLUT } + +constructor TTrigoLUT.Create(const nbr_bits: integer); +var + total_len : longint; + PI : double; + level : integer; + level_len : longint; + level_ptr : pflt_array; + mul : double; + i : longint; +begin + inherited Create; + + _ptr := nil; + + if (nbr_bits > 3) then + begin + total_len := (1 shl (nbr_bits - 1)) - 4; + GetMem(_ptr, total_len * sizeof_flt); + + PI := ArcTan(1) * 4; + for level := 3 to nbr_bits-1 do + begin + level_len := 1 shl (level - 1); + level_ptr := pointer(get_ptr(level)); + mul := PI / (level_len shl 1); + + for i := 0 to level_len-1 do + level_ptr^[i] := cos(i * mul); + end; + end; +end; + +destructor TTrigoLUT.Destroy; +begin + FreeMem(_ptr); + _ptr := nil; + inherited; +end; + +function TTrigoLUT.get_ptr(const level: integer): pflt_t; +var + tempp : pflt_t; +begin + tempp := _ptr; + inc(tempp, (1 shl (level-1)) - 4); + Result := tempp; +end; + +{ TFFTReal } + +constructor TFFTReal.Create(const length: longint); +begin + inherited Create; + + _length := length; + _nbr_bits := Floor(Ln(length) / Ln(2) + 0.5); + _bit_rev_lut := TBitReversedLUT.Create(Floor(Ln(length) / Ln(2) + 0.5)); + _trigo_lut := TTrigoLUT.Create(Floor(Ln(length) / Ln(2) + 0.05)); + _sqrt2_2 := Sqrt(2) * 0.5; + + _buffer_ptr := nil; + if _nbr_bits > 2 then + GetMem(_buffer_ptr, _length * sizeof_flt); +end; + +destructor TFFTReal.Destroy; +begin + if _buffer_ptr <> nil then + begin + FreeMem(_buffer_ptr); + _buffer_ptr := nil; + end; + + _bit_rev_lut.Free; + _bit_rev_lut := nil; + _trigo_lut.Free; + _trigo_lut := nil; + + inherited; +end; + +(*==========================================================================*/ +/* Name: do_fft */ +/* Description: Compute the FFT of the array. */ +/* Input parameters: */ +/* - x: pointer on the source array (time). */ +/* Output parameters: */ +/* - f: pointer on the destination array (frequencies). */ +/* f [0...length(x)/2] = real values, */ +/* f [length(x)/2+1...length(x)-1] = imaginary values of */ +/* coefficents 1...length(x)/2-1. */ +/*==========================================================================*) +procedure TFFTReal.do_fft(f: pflt_array; const x: pflt_array); +var + sf, df : pflt_array; + pass : integer; + nbr_coef : longint; + h_nbr_coef : longint; + d_nbr_coef : longint; + coef_index : longint; + bit_rev_lut_ptr : plongarray; + rev_index_0 : longint; + rev_index_1 : longint; + rev_index_2 : longint; + rev_index_3 : longint; + df2 : pflt_array; + n1, n2, n3 : integer; + sf_0, sf_2 : flt_t; + sqrt2_2 : flt_t; + v : flt_t; + cos_ptr : pflt_array; + i : longint; + sf1r, sf2r : pflt_array; + dfr, dfi : pflt_array; + sf1i, sf2i : pflt_array; + c, s : flt_t; + temp_ptr : pflt_array; + b_0, b_2 : flt_t; +begin + n1 := 1; + n2 := 2; + n3 := 3; + + (*______________________________________________ + * + * General case + *______________________________________________ + *) + + if _nbr_bits > 2 then + begin + if _nbr_bits and 1 <> 0 then + begin + df := pointer(_buffer_ptr); + sf := f; + end + else + begin + df := f; + sf := pointer(_buffer_ptr); + end; + + // + // Do the transformation in several passes + // + + // First and second pass at once + bit_rev_lut_ptr := pointer(_bit_rev_lut.get_ptr); + coef_index := 0; + + repeat + rev_index_0 := bit_rev_lut_ptr^[coef_index]; + rev_index_1 := bit_rev_lut_ptr^[coef_index + 1]; + rev_index_2 := bit_rev_lut_ptr^[coef_index + 2]; + rev_index_3 := bit_rev_lut_ptr^[coef_index + 3]; + + df2 := pointer(longint(df) + (coef_index*sizeof_flt)); + df2^[n1] := x^[rev_index_0] - x^[rev_index_1]; + df2^[n3] := x^[rev_index_2] - x^[rev_index_3]; + + sf_0 := x^[rev_index_0] + x^[rev_index_1]; + sf_2 := x^[rev_index_2] + x^[rev_index_3]; + + df2^[0] := sf_0 + sf_2; + df2^[n2] := sf_0 - sf_2; + + inc(coef_index, 4); + until (coef_index >= _length); + + + // Third pass + coef_index := 0; + sqrt2_2 := _sqrt2_2; + + repeat + sf^[coef_index] := df^[coef_index] + df^[coef_index + 4]; + sf^[coef_index + 4] := df^[coef_index] - df^[coef_index + 4]; + sf^[coef_index + 2] := df^[coef_index + 2]; + sf^[coef_index + 6] := df^[coef_index + 6]; + + v := (df [coef_index + 5] - df^[coef_index + 7]) * sqrt2_2; + sf^[coef_index + 1] := df^[coef_index + 1] + v; + sf^[coef_index + 3] := df^[coef_index + 1] - v; + + v := (df^[coef_index + 5] + df^[coef_index + 7]) * sqrt2_2; + sf [coef_index + 5] := v + df^[coef_index + 3]; + sf [coef_index + 7] := v - df^[coef_index + 3]; + + inc(coef_index, 8); + until (coef_index >= _length); + + + // Next pass + for pass := 3 to _nbr_bits-1 do + begin + coef_index := 0; + nbr_coef := 1 shl pass; + h_nbr_coef := nbr_coef shr 1; + d_nbr_coef := nbr_coef shl 1; + + cos_ptr := pointer(_trigo_lut.get_ptr(pass)); + repeat + sf1r := pointer(longint(sf) + (coef_index * sizeof_flt)); + sf2r := pointer(longint(sf1r) + (nbr_coef * sizeof_flt)); + dfr := pointer(longint(df) + (coef_index * sizeof_flt)); + dfi := pointer(longint(dfr) + (nbr_coef * sizeof_flt)); + + // Extreme coefficients are always real + dfr^[0] := sf1r^[0] + sf2r^[0]; + dfi^[0] := sf1r^[0] - sf2r^[0]; // dfr [nbr_coef] = + dfr^[h_nbr_coef] := sf1r^[h_nbr_coef]; + dfi^[h_nbr_coef] := sf2r^[h_nbr_coef]; + + // Others are conjugate complex numbers + sf1i := pointer(longint(sf1r) + (h_nbr_coef * sizeof_flt)); + sf2i := pointer(longint(sf1i) + (nbr_coef * sizeof_flt)); + + for i := 1 to h_nbr_coef-1 do + begin + c := cos_ptr^[i]; // cos (i*PI/nbr_coef); + s := cos_ptr^[h_nbr_coef - i]; // sin (i*PI/nbr_coef); + + v := sf2r^[i] * c - sf2i^[i] * s; + dfr^[i] := sf1r^[i] + v; + dfi^[-i] := sf1r^[i] - v; // dfr [nbr_coef - i] = + + v := sf2r^[i] * s + sf2i^[i] * c; + dfi^[i] := v + sf1i^[i]; + dfi^[nbr_coef - i] := v - sf1i^[i]; + end; + + inc(coef_index, d_nbr_coef); + until (coef_index >= _length); + + // Prepare to the next pass + temp_ptr := df; + df := sf; + sf := temp_ptr; + end; + end + + (*______________________________________________ + * + * Special cases + *______________________________________________ + *) + + // 4-point FFT + else if _nbr_bits = 2 then + begin + f^[n1] := x^[0] - x^[n2]; + f^[n3] := x^[n1] - x^[n3]; + + b_0 := x^[0] + x^[n2]; + b_2 := x^[n1] + x^[n3]; + + f^[0] := b_0 + b_2; + f^[n2] := b_0 - b_2; + end + + // 2-point FFT + else if _nbr_bits = 1 then + begin + f^[0] := x^[0] + x^[n1]; + f^[n1] := x^[0] - x^[n1]; + end + + // 1-point FFT + else + f^[0] := x^[0]; +end; + + +(*==========================================================================*/ +/* Name: do_ifft */ +/* Description: Compute the inverse FFT of the array. Notice that */ +/* IFFT (FFT (x)) = x * length (x). Data must be */ +/* post-scaled. */ +/* Input parameters: */ +/* - f: pointer on the source array (frequencies). */ +/* f [0...length(x)/2] = real values, */ +/* f [length(x)/2+1...length(x)-1] = imaginary values of */ +/* coefficents 1...length(x)/2-1. */ +/* Output parameters: */ +/* - x: pointer on the destination array (time). */ +/*==========================================================================*) +procedure TFFTReal.do_ifft(const f: pflt_array; x: pflt_array); +var + n1, n2, n3 : integer; + n4, n5, n6, n7 : integer; + sf, df, df_temp : pflt_array; + pass : integer; + nbr_coef : longint; + h_nbr_coef : longint; + d_nbr_coef : longint; + coef_index : longint; + cos_ptr : pflt_array; + i : longint; + sfr, sfi : pflt_array; + df1r, df2r : pflt_array; + df1i, df2i : pflt_array; + c, s, vr, vi : flt_t; + temp_ptr : pflt_array; + sqrt2_2 : flt_t; + bit_rev_lut_ptr : plongarray; + sf2 : pflt_array; + b_0, b_1, b_2, b_3 : flt_t; +begin + n1 := 1; + n2 := 2; + n3 := 3; + n4 := 4; + n5 := 5; + n6 := 6; + n7 := 7; + + (*______________________________________________ + * + * General case + *______________________________________________ + *) + + if _nbr_bits > 2 then + begin + sf := f; + + if _nbr_bits and 1 <> 0 then + begin + df := pointer(_buffer_ptr); + df_temp := x; + end + else + begin + df := x; + df_temp := pointer(_buffer_ptr); + end; + + // Do the transformation in several pass + + // First pass + for pass := _nbr_bits-1 downto 3 do + begin + coef_index := 0; + nbr_coef := 1 shl pass; + h_nbr_coef := nbr_coef shr 1; + d_nbr_coef := nbr_coef shl 1; + + cos_ptr := pointer(_trigo_lut.get_ptr(pass)); + + repeat + sfr := pointer(longint(sf) + (coef_index*sizeof_flt)); + sfi := pointer(longint(sfr) + (nbr_coef*sizeof_flt)); + df1r := pointer(longint(df) + (coef_index*sizeof_flt)); + df2r := pointer(longint(df1r) + (nbr_coef*sizeof_flt)); + + // Extreme coefficients are always real + df1r^[0] := sfr^[0] + sfi^[0]; // + sfr [nbr_coef] + df2r^[0] := sfr^[0] - sfi^[0]; // - sfr [nbr_coef] + df1r^[h_nbr_coef] := sfr^[h_nbr_coef] * 2; + df2r^[h_nbr_coef] := sfi^[h_nbr_coef] * 2; + + // Others are conjugate complex numbers + df1i := pointer(longint(df1r) + (h_nbr_coef*sizeof_flt)); + df2i := pointer(longint(df1i) + (nbr_coef*sizeof_flt)); + + for i := 1 to h_nbr_coef-1 do + begin + df1r^[i] := sfr^[i] + sfi^[-i]; // + sfr [nbr_coef - i] + df1i^[i] := sfi^[i] - sfi^[nbr_coef - i]; + + c := cos_ptr^[i]; // cos (i*PI/nbr_coef); + s := cos_ptr^[h_nbr_coef - i]; // sin (i*PI/nbr_coef); + vr := sfr^[i] - sfi^[-i]; // - sfr [nbr_coef - i] + vi := sfi^[i] + sfi^[nbr_coef - i]; + + df2r^[i] := vr * c + vi * s; + df2i^[i] := vi * c - vr * s; + end; + + inc(coef_index, d_nbr_coef); + until (coef_index >= _length); + + + // Prepare to the next pass + if (pass < _nbr_bits - 1) then + begin + temp_ptr := df; + df := sf; + sf := temp_ptr; + end + else + begin + sf := df; + df := df_temp; + end + end; + + // Antepenultimate pass + sqrt2_2 := _sqrt2_2; + coef_index := 0; + + repeat + df^[coef_index] := sf^[coef_index] + sf^[coef_index + 4]; + df^[coef_index + 4] := sf^[coef_index] - sf^[coef_index + 4]; + df^[coef_index + 2] := sf^[coef_index + 2] * 2; + df^[coef_index + 6] := sf^[coef_index + 6] * 2; + + df^[coef_index + 1] := sf^[coef_index + 1] + sf^[coef_index + 3]; + df^[coef_index + 3] := sf^[coef_index + 5] - sf^[coef_index + 7]; + + vr := sf^[coef_index + 1] - sf^[coef_index + 3]; + vi := sf^[coef_index + 5] + sf^[coef_index + 7]; + + df^[coef_index + 5] := (vr + vi) * sqrt2_2; + df^[coef_index + 7] := (vi - vr) * sqrt2_2; + + inc(coef_index, 8); + until (coef_index >= _length); + + + // Penultimate and last pass at once + coef_index := 0; + bit_rev_lut_ptr := pointer(_bit_rev_lut.get_ptr); + sf2 := df; + + repeat + b_0 := sf2^[0] + sf2^[n2]; + b_2 := sf2^[0] - sf2^[n2]; + b_1 := sf2^[n1] * 2; + b_3 := sf2^[n3] * 2; + + x^[bit_rev_lut_ptr^[0]] := b_0 + b_1; + x^[bit_rev_lut_ptr^[n1]] := b_0 - b_1; + x^[bit_rev_lut_ptr^[n2]] := b_2 + b_3; + x^[bit_rev_lut_ptr^[n3]] := b_2 - b_3; + + b_0 := sf2^[n4] + sf2^[n6]; + b_2 := sf2^[n4] - sf2^[n6]; + b_1 := sf2^[n5] * 2; + b_3 := sf2^[n7] * 2; + + x^[bit_rev_lut_ptr^[n4]] := b_0 + b_1; + x^[bit_rev_lut_ptr^[n5]] := b_0 - b_1; + x^[bit_rev_lut_ptr^[n6]] := b_2 + b_3; + x^[bit_rev_lut_ptr^[n7]] := b_2 - b_3; + + inc(sf2, 8); + inc(coef_index, 8); + inc(bit_rev_lut_ptr, 8); + until (coef_index >= _length); + end + + (*______________________________________________ + * + * Special cases + *______________________________________________ + *) + + // 4-point IFFT + else if _nbr_bits = 2 then + begin + b_0 := f^[0] + f [n2]; + b_2 := f^[0] - f [n2]; + + x^[0] := b_0 + f [n1] * 2; + x^[n2] := b_0 - f [n1] * 2; + x^[n1] := b_2 + f [n3] * 2; + x^[n3] := b_2 - f [n3] * 2; + end + + // 2-point IFFT + else if _nbr_bits = 1 then + begin + x^[0] := f^[0] + f^[n1]; + x^[n1] := f^[0] - f^[n1]; + end + + // 1-point IFFT + else + x^[0] := f^[0]; +end; + +(*==========================================================================*/ +/* Name: rescale */ +/* Description: Scale an array by divide each element by its length. */ +/* This function should be called after FFT + IFFT. */ +/* Input/Output parameters: */ +/* - x: pointer on array to rescale (time or frequency). */ +/*==========================================================================*) +procedure TFFTReal.rescale(x: pflt_array); +var + mul : flt_t; + i : longint; +begin + mul := 1.0 / _length; + i := _length - 1; + + repeat + x^[i] := x^[i] * mul; + dec(i); + until (i < 0); +end; + +end. diff --git a/demos/spectrum/3rdparty/fftreal/fftreal.pro b/demos/spectrum/3rdparty/fftreal/fftreal.pro new file mode 100644 index 0000000..4ab9652 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/fftreal.pro @@ -0,0 +1,41 @@ +TEMPLATE = lib +TARGET = fftreal + +# FFTReal +HEADERS += Array.h \ + Array.hpp \ + DynArray.h \ + DynArray.hpp \ + FFTRealFixLen.h \ + FFTRealFixLen.hpp \ + FFTRealFixLenParam.h \ + FFTRealPassDirect.h \ + FFTRealPassDirect.hpp \ + FFTRealPassInverse.h \ + FFTRealPassInverse.hpp \ + FFTRealSelect.h \ + FFTRealSelect.hpp \ + FFTRealUseTrigo.h \ + FFTRealUseTrigo.hpp \ + OscSinCos.h \ + OscSinCos.hpp \ + def.h + +# Wrapper used to export the required instantiation of the FFTRealFixLen template +HEADERS += fftreal_wrapper.h +SOURCES += fftreal_wrapper.cpp + +DEFINES += FFTREAL_LIBRARY + +symbian { + # Provide unique ID for the generated binary, required by Symbian OS + TARGET.UID3 = 0xA000E3FB +} else { + macx { + CONFIG += lib_bundle + } else { + DESTDIR = ../../bin + } +} + + diff --git a/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.cpp b/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.cpp new file mode 100644 index 0000000..50ab36d --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.cpp @@ -0,0 +1,54 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** This program 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. This +** program 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 General Public License +** for more details. You should have received a copy of the GNU General +** Public License along with this program. If not, see +** . +** +***************************************************************************/ + +#include "fftreal_wrapper.h" + +// FFTReal code generates quite a lot of 'unused parameter' compiler warnings, +// which we suppress here in order to get a clean build output. +#if defined Q_CC_MSVC +# pragma warning(disable:4100) +#elif defined Q_CC_GNU +# pragma GCC diagnostic ignored "-Wunused-parameter" +#elif defined Q_CC_MWERKS +# pragma warning off (10182) +#endif + +#include "FFTRealFixLen.h" + +class FFTRealWrapperPrivate { +public: + FFTRealFixLen m_fft; +}; + + +FFTRealWrapper::FFTRealWrapper() + : m_private(new FFTRealWrapperPrivate) +{ + +} + +FFTRealWrapper::~FFTRealWrapper() +{ + delete m_private; +} + +void FFTRealWrapper::calculateFFT(DataType in[], const DataType out[]) +{ + m_private->m_fft.do_fft(in, out); +} diff --git a/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.h b/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.h new file mode 100644 index 0000000..48d614e --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.h @@ -0,0 +1,63 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** This program 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. This +** program 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 General Public License +** for more details. You should have received a copy of the GNU General +** Public License along with this program. If not, see +** . +** +***************************************************************************/ + +#ifndef FFTREAL_WRAPPER_H +#define FFTREAL_WRAPPER_H + +#include + +#if defined(FFTREAL_LIBRARY) +# define FFTREAL_EXPORT Q_DECL_EXPORT +#else +# define FFTREAL_EXPORT Q_DECL_IMPORT +#endif + +class FFTRealWrapperPrivate; + +// Each pass of the FFT processes 2^X samples, where X is the +// number below. +static const int FFTLengthPowerOfTwo = 12; + +/** + * Wrapper around the FFTRealFixLen template provided by the FFTReal + * library + * + * This class instantiates a single instance of FFTRealFixLen, using + * FFTLengthPowerOfTwo as the template parameter. It then exposes + * FFTRealFixLen::do_fft via the calculateFFT + * function, thereby allowing an application to dynamically link + * against the FFTReal implementation. + * + * See http://ldesoras.free.fr/prod.html + */ +class FFTREAL_EXPORT FFTRealWrapper +{ +public: + FFTRealWrapper(); + ~FFTRealWrapper(); + + typedef float DataType; + void calculateFFT(DataType in[], const DataType out[]); + +private: + FFTRealWrapperPrivate* m_private; +}; + +#endif // FFTREAL_WRAPPER_H + diff --git a/demos/spectrum/3rdparty/fftreal/license.txt b/demos/spectrum/3rdparty/fftreal/license.txt new file mode 100644 index 0000000..918fe68 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/license.txt @@ -0,0 +1,459 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + diff --git a/demos/spectrum/3rdparty/fftreal/readme.txt b/demos/spectrum/3rdparty/fftreal/readme.txt new file mode 100644 index 0000000..0c5ce16 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/readme.txt @@ -0,0 +1,242 @@ +============================================================================== + + FFTReal + Version 2.00, 2005/10/18 + + Fourier transformation (FFT, IFFT) library specialised for real data + Portable ISO C++ + + (c) Laurent de Soras + Object Pascal port (c) Frederic Vanmol + +============================================================================== + + + +1. Legal +-------- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Check the file license.txt to get full information about the license. + + + +2. Content +---------- + +FFTReal is a library to compute Discrete Fourier Transforms (DFT) with the +FFT algorithm (Fast Fourier Transform) on arrays of real numbers. It can +also compute the inverse transform. + +You should find in this package a lot of files ; some of them are of interest: +- readme.txt: you are reading it +- FFTReal.h: FFT, length fixed at run-time +- FFTRealFixLen.h: FFT, length fixed at compile-time +- FFTReal.pas: Pascal implementation (working but not up-to-date) +- stopwatch directory + + + +3. Using FFTReal +---------------- + +Important - if you were using older versions of FFTReal (up to 1.03), some +things have changed. FFTReal is now a template. Therefore use FFTReal +or FFTReal in your code depending on the application datatype. The +flt_t typedef has been removed. + +You have two ways to use FFTReal. In the first way, the FFT has its length +fixed at run-time, when the object is instanciated. It means that you have +not to know the length when you write the code. This is the usual way of +proceeding. + + +3.1 FFTReal - Length fixed at run-time +-------------------------------------- + +Just instanciate one time a FFTReal object. Specify the data type you want +as template parameter (only floating point: float, double, long double or +custom type). The constructor precompute a lot of things, so it may be a bit +long. The parameter is the number of points used for the next FFTs. It must +be a power of 2: + + #include "FFTReal.h" + ... + long len = 1024; + ... + FFTReal fft_object (len); // 1024-point FFT object constructed. + +Then you can use this object to compute as many FFTs and IFFTs as you want. +They will be computed very quickly because a lot of work has been done in the +object construction. + + float x [1024]; + float f [1024]; + + ... + fft_object.do_fft (f, x); // x (real) --FFT---> f (complex) + ... + fft_object.do_ifft (f, x); // f (complex) --IFFT--> x (real) + fft_object.rescale (x); // Post-scaling should be done after FFT+IFFT + ... + +x [] and f [] are floating point number arrays. x [] is the real number +sequence which we want to compute the FFT. f [] is the result, in the +"frequency" domain. f has the same number of elements as x [], but f [] +elements are complex numbers. The routine uses some FFT properties to +optimize memory and to reduce calculations: the transformaton of a real +number sequence is a conjugate complex number sequence: F [k] = F [-k]*. + + +3.2 FFTRealFixLen - Length fixed at compile-time +------------------------------------------------ + +This class is significantly faster than the previous one, giving a speed +gain between 50 and 100 %. The template parameter is the base-2 logarithm of +the FFT length. The datatype is float; it can be changed by modifying the +DataType typedef in FFTRealFixLenParam.h. As FFTReal class, it supports +only floating-point types or equivalent. + +To instanciate the object, just proceed as below: + + #include "FFTRealFixLen.h" + ... + FFTRealFixLen <10> fft_object; // 1024-point (2^10) FFT object constructed. + +Use is similar as the one of FFTReal. + + +3.3 Data organisation +--------------------- + +Mathematically speaking, the formulas below show what does FFTReal: + +do_fft() : f(k) = sum (p = 0, N-1, x(p) * exp (+j*2*pi*k*p/N)) +do_ifft(): x(k) = sum (p = 0, N-1, f(p) * exp (-j*2*pi*k*p/N)) + +Where j is the square root of -1. The formulas differ only by the sign of +the exponential. When the sign is positive, the transform is called positive. +Common formulas for Fourier transform are negative for the direct tranform and +positive for the inverse one. + +However in these formulas, f is an array of complex numbers and doesn't +correspound exactly to the f[] array taken as function parameter. The +following table shows how the f[] sequence is mapped onto the usable FFT +coefficients (called bins): + + FFTReal output | Positive FFT equiv. | Negative FFT equiv. + ---------------+-----------------------+----------------------- + f [0] | Real (bin 0) | Real (bin 0) + f [...] | Real (bin ...) | Real (bin ...) + f [length/2] | Real (bin length/2) | Real (bin length/2) + f [length/2+1] | Imag (bin 1) | -Imag (bin 1) + f [...] | Imag (bin ...) | -Imag (bin ...) + f [length-1] | Imag (bin length/2-1) | -Imag (bin length/2-1) + +And FFT bins are distributed in f [] as above: + + | | Positive FFT | Negative FFT + Bin | Real part | imaginary part | imaginary part + ------------+----------------+-----------------+--------------- + 0 | f [0] | 0 | 0 + 1 | f [1] | f [length/2+1] | -f [length/2+1] + ... | f [...], | f [...] | -f [...] + length/2-1 | f [length/2-1] | f [length-1] | -f [length-1] + length/2 | f [length/2] | 0 | 0 + length/2+1 | f [length/2-1] | -f [length-1] | f [length-1] + ... | f [...] | -f [...] | f [...] + length-1 | f [1] | -f [length/2+1] | f [length/2+1] + +f [] coefficients have the same layout for FFT and IFFT functions. You may +notice that scaling must be done if you want to retrieve x after FFT and IFFT. +Actually, IFFT (FFT (x)) = x * length(x). This is a not a problem because +most of the applications don't care about absolute values. Thus, the operation +requires less calculation. If you want to use the FFT and IFFT to transform a +signal, you have to apply post- (or pre-) processing yourself. Multiplying +or dividing floating point numbers by a power of 2 doesn't generate extra +computation noise. + + + +4. Compilation and testing +-------------------------- + +Drop the following files into your project or makefile: + +Array.* +def.h +DynArray.* +FFTReal*.cpp +FFTReal*.h* +OscSinCos.* + +Other files are for testing purpose only, do not include them if you just need +to use the library ; they are not needed to use FFTReal in your own programs. + +FFTReal may be compiled in two versions: release and debug. Debug version +has checks that could slow down the code. Define NDEBUG to set the Release +mode. For example, the command line to compile the test bench on GCC would +look like: + +Debug mode: +g++ -Wall -o fftreal_debug.exe *.cpp stopwatch/*.cpp + +Release mode: +g++ -Wall -o fftreal_release.exe -DNDEBUG -O3 *.cpp stopwatch/*.cpp + +It may be tricky to compile the test bench because the speed tests use the +stopwatch sub-library, which is not that cross-platform. If you encounter +any problem that you cannot easily fix while compiling it, edit the file +test_settings.h and un-define the speed test macro. Remove the stopwatch +directory from your source file list, too. + +If it's not done by default, you should activate the exception handling +of your compiler to get the class memory-leak-safe. Thus, when a memory +allocation fails (in the constructor), an exception is thrown and the entire +object is safely destructed. It reduces the permanent error checking overhead +in the client code. Also, the test bench requires Run-Time Type Information +(RTTI) to be enabled in order to display the names of the tested classes - +sometimes mangled, depending on the compiler. + +The test bench may take a long time to compile, especially in Release mode, +because a lot of recursive templates are instanciated. + + + +5. History +---------- + +v2.00 (2005.10.18) +- Turned FFTReal class into template (data type as parameter) +- Added FFTRealFixLen +- Trigonometric tables are size-limited in order to preserve cache memory; +over a given size, sin/cos functions are computed on the fly. +- Better test bench for accuracy and speed + +v1.03 (2001.06.15) +- Thanks to Frederic Vanmol for the Pascal port (works with Delphi). +- Documentation improvement + +v1.02 (2001.03.25) +- sqrt() is now precomputed when the object FFTReal is constructed, resulting +in speed impovement for small size FFT. + +v1.01 (2000) +- Small modifications, I don't remember what. + +v1.00 (1999.08.14) +- First version released + diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.cpp b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.cpp new file mode 100644 index 0000000..fe1d424 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.cpp @@ -0,0 +1,285 @@ +/***************************************************************************** + + ClockCycleCounter.cpp + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (_MSC_VER) + #pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant" + #pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer" + #pragma warning (1 : 4705) // "statement has no effect" + #pragma warning (1 : 4706) // "assignment within conditional expression" + #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" + #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" + #pragma warning (4 : 4355) // "'this' : used in base member initializer list" +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "ClockCycleCounter.h" + +#include + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/* +============================================================================== +Name: ctor +Description: + The first object constructed initialise global data. This first + construction may be a bit slow. +Throws: Nothing +============================================================================== +*/ + +ClockCycleCounter::ClockCycleCounter () +: _start_time (0) +, _state (0) +, _best_score (-1) +{ + if (! _init_flag) + { + // Should be executed in this order + compute_clk_mul (); + compute_measure_time_total (); + compute_measure_time_lap (); + + // Restores object state + _start_time = 0; + _state = 0; + _best_score = -1; + + _init_flag = true; + } +} + + + +/* +============================================================================== +Name: get_time_total +Description: + Gives the time elapsed between the latest stop_lap() and start() calls. +Returns: + The duration, in clock cycles. +Throws: Nothing +============================================================================== +*/ + +Int64 ClockCycleCounter::get_time_total () const +{ + const Int64 duration = _state - _start_time; + assert (duration >= 0); + + const Int64 t = max ( + duration - _measure_time_total, + static_cast (0) + ); + + return (t * _clk_mul); +} + + + +/* +============================================================================== +Name: get_time_best_lap +Description: + Gives the smallest time between two consecutive stop_lap() or between + the stop_lap() and start(). The value is reset by a call to start(). + Call this function only after a stop_lap(). + The time is amputed from the duration of the stop_lap() call itself. +Returns: + The smallest duration, in clock cycles. +Throws: Nothing +============================================================================== +*/ + +Int64 ClockCycleCounter::get_time_best_lap () const +{ + assert (_best_score >= 0); + + const Int64 t1 = max ( + _best_score - _measure_time_lap, + static_cast (0) + ); + const Int64 t = min (t1, get_time_total ()); + + return (t * _clk_mul); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#if defined (__MACOS__) + +static inline double stopwatch_ClockCycleCounter_get_time_s () +{ + const Nanoseconds ns = AbsoluteToNanoseconds (UpTime ()); + + return (ns.hi * 4294967296e-9 + ns.lo * 1e-9); +} + +#endif // __MACOS__ + + + +/* +============================================================================== +Name: compute_clk_mul +Description: + This function, only for PowerPC/MacOS computers, computes the multiplier + required to deduce clock cycles from the internal counter. +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::compute_clk_mul () +{ + assert (! _init_flag); + +#if defined (__MACOS__) + + long clk_speed_mhz = CurrentProcessorSpeed (); + const Int64 clk_speed = + static_cast (clk_speed_mhz) * (1000L*1000L); + + const double start_time_s = stopwatch_ClockCycleCounter_get_time_s (); + start (); + + const double duration = 0.01; // Seconds + while (stopwatch_ClockCycleCounter_get_time_s () - start_time_s < duration) + { + continue; + } + + const double stop_time_s = stopwatch_ClockCycleCounter_get_time_s (); + stop (); + + const double diff_time_s = stop_time_s - start_time_s; + const double nbr_cycles = diff_time_s * static_cast (clk_speed); + + const Int64 diff_time_c = _state - _start_time; + const double clk_mul = nbr_cycles / static_cast (diff_time_c); + + _clk_mul = round_int (clk_mul); + +#endif // __MACOS__ +} + + + +void ClockCycleCounter::compute_measure_time_total () +{ + start (); + spend_time (); + + Int64 best_result = 0x7FFFFFFFL; // Should be enough + long nbr_tests = 100; + for (long cnt = 0; cnt < nbr_tests; ++cnt) + { + start (); + stop_lap (); + const Int64 duration = _state - _start_time; + best_result = min (best_result, duration); + } + + _measure_time_total = best_result; +} + + + +/* +============================================================================== +Name: compute_measure_time_lap +Description: + Computes the duration of one stop_lap() call and store it. It will be used + later to get the real duration of the measured operation (by substracting + the measurement duration). +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::compute_measure_time_lap () +{ + start (); + spend_time (); + + long nbr_tests = 10; + for (long cnt = 0; cnt < nbr_tests; ++cnt) + { + stop_lap (); + stop_lap (); + stop_lap (); + stop_lap (); + } + + _measure_time_lap = _best_score; +} + + + +void ClockCycleCounter::spend_time () +{ + const Int64 nbr_clocks = 500; // Number of clock cycles to spend + + const Int64 start = read_clock_counter (); + Int64 current; + + do + { + current = read_clock_counter (); + } + while ((current - start) * _clk_mul < nbr_clocks); +} + + + +Int64 ClockCycleCounter::_measure_time_total = 0; +Int64 ClockCycleCounter::_measure_time_lap = 0; +int ClockCycleCounter::_clk_mul = 1; +bool ClockCycleCounter::_init_flag = false; + + +} // namespace stopwatch + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.h b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.h new file mode 100644 index 0000000..ba7a99a --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.h @@ -0,0 +1,124 @@ +/***************************************************************************** + + ClockCycleCounter.h + Copyright (c) 2003 Laurent de Soras + +Instrumentation class, for accurate time interval measurement. You may have +to modify the implementation to adapt it to your system and/or compiler. + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_ClockCycleCounter_HEADER_INCLUDED) +#define stopwatch_ClockCycleCounter_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "Int64.h" + + + +namespace stopwatch +{ + + + +class ClockCycleCounter +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + ClockCycleCounter (); + + stopwatch_FORCEINLINE void + start (); + stopwatch_FORCEINLINE void + stop_lap (); + Int64 get_time_total () const; + Int64 get_time_best_lap () const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + void compute_clk_mul (); + void compute_measure_time_total (); + void compute_measure_time_lap (); + + static void spend_time (); + static stopwatch_FORCEINLINE Int64 + read_clock_counter (); + + Int64 _start_time; + Int64 _state; + Int64 _best_score; + + static Int64 _measure_time_total; + static Int64 _measure_time_lap; + static int _clk_mul; + static bool _init_flag; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + ClockCycleCounter (const ClockCycleCounter &other); + ClockCycleCounter & + operator = (const ClockCycleCounter &other); + bool operator == (const ClockCycleCounter &other); + bool operator != (const ClockCycleCounter &other); + +}; // class ClockCycleCounter + + + +} // namespace stopwatch + + + +#include "ClockCycleCounter.hpp" + + + +#endif // stopwatch_ClockCycleCounter_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.hpp b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.hpp new file mode 100644 index 0000000..fbd511e --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.hpp @@ -0,0 +1,150 @@ +/***************************************************************************** + + ClockCycleCounter.hpp + Copyright (c) 2003 Laurent de Soras + +Please complete the definitions according to your compiler/architecture. +It's not a big deal if it's not possible to get the clock count... + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (stopwatch_ClockCycleCounter_CURRENT_CODEHEADER) + #error Recursive inclusion of ClockCycleCounter code header. +#endif +#define stopwatch_ClockCycleCounter_CURRENT_CODEHEADER + +#if ! defined (stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED) +#define stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "fnc.h" + +#include + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/* +============================================================================== +Name: start +Description: + Starts the counter. +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::start () +{ + _best_score = (static_cast (1) << (sizeof (Int64) * CHAR_BIT - 2)); + const Int64 start_clock = read_clock_counter (); + _start_time = start_clock; + _state = start_clock - _best_score; +} + + + +/* +============================================================================== +Name: stop_lap +Description: + Captures the current time and updates the smallest duration between two + consecutive calls to stop_lap() or the latest start(). + start() must have been called at least once before calling this function. +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::stop_lap () +{ + const Int64 end_clock = read_clock_counter (); + _best_score = min (end_clock - _state, _best_score); + _state = end_clock; +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +Int64 ClockCycleCounter::read_clock_counter () +{ + register Int64 clock_cnt; + +#if defined (_MSC_VER) + + __asm + { + lea edi, clock_cnt + rdtsc + mov [edi ], eax + mov [edi + 4], edx + } + +#elif defined (__GNUC__) && defined (__i386__) + + __asm__ __volatile__ ("rdtsc" : "=A" (clock_cnt)); + +#elif (__MWERKS__) && defined (__POWERPC__) + + asm + { + loop: + mftbu clock_cnt@hiword + mftb clock_cnt@loword + mftbu r5 + cmpw clock_cnt@hiword,r5 + bne loop + } + +#endif + + return (clock_cnt); +} + + + +} // namespace stopwatch + + + +#endif // stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED + +#undef stopwatch_ClockCycleCounter_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/Int64.h b/demos/spectrum/3rdparty/fftreal/stopwatch/Int64.h new file mode 100644 index 0000000..1e786e2 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/Int64.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + Int64.h + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_Int64_HEADER_INCLUDED) +#define stopwatch_Int64_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + +#if defined (_MSC_VER) + + typedef __int64 Int64; + +#elif defined (__MWERKS__) || defined (__GNUC__) + + typedef long long Int64; + +#elif defined (__BEOS__) + + typedef int64 Int64; + +#else + + #error No 64-bit integer type defined for this compiler ! + +#endif + + +} // namespace stopwatch + + + +#endif // stopwatch_Int64_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.cpp b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.cpp new file mode 100644 index 0000000..7795d86 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.cpp @@ -0,0 +1,101 @@ +/***************************************************************************** + + StopWatch.cpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (_MSC_VER) + #pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant" + #pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer" + #pragma warning (1 : 4705) // "statement has no effect" + #pragma warning (1 : 4706) // "assignment within conditional expression" + #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" + #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" + #pragma warning (4 : 4355) // "'this' : used in base member initializer list" +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "StopWatch.h" + +#include + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +StopWatch::StopWatch () +: _ccc () +, _nbr_laps (0) +{ + // Nothing +} + + + +double StopWatch::get_time_total (Int64 nbr_op) const +{ + assert (_nbr_laps > 0); + assert (nbr_op > 0); + + return ( + static_cast (_ccc.get_time_total ()) + / (static_cast (nbr_op) * static_cast (_nbr_laps)) + ); +} + + + +double StopWatch::get_time_best_lap (Int64 nbr_op) const +{ + assert (nbr_op > 0); + + return ( + static_cast (_ccc.get_time_best_lap ()) + / static_cast (nbr_op) + ); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +} // namespace stopwatch + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.h b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.h new file mode 100644 index 0000000..9cc47e5 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.h @@ -0,0 +1,110 @@ +/***************************************************************************** + + StopWatch.h + Copyright (c) 2005 Laurent de Soras + +Utility class based on ClockCycleCounter to measure the unit time of a +repeated operation. + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_StopWatch_HEADER_INCLUDED) +#define stopwatch_StopWatch_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "ClockCycleCounter.h" + + + +namespace stopwatch +{ + + + +class StopWatch +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + StopWatch (); + + stopwatch_FORCEINLINE void + start (); + stopwatch_FORCEINLINE void + stop_lap (); + + double get_time_total (Int64 nbr_op) const; + double get_time_best_lap (Int64 nbr_op) const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + ClockCycleCounter + _ccc; + Int64 _nbr_laps; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + StopWatch (const StopWatch &other); + StopWatch & operator = (const StopWatch &other); + bool operator == (const StopWatch &other); + bool operator != (const StopWatch &other); + +}; // class StopWatch + + + +} // namespace stopwatch + + + +#include "StopWatch.hpp" + + + +#endif // stopwatch_StopWatch_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.hpp b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.hpp new file mode 100644 index 0000000..74482a7 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.hpp @@ -0,0 +1,83 @@ +/***************************************************************************** + + StopWatch.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (stopwatch_StopWatch_CURRENT_CODEHEADER) + #error Recursive inclusion of StopWatch code header. +#endif +#define stopwatch_StopWatch_CURRENT_CODEHEADER + +#if ! defined (stopwatch_StopWatch_CODEHEADER_INCLUDED) +#define stopwatch_StopWatch_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +void StopWatch::start () +{ + _nbr_laps = 0; + _ccc.start (); +} + + + +void StopWatch::stop_lap () +{ + _ccc.stop_lap (); + ++ _nbr_laps; +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +} // namespace stopwatch + + + +#endif // stopwatch_StopWatch_CODEHEADER_INCLUDED + +#undef stopwatch_StopWatch_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/def.h b/demos/spectrum/3rdparty/fftreal/stopwatch/def.h new file mode 100644 index 0000000..81ee6aa --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/def.h @@ -0,0 +1,65 @@ +/***************************************************************************** + + def.h + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_def_HEADER_INCLUDED) +#define stopwatch_def_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + + +#if defined (_MSC_VER) + + #define stopwatch_FORCEINLINE __forceinline + +#else + + #define stopwatch_FORCEINLINE inline + +#endif + + + +} // namespace stopwatch + + + +#endif // stopwatch_def_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.h b/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.h new file mode 100644 index 0000000..0554535 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.h @@ -0,0 +1,67 @@ +/***************************************************************************** + + fnc.h + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_fnc_HEADER_INCLUDED) +#define stopwatch_fnc_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + + +template +inline T min (T a, T b); + +template +inline T max (T a, T b); + +inline int round_int (double x); + + + +} // namespace rsp + + + +#include "fnc.hpp" + + + +#endif // stopwatch_fnc_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.hpp b/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.hpp new file mode 100644 index 0000000..0ab5949 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.hpp @@ -0,0 +1,85 @@ +/***************************************************************************** + + fnc.hpp + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (stopwatch_fnc_CURRENT_CODEHEADER) + #error Recursive inclusion of fnc code header. +#endif +#define stopwatch_fnc_CURRENT_CODEHEADER + +#if ! defined (stopwatch_fnc_CODEHEADER_INCLUDED) +#define stopwatch_fnc_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include +#include + +namespace std {} + + + +namespace stopwatch +{ + + + +template +inline T min (T a, T b) +{ + return ((a < b) ? a : b); +} + + + +template +inline T max (T a, T b) +{ + return ((b < a) ? a : b); +} + + + +int round_int (double x) +{ + using namespace std; + + return (static_cast (floor (x + 0.5))); +} + + + +} // namespace stopwatch + + + +#endif // stopwatch_fnc_CODEHEADER_INCLUDED + +#undef stopwatch_fnc_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/test.cpp b/demos/spectrum/3rdparty/fftreal/test.cpp new file mode 100644 index 0000000..7b6ed2c --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/test.cpp @@ -0,0 +1,267 @@ +/***************************************************************************** + + test.cpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (_MSC_VER) + #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" + #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_settings.h" +#include "TestHelperFixLen.h" +#include "TestHelperNormal.h" + +#if defined (_MSC_VER) +#include +#include +#endif // _MSC_VER + +#include + +#include +#include + + + +#define TEST_ + + +/*\\\ FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +static int TEST_perform_test_accuracy_all (); +static int TEST_perform_test_speed_all (); + +static void TEST_prog_init (); +static void TEST_prog_end (); + + + +int main (int argc, char *argv []) +{ + using namespace std; + + int ret_val = 0; + + TEST_prog_init (); + + try + { + if (ret_val == 0) + { + ret_val = TEST_perform_test_accuracy_all (); + } + + if (ret_val == 0) + { + ret_val = TEST_perform_test_speed_all (); + } + } + + catch (std::exception &e) + { + printf ("\n*** main(): Exception (std::exception) : %s\n", e.what ()); + ret_val = -1; + } + + catch (...) + { + printf ("\n*** main(): Undefined exception\n"); + ret_val = -1; + } + + TEST_prog_end (); + + return (ret_val); +} + + + +int TEST_perform_test_accuracy_all () +{ + int ret_val = 0; + + TestHelperNormal ::perform_test_accuracy (ret_val); + TestHelperNormal ::perform_test_accuracy (ret_val); + + TestHelperFixLen < 1>::perform_test_accuracy (ret_val); + TestHelperFixLen < 2>::perform_test_accuracy (ret_val); + TestHelperFixLen < 3>::perform_test_accuracy (ret_val); + TestHelperFixLen < 4>::perform_test_accuracy (ret_val); + TestHelperFixLen < 7>::perform_test_accuracy (ret_val); + TestHelperFixLen < 8>::perform_test_accuracy (ret_val); + TestHelperFixLen <10>::perform_test_accuracy (ret_val); + TestHelperFixLen <12>::perform_test_accuracy (ret_val); + TestHelperFixLen <13>::perform_test_accuracy (ret_val); + + return (ret_val); +} + + + +int TEST_perform_test_speed_all () +{ + int ret_val = 0; + +#if defined (test_settings_SPEED_TEST_ENABLED) + + TestHelperNormal ::perform_test_speed (ret_val); + TestHelperNormal ::perform_test_speed (ret_val); + + TestHelperFixLen < 1>::perform_test_speed (ret_val); + TestHelperFixLen < 2>::perform_test_speed (ret_val); + TestHelperFixLen < 3>::perform_test_speed (ret_val); + TestHelperFixLen < 4>::perform_test_speed (ret_val); + TestHelperFixLen < 7>::perform_test_speed (ret_val); + TestHelperFixLen < 8>::perform_test_speed (ret_val); + TestHelperFixLen <10>::perform_test_speed (ret_val); + TestHelperFixLen <12>::perform_test_speed (ret_val); + TestHelperFixLen <14>::perform_test_speed (ret_val); + TestHelperFixLen <16>::perform_test_speed (ret_val); + TestHelperFixLen <20>::perform_test_speed (ret_val); + +#endif + + return (ret_val); +} + + + +#if defined (_MSC_VER) +static int __cdecl TEST_new_handler_cb (size_t dummy) +{ + throw std::bad_alloc (); + return (0); +} +#endif // _MSC_VER + + + +#if defined (_MSC_VER) && ! defined (NDEBUG) +static int __cdecl TEST_debug_alloc_hook_cb (int alloc_type, void *user_data_ptr, size_t size, int block_type, long request_nbr, const unsigned char *filename_0, int line_nbr) +{ + if (block_type != _CRT_BLOCK) // Ignore CRT blocks to prevent infinite recursion + { + switch (alloc_type) + { + case _HOOK_ALLOC: + case _HOOK_REALLOC: + case _HOOK_FREE: + + // Put some debug code here + + break; + + default: + assert (false); // Undefined allocation type + break; + } + } + + return (1); +} +#endif + + + +#if defined (_MSC_VER) && ! defined (NDEBUG) +static int __cdecl TEST_debug_report_hook_cb (int report_type, char *user_msg_0, int *ret_val_ptr) +{ + *ret_val_ptr = 0; // 1 to override the CRT default reporting mode + + switch (report_type) + { + case _CRT_WARN: + case _CRT_ERROR: + case _CRT_ASSERT: + +// Put some debug code here + + break; + } + + return (*ret_val_ptr); +} +#endif + + + +static void TEST_prog_init () +{ +#if defined (_MSC_VER) + ::_set_new_handler (::TEST_new_handler_cb); +#endif // _MSC_VER + +#if defined (_MSC_VER) && ! defined (NDEBUG) + { + const int mode = (1 * _CRTDBG_MODE_DEBUG) + | (1 * _CRTDBG_MODE_WNDW); + ::_CrtSetReportMode (_CRT_WARN, mode); + ::_CrtSetReportMode (_CRT_ERROR, mode); + ::_CrtSetReportMode (_CRT_ASSERT, mode); + + const int old_flags = ::_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG); + ::_CrtSetDbgFlag ( old_flags + | (1 * _CRTDBG_LEAK_CHECK_DF) + | (1 * _CRTDBG_CHECK_ALWAYS_DF)); + ::_CrtSetBreakAlloc (-1); // Specify here a memory bloc number + ::_CrtSetAllocHook (TEST_debug_alloc_hook_cb); + ::_CrtSetReportHook (TEST_debug_report_hook_cb); + + // Speed up I/O but breaks C stdio compatibility +// std::cout.sync_with_stdio (false); +// std::cin.sync_with_stdio (false); +// std::cerr.sync_with_stdio (false); +// std::clog.sync_with_stdio (false); + } +#endif // _MSC_VER, NDEBUG +} + + + +static void TEST_prog_end () +{ +#if defined (_MSC_VER) && ! defined (NDEBUG) + { + const int mode = (1 * _CRTDBG_MODE_DEBUG) + | (0 * _CRTDBG_MODE_WNDW); + ::_CrtSetReportMode (_CRT_WARN, mode); + ::_CrtSetReportMode (_CRT_ERROR, mode); + ::_CrtSetReportMode (_CRT_ASSERT, mode); + + ::_CrtMemState mem_state; + ::_CrtMemCheckpoint (&mem_state); + ::_CrtMemDumpStatistics (&mem_state); + } +#endif // _MSC_VER, NDEBUG +} + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/test_fnc.h b/demos/spectrum/3rdparty/fftreal/test_fnc.h new file mode 100644 index 0000000..2622156 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/test_fnc.h @@ -0,0 +1,53 @@ +/***************************************************************************** + + test_fnc.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (test_fnc_HEADER_INCLUDED) +#define test_fnc_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +inline T limit (const T &x, const T &inf, const T &sup); + + + +#include "test_fnc.hpp" + + + +#endif // test_fnc_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/test_fnc.hpp b/demos/spectrum/3rdparty/fftreal/test_fnc.hpp new file mode 100644 index 0000000..4b5f9f5 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/test_fnc.hpp @@ -0,0 +1,56 @@ +/***************************************************************************** + + test_fnc.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (test_fnc_CURRENT_CODEHEADER) + #error Recursive inclusion of test_fnc code header. +#endif +#define test_fnc_CURRENT_CODEHEADER + +#if ! defined (test_fnc_CODEHEADER_INCLUDED) +#define test_fnc_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template +T limit (const T &x, const T &inf, const T &sup) +{ + assert (! (sup < inf)); + + return ((x < inf) ? inf : ((sup < x) ? sup : x)); +} + + + +#endif // test_fnc_CODEHEADER_INCLUDED + +#undef test_fnc_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/test_settings.h b/demos/spectrum/3rdparty/fftreal/test_settings.h new file mode 100644 index 0000000..b893afc --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/test_settings.h @@ -0,0 +1,45 @@ +/***************************************************************************** + + test_settings.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +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) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (test_settings_HEADER_INCLUDED) +#define test_settings_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +// #undef this label to avoid speed test compilation. +#define test_settings_SPEED_TEST_ENABLED + + + +#endif // test_settings_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/testapp.dpr b/demos/spectrum/3rdparty/fftreal/testapp.dpr new file mode 100644 index 0000000..54f2eb9 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/testapp.dpr @@ -0,0 +1,150 @@ +program testapp; +{$APPTYPE CONSOLE} +uses + SysUtils, + fftreal in 'fftreal.pas', + Math, + Windows; + +var + nbr_points : longint; + x, f : pflt_array; + fft : TFFTReal; + i : longint; + PI : double; + areal, img : double; + f_abs : double; + buffer_size : longint; + nbr_tests : longint; + time0, time1, time2 : int64; + timereso : int64; + offset : longint; + t0, t1 : double; + nbr_s_chn : longint; + tempp1, tempp2 : pflt_array; + +begin + (*______________________________________________ + * + * Exactness test + *______________________________________________ + *) + + WriteLn('Accuracy test:'); + WriteLn; + + nbr_points := 16; // Power of 2 + GetMem(x, nbr_points * sizeof_flt); + GetMem(f, nbr_points * sizeof_flt); + fft := TFFTReal.Create(nbr_points); // FFT object initialized here + + // Test signal + PI := ArcTan(1) * 4; + for i := 0 to nbr_points-1 do + begin + x^[i] := -1 + sin (3*2*PI*i/nbr_points) + + cos (5*2*PI*i/nbr_points) * 2 + - sin (7*2*PI*i/nbr_points) * 3 + + cos (8*2*PI*i/nbr_points) * 5; + end; + + // Compute FFT and IFFT + fft.do_fft(f, x); + fft.do_ifft(f, x); + fft.rescale(x); + + // Display the result + WriteLn('FFT:'); + for i := 0 to nbr_points div 2 do + begin + areal := f^[i]; + if (i > 0) and (i < nbr_points div 2) then + img := f^[i + nbr_points div 2] + else + img := 0; + + f_abs := Sqrt(areal * areal + img * img); + WriteLn(Format('%5d: %12.6f %12.6f (%12.6f)', [i, areal, img, f_abs])); + end; + + WriteLn; + WriteLn('IFFT:'); + for i := 0 to nbr_points-1 do + WriteLn(Format('%5d: %f', [i, x^[i]])); + + WriteLn; + + FreeMem(x); + FreeMem(f); + fft.Free; + + + (*______________________________________________ + * + * Speed test + *______________________________________________ + *) + + WriteLn('Speed test:'); + WriteLn('Please wait...'); + WriteLn; + + nbr_points := 1024; // Power of 2 + buffer_size := 256*nbr_points; // Number of flt_t (float or double) + nbr_tests := 10000; + + assert(nbr_points <= buffer_size); + GetMem(x, buffer_size * sizeof_flt); + GetMem(f, buffer_size * sizeof_flt); + fft := TFFTReal.Create(nbr_points); // FFT object initialized here + + // Test signal: noise + for i := 0 to nbr_points-1 do + x^[i] := Random($7fff) - ($7fff shr 1); + + // timing + QueryPerformanceFrequency(timereso); + QueryPerformanceCounter(time0); + + for i := 0 to nbr_tests-1 do + begin + offset := (i * nbr_points) and (buffer_size - 1); + tempp1 := f; + inc(tempp1, offset); + tempp2 := x; + inc(tempp2, offset); + fft.do_fft(tempp1, tempp2); + end; + + QueryPerformanceCounter(time1); + + for i := 0 to nbr_tests-1 do + begin + offset := (i * nbr_points) and (buffer_size - 1); + tempp1 := f; + inc(tempp1, offset); + tempp2 := x; + inc(tempp2, offset); + fft.do_ifft(tempp1, tempp2); + fft.rescale(x); + end; + + QueryPerformanceCounter(time2); + + t0 := ((time1-time0) / timereso) / nbr_tests; + t1 := ((time2-time1) / timereso) / nbr_tests; + + WriteLn(Format('%d-points FFT : %.0f us.', [nbr_points, t0 * 1000000])); + WriteLn(Format('%d-points IFFT + scaling: %.0f us.', [nbr_points, t1 * 1000000])); + + nbr_s_chn := Floor(nbr_points / ((t0 + t1) * 44100 * 2)); + WriteLn(Format('Peak performance: FFT+IFFT on %d mono channels at 44.1 KHz (with overlapping)', [nbr_s_chn])); + WriteLn; + + FreeMem(x); + FreeMem(f); + fft.Free; + + WriteLn('Press [Return] key to terminate...'); + ReadLn; +end. diff --git a/demos/spectrum/app/app.pro b/demos/spectrum/app/app.pro index 9964d14..2adb605 100644 --- a/demos/spectrum/app/app.pro +++ b/demos/spectrum/app/app.pro @@ -37,7 +37,9 @@ HEADERS += engine.h \ waveform.h \ wavfile.h -INCLUDEPATH += ../fftreal +fftreal_dir = ../3rdparty/fftreal + +INCLUDEPATH += $${fftreal_dir} RESOURCES = spectrum.qrc @@ -58,7 +60,7 @@ symbian { } else { macx { # Link to fftreal framework - LIBS += -F../fftreal + LIBS += -F$${fftreal_dir} LIBS += -framework fftreal } else { # Link to dynamic library which is written to ../bin @@ -92,7 +94,7 @@ symbian { QMAKE_POST_LINK = \ mkdir -p $${framework_dir} &&\ rm -rf $${framework_dir}/fftreal.framework &&\ - cp -R ../fftreal/fftreal.framework $${framework_dir} &&\ + cp -R $${fftreal_dir}/fftreal.framework $${framework_dir} &&\ install_name_tool -id @executable_path/../Frameworks/$${framework_name} \ $${framework_dir}/$${framework_name} &&\ install_name_tool -change $${framework_name} \ diff --git a/demos/spectrum/app/engine.h b/demos/spectrum/app/engine.h index 7028247..16088b2 100644 --- a/demos/spectrum/app/engine.h +++ b/demos/spectrum/app/engine.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/frequencyspectrum.h b/demos/spectrum/app/frequencyspectrum.h index 610ed6e..0dd814e 100644 --- a/demos/spectrum/app/frequencyspectrum.h +++ b/demos/spectrum/app/frequencyspectrum.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/levelmeter.h b/demos/spectrum/app/levelmeter.h index 7d4238d..ab8340b 100644 --- a/demos/spectrum/app/levelmeter.h +++ b/demos/spectrum/app/levelmeter.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/mainwidget.h b/demos/spectrum/app/mainwidget.h index 8e24f4a..846b97a 100644 --- a/demos/spectrum/app/mainwidget.h +++ b/demos/spectrum/app/mainwidget.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/progressbar.h b/demos/spectrum/app/progressbar.h index 8dc4765..de9e5a9 100644 --- a/demos/spectrum/app/progressbar.h +++ b/demos/spectrum/app/progressbar.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/settingsdialog.h b/demos/spectrum/app/settingsdialog.h index 5f613c0..7215a50 100644 --- a/demos/spectrum/app/settingsdialog.h +++ b/demos/spectrum/app/settingsdialog.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/spectrograph.h b/demos/spectrum/app/spectrograph.h index 837a1a5..6bfef33 100644 --- a/demos/spectrum/app/spectrograph.h +++ b/demos/spectrum/app/spectrograph.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/spectrum.h b/demos/spectrum/app/spectrum.h index 47b88ae..6cfe29f 100644 --- a/demos/spectrum/app/spectrum.h +++ b/demos/spectrum/app/spectrum.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/spectrumanalyser.h b/demos/spectrum/app/spectrumanalyser.h index 9d7684a..caeb1c1 100644 --- a/demos/spectrum/app/spectrumanalyser.h +++ b/demos/spectrum/app/spectrumanalyser.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/tonegenerator.h b/demos/spectrum/app/tonegenerator.h index 05d4c17..419f7e4 100644 --- a/demos/spectrum/app/tonegenerator.h +++ b/demos/spectrum/app/tonegenerator.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/tonegeneratordialog.h b/demos/spectrum/app/tonegeneratordialog.h index 33b608d..35d69c2 100644 --- a/demos/spectrum/app/tonegeneratordialog.h +++ b/demos/spectrum/app/tonegeneratordialog.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/utils.h b/demos/spectrum/app/utils.h index cfa3633..83467cd 100644 --- a/demos/spectrum/app/utils.h +++ b/demos/spectrum/app/utils.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/waveform.h b/demos/spectrum/app/waveform.h index e5cde5c..4de527f 100644 --- a/demos/spectrum/app/waveform.h +++ b/demos/spectrum/app/waveform.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/app/wavfile.cpp b/demos/spectrum/app/wavfile.cpp index 163e5ee..ec911ad 100644 --- a/demos/spectrum/app/wavfile.cpp +++ b/demos/spectrum/app/wavfile.cpp @@ -1,31 +1,31 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This device is part of the test suite of the Qt Toolkit. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage -** This device contains pre-release code and may not be distributed. -** You may use this device in accordance with the terms and conditions +** 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 device may be used under the terms of the GNU Lesser +** 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 device LICENSE.LGPL included in the -** packaging of this device. Please review the following information to +** 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 device LGPL_EXCEPTION.txt in this package. +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this device, please contact +** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. ** ** diff --git a/demos/spectrum/app/wavfile.h b/demos/spectrum/app/wavfile.h index d8c54fa..05866f7 100644 --- a/demos/spectrum/app/wavfile.h +++ b/demos/spectrum/app/wavfile.h @@ -6,6 +6,7 @@ ** ** This file is part of the examples of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ ** *****************************************************************************/ diff --git a/demos/spectrum/fftreal/Array.h b/demos/spectrum/fftreal/Array.h deleted file mode 100644 index a08e3cf..0000000 --- a/demos/spectrum/fftreal/Array.h +++ /dev/null @@ -1,97 +0,0 @@ -/***************************************************************************** - - Array.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (Array_HEADER_INCLUDED) -#define Array_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -class Array -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef T DataType; - - Array (); - - inline const DataType & - operator [] (long pos) const; - inline DataType & - operator [] (long pos); - - static inline long - size (); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - DataType _data_arr [LEN]; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - Array (const Array &other); - Array & operator = (const Array &other); - bool operator == (const Array &other); - bool operator != (const Array &other); - -}; // class Array - - - -#include "Array.hpp" - - - -#endif // Array_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/Array.hpp b/demos/spectrum/fftreal/Array.hpp deleted file mode 100644 index 8300077..0000000 --- a/demos/spectrum/fftreal/Array.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/***************************************************************************** - - Array.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (Array_CURRENT_CODEHEADER) - #error Recursive inclusion of Array code header. -#endif -#define Array_CURRENT_CODEHEADER - -#if ! defined (Array_CODEHEADER_INCLUDED) -#define Array_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -Array ::Array () -{ - // Nothing -} - - - -template -const typename Array ::DataType & Array ::operator [] (long pos) const -{ - assert (pos >= 0); - assert (pos < LEN); - - return (_data_arr [pos]); -} - - - -template -typename Array ::DataType & Array ::operator [] (long pos) -{ - assert (pos >= 0); - assert (pos < LEN); - - return (_data_arr [pos]); -} - - - -template -long Array ::size () -{ - return (LEN); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // Array_CODEHEADER_INCLUDED - -#undef Array_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/DynArray.h b/demos/spectrum/fftreal/DynArray.h deleted file mode 100644 index 8041a0c..0000000 --- a/demos/spectrum/fftreal/DynArray.h +++ /dev/null @@ -1,100 +0,0 @@ -/***************************************************************************** - - DynArray.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (DynArray_HEADER_INCLUDED) -#define DynArray_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -class DynArray -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef T DataType; - - DynArray (); - explicit DynArray (long size); - ~DynArray (); - - inline long size () const; - inline void resize (long size); - - inline const DataType & - operator [] (long pos) const; - inline DataType & - operator [] (long pos); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - DataType * _data_ptr; - long _len; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - DynArray (const DynArray &other); - DynArray & operator = (const DynArray &other); - bool operator == (const DynArray &other); - bool operator != (const DynArray &other); - -}; // class DynArray - - - -#include "DynArray.hpp" - - - -#endif // DynArray_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/DynArray.hpp b/demos/spectrum/fftreal/DynArray.hpp deleted file mode 100644 index e62b10f..0000000 --- a/demos/spectrum/fftreal/DynArray.hpp +++ /dev/null @@ -1,143 +0,0 @@ -/***************************************************************************** - - DynArray.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (DynArray_CURRENT_CODEHEADER) - #error Recursive inclusion of DynArray code header. -#endif -#define DynArray_CURRENT_CODEHEADER - -#if ! defined (DynArray_CODEHEADER_INCLUDED) -#define DynArray_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -DynArray ::DynArray () -: _data_ptr (0) -, _len (0) -{ - // Nothing -} - - - -template -DynArray ::DynArray (long size) -: _data_ptr (0) -, _len (0) -{ - assert (size >= 0); - if (size > 0) - { - _data_ptr = new DataType [size]; - _len = size; - } -} - - - -template -DynArray ::~DynArray () -{ - delete [] _data_ptr; - _data_ptr = 0; - _len = 0; -} - - - -template -long DynArray ::size () const -{ - return (_len); -} - - - -template -void DynArray ::resize (long size) -{ - assert (size >= 0); - if (size > 0) - { - DataType * old_data_ptr = _data_ptr; - DataType * tmp_data_ptr = new DataType [size]; - - _data_ptr = tmp_data_ptr; - _len = size; - - delete [] old_data_ptr; - } -} - - - -template -const typename DynArray ::DataType & DynArray ::operator [] (long pos) const -{ - assert (pos >= 0); - assert (pos < _len); - - return (_data_ptr [pos]); -} - - - -template -typename DynArray ::DataType & DynArray ::operator [] (long pos) -{ - assert (pos >= 0); - assert (pos < _len); - - return (_data_ptr [pos]); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // DynArray_CODEHEADER_INCLUDED - -#undef DynArray_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTReal.dsp b/demos/spectrum/fftreal/FFTReal.dsp deleted file mode 100644 index fe970db..0000000 --- a/demos/spectrum/fftreal/FFTReal.dsp +++ /dev/null @@ -1,273 +0,0 @@ -# Microsoft Developer Studio Project File - Name="FFTReal" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=FFTReal - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "FFTReal.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "FFTReal.mak" CFG="FFTReal - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "FFTReal - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "FFTReal - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "FFTReal - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GR /GX /O2 /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "FFTReal - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /GR /GX /Zi /Od /Gf /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c -# ADD BASE RSC /l 0x40c /d "_DEBUG" -# ADD RSC /l 0x40c /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "FFTReal - Win32 Release" -# Name "FFTReal - Win32 Debug" -# Begin Group "Library" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\Array.h -# End Source File -# Begin Source File - -SOURCE=.\Array.hpp -# End Source File -# Begin Source File - -SOURCE=.\def.h -# End Source File -# Begin Source File - -SOURCE=.\DynArray.h -# End Source File -# Begin Source File - -SOURCE=.\DynArray.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTReal.h -# End Source File -# Begin Source File - -SOURCE=.\FFTReal.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTRealFixLen.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealFixLen.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTRealFixLenParam.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealPassDirect.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealPassDirect.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTRealPassInverse.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealPassInverse.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTRealSelect.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealSelect.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTRealUseTrigo.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealUseTrigo.hpp -# End Source File -# Begin Source File - -SOURCE=.\OscSinCos.h -# End Source File -# Begin Source File - -SOURCE=.\OscSinCos.hpp -# End Source File -# End Group -# Begin Group "Test" - -# PROP Default_Filter "" -# Begin Group "stopwatch" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\stopwatch\ClockCycleCounter.cpp -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\ClockCycleCounter.h -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\ClockCycleCounter.hpp -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\def.h -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\fnc.h -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\fnc.hpp -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\Int64.h -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\StopWatch.cpp -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\StopWatch.h -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\StopWatch.hpp -# End Source File -# End Group -# Begin Source File - -SOURCE=.\test.cpp -# End Source File -# Begin Source File - -SOURCE=.\test_fnc.h -# End Source File -# Begin Source File - -SOURCE=.\test_fnc.hpp -# End Source File -# Begin Source File - -SOURCE=.\test_settings.h -# End Source File -# Begin Source File - -SOURCE=.\TestAccuracy.h -# End Source File -# Begin Source File - -SOURCE=.\TestAccuracy.hpp -# End Source File -# Begin Source File - -SOURCE=.\TestHelperFixLen.h -# End Source File -# Begin Source File - -SOURCE=.\TestHelperFixLen.hpp -# End Source File -# Begin Source File - -SOURCE=.\TestHelperNormal.h -# End Source File -# Begin Source File - -SOURCE=.\TestHelperNormal.hpp -# End Source File -# Begin Source File - -SOURCE=.\TestSpeed.h -# End Source File -# Begin Source File - -SOURCE=.\TestSpeed.hpp -# End Source File -# Begin Source File - -SOURCE=.\TestWhiteNoiseGen.h -# End Source File -# Begin Source File - -SOURCE=.\TestWhiteNoiseGen.hpp -# End Source File -# End Group -# End Target -# End Project diff --git a/demos/spectrum/fftreal/FFTReal.dsw b/demos/spectrum/fftreal/FFTReal.dsw deleted file mode 100644 index 076b0ae..0000000 --- a/demos/spectrum/fftreal/FFTReal.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "FFTReal"=.\FFTReal.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/demos/spectrum/fftreal/FFTReal.h b/demos/spectrum/fftreal/FFTReal.h deleted file mode 100644 index 9fb2725..0000000 --- a/demos/spectrum/fftreal/FFTReal.h +++ /dev/null @@ -1,142 +0,0 @@ -/***************************************************************************** - - FFTReal.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTReal_HEADER_INCLUDED) -#define FFTReal_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "DynArray.h" -#include "OscSinCos.h" - - - -template -class FFTReal -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - enum { MAX_BIT_DEPTH = 30 }; // So length can be represented as long int - - typedef DT DataType; - - explicit FFTReal (long length); - virtual ~FFTReal () {} - - long get_length () const; - void do_fft (DataType f [], const DataType x []) const; - void do_ifft (const DataType f [], DataType x []) const; - void rescale (DataType x []) const; - DataType * use_buffer () const; - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - // Over this bit depth, we use direct calculation for sin/cos - enum { TRIGO_BD_LIMIT = 12 }; - - typedef OscSinCos OscType; - - void init_br_lut (); - void init_trigo_lut (); - void init_trigo_osc (); - - FORCEINLINE const long * - get_br_ptr () const; - FORCEINLINE const DataType * - get_trigo_ptr (int level) const; - FORCEINLINE long - get_trigo_level_index (int level) const; - - inline void compute_fft_general (DataType f [], const DataType x []) const; - inline void compute_direct_pass_1_2 (DataType df [], const DataType x []) const; - inline void compute_direct_pass_3 (DataType df [], const DataType sf []) const; - inline void compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const; - inline void compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const; - inline void compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const; - - inline void compute_ifft_general (const DataType f [], DataType x []) const; - inline void compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const; - inline void compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const; - inline void compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const; - inline void compute_inverse_pass_3 (DataType df [], const DataType sf []) const; - inline void compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const; - - const long _length; - const int _nbr_bits; - DynArray - _br_lut; - DynArray - _trigo_lut; - mutable DynArray - _buffer; - mutable DynArray - _trigo_osc; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTReal (); - FFTReal (const FFTReal &other); - FFTReal & operator = (const FFTReal &other); - bool operator == (const FFTReal &other); - bool operator != (const FFTReal &other); - -}; // class FFTReal - - - -#include "FFTReal.hpp" - - - -#endif // FFTReal_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTReal.hpp b/demos/spectrum/fftreal/FFTReal.hpp deleted file mode 100644 index 335d771..0000000 --- a/demos/spectrum/fftreal/FFTReal.hpp +++ /dev/null @@ -1,916 +0,0 @@ -/***************************************************************************** - - FFTReal.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTReal_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTReal code header. -#endif -#define FFTReal_CURRENT_CODEHEADER - -#if ! defined (FFTReal_CODEHEADER_INCLUDED) -#define FFTReal_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include -#include - - - -static inline bool FFTReal_is_pow2 (long x) -{ - assert (x > 0); - - return ((x & -x) == x); -} - - - -static inline int FFTReal_get_next_pow2 (long x) -{ - --x; - - int p = 0; - while ((x & ~0xFFFFL) != 0) - { - p += 16; - x >>= 16; - } - while ((x & ~0xFL) != 0) - { - p += 4; - x >>= 4; - } - while (x > 0) - { - ++p; - x >>= 1; - } - - return (p); -} - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/* -============================================================================== -Name: ctor -Input parameters: - - length: length of the array on which we want to do a FFT. Range: power of - 2 only, > 0. -Throws: std::bad_alloc -============================================================================== -*/ - -template -FFTReal
    ::FFTReal (long length) -: _length (length) -, _nbr_bits (FFTReal_get_next_pow2 (length)) -, _br_lut () -, _trigo_lut () -, _buffer (length) -, _trigo_osc () -{ - assert (FFTReal_is_pow2 (length)); - assert (_nbr_bits <= MAX_BIT_DEPTH); - - init_br_lut (); - init_trigo_lut (); - init_trigo_osc (); -} - - - -/* -============================================================================== -Name: get_length -Description: - Returns the number of points processed by this FFT object. -Returns: The number of points, power of 2, > 0. -Throws: Nothing -============================================================================== -*/ - -template -long FFTReal
    ::get_length () const -{ - return (_length); -} - - - -/* -============================================================================== -Name: do_fft -Description: - Compute the FFT of the array. -Input parameters: - - x: pointer on the source array (time). -Output parameters: - - f: pointer on the destination array (frequencies). - f [0...length(x)/2] = real values, - f [length(x)/2+1...length(x)-1] = negative imaginary values of - coefficents 1...length(x)/2-1. -Throws: Nothing -============================================================================== -*/ - -template -void FFTReal
    ::do_fft (DataType f [], const DataType x []) const -{ - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); - - // General case - if (_nbr_bits > 2) - { - compute_fft_general (f, x); - } - - // 4-point FFT - else if (_nbr_bits == 2) - { - f [1] = x [0] - x [2]; - f [3] = x [1] - x [3]; - - const DataType b_0 = x [0] + x [2]; - const DataType b_2 = x [1] + x [3]; - - f [0] = b_0 + b_2; - f [2] = b_0 - b_2; - } - - // 2-point FFT - else if (_nbr_bits == 1) - { - f [0] = x [0] + x [1]; - f [1] = x [0] - x [1]; - } - - // 1-point FFT - else - { - f [0] = x [0]; - } -} - - - -/* -============================================================================== -Name: do_ifft -Description: - Compute the inverse FFT of the array. Note that data must be post-scaled: - IFFT (FFT (x)) = x * length (x). -Input parameters: - - f: pointer on the source array (frequencies). - f [0...length(x)/2] = real values - f [length(x)/2+1...length(x)-1] = negative imaginary values of - coefficents 1...length(x)/2-1. -Output parameters: - - x: pointer on the destination array (time). -Throws: Nothing -============================================================================== -*/ - -template -void FFTReal
    ::do_ifft (const DataType f [], DataType x []) const -{ - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); - - // General case - if (_nbr_bits > 2) - { - compute_ifft_general (f, x); - } - - // 4-point IFFT - else if (_nbr_bits == 2) - { - const DataType b_0 = f [0] + f [2]; - const DataType b_2 = f [0] - f [2]; - - x [0] = b_0 + f [1] * 2; - x [2] = b_0 - f [1] * 2; - x [1] = b_2 + f [3] * 2; - x [3] = b_2 - f [3] * 2; - } - - // 2-point IFFT - else if (_nbr_bits == 1) - { - x [0] = f [0] + f [1]; - x [1] = f [0] - f [1]; - } - - // 1-point IFFT - else - { - x [0] = f [0]; - } -} - - - -/* -============================================================================== -Name: rescale -Description: - Scale an array by divide each element by its length. This function should - be called after FFT + IFFT. -Input parameters: - - x: pointer on array to rescale (time or frequency). -Throws: Nothing -============================================================================== -*/ - -template -void FFTReal
    ::rescale (DataType x []) const -{ - const DataType mul = DataType (1.0 / _length); - - if (_length < 4) - { - long i = _length - 1; - do - { - x [i] *= mul; - --i; - } - while (i >= 0); - } - - else - { - assert ((_length & 3) == 0); - - // Could be optimized with SIMD instruction sets (needs alignment check) - long i = _length - 4; - do - { - x [i + 0] *= mul; - x [i + 1] *= mul; - x [i + 2] *= mul; - x [i + 3] *= mul; - i -= 4; - } - while (i >= 0); - } -} - - - -/* -============================================================================== -Name: use_buffer -Description: - Access the internal buffer, whose length is the FFT one. - Buffer content will be erased at each do_fft() / do_ifft() call! - This buffer cannot be used as: - - source for FFT or IFFT done with this object - - destination for FFT or IFFT done with this object -Returns: - Buffer start address -Throws: Nothing -============================================================================== -*/ - -template -typename FFTReal
    ::DataType * FFTReal
    ::use_buffer () const -{ - return (&_buffer [0]); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void FFTReal
    ::init_br_lut () -{ - const long length = 1L << _nbr_bits; - _br_lut.resize (length); - - _br_lut [0] = 0; - long br_index = 0; - for (long cnt = 1; cnt < length; ++cnt) - { - // ++br_index (bit reversed) - long bit = length >> 1; - while (((br_index ^= bit) & bit) == 0) - { - bit >>= 1; - } - - _br_lut [cnt] = br_index; - } -} - - - -template -void FFTReal
    ::init_trigo_lut () -{ - using namespace std; - - if (_nbr_bits > 3) - { - const long total_len = (1L << (_nbr_bits - 1)) - 4; - _trigo_lut.resize (total_len); - - for (int level = 3; level < _nbr_bits; ++level) - { - const long level_len = 1L << (level - 1); - DataType * const level_ptr = - &_trigo_lut [get_trigo_level_index (level)]; - const double mul = PI / (level_len << 1); - - for (long i = 0; i < level_len; ++ i) - { - level_ptr [i] = static_cast (cos (i * mul)); - } - } - } -} - - - -template -void FFTReal
    ::init_trigo_osc () -{ - const int nbr_osc = _nbr_bits - TRIGO_BD_LIMIT; - if (nbr_osc > 0) - { - _trigo_osc.resize (nbr_osc); - - for (int osc_cnt = 0; osc_cnt < nbr_osc; ++osc_cnt) - { - OscType & osc = _trigo_osc [osc_cnt]; - - const long len = 1L << (TRIGO_BD_LIMIT + osc_cnt); - const double mul = (0.5 * PI) / len; - osc.set_step (mul); - } - } -} - - - -template -const long * FFTReal
    ::get_br_ptr () const -{ - return (&_br_lut [0]); -} - - - -template -const typename FFTReal
    ::DataType * FFTReal
    ::get_trigo_ptr (int level) const -{ - assert (level >= 3); - - return (&_trigo_lut [get_trigo_level_index (level)]); -} - - - -template -long FFTReal
    ::get_trigo_level_index (int level) const -{ - assert (level >= 3); - - return ((1L << (level - 1)) - 4); -} - - - -// Transform in several passes -template -void FFTReal
    ::compute_fft_general (DataType f [], const DataType x []) const -{ - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); - - DataType * sf; - DataType * df; - - if ((_nbr_bits & 1) != 0) - { - df = use_buffer (); - sf = f; - } - else - { - df = f; - sf = use_buffer (); - } - - compute_direct_pass_1_2 (df, x); - compute_direct_pass_3 (sf, df); - - for (int pass = 3; pass < _nbr_bits; ++ pass) - { - compute_direct_pass_n (df, sf, pass); - - DataType * const temp_ptr = df; - df = sf; - sf = temp_ptr; - } -} - - - -template -void FFTReal
    ::compute_direct_pass_1_2 (DataType df [], const DataType x []) const -{ - assert (df != 0); - assert (x != 0); - assert (df != x); - - const long * const bit_rev_lut_ptr = get_br_ptr (); - long coef_index = 0; - do - { - const long rev_index_0 = bit_rev_lut_ptr [coef_index]; - const long rev_index_1 = bit_rev_lut_ptr [coef_index + 1]; - const long rev_index_2 = bit_rev_lut_ptr [coef_index + 2]; - const long rev_index_3 = bit_rev_lut_ptr [coef_index + 3]; - - DataType * const df2 = df + coef_index; - df2 [1] = x [rev_index_0] - x [rev_index_1]; - df2 [3] = x [rev_index_2] - x [rev_index_3]; - - const DataType sf_0 = x [rev_index_0] + x [rev_index_1]; - const DataType sf_2 = x [rev_index_2] + x [rev_index_3]; - - df2 [0] = sf_0 + sf_2; - df2 [2] = sf_0 - sf_2; - - coef_index += 4; - } - while (coef_index < _length); -} - - - -template -void FFTReal
    ::compute_direct_pass_3 (DataType df [], const DataType sf []) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); - long coef_index = 0; - do - { - DataType v; - - df [coef_index] = sf [coef_index] + sf [coef_index + 4]; - df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; - df [coef_index + 2] = sf [coef_index + 2]; - df [coef_index + 6] = sf [coef_index + 6]; - - v = (sf [coef_index + 5] - sf [coef_index + 7]) * sqrt2_2; - df [coef_index + 1] = sf [coef_index + 1] + v; - df [coef_index + 3] = sf [coef_index + 1] - v; - - v = (sf [coef_index + 5] + sf [coef_index + 7]) * sqrt2_2; - df [coef_index + 5] = v + sf [coef_index + 3]; - df [coef_index + 7] = v - sf [coef_index + 3]; - - coef_index += 8; - } - while (coef_index < _length); -} - - - -template -void FFTReal
    ::compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); - - if (pass <= TRIGO_BD_LIMIT) - { - compute_direct_pass_n_lut (df, sf, pass); - } - else - { - compute_direct_pass_n_osc (df, sf, pass); - } -} - - - -template -void FFTReal
    ::compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); - - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - const DataType * const cos_ptr = get_trigo_ptr (pass); - do - { - const DataType * const sf1r = sf + coef_index; - const DataType * const sf2r = sf1r + nbr_coef; - DataType * const dfr = df + coef_index; - DataType * const dfi = dfr + nbr_coef; - - // Extreme coefficients are always real - dfr [0] = sf1r [0] + sf2r [0]; - dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = - dfr [h_nbr_coef] = sf1r [h_nbr_coef]; - dfi [h_nbr_coef] = sf2r [h_nbr_coef]; - - // Others are conjugate complex numbers - const DataType * const sf1i = sf1r + h_nbr_coef; - const DataType * const sf2i = sf1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); - const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); - DataType v; - - v = sf2r [i] * c - sf2i [i] * s; - dfr [i] = sf1r [i] + v; - dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = - - v = sf2r [i] * s + sf2i [i] * c; - dfi [i] = v + sf1i [i]; - dfi [nbr_coef - i] = v - sf1i [i]; - } - - coef_index += d_nbr_coef; - } - while (coef_index < _length); -} - - - -template -void FFTReal
    ::compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass > TRIGO_BD_LIMIT); - assert (pass < _nbr_bits); - - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; - do - { - const DataType * const sf1r = sf + coef_index; - const DataType * const sf2r = sf1r + nbr_coef; - DataType * const dfr = df + coef_index; - DataType * const dfi = dfr + nbr_coef; - - osc.clear_buffers (); - - // Extreme coefficients are always real - dfr [0] = sf1r [0] + sf2r [0]; - dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = - dfr [h_nbr_coef] = sf1r [h_nbr_coef]; - dfi [h_nbr_coef] = sf2r [h_nbr_coef]; - - // Others are conjugate complex numbers - const DataType * const sf1i = sf1r + h_nbr_coef; - const DataType * const sf2i = sf1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - osc.step (); - const DataType c = osc.get_cos (); - const DataType s = osc.get_sin (); - DataType v; - - v = sf2r [i] * c - sf2i [i] * s; - dfr [i] = sf1r [i] + v; - dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = - - v = sf2r [i] * s + sf2i [i] * c; - dfi [i] = v + sf1i [i]; - dfi [nbr_coef - i] = v - sf1i [i]; - } - - coef_index += d_nbr_coef; - } - while (coef_index < _length); -} - - - -// Transform in several pass -template -void FFTReal
    ::compute_ifft_general (const DataType f [], DataType x []) const -{ - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); - - DataType * sf = const_cast (f); - DataType * df; - DataType * df_temp; - - if (_nbr_bits & 1) - { - df = use_buffer (); - df_temp = x; - } - else - { - df = x; - df_temp = use_buffer (); - } - - for (int pass = _nbr_bits - 1; pass >= 3; -- pass) - { - compute_inverse_pass_n (df, sf, pass); - - if (pass < _nbr_bits - 1) - { - DataType * const temp_ptr = df; - df = sf; - sf = temp_ptr; - } - else - { - sf = df; - df = df_temp; - } - } - - compute_inverse_pass_3 (df, sf); - compute_inverse_pass_1_2 (x, df); -} - - - -template -void FFTReal
    ::compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); - - if (pass <= TRIGO_BD_LIMIT) - { - compute_inverse_pass_n_lut (df, sf, pass); - } - else - { - compute_inverse_pass_n_osc (df, sf, pass); - } -} - - - -template -void FFTReal
    ::compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); - - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - const DataType * const cos_ptr = get_trigo_ptr (pass); - do - { - const DataType * const sfr = sf + coef_index; - const DataType * const sfi = sfr + nbr_coef; - DataType * const df1r = df + coef_index; - DataType * const df2r = df1r + nbr_coef; - - // Extreme coefficients are always real - df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] - df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] - df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; - df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; - - // Others are conjugate complex numbers - DataType * const df1i = df1r + h_nbr_coef; - DataType * const df2i = df1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] - df1i [i] = sfi [i] - sfi [nbr_coef - i]; - - const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); - const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); - const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] - const DataType vi = sfi [i] + sfi [nbr_coef - i]; - - df2r [i] = vr * c + vi * s; - df2i [i] = vi * c - vr * s; - } - - coef_index += d_nbr_coef; - } - while (coef_index < _length); -} - - - -template -void FFTReal
    ::compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass > TRIGO_BD_LIMIT); - assert (pass < _nbr_bits); - - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; - do - { - const DataType * const sfr = sf + coef_index; - const DataType * const sfi = sfr + nbr_coef; - DataType * const df1r = df + coef_index; - DataType * const df2r = df1r + nbr_coef; - - osc.clear_buffers (); - - // Extreme coefficients are always real - df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] - df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] - df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; - df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; - - // Others are conjugate complex numbers - DataType * const df1i = df1r + h_nbr_coef; - DataType * const df2i = df1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] - df1i [i] = sfi [i] - sfi [nbr_coef - i]; - - osc.step (); - const DataType c = osc.get_cos (); - const DataType s = osc.get_sin (); - const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] - const DataType vi = sfi [i] + sfi [nbr_coef - i]; - - df2r [i] = vr * c + vi * s; - df2i [i] = vi * c - vr * s; - } - - coef_index += d_nbr_coef; - } - while (coef_index < _length); -} - - - -template -void FFTReal
    ::compute_inverse_pass_3 (DataType df [], const DataType sf []) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); - long coef_index = 0; - do - { - df [coef_index] = sf [coef_index] + sf [coef_index + 4]; - df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; - df [coef_index + 2] = sf [coef_index + 2] * 2; - df [coef_index + 6] = sf [coef_index + 6] * 2; - - df [coef_index + 1] = sf [coef_index + 1] + sf [coef_index + 3]; - df [coef_index + 3] = sf [coef_index + 5] - sf [coef_index + 7]; - - const DataType vr = sf [coef_index + 1] - sf [coef_index + 3]; - const DataType vi = sf [coef_index + 5] + sf [coef_index + 7]; - - df [coef_index + 5] = (vr + vi) * sqrt2_2; - df [coef_index + 7] = (vi - vr) * sqrt2_2; - - coef_index += 8; - } - while (coef_index < _length); -} - - - -template -void FFTReal
    ::compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const -{ - assert (x != 0); - assert (sf != 0); - assert (x != sf); - - const long * bit_rev_lut_ptr = get_br_ptr (); - const DataType * sf2 = sf; - long coef_index = 0; - do - { - { - const DataType b_0 = sf2 [0] + sf2 [2]; - const DataType b_2 = sf2 [0] - sf2 [2]; - const DataType b_1 = sf2 [1] * 2; - const DataType b_3 = sf2 [3] * 2; - - x [bit_rev_lut_ptr [0]] = b_0 + b_1; - x [bit_rev_lut_ptr [1]] = b_0 - b_1; - x [bit_rev_lut_ptr [2]] = b_2 + b_3; - x [bit_rev_lut_ptr [3]] = b_2 - b_3; - } - { - const DataType b_0 = sf2 [4] + sf2 [6]; - const DataType b_2 = sf2 [4] - sf2 [6]; - const DataType b_1 = sf2 [5] * 2; - const DataType b_3 = sf2 [7] * 2; - - x [bit_rev_lut_ptr [4]] = b_0 + b_1; - x [bit_rev_lut_ptr [5]] = b_0 - b_1; - x [bit_rev_lut_ptr [6]] = b_2 + b_3; - x [bit_rev_lut_ptr [7]] = b_2 - b_3; - } - - sf2 += 8; - coef_index += 8; - bit_rev_lut_ptr += 8; - } - while (coef_index < _length); -} - - - -#endif // FFTReal_CODEHEADER_INCLUDED - -#undef FFTReal_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealFixLen.h b/demos/spectrum/fftreal/FFTRealFixLen.h deleted file mode 100644 index 0b80266..0000000 --- a/demos/spectrum/fftreal/FFTRealFixLen.h +++ /dev/null @@ -1,130 +0,0 @@ -/***************************************************************************** - - FFTRealFixLen.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealFixLen_HEADER_INCLUDED) -#define FFTRealFixLen_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "Array.h" -#include "DynArray.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - - -template -class FFTRealFixLen -{ - typedef int CompileTimeCheck1 [(LL2 >= 0) ? 1 : -1]; - typedef int CompileTimeCheck2 [(LL2 <= 30) ? 1 : -1]; - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; - - enum { FFT_LEN_L2 = LL2 }; - enum { FFT_LEN = 1 << FFT_LEN_L2 }; - - FFTRealFixLen (); - - inline long get_length () const; - void do_fft (DataType f [], const DataType x []); - void do_ifft (const DataType f [], DataType x []); - void rescale (DataType x []) const; - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - enum { TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT }; - - enum { BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) }; - enum { BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 }; - - enum { TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0) - ? (int)FFT_LEN_L2 - : (int)TRIGO_BD_LIMIT }; - enum { TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) }; - enum { TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 }; - - enum { NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD }; - enum { TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 }; - - void build_br_lut (); - void build_trigo_lut (); - void build_trigo_osc (); - - DynArray - _buffer; - DynArray - _br_data; - DynArray - _trigo_data; - Array - _trigo_osc; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTRealFixLen (const FFTRealFixLen &other); - FFTRealFixLen& operator = (const FFTRealFixLen &other); - bool operator == (const FFTRealFixLen &other); - bool operator != (const FFTRealFixLen &other); - -}; // class FFTRealFixLen - - - -#include "FFTRealFixLen.hpp" - - - -#endif // FFTRealFixLen_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealFixLen.hpp b/demos/spectrum/fftreal/FFTRealFixLen.hpp deleted file mode 100644 index 6defb00..0000000 --- a/demos/spectrum/fftreal/FFTRealFixLen.hpp +++ /dev/null @@ -1,322 +0,0 @@ -/***************************************************************************** - - FFTRealFixLen.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTRealFixLen_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealFixLen code header. -#endif -#define FFTRealFixLen_CURRENT_CODEHEADER - -#if ! defined (FFTRealFixLen_CODEHEADER_INCLUDED) -#define FFTRealFixLen_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "FFTRealPassDirect.h" -#include "FFTRealPassInverse.h" -#include "FFTRealSelect.h" - -#include -#include - -namespace std { } - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -FFTRealFixLen ::FFTRealFixLen () -: _buffer (FFT_LEN) -, _br_data (BR_ARR_SIZE) -, _trigo_data (TRIGO_TABLE_ARR_SIZE) -, _trigo_osc () -{ - build_br_lut (); - build_trigo_lut (); - build_trigo_osc (); -} - - - -template -long FFTRealFixLen ::get_length () const -{ - return (FFT_LEN); -} - - - -// General case -template -void FFTRealFixLen ::do_fft (DataType f [], const DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - assert (FFT_LEN_L2 >= 3); - - // Do the transform in several passes - const DataType * cos_ptr = &_trigo_data [0]; - const long * br_ptr = &_br_data [0]; - - FFTRealPassDirect ::process ( - FFT_LEN, - f, - &_buffer [0], - x, - cos_ptr, - TRIGO_TABLE_ARR_SIZE, - br_ptr, - &_trigo_osc [0] - ); -} - -// 4-point FFT -template <> -void FFTRealFixLen <2>::do_fft (DataType f [], const DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - - f [1] = x [0] - x [2]; - f [3] = x [1] - x [3]; - - const DataType b_0 = x [0] + x [2]; - const DataType b_2 = x [1] + x [3]; - - f [0] = b_0 + b_2; - f [2] = b_0 - b_2; -} - -// 2-point FFT -template <> -void FFTRealFixLen <1>::do_fft (DataType f [], const DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - - f [0] = x [0] + x [1]; - f [1] = x [0] - x [1]; -} - -// 1-point FFT -template <> -void FFTRealFixLen <0>::do_fft (DataType f [], const DataType x []) -{ - assert (f != 0); - assert (x != 0); - - f [0] = x [0]; -} - - - -// General case -template -void FFTRealFixLen ::do_ifft (const DataType f [], DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - assert (FFT_LEN_L2 >= 3); - - // Do the transform in several passes - DataType * s_ptr = - FFTRealSelect ::sel_bin (&_buffer [0], x); - DataType * d_ptr = - FFTRealSelect ::sel_bin (x, &_buffer [0]); - const DataType * cos_ptr = &_trigo_data [0]; - const long * br_ptr = &_br_data [0]; - - FFTRealPassInverse ::process ( - FFT_LEN, - d_ptr, - s_ptr, - f, - cos_ptr, - TRIGO_TABLE_ARR_SIZE, - br_ptr, - &_trigo_osc [0] - ); -} - -// 4-point IFFT -template <> -void FFTRealFixLen <2>::do_ifft (const DataType f [], DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - - const DataType b_0 = f [0] + f [2]; - const DataType b_2 = f [0] - f [2]; - - x [0] = b_0 + f [1] * 2; - x [2] = b_0 - f [1] * 2; - x [1] = b_2 + f [3] * 2; - x [3] = b_2 - f [3] * 2; -} - -// 2-point IFFT -template <> -void FFTRealFixLen <1>::do_ifft (const DataType f [], DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - - x [0] = f [0] + f [1]; - x [1] = f [0] - f [1]; -} - -// 1-point IFFT -template <> -void FFTRealFixLen <0>::do_ifft (const DataType f [], DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - - x [0] = f [0]; -} - - - - -template -void FFTRealFixLen ::rescale (DataType x []) const -{ - assert (x != 0); - - const DataType mul = DataType (1.0 / FFT_LEN); - - if (FFT_LEN < 4) - { - long i = FFT_LEN - 1; - do - { - x [i] *= mul; - --i; - } - while (i >= 0); - } - - else - { - assert ((FFT_LEN & 3) == 0); - - // Could be optimized with SIMD instruction sets (needs alignment check) - long i = FFT_LEN - 4; - do - { - x [i + 0] *= mul; - x [i + 1] *= mul; - x [i + 2] *= mul; - x [i + 3] *= mul; - i -= 4; - } - while (i >= 0); - } -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void FFTRealFixLen ::build_br_lut () -{ - _br_data [0] = 0; - for (long cnt = 1; cnt < BR_ARR_SIZE; ++cnt) - { - long index = cnt << 2; - long br_index = 0; - - int bit_cnt = FFT_LEN_L2; - do - { - br_index <<= 1; - br_index += (index & 1); - index >>= 1; - - -- bit_cnt; - } - while (bit_cnt > 0); - - _br_data [cnt] = br_index; - } -} - - - -template -void FFTRealFixLen ::build_trigo_lut () -{ - const double mul = (0.5 * PI) / TRIGO_TABLE_ARR_SIZE; - for (long i = 0; i < TRIGO_TABLE_ARR_SIZE; ++ i) - { - using namespace std; - - _trigo_data [i] = DataType (cos (i * mul)); - } -} - - - -template -void FFTRealFixLen ::build_trigo_osc () -{ - for (int i = 0; i < NBR_TRIGO_OSC; ++i) - { - OscType & osc = _trigo_osc [i]; - - const long len = static_cast (TRIGO_TABLE_ARR_SIZE) << (i + 1); - const double mul = (0.5 * PI) / len; - osc.set_step (mul); - } -} - - - -#endif // FFTRealFixLen_CODEHEADER_INCLUDED - -#undef FFTRealFixLen_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealFixLenParam.h b/demos/spectrum/fftreal/FFTRealFixLenParam.h deleted file mode 100644 index 163c083..0000000 --- a/demos/spectrum/fftreal/FFTRealFixLenParam.h +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************** - - FFTRealFixLenParam.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealFixLenParam_HEADER_INCLUDED) -#define FFTRealFixLenParam_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -class FFTRealFixLenParam -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - // Over this bit depth, we use direct calculation for sin/cos - enum { TRIGO_BD_LIMIT = 12 }; - - typedef float DataType; - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - -#if 0 // To avoid GCC warning: - // All member functions in class 'FFTRealFixLenParam' are private - FFTRealFixLenParam (); - ~FFTRealFixLenParam (); - FFTRealFixLenParam (const FFTRealFixLenParam &other); - FFTRealFixLenParam & - operator = (const FFTRealFixLenParam &other); - bool operator == (const FFTRealFixLenParam &other); - bool operator != (const FFTRealFixLenParam &other); -#endif - -}; // class FFTRealFixLenParam - - - -//#include "FFTRealFixLenParam.hpp" - - - -#endif // FFTRealFixLenParam_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealPassDirect.h b/demos/spectrum/fftreal/FFTRealPassDirect.h deleted file mode 100644 index 7d19c02..0000000 --- a/demos/spectrum/fftreal/FFTRealPassDirect.h +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************** - - FFTRealPassDirect.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealPassDirect_HEADER_INCLUDED) -#define FFTRealPassDirect_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - - -template -class FFTRealPassDirect -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; - - FORCEINLINE static void - process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTRealPassDirect (); - ~FFTRealPassDirect (); - FFTRealPassDirect (const FFTRealPassDirect &other); - FFTRealPassDirect & - operator = (const FFTRealPassDirect &other); - bool operator == (const FFTRealPassDirect &other); - bool operator != (const FFTRealPassDirect &other); - -}; // class FFTRealPassDirect - - - -#include "FFTRealPassDirect.hpp" - - - -#endif // FFTRealPassDirect_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealPassDirect.hpp b/demos/spectrum/fftreal/FFTRealPassDirect.hpp deleted file mode 100644 index db9d568..0000000 --- a/demos/spectrum/fftreal/FFTRealPassDirect.hpp +++ /dev/null @@ -1,204 +0,0 @@ -/***************************************************************************** - - FFTRealPassDirect.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTRealPassDirect_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealPassDirect code header. -#endif -#define FFTRealPassDirect_CURRENT_CODEHEADER - -#if ! defined (FFTRealPassDirect_CODEHEADER_INCLUDED) -#define FFTRealPassDirect_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "FFTRealUseTrigo.h" - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template <> -void FFTRealPassDirect <1>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // First and second pass at once - const long qlen = len >> 2; - - long coef_index = 0; - do - { - // To do: unroll the loop (2x). - const long ri_0 = br_ptr [coef_index >> 2]; - const long ri_1 = ri_0 + 2 * qlen; // bit_rev_lut_ptr [coef_index + 1]; - const long ri_2 = ri_0 + 1 * qlen; // bit_rev_lut_ptr [coef_index + 2]; - const long ri_3 = ri_0 + 3 * qlen; // bit_rev_lut_ptr [coef_index + 3]; - - DataType * const df2 = dest_ptr + coef_index; - df2 [1] = x_ptr [ri_0] - x_ptr [ri_1]; - df2 [3] = x_ptr [ri_2] - x_ptr [ri_3]; - - const DataType sf_0 = x_ptr [ri_0] + x_ptr [ri_1]; - const DataType sf_2 = x_ptr [ri_2] + x_ptr [ri_3]; - - df2 [0] = sf_0 + sf_2; - df2 [2] = sf_0 - sf_2; - - coef_index += 4; - } - while (coef_index < len); -} - -template <> -void FFTRealPassDirect <2>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // Executes "previous" passes first. Inverts source and destination buffers - FFTRealPassDirect <1>::process ( - len, - src_ptr, - dest_ptr, - x_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); - - // Third pass - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); - - long coef_index = 0; - do - { - dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; - dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; - dest_ptr [coef_index + 2] = src_ptr [coef_index + 2]; - dest_ptr [coef_index + 6] = src_ptr [coef_index + 6]; - - DataType v; - - v = (src_ptr [coef_index + 5] - src_ptr [coef_index + 7]) * sqrt2_2; - dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + v; - dest_ptr [coef_index + 3] = src_ptr [coef_index + 1] - v; - - v = (src_ptr [coef_index + 5] + src_ptr [coef_index + 7]) * sqrt2_2; - dest_ptr [coef_index + 5] = v + src_ptr [coef_index + 3]; - dest_ptr [coef_index + 7] = v - src_ptr [coef_index + 3]; - - coef_index += 8; - } - while (coef_index < len); -} - -template -void FFTRealPassDirect ::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // Executes "previous" passes first. Inverts source and destination buffers - FFTRealPassDirect ::process ( - len, - src_ptr, - dest_ptr, - x_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); - - const long dist = 1L << (PASS - 1); - const long c1_r = 0; - const long c1_i = dist; - const long c2_r = dist * 2; - const long c2_i = dist * 3; - const long cend = dist * 4; - const long table_step = cos_len >> (PASS - 1); - - enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; - enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; - - long coef_index = 0; - do - { - const DataType * const sf = src_ptr + coef_index; - DataType * const df = dest_ptr + coef_index; - - // Extreme coefficients are always real - df [c1_r] = sf [c1_r] + sf [c2_r]; - df [c2_r] = sf [c1_r] - sf [c2_r]; - df [c1_i] = sf [c1_i]; - df [c2_i] = sf [c2_i]; - - FFTRealUseTrigo ::prepare (osc_list [TRIGO_OSC]); - - // Others are conjugate complex numbers - for (long i = 1; i < dist; ++ i) - { - DataType c; - DataType s; - FFTRealUseTrigo ::iterate ( - osc_list [TRIGO_OSC], - c, - s, - cos_ptr, - i * table_step, - (dist - i) * table_step - ); - - const DataType sf_r_i = sf [c1_r + i]; - const DataType sf_i_i = sf [c1_i + i]; - - const DataType v1 = sf [c2_r + i] * c - sf [c2_i + i] * s; - df [c1_r + i] = sf_r_i + v1; - df [c2_r - i] = sf_r_i - v1; - - const DataType v2 = sf [c2_r + i] * s + sf [c2_i + i] * c; - df [c2_r + i] = v2 + sf_i_i; - df [cend - i] = v2 - sf_i_i; - } - - coef_index += cend; - } - while (coef_index < len); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // FFTRealPassDirect_CODEHEADER_INCLUDED - -#undef FFTRealPassDirect_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealPassInverse.h b/demos/spectrum/fftreal/FFTRealPassInverse.h deleted file mode 100644 index 2de8952..0000000 --- a/demos/spectrum/fftreal/FFTRealPassInverse.h +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************** - - FFTRealPassInverse.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealPassInverse_HEADER_INCLUDED) -#define FFTRealPassInverse_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - - - -template -class FFTRealPassInverse -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; - - FORCEINLINE static void - process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - FORCEINLINE static void - process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - FORCEINLINE static void - process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTRealPassInverse (); - ~FFTRealPassInverse (); - FFTRealPassInverse (const FFTRealPassInverse &other); - FFTRealPassInverse & - operator = (const FFTRealPassInverse &other); - bool operator == (const FFTRealPassInverse &other); - bool operator != (const FFTRealPassInverse &other); - -}; // class FFTRealPassInverse - - - -#include "FFTRealPassInverse.hpp" - - - -#endif // FFTRealPassInverse_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealPassInverse.hpp b/demos/spectrum/fftreal/FFTRealPassInverse.hpp deleted file mode 100644 index 5737546..0000000 --- a/demos/spectrum/fftreal/FFTRealPassInverse.hpp +++ /dev/null @@ -1,229 +0,0 @@ -/***************************************************************************** - - FFTRealPassInverse.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTRealPassInverse_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealPassInverse code header. -#endif -#define FFTRealPassInverse_CURRENT_CODEHEADER - -#if ! defined (FFTRealPassInverse_CODEHEADER_INCLUDED) -#define FFTRealPassInverse_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "FFTRealUseTrigo.h" - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void FFTRealPassInverse ::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - process_internal ( - len, - dest_ptr, - f_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); - FFTRealPassInverse ::process_rec ( - len, - src_ptr, - dest_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); -} - - - -template -void FFTRealPassInverse ::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - process_internal ( - len, - dest_ptr, - src_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); - FFTRealPassInverse ::process_rec ( - len, - src_ptr, - dest_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); -} - -template <> -void FFTRealPassInverse <0>::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // Stops recursion -} - - - -template -void FFTRealPassInverse ::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - const long dist = 1L << (PASS - 1); - const long c1_r = 0; - const long c1_i = dist; - const long c2_r = dist * 2; - const long c2_i = dist * 3; - const long cend = dist * 4; - const long table_step = cos_len >> (PASS - 1); - - enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; - enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; - - long coef_index = 0; - do - { - const DataType * const sf = src_ptr + coef_index; - DataType * const df = dest_ptr + coef_index; - - // Extreme coefficients are always real - df [c1_r] = sf [c1_r] + sf [c2_r]; - df [c2_r] = sf [c1_r] - sf [c2_r]; - df [c1_i] = sf [c1_i] * 2; - df [c2_i] = sf [c2_i] * 2; - - FFTRealUseTrigo ::prepare (osc_list [TRIGO_OSC]); - - // Others are conjugate complex numbers - for (long i = 1; i < dist; ++ i) - { - df [c1_r + i] = sf [c1_r + i] + sf [c2_r - i]; - df [c1_i + i] = sf [c2_r + i] - sf [cend - i]; - - DataType c; - DataType s; - FFTRealUseTrigo ::iterate ( - osc_list [TRIGO_OSC], - c, - s, - cos_ptr, - i * table_step, - (dist - i) * table_step - ); - - const DataType vr = sf [c1_r + i] - sf [c2_r - i]; - const DataType vi = sf [c2_r + i] + sf [cend - i]; - - df [c2_r + i] = vr * c + vi * s; - df [c2_i + i] = vi * c - vr * s; - } - - coef_index += cend; - } - while (coef_index < len); -} - -template <> -void FFTRealPassInverse <2>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // Antepenultimate pass - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); - - long coef_index = 0; - do - { - dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; - dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; - dest_ptr [coef_index + 2] = src_ptr [coef_index + 2] * 2; - dest_ptr [coef_index + 6] = src_ptr [coef_index + 6] * 2; - - dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + src_ptr [coef_index + 3]; - dest_ptr [coef_index + 3] = src_ptr [coef_index + 5] - src_ptr [coef_index + 7]; - - const DataType vr = src_ptr [coef_index + 1] - src_ptr [coef_index + 3]; - const DataType vi = src_ptr [coef_index + 5] + src_ptr [coef_index + 7]; - - dest_ptr [coef_index + 5] = (vr + vi) * sqrt2_2; - dest_ptr [coef_index + 7] = (vi - vr) * sqrt2_2; - - coef_index += 8; - } - while (coef_index < len); -} - -template <> -void FFTRealPassInverse <1>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // Penultimate and last pass at once - const long qlen = len >> 2; - - long coef_index = 0; - do - { - const long ri_0 = br_ptr [coef_index >> 2]; - - const DataType b_0 = src_ptr [coef_index ] + src_ptr [coef_index + 2]; - const DataType b_2 = src_ptr [coef_index ] - src_ptr [coef_index + 2]; - const DataType b_1 = src_ptr [coef_index + 1] * 2; - const DataType b_3 = src_ptr [coef_index + 3] * 2; - - dest_ptr [ri_0 ] = b_0 + b_1; - dest_ptr [ri_0 + 2 * qlen] = b_0 - b_1; - dest_ptr [ri_0 + 1 * qlen] = b_2 + b_3; - dest_ptr [ri_0 + 3 * qlen] = b_2 - b_3; - - coef_index += 4; - } - while (coef_index < len); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // FFTRealPassInverse_CODEHEADER_INCLUDED - -#undef FFTRealPassInverse_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealSelect.h b/demos/spectrum/fftreal/FFTRealSelect.h deleted file mode 100644 index bd722d4..0000000 --- a/demos/spectrum/fftreal/FFTRealSelect.h +++ /dev/null @@ -1,77 +0,0 @@ -/***************************************************************************** - - FFTRealSelect.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealSelect_HEADER_INCLUDED) -#define FFTRealSelect_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" - - - -template -class FFTRealSelect -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - FORCEINLINE static float * - sel_bin (float *e_ptr, float *o_ptr); - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTRealSelect (); - ~FFTRealSelect (); - FFTRealSelect (const FFTRealSelect &other); - FFTRealSelect& operator = (const FFTRealSelect &other); - bool operator == (const FFTRealSelect &other); - bool operator != (const FFTRealSelect &other); - -}; // class FFTRealSelect - - - -#include "FFTRealSelect.hpp" - - - -#endif // FFTRealSelect_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealSelect.hpp b/demos/spectrum/fftreal/FFTRealSelect.hpp deleted file mode 100644 index 9ddf586..0000000 --- a/demos/spectrum/fftreal/FFTRealSelect.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/***************************************************************************** - - FFTRealSelect.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTRealSelect_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealSelect code header. -#endif -#define FFTRealSelect_CURRENT_CODEHEADER - -#if ! defined (FFTRealSelect_CODEHEADER_INCLUDED) -#define FFTRealSelect_CODEHEADER_INCLUDED - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -float * FFTRealSelect

    ::sel_bin (float *e_ptr, float *o_ptr) -{ - return (o_ptr); -} - - - -template <> -float * FFTRealSelect <0>::sel_bin (float *e_ptr, float *o_ptr) -{ - return (e_ptr); -} - - - -#endif // FFTRealSelect_CODEHEADER_INCLUDED - -#undef FFTRealSelect_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealUseTrigo.h b/demos/spectrum/fftreal/FFTRealUseTrigo.h deleted file mode 100644 index c4368ee..0000000 --- a/demos/spectrum/fftreal/FFTRealUseTrigo.h +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************** - - FFTRealUseTrigo.h - Copyright (c) 2005 Laurent de Soras - -Template parameters: - - ALGO: algorithm choice. 0 = table, other = oscillator - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealUseTrigo_HEADER_INCLUDED) -#define FFTRealUseTrigo_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - - -template -class FFTRealUseTrigo -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; - - FORCEINLINE static void - prepare (OscType &osc); - FORCEINLINE static void - iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTRealUseTrigo (); - ~FFTRealUseTrigo (); - FFTRealUseTrigo (const FFTRealUseTrigo &other); - FFTRealUseTrigo & - operator = (const FFTRealUseTrigo &other); - bool operator == (const FFTRealUseTrigo &other); - bool operator != (const FFTRealUseTrigo &other); - -}; // class FFTRealUseTrigo - - - -#include "FFTRealUseTrigo.hpp" - - - -#endif // FFTRealUseTrigo_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/FFTRealUseTrigo.hpp b/demos/spectrum/fftreal/FFTRealUseTrigo.hpp deleted file mode 100644 index aa968b8..0000000 --- a/demos/spectrum/fftreal/FFTRealUseTrigo.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/***************************************************************************** - - FFTRealUseTrigo.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTRealUseTrigo_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealUseTrigo code header. -#endif -#define FFTRealUseTrigo_CURRENT_CODEHEADER - -#if ! defined (FFTRealUseTrigo_CODEHEADER_INCLUDED) -#define FFTRealUseTrigo_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "OscSinCos.h" - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void FFTRealUseTrigo ::prepare (OscType &osc) -{ - osc.clear_buffers (); -} - -template <> -void FFTRealUseTrigo <0>::prepare (OscType &osc) -{ - // Nothing -} - - - -template -void FFTRealUseTrigo ::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) -{ - osc.step (); - c = osc.get_cos (); - s = osc.get_sin (); -} - -template <> -void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) -{ - c = cos_ptr [index_c]; - s = cos_ptr [index_s]; -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // FFTRealUseTrigo_CODEHEADER_INCLUDED - -#undef FFTRealUseTrigo_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/OscSinCos.h b/demos/spectrum/fftreal/OscSinCos.h deleted file mode 100644 index 775fc14..0000000 --- a/demos/spectrum/fftreal/OscSinCos.h +++ /dev/null @@ -1,106 +0,0 @@ -/***************************************************************************** - - OscSinCos.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (OscSinCos_HEADER_INCLUDED) -#define OscSinCos_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" - - - -template -class OscSinCos -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef T DataType; - - OscSinCos (); - - FORCEINLINE void - set_step (double angle_rad); - - FORCEINLINE DataType - get_cos () const; - FORCEINLINE DataType - get_sin () const; - FORCEINLINE void - step (); - FORCEINLINE void - clear_buffers (); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1] - DataType _pos_sin; // - - DataType _step_cos; // Phase increment per step, [-1 ; 1] - DataType _step_sin; // - - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - OscSinCos (const OscSinCos &other); - OscSinCos & operator = (const OscSinCos &other); - bool operator == (const OscSinCos &other); - bool operator != (const OscSinCos &other); - -}; // class OscSinCos - - - -#include "OscSinCos.hpp" - - - -#endif // OscSinCos_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/OscSinCos.hpp b/demos/spectrum/fftreal/OscSinCos.hpp deleted file mode 100644 index 749aef0..0000000 --- a/demos/spectrum/fftreal/OscSinCos.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/***************************************************************************** - - OscSinCos.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (OscSinCos_CURRENT_CODEHEADER) - #error Recursive inclusion of OscSinCos code header. -#endif -#define OscSinCos_CURRENT_CODEHEADER - -#if ! defined (OscSinCos_CODEHEADER_INCLUDED) -#define OscSinCos_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include - -namespace std { } - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -OscSinCos ::OscSinCos () -: _pos_cos (1) -, _pos_sin (0) -, _step_cos (1) -, _step_sin (0) -{ - // Nothing -} - - - -template -void OscSinCos ::set_step (double angle_rad) -{ - using namespace std; - - _step_cos = static_cast (cos (angle_rad)); - _step_sin = static_cast (sin (angle_rad)); -} - - - -template -typename OscSinCos ::DataType OscSinCos ::get_cos () const -{ - return (_pos_cos); -} - - - -template -typename OscSinCos ::DataType OscSinCos ::get_sin () const -{ - return (_pos_sin); -} - - - -template -void OscSinCos ::step () -{ - const DataType old_cos = _pos_cos; - const DataType old_sin = _pos_sin; - - _pos_cos = old_cos * _step_cos - old_sin * _step_sin; - _pos_sin = old_cos * _step_sin + old_sin * _step_cos; -} - - - -template -void OscSinCos ::clear_buffers () -{ - _pos_cos = static_cast (1); - _pos_sin = static_cast (0); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // OscSinCos_CODEHEADER_INCLUDED - -#undef OscSinCos_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestAccuracy.h b/demos/spectrum/fftreal/TestAccuracy.h deleted file mode 100644 index 4b07a6b..0000000 --- a/demos/spectrum/fftreal/TestAccuracy.h +++ /dev/null @@ -1,105 +0,0 @@ -/***************************************************************************** - - TestAccuracy.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (TestAccuracy_HEADER_INCLUDED) -#define TestAccuracy_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -class TestAccuracy -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef typename FO::DataType DataType; - typedef long double BigFloat; // To get maximum accuracy during intermediate calculations - - static int perform_test_single_object (FO &fft); - static int perform_test_d (FO &fft, const char *class_name_0); - static int perform_test_i (FO &fft, const char *class_name_0); - static int perform_test_di (FO &fft, const char *class_name_0); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - enum { NBR_ACC_TESTS = 10 * 1000 * 1000 }; - enum { MAX_NBR_TESTS = 10000 }; - - static void compute_tf (DataType s [], const DataType x [], long length); - static void compute_itf (DataType x [], const DataType s [], long length); - static int compare_vect_display (const DataType x_ptr [], const DataType y_ptr [], long len, BigFloat &max_err_rel); - static BigFloat - compute_power (const DataType x_ptr [], long len); - static BigFloat - compute_power (const DataType x_ptr [], const DataType y_ptr [], long len); - static void compare_vect (const DataType x_ptr [], const DataType y_ptr [], BigFloat &power, long &max_err_pos, long len); - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - TestAccuracy (); - ~TestAccuracy (); - TestAccuracy (const TestAccuracy &other); - TestAccuracy & operator = (const TestAccuracy &other); - bool operator == (const TestAccuracy &other); - bool operator != (const TestAccuracy &other); - -}; // class TestAccuracy - - - -#include "TestAccuracy.hpp" - - - -#endif // TestAccuracy_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestAccuracy.hpp b/demos/spectrum/fftreal/TestAccuracy.hpp deleted file mode 100644 index 5c794f7..0000000 --- a/demos/spectrum/fftreal/TestAccuracy.hpp +++ /dev/null @@ -1,472 +0,0 @@ -/***************************************************************************** - - TestAccuracy.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (TestAccuracy_CURRENT_CODEHEADER) - #error Recursive inclusion of TestAccuracy code header. -#endif -#define TestAccuracy_CURRENT_CODEHEADER - -#if ! defined (TestAccuracy_CODEHEADER_INCLUDED) -#define TestAccuracy_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "test_fnc.h" -#include "TestWhiteNoiseGen.h" - -#include -#include - -#include -#include - - - -static const double TestAccuracy_LN10 = 2.3025850929940456840179914546844; - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -int TestAccuracy ::perform_test_single_object (FO &fft) -{ - assert (&fft != 0); - - using namespace std; - - int ret_val = 0; - - const std::type_info & ti = typeid (fft); - const char * class_name_0 = ti.name (); - - if (ret_val == 0) - { - ret_val = perform_test_d (fft, class_name_0); - } - if (ret_val == 0) - { - ret_val = perform_test_i (fft, class_name_0); - } - if (ret_val == 0) - { - ret_val = perform_test_di (fft, class_name_0); - } - - if (ret_val == 0) - { - printf ("\n"); - } - - return (ret_val); -} - - - -template -int TestAccuracy ::perform_test_d (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - using namespace std; - - int ret_val = 0; - const long len = fft.get_length (); - const long nbr_tests = limit ( - NBR_ACC_TESTS / len / len, - 1L, - static_cast (MAX_NBR_TESTS) - ); - - printf ("Testing %s::do_fft () [%ld samples]... ", class_name_0, len); - fflush (stdout); - TestWhiteNoiseGen noise; - std::vector x (len); - std::vector s1 (len); - std::vector s2 (len); - BigFloat err_avg = 0; - - for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) - { - noise.generate (&x [0], len); - fft.do_fft (&s1 [0], &x [0]); - compute_tf (&s2 [0], &x [0], len); - - BigFloat max_err; - compare_vect_display (&s1 [0], &s2 [0], len, max_err); - err_avg += max_err; - } - err_avg /= NBR_ACC_TESTS; - - printf ("done.\n"); - printf ( - "Average maximum error: %.6f %% (%f dB)\n", - static_cast (err_avg * 100), - static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) - ); - - return (ret_val); -} - - - -template -int TestAccuracy ::perform_test_i (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - using namespace std; - - int ret_val = 0; - const long len = fft.get_length (); - const long nbr_tests = limit ( - NBR_ACC_TESTS / len / len, - 10L, - static_cast (MAX_NBR_TESTS) - ); - - printf ("Testing %s::do_ifft () [%ld samples]... ", class_name_0, len); - fflush (stdout); - TestWhiteNoiseGen noise; - std::vector s (len); - std::vector x1 (len); - std::vector x2 (len); - BigFloat err_avg = 0; - - for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) - { - noise.generate (&s [0], len); - fft.do_ifft (&s [0], &x1 [0]); - compute_itf (&x2 [0], &s [0], len); - - BigFloat max_err; - compare_vect_display (&x1 [0], &x2 [0], len, max_err); - err_avg += max_err; - } - err_avg /= NBR_ACC_TESTS; - - printf ("done.\n"); - printf ( - "Average maximum error: %.6f %% (%f dB)\n", - static_cast (err_avg * 100), - static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) - ); - - return (ret_val); -} - - - -template -int TestAccuracy ::perform_test_di (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - using namespace std; - - int ret_val = 0; - const long len = fft.get_length (); - const long nbr_tests = limit ( - NBR_ACC_TESTS / len / len, - 1L, - static_cast (MAX_NBR_TESTS) - ); - - printf ( - "Testing %s::do_fft () / do_ifft () / rescale () [%ld samples]... ", - class_name_0, - len - ); - fflush (stdout); - TestWhiteNoiseGen noise; - std::vector x (len); - std::vector s (len); - std::vector y (len); - BigFloat err_avg = 0; - - for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) - { - noise.generate (&x [0], len); - fft.do_fft (&s [0], &x [0]); - fft.do_ifft (&s [0], &y [0]); - fft.rescale (&y [0]); - - BigFloat max_err; - compare_vect_display (&x [0], &y [0], len, max_err); - err_avg += max_err; - } - err_avg /= NBR_ACC_TESTS; - - printf ("done.\n"); - printf ( - "Average maximum error: %.6f %% (%f dB)\n", - static_cast (err_avg * 100), - static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) - ); - - return (ret_val); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -// Positive transform -template -void TestAccuracy ::compute_tf (DataType s [], const DataType x [], long length) -{ - assert (s != 0); - assert (x != 0); - assert (length >= 2); - assert ((length & 1) == 0); - - const long nbr_bins = length >> 1; - - // DC and Nyquist - BigFloat dc = 0; - BigFloat ny = 0; - for (long pos = 0; pos < length; pos += 2) - { - const BigFloat even = x [pos ]; - const BigFloat odd = x [pos + 1]; - dc += even + odd; - ny += even - odd; - } - s [0 ] = static_cast (dc); - s [nbr_bins] = static_cast (ny); - - // Regular bins - for (long bin = 1; bin < nbr_bins; ++ bin) - { - BigFloat sum_r = 0; - BigFloat sum_i = 0; - - const BigFloat m = bin * static_cast (2 * PI) / length; - - for (long pos = 0; pos < length; ++pos) - { - using namespace std; - - const BigFloat phase = pos * m; - const BigFloat e_r = cos (phase); - const BigFloat e_i = sin (phase); - - sum_r += x [pos] * e_r; - sum_i += x [pos] * e_i; - } - - s [ bin] = static_cast (sum_r); - s [nbr_bins + bin] = static_cast (sum_i); - } -} - - - -// Negative transform -template -void TestAccuracy ::compute_itf (DataType x [], const DataType s [], long length) -{ - assert (s != 0); - assert (x != 0); - assert (length >= 2); - assert ((length & 1) == 0); - - const long nbr_bins = length >> 1; - - // DC and Nyquist - BigFloat dc = s [0 ]; - BigFloat ny = s [nbr_bins]; - - // Regular bins - for (long pos = 0; pos < length; ++pos) - { - BigFloat sum = dc + ny * (1 - 2 * (pos & 1)); - - const BigFloat m = pos * static_cast (-2 * PI) / length; - - for (long bin = 1; bin < nbr_bins; ++ bin) - { - using namespace std; - - const BigFloat phase = bin * m; - const BigFloat e_r = cos (phase); - const BigFloat e_i = sin (phase); - - sum += 2 * ( e_r * s [bin ] - - e_i * s [bin + nbr_bins]); - } - - x [pos] = static_cast (sum); - } -} - - - -template -int TestAccuracy ::compare_vect_display (const DataType x_ptr [], const DataType y_ptr [], long len, BigFloat &max_err_rel) -{ - assert (x_ptr != 0); - assert (y_ptr != 0); - assert (len > 0); - assert (&max_err_rel != 0); - - using namespace std; - - int ret_val = 0; - - BigFloat power = compute_power (&x_ptr [0], &y_ptr [0], len); - BigFloat power_dif; - long max_err_pos; - compare_vect (&x_ptr [0], &y_ptr [0], power_dif, max_err_pos, len); - - if (power == 0) - { - power = power_dif; - } - const BigFloat power_err_rel = power_dif / power; - - BigFloat max_err = 0; - max_err_rel = 0; - if (max_err_pos >= 0) - { - max_err = y_ptr [max_err_pos] - x_ptr [max_err_pos]; - max_err_rel = 2 * fabs (max_err) / ( fabs (y_ptr [max_err_pos]) - + fabs (x_ptr [max_err_pos])); - } - - if (power_err_rel > 0.001) - { - printf ("Power error : %f (%.6f %%)\n", - static_cast (power_err_rel), - static_cast (power_err_rel * 100) - ); - if (max_err_pos >= 0) - { - printf ( - "Maximum error: %f - %f = %f (%f)\n", - static_cast (y_ptr [max_err_pos]), - static_cast (x_ptr [max_err_pos]), - static_cast (max_err), - static_cast (max_err_pos) - ); - } - } - - return (ret_val); -} - - - -template -typename TestAccuracy ::BigFloat TestAccuracy ::compute_power (const DataType x_ptr [], long len) -{ - assert (x_ptr != 0); - assert (len > 0); - - BigFloat power = 0; - for (long pos = 0; pos < len; ++pos) - { - const BigFloat val = x_ptr [pos]; - - power += val * val; - } - - using namespace std; - - power = sqrt (power) / len; - - return (power); -} - - - -template -typename TestAccuracy ::BigFloat TestAccuracy ::compute_power (const DataType x_ptr [], const DataType y_ptr [], long len) -{ - assert (x_ptr != 0); - assert (y_ptr != 0); - assert (len > 0); - - return ((compute_power (x_ptr, len) + compute_power (y_ptr, len)) * 0.5); -} - - - -template -void TestAccuracy ::compare_vect (const DataType x_ptr [], const DataType y_ptr [], BigFloat &power, long &max_err_pos, long len) -{ - assert (x_ptr != 0); - assert (y_ptr != 0); - assert (len > 0); - assert (&power != 0); - assert (&max_err_pos != 0); - - power = 0; - BigFloat max_dif2 = 0; - max_err_pos = -1; - - for (long pos = 0; pos < len; ++pos) - { - const BigFloat x = x_ptr [pos]; - const BigFloat y = y_ptr [pos]; - const BigFloat dif = y - x; - const BigFloat dif2 = dif * dif; - - power += dif2; - if (dif2 > max_dif2) - { - max_err_pos = pos; - max_dif2 = dif2; - } - } - - using namespace std; - - power = sqrt (power) / len; -} - - - -#endif // TestAccuracy_CODEHEADER_INCLUDED - -#undef TestAccuracy_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestHelperFixLen.h b/demos/spectrum/fftreal/TestHelperFixLen.h deleted file mode 100644 index ecff96d..0000000 --- a/demos/spectrum/fftreal/TestHelperFixLen.h +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************** - - TestHelperFixLen.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (TestHelperFixLen_HEADER_INCLUDED) -#define TestHelperFixLen_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "FFTRealFixLen.h" - - - -template -class TestHelperFixLen -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef FFTRealFixLen FftType; - - static void perform_test_accuracy (int &ret_val); - static void perform_test_speed (int &ret_val); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - TestHelperFixLen (); - ~TestHelperFixLen (); - TestHelperFixLen (const TestHelperFixLen &other); - TestHelperFixLen & - operator = (const TestHelperFixLen &other); - bool operator == (const TestHelperFixLen &other); - bool operator != (const TestHelperFixLen &other); - -}; // class TestHelperFixLen - - - -#include "TestHelperFixLen.hpp" - - - -#endif // TestHelperFixLen_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestHelperFixLen.hpp b/demos/spectrum/fftreal/TestHelperFixLen.hpp deleted file mode 100644 index 25048b9..0000000 --- a/demos/spectrum/fftreal/TestHelperFixLen.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************** - - TestHelperFixLen.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (TestHelperFixLen_CURRENT_CODEHEADER) - #error Recursive inclusion of TestHelperFixLen code header. -#endif -#define TestHelperFixLen_CURRENT_CODEHEADER - -#if ! defined (TestHelperFixLen_CODEHEADER_INCLUDED) -#define TestHelperFixLen_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "test_settings.h" - -#include "TestAccuracy.h" -#if defined (test_settings_SPEED_TEST_ENABLED) - #include "TestSpeed.h" -#endif - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void TestHelperFixLen ::perform_test_accuracy (int &ret_val) -{ - if (ret_val == 0) - { - FftType fft; - ret_val = TestAccuracy ::perform_test_single_object (fft); - } -} - - - -template -void TestHelperFixLen ::perform_test_speed (int &ret_val) -{ -#if defined (test_settings_SPEED_TEST_ENABLED) - - if (ret_val == 0) - { - FftType fft; - ret_val = TestSpeed ::perform_test_single_object (fft); - } - -#endif -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // TestHelperFixLen_CODEHEADER_INCLUDED - -#undef TestHelperFixLen_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestHelperNormal.h b/demos/spectrum/fftreal/TestHelperNormal.h deleted file mode 100644 index a7bff5c..0000000 --- a/demos/spectrum/fftreal/TestHelperNormal.h +++ /dev/null @@ -1,94 +0,0 @@ -/***************************************************************************** - - TestHelperNormal.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (TestHelperNormal_HEADER_INCLUDED) -#define TestHelperNormal_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "FFTReal.h" - - - -template -class TestHelperNormal -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef DT DataType; - typedef FFTReal FftType; - - static void perform_test_accuracy (int &ret_val); - static void perform_test_speed (int &ret_val); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - TestHelperNormal (); - ~TestHelperNormal (); - TestHelperNormal (const TestHelperNormal &other); - TestHelperNormal & - operator = (const TestHelperNormal &other); - bool operator == (const TestHelperNormal &other); - bool operator != (const TestHelperNormal &other); - -}; // class TestHelperNormal - - - -#include "TestHelperNormal.hpp" - - - -#endif // TestHelperNormal_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestHelperNormal.hpp b/demos/spectrum/fftreal/TestHelperNormal.hpp deleted file mode 100644 index e037696..0000000 --- a/demos/spectrum/fftreal/TestHelperNormal.hpp +++ /dev/null @@ -1,99 +0,0 @@ -/***************************************************************************** - - TestHelperNormal.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (TestHelperNormal_CURRENT_CODEHEADER) - #error Recursive inclusion of TestHelperNormal code header. -#endif -#define TestHelperNormal_CURRENT_CODEHEADER - -#if ! defined (TestHelperNormal_CODEHEADER_INCLUDED) -#define TestHelperNormal_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "test_settings.h" - -#include "TestAccuracy.h" -#if defined (test_settings_SPEED_TEST_ENABLED) - #include "TestSpeed.h" -#endif - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void TestHelperNormal

    ::perform_test_accuracy (int &ret_val) -{ - const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12 }; - const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); - for (int k = 0; k < nbr_len && ret_val == 0; ++k) - { - const long len = 1L << (len_arr [k]); - FftType fft (len); - ret_val = TestAccuracy ::perform_test_single_object (fft); - } -} - - - -template -void TestHelperNormal
    ::perform_test_speed (int &ret_val) -{ -#if defined (test_settings_SPEED_TEST_ENABLED) - - const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12, 14, 16, 18, 20, 22 }; - const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); - for (int k = 0; k < nbr_len && ret_val == 0; ++k) - { - const long len = 1L << (len_arr [k]); - FftType fft (len); - ret_val = TestSpeed ::perform_test_single_object (fft); - } - -#endif -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // TestHelperNormal_CODEHEADER_INCLUDED - -#undef TestHelperNormal_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestSpeed.h b/demos/spectrum/fftreal/TestSpeed.h deleted file mode 100644 index 2295781..0000000 --- a/demos/spectrum/fftreal/TestSpeed.h +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************** - - TestSpeed.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (TestSpeed_HEADER_INCLUDED) -#define TestSpeed_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -class TestSpeed -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef typename FO::DataType DataType; - - static int perform_test_single_object (FO &fft); - static int perform_test_d (FO &fft, const char *class_name_0); - static int perform_test_i (FO &fft, const char *class_name_0); - static int perform_test_di (FO &fft, const char *class_name_0); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - enum { NBR_SPD_TESTS = 10 * 1000 * 1000 }; - enum { MAX_NBR_TESTS = 10000 }; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - TestSpeed (); - ~TestSpeed (); - TestSpeed (const TestSpeed &other); - TestSpeed & operator = (const TestSpeed &other); - bool operator == (const TestSpeed &other); - bool operator != (const TestSpeed &other); - -}; // class TestSpeed - - - -#include "TestSpeed.hpp" - - - -#endif // TestSpeed_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestSpeed.hpp b/demos/spectrum/fftreal/TestSpeed.hpp deleted file mode 100644 index e716b2a..0000000 --- a/demos/spectrum/fftreal/TestSpeed.hpp +++ /dev/null @@ -1,223 +0,0 @@ -/***************************************************************************** - - TestSpeed.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (TestSpeed_CURRENT_CODEHEADER) - #error Recursive inclusion of TestSpeed code header. -#endif -#define TestSpeed_CURRENT_CODEHEADER - -#if ! defined (TestSpeed_CODEHEADER_INCLUDED) -#define TestSpeed_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "test_fnc.h" -#include "stopwatch/StopWatch.h" -#include "TestWhiteNoiseGen.h" - -#include - -#include - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -int TestSpeed ::perform_test_single_object (FO &fft) -{ - assert (&fft != 0); - - int ret_val = 0; - - const std::type_info & ti = typeid (fft); - const char * class_name_0 = ti.name (); - - if (ret_val == 0) - { - perform_test_d (fft, class_name_0); - } - if (ret_val == 0) - { - perform_test_i (fft, class_name_0); - } - if (ret_val == 0) - { - perform_test_di (fft, class_name_0); - } - - if (ret_val == 0) - { - printf ("\n"); - } - - return (ret_val); -} - - - -template -int TestSpeed ::perform_test_d (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - const long len = fft.get_length (); - const long nbr_tests = limit ( - static_cast (NBR_SPD_TESTS / len / len), - 1L, - static_cast (MAX_NBR_TESTS) - ); - - TestWhiteNoiseGen noise; - std::vector x (len, 0); - std::vector s (len); - noise.generate (&x [0], len); - - printf ( - "%s::do_fft () speed test [%ld samples]... ", - class_name_0, - len - ); - fflush (stdout); - - stopwatch::StopWatch chrono; - chrono.start (); - for (long test = 0; test < nbr_tests; ++ test) - { - fft.do_fft (&s [0], &x [0]); - chrono.stop_lap (); - } - - printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); - - return (0); -} - - - -template -int TestSpeed ::perform_test_i (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - const long len = fft.get_length (); - const long nbr_tests = limit ( - static_cast (NBR_SPD_TESTS / len / len), - 1L, - static_cast (MAX_NBR_TESTS) - ); - - TestWhiteNoiseGen noise; - std::vector x (len); - std::vector s (len, 0); - noise.generate (&s [0], len); - - printf ( - "%s::do_ifft () speed test [%ld samples]... ", - class_name_0, - len - ); - fflush (stdout); - - stopwatch::StopWatch chrono; - chrono.start (); - for (long test = 0; test < nbr_tests; ++ test) - { - fft.do_ifft (&s [0], &x [0]); - chrono.stop_lap (); - } - - printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); - - return (0); -} - - - -template -int TestSpeed ::perform_test_di (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - const long len = fft.get_length (); - const long nbr_tests = limit ( - static_cast (NBR_SPD_TESTS / len / len), - 1L, - static_cast (MAX_NBR_TESTS) - ); - - TestWhiteNoiseGen noise; - std::vector x (len, 0); - std::vector s (len); - std::vector y (len); - noise.generate (&x [0], len); - - printf ( - "%s::do_fft () / do_ifft () / rescale () speed test [%ld samples]... ", - class_name_0, - len - ); - fflush (stdout); - - stopwatch::StopWatch chrono; - - chrono.start (); - for (long test = 0; test < nbr_tests; ++ test) - { - fft.do_fft (&s [0], &x [0]); - fft.do_ifft (&s [0], &y [0]); - fft.rescale (&y [0]); - chrono.stop_lap (); - } - - printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); - - return (0); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // TestSpeed_CODEHEADER_INCLUDED - -#undef TestSpeed_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestWhiteNoiseGen.h b/demos/spectrum/fftreal/TestWhiteNoiseGen.h deleted file mode 100644 index d815f8e..0000000 --- a/demos/spectrum/fftreal/TestWhiteNoiseGen.h +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************** - - TestWhiteNoiseGen.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (TestWhiteNoiseGen_HEADER_INCLUDED) -#define TestWhiteNoiseGen_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -class TestWhiteNoiseGen -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef DT DataType; - - TestWhiteNoiseGen (); - virtual ~TestWhiteNoiseGen () {} - - void generate (DataType data_ptr [], long len); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - typedef unsigned long StateType; - - StateType _rand_state; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - TestWhiteNoiseGen (const TestWhiteNoiseGen &other); - TestWhiteNoiseGen & - operator = (const TestWhiteNoiseGen &other); - bool operator == (const TestWhiteNoiseGen &other); - bool operator != (const TestWhiteNoiseGen &other); - -}; // class TestWhiteNoiseGen - - - -#include "TestWhiteNoiseGen.hpp" - - - -#endif // TestWhiteNoiseGen_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/TestWhiteNoiseGen.hpp b/demos/spectrum/fftreal/TestWhiteNoiseGen.hpp deleted file mode 100644 index 13b7eb3..0000000 --- a/demos/spectrum/fftreal/TestWhiteNoiseGen.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/***************************************************************************** - - TestWhiteNoiseGen.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (TestWhiteNoiseGen_CURRENT_CODEHEADER) - #error Recursive inclusion of TestWhiteNoiseGen code header. -#endif -#define TestWhiteNoiseGen_CURRENT_CODEHEADER - -#if ! defined (TestWhiteNoiseGen_CODEHEADER_INCLUDED) -#define TestWhiteNoiseGen_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -TestWhiteNoiseGen
    ::TestWhiteNoiseGen () -: _rand_state (0) -{ - _rand_state = reinterpret_cast (this); -} - - - -template -void TestWhiteNoiseGen
    ::generate (DataType data_ptr [], long len) -{ - assert (data_ptr != 0); - assert (len > 0); - - const DataType one = static_cast (1); - const DataType mul = one / static_cast (0x80000000UL); - - long pos = 0; - do - { - const DataType x = static_cast (_rand_state & 0xFFFFFFFFUL); - data_ptr [pos] = x * mul - one; - - _rand_state = _rand_state * 1234567UL + 890123UL; - - ++ pos; - } - while (pos < len); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // TestWhiteNoiseGen_CODEHEADER_INCLUDED - -#undef TestWhiteNoiseGen_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/bwins/fftrealu.def b/demos/spectrum/fftreal/bwins/fftrealu.def deleted file mode 100644 index 7a79397..0000000 --- a/demos/spectrum/fftreal/bwins/fftrealu.def +++ /dev/null @@ -1,5 +0,0 @@ -EXPORTS - ??0FFTRealWrapper@@QAE@XZ @ 1 NONAME ; FFTRealWrapper::FFTRealWrapper(void) - ??1FFTRealWrapper@@QAE@XZ @ 2 NONAME ; FFTRealWrapper::~FFTRealWrapper(void) - ?calculateFFT@FFTRealWrapper@@QAEXQAMQBM@Z @ 3 NONAME ; void FFTRealWrapper::calculateFFT(float * const, float const * const) - diff --git a/demos/spectrum/fftreal/def.h b/demos/spectrum/fftreal/def.h deleted file mode 100644 index 99c545f..0000000 --- a/demos/spectrum/fftreal/def.h +++ /dev/null @@ -1,60 +0,0 @@ -/***************************************************************************** - - def.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (def_HEADER_INCLUDED) -#define def_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - - -const double PI = 3.1415926535897932384626433832795; -const double SQRT2 = 1.41421356237309514547462185873883; - -#if defined (_MSC_VER) - - #define FORCEINLINE __forceinline - -#else - - #define FORCEINLINE inline - -#endif - - - -#endif // def_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/eabi/fftrealu.def b/demos/spectrum/fftreal/eabi/fftrealu.def deleted file mode 100644 index f95a441..0000000 --- a/demos/spectrum/fftreal/eabi/fftrealu.def +++ /dev/null @@ -1,7 +0,0 @@ -EXPORTS - _ZN14FFTRealWrapper12calculateFFTEPfPKf @ 1 NONAME - _ZN14FFTRealWrapperC1Ev @ 2 NONAME - _ZN14FFTRealWrapperC2Ev @ 3 NONAME - _ZN14FFTRealWrapperD1Ev @ 4 NONAME - _ZN14FFTRealWrapperD2Ev @ 5 NONAME - diff --git a/demos/spectrum/fftreal/fftreal.pas b/demos/spectrum/fftreal/fftreal.pas deleted file mode 100644 index ea63754..0000000 --- a/demos/spectrum/fftreal/fftreal.pas +++ /dev/null @@ -1,661 +0,0 @@ -(***************************************************************************** - - DIGITAL SIGNAL PROCESSING TOOLS - Version 1.03, 2001/06/15 - (c) 1999 - Laurent de Soras - - FFTReal.h - Fourier transformation of real number arrays. - Portable ISO C++ - ------------------------------------------------------------------------------- - - LEGAL - - Source code may be freely used for any purpose, including commercial - applications. Programs must display in their "About" dialog-box (or - documentation) a text telling they use these routines by Laurent de Soras. - Modified source code can be distributed, but modifications must be clearly - indicated. - - CONTACT - - Laurent de Soras - 92 avenue Albert 1er - 92500 Rueil-Malmaison - France - - ldesoras@club-internet.fr - ------------------------------------------------------------------------------- - - Translation to ObjectPascal by : - Frederic Vanmol - frederic@axiworld.be - -*****************************************************************************) - - -unit - FFTReal; - -interface - -uses - Windows; - -(* Change this typedef to use a different floating point type in your FFTs - (i.e. float, double or long double). *) -type - pflt_t = ^flt_t; - flt_t = single; - - pflt_array = ^flt_array; - flt_array = array[0..0] of flt_t; - - plongarray = ^longarray; - longarray = array[0..0] of longint; - -const - sizeof_flt : longint = SizeOf(flt_t); - - - -type - // Bit reversed look-up table nested class - TBitReversedLUT = class - private - _ptr : plongint; - public - constructor Create(const nbr_bits: integer); - destructor Destroy; override; - function get_ptr: plongint; - end; - - // Trigonometric look-up table nested class - TTrigoLUT = class - private - _ptr : pflt_t; - public - constructor Create(const nbr_bits: integer); - destructor Destroy; override; - function get_ptr(const level: integer): pflt_t; - end; - - TFFTReal = class - private - _bit_rev_lut : TBitReversedLUT; - _trigo_lut : TTrigoLUT; - _sqrt2_2 : flt_t; - _length : longint; - _nbr_bits : integer; - _buffer_ptr : pflt_t; - public - constructor Create(const length: longint); - destructor Destroy; override; - - procedure do_fft(f: pflt_array; const x: pflt_array); - procedure do_ifft(const f: pflt_array; x: pflt_array); - procedure rescale(x: pflt_array); - end; - - - - - - - -implementation - -uses - Math; - -{ TBitReversedLUT } - -constructor TBitReversedLUT.Create(const nbr_bits: integer); -var - length : longint; - cnt : longint; - br_index : longint; - bit : longint; -begin - inherited Create; - - length := 1 shl nbr_bits; - GetMem(_ptr, length*SizeOf(longint)); - - br_index := 0; - plongarray(_ptr)^[0] := 0; - for cnt := 1 to length-1 do - begin - // ++br_index (bit reversed) - bit := length shr 1; - br_index := br_index xor bit; - while br_index and bit = 0 do - begin - bit := bit shr 1; - br_index := br_index xor bit; - end; - - plongarray(_ptr)^[cnt] := br_index; - end; -end; - -destructor TBitReversedLUT.Destroy; -begin - FreeMem(_ptr); - _ptr := nil; - inherited; -end; - -function TBitReversedLUT.get_ptr: plongint; -begin - Result := _ptr; -end; - -{ TTrigLUT } - -constructor TTrigoLUT.Create(const nbr_bits: integer); -var - total_len : longint; - PI : double; - level : integer; - level_len : longint; - level_ptr : pflt_array; - mul : double; - i : longint; -begin - inherited Create; - - _ptr := nil; - - if (nbr_bits > 3) then - begin - total_len := (1 shl (nbr_bits - 1)) - 4; - GetMem(_ptr, total_len * sizeof_flt); - - PI := ArcTan(1) * 4; - for level := 3 to nbr_bits-1 do - begin - level_len := 1 shl (level - 1); - level_ptr := pointer(get_ptr(level)); - mul := PI / (level_len shl 1); - - for i := 0 to level_len-1 do - level_ptr^[i] := cos(i * mul); - end; - end; -end; - -destructor TTrigoLUT.Destroy; -begin - FreeMem(_ptr); - _ptr := nil; - inherited; -end; - -function TTrigoLUT.get_ptr(const level: integer): pflt_t; -var - tempp : pflt_t; -begin - tempp := _ptr; - inc(tempp, (1 shl (level-1)) - 4); - Result := tempp; -end; - -{ TFFTReal } - -constructor TFFTReal.Create(const length: longint); -begin - inherited Create; - - _length := length; - _nbr_bits := Floor(Ln(length) / Ln(2) + 0.5); - _bit_rev_lut := TBitReversedLUT.Create(Floor(Ln(length) / Ln(2) + 0.5)); - _trigo_lut := TTrigoLUT.Create(Floor(Ln(length) / Ln(2) + 0.05)); - _sqrt2_2 := Sqrt(2) * 0.5; - - _buffer_ptr := nil; - if _nbr_bits > 2 then - GetMem(_buffer_ptr, _length * sizeof_flt); -end; - -destructor TFFTReal.Destroy; -begin - if _buffer_ptr <> nil then - begin - FreeMem(_buffer_ptr); - _buffer_ptr := nil; - end; - - _bit_rev_lut.Free; - _bit_rev_lut := nil; - _trigo_lut.Free; - _trigo_lut := nil; - - inherited; -end; - -(*==========================================================================*/ -/* Name: do_fft */ -/* Description: Compute the FFT of the array. */ -/* Input parameters: */ -/* - x: pointer on the source array (time). */ -/* Output parameters: */ -/* - f: pointer on the destination array (frequencies). */ -/* f [0...length(x)/2] = real values, */ -/* f [length(x)/2+1...length(x)-1] = imaginary values of */ -/* coefficents 1...length(x)/2-1. */ -/*==========================================================================*) -procedure TFFTReal.do_fft(f: pflt_array; const x: pflt_array); -var - sf, df : pflt_array; - pass : integer; - nbr_coef : longint; - h_nbr_coef : longint; - d_nbr_coef : longint; - coef_index : longint; - bit_rev_lut_ptr : plongarray; - rev_index_0 : longint; - rev_index_1 : longint; - rev_index_2 : longint; - rev_index_3 : longint; - df2 : pflt_array; - n1, n2, n3 : integer; - sf_0, sf_2 : flt_t; - sqrt2_2 : flt_t; - v : flt_t; - cos_ptr : pflt_array; - i : longint; - sf1r, sf2r : pflt_array; - dfr, dfi : pflt_array; - sf1i, sf2i : pflt_array; - c, s : flt_t; - temp_ptr : pflt_array; - b_0, b_2 : flt_t; -begin - n1 := 1; - n2 := 2; - n3 := 3; - - (*______________________________________________ - * - * General case - *______________________________________________ - *) - - if _nbr_bits > 2 then - begin - if _nbr_bits and 1 <> 0 then - begin - df := pointer(_buffer_ptr); - sf := f; - end - else - begin - df := f; - sf := pointer(_buffer_ptr); - end; - - // - // Do the transformation in several passes - // - - // First and second pass at once - bit_rev_lut_ptr := pointer(_bit_rev_lut.get_ptr); - coef_index := 0; - - repeat - rev_index_0 := bit_rev_lut_ptr^[coef_index]; - rev_index_1 := bit_rev_lut_ptr^[coef_index + 1]; - rev_index_2 := bit_rev_lut_ptr^[coef_index + 2]; - rev_index_3 := bit_rev_lut_ptr^[coef_index + 3]; - - df2 := pointer(longint(df) + (coef_index*sizeof_flt)); - df2^[n1] := x^[rev_index_0] - x^[rev_index_1]; - df2^[n3] := x^[rev_index_2] - x^[rev_index_3]; - - sf_0 := x^[rev_index_0] + x^[rev_index_1]; - sf_2 := x^[rev_index_2] + x^[rev_index_3]; - - df2^[0] := sf_0 + sf_2; - df2^[n2] := sf_0 - sf_2; - - inc(coef_index, 4); - until (coef_index >= _length); - - - // Third pass - coef_index := 0; - sqrt2_2 := _sqrt2_2; - - repeat - sf^[coef_index] := df^[coef_index] + df^[coef_index + 4]; - sf^[coef_index + 4] := df^[coef_index] - df^[coef_index + 4]; - sf^[coef_index + 2] := df^[coef_index + 2]; - sf^[coef_index + 6] := df^[coef_index + 6]; - - v := (df [coef_index + 5] - df^[coef_index + 7]) * sqrt2_2; - sf^[coef_index + 1] := df^[coef_index + 1] + v; - sf^[coef_index + 3] := df^[coef_index + 1] - v; - - v := (df^[coef_index + 5] + df^[coef_index + 7]) * sqrt2_2; - sf [coef_index + 5] := v + df^[coef_index + 3]; - sf [coef_index + 7] := v - df^[coef_index + 3]; - - inc(coef_index, 8); - until (coef_index >= _length); - - - // Next pass - for pass := 3 to _nbr_bits-1 do - begin - coef_index := 0; - nbr_coef := 1 shl pass; - h_nbr_coef := nbr_coef shr 1; - d_nbr_coef := nbr_coef shl 1; - - cos_ptr := pointer(_trigo_lut.get_ptr(pass)); - repeat - sf1r := pointer(longint(sf) + (coef_index * sizeof_flt)); - sf2r := pointer(longint(sf1r) + (nbr_coef * sizeof_flt)); - dfr := pointer(longint(df) + (coef_index * sizeof_flt)); - dfi := pointer(longint(dfr) + (nbr_coef * sizeof_flt)); - - // Extreme coefficients are always real - dfr^[0] := sf1r^[0] + sf2r^[0]; - dfi^[0] := sf1r^[0] - sf2r^[0]; // dfr [nbr_coef] = - dfr^[h_nbr_coef] := sf1r^[h_nbr_coef]; - dfi^[h_nbr_coef] := sf2r^[h_nbr_coef]; - - // Others are conjugate complex numbers - sf1i := pointer(longint(sf1r) + (h_nbr_coef * sizeof_flt)); - sf2i := pointer(longint(sf1i) + (nbr_coef * sizeof_flt)); - - for i := 1 to h_nbr_coef-1 do - begin - c := cos_ptr^[i]; // cos (i*PI/nbr_coef); - s := cos_ptr^[h_nbr_coef - i]; // sin (i*PI/nbr_coef); - - v := sf2r^[i] * c - sf2i^[i] * s; - dfr^[i] := sf1r^[i] + v; - dfi^[-i] := sf1r^[i] - v; // dfr [nbr_coef - i] = - - v := sf2r^[i] * s + sf2i^[i] * c; - dfi^[i] := v + sf1i^[i]; - dfi^[nbr_coef - i] := v - sf1i^[i]; - end; - - inc(coef_index, d_nbr_coef); - until (coef_index >= _length); - - // Prepare to the next pass - temp_ptr := df; - df := sf; - sf := temp_ptr; - end; - end - - (*______________________________________________ - * - * Special cases - *______________________________________________ - *) - - // 4-point FFT - else if _nbr_bits = 2 then - begin - f^[n1] := x^[0] - x^[n2]; - f^[n3] := x^[n1] - x^[n3]; - - b_0 := x^[0] + x^[n2]; - b_2 := x^[n1] + x^[n3]; - - f^[0] := b_0 + b_2; - f^[n2] := b_0 - b_2; - end - - // 2-point FFT - else if _nbr_bits = 1 then - begin - f^[0] := x^[0] + x^[n1]; - f^[n1] := x^[0] - x^[n1]; - end - - // 1-point FFT - else - f^[0] := x^[0]; -end; - - -(*==========================================================================*/ -/* Name: do_ifft */ -/* Description: Compute the inverse FFT of the array. Notice that */ -/* IFFT (FFT (x)) = x * length (x). Data must be */ -/* post-scaled. */ -/* Input parameters: */ -/* - f: pointer on the source array (frequencies). */ -/* f [0...length(x)/2] = real values, */ -/* f [length(x)/2+1...length(x)-1] = imaginary values of */ -/* coefficents 1...length(x)/2-1. */ -/* Output parameters: */ -/* - x: pointer on the destination array (time). */ -/*==========================================================================*) -procedure TFFTReal.do_ifft(const f: pflt_array; x: pflt_array); -var - n1, n2, n3 : integer; - n4, n5, n6, n7 : integer; - sf, df, df_temp : pflt_array; - pass : integer; - nbr_coef : longint; - h_nbr_coef : longint; - d_nbr_coef : longint; - coef_index : longint; - cos_ptr : pflt_array; - i : longint; - sfr, sfi : pflt_array; - df1r, df2r : pflt_array; - df1i, df2i : pflt_array; - c, s, vr, vi : flt_t; - temp_ptr : pflt_array; - sqrt2_2 : flt_t; - bit_rev_lut_ptr : plongarray; - sf2 : pflt_array; - b_0, b_1, b_2, b_3 : flt_t; -begin - n1 := 1; - n2 := 2; - n3 := 3; - n4 := 4; - n5 := 5; - n6 := 6; - n7 := 7; - - (*______________________________________________ - * - * General case - *______________________________________________ - *) - - if _nbr_bits > 2 then - begin - sf := f; - - if _nbr_bits and 1 <> 0 then - begin - df := pointer(_buffer_ptr); - df_temp := x; - end - else - begin - df := x; - df_temp := pointer(_buffer_ptr); - end; - - // Do the transformation in several pass - - // First pass - for pass := _nbr_bits-1 downto 3 do - begin - coef_index := 0; - nbr_coef := 1 shl pass; - h_nbr_coef := nbr_coef shr 1; - d_nbr_coef := nbr_coef shl 1; - - cos_ptr := pointer(_trigo_lut.get_ptr(pass)); - - repeat - sfr := pointer(longint(sf) + (coef_index*sizeof_flt)); - sfi := pointer(longint(sfr) + (nbr_coef*sizeof_flt)); - df1r := pointer(longint(df) + (coef_index*sizeof_flt)); - df2r := pointer(longint(df1r) + (nbr_coef*sizeof_flt)); - - // Extreme coefficients are always real - df1r^[0] := sfr^[0] + sfi^[0]; // + sfr [nbr_coef] - df2r^[0] := sfr^[0] - sfi^[0]; // - sfr [nbr_coef] - df1r^[h_nbr_coef] := sfr^[h_nbr_coef] * 2; - df2r^[h_nbr_coef] := sfi^[h_nbr_coef] * 2; - - // Others are conjugate complex numbers - df1i := pointer(longint(df1r) + (h_nbr_coef*sizeof_flt)); - df2i := pointer(longint(df1i) + (nbr_coef*sizeof_flt)); - - for i := 1 to h_nbr_coef-1 do - begin - df1r^[i] := sfr^[i] + sfi^[-i]; // + sfr [nbr_coef - i] - df1i^[i] := sfi^[i] - sfi^[nbr_coef - i]; - - c := cos_ptr^[i]; // cos (i*PI/nbr_coef); - s := cos_ptr^[h_nbr_coef - i]; // sin (i*PI/nbr_coef); - vr := sfr^[i] - sfi^[-i]; // - sfr [nbr_coef - i] - vi := sfi^[i] + sfi^[nbr_coef - i]; - - df2r^[i] := vr * c + vi * s; - df2i^[i] := vi * c - vr * s; - end; - - inc(coef_index, d_nbr_coef); - until (coef_index >= _length); - - - // Prepare to the next pass - if (pass < _nbr_bits - 1) then - begin - temp_ptr := df; - df := sf; - sf := temp_ptr; - end - else - begin - sf := df; - df := df_temp; - end - end; - - // Antepenultimate pass - sqrt2_2 := _sqrt2_2; - coef_index := 0; - - repeat - df^[coef_index] := sf^[coef_index] + sf^[coef_index + 4]; - df^[coef_index + 4] := sf^[coef_index] - sf^[coef_index + 4]; - df^[coef_index + 2] := sf^[coef_index + 2] * 2; - df^[coef_index + 6] := sf^[coef_index + 6] * 2; - - df^[coef_index + 1] := sf^[coef_index + 1] + sf^[coef_index + 3]; - df^[coef_index + 3] := sf^[coef_index + 5] - sf^[coef_index + 7]; - - vr := sf^[coef_index + 1] - sf^[coef_index + 3]; - vi := sf^[coef_index + 5] + sf^[coef_index + 7]; - - df^[coef_index + 5] := (vr + vi) * sqrt2_2; - df^[coef_index + 7] := (vi - vr) * sqrt2_2; - - inc(coef_index, 8); - until (coef_index >= _length); - - - // Penultimate and last pass at once - coef_index := 0; - bit_rev_lut_ptr := pointer(_bit_rev_lut.get_ptr); - sf2 := df; - - repeat - b_0 := sf2^[0] + sf2^[n2]; - b_2 := sf2^[0] - sf2^[n2]; - b_1 := sf2^[n1] * 2; - b_3 := sf2^[n3] * 2; - - x^[bit_rev_lut_ptr^[0]] := b_0 + b_1; - x^[bit_rev_lut_ptr^[n1]] := b_0 - b_1; - x^[bit_rev_lut_ptr^[n2]] := b_2 + b_3; - x^[bit_rev_lut_ptr^[n3]] := b_2 - b_3; - - b_0 := sf2^[n4] + sf2^[n6]; - b_2 := sf2^[n4] - sf2^[n6]; - b_1 := sf2^[n5] * 2; - b_3 := sf2^[n7] * 2; - - x^[bit_rev_lut_ptr^[n4]] := b_0 + b_1; - x^[bit_rev_lut_ptr^[n5]] := b_0 - b_1; - x^[bit_rev_lut_ptr^[n6]] := b_2 + b_3; - x^[bit_rev_lut_ptr^[n7]] := b_2 - b_3; - - inc(sf2, 8); - inc(coef_index, 8); - inc(bit_rev_lut_ptr, 8); - until (coef_index >= _length); - end - - (*______________________________________________ - * - * Special cases - *______________________________________________ - *) - - // 4-point IFFT - else if _nbr_bits = 2 then - begin - b_0 := f^[0] + f [n2]; - b_2 := f^[0] - f [n2]; - - x^[0] := b_0 + f [n1] * 2; - x^[n2] := b_0 - f [n1] * 2; - x^[n1] := b_2 + f [n3] * 2; - x^[n3] := b_2 - f [n3] * 2; - end - - // 2-point IFFT - else if _nbr_bits = 1 then - begin - x^[0] := f^[0] + f^[n1]; - x^[n1] := f^[0] - f^[n1]; - end - - // 1-point IFFT - else - x^[0] := f^[0]; -end; - -(*==========================================================================*/ -/* Name: rescale */ -/* Description: Scale an array by divide each element by its length. */ -/* This function should be called after FFT + IFFT. */ -/* Input/Output parameters: */ -/* - x: pointer on array to rescale (time or frequency). */ -/*==========================================================================*) -procedure TFFTReal.rescale(x: pflt_array); -var - mul : flt_t; - i : longint; -begin - mul := 1.0 / _length; - i := _length - 1; - - repeat - x^[i] := x^[i] * mul; - dec(i); - until (i < 0); -end; - -end. diff --git a/demos/spectrum/fftreal/fftreal.pro b/demos/spectrum/fftreal/fftreal.pro deleted file mode 100644 index 786a962..0000000 --- a/demos/spectrum/fftreal/fftreal.pro +++ /dev/null @@ -1,41 +0,0 @@ -TEMPLATE = lib -TARGET = fftreal - -# FFTReal -HEADERS += Array.h \ - Array.hpp \ - DynArray.h \ - DynArray.hpp \ - FFTRealFixLen.h \ - FFTRealFixLen.hpp \ - FFTRealFixLenParam.h \ - FFTRealPassDirect.h \ - FFTRealPassDirect.hpp \ - FFTRealPassInverse.h \ - FFTRealPassInverse.hpp \ - FFTRealSelect.h \ - FFTRealSelect.hpp \ - FFTRealUseTrigo.h \ - FFTRealUseTrigo.hpp \ - OscSinCos.h \ - OscSinCos.hpp \ - def.h - -# Wrapper used to export the required instantiation of the FFTRealFixLen template -HEADERS += fftreal_wrapper.h -SOURCES += fftreal_wrapper.cpp - -DEFINES += FFTREAL_LIBRARY - -symbian { - # Provide unique ID for the generated binary, required by Symbian OS - TARGET.UID3 = 0xA000E3FB -} else { - macx { - CONFIG += lib_bundle - } else { - DESTDIR = ../bin - } -} - - diff --git a/demos/spectrum/fftreal/fftreal_wrapper.cpp b/demos/spectrum/fftreal/fftreal_wrapper.cpp deleted file mode 100644 index 50ab36d..0000000 --- a/demos/spectrum/fftreal/fftreal_wrapper.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** This program 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. This -** program 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 General Public License -** for more details. You should have received a copy of the GNU General -** Public License along with this program. If not, see -** . -** -***************************************************************************/ - -#include "fftreal_wrapper.h" - -// FFTReal code generates quite a lot of 'unused parameter' compiler warnings, -// which we suppress here in order to get a clean build output. -#if defined Q_CC_MSVC -# pragma warning(disable:4100) -#elif defined Q_CC_GNU -# pragma GCC diagnostic ignored "-Wunused-parameter" -#elif defined Q_CC_MWERKS -# pragma warning off (10182) -#endif - -#include "FFTRealFixLen.h" - -class FFTRealWrapperPrivate { -public: - FFTRealFixLen m_fft; -}; - - -FFTRealWrapper::FFTRealWrapper() - : m_private(new FFTRealWrapperPrivate) -{ - -} - -FFTRealWrapper::~FFTRealWrapper() -{ - delete m_private; -} - -void FFTRealWrapper::calculateFFT(DataType in[], const DataType out[]) -{ - m_private->m_fft.do_fft(in, out); -} diff --git a/demos/spectrum/fftreal/fftreal_wrapper.h b/demos/spectrum/fftreal/fftreal_wrapper.h deleted file mode 100644 index 48d614e..0000000 --- a/demos/spectrum/fftreal/fftreal_wrapper.h +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** This program 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. This -** program 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 General Public License -** for more details. You should have received a copy of the GNU General -** Public License along with this program. If not, see -** . -** -***************************************************************************/ - -#ifndef FFTREAL_WRAPPER_H -#define FFTREAL_WRAPPER_H - -#include - -#if defined(FFTREAL_LIBRARY) -# define FFTREAL_EXPORT Q_DECL_EXPORT -#else -# define FFTREAL_EXPORT Q_DECL_IMPORT -#endif - -class FFTRealWrapperPrivate; - -// Each pass of the FFT processes 2^X samples, where X is the -// number below. -static const int FFTLengthPowerOfTwo = 12; - -/** - * Wrapper around the FFTRealFixLen template provided by the FFTReal - * library - * - * This class instantiates a single instance of FFTRealFixLen, using - * FFTLengthPowerOfTwo as the template parameter. It then exposes - * FFTRealFixLen::do_fft via the calculateFFT - * function, thereby allowing an application to dynamically link - * against the FFTReal implementation. - * - * See http://ldesoras.free.fr/prod.html - */ -class FFTREAL_EXPORT FFTRealWrapper -{ -public: - FFTRealWrapper(); - ~FFTRealWrapper(); - - typedef float DataType; - void calculateFFT(DataType in[], const DataType out[]); - -private: - FFTRealWrapperPrivate* m_private; -}; - -#endif // FFTREAL_WRAPPER_H - diff --git a/demos/spectrum/fftreal/license.txt b/demos/spectrum/fftreal/license.txt deleted file mode 100644 index 918fe68..0000000 --- a/demos/spectrum/fftreal/license.txt +++ /dev/null @@ -1,459 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - diff --git a/demos/spectrum/fftreal/readme.txt b/demos/spectrum/fftreal/readme.txt deleted file mode 100644 index 0c5ce16..0000000 --- a/demos/spectrum/fftreal/readme.txt +++ /dev/null @@ -1,242 +0,0 @@ -============================================================================== - - FFTReal - Version 2.00, 2005/10/18 - - Fourier transformation (FFT, IFFT) library specialised for real data - Portable ISO C++ - - (c) Laurent de Soras - Object Pascal port (c) Frederic Vanmol - -============================================================================== - - - -1. Legal --------- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Check the file license.txt to get full information about the license. - - - -2. Content ----------- - -FFTReal is a library to compute Discrete Fourier Transforms (DFT) with the -FFT algorithm (Fast Fourier Transform) on arrays of real numbers. It can -also compute the inverse transform. - -You should find in this package a lot of files ; some of them are of interest: -- readme.txt: you are reading it -- FFTReal.h: FFT, length fixed at run-time -- FFTRealFixLen.h: FFT, length fixed at compile-time -- FFTReal.pas: Pascal implementation (working but not up-to-date) -- stopwatch directory - - - -3. Using FFTReal ----------------- - -Important - if you were using older versions of FFTReal (up to 1.03), some -things have changed. FFTReal is now a template. Therefore use FFTReal -or FFTReal in your code depending on the application datatype. The -flt_t typedef has been removed. - -You have two ways to use FFTReal. In the first way, the FFT has its length -fixed at run-time, when the object is instanciated. It means that you have -not to know the length when you write the code. This is the usual way of -proceeding. - - -3.1 FFTReal - Length fixed at run-time --------------------------------------- - -Just instanciate one time a FFTReal object. Specify the data type you want -as template parameter (only floating point: float, double, long double or -custom type). The constructor precompute a lot of things, so it may be a bit -long. The parameter is the number of points used for the next FFTs. It must -be a power of 2: - - #include "FFTReal.h" - ... - long len = 1024; - ... - FFTReal fft_object (len); // 1024-point FFT object constructed. - -Then you can use this object to compute as many FFTs and IFFTs as you want. -They will be computed very quickly because a lot of work has been done in the -object construction. - - float x [1024]; - float f [1024]; - - ... - fft_object.do_fft (f, x); // x (real) --FFT---> f (complex) - ... - fft_object.do_ifft (f, x); // f (complex) --IFFT--> x (real) - fft_object.rescale (x); // Post-scaling should be done after FFT+IFFT - ... - -x [] and f [] are floating point number arrays. x [] is the real number -sequence which we want to compute the FFT. f [] is the result, in the -"frequency" domain. f has the same number of elements as x [], but f [] -elements are complex numbers. The routine uses some FFT properties to -optimize memory and to reduce calculations: the transformaton of a real -number sequence is a conjugate complex number sequence: F [k] = F [-k]*. - - -3.2 FFTRealFixLen - Length fixed at compile-time ------------------------------------------------- - -This class is significantly faster than the previous one, giving a speed -gain between 50 and 100 %. The template parameter is the base-2 logarithm of -the FFT length. The datatype is float; it can be changed by modifying the -DataType typedef in FFTRealFixLenParam.h. As FFTReal class, it supports -only floating-point types or equivalent. - -To instanciate the object, just proceed as below: - - #include "FFTRealFixLen.h" - ... - FFTRealFixLen <10> fft_object; // 1024-point (2^10) FFT object constructed. - -Use is similar as the one of FFTReal. - - -3.3 Data organisation ---------------------- - -Mathematically speaking, the formulas below show what does FFTReal: - -do_fft() : f(k) = sum (p = 0, N-1, x(p) * exp (+j*2*pi*k*p/N)) -do_ifft(): x(k) = sum (p = 0, N-1, f(p) * exp (-j*2*pi*k*p/N)) - -Where j is the square root of -1. The formulas differ only by the sign of -the exponential. When the sign is positive, the transform is called positive. -Common formulas for Fourier transform are negative for the direct tranform and -positive for the inverse one. - -However in these formulas, f is an array of complex numbers and doesn't -correspound exactly to the f[] array taken as function parameter. The -following table shows how the f[] sequence is mapped onto the usable FFT -coefficients (called bins): - - FFTReal output | Positive FFT equiv. | Negative FFT equiv. - ---------------+-----------------------+----------------------- - f [0] | Real (bin 0) | Real (bin 0) - f [...] | Real (bin ...) | Real (bin ...) - f [length/2] | Real (bin length/2) | Real (bin length/2) - f [length/2+1] | Imag (bin 1) | -Imag (bin 1) - f [...] | Imag (bin ...) | -Imag (bin ...) - f [length-1] | Imag (bin length/2-1) | -Imag (bin length/2-1) - -And FFT bins are distributed in f [] as above: - - | | Positive FFT | Negative FFT - Bin | Real part | imaginary part | imaginary part - ------------+----------------+-----------------+--------------- - 0 | f [0] | 0 | 0 - 1 | f [1] | f [length/2+1] | -f [length/2+1] - ... | f [...], | f [...] | -f [...] - length/2-1 | f [length/2-1] | f [length-1] | -f [length-1] - length/2 | f [length/2] | 0 | 0 - length/2+1 | f [length/2-1] | -f [length-1] | f [length-1] - ... | f [...] | -f [...] | f [...] - length-1 | f [1] | -f [length/2+1] | f [length/2+1] - -f [] coefficients have the same layout for FFT and IFFT functions. You may -notice that scaling must be done if you want to retrieve x after FFT and IFFT. -Actually, IFFT (FFT (x)) = x * length(x). This is a not a problem because -most of the applications don't care about absolute values. Thus, the operation -requires less calculation. If you want to use the FFT and IFFT to transform a -signal, you have to apply post- (or pre-) processing yourself. Multiplying -or dividing floating point numbers by a power of 2 doesn't generate extra -computation noise. - - - -4. Compilation and testing --------------------------- - -Drop the following files into your project or makefile: - -Array.* -def.h -DynArray.* -FFTReal*.cpp -FFTReal*.h* -OscSinCos.* - -Other files are for testing purpose only, do not include them if you just need -to use the library ; they are not needed to use FFTReal in your own programs. - -FFTReal may be compiled in two versions: release and debug. Debug version -has checks that could slow down the code. Define NDEBUG to set the Release -mode. For example, the command line to compile the test bench on GCC would -look like: - -Debug mode: -g++ -Wall -o fftreal_debug.exe *.cpp stopwatch/*.cpp - -Release mode: -g++ -Wall -o fftreal_release.exe -DNDEBUG -O3 *.cpp stopwatch/*.cpp - -It may be tricky to compile the test bench because the speed tests use the -stopwatch sub-library, which is not that cross-platform. If you encounter -any problem that you cannot easily fix while compiling it, edit the file -test_settings.h and un-define the speed test macro. Remove the stopwatch -directory from your source file list, too. - -If it's not done by default, you should activate the exception handling -of your compiler to get the class memory-leak-safe. Thus, when a memory -allocation fails (in the constructor), an exception is thrown and the entire -object is safely destructed. It reduces the permanent error checking overhead -in the client code. Also, the test bench requires Run-Time Type Information -(RTTI) to be enabled in order to display the names of the tested classes - -sometimes mangled, depending on the compiler. - -The test bench may take a long time to compile, especially in Release mode, -because a lot of recursive templates are instanciated. - - - -5. History ----------- - -v2.00 (2005.10.18) -- Turned FFTReal class into template (data type as parameter) -- Added FFTRealFixLen -- Trigonometric tables are size-limited in order to preserve cache memory; -over a given size, sin/cos functions are computed on the fly. -- Better test bench for accuracy and speed - -v1.03 (2001.06.15) -- Thanks to Frederic Vanmol for the Pascal port (works with Delphi). -- Documentation improvement - -v1.02 (2001.03.25) -- sqrt() is now precomputed when the object FFTReal is constructed, resulting -in speed impovement for small size FFT. - -v1.01 (2000) -- Small modifications, I don't remember what. - -v1.00 (1999.08.14) -- First version released - diff --git a/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.cpp b/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.cpp deleted file mode 100644 index fe1d424..0000000 --- a/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/***************************************************************************** - - ClockCycleCounter.cpp - Copyright (c) 2003 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (_MSC_VER) - #pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant" - #pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer" - #pragma warning (1 : 4705) // "statement has no effect" - #pragma warning (1 : 4706) // "assignment within conditional expression" - #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" - #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" - #pragma warning (4 : 4355) // "'this' : used in base member initializer list" -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "ClockCycleCounter.h" - -#include - - - -namespace stopwatch -{ - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/* -============================================================================== -Name: ctor -Description: - The first object constructed initialise global data. This first - construction may be a bit slow. -Throws: Nothing -============================================================================== -*/ - -ClockCycleCounter::ClockCycleCounter () -: _start_time (0) -, _state (0) -, _best_score (-1) -{ - if (! _init_flag) - { - // Should be executed in this order - compute_clk_mul (); - compute_measure_time_total (); - compute_measure_time_lap (); - - // Restores object state - _start_time = 0; - _state = 0; - _best_score = -1; - - _init_flag = true; - } -} - - - -/* -============================================================================== -Name: get_time_total -Description: - Gives the time elapsed between the latest stop_lap() and start() calls. -Returns: - The duration, in clock cycles. -Throws: Nothing -============================================================================== -*/ - -Int64 ClockCycleCounter::get_time_total () const -{ - const Int64 duration = _state - _start_time; - assert (duration >= 0); - - const Int64 t = max ( - duration - _measure_time_total, - static_cast (0) - ); - - return (t * _clk_mul); -} - - - -/* -============================================================================== -Name: get_time_best_lap -Description: - Gives the smallest time between two consecutive stop_lap() or between - the stop_lap() and start(). The value is reset by a call to start(). - Call this function only after a stop_lap(). - The time is amputed from the duration of the stop_lap() call itself. -Returns: - The smallest duration, in clock cycles. -Throws: Nothing -============================================================================== -*/ - -Int64 ClockCycleCounter::get_time_best_lap () const -{ - assert (_best_score >= 0); - - const Int64 t1 = max ( - _best_score - _measure_time_lap, - static_cast (0) - ); - const Int64 t = min (t1, get_time_total ()); - - return (t * _clk_mul); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#if defined (__MACOS__) - -static inline double stopwatch_ClockCycleCounter_get_time_s () -{ - const Nanoseconds ns = AbsoluteToNanoseconds (UpTime ()); - - return (ns.hi * 4294967296e-9 + ns.lo * 1e-9); -} - -#endif // __MACOS__ - - - -/* -============================================================================== -Name: compute_clk_mul -Description: - This function, only for PowerPC/MacOS computers, computes the multiplier - required to deduce clock cycles from the internal counter. -Throws: Nothing -============================================================================== -*/ - -void ClockCycleCounter::compute_clk_mul () -{ - assert (! _init_flag); - -#if defined (__MACOS__) - - long clk_speed_mhz = CurrentProcessorSpeed (); - const Int64 clk_speed = - static_cast (clk_speed_mhz) * (1000L*1000L); - - const double start_time_s = stopwatch_ClockCycleCounter_get_time_s (); - start (); - - const double duration = 0.01; // Seconds - while (stopwatch_ClockCycleCounter_get_time_s () - start_time_s < duration) - { - continue; - } - - const double stop_time_s = stopwatch_ClockCycleCounter_get_time_s (); - stop (); - - const double diff_time_s = stop_time_s - start_time_s; - const double nbr_cycles = diff_time_s * static_cast (clk_speed); - - const Int64 diff_time_c = _state - _start_time; - const double clk_mul = nbr_cycles / static_cast (diff_time_c); - - _clk_mul = round_int (clk_mul); - -#endif // __MACOS__ -} - - - -void ClockCycleCounter::compute_measure_time_total () -{ - start (); - spend_time (); - - Int64 best_result = 0x7FFFFFFFL; // Should be enough - long nbr_tests = 100; - for (long cnt = 0; cnt < nbr_tests; ++cnt) - { - start (); - stop_lap (); - const Int64 duration = _state - _start_time; - best_result = min (best_result, duration); - } - - _measure_time_total = best_result; -} - - - -/* -============================================================================== -Name: compute_measure_time_lap -Description: - Computes the duration of one stop_lap() call and store it. It will be used - later to get the real duration of the measured operation (by substracting - the measurement duration). -Throws: Nothing -============================================================================== -*/ - -void ClockCycleCounter::compute_measure_time_lap () -{ - start (); - spend_time (); - - long nbr_tests = 10; - for (long cnt = 0; cnt < nbr_tests; ++cnt) - { - stop_lap (); - stop_lap (); - stop_lap (); - stop_lap (); - } - - _measure_time_lap = _best_score; -} - - - -void ClockCycleCounter::spend_time () -{ - const Int64 nbr_clocks = 500; // Number of clock cycles to spend - - const Int64 start = read_clock_counter (); - Int64 current; - - do - { - current = read_clock_counter (); - } - while ((current - start) * _clk_mul < nbr_clocks); -} - - - -Int64 ClockCycleCounter::_measure_time_total = 0; -Int64 ClockCycleCounter::_measure_time_lap = 0; -int ClockCycleCounter::_clk_mul = 1; -bool ClockCycleCounter::_init_flag = false; - - -} // namespace stopwatch - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.h b/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.h deleted file mode 100644 index ba7a99a..0000000 --- a/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.h +++ /dev/null @@ -1,124 +0,0 @@ -/***************************************************************************** - - ClockCycleCounter.h - Copyright (c) 2003 Laurent de Soras - -Instrumentation class, for accurate time interval measurement. You may have -to modify the implementation to adapt it to your system and/or compiler. - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (stopwatch_ClockCycleCounter_HEADER_INCLUDED) -#define stopwatch_ClockCycleCounter_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "Int64.h" - - - -namespace stopwatch -{ - - - -class ClockCycleCounter -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - ClockCycleCounter (); - - stopwatch_FORCEINLINE void - start (); - stopwatch_FORCEINLINE void - stop_lap (); - Int64 get_time_total () const; - Int64 get_time_best_lap () const; - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - void compute_clk_mul (); - void compute_measure_time_total (); - void compute_measure_time_lap (); - - static void spend_time (); - static stopwatch_FORCEINLINE Int64 - read_clock_counter (); - - Int64 _start_time; - Int64 _state; - Int64 _best_score; - - static Int64 _measure_time_total; - static Int64 _measure_time_lap; - static int _clk_mul; - static bool _init_flag; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - ClockCycleCounter (const ClockCycleCounter &other); - ClockCycleCounter & - operator = (const ClockCycleCounter &other); - bool operator == (const ClockCycleCounter &other); - bool operator != (const ClockCycleCounter &other); - -}; // class ClockCycleCounter - - - -} // namespace stopwatch - - - -#include "ClockCycleCounter.hpp" - - - -#endif // stopwatch_ClockCycleCounter_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.hpp b/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.hpp deleted file mode 100644 index fbd511e..0000000 --- a/demos/spectrum/fftreal/stopwatch/ClockCycleCounter.hpp +++ /dev/null @@ -1,150 +0,0 @@ -/***************************************************************************** - - ClockCycleCounter.hpp - Copyright (c) 2003 Laurent de Soras - -Please complete the definitions according to your compiler/architecture. -It's not a big deal if it's not possible to get the clock count... - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (stopwatch_ClockCycleCounter_CURRENT_CODEHEADER) - #error Recursive inclusion of ClockCycleCounter code header. -#endif -#define stopwatch_ClockCycleCounter_CURRENT_CODEHEADER - -#if ! defined (stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED) -#define stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "fnc.h" - -#include - - - -namespace stopwatch -{ - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/* -============================================================================== -Name: start -Description: - Starts the counter. -Throws: Nothing -============================================================================== -*/ - -void ClockCycleCounter::start () -{ - _best_score = (static_cast (1) << (sizeof (Int64) * CHAR_BIT - 2)); - const Int64 start_clock = read_clock_counter (); - _start_time = start_clock; - _state = start_clock - _best_score; -} - - - -/* -============================================================================== -Name: stop_lap -Description: - Captures the current time and updates the smallest duration between two - consecutive calls to stop_lap() or the latest start(). - start() must have been called at least once before calling this function. -Throws: Nothing -============================================================================== -*/ - -void ClockCycleCounter::stop_lap () -{ - const Int64 end_clock = read_clock_counter (); - _best_score = min (end_clock - _state, _best_score); - _state = end_clock; -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -Int64 ClockCycleCounter::read_clock_counter () -{ - register Int64 clock_cnt; - -#if defined (_MSC_VER) - - __asm - { - lea edi, clock_cnt - rdtsc - mov [edi ], eax - mov [edi + 4], edx - } - -#elif defined (__GNUC__) && defined (__i386__) - - __asm__ __volatile__ ("rdtsc" : "=A" (clock_cnt)); - -#elif (__MWERKS__) && defined (__POWERPC__) - - asm - { - loop: - mftbu clock_cnt@hiword - mftb clock_cnt@loword - mftbu r5 - cmpw clock_cnt@hiword,r5 - bne loop - } - -#endif - - return (clock_cnt); -} - - - -} // namespace stopwatch - - - -#endif // stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED - -#undef stopwatch_ClockCycleCounter_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/Int64.h b/demos/spectrum/fftreal/stopwatch/Int64.h deleted file mode 100644 index 1e786e2..0000000 --- a/demos/spectrum/fftreal/stopwatch/Int64.h +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************** - - Int64.h - Copyright (c) 2003 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (stopwatch_Int64_HEADER_INCLUDED) -#define stopwatch_Int64_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -namespace stopwatch -{ - - -#if defined (_MSC_VER) - - typedef __int64 Int64; - -#elif defined (__MWERKS__) || defined (__GNUC__) - - typedef long long Int64; - -#elif defined (__BEOS__) - - typedef int64 Int64; - -#else - - #error No 64-bit integer type defined for this compiler ! - -#endif - - -} // namespace stopwatch - - - -#endif // stopwatch_Int64_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/StopWatch.cpp b/demos/spectrum/fftreal/stopwatch/StopWatch.cpp deleted file mode 100644 index 7795d86..0000000 --- a/demos/spectrum/fftreal/stopwatch/StopWatch.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************** - - StopWatch.cpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (_MSC_VER) - #pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant" - #pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer" - #pragma warning (1 : 4705) // "statement has no effect" - #pragma warning (1 : 4706) // "assignment within conditional expression" - #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" - #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" - #pragma warning (4 : 4355) // "'this' : used in base member initializer list" -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "StopWatch.h" - -#include - - - -namespace stopwatch -{ - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -StopWatch::StopWatch () -: _ccc () -, _nbr_laps (0) -{ - // Nothing -} - - - -double StopWatch::get_time_total (Int64 nbr_op) const -{ - assert (_nbr_laps > 0); - assert (nbr_op > 0); - - return ( - static_cast (_ccc.get_time_total ()) - / (static_cast (nbr_op) * static_cast (_nbr_laps)) - ); -} - - - -double StopWatch::get_time_best_lap (Int64 nbr_op) const -{ - assert (nbr_op > 0); - - return ( - static_cast (_ccc.get_time_best_lap ()) - / static_cast (nbr_op) - ); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -} // namespace stopwatch - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/StopWatch.h b/demos/spectrum/fftreal/stopwatch/StopWatch.h deleted file mode 100644 index 9cc47e5..0000000 --- a/demos/spectrum/fftreal/stopwatch/StopWatch.h +++ /dev/null @@ -1,110 +0,0 @@ -/***************************************************************************** - - StopWatch.h - Copyright (c) 2005 Laurent de Soras - -Utility class based on ClockCycleCounter to measure the unit time of a -repeated operation. - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (stopwatch_StopWatch_HEADER_INCLUDED) -#define stopwatch_StopWatch_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "ClockCycleCounter.h" - - - -namespace stopwatch -{ - - - -class StopWatch -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - StopWatch (); - - stopwatch_FORCEINLINE void - start (); - stopwatch_FORCEINLINE void - stop_lap (); - - double get_time_total (Int64 nbr_op) const; - double get_time_best_lap (Int64 nbr_op) const; - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - ClockCycleCounter - _ccc; - Int64 _nbr_laps; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - StopWatch (const StopWatch &other); - StopWatch & operator = (const StopWatch &other); - bool operator == (const StopWatch &other); - bool operator != (const StopWatch &other); - -}; // class StopWatch - - - -} // namespace stopwatch - - - -#include "StopWatch.hpp" - - - -#endif // stopwatch_StopWatch_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/StopWatch.hpp b/demos/spectrum/fftreal/stopwatch/StopWatch.hpp deleted file mode 100644 index 74482a7..0000000 --- a/demos/spectrum/fftreal/stopwatch/StopWatch.hpp +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************** - - StopWatch.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (stopwatch_StopWatch_CURRENT_CODEHEADER) - #error Recursive inclusion of StopWatch code header. -#endif -#define stopwatch_StopWatch_CURRENT_CODEHEADER - -#if ! defined (stopwatch_StopWatch_CODEHEADER_INCLUDED) -#define stopwatch_StopWatch_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -namespace stopwatch -{ - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -void StopWatch::start () -{ - _nbr_laps = 0; - _ccc.start (); -} - - - -void StopWatch::stop_lap () -{ - _ccc.stop_lap (); - ++ _nbr_laps; -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -} // namespace stopwatch - - - -#endif // stopwatch_StopWatch_CODEHEADER_INCLUDED - -#undef stopwatch_StopWatch_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/def.h b/demos/spectrum/fftreal/stopwatch/def.h deleted file mode 100644 index 81ee6aa..0000000 --- a/demos/spectrum/fftreal/stopwatch/def.h +++ /dev/null @@ -1,65 +0,0 @@ -/***************************************************************************** - - def.h - Copyright (c) 2003 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (stopwatch_def_HEADER_INCLUDED) -#define stopwatch_def_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -namespace stopwatch -{ - - - -#if defined (_MSC_VER) - - #define stopwatch_FORCEINLINE __forceinline - -#else - - #define stopwatch_FORCEINLINE inline - -#endif - - - -} // namespace stopwatch - - - -#endif // stopwatch_def_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/fnc.h b/demos/spectrum/fftreal/stopwatch/fnc.h deleted file mode 100644 index 0554535..0000000 --- a/demos/spectrum/fftreal/stopwatch/fnc.h +++ /dev/null @@ -1,67 +0,0 @@ -/***************************************************************************** - - fnc.h - Copyright (c) 2003 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (stopwatch_fnc_HEADER_INCLUDED) -#define stopwatch_fnc_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -namespace stopwatch -{ - - - -template -inline T min (T a, T b); - -template -inline T max (T a, T b); - -inline int round_int (double x); - - - -} // namespace rsp - - - -#include "fnc.hpp" - - - -#endif // stopwatch_fnc_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/stopwatch/fnc.hpp b/demos/spectrum/fftreal/stopwatch/fnc.hpp deleted file mode 100644 index 0ab5949..0000000 --- a/demos/spectrum/fftreal/stopwatch/fnc.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/***************************************************************************** - - fnc.hpp - Copyright (c) 2003 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (stopwatch_fnc_CURRENT_CODEHEADER) - #error Recursive inclusion of fnc code header. -#endif -#define stopwatch_fnc_CURRENT_CODEHEADER - -#if ! defined (stopwatch_fnc_CODEHEADER_INCLUDED) -#define stopwatch_fnc_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include -#include - -namespace std {} - - - -namespace stopwatch -{ - - - -template -inline T min (T a, T b) -{ - return ((a < b) ? a : b); -} - - - -template -inline T max (T a, T b) -{ - return ((b < a) ? a : b); -} - - - -int round_int (double x) -{ - using namespace std; - - return (static_cast (floor (x + 0.5))); -} - - - -} // namespace stopwatch - - - -#endif // stopwatch_fnc_CODEHEADER_INCLUDED - -#undef stopwatch_fnc_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/test.cpp b/demos/spectrum/fftreal/test.cpp deleted file mode 100644 index 7b6ed2c..0000000 --- a/demos/spectrum/fftreal/test.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/***************************************************************************** - - test.cpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (_MSC_VER) - #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" - #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "test_settings.h" -#include "TestHelperFixLen.h" -#include "TestHelperNormal.h" - -#if defined (_MSC_VER) -#include -#include -#endif // _MSC_VER - -#include - -#include -#include - - - -#define TEST_ - - -/*\\\ FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -static int TEST_perform_test_accuracy_all (); -static int TEST_perform_test_speed_all (); - -static void TEST_prog_init (); -static void TEST_prog_end (); - - - -int main (int argc, char *argv []) -{ - using namespace std; - - int ret_val = 0; - - TEST_prog_init (); - - try - { - if (ret_val == 0) - { - ret_val = TEST_perform_test_accuracy_all (); - } - - if (ret_val == 0) - { - ret_val = TEST_perform_test_speed_all (); - } - } - - catch (std::exception &e) - { - printf ("\n*** main(): Exception (std::exception) : %s\n", e.what ()); - ret_val = -1; - } - - catch (...) - { - printf ("\n*** main(): Undefined exception\n"); - ret_val = -1; - } - - TEST_prog_end (); - - return (ret_val); -} - - - -int TEST_perform_test_accuracy_all () -{ - int ret_val = 0; - - TestHelperNormal ::perform_test_accuracy (ret_val); - TestHelperNormal ::perform_test_accuracy (ret_val); - - TestHelperFixLen < 1>::perform_test_accuracy (ret_val); - TestHelperFixLen < 2>::perform_test_accuracy (ret_val); - TestHelperFixLen < 3>::perform_test_accuracy (ret_val); - TestHelperFixLen < 4>::perform_test_accuracy (ret_val); - TestHelperFixLen < 7>::perform_test_accuracy (ret_val); - TestHelperFixLen < 8>::perform_test_accuracy (ret_val); - TestHelperFixLen <10>::perform_test_accuracy (ret_val); - TestHelperFixLen <12>::perform_test_accuracy (ret_val); - TestHelperFixLen <13>::perform_test_accuracy (ret_val); - - return (ret_val); -} - - - -int TEST_perform_test_speed_all () -{ - int ret_val = 0; - -#if defined (test_settings_SPEED_TEST_ENABLED) - - TestHelperNormal ::perform_test_speed (ret_val); - TestHelperNormal ::perform_test_speed (ret_val); - - TestHelperFixLen < 1>::perform_test_speed (ret_val); - TestHelperFixLen < 2>::perform_test_speed (ret_val); - TestHelperFixLen < 3>::perform_test_speed (ret_val); - TestHelperFixLen < 4>::perform_test_speed (ret_val); - TestHelperFixLen < 7>::perform_test_speed (ret_val); - TestHelperFixLen < 8>::perform_test_speed (ret_val); - TestHelperFixLen <10>::perform_test_speed (ret_val); - TestHelperFixLen <12>::perform_test_speed (ret_val); - TestHelperFixLen <14>::perform_test_speed (ret_val); - TestHelperFixLen <16>::perform_test_speed (ret_val); - TestHelperFixLen <20>::perform_test_speed (ret_val); - -#endif - - return (ret_val); -} - - - -#if defined (_MSC_VER) -static int __cdecl TEST_new_handler_cb (size_t dummy) -{ - throw std::bad_alloc (); - return (0); -} -#endif // _MSC_VER - - - -#if defined (_MSC_VER) && ! defined (NDEBUG) -static int __cdecl TEST_debug_alloc_hook_cb (int alloc_type, void *user_data_ptr, size_t size, int block_type, long request_nbr, const unsigned char *filename_0, int line_nbr) -{ - if (block_type != _CRT_BLOCK) // Ignore CRT blocks to prevent infinite recursion - { - switch (alloc_type) - { - case _HOOK_ALLOC: - case _HOOK_REALLOC: - case _HOOK_FREE: - - // Put some debug code here - - break; - - default: - assert (false); // Undefined allocation type - break; - } - } - - return (1); -} -#endif - - - -#if defined (_MSC_VER) && ! defined (NDEBUG) -static int __cdecl TEST_debug_report_hook_cb (int report_type, char *user_msg_0, int *ret_val_ptr) -{ - *ret_val_ptr = 0; // 1 to override the CRT default reporting mode - - switch (report_type) - { - case _CRT_WARN: - case _CRT_ERROR: - case _CRT_ASSERT: - -// Put some debug code here - - break; - } - - return (*ret_val_ptr); -} -#endif - - - -static void TEST_prog_init () -{ -#if defined (_MSC_VER) - ::_set_new_handler (::TEST_new_handler_cb); -#endif // _MSC_VER - -#if defined (_MSC_VER) && ! defined (NDEBUG) - { - const int mode = (1 * _CRTDBG_MODE_DEBUG) - | (1 * _CRTDBG_MODE_WNDW); - ::_CrtSetReportMode (_CRT_WARN, mode); - ::_CrtSetReportMode (_CRT_ERROR, mode); - ::_CrtSetReportMode (_CRT_ASSERT, mode); - - const int old_flags = ::_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG); - ::_CrtSetDbgFlag ( old_flags - | (1 * _CRTDBG_LEAK_CHECK_DF) - | (1 * _CRTDBG_CHECK_ALWAYS_DF)); - ::_CrtSetBreakAlloc (-1); // Specify here a memory bloc number - ::_CrtSetAllocHook (TEST_debug_alloc_hook_cb); - ::_CrtSetReportHook (TEST_debug_report_hook_cb); - - // Speed up I/O but breaks C stdio compatibility -// std::cout.sync_with_stdio (false); -// std::cin.sync_with_stdio (false); -// std::cerr.sync_with_stdio (false); -// std::clog.sync_with_stdio (false); - } -#endif // _MSC_VER, NDEBUG -} - - - -static void TEST_prog_end () -{ -#if defined (_MSC_VER) && ! defined (NDEBUG) - { - const int mode = (1 * _CRTDBG_MODE_DEBUG) - | (0 * _CRTDBG_MODE_WNDW); - ::_CrtSetReportMode (_CRT_WARN, mode); - ::_CrtSetReportMode (_CRT_ERROR, mode); - ::_CrtSetReportMode (_CRT_ASSERT, mode); - - ::_CrtMemState mem_state; - ::_CrtMemCheckpoint (&mem_state); - ::_CrtMemDumpStatistics (&mem_state); - } -#endif // _MSC_VER, NDEBUG -} - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/test_fnc.h b/demos/spectrum/fftreal/test_fnc.h deleted file mode 100644 index 2622156..0000000 --- a/demos/spectrum/fftreal/test_fnc.h +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************** - - test_fnc.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (test_fnc_HEADER_INCLUDED) -#define test_fnc_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -inline T limit (const T &x, const T &inf, const T &sup); - - - -#include "test_fnc.hpp" - - - -#endif // test_fnc_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/test_fnc.hpp b/demos/spectrum/fftreal/test_fnc.hpp deleted file mode 100644 index 4b5f9f5..0000000 --- a/demos/spectrum/fftreal/test_fnc.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** - - test_fnc.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (test_fnc_CURRENT_CODEHEADER) - #error Recursive inclusion of test_fnc code header. -#endif -#define test_fnc_CURRENT_CODEHEADER - -#if ! defined (test_fnc_CODEHEADER_INCLUDED) -#define test_fnc_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -T limit (const T &x, const T &inf, const T &sup) -{ - assert (! (sup < inf)); - - return ((x < inf) ? inf : ((sup < x) ? sup : x)); -} - - - -#endif // test_fnc_CODEHEADER_INCLUDED - -#undef test_fnc_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/test_settings.h b/demos/spectrum/fftreal/test_settings.h deleted file mode 100644 index b893afc..0000000 --- a/demos/spectrum/fftreal/test_settings.h +++ /dev/null @@ -1,45 +0,0 @@ -/***************************************************************************** - - test_settings.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -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) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (test_settings_HEADER_INCLUDED) -#define test_settings_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -// #undef this label to avoid speed test compilation. -#define test_settings_SPEED_TEST_ENABLED - - - -#endif // test_settings_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/fftreal/testapp.dpr b/demos/spectrum/fftreal/testapp.dpr deleted file mode 100644 index 54f2eb9..0000000 --- a/demos/spectrum/fftreal/testapp.dpr +++ /dev/null @@ -1,150 +0,0 @@ -program testapp; -{$APPTYPE CONSOLE} -uses - SysUtils, - fftreal in 'fftreal.pas', - Math, - Windows; - -var - nbr_points : longint; - x, f : pflt_array; - fft : TFFTReal; - i : longint; - PI : double; - areal, img : double; - f_abs : double; - buffer_size : longint; - nbr_tests : longint; - time0, time1, time2 : int64; - timereso : int64; - offset : longint; - t0, t1 : double; - nbr_s_chn : longint; - tempp1, tempp2 : pflt_array; - -begin - (*______________________________________________ - * - * Exactness test - *______________________________________________ - *) - - WriteLn('Accuracy test:'); - WriteLn; - - nbr_points := 16; // Power of 2 - GetMem(x, nbr_points * sizeof_flt); - GetMem(f, nbr_points * sizeof_flt); - fft := TFFTReal.Create(nbr_points); // FFT object initialized here - - // Test signal - PI := ArcTan(1) * 4; - for i := 0 to nbr_points-1 do - begin - x^[i] := -1 + sin (3*2*PI*i/nbr_points) - + cos (5*2*PI*i/nbr_points) * 2 - - sin (7*2*PI*i/nbr_points) * 3 - + cos (8*2*PI*i/nbr_points) * 5; - end; - - // Compute FFT and IFFT - fft.do_fft(f, x); - fft.do_ifft(f, x); - fft.rescale(x); - - // Display the result - WriteLn('FFT:'); - for i := 0 to nbr_points div 2 do - begin - areal := f^[i]; - if (i > 0) and (i < nbr_points div 2) then - img := f^[i + nbr_points div 2] - else - img := 0; - - f_abs := Sqrt(areal * areal + img * img); - WriteLn(Format('%5d: %12.6f %12.6f (%12.6f)', [i, areal, img, f_abs])); - end; - - WriteLn; - WriteLn('IFFT:'); - for i := 0 to nbr_points-1 do - WriteLn(Format('%5d: %f', [i, x^[i]])); - - WriteLn; - - FreeMem(x); - FreeMem(f); - fft.Free; - - - (*______________________________________________ - * - * Speed test - *______________________________________________ - *) - - WriteLn('Speed test:'); - WriteLn('Please wait...'); - WriteLn; - - nbr_points := 1024; // Power of 2 - buffer_size := 256*nbr_points; // Number of flt_t (float or double) - nbr_tests := 10000; - - assert(nbr_points <= buffer_size); - GetMem(x, buffer_size * sizeof_flt); - GetMem(f, buffer_size * sizeof_flt); - fft := TFFTReal.Create(nbr_points); // FFT object initialized here - - // Test signal: noise - for i := 0 to nbr_points-1 do - x^[i] := Random($7fff) - ($7fff shr 1); - - // timing - QueryPerformanceFrequency(timereso); - QueryPerformanceCounter(time0); - - for i := 0 to nbr_tests-1 do - begin - offset := (i * nbr_points) and (buffer_size - 1); - tempp1 := f; - inc(tempp1, offset); - tempp2 := x; - inc(tempp2, offset); - fft.do_fft(tempp1, tempp2); - end; - - QueryPerformanceCounter(time1); - - for i := 0 to nbr_tests-1 do - begin - offset := (i * nbr_points) and (buffer_size - 1); - tempp1 := f; - inc(tempp1, offset); - tempp2 := x; - inc(tempp2, offset); - fft.do_ifft(tempp1, tempp2); - fft.rescale(x); - end; - - QueryPerformanceCounter(time2); - - t0 := ((time1-time0) / timereso) / nbr_tests; - t1 := ((time2-time1) / timereso) / nbr_tests; - - WriteLn(Format('%d-points FFT : %.0f us.', [nbr_points, t0 * 1000000])); - WriteLn(Format('%d-points IFFT + scaling: %.0f us.', [nbr_points, t1 * 1000000])); - - nbr_s_chn := Floor(nbr_points / ((t0 + t1) * 44100 * 2)); - WriteLn(Format('Peak performance: FFT+IFFT on %d mono channels at 44.1 KHz (with overlapping)', [nbr_s_chn])); - WriteLn; - - FreeMem(x); - FreeMem(f); - fft.Free; - - WriteLn('Press [Return] key to terminate...'); - ReadLn; -end. diff --git a/demos/spectrum/spectrum.pro b/demos/spectrum/spectrum.pro index 823f610..86a7583 100644 --- a/demos/spectrum/spectrum.pro +++ b/demos/spectrum/spectrum.pro @@ -6,7 +6,7 @@ TEMPLATE = subdirs CONFIG += ordered !contains(DEFINES, DISABLE_FFT) { - SUBDIRS += fftreal + SUBDIRS += 3rdparty/fftreal } SUBDIRS += app -- cgit v0.12 From 4a934cb8bb610119367f918957d871fbbc2799ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 6 May 2010 14:17:47 +0200 Subject: Some EGL implementations does not return a EGLNativeDisplayType when using EGL_DEFAULT_DISPLAY. Actualy what was being returned was a void * Reviewed-by: Andy Nichols --- src/gui/egl/qegl_qws.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/egl/qegl_qws.cpp b/src/gui/egl/qegl_qws.cpp index 56383a5..50db397 100644 --- a/src/gui/egl/qegl_qws.cpp +++ b/src/gui/egl/qegl_qws.cpp @@ -94,7 +94,7 @@ void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev) EGLNativeDisplayType QEgl::nativeDisplay() { - return EGL_DEFAULT_DISPLAY; + return EGLNativeDisplayType(EGL_DEFAULT_DISPLAY); } EGLNativeWindowType QEgl::nativeWindow(QWidget* widget) -- cgit v0.12 From fdee454d73c2a1c255e8315d35df663ab726e4db Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 6 May 2010 14:08:07 +0200 Subject: cosmetics: change enum value the existing values are fixed-point representations of the msvc versions, so adhere to it. --- qmake/generators/win32/msvc_objectmodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index 3f60a13..97f8570 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -59,7 +59,7 @@ enum DotNET { NET2003 = 0x71, NET2005 = 0x80, NET2008 = 0x90, - NET2010 = 0x91 + NET2010 = 0xa0 }; /* -- cgit v0.12 From 1c79ac10db1cf2b413ea3872641faec134664b8e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 6 May 2010 14:08:46 +0200 Subject: remove extraneous return statement --- qmake/generators/win32/msvc_vcxproj.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index da93fe3..05c1511 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -89,7 +89,6 @@ bool VcxprojGenerator::writeMakefile(QTextStream &t) return true; } return project->isActiveConfig("build_pass"); - return true; } -- cgit v0.12 From 106d8714fa9e09ef7e71c71c02a226c9a91d09f2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 6 May 2010 14:09:34 +0200 Subject: fix qmake project file following msvc2010 addition this is relevant only for maintainers, but still. --- qmake/qmake.pri | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qmake/qmake.pri b/qmake/qmake.pri index 0163839..6e0f8a2 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -13,7 +13,8 @@ SOURCES += project.cpp property.cpp main.cpp generators/makefile.cpp \ generators/xmloutput.cpp generators/win32/borland_bmake.cpp \ generators/win32/msvc_nmake.cpp generators/projectgenerator.cpp \ generators/win32/msvc_vcproj.cpp \ - generators/win32/msvc_objectmodel.cpp \ + generators/win32/msvc_vcxproj.cpp \ + generators/win32/msvc_objectmodel.cpp generators/win32/msbuild_objectmodel.cpp \ generators/symbian/symbiancommon.cpp \ generators/symbian/symmake.cpp \ generators/symbian/symmake_abld.cpp \ @@ -24,11 +25,12 @@ SOURCES += project.cpp property.cpp main.cpp generators/makefile.cpp \ HEADERS += project.h property.h generators/makefile.h \ generators/unix/unixmake.h meta.h option.h cachekeys.h \ - generators/win32/winmakefile.h generators/projectgenerator.h \ + generators/win32/winmakefile.h generators/win32/mingw_make.h generators/projectgenerator.h \ generators/makefiledeps.h generators/metamakefile.h generators/mac/pbuilder_pbx.h \ generators/xmloutput.h generators/win32/borland_bmake.h generators/win32/msvc_nmake.h \ generators/win32/msvc_vcproj.h \ - generators/win32/mingw_make.h generators/win32/msvc_objectmodel.h \ + generators/win32/msvc_vcxproj.h \ + generators/win32/msvc_objectmodel.h generators/win32/msbuild_objectmodel.h \ generators/symbian/symbiancommon.h \ generators/symbian/symmake.h \ generators/symbian/symmake_abld.h \ -- cgit v0.12 From 86260a117c9ce64d3dee71ab241559c0529f2ef5 Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Thu, 6 May 2010 14:11:32 +0200 Subject: Fix syntax error in configure script ./configure: line 5883: [: missing `]' ./configure: line 5883: no: command not found It's either if [ "$CFG_OPENGL" = "es1" -o "$CFG_OPENGL" = "es2" ]; then or if [ "$CFG_OPENGL" = "es1" ] || [ "$CFG_OPENGL" = "es2" ]; then but not if [ "$CFG_OPENGL" = "es1" || "$CFG_OPENGL" = "es2" ]; then Merge-request: 616 Reviewed-by: Oswald Buddenhagen --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 47eec92..3ed017d 100755 --- a/configure +++ b/configure @@ -5880,7 +5880,7 @@ if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" ]; then fi CFG_EGL=no # If QtOpenGL would be built against OpenGL ES, disable it as we can't to that if EGL is missing - if [ "$CFG_OPENGL" = "es1" || "$CFG_OPENGL" = "es2" ]; then + if [ "$CFG_OPENGL" = "es1" -o "$CFG_OPENGL" = "es2" ]; then CFG_OPENGL=no fi fi -- cgit v0.12 From 573be7e7ba19a2e826d17f5f78e272ee250831d0 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 6 May 2010 14:48:05 +0200 Subject: doc: Second attempt to begin reorganizing the top doc page. This change actually changes the left panels. Much more to come. --- doc/src/frameworks-technologies/graphicsview.qdoc | 2 +- doc/src/overviews.qdoc | 13 +++++++++-- doc/src/painting-and-printing/coordsys.qdoc | 1 + doc/src/painting-and-printing/paintsystem.qdoc | 2 +- tools/qdoc3/htmlgenerator.cpp | 3 +++ tools/qdoc3/test/qt-html-templates.qdocconf | 27 +++++++++-------------- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/doc/src/frameworks-technologies/graphicsview.qdoc b/doc/src/frameworks-technologies/graphicsview.qdoc index 95b3182..740fcac 100644 --- a/doc/src/frameworks-technologies/graphicsview.qdoc +++ b/doc/src/frameworks-technologies/graphicsview.qdoc @@ -47,7 +47,7 @@ /*! \page graphicsview.html \title The Graphics View Framework - \ingroup qt-gui-concepts + \ingroup qt-graphics \brief An overview of the Graphics View framework for interactive 2D graphics. diff --git a/doc/src/overviews.qdoc b/doc/src/overviews.qdoc index bc994af..b2ba3a1 100644 --- a/doc/src/overviews.qdoc +++ b/doc/src/overviews.qdoc @@ -63,9 +63,18 @@ /*! \group qt-gui-concepts - \title Qt GUI Components + \title Qt GUI Construction - \brief The Qt components for constructing graphical user intefaces. + \brief The Qt components for constructing Graphical User Intefaces. + + \generatelist {related} + */ + +/*! + \group qt-graphics + \title Qt Graphics + + \brief The Qt components for doing graphics. \generatelist {related} */ diff --git a/doc/src/painting-and-printing/coordsys.qdoc b/doc/src/painting-and-printing/coordsys.qdoc index 5807f57..b0ba093 100644 --- a/doc/src/painting-and-printing/coordsys.qdoc +++ b/doc/src/painting-and-printing/coordsys.qdoc @@ -42,6 +42,7 @@ /*! \page coordsys.html \title The Coordinate System + \ingroup qt-graphics \brief Information about the coordinate system used by the paint system. diff --git a/doc/src/painting-and-printing/paintsystem.qdoc b/doc/src/painting-and-printing/paintsystem.qdoc index 56b638c..b711b2f 100644 --- a/doc/src/painting-and-printing/paintsystem.qdoc +++ b/doc/src/painting-and-printing/paintsystem.qdoc @@ -61,7 +61,7 @@ /*! \page paintsystem.html \title The Paint System - \ingroup qt-gui-concepts + \ingroup qt-graphics \ingroup frameworks-technologies Qt's paint system enables painting on screen and print devices diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 373fa3d..dfba368 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1243,6 +1243,8 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, subtitleText << "(" << Atom(Atom::AutoLink, fullTitle) << ")" << Atom(Atom::LineBreak); +#if 0 + // No longer used because the modeule name is a breadcrumb. QString fixedModule = inner->moduleName(); if (fixedModule == "Qt3SupportLight") fixedModule = "Qt3Support"; @@ -1263,6 +1265,7 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, subtitleText << "]"; } } +#endif generateHeader(title, inner, marker); sections = marker->sections(inner, CodeMarker::Summary, CodeMarker::Okay); diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 1450149..8b007db 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -42,11 +42,12 @@ HTML.postheader = "
    \n" \ " API Lookup\n" \ "
    \n" \ " \n" \ "
    \n" \ "
    \n" \ @@ -54,20 +55,14 @@ HTML.postheader = "
    \n" \ "
    \n" \ "
    \n" \ "

    \n" \ - " API Topics

    \n" \ + " Qt Topics\n" \ "
    \n" \ " \n" \ "
    \n" \ "
    \n" \ -- cgit v0.12 From 6629adee4741c3a72a83316671331ac996d046a5 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 6 May 2010 14:46:38 +0200 Subject: Doc - mention vcsubdirs as a possible value for TEMPLATE It is usually the result of using subdirs in the .pro file and then using -tp vc to turn it into vcsubdirs. Reviewed-by: Oswald Buddenhagen --- doc/src/development/qmake-manual.qdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index 688122b..c63e96c 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -347,6 +347,7 @@ \row \o vcapp \o Creates a Visual Studio Project file to build an application. \row \o vclib \o Creates a Visual Studio Project file to build a library. + \row \o vcsubdirs \o Creates a Visual Studio Solution file to build projects in sub-directories. \endtable See the \l{qmake Tutorial} for advice on writing project files for -- cgit v0.12 From 92c4ccd5083e7efb3357bd190c07a95db604b9eb Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 6 May 2010 15:30:05 +0200 Subject: my changelog --- dist/changes-4.7.0 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0 index d156bd7..4035bfe 100644 --- a/dist/changes-4.7.0 +++ b/dist/changes-4.7.0 @@ -51,6 +51,10 @@ Third party components QtCore ------ + - QXmlStreamReader + * [QTBUG-9196] fixed crash when parsing + + QtGui ----- @@ -67,6 +71,21 @@ QtGui * Fixed a bug that led to missing text pixels in QTabBar when using small font sizes. (QTBUG-7137) + +QtNetwork +--------- + + - [QTBUG-8206] QNetworkAccessManager: add method to send custom requests + - [QTBUG-9618] [MR 2372] send secure cookies only over secure connections + +QtXmlPatterns +------------- + + - [QTBUG-8920] fixed crash with anonymous types in XsdSchemaChecker + - [QTBUG-8394] include/import/redefine schemas only once + - QXmlSchema: fix crash with referencing elements + + **************************************************************************** * Database Drivers * **************************************************************************** -- cgit v0.12 From 7770690dc220c4e75ed1411d2adf2e819092f7f2 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 6 May 2010 15:52:07 +0200 Subject: Doc: updating html and search feature Doc: implementing the search feature in the online docs Reviewed-by: Morten Engvoldsen --- doc/src/template/scripts/functions.js | 279 +++++++++------------------------- doc/src/template/style/style.css | 31 ++-- tools/qdoc3/htmlgenerator.cpp | 28 +--- 3 files changed, 90 insertions(+), 248 deletions(-) diff --git a/doc/src/template/scripts/functions.js b/doc/src/template/scripts/functions.js index 800660e..4b3107f 100755 --- a/doc/src/template/scripts/functions.js +++ b/doc/src/template/scripts/functions.js @@ -3,7 +3,6 @@ $('.t_button').mouseover(function() { $('.t_button').css('cursor','pointer'); /*document.getElementById(this.id).style.cursor='pointer';*/ }); - /* END non link areas */ $('#smallA').click(function() { $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('font-size','smaller'); @@ -38,120 +37,62 @@ $('#bigA').click(function() { var lookupCount = 0; var articleCount = 0; var exampleCount = 0; -var qturl = ""; // change to 0 +var qturl = ""; // change from "http://doc.qt.nokia.com/4.6/" to 0 so we can have relative links + function processNokiaData(response){ + // debug $('.content').prepend('
  • handling search results
  • '); // debuging var propertyTags = response.getElementsByTagName('page'); - var ulStartElement = "
      "; - var ulEndElement = "
    "; - - for (var i=0; i< propertyTags.length; i++) { + + for (var i=0; i< propertyTags.length; i++) { + var linkStart = "
  • " + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue - + '
  • ' ; - -// $('#list002 li').remove(); -// $('#tbl002').prepend('
  • foo1
  • '); -// $('#tbl002').prepend('
  • bar2
  • '); - - $('ul001').prepend(full_address_lookup); + if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'APIPage'){ + lookupCount=0; + //$('.live001').css('display','block'); + + for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ + full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; + full_li_element = full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd; + $('#ul001').prepend(full_li_element); } } - - if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Article'){ - articleCount = 0; - document.getElementById('live002').style.display = "block"; - for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ - full_address_topic = full_address_topic + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; - full_address_topic = full_address_topic + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue - + ''; + + if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Article'){ + articleCount = 0; + //$('.live002').css('display','block'); + + for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ + full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; + full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ; - $('ul002').prepend(full_address_lookup); - } - } - if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Example'){ - exampleCount = 0; - document.getElementById('live003').style.display = "block"; - - for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ - full_address_examples = full_address_examples + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; - full_address_examples = full_address_examples + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue - + ''; + $('#ul002').prepend(full_li_element); + } + } + if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Example'){ + exampleCount = 0; + //$('.live003').css('display','block'); + + for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ + full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; + full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ; - $('ul003').prepend(full_address_lookup); - } - } - + $('#ul003').prepend(full_li_element); + } + } } - - - if(lookupCount == 0){loadLookupList();} - if(articleCount == 0){loadArticleList();} - if(exampleCount == 0){loadExampleList();} + if(lookupCount == 0){$('#ul001').prepend('
  • no result
  • ');$('#ul001 li').css('display','block');} + if(articleCount == 0){$('#ul002').prepend('
  • no result
  • ');$('#ul002 li').css('display','block');} + if(exampleCount == 0){$('#ul003').prepend('
  • no result
  • ');$('#ul003 li').css('display','block');} // reset count variables; lookupCount=0; articleCount = 0; exampleCount = 0; } -function removeResults() { - -// get hold of the non-default li elements and delete them - $('.live li').remove(); - - - /* var resultsTableLookup = document.getElementById('div001'); - var recordslookup = resultsTableLookup.rows.length; - - for (var i=(recordslookup-1); i> 0; i--){ - // resultsTableLookup.deleteRow(i); - - } - - var resultsTableTopic = document.getElementById('div002'); - var recordstopic = resultsTableTopic.rows.length; - for (var i=(recordstopic-1); i> 0; i--){ - // alert("delete: " + i); - // resultsTableTopic.deleteRow(i); - } - - var resultsTableexample = document.getElementById('div003'); - var recordsexample = resultsTableexample.rows.length; - for (var i=(recordsexample-1); i> 0; i--) - // resultsTableexample.deleteRow(i); - - removeList(); */ -} - -function removeList(){ - // var resultsTableLookuplist = document.getElementById('ul001'); - // var recordlookuplist = resultsTableLookuplist.rows.length; - // for (var i=(recordlookuplist-1); i> 0; i--) - // resultsTableLookuplist.deleteRow(i); - - // var resultsTableArticlelist = document.getElementById('ul002'); - // var recordArticlelist = resultsTableArticlelist.rows.length; - // for (var i=(recordArticlelist-1); i> 0; i--) - // resultsTableArticlelist.deleteRow(i); - - // var resultsTableExamplelist = document.getElementById('ul003'); - // var recordExamplelist = resultsTableExamplelist.rows.length; - // for (var i=(recordExamplelist-1); i> 0; i--) - // resultsTableExamplelist.deleteRow(i); - } - //build regular expression object to find empty string or any number of blank var blankRE=/^\s*$/; function CheckEmptyAndLoadList() @@ -161,114 +102,44 @@ function CheckEmptyAndLoadList() { //empty inputbox // load default li elements into the ul if empty - loadAllList(); - //alert("loadAllList"); - document.getElementById('live001').style.display = "none"; - document.getElementById('live002').style.display = "none"; - document.getElementById('live003').style.display = "none"; - document.getElementById('list001').style.display = "block"; - document.getElementById('list002').style.display = "block"; - document.getElementById('list003').style.display = "block"; + // loadAllList(); // replaced + $('.defaultLink').css('display','block'); + // $('.liveResult').css('display','none'); }else{ - removeList(); - //alert("removeList"); - document.getElementById('live001').style.display = "block"; - document.getElementById('live002').style.display = "block"; - document.getElementById('live003').style.display = "block"; - - } -} -function loadAllList(){ - - /*var fullAddressListLookup = ""; - // var rowlistlookup = document.getElementById('ul001').insertRow(-1); - // var celllistlookup = rowlistlookup.insertCell(-1); - // celllistlookup.style.padding="0 0 0 0"; - //celllistlookup.style.width="10px"; - //celllistlookup.style.background = "yellow"; - //celllistlookup.innerHTML = fullAddressListLookup ; - - - - - var fullAddressListArticle = ""; - // var rowlistarticle = document.getElementById('ul002').insertRow(-1); - // var celllistarticle = rowlistarticle.insertCell(-1); - // celllistarticle.style.padding="0 0 0 0"; - //celllistarticle.innerHTML = fullAddressListArticle ; - - - var fullAddressListExample = ""; - // var rowlistexample = document.getElementById('ul003').insertRow(-1); - // var celllistexample = rowlistexample.insertCell(-1); - // celllistexample.style.padding="0 0 0 0"; - //celllistexample.innerHTML = fullAddressListExample ;*/ - -} - -function loadLookupList(){ - - /*var fullAddressListLookup = ""; - // var rowlistlookup = document.getElementById('ul001').insertRow(-1); - // var celllistlookup = rowlistlookup.insertCell(-1); - // celllistlookup.style.padding="0 0 0 0"; - //celllistlookup.style.width="10px"; - //celllistlookup.style.background = "yellow"; - celllistlookup.innerHTML = fullAddressListLookup ; - document.getElementById('live001').style.display = "none"; - document.getElementById('list001').style.display = "block"; - //alert("loadLookupList") -*/ -} -function loadArticleList(){ - /* - var fullAddressListArticle = ""; - // var rowlistarticle = document.getElementById('ul002').insertRow(-1); - // var celllistarticle = rowlistarticle.insertCell(-1); - // celllistarticle.style.padding="0 0 0 0"; - celllistarticle.innerHTML = fullAddressListArticle ; - document.getElementById('live002').style.display = "none"; - document.getElementById('list002').style.display = "block";*/ + $('.defaultLink').css('display','none'); } - -function loadExampleList(){ - /* - var fullAddressListExample = ""; - // var rowlistexample = document.getElementById('ul003').insertRow(-1); - // var celllistexample = rowlistexample.insertCell(-1); - // celllistexample.style.padding="0 0 0 0"; - celllistexample.innerHTML = fullAddressListExample ; - document.getElementById('live003').style.display = "none"; - document.getElementById('list003').style.display = "block";*/ - } +// Loads on doc ready + $(document).ready(function () { + $('#pageType').keyup(function () { + var searchString = $('#pageType').val() ; + if ((searchString == null) || (searchString.length < 3)) { + $('.liveResult').remove(); // replaces removeResults(); + CheckEmptyAndLoadList(); + $('.report').remove(); + // debug$('.content').prepend('
  • too short or blank
  • '); // debug + return; + } + if (this.timer) clearTimeout(this.timer); + this.timer = setTimeout(function () { + // debug$('.content').prepend('
  • new search started
  • ');// debug + // debug$('.content').prepend('

    Search string ' +searchString +'

    '); // debug + + $.ajax({ + contentType: "application/x-www-form-urlencoded", + url: 'http://' + location.host + '/nokiasearch/GetDataServlet', + data: 'searchString='+searchString, + dataType:'xml', + type: 'post', + success: function (response, textStatus) { + + $('.liveResult').remove(); // replaces removeResults(); + processNokiaData(response); + + } + }); + }, 500); + }); + }); diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index 220afb9..6bcb0db 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -1020,6 +1020,11 @@ overflow:hidden; } + +.indexboxcont .section { + float: left; +} + .indexboxcont .section p { padding-top: 20px; @@ -1028,7 +1033,7 @@ .indexboxcont .sectionlist { display: inline-block; - width: 33%; + width: 32.5%; padding: 0; } .indexboxcont .sectionlist ul @@ -1057,6 +1062,12 @@ color: #00732f; text-decoration: none; } + + .indexbox .indexIcon { + width: 11%; + } + + .indexbox .indexIcon span { display: block; @@ -1085,25 +1096,11 @@ clear: both; visibility: hidden; } - /* - - + - .lastcol - { - display: inline-block; - vertical-align: top; - padding: 0; - max-width: 25%; - } + /* end of screen media */ - .tricol .lastcol - { - margin-left: -6px; - } - */ - /* end indexbox */ } /* end of screen media */ diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index dfba368..93b0218 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1795,32 +1795,7 @@ void HtmlGenerator::generateHeader(const QString& title, //out() << " Qt Reference Documentation"; out() << " \n"; out() << " \n"; - out() << " \n"; + out() << " \n"; out() << "\n"; if (offlineDocs) @@ -1868,7 +1843,6 @@ void HtmlGenerator::generateFooter(const Node *node) out() << QString(footer).replace("\\" + COMMAND_VERSION, myTree->version()) << QString(address).replace("\\" + COMMAND_VERSION, myTree->version()); - out() << " \n"; out() << "\n"; out() << "\n"; } -- cgit v0.12 From fb74c8dc2f240f9e2c4f64633917ca5bd43c22a1 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 6 May 2010 17:07:53 +0300 Subject: QLineEdit / QDateEdit - white font on white background Currently QCoeFepInputContext uses default QLineEdit palette when setting up text format before passing the formatted text to native side (which uses it, for example, to show T9 suggested words). The above way is incorrect due to two reasons: - custom widget might not be anything like QLineEdit and might have really different palette from it - it ignores stylesheets (or modifications to the QLineEdit's palette) Therefore, the color for text format is picked up from focusWidget, if it is available (in most cases it should be). If the focusWidget is not available, then QLineEdit default palette is used. Task-number: QTBUG-9480 Reviewed-by: Janne Koskinen --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 610ac3c..d081cfd 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -484,9 +484,10 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) void QCoeFepInputContext::applyFormat(QList *attributes) { TCharFormat cFormat; - QColor styleTextColor = QApplication::palette("QLineEdit").text().color(); - TLogicalRgb tontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha())); - cFormat.iFontPresentation.iTextColor = tontColor; + const QColor styleTextColor = focusWidget() ? focusWidget()->palette().text().color() : + QApplication::palette("QLineEdit").text().color(); + const TLogicalRgb fontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha())); + cFormat.iFontPresentation.iTextColor = fontColor; TInt numChars = 0; TInt charPos = 0; -- cgit v0.12 From b1be4ec9def9fda88760367cc7be61248dc53d18 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 6 May 2010 17:25:30 +0300 Subject: QS60Style: Sliders are too small Sometime back slider graphic in the QS60Style was changed to use the "new" slider graphic available in 5th Edition and newer SDKs (the old SDKs still use the slider graphic). However, at that time nobody noticed that the new slider has different size than the old one in the Nokia LAF document. To fix the sliders, updated the pixel metrics calculation rules to use the new slider LAF data. Also fixed a grpahic start and end part rounding to match native look. Task-number: QTBUG-10454 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 19 +++++++++---------- util/s60pixelmetrics/pixel_metrics.cpp | 12 +++++++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index f32bd5e..a0e8496 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -92,10 +92,10 @@ static const qreal goldenRatio = 1.618; const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { // *** generated layout data *** -{240,320,1,18,"QVGA Landscape"}, -{320,240,1,18,"QVGA Portrait"}, -{360,640,1,18,"NHD Landscape"}, -{640,360,1,18,"NHD Portrait"}, +{240,320,1,19,"QVGA Landscape"}, +{320,240,1,19,"QVGA Portrait"}, +{360,640,1,19,"NHD Landscape"}, +{640,360,1,19,"NHD Portrait"}, {352,800,1,12,"E90 Landscape"} // *** End of generated data *** }; @@ -104,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,30,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,28,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,44,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,52,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,30,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} +{5,0,-909,0,0,2,0,0,-1,7,12,22,15,15,7,198,-909,-909,-909,20,13,2,0,0,21,7,18,30,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,28,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,46,37,37,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,44,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,46,37,37,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,52,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,30,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 *** }; @@ -882,7 +882,6 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag case QS60StyleEnums::SP_QgnGrafNsliderEndLeft: case QS60StyleEnums::SP_QgnGrafNsliderEndRight: case QS60StyleEnums::SP_QgnGrafNsliderMiddle: - result.setWidth(result.height() >> 1); break; case QS60StyleEnums::SP_QgnGrafNsliderMarker: diff --git a/util/s60pixelmetrics/pixel_metrics.cpp b/util/s60pixelmetrics/pixel_metrics.cpp index 0fd650e..42ae850 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 = 18; +const TInt KPMMinorVersion = 19; TPixelMetricsVersion PixelMetrics::Version() { @@ -468,7 +468,7 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) TAknLayoutRect sliderSettingRect; sliderSettingRect.LayoutRect( sliderRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_cp() ); TAknLayoutRect sliderGraph2Rect; - sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g2() ); + sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g6() ); value = sliderGraph2Rect.Rect().Width(); } break; @@ -483,7 +483,8 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) TAknLayoutRect sliderSettingRect; sliderSettingRect.LayoutRect( sliderRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_cp() ); TAknLayoutRect sliderGraph2Rect; - sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g2() ); + sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g6() ); + //todo: make a proper calculation for tick marks value = (TInt)(sliderGraph2Rect.Rect().Height()*1.5); // add assumed tickmark height } break; @@ -498,7 +499,8 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) TAknLayoutRect sliderSettingRect; sliderSettingRect.LayoutRect( sliderRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_cp() ); TAknLayoutRect sliderGraph2Rect; - sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g2() ); + sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g6() ); + //todo: make a proper calculation for tick marks value = (TInt)(sliderGraph2Rect.Rect().Height()*0.5); // no tickmarks in S60, lets assume they are half the size of slider indicator } break; @@ -513,7 +515,7 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) TAknLayoutRect sliderSettingRect; sliderSettingRect.LayoutRect( sliderRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_cp() ); TAknLayoutRect sliderGraph2Rect; - sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g2() ); + sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g6() ); value = sliderGraph2Rect.Rect().Height(); } break; -- cgit v0.12 From 6af3db7e24527731124ad1233f926bc8d1c890b3 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 6 May 2010 16:48:28 +0200 Subject: My changelog entries for core and network --- dist/changes-4.7.0 | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0 index 4035bfe..df782c0 100644 --- a/dist/changes-4.7.0 +++ b/dist/changes-4.7.0 @@ -53,7 +53,8 @@ QtCore - QXmlStreamReader * [QTBUG-9196] fixed crash when parsing - + - QTimer + * singleShot with 0 timeout will now avoid allocating objects QtGui ----- @@ -74,9 +75,25 @@ QtGui QtNetwork --------- - - - [QTBUG-8206] QNetworkAccessManager: add method to send custom requests - - [QTBUG-9618] [MR 2372] send secure cookies only over secure connections + - QHostInfo: Added a small 60 second DNS cache + - QNetworkAccessManager + * Performance improvements for file:// and http:// + * Crash fixes + * Improvements on HTTP pipelining + * Fix problem with canReadLine() + * Fix problem with HTTP 100 reply + * Some new attributes for QNetworkRequest + * [QTBUG-8206] add method to send custom requests + * [QTBUG-9618] [MR 2372] send secure cookies only over secure connections + * [QTBUG-7713] Fix bug related to re-sending request + * [QTBUG-7673] Fix issue with some webservers + - Sockets + * Better support for derived QTcpServer + * [QTBUG-7054] Fix error handling with waitFor*() for socket engine + * [QTBUG-7316, QTBUG-7317] Also handle unknown errors from socket engine + - SSL + * [QTBUG-2515] Do not make OpenSSL prompt for a password + * [QTBUG-6504, QTBUG-8924, QTBUG-5645] Fix memleak QtXmlPatterns ------------- -- cgit v0.12 From 8cd1773d49fc86e57e37a2b146dad1ef96105b04 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 6 May 2010 13:09:27 +0200 Subject: Fix compilation in C++0x mode (narrowing of constants) --- src/gui/painting/qprintengine_pdf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qprintengine_pdf.cpp b/src/gui/painting/qprintengine_pdf.cpp index 0a747e7..2955e39 100644 --- a/src/gui/painting/qprintengine_pdf.cpp +++ b/src/gui/painting/qprintengine_pdf.cpp @@ -1225,7 +1225,7 @@ void QPdfEnginePrivate::printString(const QString &string) { const ushort *utf16 = string.utf16(); for (int i=0; i < string.size(); ++i) { - char part[2] = {(*(utf16 + i)) >> 8, (*(utf16 + i)) & 0xff}; + char part[2] = {char((*(utf16 + i)) >> 8), char((*(utf16 + i)) & 0xff)}; for(int j=0; j < 2; ++j) { if (part[j] == '(' || part[j] == ')' || part[j] == '\\') array.append('\\'); -- cgit v0.12 From 932f0b32eb22fbd7d3dcbbd69740457f65ab5d1a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 6 May 2010 15:01:52 +0200 Subject: Add missing newline to static XML snippet --- src/dbus/qdbusinternalfilters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp index 8fc219a..78abf94 100644 --- a/src/dbus/qdbusinternalfilters.cpp +++ b/src/dbus/qdbusinternalfilters.cpp @@ -87,7 +87,7 @@ static const char propertiesInterfaceXml[] = " \n" " \n" " \n" - " " + " \n" " \n" " \n"; -- cgit v0.12 From c06c9ecf3f37ca8ff8a4be14c9f4e1c2e483250a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 6 May 2010 15:02:34 +0200 Subject: QDBusXmlGenerator: get the true name from QMetaType for the return type --- src/dbus/qdbusxmlgenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp index 9c25d82..463ac73 100644 --- a/src/dbus/qdbusxmlgenerator.cpp +++ b/src/dbus/qdbusxmlgenerator.cpp @@ -160,7 +160,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method // do we need to describe this argument? if (QDBusMetaType::signatureToType(typeName) == QVariant::Invalid) xml += QString::fromLatin1(" \n") - .arg(typeNameToXml(mm.typeName())); + .arg(typeNameToXml(QVariant::typeToName(QVariant::Type(typeId)))); } else continue; } -- cgit v0.12 From dbc2cfffd2e71ce4244e8e700b4928a8ab5d5a04 Mon Sep 17 00:00:00 2001 From: Mirko Damiani Date: Thu, 6 May 2010 16:50:22 +0200 Subject: Don't initialize Wintab if QT_NO_TABLETEVENT is defined. Functions qt_tablet_init() and qt_tablet_init_wce() are now wrapped with QT_NO_TABLETEVENT macro. Merge-request: 2383 Reviewed-by: Benjamin Poulain --- src/gui/kernel/qwidget_win.cpp | 2 ++ src/gui/kernel/qwidget_wince.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 7d647b7..4912291 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -512,8 +512,10 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO DestroyWindow(destroyw); } +#ifndef QT_NO_TABLETEVENT if (q != qt_tablet_widget && QWidgetPrivate::mapper) qt_tablet_init(); +#endif // QT_NO_TABLETEVENT if (q->testAttribute(Qt::WA_DropSiteRegistered)) registerDropSite(true); diff --git a/src/gui/kernel/qwidget_wince.cpp b/src/gui/kernel/qwidget_wince.cpp index 509847b..e352f5c 100644 --- a/src/gui/kernel/qwidget_wince.cpp +++ b/src/gui/kernel/qwidget_wince.cpp @@ -358,8 +358,10 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO DestroyWindow(destroyw); } +#ifndef QT_NO_TABLETEVENT if (q != qt_tablet_widget && QWidgetPrivate::mapper) qt_tablet_init_wce(); +#endif // QT_NO_TABLETEVENT if (q->testAttribute(Qt::WA_DropSiteRegistered)) registerDropSite(true); -- cgit v0.12 From 3a9c669816c2b0784b5c9e1790bc3bbd036cf013 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Thu, 6 May 2010 14:39:01 +0200 Subject: Make QCompleter cope with restricted screen real estate (mobile devices) Always prefer the bottom area for the list popup - if that doesn't work out use the maximum available space (top or bottom) and resize the popup if it still does not fit. RevBy: Dominik Holland RevBy: ogoffart --- src/gui/util/qcompleter.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index 8e7ec80..05fe744 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -873,7 +873,7 @@ void QCompleterPrivate::showPopup(const QRect& rect) const QRect screen = QApplication::desktop()->availableGeometry(widget); Qt::LayoutDirection dir = widget->layoutDirection(); QPoint pos; - int rw, rh, w; + int rh, w; int h = (popup->sizeHintForRow(0) * qMin(maxVisibleItems, popup->model()->rowCount()) + 3) + 3; QScrollBar *hsb = popup->horizontalScrollBar(); if (hsb && hsb->isVisible()) @@ -881,21 +881,30 @@ void QCompleterPrivate::showPopup(const QRect& rect) if (rect.isValid()) { rh = rect.height(); - w = rw = rect.width(); + w = rect.width(); pos = widget->mapToGlobal(dir == Qt::RightToLeft ? rect.bottomRight() : rect.bottomLeft()); } else { rh = widget->height(); - rw = widget->width(); pos = widget->mapToGlobal(QPoint(0, widget->height() - 2)); w = widget->width(); } - if ((pos.x() + rw) > (screen.x() + screen.width())) + if (w > screen.width()) + w = screen.width(); + if ((pos.x() + w) > (screen.x() + screen.width())) pos.setX(screen.x() + screen.width() - w); if (pos.x() < screen.x()) pos.setX(screen.x()); - if (((pos.y() + rh) > (screen.y() + screen.height())) && ((pos.y() - h - rh) >= 0)) - pos.setY(pos.y() - qMax(h, popup->minimumHeight()) - rh + 2); + + int top = pos.y() - rh - screen.top() + 2; + int bottom = screen.bottom() - pos.y(); + h = qMax(h, popup->minimumHeight()); + if (h > bottom) { + h = qMin(qMax(top, bottom), h); + + if (top > bottom) + pos.setY(pos.y() - h - rh + 2); + } popup->setGeometry(pos.x(), pos.y(), w, h); -- cgit v0.12 From 18411bfd474b05fd427b3d763af2fcc96e3e73df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 6 May 2010 19:07:39 +0200 Subject: Fixed bug in QIODevice::read after first reading 0 bytes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change 02532ec80375c686503c4250c6ad6bb211515ec8 removed the early-exit for 0 byte reads, causing us to hit code that assumed the buffer was empty since nothing was read. It would thus read more into the end of the buffer, causing the buffer to grow bigger than QIODEVICE_BUFFERSIZE. Next, if the actual number of bytes we wanted to read was bigger than the original buffer size we'd read the same data twice. Reviewed-by: João Abecasis Reviewed-by: Thiago Macieira --- src/corelib/io/qiodevice.cpp | 3 +++ tests/auto/qbuffer/tst_qbuffer.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index bb11d6b..223df9b 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -810,6 +810,9 @@ qint64 QIODevice::read(char *data, qint64 maxSize) } } + if (!maxSize) + return readSoFar; + if ((d->openMode & Unbuffered) == 0 && maxSize < QIODEVICE_BUFFERSIZE) { // In buffered mode, we try to fill up the QIODevice buffer before // we do anything else. diff --git a/tests/auto/qbuffer/tst_qbuffer.cpp b/tests/auto/qbuffer/tst_qbuffer.cpp index fcef6a3..dd5ca91 100644 --- a/tests/auto/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/qbuffer/tst_qbuffer.cpp @@ -76,6 +76,7 @@ private slots: void atEnd(); void readLineBoundaries(); void writeAfterQByteArrayResize(); + void read_null(); protected slots: void readyReadSlot(); @@ -529,5 +530,30 @@ void tst_QBuffer::writeAfterQByteArrayResize() QCOMPARE(buffer.buffer().size(), 1000); } +void tst_QBuffer::read_null() +{ + QByteArray buffer; + buffer.resize(32000); + for (int i = 0; i < buffer.size(); ++i) + buffer[i] = char(i & 0xff); + + QBuffer in(&buffer); + in.open(QIODevice::ReadOnly); + + QByteArray chunk; + + chunk.resize(16380); + in.read(chunk.data(), 16380); + + QCOMPARE(chunk, buffer.mid(0, chunk.size())); + + in.read(chunk.data(), 0); + + chunk.resize(8); + in.read(chunk.data(), chunk.size()); + + QCOMPARE(chunk, buffer.mid(16380, chunk.size())); +} + QTEST_MAIN(tst_QBuffer) #include "tst_qbuffer.moc" -- cgit v0.12 From 153f9f34008c0205cbbb88d03e7991aba932c913 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Fri, 7 May 2010 14:32:49 +1000 Subject: Fix auto-test failure on Mac/Linux/QWS. / should not be present in the completer -> it's the current dir. This regression happened due to a bug fix i did so the auto-test was relying on a bug :D. Reviewed-by:TrustMe --- tests/auto/qfiledialog/tst_qfiledialog.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 38a1ee7..ca7c445 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -529,10 +529,6 @@ void tst_QFiledialog::completer() #endif ++expected; } -#if !defined(Q_OS_WIN) - if (inputStartsWithRootPath) - expected++; -#endif } QTest::qWait(1000); -- cgit v0.12 From 3e9f45c5d585aabb1964e3472211c5201661eca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 7 May 2010 09:35:01 +0200 Subject: Fixed line and point drawing for the PS/PDF generators. Some lines and points could appear with artifacts when printed or viewed in a pdf viewer. If a brush was set we also generated a fill for the line/point, which was not correct. Task-number: QTBUG-8451 Reviewed-by: Gunnar --- src/gui/painting/qpdf.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index ee8b078..05341e3 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -971,12 +971,17 @@ void QPdfBaseEngine::drawPoints (const QPointF *points, int pointCount) if (!points) return; + Q_D(QPdfBaseEngine); QPainterPath p; for (int i=0; i!=pointCount;++i) { p.moveTo(points[i]); p.lineTo(points[i] + QPointF(0, 0.001)); } + + bool hadBrush = d->hasBrush; + d->hasBrush = false; drawPath(p); + d->hasBrush = hadBrush; } void QPdfBaseEngine::drawLines (const QLineF *lines, int lineCount) @@ -984,12 +989,16 @@ void QPdfBaseEngine::drawLines (const QLineF *lines, int lineCount) if (!lines) return; + Q_D(QPdfBaseEngine); QPainterPath p; for (int i=0; i!=lineCount;++i) { p.moveTo(lines[i].p1()); p.lineTo(lines[i].p2()); } + bool hadBrush = d->hasBrush; + d->hasBrush = false; drawPath(p); + d->hasBrush = hadBrush; } void QPdfBaseEngine::drawRects (const QRectF *rects, int rectCount) -- cgit v0.12 From 9cd2a03b09cbe4b024304b1d5d761b464c6c05e4 Mon Sep 17 00:00:00 2001 From: aavit Date: Fri, 7 May 2010 10:12:07 +0200 Subject: my changes --- dist/changes-4.7.0 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0 index df782c0..3766c88 100644 --- a/dist/changes-4.7.0 +++ b/dist/changes-4.7.0 @@ -72,6 +72,8 @@ QtGui * Fixed a bug that led to missing text pixels in QTabBar when using small font sizes. (QTBUG-7137) + - QImage + * Added QImage::bitPlaneCount(). (QTBUG-7982) QtNetwork --------- @@ -102,6 +104,20 @@ QtXmlPatterns - [QTBUG-8394] include/import/redefine schemas only once - QXmlSchema: fix crash with referencing elements +Qt Plugins +---------- + + - Jpeg image IO plugin + * Fixed failure to store certain QImage formats as jpeg (QTBUG-7780) + * Optimized smoothscaling + * Optimized to avoid data copy when reading from memory device (QTBUG-9095) + + - SVG image IO plugin + * Added support for svgz format (QTBUG-8227) + * Fixed canRead() so that it can be used also for non-sequential + devices. (QTBUG-9053) + * Added support for clipping and scaling and backgroundcolor + * Optimized to avoid data copy when reading from memory device (QTBUG-9095) **************************************************************************** * Database Drivers * -- cgit v0.12 From f380ab3106cb6d39087adacd77f618184f6f90c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 6 May 2010 19:07:39 +0200 Subject: Fixed bug in QIODevice::read after first reading 0 bytes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change 02532ec80375c686503c4250c6ad6bb211515ec8 removed the early-exit for 0 byte reads, causing us to hit code that assumed the buffer was empty since nothing was read. It would thus read more into the end of the buffer, causing the buffer to grow bigger than QIODEVICE_BUFFERSIZE. Next, if the actual number of bytes we wanted to read was bigger than the original buffer size we'd read the same data twice. Reviewed-by: João Abecasis Reviewed-by: Thiago Macieira --- src/corelib/io/qiodevice.cpp | 3 +++ tests/auto/qbuffer/tst_qbuffer.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index bb11d6b..223df9b 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -810,6 +810,9 @@ qint64 QIODevice::read(char *data, qint64 maxSize) } } + if (!maxSize) + return readSoFar; + if ((d->openMode & Unbuffered) == 0 && maxSize < QIODEVICE_BUFFERSIZE) { // In buffered mode, we try to fill up the QIODevice buffer before // we do anything else. diff --git a/tests/auto/qbuffer/tst_qbuffer.cpp b/tests/auto/qbuffer/tst_qbuffer.cpp index fcef6a3..dd5ca91 100644 --- a/tests/auto/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/qbuffer/tst_qbuffer.cpp @@ -76,6 +76,7 @@ private slots: void atEnd(); void readLineBoundaries(); void writeAfterQByteArrayResize(); + void read_null(); protected slots: void readyReadSlot(); @@ -529,5 +530,30 @@ void tst_QBuffer::writeAfterQByteArrayResize() QCOMPARE(buffer.buffer().size(), 1000); } +void tst_QBuffer::read_null() +{ + QByteArray buffer; + buffer.resize(32000); + for (int i = 0; i < buffer.size(); ++i) + buffer[i] = char(i & 0xff); + + QBuffer in(&buffer); + in.open(QIODevice::ReadOnly); + + QByteArray chunk; + + chunk.resize(16380); + in.read(chunk.data(), 16380); + + QCOMPARE(chunk, buffer.mid(0, chunk.size())); + + in.read(chunk.data(), 0); + + chunk.resize(8); + in.read(chunk.data(), chunk.size()); + + QCOMPARE(chunk, buffer.mid(16380, chunk.size())); +} + QTEST_MAIN(tst_QBuffer) #include "tst_qbuffer.moc" -- cgit v0.12 From f5366aea8594946e78106c5f93ecb2d47f121d32 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 7 May 2010 10:00:28 +0200 Subject: QUrl::fromLocalFile: fix silly mistake: it's fromNativeSeparators, not to --- src/corelib/io/qurl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 7b5bfed..67119b5 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5985,7 +5985,7 @@ QUrl QUrl::fromLocalFile(const QString &localFile) { QUrl url; url.setScheme(QLatin1String("file")); - QString deslashified = QDir::toNativeSeparators(localFile); + QString deslashified = QDir::fromNativeSeparators(localFile); // magic for drives on windows if (deslashified.length() > 1 && deslashified.at(1) == QLatin1Char(':') && deslashified.at(0) != QLatin1Char('/')) { -- cgit v0.12 From aebc59dde62651bbe60af626f289a587d475e73a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 7 May 2010 10:19:25 +0200 Subject: tst_qxmlquery: Fix misuse of absolute paths as URLs Reviewed-By: Peter Hartmann --- tests/auto/qxmlquery/tst_qxmlquery.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp index be0d708..6fd9b93 100644 --- a/tests/auto/qxmlquery/tst_qxmlquery.cpp +++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp @@ -857,7 +857,7 @@ void tst_QXmlQuery::bindVariableXSLTSuccess() const stylesheet.bindVariable(QLatin1String("paramSelectWithTypeIntBoundWithBindVariableRequired"), QVariant(QLatin1String("param5"))); - stylesheet.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/parameters.xsl")))); + stylesheet.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/parameters.xsl")))); QVERIFY(stylesheet.isValid()); @@ -1798,11 +1798,11 @@ void tst_QXmlQuery::setFocusQUrl() const { QXmlQuery query(QXmlQuery::XSLT20); - const TestURIResolver resolver(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + const TestURIResolver resolver(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); query.setUriResolver(&resolver); QVERIFY(query.setFocus(QUrl(QLatin1String("arbitraryURI")))); - query.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/copyWholeDocument.xsl")))); + query.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/copyWholeDocument.xsl")))); QVERIFY(query.isValid()); QBuffer result; @@ -2997,7 +2997,7 @@ void tst_QXmlQuery::setInitialTemplateNameQXmlName() const QCOMPARE(query.initialTemplateName(), name); - query.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/namedTemplate.xsl")))); + query.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/namedTemplate.xsl")))); QVERIFY(query.isValid()); QBuffer result; @@ -3059,7 +3059,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const /* Ensure fn:doc() picks up the right QNetworkAccessManager. */ { NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")), - QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")))); + QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")))); QXmlQuery query; query.setNetworkAccessManager(&networkOverrider); @@ -3075,7 +3075,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const /* Ensure setQuery() is using the right network manager. */ { NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")), - QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/concat.xq")))); + QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/queries/concat.xq")))); QXmlQuery query; query.setNetworkAccessManager(&networkOverrider); @@ -3135,7 +3135,7 @@ void tst_QXmlQuery::multipleDocsAndFocus() const query.setQuery(QLatin1String("string(doc('") + inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")) + QLatin1String("'))")); - query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); query.setQuery(QLatin1String("string(.)")); QStringList result; @@ -3159,11 +3159,11 @@ void tst_QXmlQuery::multipleEvaluationsWithDifferentFocus() const QXmlQuery query; QStringList result; - query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); query.setQuery(QLatin1String("string(.)")); QVERIFY(query.evaluateTo(&result)); - query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); QVERIFY(query.evaluateTo(&result)); } -- cgit v0.12 From e5233c4fd9a6f80ec5251cb847d08d7a088301a2 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 7 May 2010 11:05:10 +0200 Subject: Fix textdrawing under GL on N900. The driver in the N900 doesn't support glCopyTexSubImage or glReadPixels for FBO's that have a GL_ALPHA or POT color attachment. The ifdef'ed code in resize() was a previous attempt to make this work which didn't. We could have changed the texture to be GL_RGBA and changed the texture size to be NPOT, but that would have wasted precious GPU memory and would have been slower, so we waste a bit of system memory instead, by having a QImage copy along with the texture. Reviewed-by: Eskil Reviewed-by: Trond --- src/gui/painting/qtextureglyphcache_p.h | 2 +- .../gl2paintengineex/qtextureglyphcache_gl.cpp | 86 ++++++++++++++-------- .../gl2paintengineex/qtextureglyphcache_gl_p.h | 5 +- 3 files changed, 60 insertions(+), 33 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index 390fe51..a818978 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -125,7 +125,7 @@ protected: }; -class QImageTextureGlyphCache : public QTextureGlyphCache +class Q_GUI_EXPORT QImageTextureGlyphCache : public QTextureGlyphCache { public: QImageTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 994c1c9..452d37d 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -42,6 +42,10 @@ #include "qtextureglyphcache_gl_p.h" #include "qpaintengineex_opengl2_p.h" +#if defined QT_OPENGL_ES_2 && !defined(QT_NO_EGL) +#include "private/qeglcontext_p.h" +#endif + QT_BEGIN_NAMESPACE #ifdef Q_WS_WIN @@ -49,12 +53,27 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled; #endif QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix) - : QTextureGlyphCache(type, matrix) + : QImageTextureGlyphCache(type, matrix) , ctx(context) , m_width(0) , m_height(0) + , m_broken_fbo_readback(false) { - glGenFramebuffers(1, &m_fbo); + // broken FBO readback is a bug in the SGX 1.3 and 1.4 drivers for the N900 where + // copying between FBO's is broken if the texture is either GL_ALPHA or POT. The + // workaround is to use a system-memory copy of the glyph cache for this device. + // Switching to NPOT and GL_RGBA would both cost a lot more graphics memory and + // be slower, so that is not desireable. +#if defined QT_OPENGL_ES_2 && !defined(QT_NO_EGL) + if (QByteArray((char*) glGetString(GL_RENDERER)).contains("SGX")) { + QGLContextPrivate *ctxd = context->d_func(); + m_broken_fbo_readback = QByteArray((char *) eglQueryString(ctxd->eglContext->display(), EGL_VERSION)).contains("1.3"); + } +#endif + + if (!m_broken_fbo_readback) + glGenFramebuffers(1, &m_fbo); + connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), SLOT(contextDestroyed(const QGLContext*))); } @@ -63,7 +82,9 @@ QGLTextureGlyphCache::~QGLTextureGlyphCache() { if (ctx) { QGLShareContextScope scope(ctx); - glDeleteFramebuffers(1, &m_fbo); + + if (!m_broken_fbo_readback) + glDeleteFramebuffers(1, &m_fbo); if (m_width || m_height) glDeleteTextures(1, &m_texture); @@ -72,6 +93,12 @@ QGLTextureGlyphCache::~QGLTextureGlyphCache() void QGLTextureGlyphCache::createTextureData(int width, int height) { + // create in QImageTextureGlyphCache baseclass is meant to be called + // only to create the initial image and does not preserve the content, + // so we don't call when this function is called from resize. + if (m_broken_fbo_readback && image().isNull()) + QImageTextureGlyphCache::createTextureData(width, height); + glGenTextures(1, &m_texture); glBindTexture(GL_TEXTURE_2D, m_texture); @@ -93,14 +120,22 @@ void QGLTextureGlyphCache::createTextureData(int width, int height) void QGLTextureGlyphCache::resizeTextureData(int width, int height) { - // ### the QTextureGlyphCache API needs to be reworked to allow - // ### resizeTextureData to fail - int oldWidth = m_width; int oldHeight = m_height; GLuint oldTexture = m_texture; createTextureData(width, height); + + if (m_broken_fbo_readback) { + QImageTextureGlyphCache::resizeTextureData(width, height); + Q_ASSERT(image().depth() == 8); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, image().constBits()); + glDeleteTextures(1, &oldTexture); + return; + } + + // ### the QTextureGlyphCache API needs to be reworked to allow + // ### resizeTextureData to fail glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo); @@ -159,20 +194,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glBindTexture(GL_TEXTURE_2D, m_texture); -#ifdef QT_OPENGL_ES_2 - QDataBuffer buffer(4*oldWidth*oldHeight); - buffer.resize(4*oldWidth*oldHeight); - glReadPixels(0, 0, oldWidth, oldHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data()); - - // do an in-place conversion from GL_RGBA to GL_ALPHA - for (int i=0; i Date: Thu, 6 May 2010 21:09:50 +0200 Subject: Fix crash with stylesheet if widget change style in the changeEvent The problem appeared with KLineEdit and its proxy style. When setting a stylesheet, we create a QStyleSheetStyle in 9# and set it to the widget, which receive a changeEvent, that will set again the style so 3# will create a new QStyleSheetStyle with the new proxy. and set it. in 2# we will dereference the 'old' QStyleSheetStyle (the one created in #9) that will destroy it. Then, later in #7, we will still access that style ('newStyle') and we crash 0# QStyleSheetStyle::~QStyleSheetStyle() 1# QStyleSheetStyle::deref() 2# QWidgetPrivate::setStyle_helper(QStyle*, bool, bool) 3# QWidget::setStyle(QStyle*) (qwidget.cpp:2523) 4# ChangeEventWidget::changeEvent(QEvent*) [...] 6# QCoreApplication::sendEvent(QObject*, QEvent*) 7# QWidgetPrivate::setStyle_helper(QStyle*, bool, bool) 9# QWidget::setStyleSheet(QString const&) (qwidget.cpp:2470) The solution is to change the order, and do not use 'newstyle' after we sent the event. The origStyle is now protected wy a QWeakPointer, but this is just for safety reason and not related to the crash. Reviewed-by: JBache --- src/gui/kernel/qwidget.cpp | 20 +++++++------- .../auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 31 +++++++++++++++++++++- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 20d1d30..be0a8a0 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2535,7 +2535,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool Q_Q(QWidget); QStyle *oldStyle = q->style(); #ifndef QT_NO_STYLE_STYLESHEET - QStyle *origStyle = 0; + QWeakPointer origStyle; #endif #ifdef Q_WS_MAC @@ -2549,7 +2549,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool createExtra(); #ifndef QT_NO_STYLE_STYLESHEET - origStyle = extra->style; + origStyle = extra->style.data(); #endif extra->style = newStyle; } @@ -2578,23 +2578,23 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool } } - QEvent e(QEvent::StyleChange); - QApplication::sendEvent(q, &e); -#ifdef QT3_SUPPORT - q->styleChange(*oldStyle); -#endif - #ifndef QT_NO_STYLE_STYLESHEET if (!qobject_cast(newStyle)) { - if (const QStyleSheetStyle* cssStyle = qobject_cast(origStyle)) { + if (const QStyleSheetStyle* cssStyle = qobject_cast(origStyle.data())) { cssStyle->clearWidgetFont(q); } } #endif + QEvent e(QEvent::StyleChange); + QApplication::sendEvent(q, &e); +#ifdef QT3_SUPPORT + q->styleChange(*oldStyle); +#endif + #ifndef QT_NO_STYLE_STYLESHEET // dereference the old stylesheet style - if (QStyleSheetStyle *proxy = qobject_cast(origStyle)) + if (QStyleSheetStyle *proxy = qobject_cast(origStyle.data())) proxy->deref(); #endif } diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index e0512a9..e370309 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -98,6 +98,7 @@ private slots: void complexWidgetFocus(); void task188195_baseBackground(); void task232085_spinBoxLineEditBg(); + void changeStyleInChangeEvent(); //at the end because it mess with the style. void widgetStyle(); @@ -1256,7 +1257,7 @@ void tst_QStyleSheetStyle::proxyStyle() QStyleOptionViewItemV4 opt; opt.initFrom(w); opt.features |= QStyleOptionViewItemV2::HasCheckIndicator; - QVERIFY(pb5->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, + QVERIFY(pb5->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &opt, pb5).width() == 3); delete w; delete proxy; @@ -1579,6 +1580,34 @@ void tst_QStyleSheetStyle::task232085_spinBoxLineEditBg() .toLocal8Bit().constData()); } +class ChangeEventWidget : public QWidget +{ public: + void changeEvent(QEvent * event) + { + if(event->type() == QEvent::StyleChange) { + static bool recurse = false; + if (!recurse) { + recurse = true; + QStyle *style = new QMotifStyle; + style->setParent(this); + setStyle(style); + recurse = false; + } + } + QWidget::changeEvent(event); + } +}; + +void tst_QStyleSheetStyle::changeStyleInChangeEvent() +{ //must not crash; + ChangeEventWidget wid; + wid.ensurePolished(); + wid.setStyleSheet(" /* */ "); + wid.ensurePolished(); + wid.setStyleSheet(" /* ** */ "); + wid.ensurePolished(); +} + QTEST_MAIN(tst_QStyleSheetStyle) #include "tst_qstylesheetstyle.moc" -- cgit v0.12 From 1e91d6b79cba488fa5c6f7d954de611903837f76 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Fri, 7 May 2010 11:45:00 +0200 Subject: Making network reconnect happen after teardown. When the network connection teardown happens we get notification on except FD. As advised from Open C team we will use setdefaultif(0) to kill all existing sockets and restart default IAP. Task-number: QT-3284 Reviewed-by: Janne Anttila --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index c85d1be..dea2f44 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -47,6 +47,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS @@ -569,13 +571,15 @@ void QSelectThread::updateActivatedNotifiers(QSocketNotifier::Type type, fd_set * check if socket is in exception set * then signal RequestComplete for it */ - qWarning("exception on %d [will close the socket handle - hack]", i.key()->socket()); + qWarning("exception on %d [will do setdefaultif(0) - hack]", i.key()->socket()); // quick fix; there is a bug // when doing read on socket // errors not preoperly mapped // after offline-ing the device // on some devices we do get exception - ::close(i.key()->socket()); + // close all exiting sockets + // and reset default IAP + ::setdefaultif(0); toRemove.append(i.key()); TRequestStatus *status = i.value(); QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); -- cgit v0.12 From 070a3dbbb368f3e1b817a5ecff15127302458e7a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 7 May 2010 11:54:47 +0200 Subject: Add some debugging (disabled) to QUrl::resolved --- src/corelib/io/qurl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 67119b5..d6ded9d 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5557,6 +5557,12 @@ QUrl QUrl::resolved(const QUrl &relative) const removeDotsFromPath(&t.d->encodedPath); t.d->path.clear(); +#if defined(QURL_DEBUG) + qDebug("QUrl(\"%s\").resolved(\"%s\") = \"%s\"", + toEncoded().constData(), + relative.toEncoded().constData(), + t.toEncoded().constData()); +#endif return t; } -- cgit v0.12 From 0b56799601690a747c42dfbbefe95f18e837eb3f Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Fri, 7 May 2010 12:06:37 +0200 Subject: Adding some error checking for setdefaultif Task-number: QT-3284 Reviewed-by: TrustMe --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index dea2f44..6448b06 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -579,7 +579,9 @@ void QSelectThread::updateActivatedNotifiers(QSocketNotifier::Type type, fd_set // on some devices we do get exception // close all exiting sockets // and reset default IAP - ::setdefaultif(0); + if(::setdefaultif(0) != KErrNone) // well we can't do much about it + qWarning("setdefaultif(0) failed"); + toRemove.append(i.key()); TRequestStatus *status = i.value(); QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); -- cgit v0.12 From 91337cb62bca653c9df7e8b8f43f451facc1efb8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 7 May 2010 11:56:50 +0200 Subject: QtDeclarative: RFC 3986 requires schemes to be considered case-insensitively Reviewed-By: Alan Alpert --- src/declarative/qml/qdeclarativecompositetypemanager.cpp | 2 +- src/declarative/qml/qdeclarativeengine.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp index 0eb7e1b..b0c9a43 100644 --- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp +++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp @@ -338,7 +338,7 @@ void QDeclarativeCompositeTypeManager::resourceReplyFinished() // WARNING, there is a copy of this function in qdeclarativeengine.cpp static QString toLocalFileOrQrc(const QUrl& url) { - if (url.scheme() == QLatin1String("qrc")) { + if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) { if (url.authority().isEmpty()) return QLatin1Char(':') + url.path(); return QString(); diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 0ee6dfe..1387432 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1526,7 +1526,7 @@ QVariant QDeclarativeEnginePrivate::scriptValueToVariant(const QScriptValue &val // WARNING, there is a copy of this function in qdeclarativecompositetypemanager.cpp static QString toLocalFileOrQrc(const QUrl& url) { - if (url.scheme() == QLatin1String("qrc")) { + if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) { if (url.authority().isEmpty()) return QLatin1Char(':') + url.path(); return QString(); -- cgit v0.12 From 694822cbe757f2b742740f593319337127b04d17 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 7 May 2010 11:59:06 +0200 Subject: QtDeclarative: avoid waiting for a network load on URIs with empty schemes. The proper fix would be to have QNetworkAccessManager notify immediately that this load cannot work (and it knows it can't work). Then QtDeclarative can simply check what QNAM found. Reviewed-By: Alan Alpert --- .../qml/qdeclarativecompositetypemanager.cpp | 37 +++++++++++++--------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp index b0c9a43..625356c 100644 --- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp +++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp @@ -360,7 +360,10 @@ void QDeclarativeCompositeTypeManager::loadResource(QDeclarativeCompositeTypeRes } else { resource->status = QDeclarativeCompositeTypeResource::Error; } + } else if (url.scheme().isEmpty()) { + // We can't open this, so just declare as an error + resource->status = QDeclarativeCompositeTypeResource::Error; } else { QNetworkReply *reply = @@ -382,27 +385,29 @@ void QDeclarativeCompositeTypeManager::loadSource(QDeclarativeCompositeTypeData if (file.open(QFile::ReadOnly)) { QByteArray data = file.readAll(); setData(unit, data, url); - } else { - QString errorDescription; - // ### - Fill in error - errorDescription = QLatin1String("File error for URL ") + url.toString(); - unit->status = QDeclarativeCompositeTypeData::Error; - // ### FIXME - QDeclarativeError error; - error.setDescription(errorDescription); - unit->errorType = QDeclarativeCompositeTypeData::AccessError; - unit->errors << error; - doComplete(unit); + return; // success } - - } else { + } else if (!url.scheme().isEmpty()) { QNetworkReply *reply = engine->networkAccessManager()->get(QNetworkRequest(url)); QObject::connect(reply, SIGNAL(finished()), this, SLOT(replyFinished())); QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(requestProgress(qint64,qint64))); + return; // waiting } + + // error happened + QString errorDescription; + // ### - Fill in error + errorDescription = QLatin1String("File error for URL ") + url.toString(); + unit->status = QDeclarativeCompositeTypeData::Error; + // ### FIXME + QDeclarativeError error; + error.setDescription(errorDescription); + unit->errorType = QDeclarativeCompositeTypeData::AccessError; + unit->errors << error; + doComplete(unit); } void QDeclarativeCompositeTypeManager::requestProgress(qint64 received, qint64 total) @@ -724,8 +729,10 @@ void QDeclarativeCompositeTypeManager::compile(QDeclarativeCompositeTypeData *un } } - QUrl importUrl = unit->imports.baseUrl().resolved(QUrl(QLatin1String("qmldir"))); - if (toLocalFileOrQrc(importUrl).isEmpty()) + QUrl importUrl; + if (!unit->imports.baseUrl().scheme().isEmpty()) + importUrl = unit->imports.baseUrl().resolved(QUrl(QLatin1String("qmldir"))); + if (!importUrl.scheme().isEmpty() && toLocalFileOrQrc(importUrl).isEmpty()) resourceList.prepend(importUrl); for (int ii = 0; ii < resourceList.count(); ++ii) { -- cgit v0.12 From 7a33db368c6debf9668b1c11885ed2329c35e200 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 7 May 2010 12:31:33 +0200 Subject: Windows CE: fix multiple QAction::triggered() signals Adding the same menu action object to n menu bars resulted in n QAction::triggered() signals. Now, we're comparing the active window with the parent HWND of the menu bar before triggering. Task-number: QTBUG-10402 Reviewed-by: thartman --- src/gui/kernel/qapplication_win.cpp | 2 +- src/gui/widgets/qmenu.h | 2 +- src/gui/widgets/qmenu_p.h | 2 +- src/gui/widgets/qmenu_wince.cpp | 31 ++++++++++++++++++------------- src/gui/widgets/qmenubar.h | 2 +- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 49cb0f2..6c30a4a 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -2447,7 +2447,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam QApplication::postEvent(widget, new QEvent(QEvent::Close)); else #ifndef QT_NO_MENUBAR - QMenuBar::wceCommands(LOWORD(wParam), (HWND) lParam); + QMenuBar::wceCommands(LOWORD(wParam)); #endif result = true; } diff --git a/src/gui/widgets/qmenu.h b/src/gui/widgets/qmenu.h index 47dff2b..2b41515 100644 --- a/src/gui/widgets/qmenu.h +++ b/src/gui/widgets/qmenu.h @@ -142,7 +142,7 @@ public: #endif #ifdef Q_WS_WINCE - HMENU wceMenu(bool create = false); + HMENU wceMenu(); #endif bool separatorsCollapsible() const; diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index 495872c..f330686 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -358,7 +358,7 @@ public: return 0; } } *wce_menu; - HMENU wceMenu(bool create = false); + HMENU wceMenu(); QAction* wceCommands(uint command); #endif #if defined(Q_WS_S60) diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp index 37ff4c4..e088db6 100644 --- a/src/gui/widgets/qmenu_wince.cpp +++ b/src/gui/widgets/qmenu_wince.cpp @@ -126,6 +126,7 @@ static void qt_wce_enable_soft_key(HWND handle, uint command) if (ptrEnableSoftKey) ptrEnableSoftKey(handle, command, false, true); } + static void qt_wce_disable_soft_key(HWND handle, uint command) { resolveAygLibs(); @@ -232,7 +233,7 @@ static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, i return 0; } -static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action, bool created) +static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action) { Q_ASSERT_X(menu, "AppendMenu", "menu is 0"); if (action->action->isVisible()) { @@ -247,7 +248,7 @@ static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action, bool create else if (action->action->menu()) { text.remove(QChar::fromLatin1('&')); AppendMenu (menu, MF_STRING | flags | MF_POPUP, - (UINT) action->action->menu()->wceMenu(created), reinterpret_cast (text.utf16())); + (UINT) action->action->menu()->wceMenu(), reinterpret_cast (text.utf16())); } else { AppendMenu (menu, MF_STRING | flags, action->command, reinterpret_cast (text.utf16())); @@ -302,10 +303,14 @@ QAction* QMenu::wceCommands(uint command) and all their child menus. */ -void QMenuBar::wceCommands(uint command, HWND) +void QMenuBar::wceCommands(uint command) { - for (int i = 0; i < nativeMenuBars.size(); ++i) - nativeMenuBars.at(i)->d_func()->wceCommands(command); + const HWND hwndActiveWindow = GetActiveWindow(); + for (int i = 0; i < nativeMenuBars.size(); ++i) { + QMenuBarPrivate* nativeMenuBar = nativeMenuBars.at(i)->d_func(); + if (hwndActiveWindow == nativeMenuBar->wce_menubar->parentWindowHandle) + nativeMenuBar->wceCommands(command); + } } bool QMenuBarPrivate::wceEmitSignals(QList actions, uint command) @@ -460,16 +465,16 @@ void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAc Windows CE menu bar bindings. */ -HMENU QMenu::wceMenu(bool create) +HMENU QMenu::wceMenu() { - return d_func()->wceMenu(create); + return d_func()->wceMenu(); } -HMENU QMenuPrivate::wceMenu(bool create) +HMENU QMenuPrivate::wceMenu() { if (!wce_menu) wce_menu = new QWceMenuPrivate; - if (!wce_menu->menuHandle || create) + if (!wce_menu->menuHandle) wce_menu->rebuild(); return wce_menu->menuHandle; } @@ -484,7 +489,7 @@ void QMenuPrivate::QWceMenuPrivate::rebuild() for (int i = 0; i < actionItems.size(); ++i) { QWceMenuAction *action = actionItems.at(i); action->menuHandle = menuHandle; - qt_wce_insert_action(menuHandle, action, true); + qt_wce_insert_action(menuHandle, action); } QMenuBar::wceRefresh(); } @@ -589,7 +594,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() action->command = qt_wce_menu_static_cmd_id++; action->menuHandle = subMenuHandle; actionItemsClassic.last().append(action); - qt_wce_insert_action(subMenuHandle, action, true); + qt_wce_insert_action(subMenuHandle, action); } } for (int i = actions.size();imenuHandle = menuHandle; - qt_wce_insert_action(menuHandle, action, true); + qt_wce_insert_action(menuHandle, action); } if (!leftButtonIsMenu) { if (leftButtonAction) { @@ -652,7 +657,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() action->command = qt_wce_menu_static_cmd_id++; action->menuHandle = leftButtonMenuHandle; actionItemsLeftButton.append(action); - qt_wce_insert_action(leftButtonMenuHandle, action, true); + qt_wce_insert_action(leftButtonMenuHandle, action); } } } diff --git a/src/gui/widgets/qmenubar.h b/src/gui/widgets/qmenubar.h index 85c0988..c63a4f5 100644 --- a/src/gui/widgets/qmenubar.h +++ b/src/gui/widgets/qmenubar.h @@ -115,7 +115,7 @@ public: void setDefaultAction(QAction *); QAction *defaultAction() const; - static void wceCommands(uint command, HWND controlHandle); + static void wceCommands(uint command); static void wceRefresh(); #endif -- cgit v0.12 From 2f9f59d7a33a7cfa5fe2127d726706f10842ca53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 7 May 2010 12:03:12 +0200 Subject: Fixed source pixmap bug in widget graphics effect backend. The source pixmap shouldn't include the window background, as the graphics effect might then overwrite other widgets. Reviewed-by: Jens Bache-Wiig --- src/gui/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index be0a8a0..5d08d4b 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5628,7 +5628,7 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint * QPixmap pixmap(effectRect.size()); pixmap.fill(Qt::transparent); - m_widget->render(&pixmap, pixmapOffset); + m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren); return pixmap; } #endif //QT_NO_GRAPHICSEFFECT -- cgit v0.12 From 165fe7bdd7958cec3ec6c17f9ca15d92f30a4672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 7 May 2010 12:40:10 +0200 Subject: Fixed scrolling bugs in widget graphics effect backend. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cache wasn't invalidated for widgets with a graphics effect inside a scrolling QScrollArea, so for now we disable caching for widget source pixmaps. Also, we can't clip the source pixmap to device coordinates since there's no knowledge of which areas of the source pixmap the effect uses to compute the visible pixels. See change fd30cc9fabe6fc023 for the graphics item effect backend fix. Reviewed-by: Bjørn Erik Nilsen --- src/gui/effects/qgraphicseffect.cpp | 2 +- src/gui/kernel/qwidget.cpp | 35 +++-------------------------------- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index ce4ce6a..5e4e49e 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -326,7 +326,7 @@ QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offse } QPixmap pm; - if (d->m_cachedSystem == system && d->m_cachedMode == mode) + if (item && d->m_cachedSystem == system && d->m_cachedMode == mode) QPixmapCache::find(d->m_cacheKey, &pm); if (pm.isNull()) { diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 5d08d4b..c058280 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5583,47 +5583,18 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint * pixmapOffset = painterTransform.map(pixmapOffset); } - QRect effectRect; - if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { + if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); - - } else if (mode == QGraphicsEffect::PadToTransparentBorder) { + else if (mode == QGraphicsEffect::PadToTransparentBorder) effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); - - } else { + else effectRect = sourceRect.toAlignedRect(); - } - if (offset) *offset = effectRect.topLeft(); - if (deviceCoordinates) { - // Clip to device rect. - int left, top, right, bottom; - effectRect.getCoords(&left, &top, &right, &bottom); - if (left < 0) { - if (offset) - offset->rx() += -left; - effectRect.setX(0); - } - if (top < 0) { - if (offset) - offset->ry() += -top; - effectRect.setY(0); - } - // NB! We use +-1 for historical reasons (see QRect documentation). - QPaintDevice *device = context->painter->device(); - const int deviceWidth = device->width(); - const int deviceHeight = device->height(); - if (right + 1 > deviceWidth) - effectRect.setRight(deviceWidth - 1); - if (bottom + 1 > deviceHeight) - effectRect.setBottom(deviceHeight -1); - } - pixmapOffset -= effectRect.topLeft(); QPixmap pixmap(effectRect.size()); -- cgit v0.12 From 14fdf300795032b21fe51a256b5b22d3c14ca301 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Fri, 7 May 2010 13:20:14 +0200 Subject: Doc: Chages to search feature, css and table order Changes the search results Fixed table css Added odd&even classes to tables generated by the thmlgenerator Reviewed-by: Morten Engvoldsen --- doc/src/template/scripts/functions.js | 7 ++-- doc/src/template/style/style.css | 29 ++++++++++++++--- tools/qdoc3/htmlgenerator.cpp | 60 ++++++++++++++++++++++++++++------- 3 files changed, 78 insertions(+), 18 deletions(-) diff --git a/doc/src/template/scripts/functions.js b/doc/src/template/scripts/functions.js index 4b3107f..306b628 100755 --- a/doc/src/template/scripts/functions.js +++ b/doc/src/template/scripts/functions.js @@ -83,9 +83,9 @@ function processNokiaData(response){ } } - if(lookupCount == 0){$('#ul001').prepend('
  • no result
  • ');$('#ul001 li').css('display','block');} - if(articleCount == 0){$('#ul002').prepend('
  • no result
  • ');$('#ul002 li').css('display','block');} - if(exampleCount == 0){$('#ul003').prepend('
  • no result
  • ');$('#ul003 li').css('display','block');} + if(lookupCount == 0){$('#ul001').prepend('
  • Found no result
  • ');$('#ul001 li').css('display','block');} + if(articleCount == 0){$('#ul002').prepend('
  • Found no result
  • ');$('#ul002 li').css('display','block');} + if(exampleCount == 0){$('#ul003').prepend('
  • Found no result
  • ');$('#ul003 li').css('display','block');} // reset count variables; lookupCount=0; articleCount = 0; @@ -97,6 +97,7 @@ function processNokiaData(response){ var blankRE=/^\s*$/; function CheckEmptyAndLoadList() { + $('.liveResult').remove(); var value = document.getElementById('pageType').value; if((blankRE.test(value)) || (value.length < 3)) { diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index 6bcb0db..644e56b 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -460,12 +460,12 @@ padding-left: 12px; background: url(../images/bullet_sq.png) no-repeat 0 5px; font: normal 400 10pt/1 Verdana; - color: #44a51c; + /* color: #44a51c;*/ margin-bottom: 10px; } .content li:hover { - text-decoration: underline; + /* text-decoration: underline;*/ } .offline .wrap .content @@ -747,11 +747,23 @@ th { padding: 5px 15px 5px 15px; + background-color: #E1E1E1; + border-bottom: 1px solid #E6E6E6; + border-left: 1px solid #E6E6E6; + border-right: 1px solid #E6E6E6; } td { padding: 3px 15px 3px 20px; + border-left: 1px solid #E6E6E6; + border-right: 1px solid #E6E6E6; + } + tr.odd td:hover, tr.even td:hover + { + /* border-right: 1px solid #C3C3C3; + border-left: 1px solid #C3C3C3;*/ } + td.rightAlign { padding: 3px 15px 3px 10px; @@ -879,13 +891,22 @@ font: 600 12px/1.2 Arial; } - .generic{} + .generic{ + max-width:100%; + } + .generic td{ + padding:0; + } + .alignedsummary{} .propsummary{} .memItemLeft{} .memItemRight{} .bottomAlign{} - .highlightedCode{} + .highlightedCode + { + margin:10px; + } .LegaleseLeft{} .valuelist{} .annotated{} diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 93b0218..6560b68 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -912,8 +912,14 @@ int HtmlGenerator::generateAtom(const Atom *atom, else if (atom->string() == ATOM_LIST_VALUE) { threeColumnEnumValueTable = isThreeColumnEnumValueTable(atom); if (threeColumnEnumValueTable) { - out() << "" - << "" + out() << "
    Constant
    "; + // << "" + if (++numTableRows % 2 == 1) + out() << ""; + else + out() << ""; + + out() << "" << "" << "\n"; } @@ -1093,7 +1099,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, } if (!atom->string().isEmpty()) { if (atom->string().contains("%")) - out() << "
    ConstantValueDescription
    string() << "\">\n "; + out() << "
    \n "; // width=\"" << atom->string() << "\">\n "; else { out() << "
    \n"; } @@ -2456,7 +2462,13 @@ void HtmlGenerator::generateCompactList(const Node *relative, out() << "
    \n"; for (k = 0; k < numRows; k++) { - out() << "\n"; + if (++numTableRows % 2 == 1) + out() << ""; + else + out() << ""; + //break; + +// out() << "\n"; for (i = 0; i < NumColumns; i++) { if (currentOffset[i] >= firstOffset[i + 1]) { // this column is finished @@ -3159,8 +3171,13 @@ void HtmlGenerator::generateSectionList(const Section& section, twoColumn = (section.members.count() >= 5); } if (twoColumn) - out() << "
    \n" - << "
    "; + out() << "\n"; + if (++numTableRows % 2 == 1) + out() << ""; + else + out() << ""; + +// << "
    "; out() << "
      \n"; int i = 0; @@ -4367,8 +4384,12 @@ void HtmlGenerator::generateQmlSummary(const Section& section, twoColumn = (count >= 5); } if (twoColumn) - out() << "\n" - << "
      "; + out() << "\n"; + if (++numTableRows % 2 == 1) + out() << ""; + else + out() << ""; + // << ""; + else + out() << ""; + + out() << "
      "; out() << "
        \n"; int row = 0; @@ -4410,7 +4431,14 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, while (p != qpgn->childNodes().end()) { if ((*p)->type() == Node::QmlProperty) { qpn = static_cast(*p); - out() << "
      "; + + if (++numTableRows % 2 == 1) + out() << "
      "; + //out() << "
      "; // old out() << ""; if (!qpn->isWritable()) out() << "read-only"; @@ -4436,7 +4464,12 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, const FunctionNode* qsn = static_cast(node); out() << "
      "; out() << ""; - out() << ""; + if (++numTableRows % 2 == 1) + out() << ""; + else + out() << ""; + out() << ""; else out() << ""; - out() << ""; + out() << "

      "; out() << "
      "; + //out() << "
      "; out() << ""; generateSynopsis(qsn,relative,marker,CodeMarker::Detailed,false); //generateQmlItem(qsn,relative,marker,false); @@ -4448,7 +4481,12 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, const FunctionNode* qmn = static_cast(node); out() << "
      "; out() << ""; - out() << ""; + if (++numTableRows % 2 == 1) + out() << ""; + else + out() << ""; + out() << ""; -- cgit v0.12 From cafffc1b161a5b5f2f856c626e8ad2ee50d5d1e1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 7 May 2010 13:45:12 +0200 Subject: fix tst_QDockWidget::taskQTBUG_9758_undockedGeometry on Linux --- tests/auto/qdockwidget/tst_qdockwidget.cpp | 31 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp index 8d9e7bbf..3ac0ce7 100644 --- a/tests/auto/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp @@ -654,7 +654,7 @@ void tst_QDockWidget::dockLocationChanged() QCOMPARE(qvariant_cast(spy.at(0).at(0)), Qt::TopDockWidgetArea); spy.clear(); - + dw.setFloating(true); QTest::qWait(100); dw.setFloating(false); @@ -881,20 +881,21 @@ void tst_QDockWidget::taskQTBUG_1665_closableChanged() void tst_QDockWidget::taskQTBUG_9758_undockedGeometry() { - QMainWindow window; - QDockWidget dock1(&window); - QDockWidget dock2(&window); - window.addDockWidget(Qt::RightDockWidgetArea, &dock1); - window.addDockWidget(Qt::RightDockWidgetArea, &dock2); - window.tabifyDockWidget(&dock1, &dock2); - dock1.hide(); - dock2.hide(); - window.show(); - dock1.setFloating(true); - dock1.show(); - - QVERIFY(dock1.x() >= 0); - QVERIFY(dock1.y() >= 0); + QMainWindow window; + QDockWidget dock1(&window); + QDockWidget dock2(&window); + window.addDockWidget(Qt::RightDockWidgetArea, &dock1); + window.addDockWidget(Qt::RightDockWidgetArea, &dock2); + window.tabifyDockWidget(&dock1, &dock2); + dock1.hide(); + dock2.hide(); + window.show(); + dock1.setFloating(true); + dock1.show(); + QTest::qWaitForWindowShown(&dock1); + + QVERIFY(dock1.x() >= 0); + QVERIFY(dock1.y() >= 0); } -- cgit v0.12 From 137e196dc1ae2364265e7c1eb79c880120a79bb9 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 7 May 2010 13:45:39 +0200 Subject: qdoc: Reorganized examples panel. --- doc/src/declarative/examples.qdoc | 5 +- doc/src/getting-started/examples.qdoc | 92 ++++++++++++++++++++++++++++- tools/qdoc3/test/qt-html-templates.qdocconf | 18 +++--- 3 files changed, 103 insertions(+), 12 deletions(-) diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index e01459f..481617e 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -40,8 +40,9 @@ ****************************************************************************/ /*! -\page qdeclarativeexamples.html -\title QML Examples and Demos + \page qdeclarativeexamples.html + \title QML Examples and Demos + \ingroup all-examples \previouspage Graphics View Examples \contentspage Qt Examples diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index 542f672..0088817 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -50,6 +50,39 @@ */ /*! + \group all-examples + \title Qt Examples + + Qt includes a set of examples that cover nearly every aspect of Qt + development. They aren't meant to be impressive when you run them, + but in each case the source code has been carefully written to + illustrate one or more best Qt programming practices. + + You can run the examples from the \l{Examples and Demos Launcher} + application (except see \l{QML Examples and Demos} {QML Examples} + for special instructions for running thos examples). + + The examples are listed below by functional area. Each example + listed in a particular functional area is meant to illustrate how + best to use Qt to do some particular task in that functional area, + but the examples will often use features from other functional + areas as well for completeness. + + If you are new to Qt, you should probably start by going through + the \l{Tutorials}, and then begin with the + \l{mainwindows/application} {Application} example. + + In addition to these examples and the \l{Tutorials}{tutorials}, Qt + includes a \l{Qt Demonstrations}{selection of demos} that + deliberately show off Qt's features. You might want to look at + these as well. + + \section1 Examples by functional area + + \generatelist{related} +*/ + +/*! \page examples.html \title Qt Examples \brief The example programs provided with Qt. @@ -459,8 +492,18 @@ */ /*! + \group gui-examples + \title GUI Examples + \brief These pages list examples of constructing GUI components. + + \generatelist{related} +*/ + +/*! \page examples-widgets.html \title Widgets Examples + \ingroup all-examples + \ingroup gui-examples \contentspage Qt Examples \nextpage Dialog Examples @@ -509,7 +552,9 @@ /*! \page examples-dialogs.html + \ingroup all-examples \title Dialog Examples + \ingroup gui-examples \previouspage Widgets Examples \contentspage Qt Examples @@ -539,7 +584,9 @@ /*! \page examples-mainwindow.html + \ingroup all-examples \title Main Window Examples + \ingroup gui-examples \previouspage Dialog Examples \contentspage Qt Examples @@ -567,7 +614,9 @@ /*! \page examples-layouts.html + \ingroup all-examples \title Layout Examples + \ingroup gui-examples \previouspage Main Window Examples \contentspage Qt Examples @@ -594,6 +643,7 @@ /*! \page examples-itemviews.html + \ingroup all-examples \title Item Views Examples \previouspage Layout Examples @@ -631,8 +681,18 @@ */ /*! + \group graphics-examples + \title Graphics Examples + \brief These pages list examples of doing graphics. + + \generatelist{related} +*/ + +/*! \page examples-graphicsview.html + \ingroup all-examples \title Graphics View Examples + \ingroup graphics-examples \previouspage Item Views Examples \contentspage Qt Examples @@ -677,7 +737,9 @@ /*! \page examples-painting.html + \ingroup all-examples \title Painting Examples + \ingroup graphics-examples \previouspage QML Examples and Demos \contentspage Qt Examples @@ -709,6 +771,7 @@ /*! \page examples-richtext.html + \ingroup all-examples \title Rich Text Examples \previouspage Painting Examples @@ -732,6 +795,7 @@ /*! \page examples-desktop.html + \ingroup all-examples \title Desktop Examples \previouspage Rich Text Examples @@ -755,7 +819,9 @@ /*! \page examples-draganddrop.html + \ingroup all-examples \title Drag and Drop Examples + \ingroup gui-examples \previouspage Desktop Examples \contentspage Qt Examples @@ -783,6 +849,7 @@ /*! \page examples-threadandconcurrent.html + \ingroup all-examples \title Threading and Concurrent Programming Examples \previouspage Drag and Drop Examples @@ -823,6 +890,7 @@ /*! \page examples.tools.html + \ingroup all-examples \title Tools Examples \previouspage Threading and Concurrent Programming Examples @@ -861,6 +929,7 @@ /*! \page examples-network.html + \ingroup all-examples \title Network Examples \previouspage Tools Examples @@ -899,6 +968,7 @@ /*! \page examples-ipc.html + \ingroup all-examples \title Inter-Process Communication Examples \previouspage Network Examples @@ -916,7 +986,9 @@ /*! \page examples-opengl.html + \ingroup all-examples \title OpenGL Examples + \ingroup graphics-examples \previouspage Inter-Process Communication Examples \contentspage Qt Examples @@ -950,7 +1022,9 @@ /*! \page examples-openvg.html + \ingroup all-examples \title OpenVG Examples + \ingroup graphics-examples \previouspage OpenGL Examples \contentspage Qt Examples @@ -971,6 +1045,7 @@ /*! \page examples-multimedia.html + \ingroup all-examples \title Multimedia Examples \previouspage OpenGL Examples @@ -1020,6 +1095,7 @@ /*! \page examples-sql.html + \ingroup all-examples \title SQL Examples \previouspage Multimedia Examples @@ -1049,6 +1125,7 @@ /*! \page examples-xml.html + \ingroup all-examples \title XML Examples \previouspage SQL Examples @@ -1085,6 +1162,7 @@ /*! \page examples-designer.html + \ingroup all-examples \title Qt Designer Examples \previouspage XML Examples @@ -1110,6 +1188,7 @@ /*! \page examples-uitools.html + \ingroup all-examples \title UiTools Examples \previouspage Qt Designer Examples @@ -1126,6 +1205,7 @@ /*! \page examples-linguist.html + \ingroup all-examples \title Qt Linguist Examples \previouspage UiTools Examples @@ -1146,6 +1226,7 @@ /*! \page examples-script.html + \ingroup all-examples \title Qt Script Examples \previouspage Qt Linguist Examples @@ -1175,6 +1256,7 @@ /*! \page examples-webkit.html + \ingroup all-examples \title WebKit Examples \previouspage Qt Script Examples @@ -1215,7 +1297,8 @@ */ /*! - \page examples-helpsystem.html + \page examples-helpsystem.html + \ingroup all-examples \title Help System Examples \previouspage WebKit Examples @@ -1239,6 +1322,7 @@ /*! \page examples-statemachine.html + \ingroup all-examples \title State Machine Examples \previouspage Help System Examples @@ -1265,6 +1349,7 @@ /*! \page examples-animation.html + \ingroup all-examples \title Animation Framework Examples \previouspage State Machine Examples @@ -1287,6 +1372,7 @@ /*! \page examples-multitouch.html + \ingroup all-examples \title Multi-Touch Examples \previouspage Animation Framework Examples @@ -1306,6 +1392,7 @@ /*! \page examples-gestures.html + \ingroup all-examples \title Gestures Examples \previouspage Multi-Touch Examples @@ -1322,6 +1409,7 @@ /*! \page examples-dbus.html + \ingroup all-examples \title D-Bus Examples \previouspage Gestures Examples @@ -1341,6 +1429,7 @@ /*! \page examples-embeddedlinux.html + \ingroup all-examples \title Qt for Embedded Linux Examples \previouspage D-Bus Examples @@ -1363,6 +1452,7 @@ /*! \page examples-activeqt.html + \ingroup all-examples \title ActiveQt Examples \previouspage Qt for Embedded Linux Examples diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 8b007db..b94bb81 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -44,10 +44,10 @@ HTML.postheader = "
      \n" \ " \n" \ "
      \n" \ "
      \n" \ @@ -62,7 +62,7 @@ HTML.postheader = "
      \n" \ "
    • Painting & Graphics
    • \n" \ "
    • GUI Components
    • \n" \ "
    • Qt Quick
    • \n" \ - "
    • Platform specifics
    • \n" \ + "
    • Platform specific
    • \n" \ " \n" \ "
      \n" \ "
      \n" \ @@ -70,14 +70,14 @@ HTML.postheader = "
      \n" \ "
      \n" \ "
      \n" \ "

      \n" \ - " API Examples

      \n" \ + " Qt Examples\n" \ "
      \n" \ " \n" \ "
      \n" \ "
      \n" \ -- cgit v0.12 From 7af5c4c01207960a23a349a55372ca7ecd8824f4 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Fri, 7 May 2010 14:03:45 +0200 Subject: Doc: Tuning search script Reviewed-by: Morten Engvoldsen --- doc/src/template/scripts/functions.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/src/template/scripts/functions.js b/doc/src/template/scripts/functions.js index 306b628..108590f 100755 --- a/doc/src/template/scripts/functions.js +++ b/doc/src/template/scripts/functions.js @@ -48,37 +48,37 @@ function processNokiaData(response){ var linkEnd = ""; if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'APIPage'){ - lookupCount=0; + lookupCount++; //$('.live001').css('display','block'); for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; full_li_element = full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd; - $('#ul001').prepend(full_li_element); + $('#ul001').append(full_li_element); } } if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Article'){ - articleCount = 0; + articleCount++; //$('.live002').css('display','block'); for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ; - $('#ul002').prepend(full_li_element); + $('#ul002').append(full_li_element); } } if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Example'){ - exampleCount = 0; + exampleCount++; //$('.live003').css('display','block'); for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ; - $('#ul003').prepend(full_li_element); + $('#ul003').append(full_li_element); } } } -- cgit v0.12 From 011620f153b6115ba3bde672ee90fce69d771a59 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 7 May 2010 14:14:36 +0200 Subject: qdoc: Fixed annotated list generation to use
      "; else out() << ""; - out() << ""; if (!(node->type() == Node::Fake)) { Text brief = node->doc().trimmedBriefText(name); -- cgit v0.12 From a671c8442d1024e6fd842c05b35ad682a48de76d Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 7 May 2010 15:24:34 +0300 Subject: QS60Style: When context menu is open ToolButton is not pressed down QS60Style prefers to use widget and calls its down() API. The value is not true unless tool button has been set down programmatically. Thus, we should rely on State_Sunken as well. As a fix, style asks from both the widget and checks the state before drawing button raised/pressed. Task-number: QTBUG-10487 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index a0e8496..326335a 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1121,11 +1121,9 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom tool.rect = button.unite(menuRect); tool.state = bflags; const QToolButton *toolButtonWidget = qobject_cast(widget); - QS60StylePrivate::SkinElements element; - if (toolButtonWidget) - element = (toolButtonWidget->isDown()) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; - else - element = (option->state & State_Sunken) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; + const QS60StylePrivate::SkinElements element = + ((toolButtonWidget && toolButtonWidget->isDown()) || (option->state & State_Sunken)) ? + QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; QS60StylePrivate::drawSkinElement(element, painter, tool.rect, flags); drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); } -- cgit v0.12 From 039d232a13b128ae01cda0e5572edf7474983641 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 7 May 2010 15:39:58 +0300 Subject: QS60Style - PushButton with text and with icon should be of same size When pushbutton contains standardIcon or non-modified text, it should be of same size. As a fix, style now checking default text height for icon pushbuttons and if the icon is smaller than text height, style will make button to match text height content. Task-number: QT-2179 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 326335a..56d52b1 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2508,7 +2508,7 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); const int iconHeight = (!buttonWidget->icon().isNull()) ? buttonWidget->iconSize().height() : 0; const int textHeight = (buttonWidget->text().length() > 0) ? - buttonWidget->fontMetrics().size(Qt::TextSingleLine, buttonWidget->text()).height() : 0; + buttonWidget->fontMetrics().size(Qt::TextSingleLine, buttonWidget->text()).height() : opt->fontMetrics.height(); const int decoratorHeight = (buttonWidget->isCheckable()) ? pixelMetric(PM_IndicatorHeight) : 0; const int contentHeight = -- cgit v0.12 From a8c89b5d316ca8215611048f79d330a0c604ad27 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 7 May 2010 16:19:03 +0300 Subject: QS60Style: Housekeeping task Fix whitespace, remove unneeded code, break very long lines to two rows. Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 20 +++++++------------- src/gui/styles/qs60style_s60.cpp | 5 +++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 56d52b1..00e064f 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -815,12 +815,6 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const widgetPalette.setColor(QPalette::HighlightedText, s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QLineEdit"); - widgetPalette = *palette; - - widgetPalette.setColor(QPalette::Text, - s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); - widgetPalette.setColor(QPalette::HighlightedText, - s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QTextEdit"); widgetPalette = *palette; @@ -1533,13 +1527,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QS60StylePrivate::SE_TabBarTabNorthInactive; break; } - if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabNorthInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabSouthInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabWestInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| - skinElement==QS60StylePrivate::SE_TabBarTabNorthActive|| - skinElement==QS60StylePrivate::SE_TabBarTabSouthActive|| + if (skinElement == QS60StylePrivate::SE_TabBarTabEastInactive || + skinElement == QS60StylePrivate::SE_TabBarTabNorthInactive || + skinElement == QS60StylePrivate::SE_TabBarTabSouthInactive || + skinElement == QS60StylePrivate::SE_TabBarTabWestInactive || + skinElement == QS60StylePrivate::SE_TabBarTabEastActive || + skinElement == QS60StylePrivate::SE_TabBarTabNorthActive || + skinElement == QS60StylePrivate::SE_TabBarTabSouthActive || skinElement==QS60StylePrivate::SE_TabBarTabWestActive) { const int borderThickness = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 5bc36f8..d0da13f 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -969,7 +969,7 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme switch(frameElement) { case QS60StylePrivate::SF_ToolTip: - if (QSysInfo::s60Version()!=QSysInfo::SV_S60_3_1) { + if (QSysInfo::s60Version() != QSysInfo::SV_S60_3_1) { centerId.Set(EAknsMajorGeneric, 0x19c2); frameId.Set(EAknsMajorSkin, 0x5300); } else { @@ -978,7 +978,8 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme } break; case QS60StylePrivate::SF_ToolBar: - if (QSysInfo::s60Version()==QSysInfo::SV_S60_3_1 || QSysInfo::s60Version()==QSysInfo::SV_S60_3_2) { + if (QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || + QSysInfo::s60Version() == QSysInfo::SV_S60_3_2) { centerId.Set(KAknsIIDQsnFrPopupCenterSubmenu); frameId.Set(KAknsIIDQsnFrPopupSub); } -- cgit v0.12 From a260024eeb58b1b70ff8083773d9c34434cb360a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 7 May 2010 15:21:28 +0200 Subject: My 4.7.0 changelog entries. --- dist/changes-4.7.0 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0 index 3766c88..6bf7ea5 100644 --- a/dist/changes-4.7.0 +++ b/dist/changes-4.7.0 @@ -72,9 +72,38 @@ QtGui * Fixed a bug that led to missing text pixels in QTabBar when using small font sizes. (QTBUG-7137) + - QGraphicsEffect + * Fixed rendering bugs when scrolling graphics items with drop + shadows. + - QImage + * [QTBUG-9640] Prevented unneccessary copy in + QImage::setAlphaChannel(). * Added QImage::bitPlaneCount(). (QTBUG-7982) + - QPainter + * [QTBUG-10018] Fixed image drawing inconsistencies when drawing + 1x1 source rects with rotating / shear / perspective transforms. + * Optimized various blending and rendering operations for ARM + processors with a NEON vector unit. + * Fixed some performance issues when drawing sub-pixmaps of large + pixmaps and falling back to raster in the X11 paint engine. + + - QPainterPath + * [QTBUG-3778] Fixed bug in painter path polygon intersection code. + * [QTBUG-7396] Optimized painter path intersections for when at + least one of the paths is a rectangle by special casing. + * [QTBUG-8035] Got rid of bezier intersection code in the boolean + operators (intersect, subtract, unite) to prevent numerical + stability issues. + + - QRegion + * [QTBUG-7699] Fixed crash caused by large x-coordinates. + + - QTransform + * [QTBUG-8557] Fixed bug in QTransform::type() potentially occuring + after using operator/ or operator* or their overloads. + QtNetwork --------- - QHostInfo: Added a small 60 second DNS cache -- cgit v0.12 From 48ec7771d853eeeef211be7def3ebc5ff0badc3e Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 7 May 2010 16:24:18 +0300 Subject: QS60Style: QTreeView branch indicators are drawn incorrectly in RtoL QS60Style tries to rotate branch graphics around the x-axis, when it is running in RtoL UI direction. This makes the "L-shaped" branch indicators to point to too high at the item view item. Branch indicators should be mirrored across the x-axis to make them look fine. Task-number: QTBUG-9844 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 70 +++++++++++++++++++++------------------- src/gui/styles/qs60style_p.h | 2 ++ src/gui/styles/qs60style_s60.cpp | 8 +++++ 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 00e064f..8bae18e 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2354,41 +2354,43 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif QCommonStyle::drawPrimitive(element, option, painter, widget); } else { - const bool rightLine = option->state & State_Item; - const bool downLine = option->state & State_Sibling; - const bool upLine = option->state & (State_Open | State_Children | State_Item | State_Sibling); - - QS60StyleEnums::SkinParts skinPart; - bool drawSkinPart = false; - if (rightLine && downLine && upLine) { - skinPart = QS60StyleEnums::SP_QgnIndiHlLineBranch; - drawSkinPart = true; - } else if (rightLine && upLine) { - skinPart = QS60StyleEnums::SP_QgnIndiHlLineEnd; - drawSkinPart = true; - } else if (upLine && downLine) { - skinPart = QS60StyleEnums::SP_QgnIndiHlLineStraight; - drawSkinPart = true; - } - - if (drawSkinPart) - QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); + if (const QStyleOptionViewItemV2 *vopt = qstyleoption_cast(option)) { + const bool rightLine = option->state & State_Item; + const bool downLine = option->state & State_Sibling; + const bool upLine = option->state & (State_Open | State_Children | State_Item | State_Sibling); + QS60StylePrivate::SkinElementFlags adjustedFlags = flags; + + QS60StyleEnums::SkinParts skinPart; + bool drawSkinPart = false; + if (rightLine && downLine && upLine) { + skinPart = QS60StyleEnums::SP_QgnIndiHlLineBranch; + drawSkinPart = true; + } else if (rightLine && upLine) { + skinPart = QS60StyleEnums::SP_QgnIndiHlLineEnd; + drawSkinPart = true; + } else if (upLine && downLine) { + skinPart = QS60StyleEnums::SP_QgnIndiHlLineStraight; + drawSkinPart = true; + } - if (option->state & State_Children) { - QS60StyleEnums::SkinParts skinPart = - (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; - int resizeValue = minDimension >> 1; - if (!QS60StylePrivate::isTouchSupported()) { - minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. - iconRect.setSize(QSize(minDimension, minDimension)); - const int verticalMagic = (option->rect.width() <= option->rect.height()) ? magicTweak : 0; - resizeValue = verticalMagic - resizeValue; + if (option->direction == Qt::RightToLeft) + adjustedFlags |= QS60StylePrivate::SF_Mirrored_X_Axis; + + if (drawSkinPart) + QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, adjustedFlags); + + if (option->state & State_Children) { + QS60StyleEnums::SkinParts skinPart = + (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; + const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, vopt, widget); + const int minDimension = qMin(option->rect.width(), option->rect.height()); + const int magicTweak = (option->direction == Qt::RightToLeft) ? -3 : 3; //@todo: magic + //The branch indicator icon in S60 is supposed to be superimposed on top of branch lines. + QRect iconRect(QPoint(option->rect.left() + magicTweak, selectionRect.top() + 1), QSize(minDimension, minDimension)); + if (!QS60StylePrivate::isTouchSupported()) + iconRect.translate(0, -4); //@todo: magic + QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, adjustedFlags); } - iconRect.translate(magicTweak, resizeValue); - QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); } } break; @@ -3001,7 +3003,7 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con } break; case SE_ItemViewItemCheckIndicator: - if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast(opt)) { + if (const QStyleOptionViewItemV2 *vopt = qstyleoption_cast(opt)) { const QListWidget *listItem = qobject_cast(widget); const bool singleSelection = listItem && diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 9dd3810..d8c31f8 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -476,6 +476,8 @@ public: SF_StateDisabled = 0x0020, SF_ColorSkinned = 0x0040, // pixmap is colored with foreground pen color SF_Animation = 0x0080, + SF_Mirrored_X_Axis = 0x0100, + SF_Mirrored_Y_Axis = 0x0200 }; enum CacheClearReason { diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index d0da13f..c0ecc5d 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -654,6 +654,14 @@ QPixmap QS60StyleModeSpecifics::fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask pixmap = QPixmap::fromImage(iconImage); } + if ((flags & QS60StylePrivate::SF_Mirrored_X_Axis) || + (flags & QS60StylePrivate::SF_Mirrored_Y_Axis)) { + QImage iconImage = pixmap.toImage().mirrored( + flags & QS60StylePrivate::SF_Mirrored_X_Axis, + flags & QS60StylePrivate::SF_Mirrored_Y_Axis); + pixmap = QPixmap::fromImage(iconImage); + } + return pixmap; } -- cgit v0.12 From 6179db13b19b7b5e36b51abbb2cf8cb83f9f09d3 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 7 May 2010 15:28:29 +0200 Subject: QSystemTrayIcon: put WinCE specific code into qsystemtrayicon_wince.cpp The desktop Windows and Windows CE code paths diverged too much. Splitting it up now and making it work on WinCE again. Task-number: QTBUG-4828 Reviewed-by: mauricek --- src/gui/util/qsystemtrayicon_win.cpp | 53 ------ src/gui/util/qsystemtrayicon_wince.cpp | 299 +++++++++++++++++++++++++++++++++ src/gui/util/util.pri | 5 +- 3 files changed, 303 insertions(+), 54 deletions(-) create mode 100644 src/gui/util/qsystemtrayicon_wince.cpp diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index 6db158e..1571b94 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -61,17 +61,9 @@ #include #include -#if defined(Q_WS_WINCE) && !defined(STANDARDSHELL_UI_MODEL) -# include -#endif - QT_BEGIN_NAMESPACE -#if defined(Q_WS_WINCE) -static const UINT q_uNOTIFYICONID = 13; // IDs from 0 to 12 are reserved on WinCE. -#else static const UINT q_uNOTIFYICONID = 0; -#endif static uint MYWM_TASKBARCREATED = 0; #define MYWM_NOTIFYICON (WM_APP+101) @@ -125,23 +117,15 @@ bool QSystemTrayIconSys::allowsMessages() bool QSystemTrayIconSys::supportsMessages() { -#ifndef Q_OS_WINCE return allowsMessages(); -#endif - return false; } QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object) : hIcon(0), q(object), ignoreNextMouseRelease(false) { -#ifndef Q_OS_WINCE notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, guidItem); // NOTIFYICONDATAW_V2_SIZE; maxTipLength = 128; -#else - notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, szTip[64]); // NOTIFYICONDATAW_V1_SIZE; - maxTipLength = 64; -#endif // For restoring the tray icon after explorer crashes if (!MYWM_TASKBARCREATED) { @@ -317,26 +301,15 @@ bool QSystemTrayIconSys::winEvent( MSG *m, long *result ) case WM_RBUTTONUP: if (q->contextMenu()) { q->contextMenu()->popup(gpos); -#if defined(Q_WS_WINCE) - // We must ensure that the popup menu doesn't show up behind the task bar. - QRect desktopRect = qApp->desktop()->availableGeometry(); - int maxY = desktopRect.y() + desktopRect.height() - q->contextMenu()->height(); - if (gpos.y() > maxY) { - gpos.ry() = maxY; - q->contextMenu()->move(gpos); - } -#endif q->contextMenu()->activateWindow(); //Must be activated for proper keyboardfocus and menu closing on windows: } emit q->activated(QSystemTrayIcon::Context); break; -#if !defined(Q_WS_WINCE) case NIN_BALLOONUSERCLICK: emit q->messageClicked(); break; -#endif case WM_MBUTTONUP: emit q->activated(QSystemTrayIcon::MiddleClick); @@ -403,23 +376,11 @@ QRect QSystemTrayIconSys::findIconGeometry(const int iconId) //find the toolbar used in the notification area if (trayHandle) { -#if defined(Q_OS_WINCE) - trayHandle = FindWindow(L"TrayNotifyWnd", NULL); -#else trayHandle = FindWindowEx(trayHandle, NULL, L"TrayNotifyWnd", NULL); -#endif if (trayHandle) { -#if defined(Q_OS_WINCE) - HWND hwnd = FindWindow(L"SysPager", NULL); -#else HWND hwnd = FindWindowEx(trayHandle, NULL, L"SysPager", NULL); -#endif if (hwnd) { -#if defined(Q_OS_WINCE) - hwnd = FindWindow(L"ToolbarWindow32", NULL); -#else hwnd = FindWindowEx(hwnd, NULL, L"ToolbarWindow32", NULL); -#endif if (hwnd) trayHandle = hwnd; } @@ -438,11 +399,7 @@ QRect QSystemTrayIconSys::findIconGeometry(const int iconId) return ret; int buttonCount = SendMessage(trayHandle, TB_BUTTONCOUNT, 0, 0); -#if defined(Q_OS_WINCE) - LPVOID data = VirtualAlloc(NULL, sizeof(TBBUTTON), MEM_COMMIT, PAGE_READWRITE); -#else LPVOID data = VirtualAllocEx(trayProcess, NULL, sizeof(TBBUTTON), MEM_COMMIT, PAGE_READWRITE); -#endif if ( buttonCount < 1 || !data ) { CloseHandle(trayProcess); @@ -480,11 +437,7 @@ QRect QSystemTrayIconSys::findIconGeometry(const int iconId) } } } -#if defined(Q_OS_WINCE) - VirtualFree(data, 0, MEM_RELEASE); -#else VirtualFreeEx(trayProcess, data, 0, MEM_RELEASE); -#endif CloseHandle(trayProcess); return ret; } @@ -558,16 +511,10 @@ void QSystemTrayIconPrivate::updateMenu_sys() void QSystemTrayIconPrivate::updateToolTip_sys() { -#ifdef Q_WS_WINCE - // Calling sys->trayMessage(NIM_MODIFY) on an existing icon is broken on Windows CE. - // So we need to call updateIcon_sys() which creates a new icon handle. - updateIcon_sys(); -#else if (!sys) return; sys->trayMessage(NIM_MODIFY); -#endif } bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys() diff --git a/src/gui/util/qsystemtrayicon_wince.cpp b/src/gui/util/qsystemtrayicon_wince.cpp new file mode 100644 index 0000000..b74420d --- /dev/null +++ b/src/gui/util/qsystemtrayicon_wince.cpp @@ -0,0 +1,299 @@ +/**************************************************************************** +** +** 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 QtGui 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 "qsystemtrayicon_p.h" +#ifndef QT_NO_SYSTEMTRAYICON +#define _WIN32_IE 0x0600 //required for NOTIFYICONDATA_V2_SIZE + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +static const UINT q_uNOTIFYICONID = 13; // IDs from 0 to 12 are reserved on WinCE. +#define MYWM_NOTIFYICON (WM_APP+101) + +struct Q_NOTIFYICONIDENTIFIER { + DWORD cbSize; + HWND hWnd; + UINT uID; + GUID guidItem; +}; + +class QSystemTrayIconSys : QWidget +{ +public: + QSystemTrayIconSys(QSystemTrayIcon *object); + ~QSystemTrayIconSys(); + bool winEvent( MSG *m, long *result ); + bool trayMessage(DWORD msg); + void setIconContents(NOTIFYICONDATA &data); + void createIcon(); + QRect findTrayGeometry(); + HICON hIcon; + QPoint globalPos; + QSystemTrayIcon *q; +private: + uint notifyIconSize; + int maxTipLength; + bool ignoreNextMouseRelease; +}; + +QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object) + : hIcon(0), q(object), ignoreNextMouseRelease(false) + +{ + notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, szTip[64]); // NOTIFYICONDATAW_V1_SIZE; + maxTipLength = 64; +} + +QSystemTrayIconSys::~QSystemTrayIconSys() +{ + if (hIcon) + DestroyIcon(hIcon); +} + +QRect QSystemTrayIconSys::findTrayGeometry() +{ + // Use lower right corner as fallback + QPoint brCorner = qApp->desktop()->screenGeometry().bottomRight(); + QRect ret(brCorner.x() - 10, brCorner.y() - 10, 10, 10); + return ret; +} + +void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd) +{ + tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; + tnd.uCallbackMessage = MYWM_NOTIFYICON; + tnd.hIcon = hIcon; + QString tip = q->toolTip(); + + if (!tip.isNull()) { + tip = tip.left(maxTipLength - 1) + QChar(); + memcpy(tnd.szTip, tip.utf16(), qMin(tip.length() + 1, maxTipLength) * sizeof(wchar_t)); + } +} + +bool QSystemTrayIconSys::trayMessage(DWORD msg) +{ + NOTIFYICONDATA tnd; + memset(&tnd, 0, notifyIconSize); + tnd.uID = q_uNOTIFYICONID; + tnd.cbSize = notifyIconSize; + tnd.hWnd = winId(); + + Q_ASSERT(testAttribute(Qt::WA_WState_Created)); + + if (msg != NIM_DELETE) { + setIconContents(tnd); + } + + return Shell_NotifyIcon(msg, &tnd); +} + +void QSystemTrayIconSys::createIcon() +{ + hIcon = 0; + QIcon icon = q->icon(); + if (icon.isNull()) + return; + + //const QSize preferredSize(GetSystemMetrics(SM_CXSMICON) * 2, GetSystemMetrics(SM_CYSMICON) * 2); + const QSize preferredSize(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)); + QPixmap pm = icon.pixmap(preferredSize); + if (pm.isNull()) + return; + + hIcon = pm.toWinHICON(); +} + +bool QSystemTrayIconSys::winEvent( MSG *m, long *result ) +{ + switch(m->message) { + case WM_CREATE: + SetWindowLong(winId(), GWL_USERDATA, (LONG)((CREATESTRUCTW*)m->lParam)->lpCreateParams); + break; + + case MYWM_NOTIFYICON: + { + RECT r; + GetWindowRect(winId(), &r); + QEvent *e = 0; + Qt::KeyboardModifiers keys = QApplication::keyboardModifiers(); + QPoint gpos = QCursor::pos(); + + switch (m->lParam) { + case WM_LBUTTONUP: + if (ignoreNextMouseRelease) + ignoreNextMouseRelease = false; + else + emit q->activated(QSystemTrayIcon::Trigger); + break; + + case WM_LBUTTONDBLCLK: + ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse + // release we must ignore it + emit q->activated(QSystemTrayIcon::DoubleClick); + break; + + case WM_RBUTTONUP: + if (q->contextMenu()) { + q->contextMenu()->popup(gpos); + + // We must ensure that the popup menu doesn't show up behind the task bar. + QRect desktopRect = qApp->desktop()->availableGeometry(); + int maxY = desktopRect.y() + desktopRect.height() - q->contextMenu()->height(); + if (gpos.y() > maxY) { + gpos.ry() = maxY; + q->contextMenu()->move(gpos); + } + + q->contextMenu()->activateWindow(); + //Must be activated for proper keyboardfocus and menu closing on windows: + } + emit q->activated(QSystemTrayIcon::Context); + break; + + case WM_MBUTTONUP: + emit q->activated(QSystemTrayIcon::MiddleClick); + break; + default: + break; + } + if (e) { + bool res = QApplication::sendEvent(q, e); + delete e; + return res; + } + break; + } + default: + return QWidget::winEvent(m, result); + } + return 0; +} + +void QSystemTrayIconPrivate::install_sys() +{ + Q_Q(QSystemTrayIcon); + if (!sys) { + sys = new QSystemTrayIconSys(q); + sys->createIcon(); + sys->trayMessage(NIM_ADD); + } +} + +void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, int timeOut) +{ + if (!sys) + return; + + uint uSecs = 0; + if ( timeOut < 0) + uSecs = 10000; //10 sec default + else uSecs = (int)timeOut; + + //message is limited to 255 chars + NULL + QString messageString; + if (message.isEmpty() && !title.isEmpty()) + messageString = QLatin1Char(' '); //ensures that the message shows when only title is set + else + messageString = message.left(255) + QChar(); + + //title is limited to 63 chars + NULL + QString titleString = title.left(63) + QChar(); + + //show QBalloonTip + QRect trayRect = sys->findTrayGeometry(); + QBalloonTip::showBalloon(type, title, message, sys->q, QPoint(trayRect.left(), + trayRect.center().y()), uSecs, false); +} + +QRect QSystemTrayIconPrivate::geometry_sys() const +{ + return QRect(); +} + +void QSystemTrayIconPrivate::remove_sys() +{ + if (!sys) + return; + + sys->trayMessage(NIM_DELETE); + delete sys; + sys = 0; +} + +void QSystemTrayIconPrivate::updateIcon_sys() +{ + if (!sys) + return; + + HICON hIconToDestroy = sys->hIcon; + + sys->createIcon(); + sys->trayMessage(NIM_MODIFY); + + if (hIconToDestroy) + DestroyIcon(hIconToDestroy); +} + +void QSystemTrayIconPrivate::updateMenu_sys() +{ + +} + +void QSystemTrayIconPrivate::updateToolTip_sys() +{ + // Calling sys->trayMessage(NIM_MODIFY) on an existing icon is broken on Windows CE. + // So we need to call updateIcon_sys() which creates a new icon handle. + updateIcon_sys(); +} + +bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys() +{ + return true; +} + +QT_END_NAMESPACE + +#endif diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri index 3074367..7344fbd 100644 --- a/src/gui/util/util.pri +++ b/src/gui/util/util.pri @@ -20,7 +20,10 @@ SOURCES += \ util/qundoview.cpp -win32 { +wince* { + SOURCES += \ + util/qsystemtrayicon_wince.cpp +} else:win32 { SOURCES += \ util/qsystemtrayicon_win.cpp } -- cgit v0.12 From cb3f3858555bb5b385ee42bb51c4011b21779506 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 7 May 2010 16:12:10 +0200 Subject: Mark QFileDialog::Options as a Q_FLAGS So it can be inspected with designer Task-number: QTBUG-10323 Reviewed-by: jbache --- src/gui/dialogs/qfiledialog.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/dialogs/qfiledialog.h b/src/gui/dialogs/qfiledialog.h index 97fac4e..16cb317 100644 --- a/src/gui/dialogs/qfiledialog.h +++ b/src/gui/dialogs/qfiledialog.h @@ -67,6 +67,7 @@ class Q_GUI_EXPORT QFileDialog : public QDialog { Q_OBJECT Q_ENUMS(ViewMode FileMode AcceptMode Option) + Q_FLAGS(Options) Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode) Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode) Q_PROPERTY(AcceptMode acceptMode READ acceptMode WRITE setAcceptMode) -- cgit v0.12 From 3f9a617a72dc8167a762a1d75e75c98d27a7a214 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 5 May 2010 10:43:20 +0100 Subject: Modified audiodevices example to list all supported formats Divided the UI into two tabs: - One which lists all formats supported by the device, in a table. This table is populated dynamically when the user presses a button, rather than at application startup - for some backends such as ALSA, isFormatSupported() is a time-consuming operation. - One which allows the user to specify a particular format, and then test whether it is supported. If the format is not supported, the nearest supported format is displayed. Changing mode causes test result to be cleared. Call showFullScreen() on small-screen devices. Reviewed-by: Kurt Korbatits --- examples/multimedia/audiodevices/audiodevices.cpp | 158 ++++-- examples/multimedia/audiodevices/audiodevices.h | 2 + .../multimedia/audiodevices/audiodevicesbase.ui | 565 ++++++++++++--------- examples/multimedia/audiodevices/main.cpp | 4 + 4 files changed, 439 insertions(+), 290 deletions(-) diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index 7d09c38..1a7a7ee 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -44,6 +44,40 @@ #include "audiodevices.h" +// Utility functions for converting QAudioFormat fields into text + +QString toString(QAudioFormat::SampleType sampleType) +{ + QString result("Unknown"); + switch (sampleType) { + case QAudioFormat::SignedInt: + result = "SignedInt"; + break; + case QAudioFormat::UnSignedInt: + result = "UnSignedInt"; + break; + case QAudioFormat::Float: + result = "Float"; + break; + } + return result; +} + +QString toString(QAudioFormat::Endian endian) +{ + QString result("Unknown"); + switch (endian) { + case QAudioFormat::LittleEndian: + result = "LittleEndian"; + break; + case QAudioFormat::BigEndian: + result = "BigEndian"; + break; + } + return result; +} + + AudioDevicesBase::AudioDevicesBase(QWidget *parent, Qt::WFlags f) : QMainWindow(parent, f) { @@ -67,6 +101,7 @@ AudioTest::AudioTest(QWidget *parent, Qt::WFlags f) connect(sampleSizesBox, SIGNAL(activated(int)), SLOT(sampleSizeChanged(int))); connect(sampleTypesBox, SIGNAL(activated(int)), SLOT(sampleTypeChanged(int))); connect(endianBox, SIGNAL(activated(int)), SLOT(endianChanged(int))); + connect(populateTableButton, SIGNAL(clicked()), SLOT(populateTable())); modeBox->setCurrentIndex(0); modeChanged(0); @@ -81,12 +116,11 @@ AudioTest::~AudioTest() void AudioTest::test() { // tries to set all the settings picked. - logOutput->clear(); - logOutput->append("NOTE: an invalid codec audio/test exists for testing, to get a fail condition."); + testResult->clear(); if (!deviceInfo.isNull()) { if (deviceInfo.isFormatSupported(settings)) { - logOutput->append(tr("Success")); + testResult->setText(tr("Success")); nearestFreq->setText(""); nearestChannel->setText(""); nearestCodec->setText(""); @@ -95,40 +129,23 @@ void AudioTest::test() nearestEndian->setText(""); } else { QAudioFormat nearest = deviceInfo.nearestFormat(settings); - logOutput->append(tr("Failed")); + testResult->setText(tr("Failed")); nearestFreq->setText(QString("%1").arg(nearest.frequency())); nearestChannel->setText(QString("%1").arg(nearest.channels())); nearestCodec->setText(nearest.codec()); nearestSampleSize->setText(QString("%1").arg(nearest.sampleSize())); - - switch(nearest.sampleType()) { - case QAudioFormat::SignedInt: - nearestSampleType->setText("SignedInt"); - break; - case QAudioFormat::UnSignedInt: - nearestSampleType->setText("UnSignedInt"); - break; - case QAudioFormat::Float: - nearestSampleType->setText("Float"); - break; - case QAudioFormat::Unknown: - nearestSampleType->setText("Unknown"); - } - switch(nearest.byteOrder()) { - case QAudioFormat::LittleEndian: - nearestEndian->setText("LittleEndian"); - break; - case QAudioFormat::BigEndian: - nearestEndian->setText("BigEndian"); - } + nearestSampleType->setText(toString(nearest.sampleType())); + nearestEndian->setText(toString(nearest.byteOrder())); } } else - logOutput->append(tr("No Device")); + testResult->setText(tr("No Device")); } void AudioTest::modeChanged(int idx) { + testResult->clear(); + // mode has changed if (idx == 0) mode = QAudio::AudioInput; @@ -138,10 +155,15 @@ void AudioTest::modeChanged(int idx) deviceBox->clear(); foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(mode)) deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); + + deviceBox->setCurrentIndex(0); + deviceChanged(0); } void AudioTest::deviceChanged(int idx) { + testResult->clear(); + if (deviceBox->count() == 0) return; @@ -180,38 +202,68 @@ void AudioTest::deviceChanged(int idx) sampleTypesBox->clear(); QList sampleTypez = deviceInfo.supportedSampleTypes(); - for (int i = 0; i < sampleTypez.size(); ++i) { - switch(sampleTypez.at(i)) { - case QAudioFormat::SignedInt: - sampleTypesBox->addItem("SignedInt"); - break; - case QAudioFormat::UnSignedInt: - sampleTypesBox->addItem("UnSignedInt"); - break; - case QAudioFormat::Float: - sampleTypesBox->addItem("Float"); - break; - case QAudioFormat::Unknown: - sampleTypesBox->addItem("Unknown"); - } - if (sampleTypez.size()) - settings.setSampleType(sampleTypez.at(0)); - } + + for (int i = 0; i < sampleTypez.size(); ++i) + sampleTypesBox->addItem(toString(sampleTypez.at(i))); + if (sampleTypez.size()) + settings.setSampleType(sampleTypez.at(0)); endianBox->clear(); QList endianz = deviceInfo.supportedByteOrders(); - for (int i = 0; i < endianz.size(); ++i) { - switch (endianz.at(i)) { - case QAudioFormat::LittleEndian: - endianBox->addItem("Little Endian"); - break; - case QAudioFormat::BigEndian: - endianBox->addItem("Big Endian"); - break; - } - } + for (int i = 0; i < endianz.size(); ++i) + endianBox->addItem(toString(endianz.at(i))); if (endianz.size()) settings.setByteOrder(endianz.at(0)); + + allFormatsTable->clearContents(); +} + +void AudioTest::populateTable() +{ + int row = 0; + + QAudioFormat format; + foreach (QString codec, deviceInfo.supportedCodecs()) { + format.setCodec(codec); + foreach (int frequency, deviceInfo.supportedFrequencies()) { + format.setFrequency(frequency); + foreach (int channels, deviceInfo.supportedChannels()) { + format.setChannels(channels); + foreach (QAudioFormat::SampleType sampleType, deviceInfo.supportedSampleTypes()) { + format.setSampleType(sampleType); + foreach (int sampleSize, deviceInfo.supportedSampleSizes()) { + format.setSampleSize(sampleSize); + foreach (QAudioFormat::Endian endian, deviceInfo.supportedByteOrders()) { + format.setByteOrder(endian); + if (deviceInfo.isFormatSupported(format)) { + allFormatsTable->setRowCount(row + 1); + + QTableWidgetItem *codecItem = new QTableWidgetItem(format.codec()); + allFormatsTable->setItem(row, 0, codecItem); + + QTableWidgetItem *frequencyItem = new QTableWidgetItem(QString("%1").arg(format.frequency())); + allFormatsTable->setItem(row, 1, frequencyItem); + + QTableWidgetItem *channelsItem = new QTableWidgetItem(QString("%1").arg(format.channels())); + allFormatsTable->setItem(row, 2, channelsItem); + + QTableWidgetItem *sampleTypeItem = new QTableWidgetItem(toString(format.sampleType())); + allFormatsTable->setItem(row, 3, sampleTypeItem); + + QTableWidgetItem *sampleSizeItem = new QTableWidgetItem(QString("%1").arg(format.sampleSize())); + allFormatsTable->setItem(row, 4, sampleSizeItem); + + QTableWidgetItem *byteOrderItem = new QTableWidgetItem(toString(format.byteOrder())); + allFormatsTable->setItem(row, 5, byteOrderItem); + + ++row; + } + } + } + } + } + } + } } void AudioTest::freqChanged(int idx) diff --git a/examples/multimedia/audiodevices/audiodevices.h b/examples/multimedia/audiodevices/audiodevices.h index 15ace92..b5b5204 100644 --- a/examples/multimedia/audiodevices/audiodevices.h +++ b/examples/multimedia/audiodevices/audiodevices.h @@ -74,5 +74,7 @@ private slots: void sampleTypeChanged(int idx); void endianChanged(int idx); void test(); + void populateTable(); + }; diff --git a/examples/multimedia/audiodevices/audiodevicesbase.ui b/examples/multimedia/audiodevices/audiodevicesbase.ui index 667a6e5..23b45d7 100644 --- a/examples/multimedia/audiodevices/audiodevicesbase.ui +++ b/examples/multimedia/audiodevices/audiodevicesbase.ui @@ -6,8 +6,8 @@ 0 0 - 320 - 300 + 679 + 598 @@ -30,58 +30,30 @@ 0 - -192 - 282 - 471 + 0 + 659 + 558 - - - + + + - - - - 1 - 0 - - + - Device + Mode - + - Mode + Device - - - - 0 - 0 - - - - - 150 - 0 - - - - - - - - 0 - 0 - - Input @@ -94,203 +66,322 @@ - - - - QFrame::Panel - - - QFrame::Raised - - - Actual Settings - - - Qt::AlignCenter - - - - - - - QFrame::Panel - - - QFrame::Raised - - - Nearest Settings - - - Qt::AlignCenter - - - - - - - Frequency - - - - - - - Frequency - - - - - - - - - - false - - - - - - - Channels - - - - - - - Channel - - - - - - - - - - false - - - - - - - Codecs - - - - - - - Codec - - - - - - - - - - false - - - - - - - SampleSize - - - - - - - SampleSize - - - - - - - - - - false - - - - - - - SampleType - - - - - - - SampleType - - - - - - - - - - false - - - - - - - Endianess - - - - - - - Endianess - - - - - - - - - - false - - - - - - - false - - - - 0 - 0 - - - - Qt::ScrollBarAlwaysOff - - - - - - - Test - + + + + + + + 0 + + + + Test format + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + <i>Actual Settings</i> + + + Qt::RichText + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Nearest Settings</span></p></body></html> + + + Qt::RichText + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + + + + false + + + + + + + + + + false + + + + + + + + + + false + + + + + + + + + + false + + + + + + + Test + + + + + + + + + + + + + + Frequency (Hz) + + + + + + + Channels + + + + + + + Sample size (bits) + + + + + + + Endianess + + + + + + + + 0 + 0 + + + + Note: an invalid codec 'audio/test' exists in order to allow an invalid format to be constructed, and therefore to trigger a 'nearest format' calculation. + + + true + + + + + + + Codec + + + + + + + false + + + + + + + + + + SampleType + + + + + + + + + + false + + + + + + + + All formats + + + + + + Populate table + + + + + + + QAbstractItemView::NoEditTriggers + + + false + + + QAbstractItemView::NoSelection + + + QAbstractItemView::SelectItems + + + Qt::ElideNone + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + + Codec + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + Frequency (Hz) + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + Channels + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + Sample type + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + Sample size (bits) + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + Endianness + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + + diff --git a/examples/multimedia/audiodevices/main.cpp b/examples/multimedia/audiodevices/main.cpp index 0ea18a1..8ca4932 100644 --- a/examples/multimedia/audiodevices/main.cpp +++ b/examples/multimedia/audiodevices/main.cpp @@ -49,7 +49,11 @@ int main(int argv, char **args) app.setApplicationName("Audio Device Test"); AudioTest audio; +#ifdef Q_OS_SYMBIAN + audio.showMaximized(); +#else audio.show(); +#endif return app.exec(); } -- cgit v0.12 From 79533291672fd5e6ddafe5be90501cbe2ec97b1b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 8 May 2010 18:38:54 +0200 Subject: QUrl: update the whitelist of IDN domains The list is taken from the Mozilla page. --- src/corelib/io/qurl.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index ffe8d06..3604648 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3129,10 +3129,11 @@ static void toPunycodeHelper(const QChar *s, int ucLength, QString *output) static const char * const idn_whitelist[] = { - "ac", "at", - "br", + "ac", "ar", "at", + "biz", "br", "cat", "ch", "cl", "cn", "de", "dk", + "es", "fi", "gr", "hu", @@ -3146,6 +3147,9 @@ static const char * const idn_whitelist[] = { "se", "sh", "th", "tm", "tw", "vn", + "xn--mgbaam7a8h", // UAE + "xn--mgberp4a5d4ar", // Saudi Arabia + "xn--wgbh1c" // Egypt }; static QStringList *user_idn_whitelist = 0; -- cgit v0.12 From 75f0c1f0f0496ae22ed89b996dfb0050defd0f3e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 8 May 2010 18:36:26 +0200 Subject: QUrl: fix parsing of IRIs with more than one IDN label Task-number: QTBUG-10511 Reviewed-by: Trust Me --- src/corelib/io/qurl.cpp | 1 + tests/auto/qurl/tst_qurl.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 3604648..bdb0cfd 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3308,6 +3308,7 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) qt_nameprep(&result, prevLen); labelLength = result.length() - prevLen; register int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes + aceForm.resize(0); if (toReserve > aceForm.capacity()) aceForm.reserve(toReserve); toPunycodeHelper(result.constData() + prevLen, result.size() - prevLen, &aceForm); diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 83109b5..8dffebb 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -3189,6 +3189,32 @@ void tst_QUrl::ace_testsuite_data() QTest::newRow("separator-3002") << QString::fromUtf8("example\343\200\202com") << "example.com" << "." << "example.com"; + + QString egyptianIDN = + QString::fromUtf8("\331\210\330\262\330\247\330\261\330\251\055\330\247\331\204\330" + "\243\330\252\330\265\330\247\331\204\330\247\330\252.\331\205" + "\330\265\330\261"); + QTest::newRow("egyptian-tld-ace") + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; + QTest::newRow("egyptian-tld-unicode") + << egyptianIDN + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; + QTest::newRow("egyptian-tld-mix1") + << QString::fromUtf8("\331\210\330\262\330\247\330\261\330\251\055\330\247\331\204\330" + "\243\330\252\330\265\330\247\331\204\330\247\330\252.xn--wgbh1c") + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; + QTest::newRow("egyptian-tld-mix2") + << QString::fromUtf8("xn----rmckbbajlc6dj7bxne2c.\331\205\330\265\330\261") + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; } void tst_QUrl::ace_testsuite() -- cgit v0.12 From 6d7c9261239390cb7d57861417da5f6d5a8456ee Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Mon, 10 May 2010 07:48:37 +1000 Subject: Update to low-level audio documentation. Reviewed-by:Gareth Stockwell --- src/multimedia/audio/qaudioinput.cpp | 10 ++++++++++ src/multimedia/audio/qaudiooutput.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index c99e870..a1708f1 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -211,6 +211,10 @@ QAudioInput::~QAudioInput() If a problem occurs during this process the error() is set to QAudio::OpenError, state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + In either case, the stateChanged() signal may be emitted either synchronously + during execution of the start() function or asynchronously after start() has + returned to the caller. + \sa {Symbian Platform Security Requirements} \sa QIODevice @@ -233,6 +237,10 @@ void QAudioInput::start(QIODevice* device) If a problem occurs during this process the error() is set to QAudio::OpenError, state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + In either case, the stateChanged() signal may be emitted either synchronously + during execution of the start() function or asynchronously after start() has + returned to the caller. + \sa {Symbian Platform Security Requirements} \sa QIODevice @@ -278,6 +286,8 @@ void QAudioInput::reset() Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and emit stateChanged() signal. + + Note: signal will always be emitted during execution of the resume() function. */ void QAudioInput::suspend() diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp index b0b5244..371773c 100644 --- a/src/multimedia/audio/qaudiooutput.cpp +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -209,6 +209,10 @@ QAudioFormat QAudioOutput::format() const If a problem occurs during this process the error() is set to QAudio::OpenError, state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + In either case, the stateChanged() signal may be emitted either synchronously + during execution of the start() function or asynchronously after start() has + returned to the caller. + \sa QIODevice */ @@ -228,6 +232,10 @@ void QAudioOutput::start(QIODevice* device) If a problem occurs during this process the error() is set to QAudio::OpenError, state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + In either case, the stateChanged() signal may be emitted either synchronously + during execution of the start() function or asynchronously after start() has + returned to the caller. + \sa QIODevice */ @@ -276,6 +284,8 @@ void QAudioOutput::suspend() Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). Sets state() to QAudio::IdleState if you previously called start(). emits stateChanged() signal. + + Note: signal will always be emitted during execution of the resume() function. */ void QAudioOutput::resume() -- cgit v0.12 From a4bd18a3640fcad545fbd5a85374eb0056687dee Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 10 May 2010 08:40:05 +0100 Subject: Return correct formats supported lists from Symbian audio backend * QAudioDeviceInfoInternal functions now call CMMFDevSound::InitializeL() The root cause of QTBUG-10205 was that CMMFDevSound::IntitializeL() was not called before CMMFDevSound::Capabilities(), resulting in incorrect values being returned by QAudioDeviceInfo 'supported format' functions. Resolving this was not straightforward because, while QAudioDeviceInfo is an entirely synchronous API, CMMFDevSound::InitializeL() is an asynchronous function. The changes therefore include a while(QApplication::instance()->processEvents(...)) loop, which is not a particularly elegant solution. * Encapsulated all interaction with CMMFDevSound API in DevSoundWrapper class Because the original bug fix required QAudioDeviceInfoInternal to call CMMFDevSound::InitializeL(), MDevSoundObserver callback functions had to be implemented in QAudioDeviceInfoInternal. Rather than pollute QAudioDeviceInfoInternal, a new class, DevSoundWrapper, was created which encapsulates all interaction with CMMFDevSound, and therefore implements MDevSoundObserver. QAudioInputPrivate and QAudioOutputPrivate now call CMMFDevSound via DevSoundWrapper, with only the required MDevSoundObserver callbacks forwarded on via signals. After fixing this bug, running the auto test suites exposed a number of regressions which had been introduced by the necessary refactoring described above; this commit therefore also includes fixes for the following: * No stateChanged() signal emitted during DevSound initialization Previously, QAudioInput / QAudioOutput would emit a state change from StoppedState to IdleState or ActiveState, as soon as start() was called. In the case where the requested format is subsequently found to be unsupported, in addition to the error() value being set to OpenError, a second state change would be emitted, back to StoppedState. This is not the behaviour exhibited by the other platforms' backends, and therefore caused an auto test failure. Now, the backend only transitions to IdleState / ActiveState on successful initialization. * Stop emitting notify() signal when notifyInterval is set to zero * Call CMMFDevSound::RecordInitL() from QAudioInput::resume() if no buffer is currently held This is necessary in order to restart the data flow. * Call CMMFDevSound::BufferFilled() from QAudioOutput::resume() in push mode The auto test does not resume pushing data to QAudioOutput until 'bytesFree() >= periodSize()' becomes true. Because, for the Symbian backend, periodSize() == bufferSize(), this condition is only met when a new buffer is provided by DevSound via BufferToBeFilled(). Task-number: QTBUG-10205 --- src/multimedia/audio/qaudio_symbian_p.cpp | 357 +++++++++++++++++---- src/multimedia/audio/qaudio_symbian_p.h | 113 ++++--- .../audio/qaudiodeviceinfo_symbian_p.cpp | 106 ++++-- src/multimedia/audio/qaudiodeviceinfo_symbian_p.h | 28 +- src/multimedia/audio/qaudioinput_symbian_p.cpp | 231 ++++++------- src/multimedia/audio/qaudioinput_symbian_p.h | 22 +- src/multimedia/audio/qaudiooutput_symbian_p.cpp | 225 +++++-------- src/multimedia/audio/qaudiooutput_symbian_p.h | 20 +- 8 files changed, 649 insertions(+), 453 deletions(-) diff --git a/src/multimedia/audio/qaudio_symbian_p.cpp b/src/multimedia/audio/qaudio_symbian_p.cpp index afe98f5..4522c5c 100644 --- a/src/multimedia/audio/qaudio_symbian_p.cpp +++ b/src/multimedia/audio/qaudio_symbian_p.cpp @@ -45,41 +45,6 @@ QT_BEGIN_NAMESPACE namespace SymbianAudio { - -DevSoundCapabilities::DevSoundCapabilities(CMMFDevSound &devsound, - QAudio::Mode mode) -{ - QT_TRAP_THROWING(constructL(devsound, mode)); -} - -DevSoundCapabilities::~DevSoundCapabilities() -{ - m_fourCC.Close(); -} - -void DevSoundCapabilities::constructL(CMMFDevSound &devsound, - QAudio::Mode mode) -{ - m_caps = devsound.Capabilities(); - - TMMFPrioritySettings settings; - - switch (mode) { - case QAudio::AudioOutput: - settings.iState = EMMFStatePlaying; - devsound.GetSupportedInputDataTypesL(m_fourCC, settings); - break; - - case QAudio::AudioInput: - settings.iState = EMMFStateRecording; - devsound.GetSupportedInputDataTypesL(m_fourCC, settings); - break; - - default: - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); - } -} - namespace Utils { //----------------------------------------------------------------------------- @@ -274,11 +239,8 @@ bool sampleInfoQtToNative(int inputSampleSize, return found; } -//----------------------------------------------------------------------------- -// Public functions -//----------------------------------------------------------------------------- - -void capabilitiesNativeToQt(const DevSoundCapabilities &caps, +void capabilitiesNativeToQt(const TMMFCapabilities &caps, + const TFourCC &fourcc, QList &frequencies, QList &channels, QList &sampleSizes, @@ -292,37 +254,20 @@ void capabilitiesNativeToQt(const DevSoundCapabilities &caps, channels.clear(); for (int i=0; i& DevSoundWrapper::supportedCodecs() const +{ + return m_supportedCodecs; +} + +void DevSoundWrapper::initialize(const QString& codec) +{ + Q_ASSERT(StateInitializing != m_state); + m_state = StateInitializing; + if (QLatin1String("audio/pcm") == codec) { + m_fourcc = KMMFFourCCCodePCM16; + TRAPD(err, m_devsound->InitializeL(*this, m_fourcc, m_nativeMode)); + if (KErrNone != err) { + m_state = StateIdle; + emit initializeComplete(err); + } + } else { + emit initializeComplete(KErrNotSupported); + } +} + +const QList& DevSoundWrapper::supportedFrequencies() const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedFrequencies; +} + +const QList& DevSoundWrapper::supportedChannels() const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedChannels; +} + +const QList& DevSoundWrapper::supportedSampleSizes() const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedSampleSizes; +} + +const QList& DevSoundWrapper::supportedByteOrders() const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedByteOrders; +} + +const QList& DevSoundWrapper::supportedSampleTypes() const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedSampleTypes; +} + +bool DevSoundWrapper::isFormatSupported(const QAudioFormat &format) const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedCodecs.contains(format.codec()) + && m_supportedFrequencies.contains(format.frequency()) + && m_supportedChannels.contains(format.channels()) + && m_supportedSampleSizes.contains(format.sampleSize()) + && m_supportedSampleTypes.contains(format.sampleType()) + && m_supportedByteOrders.contains(format.byteOrder()); +} + +int DevSoundWrapper::samplesProcessed() const +{ + Q_ASSERT(StateInitialized == m_state); + int result = 0; + switch (m_mode) { + case QAudio::AudioInput: + result = m_devsound->SamplesRecorded(); + break; + case QAudio::AudioOutput: + result = m_devsound->SamplesPlayed(); + break; + } + return result; +} + +bool DevSoundWrapper::setFormat(const QAudioFormat &format) +{ + Q_ASSERT(StateInitialized == m_state); + bool result = false; + TUint32 fourcc; + TMMFCapabilities nativeFormat; + if (Utils::formatQtToNative(format, fourcc, nativeFormat)) { + TMMFCapabilities currentNativeFormat = m_devsound->Config(); + nativeFormat.iBufferSize = currentNativeFormat.iBufferSize; + TRAPD(err, m_devsound->SetConfigL(nativeFormat)); + result = (KErrNone == err); + } + return result; +} + +bool DevSoundWrapper::start() +{ + Q_ASSERT(StateInitialized == m_state); + int err = KErrArgument; + switch (m_mode) { + case QAudio::AudioInput: + TRAP(err, m_devsound->RecordInitL()); + break; + case QAudio::AudioOutput: + TRAP(err, m_devsound->PlayInitL()); + break; + } + return (KErrNone == err); +} + +void DevSoundWrapper::pause() +{ + Q_ASSERT(StateInitialized == m_state); + m_devsound->Pause(); +} + +void DevSoundWrapper::stop() +{ + m_devsound->Stop(); +} + +void DevSoundWrapper::bufferProcessed() +{ + Q_ASSERT(StateInitialized == m_state); + switch (m_mode) { + case QAudio::AudioInput: + m_devsound->RecordData(); + break; + case QAudio::AudioOutput: + m_devsound->PlayData(); + break; + } +} + +void DevSoundWrapper::getSupportedCodecs() +{ +/* + * TODO: once we support formats other than PCM, this function should + * convert the array of FourCC codes into MIME types for each codec. + * + RArray fourcc; + QT_TRAP_THROWING(CleanupClosePushL(&fourcc)); + + TMMFPrioritySettings settings; + switch (mode) { + case QAudio::AudioOutput: + settings.iState = EMMFStatePlaying; + m_devsound->GetSupportedInputDataTypesL(fourcc, settings); + break; + + case QAudio::AudioInput: + settings.iState = EMMFStateRecording; + m_devsound->GetSupportedInputDataTypesL(fourcc, settings); + break; + + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); + } + + CleanupStack::PopAndDestroy(); // fourcc +*/ + + m_supportedCodecs.append(QLatin1String("audio/pcm")); +} + +void DevSoundWrapper::populateCapabilities() +{ + m_supportedFrequencies.clear(); + m_supportedChannels.clear(); + m_supportedSampleSizes.clear(); + m_supportedByteOrders.clear(); + m_supportedSampleTypes.clear(); + + const TMMFCapabilities caps = m_devsound->Capabilities(); + + for (int i=0; i +#include +#include #include #include #include @@ -83,60 +84,92 @@ enum State { , SuspendedState }; -/* - * Helper class for querying DevSound codec / format support +/** + * Wrapper around DevSound instance */ -class DevSoundCapabilities { +class DevSoundWrapper + : public QObject + , public MDevSoundObserver +{ + Q_OBJECT + +public: + DevSoundWrapper(QAudio::Mode mode, QObject *parent = 0); + ~DevSoundWrapper(); + public: - DevSoundCapabilities(CMMFDevSound &devsound, QAudio::Mode mode); - ~DevSoundCapabilities(); + // List of supported codecs; can be called once object is constructed + const QList& supportedCodecs() const; + + // Asynchronous initialization function; emits devsoundInitializeComplete + void initialize(const QString& codec); + + // Capabilities, for selected codec. Can be called once initialize has returned + // successfully. + const QList& supportedFrequencies() const; + const QList& supportedChannels() const; + const QList& supportedSampleSizes() const; + const QList& supportedByteOrders() const; + const QList& supportedSampleTypes() const; - const RArray& fourCC() const { return m_fourCC; } - const TMMFCapabilities& caps() const { return m_caps; } + bool isFormatSupported(const QAudioFormat &format) const; + + int samplesProcessed() const; + bool setFormat(const QAudioFormat &format); + bool start(); + void pause(); + void stop(); + void bufferProcessed(); + +public: + // MDevSoundObserver + void InitializeComplete(TInt aError); + void ToneFinished(TInt aError); + void BufferToBeFilled(CMMFBuffer *aBuffer); + void PlayError(TInt aError); + void BufferToBeEmptied(CMMFBuffer *aBuffer); + void RecordError(TInt aError); + void ConvertError(TInt aError); + void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); + +signals: + void initializeComplete(int error); + void bufferToBeProcessed(CMMFBuffer *buffer); + void processingError(int error); private: - void constructL(CMMFDevSound &devsound, QAudio::Mode mode); + void getSupportedCodecs(); + void populateCapabilities(); private: - RArray m_fourCC; - TMMFCapabilities m_caps; -}; + const QAudio::Mode m_mode; + TMMFState m_nativeMode; -namespace Utils { + enum State { + StateIdle, + StateInitializing, + StateInitialized + } m_state; -/** - * Convert native audio capabilities to QAudio lists. - */ -void capabilitiesNativeToQt(const DevSoundCapabilities &caps, - QList &frequencies, - QList &channels, - QList &sampleSizes, - QList &byteOrders, - QList &sampleTypes); + CMMFDevSound* m_devsound; + TFourCC m_fourcc; -/** - * Check whether format is supported. - */ -bool isFormatSupported(const QAudioFormat &format, - const DevSoundCapabilities &caps); + QList m_supportedCodecs; + QList m_supportedFrequencies; + QList m_supportedChannels; + QList m_supportedSampleSizes; + QList m_supportedByteOrders; + QList m_supportedSampleTypes; -/** - * Convert QAudioFormat to native format types. - * - * Note that, despite the name, DevSound uses TMMFCapabilities to specify - * single formats as well as capabilities. - * - * Note that this function does not modify outputFormat.iBufferSize. - */ -bool formatQtToNative(const QAudioFormat &inputFormat, - TUint32 &outputFourCC, - TMMFCapabilities &outputFormat); +}; + + +namespace Utils { /** * Convert internal states to QAudio states. */ -QAudio::State stateNativeToQt(State nativeState, - QAudio::State initializingState); +QAudio::State stateNativeToQt(State nativeState); /** * Convert data length to number of samples. diff --git a/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp index 36284d3..4be116f 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include #include "qaudiodeviceinfo_symbian_p.h" #include "qaudio_symbian_p.h" @@ -50,7 +51,7 @@ QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray device, , m_mode(mode) , m_updated(false) { - QT_TRAP_THROWING(m_devsound.reset(CMMFDevSound::NewL())); + } QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() @@ -85,16 +86,21 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const } if (!isFormatSupported(format)) { - if (m_frequencies.size()) - format.setFrequency(m_frequencies[0]); - if (m_channels.size()) - format.setChannels(m_channels[0]); - if (m_sampleSizes.size()) - format.setSampleSize(m_sampleSizes[0]); - if (m_byteOrders.size()) - format.setByteOrder(m_byteOrders[0]); - if (m_sampleTypes.size()) - format.setSampleType(m_sampleTypes[0]); + format = QAudioFormat(); + format.setCodec(QLatin1String("audio/pcm")); + if (m_capabilities.contains(format.codec())) { + const Capabilities &codecCaps = m_capabilities[format.codec()]; + if (codecCaps.m_frequencies.size()) + format.setFrequency(codecCaps.m_frequencies[0]); + if (codecCaps.m_channels.size()) + format.setChannels(codecCaps.m_channels[0]); + if (codecCaps.m_sampleSizes.size()) + format.setSampleSize(codecCaps.m_sampleSizes[0]); + if (codecCaps.m_byteOrders.size()) + format.setByteOrder(codecCaps.m_byteOrders[0]); + if (codecCaps.m_sampleTypes.size()) + format.setSampleType(codecCaps.m_sampleTypes[0]); + } } return format; @@ -104,14 +110,15 @@ bool QAudioDeviceInfoInternal::isFormatSupported( const QAudioFormat &format) const { getSupportedFormats(); - const bool supported = - m_codecs.contains(format.codec()) - && m_frequencies.contains(format.frequency()) - && m_channels.contains(format.channels()) - && m_sampleSizes.contains(format.sampleSize()) - && m_byteOrders.contains(format.byteOrder()) - && m_sampleTypes.contains(format.sampleType()); - + bool supported = false; + if (m_capabilities.contains(format.codec())) { + const Capabilities &codecCaps = m_capabilities[format.codec()]; + supported = codecCaps.m_frequencies.contains(format.frequency()) + && codecCaps.m_channels.contains(format.channels()) + && codecCaps.m_sampleSizes.contains(format.sampleSize()) + && codecCaps.m_byteOrders.contains(format.byteOrder()) + && codecCaps.m_sampleTypes.contains(format.sampleType()); + } return supported; } @@ -131,37 +138,37 @@ QString QAudioDeviceInfoInternal::deviceName() const QStringList QAudioDeviceInfoInternal::codecList() { getSupportedFormats(); - return m_codecs; + return m_capabilities.keys(); } QList QAudioDeviceInfoInternal::frequencyList() { getSupportedFormats(); - return m_frequencies; + return m_unionCapabilities.m_frequencies; } QList QAudioDeviceInfoInternal::channelsList() { getSupportedFormats(); - return m_channels; + return m_unionCapabilities.m_channels; } QList QAudioDeviceInfoInternal::sampleSizeList() { getSupportedFormats(); - return m_sampleSizes; + return m_unionCapabilities.m_sampleSizes; } QList QAudioDeviceInfoInternal::byteOrderList() { getSupportedFormats(); - return m_byteOrders; + return m_unionCapabilities.m_byteOrders; } QList QAudioDeviceInfoInternal::sampleTypeList() { getSupportedFormats(); - return m_sampleTypes; + return m_unionCapabilities.m_sampleTypes; } QByteArray QAudioDeviceInfoInternal::defaultInputDevice() @@ -181,17 +188,50 @@ QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode) return result; } -void QAudioDeviceInfoInternal::getSupportedFormats() const +void QAudioDeviceInfoInternal::devsoundInitializeComplete(int err) { - if (!m_updated) { - QScopedPointer caps( - new SymbianAudio::DevSoundCapabilities(*m_devsound, m_mode)); + m_intializationResult = err; + m_initializing = false; +} - SymbianAudio::Utils::capabilitiesNativeToQt(*caps, - m_frequencies, m_channels, m_sampleSizes, - m_byteOrders, m_sampleTypes); +// Helper function +template +void appendUnique(QList &left, const QList &right) +{ + foreach (const T &value, right) + if (!left.contains(value)) + left += value; +} - m_codecs.append(QLatin1String("audio/pcm")); +void QAudioDeviceInfoInternal::getSupportedFormats() const +{ + if (!m_updated) { + QScopedPointer devsound(new SymbianAudio::DevSoundWrapper(m_mode)); + connect(devsound.data(), SIGNAL(initializeComplete(int)), + this, SLOT(devsoundInitializeComplete(int))); + + foreach (const QString& codec, devsound->supportedCodecs()) { + m_initializing = true; + devsound->initialize(codec); + while (m_initializing) + QCoreApplication::instance()->processEvents(QEventLoop::WaitForMoreEvents); + if (KErrNone == m_intializationResult) { + m_capabilities[codec].m_frequencies = devsound->supportedFrequencies(); + appendUnique(m_unionCapabilities.m_frequencies, devsound->supportedFrequencies()); + + m_capabilities[codec].m_channels = devsound->supportedChannels(); + appendUnique(m_unionCapabilities.m_channels, devsound->supportedChannels()); + + m_capabilities[codec].m_sampleSizes = devsound->supportedSampleSizes(); + appendUnique(m_unionCapabilities.m_sampleSizes, devsound->supportedSampleSizes()); + + m_capabilities[codec].m_byteOrders = devsound->supportedByteOrders(); + appendUnique(m_unionCapabilities.m_byteOrders, devsound->supportedByteOrders()); + + m_capabilities[codec].m_sampleTypes = devsound->supportedSampleTypes(); + appendUnique(m_unionCapabilities.m_sampleTypes, devsound->supportedSampleTypes()); + } + } m_updated = true; } diff --git a/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h index 89e539f..79b23cc 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h @@ -53,11 +53,16 @@ #ifndef QAUDIODEVICEINFO_SYMBIAN_P_H #define QAUDIODEVICEINFO_SYMBIAN_P_H +#include #include #include QT_BEGIN_NAMESPACE +namespace SymbianAudio { +class DevSoundWrapper; +} + class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo { @@ -82,24 +87,33 @@ public: static QByteArray defaultOutputDevice(); static QList availableDevices(QAudio::Mode); +private slots: + void devsoundInitializeComplete(int err); + private: void getSupportedFormats() const; private: - QScopedPointer m_devsound; + mutable bool m_initializing; + int m_intializationResult; QString m_deviceName; QAudio::Mode m_mode; + struct Capabilities + { + QList m_frequencies; + QList m_channels; + QList m_sampleSizes; + QList m_byteOrders; + QList m_sampleTypes; + }; + // Mutable to allow lazy initialization when called from const-qualified // public functions (isFormatSupported, nearestFormat) mutable bool m_updated; - mutable QStringList m_codecs; - mutable QList m_frequencies; - mutable QList m_channels; - mutable QList m_sampleSizes; - mutable QList m_byteOrders; - mutable QList m_sampleTypes; + mutable QMap m_capabilities; + mutable Capabilities m_unionCapabilities; }; QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudioinput_symbian_p.cpp b/src/multimedia/audio/qaudioinput_symbian_p.cpp index 52daa88..9d240ca 100644 --- a/src/multimedia/audio/qaudioinput_symbian_p.cpp +++ b/src/multimedia/audio/qaudioinput_symbian_p.cpp @@ -116,16 +116,16 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, , m_pullMode(false) , m_sink(0) , m_pullTimer(new QTimer(this)) + , m_devSound(0) , m_devSoundBuffer(0) , m_devSoundBufferSize(0) , m_totalBytesReady(0) , m_devSoundBufferPos(0) , m_totalSamplesRecorded(0) { - connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); + qRegisterMetaType("CMMFBuffer *"); - SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, - m_nativeFormat); + connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); m_pullTimer->setInterval(PushInterval); connect(m_pullTimer.data(), SIGNAL(timeout()), this, SLOT(pullData())); @@ -164,7 +164,7 @@ void QAudioInputPrivate::stop() void QAudioInputPrivate::reset() { m_totalSamplesRecorded += getSamplesRecorded(); - m_devSound->Stop(); + m_devSound->stop(); startRecording(); } @@ -174,7 +174,7 @@ void QAudioInputPrivate::suspend() || SymbianAudio::IdleState == m_internalState) { m_notifyTimer->stop(); m_pullTimer->stop(); - m_devSound->Pause(); + m_devSound->pause(); const qint64 samplesRecorded = getSamplesRecorded(); m_totalSamplesRecorded += samplesRecorded; @@ -189,8 +189,11 @@ void QAudioInputPrivate::suspend() void QAudioInputPrivate::resume() { - if (SymbianAudio::SuspendedState == m_internalState) + if (SymbianAudio::SuspendedState == m_internalState) { + if (!m_pullMode && !bytesReady()) + m_devSound->start(); startDataTransfer(); + } } int QAudioInputPrivate::bytesReady() const @@ -224,11 +227,14 @@ int QAudioInputPrivate::bufferSize() const void QAudioInputPrivate::setNotifyInterval(int ms) { - if (ms > 0) { + if (ms >= 0) { const int oldNotifyInterval = m_notifyInterval; m_notifyInterval = ms; - if (m_notifyTimer->isActive() && ms != oldNotifyInterval) + if (m_notifyInterval && (SymbianAudio::ActiveState == m_internalState || + SymbianAudio::IdleState == m_internalState)) m_notifyTimer->start(m_notifyInterval); + else + m_notifyTimer->stop(); } } @@ -275,88 +281,6 @@ QAudioFormat QAudioInputPrivate::format() const return m_format; } -//----------------------------------------------------------------------------- -// MDevSoundObserver implementation -//----------------------------------------------------------------------------- - -void QAudioInputPrivate::InitializeComplete(TInt aError) -{ - Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, - Q_FUNC_INFO, "Invalid state"); - - if (KErrNone == aError) - startRecording(); -} - -void QAudioInputPrivate::ToneFinished(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's tone playback functions, so should - // never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) -{ - Q_UNUSED(aBuffer) - // This class doesn't use DevSound in play mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::PlayError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound in play mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::BufferToBeEmptied(CMMFBuffer *aBuffer) -{ - // Following receipt of this callback, DevSound should not provide another - // buffer until we have returned the current one. - Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); - - CMMFDataBuffer *const buffer = static_cast(aBuffer); - - if (!m_devSoundBufferSize) - m_devSoundBufferSize = buffer->Data().MaxLength(); - - m_totalBytesReady += buffer->Data().Length(); - - if (SymbianAudio::SuspendedState == m_internalState) { - m_devSoundBufferQ.append(buffer); - } else { - // Will be returned to DevSound by bufferEmptied(). - m_devSoundBuffer = buffer; - m_devSoundBufferPos = 0; - - if (bytesReady() && !m_pullMode) - pushData(); - } -} - -void QAudioInputPrivate::RecordError(TInt aError) -{ - Q_UNUSED(aError) - setError(QAudio::IOError); -} - -void QAudioInputPrivate::ConvertError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's format conversion functions, so - // should never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) -{ - Q_UNUSED(aMessageType) - Q_UNUSED(aMsg) - // Ignore this callback. -} //----------------------------------------------------------------------------- // Private functions @@ -367,33 +291,30 @@ void QAudioInputPrivate::open() Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, Q_FUNC_INFO, "DevSound already opened"); - QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) - - QScopedPointer caps( - new SymbianAudio::DevSoundCapabilities(*m_devSound, QAudio::AudioInput)); + Q_ASSERT(!m_devSound); + m_devSound = new SymbianAudio::DevSoundWrapper(QAudio::AudioInput, this); - int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? - KErrNone : KErrNotSupported; - - if (KErrNone == err) { - setState(SymbianAudio::InitializingState); - TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, - EMMFStateRecording)); - } + connect(m_devSound, SIGNAL(initializeComplete(int)), + this, SLOT(devsoundInitializeComplete(int))); + connect(m_devSound, SIGNAL(bufferToBeProcessed(CMMFBuffer *)), + this, SLOT(devsoundBufferToBeEmptied(CMMFBuffer *))); + connect(m_devSound, SIGNAL(processingError(int)), + this, SLOT(devsoundRecordError(int))); - if (KErrNone != err) { - setError(QAudio::OpenError); - m_devSound.reset(); - } + setState(SymbianAudio::InitializingState); + m_devSound->initialize(m_format.codec()); } void QAudioInputPrivate::startRecording() { - const int samplesRecorded = m_devSound->SamplesRecorded(); + const int samplesRecorded = m_devSound->samplesProcessed(); Q_ASSERT(samplesRecorded == 0); - TRAPD(err, startDevSoundL()); - if (KErrNone == err) { + bool ok = m_devSound->setFormat(m_format); + if (ok) + ok = m_devSound->start(); + + if (ok) { startDataTransfer(); } else { setError(QAudio::OpenError); @@ -401,17 +322,10 @@ void QAudioInputPrivate::startRecording() } } -void QAudioInputPrivate::startDevSoundL() -{ - TMMFCapabilities nativeFormat = m_devSound->Config(); - m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; - m_devSound->SetConfigL(m_nativeFormat); - m_devSound->RecordInitL(); -} - void QAudioInputPrivate::startDataTransfer() { - m_notifyTimer->start(m_notifyInterval); + if (m_notifyInterval) + m_notifyTimer->start(m_notifyInterval); if (m_pullMode) m_pullTimer->start(); @@ -503,6 +417,48 @@ void QAudioInputPrivate::pullData() } } +void QAudioInputPrivate::devsoundInitializeComplete(int err) +{ + Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, + Q_FUNC_INFO, "Invalid state"); + + if (!err && m_devSound->isFormatSupported(m_format)) + startRecording(); + else + setError(QAudio::OpenError); +} + +void QAudioInputPrivate::devsoundBufferToBeEmptied(CMMFBuffer *baseBuffer) +{ + // Following receipt of this signal, DevSound should not provide another + // buffer until we have returned the current one. + Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); + + CMMFDataBuffer *const buffer = static_cast(baseBuffer); + + if (!m_devSoundBufferSize) + m_devSoundBufferSize = buffer->Data().MaxLength(); + + m_totalBytesReady += buffer->Data().Length(); + + if (SymbianAudio::SuspendedState == m_internalState) { + m_devSoundBufferQ.append(buffer); + } else { + // Will be returned to DevSoundWrapper by bufferProcessed(). + m_devSoundBuffer = buffer; + m_devSoundBufferPos = 0; + + if (bytesReady() && !m_pullMode) + pushData(); + } +} + +void QAudioInputPrivate::devsoundRecordError(int err) +{ + Q_UNUSED(err) + setError(QAudio::IOError); +} + void QAudioInputPrivate::bufferEmptied() { m_devSoundBufferPos = 0; @@ -510,7 +466,7 @@ void QAudioInputPrivate::bufferEmptied() if (m_devSoundBuffer) { m_totalBytesReady -= m_devSoundBuffer->Data().Length(); m_devSoundBuffer = 0; - m_devSound->RecordData(); + m_devSound->bufferProcessed(); } else { Q_ASSERT(!m_devSoundBufferQ.empty()); m_totalBytesReady -= m_devSoundBufferQ.front()->Data().Length(); @@ -518,7 +474,8 @@ void QAudioInputPrivate::bufferEmptied() // If the queue has been emptied, resume transfer from the hardware if (m_devSoundBufferQ.empty()) - m_devSound->RecordInitL(); + if (!m_devSound->start()) + setError(QAudio::IOError); } Q_ASSERT(m_totalBytesReady >= 0); @@ -532,8 +489,10 @@ void QAudioInputPrivate::close() m_error = QAudio::NoError; if (m_devSound) - m_devSound->Stop(); - m_devSound.reset(); + m_devSound->stop(); + delete m_devSound; + m_devSound = 0; + m_devSoundBuffer = 0; m_devSoundBufferSize = 0; m_totalBytesReady = 0; @@ -554,7 +513,7 @@ qint64 QAudioInputPrivate::getSamplesRecorded() const { qint64 result = 0; if (m_devSound) - result = qint64(m_devSound->SamplesRecorded()); + result = qint64(m_devSound->samplesProcessed()); return result; } @@ -565,30 +524,28 @@ void QAudioInputPrivate::setError(QAudio::Error error) // Although no state transition actually occurs here, a stateChanged event // must be emitted to inform the client that the call to start() was // unsuccessful. - if (QAudio::OpenError == error) + if (QAudio::OpenError == error) { emit stateChanged(QAudio::StoppedState); - - // Close the DevSound instance. This causes a transition to StoppedState. - // This must be done asynchronously in case the current function was called - // from a DevSound event handler, in which case deleting the DevSound - // instance may cause an exception. - QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); + } else { + if (QAudio::UnderrunError == error) + setState(SymbianAudio::IdleState); + else + // Close the DevSound instance. This causes a transition to + // StoppedState. This must be done asynchronously in case the + // current function was called from a DevSound event handler, in which + // case deleting the DevSound instance may cause an exception. + QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); + } } void QAudioInputPrivate::setState(SymbianAudio::State newInternalState) { const QAudio::State oldExternalState = m_externalState; m_internalState = newInternalState; - m_externalState = SymbianAudio::Utils::stateNativeToQt( - m_internalState, initializingState()); + m_externalState = SymbianAudio::Utils::stateNativeToQt(m_internalState); if (m_externalState != oldExternalState) emit stateChanged(m_externalState); } -QAudio::State QAudioInputPrivate::initializingState() const -{ - return QAudio::IdleState; -} - QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudioinput_symbian_p.h b/src/multimedia/audio/qaudioinput_symbian_p.h index ca3ccf7..7417655 100644 --- a/src/multimedia/audio/qaudioinput_symbian_p.h +++ b/src/multimedia/audio/qaudioinput_symbian_p.h @@ -56,7 +56,6 @@ #include #include #include -#include #include "qaudio_symbian_p.h" QT_BEGIN_NAMESPACE @@ -82,7 +81,6 @@ private: class QAudioInputPrivate : public QAbstractAudioInput - , public MDevSoundObserver { friend class SymbianAudioInputPrivate; Q_OBJECT @@ -109,23 +107,15 @@ public: QAudio::State state() const; QAudioFormat format() const; - // MDevSoundObserver - void InitializeComplete(TInt aError); - void ToneFinished(TInt aError); - void BufferToBeFilled(CMMFBuffer *aBuffer); - void PlayError(TInt aError); - void BufferToBeEmptied(CMMFBuffer *aBuffer); - void RecordError(TInt aError); - void ConvertError(TInt aError); - void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); - private slots: void pullData(); + void devsoundInitializeComplete(int err); + void devsoundBufferToBeEmptied(CMMFBuffer *); + void devsoundRecordError(int err); private: void open(); void startRecording(); - void startDevSoundL(); void startDataTransfer(); CMMFDataBuffer* currentBuffer() const; void pushData(); @@ -138,8 +128,6 @@ private: void setError(QAudio::Error error); void setState(SymbianAudio::State state); - QAudio::State initializingState() const; - private: const QByteArray m_device; const QAudioFormat m_format; @@ -158,9 +146,7 @@ private: QScopedPointer m_pullTimer; - QScopedPointer m_devSound; - TUint32 m_nativeFourCC; - TMMFCapabilities m_nativeFormat; + SymbianAudio::DevSoundWrapper* m_devSound; // Latest buffer provided by DevSound, to be empied of data. CMMFDataBuffer *m_devSoundBuffer; diff --git a/src/multimedia/audio/qaudiooutput_symbian_p.cpp b/src/multimedia/audio/qaudiooutput_symbian_p.cpp index 3f8e933..5098469 100644 --- a/src/multimedia/audio/qaudiooutput_symbian_p.cpp +++ b/src/multimedia/audio/qaudiooutput_symbian_p.cpp @@ -110,6 +110,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, , m_externalState(QAudio::StoppedState) , m_pullMode(false) , m_source(0) + , m_devSound(0) , m_devSoundBuffer(0) , m_devSoundBufferSize(0) , m_bytesWritten(0) @@ -121,10 +122,9 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, , m_samplesPlayed(0) , m_totalSamplesPlayed(0) { - connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); + qRegisterMetaType("CMMFBuffer *"); - SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, - m_nativeFormat); + connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); m_underflowTimer->setInterval(UnderflowTimerInterval); connect(m_underflowTimer.data(), SIGNAL(timeout()), this, @@ -140,8 +140,6 @@ QIODevice* QAudioOutputPrivate::start(QIODevice *device) { stop(); - // We have to set these before the call to open() because of the - // logic in initializingState() if (device) { m_pullMode = true; m_source = device; @@ -171,7 +169,7 @@ void QAudioOutputPrivate::stop() void QAudioOutputPrivate::reset() { m_totalSamplesPlayed += getSamplesPlayed(); - m_devSound->Stop(); + m_devSound->stop(); m_bytesPadding = 0; startPlayback(); } @@ -196,11 +194,12 @@ void QAudioOutputPrivate::suspend() // Because this causes buffered data to be dropped, we replace the // lost data with silence following a call to resume(), in order to // ensure that processedUSecs() returns the correct value. - m_devSound->Stop(); + m_devSound->stop(); m_totalSamplesPlayed += samplesPlayed; // Calculate the amount of data dropped const qint64 paddingSamples = samplesWritten - samplesPlayed; + Q_ASSERT(paddingSamples >= 0); m_bytesPadding = SymbianAudio::Utils::samplesToBytes(m_format, paddingSamples); @@ -210,8 +209,11 @@ void QAudioOutputPrivate::suspend() void QAudioOutputPrivate::resume() { - if (SymbianAudio::SuspendedState == m_internalState) + if (SymbianAudio::SuspendedState == m_internalState) { + if (!m_pullMode && m_devSoundBuffer && m_devSoundBuffer->Data().Length()) + bufferFilled(); startPlayback(); + } } int QAudioOutputPrivate::bytesFree() const @@ -249,11 +251,14 @@ int QAudioOutputPrivate::bufferSize() const void QAudioOutputPrivate::setNotifyInterval(int ms) { - if (ms > 0) { + if (ms >= 0) { const int oldNotifyInterval = m_notifyInterval; m_notifyInterval = ms; - if (m_notifyTimer->isActive() && ms != oldNotifyInterval) + if (m_notifyInterval && (SymbianAudio::ActiveState == m_internalState || + SymbianAudio::IdleState == m_internalState)) m_notifyTimer->start(m_notifyInterval); + else + m_notifyTimer->stop(); } } @@ -300,35 +305,52 @@ QAudioFormat QAudioOutputPrivate::format() const return m_format; } + //----------------------------------------------------------------------------- -// MDevSoundObserver implementation +// Private functions //----------------------------------------------------------------------------- -void QAudioOutputPrivate::InitializeComplete(TInt aError) +void QAudioOutputPrivate::dataReady() { - Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, - Q_FUNC_INFO, "Invalid state"); + // Client-provided QIODevice has data ready to read. - if (KErrNone == aError) - startPlayback(); + Q_ASSERT_X(m_source->bytesAvailable(), Q_FUNC_INFO, + "readyRead signal received, but no data available"); + + if (!m_bytesPadding) + pullData(); } -void QAudioOutputPrivate::ToneFinished(TInt aError) +void QAudioOutputPrivate::underflowTimerExpired() { - Q_UNUSED(aError) - // This class doesn't use DevSound's tone playback functions, so should - // never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); + const TInt samplesPlayed = getSamplesPlayed(); + if (m_samplesPlayed && (samplesPlayed == m_samplesPlayed)) { + setError(QAudio::UnderrunError); + } else { + m_samplesPlayed = samplesPlayed; + m_underflowTimer->start(); + } +} + +void QAudioOutputPrivate::devsoundInitializeComplete(int err) +{ + Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, + Q_FUNC_INFO, "Invalid state"); + + if (!err && m_devSound->isFormatSupported(m_format)) + startPlayback(); + else + setError(QAudio::OpenError); } -void QAudioOutputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) +void QAudioOutputPrivate::devsoundBufferToBeFilled(CMMFBuffer *bufferBase) { - // Following receipt of this callback, DevSound should not provide another + // Following receipt of this signal, DevSound should not provide another // buffer until we have returned the current one. Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); - // Will be returned to DevSound by bufferFilled(). - m_devSoundBuffer = static_cast(aBuffer); + // Will be returned to DevSoundWrapper by bufferProcessed(). + m_devSoundBuffer = static_cast(bufferBase); if (!m_devSoundBufferSize) m_devSoundBufferSize = m_devSoundBuffer->Data().MaxLength(); @@ -339,9 +361,9 @@ void QAudioOutputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) pullData(); } -void QAudioOutputPrivate::PlayError(TInt aError) +void QAudioOutputPrivate::devsoundPlayError(int err) { - switch (aError) { + switch (err) { case KErrUnderflow: m_underflow = true; if (m_pullMode && !m_lastBuffer) @@ -355,102 +377,42 @@ void QAudioOutputPrivate::PlayError(TInt aError) } } -void QAudioOutputPrivate::BufferToBeEmptied(CMMFBuffer *aBuffer) -{ - Q_UNUSED(aBuffer) - // This class doesn't use DevSound in record mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioOutputPrivate::RecordError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound in record mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioOutputPrivate::ConvertError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's format conversion functions, so - // should never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioOutputPrivate::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) -{ - Q_UNUSED(aMessageType) - Q_UNUSED(aMsg) - // Ignore this callback. -} - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -void QAudioOutputPrivate::dataReady() -{ - // Client-provided QIODevice has data ready to read. - - Q_ASSERT_X(m_source->bytesAvailable(), Q_FUNC_INFO, - "readyRead signal received, but no data available"); - - if (!m_bytesPadding) - pullData(); -} - -void QAudioOutputPrivate::underflowTimerExpired() -{ - const TInt samplesPlayed = getSamplesPlayed(); - if (m_samplesPlayed && (samplesPlayed == m_samplesPlayed)) { - setError(QAudio::UnderrunError); - } else { - m_samplesPlayed = samplesPlayed; - m_underflowTimer->start(); - } -} - void QAudioOutputPrivate::open() { Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, Q_FUNC_INFO, "DevSound already opened"); - QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) - - QScopedPointer caps( - new SymbianAudio::DevSoundCapabilities(*m_devSound, - QAudio::AudioOutput)); + Q_ASSERT(!m_devSound); + m_devSound = new SymbianAudio::DevSoundWrapper(QAudio::AudioOutput, this); - int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? - KErrNone : KErrNotSupported; + connect(m_devSound, SIGNAL(initializeComplete(int)), + this, SLOT(devsoundInitializeComplete(int))); + connect(m_devSound, SIGNAL(bufferToBeProcessed(CMMFBuffer *)), + this, SLOT(devsoundBufferToBeFilled(CMMFBuffer *))); + connect(m_devSound, SIGNAL(processingError(int)), + this, SLOT(devsoundPlayError(int))); - if (KErrNone == err) { - setState(SymbianAudio::InitializingState); - TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, - EMMFStatePlaying)); - } - - if (KErrNone != err) { - setError(QAudio::OpenError); - m_devSound.reset(); - } + setState(SymbianAudio::InitializingState); + m_devSound->initialize(m_format.codec()); } void QAudioOutputPrivate::startPlayback() { - TRAPD(err, startDevSoundL()); - if (KErrNone == err) { + bool ok = m_devSound->setFormat(m_format); + if (ok) + ok = m_devSound->start(); + + if (ok) { if (isDataReady()) setState(SymbianAudio::ActiveState); else setState(SymbianAudio::IdleState); - m_notifyTimer->start(m_notifyInterval); + if (m_notifyInterval) + m_notifyTimer->start(m_notifyInterval); m_underflow = false; - Q_ASSERT(m_devSound->SamplesPlayed() == 0); + Q_ASSERT(m_devSound->samplesProcessed() == 0); writePaddingData(); @@ -462,14 +424,6 @@ void QAudioOutputPrivate::startPlayback() } } -void QAudioOutputPrivate::startDevSoundL() -{ - TMMFCapabilities nativeFormat = m_devSound->Config(); - m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; - m_devSound->SetConfigL(m_nativeFormat); - m_devSound->PlayInitL(); -} - void QAudioOutputPrivate::writePaddingData() { // See comments in suspend() @@ -486,10 +440,11 @@ void QAudioOutputPrivate::writePaddingData() Mem::FillZ(ptr, paddingBytes); outputBuffer.SetLength(outputBuffer.Length() + paddingBytes); m_bytesPadding -= paddingBytes; + Q_ASSERT(m_bytesPadding >= 0); if (m_pullMode && m_source->atEnd()) lastBufferFilled(); - if (paddingBytes == outputBytes) + if ((paddingBytes == outputBytes) || !m_bytesPadding) bufferFilled(); } } @@ -543,9 +498,6 @@ void QAudioOutputPrivate::pullData() Q_ASSERT_X(m_pullMode, Q_FUNC_INFO, "pullData called when in push mode"); - if (m_bytesPadding) - m_bytesPadding = 1; - // writePaddingData() is called by BufferToBeFilled() before pullData(), // so we should never have any padding data left at this point. Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO, @@ -590,7 +542,7 @@ void QAudioOutputPrivate::bufferFilled() if (QAudio::UnderrunError == m_error) m_error = QAudio::NoError; - m_devSound->PlayData(); + m_devSound->bufferProcessed(); } void QAudioOutputPrivate::lastBufferFilled() @@ -610,8 +562,10 @@ void QAudioOutputPrivate::close() m_error = QAudio::NoError; if (m_devSound) - m_devSound->Stop(); - m_devSound.reset(); + m_devSound->stop(); + delete m_devSound; + m_devSound = 0; + m_devSoundBuffer = 0; m_devSoundBufferSize = 0; @@ -644,7 +598,7 @@ qint64 QAudioOutputPrivate::getSamplesPlayed() const // This is necessary because some DevSound implementations report // that they have played more data than has actually been provided to them // by the client. - const qint64 devSoundSamplesPlayed(m_devSound->SamplesPlayed()); + const qint64 devSoundSamplesPlayed(m_devSound->samplesProcessed()); result = qMin(devSoundSamplesPlayed, samplesWritten); } } @@ -658,25 +612,25 @@ void QAudioOutputPrivate::setError(QAudio::Error error) // Although no state transition actually occurs here, a stateChanged event // must be emitted to inform the client that the call to start() was // unsuccessful. - if (QAudio::OpenError == error) + if (QAudio::OpenError == error) { emit stateChanged(QAudio::StoppedState); - - if (QAudio::UnderrunError == error) - setState(SymbianAudio::IdleState); - else - // Close the DevSound instance. This causes a transition to - // StoppedState. This must be done asynchronously in case the - // current function was called from a DevSound event handler, in which - // case deleting the DevSound instance may cause an exception. - QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); + } else { + if (QAudio::UnderrunError == error) + setState(SymbianAudio::IdleState); + else + // Close the DevSound instance. This causes a transition to + // StoppedState. This must be done asynchronously in case the + // current function was called from a DevSound event handler, in which + // case deleting the DevSound instance may cause an exception. + QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); + } } void QAudioOutputPrivate::setState(SymbianAudio::State newInternalState) { const QAudio::State oldExternalState = m_externalState; m_internalState = newInternalState; - m_externalState = SymbianAudio::Utils::stateNativeToQt( - m_internalState, initializingState()); + m_externalState = SymbianAudio::Utils::stateNativeToQt(m_internalState); if (m_externalState != oldExternalState) emit stateChanged(m_externalState); @@ -689,9 +643,4 @@ bool QAudioOutputPrivate::isDataReady() const || m_pushDataReady; } -QAudio::State QAudioOutputPrivate::initializingState() const -{ - return isDataReady() ? QAudio::ActiveState : QAudio::IdleState; -} - QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiooutput_symbian_p.h b/src/multimedia/audio/qaudiooutput_symbian_p.h index 00ccb24..c0acb07 100644 --- a/src/multimedia/audio/qaudiooutput_symbian_p.h +++ b/src/multimedia/audio/qaudiooutput_symbian_p.h @@ -80,7 +80,6 @@ private: class QAudioOutputPrivate : public QAbstractAudioOutput - , public MDevSoundObserver { friend class SymbianAudioOutputPrivate; Q_OBJECT @@ -107,24 +106,16 @@ public: QAudio::State state() const; QAudioFormat format() const; - // MDevSoundObserver - void InitializeComplete(TInt aError); - void ToneFinished(TInt aError); - void BufferToBeFilled(CMMFBuffer *aBuffer); - void PlayError(TInt aError); - void BufferToBeEmptied(CMMFBuffer *aBuffer); - void RecordError(TInt aError); - void ConvertError(TInt aError); - void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); - private slots: void dataReady(); void underflowTimerExpired(); + void devsoundInitializeComplete(int err); + void devsoundBufferToBeFilled(CMMFBuffer *); + void devsoundPlayError(int err); private: void open(); void startPlayback(); - void startDevSoundL(); void writePaddingData(); qint64 pushData(const char *data, qint64 len); void pullData(); @@ -138,7 +129,6 @@ private: void setState(SymbianAudio::State state); bool isDataReady() const; - QAudio::State initializingState() const; private: const QByteArray m_device; @@ -156,9 +146,7 @@ private: bool m_pullMode; QIODevice *m_source; - QScopedPointer m_devSound; - TUint32 m_nativeFourCC; - TMMFCapabilities m_nativeFormat; + SymbianAudio::DevSoundWrapper* m_devSound; // Buffer provided by DevSound, to be filled with data. CMMFDataBuffer *m_devSoundBuffer; -- cgit v0.12 From a863691765b1788a17a67e826f483b68f0f34066 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 10 May 2010 10:11:18 +0200 Subject: Stabilize tst_QDockWidget::taskQTBUG_9758_undockedGeometry --- tests/auto/qdockwidget/tst_qdockwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp index 3ac0ce7..2059101 100644 --- a/tests/auto/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp @@ -890,6 +890,7 @@ void tst_QDockWidget::taskQTBUG_9758_undockedGeometry() dock1.hide(); dock2.hide(); window.show(); + QTest::qWaitForWindowShown(&window); dock1.setFloating(true); dock1.show(); QTest::qWaitForWindowShown(&dock1); -- cgit v0.12 From 37b45fe0415bd6695640b26eb7545280b2e8ffe1 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 7 May 2010 16:23:10 +0200 Subject: Fix off-by-one in text layouts and widget size hints on Mac The mac font engine was made to return fractional values. This has exposed a few bugs where the rounded height of the font was used for text layouts and widget size hints. Since a fractional part of the font's height also creates pixels, rounding the height down in these cases is always wrong. The biggest culprit was QScriptLine::height. This is used to lay out text lines and returning a fractional height created problems all over the place. Rather than ceil the number in all places where it is used, we simply return a ceiled value for the line's height. In 4.6, this value would be qRound(ascent)+qRound(descent)+1, which would in some cases cause the previous and current line to overlap by one pixel. By ceiling the sum of the two, we guarantee that the text line contains the complete bounds of the font. A note about the removal of the code that gets the font metrics for QSmallFont: The condition would never be true since this is inside a branch which is only evaluated if fontIsSet is true. Task-number: QTBUG-9971 Reviewed-by: Gunnar --- src/gui/styles/qmacstyle_mac.mm | 20 +++++++++++--------- src/gui/text/qtextengine_p.h | 2 +- src/gui/widgets/qcombobox.cpp | 3 ++- src/gui/widgets/qcommandlinkbutton.cpp | 3 ++- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index f5b0b0c..e065bcc 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -97,6 +97,7 @@ #include #include #include +#include #include #include #include @@ -2142,6 +2143,9 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW // The combo box popup has no frame. if (qstyleoption_cast(opt) != 0) ret = 0; + // Frame of mac style line edits is two pixels on top and one on the bottom + else if (qobject_cast(widget) != 0) + ret = 2; else ret = 1; break; @@ -5437,14 +5441,12 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op CGFloat height; QCFString groupText = qt_mac_removeMnemonics(groupBox->text); HIThemeGetTextDimensions(groupText, 0, &tti, &width, &height, 0); - tw = int(width); - h = int(height); + tw = qRound(width); + h = qCeil(height); } else { - QFontMetrics fm = groupBox->fontMetrics; - if (!checkable && !fontIsSet) - fm = QFontMetrics(qt_app_fonts_hash()->value("QSmallFont", QFont())); - h = fm.height(); - tw = fm.size(Qt::TextShowMnemonic, groupBox->text).width(); + QFontMetricsF fm = QFontMetricsF(groupBox->fontMetrics); + h = qCeil(fm.height()); + tw = qCeil(fm.size(Qt::TextShowMnemonic, groupBox->text).width()); } ret.setHeight(h); @@ -5491,10 +5493,10 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op fm = QFontMetrics(qt_app_fonts_hash()->value("QSmallFont", QFont())); yOffset = 5; if (hasNoText) - yOffset = -fm.height(); + yOffset = -qCeil(QFontMetricsF(fm).height()); } - ret = opt->rect.adjusted(0, fm.height() + yOffset, 0, 0); + ret = opt->rect.adjusted(0, qCeil(QFontMetricsF(fm).height()) + yOffset, 0, 0); if (sc == SC_GroupBoxContents) ret.adjust(3, 3, -3, -4); // guess } diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 5054b66..d92148f 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -389,7 +389,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine mutable uint gridfitted : 1; uint hasTrailingSpaces : 1; uint leadingIncluded : 1; - QFixed height() const { return ascent + descent + 1 + QFixed height() const { return (ascent + descent).ceil() + 1 + (leadingIncluded? qMax(QFixed(),leading) : QFixed()); } QFixed base() const { return ascent + (leadingIncluded ? qMax(QFixed(),leading) : QFixed()); } diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index ca58e6d..e0b09aa 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #ifndef QT_NO_IM #include "qinputcontext.h" #endif @@ -328,7 +329,7 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const // height - sh.setHeight(qMax(fm.height(), 14) + 2); + sh.setHeight(qMax(qCeil(QFontMetricsF(fm).height()), 14) + 2); if (hasIcon) { sh.setHeight(qMax(sh.height(), iconSize.height() + 2)); } diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/gui/widgets/qcommandlinkbutton.cpp index 6919bc0..e8fe299 100644 --- a/src/gui/widgets/qcommandlinkbutton.cpp +++ b/src/gui/widgets/qcommandlinkbutton.cpp @@ -46,6 +46,7 @@ #include "qtextlayout.h" #include "qcolor.h" #include "qfont.h" +#include #include "private/qpushbutton_p.h" @@ -242,7 +243,7 @@ int QCommandLinkButtonPrivate::descriptionHeight(int widgetWidth) const } layout.endLayout(); } - return qRound(descriptionheight); + return qCeil(descriptionheight); } /*! -- cgit v0.12 From abcec6ba4b126358c50bf4c539253f88da6bb2d6 Mon Sep 17 00:00:00 2001 From: Nicolai de Haan Date: Wed, 5 May 2010 16:54:34 +0200 Subject: Opt out of visual-config size checks with extension EGL_NV_post_convert_replication. QTBUG-9444. Task-number: QTBUG-9444 Merge-request: 612 Reviewed-by: Trond --- src/gui/egl/qegl_x11.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index cb8dcda..969acc4 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -163,6 +163,11 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config) int matchingCount = 0; chosenVisualInfo = XGetVisualInfo(X11->display, VisualIDMask, &visualInfoTemplate, &matchingCount); if (chosenVisualInfo) { + // Skip size checks if implementation supports non-matching visual + // and config (http://bugreports.qt.nokia.com/browse/QTBUG-9444). + if (QEgl::hasExtension("EGL_NV_post_convert_replication")) + return visualId; + int visualRedSize = countBits(chosenVisualInfo->red_mask); int visualGreenSize = countBits(chosenVisualInfo->green_mask); int visualBlueSize = countBits(chosenVisualInfo->blue_mask); -- cgit v0.12 From 346215c3d9f0be621a833e7c735501504c7aa0b0 Mon Sep 17 00:00:00 2001 From: Jakub Wieczorek Date: Mon, 10 May 2010 11:02:37 +0200 Subject: tst_SuiteTest: Fix a meaningless switch statement The switch statement, that specifies which test handler should be used to run a test suite was missing break; statements, which made it always fall back to the XML Schema test suite. Merge-request: 619 Reviewed-by: Benjamin Poulain --- tests/auto/xmlpatternsxqts/tst_suitetest.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp index 64120c7..ec63858 100644 --- a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp +++ b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp @@ -89,10 +89,17 @@ void tst_SuiteTest::runTestSuite() const TestSuite::SuiteType suiteType; switch (m_suiteType) { - case XQuerySuite: suiteType = TestSuite::XQuerySuite; - case XsltSuite: suiteType = TestSuite::XsltSuite; - case XsdSuite: suiteType = TestSuite::XsdSuite; - default: break; + case XQuerySuite: + suiteType = TestSuite::XQuerySuite; + break; + case XsltSuite: + suiteType = TestSuite::XsltSuite; + break; + case XsdSuite: + suiteType = TestSuite::XsdSuite; + break; + default: + break; } TestSuite *const ts = TestSuite::openCatalog(catalogPath, errMsg, true, suiteType); -- cgit v0.12 From 14f97fdd925ca27ca5f3058e652223e447f24358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 10 May 2010 12:09:12 +0200 Subject: Fixed an issue with pixmaps not being released correctly in the GL 1 engine. When a pixmap is bound using the texture_from_pixmap extension we retain a reference to the pixmap to stop us destroying it before swapBuffers() or glFlush() is called. The references were not cleared out correctly in the GL 1 engine. Task-number: QTBUG-10529 Reviewed-by: Samuel --- src/opengl/qpaintengine_opengl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 57918d0..fc31548 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -1453,6 +1453,11 @@ bool QOpenGLPaintEngine::end() d->device->endPaint(); qt_mask_texture_cache()->maintainCache(); +#if defined(Q_WS_X11) + // clear out the references we hold for textures bound with the + // texture_from_pixmap extension + ctx->d_func()->boundPixmaps.clear(); +#endif return true; } -- cgit v0.12 From 005dc6c7448a724d3df496a1e528199f5a638ce0 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 7 May 2010 17:02:14 +0200 Subject: Fixes a crash in gestures. This is a partial backport of a fix that was pushed to 4.7 (734ba1f540aaedc4a3558268bd7350c0b15325a4) Task-number: QT-3349 Reviewed-by: trustme --- src/gui/graphicsview/qgraphicsscene.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 98fc10f..2131993 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -693,6 +693,14 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) --selectionChanging; if (!selectionChanging && selectedItems.size() != oldSelectedItemsSize) emit q->selectionChanged(); + + QHash::iterator it; + for (it = gestureTargets.begin(); it != gestureTargets.end();) { + if (it.value() == item) + it = gestureTargets.erase(it); + else + ++it; + } } /*! @@ -5960,7 +5968,8 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) if (gesture->state() == Qt::GestureStarted) startedGestures.insert(gesture); } else { - gesturesPerItem[target].append(gesture); + if (index->items().contains(target)) + gesturesPerItem[target].append(gesture); } } -- cgit v0.12 From 48d22dbcf4a8608b0e5242b25f0b4f771656b683 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 10 May 2010 12:51:37 +0200 Subject: Doc: Updates to the html template and javascript Reviewed-by: Morten Engvoldsen --- doc/src/template/scripts/functions.js | 9 +++++++++ tools/qdoc3/htmlgenerator.cpp | 1 + tools/qdoc3/test/qt-html-templates.qdocconf | 5 +++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/src/template/scripts/functions.js b/doc/src/template/scripts/functions.js index 108590f..2362bc4 100755 --- a/doc/src/template/scripts/functions.js +++ b/doc/src/template/scripts/functions.js @@ -50,6 +50,8 @@ function processNokiaData(response){ if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'APIPage'){ lookupCount++; //$('.live001').css('display','block'); + $('#ul001 .defaultLink').css('display','none'); + for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; @@ -62,6 +64,8 @@ function processNokiaData(response){ if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Article'){ articleCount++; //$('.live002').css('display','block'); + $('#ul002 .defaultLink').css('display','none'); + for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; @@ -73,6 +77,8 @@ function processNokiaData(response){ if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Example'){ exampleCount++; //$('.live003').css('display','block'); + $('#ul003 .defaultLink').css('display','none'); + for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; @@ -114,6 +120,9 @@ function CheckEmptyAndLoadList() // Loads on doc ready $(document).ready(function () { + var pageTitle = $('title').html(); + $('#feedform').append(''); + $('#pageType').keyup(function () { var searchString = $('#pageType').val() ; if ((searchString == null) || (searchString.length < 3)) { diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 67aa6c6..638ae94 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1849,6 +1849,7 @@ void HtmlGenerator::generateFooter(const Node *node) out() << QString(footer).replace("\\" + COMMAND_VERSION, myTree->version()) << QString(address).replace("\\" + COMMAND_VERSION, myTree->version()); + out() << " \n"; out() << "\n"; out() << "\n"; } diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index b94bb81..534f19f 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -127,8 +127,9 @@ HTML.footer = " \n" \ "
      \n" \ " X\n" \ "
      \n" \ - "
      \n" \ - "

      \n" \ + " \n" \ + "

      \n" \ + " \n" \ "

      \n" \ " \n" \ -- cgit v0.12 From da45b1ce09c318acecf8a44ca08bef57a74ff1f1 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 10 May 2010 15:00:26 +0300 Subject: QS60Style will draw focus frame to a PushButton with any stylesheeting Due to incorrect braces in the if-within-if, QS60Style decided to use QCommonStyle for styling focus frame into QPushButton when button had *any* kind of stylesheet. Corrected the braces. Task-number: QTBUG-10549 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 8bae18e..924cabc 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2045,16 +2045,17 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti case PE_FrameFocusRect: { //Draw themed highlight to radiobuttons and checkboxes. //For other widgets skip, unless palette has been modified. In that case, draw with commonstyle. - if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) + if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) { if ((qstyleoption_cast(option) && (qobject_cast(widget) || qobject_cast(widget)))) QS60StylePrivate::drawSkinElement( QS60StylePrivate::isWidgetPressed(widget) ? QS60StylePrivate::SE_ListItemPressed : QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); - else + } else { commonStyleDraws = true; } + } break; #ifndef QT_NO_LINEEDIT case PE_PanelLineEdit: -- cgit v0.12 From d47adf836b8a044dbe154dd7ffab8c057fedccbf Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 5 Mar 2010 15:48:10 +0100 Subject: Fix for torn off menus that were way too big --- src/gui/widgets/qmenu.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index d0ae90c..879ba2a 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -261,9 +261,6 @@ void QMenuPrivate::updateActionRects() const icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q); const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q); const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q); - - const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); - const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin)); const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0; //for compatability now - will have to refactor this away.. @@ -337,7 +334,7 @@ void QMenuPrivate::updateActionRects() const if (!sz.isEmpty()) { - max_column_width = qMax(min_column_width, qMax(max_column_width, sz.width())); + max_column_width = qMax(max_column_width, sz.width()); //wrapping if (!scroll && y+sz.height()+vmargin > dh - (deskFw * 2)) { @@ -351,6 +348,10 @@ void QMenuPrivate::updateActionRects() const } max_column_width += tabWidth; //finally add in the tab width + const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); + const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin)); + max_column_width = qMax(min_column_width, max_column_width); + //calculate position const int base_y = vmargin + fw + topmargin + -- cgit v0.12 From 5e07004df26cbf65a0fe0096a3417a5329f72431 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 10 May 2010 14:14:38 +0200 Subject: Doc correction to css Reviewed-by: Morten Engvoldsen --- doc/src/template/style/style.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index 644e56b..2e01af6 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -1026,8 +1026,8 @@ { display: inline-block; width: 49%; - /* *width:42%; - _width:42%;*/ + *width:42%; + _width:42%; padding:0 2% 0 1%; vertical-align:top; @@ -1036,8 +1036,8 @@ .indexboxcont .indexIcon { width: 11%; - /* *width:18%; - _width:18%;*/ + *width:18%; + _width:18%; overflow:hidden; } -- cgit v0.12 From 147ef453d130fc7817b3b4406502b1b887ab6c79 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 10 May 2010 14:20:47 +0200 Subject: qdoc: Another revision of the top doc page. More to come. --- doc/src/getting-started/examples.qdoc | 31 ++++++----------------------- doc/src/index.qdoc | 22 ++++++++++---------- doc/src/overviews.qdoc | 13 ++++++++---- tools/qdoc3/test/qt-html-templates.qdocconf | 13 ++++++------ 4 files changed, 32 insertions(+), 47 deletions(-) diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index 0088817..400714f 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -492,18 +492,10 @@ */ /*! - \group gui-examples - \title GUI Examples - \brief These pages list examples of constructing GUI components. - - \generatelist{related} -*/ - -/*! \page examples-widgets.html \title Widgets Examples \ingroup all-examples - \ingroup gui-examples + \brief Lots of examples of how to use different kinds of widgets. \contentspage Qt Examples \nextpage Dialog Examples @@ -554,7 +546,7 @@ \page examples-dialogs.html \ingroup all-examples \title Dialog Examples - \ingroup gui-examples + \brief Using Qt's standard dialogs and building and using custom dialogs. \previouspage Widgets Examples \contentspage Qt Examples @@ -586,7 +578,7 @@ \page examples-mainwindow.html \ingroup all-examples \title Main Window Examples - \ingroup gui-examples + \building applications around a main window. \previouspage Dialog Examples \contentspage Qt Examples @@ -616,7 +608,7 @@ \page examples-layouts.html \ingroup all-examples \title Layout Examples - \ingroup gui-examples + Using Qt's layout-based approach to widget management. \previouspage Main Window Examples \contentspage Qt Examples @@ -645,6 +637,7 @@ \page examples-itemviews.html \ingroup all-examples \title Item Views Examples + \brief Using the model/view design pattern to separate presentation from data. \previouspage Layout Examples \contentspage Qt Examples @@ -681,18 +674,10 @@ */ /*! - \group graphics-examples - \title Graphics Examples - \brief These pages list examples of doing graphics. - - \generatelist{related} -*/ - -/*! \page examples-graphicsview.html \ingroup all-examples \title Graphics View Examples - \ingroup graphics-examples + \brief Using Qt to manage and interact with a large (potentially) number of graphics items. \previouspage Item Views Examples \contentspage Qt Examples @@ -739,7 +724,6 @@ \page examples-painting.html \ingroup all-examples \title Painting Examples - \ingroup graphics-examples \previouspage QML Examples and Demos \contentspage Qt Examples @@ -821,7 +805,6 @@ \page examples-draganddrop.html \ingroup all-examples \title Drag and Drop Examples - \ingroup gui-examples \previouspage Desktop Examples \contentspage Qt Examples @@ -988,7 +971,6 @@ \page examples-opengl.html \ingroup all-examples \title OpenGL Examples - \ingroup graphics-examples \previouspage Inter-Process Communication Examples \contentspage Qt Examples @@ -1024,7 +1006,6 @@ \page examples-openvg.html \ingroup all-examples \title OpenVG Examples - \ingroup graphics-examples \previouspage OpenGL Examples \contentspage Qt Examples diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 92f91e6..e6efe4d 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -70,26 +70,26 @@
      • Canvas UI with Graphics View
      • -
      • UI design & Qt Quick
      • Input/output
      • Integrating Web Content
      • X-platform, debug & deploy
      • diff --git a/doc/src/overviews.qdoc b/doc/src/overviews.qdoc index b2ba3a1..cb6541d 100644 --- a/doc/src/overviews.qdoc +++ b/doc/src/overviews.qdoc @@ -49,9 +49,9 @@ /*! \group qt-basic-concepts - \title Qt Basic Concepts + \title Basic Qt Architecture - \brief The basic concepts of the Qt cross-platform application and UI framework. + \brief The basic architecture of the Qt cross-platform application and UI framework. Qt is a cross-platform application and UI framework for writing web-enabled applications for desktop, mobile, and embedded @@ -63,9 +63,14 @@ /*! \group qt-gui-concepts - \title Qt GUI Construction + \title Qt Desktop UI Components - \brief The Qt components for constructing Graphical User Intefaces. + \brief The Qt components for constructing native look & feel desktop UI's. + + These pages are about Qt's traditional set of GUI components for + building both native look ^ feel and custom UI's for the desktop + environment. Use \l {declarativeui.html} {Qt Quick} for building + UI's for mobile devices. \generatelist {related} */ diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index b94bb81..e691705 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -47,7 +47,7 @@ HTML.postheader = "
        \n" \ "
      • Modules
      • \n" \ "
      • Namespaces
      • \n" \ "
      • Global stuff
      • \n" \ - "
      • QML Elements
      • \n" \ + "
      • QML elements
      • \n" \ "
      \n" \ "
      \n" \ "
      \n" \ @@ -58,11 +58,10 @@ HTML.postheader = "
      \n" \ " Qt Topics\n" \ "
      \n" \ " \n" \ "
      \n" \ "
      \n" \ @@ -70,7 +69,7 @@ HTML.postheader = "
      \n" \ "
      \n" \ "
      \n" \ "

      \n" \ - " Qt Examples

      \n" \ + " Examples\n" \ "
      \n" \ "
        \n" \ "
      • Examples
      • \n" \ -- cgit v0.12 From 0828b63ce77846f14994f7c47468f0db8b42fbd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 10 May 2010 12:39:52 +0200 Subject: Revert "Use QUrl::isLocalFile and fix the scheme checking in local URLs." This reverts commit ebddf7a8739d7f4aaa7d9cb8a41a14eebb65e4f4. --- src/network/access/qnetworkaccessfilebackend.cpp | 11 +++-------- src/network/access/qnetworkaccessmanager.cpp | 11 ++++++----- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 6 ------ 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp index 710c258..4560153 100644 --- a/src/network/access/qnetworkaccessfilebackend.cpp +++ b/src/network/access/qnetworkaccessfilebackend.cpp @@ -65,15 +65,10 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op, } QUrl url = request.url(); - if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0 || url.isLocalFile()) { + if (url.scheme() == QLatin1String("qrc") || !url.toLocalFile().isEmpty()) return new QNetworkAccessFileBackend; - } else if (!url.scheme().isEmpty() && url.authority().isEmpty()) { - // check if QFile could, in theory, open this URL via the file engines - // it has to be in the format: - // prefix:path/to/file - // or prefix:/path/to/file - // - // this construct here must match the one below in open() + else if (!url.isEmpty() && url.authority().isEmpty()) { + // check if QFile could, in theory, open this URL QFileInfo fi(url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery)); if (fi.exists() || (op == QNetworkAccessManager::PutOperation && fi.dir().exists())) return new QNetworkAccessFileBackend; diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 10fdc6f..1c7661d 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -907,20 +907,21 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera { Q_D(QNetworkAccessManager); - bool isLocalFile = req.url().isLocalFile(); - // fast path for GET on file:// URLs + // Also if the scheme is empty we consider it a file. // The QNetworkAccessFileBackend will right now only be used // for PUT or qrc:// if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation) - && isLocalFile) { + && (req.url().scheme() == QLatin1String("file") + || req.url().scheme().isEmpty())) { return new QFileNetworkReply(this, req, op); } #ifndef QT_NO_BEARERMANAGEMENT // Return a disabled network reply if network access is disabled. // Except if the scheme is empty or file://. - if (!d->networkAccessible && !isLocalFile) { + if (!d->networkAccessible && !(req.url().scheme() == QLatin1String("file") || + req.url().scheme().isEmpty())) { return new QDisabledNetworkReply(this, req, op); } @@ -962,7 +963,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera QUrl url = request.url(); QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); #ifndef QT_NO_BEARERMANAGEMENT - if (!isLocalFile) { + if (req.url().scheme() != QLatin1String("file") && !req.url().scheme().isEmpty()) { connect(this, SIGNAL(networkSessionConnected()), reply, SLOT(_q_networkSessionConnected())); } diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index c4d458f..9d942bf 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -1166,12 +1166,6 @@ void tst_QNetworkReply::getErrors_data() QTest::addColumn("httpStatusCode"); QTest::addColumn("dataIsEmpty"); - // empties - QTest::newRow("empty-url") << QString() << int(QNetworkReply::ProtocolUnknownError) << 0 << true; - QTest::newRow("empty-scheme-host") << SRCDIR "/rfc3252.txt" << int(QNetworkReply::ProtocolUnknownError) << 0 << true; - QTest::newRow("empty-scheme") << "//" + QtNetworkSettings::winServerName() + "/testshare/test.pri" - << int(QNetworkReply::ProtocolUnknownError) << 0 << true; - // file: errors QTest::newRow("file-host") << "file://this-host-doesnt-exist.troll.no/foo.txt" #if !defined Q_OS_WIN -- cgit v0.12 From 82433177590490e6a69074c2d86adaa7741b4913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 10 May 2010 14:11:54 +0200 Subject: Revert "QUrl::fromLocalFile: fix silly mistake: it's fromNativeSeparators, not to" This reverts commit f5366aea8594946e78106c5f93ecb2d47f121d32. --- src/corelib/io/qurl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index d6ded9d..7e5c622 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5991,7 +5991,7 @@ QUrl QUrl::fromLocalFile(const QString &localFile) { QUrl url; url.setScheme(QLatin1String("file")); - QString deslashified = QDir::fromNativeSeparators(localFile); + QString deslashified = QDir::toNativeSeparators(localFile); // magic for drives on windows if (deslashified.length() > 1 && deslashified.at(1) == QLatin1Char(':') && deslashified.at(0) != QLatin1Char('/')) { -- cgit v0.12 From cc422e939d671bba8d70a5d02abfb893627303cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 10 May 2010 14:12:42 +0200 Subject: Revert "[QNAM FTP] Check for the "ftp" scheme case-insensitively" This reverts commit a9fb306a1cf1308a3f8b9bb12ed01aed1f6f6f8d. --- src/network/access/qnetworkaccessftpbackend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index da336d0..1a59011 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -77,7 +77,7 @@ QNetworkAccessFtpBackendFactory::create(QNetworkAccessManager::Operation op, } QUrl url = request.url(); - if (url.scheme().compare(QLatin1String("ftp"), Qt::CaseInsensitive) == 0) + if (url.scheme() == QLatin1String("ftp")) return new QNetworkAccessFtpBackend; return 0; } -- cgit v0.12 From 98e935eed5549e479f6666680aed1711dc42111c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 10 May 2010 14:12:52 +0200 Subject: Revert "Improve QUrl handling of local file paths" This reverts commit a2f797b52c4274a62a7cf1f0939aca1429afe211. --- src/corelib/io/qurl.cpp | 73 +++++++++++++------------------------------- src/corelib/io/qurl.h | 1 - tests/auto/qurl/tst_qurl.cpp | 11 +------ 3 files changed, 23 insertions(+), 62 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 7e5c622..d4b8b5f 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5976,22 +5976,19 @@ bool QUrl::isDetached() const /*! - Returns a QUrl representation of \a localFile, interpreted as a local - file. This function accepts paths separated by slashes as well as the - native separator for this platform. + Returns a QUrl representation of \a localFile, interpreted as a + local file. - This function also accepts paths with a doubled leading slash (or - backslash) to indicate a remote file, as in - "//servername/path/to/file.txt". Note that only certain platforms can - actually open this file using QFile::open(). - - \sa toLocalFile(), isLocalFile(), QDir::toNativeSeparators + \sa toLocalFile() */ QUrl QUrl::fromLocalFile(const QString &localFile) { QUrl url; url.setScheme(QLatin1String("file")); - QString deslashified = QDir::toNativeSeparators(localFile); + QString deslashified = localFile; + deslashified.replace(QLatin1Char('\\'), QLatin1Char('/')); + + // magic for drives on windows if (deslashified.length() > 1 && deslashified.at(1) == QLatin1Char(':') && deslashified.at(0) != QLatin1Char('/')) { @@ -6010,61 +6007,35 @@ QUrl QUrl::fromLocalFile(const QString &localFile) } /*! - Returns the path of this URL formatted as a local file path. The path - returned will use forward slashes, even if it was originally created - from one with backslashes. + Returns the path of this URL formatted as a local file path. - If this URL contains a non-empty hostname, it will be encoded in the - returned value in the form found on SMB networks (for example, - "//servername/path/to/file.txt"). - - \sa fromLocalFile(), isLocalFile() + \sa fromLocalFile() */ QString QUrl::toLocalFile() const { - // the call to isLocalFile() also ensures that we're parsed - if (!isLocalFile()) - return QString(); + if (!d) return QString(); + if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); QString tmp; QString ourPath = path(); + if (d->scheme.isEmpty() || QString::compare(d->scheme, QLatin1String("file"), Qt::CaseInsensitive) == 0) { - // magic for shared drive on windows - if (!d->host.isEmpty()) { - tmp = QLatin1String("//") + d->host + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/') - ? QLatin1Char('/') + ourPath : ourPath); - } else { - tmp = ourPath; - // magic for drives on windows - if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':')) - tmp.remove(0, 1); + // magic for shared drive on windows + if (!d->host.isEmpty()) { + tmp = QLatin1String("//") + d->host + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/') + ? QLatin1Char('/') + ourPath : ourPath); + } else { + tmp = ourPath; + // magic for drives on windows + if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':')) + tmp.remove(0, 1); + } } return tmp; } /*! - \since 4.7 - Returns true if this URL is pointing to a local file path. A URL is a - local file path if the scheme is "file". - - Note that this function considers URLs with hostnames to be local file - paths, even if the eventual file path cannot be opened with - QFile::open(). - - \sa fromLocalFile(), toLocalFile() -*/ -bool QUrl::isLocalFile() const -{ - if (!d) return false; - if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); - - if (d->scheme.compare(QLatin1String("file"), Qt::CaseInsensitive) != 0) - return false; // not file - return true; -} - -/*! Returns true if this URL is a parent of \a childUrl. \a childUrl is a child of this URL if the two URLs share the same scheme and authority, and this URL's path is a parent of the path of \a childUrl. diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 162aa7c..6f8331a 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -183,7 +183,6 @@ public: static QUrl fromLocalFile(const QString &localfile); QString toLocalFile() const; - bool isLocalFile() const; QString toString(FormattingOptions options = None) const; diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 67bf0c1..fa42adc 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -314,7 +314,6 @@ void tst_QUrl::constructing() QUrl buildUNC; - buildUNC.setScheme(QString::fromLatin1("file")); buildUNC.setHost(QString::fromLatin1("somehost")); buildUNC.setPath(QString::fromLatin1("somepath")); QCOMPARE(buildUNC.toLocalFile(), QString::fromLatin1("//somehost/somepath")); @@ -1758,15 +1757,7 @@ void tst_QUrl::toLocalFile_data() QTest::newRow("data7") << QString::fromLatin1("file://somehost/") << QString::fromLatin1("//somehost/"); QTest::newRow("data8") << QString::fromLatin1("file://somehost") << QString::fromLatin1("//somehost"); QTest::newRow("data9") << QString::fromLatin1("file:////somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile"); - QTest::newRow("data10") << QString::fromLatin1("FILE:/a.txt") << QString::fromLatin1("/a.txt"); - - // and some that result in empty (i.e., not local) - QTest::newRow("xdata0") << QString::fromLatin1("/a.txt") << QString(); - QTest::newRow("xdata1") << QString::fromLatin1("//a.txt") << QString(); - QTest::newRow("xdata2") << QString::fromLatin1("///a.txt") << QString(); - QTest::newRow("xdata3") << QString::fromLatin1("foo:/a.txt") << QString(); - QTest::newRow("xdata4") << QString::fromLatin1("foo://a.txt") << QString(); - QTest::newRow("xdata5") << QString::fromLatin1("foo:///a.txt") << QString(); + } void tst_QUrl::toLocalFile() -- cgit v0.12 From 79a173386abe7dbd0dba2bc8c96298484a3bba27 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 10 May 2010 14:48:27 +0200 Subject: An improvement to the previous commit. This fixes 005dc6c7448a724d3df496a1e528199f5a638ce0 that was pushed by mistake. Task-number: QT-3349 Reviewed-by: trustme --- src/gui/graphicsview/qgraphicsscene.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 2131993..c5e3644 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -696,10 +696,10 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) QHash::iterator it; for (it = gestureTargets.begin(); it != gestureTargets.end();) { - if (it.value() == item) - it = gestureTargets.erase(it); - else - ++it; + if (it.value() == item) + it = gestureTargets.erase(it); + else + ++it; } } @@ -5968,8 +5968,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) if (gesture->state() == Qt::GestureStarted) startedGestures.insert(gesture); } else { - if (index->items().contains(target)) - gesturesPerItem[target].append(gesture); + gesturesPerItem[target].append(gesture); } } -- cgit v0.12 From 349a8e83b8a5dd352fd2db053562b6bd874f30e8 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 10 May 2010 14:23:30 +0200 Subject: Improved mapping of locales on symbian. Map Latin American Spanish to es_MX - Spanish in Mexica - the locale data for those two locales are the same, so it should be more or less safe. The proper solution is to add support for es-419_419 and es_419 locales to QLocale. Task-number: QT-3312 Reviewed-by: trustme --- src/corelib/tools/qlocale_symbian.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index b1a7caa..2e5daec 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -134,7 +134,7 @@ static const symbianToISO symbian_to_iso_list[] = { { ELangBrazilianPortuguese, "pt_BR" }, { ELangRomanian, "ro_RO" }, { ELangSerbian, "sr_YU" }, - { ELangLatinAmericanSpanish, "es" }, + { ELangLatinAmericanSpanish,"es_MX" }, // TODO: should be es_419 { ELangUkrainian, "uk_UA" }, { ELangUrdu, "ur_PK" }, // India/Pakistan { ELangVietnamese, "vi_VN" }, -- cgit v0.12 From ae09e6a14dce54190758428a9ea369cd28d36d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 10 May 2010 15:23:09 +0200 Subject: Made paint engine texture drawing work in GL ES 2 and updated docs. Now QGLWidget::drawTexture() can be used on OpenGL ES 2.0 when there's an active painter. Task-number: QTBUG-10420 Reviewed-by: Trond --- src/opengl/qgl.cpp | 73 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index cfacf26..a3c1bac 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2773,23 +2773,27 @@ static void qDrawTextureRect(const QRectF &target, GLint textureWidth, GLint tex /*! \since 4.4 - Draws the given texture, \a textureId, to the given target rectangle, - \a target, in OpenGL model space. The \a textureTarget should be a 2D - texture target. + This function supports the following use cases: + + \list + \i On OpenGL and OpenGL ES 1.x it draws the given texture, \a textureId, + to the given target rectangle, \a target, in OpenGL model space. The + \a textureTarget should be a 2D texture target. + \i On OpenGL and OpenGL ES 2.x, if a painter is active, not inside a + beginNativePainting / endNativePainting block, and uses the + engine with type QPaintEngine::OpenGL2, the function will draw the given + texture, \a textureId, to the given target rectangle, \a target, + respecting the current painter state. This will let you draw a texture + with the clip, transform, render hints, and composition mode set by the + painter. Note that the texture target needs to be GL_TEXTURE_2D for this + use case, and that this is the only supported use case under OpenGL ES 2.x. + \endlist - \note This function is not supported under OpenGL/ES 2.0. */ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) { -#ifndef QT_OPENGL_ES_2 -#ifdef QT_OPENGL_ES - if (textureTarget != GL_TEXTURE_2D) { - qWarning("QGLContext::drawTexture(): texture target must be GL_TEXTURE_2D on OpenGL ES"); - return; - } -#else - - if (d_ptr->active_engine && +#if !defined(QT_OPENGL_ES) || defined(QT_OPENGL_ES_2) + if (d_ptr->active_engine && d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { QGL2PaintEngineEx *eng = static_cast(d_ptr->active_engine); if (!eng->isNativePaintingActive()) { @@ -2799,7 +2803,15 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text return; } } +#endif +#ifndef QT_OPENGL_ES_2 +#ifdef QT_OPENGL_ES + if (textureTarget != GL_TEXTURE_2D) { + qWarning("QGLContext::drawTexture(): texture target must be GL_TEXTURE_2D on OpenGL ES"); + return; + } +#else const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D); GLint oldTexture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture); @@ -2821,7 +2833,7 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text Q_UNUSED(target); Q_UNUSED(textureId); Q_UNUSED(textureTarget); - qWarning("drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) not supported with OpenGL ES/2.0"); + qWarning("drawTexture() with OpenGL ES 2.0 requires an active OpenGL2 paint engine"); #endif } @@ -2836,14 +2848,26 @@ void QGLContext::drawTexture(const QRectF &target, QMacCompatGLuint textureId, Q /*! \since 4.4 - Draws the given texture at the given \a point in OpenGL model - space. The \a textureTarget should be a 2D texture target. + This function supports the following use cases: + + \list + \i By default it draws the given texture, \a textureId, + at the given \a point in OpenGL model space. The + \a textureTarget should be a 2D texture target. + \i If a painter is active, not inside a + beginNativePainting / endNativePainting block, and uses the + engine with type QPaintEngine::OpenGL2, the function will draw the given + texture, \a textureId, at the given \a point, + respecting the current painter state. This will let you draw a texture + with the clip, transform, render hints, and composition mode set by the + painter. Note that the texture target needs to be GL_TEXTURE_2D for this + use case. + \endlist - \note This function is not supported under OpenGL/ES. + \note This function is not supported under any version of OpenGL ES. */ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) { - // this would be ok on OpenGL ES 2.0, but currently we don't have a define for that #ifdef QT_OPENGL_ES Q_UNUSED(point); Q_UNUSED(textureId); @@ -4911,11 +4935,8 @@ void QGLWidget::deleteTexture(QMacCompatGLuint id) /*! \since 4.4 - Draws the given texture, \a textureId to the given target rectangle, - \a target, in OpenGL model space. The \a textureTarget should be a 2D - texture target. - - Equivalent to the corresponding QGLContext::drawTexture(). + Calls the corresponding QGLContext::drawTexture() on + this widget's context. */ void QGLWidget::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) { @@ -4935,10 +4956,8 @@ void QGLWidget::drawTexture(const QRectF &target, QMacCompatGLuint textureId, QM /*! \since 4.4 - Draws the given texture, \a textureId, at the given \a point in OpenGL - model space. The \a textureTarget should be a 2D texture target. - - Equivalent to the corresponding QGLContext::drawTexture(). + Calls the corresponding QGLContext::drawTexture() on + this widget's context. */ void QGLWidget::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) { -- cgit v0.12 From e5622ab31b8cd20074fe29c1d597c1d7f4c6e6e8 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 10 May 2010 16:34:51 +0200 Subject: Fix typos in Elastic Nodes example documentation. Among other things, use \c instead of \e (courier instead of italic). --- doc/src/examples/elasticnodes.qdoc | 124 +++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 59 deletions(-) diff --git a/doc/src/examples/elasticnodes.qdoc b/doc/src/examples/elasticnodes.qdoc index edc62d8..e6e6594 100644 --- a/doc/src/examples/elasticnodes.qdoc +++ b/doc/src/examples/elasticnodes.qdoc @@ -83,7 +83,7 @@ also reimplements \l{QGraphicsItem::shape()}{shape()} to ensure its hit area has an elliptic shape (as opposed to the default bounding rectangle). - For edge management purposes the node provides a simple API for adding + For edge management purposes, the node provides a simple API for adding edges to a node, and for listing all connected edges. The \l{QGraphicsItem::advance()}{advance()} reimplementation is called @@ -126,16 +126,21 @@ \snippet examples/graphicsview/elasticnodes/node.cpp 2 - The \e calculateForces() function implements the elastic forces effect that - pulls and pushes on nodes in the grid. In addition to this algorithm, the - user can move one node around with the mouse. Because we do not want the - two to interfere, we start by checking if this \c Node is the current mouse - grabber item (i.e., QGraphicsScene::mouseGrabberItem()). Because we need to - find all neighboring (but not necessarily connected) nodes, we also make - sure the item is part of a scene in the first place. + There are two ways to move a node. The \c calculateForces() function + implements the elastic effect that pulls and pushes on nodes in the grid. + In addition, the user can directly move one node around with the mouse. + Because we do not want the two approaches to operate at the same time on + the same node, we start \c calculateForces() by checking if this \c Node is + the current mouse grabber item (i.e., QGraphicsScene::mouseGrabberItem()). + Because we need to find all neighboring (but not necessarily connected) + nodes, we also make sure the item is part of a scene in the first place. \snippet examples/graphicsview/elasticnodes/node.cpp 3 + The "elastic" effect comes from an algorithm that applies pushing and + pulling forces. The effect is impressive, and surprisingly simple to + implement. + The algorithm has two steps: the first is to calculate the forces that push the nodes apart, and the second is to subtract the forces that pull the nodes together. First we need to find all the nodes in the graph. We call @@ -143,19 +148,20 @@ qgraphicsitem_cast() to look for \c Node instances. We make use of \l{QGraphicsItem::mapFromItem()}{mapFromItem()} to create a - vector pointing from this node to each other node, in \l{The Graphics View - Coordinate System}{local coordinates}. We use the decomposed components of - this vector to determine the direction and strength of force that apply to - the node. The forces are added up for each node, and weighted so that the - closest nodes are given the strongest force. The sum of all forces are - stored in \e xvel (X-velocity) and \e yvel (Y-velocity). + temporary vector pointing from this node to each other node, in \l{The + Graphics View Coordinate System}{local coordinates}. We use the decomposed + components of this vector to determine the direction and strength of force + that should apply to the node. The forces accumulate for each node, and are + then adjusted so that the closest nodes are given the strongest force, with + rapid degradation when distance increases. The sum of all forces is stored + in \c xvel (X-velocity) and \c yvel (Y-velocity). \snippet examples/graphicsview/elasticnodes/node.cpp 4 - The edges between the nodes represent the forces that pull the nodes - together. By visiting each edge that is connected to this node, we can use - a similar approach as above to find the direction and strength of all - forces. These forces are subtracted from \e xvel and \e yvel. + The edges between the nodes represent forces that pull the nodes together. + By visiting each edge that is connected to this node, we can use a similar + approach as above to find the direction and strength of all pulling forces. + These forces are subtracted from \c xvel and \c yvel. \snippet examples/graphicsview/elasticnodes/node.cpp 5 @@ -166,20 +172,20 @@ \snippet examples/graphicsview/elasticnodes/node.cpp 6 - The final step of \e calculateForces() determines the node's new position. + The final step of \c calculateForces() determines the node's new position. We add the force to the node's current position. We also make sure the new position stays inside of our defined boundaries. We don't actually move the - item in this function; that's done in a separate step, from \e advance(). + item in this function; that's done in a separate step, from \c advance(). \snippet examples/graphicsview/elasticnodes/node.cpp 7 - The \e advance() function updates the item's current position. It is called - from \e GraphWidget::timerEvent(). If the node's position changed, the + The \c advance() function updates the item's current position. It is called + from \c GraphWidget::timerEvent(). If the node's position changed, the function returns true; otherwise false is returned. \snippet examples/graphicsview/elasticnodes/node.cpp 8 - The \e Node's bounding rectangle is a 20x20 sized rectangle centered around + The \c Node's bounding rectangle is a 20x20 sized rectangle centered around its origin (0, 0), adjusted by 2 units in all directions to compensate for the node's outline stroke, and by 3 units down and to the right to make room for a simple drop shadow. @@ -188,8 +194,8 @@ The shape is a simple ellipse. This ensures that you must click inside the node's elliptic shape in order to drag it around. You can test this effect - by running the example, and zooming far enough in so that the nodes become - very large. Without reimplementing \l{QGraphicsItem::shape()}{shape()}, the + by running the example, and zooming far in so that the nodes are very + large. Without reimplementing \l{QGraphicsItem::shape()}{shape()}, the item's hit area would be identical to its bounding rectangle (i.e., rectangular). @@ -197,7 +203,7 @@ This function implements the node's painting. We start by drawing a simple dark gray elliptic drop shadow at (-7, -7), that is, (3, 3) units down and - to the right. + to the right from the top-left corner (-10, -10) of the ellipse. We then draw an ellipse with a radial gradient fill. This fill is either Qt::yellow to Qt::darkYellow when raised, or the opposite when sunken. In @@ -217,8 +223,8 @@ calculations. This notification is the only reason why the nodes need to keep a pointer - back to the \e GraphWidget. Another approach could be to provide such - notification using a signal; in such case, \e Node would need to inherit + back to the \c GraphWidget. Another approach could be to provide such + notification using a signal; in such case, \c Node would need to inherit from QGraphicsObject. \snippet examples/graphicsview/elasticnodes/node.cpp 12 @@ -226,14 +232,14 @@ Because we have set the \l{QGraphicsItem::ItemIsMovable}{ItemIsMovable} flag, we don't need to implement the logic that moves the node according to mouse input; this is already provided for us. We still need to reimplement - the mouse press and release handlers though, to update the nodes' visual + the mouse press and release handlers, though, to update the nodes' visual appearance (i.e., sunken or raised). \section1 Edge Class Definition - The \e Edge class represents the arrow-lines between the nodes in this + The \c Edge class represents the arrow-lines between the nodes in this example. The class is very simple: it maintains a source- and destination - node pointer, and provides an \e adjust() function that makes sure the line + node pointer, and provides an \c adjust() function that makes sure the line starts at the position of the source, and ends at the position of the destination. The edges are the only items that change continuously as forces pull and push on the nodes. @@ -242,13 +248,13 @@ \snippet examples/graphicsview/elasticnodes/edge.h 0 - \e Edge inherits from QGraphicsItem, as it's a simple class that has no use + \c Edge inherits from QGraphicsItem, as it's a simple class that has no use for signals, slots, and properties (compare to QGraphicsObject). The constructor takes two node pointers as input. Both pointers are mandatory in this example. We also provide get-functions for each node. - The \e adjust() function repositions the edge, and the item also implements + The \c adjust() function repositions the edge, and the item also implements \l{QGraphicsItem::boundingRect()}{boundingRect()} and \{QGraphicsItem::paint()}{paint()}. @@ -256,7 +262,7 @@ \snippet examples/graphicsview/elasticnodes/edge.cpp 0 - The \e Edge constructor initializes its arrowSize data member to 10 units; + The \c Edge constructor initializes its \c arrowSize data member to 10 units; this determines the size of the arrow which is drawn in \l{QGraphicsItem::paint()}{paint()}. @@ -265,7 +271,7 @@ This ensures that the edge items are not considered for mouse input at all (i.e., you cannot click the edges). Then, the source and destination pointers are updated, this edge is registered with each node, and we call - \e adjust() to update this edge's start end end position. + \c adjust() to update this edge's start end end position. \snippet examples/graphicsview/elasticnodes/edge.cpp 1 @@ -274,7 +280,7 @@ \snippet examples/graphicsview/elasticnodes/edge.cpp 2 - In \e adjust(), we define two points: \e sourcePoint, and \e destPoint, + In \c adjust(), we define two points: \c sourcePoint, and \c destPoint, pointing at the source and destination nodes' origins respectively. Each point is calculated using \l{The Graphics View Coordinate System}{local coordinates}. @@ -295,7 +301,7 @@ It's important to notice that we call \l{QGraphicsItem::prepareGeometryChange()}{prepareGeometryChange()} in this - function. The reason is that the variables \e sourcePoint and \e destPoint + function. The reason is that the variables \c sourcePoint and \c destPoint are used directly when painting, and they are returned from the \l{QGraphicsItem::boundingRect()}{boundingRect()} reimplementation. We must always call @@ -338,26 +344,26 @@ \section1 GraphWidget Class Definition - \e GraphWidget is a subclass of QGraphicsView, which provides the main + \c GraphWidget is a subclass of QGraphicsView, which provides the main window with scrollbars. \snippet examples/graphicsview/elasticnodes/graphwidget.h 0 - It provides a basic constructor that initializes the scene, an \e + The class provides a basic constructor that initializes the scene, an \c itemMoved() function to notify changes in the scene's node graph, a few event handlers, a reimplementation of \l{QGraphicsView::drawBackground()}{drawBackground()}, and a helper - function for scaling the view by mouse or keyboard. + function for scaling the view by using the mouse wheel or keyboard. \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 0 - \e GraphicsWidget's constructor creates the scene, and because most items - move around most of the time, it sets QGraphicsScene::NoIndex. Then the - scene gets a fixed \l{QGraphicsScene::sceneRect}{scene rectangle}. - The scene is then assigned to the \e GraphWidget view. + \c GraphicsWidget's constructor creates the scene, and because most items + move around most of the time, it sets QGraphicsScene::NoIndex. The scene + then gets a fixed \l{QGraphicsScene::sceneRect}{scene rectangle}, and is + assigned to the \c GraphWidget view. The view enables QGraphicsView::CacheBackground to cache rendering of its - static and somewhat complex background. Because the graph renders a close + static, and somewhat complex, background. Because the graph renders a close collection of small items that all move around, it's unnecessary for Graphics View to waste time finding accurate update regions, so we set the QGraphicsView::BoundingRectViewportUpdate viewport update mode. The default @@ -381,15 +387,15 @@ \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 2 - \e GraphWidget is notified of node movement through this \e itemMoved() + \c GraphWidget is notified of node movement through this \c itemMoved() function. Its job is simply to restart the main timer in case it's not running already. The timer is designed to stop when the graph stabilizes, and start once it's unstable again. \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 3 - This is \e GraphWidget's key event handler. The arrow keys move the center - node around, the '+' and '-' keys zoom in and out by calling \e + This is \c GraphWidget's key event handler. The arrow keys move the center + node around, the '+' and '-' keys zoom in and out by calling \c scaleView(), and the enter and space keys randomize the positions of the nodes. All other key events (e.g., page up and page down) are handled by QGraphicsView's default implementation. @@ -398,16 +404,16 @@ The timer event handler's job is to run the whole force calculation machinery as a smooth animation. Each time the timer is triggered, the - handler will find all nodes in the scene, and call \e + handler will find all nodes in the scene, and call \c Node::calculateForces() on each node, one at a time. Then, in a final step - it will call \e Node::advance() to move all nodes to their new positions. - By checking the return value of \e advance(), we can decide if the grid + it will call \c Node::advance() to move all nodes to their new positions. + By checking the return value of \c advance(), we can decide if the grid stabilized (i.e., no nodes moved). If so, we can stop the timer. \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 5 In the wheel event handler, we convert the mouse wheel delta to a scale - factor, and pass this factor to \e scaleView(). This approach takes into + factor, and pass this factor to \c scaleView(). This approach takes into account the speed that the wheel is rolled. The faster you roll the mouse wheel, the faster the view will zoom. @@ -415,24 +421,24 @@ The view's background is rendered in a reimplementation of QGraphicsView::drawBackground(). We draw a large rectangle filled with a - linear gradient, with a drop shadow, and then render text in top. The text - is rendered twice to give a similar simple drop-shadow effect. + linear gradient, add a drop shadow, and then render text on top. The text + is rendered twice for a simple drop-shadow effect. This background rendering is quite expensive; this is why the view enables QGraphicsView::CacheBackground. \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 7 - The \e scaleView() helper function checks that the scale factor stays + The \c scaleView() helper function checks that the scale factor stays within certain limits (i.e., you cannot zoom too far in nor too far out), - and then applies this scale. + and then applies this scale to the view. \section1 The main() Function - In contrast to the complexity of the rest of this example, the \e main() + In contrast to the complexity of the rest of this example, the \c main() function is very simple: We create a QApplication instance, seed the - randomizer using qsrand(), and then create and show an instance of \e - GraphWidget. Because all nodes in the grid are moved initially, the \e + randomizer using qsrand(), and then create and show an instance of \c + GraphWidget. Because all nodes in the grid are moved initially, the \c GraphWidget timer will start immediately after control has returned to the event loop. */ -- cgit v0.12 From 121e325e7bb2f14f4c9e4e25078ac16b47dcd372 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 10 May 2010 21:13:21 +0200 Subject: Really fix tst_QDockWidget::taskQTBUG_9758_undockedGeometry on Linux If there is no window manager the current coordinate are taken in account even if WA_Moved is false. When a dockwidget is hidden, it is sent far in the negative coordinate. The test was failing because the WM is assync and may take some time to update the geometry. --- src/gui/widgets/qdockwidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index ae00710..11f0a94 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -1269,8 +1269,11 @@ void QDockWidget::setFloating(bool floating) QRect r = d->undockedGeometry; d->setWindowState(floating, false, floating ? r : QRect()); + if (floating && r.isNull()) { - setAttribute(Qt::WA_Moved, false); //we want it at the default position + if (x() < 0 || y() < 0) //may happen if we have been hidden + move(QPoint()); + setAttribute(Qt::WA_Moved, false); //we want it at the default position } } -- cgit v0.12 From 2445d7adc19bb1355cbba8361345feb9d4cf10f9 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 11 May 2010 09:21:50 +0200 Subject: Emit numFlagsChanged Task-number: QTBUG-10552 --- demos/declarative/minehunt/minehunt.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/demos/declarative/minehunt/minehunt.cpp b/demos/declarative/minehunt/minehunt.cpp index 93cd1c1..2a4ed10 100644 --- a/demos/declarative/minehunt/minehunt.cpp +++ b/demos/declarative/minehunt/minehunt.cpp @@ -212,6 +212,8 @@ void MinehuntGame::reset() } nMines = 12; nFlags = 0; + emit numMinesChanged(); + emit numFlagsChanged(); setPlaying(false); QTimer::singleShot(600,this, SLOT(setBoard())); } -- cgit v0.12 From 952ab3f97a77c1f15b526df13c96602f6501f8ea Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 11 May 2010 17:44:12 +1000 Subject: Cleanup and simplify the webbrowser demo. --- demos/declarative/webbrowser/content/Button.qml | 18 ++ .../webbrowser/content/FlickableWebView.qml | 2 +- demos/declarative/webbrowser/content/Header.qml | 69 ++++++++ .../webbrowser/content/RectSoftShadow.qml | 32 ---- .../content/RetractingWebBrowserHeader.qml | 113 ------------- demos/declarative/webbrowser/content/ScrollBar.qml | 66 ++++++++ demos/declarative/webbrowser/content/UrlInput.qml | 44 +++++ .../webbrowser/content/fieldtext/FieldText.qml | 157 ------------------ .../webbrowser/content/fieldtext/pics/cancel.png | Bin 1038 -> 0 bytes .../webbrowser/content/fieldtext/pics/ok.png | Bin 655 -> 0 bytes .../webbrowser/content/pics/addressbar-filled.png | Bin 694 -> 0 bytes .../webbrowser/content/pics/addressbar-filled.sci | 6 - .../webbrowser/content/pics/addressbar.png | Bin 467 -> 0 bytes .../webbrowser/content/pics/addressbar.sci | 6 - .../webbrowser/content/pics/back-disabled.png | Bin 475 -> 0 bytes demos/declarative/webbrowser/content/pics/back.png | Bin 707 -> 0 bytes .../webbrowser/content/pics/display.png | Bin 0 -> 998 bytes .../webbrowser/content/pics/edit-delete.png | Bin 0 -> 1333 bytes .../declarative/webbrowser/content/pics/footer.png | Bin 200 -> 0 bytes .../declarative/webbrowser/content/pics/footer.sci | 6 - .../webbrowser/content/pics/forward-disabled.png | Bin 471 -> 0 bytes .../webbrowser/content/pics/forward.png | Bin 682 -> 0 bytes .../webbrowser/content/pics/go-next-view.png | Bin 0 -> 1187 bytes .../webbrowser/content/pics/go-previous-view.png | Bin 0 -> 1226 bytes .../declarative/webbrowser/content/pics/header.png | Bin 193 -> 0 bytes .../declarative/webbrowser/content/pics/reload.png | Bin 1283 -> 0 bytes .../webbrowser/content/pics/scrollbar.png | Bin 0 -> 161 bytes .../webbrowser/content/pics/softshadow-bottom.png | Bin 186 -> 0 bytes .../webbrowser/content/pics/softshadow-left.png | Bin 598 -> 0 bytes .../webbrowser/content/pics/softshadow-left.sci | 5 - .../webbrowser/content/pics/softshadow-right.png | Bin 636 -> 0 bytes .../webbrowser/content/pics/softshadow-right.sci | 5 - .../webbrowser/content/pics/softshadow-top.png | Bin 186 -> 0 bytes .../webbrowser/content/pics/titlebar-bg.png | Bin 0 -> 213 bytes .../webbrowser/content/pics/view-refresh.png | Bin 0 -> 2182 bytes demos/declarative/webbrowser/webbrowser.qml | 183 +++------------------ 36 files changed, 225 insertions(+), 487 deletions(-) create mode 100644 demos/declarative/webbrowser/content/Button.qml create mode 100644 demos/declarative/webbrowser/content/Header.qml delete mode 100644 demos/declarative/webbrowser/content/RectSoftShadow.qml delete mode 100644 demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml create mode 100644 demos/declarative/webbrowser/content/ScrollBar.qml create mode 100644 demos/declarative/webbrowser/content/UrlInput.qml delete mode 100644 demos/declarative/webbrowser/content/fieldtext/FieldText.qml delete mode 100644 demos/declarative/webbrowser/content/fieldtext/pics/cancel.png delete mode 100644 demos/declarative/webbrowser/content/fieldtext/pics/ok.png delete mode 100644 demos/declarative/webbrowser/content/pics/addressbar-filled.png delete mode 100644 demos/declarative/webbrowser/content/pics/addressbar-filled.sci delete mode 100644 demos/declarative/webbrowser/content/pics/addressbar.png delete mode 100644 demos/declarative/webbrowser/content/pics/addressbar.sci delete mode 100644 demos/declarative/webbrowser/content/pics/back-disabled.png delete mode 100644 demos/declarative/webbrowser/content/pics/back.png create mode 100644 demos/declarative/webbrowser/content/pics/display.png create mode 100644 demos/declarative/webbrowser/content/pics/edit-delete.png delete mode 100644 demos/declarative/webbrowser/content/pics/footer.png delete mode 100644 demos/declarative/webbrowser/content/pics/footer.sci delete mode 100644 demos/declarative/webbrowser/content/pics/forward-disabled.png delete mode 100644 demos/declarative/webbrowser/content/pics/forward.png create mode 100644 demos/declarative/webbrowser/content/pics/go-next-view.png create mode 100644 demos/declarative/webbrowser/content/pics/go-previous-view.png delete mode 100644 demos/declarative/webbrowser/content/pics/header.png delete mode 100644 demos/declarative/webbrowser/content/pics/reload.png create mode 100644 demos/declarative/webbrowser/content/pics/scrollbar.png delete mode 100644 demos/declarative/webbrowser/content/pics/softshadow-bottom.png delete mode 100644 demos/declarative/webbrowser/content/pics/softshadow-left.png delete mode 100644 demos/declarative/webbrowser/content/pics/softshadow-left.sci delete mode 100644 demos/declarative/webbrowser/content/pics/softshadow-right.png delete mode 100644 demos/declarative/webbrowser/content/pics/softshadow-right.sci delete mode 100644 demos/declarative/webbrowser/content/pics/softshadow-top.png create mode 100644 demos/declarative/webbrowser/content/pics/titlebar-bg.png create mode 100644 demos/declarative/webbrowser/content/pics/view-refresh.png diff --git a/demos/declarative/webbrowser/content/Button.qml b/demos/declarative/webbrowser/content/Button.qml new file mode 100644 index 0000000..a1baf16 --- /dev/null +++ b/demos/declarative/webbrowser/content/Button.qml @@ -0,0 +1,18 @@ +import Qt 4.7 + +Item { + property alias image: icon.source + property variant action + + width: 40; height: parent.height + + Image { + id: icon; anchors.centerIn: parent + opacity: action.enabled ? 1.0 : 0.4 + } + + MouseArea { + anchors { fill: parent; topMargin: -10; bottomMargin: -10 } + onClicked: action.trigger() + } +} diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 50ea97d..2862cc4 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -15,7 +15,7 @@ Flickable { contentWidth: Math.max(parent.width,webView.width*webView.scale) contentHeight: Math.max(parent.height,webView.height*webView.scale) anchors.top: headerSpace.bottom - anchors.bottom: footer.top + anchors.bottom: parent.top anchors.left: parent.left anchors.right: parent.right pressDelay: 200 diff --git a/demos/declarative/webbrowser/content/Header.qml b/demos/declarative/webbrowser/content/Header.qml new file mode 100644 index 0000000..7c93580 --- /dev/null +++ b/demos/declarative/webbrowser/content/Header.qml @@ -0,0 +1,69 @@ +import Qt 4.7 + +Image { + property alias editUrl: urlInput.url + + source: "pics/titlebar-bg.png"; fillMode: Image.TileHorizontally + + x: webView.contentX < 0 ? -webView.contentX : webView.contentX > webView.contentWidth-webView.width + ? -webView.contentX+webView.contentWidth-webView.width : 0 + + y: { + if (webView.progress < 1.0) + return 0; + else { + webView.contentY < 0 ? -webView.contentY : webView.contentY > height ? -height : -webView.contentY + } + } + + Column { + width: parent.width + + Item { + width: parent.width; height: 20 + Text { + anchors.centerIn: parent + text: webView.title; font.pixelSize: 14; font.bold: true + color: "white"; styleColor: "black"; style: Text.Sunken + } + } + + Item { + width: parent.width; height: 40 + + Button { + id: backButton + action: webView.back; image: "pics/go-previous-view.png" + anchors { left: parent.left; bottom: parent.bottom } + } + + Button { + id: nextButton + anchors.left: backButton.right + action: webView.forward; image: "pics/go-next-view.png" + } + + UrlInput { + id: urlInput + anchors { left: nextButton.right; right: reloadButton.left } + image: "pics/display.png" + onUrlEntered: { + webBrowser.urlString = url + webBrowser.focus = true + } + } + + Button { + id: reloadButton + anchors { right: parent.right; rightMargin: 4 } + action: webView.reload; image: "pics/view-refresh.png"; visible: webView.progress == 1.0 + } + + Button { + id: stopButton + anchors { right: parent.right; rightMargin: 4 } + action: webView.stop; image: "pics/edit-delete.png"; visible: webView.progress < 1.0 + } + } + } +} diff --git a/demos/declarative/webbrowser/content/RectSoftShadow.qml b/demos/declarative/webbrowser/content/RectSoftShadow.qml deleted file mode 100644 index 53d098c..0000000 --- a/demos/declarative/webbrowser/content/RectSoftShadow.qml +++ /dev/null @@ -1,32 +0,0 @@ -import Qt 4.7 - -Item { - BorderImage { - source: "pics/softshadow-left.sci" - x: -16 - y: -16 - width: 16 - height: parent.height+32 - } - BorderImage { - source: "pics/softshadow-right.sci" - x: parent.width - y: -16 - width: 16 - height: parent.height+32 - } - Image { - source: "pics/softshadow-top.png" - x: 0 - y: -16 - width: parent.width - height: 16 - } - Image { - source: "pics/softshadow-bottom.png" - x: 0 - y: parent.height - width: parent.width - height: 16 - } -} diff --git a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml b/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml deleted file mode 100644 index b02a5bf..0000000 --- a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml +++ /dev/null @@ -1,113 +0,0 @@ -import Qt 4.7 - -import "fieldtext" - -Image { - property alias editUrl: editUrl.text - - id: header - source: "pics/header.png" - width: parent.width - height: 60 - x: webView.contentX < 0 ? -webView.contentX : webView.contentX > webView.contentWidth-webView.width - ? -webView.contentX+webView.contentWidth-webView.width : 0 - y: webView.contentY < 0 ? -webView.contentY : progressOff* - (webView.contentY>height?-height:-webView.contentY) - Row { - id: headerTitle - - anchors.top: header.top - anchors.topMargin: 4 - x: parent.width > headerIcon.width+headerText.width+6 ? (parent.width-headerIcon.width-headerText.width-6)/2 : 0 - spacing: 6 - - Image { - id: headerIcon - pixmap: webView.icon - } - - Text { - id: headerText - - text: webView.title!='' || webView.progress == 1.0 ? webView.title : 'Loading...' - - color: "white" - styleColor: "black" - style: Text.Raised - - font.family: "Helvetica" - font.pointSize: 10 - font.bold: true - - horizontalAlignment: Text.AlignHCenter - } - } - Item { - width: parent.width - anchors.top: headerTitle.bottom - anchors.topMargin: 2 - anchors.bottom: parent.bottom - - Item { - id: urlBox - height: 31 - anchors.left: parent.left - anchors.leftMargin: 12 - anchors.right: parent.right - anchors.rightMargin: 12 - anchors.top: parent.top - clip: true - property bool mouseGrabbed: false - - BorderImage { - source: "pics/addressbar.sci" - anchors.fill: urlBox - } - - BorderImage { - id: urlBoxhl - source: "pics/addressbar-filled.sci" - width: parent.width*webView.progress - height: parent.height - opacity: 1-header.progressOff - clip: true - } - - FieldText { - id: editUrl - mouseGrabbed: parent.mouseGrabbed - - text: webBrowser.urlString - label: "url:" - onConfirmed: { webBrowser.urlString = editUrl.text; webView.focus=true } - onCancelled: { webView.focus=true } - onStartEdit: { webView.focus=false } - - anchors.left: urlBox.left - anchors.right: urlBox.right - anchors.leftMargin: 6 - anchors.verticalCenter: urlBox.verticalCenter - anchors.verticalCenterOffset: 1 - } - } - } - - property real progressOff : 1 - states: [ - State { - name: "ProgressShown" - when: webView.progress < 1.0 - PropertyChanges { target: header; progressOff: 0; } - } - ] - transitions: [ - Transition { - NumberAnimation { - targets: header - properties: "progressOff" - easing.type: Easing.InOutQuad - duration: 300 - } - } - ] -} diff --git a/demos/declarative/webbrowser/content/ScrollBar.qml b/demos/declarative/webbrowser/content/ScrollBar.qml new file mode 100644 index 0000000..976297b --- /dev/null +++ b/demos/declarative/webbrowser/content/ScrollBar.qml @@ -0,0 +1,66 @@ +import Qt 4.7 + +Item { + id: container + + property variant scrollArea + property variant orientation: Qt.Vertical + + opacity: 0 + + function position() + { + var ny = 0; + if (container.orientation == Qt.Vertical) + ny = scrollArea.visibleArea.yPosition * container.height; + else + ny = scrollArea.visibleArea.xPosition * container.width; + if (ny > 2) return ny; else return 2; + } + + function size() + { + var nh, ny; + + if (container.orientation == Qt.Vertical) + nh = scrollArea.visibleArea.heightRatio * container.height; + else + nh = scrollArea.visibleArea.widthRatio * container.width; + + if (container.orientation == Qt.Vertical) + ny = scrollArea.visibleArea.yPosition * container.height; + else + ny = scrollArea.visibleArea.xPosition * container.width; + + if (ny > 3) { + var t; + if (container.orientation == Qt.Vertical) + t = Math.ceil(container.height - 3 - ny); + else + t = Math.ceil(container.width - 3 - ny); + if (nh > t) return t; else return nh; + } else return nh + ny; + } + + Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.5 } + + BorderImage { + source: "pics/scrollbar.png" + border { left: 1; right: 1; top: 1; bottom: 1 } + x: container.orientation == Qt.Vertical ? 2 : position() + width: container.orientation == Qt.Vertical ? container.width - 4 : size() + y: container.orientation == Qt.Vertical ? position() : 2 + height: container.orientation == Qt.Vertical ? size() : container.height - 4 + } + + states: State { + name: "visible" + when: scrollArea.moving + PropertyChanges { target: container; opacity: 1.0 } + } + + transitions: Transition { + from: "visible"; to: "" + NumberAnimation { properties: "opacity"; duration: 600 } + } +} diff --git a/demos/declarative/webbrowser/content/UrlInput.qml b/demos/declarative/webbrowser/content/UrlInput.qml new file mode 100644 index 0000000..9f7fc38 --- /dev/null +++ b/demos/declarative/webbrowser/content/UrlInput.qml @@ -0,0 +1,44 @@ +import Qt 4.7 + +Item { + id: container + + property alias image: bg.source + property alias url: urlText.text + + signal urlEntered(string url) + + width: parent.height; height: parent.height + + BorderImage { + id: bg; rotation: 180 + x: 8; width: parent.width - 16; height: 30; + anchors.verticalCenter: parent.verticalCenter + border { left: 10; top: 10; right: 10; bottom: 10 } + } + + Rectangle { + anchors.bottom: bg.bottom + x: 18; height: 4; color: "#63b1ed" + width: (bg.width - 20) * webView.progress + opacity: webView.progress == 1.0 ? 0.0 : 1.0 + } + + TextInput { + id: urlText + horizontalAlignment: TextEdit.AlignLeft + font.pixelSize: 14; focusOnPress: true + Keys.onEscapePressed: { + urlText.text = webView.url + webView.focus = true + } + Keys.onReturnPressed: { + container.urlEntered(urlText.text) + webView.focus = true + } + anchors { + left: parent.left; right: parent.right; leftMargin: 18; rightMargin: 18 + verticalCenter: parent.verticalCenter + } + } +} diff --git a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml deleted file mode 100644 index d1d003f..0000000 --- a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml +++ /dev/null @@ -1,157 +0,0 @@ -import Qt 4.7 - -Item { - id: fieldText - height: 30 - property string text: "" - property string label: "" - property bool mouseGrabbed: false - signal confirmed - signal cancelled - signal startEdit - - function edit() { - if (!mouseGrabbed) { - fieldText.startEdit(); - fieldText.state='editing'; - mouseGrabbed=true; - } - } - - function confirm() { - fieldText.state=''; - fieldText.text = textEdit.text; - mouseGrabbed=false; - fieldText.confirmed(); - } - - function reset() { - textEdit.text = fieldText.text; - fieldText.state=''; - mouseGrabbed=false; - fieldText.cancelled(); - } - - Image { - id: cancelIcon - width: 22 - height: 22 - anchors.right: parent.right - anchors.rightMargin: 4 - anchors.verticalCenter: parent.verticalCenter - source: "pics/cancel.png" - opacity: 0 - } - - Image { - id: confirmIcon - width: 22 - height: 22 - anchors.left: parent.left - anchors.leftMargin: 4 - anchors.verticalCenter: parent.verticalCenter - source: "pics/ok.png" - opacity: 0 - } - - TextInput { - id: textEdit - text: fieldText.text - focus: false - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.right: parent.right - anchors.rightMargin: 0 - anchors.verticalCenter: parent.verticalCenter - color: "black" - font.bold: true - readOnly: true - onAccepted: confirm() - Keys.onEscapePressed: reset() - } - - Text { - id: textLabel - x: 5 - width: parent.width-10 - anchors.verticalCenter: parent.verticalCenter - horizontalAlignment: Text.AlignHCenter - color: fieldText.state == "editing" ? "#505050" : "#AAAAAA" - font.italic: true - font.bold: true - text: label - opacity: textEdit.text == '' ? 1 : 0 - Behavior on opacity { - NumberAnimation { - property: "opacity" - duration: 250 - } - } - } - - MouseArea { - anchors.fill: cancelIcon - onClicked: { reset() } - } - - MouseArea { - anchors.fill: confirmIcon - onClicked: { confirm() } - } - - MouseArea { - id: editRegion - anchors.fill: textEdit - onClicked: { edit() } - } - - states: [ - State { - name: "editing" - PropertyChanges { - target: confirmIcon - opacity: 1 - } - PropertyChanges { - target: cancelIcon - opacity: 1 - } - PropertyChanges { - target: textEdit - color: "black" - readOnly: false - focus: true - selectionStart: 0 - selectionEnd: -1 - } - PropertyChanges { - target: editRegion - opacity: 0 - } - PropertyChanges { - target: textEdit.anchors - leftMargin: 34 - } - PropertyChanges { - target: textEdit.anchors - rightMargin: 34 - } - } - ] - - transitions: [ - Transition { - from: "" - to: "*" - reversible: true - NumberAnimation { - properties: "opacity,leftMargin,rightMargin" - duration: 200 - } - ColorAnimation { - property: "color" - duration: 150 - } - } - ] -} diff --git a/demos/declarative/webbrowser/content/fieldtext/pics/cancel.png b/demos/declarative/webbrowser/content/fieldtext/pics/cancel.png deleted file mode 100644 index ecc9533..0000000 Binary files a/demos/declarative/webbrowser/content/fieldtext/pics/cancel.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/fieldtext/pics/ok.png b/demos/declarative/webbrowser/content/fieldtext/pics/ok.png deleted file mode 100644 index 5795f04..0000000 Binary files a/demos/declarative/webbrowser/content/fieldtext/pics/ok.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/addressbar-filled.png b/demos/declarative/webbrowser/content/pics/addressbar-filled.png deleted file mode 100644 index d8452ec..0000000 Binary files a/demos/declarative/webbrowser/content/pics/addressbar-filled.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/addressbar-filled.sci b/demos/declarative/webbrowser/content/pics/addressbar-filled.sci deleted file mode 100644 index 96c5efb..0000000 --- a/demos/declarative/webbrowser/content/pics/addressbar-filled.sci +++ /dev/null @@ -1,6 +0,0 @@ -border.left: 7 -border.top: 7 -border.bottom: 7 -border.right: 7 -source: addressbar-filled.png - diff --git a/demos/declarative/webbrowser/content/pics/addressbar.png b/demos/declarative/webbrowser/content/pics/addressbar.png deleted file mode 100644 index 3278f58..0000000 Binary files a/demos/declarative/webbrowser/content/pics/addressbar.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/addressbar.sci b/demos/declarative/webbrowser/content/pics/addressbar.sci deleted file mode 100644 index 8f1cd18..0000000 --- a/demos/declarative/webbrowser/content/pics/addressbar.sci +++ /dev/null @@ -1,6 +0,0 @@ -border.left: 7 -border.top: 7 -border.bottom: 7 -border.right: 7 -source: addressbar.png - diff --git a/demos/declarative/webbrowser/content/pics/back-disabled.png b/demos/declarative/webbrowser/content/pics/back-disabled.png deleted file mode 100644 index 91b9e76..0000000 Binary files a/demos/declarative/webbrowser/content/pics/back-disabled.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/back.png b/demos/declarative/webbrowser/content/pics/back.png deleted file mode 100644 index 9988dd3..0000000 Binary files a/demos/declarative/webbrowser/content/pics/back.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/display.png b/demos/declarative/webbrowser/content/pics/display.png new file mode 100644 index 0000000..9507f43 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/display.png differ diff --git a/demos/declarative/webbrowser/content/pics/edit-delete.png b/demos/declarative/webbrowser/content/pics/edit-delete.png new file mode 100644 index 0000000..351659b Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/edit-delete.png differ diff --git a/demos/declarative/webbrowser/content/pics/footer.png b/demos/declarative/webbrowser/content/pics/footer.png deleted file mode 100644 index 8391a93..0000000 Binary files a/demos/declarative/webbrowser/content/pics/footer.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/footer.sci b/demos/declarative/webbrowser/content/pics/footer.sci deleted file mode 100644 index 7be58f1..0000000 --- a/demos/declarative/webbrowser/content/pics/footer.sci +++ /dev/null @@ -1,6 +0,0 @@ -border.left: 5 -border.top: 0 -border.bottom: 0 -border.right: 5 -source: footer.png - diff --git a/demos/declarative/webbrowser/content/pics/forward-disabled.png b/demos/declarative/webbrowser/content/pics/forward-disabled.png deleted file mode 100644 index cb87f4f..0000000 Binary files a/demos/declarative/webbrowser/content/pics/forward-disabled.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/forward.png b/demos/declarative/webbrowser/content/pics/forward.png deleted file mode 100644 index 83870ee..0000000 Binary files a/demos/declarative/webbrowser/content/pics/forward.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/go-next-view.png b/demos/declarative/webbrowser/content/pics/go-next-view.png new file mode 100644 index 0000000..3bce02d Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/go-next-view.png differ diff --git a/demos/declarative/webbrowser/content/pics/go-previous-view.png b/demos/declarative/webbrowser/content/pics/go-previous-view.png new file mode 100644 index 0000000..3ec011e Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/go-previous-view.png differ diff --git a/demos/declarative/webbrowser/content/pics/header.png b/demos/declarative/webbrowser/content/pics/header.png deleted file mode 100644 index 26588c3..0000000 Binary files a/demos/declarative/webbrowser/content/pics/header.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/reload.png b/demos/declarative/webbrowser/content/pics/reload.png deleted file mode 100644 index 45b5535..0000000 Binary files a/demos/declarative/webbrowser/content/pics/reload.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/scrollbar.png b/demos/declarative/webbrowser/content/pics/scrollbar.png new file mode 100644 index 0000000..0228dcf Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/scrollbar.png differ diff --git a/demos/declarative/webbrowser/content/pics/softshadow-bottom.png b/demos/declarative/webbrowser/content/pics/softshadow-bottom.png deleted file mode 100644 index 85b0b44..0000000 Binary files a/demos/declarative/webbrowser/content/pics/softshadow-bottom.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/softshadow-left.png b/demos/declarative/webbrowser/content/pics/softshadow-left.png deleted file mode 100644 index 02926d1..0000000 Binary files a/demos/declarative/webbrowser/content/pics/softshadow-left.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/softshadow-left.sci b/demos/declarative/webbrowser/content/pics/softshadow-left.sci deleted file mode 100644 index 45c88d5..0000000 --- a/demos/declarative/webbrowser/content/pics/softshadow-left.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 0 -border.top: 16 -border.bottom: 16 -border.right: 0 -source: softshadow-left.png diff --git a/demos/declarative/webbrowser/content/pics/softshadow-right.png b/demos/declarative/webbrowser/content/pics/softshadow-right.png deleted file mode 100644 index e459f4f..0000000 Binary files a/demos/declarative/webbrowser/content/pics/softshadow-right.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/softshadow-right.sci b/demos/declarative/webbrowser/content/pics/softshadow-right.sci deleted file mode 100644 index 4d459c0..0000000 --- a/demos/declarative/webbrowser/content/pics/softshadow-right.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 0 -border.top: 16 -border.bottom: 16 -border.right: 0 -source: softshadow-right.png diff --git a/demos/declarative/webbrowser/content/pics/softshadow-top.png b/demos/declarative/webbrowser/content/pics/softshadow-top.png deleted file mode 100644 index 9a9e232..0000000 Binary files a/demos/declarative/webbrowser/content/pics/softshadow-top.png and /dev/null differ diff --git a/demos/declarative/webbrowser/content/pics/titlebar-bg.png b/demos/declarative/webbrowser/content/pics/titlebar-bg.png new file mode 100644 index 0000000..06961e8 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/titlebar-bg.png differ diff --git a/demos/declarative/webbrowser/content/pics/view-refresh.png b/demos/declarative/webbrowser/content/pics/view-refresh.png new file mode 100644 index 0000000..afa2a9d Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/view-refresh.png differ diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index f1a6034..27da814 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -3,168 +3,39 @@ import org.webkit 1.0 import "content" -Item { +Rectangle { id: webBrowser property string urlString : "http://qt.nokia.com/" - width: 640 - height: 480 + width: 800; height: 600 + color: "#343434" + + FlickableWebView { + id: webView + url: webBrowser.urlString + anchors { top: headerSpace.bottom; left: parent.left; right: parent.right; bottom: parent.bottom } + + } Item { - id: webPanel - anchors.fill: parent - clip: true - Rectangle { - color: "#555555" - anchors.fill: parent - } - Image { - source: "content/pics/softshadow-bottom.png" - width: webPanel.width - height: 16 - } - Image { - source: "content/pics/softshadow-top.png" - width: webPanel.width - height: 16 - anchors.bottom: footer.top - } - RectSoftShadow { - x: -webView.contentX - y: -webView.contentY - width: webView.contentWidth - height: webView.contentHeight+headerSpace.height - } - Item { - id: headerSpace - width: parent.width - height: 60 - z: 1 + id: headerSpace + width: parent.width; height: 62 + } - RetractingWebBrowserHeader { id: header } - } - FlickableWebView { - id: webView - width: parent.width - anchors.top: headerSpace.bottom - anchors.bottom: footer.top - anchors.left: parent.left - anchors.right: parent.right - } - BorderImage { - id: footer - source: "content/pics/footer.sci" - width: parent.width - height: 43 - anchors.bottom: parent.bottom - Rectangle { - y: -1 - width: parent.width - height: 1 - color: "#555555" - } - Item { - id: backbutton - width: back_e.width - height: back_e.height - anchors.right: reload.left - anchors.rightMargin: 10 - anchors.verticalCenter: parent.verticalCenter - Image { - id: back_e - source: "content/pics/back.png" - anchors.fill: parent - } - Image { - id: back_d - source: "content/pics/back-disabled.png" - anchors.fill: parent - } - states: [ - State { - name: "Enabled" - when: webView.back.enabled==true - PropertyChanges { target: back_e; opacity: 1 } - PropertyChanges { target: back_d; opacity: 0 } - }, - State { - name: "Disabled" - when: webView.back.enabled==false - PropertyChanges { target: back_e; opacity: 0 } - PropertyChanges { target: back_d; opacity: 1 } - } - ] - transitions: [ - Transition { - NumberAnimation { - properties: "opacity" - easing.type: Easing.InOutQuad - duration: 300 - } - } - ] - MouseArea { - anchors.fill: back_e - onClicked: { if (webView.back.enabled) webView.back.trigger() } - } - } - Image { - id: reload - source: "content/pics/reload.png" - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - } - MouseArea { - anchors.fill: reload - onClicked: { webView.reload.trigger() } - } - Item { - id: forwardbutton - width: forward_e.width - height: forward_e.height - anchors.left: reload.right - anchors.leftMargin: 10 - anchors.verticalCenter: parent.verticalCenter - Image { - id: forward_e - source: "content/pics/forward.png" - anchors.fill: parent - anchors.verticalCenter: parent.verticalCenter - } - Image { - id: forward_d - source: "content/pics/forward-disabled.png" - anchors.fill: parent - } - states: [ - State { - name: "Enabled" - when: webView.forward.enabled==true - PropertyChanges { target: forward_e; opacity: 1 } - PropertyChanges { target: forward_d; opacity: 0 } - }, - State { - name: "Disabled" - when: webView.forward.enabled==false - PropertyChanges { target: forward_e; opacity: 0 } - PropertyChanges { target: forward_d; opacity: 1 } - } - ] - transitions: [ - Transition { - NumberAnimation { - properties: "opacity" - easing.type: Easing.InOutQuad - duration: 320 - } - } - ] - MouseArea { - anchors.fill: parent - onClicked: { if (webView.forward.enabled) webView.forward.trigger() } - } - } - } + Header { + id: header + editUrl: webBrowser.urlString + width: headerSpace.width; height: headerSpace.height } + + ScrollBar { + scrollArea: webView; width: 8 + anchors { right: parent.right; top: header.bottom; bottom: parent.bottom } + } + +// ScrollBar { +// scrollArea: webView; height: 8; orientation: Qt.Horizontal +// anchors { right: parent.right; rightMargin: 8; left: parent.left; bottom: parent.bottom } +// } } -- cgit v0.12 From 4d36724867d77f3c8bf31b084ef8beae3a9646b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 11 May 2010 09:58:41 +0200 Subject: Fixed a potential crash with misconfigured CUPS printers. Task-number: QTBUG-10512 Reviewed-by: Kim --- src/gui/dialogs/qprintdialog_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp index 00dc3e6..9135350 100644 --- a/src/gui/dialogs/qprintdialog_unix.cpp +++ b/src/gui/dialogs/qprintdialog_unix.cpp @@ -968,7 +968,7 @@ void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) void QUnixPrintWidgetPrivate::setCupsProperties() { - if (cups && QCUPSSupport::isAvailable()) { + if (cups && QCUPSSupport::isAvailable() && cups->pageSizes()) { QPrintEngine *engine = printer->printEngine(); const ppd_option_t* pageSizes = cups->pageSizes(); QByteArray cupsPageSize; -- cgit v0.12 From a7b128ae838b006be1259ef6ba79da5440ed52dd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 11 May 2010 09:59:56 +0200 Subject: Stabilize tst_QColumnView::parentCurrentIndex --- tests/auto/qcolumnview/tst_qcolumnview.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/auto/qcolumnview/tst_qcolumnview.cpp b/tests/auto/qcolumnview/tst_qcolumnview.cpp index 90f499d..1da8c5d 100644 --- a/tests/auto/qcolumnview/tst_qcolumnview.cpp +++ b/tests/auto/qcolumnview/tst_qcolumnview.cpp @@ -596,11 +596,11 @@ void tst_QColumnView::clicked() QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, localPoint); QCOMPARE(clickedSpy.count(), 1); qApp->processEvents(); - + if (sizeof(qreal) != sizeof(double)) { QSKIP("Skipped due to rounding errors", SkipAll); } - + for (int i = 0; i < view.createdColumns.count(); ++i) { QAbstractItemView *column = view.createdColumns.at(i); if (column && column->selectionModel() && (column->rootIndex() == home)) @@ -961,9 +961,9 @@ void tst_QColumnView::parentCurrentIndex() QVERIFY(third.isValid()); view.setCurrentIndex(third); QTest::qWait(ANIMATION_DELAY); - QCOMPARE(view.createdColumns[0]->currentIndex(), first); - QCOMPARE(view.createdColumns[1]->currentIndex(), second); - QCOMPARE(view.createdColumns[2]->currentIndex(), third); + QTRY_COMPARE(view.createdColumns[0]->currentIndex(), first); + QTRY_COMPARE(view.createdColumns[1]->currentIndex(), second); + QTRY_COMPARE(view.createdColumns[2]->currentIndex(), third); first = model.index(0, 0, QModelIndex()); second = model.index(secondRow, 0, first); -- cgit v0.12 From 560aa609be8b3f4d05e3df050cfa4feb39d060f1 Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Tue, 11 May 2010 11:11:39 +0300 Subject: Spectrum Analyzer demo Symbian fix Fixes compilation and deployment issue when compiling the app from root directory. Reviewed-by: Gareth Stockwell --- demos/spectrum/spectrum.pro | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/demos/spectrum/spectrum.pro b/demos/spectrum/spectrum.pro index 86a7583..04bbdee 100644 --- a/demos/spectrum/spectrum.pro +++ b/demos/spectrum/spectrum.pro @@ -1,3 +1,4 @@ +load(data_caging_paths) include(spectrum.pri) TEMPLATE = subdirs @@ -21,19 +22,16 @@ symbian { # UID for the SIS file TARGET.UID3 = 0xA000E3FA - epoc32_dir = $${EPOCROOT}epoc32 - release_dir = $${epoc32_dir}/release/$(PLATFORM)/$(TARGET) - - bin.sources = $${release_dir}/spectrum.exe + bin.sources = spectrum.exe !contains(DEFINES, DISABLE_FFT) { - bin.sources += $${release_dir}/fftreal.dll + bin.sources += fftreal.dll } - bin.path = !:/sys/bin - rsc.sources = $${epoc32_dir}/data/z/resource/apps/spectrum.rsc - rsc.path = !:/resource/apps - mif.sources = $${epoc32_dir}/data/z/resource/apps/spectrum.mif - mif.path = !:/resource/apps - reg_rsc.sources = $${epoc32_dir}/data/z/private/10003a3f/import/apps/spectrum_reg.rsc - reg_rsc.path = !:/private/10003a3f/import/apps + bin.path = /sys/bin + rsc.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/spectrum.rsc + rsc.path = $$APP_RESOURCE_DIR + mif.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/spectrum.mif + mif.path = $$APP_RESOURCE_DIR + reg_rsc.sources = $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/spectrum_reg.rsc + reg_rsc.path = $$REG_RESOURCE_IMPORT_DIR DEPLOYMENT += bin rsc mif reg_rsc } -- cgit v0.12 From b2a85acc6e17240ec6c8667f5ed3be26426ac57d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 11 May 2010 09:34:08 +0100 Subject: Fixed typo in QAudioInput bufferSize documentation Docs stated that the bufferSize was a value in milliseconds. Corrected this to bytes. Reviewed-by: trustme --- src/multimedia/audio/qaudioinput.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index c99e870..2fef962 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -300,7 +300,7 @@ void QAudioInput::resume() } /*! - Sets the audio buffer size to \a value milliseconds. + Sets the audio buffer size to \a value bytes. Note: This function can be called anytime before start(), calls to this are ignored after start(). It should not be assumed that the buffer size @@ -315,7 +315,7 @@ void QAudioInput::setBufferSize(int value) } /*! - Returns the audio buffer size in milliseconds. + Returns the audio buffer size in bytes. If called before start(), returns platform default value. If called before start() but setBufferSize() was called prior, returns value set by setBufferSize(). -- cgit v0.12 From 70dd6652b8f649871e6801cc9190543f43daa650 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 11 May 2010 10:58:15 +0200 Subject: qdoc: Yet another revision of the top doc page. Still more to come. --- doc/src/files-and-resources/datastreamformat.qdoc | 3 +- doc/src/files-and-resources/resources.qdoc | 2 ++ doc/src/frameworks-technologies/graphicsview.qdoc | 2 +- .../model-view-programming.qdoc | 1 - doc/src/index.qdoc | 10 +++--- doc/src/network-programming/bearermanagement.qdoc | 9 +++-- doc/src/network-programming/qtnetwork.qdoc | 1 + doc/src/network-programming/ssl.qdoc | 6 ++-- doc/src/overviews.qdoc | 13 ++++++- doc/src/painting-and-printing/coordsys.qdoc | 2 +- doc/src/painting-and-printing/paintsystem.qdoc | 3 +- doc/src/painting-and-printing/printing.qdoc | 1 + tools/qdoc3/test/qt-defines.qdocconf | 28 +++++++-------- tools/qdoc3/test/qt.qdocconf | 42 +++++++++++----------- 14 files changed, 69 insertions(+), 54 deletions(-) diff --git a/doc/src/files-and-resources/datastreamformat.qdoc b/doc/src/files-and-resources/datastreamformat.qdoc index bab2c2c..c4be7bb 100644 --- a/doc/src/files-and-resources/datastreamformat.qdoc +++ b/doc/src/files-and-resources/datastreamformat.qdoc @@ -41,7 +41,8 @@ /*! \page datastreamformat.html - \title Format of the QDataStream Operators + \title Serializing Qt Data Types + \ingroup qt-network \brief Representations of data types that can be serialized by QDataStream. The \l QDataStream allows you to serialize some of the Qt data types. diff --git a/doc/src/files-and-resources/resources.qdoc b/doc/src/files-and-resources/resources.qdoc index 00646ac..83d74a3 100644 --- a/doc/src/files-and-resources/resources.qdoc +++ b/doc/src/files-and-resources/resources.qdoc @@ -54,6 +54,8 @@ /*! \page resources.html \title The Qt Resource System + \ingroup qt-network + \brief A platform-independent mechanism for storing binary files in an application. \keyword resource system diff --git a/doc/src/frameworks-technologies/graphicsview.qdoc b/doc/src/frameworks-technologies/graphicsview.qdoc index 740fcac..1dd6c7c 100644 --- a/doc/src/frameworks-technologies/graphicsview.qdoc +++ b/doc/src/frameworks-technologies/graphicsview.qdoc @@ -46,7 +46,7 @@ /*! \page graphicsview.html - \title The Graphics View Framework + \title Graphics View Framework \ingroup qt-graphics \brief An overview of the Graphics View framework for interactive 2D graphics. diff --git a/doc/src/frameworks-technologies/model-view-programming.qdoc b/doc/src/frameworks-technologies/model-view-programming.qdoc index e02f1eb..7568981 100644 --- a/doc/src/frameworks-technologies/model-view-programming.qdoc +++ b/doc/src/frameworks-technologies/model-view-programming.qdoc @@ -50,7 +50,6 @@ \startpage index.html Qt Reference Documentation \title Model/View Programming - \ingroup qt-gui-concepts \brief A guide to the extensible model/view architecture used by Qt's item view classes. diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index e6efe4d..c9b6929 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -82,17 +82,17 @@
      diff --git a/doc/src/network-programming/bearermanagement.qdoc b/doc/src/network-programming/bearermanagement.qdoc index 10d697a..b10481e 100644 --- a/doc/src/network-programming/bearermanagement.qdoc +++ b/doc/src/network-programming/bearermanagement.qdoc @@ -40,12 +40,11 @@ ****************************************************************************/ /*! -\page bearer-management.html + \page bearer-management.html -\title Bearer Management -\brief An API to control the system's connectivity state. - -\ingroup network + \title Bearer Management + \ingroup qt-network + \brief An API to control the system's connectivity state. Bearer Management controls the connectivity state of the system so that the user can start or stop interfaces or roam transparently between diff --git a/doc/src/network-programming/qtnetwork.qdoc b/doc/src/network-programming/qtnetwork.qdoc index 36f48cf..9134809 100644 --- a/doc/src/network-programming/qtnetwork.qdoc +++ b/doc/src/network-programming/qtnetwork.qdoc @@ -50,6 +50,7 @@ /*! \page network-programming.html \title Network Programming + \ingroup qt-network \brief An Introduction to Network Programming with Qt The QtNetwork module offers classes that allow you to write TCP/IP clients diff --git a/doc/src/network-programming/ssl.qdoc b/doc/src/network-programming/ssl.qdoc index 2feb7b6..7f365a9 100644 --- a/doc/src/network-programming/ssl.qdoc +++ b/doc/src/network-programming/ssl.qdoc @@ -40,11 +40,11 @@ ****************************************************************************/ /*! - \group ssl + \page ssl.html \title Secure Sockets Layer (SSL) Classes - \ingroup groups - \brief Classes for secure communication over network sockets. + \ingroup qt-network + \keyword SSL The classes below provide support for secure network communication using diff --git a/doc/src/overviews.qdoc b/doc/src/overviews.qdoc index cb6541d..cee1109 100644 --- a/doc/src/overviews.qdoc +++ b/doc/src/overviews.qdoc @@ -77,7 +77,7 @@ /*! \group qt-graphics - \title Qt Graphics + \title Qt Graphics and Painting \brief The Qt components for doing graphics. @@ -85,6 +85,17 @@ */ /*! + \group qt-network + \title Network programming with Qt + + \brief The these pages are about Qt's support for network programming. + + \generatelist {related} + */ + + + +/*! \group frameworks-technologies \title Frameworks and Technologies diff --git a/doc/src/painting-and-printing/coordsys.qdoc b/doc/src/painting-and-printing/coordsys.qdoc index b0ba093..b360d0b 100644 --- a/doc/src/painting-and-printing/coordsys.qdoc +++ b/doc/src/painting-and-printing/coordsys.qdoc @@ -41,7 +41,7 @@ /*! \page coordsys.html - \title The Coordinate System + \title Coordinate System \ingroup qt-graphics \brief Information about the coordinate system used by the paint system. diff --git a/doc/src/painting-and-printing/paintsystem.qdoc b/doc/src/painting-and-printing/paintsystem.qdoc index b711b2f..44c84a2 100644 --- a/doc/src/painting-and-printing/paintsystem.qdoc +++ b/doc/src/painting-and-printing/paintsystem.qdoc @@ -60,7 +60,8 @@ /*! \page paintsystem.html - \title The Paint System + \title Paint System + \brief A system for painting on the screen or on print devices using the same API \ingroup qt-graphics \ingroup frameworks-technologies diff --git a/doc/src/painting-and-printing/printing.qdoc b/doc/src/painting-and-printing/printing.qdoc index 3d6ade2..6dad097 100644 --- a/doc/src/painting-and-printing/printing.qdoc +++ b/doc/src/painting-and-printing/printing.qdoc @@ -49,6 +49,7 @@ /*! \page printing.html \title Printing with Qt + \ingroup qt-graphics \previouspage Styling \contentspage The Paint System diff --git a/tools/qdoc3/test/qt-defines.qdocconf b/tools/qdoc3/test/qt-defines.qdocconf index dc81757..f3291df 100644 --- a/tools/qdoc3/test/qt-defines.qdocconf +++ b/tools/qdoc3/test/qt-defines.qdocconf @@ -20,20 +20,20 @@ codeindent = 1 # See also qhp.Qt.extraFiles extraimages.HTML = qt-logo \ trolltech-logo \ - bg_l.png \ - bg_l_blank.png \ - bg_r.png \ - box_bg.png \ - breadcrumb.png \ - bullet_gt.png \ - bullet_dn.png \ - bullet_sq.png \ - bullet_up.png \ - feedbackground.png \ - horBar.png \ - page.png \ - page_bg.png \ - sprites-combined.png \ + bg_l.png \ + bg_l_blank.png \ + bg_r.png \ + box_bg.png \ + breadcrumb.png \ + bullet_gt.png \ + bullet_dn.png \ + bullet_sq.png \ + bullet_up.png \ + feedbackground.png \ + horBar.png \ + page.png \ + page_bg.png \ + sprites-combined.png \ taskmenuextension-example.png \ coloreditorfactoryimage.png \ dynamiclayouts-example.png \ diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf index 59dd855..2f6983a 100644 --- a/tools/qdoc3/test/qt.qdocconf +++ b/tools/qdoc3/test/qt.qdocconf @@ -26,27 +26,27 @@ qhp.Qt.indexRoot = # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML qhp.Qt.extraFiles = index.html \ - images/bg_l.png \ - images/bg_l_blank.png \ - images/bg_r.png \ - images/box_bg.png \ - images/breadcrumb.png \ - images/bullet_gt.png \ - images/bullet_dn.png \ - images/bullet_sq.png \ - images/bullet_up.png \ - images/feedbackground.png \ - images/horBar.png \ - images/page.png \ - images/page_bg.png \ - images/sprites-combined.png \ - images/stylesheet-coffee-plastique.png \ - images/taskmenuextension-example.png \ - images/coloreditorfactoryimage.png \ - images/dynamiclayouts-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - style/style.css + images/bg_l.png \ + images/bg_l_blank.png \ + images/bg_r.png \ + images/box_bg.png \ + images/breadcrumb.png \ + images/bullet_gt.png \ + images/bullet_dn.png \ + images/bullet_sq.png \ + images/bullet_up.png \ + images/feedbackground.png \ + images/horBar.png \ + images/page.png \ + images/page_bg.png \ + images/sprites-combined.png \ + images/stylesheet-coffee-plastique.png \ + images/taskmenuextension-example.png \ + images/coloreditorfactoryimage.png \ + images/dynamiclayouts-example.png \ + scripts/functions.js \ + scripts/jquery.js \ + style/style.css qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc qhp.Qt.customFilters.Qt.name = Qt 4.7.0 -- cgit v0.12 From ad6dafee9be288bcef6b2c4b318b234d2995abff Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 10 May 2010 16:23:44 +0200 Subject: Optimize QPixmapIconEngine's pixmap() function Replace needlessly expensive cache key generation Task-number: QTBUG-9850 Reviewed-by: Trond --- src/gui/image/qicon.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 891b1db..5ef0ff9 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -261,21 +261,28 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height())) actualSize.scale(size, Qt::KeepAspectRatio); - QString key = QLatin1String("$qt_icon_") - + QString::number(pm.cacheKey()) - + QString::number(pe->mode) - + QString::number(QApplication::palette().cacheKey()) - + QLatin1Char('_') - + QString::number(actualSize.width()) - + QLatin1Char('_') - + QString::number(actualSize.height()) - + QLatin1Char('_'); - + struct { + quint64 pmc; + qint32 w; + qint32 h; + quint64 pac; + qint32 m; // Make struct size a multiple of 4, for safety's sake + } dill; + + dill.pmc = pm.cacheKey(); + dill.w = actualSize.width(); + dill.h = actualSize.height(); + dill.pac = QApplication::palette().cacheKey(); + dill.m = pe->mode; + + QString keyBase = QLatin1String("$qt_icon_") + + QString::fromRawData((QChar *)&dill, sizeof(dill)/sizeof(QChar)); + QString key = keyBase + QString::number(mode, 16); if (mode == QIcon::Active) { - if (QPixmapCache::find(key + QString::number(mode), pm)) + if (QPixmapCache::find(key, pm)) return pm; // horray - if (QPixmapCache::find(key + QString::number(QIcon::Normal), pm)) { + if (QPixmapCache::find(keyBase + QString::number(QIcon::Normal, 16), pm)) { QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt); @@ -284,7 +291,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St } } - if (!QPixmapCache::find(key + QString::number(mode), pm)) { + if (!QPixmapCache::find(key, pm)) { if (pm.size() != actualSize) pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (pe->mode != mode && mode != QIcon::Normal) { @@ -294,7 +301,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!generated.isNull()) pm = generated; } - QPixmapCache::insert(key + QString::number(mode), pm); + QPixmapCache::insert(key, pm); } return pm; } -- cgit v0.12 From 3eec5af3f07fdab9084f40d6955411a667b433c4 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 11 May 2010 12:26:30 +0200 Subject: Updated WebKit to b4aa5e1ddc41edab895132aba3cc66d9d7129444 Integrated changes: || || mingw-w64 and JIT support || || || [Qt] QWebPage viewMode property || || || [Qt] Fix infinite redirection loop in QNetworkReplyHandler || || || [Qt] Enable YARR_JIT for X86 Mac for QtWebKit || || || [Qt] Adapt DNS pre-fetching to Qt DNS cache code || || || [Qt] Crash in QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate when animation were used || || || [PATCH] [Qt] Compilation with Plugins disabled is broken || || || Crash in handleTouchEvent: using dangling node ptrs in hashmap || || || Potential crash in EventHandler::handleTouchEvent || || || Spatial Navigation: create a getter for the "fudgeFactor" || || || [Qt] QtWebKit has render bugs on Google Maps markers || || || LayoutTests/fast/canvas/pointInPath.html passed, actually it failed || || || [Qt] Expose HTMLTokenizer yielding parameters || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/JavaScriptCore/ChangeLog | 23 +++ src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h | 6 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 163 +++++++++++++++++++++ src/3rdparty/webkit/WebCore/WebCore.gypi | 2 +- src/3rdparty/webkit/WebCore/WebCore.pro | 2 +- src/3rdparty/webkit/WebCore/page/EventHandler.cpp | 13 +- .../webkit/WebCore/page/SpatialNavigation.cpp | 13 +- .../webkit/WebCore/page/SpatialNavigation.h | 5 + .../platform/graphics/qt/GraphicsContextQt.cpp | 16 +- .../webkit/WebCore/platform/graphics/qt/PathQt.cpp | 29 ++++ .../platform/network/qt/DnsPrefetchHelper.h | 11 ++ .../platform/network/qt/QNetworkReplyHandler.cpp | 13 +- .../platform/network/qt/QNetworkReplyHandler.h | 1 + .../WebCore/platform/qt/TemporaryLinkStubs.cpp | 119 --------------- .../WebCore/platform/qt/TemporaryLinkStubsQt.cpp | 119 +++++++++++++++ .../webkit/WebKit/qt/Api/qgraphicswebview.cpp | 22 ++- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 32 ++-- src/3rdparty/webkit/WebKit/qt/Api/qwebpage_p.h | 2 + src/3rdparty/webkit/WebKit/qt/ChangeLog | 58 ++++++++ .../webkit/WebKit/qt/symbian/bwins/QtWebKitu.def | 2 +- .../webkit/WebKit/qt/symbian/eabi/QtWebKitu.def | 2 +- .../WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 17 +++ 24 files changed, 505 insertions(+), 169 deletions(-) delete mode 100644 src/3rdparty/webkit/WebCore/platform/qt/TemporaryLinkStubs.cpp create mode 100644 src/3rdparty/webkit/WebCore/platform/qt/TemporaryLinkStubsQt.cpp diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 75fc5e7..65cfdda 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -b4aa5e1ddc41edab895132aba3cc66d9d7129444 +dc5821c3df2ef60456d85263160852f5335cf946 diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index 1439ae0..97176ef 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,26 @@ +2010-05-10 Laszlo Gombos + + Reviewed by Darin Adler. + + [Qt] Disable JIT support for mingw-w64 + https://bugs.webkit.org/show_bug.cgi?id=38747 + + Disale JIT for mingw-w64 as it is reportedly + unstable. + + Thanks for Vanboxem Rruben for the investigation. + + * wtf/Platform.h: + +2010-05-06 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Enable YARR_JIT for X86 Mac for QtWebKit + https://bugs.webkit.org/show_bug.cgi?id=38668 + + * wtf/Platform.h: + 2010-05-02 Laszlo Gombos Reviewed by Eric Seidel. diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h index c582905..8d98765 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h @@ -927,8 +927,6 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ #elif CPU(X86) && OS(WINDOWS) && COMPILER(MINGW) && GCC_VERSION >= 40100 #define ENABLE_JIT 1 #define WTF_USE_JIT_STUB_ARGUMENT_VA_LIST 1 -#elif CPU(X86_64) && OS(WINDOWS) && COMPILER(MINGW64) && GCC_VERSION >= 40100 - #define ENABLE_JIT 1 #elif CPU(X86) && OS(WINDOWS) && COMPILER(MSVC) #define ENABLE_JIT 1 #define WTF_USE_JIT_STUB_ARGUMENT_REGISTER 1 @@ -1011,7 +1009,9 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ || (CPU(X86_64) && OS(LINUX) && GCC_VERSION >= 40100) \ || (CPU(ARM_TRADITIONAL) && OS(LINUX)) \ || (CPU(ARM_TRADITIONAL) && OS(SYMBIAN) && COMPILER(RVCT)) \ - || (CPU(MIPS) && OS(LINUX)) + || (CPU(MIPS) && OS(LINUX)) \ + || (CPU(X86) && OS(DARWIN)) \ + || (CPU(X86_64) && OS(DARWIN)) #define ENABLE_YARR 1 #define ENABLE_YARR_JIT 1 #endif diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 98debf6..24f855b 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 07b60cf799680fcfb7785ee88e14f8030a5dbfa2 + b4aa5e1ddc41edab895132aba3cc66d9d7129444 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 6617b66..ee42878 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,166 @@ +2010-05-03 Antonio Gomes + + Reviewed by Kenneth Christiansen. + + Spatial Navigation: create a getter for the "fudgeFactor" + https://bugs.webkit.org/show_bug.cgi?id=38488 + + A couple of places in the Spatial Navigation code make use of a "fudge factor" + to improve precision by working around outline focus metrics and such. Patch adds + a helper method for unify getter operations of this value, instead of having it + declared locally in the various methods it is used. + + No behaviour change. + + * page/SpatialNavigation.cpp: + (WebCore::scrollIntoView): + (WebCore::deflateIfOverlapped): + * page/SpatialNavigation.h: + (WebCore::fudgeFactor): + +2010-05-10 Markus Goetz + + Reviewed by Simon Hausmann. + + Qt after 4.6.3 has its integrated DNS cache. Therefore some + code is not necessary anymore. + + https://bugs.webkit.org/show_bug.cgi?id=38834 + + * platform/network/qt/DnsPrefetchHelper.h: + (WebCore::DnsPrefetchHelper::lookup): + (WebCore::DnsPrefetchHelper::lookedUp): + +2010-05-06 Laszlo Gombos + + Unreviewed, build fix WinCE for QtWebKit. + + [Qt] Compilation with Plugins disabled is broken + https://bugs.webkit.org/show_bug.cgi?id=31407 + + Rename platform/qt/TemporaryLinkStubs.cpp to avoid name collition on + Windows. + + Thanks for Ismail "cartman" Donmez for help. + + No new tests, as there is no new functionality. + + * WebCore.gypi: + * WebCore.pro: + * platform/qt/TemporaryLinkStubs.cpp: Removed. + * platform/qt/TemporaryLinkStubsQt.cpp: Copied from WebCore/platform/qt/TemporaryLinkStubs.cpp. + +2010-04-23 Qi Zhang + + Reviewed by Laszlo Gombos. + + [Qt] LayoutTests/fast/canvas/pointInPath.html passed, actually it failed + https://bugs.webkit.org/show_bug.cgi?id=37276 + + QPainterPath::contains doesn't count the point on the bound. + + * platform/graphics/qt/PathQt.cpp: + (WebCore::isPointOnPathBorder): + (WebCore::Path::contains): + +2010-05-07 Tor Arne Vestbø + + Reviewed by Simon Hausmann. + + [Qt] Fix rendering of -webkit-user-select: none + + -webkit-user-select: none is implemented by filling + the area with an invalid default-constructed Color. + In most ports passing an invalid color down to the + graphics backend seems to produce transparent fills. + + In Qt the behavior of painting with an invalid QColor + is undefined, and in practice it results in painting + black opaque areas. + + One way to fix this would be to use Qt::transparent + when converting an undefined Color to a QColor, but + Qt does not have short circuits for fully transparent + painting, and we actually end up in slow code paths + due to the transparency. So, we're better of doing the + short circuit in WebKit. + + https://bugs.webkit.org/show_bug.cgi?id=38523 + + * platform/graphics/qt/GraphicsContextQt.cpp: + +2010-04-05 Robert Hogan + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Fix infinite redirection loop in QNetworkReplyHandler + + Put a maximum on consecutive redirections so we don't have to + worry about whether it's the same url or not. + + Tolerate up to 10 consecutive redirections, anything beyond + that is considered a potentially infinite recursion in the + redirection requests. This is the same behaviour as Firefox. + + https://bugs.webkit.org/show_bug.cgi?id=37097 + + * platform/network/qt/QNetworkReplyHandler.cpp: + (WebCore::QNetworkReplyHandler::QNetworkReplyHandler): + (WebCore::QNetworkReplyHandler::sendResponseIfNeeded): + * platform/network/qt/QNetworkReplyHandler.h: + +2010-04-05 Robert Hogan + + Reviewed by Kenneth Rohde-Christiansen. + + [Qt] Fix infinite redirection loop in QNetworkReplyHandler + + Qt enters an infinite loop if a redirect response redirects to itself. + + Fixes http/tests/xmlhttprequest/connection-error-sync.html + + https://bugs.webkit.org/show_bug.cgi?id=37097 + + * platform/network/qt/QNetworkReplyHandler.cpp: + (WebCore::QNetworkReplyHandler::sendResponseIfNeeded): + +2010-05-07 Ben Murdoch + + Reviewed by Darin Adler. + + Potential crash in EventHandler::handleTouchEvent + https://bugs.webkit.org/show_bug.cgi?id=38646 + + Fix a ref counting bug that can cause a crash if the m_originatingouchPointTargets + hashmap holds the last ref to an EventTarget when the user lifts their finger. + + This is very hard to reproduce in a consistent way and clearly a + simple logic error in the code, therefore no new tests. + + * page/EventHandler.cpp: + (WebCore::EventHandler::handleTouchEvent): Don't let the RefPtr we get back from + the hasmap go out of scope so soon as it could delete the wrapped ptr if the + hashmap held the last ref (and we use the raw ptr that the RefPtr + wraps later in the WebCore::Touch constructor). + +2010-05-04 Ben Murdoch + + Reviewed by Simon Hausmann. + + Crash in handleTouchEvent: using dangling node ptrs in hashmap + https://bugs.webkit.org/show_bug.cgi?id=38514 + + When navigating away from a page, if you have your finger still + pressed and then lift it on the new page we see a crash if the + node got deleted as we still have a dangling pointer in the + m_originatingTouchPointTargets hashmap and try to use it as the + receiver to dispatch a touchend event. + + Test: fast/events/touch/touch-stale-node-crash.html + + * page/EventHandler.cpp: + (WebCore::EventHandler::clear): Clear the hashmap of touch targets. + 2010-05-04 Luiz Agostini Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/WebCore.gypi b/src/3rdparty/webkit/WebCore/WebCore.gypi index caa79f2..701ad90 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.gypi +++ b/src/3rdparty/webkit/WebCore/WebCore.gypi @@ -2640,7 +2640,7 @@ 'platform/qt/SharedBufferQt.cpp', 'platform/qt/SharedTimerQt.cpp', 'platform/qt/SoundQt.cpp', - 'platform/qt/TemporaryLinkStubs.cpp', + 'platform/qt/TemporaryLinkStubsQt.cpp', 'platform/qt/WheelEventQt.cpp', 'platform/qt/WidgetQt.cpp', 'platform/sql/SQLValue.cpp', diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index beeb529..e42cd8e 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -2081,7 +2081,7 @@ SOURCES += \ platform/qt/SoundQt.cpp \ platform/qt/LoggingQt.cpp \ platform/text/qt/StringQt.cpp \ - platform/qt/TemporaryLinkStubs.cpp \ + platform/qt/TemporaryLinkStubsQt.cpp \ platform/text/qt/TextBoundariesQt.cpp \ platform/text/qt/TextBreakIteratorQt.cpp \ platform/text/qt/TextCodecQt.cpp \ diff --git a/src/3rdparty/webkit/WebCore/page/EventHandler.cpp b/src/3rdparty/webkit/WebCore/page/EventHandler.cpp index 0a0e8c6..46dd7ae 100644 --- a/src/3rdparty/webkit/WebCore/page/EventHandler.cpp +++ b/src/3rdparty/webkit/WebCore/page/EventHandler.cpp @@ -230,6 +230,9 @@ void EventHandler::clear() m_capturingMouseEventsNode = 0; m_latchedWheelEventNode = 0; m_previousWheelScrolledNode = 0; +#if ENABLE(TOUCH_EVENTS) + m_originatingTouchPointTargets.clear(); +#endif } void EventHandler::selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults& result) @@ -2714,21 +2717,21 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) // Increment the platform touch id by 1 to avoid storing a key of 0 in the hashmap. unsigned touchPointTargetKey = point.id() + 1; - EventTarget* touchTarget = 0; + RefPtr touchTarget; if (point.state() == PlatformTouchPoint::TouchPressed) { m_originatingTouchPointTargets.set(touchPointTargetKey, target); touchTarget = target; } else if (point.state() == PlatformTouchPoint::TouchReleased || point.state() == PlatformTouchPoint::TouchCancelled) { // The target should be the original target for this touch, so get it from the hashmap. As it's a release or cancel // we also remove it from the map. - touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKey).get(); + touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKey); } else - touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey).get(); + touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey); - if (!touchTarget) + if (!touchTarget.get()) continue; - RefPtr touch = Touch::create(doc->frame(), touchTarget, point.id(), + RefPtr touch = Touch::create(doc->frame(), touchTarget.get(), point.id(), point.screenPos().x(), point.screenPos().y(), adjustedPageX, adjustedPageY); diff --git a/src/3rdparty/webkit/WebCore/page/SpatialNavigation.cpp b/src/3rdparty/webkit/WebCore/page/SpatialNavigation.cpp index 890eacd..d7eaf25 100644 --- a/src/3rdparty/webkit/WebCore/page/SpatialNavigation.cpp +++ b/src/3rdparty/webkit/WebCore/page/SpatialNavigation.cpp @@ -477,9 +477,8 @@ void scrollIntoView(Element* element) // it is preferable to inflate |element|'s bounding rect a bit before // scrolling it for accurate reason. // Element's scrollIntoView method does not provide this flexibility. - static const int fudgeFactor = 2; IntRect bounds = element->getRect(); - bounds.inflate(fudgeFactor); + bounds.inflate(fudgeFactor()); element->renderer()->enclosingLayer()->scrollRectToVisible(bounds); } @@ -497,14 +496,14 @@ static void deflateIfOverlapped(IntRect& a, IntRect& b) if (!a.intersects(b) || a.contains(b) || b.contains(a)) return; - static const int fudgeFactor = -2; + int deflateFactor = -fudgeFactor(); // Avoid negative width or height values. - if ((a.width() + 2 * fudgeFactor > 0) && (a.height() + 2 * fudgeFactor > 0)) - a.inflate(fudgeFactor); + if ((a.width() + 2 * deflateFactor > 0) && (a.height() + 2 * deflateFactor > 0)) + a.inflate(deflateFactor); - if ((b.width() + 2 * fudgeFactor > 0) && (b.height() + 2 * fudgeFactor > 0)) - b.inflate(fudgeFactor); + if ((b.width() + 2 * deflateFactor > 0) && (b.height() + 2 * deflateFactor > 0)) + b.inflate(deflateFactor); } static bool checkNegativeCoordsForNode(Node* node, const IntRect& curRect) diff --git a/src/3rdparty/webkit/WebCore/page/SpatialNavigation.h b/src/3rdparty/webkit/WebCore/page/SpatialNavigation.h index 90ff1cf..309b095 100644 --- a/src/3rdparty/webkit/WebCore/page/SpatialNavigation.h +++ b/src/3rdparty/webkit/WebCore/page/SpatialNavigation.h @@ -40,6 +40,11 @@ inline long long maxDistance() return numeric_limits::max(); } +inline unsigned int fudgeFactor() +{ + return 2; +} + // Spatially speaking, two given elements in a web page can be: // 1) Fully aligned: There is a full intersection between the rects, either // vertically or horizontally. diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index edac268..0100b72 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -641,12 +641,12 @@ void GraphicsContext::fillRect(const FloatRect& rect) } } -void GraphicsContext::fillRect(const FloatRect& rect, const Color& c, ColorSpace colorSpace) +void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace) { - if (paintingDisabled()) + if (paintingDisabled() || !color.isValid()) return; - m_data->solidColor.setColor(c); + m_data->solidColor.setColor(color); QPainter* p = m_data->p(); if (m_common->state.shadowColor.isValid()) drawBorderlessRectShadow(this, p, rect); @@ -655,7 +655,7 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& c, ColorSpace void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace colorSpace) { - if (paintingDisabled() || !color.alpha()) + if (paintingDisabled() || !color.isValid() || !color.alpha()) return; Path path = Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight); @@ -717,7 +717,7 @@ void GraphicsContext::drawFocusRing(const Vector& paths, int width, int of */ void GraphicsContext::drawFocusRing(const Vector& rects, int /* width */, int /* offset */, const Color& color) { - if (paintingDisabled()) + if (paintingDisabled() || !color.isValid()) return; unsigned rectCount = rects.size(); @@ -1141,8 +1141,9 @@ void GraphicsContext::setURLForRect(const KURL&, const IntRect&) void GraphicsContext::setPlatformStrokeColor(const Color& color, ColorSpace colorSpace) { - if (paintingDisabled()) + if (paintingDisabled() || !color.isValid()) return; + QPainter* p = m_data->p(); QPen newPen(p->pen()); m_data->solidColor.setColor(color); @@ -1172,8 +1173,9 @@ void GraphicsContext::setPlatformStrokeThickness(float thickness) void GraphicsContext::setPlatformFillColor(const Color& color, ColorSpace colorSpace) { - if (paintingDisabled()) + if (paintingDisabled() || !color.isValid()) return; + m_data->solidColor.setColor(color); m_data->p()->setBrush(m_data->solidColor); } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/PathQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/PathQt.cpp index ee4af7f..4b0c21f 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/PathQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/PathQt.cpp @@ -69,12 +69,41 @@ Path& Path::operator=(const Path& other) return *this; } +// Check whether a point is on the border +bool isPointOnPathBorder(const QPolygonF& border, const QPointF& p) +{ + QPointF p1 = border.at(0); + QPointF p2; + + for (int i = 1; i < border.size(); ++i) { + p2 = border.at(i); + // (x1<=x<=x2||x1=>x>=x2) && (y1<=y<=y2||y1=>y>=y2) && (y2-y1)(x-x1) == (y-y1)(x2-x1) + // In which, (y2-y1)(x-x1) == (y-y1)(x2-x1) is from (y2-y1)/(x2-x1) == (y-y1)/(x-x1) + // it want to check the slope between p1 and p2 is same with slope between p and p1, + // if so then the three points lie on the same line. + // In which, (x1<=x<=x2||x1=>x>=x2) && (y1<=y<=y2||y1=>y>=y2) want to make sure p is + // between p1 and p2, not outside. + if (((p.x() <= p1.x() && p.x() >= p2.x()) || (p.x() >= p1.x() && p.x() <= p2.x())) + && ((p.y() <= p1.y() && p.y() >= p2.y()) || (p.y() >= p1.y() && p.y() <= p2.y())) + && (p2.y() - p1.y()) * (p.x() - p1.x()) == (p.y() - p1.y()) * (p2.x() - p1.x())) { + return true; + } + p1 = p2; + } + return false; +} + bool Path::contains(const FloatPoint& point, WindRule rule) const { Qt::FillRule savedRule = m_path.fillRule(); const_cast(&m_path)->setFillRule(rule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill); bool contains = m_path.contains(point); + + if (!contains) { + // check whether the point is on the border + contains = isPointOnPathBorder(m_path.toFillPolygon(), point); + } const_cast(&m_path)->setFillRule(savedRule); return contains; diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/DnsPrefetchHelper.h b/src/3rdparty/webkit/WebCore/platform/network/qt/DnsPrefetchHelper.h index 0d98fcb..e355025 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/DnsPrefetchHelper.h +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/DnsPrefetchHelper.h @@ -42,6 +42,13 @@ namespace WebCore { if (currentLookups >= 10) return; // do not launch more than 10 lookups at the same time +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 3) + currentLookups++; + QHostInfo::lookupHost(hostname, this, SLOT(lookedUp(QHostInfo))); +#else + // This code is only needed for Qt versions that do not have + // the small Qt DNS cache yet. + QTime* entryTime = lookupCache.object(hostname); if (entryTime && entryTime->elapsed() > 300*1000) { // delete knowledge about lookup if it is already 300 seconds old @@ -54,6 +61,7 @@ namespace WebCore { currentLookups++; QHostInfo::lookupHost(hostname, this, SLOT(lookedUp(QHostInfo))); } +#endif } void lookedUp(const QHostInfo&) @@ -61,11 +69,14 @@ namespace WebCore { // we do not cache the result, we throw it away. // we currently rely on the OS to cache the results. If it does not do that // then at least the ISP nameserver did it. + // Since Qt 4.6.3, Qt also has a small DNS cache. currentLookups--; } protected: +#if QT_VERSION < QT_VERSION_CHECK(4, 6, 3) QCache lookupCache; // 100 entries +#endif int currentLookups; }; diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp index 403718f..abeb895 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp @@ -49,6 +49,7 @@ #define SIGNAL_CONN Qt::QueuedConnection #endif +static const int gMaxRecursionLimit = 10; namespace WebCore { @@ -139,6 +140,7 @@ QNetworkReplyHandler::QNetworkReplyHandler(ResourceHandle* handle, LoadMode load , m_shouldFinish(false) , m_shouldSendResponse(false) , m_shouldForwardData(false) + , m_redirectionTries(gMaxRecursionLimit) { const ResourceRequest &r = m_resourceHandle->request(); @@ -336,9 +338,18 @@ void QNetworkReplyHandler::sendResponseIfNeeded() QUrl redirection = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); if (redirection.isValid()) { + QUrl newUrl = m_reply->url().resolved(redirection); + + m_redirectionTries--; + if (m_redirectionTries == 0) { // 10 or more redirections to the same url is considered infinite recursion + ResourceError error(newUrl.host(), 400 /*bad request*/, + newUrl.toString(), + QCoreApplication::translate("QWebPage", "Redirection limit reached")); + client->didFail(m_resourceHandle, error); + return; + } m_redirected = true; - QUrl newUrl = m_reply->url().resolved(redirection); ResourceRequest newRequest = m_resourceHandle->request(); newRequest.setURL(newUrl); diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.h b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.h index eb5ae3c..1abad4e 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.h +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.h @@ -82,6 +82,7 @@ private: bool m_shouldFinish; bool m_shouldSendResponse; bool m_shouldForwardData; + int m_redirectionTries; }; // Self destructing QIODevice for FormData diff --git a/src/3rdparty/webkit/WebCore/platform/qt/TemporaryLinkStubs.cpp b/src/3rdparty/webkit/WebCore/platform/qt/TemporaryLinkStubs.cpp deleted file mode 100644 index 814f961..0000000 --- a/src/3rdparty/webkit/WebCore/platform/qt/TemporaryLinkStubs.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com - * Copyright (C) 2006 George Staikos - * Copyright (C) 2006 Dirk Mueller - * Copyright (C) 2006 Nikolas Zimmermann - * Copyright (C) 2008 Collabora, Ltd. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include "AXObjectCache.h" -#include "DNS.h" -#include "CString.h" -#include "CachedResource.h" -#include "CookieJar.h" -#include "Cursor.h" -#include "Font.h" -#include "Frame.h" -#include "FrameLoader.h" -#include "FTPDirectoryDocument.h" -#include "IntPoint.h" -#include "Widget.h" -#include "GraphicsContext.h" -#include "Cursor.h" -#include "loader.h" -#include "FileSystem.h" -#include "FrameView.h" -#include "GraphicsContext.h" -#include "IconLoader.h" -#include "IntPoint.h" -#include "KURL.h" -#include "Language.h" -#include "loader.h" -#include "LocalizedStrings.h" -#include "Node.h" -#include "NotImplemented.h" -#include "Path.h" -#include "PlatformMouseEvent.h" -#include "PluginDatabase.h" -#include "PluginPackage.h" -#include "PluginView.h" -#include "RenderTheme.h" -#include "SharedBuffer.h" -#include "SystemTime.h" -#include "TextBoundaries.h" -#include "Widget.h" -#include -#include -#include - -using namespace WebCore; - -#if defined(Q_OS_WINCE) -Vector PluginDatabase::defaultPluginDirectories() -{ - notImplemented(); - return Vector(); -} - -void PluginDatabase::getPluginPathsInDirectories(HashSet& paths) const -{ - notImplemented(); -} - -bool PluginDatabase::isPreferredPluginDirectory(const String& directory) -{ - notImplemented(); - return false; -} -#endif - -namespace WebCore { - -void getSupportedKeySizes(Vector&) -{ - notImplemented(); -} - -String signedPublicKeyAndChallengeString(unsigned, const String&, const KURL&) -{ - return String(); -} - -#if !defined(Q_OS_WIN) -// defined in win/SystemTimeWin.cpp, which is compiled for the Qt/Windows port -float userIdleTime() -{ - notImplemented(); - return FLT_MAX; // return an arbitrarily high userIdleTime so that releasing pages from the page cache isn't postponed -} -#endif - -} - -// vim: ts=4 sw=4 et diff --git a/src/3rdparty/webkit/WebCore/platform/qt/TemporaryLinkStubsQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/TemporaryLinkStubsQt.cpp new file mode 100644 index 0000000..814f961 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/qt/TemporaryLinkStubsQt.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com + * Copyright (C) 2006 George Staikos + * Copyright (C) 2006 Dirk Mueller + * Copyright (C) 2006 Nikolas Zimmermann + * Copyright (C) 2008 Collabora, Ltd. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "AXObjectCache.h" +#include "DNS.h" +#include "CString.h" +#include "CachedResource.h" +#include "CookieJar.h" +#include "Cursor.h" +#include "Font.h" +#include "Frame.h" +#include "FrameLoader.h" +#include "FTPDirectoryDocument.h" +#include "IntPoint.h" +#include "Widget.h" +#include "GraphicsContext.h" +#include "Cursor.h" +#include "loader.h" +#include "FileSystem.h" +#include "FrameView.h" +#include "GraphicsContext.h" +#include "IconLoader.h" +#include "IntPoint.h" +#include "KURL.h" +#include "Language.h" +#include "loader.h" +#include "LocalizedStrings.h" +#include "Node.h" +#include "NotImplemented.h" +#include "Path.h" +#include "PlatformMouseEvent.h" +#include "PluginDatabase.h" +#include "PluginPackage.h" +#include "PluginView.h" +#include "RenderTheme.h" +#include "SharedBuffer.h" +#include "SystemTime.h" +#include "TextBoundaries.h" +#include "Widget.h" +#include +#include +#include + +using namespace WebCore; + +#if defined(Q_OS_WINCE) +Vector PluginDatabase::defaultPluginDirectories() +{ + notImplemented(); + return Vector(); +} + +void PluginDatabase::getPluginPathsInDirectories(HashSet& paths) const +{ + notImplemented(); +} + +bool PluginDatabase::isPreferredPluginDirectory(const String& directory) +{ + notImplemented(); + return false; +} +#endif + +namespace WebCore { + +void getSupportedKeySizes(Vector&) +{ + notImplemented(); +} + +String signedPublicKeyAndChallengeString(unsigned, const String&, const KURL&) +{ + return String(); +} + +#if !defined(Q_OS_WIN) +// defined in win/SystemTimeWin.cpp, which is compiled for the Qt/Windows port +float userIdleTime() +{ + notImplemented(); + return FLT_MAX; // return an arbitrarily high userIdleTime so that releasing pages from the page cache isn't postponed +} +#endif + +} + +// vim: ts=4 sw=4 et diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp index 0c13e43..75a23d9 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp @@ -82,7 +82,6 @@ public: , page(0) , resizesToContents(false) #if USE(ACCELERATED_COMPOSITING) - , rootGraphicsLayer(0) , shouldSync(false) #endif { @@ -158,7 +157,7 @@ public: enum { RootGraphicsLayerZValue, OverlayZValue }; #if USE(ACCELERATED_COMPOSITING) - QGraphicsItem* rootGraphicsLayer; + QWeakPointer rootGraphicsLayer; // we need to sync the layers if we get a special call from the WebCore // compositor telling us to do so. We'll get that call from ChromeClientQt bool shouldSync; @@ -171,12 +170,11 @@ public: QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate() { #if USE(ACCELERATED_COMPOSITING) - if (rootGraphicsLayer) { - // we don't need to delete the root graphics layer - // The lifecycle is managed in GraphicsLayerQt.cpp - rootGraphicsLayer->setParentItem(0); - q->scene()->removeItem(rootGraphicsLayer); - } + if (!rootGraphicsLayer) + return; + // we don't need to delete the root graphics layer. The lifecycle is managed in GraphicsLayerQt.cpp. + rootGraphicsLayer.data()->setParentItem(0); + q->scene()->removeItem(rootGraphicsLayer.data()); #endif } @@ -204,12 +202,12 @@ void QGraphicsWebViewPrivate::createOrDeleteOverlay() void QGraphicsWebViewPrivate::setRootGraphicsLayer(QGraphicsItem* layer) { if (rootGraphicsLayer) { - rootGraphicsLayer->setParentItem(0); - q->scene()->removeItem(rootGraphicsLayer); + rootGraphicsLayer.data()->setParentItem(0); + q->scene()->removeItem(rootGraphicsLayer.data()); QWebFramePrivate::core(q->page()->mainFrame())->view()->syncCompositingStateRecursive(); } - rootGraphicsLayer = layer; + rootGraphicsLayer = layer ? layer->toGraphicsObject() : 0; if (layer) { layer->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); @@ -231,7 +229,7 @@ void QGraphicsWebViewPrivate::updateCompositingScrollPosition() { if (rootGraphicsLayer && q->page() && q->page()->mainFrame()) { const QPoint scrollPosition = q->page()->mainFrame()->scrollPosition(); - rootGraphicsLayer->setPos(-scrollPosition); + rootGraphicsLayer.data()->setPos(-scrollPosition); } } #endif diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index b8b50b7..e9ebce5 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -119,15 +119,6 @@ using namespace WebCore; -void QWEBKIT_EXPORT qt_wrt_setViewMode(QWebPage* page, const QString& mode) -{ - QWebPagePrivate::priv(page)->viewMode = mode; - WebCore::Frame* frame = QWebFramePrivate::core(page->mainFrame()); - WebCore::FrameView* view = frame->view(); - frame->document()->updateStyleSelector(); - view->forceLayout(); -} - void QWEBKIT_EXPORT qt_drt_overwritePluginDirectories() { PluginDatabase* db = PluginDatabase::installedPlugins(/* populate */ false); @@ -1361,6 +1352,26 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) ev->accept(); } +void QWebPagePrivate::dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent* event) +{ + if (event->propertyName() == "_q_viewMode") { + QString mode = q->property("_q_viewMode").toString(); + if (mode != viewMode) { + viewMode = mode; + WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame()); + WebCore::FrameView* view = frame->view(); + frame->document()->updateStyleSelector(); + view->forceLayout(); + } + } else if (event->propertyName() == "_q_HTMLTokenizerChunkSize") { + int chunkSize = q->property("_q_HTMLTokenizerChunkSize").toInt(); + q->handle()->page->setCustomHTMLTokenizerChunkSize(chunkSize); + } else if (event->propertyName() == "_q_HTMLTokenizerTimeDelay") { + double timeDelay = q->property("_q_HTMLTokenizerTimeDelay").toDouble(); + q->handle()->page->setCustomHTMLTokenizerTimeDelay(timeDelay); + } +} + void QWebPagePrivate::shortcutOverrideEvent(QKeyEvent* event) { WebCore::Frame* frame = page->focusController()->focusedOrMainFrame(); @@ -2708,6 +2719,9 @@ bool QWebPage::event(QEvent *ev) d->touchEvent(static_cast(ev)); break; #endif + case QEvent::DynamicPropertyChange: + d->dynamicPropertyChangeEvent(static_cast(ev)); + break; default: return QObject::event(ev); } diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage_p.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage_p.h index 0712d0c..5350cd9 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage_p.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage_p.h @@ -112,6 +112,8 @@ public: void inputMethodEvent(QInputMethodEvent*); + void dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent*); + void shortcutOverrideEvent(QKeyEvent*); void leaveEvent(QEvent*); void handleClipboard(QEvent*, Qt::MouseButton); diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 555b14d..6ddaa2b 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,61 @@ +2010-05-09 Noam Rosenthal + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Crash in QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate when animation were used + https://bugs.webkit.org/show_bug.cgi?id=38574 + + The fix uses a QWeakPointer for rootGraphicsLayer, protecting from a crash in case the layer is deleted before the QGraphicsWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate): + (QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate): + (QGraphicsWebViewPrivate::setRootGraphicsLayer): + (QGraphicsWebViewPrivate::updateCompositingScrollPosition): + +2010-05-03 Laszlo Gombos + + Reviewed by Simon Hausmann. + + [Qt] Expose HTMLTokenizer yielding parameters + https://bugs.webkit.org/show_bug.cgi?id=37023 + + Enables to set TimeDelay and ChunkSize for + HTMLTokenizer. + + * Api/qwebpage.cpp: + (QWebPagePrivate::dynamicPropertyChangeEvent): + +2010-05-04 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] QWebPage viewMode property + https://bugs.webkit.org/show_bug.cgi?id=38119 + + Rename the property from wrt_viewMode to _q_viewMode. + + * Api/qwebpage.cpp: + (QWebPagePrivate::dynamicPropertyChangeEvent): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::viewModes): + +2010-04-28 Luiz Agostini + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] QWebPage viewMode property + https://bugs.webkit.org/show_bug.cgi?id=38119 + + Replacing method qt_wrt_setViewMode by wrt_viewMode property. + + * Api/qwebpage.cpp: + (QWebPagePrivate::dynamicPropertyChangeEvent): + (QWebPage::event): + * Api/qwebpage_p.h: + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::wrt_viewModes): + 2010-04-09 Tasuku Suzuki Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def b/src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def index a450f9e..910ba8f 100644 --- a/src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def +++ b/src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def @@ -642,7 +642,7 @@ EXPORTS ?qt_drt_webinspector_executeScript@@YAXPAVQWebPage@@JABVQString@@@Z @ 641 NONAME ; void qt_drt_webinspector_executeScript(class QWebPage *, long, class QString const &) ?qt_drt_webinspector_show@@YAXPAVQWebPage@@@Z @ 642 NONAME ; void qt_drt_webinspector_show(class QWebPage *) ?qt_drt_workerThreadCount@@YAHXZ @ 643 NONAME ; int qt_drt_workerThreadCount(void) - ?qt_wrt_setViewMode@@YAXPAVQWebPage@@ABVQString@@@Z @ 644 NONAME ; void qt_wrt_setViewMode(class QWebPage *, class QString const &) + ?qt_wrt_setViewMode@@YAXPAVQWebPage@@ABVQString@@@Z @ 644 NONAME ABSENT ; void qt_wrt_setViewMode(class QWebPage *, class QString const &) ?qtwebkit_webframe_scrollRecursively@@YAXPAVQWebFrame@@HHABVQPoint@@@Z @ 645 NONAME ; void qtwebkit_webframe_scrollRecursively(class QWebFrame *, int, int, class QPoint const &) ?resizesToContents@QGraphicsWebView@@QBE_NXZ @ 646 NONAME ; bool QGraphicsWebView::resizesToContents(void) const ?scrollToAnchor@QWebFrame@@QAEXABVQString@@@Z @ 647 NONAME ; void QWebFrame::scrollToAnchor(class QString const &) diff --git a/src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def b/src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def index 145fe0b..ca462d0 100644 --- a/src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def +++ b/src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def @@ -716,7 +716,7 @@ EXPORTS _ZN13QWebInspector10closeEventEP11QCloseEvent @ 715 NONAME _ZN16QGraphicsWebView26setTiledBackingStoreFrozenEb @ 716 NONAME _ZNK16QGraphicsWebView25isTiledBackingStoreFrozenEv @ 717 NONAME - _Z18qt_wrt_setViewModeP8QWebPageRK7QString @ 718 NONAME + _Z18qt_wrt_setViewModeP8QWebPageRK7QString @ 718 NONAME ABSENT _Z19qt_drt_setMediaTypeP9QWebFrameRK7QString @ 719 NONAME _Z26qt_drt_enableCaretBrowsingP8QWebPageb @ 720 NONAME _ZNK12QWebSettings12inspectorUrlEv @ 721 NONAME diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index f7eddd5..834a394 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -110,6 +110,8 @@ private slots: void userAgentApplicationName(); void userAgentLocaleChange(); + void viewModes(); + void crashTests_LazyInitializationOfMainFrame(); void screenshot_data(); @@ -357,6 +359,21 @@ void tst_QWebPage::userStyleSheet() QCOMPARE(networkManager->requestedUrls.at(0), QUrl("http://does.not/exist.png")); } +void tst_QWebPage::viewModes() +{ + m_view->setHtml(""); + m_page->setProperty("_q_viewMode", "minimized"); + + QVariant empty = m_page->mainFrame()->evaluateJavaScript("window.styleMedia.matchMedium(\"(-webkit-view-mode)\")"); + QVERIFY(empty.type() == QVariant::Bool && empty.toBool()); + + QVariant minimized = m_page->mainFrame()->evaluateJavaScript("window.styleMedia.matchMedium(\"(-webkit-view-mode: minimized)\")"); + QVERIFY(minimized.type() == QVariant::Bool && minimized.toBool()); + + QVariant maximized = m_page->mainFrame()->evaluateJavaScript("window.styleMedia.matchMedium(\"(-webkit-view-mode: maximized)\")"); + QVERIFY(maximized.type() == QVariant::Bool && !maximized.toBool()); +} + void tst_QWebPage::modified() { m_page->mainFrame()->setUrl(QUrl("data:text/html,blub")); -- cgit v0.12 From 814f7d3d607edacca091273302297b6b2674424f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 11 May 2010 12:49:32 +0200 Subject: Fix compiler warning in QT_REQUIRE_VERSION warning: format not a string literal and no format arguments Task-number: QTBUG-8967 Reviewed-by: Gabriel --- src/gui/dialogs/qmessagebox.h | 2 +- tests/auto/qmessagebox/tst_qmessagebox.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qmessagebox.h b/src/gui/dialogs/qmessagebox.h index bc6170d..f1ff6cc 100644 --- a/src/gui/dialogs/qmessagebox.h +++ b/src/gui/dialogs/qmessagebox.h @@ -354,7 +354,7 @@ if (!qApp){ \ QString s = QApplication::tr("Executable '%1' requires Qt "\ "%2, found Qt %3.").arg(qAppName()).arg(QString::fromLatin1(\ str)).arg(QString::fromLatin1(qVersion())); QMessageBox::critical(0, QApplication::tr(\ -"Incompatible Qt Library Error"), s, QMessageBox::Abort, 0); qFatal(s.toLatin1().data()); }} +"Incompatible Qt Library Error"), s, QMessageBox::Abort, 0); qFatal("%s", s.toLatin1().data()); }} #endif // QT_NO_MESSAGEBOX diff --git a/tests/auto/qmessagebox/tst_qmessagebox.cpp b/tests/auto/qmessagebox/tst_qmessagebox.cpp index 2de1c52..d4ca064 100644 --- a/tests/auto/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/qmessagebox/tst_qmessagebox.cpp @@ -140,6 +140,8 @@ private: tst_QMessageBox::tst_QMessageBox() : keyToSend(-1) { + int argc = qApp->argc(); + QT_REQUIRE_VERSION(argc, qApp->argv(), "4.6.2") } int tst_QMessageBox::exec(QMessageBox *msgBox, int key) -- cgit v0.12 From 949f49c9ea4dadfc6e7f3bf7d822830b7ef8a8e6 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Tue, 11 May 2010 15:30:12 +0200 Subject: Doc: Fixed tables and images for the new docs Added page.png to images dir. Fixed tables "generic" --- doc/src/getting-started/demos.qdoc | 7 +++--- doc/src/template/images/page.png | Bin 0 -> 3102 bytes doc/src/template/scripts/functions.js | 14 +++++++++--- doc/src/template/style/style.css | 39 +++++++++++++++++++++----------- tools/qdoc3/htmlgenerator.cpp | 41 ++++++++++++++++++---------------- 5 files changed, 62 insertions(+), 39 deletions(-) create mode 100644 doc/src/template/images/page.png diff --git a/doc/src/getting-started/demos.qdoc b/doc/src/getting-started/demos.qdoc index 6974634..f8c70fe 100644 --- a/doc/src/getting-started/demos.qdoc +++ b/doc/src/getting-started/demos.qdoc @@ -53,15 +53,14 @@ \l{Qt Examples} and are used to highlight certain features of Qt. - \table 50% + \table \header \o {2,1} Getting an Overview \row \o \inlineimage qtdemo-small.png - \o - If you run the \l{Examples and Demos Launcher}, you'll see many of Qt's + \o If you run the \l{Examples and Demos Launcher}, you'll see many of Qt's widgets in action. - + The \l{Qt Widget Gallery} also provides overviews of selected Qt widgets in each of the styles used on various supported platforms. \endtable diff --git a/doc/src/template/images/page.png b/doc/src/template/images/page.png new file mode 100644 index 0000000..1db151b Binary files /dev/null and b/doc/src/template/images/page.png differ diff --git a/doc/src/template/scripts/functions.js b/doc/src/template/scripts/functions.js index 2362bc4..09b7de3 100755 --- a/doc/src/template/scripts/functions.js +++ b/doc/src/template/scripts/functions.js @@ -50,7 +50,6 @@ function processNokiaData(response){ if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'APIPage'){ lookupCount++; //$('.live001').css('display','block'); - $('#ul001 .defaultLink').css('display','none'); for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ @@ -58,13 +57,14 @@ function processNokiaData(response){ full_li_element = full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd; $('#ul001').append(full_li_element); + $('#ul001 .defaultLink').css('display','none'); + } } if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Article'){ articleCount++; //$('.live002').css('display','block'); - $('#ul002 .defaultLink').css('display','none'); for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ @@ -72,12 +72,13 @@ function processNokiaData(response){ full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ; $('#ul002').append(full_li_element); + $('#ul002 .defaultLink').css('display','none'); + } } if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Example'){ exampleCount++; //$('.live003').css('display','block'); - $('#ul003 .defaultLink').css('display','none'); for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ @@ -85,6 +86,8 @@ function processNokiaData(response){ full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ; $('#ul003').append(full_li_element); + $('#ul003 .defaultLink').css('display','none'); + } } } @@ -122,6 +125,11 @@ function CheckEmptyAndLoadList() $(document).ready(function () { var pageTitle = $('title').html(); $('#feedform').append(''); + var currentString = $('#pageType').val() ; + if(currentString.length < 1){ + $('.defaultLink').css('display','block'); + CheckEmptyAndLoadList(); + } $('#pageType').keyup(function () { var searchString = $('#pageType').val() ; diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index 2e01af6..d87b11f 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -302,6 +302,9 @@ .sidebar .box .list { display: block; + max-height:200px; + overflow-y:auto; + overflow-x:none; } .sidebar .box .live { @@ -315,7 +318,7 @@ } .sidebar .box ul { - padding:10px 0 0 10px; + padding:10px; } .sidebar .box ul li { @@ -488,8 +491,13 @@ .wrap .content p { line-height: 20px; - padding: 5px 5px 5px 5px; + padding: 5px; } + .wrap .content table p + { + line-height: 20px; + padding: 0px; + } .wrap .content ul { padding-left: 25px; @@ -743,20 +751,21 @@ thead { margin-top: 5px; + font:600 12px/1.2 Arial; } th { padding: 5px 15px 5px 15px; background-color: #E1E1E1; - border-bottom: 1px solid #E6E6E6; + /* border-bottom: 1px solid #E6E6E6;*/ border-left: 1px solid #E6E6E6; - border-right: 1px solid #E6E6E6; + /* border-right: 1px solid #E6E6E6;*/ } td { padding: 3px 15px 3px 20px; - border-left: 1px solid #E6E6E6; - border-right: 1px solid #E6E6E6; + /* border-left: 1px solid #E6E6E6; + border-right: 1px solid #E6E6E6;*/ } tr.odd td:hover, tr.even td:hover { @@ -780,15 +789,11 @@ background-color: #ffffff; color: #66666E; } - table tr.odd:hover - { - background-color: #E6E6E6; - } - table tr.even:hover + table tr.odd td:hover, table tr.even td:hover { background-color: #E6E6E6; } - + span.comment { color: #8B0000; @@ -892,12 +897,20 @@ } .generic{ - max-width:100%; + max-width:75%; } .generic td{ padding:0; } + .generic .odd .alphaChar{ + background-color: #F6F6F6; + } + + .generic .even .alphaChar{ + background-color: #FFFFFF; + } + .alignedsummary{} .propsummary{} .memItemLeft{} diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 638ae94..5e33463 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1149,7 +1149,10 @@ int HtmlGenerator::generateAtom(const Atom *atom, out() << " colspan=\"" << spans.at(0) << "\""; if (spans.at(1) != "1") out() << " rowspan=\"" << spans.at(1) << "\""; + if (inTableHeader) out() << ">"; + else + out() << ">

      "; } if (matchAhead(atom, Atom::ParaLeft)) skipAhead = 1; @@ -1159,7 +1162,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, if (inTableHeader) out() << ""; else - out() << ""; + out() << "

      "; if (matchAhead(atom, Atom::ParaLeft)) skipAhead = 1; break; @@ -2276,22 +2279,22 @@ void HtmlGenerator::generateAnnotatedList(const Node *relative, out() << "
      "; else out() << ""; - out() << ""; + out() << "

      "; if (!(node->type() == Node::Fake)) { Text brief = node->doc().trimmedBriefText(name); if (!brief.isEmpty()) { - out() << ""; + out() << "

      "; } } else { - out() << ""; + out() << "

      "; } out() << "\n"; } @@ -2473,7 +2476,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, for (i = 0; i < NumColumns; i++) { if (currentOffset[i] >= firstOffset[i + 1]) { // this column is finished - out() << "\n"; + out() << "\n"; // check why? } else { while ((currentParagraphNo[i] < NumParagraphs) && @@ -2488,7 +2491,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, currentParagraphNo[i] = NumParagraphs - 1; } #endif - out() << "\n"; - out() << "\n"; + out() << "

      \n"; currentOffset[i]++; currentOffsetInParagraph[i]++; @@ -4438,7 +4441,7 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, else out() << ""; - out() << ""; + out() << "

      "; if (qpgn->isDefault()) { out() << "
      "; + //out() << "
      "; out() << ""; generateSynopsis(qmn,relative,marker,CodeMarker::Detailed,false); out() << "
      , not . --- tools/qdoc3/htmlgenerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 6560b68..67aa6c6 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -2275,9 +2275,9 @@ void HtmlGenerator::generateAnnotatedList(const Node *relative, out() << "
      "; + out() << ""; generateFullName(node, relative, marker); - out() << ""; + out() << "
      "; + out() << "

      "; generateFullName(node, relative, marker); - out() << "

      "; + out() << "

      "; generateText(brief, node, marker); - out() << "

      "; + out() << "

      "; out() << protectEnc(node->doc().briefText().toString()); - out() << "

      \n\n"; + out() << "

      "; if (currentOffsetInParagraph[i] == 0) { // start a new paragraph if (includeAlphabet) { @@ -2499,9 +2502,9 @@ void HtmlGenerator::generateCompactList(const Node *relative, << paragraphName[currentParagraphNo[i]] << ""; } - out() << "\n"; + out() << "

      "; + out() << "

      "; if ((currentParagraphNo[i] < NumParagraphs) && !paragraphName[currentParagraphNo[i]].isEmpty()) { NodeMap::Iterator it; @@ -2527,7 +2530,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, out() << ")"; } } - out() << "

      "; + out() << "

      "; //out() << "

      "; // old out() << ""; if (!qpn->isWritable()) @@ -4446,14 +4449,14 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, if (qpgn->isDefault()) out() << "default"; generateQmlItem(qpn, relative, marker, false); - out() << "
      " << "
      " << "
      " << "
      " << "" - << ""; + << ""; } } ++p; @@ -4470,11 +4473,11 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, out() << ""; else out() << ""; - out() << ""; + out() << "

      "; out() << "
      default

      default

      "; + out() << "

      "; out() << ""; generateSynopsis(qsn,relative,marker,CodeMarker::Detailed,false); //generateQmlItem(qsn,relative,marker,false); - out() << "

      "; out() << "
      "; } @@ -4487,10 +4490,10 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, out() << "
      "; + out() << "

      "; out() << ""; generateSynopsis(qmn,relative,marker,CodeMarker::Detailed,false); - out() << "

      "; out() << "
      "; } -- cgit v0.12 From a1cda97c4002195f98c18c460d1f30682bb5a82e Mon Sep 17 00:00:00 2001 From: Jason Hollingsworth Date: Tue, 11 May 2010 16:26:42 +0200 Subject: Added QDateTime::msecsTo() This adds a QDateTime::msecsTo() function which is similar to QDateTime::secsTo(). This refers to QTBUG-8790 and task 147685. According to the task this functionality should have been added in version 4.5.0 but it never was. Task-number: 147685 Task-number: QTBUG-8790 Merge-request: 501 Reviewed-by: Benjamin Poulain Reviewed-by: Andreas Kling --- src/corelib/tools/qdatetime.cpp | 44 +++++++++++++++++++++++++++------- src/corelib/tools/qdatetime.h | 1 + tests/auto/qdatetime/tst_qdatetime.cpp | 26 ++++++++++++++++++++ 3 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 9afcd80..9f5d8c6 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1705,7 +1705,7 @@ int QTime::secsTo(const QTime &t) const Note that the time will wrap if it passes midnight. See addSecs() for an example. - \sa addSecs(), msecsTo() + \sa addSecs(), msecsTo(), QDateTime::addMSecs() */ QTime QTime::addMSecs(int ms) const @@ -1734,7 +1734,7 @@ QTime QTime::addMSecs(int ms) const seconds in a day, the result is always between -86400000 and 86400000 ms. - \sa secsTo(), addMSecs() + \sa secsTo(), addMSecs(), QDateTime::msecsTo() */ int QTime::msecsTo(const QTime &t) const @@ -2042,10 +2042,11 @@ int QTime::elapsed() const later. You can increment (or decrement) a datetime by a given number of - seconds using addSecs(), or days using addDays(). Similarly you can - use addMonths() and addYears(). The daysTo() function returns the - number of days between two datetimes, and secsTo() returns the - number of seconds between two datetimes. + milliseconds using addMSecs(), seconds using addSecs(), or days + using addDays(). Similarly you can use addMonths() and addYears(). + The daysTo() function returns the number of days between two datetimes, + secsTo() returns the number of seconds between two datetimes, and + msecsTo() returns the number of milliseconds between two datetimes. QDateTime can store datetimes as \l{Qt::LocalTime}{local time} or as \l{Qt::UTC}{UTC}. QDateTime::currentDateTime() returns a @@ -2719,7 +2720,7 @@ QDateTime QDateTime::addSecs(int s) const later than the datetime of this object (or earlier if \a msecs is negative). - \sa addSecs(), secsTo(), addDays(), addMonths(), addYears() + \sa addSecs(), msecsTo(), addDays(), addMonths(), addYears() */ QDateTime QDateTime::addMSecs(qint64 msecs) const { @@ -2731,7 +2732,7 @@ QDateTime QDateTime::addMSecs(qint64 msecs) const datetime. If the \a other datetime is earlier than this datetime, the value returned is negative. - \sa addDays(), secsTo() + \sa addDays(), secsTo(), msecsTo() */ int QDateTime::daysTo(const QDateTime &other) const @@ -2766,6 +2767,33 @@ int QDateTime::secsTo(const QDateTime &other) const } /*! + Returns the number of milliseconds from this datetime to the \a other + datetime. If the \a other datetime is earlier than this datetime, + the value returned is negative. + + Before performing the comparison, the two datetimes are converted + to Qt::UTC to ensure that the result is correct if one of the two + datetimes has daylight saving time (DST) and the other doesn't. + + \sa addMSecs(), daysTo(), QTime::msecsTo() +*/ + +qint64 QDateTime::msecsTo(const QDateTime &other) const +{ + QDate selfDate; + QDate otherDate; + QTime selfTime; + QTime otherTime; + + d->getUTC(selfDate, selfTime); + other.d->getUTC(otherDate, otherTime); + + return (static_cast(selfDate.daysTo(otherDate)) * static_cast(MSECS_PER_DAY)) + + static_cast(selfTime.msecsTo(otherTime)); +} + + +/*! \fn QDateTime QDateTime::toTimeSpec(Qt::TimeSpec specification) const Returns a copy of this datetime configured to use the given time diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index f445f1c..2466aeb 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -251,6 +251,7 @@ public: inline QDateTime toUTC() const { return toTimeSpec(Qt::UTC); } int daysTo(const QDateTime &) const; int secsTo(const QDateTime &) const; + qint64 msecsTo(const QDateTime &) const; bool operator==(const QDateTime &other) const; inline bool operator!=(const QDateTime &other) const { return !(*this == other); } diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index 6aca996..47c54a5 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -106,6 +106,8 @@ private slots: void daysTo(); void secsTo_data(); void secsTo(); + void msecsTo_data(); + void msecsTo(); void operator_eqeq(); void currentDateTime(); void currentDateTimeUtc(); @@ -910,6 +912,30 @@ void tst_QDateTime::secsTo() QVERIFY((dt >= result) == (0 >= nsecs)); } +void tst_QDateTime::msecsTo_data() +{ + addMSecs_data(); +} + +void tst_QDateTime::msecsTo() +{ + QFETCH(QDateTime, dt); + QFETCH(int, nsecs); + QFETCH(QDateTime, result); + +#ifdef Q_OS_IRIX + QEXPECT_FAIL("cet4", "IRIX databases say 1970 had DST", Abort); +#endif + QCOMPARE(dt.msecsTo(result), qint64(nsecs) * 1000); + QCOMPARE(result.msecsTo(dt), -qint64(nsecs) * 1000); + QVERIFY((dt == result) == (0 == (qint64(nsecs) * 1000))); + QVERIFY((dt != result) == (0 != (qint64(nsecs) * 1000))); + QVERIFY((dt < result) == (0 < (qint64(nsecs) * 1000))); + QVERIFY((dt <= result) == (0 <= (qint64(nsecs) * 1000))); + QVERIFY((dt > result) == (0 > (qint64(nsecs) * 1000))); + QVERIFY((dt >= result) == (0 >= (qint64(nsecs) * 1000))); +} + void tst_QDateTime::currentDateTime() { #if defined(Q_OS_WINCE) -- cgit v0.12 From d8b693310ef268c4f58bd2e04b7613460b76bac3 Mon Sep 17 00:00:00 2001 From: Trond Kjernaasen Date: Tue, 11 May 2010 16:34:14 +0200 Subject: Fixed QGLPixmapDropShadowFilter on Nvidia hardware. There seems to be a driver bug that causes glTexSubImage2D() to not align data correctly when uploading a GL_ALPHA texture. Task-number: related to QTBUG-10510 Reviewed-by: Samuel --- src/opengl/qglpixmapfilter.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index d5a11d9..bfa5ef1 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -591,10 +591,11 @@ bool QGLPixmapDropShadowFilter::processGL(QPainter *painter, const QPointF &pos, qt_blurImage(image, r * qreal(0.5), false, 1); - GLuint texture = generateBlurTexture(image.size(), GL_ALPHA); - - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image.width(), image.height(), GL_ALPHA, - GL_UNSIGNED_BYTE, image.bits()); + GLuint texture; + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, image.width(), image.height(), + 0, GL_ALPHA, GL_UNSIGNED_BYTE, image.bits()); info = new QGLBlurTextureInfo(image, texture, r); } -- cgit v0.12 From c316e141fa511a6f0549630153e3502cca42f592 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Tue, 11 May 2010 22:57:29 +0200 Subject: Doc: Update on web template Updated Form action --- tools/qdoc3/test/qt-html-templates.qdocconf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index e5d73c7..31fc414 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -31,7 +31,7 @@ HTML.postheader = "
      \n" \ "
      \n" \ " Search index:
      \n" \ "
      \n" \ - "
      \n" \ + " \n" \ "
      \n" \ " \n" \ "
      \n" \ -- cgit v0.12 From dae547d26f8c7d4c75b02045e23213c798a2fa3e Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 12 May 2010 08:13:41 +1000 Subject: Clarify ListModel population via JS. Task-number: QTBUG-10457 --- doc/src/declarative/qdeclarativemodels.qdoc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc index 9b706a1..788d417 100644 --- a/doc/src/declarative/qdeclarativemodels.qdoc +++ b/doc/src/declarative/qdeclarativemodels.qdoc @@ -143,6 +143,28 @@ ListView { } \endcode +It is also possible to manipulate the ListModel directly via JavaScript. +In this case, the first item inserted will determine the roles available +to any views using the model. For example, if an empty ListModel is +created and populated via JavaScript the roles provided by the first +insertion are the only roles that will be shown in the view: + +\code +Item { + ListModel { + id: fruitModel + } + MouseArea { + anchors.fill: parent + onClicked: fruitModel.append({"cost": 5.95, "name":"Pizza"}) + } +} +\endcode + +When the MouseArea is clicked fruitModel will have two roles, "cost" and "name". +Even if subsequent roles are added, only the first two will be handled by views +using the model. + \section2 XmlListModel -- cgit v0.12 From c4bb04a6154931570dee72b3a1ed34af31814d17 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 12 May 2010 08:28:55 +1000 Subject: Don't store the role-property map for each individual item. C++ models share a single metaobject type, so we don't need to create role-property mappings for each individual item. Also warn on attempt to modify a role that the model is unaware of (part of QTBUG-10457) --- .../graphicsitems/qdeclarativegridview.cpp | 2 +- .../graphicsitems/qdeclarativelistview.cpp | 3 +- .../graphicsitems/qdeclarativerepeater.cpp | 2 +- .../graphicsitems/qdeclarativevisualitemmodel.cpp | 63 ++++++++++++++-------- .../graphicsitems/qdeclarativevisualitemmodel_p.h | 6 +-- 5 files changed, 47 insertions(+), 29 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 7b413fb..305d55c 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1027,7 +1027,7 @@ void QDeclarativeGridView::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this)); + d->model = new QDeclarativeVisualDataModel(qmlContext(this), this); d->ownModel = true; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 416e0a8..65edb03 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -1461,7 +1462,7 @@ void QDeclarativeListView::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this)); + d->model = new QDeclarativeVisualDataModel(qmlContext(this), this); d->ownModel = true; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index ca0b8c6..04076f8 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -193,7 +193,7 @@ void QDeclarativeRepeater::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this)); + d->model = new QDeclarativeVisualDataModel(qmlContext(this), this); d->ownModel = true; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 1038c83..0e4217e 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -138,8 +138,8 @@ public: } \endcode */ -QDeclarativeVisualItemModel::QDeclarativeVisualItemModel() - : QDeclarativeVisualModel(*(new QDeclarativeVisualItemModelPrivate)) +QDeclarativeVisualItemModel::QDeclarativeVisualItemModel(QObject *parent) + : QDeclarativeVisualModel(*(new QDeclarativeVisualItemModelPrivate), parent) { } @@ -269,7 +269,8 @@ public: } if (m_roles.count() == 1) m_roleNames.insert("modelData", m_roles.at(0)); - m_roleNames.insert("hasModelChildren", 0); + if (m_roles.count()) + m_roleNames.insert("hasModelChildren", 0); } else if (m_listAccessor) { m_roleNames.insert("modelData", 0); if (m_listAccessor->type() == QDeclarativeListAccessor::Instance) { @@ -285,15 +286,19 @@ public: } } + QHash roleToPropId; void createMetaData() { if (!m_metaDataCreated) { ensureRoles(); - QHash::const_iterator it = m_roleNames.begin(); - while (it != m_roleNames.end()) { - m_delegateDataType->createProperty(it.key()); - ++it; + if (m_roleNames.count()) { + QHash::const_iterator it = m_roleNames.begin(); + while (it != m_roleNames.end()) { + int propId = m_delegateDataType->createProperty(it.key()) - m_delegateDataType->propertyOffset(); + roleToPropId.insert(*it, propId); + ++it; + } + m_metaDataCreated = true; } - m_metaDataCreated = true; } } @@ -383,7 +388,6 @@ public: private: friend class QDeclarativeVisualDataModelData; - QHash roleToProp; }; class QDeclarativeVisualDataModelData : public QObject @@ -400,6 +404,8 @@ public: int propForRole(int) const; void setValue(int, const QVariant &); + void ensureProperties(); + Q_SIGNALS: void indexChanged(); @@ -412,9 +418,11 @@ private: int QDeclarativeVisualDataModelData::propForRole(int id) const { - QHash::const_iterator it = m_meta->roleToProp.find(id); - if (it != m_meta->roleToProp.end()) - return m_meta->roleToProp[id]; + QDeclarativeVisualDataModelPrivate *model = QDeclarativeVisualDataModelPrivate::get(m_model); + QHash::const_iterator it = model->roleToPropId.find(id); + if (it != model->roleToPropId.end()) + return *it; + return -1; } @@ -470,12 +478,10 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId) model->ensureRoles(); QHash::const_iterator it = model->m_roleNames.find(propName); if (it != model->m_roleNames.end()) { - roleToProp.insert(*it, propId); QVariant value = model->m_listModelInterface->data(data->m_index, *it); return value; } else if (model->m_roles.count() == 1 && propName == "modelData") { //for compatability with other lists, assign modelData if there is only a single role - roleToProp.insert(model->m_roles.first(), propId); QVariant value = model->m_listModelInterface->data(data->m_index, model->m_roles.first()); return value; } @@ -487,7 +493,6 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId) } else { QHash::const_iterator it = model->m_roleNames.find(propName); if (it != model->m_roleNames.end()) { - roleToProp.insert(*it, propId); QModelIndex index = model->m_abstractItemModel->index(data->m_index, 0, model->m_root); return model->m_abstractItemModel->data(index, *it); } @@ -502,18 +507,23 @@ QDeclarativeVisualDataModelData::QDeclarativeVisualDataModelData(int index, : m_index(index), m_model(model), m_meta(new QDeclarativeVisualDataModelDataMetaObject(this, QDeclarativeVisualDataModelPrivate::get(model)->m_delegateDataType)) { - QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(model); - if (modelPriv->m_metaDataCacheable) { - if (!modelPriv->m_metaDataCreated) - modelPriv->createMetaData(); - m_meta->setCached(true); - } + ensureProperties(); } QDeclarativeVisualDataModelData::~QDeclarativeVisualDataModelData() { } +void QDeclarativeVisualDataModelData::ensureProperties() +{ + QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(m_model); + if (modelPriv->m_metaDataCacheable && !modelPriv->m_metaDataCreated) { + modelPriv->createMetaData(); + if (modelPriv->m_metaDataCreated) + m_meta->setCached(true); + } +} + int QDeclarativeVisualDataModelData::index() const { return m_index; @@ -626,8 +636,8 @@ QDeclarativeVisualDataModel::QDeclarativeVisualDataModel() { } -QDeclarativeVisualDataModel::QDeclarativeVisualDataModel(QDeclarativeContext *ctxt) -: QDeclarativeVisualModel(*(new QDeclarativeVisualDataModelPrivate(ctxt))) +QDeclarativeVisualDataModel::QDeclarativeVisualDataModel(QDeclarativeContext *ctxt, QObject *parent) +: QDeclarativeVisualModel(*(new QDeclarativeVisualDataModelPrivate(ctxt)), parent) { } @@ -1212,6 +1222,13 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root); data->setValue(propId, d->m_abstractItemModel->data(index, role)); } + } else { + QString roleName; + if (d->m_listModelInterface) + roleName = d->m_listModelInterface->toString(role); + else if (d->m_abstractItemModel) + roleName = d->m_abstractItemModel->roleNames().value(role); + qmlInfo(this) << "Changing role not present in item: " << roleName; } } } diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h index edfd387..0bdbbcf 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h @@ -72,7 +72,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeVisualModel : public QObject Q_PROPERTY(int count READ count NOTIFY countChanged) public: - QDeclarativeVisualModel() {} + QDeclarativeVisualModel(QObject *parent=0) : QObject(parent) {} virtual ~QDeclarativeVisualModel() {} enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02 }; @@ -117,7 +117,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeVisualItemModel : public QDeclarativeVisu Q_CLASSINFO("DefaultProperty", "children") public: - QDeclarativeVisualItemModel(); + QDeclarativeVisualItemModel(QObject *parent=0); virtual ~QDeclarativeVisualItemModel() {} virtual int count() const; @@ -156,7 +156,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeVisualDataModel : public QDeclarativeVisu Q_CLASSINFO("DefaultProperty", "delegate") public: QDeclarativeVisualDataModel(); - QDeclarativeVisualDataModel(QDeclarativeContext *); + QDeclarativeVisualDataModel(QDeclarativeContext *, QObject *parent=0); virtual ~QDeclarativeVisualDataModel(); QVariant model() const; -- cgit v0.12 From 1809eb091cb47c914713ecef6e514e912a4e113b Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 10 May 2010 15:38:12 +1000 Subject: Expand if available space changes. Task-number: QT-3175 --- demos/declarative/webbrowser/content/FlickableWebView.qml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 2862cc4..7efbaa3 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -20,6 +20,12 @@ Flickable { anchors.right: parent.right pressDelay: 200 + onWidthChanged : { + // Expand (but not above 1:1) if otherwise would be smaller that available width. + if (width > webView.width*webView.contentsScale && webView.contentsScale < 1.0) + webView.contentsScale = width / webView.width * webView.contentsScale; + } + WebView { id: webView pixelCacheSize: 4000000 -- cgit v0.12 From 797d44e7415e8f9d582dd2838957cf309cea9449 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 11 May 2010 09:01:51 +1000 Subject: Temporary work-around for QTBUG-9849. May allow better experimentation and bug fixing. --- tools/qml/main.cpp | 6 ++++++ tools/qml/qmlruntime.cpp | 11 +++++++++++ tools/qml/qmlruntime.h | 2 ++ 3 files changed, 19 insertions(+) diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index fb687ac..116ca71 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -231,6 +231,7 @@ int main(int argc, char ** argv) bool stayOnTop = false; bool maximized = false; bool useNativeFileBrowser = true; + bool experimentalGestures = false; WarningsConfig warningsConfig = DefaultWarnings; bool sizeToView = true; @@ -334,6 +335,8 @@ int main(int argc, char ** argv) sizeToView = false; } else if (arg == "-sizerootobjecttoview") { sizeToView = true; + } else if (arg == "-experimentalgestures") { + experimentalGestures = true; } else if (arg[0] != '-') { fileName = arg; } else if (1 || arg == "-help") { @@ -403,6 +406,9 @@ int main(int argc, char ** argv) } #endif + if (experimentalGestures) + viewer->enableExperimentalGestures(); + foreach (QString lib, imports) viewer->addLibraryPath(lib); diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 06fa004..16b0ffb 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -501,6 +501,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) } canvas = new QDeclarativeView(this); + canvas->setAttribute(Qt::WA_OpaquePaintEvent); canvas->setAttribute(Qt::WA_NoSystemBackground); @@ -550,6 +551,16 @@ QDeclarativeViewer::~QDeclarativeViewer() delete namFactory; } +void QDeclarativeViewer::enableExperimentalGestures() +{ + canvas->viewport()->grabGesture(Qt::TapGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); + canvas->viewport()->grabGesture(Qt::TapAndHoldGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); + canvas->viewport()->grabGesture(Qt::PanGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); + canvas->viewport()->grabGesture(Qt::PinchGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); + canvas->viewport()->grabGesture(Qt::SwipeGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); + canvas->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); +} + int QDeclarativeViewer::menuBarHeight() const { if (!(windowFlags() & Qt::FramelessWindowHint)) diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 9551090..b021d0d 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -112,6 +112,8 @@ public: QDeclarativeView *view() const; LoggerWidget *warningsWidget() const; + void enableExperimentalGestures(); + public slots: void sceneResized(QSize size); bool open(const QString&); -- cgit v0.12 From 355bacaa767f48014478d91e3d79f19f966c9756 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 11 May 2010 16:50:24 +1000 Subject: Ensure QPixmapCache does not flush pixmaps that are still in use. Task-number: QTBUG-10576 Reviewed-by: Alexis Menard --- src/gui/image/qpixmapcache.cpp | 43 ++++++++++++++++++++++++++-- src/gui/image/qpixmapcache.h | 10 +++++++ src/gui/image/qpixmapcache_p.h | 2 ++ tests/auto/qpixmapcache/tst_qpixmapcache.cpp | 34 +++++++++++++++------- 4 files changed, 77 insertions(+), 12 deletions(-) diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 5fc605a..7a6a73f 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#define Q_TEST_QPIXMAPCACHE #include "qpixmapcache.h" #include "qobject.h" #include "qdebug.h" @@ -194,6 +195,9 @@ public: static QPixmapCache::KeyData* getKeyData(QPixmapCache::Key *key); + QList< QPair > allPixmaps() const; + void flushDetachedPixmaps(bool nt); + private: int *keyArray; int theid; @@ -235,10 +239,9 @@ QPMCache::~QPMCache() When the last pixmap has been deleted from the cache, kill the timer so Qt won't keep the CPU from going into sleep mode. */ -void QPMCache::timerEvent(QTimerEvent *) +void QPMCache::flushDetachedPixmaps(bool nt) { int mc = maxCost(); - bool nt = totalCost() == ps; setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1); setMaxCost(mc); ps = totalCost(); @@ -252,6 +255,12 @@ void QPMCache::timerEvent(QTimerEvent *) ++it; } } +} + +void QPMCache::timerEvent(QTimerEvent *) +{ + bool nt = totalCost() == ps; + flushDetachedPixmaps(nt); if (!size()) { killTimer(theid); @@ -263,6 +272,7 @@ void QPMCache::timerEvent(QTimerEvent *) } } + QPixmap *QPMCache::object(const QString &key) const { QPixmapCache::Key cacheKey = cacheKeys.value(key); @@ -422,6 +432,20 @@ QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key) return key->d; } +QList< QPair > QPMCache::allPixmaps() const +{ + QList< QPair > r; + QHash::const_iterator it = cacheKeys.begin(); + while (it != cacheKeys.end()) { + QPixmap *ptr = QCache::object(it.value()); + if (ptr) + r.append(QPair(it.key(),*ptr)); + ++it; + } + return r; +} + + Q_GLOBAL_STATIC(QPMCache, pm_cache) int Q_AUTOTEST_EXPORT q_QPixmapCache_keyHashSize() @@ -633,4 +657,19 @@ void QPixmapCache::clear() } } +void QPixmapCache::flushDetachedPixmaps() +{ + pm_cache()->flushDetachedPixmaps(true); +} + +int QPixmapCache::totalUsed() +{ + return (pm_cache()->totalCost()+1023) / 1024; +} + +QList< QPair > QPixmapCache::allPixmaps() +{ + return pm_cache()->allPixmaps(); +} + QT_END_NAMESPACE diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h index 50a9369..e9c8c15 100644 --- a/src/gui/image/qpixmapcache.h +++ b/src/gui/image/qpixmapcache.h @@ -44,6 +44,10 @@ #include +#ifdef Q_TEST_QPIXMAPCACHE +#include +#endif + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -83,6 +87,12 @@ public: static void remove(const QString &key); static void remove(const Key &key); static void clear(); + +#ifdef Q_TEST_QPIXMAPCACHE + static void flushDetachedPixmaps(); + static int totalUsed(); + static QList< QPair > allPixmaps(); +#endif }; QT_END_NAMESPACE diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h index 86a1b78..825f272 100644 --- a/src/gui/image/qpixmapcache_p.h +++ b/src/gui/image/qpixmapcache_p.h @@ -95,6 +95,8 @@ public: QPixmapCache::Key key; }; +inline bool qIsDetached(QPixmapCacheEntry &t) { return t.isDetached(); } + QT_END_NAMESPACE #endif // QPIXMAPCACHE_P_H diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp index f8951f5..70f2ac3 100644 --- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#define Q_TEST_QPIXMAPCACHE #include @@ -152,6 +153,7 @@ void tst_QPixmapCache::setCacheLimit() p1 = new QPixmap(2, 3); key = QPixmapCache::insert(*p1); QVERIFY(QPixmapCache::find(key, p1) != 0); + p1->detach(); // dectach so that the cache thinks no-one is using it. QPixmapCache::setCacheLimit(0); QVERIFY(QPixmapCache::find(key, p1) == 0); QPixmapCache::setCacheLimit(1000); @@ -169,6 +171,8 @@ void tst_QPixmapCache::setCacheLimit() key = QPixmapCache::insert(*p1); QVERIFY(QPixmapCache::find(key, &p2) != 0); //we flush the cache + p1->detach(); + p2.detach(); QPixmapCache::setCacheLimit(0); QPixmapCache::setCacheLimit(1000); QPixmapCache::Key key2 = QPixmapCache::insert(*p1); @@ -180,21 +184,25 @@ void tst_QPixmapCache::setCacheLimit() delete p1; //Here we simulate the flushing when the app is idle - /*QPixmapCache::clear(); + QPixmapCache::clear(); QPixmapCache::setCacheLimit(originalCacheLimit); p1 = new QPixmap(300, 300); key = QPixmapCache::insert(*p1); + p1->detach(); QCOMPARE(getPrivate(key)->key, 1); key2 = QPixmapCache::insert(*p1); + p1->detach(); key2 = QPixmapCache::insert(*p1); + p1->detach(); QPixmapCache::Key key3 = QPixmapCache::insert(*p1); - QTest::qWait(32000); + p1->detach(); + QPixmapCache::flushDetachedPixmaps(); key2 = QPixmapCache::insert(*p1); QCOMPARE(getPrivate(key2)->key, 1); //This old key is not valid anymore after the flush QCOMPARE(getPrivate(key)->isValid, false); QVERIFY(QPixmapCache::find(key, &p2) == 0); - delete p1;*/ + delete p1; } void tst_QPixmapCache::find() @@ -225,12 +233,14 @@ void tst_QPixmapCache::find() QPixmapCache::clear(); QPixmapCache::setCacheLimit(128); - key = QPixmapCache::insert(p1); + QPixmap p4(10,10); + key = QPixmapCache::insert(p4); + p4.detach(); - //The int part of the API + QPixmap p5(10,10); QList keys; for (int i = 0; i < 4000; ++i) - QPixmapCache::insert(p1); + QPixmapCache::insert(p5); //at that time the first key has been erase because no more place in the cache QVERIFY(QPixmapCache::find(key, &p1) == 0); @@ -257,8 +267,10 @@ void tst_QPixmapCache::insert() QPixmapCache::insert("0", p1); // ditto - for (int j = 0; j < numberOfKeys; ++j) - QPixmapCache::insert(QString::number(j), p1); + for (int j = 0; j < numberOfKeys; ++j) { + QPixmap p3(10, 10); + QPixmapCache::insert(QString::number(j), p3); + } int num = 0; for (int k = 0; k < numberOfKeys; ++k) { @@ -286,8 +298,10 @@ void tst_QPixmapCache::insert() //The int part of the API // make sure it doesn't explode QList keys; - for (int i = 0; i < numberOfKeys; ++i) - keys.append(QPixmapCache::insert(p1)); + for (int i = 0; i < numberOfKeys; ++i) { + QPixmap p3(10,10); + keys.append(QPixmapCache::insert(p3)); + } num = 0; for (int k = 0; k < numberOfKeys; ++k) { -- cgit v0.12 From 0f9f07c52310c33433dcdf5db3e9d02c695b85af Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 12 May 2010 08:45:12 +1000 Subject: Document Component::createObject() parent argument. Task-number: QTBUG-10617 --- src/declarative/QmlChanges.txt | 4 ++-- src/declarative/qml/qdeclarativecomponent.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index dfc4244..9f618d8 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -7,7 +7,7 @@ Component: isReady, isLoading, isError and isNull properties removed, use QList models no longer provide properties in model object. The properties are now updated when the object changes. An object's property "foo" may now be accessed as "foo", modelData.foo" or model.modelData.foo" - +component.createObject has gained a mandatory "parent" argument C++ API ------- @@ -15,7 +15,7 @@ QDeclarativeExpression::value() has been renamed to QDeclarativeExpression::evaluate() ============================================================================= -The changes below are pre Qt 4.7.0 beta +The changes below are pre Qt 4.7.0 beta 1 TextEdit: wrap property is replaced by wrapMode enumeration. Text: wrap property is replaced by wrapMode enumeration. diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index afdaee8..e757675 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -545,7 +545,7 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q } /*! - \qmlmethod object Component::createObject() + \qmlmethod object Component::createObject(parent) Returns an object instance from this component, or null if object creation fails. The object will be created in the same context as the one in which the component -- cgit v0.12 From 6527735ff53a8ec593f5f85b037de46059e1207e Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 12 May 2010 09:24:30 +1000 Subject: Ensure PathView "attribute" attached properties are created correctly If an item was created spontaneously (i.e. delegate is a package and some other view created the item), ensure its attached properties are correctly initialized. Task-number: QTBUG-10527 --- src/declarative/graphicsitems/qdeclarativepath.cpp | 11 +++ .../graphicsitems/qdeclarativepathview.cpp | 42 ++++++++--- .../graphicsitems/qdeclarativepathview_p.h | 1 + .../qdeclarativepathview/data/pathview_package.qml | 88 ++++++++++++++++++++++ .../tst_qdeclarativepathview.cpp | 17 +++++ 5 files changed, 147 insertions(+), 12 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp index 4d8b619..3d0df87 100644 --- a/src/declarative/graphicsitems/qdeclarativepath.cpp +++ b/src/declarative/graphicsitems/qdeclarativepath.cpp @@ -322,6 +322,17 @@ QPainterPath QDeclarativePath::path() const QStringList QDeclarativePath::attributes() const { Q_D(const QDeclarativePath); + if (!d->componentComplete) { + QSet attrs; + + // First gather up all the attributes + foreach (QDeclarativePathElement *pathElement, d->_pathElements) { + if (QDeclarativePathAttribute *attribute = + qobject_cast(pathElement)) + attrs.insert(attribute->name()); + } + return attrs.toList(); + } return d->_attributes; } diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 040fc98..503d096 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -98,9 +98,8 @@ QDeclarativeItem *QDeclarativePathViewPrivate::getItem(int modelIndex) if (!attType) { // pre-create one metatype to share with all attached objects attType = new QDeclarativeOpenMetaObjectType(&QDeclarativePathViewAttached::staticMetaObject, qmlEngine(q)); - foreach(const QString &attr, path->attributes()) { + foreach(const QString &attr, path->attributes()) attType->createProperty(attr.toUtf8()); - } } qPathViewAttachedType = attType; QDeclarativePathViewAttached *att = static_cast(qmlAttachedPropertiesObject(item)); @@ -418,7 +417,7 @@ void QDeclarativePathView::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this)); + d->model = new QDeclarativeVisualDataModel(qmlContext(this), this); d->ownModel = true; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) @@ -471,12 +470,14 @@ void QDeclarativePathView::setPath(QDeclarativePath *path) disconnect(d->path, SIGNAL(changed()), this, SLOT(refill())); d->path = path; connect(d->path, SIGNAL(changed()), this, SLOT(refill())); - d->clear(); - if (d->attType) { - d->attType->release(); - d->attType = 0; + if (d->isValid() && isComponentComplete()) { + d->clear(); + if (d->attType) { + d->attType->release(); + d->attType = 0; + } + d->regenerate(); } - d->regenerate(); emit pathChanged(); } @@ -1119,7 +1120,8 @@ void QDeclarativePathView::refill() while ((pos > startPos || !d->items.count()) && d->items.count() < count) { // qDebug() << "append" << idx; QDeclarativeItem *item = d->getItem(idx); - item->setZValue(idx+1); + if (d->model->completePending()) + item->setZValue(idx+1); if (d->currentIndex == idx) { item->setFocus(true); if (QDeclarativePathViewAttached *att = d->attached(item)) @@ -1132,7 +1134,8 @@ void QDeclarativePathView::refill() d->firstIndex = idx; d->items.append(item); d->updateItem(item, pos); - d->model->completeItem(); + if (d->model->completePending()) + d->model->completeItem(); ++idx; if (idx >= d->model->count()) idx = 0; @@ -1146,7 +1149,8 @@ void QDeclarativePathView::refill() while (pos >= 0.0 && pos < startPos) { // qDebug() << "prepend" << idx; QDeclarativeItem *item = d->getItem(idx); - item->setZValue(idx+1); + if (d->model->completePending()) + item->setZValue(idx+1); if (d->currentIndex == idx) { item->setFocus(true); if (QDeclarativePathViewAttached *att = d->attached(item)) @@ -1157,7 +1161,8 @@ void QDeclarativePathView::refill() } d->items.prepend(item); d->updateItem(item, pos); - d->model->completeItem(); + if (d->model->completePending()) + d->model->completeItem(); d->firstIndex = idx; idx = d->firstIndex - 1; if (idx < 0) @@ -1269,6 +1274,19 @@ void QDeclarativePathView::createdItem(int index, QDeclarativeItem *item) { Q_D(QDeclarativePathView); if (d->requestedIndex != index) { + if (!d->attType) { + // pre-create one metatype to share with all attached objects + d->attType = new QDeclarativeOpenMetaObjectType(&QDeclarativePathViewAttached::staticMetaObject, qmlEngine(this)); + foreach(const QString &attr, d->path->attributes()) + d->attType->createProperty(attr.toUtf8()); + } + qPathViewAttachedType = d->attType; + QDeclarativePathViewAttached *att = static_cast(qmlAttachedPropertiesObject(item)); + qPathViewAttachedType = 0; + if (att) { + att->m_view = this; + att->setOnPath(false); + } item->setParentItem(this); d->updateItem(item, index < d->firstIndex ? 0.0 : 1.0); } diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h index 7240578..85f47fd 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h @@ -215,6 +215,7 @@ Q_SIGNALS: private: friend class QDeclarativePathViewPrivate; + friend class QDeclarativePathView; QDeclarativePathView *m_view; QDeclarativeOpenMetaObject *m_metaobject; bool m_onPath : 1; diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml new file mode 100644 index 0000000..082da13 --- /dev/null +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml @@ -0,0 +1,88 @@ +import Qt 4.7 + +Item { + width: 800; height: 600 + Component { + id: photoDelegate + Package { + Item { id: pathItem; objectName: "pathItem"; Package.name: 'path'; width: 85; height: 85; scale: pathItem.PathView.scale } + Item { id: linearItem; Package.name: 'linear'; width: 85; height: 85 } + Rectangle { + id: wrapper + width: 85; height: 85; color: lColor + + transform: Rotation { + id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 + axis.y: 1; axis.z: 0 + } + state: 'path' + states: [ + State { + name: 'path' + ParentChange { target: wrapper; parent: pathItem; x: 0; y: 0 } + PropertyChanges { target: wrapper; opacity: pathItem.PathView.onPath ? 1.0 : 0 } + } + ] + } + } + } + ListModel { + id: rssModel + ListElement { lColor: "red" } + ListElement { lColor: "green" } + ListElement { lColor: "yellow" } + ListElement { lColor: "blue" } + ListElement { lColor: "purple" } + ListElement { lColor: "gray" } + ListElement { lColor: "brown" } + ListElement { lColor: "thistle" } + } + VisualDataModel { id: visualModel; model: rssModel; delegate: photoDelegate } + + PathView { + id: photoPathView + objectName: "photoPathView" + width: 800; height: 330; pathItemCount: 4; offset: 1 + dragMargin: 24 + preferredHighlightBegin: 0.50 + preferredHighlightEnd: 0.50 + + path: Path { + startX: -50; startY: 40; + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: -45 } + + PathCubic { + x: 400; y: 220 + control1X: 140; control1Y: 40 + control2X: 210; control2Y: 220 + } + + PathAttribute { name: "scale"; value: 1.2 } + PathAttribute { name: "angle"; value: 0 } + + PathCubic { + x: 850; y: 40 + control2X: 660; control2Y: 40 + control1X: 590; control1Y: 220 + } + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: 45 } + } + + model: visualModel.parts.path + } + + PathView { + y: 400; width: 800; height: 330; pathItemCount: 8 + + path: Path { + startX: 0; startY: 40; + PathLine { x: 800; y: 40 } + } + + model: visualModel.parts.linear + } +} diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index c32e9cc..62d0b89 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -78,6 +78,7 @@ private slots: void componentChanges(); void modelChanges(); void pathUpdateOnStartChanged(); + void package(); private: @@ -695,6 +696,22 @@ void tst_QDeclarativePathView::pathUpdateOnStartChanged() delete canvas; } +void tst_QDeclarativePathView::package() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview_package.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild("photoPathView"); + QVERIFY(pathView); + + QDeclarativeItem *item = findItem(pathView, "pathItem"); + QVERIFY(item); + QVERIFY(item->scale() != 1.0); + + delete canvas; +} + QDeclarativeView *tst_QDeclarativePathView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); -- cgit v0.12 From 6a3bbb128046942b169a3f7e6c0cf14397662d83 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 7 May 2010 15:58:10 +1000 Subject: Clean up --- doc/src/declarative/qdeclarativeintro.qdoc | 5 ++++- examples/declarative/xmldata/daringfireball.qml | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/src/declarative/qdeclarativeintro.qdoc b/doc/src/declarative/qdeclarativeintro.qdoc index a98c9e1..acf4ec9 100644 --- a/doc/src/declarative/qdeclarativeintro.qdoc +++ b/doc/src/declarative/qdeclarativeintro.qdoc @@ -60,10 +60,13 @@ technologies like HTML and CSS, but it's not required. QML looks like this: \code +import Qt 4.7 + Rectangle { width: 200 height: 200 - color: "white" + color: "blue" + Image { source: "pics/logo.png" anchors.centerIn: parent diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml index a1df809..480b13c 100644 --- a/examples/declarative/xmldata/daringfireball.qml +++ b/examples/declarative/xmldata/daringfireball.qml @@ -1,7 +1,6 @@ import Qt 4.7 Rectangle { - color: "white" width: 600; height: 600 XmlListModel { -- cgit v0.12 From ef23de2b16f3eaf6621c9407f7d921d55e380982 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 11 May 2010 11:53:25 +1000 Subject: QDeclarativeViewPrivate should subclass QGraphicsViewPrivate Task-number: QTBUG-10528 --- src/declarative/util/qdeclarativeview.cpp | 45 ++++++++++++++++++++++--------- src/declarative/util/qdeclarativeview.h | 3 +-- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 833e284..e68ef94 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -128,19 +128,18 @@ void FrameBreakAnimation::updateCurrentTime(int msecs) server->frameBreak(); } -class QDeclarativeViewPrivate : public QDeclarativeItemChangeListener +class QDeclarativeViewPrivate : public QGraphicsViewPrivate, public QDeclarativeItemChangeListener { + Q_DECLARE_PUBLIC(QDeclarativeView) public: - QDeclarativeViewPrivate(QDeclarativeView *view) - : q(view), root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {} + QDeclarativeViewPrivate() + : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {} ~QDeclarativeViewPrivate() { delete root; } void execute(); void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); void initResize(); void updateSize(); - inline QSize rootObjectSize(); - - QDeclarativeView *q; + inline QSize rootObjectSize() const; QDeclarativeGuard root; QDeclarativeGuard declarativeItemRoot; @@ -162,6 +161,7 @@ public: void QDeclarativeViewPrivate::execute() { + Q_Q(QDeclarativeView); if (root) { delete root; root = 0; @@ -182,6 +182,7 @@ void QDeclarativeViewPrivate::execute() void QDeclarativeViewPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry) { + Q_Q(QDeclarativeView); if (resizeItem == root && resizeMode == QDeclarativeView::SizeViewToRootObject) { // wait for both width and height to be changed resizetimer.start(0,q); @@ -250,8 +251,9 @@ void QDeclarativeViewPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, Constructs a QDeclarativeView with the given \a parent. */ QDeclarativeView::QDeclarativeView(QWidget *parent) -: QGraphicsView(parent), d(new QDeclarativeViewPrivate(this)) + : QGraphicsView(*(new QDeclarativeViewPrivate), parent) { + Q_D(QDeclarativeView); setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); d->init(); } @@ -262,8 +264,9 @@ QDeclarativeView::QDeclarativeView(QWidget *parent) Constructs a QDeclarativeView with the given QML \a source and \a parent. */ QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent) -: QGraphicsView(parent), d(new QDeclarativeViewPrivate(this)) + : QGraphicsView(*(new QDeclarativeViewPrivate), parent) { + Q_D(QDeclarativeView); setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); d->init(); setSource(source); @@ -271,6 +274,7 @@ QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent) void QDeclarativeViewPrivate::init() { + Q_Q(QDeclarativeView); q->setScene(&scene); q->setOptimizationFlags(QGraphicsView::DontSavePainterState); @@ -288,12 +292,10 @@ void QDeclarativeViewPrivate::init() } /*! - The destructor clears the view's \l {QGraphicsObject} {items} and - deletes the internal representation. + Destroys the view. */ QDeclarativeView::~QDeclarativeView() { - delete d; } /*! \property QDeclarativeView::source @@ -316,6 +318,7 @@ QDeclarativeView::~QDeclarativeView() */ void QDeclarativeView::setSource(const QUrl& url) { + Q_D(QDeclarativeView); d->source = url; d->execute(); } @@ -327,6 +330,7 @@ void QDeclarativeView::setSource(const QUrl& url) */ QUrl QDeclarativeView::source() const { + Q_D(const QDeclarativeView); return d->source; } @@ -336,6 +340,7 @@ QUrl QDeclarativeView::source() const */ QDeclarativeEngine* QDeclarativeView::engine() { + Q_D(QDeclarativeView); return &d->engine; } @@ -348,6 +353,7 @@ QDeclarativeEngine* QDeclarativeView::engine() */ QDeclarativeContext* QDeclarativeView::rootContext() { + Q_D(QDeclarativeView); return d->engine.rootContext(); } @@ -376,6 +382,7 @@ QDeclarativeContext* QDeclarativeView::rootContext() QDeclarativeView::Status QDeclarativeView::status() const { + Q_D(const QDeclarativeView); if (!d->component) return QDeclarativeView::Null; @@ -388,6 +395,7 @@ QDeclarativeView::Status QDeclarativeView::status() const */ QList QDeclarativeView::errors() const { + Q_D(const QDeclarativeView); if (d->component) return d->component->errors(); return QList(); @@ -410,6 +418,7 @@ QList QDeclarativeView::errors() const void QDeclarativeView::setResizeMode(ResizeMode mode) { + Q_D(QDeclarativeView); if (d->resizeMode == mode) return; @@ -433,6 +442,7 @@ void QDeclarativeView::setResizeMode(ResizeMode mode) void QDeclarativeViewPrivate::initResize() { + Q_Q(QDeclarativeView); if (declarativeItemRoot) { if (resizeMode == QDeclarativeView::SizeViewToRootObject) { QDeclarativeItemPrivate *p = @@ -449,6 +459,7 @@ void QDeclarativeViewPrivate::initResize() void QDeclarativeViewPrivate::updateSize() { + Q_Q(QDeclarativeView); if (!root) return; if (declarativeItemRoot) { @@ -479,7 +490,7 @@ void QDeclarativeViewPrivate::updateSize() q->updateGeometry(); } -QSize QDeclarativeViewPrivate::rootObjectSize() +QSize QDeclarativeViewPrivate::rootObjectSize() const { QSize rootObjectSize(0,0); int widthCandidate = -1; @@ -500,6 +511,7 @@ QSize QDeclarativeViewPrivate::rootObjectSize() QDeclarativeView::ResizeMode QDeclarativeView::resizeMode() const { + Q_D(const QDeclarativeView); return d->resizeMode; } @@ -508,7 +520,7 @@ QDeclarativeView::ResizeMode QDeclarativeView::resizeMode() const */ void QDeclarativeView::continueExecute() { - + Q_D(QDeclarativeView); disconnect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute())); if (d->component->isError()) { @@ -541,6 +553,7 @@ void QDeclarativeView::continueExecute() */ void QDeclarativeView::setRootObject(QObject *obj) { + Q_D(QDeclarativeView); if (d->root == obj) return; if (QDeclarativeItem *declarativeItem = qobject_cast(obj)) { @@ -590,6 +603,7 @@ void QDeclarativeView::setRootObject(QObject *obj) */ void QDeclarativeView::timerEvent(QTimerEvent* e) { + Q_D(QDeclarativeView); if (!e || e->timerId() == d->resizetimer.timerId()) { d->updateSize(); d->resizetimer.stop(); @@ -599,6 +613,7 @@ void QDeclarativeView::timerEvent(QTimerEvent* e) /*! \reimp */ bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e) { + Q_D(QDeclarativeView); if (watched == d->root && d->resizeMode == SizeViewToRootObject) { if (d->graphicsWidgetRoot) { if (e->type() == QEvent::GraphicsSceneResize) { @@ -615,6 +630,7 @@ bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e) */ QSize QDeclarativeView::sizeHint() const { + Q_D(const QDeclarativeView); QSize rootObjectSize = d->rootObjectSize(); if (rootObjectSize.isEmpty()) { return size(); @@ -628,6 +644,7 @@ QSize QDeclarativeView::sizeHint() const */ QGraphicsObject *QDeclarativeView::rootObject() const { + Q_D(const QDeclarativeView); return d->root; } @@ -638,6 +655,7 @@ QGraphicsObject *QDeclarativeView::rootObject() const */ void QDeclarativeView::resizeEvent(QResizeEvent *e) { + Q_D(QDeclarativeView); if (d->resizeMode == SizeRootObjectToView) { d->updateSize(); } @@ -657,6 +675,7 @@ void QDeclarativeView::resizeEvent(QResizeEvent *e) */ void QDeclarativeView::paintEvent(QPaintEvent *event) { + Q_D(QDeclarativeView); int time = 0; if (frameRateDebug() || QDeclarativeViewDebugServer::isDebuggingEnabled()) time = d->frameTimer.restart(); diff --git a/src/declarative/util/qdeclarativeview.h b/src/declarative/util/qdeclarativeview.h index 3513c04..e9cff32 100644 --- a/src/declarative/util/qdeclarativeview.h +++ b/src/declarative/util/qdeclarativeview.h @@ -106,9 +106,8 @@ protected: virtual bool eventFilter(QObject *watched, QEvent *e); private: - friend class QDeclarativeViewPrivate; - QDeclarativeViewPrivate *d; Q_DISABLE_COPY(QDeclarativeView) + Q_DECLARE_PRIVATE(QDeclarativeView) }; QT_END_NAMESPACE -- cgit v0.12 From 0b715811609b86f9332ffd49aea08f4a4b634d21 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 11 May 2010 13:47:08 +1000 Subject: Improve XmlListModel::namespaceDeclarations() docs Task-number: QTBUG-10522 --- src/declarative/util/qdeclarativexmllistmodel.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index ae3b5d7..b9afa1f 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -479,7 +479,6 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty Date: Tue, 11 May 2010 17:23:11 +1000 Subject: Doc improvements --- doc/src/declarative/advtutorial.qdoc | 2 +- doc/src/declarative/codingconventions.qdoc | 1 - doc/src/declarative/extending-examples.qdoc | 8 +-- doc/src/declarative/qmlruntime.qdoc | 2 +- src/declarative/util/qdeclarativexmllistmodel.cpp | 68 +++++++++++++++++------ 5 files changed, 55 insertions(+), 26 deletions(-) diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc index 8f95190..47504ae 100644 --- a/doc/src/declarative/advtutorial.qdoc +++ b/doc/src/declarative/advtutorial.qdoc @@ -105,7 +105,7 @@ is the \l SystemPalette item. This provides access to the Qt system palette and is used to give the button a more native look-and-feel. Notice the anchors for the \c Item, \c Button and \c Text elements are set using -\l {codingconventions.html#Grouped-properties}{group notation} for readability. +\l {qdeclarativeintroduction.html#dot-properties}{group notation} for readability. \section2 Adding \c Button and \c Block components diff --git a/doc/src/declarative/codingconventions.qdoc b/doc/src/declarative/codingconventions.qdoc index d0f873d..4fa7d0c 100644 --- a/doc/src/declarative/codingconventions.qdoc +++ b/doc/src/declarative/codingconventions.qdoc @@ -72,7 +72,6 @@ For example, a hypothetical \e photo QML object would look like this: \snippet doc/src/snippets/declarative/codingconventions/photo.qml 0 -\target Grouped properties \section1 Grouped properties If using multiple properties from a group of properties, diff --git a/doc/src/declarative/extending-examples.qdoc b/doc/src/declarative/extending-examples.qdoc index 307162e..611dac1 100644 --- a/doc/src/declarative/extending-examples.qdoc +++ b/doc/src/declarative/extending-examples.qdoc @@ -64,8 +64,8 @@ element, the C++ class can be named differently, or appear in a namespace. The Person class implementation is quite basic. The property accessors simply return members of the object instance. -The implementation must also be registered using the QML_REGISTER_TYPE() macro. This macro -registers the Person class with QML as a type in the People library version 1.0, +The \c main.cpp file also calls the \c qmlRegisterType() function to +register the \c Person type with QML as a type in the People library version 1.0, and defines the mapping between the C++ and QML class names. \section1 Running the example @@ -159,9 +159,7 @@ directly - an explicit Boy or Girl should be instantiated instead. While we want to disallow instantiating Person from within QML, it still needs to be registered with the QML engine, so that it can be used as a property type -and other types can be coerced to it. To register a type, without defining a -named mapping into QML, we call the QML_REGISTER_NOCREATE_TYPE() macro instead of -the QML_REGISTER_TYPE() macro used previously. +and other types can be coerced to it. \section2 Define Boy and Girl diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc index 23c5c32..10aeac0 100644 --- a/doc/src/declarative/qmlruntime.qdoc +++ b/doc/src/declarative/qmlruntime.qdoc @@ -123,7 +123,7 @@ Such files can be created using \l{Qt Linguist}. - See \l{scripting.html#internationalization} for information about how to make + See the \l{scripting.html#internationalization}{Qt Internationalization} documentation for information about how to make the JavaScript in QML files use translatable strings. Additionally, the QML runtime will load translation files specified on the diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index b9afa1f..f02ed16 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -472,39 +472,71 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty + + ... + + + Item A + Sat, 07 Sep 2010 10:00:01 GMT + + + Item B + Sat, 07 Sep 2010 15:35:01 GMT + + + + \endcode + + Then it could be used to create the following model: - Here is an example of a model containing news from a Yahoo RSS feed: \qml XmlListModel { - source: "http://rss.news.yahoo.com/rss/oceania" + source: "http://www.mysite.com/feed.xml" query: "/rss/channel/item" XmlRole { name: "title"; query: "title/string()" } XmlRole { name: "pubDate"; query: "pubDate/string()" } - XmlRole { name: "description"; query: "description/string()" } } \endqml - You can also define certain roles as "keys" so that the model only adds data - that contains new values for these keys when reload() is called. + The \l {XmlListModel::query}{query} value of "/rss/channel/item" specifies that the XmlListModel should generate + a model item for each \c in the XML document. The XmlRole objects define the + model item attributes; here, each model item will have \c title and \c pubDate + attributes that match the \c title and \c pubDate values of its corresponding \c . - For example, if the roles above were defined like this: + + \section2 Using key XML roles + + You can define certain roles as "keys" so that when reload() is called, + the model will only add and refresh data that contains new values for + these keys. + + For example, if above role for "pubDate" was defined like this instead: \qml - XmlRole { name: "title"; query: "title/string()"; isKey: true } XmlRole { name: "pubDate"; query: "pubDate/string()"; isKey: true } \endqml - Then when reload() is called, the model will only add new items with a - "title" and "pubDate" value combination that is not already present in - the model. + Then when reload() is called, the model will only add and reload + items with a "pubDate" value that is not already + present in the model. - This is useful to provide incremental updates and avoid repainting an - entire model in a view. + This is useful when displaying the contents of XML documents that + are incrementally updated (such as RSS feeds) to avoid repainting the + entire contents of a model in a view. - \sa {QtDeclarative} + If multiple key roles are specified, the model only adds and reload items + with a combined value of all key roles that is not already present in + the model. + + \sa {declarative/xmldata}{XML data example} */ QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent) @@ -625,8 +657,8 @@ void QDeclarativeXmlListModel::setXml(const QString &xml) /*! \qmlproperty string XmlListModel::query - An absolute XPath query representing the base query for the model items. The query should start with - '/' or '//'. + An absolute XPath query representing the base query for creating model items + from this model's XmlRole objects. The query should start with '/' or '//'. */ QString QDeclarativeXmlListModel::query() const { @@ -747,7 +779,7 @@ void QDeclarativeXmlListModel::componentComplete() Otherwise, items are only added if the model does not already contain items with matching key role values. - \sa XmlRole::isKey + \sa {Using key XML roles}, XmlRole::isKey */ void QDeclarativeXmlListModel::reload() { -- cgit v0.12 From 1b2b9ba6b4cea31d679aeae915e590ddbf1da945 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 11 May 2010 03:23:21 +0200 Subject: Don't use Q_UNUSED if you use parameters. That's many "use" in the sentence. Task-number:QT-1652 Reviewed-by:TrustMe --- src/gui/graphicsview/qgraphicsview.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 0bba7e9..9519ca0 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -1819,8 +1819,6 @@ void QGraphicsView::centerOn(const QGraphicsItem *item) void QGraphicsView::ensureVisible(const QRectF &rect, int xmargin, int ymargin) { Q_D(QGraphicsView); - Q_UNUSED(xmargin); - Q_UNUSED(ymargin); qreal width = viewport()->width(); qreal height = viewport()->height(); QRectF viewRect = d->matrix.mapRect(rect); -- cgit v0.12 From 60f6dfc230cac169fa06969383a53fc433e9dc2b Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Wed, 12 May 2010 10:53:41 +1000 Subject: Phonon QT7 backend; Don't release string after unsuccessful AudioDeviceGetProperty(). Reviewed-by:Andrew den Exter --- src/3rdparty/phonon/qt7/audiodevice.mm | 1 - 1 file changed, 1 deletion(-) diff --git a/src/3rdparty/phonon/qt7/audiodevice.mm b/src/3rdparty/phonon/qt7/audiodevice.mm index 6bec62d..3aae0ee4 100644 --- a/src/3rdparty/phonon/qt7/audiodevice.mm +++ b/src/3rdparty/phonon/qt7/audiodevice.mm @@ -149,7 +149,6 @@ QString AudioDevice::deviceSourceName(AudioDeviceID deviceID) size = sizeof(translation); err = AudioDeviceGetProperty(deviceID, 0, 0, kAudioDevicePropertyDataSourceNameForIDCFString, &size, &translation); if (err != noErr){ - CFRelease(cfName); return QString(); } QString name = PhononCFString::toQString(cfName); -- cgit v0.12 From 855368e447a1db8f72c1ad135b9edfb9c373a01d Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 12 May 2010 11:33:56 +1000 Subject: Qt.widgets was removed, point to graphics layouts example --- doc/src/declarative/integrating.qdoc | 50 ++---------------- .../declarative/graphicswidgets/bluecircle.h | 55 ------------------- .../graphicswidgets/graphicswidgets.pro | 13 ----- .../snippets/declarative/graphicswidgets/main.qml | 32 ------------ .../snippets/declarative/graphicswidgets/qmldir | 1 - .../declarative/graphicswidgets/redsquare.h | 54 ------------------- .../declarative/graphicswidgets/shapesplugin.cpp | 61 ---------------------- 7 files changed, 5 insertions(+), 261 deletions(-) delete mode 100644 doc/src/snippets/declarative/graphicswidgets/bluecircle.h delete mode 100644 doc/src/snippets/declarative/graphicswidgets/graphicswidgets.pro delete mode 100644 doc/src/snippets/declarative/graphicswidgets/main.qml delete mode 100644 doc/src/snippets/declarative/graphicswidgets/qmldir delete mode 100644 doc/src/snippets/declarative/graphicswidgets/redsquare.h delete mode 100644 doc/src/snippets/declarative/graphicswidgets/shapesplugin.cpp diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc index 1c07f8e..972976f 100644 --- a/doc/src/declarative/integrating.qdoc +++ b/doc/src/declarative/integrating.qdoc @@ -110,51 +110,11 @@ of QML UIs: \section2 Loading QGraphicsWidget objects in QML An alternative approach is to expose your existing QGraphicsWidget objects to -QML and construct your scene in QML instead. To do this, you need to register -any custom C++ types and create a plugin that registers the custom types -so that they can be used from your QML file. +QML and construct your scene in QML instead. See the \l {declarative/layouts/graphicsLayouts}{graphics layouts example} +which shows how to expose Qt's graphics layout classes to QML in order +to use QGraphicsWidget with classes like QGraphicsLinearLayout and QGraphicsGridLayout. -Here is an example. Suppose you have two classes, \c RedSquare and \c BlueCircle, -that both inherit from QGraphicsWidget: - -\c [graphicswidgets/redsquare.h] -\snippet doc/src/snippets/declarative/graphicswidgets/redsquare.h 0 - -\c [graphicswidgets/bluecircle.h] -\snippet doc/src/snippets/declarative/graphicswidgets/bluecircle.h 0 - -Then, create a plugin by subclassing QDeclarativeExtensionPlugin, and register the -types by calling qmlRegisterType(). Also export the plugin with Q_EXPORT_PLUGIN2. - -\c [graphicswidgets/shapesplugin.cpp] -\snippet doc/src/snippets/declarative/graphicswidgets/shapesplugin.cpp 0 - -Now write a project file that creates the plugin: - -\c [graphicswidgets/graphicswidgets.pro] -\quotefile doc/src/snippets/declarative/graphicswidgets/graphicswidgets.pro - -And add a \c qmldir file that includes the \c graphicswidgets plugin from the \c lib -subdirectory (as defined in the project file): - -\c [graphicswidgets/qmldir] -\quotefile doc/src/snippets/declarative/graphicswidgets/qmldir - -Now, we can write a QML file that uses the \c RedSquare and \c BlueCircle widgets. -(As an example, we can also create \c QGraphicsWidget items if we import the \c Qt.widgets -module.) - -\c [main.qml] -\quotefile doc/src/snippets/declarative/graphicswidgets/main.qml - -Here is a screenshot of the result: - -\image declarative-integrating-graphicswidgets.png - - -Note this approach of creating your graphics objects from QML does not work -with QGraphicsItems that are not QGraphicsObject-based, since they are not QObjects. - -See \l{Extending QML in C++} for further information on using C++ types. +To expose your existing QGraphicsWidget classes to QML, use \l {qmlRegisterType()}. +See \l{Extending QML in C++} for further information on using C++ types in QML. */ diff --git a/doc/src/snippets/declarative/graphicswidgets/bluecircle.h b/doc/src/snippets/declarative/graphicswidgets/bluecircle.h deleted file mode 100644 index 73d66b7..0000000 --- a/doc/src/snippets/declarative/graphicswidgets/bluecircle.h +++ /dev/null @@ -1,55 +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 documentation 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$ -** -****************************************************************************/ -//![0] -#include -#include - -class BlueCircle : public QGraphicsWidget -{ - Q_OBJECT -public: - void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) - { - painter->setPen(QColor(Qt::blue)); - painter->drawEllipse(0, 0, size().width(), size().height()); - } -}; -//![0] diff --git a/doc/src/snippets/declarative/graphicswidgets/graphicswidgets.pro b/doc/src/snippets/declarative/graphicswidgets/graphicswidgets.pro deleted file mode 100644 index 21c8a37..0000000 --- a/doc/src/snippets/declarative/graphicswidgets/graphicswidgets.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative - -HEADERS += redsquare.h \ - bluecircle.h - -SOURCES += shapesplugin.cpp - -DESTDIR = lib -OBJECTS_DIR = tmp -MOC_DIR = tmp - diff --git a/doc/src/snippets/declarative/graphicswidgets/main.qml b/doc/src/snippets/declarative/graphicswidgets/main.qml deleted file mode 100644 index ffcf79d..0000000 --- a/doc/src/snippets/declarative/graphicswidgets/main.qml +++ /dev/null @@ -1,32 +0,0 @@ -import Qt 4.7 -import Qt.widgets 4.7 - -Rectangle { - width: 200 - height: 200 - - RedSquare { - id: square - width: 80 - height: 80 - } - - BlueCircle { - anchors.left: square.right - width: 80 - height: 80 - } - - QGraphicsWidget { - anchors.top: square.bottom - size.width: 80 - size.height: 80 - layout: QGraphicsLinearLayout { - LayoutItem { - preferredSize: "100x100" - Rectangle { color: "yellow"; anchors.fill: parent } - } - } - } -} - diff --git a/doc/src/snippets/declarative/graphicswidgets/qmldir b/doc/src/snippets/declarative/graphicswidgets/qmldir deleted file mode 100644 index f94dad2..0000000 --- a/doc/src/snippets/declarative/graphicswidgets/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin graphicswidgets lib diff --git a/doc/src/snippets/declarative/graphicswidgets/redsquare.h b/doc/src/snippets/declarative/graphicswidgets/redsquare.h deleted file mode 100644 index 3050662..0000000 --- a/doc/src/snippets/declarative/graphicswidgets/redsquare.h +++ /dev/null @@ -1,54 +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 documentation 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$ -** -****************************************************************************/ -//![0] -#include -#include - -class RedSquare : public QGraphicsWidget -{ - Q_OBJECT -public: - void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) - { - painter->fillRect(0, 0, size().width(), size().height(), QColor(Qt::red)); - } -}; -//![0] diff --git a/doc/src/snippets/declarative/graphicswidgets/shapesplugin.cpp b/doc/src/snippets/declarative/graphicswidgets/shapesplugin.cpp deleted file mode 100644 index 4c18ef3..0000000 --- a/doc/src/snippets/declarative/graphicswidgets/shapesplugin.cpp +++ /dev/null @@ -1,61 +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 documentation 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$ -** -****************************************************************************/ -//![0] -#include "redsquare.h" -#include "bluecircle.h" - -#include -#include - -class ShapesPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) { - qmlRegisterType(uri, 1, 0, "RedSquare"); - qmlRegisterType(uri, 1, 0, "BlueCircle"); - } -}; - -#include "shapesplugin.moc" - -Q_EXPORT_PLUGIN2(shapesplugin, ShapesPlugin); -//![0] -- cgit v0.12 From 34f9f08dd290710512fb7dc8a4d473b6e08c84b4 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 12 May 2010 11:40:23 +1000 Subject: Remove unused image --- .../images/declarative-integrating-graphicswidgets.png | Bin 1061 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 doc/src/images/declarative-integrating-graphicswidgets.png diff --git a/doc/src/images/declarative-integrating-graphicswidgets.png b/doc/src/images/declarative-integrating-graphicswidgets.png deleted file mode 100644 index d57f4b9..0000000 Binary files a/doc/src/images/declarative-integrating-graphicswidgets.png and /dev/null differ -- cgit v0.12 From f303375383ff405afbbe78ec2c951f2e24a121be Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 12 May 2010 10:36:34 +1000 Subject: Apply signal handler changes immediately. Fix regression in bindinganimation visual test introduced in 129940723d9145a4380f7e44c06cbaa88ee4053b. --- src/declarative/util/qdeclarativepropertychanges.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index 94780c4..a22c756 100644 --- a/src/declarative/util/qdeclarativepropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -161,20 +161,15 @@ public: QDeclarativeExpression *rewindExpression; QDeclarativeGuard ownedExpression; - virtual bool changesBindings() { return true; } - virtual void clearBindings() { - ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, 0); - } - virtual void execute(Reason) { - QDeclarativePropertyPrivate::setSignalExpression(property, expression); + ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, expression); if (ownedExpression == expression) ownedExpression = 0; } virtual bool isReversable() { return true; } virtual void reverse(Reason) { - QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression); + ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression); if (ownedExpression == reverseExpression) ownedExpression = 0; } @@ -198,7 +193,7 @@ public: } virtual void rewind() { - QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression); + ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression); if (ownedExpression == rewindExpression) ownedExpression = 0; } -- cgit v0.12 From 43db14d83279566cdd5626321251efc5da8acc1d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 12 May 2010 11:06:55 +1000 Subject: Correctly resize TextInput in the presence of preedit text. Task-number: QTBUG-10466 Reviewed-by: alexis --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 604f508..4d89887 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1233,9 +1233,7 @@ void QDeclarativeTextInput::updateSize(bool needsRedraw) int cursorWidth = d->control->cursorWidth(); if(d->cursorItem) cursorWidth = d->cursorItem->width(); - //### Is QFontMetrics too slow? - QFontMetricsF fm(d->font); - setImplicitWidth(fm.width(d->control->displayText())+cursorWidth); + setImplicitWidth(d->control->naturalTextWidth() + cursorWidth); setContentsSize(QSize(width(), height()));//Repaints if changed if(w==width() && h==height() && needsRedraw){ clearCache(); -- cgit v0.12 From 7827b791828c3efa96143ed7a9af354883c8d926 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 12 May 2010 11:14:39 +1000 Subject: Correctly position any input method popups for TextInput. Reviewed-by: alexis --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 4d89887..8f86aa0 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1018,6 +1018,8 @@ QVariant QDeclarativeTextInput::inputMethodQuery(Qt::InputMethodQuery property) { Q_D(const QDeclarativeTextInput); switch(property) { + case Qt::ImMicroFocus: + return d->control->cursorRect(); case Qt::ImFont: return font(); case Qt::ImCursorPosition: -- cgit v0.12 From 5e843ec092e2d236bd51f015b136db3fca5c10ba Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 12 May 2010 11:46:15 +1000 Subject: Bail out early if the same target value is reassigned to a Behavior. Task-number: QTBUG-10586 Reviewed-by: leo --- src/declarative/util/qdeclarativebehavior.cpp | 6 + .../animation/qtbug10586/data/qtbug10586.0.png | Bin 0 -> 1149 bytes .../animation/qtbug10586/data/qtbug10586.1.png | Bin 0 -> 1173 bytes .../animation/qtbug10586/data/qtbug10586.2.png | Bin 0 -> 1173 bytes .../animation/qtbug10586/data/qtbug10586.3.png | Bin 0 -> 1149 bytes .../animation/qtbug10586/data/qtbug10586.qml | 1151 ++++++++++++++++++++ .../qmlvisual/animation/qtbug10586/qtbug10586.qml | 27 + tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp | 5 +- 8 files changed, 1187 insertions(+), 2 deletions(-) create mode 100644 tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.0.png create mode 100644 tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.1.png create mode 100644 tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.2.png create mode 100644 tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.3.png create mode 100644 tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.qml create mode 100644 tests/auto/declarative/qmlvisual/animation/qtbug10586/qtbug10586.qml diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp index ba90007..90e0ca3 100644 --- a/src/declarative/util/qdeclarativebehavior.cpp +++ b/src/declarative/util/qdeclarativebehavior.cpp @@ -62,6 +62,7 @@ public: QDeclarativeProperty property; QVariant currentValue; + QVariant targetValue; QDeclarativeGuard animation; bool enabled; bool finalized; @@ -162,10 +163,15 @@ void QDeclarativeBehavior::write(const QVariant &value) qmlExecuteDeferred(this); if (!d->animation || !d->enabled || !d->finalized) { QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); + d->targetValue = value; return; } + if (value == d->targetValue) + return; + d->currentValue = d->property.read(); + d->targetValue = value; if (d->animation->qtAnimation()->duration() != -1) d->animation->qtAnimation()->stop(); diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.0.png b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.0.png new file mode 100644 index 0000000..d8be67b Binary files /dev/null and b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.0.png differ diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.1.png b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.1.png new file mode 100644 index 0000000..249e0dd Binary files /dev/null and b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.1.png differ diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.2.png b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.2.png new file mode 100644 index 0000000..044f823 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.2.png differ diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.3.png b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.3.png new file mode 100644 index 0000000..d8be67b Binary files /dev/null and b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.3.png differ diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.qml b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.qml new file mode 100644 index 0000000..dc8e2e2 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.qml @@ -0,0 +1,1151 @@ +import Qt.VisualTest 4.7 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 32 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 48 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 64 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 80 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 96 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 112 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 128 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 144 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 160 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 176 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 192 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 208 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 224 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 240 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 256 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 272 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 288 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 304 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 320 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 336 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 352 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 368 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 384 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 400 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 416 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 432 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 448 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 464 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 480 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 496 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 512 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 528 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 544 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 560 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 576 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 592 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 608 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 624 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 640 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 656 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 672 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 688 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 704 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 720 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 736 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 752 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 768 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 784 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 800 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 816 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 832 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 848 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 864 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 880 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 896 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 912 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 928 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 944 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 960 + image: "qtbug10586.0.png" + } + Frame { + msec: 976 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 992 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1008 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1024 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1040 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1056 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1072 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1088 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1104 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1120 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1136 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1152 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1168 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1184 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1200 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1216 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1232 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1248 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1264 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1280 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1296 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1312 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Mouse { + type: 2 + button: 1 + buttons: 1 + x: 174; y: 204 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1328 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1344 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1360 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1376 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1392 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 170; y: 204 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1408 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 156; y: 204 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1424 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1440 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 130; y: 204 + modifiers: 0 + sendToViewport: true + } + Mouse { + type: 3 + button: 1 + buttons: 0 + x: 130; y: 204 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1456 + hash: "8b7dd0f0a3881f10d76b47cbec4754c3" + } + Frame { + msec: 1472 + hash: "b6fc4990acb245e015c35261a3c6fd75" + } + Frame { + msec: 1488 + hash: "849fa4174134804dadc000323141b341" + } + Frame { + msec: 1504 + hash: "35f2d6405ed7d992bb62eb6e24478492" + } + Frame { + msec: 1520 + hash: "673ebb4499522c3f27b775dff1dbbe44" + } + Frame { + msec: 1536 + hash: "96945f5489ffd0dc8ab995c96eb5da43" + } + Frame { + msec: 1552 + hash: "2e4543754429ac3db831a2432098c063" + } + Frame { + msec: 1568 + hash: "02253fe8a9fd5009a07265c2c6ffc8e4" + } + Frame { + msec: 1584 + hash: "200a89949df1e9ef58d005a139857d2c" + } + Frame { + msec: 1600 + hash: "ceb28be34c7ea8eff5fa00fdea087439" + } + Frame { + msec: 1616 + hash: "a9ece475c51f126094c5eff4e20f4a19" + } + Frame { + msec: 1632 + hash: "aa0776f84aef87d6971affdfa2d8dd82" + } + Frame { + msec: 1648 + hash: "4c74661e1c73fefc9c5154b257239352" + } + Frame { + msec: 1664 + hash: "c10d23df3a75966aad5016bd8ba8e9d8" + } + Frame { + msec: 1680 + hash: "41692977d654a55d3b1d037aea9f2c03" + } + Frame { + msec: 1696 + hash: "2f1835a1de94f962eb5dc781c85b4c32" + } + Frame { + msec: 1712 + hash: "7cb78e2e5f6d35d456c95f2bd8652eb5" + } + Frame { + msec: 1728 + hash: "4388aee9b1c8b4fde43634ad08f03557" + } + Frame { + msec: 1744 + hash: "1cdc71100fd11cb6e60c9ab7e65e95bf" + } + Frame { + msec: 1760 + hash: "feddbf269adfc8bb1b1a3656b5b5736d" + } + Frame { + msec: 1776 + hash: "76b39ce0ee9b9b4af8aa0141577b8460" + } + Frame { + msec: 1792 + hash: "bac963d3df2841ab7a3770a371f3a94d" + } + Frame { + msec: 1808 + hash: "403007bb6c0782fece1cedbd40994550" + } + Frame { + msec: 1824 + hash: "72076c743fdd33fab2ac789c7c22973a" + } + Frame { + msec: 1840 + hash: "662be553c32b0145b3f4fee9bb0d659d" + } + Frame { + msec: 1856 + hash: "e6b9049949a0ee4ff8a0fcaf5464f479" + } + Frame { + msec: 1872 + hash: "eb1939458851780b7bb51ee50f0a3bd7" + } + Frame { + msec: 1888 + hash: "41c8d2686ddb882981a7d3a5c8c69005" + } + Frame { + msec: 1904 + hash: "7d3b1fc34082a160cbea4409af85fc9c" + } + Frame { + msec: 1920 + image: "qtbug10586.1.png" + } + Frame { + msec: 1936 + hash: "17be4a9c3d4d19e93bf1fc3a13a374a2" + } + Frame { + msec: 1952 + hash: "d449593024a59487eb92195ee6b77a64" + } + Frame { + msec: 1968 + hash: "c6ccbc2acec8e32f043f2cfb7b7848a9" + } + Frame { + msec: 1984 + hash: "cef9f8e8cdd5e2d33b86a9a6fb64ecb4" + } + Frame { + msec: 2000 + hash: "2a8956de5ce417431bdb156144985370" + } + Frame { + msec: 2016 + hash: "73721425a9c658bd9d40eac3fcbe8e25" + } + Frame { + msec: 2032 + hash: "9a9cf8eee0bf2f09944a4fb3b1c139d5" + } + Frame { + msec: 2048 + hash: "3673cdee04343ce679ec2cebadc9f512" + } + Frame { + msec: 2064 + hash: "eedd62019867e3189f9cf6e2b4149c6d" + } + Frame { + msec: 2080 + hash: "7a66bc37f5cf917e8b121003af0530b0" + } + Frame { + msec: 2096 + hash: "401667ed0f38858553de27164e9cadb5" + } + Frame { + msec: 2112 + hash: "b391699437c4092de3ad1684a35bfd30" + } + Frame { + msec: 2128 + hash: "109c91215f075292910095a25eaded49" + } + Frame { + msec: 2144 + hash: "c44d3f6ce1fa1ab324dd9ef394f37f87" + } + Frame { + msec: 2160 + hash: "299d43cb3dcf7b95af8803df3eb17a46" + } + Frame { + msec: 2176 + hash: "7ddd97266383d954a008fbe7b95a3169" + } + Frame { + msec: 2192 + hash: "941f2837ff5145a26df9a0d9f6d20bd9" + } + Frame { + msec: 2208 + hash: "d99d76cba43f3ae953605d7732d6ce21" + } + Frame { + msec: 2224 + hash: "929f49416f7ca80d7f5f2be3b13b849e" + } + Frame { + msec: 2240 + hash: "929f49416f7ca80d7f5f2be3b13b849e" + } + Frame { + msec: 2256 + hash: "fff9bbf16d1c3f7510ddfc44af616a5e" + } + Frame { + msec: 2272 + hash: "70b6cdb95ad6723d18c623e1dc79a8db" + } + Frame { + msec: 2288 + hash: "70b6cdb95ad6723d18c623e1dc79a8db" + } + Frame { + msec: 2304 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2320 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2336 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2352 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2368 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2384 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2400 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2416 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2432 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2448 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2464 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2480 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2496 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2512 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2528 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2544 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2560 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2576 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2592 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2608 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2624 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2640 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2656 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2672 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2688 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2704 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2720 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2736 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Mouse { + type: 2 + button: 1 + buttons: 1 + x: 29; y: 239 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2752 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2768 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2784 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2800 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2816 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 35; y: 241 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2832 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 63; y: 243 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2848 + hash: "2732b282b8ac482033694cd04c6f5b7e" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 106; y: 244 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2864 + hash: "7d253797885f8b304d8fb3ba727a3c5d" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 158; y: 243 + modifiers: 0 + sendToViewport: true + } + Mouse { + type: 3 + button: 1 + buttons: 0 + x: 158; y: 243 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2880 + image: "qtbug10586.2.png" + } + Frame { + msec: 2896 + hash: "d85a416e4ddf59dfd0723b0be0e2b418" + } + Frame { + msec: 2912 + hash: "f1934f6ca6a3c5ac5df3451596b8d8ba" + } + Frame { + msec: 2928 + hash: "28fc74a76f9eaeeccbd3063dc55a1000" + } + Frame { + msec: 2944 + hash: "eb8ad8dae734b624664fcf584cda6ba0" + } + Frame { + msec: 2960 + hash: "a6d0f4aba3e5ae1e003520f45b75d6dd" + } + Frame { + msec: 2976 + hash: "4e5a4d04dfa5f06292774e6bf4f86508" + } + Frame { + msec: 2992 + hash: "fc9e16fd8c7379d774a09fe50d4259dc" + } + Frame { + msec: 3008 + hash: "721ea322d9a5e9d48117336476f568cb" + } + Frame { + msec: 3024 + hash: "5930448341bce1c50de7acaba1f64ca1" + } + Frame { + msec: 3040 + hash: "7194bacd56906f83948844224ce6a3e7" + } + Frame { + msec: 3056 + hash: "fcf11cf70b8ac210d4bb2bc716942053" + } + Frame { + msec: 3072 + hash: "767d707db4dbb02b6f97153b3822a1d1" + } + Frame { + msec: 3088 + hash: "f8eb75b97f5233aa82b887aab34a38e3" + } + Frame { + msec: 3104 + hash: "1d3beb06b39fa1d5cabd31ec4297f59f" + } + Frame { + msec: 3120 + hash: "cadc775e0764afa7b50c5bab782035dd" + } + Frame { + msec: 3136 + hash: "385f5a6e80da0d3ddf24539a64f26eb9" + } + Frame { + msec: 3152 + hash: "34204871a684ea251c9d07fb125436da" + } + Frame { + msec: 3168 + hash: "bc3e496535e66ff0d1e800092b7c78ca" + } + Frame { + msec: 3184 + hash: "d6c4ff5bf223361be42c78d6d81248c3" + } + Frame { + msec: 3200 + hash: "cb09d41612df66a8d099153026adcbf3" + } + Frame { + msec: 3216 + hash: "f82180b8c0389ddc3623107a049c3366" + } + Frame { + msec: 3232 + hash: "1b0f65e4599c65b8a603abd8da718d48" + } + Frame { + msec: 3248 + hash: "897391a8206178356858139b3d1a4ce8" + } + Frame { + msec: 3264 + hash: "b66d268dc7a42a7b1172b1ff566f4eb8" + } + Frame { + msec: 3280 + hash: "0fe5d38a253dbd1ebcc67cca7ea86dc7" + } + Frame { + msec: 3296 + hash: "b788f8a7e1e42f768fd1fe1198ca0344" + } + Frame { + msec: 3312 + hash: "4f7f8b7f5bb78bb9327b6fa8142ce3a2" + } + Frame { + msec: 3328 + hash: "30f041278c08174671568a0dfb7cbdf7" + } + Frame { + msec: 3344 + hash: "6ecd90fc89ab9b6c4813fa6a6e9dffdb" + } + Frame { + msec: 3360 + hash: "6ecd90fc89ab9b6c4813fa6a6e9dffdb" + } + Frame { + msec: 3376 + hash: "6d79d9d0ba8da0b5654b39768b25591f" + } + Frame { + msec: 3392 + hash: "6d79d9d0ba8da0b5654b39768b25591f" + } + Frame { + msec: 3408 + hash: "6d79d9d0ba8da0b5654b39768b25591f" + } + Frame { + msec: 3424 + hash: "6d79d9d0ba8da0b5654b39768b25591f" + } + Frame { + msec: 3440 + hash: "6d79d9d0ba8da0b5654b39768b25591f" + } + Frame { + msec: 3456 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3472 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3488 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3504 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3520 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3536 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3552 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3568 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3584 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3600 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3616 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3632 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3648 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3664 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3680 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3696 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3712 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3728 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3744 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3760 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3776 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3792 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3808 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3824 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3840 + image: "qtbug10586.3.png" + } + Frame { + msec: 3856 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3872 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3888 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3904 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3920 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3936 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3952 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3968 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3984 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4000 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4016 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4032 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4048 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4064 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Key { + type: 6 + key: 16777249 + modifiers: 67108864 + text: "" + autorep: false + count: 1 + } + Frame { + msec: 4080 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4096 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4112 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4128 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4144 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4160 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4176 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4192 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } +} diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/qtbug10586.qml b/tests/auto/declarative/qmlvisual/animation/qtbug10586/qtbug10586.qml new file mode 100644 index 0000000..f1a3ef7 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/qtbug10586/qtbug10586.qml @@ -0,0 +1,27 @@ +import Qt 4.7 + +Rectangle { + width: 200 + height: 400 + Flickable { + id: flick + anchors.fill: parent + contentWidth: 1000; contentHeight: parent.height + Rectangle { + border.color: "black" + border.width: 10 + width: 1000; height: 1000 + rotation: 90 + gradient: Gradient { + GradientStop { position: 0; color: "black" } + GradientStop { position: 1; color: "white" } + } + } + } + Rectangle { + color: "red" + width: 100; height: 100 + y: flick.contentX < 10 ? 300 : 0 + Behavior on y { NumberAnimation {} } + } +} diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp index 5f25882..0f33a07 100644 --- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp +++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp @@ -101,9 +101,8 @@ void tst_qmlvisual::visual_data() files << findQmlFiles(QDir(QT_TEST_SOURCE_DIR)); else { //these are newly added tests we want to try out in CI (then move to the stable list) - files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/borders.qml"; + files << QT_TEST_SOURCE_DIR "/animation/qtbug10586/qtbug10586.qml"; files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/animated.qml"; - files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/animated-smooth.qml"; files << QT_TEST_SOURCE_DIR "/qdeclarativeflipable/test-flipable.qml"; files << QT_TEST_SOURCE_DIR "/qdeclarativepositioners/usingRepeater.qml"; @@ -123,6 +122,8 @@ void tst_qmlvisual::visual_data() //these reliably fail in CI, for unknown reasons //files << QT_TEST_SOURCE_DIR "/animation/easing/easing.qml"; //files << QT_TEST_SOURCE_DIR "/animation/pauseAnimation/pauseAnimation-visual.qml"; + //files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/borders.qml"; + //files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/animated-smooth.qml"; //these reliably fail on Linux because of color interpolation (different float rounding) #if !defined(Q_WS_X11) && !defined(Q_WS_QWS) -- cgit v0.12 From 84ae0d5c700b9b7396585301e7ef129ee0a2696d Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Wed, 12 May 2010 13:17:13 +1000 Subject: Sorted the tests list in declarative.pro Also removed the #Cover tag, which is not used anymore. --- tests/auto/declarative/declarative.pro | 130 ++++++++++++++++----------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index a9b069c..2520bcd 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -1,74 +1,74 @@ TEMPLATE = subdirs SUBDIRS += \ examples \ - parserstress \ # Cover - qmetaobjectbuilder \ # Cover - qdeclarativeanimations \ # Cover - qdeclarativebehaviors \ # Cover - qdeclarativebinding \ # Cover - qdeclarativecomponent \ # Cover - qdeclarativeconnection \ # Cover - qdeclarativecontext \ # Cover - qdeclarativedebug \ # Cover - qdeclarativedebugclient \ # Cover - qdeclarativedebugservice \ # Cover - qdeclarativedom \ # Cover - qdeclarativeecmascript \ # Cover - qdeclarativeengine \ # Cover - qdeclarativeerror \ # Cover - qdeclarativefontloader \ # Cover - qdeclarativeanchors \ # Cover - qdeclarativeanimatedimage \ # Cover - qdeclarativeimage \ # Cover - qdeclarativeborderimage \ # Cover - qdeclarativeflickable \ # Cover - qdeclarativeflipable \ # Cover - qdeclarativefocusscope \ # Cover - qdeclarativegridview \ # Cover - qdeclarativeitem \ # Cover - qdeclarativelistview \ # Cover - qdeclarativeloader \ # Cover - qdeclarativemousearea \ # Cover - qdeclarativeparticles \ # Cover - qdeclarativepathview \ # Cover - qdeclarativepositioners \ # Cover - qdeclarativetext \ # Cover - qdeclarativetextedit \ # Cover - qdeclarativetextinput \ # Cover - qdeclarativeinfo \ # Cover - qdeclarativeinstruction \ # Cover - qdeclarativelanguage \ # Cover - qdeclarativelistreference \ # Cover - qdeclarativelistmodel \ # Cover - qdeclarativeproperty \ # Cover - qdeclarativemetatype \ # Cover - qdeclarativemoduleplugin \ # Cover - qdeclarativepixmapcache \ # Cover - qdeclarativepropertymap \ # Cover - qdeclarativeqt \ # Cover - qdeclarativesmoothedanimation \ # Cover - qdeclarativesmoothedfollow\ # Cover - qdeclarativespringfollow \ # Cover - qdeclarativestates \ # Cover - qdeclarativesystempalette \ # Cover - qdeclarativetimer \ # Cover - qdeclarativexmllistmodel \ # Cover - qpacketprotocol \ # Cover - qdeclarativerepeater \ # Cover - qdeclarativeworkerscript \ # Cover - qdeclarativevaluetypes \ # Cover - qdeclarativeview \ # Cover - qdeclarativexmlhttprequest \ # Cover - qdeclarativeimageprovider \ # Cover - qdeclarativestyledtext \ # Cover - qdeclarativesqldatabase \ # Cover - qdeclarativevisualdatamodel \ # Cover - qdeclarativeviewer \ # Cover - qmlvisual # Cover + parserstress \ + qdeclarativeanchors \ + qdeclarativeanimatedimage \ + qdeclarativeanimations \ + qdeclarativebehaviors \ + qdeclarativebinding \ + qdeclarativeborderimage \ + qdeclarativecomponent \ + qdeclarativeconnection \ + qdeclarativecontext \ + qdeclarativedebug \ + qdeclarativedebugclient \ + qdeclarativedebugservice \ + qdeclarativedom \ + qdeclarativeecmascript \ + qdeclarativeengine \ + qdeclarativeerror \ + qdeclarativefontloader \ + qdeclarativeflickable \ + qdeclarativeflipable \ + qdeclarativefocusscope \ + qdeclarativegridview \ + qdeclarativeimage \ + qdeclarativeimageprovider \ + qdeclarativeinfo \ + qdeclarativeinstruction \ + qdeclarativeitem \ + qdeclarativelanguage \ + qdeclarativelistmodel \ + qdeclarativelistreference \ + qdeclarativelistview \ + qdeclarativeloader \ + qdeclarativemetatype \ + qdeclarativemoduleplugin \ + qdeclarativemousearea \ + qdeclarativeparticles \ + qdeclarativepathview \ + qdeclarativepixmapcache \ + qdeclarativepositioners \ + qdeclarativeproperty \ + qdeclarativepropertymap \ + qdeclarativeqt \ + qdeclarativerepeater \ + qdeclarativesmoothedanimation \ + qdeclarativesmoothedfollow\ + qdeclarativespringfollow \ + qdeclarativesqldatabase \ + qdeclarativestates \ + qdeclarativestyledtext \ + qdeclarativesystempalette \ + qdeclarativetext \ + qdeclarativetextedit \ + qdeclarativetextinput \ + qdeclarativetimer \ + qdeclarativevaluetypes \ + qdeclarativeview \ + qdeclarativeviewer \ + qdeclarativevisualdatamodel \ + qdeclarativeworkerscript \ + qdeclarativexmlhttprequest \ + qdeclarativexmllistmodel \ + qmlvisual \ + qpacketprotocol \ + qmetaobjectbuilder contains(QT_CONFIG, webkit) { SUBDIRS += \ - qdeclarativewebview # Cover + qdeclarativewebview } # Tests which should run in Pulse -- cgit v0.12 From 9e84653e20b20ea32a789deaef9d5d4acd5d68ea Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Wed, 12 May 2010 13:21:16 +1000 Subject: Add missing test, qdeclarativelayoutitem, to declarative.pro --- tests/auto/declarative/declarative.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 2520bcd..3496906 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -29,6 +29,7 @@ SUBDIRS += \ qdeclarativeinstruction \ qdeclarativeitem \ qdeclarativelanguage \ + qdeclarativelayoutitem \ qdeclarativelistmodel \ qdeclarativelistreference \ qdeclarativelistview \ -- cgit v0.12 From d412a77d1e9a1c6810e10dfa4a0a35a81391cf29 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 12 May 2010 13:27:55 +1000 Subject: Use raster graphicssystem for qml.app on OS X. Task-number: QTBUG-10544 --- tools/qml/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 116ca71..003716e 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -184,7 +184,7 @@ int main(int argc, char ** argv) atexit(showWarnings); #endif -#if defined (Q_WS_X11) +#if defined (Q_WS_X11) || defined(Q_WS_MAC) //### default to using raster graphics backend for now bool gsSpecified = false; for (int i = 0; i < argc; ++i) { -- cgit v0.12 From 1e992df9dfa4abcd5073f94da765c5e47b2f0319 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 12 May 2010 12:20:00 +1000 Subject: Stop GIF handler claiming it can report Size for sequential devices, since it scans the entire image to do so (and then can't read the image). Task-number: QTBUG-10621 --- src/plugins/imageformats/gif/qgifhandler.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index 25d3dfa..8abc2d1 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -1119,8 +1119,11 @@ bool QGifHandler::write(const QImage &image) bool QGifHandler::supportsOption(ImageOption option) const { - return option == Size - || option == Animation; + if (!device() || device()->isSequential()) + return option == Animation; + else + return option == Size + || option == Animation; } QVariant QGifHandler::option(ImageOption option) const -- cgit v0.12 From b3a06e47bc66c36de8558ab7bc9817ed2518ae9c Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 12 May 2010 13:18:32 +1000 Subject: Don't pass sequential (QNetworkReply) to image reader, it doesn't work well enough. Work around QTBUG-10622 --- src/declarative/util/qdeclarativepixmapcache.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index dbca326..d9ce42c 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -342,7 +343,10 @@ void QDeclarativeImageRequestHandler::networkRequestDone() errorString = reply->errorString(); } else { QSize read_impsize; - if (readImage(reply->url(), reply, &image, &errorString, &read_impsize, job->forcedWidth(), job->forcedHeight())) { + QByteArray all = reply->readAll(); + QBuffer buff(&all); + buff.open(QIODevice::ReadOnly); + if (readImage(reply->url(), &buff, &image, &errorString, &read_impsize, job->forcedWidth(), job->forcedHeight())) { qmlOriginalSizes()->insert(reply->url(), read_impsize); error = QDeclarativeImageReaderEvent::NoError; } else { -- cgit v0.12 From 29450fd82c2c8efdc296a051f6a8fac2bd3fa76a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 12 May 2010 13:56:44 +1000 Subject: Avoid warning (and possible future crash) upon reload. Task-number: QTBUG-10555 --- src/declarative/util/qdeclarativexmllistmodel.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index f02ed16..f1a00989 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -796,8 +796,11 @@ void QDeclarativeXmlListModel::reload() if (d->reply) { d->reply->abort(); - d->reply->deleteLater(); - d->reply = 0; + if (d->reply) { + // abort will generally have already done this (and more) + d->reply->deleteLater(); + d->reply = 0; + } } if (!d->xml.isEmpty()) { -- cgit v0.12 From 798bdb4543f84d427659b950a3a1643ae4987b8b Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 12 May 2010 07:12:34 +0200 Subject: Reset the dragDropItem to 0 when the item dies while dragging on top it. If you drag something on top of an item and the former is deleted then we need to reset the dragDropItem pointer to 0. Task-number:KDE BUG 232182 Reviewed-by:leo --- src/gui/graphicsview/qgraphicsscene.cpp | 4 ++++ tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 0d4e48a..dacdbfe 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -690,6 +690,10 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) if (item == lastMouseGrabberItem) lastMouseGrabberItem = 0; + // Reset the current drop item + if (item == dragDropItem) + dragDropItem = 0; + // Reenable selectionChanged() for individual items --selectionChanging; if (!selectionChanging && selectedItems.size() != oldSelectedItemsSize) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 81097be..5a5a821 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -447,6 +448,7 @@ private slots: void QT_2649_focusScope(); void sortItemsWhileAdding(); void doNotMarkFullUpdateIfNotInScene(); + void itemDiesDuringDraggingOperation(); private: QList paintedItems; @@ -10484,5 +10486,27 @@ void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene() QTRY_COMPARE(item3->painted, 3); } +void tst_QGraphicsItem::itemDiesDuringDraggingOperation() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsRectItem *item = new QGraphicsRectItem(QRectF(0, 0, 100, 100)); + item->setFlag(QGraphicsItem::ItemIsMovable); + item->setAcceptDrops(true); + scene.addItem(item); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view); + QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter); + dragEnter.setScenePos(item->boundingRect().center()); + QApplication::sendEvent(&scene, &dragEnter); + QGraphicsSceneDragDropEvent event(QEvent::GraphicsSceneDragMove); + event.setScenePos(item->boundingRect().center()); + QApplication::sendEvent(&scene, &event); + QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == item); + delete item; + QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == 0); +} QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From 71187a1f0d26ff61c033a7c2d46892f48816fc45 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 11 May 2010 13:33:48 +1000 Subject: Flickable small API changes. - Split moving into movingHorizontally anf movingVertically - Split flicking into flickingHorizontally and flickingVertically - Rename flickDirection to flickableDirection - onMovementStarted, onMovementEnded, onFlickStarted and onFlickEnded signals removed Task-number: QTBUG-10572 Reviewed-by: Martin Jones --- demos/declarative/flickr/common/ScrollBar.qml | 2 +- demos/declarative/flickr/mobile/ImageDetails.qml | 4 +- demos/declarative/webbrowser/content/ScrollBar.qml | 2 +- demos/declarative/webbrowser/webbrowser.qml | 14 +- examples/declarative/listview/dynamic.qml | 2 +- examples/declarative/scrollbar/display.qml | 2 +- src/declarative/QmlChanges.txt | 7 +- .../graphicsitems/qdeclarativeflickable.cpp | 213 ++++++++++++--------- .../graphicsitems/qdeclarativeflickable_p.h | 43 +++-- .../graphicsitems/qdeclarativeflickable_p_p.h | 10 +- .../graphicsitems/qdeclarativegridview.cpp | 44 +++-- .../graphicsitems/qdeclarativelistview.cpp | 42 ++-- .../tst_qdeclarativeflickable.cpp | 28 +++ 13 files changed, 257 insertions(+), 156 deletions(-) diff --git a/demos/declarative/flickr/common/ScrollBar.qml b/demos/declarative/flickr/common/ScrollBar.qml index 4022d23..d70cd3c 100644 --- a/demos/declarative/flickr/common/ScrollBar.qml +++ b/demos/declarative/flickr/common/ScrollBar.qml @@ -19,7 +19,7 @@ Item { states: [ State { name: "show" - when: flickableArea.moving + when: flickableArea.movingVertically PropertyChanges { target: container opacity: 1 diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml index caf1571..79d7cab 100644 --- a/demos/declarative/flickr/mobile/ImageDetails.qml +++ b/demos/declarative/flickr/mobile/ImageDetails.qml @@ -70,7 +70,7 @@ Flipable { Image { id: bigImage; source: container.photoUrl; scale: slider.value - anchors.centerIn: parent; smooth: !flickable.moving + anchors.centerIn: parent; smooth: !flickable.movingVertically onStatusChanged : { // Default scale shows the entire image. if (status == Image.Ready && width != 0) { @@ -119,7 +119,7 @@ Flipable { SequentialAnimation { PropertyAction { target: bigImage; property: "smooth"; value: false } NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: 500 } - PropertyAction { target: bigImage; property: "smooth"; value: !flickable.moving } + PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically } } } } diff --git a/demos/declarative/webbrowser/content/ScrollBar.qml b/demos/declarative/webbrowser/content/ScrollBar.qml index 976297b..aa79d35 100644 --- a/demos/declarative/webbrowser/content/ScrollBar.qml +++ b/demos/declarative/webbrowser/content/ScrollBar.qml @@ -55,7 +55,7 @@ Item { states: State { name: "visible" - when: scrollArea.moving + when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally PropertyChanges { target: container; opacity: 1.0 } } diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 27da814..f539e21 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -15,13 +15,9 @@ Rectangle { id: webView url: webBrowser.urlString anchors { top: headerSpace.bottom; left: parent.left; right: parent.right; bottom: parent.bottom } - } - Item { - id: headerSpace - width: parent.width; height: 62 - } + Item { id: headerSpace; width: parent.width; height: 62 } Header { id: header @@ -34,8 +30,8 @@ Rectangle { anchors { right: parent.right; top: header.bottom; bottom: parent.bottom } } -// ScrollBar { -// scrollArea: webView; height: 8; orientation: Qt.Horizontal -// anchors { right: parent.right; rightMargin: 8; left: parent.left; bottom: parent.bottom } -// } + ScrollBar { + scrollArea: webView; height: 8; orientation: Qt.Horizontal + anchors { right: parent.right; rightMargin: 8; left: parent.left; bottom: parent.bottom } + } } diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml index 9b05ad5..64f324e 100644 --- a/examples/declarative/listview/dynamic.qml +++ b/examples/declarative/listview/dynamic.qml @@ -151,7 +151,7 @@ Rectangle { // Only show the scrollbar when the view is moving. states: State { - name: "ShowBars"; when: view.moving + name: "ShowBars"; when: view.movingVertically PropertyChanges { target: verticalScrollBar; opacity: 1 } } transitions: Transition { diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml index b8a5e36..6b12d85 100644 --- a/examples/declarative/scrollbar/display.qml +++ b/examples/declarative/scrollbar/display.qml @@ -20,7 +20,7 @@ Rectangle { // Only show the scrollbars when the view is moving. states: State { name: "ShowBars" - when: view.moving + when: view.movingVertically || view.movingHorizontally PropertyChanges { target: verticalScrollBar; opacity: 1 } PropertyChanges { target: horizontalScrollBar; opacity: 1 } } diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 9f618d8..9ab3f08 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -1,7 +1,12 @@ ============================================================================= The changes below are pre Qt 4.7.0 RC -Flickable: overShoot is replaced by boundsBehavior enumeration. +Flickable: + - overShoot is replaced by boundsBehavior enumeration + - flicking is replaced by flickingHorizontally and flickingVertically + - moving is replaced by movingHorizontally and movingVertically + - flickDirection is renamed flickableDirection + - onMovementStarted, onMovementEnded, onFlickStarted and onFlickEnded signals removed Component: isReady, isLoading, isError and isNull properties removed, use status property instead QList models no longer provide properties in model object. The diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 34b0606..a7a8983 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -125,12 +125,14 @@ QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate() : viewport(new QDeclarativeItem) , hData(this, &QDeclarativeFlickablePrivate::setRoundedViewportX) , vData(this, &QDeclarativeFlickablePrivate::setRoundedViewportY) - , flicked(false), moving(false), stealMouse(false) - , pressed(false) + , flickingHorizontally(false), flickingVertically(false) + , hMoved(false), vMoved(false) + , movingHorizontally(false), movingVertically(false) + , stealMouse(false), pressed(false) , interactive(true), deceleration(500), maxVelocity(2000), reportedVelocitySmoothing(100) , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(600) , vTime(0), visibleArea(0) - , flickDirection(QDeclarativeFlickable::AutoFlickDirection) + , flickableDirection(QDeclarativeFlickable::AutoFlickDirection) , boundsBehavior(QDeclarativeFlickable::DragAndOvershootBounds) { } @@ -226,10 +228,15 @@ void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal timeline.reset(data.move); timeline.accel(data.move, v, deceleration, maxDistance); timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); - if (!flicked) { - flicked = true; - emit q->flickingChanged(); - emit q->flickStarted(); + if (!flickingHorizontally && q->xflick()) { + flickingHorizontally = true; + emit q->flickingChanged(); // deprecated + emit q->flickingHorizontallyChanged(); + } + if (!flickingVertically && q->yflick()) { + flickingVertically = true; + emit q->flickingChanged(); // deprecated + emit q->flickingVerticallyChanged(); } } else { timeline.reset(data.move); @@ -274,7 +281,6 @@ void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal q->viewportMoved(); } } - //emit flickingChanged(); } else if (data.move.value() < maxExtent) { timeline.reset(data.move); if (fixupDuration) { @@ -285,11 +291,7 @@ void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal data.move.setValue(maxExtent); q->viewportMoved(); } - //emit flickingChanged(); - } else { - flicked = false; } - vTime = timeline.time(); } @@ -363,37 +365,6 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() */ /*! - \qmlsignal Flickable::onMovementStarted() - - This handler is called when the view begins moving due to user - interaction. -*/ - -/*! - \qmlsignal Flickable::onMovementEnded() - - This handler is called when the view stops moving due to user - interaction. If a flick was generated, this handler will - be triggered once the flick stops. If a flick was not - generated, the handler will be triggered when the - user stops dragging - i.e. a mouse or touch release. -*/ - -/*! - \qmlsignal Flickable::onFlickStarted() - - This handler is called when the view is flicked. A flick - starts from the point that the mouse or touch is released, - while still in motion. -*/ - -/*! - \qmlsignal Flickable::onFlickEnded() - - This handler is called when the view stops moving due to a flick. -*/ - -/*! \qmlproperty real Flickable::visibleArea.xPosition \qmlproperty real Flickable::visibleArea.widthRatio \qmlproperty real Flickable::visibleArea.yPosition @@ -498,12 +469,14 @@ void QDeclarativeFlickable::setInteractive(bool interactive) Q_D(QDeclarativeFlickable); if (interactive != d->interactive) { d->interactive = interactive; - if (!interactive && d->flicked) { + if (!interactive && (d->flickingHorizontally || d->flickingVertically)) { d->timeline.clear(); d->vTime = d->timeline.time(); - d->flicked = false; - emit flickingChanged(); - emit flickEnded(); + d->flickingHorizontally = false; + d->flickingVertically = false; + emit flickingChanged(); // deprecated + emit flickingHorizontallyChanged(); + emit flickingVerticallyChanged(); } emit interactiveChanged(); } @@ -582,7 +555,7 @@ QDeclarativeFlickableVisibleArea *QDeclarativeFlickable::visibleArea() } /*! - \qmlproperty enumeration Flickable::flickDirection + \qmlproperty enumeration Flickable::flickableDirection This property determines which directions the view can be flicked. @@ -596,21 +569,33 @@ QDeclarativeFlickableVisibleArea *QDeclarativeFlickable::visibleArea() \o Flickable.HorizontalAndVerticalFlick - allows flicking in both directions. \endlist */ -QDeclarativeFlickable::FlickDirection QDeclarativeFlickable::flickDirection() const +QDeclarativeFlickable::FlickableDirection QDeclarativeFlickable::flickableDirection() const { Q_D(const QDeclarativeFlickable); - return d->flickDirection; + return d->flickableDirection; } -void QDeclarativeFlickable::setFlickDirection(FlickDirection direction) +void QDeclarativeFlickable::setFlickableDirection(FlickableDirection direction) { Q_D(QDeclarativeFlickable); - if (direction != d->flickDirection) { - d->flickDirection = direction; - emit flickDirectionChanged(); + if (direction != d->flickableDirection) { + d->flickableDirection = direction; + emit flickableDirectionChanged(); } } +QDeclarativeFlickable::FlickableDirection QDeclarativeFlickable::flickDirection() const +{ + qmlInfo(this) << "'flickDirection' is deprecated. Please use 'flickableDirection' instead."; + return flickableDirection(); +} + +void QDeclarativeFlickable::setFlickDirection(FlickableDirection direction) +{ + qmlInfo(this) << "'flickDirection' is deprecated. Please use 'flickableDirection' instead."; + setFlickableDirection(direction); +} + void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event) { if (interactive && timeline.isActive() && (qAbs(hData.velocity) > 10 || qAbs(vData.velocity) > 10)) @@ -626,7 +611,8 @@ void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEven pressPos = event->pos(); hData.pressPos = hData.move.value(); vData.pressPos = vData.move.value(); - flicked = false; + flickingHorizontally = false; + flickingVertically = false; QDeclarativeItemPrivate::start(pressTime); QDeclarativeItemPrivate::start(velocityTime); } @@ -638,7 +624,6 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent return; bool rejectY = false; bool rejectX = false; - bool moved = false; if (q->yflick()) { int dy = int(event->pos().y() - pressPos.y()); @@ -660,7 +645,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent } if (!rejectY && stealMouse) { vData.move.setValue(qRound(newY)); - moved = true; + vMoved = true; } if (qAbs(dy) > QApplication::startDragDistance()) stealMouse = true; @@ -687,7 +672,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent } if (!rejectX && stealMouse) { hData.move.setValue(qRound(newX)); - moved = true; + hMoved = true; } if (qAbs(dx) > QApplication::startDragDistance()) @@ -717,7 +702,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent if (rejectY) vData.velocity = 0; if (rejectX) hData.velocity = 0; - if (moved) { + if (hMoved || vMoved) { q->movementStarting(); q->viewportMoved(); } @@ -812,9 +797,9 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event) d->vData.velocity = qMax(event->delta() - d->vData.smoothVelocity.value(), qreal(250.0)); else d->vData.velocity = qMin(event->delta() - d->vData.smoothVelocity.value(), qreal(-250.0)); - d->flicked = false; + d->flickingVertically = false; d->flickY(d->vData.velocity); - if (d->flicked) + if (d->flickingVertically) movementStarting(); event->accept(); } else if (xflick()) { @@ -822,9 +807,9 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event) d->hData.velocity = qMax(event->delta() - d->hData.smoothVelocity.value(), qreal(250.0)); else d->hData.velocity = qMin(event->delta() - d->hData.smoothVelocity.value(), qreal(-250.0)); - d->flicked = false; + d->flickingHorizontally = false; d->flickX(d->hData.velocity); - if (d->flicked) + if (d->flickingHorizontally) movementStarting(); event->accept(); } else { @@ -1091,7 +1076,7 @@ void QDeclarativeFlickable::setContentWidth(qreal w) else d->viewport->setWidth(w); // Make sure that we're entirely in view. - if (!d->pressed && !d->moving) { + if (!d->pressed && !d->movingHorizontally && !d->movingVertically) { int oldDuration = d->fixupDuration; d->fixupDuration = 0; d->fixupX(); @@ -1118,7 +1103,7 @@ void QDeclarativeFlickable::setContentHeight(qreal h) else d->viewport->setHeight(h); // Make sure that we're entirely in view. - if (!d->pressed && !d->moving) { + if (!d->pressed && !d->movingHorizontally && !d->movingVertically) { int oldDuration = d->fixupDuration; d->fixupDuration = 0; d->fixupY(); @@ -1149,17 +1134,17 @@ qreal QDeclarativeFlickable::vHeight() const bool QDeclarativeFlickable::xflick() const { Q_D(const QDeclarativeFlickable); - if (d->flickDirection == QDeclarativeFlickable::AutoFlickDirection) + if (d->flickableDirection == QDeclarativeFlickable::AutoFlickDirection) return vWidth() != width(); - return d->flickDirection & QDeclarativeFlickable::HorizontalFlick; + return d->flickableDirection & QDeclarativeFlickable::HorizontalFlick; } bool QDeclarativeFlickable::yflick() const { Q_D(const QDeclarativeFlickable); - if (d->flickDirection == QDeclarativeFlickable::AutoFlickDirection) + if (d->flickableDirection == QDeclarativeFlickable::AutoFlickDirection) return vHeight() != height(); - return d->flickDirection & QDeclarativeFlickable::VerticalFlick; + return d->flickableDirection & QDeclarativeFlickable::VerticalFlick; } bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) @@ -1281,16 +1266,30 @@ void QDeclarativeFlickable::setFlickDeceleration(qreal deceleration) emit flickDecelerationChanged(); } +bool QDeclarativeFlickable::isFlicking() const +{ + Q_D(const QDeclarativeFlickable); + qmlInfo(this) << "'flicking' is deprecated. Please use 'flickingHorizontally' and 'flickingVertically' instead."; + return d->flickingHorizontally || d->flickingVertically; +} + /*! - \qmlproperty bool Flickable::flicking + \qmlproperty bool Flickable::flickingHorizontally + \qmlproperty bool Flickable::flickingVertically - This property holds whether the view is currently moving due to - the user flicking the view. + These properties hold whether the view is currently moving horizontally + or vertically due to the user flicking the view. */ -bool QDeclarativeFlickable::isFlicking() const +bool QDeclarativeFlickable::isFlickingHorizontally() const { Q_D(const QDeclarativeFlickable); - return d->flicked; + return d->flickingHorizontally; +} + +bool QDeclarativeFlickable::isFlickingVertically() const +{ + Q_D(const QDeclarativeFlickable); + return d->flickingVertically; } /*! @@ -1319,40 +1318,72 @@ void QDeclarativeFlickable::setPressDelay(int delay) emit pressDelayChanged(); } + +bool QDeclarativeFlickable::isMoving() const +{ + Q_D(const QDeclarativeFlickable); + qmlInfo(this) << "'moving' is deprecated. Please use 'movingHorizontally' or 'movingVertically' instead."; + return d->movingHorizontally || d->movingVertically; +} + /*! - \qmlproperty bool Flickable::moving + \qmlproperty bool Flickable::movingHorizontally + \qmlproperty bool Flickable::movingVertically - This property holds whether the view is currently moving due to - the user either dragging or flicking the view. + These properties hold whether the view is currently moving horizontally + or vertically due to the user either dragging or flicking the view. */ -bool QDeclarativeFlickable::isMoving() const +bool QDeclarativeFlickable::isMovingHorizontally() const +{ + Q_D(const QDeclarativeFlickable); + return d->movingHorizontally; +} + +bool QDeclarativeFlickable::isMovingVertically() const { Q_D(const QDeclarativeFlickable); - return d->moving; + return d->movingVertically; } void QDeclarativeFlickable::movementStarting() { Q_D(QDeclarativeFlickable); - if (!d->moving) { - d->moving = true; - emit movingChanged(); - emit movementStarted(); + if (d->hMoved && !d->movingHorizontally) { + d->movingHorizontally = true; + emit movingChanged(); // deprecated + emit movingHorizontallyChanged(); + } + if (d->vMoved && !d->movingVertically) { + d->movingVertically = true; + emit movingChanged(); // deprecated + emit movingVerticallyChanged(); } } void QDeclarativeFlickable::movementEnding() { Q_D(QDeclarativeFlickable); - if (d->moving) { - d->moving = false; - emit movingChanged(); - emit movementEnded(); + if (d->flickingHorizontally) { + d->flickingHorizontally = false; + emit flickingChanged(); // deprecated + emit flickingHorizontallyChanged(); + } + if (d->flickingVertically) { + d->flickingVertically = false; + emit flickingChanged(); // deprecated + emit flickingVerticallyChanged(); + } + if (d->movingHorizontally) { + d->movingHorizontally = false; + d->hMoved = false; + emit movingChanged(); // deprecated + emit movingHorizontallyChanged(); } - if (d->flicked) { - d->flicked = false; - emit flickingChanged(); - emit flickEnded(); + if (d->movingVertically) { + d->movingVertically = false; + d->vMoved = false; + emit movingChanged(); // deprecated + emit movingVerticallyChanged(); } d->hData.smoothVelocity.setValue(0); d->vData.smoothVelocity.setValue(0); diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h index f031a24..7944e2b 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h @@ -68,9 +68,14 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged) Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged) Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) - Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged) - Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged) - Q_PROPERTY(FlickDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickDirectionChanged) + Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged) // deprecated + Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged) + Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged) + Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged) // deprecated + Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged) + Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged) + Q_PROPERTY(FlickableDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickableDirectionChanged) // deprecated + Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged) Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged) Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged) @@ -86,7 +91,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem Q_PROPERTY(QDeclarativeListProperty flickableChildren READ flickableChildren) Q_CLASSINFO("DefaultProperty", "flickableData") - Q_ENUMS(FlickDirection) + Q_ENUMS(FlickableDirection) Q_ENUMS(BoundsBehavior) public: @@ -115,8 +120,12 @@ public: qreal contentY() const; void setContentY(qreal pos); - bool isMoving() const; - bool isFlicking() const; + bool isMoving() const; // deprecated + bool isMovingHorizontally() const; + bool isMovingVertically() const; + bool isFlicking() const; // deprecated + bool isFlickingHorizontally() const; + bool isFlickingVertically() const; int pressDelay() const; void setPressDelay(int delay); @@ -140,26 +149,28 @@ public: QDeclarativeItem *viewport(); - enum FlickDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 }; - FlickDirection flickDirection() const; - void setFlickDirection(FlickDirection); + enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 }; + FlickableDirection flickDirection() const; // deprecated + void setFlickDirection(FlickableDirection); // deprecated + FlickableDirection flickableDirection() const; + void setFlickableDirection(FlickableDirection); Q_SIGNALS: void contentWidthChanged(); void contentHeightChanged(); void contentXChanged(); void contentYChanged(); - void movingChanged(); - void flickingChanged(); - void movementStarted(); - void movementEnded(); - void flickStarted(); - void flickEnded(); + void movingChanged(); // deprecated + void movingHorizontallyChanged(); + void movingVerticallyChanged(); + void flickingChanged(); // deprecated + void flickingHorizontallyChanged(); + void flickingVerticallyChanged(); void horizontalVelocityChanged(); void verticalVelocityChanged(); void isAtBoundaryChanged(); void pageChanged(); - void flickDirectionChanged(); + void flickableDirectionChanged(); void interactiveChanged(); void overShootChanged(); void boundsBehaviorChanged(); diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index 01cfb18..b467ed2 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -131,8 +131,12 @@ public: AxisData vData; QDeclarativeTimeLine timeline; - bool flicked : 1; - bool moving : 1; + bool flickingHorizontally : 1; + bool flickingVertically : 1; + bool hMoved : 1; + bool vMoved : 1; + bool movingHorizontally : 1; + bool movingVertically : 1; bool stealMouse : 1; bool pressed : 1; bool interactive : 1; @@ -158,7 +162,7 @@ public: int vTime; QDeclarativeTimeLine velocityTimeline; QDeclarativeFlickableVisibleArea *visibleArea; - QDeclarativeFlickable::FlickDirection flickDirection; + QDeclarativeFlickable::FlickableDirection flickableDirection; QDeclarativeFlickable::BoundsBehavior boundsBehavior; void handleMousePressEvent(QGraphicsSceneMouseEvent *); diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 305d55c..396acd0 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -347,9 +347,10 @@ public: void QDeclarativeGridViewPrivate::init() { Q_Q(QDeclarativeGridView); - QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped())); + QObject::connect(q, SIGNAL(movingHorizontallyChanged()), q, SLOT(animStopped())); + QObject::connect(q, SIGNAL(movingVerticallyChanged()), q, SLOT(animStopped())); q->setFlag(QGraphicsItem::ItemIsFocusScope); - q->setFlickDirection(QDeclarativeFlickable::VerticalFlick); + q->setFlickableDirection(QDeclarativeFlickable::VerticalFlick); addItemChangeListener(this, Geometry); } @@ -692,7 +693,7 @@ void QDeclarativeGridViewPrivate::updateHighlight() { if ((!currentItem && highlight) || (currentItem && !highlight)) createHighlight(); - if (currentItem && autoHighlight && highlight && !moving) { + if (currentItem && autoHighlight && highlight && !movingHorizontally && !movingVertically) { // auto-update highlight highlightXAnimator->to = currentItem->item->x(); highlightYAnimator->to = currentItem->item->y(); @@ -806,7 +807,8 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m Q_Q(QDeclarativeGridView); moveReason = Mouse; - if ((!haveHighlightRange || highlightRange != QDeclarativeGridView::StrictlyEnforceRange) && snapMode == QDeclarativeGridView::NoSnap) { + if ((!haveHighlightRange || highlightRange != QDeclarativeGridView::StrictlyEnforceRange) + && snapMode == QDeclarativeGridView::NoSnap) { QDeclarativeFlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity); return; } @@ -874,9 +876,16 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m timeline.reset(data.move); timeline.accel(data.move, v, accel, maxDistance + overshootDist); timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); - flicked = true; - emit q->flickingChanged(); - emit q->flickStarted(); + if (!flickingHorizontally && q->xflick()) { + flickingHorizontally = true; + emit q->flickingChanged(); // deprecated + emit q->flickingHorizontallyChanged(); + } + if (!flickingVertically && q->yflick()) { + flickingVertically = true; + emit q->flickingChanged(); // deprecated + emit q->flickingVerticallyChanged(); + } } else { timeline.reset(data.move); fixup(data, minExtent, maxExtent); @@ -1371,10 +1380,10 @@ void QDeclarativeGridView::setFlow(Flow flow) d->flow = flow; if (d->flow == LeftToRight) { setContentWidth(-1); - setFlickDirection(QDeclarativeFlickable::VerticalFlick); + setFlickableDirection(QDeclarativeFlickable::VerticalFlick); } else { setContentHeight(-1); - setFlickDirection(QDeclarativeFlickable::HorizontalFlick); + setFlickableDirection(QDeclarativeFlickable::HorizontalFlick); } d->clear(); d->updateGrid(); @@ -1530,7 +1539,7 @@ void QDeclarativeGridView::viewportMoved() Q_D(QDeclarativeGridView); QDeclarativeFlickable::viewportMoved(); d->lazyRelease = true; - if (d->flicked) { + if (d->flickingHorizontally || d->flickingVertically) { if (yflick()) { if (d->vData.velocity > 0) d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore; @@ -1546,7 +1555,7 @@ void QDeclarativeGridView::viewportMoved() } } refill(); - if (isFlicking() || d->moving) + if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically) d->moveReason = QDeclarativeGridViewPrivate::Mouse; if (d->moveReason != QDeclarativeGridViewPrivate::SetIndex) { if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { @@ -1885,7 +1894,8 @@ void QDeclarativeGridView::trackedPositionChanged() Q_D(QDeclarativeGridView); if (!d->trackedItem || !d->currentItem) return; - if (!isFlicking() && !d->moving && d->moveReason == QDeclarativeGridViewPrivate::SetIndex) { + if (!d->flickingHorizontally && !d->flickingVertically && !d->movingHorizontally && !d->movingVertically + && d->moveReason == QDeclarativeGridViewPrivate::SetIndex) { const qreal trackedPos = d->trackedItem->rowPos(); const qreal viewPos = d->position(); if (d->haveHighlightRange) { @@ -2301,9 +2311,13 @@ void QDeclarativeGridView::destroyingItem(QDeclarativeItem *item) void QDeclarativeGridView::animStopped() { Q_D(QDeclarativeGridView); - d->bufferMode = QDeclarativeGridViewPrivate::NoBuffer; - if (d->haveHighlightRange && d->highlightRange == QDeclarativeGridView::StrictlyEnforceRange) - d->updateHighlight(); + if ((!d->movingVertically && d->flow == QDeclarativeGridView::LeftToRight) + || (!d->movingHorizontally && d->flow == QDeclarativeGridView::TopToBottom)) + { + d->bufferMode = QDeclarativeGridViewPrivate::NoBuffer; + if (d->haveHighlightRange && d->highlightRange == QDeclarativeGridView::StrictlyEnforceRange) + d->updateHighlight(); + } } void QDeclarativeGridView::refill() diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 65edb03..20106cb 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -525,8 +525,9 @@ void QDeclarativeListViewPrivate::init() Q_Q(QDeclarativeListView); q->setFlag(QGraphicsItem::ItemIsFocusScope); addItemChangeListener(this, Geometry); - QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped())); - q->setFlickDirection(QDeclarativeFlickable::VerticalFlick); + QObject::connect(q, SIGNAL(movingHorizontallyChanged()), q, SLOT(animStopped())); + QObject::connect(q, SIGNAL(movingVerticallyChanged()), q, SLOT(animStopped())); + q->setFlickableDirection(QDeclarativeFlickable::VerticalFlick); ::memset(sectionCache, 0, sizeof(QDeclarativeItem*) * sectionCacheSize); } @@ -869,7 +870,7 @@ void QDeclarativeListViewPrivate::updateHighlight() { if ((!currentItem && highlight) || (currentItem && !highlight)) createHighlight(); - if (currentItem && autoHighlight && highlight && !moving) { + if (currentItem && autoHighlight && highlight && !movingHorizontally && !movingVertically) { // auto-update highlight highlightPosAnimator->to = currentItem->position(); highlightSizeAnimator->to = currentItem->size(); @@ -1209,7 +1210,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m else v = maxVelocity; } - if (!flicked) { + if (!flickingHorizontally && !flickingVertically) { // the initial flick - estimate boundary qreal accel = deceleration; qreal v2 = v * v; @@ -1257,9 +1258,16 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m timeline.reset(data.move); timeline.accel(data.move, v, accel, maxDistance + overshootDist); timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); - flicked = true; - emit q->flickingChanged(); - emit q->flickStarted(); + if (!flickingHorizontally && q->xflick()) { + flickingHorizontally = true; + emit q->flickingChanged(); // deprecated + emit q->flickingHorizontallyChanged(); + } + if (!flickingVertically && q->yflick()) { + flickingVertically = true; + emit q->flickingChanged(); // deprecated + emit q->flickingVerticallyChanged(); + } correctFlick = true; } else { // reevaluate the target boundary. @@ -1805,10 +1813,10 @@ void QDeclarativeListView::setOrientation(QDeclarativeListView::Orientation orie d->orient = orientation; if (d->orient == QDeclarativeListView::Vertical) { setContentWidth(-1); - setFlickDirection(VerticalFlick); + setFlickableDirection(VerticalFlick); } else { setContentHeight(-1); - setFlickDirection(HorizontalFlick); + setFlickableDirection(HorizontalFlick); } d->clear(); d->setPosition(0); @@ -2107,7 +2115,7 @@ void QDeclarativeListView::viewportMoved() QDeclarativeFlickable::viewportMoved(); d->lazyRelease = true; refill(); - if (isFlicking() || d->moving) + if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically) d->moveReason = QDeclarativeListViewPrivate::Mouse; if (d->moveReason != QDeclarativeListViewPrivate::SetIndex) { if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { @@ -2127,7 +2135,7 @@ void QDeclarativeListView::viewportMoved() } } - if (d->flicked && d->correctFlick && !d->inFlickCorrection) { + if ((d->flickingHorizontally || d->flickingVertically) && d->correctFlick && !d->inFlickCorrection) { d->inFlickCorrection = true; // Near an end and it seems that the extent has changed? // Recalculate the flick so that we don't end up in an odd position. @@ -2447,7 +2455,8 @@ void QDeclarativeListView::trackedPositionChanged() Q_D(QDeclarativeListView); if (!d->trackedItem || !d->currentItem) return; - if (!isFlicking() && !d->moving && d->moveReason == QDeclarativeListViewPrivate::SetIndex) { + if (!d->flickingHorizontally && !d->flickingVertically && !d->movingHorizontally && !d->movingVertically + && d->moveReason == QDeclarativeListViewPrivate::SetIndex) { const qreal trackedPos = qCeil(d->trackedItem->position()); const qreal viewPos = d->position(); if (d->haveHighlightRange) { @@ -2881,9 +2890,12 @@ void QDeclarativeListView::destroyingItem(QDeclarativeItem *item) void QDeclarativeListView::animStopped() { Q_D(QDeclarativeListView); - d->bufferMode = QDeclarativeListViewPrivate::NoBuffer; - if (d->haveHighlightRange && d->highlightRange == QDeclarativeListView::StrictlyEnforceRange) - d->updateHighlight(); + if ((!d->movingVertically && d->orient == QDeclarativeListView::Vertical) || (!d->movingHorizontally && d->orient == QDeclarativeListView::Horizontal)) + { + d->bufferMode = QDeclarativeListViewPrivate::NoBuffer; + if (d->haveHighlightRange && d->highlightRange == QDeclarativeListView::StrictlyEnforceRange) + d->updateHighlight(); + } } QDeclarativeListViewAttached *QDeclarativeListView::qmlAttachedProperties(QObject *obj) diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index 9ce9c49..2c6890e 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -61,6 +61,7 @@ private slots: void maximumFlickVelocity(); void flickDeceleration(); void pressDelay(); + void flickableDirection(); private: QDeclarativeEngine engine; @@ -224,6 +225,33 @@ void tst_qdeclarativeflickable::pressDelay() QCOMPARE(spy.count(),1); } +void tst_qdeclarativeflickable::flickableDirection() +{ + QDeclarativeComponent component(&engine); + component.setData("import Qt 4.7; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile("")); + QDeclarativeFlickable *flickable = qobject_cast(component.create()); + QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::VerticalFlick); + + flickable->setFlickableDirection(QDeclarativeFlickable::HorizontalAndVerticalFlick); + QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::HorizontalAndVerticalFlick); + QCOMPARE(spy.count(),1); + + flickable->setFlickableDirection(QDeclarativeFlickable::AutoFlickDirection); + QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::AutoFlickDirection); + QCOMPARE(spy.count(),2); + + flickable->setFlickableDirection(QDeclarativeFlickable::HorizontalFlick); + QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::HorizontalFlick); + QCOMPARE(spy.count(),3); + + flickable->setFlickableDirection(QDeclarativeFlickable::HorizontalFlick); + QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::HorizontalFlick); + QCOMPARE(spy.count(),3); +} + QTEST_MAIN(tst_qdeclarativeflickable) #include "tst_qdeclarativeflickable.moc" -- cgit v0.12 From bb6daf55c88addd58db914e62245b3e3296308b8 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Tue, 11 May 2010 08:49:23 +0200 Subject: Don't crash when applications set Qt::WA_TranslucentBackground. After replacing some code with a function call to s60UpdateIsOpaque() we introduced a crash for widgets that set Qt::WA_TranslucentBackground. The reason for the crash was that the Qt::WA_WState_Created attribute was being set before calling this function, but *not* before setWinId() was being called. This meant that s60UpdateIsOpaque() assumed that the window was created (and the handle added to the widget map), but this was not actually the case. The fix here is to move the call to s60UpdateIsOpaque() after the call to setWinId() such that those assumptions are true. Reviewed-by: Jani Hautakangas --- src/gui/kernel/qwidget_s60.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index a0429d3..02e7cb8 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -387,7 +387,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de | EPointerFilterMove | EPointerFilterDrag, 0); drawableWindow->EnableVisibilityChangeEvents(); - s60UpdateIsOpaque(); } q->setAttribute(Qt::WA_WState_Created); @@ -400,6 +399,9 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de // this generates a WinIdChanged event. setWinId(control.take()); + if (!desktop) + s60UpdateIsOpaque(); // must be called after setWinId() + } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget QScopedPointer control( q_check_ptr(new QSymbianControl(q)) ); -- cgit v0.12 From 9a45f780a24625f8f1104a6e2442f00874ab296f Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 12 May 2010 16:27:34 +1000 Subject: Improve Image docs. Move all fillMode image examples to fillMode property docs and remove the animated gif. --- doc/src/images/declarative-image_fillMode.gif | Bin 79561 -> 0 bytes .../declarative-qtlogo-preserveaspectcrop.png | Bin 0 -> 6440 bytes .../declarative-qtlogo-preserveaspectfit.png | Bin 0 -> 4076 bytes doc/src/images/declarative-qtlogo-stretch.png | Bin 0 -> 5584 bytes doc/src/images/declarative-qtlogo-tile.png | Bin 0 -> 3940 bytes .../images/declarative-qtlogo-tilehorizontally.png | Bin 0 -> 5544 bytes .../images/declarative-qtlogo-tilevertically.png | Bin 0 -> 6288 bytes doc/src/images/declarative-qtlogo.png | Bin 0 -> 3436 bytes doc/src/images/declarative-qtlogo1.png | Bin 3436 -> 0 bytes doc/src/images/declarative-qtlogo2.png | Bin 11023 -> 0 bytes doc/src/images/declarative-qtlogo3.png | Bin 4783 -> 0 bytes doc/src/images/declarative-qtlogo4.png | Bin 11241 -> 0 bytes doc/src/images/declarative-qtlogo5.png | Bin 3553 -> 0 bytes doc/src/images/declarative-qtlogo6.png | Bin 4763 -> 0 bytes .../graphicsitems/qdeclarativeimage.cpp | 193 ++++++++++++--------- 15 files changed, 109 insertions(+), 84 deletions(-) delete mode 100644 doc/src/images/declarative-image_fillMode.gif create mode 100644 doc/src/images/declarative-qtlogo-preserveaspectcrop.png create mode 100644 doc/src/images/declarative-qtlogo-preserveaspectfit.png create mode 100644 doc/src/images/declarative-qtlogo-stretch.png create mode 100644 doc/src/images/declarative-qtlogo-tile.png create mode 100644 doc/src/images/declarative-qtlogo-tilehorizontally.png create mode 100644 doc/src/images/declarative-qtlogo-tilevertically.png create mode 100644 doc/src/images/declarative-qtlogo.png delete mode 100644 doc/src/images/declarative-qtlogo1.png delete mode 100644 doc/src/images/declarative-qtlogo2.png delete mode 100644 doc/src/images/declarative-qtlogo3.png delete mode 100644 doc/src/images/declarative-qtlogo4.png delete mode 100644 doc/src/images/declarative-qtlogo5.png delete mode 100644 doc/src/images/declarative-qtlogo6.png diff --git a/doc/src/images/declarative-image_fillMode.gif b/doc/src/images/declarative-image_fillMode.gif deleted file mode 100644 index eb0a9af..0000000 Binary files a/doc/src/images/declarative-image_fillMode.gif and /dev/null differ diff --git a/doc/src/images/declarative-qtlogo-preserveaspectcrop.png b/doc/src/images/declarative-qtlogo-preserveaspectcrop.png new file mode 100644 index 0000000..64fb086 Binary files /dev/null and b/doc/src/images/declarative-qtlogo-preserveaspectcrop.png differ diff --git a/doc/src/images/declarative-qtlogo-preserveaspectfit.png b/doc/src/images/declarative-qtlogo-preserveaspectfit.png new file mode 100644 index 0000000..2585fa5 Binary files /dev/null and b/doc/src/images/declarative-qtlogo-preserveaspectfit.png differ diff --git a/doc/src/images/declarative-qtlogo-stretch.png b/doc/src/images/declarative-qtlogo-stretch.png new file mode 100644 index 0000000..32a0114 Binary files /dev/null and b/doc/src/images/declarative-qtlogo-stretch.png differ diff --git a/doc/src/images/declarative-qtlogo-tile.png b/doc/src/images/declarative-qtlogo-tile.png new file mode 100644 index 0000000..7d1b9d0 Binary files /dev/null and b/doc/src/images/declarative-qtlogo-tile.png differ diff --git a/doc/src/images/declarative-qtlogo-tilehorizontally.png b/doc/src/images/declarative-qtlogo-tilehorizontally.png new file mode 100644 index 0000000..367a8c7 Binary files /dev/null and b/doc/src/images/declarative-qtlogo-tilehorizontally.png differ diff --git a/doc/src/images/declarative-qtlogo-tilevertically.png b/doc/src/images/declarative-qtlogo-tilevertically.png new file mode 100644 index 0000000..68afafa Binary files /dev/null and b/doc/src/images/declarative-qtlogo-tilevertically.png differ diff --git a/doc/src/images/declarative-qtlogo.png b/doc/src/images/declarative-qtlogo.png new file mode 100644 index 0000000..940d159 Binary files /dev/null and b/doc/src/images/declarative-qtlogo.png differ diff --git a/doc/src/images/declarative-qtlogo1.png b/doc/src/images/declarative-qtlogo1.png deleted file mode 100644 index 940d159..0000000 Binary files a/doc/src/images/declarative-qtlogo1.png and /dev/null differ diff --git a/doc/src/images/declarative-qtlogo2.png b/doc/src/images/declarative-qtlogo2.png deleted file mode 100644 index b1d128a..0000000 Binary files a/doc/src/images/declarative-qtlogo2.png and /dev/null differ diff --git a/doc/src/images/declarative-qtlogo3.png b/doc/src/images/declarative-qtlogo3.png deleted file mode 100644 index d516524..0000000 Binary files a/doc/src/images/declarative-qtlogo3.png and /dev/null differ diff --git a/doc/src/images/declarative-qtlogo4.png b/doc/src/images/declarative-qtlogo4.png deleted file mode 100644 index 7c8aa64..0000000 Binary files a/doc/src/images/declarative-qtlogo4.png and /dev/null differ diff --git a/doc/src/images/declarative-qtlogo5.png b/doc/src/images/declarative-qtlogo5.png deleted file mode 100644 index b7b3513..0000000 Binary files a/doc/src/images/declarative-qtlogo5.png and /dev/null differ diff --git a/doc/src/images/declarative-qtlogo6.png b/doc/src/images/declarative-qtlogo6.png deleted file mode 100644 index 07a078f..0000000 Binary files a/doc/src/images/declarative-qtlogo6.png and /dev/null differ diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index aeddb15..88e8520 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -54,79 +54,36 @@ QT_BEGIN_NAMESPACE \brief The Image element allows you to add bitmaps to a scene. \inherits Item - Displays the image from the specified \l source. If a size is not specified explicitly, - the Image element will be sized to the loaded image. + An Image element displays a specified \l source image: - If the source resolves to a network resource, the image will be loaded asynchronously, - updating the \l progress and \l status properties appropriately. + \table + \o + \image declarative-qtlogo.png + \o + \qml + import Qt 4.7 + + Image { source: "qtlogo.png" } + \endqml + \endtable + + If a size is not specified explicitly, the Image element is sized to the loaded image. + Image elements can be stretched and tiled using the \l fillMode property. - Images which are available locally - will be loaded immediately, blocking the user interface. This is typically the - correct behavior for user interface elements. For large local images, which do not need - to be visible immediately, it may be preferable to enable \l asynchronous loading. - This will load the image in the background using a low priority thread. + If the image \l source is a network resource, the image is loaded asynchronous and the + \l progress and \l status properties are updated appropriately. Otherwise, if the image is + available locally, it is loaded immediately and the user interface is blocked until loading is + complete. (This is typically the correct behavior for user interface elements.) + For large local images, which do not need to be visible immediately, it may be preferable to + enable \l asynchronous loading. This loads the image in the background using a low priority thread. Images are cached and shared internally, so if several Image elements have the same source only one copy of the image will be loaded. - \bold Note: Images are often the greatest user of memory in QML UIs. It is recommended + \bold Note: Images are often the greatest user of memory in QML user interfaces. It is recommended that images which do not form part of the user interface have their size bounded via the \l sourceSize property. This is especially important for content that is loaded from external sources or provided by the user. - - The Image element supports untransformed, stretched and tiled images. - - For an explanation of stretching and tiling, see the fillMode property description. - - Examples: - \table - \row - \o \image declarative-qtlogo1.png - \o Untransformed - \qml - Image { source: "pics/qtlogo.png" } - \endqml - \row - \o \image declarative-qtlogo2.png - \o fillMode: Stretch (default) - \qml - Image { - width: 160 - height: 160 - source: "pics/qtlogo.png" - } - \endqml - \row - \o \image declarative-qtlogo3.png - \o fillMode: Tile - \qml - Image { - fillMode: Image.Tile - width: 160; height: 160 - source: "pics/qtlogo.png" - } - \endqml - \row - \o \image declarative-qtlogo6.png - \o fillMode: TileVertically - \qml - Image { - fillMode: Image.TileVertically - width: 160; height: 160 - source: "pics/qtlogo.png" - } - \endqml - \row - \o \image declarative-qtlogo5.png - \o fillMode: TileHorizontally - \qml - Image { - fillMode: Image.TileHorizontally - width: 160; height: 160 - source: "pics/qtlogo.png" - } - \endqml - \endtable */ /*! @@ -207,7 +164,77 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap) \o Image.TileHorizontally - the image is stretched vertically and tiled horizontally \endlist - \image declarative-image_fillMode.gif + \table + + \row + \o \image declarative-qtlogo-stretch.png + \o Stretch (default) + \qml + Image { + width: 130; height: 100 + smooth: true + source: "qtlogo.png" + } + \endqml + + \row + \o \image declarative-qtlogo-preserveaspectfit.png + \o PreserveAspectFit + \qml + Image { + width: 130; height: 100 + fillMode: Image.PreserveAspectFit + smooth: true + source: "qtlogo.png" + } + \endqml + + \row + \o \image declarative-qtlogo-preserveaspectcrop.png + \o PreserveAspectCrop + \qml + Image { + width: 130; height: 100 + fillMode: Image.PreserveAspectCrop + smooth: true + source: "qtlogo.png" + } + \endqml + + \row + \o \image declarative-qtlogo-tile.png + \o Tile + \qml + Image { + width: 120; height: 120 + fillMode: Image.Tile + source: "qtlogo.png" + } + \endqml + + \row + \o \image declarative-qtlogo-tilevertically.png + \o TileVertically + \qml + Image { + width: 120; height: 120 + fillMode: Image.TileVertically + source: "qtlogo.png" + } + \endqml + + \row + \o \image declarative-qtlogo-tilehorizontally.png + \o TileHorizontally + \qml + Image { + width: 120; height: 120 + fillMode: Image.TileHorizontally + source: "qtlogo.png" + } + \endqml + + \endtable */ QDeclarativeImage::FillMode QDeclarativeImage::fillMode() const { @@ -290,32 +317,30 @@ qreal QDeclarativeImage::paintedHeight() const /*! \qmlproperty QSize Image::sourceSize - This properties is the size of the loaded image, in pixels. + This property holds the size of the loaded image, in pixels. - 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 this value. - - If only one dimension of the size is set (and the other left at 0), the - unset dimension will be set in proportion to the set dimension to preserve - the source image aspect ratio. The fillMode is independent of this. - - Unlike setting the width and height properties, which merely scale the painting - of the image, this property affects the number of pixels stored. - - \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.} + This is used to control the storage used by a loaded image. Unlike + the width and height properties, which scale the painting of the image, this property + affects the number of pixels stored. + If the image's actual size is larger than the sourceSize, the image is scaled down. + If only one dimension of the size is set to greater than 0, the + other dimension is set in proportion to preserve the source image's aspect ratio. + (The \l fillMode is independent of this.) + 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 + determines the size of the loaded image regardless of intrinsic size. + 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 this property specifies. For some formats (currently only JPEG), the whole image will never actually be loaded into memory. + + \note \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.} - The example below will ensure that the size of the image in memory is + Here is an example that ensures the size of the image in memory is no larger than 1024x1024 pixels, regardless of the size of the Image element. \code @@ -327,8 +352,8 @@ qreal QDeclarativeImage::paintedHeight() const } \endcode - The example below will ensure that the memory used by the image is - no more than necessary to display the image at the size of the Image element. + The example below ensures the memory used by the image is no more than necessary + to display the image at the size of the Image element. Of course if the Image element is resized a costly reload will be required, so use this technique \e only when the Image size is fixed. -- cgit v0.12 From 01fbf55727678509f87523ef2ddda1d21d4ac2ab Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 12 May 2010 17:02:14 +1000 Subject: Correctly assign bool to variant properties QTBUG-10623 --- src/declarative/qml/qdeclarativecompiler.cpp | 4 ++++ src/declarative/qml/qdeclarativeinstruction.cpp | 3 +++ src/declarative/qml/qdeclarativeinstruction_p.h | 1 + src/declarative/qml/qdeclarativevme.cpp | 10 ++++++++++ .../qdeclarativelanguage/data/assignLiteralToVariant.qml | 2 ++ .../qdeclarativelanguage/tst_qdeclarativelanguage.cpp | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 6d420a7..a43b9ac 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -352,6 +352,10 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop, instr.storeDouble.propertyIndex = prop.propertyIndex(); instr.storeDouble.value = n; } + } else if(v->value.isBoolean()) { + instr.type = QDeclarativeInstruction::StoreVariantBool; + instr.storeBool.propertyIndex = prop.propertyIndex(); + instr.storeBool.value = v->value.asBoolean(); } else { instr.type = QDeclarativeInstruction::StoreVariant; instr.storeString.propertyIndex = prop.propertyIndex(); diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp index 99f1cc8..0236950 100644 --- a/src/declarative/qml/qdeclarativeinstruction.cpp +++ b/src/declarative/qml/qdeclarativeinstruction.cpp @@ -136,6 +136,9 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx) case QDeclarativeInstruction::StoreVariantDouble: qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value; break; + case QDeclarativeInstruction::StoreVariantBool: + qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value; + break; case QDeclarativeInstruction::StoreObject: qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex; break; diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h index c09b157..dc5f2f8 100644 --- a/src/declarative/qml/qdeclarativeinstruction_p.h +++ b/src/declarative/qml/qdeclarativeinstruction_p.h @@ -116,6 +116,7 @@ public: StoreVariant, /* storeString */ StoreVariantInteger, /* storeInteger */ StoreVariantDouble, /* storeDouble */ + StoreVariantBool, /* storeBool */ StoreObject, /* storeObject */ StoreVariantObject, /* storeObject */ StoreInterface, /* storeObject */ diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index 3e63e24..8ba79a6 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -360,6 +360,16 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack &stack, } break; + case QDeclarativeInstruction::StoreVariantBool: + { + QObject *target = stack.top(); + QVariant v(instr.storeBool.value); + void *a[] = { &v, 0, &status, &flags }; + QMetaObject::metacall(target, QMetaObject::WriteProperty, + instr.storeString.propertyIndex, a); + } + break; + case QDeclarativeInstruction::StoreString: { QObject *target = stack.top(); diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml index 5af3d6e..bac704e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml @@ -10,5 +10,7 @@ QtObject { property variant test7: "10x10" property variant test8: "100,100,100" property variant test9: String("#FF008800") + property variant test10: true + property variant test11: false } diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index ff03005..6b070f5 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -536,6 +536,8 @@ void tst_qdeclarativelanguage::assignLiteralToVariant() QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF); QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D); QCOMPARE(object->property("test9").userType(), (int)QVariant::String); + QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool); + QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool); QVERIFY(object->property("test1") == QVariant(1)); QVERIFY(object->property("test2") == QVariant((double)1.7)); @@ -546,6 +548,8 @@ void tst_qdeclarativelanguage::assignLiteralToVariant() QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10))); QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100))); QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800")))); + QVERIFY(object->property("test10") == QVariant(bool(true))); + QVERIFY(object->property("test11") == QVariant(bool(false))); delete object; } -- cgit v0.12 From ad7988629c47a5fc1a671d36d9cdaed630f5e7f2 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 12 May 2010 09:24:39 +0200 Subject: Stabilize tst_QWidgetAction::visibilityUpdate --- tests/auto/qwidgetaction/tst_qwidgetaction.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp index 5dfcd43..53dc4b5 100644 --- a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp +++ b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp @@ -51,6 +51,8 @@ #include #include +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -190,8 +192,8 @@ void tst_QWidgetAction::visibilityUpdate() QVERIFY(action->isVisible()); action->setVisible(false); - QTest::qWait(100); //the call to hide is delayed by the toolbar layout - QVERIFY(!combo->isVisible()); + qApp->processEvents(); //the call to hide is delayed by the toolbar layout + QTRY_VERIFY(!combo->isVisible()); delete action; // action also deletes combo -- cgit v0.12 From a81cc0add7f9517dfbd31bb9988ab6bdc08c2b96 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 12 May 2010 10:36:18 +0300 Subject: Provide a way to specify the final sis name with createpackage/make sis The -n parameter can be used to specify the final sis name when using createpackage script or "make sis" with QT_SIS_OPTIONS. Task-number: QTBUG-9400 Reviewed-by: Janne Koskinen --- bin/createpackage.pl | 29 ++++++++++++++++++++++------- doc/src/platforms/symbian-introduction.qdoc | 5 ++++- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/bin/createpackage.pl b/bin/createpackage.pl index e844767..7453ba5 100755 --- a/bin/createpackage.pl +++ b/bin/createpackage.pl @@ -69,15 +69,17 @@ Convenience script for creating signed packages you can install on your phone. Usage: createpackage.pl [options] templatepkg [target]-[platform] [certificate key [passphrase]] Where supported options are as follows: - [-i|install] = Install the package right away using PC suite + [-i|install] = Install the package right away using PC suite. [-p|preprocess] = Only preprocess the template .pkg file. - [-c|certfile=] = The file containing certificate information for signing. + [-c|certfile ] = The file containing certificate information for signing. The file can have several certificates, each specified in separate line. The certificate, key and passphrase in line must be ';' separated. Lines starting with '#' are treated as a comments. Also empty lines are ignored. The paths in can be absolute or relative to . - [-u|unsigned] = Preserves the unsigned package + [-u|unsigned] = Preserves the unsigned package. + [-s|stub] = Generates stub sis for ROM. + [-n|sisname ] = Specifies the final sis name. Where parameters are as follows: templatepkg = Name of .pkg file template target = Either debug or release @@ -118,12 +120,14 @@ my $preprocessonly = ""; my $certfile = ""; my $preserveUnsigned = ""; my $stub = ""; +my $signed_sis_name = ""; unless (GetOptions('i|install' => \$install, 'p|preprocess' => \$preprocessonly, 'c|certfile=s' => \$certfile, 'u|unsigned' => \$preserveUnsigned, - 's|stub' => \$stub,)){ + 's|stub' => \$stub, + 'n|sisname=s' => \$signed_sis_name,)) { Usage(); } @@ -162,10 +166,21 @@ $pkgoutputbasename = $pkgoutputbasename; # Store output file names to variables my $pkgoutput = $pkgoutputbasename.".pkg"; -my $sisoutputbasename = $pkgoutputbasename; -$sisoutputbasename =~ s/_$targetplatform//g; +my $sisoutputbasename; +if ($signed_sis_name eq "") { + $sisoutputbasename = $pkgoutputbasename; + $sisoutputbasename =~ s/_$targetplatform//g; + $signed_sis_name = $sisoutputbasename.".sis"; +} else { + $sisoutputbasename = $signed_sis_name; + if ($sisoutputbasename =~ m/(\.sis$|\.sisx$)/i) { + $sisoutputbasename =~ s/$1//i; + } else { + $signed_sis_name = $signed_sis_name.".sis"; + } +} + my $unsigned_sis_name = $sisoutputbasename."_unsigned.sis"; -my $signed_sis_name = $sisoutputbasename.".sis"; my $stub_sis_name = $sisoutputbasename."_stub.sis"; # Store some utility variables diff --git a/doc/src/platforms/symbian-introduction.qdoc b/doc/src/platforms/symbian-introduction.qdoc index 591d6f1..6ffc568 100644 --- a/doc/src/platforms/symbian-introduction.qdoc +++ b/doc/src/platforms/symbian-introduction.qdoc @@ -191,7 +191,10 @@ \table \row \o -i \o Install the package right away using PC suite. \row \o -p \o Only preprocess the template \c .pkg file. - \row \o -c= \o Read certificate information from a file. + \row \o -c \o Read certificate information from a file. + \row \o -u \o Preserves unsigned package. + \row \o -s \o Generates stub sis for ROM. + \row \o -n \o Specifies the final sis name. \endtable Execute the \c{createpackage.pl} script without any -- cgit v0.12 From 8902980cec40b25ec85ec20f79858224f68f73b6 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 12 May 2010 10:14:02 +0200 Subject: QNAM HTTP: Only force read when actual bytes available This should fix the problem where we were showing a warning that didn't matter anyway. Task-number: QTBUG-9619 --- src/network/access/qhttpnetworkconnectionchannel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 22dd5cb..6a13669 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -291,7 +291,8 @@ bool QHttpNetworkConnectionChannel::sendRequest() // ensure we try to receive a reply in all cases, even if _q_readyRead_ hat not been called // this is needed if the sends an reply before we have finished sending the request. In that // case receiveReply had been called before but ignored the server reply - QMetaObject::invokeMethod(this, "_q_receiveReply", Qt::QueuedConnection); + if (socket->bytesAvailable()) + QMetaObject::invokeMethod(this, "_q_receiveReply", Qt::QueuedConnection); break; } case QHttpNetworkConnectionChannel::ReadingState: -- cgit v0.12 From bf3544fb5cb04d0271fb92bdb683e9b4a2a17816 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 12 May 2010 10:04:52 +0100 Subject: Compilation fix for Metrowerks compiler Compiler was failing to disambiguate the following overloads: pow(double, double) pow(float, float) Reviewed-by: mread --- demos/spectrum/app/levelmeter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/spectrum/app/levelmeter.cpp b/demos/spectrum/app/levelmeter.cpp index eb37684..39e43c9 100644 --- a/demos/spectrum/app/levelmeter.cpp +++ b/demos/spectrum/app/levelmeter.cpp @@ -87,7 +87,7 @@ void LevelMeter::reset() void LevelMeter::levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples) { // Smooth the RMS signal - const qreal smooth = pow(0.9, static_cast(numSamples) / 256); // TODO: remove this magic number + const qreal smooth = pow(qreal(0.9), static_cast(numSamples) / 256); // TODO: remove this magic number m_rmsLevel = (m_rmsLevel * smooth) + (rmsLevel * (1.0 - smooth)); if (peakLevel > m_decayedPeakLevel) { -- cgit v0.12 From d3c54f401d1b8aeab4a911b4be9bcbdd99056e1f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 12 May 2010 11:37:03 +0200 Subject: fix install of default mkspec from shadow build under windows Patch-by: Lincoln Ramsay Reviewed-by: joerg Task-number: QTBUG-10619 --- projects.pro | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects.pro b/projects.pro index d405a5b..c9e77cb 100644 --- a/projects.pro +++ b/projects.pro @@ -154,6 +154,10 @@ unix { DEFAULT_QMAKESPEC ~= s,^.*mkspecs/,,g mkspecs.commands += $(DEL_FILE) $(INSTALL_ROOT)$$mkspecs.path/default; $(SYMLINK) $$DEFAULT_QMAKESPEC $(INSTALL_ROOT)$$mkspecs.path/default } +win32:!equals(QT_BUILD_TREE, $$QT_SOURCE_TREE) { + # When shadow building on Windows, the default mkspec only exists in the build tree. + mkspecs.files += $$QT_BUILD_TREE/mkspecs/default +} INSTALLS += mkspecs false:macx { #mac install location -- cgit v0.12 From 9b6041bf62cfd2b0be62134ff6ee0fd488ce5921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 12 May 2010 12:37:47 +0200 Subject: Modified QPainter and QPixmap benchmarks to use raster pixmaps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These benchmarks are not written in a way that supports robust benchmarking of asynchronous pixmap backends. Reviewed-by: Bjørn Erik Nilsen --- tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp | 38 +++++++++-- .../gui/painting/qpainter/tst_qpainter.cpp | 79 +++++++++++++++------- 2 files changed, 88 insertions(+), 29 deletions(-) diff --git a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp index 9ffbefb..8e9de4a 100644 --- a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp @@ -43,6 +43,7 @@ #include #include #include +#include class tst_QPixmap : public QObject { @@ -67,6 +68,31 @@ Q_DECLARE_METATYPE(QImage::Format) Q_DECLARE_METATYPE(Qt::AspectRatioMode) Q_DECLARE_METATYPE(Qt::TransformationMode) +QPixmap rasterPixmap(int width, int height) +{ + QPixmapData *data = + new QRasterPixmapData(QPixmapData::PixmapType); + + data->resize(width, height); + + return QPixmap(data); +} + +QPixmap rasterPixmap(const QSize &size) +{ + return rasterPixmap(size.width(), size.height()); +} + +QPixmap rasterPixmap(const QImage &image) +{ + QPixmapData *data = + new QRasterPixmapData(QPixmapData::PixmapType); + + data->fromImage(image, Qt::AutoColor); + + return QPixmap(data); +} + tst_QPixmap::tst_QPixmap() { } @@ -90,7 +116,7 @@ void tst_QPixmap::fill() QFETCH(int, height); const QColor color = opaque ? QColor(255, 0, 0) : QColor(255, 0, 0, 200); - QPixmap pixmap(width, height); + QPixmap pixmap = rasterPixmap(width, height); QBENCHMARK { pixmap.fill(color); @@ -126,8 +152,8 @@ void tst_QPixmap::scaled() QFETCH(Qt::AspectRatioMode, ratioMode); QFETCH(Qt::TransformationMode, transformMode); - QPixmap opaque(size); - QPixmap transparent(size); + QPixmap opaque = rasterPixmap(size); + QPixmap transparent = rasterPixmap(size); opaque.fill(QColor(255, 0, 0)); transparent.fill(QColor(255, 0, 0, 200)); @@ -180,8 +206,8 @@ void tst_QPixmap::transformed() QFETCH(QTransform, transform); QFETCH(Qt::TransformationMode, transformMode); - QPixmap opaque(size); - QPixmap transparent(size); + QPixmap opaque = rasterPixmap(size); + QPixmap transparent = rasterPixmap(size); opaque.fill(QColor(255, 0, 0)); transparent.fill(QColor(255, 0, 0, 200)); @@ -209,7 +235,7 @@ void tst_QPixmap::mask() { QFETCH(QSize, size); - QPixmap src(size); + QPixmap src = rasterPixmap(size); src.fill(Qt::transparent); { QPainter p(&src); diff --git a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp index d570bb3..318b671 100644 --- a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp @@ -50,6 +50,8 @@ #define M_PI 3.14159265358979323846 #endif +#include + Q_DECLARE_METATYPE(QLine) Q_DECLARE_METATYPE(QRect) Q_DECLARE_METATYPE(QSize) @@ -125,6 +127,32 @@ struct PrimitiveSet { }; +QPixmap rasterPixmap(int width, int height) +{ + QPixmapData *data = + new QRasterPixmapData(QPixmapData::PixmapType); + + data->resize(width, height); + + return QPixmap(data); +} + +QPixmap rasterPixmap(const QSize &size) +{ + return rasterPixmap(size.width(), size.height()); +} + +QPixmap rasterPixmap(const QImage &image) +{ + QPixmapData *data = + new QRasterPixmapData(QPixmapData::PixmapType); + + data->fromImage(image, Qt::AutoColor); + + return QPixmap(data); +} + + class tst_QPainter : public QObject { Q_OBJECT @@ -222,7 +250,8 @@ private: QPaintDevice *surface() { - return new QPixmap(1024, 1024); + m_pixmap = rasterPixmap(1024, 1024); + return &m_pixmap; } @@ -233,6 +262,7 @@ private: PrimitiveSet m_primitives_100; PrimitiveSet m_primitives_1000; + QPixmap m_pixmap; QPaintDevice *m_surface; QPainter m_painter; @@ -490,7 +520,7 @@ void tst_QPainter::setupBrushes() void tst_QPainter::beginAndEnd() { - QPixmap pixmap(100, 100); + QPixmap pixmap = rasterPixmap(100, 100); QBENCHMARK { QPainter p; @@ -505,10 +535,11 @@ void tst_QPainter::drawLine() QFETCH(QPen, pen); const int offset = 5; - QPixmap pixmapUnclipped(qMin(line.x1(), line.x2()) - + 2*offset + qAbs(line.dx()), - qMin(line.y1(), line.y2()) - + 2*offset + qAbs(line.dy())); + QPixmap pixmapUnclipped = + rasterPixmap(qMin(line.x1(), line.x2()) + + 2*offset + qAbs(line.dx()), + qMin(line.y1(), line.y2()) + + 2*offset + qAbs(line.dy())); pixmapUnclipped.fill(Qt::white); QPainter p(&pixmapUnclipped); @@ -535,10 +566,11 @@ void tst_QPainter::drawLine_clipped() QFETCH(QPen, pen); const int offset = 5; - QPixmap pixmapClipped(qMin(line.x1(), line.x2()) - + 2*offset + qAbs(line.dx()), - qMin(line.y1(), line.y2()) - + 2*offset + qAbs(line.dy())); + QPixmap pixmapClipped + = rasterPixmap(qMin(line.x1(), line.x2()) + + 2*offset + qAbs(line.dx()), + qMin(line.y1(), line.y2()) + + 2*offset + qAbs(line.dy())); const QRect clip = QRect(line.p1(), line.p2()).normalized(); @@ -569,10 +601,11 @@ void tst_QPainter::drawLine_antialiased_clipped() QFETCH(QPen, pen); const int offset = 5; - QPixmap pixmapClipped(qMin(line.x1(), line.x2()) - + 2*offset + qAbs(line.dx()), - qMin(line.y1(), line.y2()) - + 2*offset + qAbs(line.dy())); + QPixmap pixmapClipped + = rasterPixmap(qMin(line.x1(), line.x2()) + + 2*offset + qAbs(line.dx()), + qMin(line.y1(), line.y2()) + + 2*offset + qAbs(line.dy())); const QRect clip = QRect(line.p1(), line.p2()).normalized(); @@ -696,8 +729,8 @@ void tst_QPainter::drawPixmap() QImage sourceImage = createImage(type, size).convertToFormat(sourceFormat); QImage targetImage(size, targetFormat); - QPixmap sourcePixmap = QPixmap::fromImage(sourceImage); - QPixmap targetPixmap = QPixmap::fromImage(targetImage); + QPixmap sourcePixmap = rasterPixmap(sourceImage); + QPixmap targetPixmap = rasterPixmap(targetImage); QPainter p(&targetPixmap); @@ -759,10 +792,10 @@ void tst_QPainter::compositionModes() QFETCH(QSize, size); QFETCH(QColor, color); - QPixmap src(size); + QPixmap src = rasterPixmap(size); src.fill(color); - QPixmap dest(size); + QPixmap dest = rasterPixmap(size); if (mode < QPainter::RasterOp_SourceOrDestination) color.setAlpha(127); // porter-duff needs an alpha channel dest.fill(color); @@ -844,11 +877,11 @@ void tst_QPainter::drawTiledPixmap() QFETCH(QColor, color); QFETCH(QPainter::RenderHint, renderHint); - QPixmap src(srcSize); + QPixmap src = rasterPixmap(srcSize); src.fill(color); const QRect dstRect = transform.mapRect(QRect(QPoint(), dstSize)); - QPixmap dst(dstRect.right() + 5, dstRect.bottom() + 5); + QPixmap dst = rasterPixmap(dstRect.right() + 5, dstRect.bottom() + 5); QPainter p(&dst); p.setTransform(transform); p.setRenderHint(renderHint); @@ -1411,7 +1444,7 @@ void tst_QPainter::drawBorderPixmapRoundedRect() rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius); else rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); - QPixmap rectPixmap = QPixmap::fromImage(rectImage); + QPixmap rectPixmap = rasterPixmap(rectImage); //setup surface QImage surface(100, 100, QImage::Format_RGB16); @@ -1466,7 +1499,7 @@ void tst_QPainter::drawScaledBorderPixmapRoundedRect() else rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); - QPixmap rectPixmap = QPixmap::fromImage(rectImage); + QPixmap rectPixmap = rasterPixmap(rectImage); //setup surface QImage surface(400, 400, QImage::Format_RGB16); @@ -1522,7 +1555,7 @@ void tst_QPainter::drawTransformedBorderPixmapRoundedRect() else rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); - QPixmap rectPixmap = QPixmap::fromImage(rectImage); + QPixmap rectPixmap = rasterPixmap(rectImage); //setup surface QImage surface(400, 400, QImage::Format_RGB16); -- cgit v0.12 From 8191aae91f97c22545750460c7a7d5ef1a7288bd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 12 May 2010 12:55:03 +0200 Subject: Updated WebKit to dc5821c3df2ef60456d85263160852f5335cf946 Integrated changes: || || [Qt] fast/text/find-hidden-text.html || || || Rename window.media to window.styleMedia || || || Need to call FrameView::scrollPositionChanged when changing the scroll position when the ScrollView does not have a platformWidget || || || [Qt] fast/frames/flattening/frameset-flattening-subframesets.html fails intermittently on Qt bot || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 99 ++++++++++ src/3rdparty/webkit/WebCore/WebCore.gypi | 16 +- src/3rdparty/webkit/WebCore/WebCore.pri | 4 +- src/3rdparty/webkit/WebCore/WebCore.pro | 4 +- src/3rdparty/webkit/WebCore/css/Media.cpp | 77 -------- src/3rdparty/webkit/WebCore/css/Media.h | 54 ------ src/3rdparty/webkit/WebCore/css/Media.idl | 31 ---- src/3rdparty/webkit/WebCore/css/StyleMedia.cpp | 77 ++++++++ src/3rdparty/webkit/WebCore/css/StyleMedia.h | 55 ++++++ src/3rdparty/webkit/WebCore/css/StyleMedia.idl | 32 ++++ .../webkit/WebCore/generated/JSDOMWindow.cpp | 10 +- .../webkit/WebCore/generated/JSDOMWindow.h | 2 +- src/3rdparty/webkit/WebCore/generated/JSMedia.cpp | 201 --------------------- src/3rdparty/webkit/WebCore/generated/JSMedia.h | 87 --------- .../webkit/WebCore/generated/JSStyleMedia.cpp | 201 +++++++++++++++++++++ .../webkit/WebCore/generated/JSStyleMedia.h | 87 +++++++++ src/3rdparty/webkit/WebCore/page/AbstractView.idl | 2 +- src/3rdparty/webkit/WebCore/page/DOMWindow.cpp | 6 +- src/3rdparty/webkit/WebCore/page/DOMWindow.h | 8 +- src/3rdparty/webkit/WebCore/page/DOMWindow.idl | 2 +- src/3rdparty/webkit/WebCore/page/FrameView.h | 2 +- .../webkit/WebCore/platform/ScrollView.cpp | 1 + src/3rdparty/webkit/WebCore/platform/ScrollView.h | 3 + .../WebCore/platform/qt/ScrollbarThemeQt.cpp | 2 +- 26 files changed, 586 insertions(+), 481 deletions(-) delete mode 100644 src/3rdparty/webkit/WebCore/css/Media.cpp delete mode 100644 src/3rdparty/webkit/WebCore/css/Media.h delete mode 100644 src/3rdparty/webkit/WebCore/css/Media.idl create mode 100644 src/3rdparty/webkit/WebCore/css/StyleMedia.cpp create mode 100644 src/3rdparty/webkit/WebCore/css/StyleMedia.h create mode 100644 src/3rdparty/webkit/WebCore/css/StyleMedia.idl delete mode 100644 src/3rdparty/webkit/WebCore/generated/JSMedia.cpp delete mode 100644 src/3rdparty/webkit/WebCore/generated/JSMedia.h create mode 100644 src/3rdparty/webkit/WebCore/generated/JSStyleMedia.cpp create mode 100644 src/3rdparty/webkit/WebCore/generated/JSStyleMedia.h diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 65cfdda..d8b4b32 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -dc5821c3df2ef60456d85263160852f5335cf946 +57d10d5c05e59bbf7de8189ff47dd18d1be996dc diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 24f855b..c8c2aa3 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - b4aa5e1ddc41edab895132aba3cc66d9d7129444 + dc5821c3df2ef60456d85263160852f5335cf946 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index ee42878..76b4eff 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,102 @@ +2010-04-29 James Robinson + + Reviewed by Simon Fraser. + + Calls FrameView::scrollPositionChanged whenever a ScrollView is scrolled + https://bugs.webkit.org/show_bug.cgi?id=38286 + + When a ScrollView's scroll position is changed, we have to call + FrameView::scrollPositionChanged to generate repaint invalidation for + fixed position elements. This ends up getting called indirectly when + the ScrollView has a platformWidget through the port layer + (see WebHTMLView.mm's _frameOrBoundsChanged method for how the mac + port does it) but not when there is no platformWidget. + + This is tested by the fast/repaint/fixed-* tests when run in pixel + mode. + + Test: fast/repaint/fixed-move-after-keyboard-scroll.html + + * page/FrameView.h: + * platform/ScrollView.cpp: + (WebCore::ScrollView::valueChanged): + * platform/ScrollView.h: + (WebCore::ScrollView::scrollPositionChanged): + +2010-04-23 Kenneth Rohde Christiansen + + Unreviewed build fix. + + Change Media to StyleMedia + + * DerivedSources.make: + +2010-04-22 Kenneth Rohde Christiansen + + Reviewed by Laszlo Gombos. + + Rename window.media to window.styleMedia + https://bugs.webkit.org/show_bug.cgi?id=36187 + + Rename the interface Media to StyleMedia as required by the + new CSSOM View spec. + + * Android.derived.jscbindings.mk: + * Android.derived.v8bindings.mk: + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.pri: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * css/Media.cpp: Removed. + * css/Media.h: Removed. + * css/Media.idl: Removed. + * css/StyleMedia.cpp: Added. + (WebCore::StyleMedia::StyleMedia): + (WebCore::StyleMedia::type): + (WebCore::StyleMedia::matchMedium): + * css/StyleMedia.h: Added. + (WebCore::StyleMedia::create): + (WebCore::StyleMedia::disconnectFrame): + * css/StyleMedia.idl: Added. + * page/DOMWindow.cpp: + (WebCore::DOMWindow::styleMedia): + * page/DOMWindow.h: + (WebCore::DOMWindow::optionalMedia): + * page/DOMWindow.idl: + +2010-04-22 Kenneth Rohde Christiansen + + Reviewed by Simon Fraser. + + Rename window.media to window.styleMedia + https://bugs.webkit.org/show_bug.cgi?id=36187 + + It has been defined that the AbstractView media extension + defined in the CSSOM View spec should be renamed to styleMedia. + This patch does that and updates the current layout tests + making use of it. + + * page/AbstractView.idl: + * page/DOMWindow.cpp: + (WebCore::DOMWindow::styleMedia): + * page/DOMWindow.h: + * page/DOMWindow.idl: + +2010-05-11 Benjamin Poulain + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] fast/text/find-hidden-text.html + https://bugs.webkit.org/show_bug.cgi?id=32922 + + Use the real page step for populating the QStyleOption otherwhise + the size can be negative, which can break the QStyle used. + + * platform/qt/ScrollbarThemeQt.cpp: + (WebCore::styleOptionSlider): + 2010-05-03 Antonio Gomes Reviewed by Kenneth Christiansen. diff --git a/src/3rdparty/webkit/WebCore/WebCore.gypi b/src/3rdparty/webkit/WebCore/WebCore.gypi index 701ad90..1e92f1f 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.gypi +++ b/src/3rdparty/webkit/WebCore/WebCore.gypi @@ -18,10 +18,10 @@ 'css/CSSVariablesDeclaration.idl', 'css/CSSVariablesRule.idl', 'css/Counter.idl', - 'css/Media.idl', 'css/MediaList.idl', - 'css/RGBColor.idl', 'css/Rect.idl', + 'css/RGBColor.idl', + 'css/StyleMedia.idl', 'css/StyleSheet.idl', 'css/StyleSheetList.idl', 'css/WebKitCSSKeyframeRule.idl', @@ -1003,33 +1003,33 @@ 'css/FontValue.h', 'css/MediaFeatureNames.cpp', 'css/MediaFeatureNames.h', - 'css/Media.cpp', - 'css/Media.h', 'css/MediaList.cpp', 'css/MediaList.h', 'css/MediaQuery.cpp', - 'css/MediaQuery.h', 'css/MediaQueryEvaluator.cpp', 'css/MediaQueryEvaluator.h', 'css/MediaQueryExp.cpp', 'css/MediaQueryExp.h', + 'css/MediaQuery.h', 'css/Pair.h', 'css/Rect.h', 'css/RGBColor.cpp', 'css/RGBColor.h', - 'css/SVGCSSComputedStyleDeclaration.cpp', - 'css/SVGCSSParser.cpp', - 'css/SVGCSSStyleSelector.cpp', 'css/ShadowValue.cpp', 'css/ShadowValue.h', 'css/StyleBase.cpp', 'css/StyleBase.h', 'css/StyleList.cpp', 'css/StyleList.h', + 'css/StyleMedia.cpp', + 'css/StyleMedia.h', 'css/StyleSheet.cpp', 'css/StyleSheet.h', 'css/StyleSheetList.cpp', 'css/StyleSheetList.h', + 'css/SVGCSSComputedStyleDeclaration.cpp', + 'css/SVGCSSParser.cpp', + 'css/SVGCSSStyleSelector.cpp', 'css/WebKitCSSKeyframeRule.cpp', 'css/WebKitCSSKeyframeRule.h', 'css/WebKitCSSKeyframesRule.cpp', diff --git a/src/3rdparty/webkit/WebCore/WebCore.pri b/src/3rdparty/webkit/WebCore/WebCore.pri index ad514a2..5f5987f 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pri +++ b/src/3rdparty/webkit/WebCore/WebCore.pri @@ -227,10 +227,10 @@ IDL_BINDINGS += \ css/CSSValueList.idl \ css/CSSVariablesDeclaration.idl \ css/CSSVariablesRule.idl \ - css/Media.idl \ css/MediaList.idl \ - css/RGBColor.idl \ css/Rect.idl \ + css/RGBColor.idl \ + css/StyleMedia.idl \ css/StyleSheet.idl \ css/StyleSheetList.idl \ css/WebKitCSSKeyframeRule.idl \ diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index e42cd8e..254d17b 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -431,7 +431,6 @@ SOURCES += \ css/FontFamilyValue.cpp \ css/FontValue.cpp \ css/MediaFeatureNames.cpp \ - css/Media.cpp \ css/MediaList.cpp \ css/MediaQuery.cpp \ css/MediaQueryEvaluator.cpp \ @@ -440,6 +439,7 @@ SOURCES += \ css/ShadowValue.cpp \ css/StyleBase.cpp \ css/StyleList.cpp \ + css/StyleMedia.cpp \ css/StyleSheet.cpp \ css/StyleSheetList.cpp \ css/WebKitCSSKeyframeRule.cpp \ @@ -1145,7 +1145,6 @@ HEADERS += \ css/FontFamilyValue.h \ css/FontValue.h \ css/MediaFeatureNames.h \ - css/Media.h \ css/MediaList.h \ css/MediaQueryEvaluator.h \ css/MediaQueryExp.h \ @@ -1154,6 +1153,7 @@ HEADERS += \ css/ShadowValue.h \ css/StyleBase.h \ css/StyleList.h \ + css/StyleMedia.h \ css/StyleSheet.h \ css/StyleSheetList.h \ css/WebKitCSSKeyframeRule.h \ diff --git a/src/3rdparty/webkit/WebCore/css/Media.cpp b/src/3rdparty/webkit/WebCore/css/Media.cpp deleted file mode 100644 index e238602..0000000 --- a/src/3rdparty/webkit/WebCore/css/Media.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include "Media.h" -#include "CSSStyleSelector.h" -#include "Frame.h" -#include "FrameView.h" -#include "MediaList.h" -#include "MediaQueryEvaluator.h" - -namespace WebCore { - -Media::Media(Frame* frame) - : m_frame(frame) -{ -} - -String Media::type() const -{ - FrameView* view = m_frame ? m_frame->view() : 0; - if (view) - return view->mediaType(); - - return String(); -} - -bool Media::matchMedium(const String& query) const -{ - if (!m_frame) - return false; - - Document* document = m_frame->document(); - ASSERT(document); - Element* documentElement = document->documentElement(); - ASSERT(documentElement); - - CSSStyleSelector* styleSelector = document->styleSelector(); - if (!styleSelector) - return false; - - RefPtr rootStyle = styleSelector->styleForElement(documentElement, 0 /*defaultParent*/, false /*allowSharing*/, true /*resolveForRootDefault*/); - RefPtr media = MediaList::create(); - - ExceptionCode ec = 0; - media->setMediaText(query, ec); - if (ec) - return false; - - MediaQueryEvaluator screenEval(type(), m_frame, rootStyle.get()); - return screenEval.eval(media.get()); -} - -} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/css/Media.h b/src/3rdparty/webkit/WebCore/css/Media.h deleted file mode 100644 index ee6961b..0000000 --- a/src/3rdparty/webkit/WebCore/css/Media.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef Media_h -#define Media_h - -#include "DOMWindow.h" - -namespace WebCore { - -class Media : public RefCounted { -public: - static PassRefPtr create(Frame* frame) - { - return adoptRef(new Media(frame)); - } - - void disconnectFrame() { m_frame = 0; } - - String type() const; - - bool matchMedium(const String&) const; - -private: - Media(Frame*); - - Frame* m_frame; -}; - -} // namespace - -#endif // Media_h diff --git a/src/3rdparty/webkit/WebCore/css/Media.idl b/src/3rdparty/webkit/WebCore/css/Media.idl deleted file mode 100644 index 1bf5900..0000000 --- a/src/3rdparty/webkit/WebCore/css/Media.idl +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -module view { - interface Media { - readonly attribute DOMString type; - boolean matchMedium(in DOMString mediaquery); - }; -} diff --git a/src/3rdparty/webkit/WebCore/css/StyleMedia.cpp b/src/3rdparty/webkit/WebCore/css/StyleMedia.cpp new file mode 100644 index 0000000..6cb662f --- /dev/null +++ b/src/3rdparty/webkit/WebCore/css/StyleMedia.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "StyleMedia.h" + +#include "CSSStyleSelector.h" +#include "Frame.h" +#include "FrameView.h" +#include "MediaList.h" +#include "MediaQueryEvaluator.h" + +namespace WebCore { + +StyleMedia::StyleMedia(Frame* frame) + : m_frame(frame) +{ +} + +String StyleMedia::type() const +{ + FrameView* view = m_frame ? m_frame->view() : 0; + if (view) + return view->mediaType(); + + return String(); +} + +bool StyleMedia::matchMedium(const String& query) const +{ + if (!m_frame) + return false; + + Document* document = m_frame->document(); + ASSERT(document); + Element* documentElement = document->documentElement(); + ASSERT(documentElement); + + CSSStyleSelector* styleSelector = document->styleSelector(); + if (!styleSelector) + return false; + + RefPtr rootStyle = styleSelector->styleForElement(documentElement, 0 /*defaultParent*/, false /*allowSharing*/, true /*resolveForRootDefault*/); + RefPtr media = MediaList::create(); + + ExceptionCode ec = 0; + media->setMediaText(query, ec); + if (ec) + return false; + + MediaQueryEvaluator screenEval(type(), m_frame, rootStyle.get()); + return screenEval.eval(media.get()); +} + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/css/StyleMedia.h b/src/3rdparty/webkit/WebCore/css/StyleMedia.h new file mode 100644 index 0000000..761e6a3 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/css/StyleMedia.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef StyleMedia_h +#define StyleMedia_h + +#include "DOMWindow.h" + +namespace WebCore { + +class StyleMedia : public RefCounted { +public: + static PassRefPtr create(Frame* frame) + { + return adoptRef(new StyleMedia(frame)); + } + + void disconnectFrame() { m_frame = 0; } + + String type() const; + + bool matchMedium(const String&) const; + +private: + StyleMedia(Frame*); + + Frame* m_frame; +}; + +} // namespace + +#endif // StyleMedia_h diff --git a/src/3rdparty/webkit/WebCore/css/StyleMedia.idl b/src/3rdparty/webkit/WebCore/css/StyleMedia.idl new file mode 100644 index 0000000..7be35cc --- /dev/null +++ b/src/3rdparty/webkit/WebCore/css/StyleMedia.idl @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +module view { + interface StyleMedia { + readonly attribute DOMString type; + boolean matchMedium(in DOMString mediaquery); + }; +} diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp index 04238bc..11dfd2e 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp @@ -152,7 +152,6 @@ #include "JSHTMLVideoElement.h" #include "JSImageData.h" #include "JSKeyboardEvent.h" -#include "JSMedia.h" #include "JSMediaError.h" #include "JSMediaList.h" #include "JSMessageChannel.h" @@ -299,6 +298,7 @@ #include "JSSharedWorker.h" #include "JSStorage.h" #include "JSStorageEvent.h" +#include "JSStyleMedia.h" #include "JSStyleSheet.h" #include "JSStyleSheetList.h" #include "JSText.h" @@ -334,11 +334,11 @@ #include "JSXPathResult.h" #include "JSXSLTProcessor.h" #include "KURL.h" -#include "Media.h" #include "Navigator.h" #include "RegisteredEventListener.h" #include "Screen.h" #include "Storage.h" +#include "StyleMedia.h" #include "WebKitPoint.h" #include #include @@ -395,7 +395,7 @@ static const HashTableValue JSDOMWindowTableValues[409] = { "parent", DontDelete, (intptr_t)static_cast(jsDOMWindowParent), (intptr_t)setJSDOMWindowParent }, { "top", DontDelete, (intptr_t)static_cast(jsDOMWindowTop), (intptr_t)setJSDOMWindowTop }, { "document", DontDelete|ReadOnly, (intptr_t)static_cast(jsDOMWindowDocument), (intptr_t)0 }, - { "media", DontDelete|ReadOnly, (intptr_t)static_cast(jsDOMWindowMedia), (intptr_t)0 }, + { "styleMedia", DontDelete|ReadOnly, (intptr_t)static_cast(jsDOMWindowStyleMedia), (intptr_t)0 }, { "devicePixelRatio", DontDelete, (intptr_t)static_cast(jsDOMWindowDevicePixelRatio), (intptr_t)setJSDOMWindowDevicePixelRatio }, { "applicationCache", DontDelete|ReadOnly, (intptr_t)static_cast(jsDOMWindowApplicationCache), (intptr_t)0 }, { "sessionStorage", DontDelete|ReadOnly, (intptr_t)static_cast(jsDOMWindowSessionStorage), (intptr_t)0 }, @@ -1304,14 +1304,14 @@ JSValue jsDOMWindowDocument(ExecState* exec, JSValue slotBase, const Identifier& return result; } -JSValue jsDOMWindowMedia(ExecState* exec, JSValue slotBase, const Identifier&) +JSValue jsDOMWindowStyleMedia(ExecState* exec, JSValue slotBase, const Identifier&) { JSDOMWindow* castedThis = static_cast(asObject(slotBase)); if (!castedThis->allowsAccessFrom(exec)) return jsUndefined(); UNUSED_PARAM(exec); DOMWindow* imp = static_cast(castedThis->impl()); - JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->media())); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->styleMedia())); return result; } diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h index a6f3253..7e50556 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.h @@ -231,7 +231,7 @@ void setJSDOMWindowParent(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsDOMWindowTop(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); void setJSDOMWindowTop(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsDOMWindowDocument(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); -JSC::JSValue jsDOMWindowMedia(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsDOMWindowStyleMedia(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); JSC::JSValue jsDOMWindowDevicePixelRatio(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); void setJSDOMWindowDevicePixelRatio(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsDOMWindowApplicationCache(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); diff --git a/src/3rdparty/webkit/WebCore/generated/JSMedia.cpp b/src/3rdparty/webkit/WebCore/generated/JSMedia.cpp deleted file mode 100644 index 1579c2b..0000000 --- a/src/3rdparty/webkit/WebCore/generated/JSMedia.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - This file is part of the WebKit open source project. - This file has been generated by generate-bindings.pl. DO NOT MODIFY! - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" -#include "JSMedia.h" - -#include "KURL.h" -#include "Media.h" -#include -#include -#include - -using namespace JSC; - -namespace WebCore { - -ASSERT_CLASS_FITS_IN_CELL(JSMedia); - -/* Hash table */ - -static const HashTableValue JSMediaTableValues[3] = -{ - { "type", DontDelete|ReadOnly, (intptr_t)static_cast(jsMediaType), (intptr_t)0 }, - { "constructor", DontEnum|ReadOnly, (intptr_t)static_cast(jsMediaConstructor), (intptr_t)0 }, - { 0, 0, 0, 0 } -}; - -static JSC_CONST_HASHTABLE HashTable JSMediaTable = -#if ENABLE(PERFECT_HASH_SIZE) - { 3, JSMediaTableValues, 0 }; -#else - { 4, 3, JSMediaTableValues, 0 }; -#endif - -/* Hash table for constructor */ - -static const HashTableValue JSMediaConstructorTableValues[1] = -{ - { 0, 0, 0, 0 } -}; - -static JSC_CONST_HASHTABLE HashTable JSMediaConstructorTable = -#if ENABLE(PERFECT_HASH_SIZE) - { 0, JSMediaConstructorTableValues, 0 }; -#else - { 1, 0, JSMediaConstructorTableValues, 0 }; -#endif - -class JSMediaConstructor : public DOMConstructorObject { -public: - JSMediaConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSMediaConstructor::createStructure(globalObject->objectPrototype()), globalObject) - { - putDirect(exec->propertyNames().prototype, JSMediaPrototype::self(exec, globalObject), None); - } - virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); - virtual const ClassInfo* classInfo() const { return &s_info; } - static const ClassInfo s_info; - - static PassRefPtr createStructure(JSValue proto) - { - return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); - } - -protected: - static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags; -}; - -const ClassInfo JSMediaConstructor::s_info = { "MediaConstructor", 0, &JSMediaConstructorTable, 0 }; - -bool JSMediaConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot(exec, &JSMediaConstructorTable, this, propertyName, slot); -} - -bool JSMediaConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) -{ - return getStaticValueDescriptor(exec, &JSMediaConstructorTable, this, propertyName, descriptor); -} - -/* Hash table for prototype */ - -static const HashTableValue JSMediaPrototypeTableValues[2] = -{ - { "matchMedium", DontDelete|Function, (intptr_t)static_cast(jsMediaPrototypeFunctionMatchMedium), (intptr_t)1 }, - { 0, 0, 0, 0 } -}; - -static JSC_CONST_HASHTABLE HashTable JSMediaPrototypeTable = -#if ENABLE(PERFECT_HASH_SIZE) - { 0, JSMediaPrototypeTableValues, 0 }; -#else - { 2, 1, JSMediaPrototypeTableValues, 0 }; -#endif - -const ClassInfo JSMediaPrototype::s_info = { "MediaPrototype", 0, &JSMediaPrototypeTable, 0 }; - -JSObject* JSMediaPrototype::self(ExecState* exec, JSGlobalObject* globalObject) -{ - return getDOMPrototype(exec, globalObject); -} - -bool JSMediaPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticFunctionSlot(exec, &JSMediaPrototypeTable, this, propertyName, slot); -} - -bool JSMediaPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) -{ - return getStaticFunctionDescriptor(exec, &JSMediaPrototypeTable, this, propertyName, descriptor); -} - -const ClassInfo JSMedia::s_info = { "Media", 0, &JSMediaTable, 0 }; - -JSMedia::JSMedia(NonNullPassRefPtr structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) - : DOMObjectWithGlobalPointer(structure, globalObject) - , m_impl(impl) -{ -} - -JSMedia::~JSMedia() -{ - forgetDOMObject(this, impl()); -} - -JSObject* JSMedia::createPrototype(ExecState* exec, JSGlobalObject* globalObject) -{ - return new (exec) JSMediaPrototype(JSMediaPrototype::createStructure(globalObject->objectPrototype())); -} - -bool JSMedia::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot(exec, &JSMediaTable, this, propertyName, slot); -} - -bool JSMedia::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) -{ - return getStaticValueDescriptor(exec, &JSMediaTable, this, propertyName, descriptor); -} - -JSValue jsMediaType(ExecState* exec, JSValue slotBase, const Identifier&) -{ - JSMedia* castedThis = static_cast(asObject(slotBase)); - UNUSED_PARAM(exec); - Media* imp = static_cast(castedThis->impl()); - JSValue result = jsString(exec, imp->type()); - return result; -} - -JSValue jsMediaConstructor(ExecState* exec, JSValue slotBase, const Identifier&) -{ - JSMedia* domObject = static_cast(asObject(slotBase)); - return JSMedia::getConstructor(exec, domObject->globalObject()); -} -JSValue JSMedia::getConstructor(ExecState* exec, JSGlobalObject* globalObject) -{ - return getDOMConstructor(exec, static_cast(globalObject)); -} - -JSValue JSC_HOST_CALL jsMediaPrototypeFunctionMatchMedium(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) -{ - UNUSED_PARAM(args); - if (!thisValue.inherits(&JSMedia::s_info)) - return throwError(exec, TypeError); - JSMedia* castedThisObj = static_cast(asObject(thisValue)); - Media* imp = static_cast(castedThisObj->impl()); - const UString& mediaquery = args.at(0).toString(exec); - - - JSC::JSValue result = jsBoolean(imp->matchMedium(mediaquery)); - return result; -} - -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Media* object) -{ - return getDOMObjectWrapper(exec, globalObject, object); -} -Media* toMedia(JSC::JSValue value) -{ - return value.inherits(&JSMedia::s_info) ? static_cast(asObject(value))->impl() : 0; -} - -} diff --git a/src/3rdparty/webkit/WebCore/generated/JSMedia.h b/src/3rdparty/webkit/WebCore/generated/JSMedia.h deleted file mode 100644 index 28515c9..0000000 --- a/src/3rdparty/webkit/WebCore/generated/JSMedia.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - This file is part of the WebKit open source project. - This file has been generated by generate-bindings.pl. DO NOT MODIFY! - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef JSMedia_h -#define JSMedia_h - -#include "JSDOMBinding.h" -#include -#include - -namespace WebCore { - -class Media; - -class JSMedia : public DOMObjectWithGlobalPointer { - typedef DOMObjectWithGlobalPointer Base; -public: - JSMedia(NonNullPassRefPtr, JSDOMGlobalObject*, PassRefPtr); - virtual ~JSMedia(); - static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); - virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); - virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - static const JSC::ClassInfo s_info; - - static PassRefPtr createStructure(JSC::JSValue prototype) - { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); - } - - static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); - Media* impl() const { return m_impl.get(); } - -private: - RefPtr m_impl; -protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; -}; - -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Media*); -Media* toMedia(JSC::JSValue); - -class JSMediaPrototype : public JSC::JSObject { - typedef JSC::JSObject Base; -public: - static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - static const JSC::ClassInfo s_info; - virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); - virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); - static PassRefPtr createStructure(JSC::JSValue prototype) - { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); - } - JSMediaPrototype(NonNullPassRefPtr structure) : JSC::JSObject(structure) { } -protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; -}; - -// Functions - -JSC::JSValue JSC_HOST_CALL jsMediaPrototypeFunctionMatchMedium(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); -// Attributes - -JSC::JSValue jsMediaType(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); -JSC::JSValue jsMediaConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); - -} // namespace WebCore - -#endif diff --git a/src/3rdparty/webkit/WebCore/generated/JSStyleMedia.cpp b/src/3rdparty/webkit/WebCore/generated/JSStyleMedia.cpp new file mode 100644 index 0000000..b06bf09 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/generated/JSStyleMedia.cpp @@ -0,0 +1,201 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "JSStyleMedia.h" + +#include "KURL.h" +#include "StyleMedia.h" +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSStyleMedia); + +/* Hash table */ + +static const HashTableValue JSStyleMediaTableValues[3] = +{ + { "type", DontDelete|ReadOnly, (intptr_t)static_cast(jsStyleMediaType), (intptr_t)0 }, + { "constructor", DontEnum|ReadOnly, (intptr_t)static_cast(jsStyleMediaConstructor), (intptr_t)0 }, + { 0, 0, 0, 0 } +}; + +static JSC_CONST_HASHTABLE HashTable JSStyleMediaTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 3, JSStyleMediaTableValues, 0 }; +#else + { 4, 3, JSStyleMediaTableValues, 0 }; +#endif + +/* Hash table for constructor */ + +static const HashTableValue JSStyleMediaConstructorTableValues[1] = +{ + { 0, 0, 0, 0 } +}; + +static JSC_CONST_HASHTABLE HashTable JSStyleMediaConstructorTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 0, JSStyleMediaConstructorTableValues, 0 }; +#else + { 1, 0, JSStyleMediaConstructorTableValues, 0 }; +#endif + +class JSStyleMediaConstructor : public DOMConstructorObject { +public: + JSStyleMediaConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSStyleMediaConstructor::createStructure(globalObject->objectPrototype()), globalObject) + { + putDirect(exec->propertyNames().prototype, JSStyleMediaPrototype::self(exec, globalObject), None); + } + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); + virtual const ClassInfo* classInfo() const { return &s_info; } + static const ClassInfo s_info; + + static PassRefPtr createStructure(JSValue proto) + { + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); + } + +protected: + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags; +}; + +const ClassInfo JSStyleMediaConstructor::s_info = { "StyleMediaConstructor", 0, &JSStyleMediaConstructorTable, 0 }; + +bool JSStyleMediaConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSStyleMediaConstructorTable, this, propertyName, slot); +} + +bool JSStyleMediaConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSStyleMediaConstructorTable, this, propertyName, descriptor); +} + +/* Hash table for prototype */ + +static const HashTableValue JSStyleMediaPrototypeTableValues[2] = +{ + { "matchMedium", DontDelete|Function, (intptr_t)static_cast(jsStyleMediaPrototypeFunctionMatchMedium), (intptr_t)1 }, + { 0, 0, 0, 0 } +}; + +static JSC_CONST_HASHTABLE HashTable JSStyleMediaPrototypeTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 0, JSStyleMediaPrototypeTableValues, 0 }; +#else + { 2, 1, JSStyleMediaPrototypeTableValues, 0 }; +#endif + +const ClassInfo JSStyleMediaPrototype::s_info = { "StyleMediaPrototype", 0, &JSStyleMediaPrototypeTable, 0 }; + +JSObject* JSStyleMediaPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSStyleMediaPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticFunctionSlot(exec, &JSStyleMediaPrototypeTable, this, propertyName, slot); +} + +bool JSStyleMediaPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticFunctionDescriptor(exec, &JSStyleMediaPrototypeTable, this, propertyName, descriptor); +} + +const ClassInfo JSStyleMedia::s_info = { "StyleMedia", 0, &JSStyleMediaTable, 0 }; + +JSStyleMedia::JSStyleMedia(NonNullPassRefPtr structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : DOMObjectWithGlobalPointer(structure, globalObject) + , m_impl(impl) +{ +} + +JSStyleMedia::~JSStyleMedia() +{ + forgetDOMObject(this, impl()); +} + +JSObject* JSStyleMedia::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return new (exec) JSStyleMediaPrototype(JSStyleMediaPrototype::createStructure(globalObject->objectPrototype())); +} + +bool JSStyleMedia::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSStyleMediaTable, this, propertyName, slot); +} + +bool JSStyleMedia::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSStyleMediaTable, this, propertyName, descriptor); +} + +JSValue jsStyleMediaType(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSStyleMedia* castedThis = static_cast(asObject(slotBase)); + UNUSED_PARAM(exec); + StyleMedia* imp = static_cast(castedThis->impl()); + JSValue result = jsString(exec, imp->type()); + return result; +} + +JSValue jsStyleMediaConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSStyleMedia* domObject = static_cast(asObject(slotBase)); + return JSStyleMedia::getConstructor(exec, domObject->globalObject()); +} +JSValue JSStyleMedia::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, static_cast(globalObject)); +} + +JSValue JSC_HOST_CALL jsStyleMediaPrototypeFunctionMatchMedium(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSStyleMedia::s_info)) + return throwError(exec, TypeError); + JSStyleMedia* castedThisObj = static_cast(asObject(thisValue)); + StyleMedia* imp = static_cast(castedThisObj->impl()); + const UString& mediaquery = args.at(0).toString(exec); + + + JSC::JSValue result = jsBoolean(imp->matchMedium(mediaquery)); + return result; +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, StyleMedia* object) +{ + return getDOMObjectWrapper(exec, globalObject, object); +} +StyleMedia* toStyleMedia(JSC::JSValue value) +{ + return value.inherits(&JSStyleMedia::s_info) ? static_cast(asObject(value))->impl() : 0; +} + +} diff --git a/src/3rdparty/webkit/WebCore/generated/JSStyleMedia.h b/src/3rdparty/webkit/WebCore/generated/JSStyleMedia.h new file mode 100644 index 0000000..12601d5 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/generated/JSStyleMedia.h @@ -0,0 +1,87 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef JSStyleMedia_h +#define JSStyleMedia_h + +#include "JSDOMBinding.h" +#include +#include + +namespace WebCore { + +class StyleMedia; + +class JSStyleMedia : public DOMObjectWithGlobalPointer { + typedef DOMObjectWithGlobalPointer Base; +public: + JSStyleMedia(NonNullPassRefPtr, JSDOMGlobalObject*, PassRefPtr); + virtual ~JSStyleMedia(); + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + + static PassRefPtr createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + StyleMedia* impl() const { return m_impl.get(); } + +private: + RefPtr m_impl; +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, StyleMedia*); +StyleMedia* toStyleMedia(JSC::JSValue); + +class JSStyleMediaPrototype : public JSC::JSObject { + typedef JSC::JSObject Base; +public: + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static PassRefPtr createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + JSStyleMediaPrototype(NonNullPassRefPtr structure) : JSC::JSObject(structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +// Functions + +JSC::JSValue JSC_HOST_CALL jsStyleMediaPrototypeFunctionMatchMedium(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +// Attributes + +JSC::JSValue jsStyleMediaType(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsStyleMediaConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/src/3rdparty/webkit/WebCore/page/AbstractView.idl b/src/3rdparty/webkit/WebCore/page/AbstractView.idl index 290bf48..e4ece0f 100644 --- a/src/3rdparty/webkit/WebCore/page/AbstractView.idl +++ b/src/3rdparty/webkit/WebCore/page/AbstractView.idl @@ -32,7 +32,7 @@ module views { OmitConstructor ] AbstractView { readonly attribute Document document; - readonly attribute Media media; + readonly attribute Media styleMedia; }; } diff --git a/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp b/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp index dd90200..8dcff5c 100644 --- a/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp +++ b/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp @@ -57,7 +57,7 @@ #include "InspectorController.h" #include "InspectorTimelineAgent.h" #include "Location.h" -#include "Media.h" +#include "StyleMedia.h" #include "MessageEvent.h" #include "Navigator.h" #include "NotificationCenter.h" @@ -1112,10 +1112,10 @@ Document* DOMWindow::document() const return m_frame->document(); } -PassRefPtr DOMWindow::media() const +PassRefPtr DOMWindow::styleMedia() const { if (!m_media) - m_media = Media::create(m_frame); + m_media = StyleMedia::create(m_frame); return m_media.get(); } diff --git a/src/3rdparty/webkit/WebCore/page/DOMWindow.h b/src/3rdparty/webkit/WebCore/page/DOMWindow.h index a70713b..cf9bc88 100644 --- a/src/3rdparty/webkit/WebCore/page/DOMWindow.h +++ b/src/3rdparty/webkit/WebCore/page/DOMWindow.h @@ -56,7 +56,7 @@ namespace WebCore { class IndexedDatabaseRequest; class InspectorTimelineAgent; class Location; - class Media; + class StyleMedia; class Navigator; class Node; class NotificationCenter; @@ -187,7 +187,7 @@ namespace WebCore { // DOM Level 2 AbstractView Interface Document* document() const; // CSSOM View Module - PassRefPtr media() const; + PassRefPtr styleMedia() const; // DOM Level 2 Style Interface PassRefPtr getComputedStyle(Element*, const String& pseudoElt) const; @@ -353,7 +353,7 @@ namespace WebCore { Console* optionalConsole() const { return m_console.get(); } Navigator* optionalNavigator() const { return m_navigator.get(); } Location* optionalLocation() const { return m_location.get(); } - Media* optionalMedia() const { return m_media.get(); } + StyleMedia* optionalMedia() const { return m_media.get(); } #if ENABLE(DOM_STORAGE) Storage* optionalSessionStorage() const { return m_sessionStorage.get(); } Storage* optionalLocalStorage() const { return m_localStorage.get(); } @@ -390,7 +390,7 @@ namespace WebCore { mutable RefPtr m_console; mutable RefPtr m_navigator; mutable RefPtr m_location; - mutable RefPtr m_media; + mutable RefPtr m_media; #if ENABLE(DOM_STORAGE) mutable RefPtr m_sessionStorage; mutable RefPtr m_localStorage; diff --git a/src/3rdparty/webkit/WebCore/page/DOMWindow.idl b/src/3rdparty/webkit/WebCore/page/DOMWindow.idl index 31e4d4f..33e49e8 100644 --- a/src/3rdparty/webkit/WebCore/page/DOMWindow.idl +++ b/src/3rdparty/webkit/WebCore/page/DOMWindow.idl @@ -141,7 +141,7 @@ module window { readonly attribute Document document; // CSSOM View Module - readonly attribute Media media; + readonly attribute StyleMedia styleMedia; // DOM Level 2 Style Interface CSSStyleDeclaration getComputedStyle(in Element element, diff --git a/src/3rdparty/webkit/WebCore/page/FrameView.h b/src/3rdparty/webkit/WebCore/page/FrameView.h index 7371d13..7119975 100644 --- a/src/3rdparty/webkit/WebCore/page/FrameView.h +++ b/src/3rdparty/webkit/WebCore/page/FrameView.h @@ -139,7 +139,7 @@ public: virtual void scrollRectIntoViewRecursively(const IntRect&); virtual void setScrollPosition(const IntPoint&); - void scrollPositionChanged(); + virtual void scrollPositionChanged(); String mediaType() const; void setMediaType(const String&); diff --git a/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp b/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp index 5c70eff..e50ab55 100644 --- a/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp +++ b/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp @@ -292,6 +292,7 @@ void ScrollView::valueChanged(Scrollbar* scrollbar) if (scrollbarsSuppressed()) return; + scrollPositionChanged(); scrollContents(scrollDelta); } diff --git a/src/3rdparty/webkit/WebCore/platform/ScrollView.h b/src/3rdparty/webkit/WebCore/platform/ScrollView.h index 9134ddf..118a310 100644 --- a/src/3rdparty/webkit/WebCore/platform/ScrollView.h +++ b/src/3rdparty/webkit/WebCore/platform/ScrollView.h @@ -302,6 +302,9 @@ private: // Called to update the scrollbars to accurately reflect the state of the view. void updateScrollbars(const IntSize& desiredOffset); + // Called when the scroll position within this view changes. FrameView overrides this to generate repaint invalidations. + virtual void scrollPositionChanged() {} + void platformInit(); void platformDestroy(); void platformAddChild(Widget*); diff --git a/src/3rdparty/webkit/WebCore/platform/qt/ScrollbarThemeQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/ScrollbarThemeQt.cpp index 04a2b1b..eb2d934 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/ScrollbarThemeQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/ScrollbarThemeQt.cpp @@ -114,7 +114,7 @@ static QStyleOptionSlider* styleOptionSlider(Scrollbar* scrollbar, QWidget* widg opt.state |= QStyle::State_Horizontal; opt.sliderValue = scrollbar->value(); opt.sliderPosition = opt.sliderValue; - opt.pageStep = scrollbar->visibleSize(); + opt.pageStep = scrollbar->pageStep(); opt.singleStep = scrollbar->lineStep(); opt.minimum = 0; opt.maximum = qMax(0, scrollbar->maximum()); -- cgit v0.12 From 7894bbb901a2ba74284bd6c0544b06c6a41f6b6f Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 12 May 2010 14:44:06 +0200 Subject: Possibly fix autotest It's unclear why the autotest failed on a platform I can't test on right now, but this might clear it up. --- .../declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp index 2207635..c0c5abc 100644 --- a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp +++ b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp @@ -75,7 +75,7 @@ void tst_qdeclarativelayoutitem::test_resizing() view.setScene(&scene); //Add the QML snippet into the layout QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl(SRCDIR "/data/layoutItem.qml")); + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/layoutItem.qml")); QDeclarativeLayoutItem* obj = static_cast(c.create()); layout->addItem(obj); layout->setContentsMargins(0,0,0,0); -- cgit v0.12 From 51a5901a26169276131c88aab3184fb0fa5b814c Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 12 May 2010 15:54:50 +0300 Subject: Double-click support for virtual cursor in Symbian This makes it possible to use itemviews with S60 style, as activation of items requires a double-click there. Task-number: QTBUG-8138 Reviewed-by: Shane Kearns --- src/gui/kernel/qapplication_s60.cpp | 12 +++++++++++- src/gui/kernel/qt_s60_p.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index f4c7304..387762f 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -364,6 +364,7 @@ void QSymbianControl::ConstructL(bool isWindowOwning, bool desktop) SetFocusing(true); m_longTapDetector = QLongTapTimer::NewL(this); + m_doubleClickTimer.invalidate(); DrawableWindow()->SetPointerGrab(ETrue); } @@ -642,6 +643,7 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod QPoint pos = QCursor::pos(); TPointerEvent fakeEvent; + fakeEvent.iModifiers = keyEvent.iModifiers; TInt x = pos.x(); TInt y = pos.y(); if (type == EEventKeyUp) { @@ -668,6 +670,8 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod } } else if (type == EEventKey) { + if (keyCode != Qt::Key_Select) + m_doubleClickTimer.invalidate(); switch (keyCode) { case Qt::Key_Left: S60->virtualMousePressedKeys |= QS60Data::Left; @@ -700,6 +704,13 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod } else { S60->virtualMousePressedKeys |= QS60Data::Select; fakeEvent.iType = TPointerEvent::EButton1Down; + if (m_doubleClickTimer.isValid() + && !m_doubleClickTimer.hasExpired(QApplication::doubleClickInterval())) { + fakeEvent.iModifiers |= EModifierDoubleClick; + m_doubleClickTimer.invalidate(); + } else { + m_doubleClickTimer.start(); + } } break; } @@ -715,7 +726,6 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod y = S60->screenHeightInPixels - 1; TPoint epos(x, y); TPoint cpos = epos - PositionRelativeToScreen(); - fakeEvent.iModifiers = keyEvent.iModifiers; fakeEvent.iPosition = cpos; fakeEvent.iParentPosition = epos; HandlePointerEvent(fakeEvent); diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 58da302..1af8eeb 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -62,6 +62,7 @@ #include "QtGui/qevent.h" #include "qpointer.h" #include "qapplication.h" +#include "qelapsedtimer.h" #include #include #include @@ -222,6 +223,7 @@ private: private: QWidget *qwidget; QLongTapTimer* m_longTapDetector; + QElapsedTimer m_doubleClickTimer; bool m_ignoreFocusChanged : 1; bool m_symbianPopupIsOpen : 1; -- cgit v0.12 From c46688b8a88da02028405604ab633b27d3fefa68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 11 May 2010 12:46:46 +0200 Subject: Made curve tesselation be dynamically adjusted based on transform. This lets us avoid having to use a very low curve threshold value for all scales, and thus avoids the performance regression from change c41dbbb5e6495e26cd32. Task-number: QTBUG-9218 Reviewed-by: Gunnar Sletta --- src/gui/painting/qbezier.cpp | 228 +----------------------------------- src/gui/painting/qbezier_p.h | 7 +- src/gui/painting/qpaintengineex.cpp | 2 + src/gui/painting/qstroker.cpp | 23 ++-- src/gui/painting/qstroker_p.h | 18 ++- src/gui/painting/qtransform.cpp | 9 +- src/s60installs/bwins/QtGuiu.def | 4 +- src/s60installs/eabi/QtGuiu.def | 4 +- 8 files changed, 50 insertions(+), 245 deletions(-) diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index 7ff2a37..2a9b31a 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -93,7 +93,7 @@ QBezier QBezier::fromPoints(const QPointF &p1, const QPointF &p2, /*! \internal */ -QPolygonF QBezier::toPolygon() const +QPolygonF QBezier::toPolygon(qreal bezier_flattening_threshold) const { // flattening is done by splitting the bezier until we can replace the segment by a straight // line. We split further until the control points are close enough to the line connecting the @@ -108,7 +108,7 @@ QPolygonF QBezier::toPolygon() const QPolygonF polygon; polygon.append(QPointF(x1, y1)); - addToPolygon(&polygon); + addToPolygon(&polygon, bezier_flattening_threshold); return polygon; } @@ -117,34 +117,6 @@ QBezier QBezier::mapBy(const QTransform &transform) const return QBezier::fromPoints(transform.map(pt1()), transform.map(pt2()), transform.map(pt3()), transform.map(pt4())); } -//0.05 is really low, but required for scaled-up beziers... -static const qreal flatness = 0.05; - -//based on "Fast, precise flattening of cubic Bezier path and offset curves" -// by T. F. Hain, A. L. Ahmad, S. V. R. Racherla and D. D. Langan -static inline void flattenBezierWithoutInflections(QBezier &bez, - QPolygonF *&p) -{ - QBezier left; - - while (1) { - qreal dx = bez.x2 - bez.x1; - qreal dy = bez.y2 - bez.y1; - - qreal normalized = qSqrt(dx * dx + dy * dy); - if (qFuzzyIsNull(normalized)) - break; - - qreal d = qAbs(dx * (bez.y3 - bez.y2) - dy * (bez.x3 - bez.x2)); - - qreal t = qSqrt(4. / 3. * normalized * flatness / d); - if (t > 1 || qFuzzyIsNull(t - (qreal)1.)) - break; - bez.parameterSplitLeft(t, &left); - p->append(bez.pt1()); - } -} - QBezier QBezier::getSubRange(qreal t0, qreal t1) const { QBezier result; @@ -223,7 +195,7 @@ static inline bool findInflections(qreal a, qreal b, qreal c, } -void QBezier::addToPolygon(QPolygonF *polygon) const +void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold) const { QBezier beziers[32]; beziers[0] = *this; @@ -243,7 +215,7 @@ void QBezier::addToPolygon(QPolygonF *polygon) const qAbs(b->x1 - b->x3) + qAbs(b->y1 - b->y3); l = 1.; } - if (d < flatness*l || b == beziers + 31) { + if (d < bezier_flattening_threshold*l || b == beziers + 31) { // good enough, we pop it off and add the endpoint polygon->append(QPointF(b->x4, b->y4)); --b; @@ -255,55 +227,6 @@ void QBezier::addToPolygon(QPolygonF *polygon) const } } -void QBezier::addToPolygonMixed(QPolygonF *polygon) const -{ - qreal ax = -x1 + 3*x2 - 3*x3 + x4; - qreal ay = -y1 + 3*y2 - 3*y3 + y4; - qreal bx = 3*x1 - 6*x2 + 3*x3; - qreal by = 3*y1 - 6*y2 + 3*y3; - qreal cx = -3*x1 + 3*x2; - qreal cy = -3*y1 + 2*y2; - qreal a = 6 * (ay * bx - ax * by); - qreal b = 6 * (ay * cx - ax * cy); - qreal c = 2 * (by * cx - bx * cy); - - if ((qFuzzyIsNull(a) && qFuzzyIsNull(b)) || - (b * b - 4 * a *c) < 0) { - QBezier bez(*this); - flattenBezierWithoutInflections(bez, polygon); - polygon->append(QPointF(x4, y4)); - } else { - QBezier beziers[32]; - beziers[0] = *this; - QBezier *b = beziers; - - while (b >= beziers) { - // check if we can pop the top bezier curve from the stack - qreal y4y1 = b->y4 - b->y1; - qreal x4x1 = b->x4 - b->x1; - qreal l = qAbs(x4x1) + qAbs(y4y1); - qreal d; - if (l > 1.) { - d = qAbs( (x4x1)*(b->y1 - b->y2) - (y4y1)*(b->x1 - b->x2) ) - + qAbs( (x4x1)*(b->y1 - b->y3) - (y4y1)*(b->x1 - b->x3) ); - } else { - d = qAbs(b->x1 - b->x2) + qAbs(b->y1 - b->y2) + - qAbs(b->x1 - b->x3) + qAbs(b->y1 - b->y3); - l = 1.; - } - if (d < .5*l || b == beziers + 31) { - // good enough, we pop it off and add the endpoint - polygon->append(QPointF(b->x4, b->y4)); - --b; - } else { - // split, second half of the polygon goes lower into the stack - b->split(b+1, b); - ++b; - } - } - } -} - QRectF QBezier::bounds() const { qreal xmin = x1; @@ -824,147 +747,4 @@ QBezier QBezier::bezierOnInterval(qreal t0, qreal t1) const return result; } - -static inline void bindInflectionPoint(const QBezier &bez, const qreal t, - qreal *tMinus , qreal *tPlus) -{ - if (t <= 0) { - *tMinus = *tPlus = -1; - return; - } else if (t >= 1) { - *tMinus = *tPlus = 2; - return; - } - - QBezier left, right; - splitBezierAt(bez, t, &left, &right); - - qreal ax = -right.x1 + 3*right.x2 - 3*right.x3 + right.x4; - qreal ay = -right.y1 + 3*right.y2 - 3*right.y3 + right.y4; - qreal ex = 3 * (right.x2 - right.x3); - qreal ey = 3 * (right.y2 - right.y3); - - qreal s4 = qAbs(6 * (ey * ax - ex * ay) / qSqrt(ex * ex + ey * ey)) + 0.00001f; - qreal tf = qPow(qreal(9 * flatness / s4), qreal(1./3.)); - *tMinus = t - (1 - t) * tf; - *tPlus = t + (1 - t) * tf; -} - -void QBezier::addToPolygonIterative(QPolygonF *p) const -{ - qreal t1, t2, tcusp; - qreal t1min, t1plus, t2min, t2plus; - - qreal ax = -x1 + 3*x2 - 3*x3 + x4; - qreal ay = -y1 + 3*y2 - 3*y3 + y4; - qreal bx = 3*x1 - 6*x2 + 3*x3; - qreal by = 3*y1 - 6*y2 + 3*y3; - qreal cx = -3*x1 + 3*x2; - qreal cy = -3*y1 + 2*y2; - - if (findInflections(6 * (ay * bx - ax * by), - 6 * (ay * cx - ax * cy), - 2 * (by * cx - bx * cy), - &t1, &t2, &tcusp)) { - bindInflectionPoint(*this, t1, &t1min, &t1plus); - bindInflectionPoint(*this, t2, &t2min, &t2plus); - - QBezier tmpBez = *this; - QBezier left, right, bez1, bez2, bez3; - if (t1min > 0) { - if (t1min >= 1) { - flattenBezierWithoutInflections(tmpBez, p); - } else { - splitBezierAt(tmpBez, t1min, &left, &right); - flattenBezierWithoutInflections(left, p); - p->append(tmpBez.pointAt(t1min)); - - if (t2min < t1plus) { - if (tcusp < 1) { - p->append(tmpBez.pointAt(tcusp)); - } - if (t2plus < 1) { - splitBezierAt(tmpBez, t2plus, &left, &right); - flattenBezierWithoutInflections(right, p); - } - } else if (t1plus < 1) { - if (t2min < 1) { - splitBezierAt(tmpBez, t2min, &bez3, &right); - splitBezierAt(bez3, t1plus, &left, &bez2); - - flattenBezierWithoutInflections(bez2, p); - p->append(tmpBez.pointAt(t2min)); - - if (t2plus < 1) { - splitBezierAt(tmpBez, t2plus, &left, &bez2); - flattenBezierWithoutInflections(bez2, p); - } - } else { - splitBezierAt(tmpBez, t1plus, &left, &bez2); - flattenBezierWithoutInflections(bez2, p); - } - } - } - } else if (t1plus > 0) { - p->append(QPointF(x1, y1)); - if (t2min < t1plus) { - if (tcusp < 1) { - p->append(tmpBez.pointAt(tcusp)); - } - if (t2plus < 1) { - splitBezierAt(tmpBez, t2plus, &left, &bez2); - flattenBezierWithoutInflections(bez2, p); - } - } else if (t1plus < 1) { - if (t2min < 1) { - splitBezierAt(tmpBez, t2min, &bez3, &right); - splitBezierAt(bez3, t1plus, &left, &bez2); - - flattenBezierWithoutInflections(bez2, p); - - p->append(tmpBez.pointAt(t2min)); - if (t2plus < 1) { - splitBezierAt(tmpBez, t2plus, &left, &bez2); - flattenBezierWithoutInflections(bez2, p); - } - } else { - splitBezierAt(tmpBez, t1plus, &left, &bez2); - flattenBezierWithoutInflections(bez2, p); - } - } - } else if (t2min > 0) { - if (t2min < 1) { - splitBezierAt(tmpBez, t2min, &bez1, &right); - flattenBezierWithoutInflections(bez1, p); - p->append(tmpBez.pointAt(t2min)); - - if (t2plus < 1) { - splitBezierAt(tmpBez, t2plus, &left, &bez2); - flattenBezierWithoutInflections(bez2, p); - } - } else { - //### in here we should check whether the area of the - // triangle formed between pt1/pt2/pt3 is smaller - // or equal to 0 and then do iterative flattening - // if not we should fallback and do the recursive - // flattening. - flattenBezierWithoutInflections(tmpBez, p); - } - } else if (t2plus > 0) { - p->append(QPointF(x1, y1)); - if (t2plus < 1) { - splitBezierAt(tmpBez, t2plus, &left, &bez2); - flattenBezierWithoutInflections(bez2, p); - } - } else { - flattenBezierWithoutInflections(tmpBez, p); - } - } else { - QBezier bez = *this; - flattenBezierWithoutInflections(bez, p); - } - - p->append(QPointF(x4, y4)); -} - QT_END_NAMESPACE diff --git a/src/gui/painting/qbezier_p.h b/src/gui/painting/qbezier_p.h index 846635f..18ec116 100644 --- a/src/gui/painting/qbezier_p.h +++ b/src/gui/painting/qbezier_p.h @@ -79,10 +79,9 @@ public: inline QPointF derivedAt(qreal t) const; inline QPointF secondDerivedAt(qreal t) const; - QPolygonF toPolygon() const; - void addToPolygon(QPolygonF *p) const; - void addToPolygonIterative(QPolygonF *p) const; - void addToPolygonMixed(QPolygonF *p) const; + QPolygonF toPolygon(qreal bezier_flattening_threshold = 0.5) const; + void addToPolygon(QPolygonF *p, qreal bezier_flattening_threshold = 0.5) const; + QRectF bounds() const; qreal length(qreal error = 0.01) const; void addIfClose(qreal *length, qreal error) const; diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index fda937e..ff82d59 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -461,6 +461,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) // change the current transform. Normal transformed, // non-cosmetic pens will be transformed as part of fill // later, so they are also covered here.. + d->activeStroker->setCurveThresholdFromTransform(state()->matrix); d->activeStroker->begin(d->strokeHandler); if (types) { while (points < lastPoint) { @@ -518,6 +519,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath()); d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform()); } else { + d->activeStroker->setCurveThresholdFromTransform(state()->matrix); d->activeStroker->begin(d->strokeHandler); if (types) { while (points < lastPoint) { diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index 9b8e099..eabbd8a 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -120,8 +120,8 @@ private: class QSubpathFlatIterator { public: - QSubpathFlatIterator(const QDataBuffer *path) - : m_path(path), m_pos(0), m_curve_index(-1) { } + QSubpathFlatIterator(const QDataBuffer *path, qreal threshold) + : m_path(path), m_pos(0), m_curve_index(-1), m_curve_threshold(threshold) { } inline bool hasNext() const { return m_curve_index >= 0 || m_pos < m_path->size(); } @@ -152,7 +152,7 @@ public: QPointF(qt_fixed_to_real(m_path->at(m_pos+1).x), qt_fixed_to_real(m_path->at(m_pos+1).y)), QPointF(qt_fixed_to_real(m_path->at(m_pos+2).x), - qt_fixed_to_real(m_path->at(m_pos+2).y))).toPolygon(); + qt_fixed_to_real(m_path->at(m_pos+2).y))).toPolygon(m_curve_threshold); m_curve_index = 1; e.type = QPainterPath::LineToElement; e.x = m_curve.at(0).x(); @@ -169,6 +169,7 @@ private: int m_pos; QPolygonF m_curve; int m_curve_index; + qreal m_curve_threshold; }; template bool qt_stroke_side(Iterator *it, QStroker *stroker, @@ -187,7 +188,12 @@ static inline qreal adapted_angle_on_x(const QLineF &line) } QStrokerOps::QStrokerOps() - : m_elements(0), m_customData(0), m_moveTo(0), m_lineTo(0), m_cubicTo(0) + : m_elements(0) + , m_curveThreshold(qt_real_to_fixed(0.25)) + , m_customData(0) + , m_moveTo(0) + , m_lineTo(0) + , m_cubicTo(0) { } @@ -195,7 +201,6 @@ QStrokerOps::~QStrokerOps() { } - /*! Prepares the stroker. Call this function once before starting a stroke by calling moveTo, lineTo or cubicTo. @@ -238,6 +243,7 @@ void QStrokerOps::strokePath(const QPainterPath &path, void *customData, const Q if (path.isEmpty()) return; + setCurveThresholdFromTransform(matrix); begin(customData); int count = path.elementCount(); if (matrix.isIdentity()) { @@ -308,6 +314,8 @@ void QStrokerOps::strokePolygon(const QPointF *points, int pointCount, bool impl { if (!pointCount) return; + + setCurveThresholdFromTransform(matrix); begin(data); if (matrix.isIdentity()) { moveTo(qt_real_to_fixed(points[0].x()), qt_real_to_fixed(points[0].y())); @@ -348,6 +356,7 @@ void QStrokerOps::strokeEllipse(const QRectF &rect, void *data, const QTransform } } + setCurveThresholdFromTransform(matrix); begin(data); moveTo(qt_real_to_fixed(start.x()), qt_real_to_fixed(start.y())); for (int i=0; i<12; i+=3) { @@ -366,12 +375,10 @@ QStroker::QStroker() { m_strokeWidth = qt_real_to_fixed(1); m_miterLimit = qt_real_to_fixed(2); - m_curveThreshold = qt_real_to_fixed(0.25); } QStroker::~QStroker() { - } Qt::PenCapStyle QStroker::capForJoinMode(LineJoinMode mode) @@ -1135,7 +1142,7 @@ void QDashStroker::processCurrentSubpath() QPainterPath dashPath; - QSubpathFlatIterator it(&m_elements); + QSubpathFlatIterator it(&m_elements, m_curveThreshold); qfixed2d prev = it.next(); bool clipping = !m_clip_rect.isEmpty(); diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h index 3e622a8..0f133ef 100644 --- a/src/gui/painting/qstroker_p.h +++ b/src/gui/painting/qstroker_p.h @@ -124,6 +124,9 @@ typedef void (*qStrokerCubicToHook)(qfixed c1x, qfixed c1y, qfixed ex, qfixed ey, void *data); +// qtransform.cpp +extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); + class Q_GUI_EXPORT QStrokerOps { public: @@ -161,6 +164,16 @@ public: QRectF clipRect() const { return m_clip_rect; } void setClipRect(const QRectF &clip) { m_clip_rect = clip; } + void setCurveThresholdFromTransform(const QTransform &transform) + { + qreal scale; + qt_scaleForTransform(transform, &scale); + setCurveThreshold(scale == 0 ? qreal(0.5) : (qreal(0.5) / scale)); + } + + void setCurveThreshold(qfixed threshold) { m_curveThreshold = threshold; } + qfixed curveThreshold() const { return m_curveThreshold; } + protected: inline void emitMoveTo(qfixed x, qfixed y); inline void emitLineTo(qfixed x, qfixed y); @@ -170,6 +183,7 @@ protected: QDataBuffer m_elements; QRectF m_clip_rect; + qfixed m_curveThreshold; void *m_customData; qStrokerMoveToHook m_moveTo; @@ -208,9 +222,6 @@ public: void setMiterLimit(qfixed length) { m_miterLimit = length; } qfixed miterLimit() const { return m_miterLimit; } - void setCurveThreshold(qfixed threshold) { m_curveThreshold = threshold; } - qfixed curveThreshold() const { return m_curveThreshold; } - void joinPoints(qfixed x, qfixed y, const QLineF &nextLine, LineJoinMode join); inline void emitMoveTo(qfixed x, qfixed y); inline void emitLineTo(qfixed x, qfixed y); @@ -227,7 +238,6 @@ protected: qfixed m_strokeWidth; qfixed m_miterLimit; - qfixed m_curveThreshold; LineJoinMode m_capStyle; LineJoinMode m_joinStyle; diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 80b7520..c72a08e 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1545,12 +1545,19 @@ static inline bool lineTo_clipped(QPainterPath &path, const QTransform &transfor return true; } +bool qt_scaleForTransform(const QTransform &transform, qreal *scale); static inline bool cubicTo_clipped(QPainterPath &path, const QTransform &transform, const QPointF &a, const QPointF &b, const QPointF &c, const QPointF &d, bool needsMoveTo) { // Convert projective xformed curves to line // segments so they can be transformed more accurately - QPolygonF segment = QBezier::fromPoints(a, b, c, d).toPolygon(); + + qreal scale; + qt_scaleForTransform(transform, &scale); + + qreal curveThreshold = scale == 0 ? qreal(0.25) : (qreal(0.25) / scale); + + QPolygonF segment = QBezier::fromPoints(a, b, c, d).toPolygon(curveThreshold); for (int i = 0; i < segment.size() - 1; ++i) if (lineTo_clipped(path, transform, segment.at(i), segment.at(i+1), needsMoveTo)) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index c3a3a08..8957c34 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -2126,8 +2126,8 @@ EXPORTS ?addToGroup@QGraphicsItemGroup@@QAEXPAVQGraphicsItem@@@Z @ 2125 NONAME ; void QGraphicsItemGroup::addToGroup(class QGraphicsItem *) ?addToIndex@QGraphicsItem@@IAEXXZ @ 2126 NONAME ; void QGraphicsItem::addToIndex(void) ?addToPolygon@QBezier@@QBEXPAVQPolygonF@@@Z @ 2127 NONAME ; void QBezier::addToPolygon(class QPolygonF *) const - ?addToPolygonIterative@QBezier@@QBEXPAVQPolygonF@@@Z @ 2128 NONAME ; void QBezier::addToPolygonIterative(class QPolygonF *) const - ?addToPolygonMixed@QBezier@@QBEXPAVQPolygonF@@@Z @ 2129 NONAME ; void QBezier::addToPolygonMixed(class QPolygonF *) const + ?addToPolygonIterative@QBezier@@QBEXPAVQPolygonF@@@Z @ 2128 NONAME ABSENT ; void QBezier::addToPolygonIterative(class QPolygonF *) const + ?addToPolygonMixed@QBezier@@QBEXPAVQPolygonF@@@Z @ 2129 NONAME ABSENT ; void QBezier::addToPolygonMixed(class QPolygonF *) const ?addToolBar@QMainWindow@@QAEPAVQToolBar@@ABVQString@@@Z @ 2130 NONAME ; class QToolBar * QMainWindow::addToolBar(class QString const &) ?addToolBar@QMainWindow@@QAEXPAVQToolBar@@@Z @ 2131 NONAME ; void QMainWindow::addToolBar(class QToolBar *) ?addToolBar@QMainWindow@@QAEXW4ToolBarArea@Qt@@PAVQToolBar@@@Z @ 2132 NONAME ; void QMainWindow::addToolBar(enum Qt::ToolBarArea, class QToolBar *) diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index b1166c5..d127b41 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -9901,9 +9901,9 @@ EXPORTS _ZNK7QBezier10addIfCloseEPff @ 9900 NONAME _ZNK7QBezier12addToPolygonEP9QPolygonF @ 9901 NONAME _ZNK7QBezier16bezierOnIntervalEff @ 9902 NONAME - _ZNK7QBezier17addToPolygonMixedEP9QPolygonF @ 9903 NONAME + _ZNK7QBezier17addToPolygonMixedEP9QPolygonF @ 9903 NONAME ABSENT _ZNK7QBezier17stationaryYPointsERfS0_ @ 9904 NONAME - _ZNK7QBezier21addToPolygonIterativeEP9QPolygonF @ 9905 NONAME + _ZNK7QBezier21addToPolygonIterativeEP9QPolygonF @ 9905 NONAME ABSENT _ZNK7QBezier5tForYEfff @ 9906 NONAME _ZNK7QBezier6boundsEv @ 9907 NONAME _ZNK7QBezier6lengthEf @ 9908 NONAME -- cgit v0.12 From 50fa9ebe8fc0e7eca7536a8663c86cd6b98b2c04 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 12 May 2010 15:04:18 +0200 Subject: qdoc: Yet another revision of the top doc page. Still more to come. --- doc/src/frameworks-technologies/accessible.qdoc | 3 +-- .../activeqt-container.qdoc | 7 ++++--- .../frameworks-technologies/activeqt-server.qdoc | 6 +++--- doc/src/frameworks-technologies/activeqt.qdoc | 5 ++--- doc/src/frameworks-technologies/containers.qdoc | 2 +- doc/src/frameworks-technologies/dbus-adaptors.qdoc | 1 + doc/src/frameworks-technologies/dbus-intro.qdoc | 2 +- .../desktop-integration.qdoc | 6 +----- doc/src/frameworks-technologies/dnd.qdoc | 10 ++------- doc/src/frameworks-technologies/gestures.qdoc | 7 ++++--- doc/src/frameworks-technologies/graphicsview.qdoc | 2 -- .../frameworks-technologies/implicit-sharing.qdoc | 2 +- doc/src/frameworks-technologies/ipc.qdoc | 3 ++- doc/src/frameworks-technologies/phonon.qdoc | 4 ++-- doc/src/frameworks-technologies/unicode.qdoc | 2 +- doc/src/index.qdoc | 3 ++- doc/src/overviews.qdoc | 24 ++++++++++++++-------- src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc | 4 +++- 18 files changed, 47 insertions(+), 46 deletions(-) diff --git a/doc/src/frameworks-technologies/accessible.qdoc b/doc/src/frameworks-technologies/accessible.qdoc index 101d22a..35f1c75 100644 --- a/doc/src/frameworks-technologies/accessible.qdoc +++ b/doc/src/frameworks-technologies/accessible.qdoc @@ -47,8 +47,7 @@ /*! \page accessible.html \title Accessibility - - \ingroup frameworks-technologies + \ingroup technology-apis \tableofcontents diff --git a/doc/src/frameworks-technologies/activeqt-container.qdoc b/doc/src/frameworks-technologies/activeqt-container.qdoc index c1c0947..03cfa8f 100644 --- a/doc/src/frameworks-technologies/activeqt-container.qdoc +++ b/doc/src/frameworks-technologies/activeqt-container.qdoc @@ -41,10 +41,11 @@ /*! \page activeqt-container.html - \title Using ActiveX controls and COM objects in Qt + \title Using ActiveX controls and COM in Qt + \ingroup qt-activex - \brief The QAxContainer module is a Windows-only extension for - accessing ActiveX controls and COM objects. + \brief A Windows-only extension for accessing ActiveX controls and + COM objects. The QAxContainer module is part of the \l ActiveQt framework. It provides a library implementing a QWidget subclass, QAxWidget, diff --git a/doc/src/frameworks-technologies/activeqt-server.qdoc b/doc/src/frameworks-technologies/activeqt-server.qdoc index 4afcee1..900953a 100644 --- a/doc/src/frameworks-technologies/activeqt-server.qdoc +++ b/doc/src/frameworks-technologies/activeqt-server.qdoc @@ -41,10 +41,10 @@ /*! \page activeqt-server.html - \title Building ActiveX servers and controls with Qt + \title Building ActiveX servers in Qt + \ingroup qt-activex - \brief The QAxServer module is a Windows-only static library that - you can use to turn a standard Qt binary into a COM server. + \brief A Windows-only static library for turning a Qt binary into a COM server. The QAxServer module is part of the \l ActiveQt framework. It consists of three classes: diff --git a/doc/src/frameworks-technologies/activeqt.qdoc b/doc/src/frameworks-technologies/activeqt.qdoc index b752122..6f4ec30 100644 --- a/doc/src/frameworks-technologies/activeqt.qdoc +++ b/doc/src/frameworks-technologies/activeqt.qdoc @@ -53,11 +53,10 @@ /*! \page activeqt.html - \title ActiveQt Framework + \title Qt's ActiveX Framework (ActiveQt) \brief An overview of Qt's ActiveX and COM integration on Windows. - \ingroup platform-specific - \ingroup frameworks-technologies + \ingroup qt-activex \keyword ActiveQt Qt's ActiveX and COM support allows Qt for Windows developers to: diff --git a/doc/src/frameworks-technologies/containers.qdoc b/doc/src/frameworks-technologies/containers.qdoc index 505b65c..5b184fa 100644 --- a/doc/src/frameworks-technologies/containers.qdoc +++ b/doc/src/frameworks-technologies/containers.qdoc @@ -58,7 +58,7 @@ /*! \page containers.html \title Generic Containers - \ingroup frameworks-technologies + \ingroup technology-apis \ingroup groups \keyword container class \keyword container classes diff --git a/doc/src/frameworks-technologies/dbus-adaptors.qdoc b/doc/src/frameworks-technologies/dbus-adaptors.qdoc index 5fc7a79..11c5998 100644 --- a/doc/src/frameworks-technologies/dbus-adaptors.qdoc +++ b/doc/src/frameworks-technologies/dbus-adaptors.qdoc @@ -42,6 +42,7 @@ /*! \page usingadaptors.html \title Using QtDBus Adaptors + \ingroup technology-apis \ingroup best-practices diff --git a/doc/src/frameworks-technologies/dbus-intro.qdoc b/doc/src/frameworks-technologies/dbus-intro.qdoc index 1fe2ed2..10726e5 100644 --- a/doc/src/frameworks-technologies/dbus-intro.qdoc +++ b/doc/src/frameworks-technologies/dbus-intro.qdoc @@ -45,7 +45,7 @@ \brief An introduction to Inter-Process Communication and Remote Procedure Calling with D-Bus. \keyword QtDBus - \ingroup frameworks-technologies + \ingroup technology-apis \section1 Introduction diff --git a/doc/src/frameworks-technologies/desktop-integration.qdoc b/doc/src/frameworks-technologies/desktop-integration.qdoc index 7f01ae3..59b2570 100644 --- a/doc/src/frameworks-technologies/desktop-integration.qdoc +++ b/doc/src/frameworks-technologies/desktop-integration.qdoc @@ -40,16 +40,12 @@ ****************************************************************************/ /*! - \group desktop - \title Desktop Integration Classes -*/ - -/*! \page desktop-integration.html \title Desktop Integration \brief Integrating with the user's desktop environment. \ingroup best-practices + \ingroup qt-gui-concepts Qt applications behave well in the user's desktop environment, but certain integrations require additional, and sometimes platform specific, techniques. diff --git a/doc/src/frameworks-technologies/dnd.qdoc b/doc/src/frameworks-technologies/dnd.qdoc index 49468de..0e952ad 100644 --- a/doc/src/frameworks-technologies/dnd.qdoc +++ b/doc/src/frameworks-technologies/dnd.qdoc @@ -40,18 +40,12 @@ ****************************************************************************/ /*! - \group draganddrop - \title Drag And Drop Classes - - \brief Classes dealing with drag and drop and mime type encoding and decoding. -*/ - -/*! \page dnd.html \title Drag and Drop \brief An overview of the drag and drop system provided by Qt. - \ingroup frameworks-technologies + \ingroup technology-apis + \ingroup qt-gui-concepts Drag and drop provides a simple visual mechanism which users can use to transfer information between and within applications. (In the diff --git a/doc/src/frameworks-technologies/gestures.qdoc b/doc/src/frameworks-technologies/gestures.qdoc index 1b395b0..c999fa6 100644 --- a/doc/src/frameworks-technologies/gestures.qdoc +++ b/doc/src/frameworks-technologies/gestures.qdoc @@ -42,12 +42,13 @@ /*! \page gestures-overview.html \title Gestures Programming - \ingroup frameworks-technologies \startpage index.html Qt Reference Documentation + \ingroup technology-apis + \ingroup qt-gui-concepts - \brief An overview of the Qt support for Gesture programming. + \brief An overview of Qt support for Gesture programming. - Qt includes a framework for gesture programming that gives has the ability + Qt includes a framework for gesture programming that has the ability to form gestures from a series of events, independently of the input methods used. A gesture could be a particular movement of a mouse, a touch screen action, or a series of events from some other source. The nature of the input, diff --git a/doc/src/frameworks-technologies/graphicsview.qdoc b/doc/src/frameworks-technologies/graphicsview.qdoc index 1dd6c7c..681568e 100644 --- a/doc/src/frameworks-technologies/graphicsview.qdoc +++ b/doc/src/frameworks-technologies/graphicsview.qdoc @@ -51,8 +51,6 @@ \brief An overview of the Graphics View framework for interactive 2D graphics. - \ingroup frameworks-technologies - \keyword Graphics View \keyword GraphicsView \keyword Graphics diff --git a/doc/src/frameworks-technologies/implicit-sharing.qdoc b/doc/src/frameworks-technologies/implicit-sharing.qdoc index e4d6f65..f42ec93 100644 --- a/doc/src/frameworks-technologies/implicit-sharing.qdoc +++ b/doc/src/frameworks-technologies/implicit-sharing.qdoc @@ -50,7 +50,7 @@ /*! \page implicit-sharing.html \title Implicit Sharing - \ingroup frameworks-technologies + \ingroup qt-basic-concepts \brief Reference counting for fast copying. diff --git a/doc/src/frameworks-technologies/ipc.qdoc b/doc/src/frameworks-technologies/ipc.qdoc index 18a9455..5139f04 100644 --- a/doc/src/frameworks-technologies/ipc.qdoc +++ b/doc/src/frameworks-technologies/ipc.qdoc @@ -44,7 +44,8 @@ \title Inter-Process Communication in Qt \brief Inter-Process communication in Qt applications. - \ingroup frameworks-technologies + \ingroup technology-apis + \ingout qt-network Qt provides several ways to implement Inter-Process Communication (IPC) in Qt applications. diff --git a/doc/src/frameworks-technologies/phonon.qdoc b/doc/src/frameworks-technologies/phonon.qdoc index 2d035c7..61d7926 100644 --- a/doc/src/frameworks-technologies/phonon.qdoc +++ b/doc/src/frameworks-technologies/phonon.qdoc @@ -41,8 +41,8 @@ /*! \page phonon-overview.html - \title Phonon Overview - \ingroup frameworks-technologies + \title Phonon multimedia framework + \ingroup technology-apis \tableofcontents diff --git a/doc/src/frameworks-technologies/unicode.qdoc b/doc/src/frameworks-technologies/unicode.qdoc index 8fa168a..88393a0 100644 --- a/doc/src/frameworks-technologies/unicode.qdoc +++ b/doc/src/frameworks-technologies/unicode.qdoc @@ -58,7 +58,7 @@ \keyword Unicode - \ingroup frameworks-technologies + \ingroup technology-apis Unicode is a multi-byte character set, portable across all major computing platforms and with decent coverage over most of the world. diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index c9b6929..b759435 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -90,8 +90,9 @@
      diff --git a/doc/src/overviews.qdoc b/doc/src/overviews.qdoc index cee1109..0b82388 100644 --- a/doc/src/overviews.qdoc +++ b/doc/src/overviews.qdoc @@ -93,19 +93,27 @@ \generatelist {related} */ +/*! + \group technology-apis + \title Qt API's for other technologies + These pages document Qt's API's for some widely-used standards and + technologies. -/*! - \group frameworks-technologies - \title Frameworks and Technologies + \generatelist{related} +*/ - \brief Documentation about the frameworks and technologies in Qt +/*! + \group qt-activex + \title Qt For ActiveX + \brief Qt API's for using ActiveX controls, servers, and COM. + \ingroup technology-apis + \ingroup platform-specific - These documents dive into the frameworks of classes that Qt provides, - and provide background information about the technical solutions used - in Qt's architecture. + These pages document Qt's API's for developing with ActiveX + controls, servers, and COM. - \generatelist{related} + \generatelist{related} */ /*! diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc index 9e653e4..96eb16e 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc +++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc @@ -5,7 +5,9 @@ \previouspage QtSvg \nextpage QtXml \ingroup modules - \brief The QtWebKit module provides a web browser engine as well as + \ingroup technology-apis + + \brief The QtWebKit module provides a web browser engine and classes to render and interact with web content. To include the definitions of the module's classes, use the -- cgit v0.12 From 1022d67cde2c8c45c304612732e0399c66f8a04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 12 May 2010 14:51:00 +0200 Subject: Fixed QFont to respect the italics constructor flag. Creating a QFont with the constructor that takes the italic bool flag didn't work properly, since the property wasn't set to be resolved. It may be that the property should *always* be resolved, but to minimize impact, it's only done now if you pass in 'true' for italics. Reviewed-by: Eskil --- src/gui/text/qfont.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index b349bcf..b02a42e 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -805,6 +805,9 @@ QFont::QFont(const QString &family, int pointSize, int weight, bool italic) resolve_mask |= QFont::WeightResolved | QFont::StyleResolved; } + if (italic) + resolve_mask |= QFont::StyleResolved; + d->request.family = family; d->request.pointSize = qreal(pointSize); d->request.pixelSize = -1; -- cgit v0.12 From 953411c6eecc4175752ade1834bf8db3398961c5 Mon Sep 17 00:00:00 2001 From: Mirko Damiani Date: Wed, 12 May 2010 16:08:23 +0200 Subject: Skip definition of wintab functions in case of QT_NO_TABLETEVENT. Following functions are not compiled when QT_NO_TABLETEVENT is defined (both declaration and definition): - qt_tablet_init - qt_tablet_cleanup - init_wintab_functions - qt_tablet_init_wce - qt_tablet_cleanup_wce Merge-request: 2388 Reviewed-by: Benjamin Poulain --- src/gui/kernel/qwidget_win.cpp | 5 +++++ src/gui/kernel/qwidget_wince.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 7d647b7..c2a24fe 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -123,9 +123,11 @@ static PtrWTClose ptrWTClose = 0; static PtrWTInfo ptrWTInfo = 0; static PtrWTQueueSizeGet ptrWTQueueSizeGet = 0; static PtrWTQueueSizeSet ptrWTQueueSizeSet = 0; +#ifndef QT_NO_TABLETEVENT static void init_wintab_functions(); static void qt_tablet_init(); static void qt_tablet_cleanup(); +#endif // QT_NO_TABLETEVENT extern HCTX qt_tablet_context; extern bool qt_tablet_tilt_support; @@ -136,6 +138,8 @@ QWidget* qt_get_tablet_widget() } extern bool qt_is_gui_used; + +#ifndef QT_NO_TABLETEVENT static void init_wintab_functions() { #if defined(Q_OS_WINCE) @@ -227,6 +231,7 @@ static void qt_tablet_cleanup() delete qt_tablet_widget; qt_tablet_widget = 0; } +#endif // QT_NO_TABLETEVENT const QString qt_reg_winclass(QWidget *w); // defined in qapplication_win.cpp diff --git a/src/gui/kernel/qwidget_wince.cpp b/src/gui/kernel/qwidget_wince.cpp index 509847b..9c2c8c7 100644 --- a/src/gui/kernel/qwidget_wince.cpp +++ b/src/gui/kernel/qwidget_wince.cpp @@ -63,6 +63,7 @@ typedef BOOL (API *PtrWTGet)(HCTX, LPLOGCONTEXT); typedef int (API *PtrWTQueueSizeGet)(HCTX); typedef BOOL (API *PtrWTQueueSizeSet)(HCTX, int); +#ifndef QT_NO_TABLETEVENT static void qt_tablet_init_wce(); static void qt_tablet_cleanup_wce(); @@ -135,6 +136,7 @@ static void qt_tablet_cleanup_wce() { delete qt_tablet_widget; qt_tablet_widget = 0; } +#endif // QT_NO_TABLETEVENT // The internal qWinRequestConfig, defined in qapplication_win.cpp, stores move, -- cgit v0.12 From c03ecbc6163089f8eb73c97b7bfd05ab6269a278 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 12 May 2010 15:07:24 +0100 Subject: Fix wins def file for qtgui The .def file contained symbols for both: public: static int __cdecl QEglContext::display(void) public: int __thiscall QEglContext::display(void) const But the autogenerated def file comments showed both of these as just QEglContext::display(void) Leading to confusion. There is some bug in SBSv2 which made the postlink succeed on retry. Task-number: QTBUG-10520 Reviewed-by: Trust Me --- src/s60installs/bwins/QtGuiu.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index c7a23fb..88427ec 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -12597,7 +12597,7 @@ EXPORTS ?setConfig@QEglContext@@QAEXH@Z @ 12596 NONAME ; void QEglContext::setConfig(int) ?hasExtension@QEglContext@@SA_NPBD@Z @ 12597 NONAME ABSENT ; bool QEglContext::hasExtension(char const *) ?doneCurrent@QEglContext@@QAE_NXZ @ 12598 NONAME ; bool QEglContext::doneCurrent(void) - ?display@QEglContext@@QBEHXZ @ 12599 NONAME ; int QEglContext::display(void) const + ?display@QEglContext@@QBEHXZ @ 12599 NONAME ABSENT ; int QEglContext::display(void) const ?setPixelFormat@QEglProperties@@QAEXW4Format@QImage@@@Z @ 12600 NONAME ; void QEglProperties::setPixelFormat(enum QImage::Format) ?currentContext@QEglContext@@CAPAV1@W4API@QEgl@@@Z @ 12601 NONAME ; class QEglContext * QEglContext::currentContext(enum QEgl::API) ?errorString@QEglContext@@SA?AVQString@@H@Z @ 12602 NONAME ; class QString QEglContext::errorString(int) -- cgit v0.12 From e4902b4f25ca9c1ecff99609dbe376b407d9c6c5 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Tue, 11 May 2010 16:02:16 +0200 Subject: New Pad Nagivator example implementation. The old implementation was demo-quality and didn't really belong in the examples section. This new code cleans up the implementation, and also makes use of brand new features such as the state machine and animated transitions system. The new code is more suitable for documentation, and full docs are coming up in the next commit. --- examples/graphicsview/padnavigator/backside.ui | 208 ---------------- .../graphicsview/padnavigator/flippablepad.cpp | 90 +++++++ examples/graphicsview/padnavigator/flippablepad.h | 63 +++++ examples/graphicsview/padnavigator/main.cpp | 12 +- .../graphicsview/padnavigator/padnavigator.cpp | 265 +++++++++++++++++++++ examples/graphicsview/padnavigator/padnavigator.h | 65 +++++ .../graphicsview/padnavigator/padnavigator.pro | 23 +- examples/graphicsview/padnavigator/panel.cpp | 238 ------------------ examples/graphicsview/padnavigator/panel.h | 92 ------- .../graphicsview/padnavigator/roundrectitem.cpp | 129 +++------- examples/graphicsview/padnavigator/roundrectitem.h | 48 ++-- examples/graphicsview/padnavigator/splashitem.cpp | 44 ++-- examples/graphicsview/padnavigator/splashitem.h | 23 +- 13 files changed, 577 insertions(+), 723 deletions(-) delete mode 100644 examples/graphicsview/padnavigator/backside.ui create mode 100644 examples/graphicsview/padnavigator/flippablepad.cpp create mode 100644 examples/graphicsview/padnavigator/flippablepad.h create mode 100644 examples/graphicsview/padnavigator/padnavigator.cpp create mode 100644 examples/graphicsview/padnavigator/padnavigator.h delete mode 100644 examples/graphicsview/padnavigator/panel.cpp delete mode 100644 examples/graphicsview/padnavigator/panel.h diff --git a/examples/graphicsview/padnavigator/backside.ui b/examples/graphicsview/padnavigator/backside.ui deleted file mode 100644 index afa488c..0000000 --- a/examples/graphicsview/padnavigator/backside.ui +++ /dev/null @@ -1,208 +0,0 @@ - - BackSide - - - - 0 - 0 - 378 - 385 - - - - BackSide - - - - - - Settings - - - true - - - true - - - - - - Title: - - - - - - - Pad Navigator Example - - - - - - - Modified: - - - - - - - Extent - - - - - - - - - 42 - - - Qt::Horizontal - - - - - - - 42 - - - - - - - - - - - - - - - Other input - - - true - - - true - - - - - - - Widgets On Graphics View - - - - - QGraphicsProxyWidget - - - - QGraphicsWidget - - - - QObject - - - - - QGraphicsItem - - - - - QGraphicsLayoutItem - - - - - - - QGraphicsGridLayout - - - - QGraphicsLayout - - - - QGraphicsLayoutItem - - - - - - - QGraphicsLinearLayout - - - - QGraphicsLayout - - - - QGraphicsLayoutItem - - - - - - - - - - - - - groupBox - hostName - dateTimeEdit - horizontalSlider - spinBox - groupBox_2 - treeWidget - - - - - horizontalSlider - valueChanged(int) - spinBox - setValue(int) - - - 184 - 125 - - - 275 - 127 - - - - - spinBox - valueChanged(int) - horizontalSlider - setValue(int) - - - 272 - 114 - - - 190 - 126 - - - - - diff --git a/examples/graphicsview/padnavigator/flippablepad.cpp b/examples/graphicsview/padnavigator/flippablepad.cpp new file mode 100644 index 0000000..61f421f --- /dev/null +++ b/examples/graphicsview/padnavigator/flippablepad.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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 examples 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 "flippablepad.h" + +#include + +static QRectF boundsFromSize(const QSize &size) +{ + return QRectF((-size.width() / 2.0) * 150, (-size.height() / 2.0) * 150, + size.width() * 150, size.height() * 150); +} + +static QPointF posForLocation(int x, int y, const QSize &size) +{ + return QPointF(x * 150, y * 150) + - QPointF((size.width() - 1) * 75, (size.height() - 1) * 75); +} + +FlippablePad::FlippablePad(const QSize &size, QGraphicsItem *parent) + : RoundRectItem(boundsFromSize(size), QColor(226, 255, 92, 64), parent) +{ + columns = size.width(); + + int numIcons = size.width() * size.height(); + QList pixmaps; + QDirIterator it(":/images", QStringList() << "*.png"); + while (it.hasNext() && pixmaps.size() < numIcons) + pixmaps << it.next(); + + const QRectF iconRect(-54, -54, 108, 108); + const QColor iconColor(214, 240, 110, 128); + + iconGrid.resize(size.height()); + + int n = 0; + for (int y = 0; y < size.height(); ++y) { + iconGrid[y].resize(columns); + for (int x = 0; x < size.width(); ++x) { + RoundRectItem *rect = new RoundRectItem(iconRect, iconColor, this); + rect->setZValue(1); + rect->setPos(posForLocation(x, y, size)); + rect->setPixmap(pixmaps.at(n++ % pixmaps.size())); + iconGrid[y][x] = rect; + } + } +} + +RoundRectItem *FlippablePad::iconAt(int x, int y) const +{ + return iconGrid[y][x]; +} diff --git a/examples/graphicsview/padnavigator/flippablepad.h b/examples/graphicsview/padnavigator/flippablepad.h new file mode 100644 index 0000000..9adb18b --- /dev/null +++ b/examples/graphicsview/padnavigator/flippablepad.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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 examples 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 FLIPPABLEPAD_H +#define FLIPPABLEPAD_H + +#include "roundrectitem.h" + +#include +#include +#include + +class FlippablePad : public RoundRectItem +{ +public: + FlippablePad(const QSize &size, QGraphicsItem *parent = 0); + + RoundRectItem *iconAt(int x, int y) const; + +private: + int columns; + QVector > iconGrid; +}; + +#endif // FLIPPABLEPAD_H diff --git a/examples/graphicsview/padnavigator/main.cpp b/examples/graphicsview/padnavigator/main.cpp index fb6c120..6d148bb 100644 --- a/examples/graphicsview/padnavigator/main.cpp +++ b/examples/graphicsview/padnavigator/main.cpp @@ -39,21 +39,17 @@ ** ****************************************************************************/ -#include -#ifndef QT_NO_OPENGL -# include -#endif +#include "padnavigator.h" -#include "panel.h" +#include int main(int argc, char *argv[]) { QApplication app(argc, argv); Q_INIT_RESOURCE(padnavigator); - Panel panel(3, 3); - panel.setFocus(); - panel.show(); + PadNavigator navigator(QSize(3, 3)); + navigator.show(); return app.exec(); } diff --git a/examples/graphicsview/padnavigator/padnavigator.cpp b/examples/graphicsview/padnavigator/padnavigator.cpp new file mode 100644 index 0000000..456b3f4 --- /dev/null +++ b/examples/graphicsview/padnavigator/padnavigator.cpp @@ -0,0 +1,265 @@ +/**************************************************************************** +** +** 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 examples 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 "flippablepad.h" +#include "padnavigator.h" +#include "splashitem.h" +#include "ui_form.h" + +#include +#ifndef QT_NO_OPENGL +#include +#endif + +PadNavigator::PadNavigator(const QSize &size, QWidget *parent) + : QGraphicsView(parent) +{ + // Prepare splash item + SplashItem *splash = new SplashItem; + splash->setZValue(1); + + // Prepare pad item + FlippablePad *pad = new FlippablePad(size); + QGraphicsRotation *flipRotation = new QGraphicsRotation(pad); + flipRotation->setAxis(Qt::YAxis); + QGraphicsRotation *xRotation = new QGraphicsRotation(pad); + xRotation->setAxis(Qt::YAxis); + QGraphicsRotation *yRotation = new QGraphicsRotation(pad); + yRotation->setAxis(Qt::XAxis); + pad->setTransformations(QList() + << flipRotation + << xRotation << yRotation); + + // Prepare backitem + form = new Ui_Form; + QWidget *widget = new QWidget; + form->setupUi(widget); + form->hostName->setFocus(); + QGraphicsProxyWidget *backItem = new QGraphicsProxyWidget(pad); + backItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); + backItem->setWidget(widget); + backItem->setTransform(QTransform() + .rotate(180, Qt::YAxis) + .translate(-backItem->rect().width()/2, -backItem->rect().height()/2)); + backItem->setFocus(); + backItem->setVisible(false); + + // Prepare selection item + RoundRectItem *selectionItem = new RoundRectItem(QRectF(-60, -60, 120, 120), + Qt::gray, pad); + selectionItem->setZValue(0.5); + + // Selection animation setup + QPropertyAnimation *smoothXSelection = new QPropertyAnimation(selectionItem, "x"); + smoothXSelection->setDuration(125); + smoothXSelection->setEasingCurve(QEasingCurve::InOutQuad); + QPropertyAnimation *smoothYSelection = new QPropertyAnimation(selectionItem, "y"); + smoothYSelection->setDuration(125); + smoothYSelection->setEasingCurve(QEasingCurve::InOutQuad); + QPropertyAnimation *smoothXRotation = new QPropertyAnimation(xRotation, "angle"); + smoothXRotation->setDuration(125); + smoothXRotation->setEasingCurve(QEasingCurve::InOutQuad); + QPropertyAnimation *smoothYRotation = new QPropertyAnimation(yRotation, "angle"); + smoothYRotation->setDuration(125); + smoothYRotation->setEasingCurve(QEasingCurve::InOutQuad); + QPropertyAnimation *smoothScale = new QPropertyAnimation(pad, "scale"); + smoothScale->setDuration(500); + smoothScale->setKeyValueAt(0, qVariantValue(1.0)); + smoothScale->setKeyValueAt(0.5, qVariantValue(0.7)); + smoothScale->setKeyValueAt(1, qVariantValue(1.0)); + smoothScale->setEasingCurve(QEasingCurve::InOutQuad); + + // Flip animation setup + QPropertyAnimation *smoothFlipRotation = new QPropertyAnimation(flipRotation, "angle"); + smoothFlipRotation->setDuration(500); + smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad); + QPropertyAnimation *flipSmoothXRotation = new QPropertyAnimation(xRotation, "angle"); + flipSmoothXRotation->setDuration(500); + flipSmoothXRotation->setEasingCurve(QEasingCurve::InOutQuad); + QPropertyAnimation *flipSmoothYRotation = new QPropertyAnimation(yRotation, "angle"); + flipSmoothYRotation->setDuration(500); + flipSmoothYRotation->setEasingCurve(QEasingCurve::InOutQuad); + QPropertyAnimation *setBackItemVisibleAnim = new QPropertyAnimation(backItem, "visible"); + setBackItemVisibleAnim->setDuration(0); + QPropertyAnimation *setSelectionItemVisibleAnim = new QPropertyAnimation(selectionItem, "visible"); + setSelectionItemVisibleAnim->setDuration(0); + QPropertyAnimation *setFillAnim = new QPropertyAnimation(pad, "fill"); + setFillAnim->setDuration(0); + QSequentialAnimationGroup *setVisibleAnimation = new QSequentialAnimationGroup; + setVisibleAnimation->addPause(250); + setVisibleAnimation->addAnimation(setBackItemVisibleAnim); + setVisibleAnimation->addAnimation(setSelectionItemVisibleAnim); + setVisibleAnimation->addAnimation(setFillAnim); + QParallelAnimationGroup *flipAnimation = new QParallelAnimationGroup(this); + flipAnimation->addAnimation(smoothFlipRotation); + flipAnimation->addAnimation(smoothScale); + flipAnimation->addAnimation(flipSmoothXRotation); + flipAnimation->addAnimation(flipSmoothYRotation); + flipAnimation->addAnimation(setVisibleAnimation); + + QPropertyAnimation *smoothSplashMove = new QPropertyAnimation(splash, "y"); + smoothSplashMove->setEasingCurve(QEasingCurve::InQuad); + smoothSplashMove->setDuration(250); + QPropertyAnimation *smoothSplashOpacity = new QPropertyAnimation(splash, "opacity"); + smoothSplashOpacity->setDuration(250); + + // Build the state machine + QStateMachine *stateMachine = new QStateMachine(this); + QState *splashState = new QState(stateMachine); + QState *frontState = new QState(stateMachine); + QHistoryState *historyState = new QHistoryState(frontState); + QState *backState = new QState(stateMachine); + frontState->assignProperty(splash, "opacity", 0.0); + frontState->assignProperty(flipRotation, "angle", qVariantValue(0.0)); + frontState->assignProperty(backItem, "visible", false); + frontState->assignProperty(selectionItem, "visible", true); + frontState->assignProperty(pad, "fill", false); + backState->assignProperty(flipRotation, "angle", qVariantValue(180.0)); + backState->assignProperty(xRotation, "angle", qVariantValue(0.0)); + backState->assignProperty(yRotation, "angle", qVariantValue(0.0)); + backState->assignProperty(selectionItem, "visible", false); + backState->assignProperty(backItem, "visible", true); + backState->assignProperty(pad, "fill", true); + stateMachine->addDefaultAnimation(smoothXRotation); + stateMachine->addDefaultAnimation(smoothYRotation); + stateMachine->addDefaultAnimation(smoothXSelection); + stateMachine->addDefaultAnimation(smoothYSelection); + stateMachine->setInitialState(splashState); + + // Transitions + QEventTransition *anyKeyTransition = new QEventTransition(this, QEvent::KeyPress, splashState); + anyKeyTransition->setTargetState(frontState); + anyKeyTransition->addAnimation(smoothSplashMove); + anyKeyTransition->addAnimation(smoothSplashOpacity); + + QKeyEventTransition *enterTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Enter, backState); + enterTransition->setTargetState(historyState); + QKeyEventTransition *returnTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Return, backState); + returnTransition->setTargetState(historyState); + QKeyEventTransition *backEnterTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Enter, frontState); + backEnterTransition->setTargetState(backState); + QKeyEventTransition *backReturnTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Return, frontState); + backReturnTransition->setTargetState(backState); + enterTransition->addAnimation(flipAnimation); + returnTransition->addAnimation(flipAnimation); + backEnterTransition->addAnimation(flipAnimation); + backReturnTransition->addAnimation(flipAnimation); + + // Substates, one for each icon + int columns = size.width(); + int rows = size.height(); + QVector< QVector< QState * > > stateGrid; + stateGrid.resize(rows); + for (int y = 0; y < rows; ++y) { + stateGrid[y].resize(columns); + for (int x = 0; x < columns; ++x) { + QState *state = new QState(frontState); + stateGrid[y][x] = state; + } + } + frontState->setInitialState(stateGrid[0][0]); + selectionItem->setPos(pad->iconAt(0, 0)->pos()); + + // Enable key navigation using state transitions + for (int y = 0; y < rows; ++y) { + for (int x = 0; x < columns; ++x) { + QState *state = stateGrid[y][x]; + QKeyEventTransition *rightTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Right, state); + rightTransition->setTargetState(stateGrid[y][(x + 1) % columns]); + QKeyEventTransition *leftTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Left, state); + leftTransition->setTargetState(stateGrid[y][((x - 1) + columns) % columns]); + QKeyEventTransition *downTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Down, state); + downTransition->setTargetState(stateGrid[(y + 1) % rows][x]); + QKeyEventTransition *upTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Up, state); + upTransition->setTargetState(stateGrid[((y - 1) + rows) % rows][x]); + + RoundRectItem *icon = pad->iconAt(x, y); + state->assignProperty(xRotation, "angle", -icon->x() / 6.0); + state->assignProperty(yRotation, "angle", icon->y() / 6.0); + state->assignProperty(selectionItem, "x", icon->x()); + state->assignProperty(selectionItem, "y", icon->y()); + frontState->assignProperty(icon, "visible", true); + backState->assignProperty(icon, "visible", false); + + QPropertyAnimation *setVisibleAnim = new QPropertyAnimation(icon, "visible"); + setVisibleAnim->setDuration(0); + setVisibleAnimation->addAnimation(setVisibleAnim); + } + } + + // Setup scene + QGraphicsScene *scene = new QGraphicsScene(this); + scene->setBackgroundBrush(QPixmap(":/images/blue_angle_swirl.jpg")); + scene->setItemIndexMethod(QGraphicsScene::NoIndex); + scene->addItem(pad); + scene->setSceneRect(scene->itemsBoundingRect()); + setScene(scene); + + // Adjust splash item + splash->setPos(-splash->boundingRect().width() / 2, scene->sceneRect().top()); + frontState->assignProperty(splash, "y", splash->y() - 100.0); + scene->addItem(splash); + + // Setup view + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setMinimumSize(50, 50); + setViewportUpdateMode(FullViewportUpdate); + setCacheMode(CacheBackground); + setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform + | QPainter::TextAntialiasing); +#ifndef QT_NO_OPENGL + setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); +#endif + + stateMachine->start(); +} + +PadNavigator::~PadNavigator() +{ + delete form; +} + +void PadNavigator::resizeEvent(QResizeEvent *event) +{ + QGraphicsView::resizeEvent(event); + fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); +} diff --git a/examples/graphicsview/padnavigator/padnavigator.h b/examples/graphicsview/padnavigator/padnavigator.h new file mode 100644 index 0000000..c79a13c --- /dev/null +++ b/examples/graphicsview/padnavigator/padnavigator.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 examples 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 PADNAVIGATOR_H +#define PADNAVIGATOR_H + +#include + +class QState; +class QStateMachine; +class Ui_Form; + +class PadNavigator : public QGraphicsView +{ + Q_OBJECT +public: + explicit PadNavigator(const QSize &size, QWidget *parent = 0); + ~PadNavigator(); + +protected: + void resizeEvent(QResizeEvent *event); + +private: + Ui_Form *form; +}; + +#endif // PADNAVIGATOR_H diff --git a/examples/graphicsview/padnavigator/padnavigator.pro b/examples/graphicsview/padnavigator/padnavigator.pro index d6f536c..93ea293 100644 --- a/examples/graphicsview/padnavigator/padnavigator.pro +++ b/examples/graphicsview/padnavigator/padnavigator.pro @@ -1,19 +1,20 @@ -HEADERS += \ - panel.h \ - roundrectitem.h \ - splashitem.h +SOURCES += main.cpp \ + roundrectitem.cpp \ + flippablepad.cpp \ + padnavigator.cpp \ + splashitem.cpp -SOURCES += \ - panel.cpp \ - roundrectitem.cpp \ - splashitem.cpp \ - main.cpp +HEADERS += \ + roundrectitem.h \ + flippablepad.h \ + padnavigator.h \ + splashitem.h RESOURCES += \ - padnavigator.qrc + padnavigator.qrc FORMS += \ - backside.ui + form.ui contains(QT_CONFIG, opengl):QT += opengl diff --git a/examples/graphicsview/padnavigator/panel.cpp b/examples/graphicsview/padnavigator/panel.cpp deleted file mode 100644 index c4a5cd9..0000000 --- a/examples/graphicsview/padnavigator/panel.cpp +++ /dev/null @@ -1,238 +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 examples 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 "panel.h" -#include "roundrectitem.h" -#include "splashitem.h" -#include "ui_backside.h" - -#ifndef QT_NO_OPENGL -#include -#else -#endif -#include - -#include - -Panel::Panel(int width, int height) - : selectedX(0), - selectedY(0), - width(width), - height(height), - flipped(false), - flipLeft(true) -{ - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setCacheMode(CacheBackground); - setViewportUpdateMode(FullViewportUpdate); - setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform - | QPainter::TextAntialiasing); - setBackgroundBrush(QPixmap(":/images/blue_angle_swirl.jpg")); -#ifndef QT_NO_OPENGL - setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); -#endif - setMinimumSize(50, 50); - - selectionTimeLine = new QTimeLine(150, this); - flipTimeLine = new QTimeLine(500, this); - - QRectF bounds((-width / 2.0) * 150, (-height / 2.0) * 150, width * 150, height * 150); - - scene = new QGraphicsScene(bounds, this); - scene->setItemIndexMethod(QGraphicsScene::NoIndex); - setScene(scene); - - baseItem = new RoundRectItem(bounds, QColor(226, 255, 92, 64)); - scene->addItem(baseItem); - - QWidget *embed = new QWidget; - ui = new Ui_BackSide; - ui->setupUi(embed); - ui->hostName->setFocus(); - - backItem = new RoundRectItem(bounds, embed->palette().window(), embed); - backItem->setTransform(QTransform().rotate(180, Qt::YAxis)); - backItem->setParentItem(baseItem); - - selectionItem = new RoundRectItem(QRectF(-60, -60, 120, 120), Qt::gray); - selectionItem->setParentItem(baseItem); - selectionItem->setZValue(-1); - selectionItem->setPos(posForLocation(0, 0)); - startPos = selectionItem->pos(); - - grid = new QGraphicsItem **[height]; - - for (int y = 0; y < height; ++y) { - grid[y] = new QGraphicsItem *[width]; - - for (int x = 0; x < width; ++x) { - RoundRectItem *item = new RoundRectItem(QRectF(-54, -54, 108, 108), - QColor(214, 240, 110, 128)); - item->setPos(posForLocation(x, y)); - - item->setParentItem(baseItem); - item->setFlag(QGraphicsItem::ItemIsFocusable); - grid[y][x] = item; - - switch (qrand() % 9) { - case 0: item->setPixmap(QPixmap(":/images/kontact_contacts.png")); break; - case 1: item->setPixmap(QPixmap(":/images/kontact_journal.png")); break; - case 2: item->setPixmap(QPixmap(":/images/kontact_notes.png")); break; - case 3: item->setPixmap(QPixmap(":/images/kopeteavailable.png")); break; - case 4: item->setPixmap(QPixmap(":/images/metacontact_online.png")); break; - case 5: item->setPixmap(QPixmap(":/images/minitools.png")); break; - case 6: item->setPixmap(QPixmap(":/images/kontact_journal.png")); break; - case 7: item->setPixmap(QPixmap(":/images/kontact_contacts.png")); break; - case 8: item->setPixmap(QPixmap(":/images/kopeteavailable.png")); break; - default: - break; - } - - connect(item, SIGNAL(activated()), this, SLOT(flip())); - } - } - - grid[0][0]->setFocus(); - - connect(backItem, SIGNAL(activated()), - this, SLOT(flip())); - connect(selectionTimeLine, SIGNAL(valueChanged(qreal)), - this, SLOT(updateSelectionStep(qreal))); - connect(flipTimeLine, SIGNAL(valueChanged(qreal)), - this, SLOT(updateFlipStep(qreal))); - - splash = new SplashItem; - splash->setZValue(5); - splash->setPos(-splash->rect().width() / 2, scene->sceneRect().top()); - scene->addItem(splash); - - splash->grabKeyboard(); - - updateSelectionStep(0); - - setWindowTitle(tr("Pad Navigator Example")); -} - -Panel::~Panel() -{ - for (int y = 0; y < height; ++y) - delete [] grid[y]; - delete [] grid; -} - -void Panel::keyPressEvent(QKeyEvent *event) -{ - if (splash->isVisible() || event->key() == Qt::Key_Return || flipped) { - QGraphicsView::keyPressEvent(event); - return; - } - - selectedX = (selectedX + width + (event->key() == Qt::Key_Right) - (event->key() == Qt::Key_Left)) % width; - selectedY = (selectedY + height + (event->key() == Qt::Key_Down) - (event->key() == Qt::Key_Up)) % height; - grid[selectedY][selectedX]->setFocus(); - - selectionTimeLine->stop(); - startPos = selectionItem->pos(); - endPos = posForLocation(selectedX, selectedY); - selectionTimeLine->start(); -} - -void Panel::resizeEvent(QResizeEvent *event) -{ - QGraphicsView::resizeEvent(event); - fitInView(scene->sceneRect(), Qt::KeepAspectRatio); -} - -void Panel::updateSelectionStep(qreal val) -{ - QPointF newPos(startPos.x() + (endPos - startPos).x() * val, - startPos.y() + (endPos - startPos).y() * val); - selectionItem->setPos(newPos); - - QTransform transform; - yrot = newPos.x() / 6.0; - xrot = newPos.y() / 6.0; - transform.rotate(newPos.x() / 6.0, Qt::YAxis); - transform.rotate(newPos.y() / 6.0, Qt::XAxis); - baseItem->setTransform(transform); -} - -void Panel::updateFlipStep(qreal val) -{ - qreal finalxrot = xrot - xrot * val; - qreal finalyrot; - if (flipLeft) - finalyrot = yrot - yrot * val - 180 * val; - else - finalyrot = yrot - yrot * val + 180 * val; - QTransform transform; - transform.rotate(finalyrot, Qt::YAxis); - transform.rotate(finalxrot, Qt::XAxis); - qreal scale = 1 - sin(3.14 * val) * 0.3; - transform.scale(scale, scale); - baseItem->setTransform(transform); - if (val == 0) - grid[selectedY][selectedX]->setFocus(); -} - -void Panel::flip() -{ - if (flipTimeLine->state() == QTimeLine::Running) - return; - - if (flipTimeLine->currentValue() == 0) { - flipTimeLine->setDirection(QTimeLine::Forward); - flipTimeLine->start(); - flipped = true; - flipLeft = selectionItem->pos().x() < 0; - } else { - flipTimeLine->setDirection(QTimeLine::Backward); - flipTimeLine->start(); - flipped = false; - } -} - -QPointF Panel::posForLocation(int x, int y) const -{ - return QPointF(x * 150, y * 150) - - QPointF((width - 1) * 75, (height - 1) * 75); -} diff --git a/examples/graphicsview/padnavigator/panel.h b/examples/graphicsview/padnavigator/panel.h deleted file mode 100644 index 908092b..0000000 --- a/examples/graphicsview/padnavigator/panel.h +++ /dev/null @@ -1,92 +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 examples 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 - -QT_BEGIN_NAMESPACE -class QTimeLine; -class Ui_BackSide; -QT_END_NAMESPACE - -class RoundRectItem; - -class Panel : public QGraphicsView -{ - Q_OBJECT -public: - Panel(int width, int height); - ~Panel(); - -protected: - void keyPressEvent(QKeyEvent *event); - void resizeEvent(QResizeEvent *event); - -private Q_SLOTS: - void updateSelectionStep(qreal val); - void updateFlipStep(qreal val); - void flip(); - -private: - QPointF posForLocation(int x, int y) const; - - QGraphicsScene *scene; - RoundRectItem *selectionItem; - RoundRectItem *baseItem; - RoundRectItem *backItem; - QGraphicsWidget *splash; - QTimeLine *selectionTimeLine; - QTimeLine *flipTimeLine; - int selectedX, selectedY; - - QGraphicsItem ***grid; - - QPointF startPos; - QPointF endPos; - qreal xrot, yrot; - qreal xrot2, yrot2; - - int width; - int height; - bool flipped; - bool flipLeft; - - Ui_BackSide *ui; -}; diff --git a/examples/graphicsview/padnavigator/roundrectitem.cpp b/examples/graphicsview/padnavigator/roundrectitem.cpp index d53eea4..2141e9a 100644 --- a/examples/graphicsview/padnavigator/roundrectitem.cpp +++ b/examples/graphicsview/padnavigator/roundrectitem.cpp @@ -43,122 +43,61 @@ #include -RoundRectItem::RoundRectItem(const QRectF &rect, const QBrush &brush, QWidget *embeddedWidget) - : QGraphicsRectItem(rect), - brush(brush), - timeLine(75), - lastVal(0), - opa(1), - proxyWidget(0) +RoundRectItem::RoundRectItem(const QRectF &bounds, const QColor &color, + QGraphicsItem *parent) + : QGraphicsObject(parent), fillRect(false), color(color), bounds(bounds) { - connect(&timeLine, SIGNAL(valueChanged(qreal)), - this, SLOT(updateValue(qreal))); - - if (embeddedWidget) { - proxyWidget = new QGraphicsProxyWidget(this); - proxyWidget->setFocusPolicy(Qt::StrongFocus); - proxyWidget->setWidget(embeddedWidget); - proxyWidget->setGeometry(boundingRect().adjusted(25, 25, -25, -25)); - } -} + gradient.setStart(bounds.topLeft()); + gradient.setFinalStop(bounds.bottomRight()); + gradient.setColorAt(0, color); + gradient.setColorAt(1, color.dark(200)); -void RoundRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - QTransform x = painter->worldTransform(); - - QLineF unit = x.map(QLineF(0, 0, 1, 1)); - if (unit.p1().x() > unit.p2().x() || unit.p1().y() > unit.p2().y()) { - if (proxyWidget && proxyWidget->isVisible()) { - proxyWidget->hide(); - proxyWidget->setGeometry(rect()); - } - return; - } - - if (proxyWidget && !proxyWidget->isVisible()) { - proxyWidget->show(); - proxyWidget->setFocus(); - } - if (proxyWidget && proxyWidget->pos() != QPoint()) - proxyWidget->setGeometry(boundingRect().adjusted(25, 25, -25, -25)); - - painter->setOpacity(opacity()); - painter->setPen(Qt::NoPen); - painter->setBrush(QColor(0, 0, 0, 64)); - painter->drawRoundRect(rect().translated(2, 2)); - - if (!proxyWidget) { - QLinearGradient gradient(rect().topLeft(), rect().bottomRight()); - const QColor col = brush.color(); - gradient.setColorAt(0, col); - gradient.setColorAt(1, col.dark(int(200 + lastVal * 50))); - painter->setBrush(gradient); - } else { - painter->setBrush(brush); - } - - painter->setPen(QPen(Qt::black, 1)); - painter->drawRoundRect(rect()); - if (!pix.isNull()) { - painter->scale(1.95, 1.95); - painter->drawPixmap(-pix.width() / 2, -pix.height() / 2, pix);; - } + setCacheMode(ItemCoordinateCache); } -QRectF RoundRectItem::boundingRect() const +QPixmap RoundRectItem::pixmap() const { - qreal penW = 0.5; - qreal shadowW = 2.0; - return rect().adjusted(-penW, -penW, penW + shadowW, penW + shadowW); + return pix; } void RoundRectItem::setPixmap(const QPixmap &pixmap) { pix = pixmap; - if (scene() && isVisible()) - update(); -} - -qreal RoundRectItem::opacity() const -{ - RoundRectItem *parent = parentItem() ? (RoundRectItem *)parentItem() : 0; - return opa + (parent ? parent->opacity() : 0); + update(); } -void RoundRectItem::setOpacity(qreal opacity) +QRectF RoundRectItem::boundingRect() const { - opa = opacity; - update(); + return bounds.adjusted(0, 0, 2, 2); } -void RoundRectItem::keyPressEvent(QKeyEvent *event) +void RoundRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget) { - if (event->isAutoRepeat() || event->key() != Qt::Key_Return - || (timeLine.state() == QTimeLine::Running && timeLine.direction() == QTimeLine::Forward)) { - QGraphicsRectItem::keyPressEvent(event); - return; + Q_UNUSED(option); + Q_UNUSED(widget); + painter->setPen(Qt::NoPen); + painter->setBrush(QColor(0, 0, 0, 64)); + painter->drawRoundRect(bounds.translated(2, 2)); + if (fillRect) + painter->setBrush(QApplication::palette().brush(QPalette::Window)); + else + painter->setBrush(gradient); + painter->setPen(QPen(Qt::black, 1)); + painter->drawRoundRect(bounds); + if (!pix.isNull()) { + painter->scale(1.95, 1.95); + painter->drawPixmap(-pix.width() / 2, -pix.height() / 2, pix); } - - timeLine.stop(); - timeLine.setDirection(QTimeLine::Forward); - timeLine.start(); - emit activated(); } -void RoundRectItem::keyReleaseEvent(QKeyEvent *event) +bool RoundRectItem::fill() const { - if (event->key() != Qt::Key_Return) { - QGraphicsRectItem::keyReleaseEvent(event); - return; - } - timeLine.stop(); - timeLine.setDirection(QTimeLine::Backward); - timeLine.start(); + return fillRect; } -void RoundRectItem::updateValue(qreal value) +void RoundRectItem::setFill(bool fill) { - lastVal = value; - if (!proxyWidget) - setTransform(QTransform().scale(1 - value / 10.0, 1 - value / 10.0)); + fillRect = fill; + update(); } diff --git a/examples/graphicsview/padnavigator/roundrectitem.h b/examples/graphicsview/padnavigator/roundrectitem.h index 683c09f..ae5fb4c 100644 --- a/examples/graphicsview/padnavigator/roundrectitem.h +++ b/examples/graphicsview/padnavigator/roundrectitem.h @@ -39,45 +39,35 @@ ** ****************************************************************************/ -#include -#include -#include -#include +#ifndef ROUNDRECTITEM_H +#define ROUNDRECTITEM_H -QT_BEGIN_NAMESPACE -class QGraphicsProxyWidget; -QT_END_NAMESPACE +#include +#include -class RoundRectItem : public QObject, public QGraphicsRectItem +class RoundRectItem : public QGraphicsObject { Q_OBJECT + Q_PROPERTY(bool fill READ fill WRITE setFill) public: - RoundRectItem(const QRectF &rect, const QBrush &brush, QWidget *embeddedWidget = 0); - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *); - QRectF boundingRect() const; + RoundRectItem(const QRectF &bounds, const QColor &color, + QGraphicsItem *parent = 0); + QPixmap pixmap() const; void setPixmap(const QPixmap &pixmap); - qreal opacity() const; - void setOpacity(qreal opacity); - -Q_SIGNALS: - void activated(); - -protected: - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *event); + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); -private slots: - void updateValue(qreal value); + bool fill() const; + void setFill(bool fill); private: - QBrush brush; QPixmap pix; - QTimeLine timeLine; - qreal lastVal; - qreal opa; - - QGraphicsProxyWidget *proxyWidget; + bool fillRect; + QColor color; + QRectF bounds; + QLinearGradient gradient; }; + +#endif // ROUNDRECTITEM_H diff --git a/examples/graphicsview/padnavigator/splashitem.cpp b/examples/graphicsview/padnavigator/splashitem.cpp index b5b03d4..e609656 100644 --- a/examples/graphicsview/padnavigator/splashitem.cpp +++ b/examples/graphicsview/padnavigator/splashitem.cpp @@ -43,31 +43,31 @@ #include -SplashItem::SplashItem(QGraphicsItem *parent) - : QGraphicsWidget(parent) +SplashItem::SplashItem(QGraphicsItem *parent) : + QGraphicsObject(parent) { - opacity = 1.0; - - - timeLine = new QTimeLine(350); - timeLine->setCurveShape(QTimeLine::EaseInCurve); - connect(timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(setValue(qreal))); - text = tr("Welcome to the Pad Navigator Example. You can use the" " keyboard arrows to navigate the icons, and press enter" - " to activate an item. Please press any key to continue."); - resize(400, 175); + " to activate an item. Press any key to begin."); + setCacheMode(DeviceCoordinateCache); +} + +QRectF SplashItem::boundingRect() const +{ + return QRectF(0, 0, 400, 175); } -void SplashItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +void SplashItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget) { - painter->setOpacity(opacity); + Q_UNUSED(option); + Q_UNUSED(widget); painter->setPen(QPen(Qt::black, 2)); painter->setBrush(QColor(245, 245, 255, 220)); - painter->setClipRect(rect()); + painter->setClipRect(boundingRect()); painter->drawRoundRect(3, -100 + 3, 400 - 6, 250 - 6); - QRectF textRect = rect().adjusted(10, 10, -10, -10); + QRectF textRect = boundingRect().adjusted(10, 10, -10, -10); int flags = Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap; QFont font; @@ -76,17 +76,3 @@ void SplashItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWid painter->setFont(font); painter->drawText(textRect, flags, text); } - -void SplashItem::keyPressEvent(QKeyEvent * /* event */) -{ - if (timeLine->state() == QTimeLine::NotRunning) - timeLine->start(); -} - -void SplashItem::setValue(qreal value) -{ - opacity = 1 - value; - setPos(x(), scene()->sceneRect().top() - rect().height() * value); - if (value == 1) - hide(); -} diff --git a/examples/graphicsview/padnavigator/splashitem.h b/examples/graphicsview/padnavigator/splashitem.h index 7a33bee..9d57653 100644 --- a/examples/graphicsview/padnavigator/splashitem.h +++ b/examples/graphicsview/padnavigator/splashitem.h @@ -39,25 +39,22 @@ ** ****************************************************************************/ -#include -#include -#include +#ifndef SPLASHITEM_H +#define SPLASHITEM_H -class SplashItem : public QGraphicsWidget +#include + +class SplashItem : public QGraphicsObject { Q_OBJECT public: - SplashItem(QGraphicsItem *parent = 0); - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - -protected: - void keyPressEvent(QKeyEvent *event); + explicit SplashItem(QGraphicsItem *parent = 0); -private Q_SLOTS: - void setValue(qreal value); + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); private: - QTimeLine *timeLine; QString text; - qreal opacity; }; + +#endif // SPLASHITEM_H -- cgit v0.12 From 812f78e55aa3db4d51ec8617320358d80c4a71d5 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 12 May 2010 16:32:12 +0200 Subject: Documentation for the Pad Navigator Example. This also does a few touch-ups on the source code. --- doc/src/examples/padnavigator.qdoc | 552 ++++++++++++++++++++- doc/src/getting-started/examples.qdoc | 1 + .../graphicsview/padnavigator/flippablepad.cpp | 27 +- examples/graphicsview/padnavigator/flippablepad.h | 5 +- examples/graphicsview/padnavigator/main.cpp | 2 + .../graphicsview/padnavigator/padnavigator.cpp | 218 ++++---- examples/graphicsview/padnavigator/padnavigator.h | 6 +- .../graphicsview/padnavigator/roundrectitem.cpp | 19 +- examples/graphicsview/padnavigator/roundrectitem.h | 5 +- examples/graphicsview/padnavigator/splashitem.cpp | 10 +- examples/graphicsview/padnavigator/splashitem.h | 2 + 11 files changed, 736 insertions(+), 111 deletions(-) diff --git a/doc/src/examples/padnavigator.qdoc b/doc/src/examples/padnavigator.qdoc index 70e131e..e29a3b2 100644 --- a/doc/src/examples/padnavigator.qdoc +++ b/doc/src/examples/padnavigator.qdoc @@ -43,9 +43,555 @@ \example graphicsview/padnavigator \title Pad Navigator Example - The Pad Navigator Example shows how you can use Graphics View - together with embedded widgets to create a simple but useful - dynamic user interface for embedded devices. + The Pad Navigator Example shows how you can use Graphics View together with + embedded widgets and Qt's \l{State Machine Framework} to create a simple + but useful, dynamic, animated user interface. \image padnavigator-example.png + + The interface consists of a flippable, rotating pad with icons that can be + selected using the arrow keys on your keyboard or keypad. Pressing enter + will flip the pad around and reveal its back side, which has a form + embedded into a QGraphicsProxyWidget. You can interact with the form, and + press the enter key to flip back to the front side of the pad at any time. + + Graphics View provides the QGraphicsScene class for managing and + interacting with a large number of custom-made 2D graphical items derived + from the QGraphicsItem class, and a QGraphicsView widget for visualizing + the items, with support for zooming and rotation. + + This example consists of a \c RoundRectItem class, a \c FlippablePad class, + a \c PadNavigator class, a \c SplashItem class, and a \c main() function. + + \section1 RoundRectItem Class Definition + + The \c RoundRectItem class is used by itself to diplay the icons on the + pad, and as a base class for \c FlippablePad, the class for the pad itself. + The role of the class is to paint a round rectangle of a specified size and + gradient color, and optionally to paint a pixmap icon on top. To support \c + FlippablePad it also allows filling its contents with a plain window + background color. + + Let's start by reviewing the \c RoundRectItem class declaration. + + \snippet examples/graphicsview/padnavigator/roundrectitem.h 0 + + \c RoundRectItem inherits QGraphicsObject, which makes it easy to control + its properties using QPropertyAnimation. Its constructor takes a rectangle + to determine its bounds, and a color. + + Besides implementing the mandatory \l{QGraphicsItem::paint()}{paint()} and + \l{QGraphicsItem::boundingRect()}{boundingRect()} pure virtual functions, + it also provides the \c pixmap and \c fill properties. + + The \c pixmap property sets an optional pixmap that is drawn on top of the + round rectangle. The \c fill property will, when true, fill the round + rectangle contents with a fixed QPalette::Window background color. + Otherwise the contents are filled using a gradient based on the color + passed to \c RoundRectItem's constructor. + + \snippet examples/graphicsview/padnavigator/roundrectitem.h 1 + + The private data members are: + + \list + \o \c pix: The optional pixmap that is drawn on top of the rectangle. + \o \c fillRect: Corresponds to the \c fill property. + \o \c color: The configurable gradient color fill of the rectangle. + \o \c bounds: The bounds of the rectangle. + \o \c gradient: A precalculated gradient used to fill the rectangle. + \endlist + + We will now review the \c RoundRectItem implementation. Let's start by + looking at its constructor: + + \snippet examples/graphicsview/padnavigator/roundrectitem.cpp 0 + + The constructor initializes its member variables and forwards the \c parent + argument to QGraphicsObject's constructor. It then constructs the linear + gradient that is used in \l{QGraphicsItem::paint()}{paint()} to draw the + round rectangle's gradient background. The linear gradient's starting point + is at the top-left corner of the bounds, and the end is at the bottom-left + corner. The start color is identical to the color passed as an argument, + and a slightly darker color is chosen for the final stop. + + We store this gradient as a member variable to avoid having to recreate the + gradient every time the item is repainted. + + Finally we set the cache mode + \l{QGraphicsItem::ItemCoordinateCache}{ItemCoordinateCache}. This mode + causes the item's rendering to be cached into an off-screen pixmap that + remains persistent as we move and transform the item. This mode is ideal + for this example, and works particularily well with OpenGL and OpenGL ES. + + \snippet examples/graphicsview/padnavigator/roundrectitem.cpp 1 + + The \c pixmap property implementation simple returns the member pixmap, or + sets it and then calls \l{QGraphicsItem::update()}{update()}. + + \snippet examples/graphicsview/padnavigator/roundrectitem.cpp 2 + + As the \l{QGraphicsItem::paint()}{paint()} implementation below draws a + simple drop shadow down and to the right of the item, we return a slightly + adjusted rectangle from \l{QGraphicsItem::boundingRect()}{boundingRect()}. + + \snippet examples/graphicsview/padnavigator/roundrectitem.cpp 3 + + The \l{QGraphicsItem::paint()}{paint()} implementation starts by rendering + a semi transparent black round rectangle drop shadow, two units down and to + the right of the main item. + + \snippet examples/graphicsview/padnavigator/roundrectitem.cpp 4 + + We then draw the "foreground" round rectangle itself. The fill depends on + the \c fill property; if true, we will with a plain QPalette::Window color. + We get the corrent brush from QApplication::palette(). We assign a single + unit wide pen for the stroke, assign the brush, and then draw the + rectangle. + + \snippet examples/graphicsview/padnavigator/roundrectitem.cpp 5 + + If a pixmap has been assigned to the \e pixmap property, we draw this + pixmap in the center of the rectangle item. The pixmaps are scaled to match + the size of the icons; in arguably a better approach would have been to + store the icons with the right size in the first places. + + \snippet examples/graphicsview/padnavigator/roundrectitem.cpp 6 + + Finally, for completeness we include the \c fill property implementation. + It returns the \c fill member variable's value, and when assigned to, it + calls \l{QGraphicsItem::update()}{update()}. + + As mentioned already, \c RoundRectItem is the base class for \c + FlippablePad, which is the class representing the tilting pad itself. We + will proceed to reviewing \c FlippablePad. + + \section1 FlippablePad Class Definition + + \c FlippablePad is, in addition to its inherited \c RoundRectItem + responsibilities, responsible for creating and managing a grid of icons. + + \snippet examples/graphicsview/padnavigator/flippablepad.h 0 + + Its declaration is very simple: It inherits \c RoundRectItem and does not + need any special polymorphic behavior. It's suitable to declare its own + constructor, and a getter-function that allows \c PadNavigator to access + the icons in the grid by (row, column). + + The example has no "real" behavior or logic of any kind, and because of + that, the icons do not need to provide any \e behavior or special + interactions management. In a real application, however, it would be + natural for the \c FlippablePad and its icons to handle more of the + navigation logic. In this example, we have chosen to leave this to + the \c PadNavigator class, which we will get back to below. + + We will now review the \c FlippablePad implementation. This implementation + starts with two helper functions: \c boundsFromSize() and \c + posForLocation(): + + \snippet examples/graphicsview/padnavigator/flippablepad.cpp 0 + + \c boundsForSize() takes a QSize argument, and returns the bounding + rectangle of the flippable pad item. The QSize determines how many rows and + columns the icon grid should have. Each icon is given 150x150 units of + space, and this determines the bounds. + + \snippet examples/graphicsview/padnavigator/flippablepad.cpp 1 + + \c posForLocation() returns the position of an icon given its row and + column position. Like \c boundsForSize(), the function assumes each icon is + given 150x150 units of space, and that all icons are centered around the + flippable pad item's origin (0, 0). + + \snippet examples/graphicsview/padnavigator/flippablepad.cpp 2 + + The \c FlippablePad constructor passes suitable bounds (using \c + boundsForSize()) and specific color to \c RoundRectItem's constructor. + + \snippet examples/graphicsview/padnavigator/flippablepad.cpp 3 + + It then loads pixmaps from compiled-in resources to use for its icons. + QDirIterator is very useful in this context, as it allows us to fetch all + resource "*.png" files inside the \c :/images directory without explicitly + naming the files. + + We also make sure not to load more pixmaps than we need. + + \snippet examples/graphicsview/padnavigator/flippablepad.cpp 4 + + Now that we have the pixmaps, we can create icons, position then and assign + pixmaps. We start by finding a suitable size and color for the icons, and + initializing a convenient grid structure for storing the icons. This \c + iconGrid is also used later to find the icon for a specific (column, row) + location. + + For each row and column in our grid, we proceed to constructing each icon + as an instance of \c RoundRectItem. The item is placed by using the \c + posForLocation() helper function. To make room for the slip-behind + selection item, we give each icon a \l{QGraphicsItem::zValue()}{Z-value} of + 1. The pixmaps are distributed to the icons in round-robin fasion. + + Again, this approach is only suitable for example purposes. In a real-life + application where each icon represents a specific action, it would be more + natural to assign the pixmaps directly, or that the icons themselves + provide suitable pixmaps. + + \snippet examples/graphicsview/padnavigator/flippablepad.cpp 5 + + Finally, the \c iconAt() function returns a pointer to the icon at a + specific row and column. It makes a somewhat bold assumption that the input + is valid, which is fair because the \c PadNavigator class only calls this + function with correct input. + + We will now review the \c SplashItem class. + + \section1 SplashItem Class Definition + + The \c SplashItem class represents the "splash window", a semitransparent + white overlay with text that appears immediately after the application has + started, and disappears after pressing any key. The animation is controlled + by \c PadNavigator; this class is very simple by itself. + + \snippet examples/graphicsview/padnavigator/splashitem.h 0 + + The class declaration shows that \c SplashItem inherits QGraphicsObject to + allow it to be controlled by QPropertyAnimation. It reimplements the + mandatory \l{QGraphicsItem::paint()}{paint()} and + \l{QGraphicsItem::boundingRect()}{boundingRect()} pure virtual functions, + and keeps a \c text member variable which will contain the information text + displayed on this splash item. + + Let's look at its implementation. + + \snippet examples/graphicsview/padnavigator/splashitem.cpp 0 + + The constructor forwards to QGraphicsObject as expected, assigns a text + message to the \c text member variable, and enables + \l{QGraphicsItem::DeviceCoordinateCache}{DeviceCoordinateCache}. This cache + mode is suitable because the splash item only moves and is never + transformed, and because it contains text, it's important that it has a + pixel perfect visual appearance (in constrast to + \l{QGraphicsItem::ItemCoordinateCache}{ItemCoordinateCache}, where the + visual appearance is not as good). + + We use caching to avoid having to relayout and rerender the text for each + frame. An alterative approach would be to use the new QStaticText class. + + \snippet examples/graphicsview/padnavigator/splashitem.cpp 1 + + \c SplashItem's bounding rectangle is fixed at (400x175). + + \snippet examples/graphicsview/padnavigator/splashitem.cpp 2 + + The \l{QGraphicsItem::paint()}{paint()} implementation draws a clipped + round rectangle with a thick 2-unit border and a semi-transparent white + background. It proceeds to finding a suitable text area by adjusting the + splash item's bounding rectangle with 10 units in each side. The text is + rendered inside this rectangle, with top-left alignment, and with word + wrapping enabled. + + The main class now remains. We will proceed to reviewing \c PadNavigator. + + \section1 PadNavigator Class Definition + + \c PadNavigator represents the main window of our Pad Navigator Example + application. It creates and controls a somewhat complex state machine, and + several animations. Its class declaration is very simple: + + \snippet examples/graphicsview/padnavigator/padnavigator.h 0 + + It inherits QGraphicsView and reimplements only one function: + \l{QGraphicsView::resizeEvent()}{resizeEvent()}, to ensure the scene is + scaled to fit inside the view when resizing the main window. + + The \c PadNavigator constructor takes a QSize argument that determines the + number or rows and columns in the grid. + + It also keeps a private member instance, \c form, which is the generated + code for the pad's back side item's QGraphicsProxyWidget-embedded form. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 0 + + \c PadNavigator's constructor is a bit long. In short, its job is to create + all items, including the \c FlippablePad, the \c SplashItem and the + QGraphicsProxyWidget \c backItem, and then to set up all animations, states + and transitions that control the behavior of the application. + + It starts out simple, by forwarding to QGraphicsView's constructor. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 1 + + The first item to be created is \c SplashItem. This is going to be a top-level + item in the scene, next to \c FlippablePad, and stacked on top of it, so we + assign it a \l{QGraphicsItem::zValue()}{Z-value} of 1. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 2 + + Now we construct the \c FlippablePad item, passing its column-row count to + its constructor. + + The pad is constrolled by three transformations, and we create one + QGraphicsRotation object for each of these. + + \list + \o \c flipRotation: Rotates the grid around its Qt::YAxis. This rotation is + animated from 0 to 180, and eventually back, when enter is pressed on the + keyboard, flipping the pad around. + \o \c xRotation: Rotates the grid around its Qt::XAxis. This is used to + tilt the pad vertically corresponding to which item is currently selected. + This way, the selected item is always kept in front. + \o \c yRotation: Rotates the grid around its Qt::YAxis. This is used to + tilt the pad horizontally corresponding to which item is selected. This + way, the selected item is always kept in front. + \endlist + + The combination of all three rotations is assigned via + QGraphicsItem::setTransformations(). + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 3 + + Now we construct the QGraphicsProxyWidget-embedded \c backItem. The proxy + widget is created as a child of the pad. We create a new QWidget and + populate it with the \c form member. To ensure the \c hostName line edit is + the first to receive input focus when this item is shown, we call + \l{QWidget::setFocus()}{setFocus()} immediately. This will not give the + widget focus right away; it will only prepare the item to automatically + receive focus once it is shown. + + The QWidget based form is embedded into the proxy widget. The proxy is + hidden initially; we only want to show it when the pad is rotated at least + 90 degrees, and we also rotate the proxy itself by 180 degrees. This way we + give the impression that the proxy widget is "behind" the flipped pad, when + in fact, it's actually \e{on top of it}. + + We enable \l{QGraphicsItem::ItemCoordinateCache}{ItemCoordinateCache} to + ensure the flip animation can run smoothly. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 4 + + We now create the selection item. This is simply another instance of \c + RoundRectItem that is slightly larger than the icons on the pad. We create + it as an immediate child of the \c FlippablePad, so the selection item is a + sibling to all the icons. By giving it a + \l{QGraphicsItem::zValue()}{Z-value} of 0.5 we ensure it will slide beteen + the pad and its icons. + + What follows now is a series of animation initializations. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 5 + + We begin with the animations that apply to the splash item. The first + animation, \c smoothSplashMove, ensures that the "y" property of \c splash + will be animated with a 250-millisecond duration + \l{QEasingCurve::InQuad}{InQuad} easing function. \c smoothSplashOpacity + ensures the opacity of \c splash eases in and out in 250 milliseconds. + + The values are assigned by \c PadNavigator's state machine, which is + created later. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 6 + + These are the animations that control the selection item's movement and the + \c xRotation and \c yRotation QGraphicsRotation objects that tilt the pad. + All animations have a duration of 125 milliseconds, and they all use the + \l{QEasingCurve::InOutQuad}{InOutQuad} easing function. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 7 + + We now create the animations that control the flip-effect when you press + the enter key. The main goal is to rotate the pad by 180 degrees or back, + but we also need to make sure the selection item's tilt rotations are reset + back to 0 when the pad is flipped, and restored back to their original + values when flipped back: + + \list + \o \c smoothFlipRotation: Animates the main 180 degree rotation of the pad. + \o \c smoothFlipScale: Scales the pad out and then in again while the pad is rotating. + \o \c smoothFlipXRotation: Animates the selection item's X-tilt to 0 and back. + \o \c smoothFlipYRotation: Animates the selection item's Y-tilt to 0 and back. + \o \c flipAnimation: A parallel animation group that ensures all the above animations are run in parallel. + \endlist + + All animations are given a 500 millisecond duration and an + \l{QEasingCurve::InOutQuad}{InOutQuad} easing function. + + It's worth taking a close look at \c smoothFlipScale. This animation's + start and end values are both 1.0, but at animation step 0.5 the + animation's value is 0.7. This means that after 50% of the animation's + duration, or 250 milliseconds, the pad will be scaled down to 0.7x of its + original size, which gives a great visual effect while flipping. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 8 + + This section uses a trick to ensure that certain properties are assigned + precisely when the flip animation passes 50%, or 90 degrees, rotation. In + short, the pad's icons and selection item are all hidden, the pad's \c fill + property is enabled, and \c backItem is shown when flipping over. When + flipping back, the reverse properties are applied. + + The way this is achieved is by running a sequential animation in parallel + to the other animations. This sequence, dubbed \c setVariablesSequence, + starts with a 250 millisecond pause, and then executes several animations + with a duration of 0. Each animation will ensure that properties are set + immediate at this point. + + This approach can also be used to call functions or set any other + properties at a specific time while an animation is running. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 9 + + We will now create the state machine. The whole \c PadNavigator state + machinery is controlled by one single state machine that has a + straight-forward state structure. The state engine itself is created + as a child of the \c PadNavigator itself. We then create three top level + states: + + \list + \o \c splashState: The initial state where the splash item is visible. + \o \c frontState: The base state where the splash is gone and we can see + the front side of the pad, and navigate the selection item. + \o \c backState: The flipped state where the \c backItem is visible, and we + can interact with the QGraphicsProxyWidget-embedded form. + \endlist + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 10 + + Each state assigns specific properties to objects on entry. Most + interesting perhaps is the assignment of the value 0.0 to the pad's \c + flipRotation angle property when in \c frontState, and 180.0 when in \c + backState. At the end of this section we register default animations with + the state engine; these animations will apply to their respective objects + and properties for any state transition. Otherwise it's common to assign + animations to specific transitions. + + The \c splashState state is set as the initial state. This is required + before we start the state engine. We proceed with creating some + transitions. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 11 + + QEventTransition defines a very flexible transition type. You can use this + class to trigger a transition based on an object receiving an event of a + specific type. In this case, we would like to transition from \c + splashState into \c frontState if \c PadNavigator receives any key press + event (QEvent::KeyPress). + + We register the \c splashItem's animations to this transition to ensure they + are used to animate the item's movement and opacity. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 12 + + We use QKeyEventTransition to capture specific key events. In this case, we + detect that the user presses Qt::Key_Return or Qt::Key_Enter, and use this + to trigger transitions between \c frontState and backState. We register \c + flipAnimation, our complex parallel animation group, with these + transitions. + + We continue by defining the states for each of the icons in the grid. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 13 + + We will use state groups to control transitions between icons. Each icon + represents a \e substate of \c frontState. We will then define transitions + between the states by detecting key presses, using QKeyEventTransition. + + We start by creating all the substates, and at the same time we create a + temporary grid structure for the states to make it easier to find which + states represents icons that are up, down, left and to the right each + other. + + Once the first substate is known, we set this up as the initial substate of + \c frontState. We will use the (0, 0), or top-left, icon for the initial + substate. We initialze the selection item's position to be exactly where + the top-left icon is. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 14 + + We can now create four transitions for each icon. Each transition ensures + that we move to the state corresponding to which arrow key has been + pressed. It's clear from this techinique that we could design any other + specific transitions to and from each of the sub states depending on these + and other keys. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 15 + + Also, for each of the icons, we assign suitable values to the \c xRotation + and \c yRotation objects' "angle"-properties. If you recall, these + properties "tilt" the pad corresponding to which item is currently + selected. We ensure each icon is invisible when the pad is flipped, and + visible when the pad is not flipped. To ensure the visible property is + assigned at the right time, we add property-controlling animations to the + \c setVariableSequence animation defined earlier. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 16 + + We are now finished with all states, transitions, and animations. We now + create the scene that will contain all our items. The scene gets a defined + background pixmap, and we disable item indexing (as most items in this + scene are animated). We add our \c pad item to the scene, and use its + bounding rectangle to fixate the scene rectangle. This rectangle is used by + the view to find a suitable size for the application window. + + Then the scene is assigned to the view, or in our case, \c PadNavigator + itself. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 17 + + Now that the scene has received its final size, we can position the splash + item at the very top, find its fade-out position, and add it to the scene. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 18 + + The view toggles a few necessary properties: + + \list + \o It disables its scroll bars - this application has no use for scroll bars. + \o It assigns a minimum size. This is necessary to avoid numerical errors + in our fit-in-view \c resizeEvent() implementation. + \o It sets \l{QGraphicsView::FullViewportUpdate}{FullViewportUpdate}, to + ensure QGraphicsView doesn't spend time figuring out precisely what needs + to be redrawn. This application is very simple - if anything changes, + everything is updated. + \o It enables background caching - this makes no performance difference + with OpenGL, but without OpenGL it avoids unnecessary re-scaling of the + background pixmap. + \o It sets render hints that increase rendering quality. + \o If OpenGL is supported, a QGLWidget viewport is assigned to the view. + \endlist + + Finally, we start the state engine. + + \snippet examples/graphicsview/padnavigator/padnavigator.cpp 19 + + The \l{QGraphicsView::resizeEvent()}{resizeEvent()} implementation calls + the base implementation, and then calls QGraphicsView::fitInView() to scale + the scene so that it fits perfectly inside the view. + + By resizing the main application window, you can see this effect yourself. + The scene contents grow when you make the window larger, and shrink when + you make it smaller, while keeping the aspect ratio intact. + + \section1 The main() Function + + \snippet examples/graphicsview/padnavigator/main.cpp 0 + + The \c main function creates the QApplication instance, uses + Q_INIT_RESOURCE to ensure our compiled-in resources aren't removed by the + linker, and then creates a 3x3 \c PadNavigator instance and shows it. + + Our flippable pad shows up with a suitable splash item once control returns + to the event loop. + + \section1 Performance Notes + + The example uses OpenGL if this is available, to achieve optimal + performance; otherwise perspective tranformations can be quite costly. + + Although this example does use QGraphicsProxyWidget to demonstrate + integration of Qt widget components integrated into Graphics View, using + QGraphicsProxyWidget comes with a performance penalty, and is therefore not + recommended for embedded development. + + This example uses extensive item caching to avoid rerendering of static + elements, at the expense of graphics memory. */ diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index 542f672..f511cd6 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -651,6 +651,7 @@ \o \l{graphicsview/diagramscene}{Diagram Scene}\raisedaster \o \l{graphicsview/dragdroprobot}{Drag and Drop Robot}\raisedaster \o \l{graphicsview/elasticnodes}{Elastic Nodes}\raisedaster + \o \l{graphicsview/padnavigator}{Pad Navigator}\raisedaster \o \l{graphicsview/portedasteroids}{Ported Asteroids} \o \l{graphicsview/portedcanvas}{Ported Canvas} \endlist diff --git a/examples/graphicsview/padnavigator/flippablepad.cpp b/examples/graphicsview/padnavigator/flippablepad.cpp index 61f421f..58aea00 100644 --- a/examples/graphicsview/padnavigator/flippablepad.cpp +++ b/examples/graphicsview/padnavigator/flippablepad.cpp @@ -43,37 +43,43 @@ #include +//! [0] static QRectF boundsFromSize(const QSize &size) { return QRectF((-size.width() / 2.0) * 150, (-size.height() / 2.0) * 150, size.width() * 150, size.height() * 150); } +//! [0] -static QPointF posForLocation(int x, int y, const QSize &size) +//! [1] +static QPointF posForLocation(int column, int row, const QSize &size) { - return QPointF(x * 150, y * 150) + return QPointF(column * 150, row * 150) - QPointF((size.width() - 1) * 75, (size.height() - 1) * 75); } +//! [1] +//! [2] FlippablePad::FlippablePad(const QSize &size, QGraphicsItem *parent) : RoundRectItem(boundsFromSize(size), QColor(226, 255, 92, 64), parent) { - columns = size.width(); - +//! [2] +//! [3] int numIcons = size.width() * size.height(); QList pixmaps; QDirIterator it(":/images", QStringList() << "*.png"); while (it.hasNext() && pixmaps.size() < numIcons) pixmaps << it.next(); +//! [3] +//! [4] const QRectF iconRect(-54, -54, 108, 108); const QColor iconColor(214, 240, 110, 128); - iconGrid.resize(size.height()); - int n = 0; + for (int y = 0; y < size.height(); ++y) { - iconGrid[y].resize(columns); + iconGrid[y].resize(size.width()); for (int x = 0; x < size.width(); ++x) { RoundRectItem *rect = new RoundRectItem(iconRect, iconColor, this); rect->setZValue(1); @@ -83,8 +89,11 @@ FlippablePad::FlippablePad(const QSize &size, QGraphicsItem *parent) } } } +//! [4] -RoundRectItem *FlippablePad::iconAt(int x, int y) const +//! [5] +RoundRectItem *FlippablePad::iconAt(int column, int row) const { - return iconGrid[y][x]; + return iconGrid[row][column]; } +//! [5] diff --git a/examples/graphicsview/padnavigator/flippablepad.h b/examples/graphicsview/padnavigator/flippablepad.h index 9adb18b..7d99536 100644 --- a/examples/graphicsview/padnavigator/flippablepad.h +++ b/examples/graphicsview/padnavigator/flippablepad.h @@ -48,16 +48,17 @@ #include #include +//! [0] class FlippablePad : public RoundRectItem { public: FlippablePad(const QSize &size, QGraphicsItem *parent = 0); - RoundRectItem *iconAt(int x, int y) const; + RoundRectItem *iconAt(int column, int row) const; private: - int columns; QVector > iconGrid; }; +//! [0] #endif // FLIPPABLEPAD_H diff --git a/examples/graphicsview/padnavigator/main.cpp b/examples/graphicsview/padnavigator/main.cpp index 6d148bb..984b976 100644 --- a/examples/graphicsview/padnavigator/main.cpp +++ b/examples/graphicsview/padnavigator/main.cpp @@ -43,6 +43,7 @@ #include +//! [0] int main(int argc, char *argv[]) { QApplication app(argc, argv); @@ -53,3 +54,4 @@ int main(int argc, char *argv[]) return app.exec(); } +//! [0] diff --git a/examples/graphicsview/padnavigator/padnavigator.cpp b/examples/graphicsview/padnavigator/padnavigator.cpp index 456b3f4..b1d19f6 100644 --- a/examples/graphicsview/padnavigator/padnavigator.cpp +++ b/examples/graphicsview/padnavigator/padnavigator.cpp @@ -42,175 +42,213 @@ #include "flippablepad.h" #include "padnavigator.h" #include "splashitem.h" -#include "ui_form.h" #include #ifndef QT_NO_OPENGL #include #endif +//! [0] PadNavigator::PadNavigator(const QSize &size, QWidget *parent) : QGraphicsView(parent) { - // Prepare splash item +//! [0] +//! [1] + // Splash item SplashItem *splash = new SplashItem; splash->setZValue(1); +//! [1] - // Prepare pad item +//! [2] + // Pad item FlippablePad *pad = new FlippablePad(size); QGraphicsRotation *flipRotation = new QGraphicsRotation(pad); - flipRotation->setAxis(Qt::YAxis); QGraphicsRotation *xRotation = new QGraphicsRotation(pad); - xRotation->setAxis(Qt::YAxis); QGraphicsRotation *yRotation = new QGraphicsRotation(pad); + flipRotation->setAxis(Qt::YAxis); + xRotation->setAxis(Qt::YAxis); yRotation->setAxis(Qt::XAxis); pad->setTransformations(QList() << flipRotation << xRotation << yRotation); +//! [2] - // Prepare backitem - form = new Ui_Form; - QWidget *widget = new QWidget; - form->setupUi(widget); - form->hostName->setFocus(); +//! [3] + // Back (proxy widget) item QGraphicsProxyWidget *backItem = new QGraphicsProxyWidget(pad); - backItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); + QWidget *widget = new QWidget; + form.setupUi(widget); + form.hostName->setFocus(); backItem->setWidget(widget); + backItem->setVisible(false); + backItem->setFocus(); + backItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); + const QRectF r = backItem->rect(); backItem->setTransform(QTransform() .rotate(180, Qt::YAxis) - .translate(-backItem->rect().width()/2, -backItem->rect().height()/2)); - backItem->setFocus(); - backItem->setVisible(false); + .translate(-r.width()/2, -r.height()/2)); +//! [3] - // Prepare selection item +//! [4] + // Selection item RoundRectItem *selectionItem = new RoundRectItem(QRectF(-60, -60, 120, 120), Qt::gray, pad); selectionItem->setZValue(0.5); +//! [4] - // Selection animation setup +//! [5] + // Splash animations + QPropertyAnimation *smoothSplashMove = new QPropertyAnimation(splash, "y"); + QPropertyAnimation *smoothSplashOpacity = new QPropertyAnimation(splash, "opacity"); + smoothSplashMove->setEasingCurve(QEasingCurve::InQuad); + smoothSplashMove->setDuration(250); + smoothSplashOpacity->setDuration(250); +//! [5] + +//! [6] + // Selection animation QPropertyAnimation *smoothXSelection = new QPropertyAnimation(selectionItem, "x"); - smoothXSelection->setDuration(125); - smoothXSelection->setEasingCurve(QEasingCurve::InOutQuad); QPropertyAnimation *smoothYSelection = new QPropertyAnimation(selectionItem, "y"); - smoothYSelection->setDuration(125); - smoothYSelection->setEasingCurve(QEasingCurve::InOutQuad); QPropertyAnimation *smoothXRotation = new QPropertyAnimation(xRotation, "angle"); - smoothXRotation->setDuration(125); - smoothXRotation->setEasingCurve(QEasingCurve::InOutQuad); QPropertyAnimation *smoothYRotation = new QPropertyAnimation(yRotation, "angle"); + smoothXSelection->setDuration(125); + smoothYSelection->setDuration(125); + smoothXRotation->setDuration(125); smoothYRotation->setDuration(125); + smoothXSelection->setEasingCurve(QEasingCurve::InOutQuad); + smoothYSelection->setEasingCurve(QEasingCurve::InOutQuad); + smoothXRotation->setEasingCurve(QEasingCurve::InOutQuad); smoothYRotation->setEasingCurve(QEasingCurve::InOutQuad); - QPropertyAnimation *smoothScale = new QPropertyAnimation(pad, "scale"); - smoothScale->setDuration(500); - smoothScale->setKeyValueAt(0, qVariantValue(1.0)); - smoothScale->setKeyValueAt(0.5, qVariantValue(0.7)); - smoothScale->setKeyValueAt(1, qVariantValue(1.0)); - smoothScale->setEasingCurve(QEasingCurve::InOutQuad); +//! [6] +//! [7] // Flip animation setup QPropertyAnimation *smoothFlipRotation = new QPropertyAnimation(flipRotation, "angle"); + QPropertyAnimation *smoothFlipScale = new QPropertyAnimation(pad, "scale"); + QPropertyAnimation *smoothFlipXRotation = new QPropertyAnimation(xRotation, "angle"); + QPropertyAnimation *smoothFlipYRotation = new QPropertyAnimation(yRotation, "angle"); + QParallelAnimationGroup *flipAnimation = new QParallelAnimationGroup(this); + smoothFlipScale->setDuration(500); smoothFlipRotation->setDuration(500); + smoothFlipXRotation->setDuration(500); + smoothFlipYRotation->setDuration(500); + smoothFlipScale->setEasingCurve(QEasingCurve::InOutQuad); smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad); - QPropertyAnimation *flipSmoothXRotation = new QPropertyAnimation(xRotation, "angle"); - flipSmoothXRotation->setDuration(500); - flipSmoothXRotation->setEasingCurve(QEasingCurve::InOutQuad); - QPropertyAnimation *flipSmoothYRotation = new QPropertyAnimation(yRotation, "angle"); - flipSmoothYRotation->setDuration(500); - flipSmoothYRotation->setEasingCurve(QEasingCurve::InOutQuad); - QPropertyAnimation *setBackItemVisibleAnim = new QPropertyAnimation(backItem, "visible"); - setBackItemVisibleAnim->setDuration(0); - QPropertyAnimation *setSelectionItemVisibleAnim = new QPropertyAnimation(selectionItem, "visible"); - setSelectionItemVisibleAnim->setDuration(0); - QPropertyAnimation *setFillAnim = new QPropertyAnimation(pad, "fill"); - setFillAnim->setDuration(0); - QSequentialAnimationGroup *setVisibleAnimation = new QSequentialAnimationGroup; - setVisibleAnimation->addPause(250); - setVisibleAnimation->addAnimation(setBackItemVisibleAnim); - setVisibleAnimation->addAnimation(setSelectionItemVisibleAnim); - setVisibleAnimation->addAnimation(setFillAnim); - QParallelAnimationGroup *flipAnimation = new QParallelAnimationGroup(this); + smoothFlipXRotation->setEasingCurve(QEasingCurve::InOutQuad); + smoothFlipYRotation->setEasingCurve(QEasingCurve::InOutQuad); + smoothFlipScale->setKeyValueAt(0, qVariantValue(1.0)); + smoothFlipScale->setKeyValueAt(0.5, qVariantValue(0.7)); + smoothFlipScale->setKeyValueAt(1, qVariantValue(1.0)); flipAnimation->addAnimation(smoothFlipRotation); - flipAnimation->addAnimation(smoothScale); - flipAnimation->addAnimation(flipSmoothXRotation); - flipAnimation->addAnimation(flipSmoothYRotation); - flipAnimation->addAnimation(setVisibleAnimation); + flipAnimation->addAnimation(smoothFlipScale); + flipAnimation->addAnimation(smoothFlipXRotation); + flipAnimation->addAnimation(smoothFlipYRotation); +//! [7] - QPropertyAnimation *smoothSplashMove = new QPropertyAnimation(splash, "y"); - smoothSplashMove->setEasingCurve(QEasingCurve::InQuad); - smoothSplashMove->setDuration(250); - QPropertyAnimation *smoothSplashOpacity = new QPropertyAnimation(splash, "opacity"); - smoothSplashOpacity->setDuration(250); +//! [8] + // Flip animation delayed property assignment + QSequentialAnimationGroup *setVariablesSequence = new QSequentialAnimationGroup; + QPropertyAnimation *setFillAnimation = new QPropertyAnimation(pad, "fill"); + QPropertyAnimation *setBackItemVisibleAnimation = new QPropertyAnimation(backItem, "visible"); + QPropertyAnimation *setSelectionItemVisibleAnimation = new QPropertyAnimation(selectionItem, "visible"); + setFillAnimation->setDuration(0); + setBackItemVisibleAnimation->setDuration(0); + setSelectionItemVisibleAnimation->setDuration(0); + setVariablesSequence->addPause(250); + setVariablesSequence->addAnimation(setBackItemVisibleAnimation); + setVariablesSequence->addAnimation(setSelectionItemVisibleAnimation); + setVariablesSequence->addAnimation(setFillAnimation); + flipAnimation->addAnimation(setVariablesSequence); +//! [8] +//! [9] // Build the state machine QStateMachine *stateMachine = new QStateMachine(this); QState *splashState = new QState(stateMachine); QState *frontState = new QState(stateMachine); QHistoryState *historyState = new QHistoryState(frontState); QState *backState = new QState(stateMachine); +//! [9] +//! [10] + frontState->assignProperty(pad, "fill", false); frontState->assignProperty(splash, "opacity", 0.0); - frontState->assignProperty(flipRotation, "angle", qVariantValue(0.0)); frontState->assignProperty(backItem, "visible", false); + frontState->assignProperty(flipRotation, "angle", qVariantValue(0.0)); frontState->assignProperty(selectionItem, "visible", true); - frontState->assignProperty(pad, "fill", false); - backState->assignProperty(flipRotation, "angle", qVariantValue(180.0)); + backState->assignProperty(pad, "fill", true); + backState->assignProperty(backItem, "visible", true); backState->assignProperty(xRotation, "angle", qVariantValue(0.0)); backState->assignProperty(yRotation, "angle", qVariantValue(0.0)); + backState->assignProperty(flipRotation, "angle", qVariantValue(180.0)); backState->assignProperty(selectionItem, "visible", false); - backState->assignProperty(backItem, "visible", true); - backState->assignProperty(pad, "fill", true); stateMachine->addDefaultAnimation(smoothXRotation); stateMachine->addDefaultAnimation(smoothYRotation); stateMachine->addDefaultAnimation(smoothXSelection); stateMachine->addDefaultAnimation(smoothYSelection); stateMachine->setInitialState(splashState); +//! [10] +//! [11] // Transitions QEventTransition *anyKeyTransition = new QEventTransition(this, QEvent::KeyPress, splashState); anyKeyTransition->setTargetState(frontState); anyKeyTransition->addAnimation(smoothSplashMove); anyKeyTransition->addAnimation(smoothSplashOpacity); +//! [11] - QKeyEventTransition *enterTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Enter, backState); +//! [12] + QKeyEventTransition *enterTransition = new QKeyEventTransition(this, QEvent::KeyPress, + Qt::Key_Enter, backState); + QKeyEventTransition *returnTransition = new QKeyEventTransition(this, QEvent::KeyPress, + Qt::Key_Return, backState); + QKeyEventTransition *backEnterTransition = new QKeyEventTransition(this, QEvent::KeyPress, + Qt::Key_Enter, frontState); + QKeyEventTransition *backReturnTransition = new QKeyEventTransition(this, QEvent::KeyPress, + Qt::Key_Return, frontState); enterTransition->setTargetState(historyState); - QKeyEventTransition *returnTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Return, backState); returnTransition->setTargetState(historyState); - QKeyEventTransition *backEnterTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Enter, frontState); backEnterTransition->setTargetState(backState); - QKeyEventTransition *backReturnTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Return, frontState); backReturnTransition->setTargetState(backState); enterTransition->addAnimation(flipAnimation); returnTransition->addAnimation(flipAnimation); backEnterTransition->addAnimation(flipAnimation); backReturnTransition->addAnimation(flipAnimation); +//! [12] - // Substates, one for each icon +//! [13] + // Create substates for each icon; store in temporary grid. int columns = size.width(); int rows = size.height(); QVector< QVector< QState * > > stateGrid; stateGrid.resize(rows); for (int y = 0; y < rows; ++y) { stateGrid[y].resize(columns); - for (int x = 0; x < columns; ++x) { - QState *state = new QState(frontState); - stateGrid[y][x] = state; - } + for (int x = 0; x < columns; ++x) + stateGrid[y][x] = new QState(frontState); } frontState->setInitialState(stateGrid[0][0]); selectionItem->setPos(pad->iconAt(0, 0)->pos()); +//! [13] +//! [14] // Enable key navigation using state transitions for (int y = 0; y < rows; ++y) { for (int x = 0; x < columns; ++x) { QState *state = stateGrid[y][x]; - QKeyEventTransition *rightTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Right, state); + QKeyEventTransition *rightTransition = new QKeyEventTransition(this, QEvent::KeyPress, + Qt::Key_Right, state); + QKeyEventTransition *leftTransition = new QKeyEventTransition(this, QEvent::KeyPress, + Qt::Key_Left, state); + QKeyEventTransition *downTransition = new QKeyEventTransition(this, QEvent::KeyPress, + Qt::Key_Down, state); + QKeyEventTransition *upTransition = new QKeyEventTransition(this, QEvent::KeyPress, + Qt::Key_Up, state); rightTransition->setTargetState(stateGrid[y][(x + 1) % columns]); - QKeyEventTransition *leftTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Left, state); leftTransition->setTargetState(stateGrid[y][((x - 1) + columns) % columns]); - QKeyEventTransition *downTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Down, state); downTransition->setTargetState(stateGrid[(y + 1) % rows][x]); - QKeyEventTransition *upTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Up, state); upTransition->setTargetState(stateGrid[((y - 1) + rows) % rows][x]); - +//! [14] +//! [15] RoundRectItem *icon = pad->iconAt(x, y); state->assignProperty(xRotation, "angle", -icon->x() / 6.0); state->assignProperty(yRotation, "angle", icon->y() / 6.0); @@ -219,47 +257,51 @@ PadNavigator::PadNavigator(const QSize &size, QWidget *parent) frontState->assignProperty(icon, "visible", true); backState->assignProperty(icon, "visible", false); - QPropertyAnimation *setVisibleAnim = new QPropertyAnimation(icon, "visible"); - setVisibleAnim->setDuration(0); - setVisibleAnimation->addAnimation(setVisibleAnim); + QPropertyAnimation *setIconVisibleAnimation = new QPropertyAnimation(icon, "visible"); + setIconVisibleAnimation->setDuration(0); + setVariablesSequence->addAnimation(setIconVisibleAnimation); } } +//! [15] - // Setup scene +//! [16] + // Scene QGraphicsScene *scene = new QGraphicsScene(this); scene->setBackgroundBrush(QPixmap(":/images/blue_angle_swirl.jpg")); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->addItem(pad); scene->setSceneRect(scene->itemsBoundingRect()); setScene(scene); +//! [16] - // Adjust splash item - splash->setPos(-splash->boundingRect().width() / 2, scene->sceneRect().top()); +//! [17] + // Adjust splash item to scene contents + const QRectF sbr = splash->boundingRect(); + splash->setPos(-sbr.width() / 2, scene->sceneRect().top() - 2); frontState->assignProperty(splash, "y", splash->y() - 100.0); scene->addItem(splash); +//! [17] - // Setup view +//! [18] + // View setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setMinimumSize(50, 50); setViewportUpdateMode(FullViewportUpdate); setCacheMode(CacheBackground); - setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform - | QPainter::TextAntialiasing); + setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing); #ifndef QT_NO_OPENGL setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); #endif stateMachine->start(); +//! [18] } -PadNavigator::~PadNavigator() -{ - delete form; -} - +//! [19] void PadNavigator::resizeEvent(QResizeEvent *event) { QGraphicsView::resizeEvent(event); fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); } +//! [19] diff --git a/examples/graphicsview/padnavigator/padnavigator.h b/examples/graphicsview/padnavigator/padnavigator.h index c79a13c..03a1ea2 100644 --- a/examples/graphicsview/padnavigator/padnavigator.h +++ b/examples/graphicsview/padnavigator/padnavigator.h @@ -43,23 +43,25 @@ #define PADNAVIGATOR_H #include +#include "ui_form.h" class QState; class QStateMachine; class Ui_Form; +//! [0] class PadNavigator : public QGraphicsView { Q_OBJECT public: explicit PadNavigator(const QSize &size, QWidget *parent = 0); - ~PadNavigator(); protected: void resizeEvent(QResizeEvent *event); private: - Ui_Form *form; + Ui_Form form; }; +//! [0] #endif // PADNAVIGATOR_H diff --git a/examples/graphicsview/padnavigator/roundrectitem.cpp b/examples/graphicsview/padnavigator/roundrectitem.cpp index 2141e9a..7a0b279 100644 --- a/examples/graphicsview/padnavigator/roundrectitem.cpp +++ b/examples/graphicsview/padnavigator/roundrectitem.cpp @@ -43,34 +43,39 @@ #include +//! [0] RoundRectItem::RoundRectItem(const QRectF &bounds, const QColor &color, QGraphicsItem *parent) - : QGraphicsObject(parent), fillRect(false), color(color), bounds(bounds) + : QGraphicsObject(parent), fillRect(false), bounds(bounds) { gradient.setStart(bounds.topLeft()); gradient.setFinalStop(bounds.bottomRight()); gradient.setColorAt(0, color); gradient.setColorAt(1, color.dark(200)); - setCacheMode(ItemCoordinateCache); } +//! [0] +//! [1] QPixmap RoundRectItem::pixmap() const { return pix; } - void RoundRectItem::setPixmap(const QPixmap &pixmap) { pix = pixmap; update(); } +//! [1] +//! [2] QRectF RoundRectItem::boundingRect() const { return bounds.adjusted(0, 0, 2, 2); } +//! [2] +//! [3] void RoundRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { @@ -79,25 +84,31 @@ void RoundRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt painter->setPen(Qt::NoPen); painter->setBrush(QColor(0, 0, 0, 64)); painter->drawRoundRect(bounds.translated(2, 2)); +//! [3] +//! [4] if (fillRect) painter->setBrush(QApplication::palette().brush(QPalette::Window)); else painter->setBrush(gradient); painter->setPen(QPen(Qt::black, 1)); painter->drawRoundRect(bounds); +//! [4] +//! [5] if (!pix.isNull()) { painter->scale(1.95, 1.95); painter->drawPixmap(-pix.width() / 2, -pix.height() / 2, pix); } } +//! [5] +//! [6] bool RoundRectItem::fill() const { return fillRect; } - void RoundRectItem::setFill(bool fill) { fillRect = fill; update(); } +//! [6] diff --git a/examples/graphicsview/padnavigator/roundrectitem.h b/examples/graphicsview/padnavigator/roundrectitem.h index ae5fb4c..bc58cec 100644 --- a/examples/graphicsview/padnavigator/roundrectitem.h +++ b/examples/graphicsview/padnavigator/roundrectitem.h @@ -45,6 +45,7 @@ #include #include +//! [0] class RoundRectItem : public QGraphicsObject { Q_OBJECT @@ -61,13 +62,15 @@ public: bool fill() const; void setFill(bool fill); +//! [0] +//! [1] private: QPixmap pix; bool fillRect; - QColor color; QRectF bounds; QLinearGradient gradient; }; +//! [1] #endif // ROUNDRECTITEM_H diff --git a/examples/graphicsview/padnavigator/splashitem.cpp b/examples/graphicsview/padnavigator/splashitem.cpp index e609656..cd7074a 100644 --- a/examples/graphicsview/padnavigator/splashitem.cpp +++ b/examples/graphicsview/padnavigator/splashitem.cpp @@ -43,20 +43,25 @@ #include -SplashItem::SplashItem(QGraphicsItem *parent) : - QGraphicsObject(parent) +//! [0] +SplashItem::SplashItem(QGraphicsItem *parent) + : QGraphicsObject(parent) { text = tr("Welcome to the Pad Navigator Example. You can use the" " keyboard arrows to navigate the icons, and press enter" " to activate an item. Press any key to begin."); setCacheMode(DeviceCoordinateCache); } +//! [0] +//! [1] QRectF SplashItem::boundingRect() const { return QRectF(0, 0, 400, 175); } +//! [1] +//! [2] void SplashItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { @@ -76,3 +81,4 @@ void SplashItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option painter->setFont(font); painter->drawText(textRect, flags, text); } +//! [2] diff --git a/examples/graphicsview/padnavigator/splashitem.h b/examples/graphicsview/padnavigator/splashitem.h index 9d57653..98c4a1f 100644 --- a/examples/graphicsview/padnavigator/splashitem.h +++ b/examples/graphicsview/padnavigator/splashitem.h @@ -44,6 +44,7 @@ #include +//! [0] class SplashItem : public QGraphicsObject { Q_OBJECT @@ -56,5 +57,6 @@ public: private: QString text; }; +//! [0] #endif // SPLASHITEM_H -- cgit v0.12 From 5987412720498aa22202a1bcca3cb988a9cf5606 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Wed, 12 May 2010 17:00:46 +0200 Subject: Doc: Adding loading image to search textbox --- doc/src/template/images/spinner.gif | Bin 0 -> 2037 bytes doc/src/template/scripts/functions.js | 14 +++++++++++--- doc/src/template/style/style.css | 4 ++++ tools/qdoc3/test/qt-html-templates.qdocconf | 6 +++--- 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 doc/src/template/images/spinner.gif diff --git a/doc/src/template/images/spinner.gif b/doc/src/template/images/spinner.gif new file mode 100644 index 0000000..1ed786f Binary files /dev/null and b/doc/src/template/images/spinner.gif differ diff --git a/doc/src/template/scripts/functions.js b/doc/src/template/scripts/functions.js index 09b7de3..7d93486 100755 --- a/doc/src/template/scripts/functions.js +++ b/doc/src/template/scripts/functions.js @@ -40,6 +40,7 @@ var exampleCount = 0; var qturl = ""; // change from "http://doc.qt.nokia.com/4.6/" to 0 so we can have relative links function processNokiaData(response){ +$('.sidebar .search form input').addClass('loading'); // debug $('.content').prepend('
    • handling search results
    • '); // debuging var propertyTags = response.getElementsByTagName('page'); @@ -92,7 +93,8 @@ function processNokiaData(response){ } } - if(lookupCount == 0){$('#ul001').prepend('
    • Found no result
    • ');$('#ul001 li').css('display','block');} + if(lookupCount == 0){$('#ul001').prepend('
    • Found no result
    • ');$('#ul001 li').css('display','block');$('.sidebar .search form input').removeClass('loading'); +} if(articleCount == 0){$('#ul002').prepend('
    • Found no result
    • ');$('#ul002 li').css('display','block');} if(exampleCount == 0){$('#ul003').prepend('
    • Found no result
    • ');$('#ul003 li').css('display','block');} // reset count variables; @@ -119,8 +121,14 @@ function CheckEmptyAndLoadList() $('.defaultLink').css('display','none'); } } - - +/* +$(window).resize(function(){ +if($(window).width()<400) + $('body').addClass('offline'); +else + $('body').removeClass('offline'); + }); + */ // Loads on doc ready $(document).ready(function () { var pageTitle = $('title').html(); diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index d87b11f..5ad90e3 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -1131,6 +1131,10 @@ visibility: hidden; } +.sidebar .search form input.loading +{ + background:url("../images/spinner.gif") no-repeat scroll right center transparent; +} /* end of screen media */ diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 31fc414..9af2f92 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -105,7 +105,7 @@ HTML.postpostheader = " \n" \ "
      \n" HTML.footer = " \n" \ - "
      \n" \ + "
      \n" \ " [+] Documentation Feedback
      \n" \ "
      \n" \ "
      \n" \ @@ -124,12 +124,12 @@ HTML.footer = " \n" \ "
      \n" \ "
      \n" \ "
      \n" \ - " X\n" \ + " X\n" \ "
      \n" \ " \n" \ "

      \n" \ " \n" \ - "

      \n" \ " \n" \ "
      \n" \ -- cgit v0.12 From 0fd9d9ca457aa3e400188214f79830cd853e6348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 12 May 2010 17:10:58 +0200 Subject: Remove an unnecessary assert. Reviewed-by: Kim --- src/opengl/qgl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index a3c1bac..7c457de 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1723,7 +1723,6 @@ QGLTextureCache::QGLTextureCache() QGLTextureCache::~QGLTextureCache() { - Q_ASSERT(size() == 0); QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTexturesForPixampData); QImagePixmapCleanupHooks::instance()->removePixmapDataDestructionHook(cleanupBeforePixmapDestruction); QImagePixmapCleanupHooks::instance()->removeImageHook(cleanupTexturesForCacheKey); @@ -2888,7 +2887,7 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth); glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight); - if (d_ptr->active_engine && + if (d_ptr->active_engine && d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { QGL2PaintEngineEx *eng = static_cast(d_ptr->active_engine); if (!eng->isNativePaintingActive()) { -- cgit v0.12 From 770a2428357f030d4efad8c64ceb381ce50c9fb9 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 12 May 2010 17:36:04 +0200 Subject: Compile fix on Windows. Reviewed-by: Trond --- src/gui/painting/qstroker_p.h | 2 +- src/gui/painting/qtransform.cpp | 2 +- src/opengl/qpaintengine_opengl.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h index 0f133ef..d646135 100644 --- a/src/gui/painting/qstroker_p.h +++ b/src/gui/painting/qstroker_p.h @@ -125,7 +125,7 @@ typedef void (*qStrokerCubicToHook)(qfixed c1x, qfixed c1y, void *data); // qtransform.cpp -extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); +Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); class Q_GUI_EXPORT QStrokerOps { diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index c72a08e..aaa241f 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1545,7 +1545,7 @@ static inline bool lineTo_clipped(QPainterPath &path, const QTransform &transfor return true; } -bool qt_scaleForTransform(const QTransform &transform, qreal *scale); +Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); static inline bool cubicTo_clipped(QPainterPath &path, const QTransform &transform, const QPointF &a, const QPointF &b, const QPointF &c, const QPointF &d, bool needsMoveTo) { diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index d2b0d4f..08a50cb 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -3950,7 +3950,7 @@ void QOpenGLPaintEnginePrivate::strokeLines(const QPainterPath &path) enableClipping(); } -extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp +Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp void QOpenGLPaintEnginePrivate::strokePath(const QPainterPath &path, bool use_cache) { -- cgit v0.12 From 7f1b5ae80535f7be95002ef947744828ad70be89 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 12 May 2010 17:39:12 +0200 Subject: Workaround for ATI driver bug when using QGraphicsEffect with GL. If you forward declare a shader function which takes a sampler as argument, the shader program will fail to link on ATI cards under Windows. Task-number: QTBUG-10510 Reviewed-by: Trond --- src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 10 ++++++---- src/opengl/gl2paintengineex/qglengineshadersource_p.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 8183f08..0c98e3b 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -265,10 +265,12 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS do { QByteArray source; - source.append(qShaderSnippets[prog.mainFragShader]); - source.append(qShaderSnippets[prog.srcPixelFragShader]); + // Insert the custom stage before the srcPixel shader to work around an ATI driver bug + // where you cannot forward declare a function that takes a sampler as argument. if (prog.srcPixelFragShader == CustomImageSrcFragmentShader) source.append(prog.customStageSource); + source.append(qShaderSnippets[prog.mainFragShader]); + source.append(qShaderSnippets[prog.srcPixelFragShader]); if (prog.compositionFragShader) source.append(qShaderSnippets[prog.compositionFragShader]); if (prog.maskFragShader) @@ -765,8 +767,8 @@ bool QGLEngineShaderManager::useCorrectShaderProg() // doesn't use are disabled) QGLContextPrivate* ctx_d = ctx->d_func(); ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); - ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg->useTextureCoords); - ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg->useOpacityAttribute); + ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg && currentShaderProg->useTextureCoords); + ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg && currentShaderProg->useOpacityAttribute); shaderProgNeedsChanging = false; return true; diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index c88c041..c963265 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -343,7 +343,6 @@ static const char* const qglslImageSrcFragmentShader = "\n\ static const char* const qglslCustomSrcFragmentShader = "\n\ varying highp vec2 textureCoords; \n\ uniform lowp sampler2D imageTexture; \n\ - lowp vec4 customShader(lowp sampler2D texture, highp vec2 coords); \n\ lowp vec4 srcPixel() \n\ { \n\ return customShader(imageTexture, textureCoords); \n\ -- cgit v0.12 From f699d9af27c8450a36266d8542c54d53a6d57f15 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 12 May 2010 15:55:27 +0200 Subject: Add 'runonphone' target for symbian / makefile This new target simply takes a sis file and runs the app on phone. Reviewed-by: Shane Kearns --- mkspecs/common/symbian/symbian-makefile.conf | 1 + mkspecs/features/symbian/run_on_phone.prf | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 mkspecs/features/symbian/run_on_phone.prf diff --git a/mkspecs/common/symbian/symbian-makefile.conf b/mkspecs/common/symbian/symbian-makefile.conf index 2397c96..66b3d7f 100644 --- a/mkspecs/common/symbian/symbian-makefile.conf +++ b/mkspecs/common/symbian/symbian-makefile.conf @@ -26,6 +26,7 @@ include(../../common/unix.conf) QMAKE_PREFIX_SHLIB = QMAKE_EXTENSION_SHLIB = dll CONFIG *= no_plugin_name_prefix +CONFIG += run_on_phone QMAKE_EXTENSION_PLUGIN = dll QMAKE_PREFIX_STATICLIB = QMAKE_EXTENSION_STATICLIB = lib diff --git a/mkspecs/features/symbian/run_on_phone.prf b/mkspecs/features/symbian/run_on_phone.prf new file mode 100644 index 0000000..c4c7baf --- /dev/null +++ b/mkspecs/features/symbian/run_on_phone.prf @@ -0,0 +1,9 @@ +# make sure we have a sis file and then call 'runonphone' to execute it on the phone + +contains(TEMPLATE, app) { + run_target.target = runonphone + run_target.depends = sis + run_target.commands = runonphone $(QT_RUN_ON_PHONE_OPTIONS) --sis "$${sis_destdir}$${TARGET}.sis" "$${TARGET}.exe" $(QT_RUN_OPTIONS) + + QMAKE_EXTRA_TARGETS += run_target +} -- cgit v0.12 From c8f5e6043e9a8baa02905ad434e26f5602315ef4 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 12 May 2010 17:26:03 +0100 Subject: Fix spurious mouse click when dismissing a native menu Native menus are dismissed by the key press event. The Qt application then receives the key up event, as it now has keyboard focus. The virtual mouse implementation now filters out select key press/release which don't match the expected mouse button state. Task-number: QTBUG-9860 Reviewed-by: Alessandro Portale --- src/gui/kernel/qapplication_s60.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 2bd29fc..dbdcef9 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -642,10 +642,12 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod QPoint pos = QCursor::pos(); TPointerEvent fakeEvent; + fakeEvent.iType = (TPointerEvent::TType)(-1); TInt x = pos.x(); TInt y = pos.y(); if (type == EEventKeyUp) { - if (keyCode == Qt::Key_Select) + if (keyCode == Qt::Key_Select && + (S60->virtualMousePressedKeys & QS60Data::Select)) fakeEvent.iType = TPointerEvent::EButton1Up; S60->virtualMouseAccel = 1; S60->virtualMouseLastKey = 0; @@ -694,8 +696,7 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod // example for drag'n'drop), Symbian starts producing spurious up and // down messages for some keys. Therefore, make sure we have a clean slate // of pressed keys before starting a new button press. - if (S60->virtualMousePressedKeys != 0) { - S60->virtualMousePressedKeys |= QS60Data::Select; + if (S60->virtualMousePressedKeys & QS60Data::Select) { return EKeyWasConsumed; } else { S60->virtualMousePressedKeys |= QS60Data::Select; @@ -718,7 +719,8 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod fakeEvent.iModifiers = keyEvent.iModifiers; fakeEvent.iPosition = cpos; fakeEvent.iParentPosition = epos; - HandlePointerEvent(fakeEvent); + if(fakeEvent.iType != -1) + HandlePointerEvent(fakeEvent); return EKeyWasConsumed; } else { -- cgit v0.12 From 25107b9b08dbb97363181eeb5768e7769cbb98c7 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 12 May 2010 17:26:03 +0100 Subject: Fix spurious mouse click when dismissing a native menu Native menus are dismissed by the key press event. The Qt application then receives the key up event, as it now has keyboard focus. The virtual mouse implementation now filters out select key press/release which don't match the expected mouse button state. Task-number: QTBUG-9860 Reviewed-by: Alessandro Portale --- src/gui/kernel/qapplication_s60.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 387762f..ea5c14c 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -643,11 +643,13 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod QPoint pos = QCursor::pos(); TPointerEvent fakeEvent; + fakeEvent.iType = (TPointerEvent::TType)(-1); fakeEvent.iModifiers = keyEvent.iModifiers; TInt x = pos.x(); TInt y = pos.y(); if (type == EEventKeyUp) { - if (keyCode == Qt::Key_Select) + if (keyCode == Qt::Key_Select && + (S60->virtualMousePressedKeys & QS60Data::Select)) fakeEvent.iType = TPointerEvent::EButton1Up; S60->virtualMouseAccel = 1; S60->virtualMouseLastKey = 0; @@ -698,8 +700,7 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod // example for drag'n'drop), Symbian starts producing spurious up and // down messages for some keys. Therefore, make sure we have a clean slate // of pressed keys before starting a new button press. - if (S60->virtualMousePressedKeys != 0) { - S60->virtualMousePressedKeys |= QS60Data::Select; + if (S60->virtualMousePressedKeys & QS60Data::Select) { return EKeyWasConsumed; } else { S60->virtualMousePressedKeys |= QS60Data::Select; @@ -728,7 +729,8 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod TPoint cpos = epos - PositionRelativeToScreen(); fakeEvent.iPosition = cpos; fakeEvent.iParentPosition = epos; - HandlePointerEvent(fakeEvent); + if(fakeEvent.iType != -1) + HandlePointerEvent(fakeEvent); return EKeyWasConsumed; } else { -- cgit v0.12 From 476414a53a02d99c0887acdb18c96dd65ad9ffa4 Mon Sep 17 00:00:00 2001 From: x29a <0.x29a.0@gmail.com> Date: Wed, 12 May 2010 23:22:41 +0200 Subject: Set the pictures for the examples of multitouch Changed filenames in multitouch examples to follow the format of existing examples. Added a picture for the fingerpaint example using a selfbuilt table and the qTUIO library. Merge-request: 608 Reviewed-by: Benjamin Poulain --- doc/src/examples/fingerpaint.qdoc | 2 +- doc/src/examples/pinchzoom.qdoc | 2 +- doc/src/images/multitouch-fingerpaint-example.png | Bin 0 -> 17026 bytes 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 doc/src/images/multitouch-fingerpaint-example.png diff --git a/doc/src/examples/fingerpaint.qdoc b/doc/src/examples/fingerpaint.qdoc index e5eb4ef..7eb1512 100644 --- a/doc/src/examples/fingerpaint.qdoc +++ b/doc/src/examples/fingerpaint.qdoc @@ -46,5 +46,5 @@ The Finger Paint example shows the use of multi-touch with a custom widget to create a simple painting application. - \image multitouch-fingerpaint.png + \image multitouch-fingerpaint-example.png */ diff --git a/doc/src/examples/pinchzoom.qdoc b/doc/src/examples/pinchzoom.qdoc index 726b1b3..867b2b3 100644 --- a/doc/src/examples/pinchzoom.qdoc +++ b/doc/src/examples/pinchzoom.qdoc @@ -46,5 +46,5 @@ The Pinch Zoom example shows how to use low-level multi-touch information to recognize a gesture. - \image multitouch-pinchzoom.png + \image multitouch-pinchzoom-example.png */ diff --git a/doc/src/images/multitouch-fingerpaint-example.png b/doc/src/images/multitouch-fingerpaint-example.png new file mode 100644 index 0000000..c741b65 Binary files /dev/null and b/doc/src/images/multitouch-fingerpaint-example.png differ -- cgit v0.12 From 13c3a19eff8dead535e0ef20f69a311c2925f663 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 13 May 2010 08:46:35 +1000 Subject: OpenVG blending modes from VG_KHR_advanced_blending extension This change introduces the extra blending modes that are defined in the VG_KHR_advanced_blending extension. Patch originally provided by contributor: http://qt.gitorious.org/qt/qt/merge_requests/505 Reviewed-by: Julian de Bhal --- doc/src/howtos/openvg.qdoc | 21 ++++++++- doc/src/platforms/emb-openvg.qdocinc | 21 ++++++++- src/openvg/qpaintengine_vg.cpp | 87 ++++++++++++++++++++++++++++++++++-- 3 files changed, 121 insertions(+), 8 deletions(-) diff --git a/doc/src/howtos/openvg.qdoc b/doc/src/howtos/openvg.qdoc index f70ed54..e448d9c 100644 --- a/doc/src/howtos/openvg.qdoc +++ b/doc/src/howtos/openvg.qdoc @@ -172,8 +172,25 @@ \endlist The other members of QPainter::CompositionMode are not supported - because OpenVG 1.1 does not have an equivalent in its \c VGBlendMode - enumeration. Any attempt to set an unsupported mode will result in + unless the \c{VG_KHR_advanced_blending} extension is present, + in which case the following additional modes are supported: + + \list + \o QPainter::CompositionMode_Overlay + \o QPainter::CompositionMode_ColorDodge + \o QPainter::CompositionMode_ColorBurn + \o QPainter::CompositionMode_HardLight + \o QPainter::CompositionMode_SoftLight + \o QPainter::CompositionMode_Difference + \o QPainter::CompositionMode_Exclusion + \o QPainter::CompositionMode_SourceOut + \o QPainter::CompositionMode_DestinationOut + \o QPainter::CompositionMode_SourceAtop + \o QPainter::CompositionMode_DestinationAtop + \o QPainter::CompositionMode_Xor + \endlist + + Any attempt to set an unsupported mode will result in the actual mode being set to QPainter::CompositionMode_SourceOver. Client applications should avoid using unsupported modes. diff --git a/doc/src/platforms/emb-openvg.qdocinc b/doc/src/platforms/emb-openvg.qdocinc index 2f9cc21..579af67 100644 --- a/doc/src/platforms/emb-openvg.qdocinc +++ b/doc/src/platforms/emb-openvg.qdocinc @@ -135,8 +135,25 @@ transformations for non-image elements in performance critical code. \endlist The other members of QPainter::CompositionMode are not supported -because OpenVG 1.1 does not have an equivalent in its \c VGBlendMode -enumeration. Any attempt to set an unsupported mode will result in +unless the \c{VG_KHR_advanced_blending} extension is present, +in which case the following additional modes are supported: + +\list +\o QPainter::CompositionMode_Overlay +\o QPainter::CompositionMode_ColorDodge +\o QPainter::CompositionMode_ColorBurn +\o QPainter::CompositionMode_HardLight +\o QPainter::CompositionMode_SoftLight +\o QPainter::CompositionMode_Difference +\o QPainter::CompositionMode_Exclusion +\o QPainter::CompositionMode_SourceOut +\o QPainter::CompositionMode_DestinationOut +\o QPainter::CompositionMode_SourceAtop +\o QPainter::CompositionMode_DestinationAtop +\o QPainter::CompositionMode_Xor +\endlist + +Any attempt to set an unsupported mode will result in the actual mode being set to QPainter::CompositionMode_SourceOver. Client applications should avoid using unsupported modes. diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index cabb41c..07f8415 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -120,6 +120,35 @@ private: class QVGPaintEnginePrivate : public QPaintEngineExPrivate { public: + // Extra blending modes from VG_KHR_advanced_blending extension. + // Use the QT_VG prefix to avoid conflicts with any definitions + // that may come in via . + enum AdvancedBlending { + QT_VG_BLEND_OVERLAY_KHR = 0x2010, + QT_VG_BLEND_HARDLIGHT_KHR = 0x2011, + QT_VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012, + QT_VG_BLEND_SOFTLIGHT_KHR = 0x2013, + QT_VG_BLEND_COLORDODGE_KHR = 0x2014, + QT_VG_BLEND_COLORBURN_KHR = 0x2015, + QT_VG_BLEND_DIFFERENCE_KHR = 0x2016, + QT_VG_BLEND_SUBTRACT_KHR = 0x2017, + QT_VG_BLEND_INVERT_KHR = 0x2018, + QT_VG_BLEND_EXCLUSION_KHR = 0x2019, + QT_VG_BLEND_LINEARDODGE_KHR = 0x201a, + QT_VG_BLEND_LINEARBURN_KHR = 0x201b, + QT_VG_BLEND_VIVIDLIGHT_KHR = 0x201c, + QT_VG_BLEND_LINEARLIGHT_KHR = 0x201d, + QT_VG_BLEND_PINLIGHT_KHR = 0x201e, + QT_VG_BLEND_HARDMIX_KHR = 0x201f, + QT_VG_BLEND_CLEAR_KHR = 0x2020, + QT_VG_BLEND_DST_KHR = 0x2021, + QT_VG_BLEND_SRC_OUT_KHR = 0x2022, + QT_VG_BLEND_DST_OUT_KHR = 0x2023, + QT_VG_BLEND_SRC_ATOP_KHR = 0x2024, + QT_VG_BLEND_DST_ATOP_KHR = 0x2025, + QT_VG_BLEND_XOR_KHR = 0x2026 + }; + QVGPaintEnginePrivate(); ~QVGPaintEnginePrivate(); @@ -217,6 +246,8 @@ public: QVGFontEngineCleaner *fontEngineCleaner; #endif + bool hasAdvancedBlending; + QScopedPointer convolutionFilter; QScopedPointer colorizeFilter; QScopedPointer dropShadowFilter; @@ -370,6 +401,8 @@ void QVGPaintEnginePrivate::init() fontEngineCleaner = 0; #endif + hasAdvancedBlending = false; + clearModes(); } @@ -446,6 +479,10 @@ void QVGPaintEnginePrivate::initObjects() VG_PATH_CAPABILITY_ALL); vgAppendPathData(linePath, 2, segments, coords); #endif + + const char *extensions = reinterpret_cast(vgGetString(VG_EXTENSIONS)); + if (extensions) + hasAdvancedBlending = strstr(extensions, "VG_KHR_advanced_blending") != 0; } void QVGPaintEnginePrivate::destroy() @@ -2292,7 +2329,7 @@ void QVGPaintEngine::compositionModeChanged() Q_D(QVGPaintEngine); d->dirty |= QPaintEngine::DirtyCompositionMode; - VGBlendMode vgMode = VG_BLEND_SRC_OVER; + VGint vgMode = VG_BLEND_SRC_OVER; switch (state()->composition_mode) { case QPainter::CompositionMode_SourceOver: @@ -2326,11 +2363,53 @@ void QVGPaintEngine::compositionModeChanged() vgMode = VG_BLEND_LIGHTEN; break; default: - qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode; - break; // Fall back to VG_BLEND_SRC_OVER. + if (d->hasAdvancedBlending) { + switch (state()->composition_mode) { + case QPainter::CompositionMode_Overlay: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_OVERLAY_KHR; + break; + case QPainter::CompositionMode_ColorDodge: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORDODGE_KHR; + break; + case QPainter::CompositionMode_ColorBurn: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORBURN_KHR; + break; + case QPainter::CompositionMode_HardLight: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_HARDLIGHT_KHR; + break; + case QPainter::CompositionMode_SoftLight: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SOFTLIGHT_KHR; + break; + case QPainter::CompositionMode_Difference: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DIFFERENCE_KHR; + break; + case QPainter::CompositionMode_Exclusion: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_EXCLUSION_KHR; + break; + case QPainter::CompositionMode_SourceOut: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_OUT_KHR; + break; + case QPainter::CompositionMode_DestinationOut: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_OUT_KHR; + break; + case QPainter::CompositionMode_SourceAtop: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_ATOP_KHR; + break; + case QPainter::CompositionMode_DestinationAtop: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_ATOP_KHR; + break; + case QPainter::CompositionMode_Xor: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_XOR_KHR; + break; + default: break; // Fall back to VG_BLEND_SRC_OVER. + } + } + if (vgMode == VG_BLEND_SRC_OVER) + qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode; + break; } - d->setBlendMode(vgMode); + d->setBlendMode(VGBlendMode(vgMode)); } void QVGPaintEngine::renderHintsChanged() -- cgit v0.12 From 386b658ce39bfab16ea14b232c61ad4703f11619 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 13 May 2010 10:08:48 +1000 Subject: Fix broken benchmarks. --- src/declarative/qml/qdeclarativeengine.cpp | 11 ++++++----- tests/benchmarks/declarative/creation/tst_creation.cpp | 4 ++-- tests/benchmarks/declarative/painting/painting.pro | 1 + .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 6 +++--- .../benchmarks/declarative/script/data/slot_complex_js.js | 8 ++++++++ .../benchmarks/declarative/script/data/slot_complex_js.qml | 14 ++------------ tests/benchmarks/declarative/script/data/slot_simple_js.js | 3 +++ .../benchmarks/declarative/script/data/slot_simple_js.qml | 10 ++-------- 8 files changed, 27 insertions(+), 30 deletions(-) create mode 100644 tests/benchmarks/declarative/script/data/slot_complex_js.js create mode 100644 tests/benchmarks/declarative/script/data/slot_simple_js.js diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 9f5cafe..94e6771 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -327,11 +327,12 @@ Q_GLOBAL_STATIC(QDeclarativeEngineDebugServer, qmlEngineDebugServer); void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o) { QObjectPrivate *p = QObjectPrivate::get(o); - Q_ASSERT(p->declarativeData); - QDeclarativeData *d = static_cast(p->declarativeData); - if (d->ownContext && d->context) { - d->context->destroy(); - d->context = 0; + if (p->declarativeData) { + QDeclarativeData *d = static_cast(p->declarativeData); + if (d->ownContext && d->context) { + d->context->destroy(); + d->context = 0; + } } } diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 6f00473..99324f4 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -203,7 +203,7 @@ void tst_creation::qobject_10tree_cpp() void tst_creation::qobject_qmltype() { - QDeclarativeType *t = QDeclarativeMetaType::qmlType("Qt/QtObject", 4, 6); + QDeclarativeType *t = QDeclarativeMetaType::qmlType("Qt/QtObject", 4, 7); QBENCHMARK { QObject *obj = t->create(); @@ -347,7 +347,7 @@ void tst_creation::elements_data() void tst_creation::elements() { QFETCH(QByteArray, type); - QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 4, 6); + QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 4, 7); if (!t || !t->isCreatable()) QSKIP("Non-creatable type", SkipSingle); diff --git a/tests/benchmarks/declarative/painting/painting.pro b/tests/benchmarks/declarative/painting/painting.pro index 2f98e8b..a228ea7 100644 --- a/tests/benchmarks/declarative/painting/painting.pro +++ b/tests/benchmarks/declarative/painting/painting.pro @@ -11,3 +11,4 @@ INCLUDEPATH += . SOURCES += paintbenchmark.cpp QT += opengl CONFIG += console +macx:CONFIG -= app_bundle diff --git a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 4bba022..e2e8c8a 100644 --- a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -68,7 +68,7 @@ private: void tst_qmlgraphicsimage::qmlgraphicsimage() { int x = 0; - QUrl url("image.png"); + QUrl url(SRCDIR "/image.png"); QBENCHMARK { QUrl url2("http://localhost/image" + QString::number(x++) + ".png"); QDeclarativeImage *image = new QDeclarativeImage; @@ -80,7 +80,7 @@ void tst_qmlgraphicsimage::qmlgraphicsimage() void tst_qmlgraphicsimage::qmlgraphicsimage_file() { int x = 0; - QUrl url("image.png"); + QUrl url(SRCDIR "/image.png"); QBENCHMARK { QUrl url2("http://localhost/image" + QString::number(x++) + ".png"); QDeclarativeImage *image = new QDeclarativeImage; @@ -93,7 +93,7 @@ void tst_qmlgraphicsimage::qmlgraphicsimage_file() void tst_qmlgraphicsimage::qmlgraphicsimage_url() { int x = 0; - QUrl url("image.png"); + QUrl url(SRCDIR "/image.png"); QBENCHMARK { QUrl url2("http://localhost/image" + QString::number(x++) + ".png"); QDeclarativeImage *image = new QDeclarativeImage; diff --git a/tests/benchmarks/declarative/script/data/slot_complex_js.js b/tests/benchmarks/declarative/script/data/slot_complex_js.js new file mode 100644 index 0000000..64a1f65 --- /dev/null +++ b/tests/benchmarks/declarative/script/data/slot_complex_js.js @@ -0,0 +1,8 @@ +function myCustomFunction(n) { + var a = 1; + while (n > 0) { + a = a * n; + n--; + } + return a; +} diff --git a/tests/benchmarks/declarative/script/data/slot_complex_js.qml b/tests/benchmarks/declarative/script/data/slot_complex_js.qml index ed4f78b..7bda48b 100644 --- a/tests/benchmarks/declarative/script/data/slot_complex_js.qml +++ b/tests/benchmarks/declarative/script/data/slot_complex_js.qml @@ -1,18 +1,8 @@ import Qt.test 1.0 +import "slot_complex_js.js" as Logic TestObject { - Script { - function myCustomFunction(n) { - var a = 1; - while (n > 0) { - a = a * n; - n--; - } - return a; - } - } - - onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(10); } } + onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(10); } } } diff --git a/tests/benchmarks/declarative/script/data/slot_simple_js.js b/tests/benchmarks/declarative/script/data/slot_simple_js.js new file mode 100644 index 0000000..d6e6060 --- /dev/null +++ b/tests/benchmarks/declarative/script/data/slot_simple_js.js @@ -0,0 +1,3 @@ +function myCustomFunction() { + return 0; +} diff --git a/tests/benchmarks/declarative/script/data/slot_simple_js.qml b/tests/benchmarks/declarative/script/data/slot_simple_js.qml index a88265c..7ea3177 100644 --- a/tests/benchmarks/declarative/script/data/slot_simple_js.qml +++ b/tests/benchmarks/declarative/script/data/slot_simple_js.qml @@ -1,13 +1,7 @@ import Qt.test 1.0 +import "slot_simple_js.js" as Logic TestObject { - - Script { - function myCustomFunction() { - return 0; - } - } - - onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(); } } + onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(); } } } -- cgit v0.12 From f17c706db16aae93f024e88208e139063f5b2c7c Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Wed, 12 May 2010 16:28:57 +1000 Subject: Fix for graphics widget in the background stealing declarative item's focus Task-number: QTBUG-10584 Reviewed-by: Warwick Allison --- src/gui/graphicsview/qgraphicsscene.cpp | 4 +-- .../qdeclarativeitem/data/mouseFocus.qml | 20 ++++++++++++ .../qdeclarativeitem/tst_qdeclarativeitem.cpp | 37 ++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeitem/data/mouseFocus.qml diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index dacdbfe..7abd5f6 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1320,10 +1320,10 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou setFocus = true; break; } - if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) { + if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable))) { if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) { setFocus = true; - if (item != q->focusItem()) + if (item != q->focusItem() && item->d_ptr->mouseSetsFocus) q->setFocusItem(item, Qt::MouseFocusReason); break; } diff --git a/tests/auto/declarative/qdeclarativeitem/data/mouseFocus.qml b/tests/auto/declarative/qdeclarativeitem/data/mouseFocus.qml new file mode 100644 index 0000000..a562b8b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/mouseFocus.qml @@ -0,0 +1,20 @@ +import Qt 4.7 + +QGraphicsWidget { + size: "200x100" + focusPolicy: QGraphicsWidget.ClickFocus + Item { + objectName: "declarativeItem" + id: item + width: 200 + height: 100 + MouseArea { + anchors.fill: parent + onPressed: { + if (!item.focus) { + item.focus = true; + } + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index e0ca746..f4edeb2 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -45,6 +45,7 @@ #include #include #include +#include "../../../shared/util.h" class tst_QDeclarativeItem : public QObject @@ -67,6 +68,7 @@ private slots: void childrenProperty(); void resourcesProperty(); + void mouseFocus(); private: template @@ -466,6 +468,41 @@ void tst_QDeclarativeItem::resourcesProperty() delete o; } +void tst_QDeclarativeItem::mouseFocus() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/mouseFocus.qml")); + canvas->show(); + QVERIFY(canvas->rootObject()); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); + + QDeclarativeItem *item = findItem(canvas->rootObject(), "declarativeItem"); + QVERIFY(item); + QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); + + QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos())); + QApplication::processEvents(); + QCOMPARE(focusSpy.count(), 1); + QVERIFY(item->hasFocus()); + + // make sure focusable graphics widget underneath does not steal focus + QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos())); + QApplication::processEvents(); + QCOMPARE(focusSpy.count(), 1); + QVERIFY(item->hasFocus()); + + item->setFocus(false); + QVERIFY(!item->hasFocus()); + QCOMPARE(focusSpy.count(), 2); + item->setFocus(true); + QCOMPARE(focusSpy.count(), 3); + + delete canvas; +} + void tst_QDeclarativeItem::propertyChanges() { QDeclarativeView *canvas = new QDeclarativeView(0); -- cgit v0.12 From d45c45432ccd0a74c67e70ce5fc3a09f35923c26 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Wed, 12 May 2010 18:20:18 +1000 Subject: Fix TextEdit and TextInput input panel support for mode RSIP_OnMouseClickAndAlreadyFocused Task-number: Reviewed-by: Warwick Allison --- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 11 ++++++++--- src/declarative/graphicsitems/qdeclarativetextedit_p_p.h | 3 ++- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 16 ++++++++++++---- .../graphicsitems/qdeclarativetextinput_p_p.h | 3 ++- .../qdeclarativelistview/tst_qdeclarativelistview.cpp | 2 -- .../qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 11 ++++++++--- .../qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 11 ++++++++--- 7 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 6d86e58..db20da8 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -899,6 +899,7 @@ Handles the given mouse \a event. void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextEdit); + bool hadFocus = hasFocus(); if (d->focusOnPress){ QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope? while(p) { @@ -910,6 +911,8 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) } setFocus(true); } + if (!hadFocus && hasFocus()) + d->clickCausedFocus = true; d->control->processEvent(event, QPointF(0, 0)); if (!event->isAccepted()) QDeclarativePaintedItem::mousePressEvent(event); @@ -924,11 +927,12 @@ void QDeclarativeTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_D(QDeclarativeTextEdit); QWidget *widget = event->widget(); if (widget && (d->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos())) - qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress); + qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); + d->clickCausedFocus = false; d->control->processEvent(event, QPointF(0, 0)); if (!event->isAccepted()) - QDeclarativePaintedItem::mousePressEvent(event); + QDeclarativePaintedItem::mouseReleaseEvent(event); } /*! @@ -952,7 +956,8 @@ void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_D(QDeclarativeTextEdit); d->control->processEvent(event, QPointF(0, 0)); if (!event->isAccepted()) - QDeclarativePaintedItem::mousePressEvent(event); + QDeclarativePaintedItem::mouseMoveEvent(event); + event->setAccepted(true); } /*! diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h index 8d4b611..5e19c3d 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h @@ -70,7 +70,7 @@ public: QDeclarativeTextEditPrivate() : color("black"), hAlign(QDeclarativeTextEdit::AlignLeft), vAlign(QDeclarativeTextEdit::AlignTop), imgDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true), - persistentSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), + persistentSelection(true), clickCausedFocus(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0), wrapMode(QDeclarativeTextEdit::NoWrap) { @@ -100,6 +100,7 @@ public: bool cursorVisible : 1; bool focusOnPress : 1; bool persistentSelection : 1; + bool clickCausedFocus : 1; qreal textMargin; int lastSelectionStart; int lastSelectionEnd; diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 8f86aa0..afbaaac 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -882,6 +882,7 @@ void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev) void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextInput); + bool hadFocus = hasFocus(); if(d->focusOnPress){ QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope? while(p) { @@ -893,15 +894,20 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) } setFocus(true); } + if (!hadFocus && hasFocus()) + d->clickCausedFocus = true; + bool mark = event->modifiers() & Qt::ShiftModifier; int cursor = d->xToPos(event->pos().x()); d->control->moveCursor(cursor, mark); + event->setAccepted(true); } void QDeclarativeTextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextInput); d->control->moveCursor(d->xToPos(event->pos().x()), true); + event->setAccepted(true); } /*! @@ -913,8 +919,10 @@ void QDeclarativeTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_D(QDeclarativeTextInput); QWidget *widget = event->widget(); if (widget && !d->control->isReadOnly() && boundingRect().contains(event->pos())) - qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress); - d->control->processEvent(event); + qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); + d->clickCausedFocus = false; + if (!event->isAccepted()) + QDeclarativePaintedItem::mouseReleaseEvent(event); } bool QDeclarativeTextInput::event(QEvent* ev) @@ -935,8 +943,8 @@ bool QDeclarativeTextInput::event(QEvent* ev) updateSize(); } if(!handled) - return QDeclarativePaintedItem::event(ev); - return true; + handled = QDeclarativePaintedItem::event(ev); + return handled; } void QDeclarativeTextInput::geometryChanged(const QRectF &newGeometry, diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h index 26cf78c..99866b8 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h @@ -72,7 +72,7 @@ public: color((QRgb)0), style(QDeclarativeText::Normal), styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft), hscroll(0), oldScroll(0), focused(false), focusOnPress(true), - cursorVisible(false), autoScroll(true) + cursorVisible(false), autoScroll(true), clickCausedFocus(false) { } @@ -116,6 +116,7 @@ public: bool focusOnPress; bool cursorVisible; bool autoScroll; + bool clickCausedFocus; }; QT_END_NAMESPACE diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 22eb734..ec2afae 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -1432,8 +1432,6 @@ void tst_QDeclarativeListView::QTBUG_9791() { QDeclarativeView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/strictlyenforcerange.qml")); qApp->processEvents(); diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index b92024f..c65c883 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -793,8 +793,6 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() view.viewport()->setInputContext(&ic); QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); - if ((behavior != QStyle::RSIP_OnMouseClick)) - QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle); QDeclarativeTextEdit edit; edit.setText("Hello world"); edit.setPos(0, 0); @@ -806,7 +804,14 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); QApplication::processEvents(); - QCOMPARE(ic.softwareInputPanelEventReceived, true); + if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) { + QCOMPARE(ic.softwareInputPanelEventReceived, false); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); + QApplication::processEvents(); + QCOMPARE(ic.softwareInputPanelEventReceived, true); + } else if (behavior == QStyle::RSIP_OnMouseClick) { + QCOMPARE(ic.softwareInputPanelEventReceived, true); + } } void tst_qdeclarativetextedit::geometrySignals() diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index c00390d..ac80edb 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -743,8 +743,6 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() view.viewport()->setInputContext(&ic); QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); - if ((behavior != QStyle::RSIP_OnMouseClick)) - QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle); QDeclarativeTextInput input; input.setText("Hello world"); input.setPos(0, 0); @@ -756,7 +754,14 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); QApplication::processEvents(); - QCOMPARE(ic.softwareInputPanelEventReceived, true); + if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) { + QCOMPARE(ic.softwareInputPanelEventReceived, false); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); + QApplication::processEvents(); + QCOMPARE(ic.softwareInputPanelEventReceived, true); + } else if (behavior == QStyle::RSIP_OnMouseClick) { + QCOMPARE(ic.softwareInputPanelEventReceived, true); + } } class MyTextInput : public QDeclarativeTextInput -- cgit v0.12 From 2555221bbcb33e0d12e786eb0b3d08bd9260eeb7 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Wed, 12 May 2010 11:51:56 +1000 Subject: Avoid running animation when loopCount == 0 Task-number: QTBUG-10654 Reviewed-by: Thierry Bastian --- src/corelib/animation/qabstractanimation.cpp | 3 +++ .../qpropertyanimation/tst_qpropertyanimation.cpp | 24 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 01570ad..04342e7 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -369,6 +369,9 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) if (state == newState) return; + if (loopCount == 0) + return; + QAbstractAnimation::State oldState = state; int oldCurrentTime = currentTime; int oldCurrentLoop = currentLoop; diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 849b8b2..ea527de 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -133,6 +133,7 @@ private slots: void twoAnimations(); void deletedInUpdateCurrentTime(); void totalDuration(); + void zeroLoopCount(); }; tst_QPropertyAnimation::tst_QPropertyAnimation() @@ -1214,6 +1215,29 @@ void tst_QPropertyAnimation::totalDuration() QCOMPARE(anim.totalDuration(), 0); } +void tst_QPropertyAnimation::zeroLoopCount() +{ + DummyPropertyAnimation* anim; + anim = new DummyPropertyAnimation; + anim->setStartValue(0); + anim->setDuration(20); + anim->setLoopCount(0); + + QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); + QSignalSpy finishedSpy(anim, SIGNAL(finished())); + + QCOMPARE(anim->state(), QAnimationGroup::Stopped); + QCOMPARE(anim->currentValue().toInt(), 0); + QCOMPARE(runningSpy.count(), 0); + QCOMPARE(finishedSpy.count(), 0); + + anim->start(); + + QCOMPARE(anim->state(), QAnimationGroup::Stopped); + QCOMPARE(anim->currentValue().toInt(), 0); + QCOMPARE(runningSpy.count(), 0); + QCOMPARE(finishedSpy.count(), 0); +} QTEST_MAIN(tst_QPropertyAnimation) #include "tst_qpropertyanimation.moc" -- cgit v0.12 From 6c19bdb8552f3cc6ced2a20868f1f1952f94a69c Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 13 May 2010 13:19:35 +1000 Subject: Dates and variants are not considered nested objects --- src/declarative/util/qdeclarativelistmodel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 0985a6b..a8a445a 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -999,7 +999,8 @@ bool FlatListModel::addValue(const QScriptValue &value, QHash *ro QScriptValueIterator it(value); while (it.hasNext()) { it.next(); - if (it.value().isObject()) { + QScriptValue value = it.value(); + if (!value.isVariant() && !value.isRegExp() && !value.isDate() && value.isObject()) { qmlInfo(m_listModel) << "Cannot add nested list values when modifying or after modification from a worker script"; return false; } -- cgit v0.12 From 72094648438d8214dcaabddf4d94d9d7e346675a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 13 May 2010 14:32:19 +1000 Subject: Fix crash on remote content. Breakage was actually quite bad, just hard to reproduce. Task-number: QTBUG-10565 --- src/declarative/qml/qdeclarativecompositetypemanager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp index 0ea198d..6014b10 100644 --- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp +++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp @@ -509,7 +509,9 @@ void QDeclarativeCompositeTypeManager::checkComplete(QDeclarativeCompositeTypeDa unit->errors = u->errors; doComplete(unit); return; - } else if (u->status == QDeclarativeCompositeTypeData::Waiting) { + } else if (u->status == QDeclarativeCompositeTypeData::Waiting + || u->status == QDeclarativeCompositeTypeData::WaitingResources) + { waiting++; } } -- cgit v0.12 From ae8e4afcadc9ff084e1d1859c29fbc8b629e3392 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 13 May 2010 15:07:21 +1000 Subject: Add an example spinner. Also add missing increment/decrementCurrentIndex() slots to PathView, and tweak the number of points cached along a Path. --- examples/declarative/declarative.pro | 1 + examples/declarative/spinner/content/Spinner.qml | 25 ++++++++++++++++ .../declarative/spinner/content/spinner-bg.png | Bin 0 -> 345 bytes .../declarative/spinner/content/spinner-select.png | Bin 0 -> 320 bytes examples/declarative/spinner/main.qml | 18 +++++++++++ examples/declarative/spinner/spinner.qmlproject | 16 ++++++++++ src/declarative/graphicsitems/qdeclarativepath.cpp | 4 ++- .../graphicsitems/qdeclarativepathview.cpp | 33 +++++++++++++++++++-- .../graphicsitems/qdeclarativepathview_p.h | 4 +++ .../tst_qdeclarativepathview.cpp | 30 +++++++++++++++++-- 10 files changed, 125 insertions(+), 6 deletions(-) create mode 100644 examples/declarative/spinner/content/Spinner.qml create mode 100644 examples/declarative/spinner/content/spinner-bg.png create mode 100644 examples/declarative/spinner/content/spinner-select.png create mode 100644 examples/declarative/spinner/main.qml create mode 100644 examples/declarative/spinner/spinner.qmlproject diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro index ba9b628..913b2b0 100644 --- a/examples/declarative/declarative.pro +++ b/examples/declarative/declarative.pro @@ -37,6 +37,7 @@ sources.files = \ scrollbar \ searchbox \ slideswitch \ + spinner \ sql \ states \ tabwidget \ diff --git a/examples/declarative/spinner/content/Spinner.qml b/examples/declarative/spinner/content/Spinner.qml new file mode 100644 index 0000000..8145a28 --- /dev/null +++ b/examples/declarative/spinner/content/Spinner.qml @@ -0,0 +1,25 @@ +import Qt 4.7 + +Image { + property alias model: view.model + property alias delegate: view.delegate + property alias currentIndex: view.currentIndex + property real itemHeight: 30 + source: "spinner-bg.png" + clip: true + PathView { + id: view + anchors.fill: parent + pathItemCount: height/itemHeight + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } + dragMargin: view.width/2 + path: Path { + startX: view.width/2; startY: -itemHeight/2 + PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } + } + } + Keys.onDownPressed: view.incrementCurrentIndex() + Keys.onUpPressed: view.decrementCurrentIndex() +} diff --git a/examples/declarative/spinner/content/spinner-bg.png b/examples/declarative/spinner/content/spinner-bg.png new file mode 100644 index 0000000..b3556f1 Binary files /dev/null and b/examples/declarative/spinner/content/spinner-bg.png differ diff --git a/examples/declarative/spinner/content/spinner-select.png b/examples/declarative/spinner/content/spinner-select.png new file mode 100644 index 0000000..95a17a1 Binary files /dev/null and b/examples/declarative/spinner/content/spinner-select.png differ diff --git a/examples/declarative/spinner/main.qml b/examples/declarative/spinner/main.qml new file mode 100644 index 0000000..6be567a --- /dev/null +++ b/examples/declarative/spinner/main.qml @@ -0,0 +1,18 @@ +import Qt 4.7 +import "content" + +Rectangle { + width: 240; height: 320 + Column { + y: 20; x: 20; spacing: 20 + Spinner { + id: spinner + width: 200; height: 240 + focus: true + model: 20 + itemHeight: 30 + delegate: Text { font.pixelSize: 25; text: index; height: 30 } + } + Text { text: "Current item index: " + spinner.currentIndex } + } +} diff --git a/examples/declarative/spinner/spinner.qmlproject b/examples/declarative/spinner/spinner.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/spinner/spinner.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp index 3d0df87..2d08c7c 100644 --- a/src/declarative/graphicsitems/qdeclarativepath.cpp +++ b/src/declarative/graphicsitems/qdeclarativepath.cpp @@ -377,7 +377,9 @@ void QDeclarativePath::createPointCache() const { Q_D(const QDeclarativePath); qreal pathLength = d->_path.length(); - const int points = int(pathLength*2); + // more points means less jitter between items as they move along the + // path, but takes longer to generate + const int points = int(pathLength*5); const int lastElement = d->_path.elementCount() - 1; d->_pointCache.resize(points+1); diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 503d096..207cc25 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -49,6 +49,7 @@ #include #include +#include #include QT_BEGIN_NAMESPACE @@ -279,8 +280,8 @@ void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal perce 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); + item->setX(qRound(pf.x() - item->width()*item->scale()/2)); + item->setY(qRound(pf.y() - item->height()*item->scale()/2)); } void QDeclarativePathViewPrivate::regenerate() @@ -527,6 +528,33 @@ void QDeclarativePathView::setCurrentIndex(int idx) } /*! + \qmlmethod PathView::incrementCurrentIndex() + + Increments the current index. +*/ +void QDeclarativePathView::incrementCurrentIndex() +{ + setCurrentIndex(currentIndex()+1); +} + + +/*! + \qmlmethod PathView::decrementCurrentIndex() + + Decrements the current index. +*/ +void QDeclarativePathView::decrementCurrentIndex() +{ + Q_D(QDeclarativePathView); + if (d->model && d->model->count()) { + int idx = currentIndex()-1; + if (idx < 0) + idx = d->model->count() - 1; + setCurrentIndex(idx); + } +} + +/*! \qmlproperty real PathView::offset The offset specifies how far along the path the items are from their initial positions. @@ -1312,6 +1340,7 @@ int QDeclarativePathViewPrivate::calcCurrentIndex() if (offset < 0) offset += model->count(); current = qRound(qAbs(qmlMod(model->count() - offset, model->count()))); + current = current % model->count(); } return current; diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h index 85f47fd..349a01c 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h @@ -132,6 +132,10 @@ public: static QDeclarativePathViewAttached *qmlAttachedProperties(QObject *); +public Q_SLOTS: + void incrementCurrentIndex(); + void decrementCurrentIndex(); + Q_SIGNALS: void currentIndexChanged(); void offsetChanged(); diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 62d0b89..0e16f66 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -438,7 +438,8 @@ void tst_QDeclarativePathView::pathMoved() for(int i=0; i(pathview, "wrapper", i); - QCOMPARE(curItem->pos() + offset, path->pointAt(0.25 + i*0.25)); + QPointF itemPos(path->pointAt(0.25 + i*0.25)); + QCOMPARE(curItem->pos() + offset, QPointF(qRound(itemPos.x()), qRound(itemPos.y()))); } pathview->setOffset(0.0); @@ -479,13 +480,36 @@ void tst_QDeclarativePathView::setCurrentIndex() QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 0); pathview->setCurrentIndex(2); - QTest::qWait(1000); firstItem = findItem(pathview, "wrapper", 2); - QCOMPARE(firstItem->pos() + offset, start); + QTRY_COMPARE(firstItem->pos() + offset, start); QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2); QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2); + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 1); + firstItem = findItem(pathview, "wrapper", 1); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 0); + firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 3); + firstItem = findItem(pathview, "wrapper", 3); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + + pathview->incrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 0); + firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + delete canvas; } -- cgit v0.12 From 5220b879a19b4fa1e28829e724c1ad12e85566f4 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 13 May 2010 15:21:38 +1000 Subject: ListModel::get() should return undefined if bad index specified --- src/declarative/util/qdeclarativelistmodel.cpp | 28 ++++++++++++++-------- .../tst_qdeclarativelistmodel.cpp | 4 +++- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index a8a445a..a8e1be8 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -537,10 +537,9 @@ void QDeclarativeListModel::append(const QScriptValue& valuemap) */ QScriptValue QDeclarativeListModel::get(int index) const { - if (index >= count() || index < 0) { + // the internal flat/nested class takes care of return value for bad index + if (index >= count() || index < 0) qmlInfo(this) << tr("get: index %1 out of range").arg(index); - return 0; - } return m_flat ? m_flat->get(index) : m_nested->get(index); } @@ -930,13 +929,14 @@ bool FlatListModel::insert(int index, const QScriptValue &value) QScriptValue FlatListModel::get(int index) const { - Q_ASSERT(index >= 0 && index < m_values.count()); - QScriptEngine *scriptEngine = m_scriptEngine ? m_scriptEngine : QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(m_listModel)); - if (!scriptEngine) + if (!scriptEngine) return 0; + if (index < 0 || index >= m_values.count()) + return scriptEngine->undefinedValue(); + QScriptValue rv = scriptEngine->newObject(); QHash row = m_values.at(index); @@ -1183,13 +1183,21 @@ bool NestedListModel::append(const QScriptValue& valuemap) } QScriptValue NestedListModel::get(int index) const -{ - ModelNode *node = qvariant_cast(_root->values.at(index)); - if (!node) - return 0; +{ QDeclarativeEngine *eng = qmlEngine(m_listModel); if (!eng) return 0; + + if (index < 0 || index >= count()) { + QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(eng); + if (seng) + return seng->undefinedValue(); + return 0; + } + + ModelNode *node = qvariant_cast(_root->values.at(index)); + if (!node) + return 0; return QDeclarativeEnginePrivate::qmlScriptObject(node->object(this), eng); } diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index ec97461..aed4781 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -282,7 +282,9 @@ void tst_qdeclarativelistmodel::dynamic() int actual = e.evaluate().toInt(); if (e.hasError()) qDebug() << e.error(); // errors not expected - QVERIFY(!e.hasError()); + + if (QTest::currentDataTag() != QLatin1String("clear3") && QTest::currentDataTag() != QLatin1String("remove3")) + QVERIFY(!e.hasError()); QCOMPARE(actual,result); } -- cgit v0.12 From 2e04552969f925f7e32e2757dc2ebb3e93936a03 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 13 May 2010 15:23:23 +1000 Subject: Follow-up on Flickable changes. - flicking and moving properties will not be removed - onMovement* and onFlick* signals are back in Reviewed-by: Martin Jones --- src/declarative/QmlChanges.txt | 5 +- .../graphicsitems/qdeclarativeflickable.cpp | 80 ++++++++++++++++++---- .../graphicsitems/qdeclarativeflickable_p.h | 16 +++-- .../graphicsitems/qdeclarativegridview.cpp | 19 +++-- .../graphicsitems/qdeclarativelistview.cpp | 18 +++-- 5 files changed, 94 insertions(+), 44 deletions(-) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 9ab3f08..604c14c 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -3,10 +3,9 @@ The changes below are pre Qt 4.7.0 RC Flickable: - overShoot is replaced by boundsBehavior enumeration - - flicking is replaced by flickingHorizontally and flickingVertically - - moving is replaced by movingHorizontally and movingVertically + - flickingHorizontally and flickingVertically properties added + - movingHorizontally and movingVertically properties added - flickDirection is renamed flickableDirection - - onMovementStarted, onMovementEnded, onFlickStarted and onFlickEnded signals removed Component: isReady, isLoading, isError and isNull properties removed, use status property instead QList models no longer provide properties in model object. The diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index a7a8983..a03a51d 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -230,13 +230,17 @@ void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); if (!flickingHorizontally && q->xflick()) { flickingHorizontally = true; - emit q->flickingChanged(); // deprecated + emit q->flickingChanged(); emit q->flickingHorizontallyChanged(); + if (!flickingVertically) + emit q->flickStarted(); } if (!flickingVertically && q->yflick()) { flickingVertically = true; - emit q->flickingChanged(); // deprecated + emit q->flickingChanged(); emit q->flickingVerticallyChanged(); + if (!flickingHorizontally) + emit q->flickStarted(); } } else { timeline.reset(data.move); @@ -365,6 +369,37 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() */ /*! + \qmlsignal Flickable::onMovementStarted() + + This handler is called when the view begins moving due to user + interaction. +*/ + +/*! + \qmlsignal Flickable::onMovementEnded() + + This handler is called when the view stops moving due to user + interaction. If a flick was generated, this handler will + be triggered once the flick stops. If a flick was not + generated, the handler will be triggered when the + user stops dragging - i.e. a mouse or touch release. +*/ + +/*! + \qmlsignal Flickable::onFlickStarted() + + This handler is called when the view is flicked. A flick + starts from the point that the mouse or touch is released, + while still in motion. +*/ + +/*! + \qmlsignal Flickable::onFlickEnded() + + This handler is called when the view stops moving due to a flick. +*/ + +/*! \qmlproperty real Flickable::visibleArea.xPosition \qmlproperty real Flickable::visibleArea.widthRatio \qmlproperty real Flickable::visibleArea.yPosition @@ -474,9 +509,10 @@ void QDeclarativeFlickable::setInteractive(bool interactive) d->vTime = d->timeline.time(); d->flickingHorizontally = false; d->flickingVertically = false; - emit flickingChanged(); // deprecated + emit flickingChanged(); emit flickingHorizontallyChanged(); emit flickingVerticallyChanged(); + emit flickEnded(); } emit interactiveChanged(); } @@ -799,8 +835,10 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event) d->vData.velocity = qMin(event->delta() - d->vData.smoothVelocity.value(), qreal(-250.0)); d->flickingVertically = false; d->flickY(d->vData.velocity); - if (d->flickingVertically) + if (d->flickingVertically) { + d->vMoved = true; movementStarting(); + } event->accept(); } else if (xflick()) { if (event->delta() > 0) @@ -809,8 +847,10 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event) d->hData.velocity = qMin(event->delta() - d->hData.smoothVelocity.value(), qreal(-250.0)); d->flickingHorizontally = false; d->flickX(d->hData.velocity); - if (d->flickingHorizontally) + if (d->flickingHorizontally) { + d->hMoved = true; movementStarting(); + } event->accept(); } else { QDeclarativeItem::wheelEvent(event); @@ -1269,11 +1309,11 @@ void QDeclarativeFlickable::setFlickDeceleration(qreal deceleration) bool QDeclarativeFlickable::isFlicking() const { Q_D(const QDeclarativeFlickable); - qmlInfo(this) << "'flicking' is deprecated. Please use 'flickingHorizontally' and 'flickingVertically' instead."; return d->flickingHorizontally || d->flickingVertically; } /*! + \qmlproperty bool Flickable::flicking \qmlproperty bool Flickable::flickingHorizontally \qmlproperty bool Flickable::flickingVertically @@ -1322,11 +1362,11 @@ void QDeclarativeFlickable::setPressDelay(int delay) bool QDeclarativeFlickable::isMoving() const { Q_D(const QDeclarativeFlickable); - qmlInfo(this) << "'moving' is deprecated. Please use 'movingHorizontally' or 'movingVertically' instead."; return d->movingHorizontally || d->movingVertically; } /*! + \qmlproperty bool Flickable::moving \qmlproperty bool Flickable::movingHorizontally \qmlproperty bool Flickable::movingVertically @@ -1350,13 +1390,17 @@ void QDeclarativeFlickable::movementStarting() Q_D(QDeclarativeFlickable); if (d->hMoved && !d->movingHorizontally) { d->movingHorizontally = true; - emit movingChanged(); // deprecated + emit movingChanged(); emit movingHorizontallyChanged(); + if (!d->movingVertically) + emit movementStarted(); } - if (d->vMoved && !d->movingVertically) { + else if (d->vMoved && !d->movingVertically) { d->movingVertically = true; - emit movingChanged(); // deprecated + emit movingChanged(); emit movingVerticallyChanged(); + if (!d->movingHorizontally) + emit movementStarted(); } } @@ -1365,25 +1409,33 @@ void QDeclarativeFlickable::movementEnding() Q_D(QDeclarativeFlickable); if (d->flickingHorizontally) { d->flickingHorizontally = false; - emit flickingChanged(); // deprecated + emit flickingChanged(); emit flickingHorizontallyChanged(); + if (!d->flickingVertically) + emit flickEnded(); } if (d->flickingVertically) { d->flickingVertically = false; - emit flickingChanged(); // deprecated + emit flickingChanged(); emit flickingVerticallyChanged(); + if (!d->flickingHorizontally) + emit flickEnded(); } if (d->movingHorizontally) { d->movingHorizontally = false; d->hMoved = false; - emit movingChanged(); // deprecated + emit movingChanged(); emit movingHorizontallyChanged(); + if (!d->movingVertically) + emit movementEnded(); } if (d->movingVertically) { d->movingVertically = false; d->vMoved = false; - emit movingChanged(); // deprecated + emit movingChanged(); emit movingVerticallyChanged(); + if (!d->movingHorizontally) + emit movementEnded(); } d->hData.smoothVelocity.setValue(0); d->vData.smoothVelocity.setValue(0); diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h index 7944e2b..05887b8 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h @@ -68,10 +68,10 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged) Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged) Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) - Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged) // deprecated + Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged) Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged) Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged) - Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged) // deprecated + Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged) Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged) Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged) Q_PROPERTY(FlickableDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickableDirectionChanged) // deprecated @@ -120,10 +120,10 @@ public: qreal contentY() const; void setContentY(qreal pos); - bool isMoving() const; // deprecated + bool isMoving() const; bool isMovingHorizontally() const; bool isMovingVertically() const; - bool isFlicking() const; // deprecated + bool isFlicking() const; bool isFlickingHorizontally() const; bool isFlickingVertically() const; @@ -160,10 +160,10 @@ Q_SIGNALS: void contentHeightChanged(); void contentXChanged(); void contentYChanged(); - void movingChanged(); // deprecated + void movingChanged(); void movingHorizontallyChanged(); void movingVerticallyChanged(); - void flickingChanged(); // deprecated + void flickingChanged(); void flickingHorizontallyChanged(); void flickingVerticallyChanged(); void horizontalVelocityChanged(); @@ -177,6 +177,10 @@ Q_SIGNALS: void maximumFlickVelocityChanged(); void flickDecelerationChanged(); void pressDelayChanged(); + void movementStarted(); + void movementEnded(); + void flickStarted(); + void flickEnded(); protected: virtual bool sceneEventFilter(QGraphicsItem *, QEvent *); diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 396acd0..fe78c84 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -347,8 +347,7 @@ public: void QDeclarativeGridViewPrivate::init() { Q_Q(QDeclarativeGridView); - QObject::connect(q, SIGNAL(movingHorizontallyChanged()), q, SLOT(animStopped())); - QObject::connect(q, SIGNAL(movingVerticallyChanged()), q, SLOT(animStopped())); + QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped())); q->setFlag(QGraphicsItem::ItemIsFocusScope); q->setFlickableDirection(QDeclarativeFlickable::VerticalFlick); addItemChangeListener(this, Geometry); @@ -878,13 +877,15 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); if (!flickingHorizontally && q->xflick()) { flickingHorizontally = true; - emit q->flickingChanged(); // deprecated + emit q->flickingChanged(); emit q->flickingHorizontallyChanged(); + emit q->flickStarted(); } if (!flickingVertically && q->yflick()) { flickingVertically = true; - emit q->flickingChanged(); // deprecated + emit q->flickingChanged(); emit q->flickingVerticallyChanged(); + emit q->flickStarted(); } } else { timeline.reset(data.move); @@ -2311,13 +2312,9 @@ void QDeclarativeGridView::destroyingItem(QDeclarativeItem *item) void QDeclarativeGridView::animStopped() { Q_D(QDeclarativeGridView); - if ((!d->movingVertically && d->flow == QDeclarativeGridView::LeftToRight) - || (!d->movingHorizontally && d->flow == QDeclarativeGridView::TopToBottom)) - { - d->bufferMode = QDeclarativeGridViewPrivate::NoBuffer; - if (d->haveHighlightRange && d->highlightRange == QDeclarativeGridView::StrictlyEnforceRange) - d->updateHighlight(); - } + d->bufferMode = QDeclarativeGridViewPrivate::NoBuffer; + if (d->haveHighlightRange && d->highlightRange == QDeclarativeGridView::StrictlyEnforceRange) + d->updateHighlight(); } void QDeclarativeGridView::refill() diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 20106cb..46e9ce3 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -525,8 +525,7 @@ void QDeclarativeListViewPrivate::init() Q_Q(QDeclarativeListView); q->setFlag(QGraphicsItem::ItemIsFocusScope); addItemChangeListener(this, Geometry); - QObject::connect(q, SIGNAL(movingHorizontallyChanged()), q, SLOT(animStopped())); - QObject::connect(q, SIGNAL(movingVerticallyChanged()), q, SLOT(animStopped())); + QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped())); q->setFlickableDirection(QDeclarativeFlickable::VerticalFlick); ::memset(sectionCache, 0, sizeof(QDeclarativeItem*) * sectionCacheSize); } @@ -1260,13 +1259,15 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); if (!flickingHorizontally && q->xflick()) { flickingHorizontally = true; - emit q->flickingChanged(); // deprecated + emit q->flickingChanged(); emit q->flickingHorizontallyChanged(); + emit q->flickStarted(); } if (!flickingVertically && q->yflick()) { flickingVertically = true; - emit q->flickingChanged(); // deprecated + emit q->flickingChanged(); emit q->flickingVerticallyChanged(); + emit q->flickStarted(); } correctFlick = true; } else { @@ -2890,12 +2891,9 @@ void QDeclarativeListView::destroyingItem(QDeclarativeItem *item) void QDeclarativeListView::animStopped() { Q_D(QDeclarativeListView); - if ((!d->movingVertically && d->orient == QDeclarativeListView::Vertical) || (!d->movingHorizontally && d->orient == QDeclarativeListView::Horizontal)) - { - d->bufferMode = QDeclarativeListViewPrivate::NoBuffer; - if (d->haveHighlightRange && d->highlightRange == QDeclarativeListView::StrictlyEnforceRange) - d->updateHighlight(); - } + d->bufferMode = QDeclarativeListViewPrivate::NoBuffer; + if (d->haveHighlightRange && d->highlightRange == QDeclarativeListView::StrictlyEnforceRange) + d->updateHighlight(); } QDeclarativeListViewAttached *QDeclarativeListView::qmlAttachedProperties(QObject *obj) -- cgit v0.12 From 50ac9b21d999f698552125c0ba1ee9874f9e2989 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 13 May 2010 17:22:37 +1000 Subject: Remove garbage test. --- tests/auto/qdbusserver/.gitignore | 1 - tests/auto/qdbusserver/qdbusserver.pro | 11 ----- tests/auto/qdbusserver/server.cpp | 49 ------------------- tests/auto/qdbusserver/tst_qdbusserver.cpp | 78 ------------------------------ 4 files changed, 139 deletions(-) delete mode 100644 tests/auto/qdbusserver/.gitignore delete mode 100644 tests/auto/qdbusserver/qdbusserver.pro delete mode 100644 tests/auto/qdbusserver/server.cpp delete mode 100644 tests/auto/qdbusserver/tst_qdbusserver.cpp diff --git a/tests/auto/qdbusserver/.gitignore b/tests/auto/qdbusserver/.gitignore deleted file mode 100644 index 33a9be2..0000000 --- a/tests/auto/qdbusserver/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qdbusserver diff --git a/tests/auto/qdbusserver/qdbusserver.pro b/tests/auto/qdbusserver/qdbusserver.pro deleted file mode 100644 index 05a4eb8..0000000 --- a/tests/auto/qdbusserver/qdbusserver.pro +++ /dev/null @@ -1,11 +0,0 @@ -load(qttest_p4) -QT = core - -contains(QT_CONFIG,dbus): { - SOURCES += tst_qdbusserver.cpp - QT += dbus -} else { - SOURCES += ../qdbusmarshall/dummy.cpp -} - - diff --git a/tests/auto/qdbusserver/server.cpp b/tests/auto/qdbusserver/server.cpp deleted file mode 100644 index d4422f0..0000000 --- a/tests/auto/qdbusserver/server.cpp +++ /dev/null @@ -1,49 +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 - -int main(int argc, char *argv[]) -{ - QCoreApplication app(argc, argv); - QDBusServer server("unix:path=/tmp/qdbus-test"); - return app.exec(); -} diff --git a/tests/auto/qdbusserver/tst_qdbusserver.cpp b/tests/auto/qdbusserver/tst_qdbusserver.cpp deleted file mode 100644 index f0da02a..0000000 --- a/tests/auto/qdbusserver/tst_qdbusserver.cpp +++ /dev/null @@ -1,78 +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 - -static const QString bus = "unix:path=/tmp/qdbus-test"; -static const QString service = "com.trolltech.Qt.Autotests.QDBusServer"; -static const QString path = "/com/trolltech/test"; - -class tst_QDBusServer : public QObject -{ - Q_OBJECT - - void connectToServer(); - void callMethod(); -private slots: -}; - -void tst_QDBusServer::connectToServer() -{ - QDBusConnection connection = QDBusConnection::connectToBus(bus, "test-connection"); - QTest::qWait(100); - QVERIFY(connection.isConnected()); -} - -void tst_QDBusServer::callMethod() -{ - QDBusConnection connection = QDBusConnection::connectToBus(bus, "test-connection"); - QTest::qWait(100); - QVERIFY(connection.isConnected()); - //QDBusMessage msg = QDBusMessage::createMethodCall(bus, path, /*service*/"", "method"); - //QDBusMessage reply = connection.call(msg, QDBus::Block); -} - -QTEST_MAIN(tst_QDBusServer) - -#include "tst_qdbusserver.moc" -- cgit v0.12 From 286bc423df6ed670d46d9a7075114f787b8db4bc Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Thu, 13 May 2010 09:42:38 +0200 Subject: Fixing compiling issues. On tb92 compiler gets confused when there is private header in the main cpp file. This happens in a lot of places in autoteste and benchmarks. We have to give explicite path to the MW headers. Reviewed-by: TrustMe --- tests/auto/qhostinfo/qhostinfo.pro | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/auto/qhostinfo/qhostinfo.pro b/tests/auto/qhostinfo/qhostinfo.pro index 9bfe576..f5c3923 100644 --- a/tests/auto/qhostinfo/qhostinfo.pro +++ b/tests/auto/qhostinfo/qhostinfo.pro @@ -2,7 +2,7 @@ load(qttest_p4) SOURCES += tst_qhostinfo.cpp -QT = core network core +QT = core network wince*: { LIBS += ws2.lib @@ -10,4 +10,8 @@ wince*: { win32:LIBS += -lws2_32 } +symbian: { + INCLUDEPATH *= $$MW_LAYER_SYSTEMINCLUDE +} + -- cgit v0.12 From 4698e02579a4427c7a4ff7d59b1e37ba28ebc8e0 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 13 May 2010 14:54:34 +0200 Subject: QNAM HTTP: More testcases --- .../tst_qhttpnetworkconnection.cpp | 44 ++++++++++++++++++++ tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 47 ++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 21f228a..89f608e 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -109,6 +109,9 @@ private Q_SLOTS: void getMultipleWithPriorities(); void getEmptyWithPipelining(); + + void getAndThenDeleteObject(); + void getAndThenDeleteObject_data(); }; tst_QHttpNetworkConnection::tst_QHttpNetworkConnection() @@ -1033,6 +1036,47 @@ void tst_QHttpNetworkConnection::getEmptyWithPipelining() qDeleteAll(replies); } +void tst_QHttpNetworkConnection::getAndThenDeleteObject_data() +{ + QTest::addColumn("replyFirst"); + + QTest::newRow("delete-reply-first") << true; + QTest::newRow("delete-connection-first") << false; +} + +void tst_QHttpNetworkConnection::getAndThenDeleteObject() +{ + // yes, this will leak if the testcase fails. I don't care. It must not fail then :P + QHttpNetworkConnection *connection = new QHttpNetworkConnection(QtNetworkSettings::serverName()); + QHttpNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QHttpNetworkReply *reply = connection->sendRequest(request); + reply->setDownstreamLimited(true); + + QTime stopWatch; + stopWatch.start(); + forever { + QCoreApplication::instance()->processEvents(); + if (reply->bytesAvailable()) + break; + if (stopWatch.elapsed() >= 30000) + break; + } + + QVERIFY(reply->bytesAvailable()); + QCOMPARE(reply->statusCode() ,200); + QVERIFY(!reply->isFinished()); // must not be finished + + QFETCH(bool, replyFirst); + + if (replyFirst) { + delete reply; + delete connection; + } else { + delete connection; + delete reply; + } +} + QTEST_MAIN(tst_QHttpNetworkConnection) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 038610d..74ed7fc 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -276,6 +276,9 @@ private Q_SLOTS: void ignoreSslErrorsListWithSlot(); #endif + void getAndThenDeleteObject_data(); + void getAndThenDeleteObject(); + // NOTE: This test must be last! void parentingRepliesToTheApp(); }; @@ -4108,6 +4111,50 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot() #endif // QT_NO_OPENSSL +void tst_QNetworkReply::getAndThenDeleteObject_data() +{ + QTest::addColumn("replyFirst"); + + QTest::newRow("delete-reply-first") << true; + QTest::newRow("delete-qnam-first") << false; +} + +void tst_QNetworkReply::getAndThenDeleteObject() +{ + // yes, this will leak if the testcase fails. I don't care. It must not fail then :P + QNetworkAccessManager *manager = new QNetworkAccessManager(); + QNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QNetworkReply *reply = manager->get(request); + reply->setReadBufferSize(1); + reply->setParent((QObject*)0); // must be 0 because else it is the manager + + QTime stopWatch; + stopWatch.start(); + forever { + QCoreApplication::instance()->processEvents(); + if (reply->bytesAvailable()) + break; + if (stopWatch.elapsed() >= 30000) + break; + } + + QVERIFY(reply->bytesAvailable()); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); + QVERIFY(!reply->isFinished()); // must not be finished + + QFETCH(bool, replyFirst); + + if (replyFirst) { + delete reply; + delete manager; + } else { + delete manager; + delete reply; + } +} + + + // NOTE: This test must be last testcase in tst_qnetworkreply! void tst_QNetworkReply::parentingRepliesToTheApp() { -- cgit v0.12 From 20689ba77501c6c91d3db78f81f7ce64e7d15b95 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 13 May 2010 15:31:43 +0200 Subject: QNAM HTTP: Preemptive anti crash if() statement Task-number: QTBUG-10649 --- src/network/access/qhttpnetworkreply.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 338236e..108ba8a 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -179,6 +179,9 @@ qint64 QHttpNetworkReply::bytesAvailableNextBlock() const QByteArray QHttpNetworkReply::readAny() { Q_D(QHttpNetworkReply); + if (d->responseData.bufferCount() == 0) + return QByteArray(); + // we'll take the last buffer, so schedule another read from http if (d->downstreamLimited && d->responseData.bufferCount() == 1) d->connection->d_func()->readMoreLater(this); -- cgit v0.12 From 29559bb440529e4afd766cad61578947e86fa948 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 13 May 2010 16:41:42 +0200 Subject: Note that you need to unset a flag to create a visual item This needs to be documented as long as its true, or else it's a common source of confusion when writing QML items. --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 9433ba0..f251ba1 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1194,7 +1194,10 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec width and height, \l {anchor-layout}{anchoring} and key handling. You can subclass QDeclarativeItem to provide your own custom visual item that inherits - these features. + these features. Note that, because it does not draw anything, QDeclarativeItem sets the + QGraphicsItem::ItemHasNoContents flag. If you subclass QDeclarativeItem to create a visual + item, you will need to unset this flag. + */ /*! -- cgit v0.12 From 3c1cb52aae6f7a5bd94c28a0b183e2375526724b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 10 May 2010 12:45:27 +0200 Subject: Removed dependency of QDeclarativeWebView to private Qt (Declarative) API Exchanged the use of QDeclarativePaintedItem with the use of QGraphicsWebView and its tiled backing store. --- .../webbrowser/content/FlickableWebView.qml | 29 +-- src/imports/webkit/qdeclarativewebview.cpp | 237 ++++++++------------- src/imports/webkit/qdeclarativewebview_p.h | 32 ++- 3 files changed, 113 insertions(+), 185 deletions(-) diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 7efbaa3..32d69d8 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -12,8 +12,8 @@ Flickable { id: flickable width: parent.width - contentWidth: Math.max(parent.width,webView.width*webView.scale) - contentHeight: Math.max(parent.height,webView.height*webView.scale) + contentWidth: Math.max(parent.width,webView.width) + contentHeight: Math.max(parent.height,webView.height) anchors.top: headerSpace.bottom anchors.bottom: parent.top anchors.left: parent.left @@ -28,7 +28,6 @@ Flickable { WebView { id: webView - pixelCacheSize: 4000000 transformOrigin: Item.TopLeft function fixUrl(url) @@ -48,8 +47,6 @@ Flickable { url: fixUrl(webBrowser.urlString) smooth: false // We don't want smooth scaling, since we only scale during (fast) transitions - smoothCache: true // We do want smooth rendering - fillColor: "white" focus: true zoomFactor: 1 @@ -59,14 +56,13 @@ Flickable { { if (centerX) { var sc = zoom/contentsScale; - scaleAnim.to = sc; + scaleAnim.to = zoom; flickVX.from = flickable.contentX flickVX.to = Math.max(0,Math.min(centerX-flickable.width/2,webView.width*sc-flickable.width)) finalX.value = flickVX.to flickVY.from = flickable.contentY flickVY.to = Math.max(0,Math.min(centerY-flickable.height/2,webView.height*sc-flickable.height)) finalY.value = flickVY.to - finalZoom.value = zoom quickZoom.start() } } @@ -74,8 +70,8 @@ Flickable { Keys.onLeftPressed: webView.contentsScale -= 0.1 Keys.onRightPressed: webView.contentsScale += 0.1 - preferredWidth: flickable.width*zoomFactor - preferredHeight: flickable.height*zoomFactor + preferredWidth: flickable.width + preferredHeight: flickable.height contentsScale: 1/zoomFactor onContentsSizeChanged: { // zoom out @@ -108,9 +104,8 @@ Flickable { NumberAnimation { id: scaleAnim target: webView - property: "scale" - from: 1 - to: 0 // set before calling + property: "contentsScale" + // the to property is set before calling easing.type: Easing.Linear duration: 200 } @@ -133,16 +128,6 @@ Flickable { to: 0 // set before calling } } - PropertyAction { - id: finalZoom - target: webView - property: "contentsScale" - } - PropertyAction { - target: webView - property: "scale" - value: 1.0 - } // Have to set the contentXY, since the above 2 // size changes may have started a correction if // contentsScale < 1.0. diff --git a/src/imports/webkit/qdeclarativewebview.cpp b/src/imports/webkit/qdeclarativewebview.cpp index 9571470..9e24007 100644 --- a/src/imports/webkit/qdeclarativewebview.cpp +++ b/src/imports/webkit/qdeclarativewebview.cpp @@ -42,11 +42,9 @@ #include "qdeclarativewebview_p.h" #include "qdeclarativewebview_p_p.h" -#include - #include #include -#include +#include #include #include @@ -61,29 +59,29 @@ #include #include #include -#include QT_BEGIN_NAMESPACE static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system -class QDeclarativeWebViewPrivate : public QDeclarativePaintedItemPrivate +class QDeclarativeWebViewPrivate { - Q_DECLARE_PUBLIC(QDeclarativeWebView) - public: - QDeclarativeWebViewPrivate() - : QDeclarativePaintedItemPrivate(), page(0), preferredwidth(0), preferredheight(0), + QDeclarativeWebViewPrivate(QDeclarativeWebView* qq) + : q(qq), page(0), preferredwidth(0), preferredheight(0), progress(1.0), status(QDeclarativeWebView::Null), pending(PendingNone), newWindowComponent(0), newWindowParent(0), pressTime(400), rendering(true) { + QObject::connect(q, SIGNAL(focusChanged(bool)), q, SLOT(propagateFocusToWebPage(bool))); } - void focusChanged(bool); + + QDeclarativeWebView *q; QUrl url; // page url might be different if it has not loaded yet QWebPage *page; + QGraphicsWebView* view; int preferredwidth, preferredheight; qreal progress; @@ -101,7 +99,6 @@ public: QPoint pressPoint; int pressTime; // milliseconds before it's a "hold" - static void windowObjects_append(QDeclarativeListProperty *prop, QObject *o) { static_cast(prop->data)->windowObjects.append(o); static_cast(prop->data)->updateWindowObjects(); @@ -169,34 +166,39 @@ public: */ QDeclarativeWebView::QDeclarativeWebView(QDeclarativeItem *parent) - : QDeclarativePaintedItem(*(new QDeclarativeWebViewPrivate), parent) + : QDeclarativeItem(parent) { init(); } QDeclarativeWebView::~QDeclarativeWebView() { - Q_D(QDeclarativeWebView); delete d->page; + delete d; } void QDeclarativeWebView::init() { - Q_D(QDeclarativeWebView); + d = new QDeclarativeWebViewPrivate(this); QWebSettings::enablePersistentStorage(); setAcceptHoverEvents(true); setAcceptedMouseButtons(Qt::LeftButton); - setFlag(QGraphicsItem::ItemHasNoContents, false); + setFlag(QGraphicsItem::ItemHasNoContents, true); + setClip(true); d->page = 0; + d->view = new QGraphicsWebView(this); + d->view->setResizesToContents(true); + d->view->setFlag(QGraphicsItem::ItemStacksBehindParent, true); + connect(d->view, SIGNAL(geometryChanged()), this, SLOT(updateDeclarativeWebViewSize())); + connect(d->view, SIGNAL(scaleChanged()), this, SIGNAL(contentsScaleChanged())); } void QDeclarativeWebView::componentComplete() { - QDeclarativePaintedItem::componentComplete(); - Q_D(QDeclarativeWebView); + QDeclarativeItem::componentComplete(); switch (d->pending) { case QDeclarativeWebViewPrivate::PendingUrl: setUrl(d->pending_url); @@ -216,7 +218,6 @@ void QDeclarativeWebView::componentComplete() QDeclarativeWebView::Status QDeclarativeWebView::status() const { - Q_D(const QDeclarativeWebView); return d->status; } @@ -230,13 +231,11 @@ QDeclarativeWebView::Status QDeclarativeWebView::status() const */ qreal QDeclarativeWebView::progress() const { - Q_D(const QDeclarativeWebView); return d->progress; } void QDeclarativeWebView::doLoadStarted() { - Q_D(QDeclarativeWebView); if (!d->url.isEmpty()) { d->status = Loading; @@ -247,7 +246,6 @@ void QDeclarativeWebView::doLoadStarted() void QDeclarativeWebView::doLoadProgress(int p) { - Q_D(QDeclarativeWebView); if (d->progress == p/100.0) return; d->progress = p/100.0; @@ -256,12 +254,7 @@ void QDeclarativeWebView::doLoadProgress(int p) void QDeclarativeWebView::pageUrlChanged() { - Q_D(QDeclarativeWebView); - - page()->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth : width(), - d->preferredheight>0 ? d->preferredheight : height())); - expandToWebPage(); + updateContentsSize(); if ((d->url.isEmpty() && page()->mainFrame()->url() != QUrl(QLatin1String("about:blank"))) || (d->url != page()->mainFrame()->url() && !page()->mainFrame()->url().isEmpty())) @@ -275,7 +268,6 @@ void QDeclarativeWebView::pageUrlChanged() void QDeclarativeWebView::doLoadFinished(bool ok) { - Q_D(QDeclarativeWebView); if (title().isEmpty()) pageUrlChanged(); // XXX bug 232556 - pages with no title never get urlChanged() @@ -302,21 +294,17 @@ void QDeclarativeWebView::doLoadFinished(bool ok) */ QUrl QDeclarativeWebView::url() const { - Q_D(const QDeclarativeWebView); return d->url; } void QDeclarativeWebView::setUrl(const QUrl &url) { - Q_D(QDeclarativeWebView); if (url == d->url) return; if (isComponentComplete()) { d->url = url; - page()->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth : width(), - d->preferredheight>0 ? d->preferredheight : height())); + updateContentsSize(); QUrl seturl = url; if (seturl.isEmpty()) seturl = QUrl(QLatin1String("about:blank")); @@ -338,16 +326,14 @@ void QDeclarativeWebView::setUrl(const QUrl &url) */ int QDeclarativeWebView::preferredWidth() const { - Q_D(const QDeclarativeWebView); return d->preferredwidth; } void QDeclarativeWebView::setPreferredWidth(int iw) { - Q_D(QDeclarativeWebView); if (d->preferredwidth == iw) return; d->preferredwidth = iw; - //expandToWebPage(); + updateContentsSize(); emit preferredWidthChanged(); } @@ -358,14 +344,14 @@ void QDeclarativeWebView::setPreferredWidth(int iw) */ int QDeclarativeWebView::preferredHeight() const { - Q_D(const QDeclarativeWebView); return d->preferredheight; } + void QDeclarativeWebView::setPreferredHeight(int ih) { - Q_D(QDeclarativeWebView); if (d->preferredheight == ih) return; d->preferredheight = ih; + updateContentsSize(); emit preferredHeightChanged(); } @@ -383,55 +369,45 @@ QVariant QDeclarativeWebView::evaluateJavaScript(const QString &scriptSource) return this->page()->mainFrame()->evaluateJavaScript(scriptSource); } -void QDeclarativeWebViewPrivate::focusChanged(bool hasFocus) +void QDeclarativeWebView::propagateFocusToWebPage(bool hasFocus) { - Q_Q(QDeclarativeWebView); QFocusEvent e(hasFocus ? QEvent::FocusIn : QEvent::FocusOut); - q->page()->event(&e); - QDeclarativeItemPrivate::focusChanged(hasFocus); + page()->event(&e); } -void QDeclarativeWebView::initialLayout() +void QDeclarativeWebView::updateDeclarativeWebViewSize() { - // nothing useful to do at this point + QSizeF size = d->view->geometry().size() * contentsScale(); + setImplicitWidth(size.width()); + setImplicitHeight(size.height()); } -void QDeclarativeWebView::noteContentsSizeChanged(const QSize&) +void QDeclarativeWebView::initialLayout() { - expandToWebPage(); + // nothing useful to do at this point } -void QDeclarativeWebView::expandToWebPage() +void QDeclarativeWebView::updateContentsSize() { - Q_D(QDeclarativeWebView); - QSize cs = page()->mainFrame()->contentsSize(); - if (cs.width() < d->preferredwidth) - cs.setWidth(d->preferredwidth); - if (cs.height() < d->preferredheight) - cs.setHeight(d->preferredheight); - if (widthValid()) - cs.setWidth(width()); - if (heightValid()) - cs.setHeight(height()); - if (cs != page()->viewportSize()) { - page()->setViewportSize(cs); - } - if (cs != contentsSize()) - setContentsSize(cs); + if (d->page) + d->page->setPreferredContentsSize(QSize( + d->preferredwidth>0 ? d->preferredwidth : width(), + d->preferredheight>0 ? d->preferredheight : height())); } void QDeclarativeWebView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - if (newGeometry.size() != oldGeometry.size()) - expandToWebPage(); - QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry); -} - -void QDeclarativeWebView::paintPage(const QRect& r) -{ - dirtyCache(r); - update(); + if (newGeometry.size() != oldGeometry.size() && d->page) { + QSize cs = d->page->preferredContentsSize(); + if (widthValid()) + cs.setWidth(width()); + if (heightValid()) + cs.setHeight(height()); + if (cs != d->page->preferredContentsSize()) + d->page->setPreferredContentsSize(cs); + } + QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); } /*! @@ -473,7 +449,6 @@ void QDeclarativeWebView::paintPage(const QRect& r) */ QDeclarativeListProperty QDeclarativeWebView::javaScriptWindowObjects() { - Q_D(QDeclarativeWebView); return QDeclarativeListProperty(this, d, &QDeclarativeWebViewPrivate::windowObjects_append); } @@ -484,8 +459,7 @@ QDeclarativeWebViewAttached *QDeclarativeWebView::qmlAttachedProperties(QObject void QDeclarativeWebViewPrivate::updateWindowObjects() { - Q_Q(QDeclarativeWebView); - if (!q->isComponentComplete() || !page) + if (!q->isComponentCompletePublic() || !page) return; for (int ii = 0; ii < windowObjects.count(); ++ii) { @@ -499,29 +473,17 @@ void QDeclarativeWebViewPrivate::updateWindowObjects() bool QDeclarativeWebView::renderingEnabled() const { - Q_D(const QDeclarativeWebView); return d->rendering; } void QDeclarativeWebView::setRenderingEnabled(bool enabled) { - Q_D(QDeclarativeWebView); if (d->rendering == enabled) return; d->rendering = enabled; emit renderingEnabledChanged(); - setCacheFrozen(!enabled); - if (enabled) - clearCache(); -} - - -void QDeclarativeWebView::drawContents(QPainter *p, const QRect &r) -{ - Q_D(QDeclarativeWebView); - if (d->rendering) - page()->mainFrame()->render(p,r); + d->view->setTiledBackingStoreFrozen(!enabled); } QMouseEvent *QDeclarativeWebView::sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e) @@ -556,7 +518,6 @@ QMouseEvent *QDeclarativeWebView::sceneHoverMoveEventToMouseEvent(QGraphicsScene return me; } - /*! \qmlsignal WebView::onDoubleClick(clickx,clicky) @@ -588,7 +549,6 @@ void QDeclarativeWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) */ bool QDeclarativeWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom) { - Q_D(QDeclarativeWebView); if (contentsScale() >= maxzoom/zoomFactor()) return false; qreal ozf = contentsScale(); @@ -617,13 +577,11 @@ bool QDeclarativeWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom) */ int QDeclarativeWebView::pressGrabTime() const { - Q_D(const QDeclarativeWebView); return d->pressTime; } void QDeclarativeWebView::setPressGrabTime(int ms) { - Q_D(QDeclarativeWebView); if (d->pressTime == ms) return; d->pressTime = ms; @@ -632,8 +590,6 @@ void QDeclarativeWebView::setPressGrabTime(int ms) void QDeclarativeWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeWebView); - setFocus (true); QMouseEvent *me = sceneMouseEventToMouseEvent(event); @@ -661,14 +617,12 @@ void QDeclarativeWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) ); delete me; if (!event->isAccepted()) { - QDeclarativePaintedItem::mousePressEvent(event); + QDeclarativeItem::mousePressEvent(event); } } void QDeclarativeWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeWebView); - QMouseEvent *me = sceneMouseEventToMouseEvent(event); page()->event(me); d->pressTimer.stop(); @@ -685,7 +639,7 @@ void QDeclarativeWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) ); delete me; if (!event->isAccepted()) { - QDeclarativePaintedItem::mouseReleaseEvent(event); + QDeclarativeItem::mouseReleaseEvent(event); } setKeepMouseGrab(false); ungrabMouse(); @@ -693,7 +647,6 @@ void QDeclarativeWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void QDeclarativeWebView::timerEvent(QTimerEvent *event) { - Q_D(QDeclarativeWebView); if (event->timerId() == d->pressTimer.timerId()) { d->pressTimer.stop(); grabMouse(); @@ -703,8 +656,6 @@ void QDeclarativeWebView::timerEvent(QTimerEvent *event) void QDeclarativeWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeWebView); - QMouseEvent *me = sceneMouseEventToMouseEvent(event); if (d->pressTimer.isActive()) { if ((me->pos() - d->pressPoint).manhattanLength() > QApplication::startDragDistance()) { @@ -728,9 +679,9 @@ void QDeclarativeWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } delete me; if (!event->isAccepted()) - QDeclarativePaintedItem::mouseMoveEvent(event); - + QDeclarativeItem::mouseMoveEvent(event); } + void QDeclarativeWebView::hoverMoveEvent (QGraphicsSceneHoverEvent * event) { QMouseEvent *me = sceneHoverMoveEventToMouseEvent(event); @@ -744,21 +695,7 @@ void QDeclarativeWebView::hoverMoveEvent (QGraphicsSceneHoverEvent * event) ); delete me; if (!event->isAccepted()) - QDeclarativePaintedItem::hoverMoveEvent(event); -} - -void QDeclarativeWebView::keyPressEvent(QKeyEvent* event) -{ - page()->event(event); - if (!event->isAccepted()) - QDeclarativePaintedItem::keyPressEvent(event); -} - -void QDeclarativeWebView::keyReleaseEvent(QKeyEvent* event) -{ - page()->event(event); - if (!event->isAccepted()) - QDeclarativePaintedItem::keyReleaseEvent(event); + QDeclarativeItem::hoverMoveEvent(event); } bool QDeclarativeWebView::sceneEvent(QEvent *event) @@ -773,7 +710,7 @@ bool QDeclarativeWebView::sceneEvent(QEvent *event) } } } - return QDeclarativePaintedItem::sceneEvent(event); + return QDeclarativeItem::sceneEvent(event); } @@ -842,15 +779,11 @@ QPixmap QDeclarativeWebView::icon() const */ void QDeclarativeWebView::setZoomFactor(qreal factor) { - Q_D(QDeclarativeWebView); if (factor == page()->mainFrame()->zoomFactor()) return; page()->mainFrame()->setZoomFactor(factor); - page()->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth*factor : width()*factor, - d->preferredheight>0 ? d->preferredheight*factor : height()*factor)); - expandToWebPage(); + updateContentsSize(); emit zoomFactorChanged(); } @@ -868,37 +801,27 @@ qreal QDeclarativeWebView::zoomFactor() const */ void QDeclarativeWebView::setStatusText(const QString& s) { - Q_D(QDeclarativeWebView); d->statusText = s; emit statusTextChanged(); } void QDeclarativeWebView::windowObjectCleared() { - Q_D(QDeclarativeWebView); d->updateWindowObjects(); } QString QDeclarativeWebView::statusText() const { - Q_D(const QDeclarativeWebView); return d->statusText; } QWebPage *QDeclarativeWebView::page() const { - Q_D(const QDeclarativeWebView); if (!d->page) { QDeclarativeWebView *self = const_cast(this); QWebPage *wp = new QDeclarativeWebPage(self); - // QML items don't default to having a background, - // even though most we pages will set one anyway. - QPalette pal = QApplication::palette(); - pal.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0)); - wp->setPalette(pal); - wp->setNetworkAccessManager(qmlEngine(this)->networkAccessManager()); self->setPage(wp); @@ -954,14 +877,12 @@ QWebPage *QDeclarativeWebView::page() const */ QDeclarativeWebSettings *QDeclarativeWebView::settingsObject() const { - Q_D(const QDeclarativeWebView); d->settings.s = page()->settings(); return &d->settings; } void QDeclarativeWebView::setPage(QWebPage *page) { - Q_D(QDeclarativeWebView); if (d->page == page) return; if (d->page) { @@ -972,18 +893,15 @@ void QDeclarativeWebView::setPage(QWebPage *page) } } d->page = page; - d->page->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth : width(), - d->preferredheight>0 ? d->preferredheight : height())); + updateContentsSize(); d->page->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff); d->page->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff); - connect(d->page,SIGNAL(repaintRequested(QRect)),this,SLOT(paintPage(QRect))); connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SLOT(pageUrlChanged())); connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(iconChanged())); connect(d->page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); - connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(noteContentsSizeChanged(QSize))); connect(d->page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout())); + connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SIGNAL(contentsSizeChanged(QSize))); connect(d->page,SIGNAL(loadStarted()),this,SLOT(doLoadStarted())); connect(d->page,SIGNAL(loadProgress(int)),this,SLOT(doLoadProgress(int))); @@ -991,6 +909,10 @@ void QDeclarativeWebView::setPage(QWebPage *page) connect(d->page,SIGNAL(statusBarMessage(QString)),this,SLOT(setStatusText(QString))); connect(d->page->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(windowObjectCleared())); + + d->page->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); + + d->view->setPage(page); } /*! @@ -1045,10 +967,7 @@ QString QDeclarativeWebView::html() const */ void QDeclarativeWebView::setHtml(const QString &html, const QUrl &baseUrl) { - Q_D(QDeclarativeWebView); - page()->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth : width(), - d->preferredheight>0 ? d->preferredheight : height())); + updateContentsSize(); if (isComponentComplete()) page()->mainFrame()->setHtml(html, baseUrl); else { @@ -1061,10 +980,7 @@ void QDeclarativeWebView::setHtml(const QString &html, const QUrl &baseUrl) void QDeclarativeWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl) { - Q_D(QDeclarativeWebView); - page()->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth : width(), - d->preferredheight>0 ? d->preferredheight : height())); + updateContentsSize(); if (isComponentComplete()) page()->mainFrame()->setContent(data,mimeType,qmlContext(this)->resolvedUrl(baseUrl)); @@ -1088,7 +1004,6 @@ QWebSettings *QDeclarativeWebView::settings() const QDeclarativeWebView *QDeclarativeWebView::createWindow(QWebPage::WebWindowType type) { - Q_D(QDeclarativeWebView); switch (type) { case QWebPage::WebBrowserWindow: { if (!d->newWindowComponent && d->newWindowParent) @@ -1142,13 +1057,11 @@ QDeclarativeWebView *QDeclarativeWebView::createWindow(QWebPage::WebWindowType t */ QDeclarativeComponent *QDeclarativeWebView::newWindowComponent() const { - Q_D(const QDeclarativeWebView); return d->newWindowComponent; } void QDeclarativeWebView::setNewWindowComponent(QDeclarativeComponent *newWindow) { - Q_D(QDeclarativeWebView); if (newWindow == d->newWindowComponent) return; d->newWindowComponent = newWindow; @@ -1165,13 +1078,11 @@ void QDeclarativeWebView::setNewWindowComponent(QDeclarativeComponent *newWindow */ QDeclarativeItem *QDeclarativeWebView::newWindowParent() const { - Q_D(const QDeclarativeWebView); return d->newWindowParent; } void QDeclarativeWebView::setNewWindowParent(QDeclarativeItem *parent) { - Q_D(QDeclarativeWebView); if (parent == d->newWindowParent) return; if (d->newWindowParent && parent) { @@ -1184,6 +1095,25 @@ void QDeclarativeWebView::setNewWindowParent(QDeclarativeItem *parent) emit newWindowParentChanged(); } +QSize QDeclarativeWebView::contentsSize() const +{ + return d->page->mainFrame()->contentsSize() * contentsScale(); +} + +qreal QDeclarativeWebView::contentsScale() const +{ + return d->view->scale(); +} + +void QDeclarativeWebView::setContentsScale(qreal scale) +{ + if (scale == d->view->scale()) + return; + d->view->setScale(scale); + updateDeclarativeWebViewSize(); + emit contentsScaleChanged(); +} + /*! Returns the area of the largest element at position (\a x,\a y) that is no larger than \a maxwidth by \a maxheight pixels. @@ -1280,3 +1210,4 @@ QWebPage *QDeclarativeWebPage::createWindow(WebWindowType type) } QT_END_NAMESPACE + diff --git a/src/imports/webkit/qdeclarativewebview_p.h b/src/imports/webkit/qdeclarativewebview_p.h index 81581d8..87bd938 100644 --- a/src/imports/webkit/qdeclarativewebview_p.h +++ b/src/imports/webkit/qdeclarativewebview_p.h @@ -42,12 +42,13 @@ #ifndef QDECLARATIVEWEBVIEW_H #define QDECLARATIVEWEBVIEW_H -#include +#include #include #include #include #include +#include QT_BEGIN_HEADER @@ -61,6 +62,7 @@ class QDeclarativeWebSettings; class QDeclarativeWebViewPrivate; class QNetworkRequest; class QDeclarativeWebView; +class QDeclarativeWebViewPrivate; class QDeclarativeWebPage : public QWebPage { @@ -85,7 +87,7 @@ class QDeclarativeWebViewAttached; //### TODO: browser plugins -class QDeclarativeWebView : public QDeclarativePaintedItem +class QDeclarativeWebView : public QDeclarativeItem { Q_OBJECT @@ -120,6 +122,9 @@ class QDeclarativeWebView : public QDeclarativePaintedItem Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged) + Q_PROPERTY(QSize contentsSize READ contentsSize NOTIFY contentsSizeChanged) + Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged) + public: QDeclarativeWebView(QDeclarativeItem *parent=0); ~QDeclarativeWebView(); @@ -182,6 +187,13 @@ public: QDeclarativeItem *newWindowParent() const; void setNewWindowParent(QDeclarativeItem *newWindow); + bool isComponentCompletePublic() const { return isComponentComplete(); } + + QSize contentsSize() const; + + void setContentsScale(qreal scale); + qreal contentsScale() const; + Q_SIGNALS: void preferredWidthChanged(); void preferredHeightChanged(); @@ -197,6 +209,8 @@ Q_SIGNALS: void newWindowComponentChanged(); void newWindowParentChanged(); void renderingEnabledChanged(); + void contentsSizeChanged(const QSize&); + void contentsScaleChanged(); void loadStarted(); void loadFinished(); @@ -212,38 +226,36 @@ public Q_SLOTS: QVariant evaluateJavaScript(const QString&); private Q_SLOTS: - void expandToWebPage(); - void paintPage(const QRect&); void doLoadStarted(); void doLoadProgress(int p); void doLoadFinished(bool ok); void setStatusText(const QString&); void windowObjectCleared(); void pageUrlChanged(); - void noteContentsSizeChanged(const QSize&); void initialLayout(); -protected: - void drawContents(QPainter *, const QRect &); + void propagateFocusToWebPage(bool); + void updateDeclarativeWebViewSize(); + +protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void timerEvent(QTimerEvent *event); void hoverMoveEvent (QGraphicsSceneHoverEvent * event); - void keyPressEvent(QKeyEvent* event); - void keyReleaseEvent(QKeyEvent* event); virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); virtual bool sceneEvent(QEvent *event); QDeclarativeWebView *createWindow(QWebPage::WebWindowType type); private: + void updateContentsSize(); void init(); virtual void componentComplete(); Q_DISABLE_COPY(QDeclarativeWebView) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeWebView) + QDeclarativeWebViewPrivate* d; QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *); QMouseEvent *sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *); friend class QDeclarativeWebPage; -- cgit v0.12 From cce4e4393277298b5b5246ab79e615173b2cb13a Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 13 May 2010 18:36:15 +0200 Subject: Minor declarative webview tweaks Added a comment to the class docs, and cleaned up the visual tests a little. However the visual tests are old and text heavy, and since we never seem to check them we might wait on updating them for a little longer. --- src/imports/webkit/qdeclarativewebview.cpp | 7 +- .../qmlvisual/qfxwebview/autosize/autosize.qml | 61 ---- .../qfxwebview/autosize/data-X11/autosize.0.png | Bin 6886 -> 0 bytes .../qfxwebview/autosize/data-X11/autosize.qml | 83 ----- .../qfxwebview/autosize/data/autosize.0.png | Bin 6886 -> 0 bytes .../qfxwebview/autosize/data/autosize.qml | 83 ----- .../qmlvisual/webview/autosize/autosize.qml | 61 ++++ .../webview/autosize/data-X11/autosize.0.png | Bin 0 -> 10185 bytes .../webview/autosize/data-X11/autosize.1.png | Bin 0 -> 10185 bytes .../webview/autosize/data-X11/autosize.2.png | Bin 0 -> 10185 bytes .../webview/autosize/data-X11/autosize.3.png | Bin 0 -> 10185 bytes .../webview/autosize/data-X11/autosize.4.png | Bin 0 -> 10185 bytes .../webview/autosize/data-X11/autosize.qml | 115 +++++++ .../qmlvisual/webview/autosize/data/autosize.0.png | Bin 0 -> 10185 bytes .../qmlvisual/webview/autosize/data/autosize.1.png | Bin 0 -> 10185 bytes .../qmlvisual/webview/autosize/data/autosize.2.png | Bin 0 -> 10185 bytes .../qmlvisual/webview/autosize/data/autosize.3.png | Bin 0 -> 10185 bytes .../qmlvisual/webview/autosize/data/autosize.4.png | Bin 0 -> 10185 bytes .../qmlvisual/webview/autosize/data/autosize.qml | 115 +++++++ .../qmlvisual/webview/embedding/data/nesting.0.png | Bin 5659 -> 0 bytes .../qmlvisual/webview/embedding/data/nesting.qml | 363 --------------------- .../qmlvisual/webview/embedding/egg.qml | 26 -- .../qmlvisual/webview/embedding/nesting.html | 9 - .../qmlvisual/webview/embedding/nesting.qml | 9 - 24 files changed, 296 insertions(+), 636 deletions(-) delete mode 100644 tests/auto/declarative/qmlvisual/qfxwebview/autosize/autosize.qml delete mode 100644 tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.0.png delete mode 100644 tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.qml delete mode 100644 tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.0.png delete mode 100644 tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.qml create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/autosize.qml create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.0.png create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.1.png create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.2.png create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.3.png create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.4.png create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.qml create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.0.png create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.1.png create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.2.png create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.3.png create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.4.png create mode 100644 tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.qml delete mode 100644 tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.0.png delete mode 100644 tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.qml delete mode 100644 tests/auto/declarative/qmlvisual/webview/embedding/egg.qml delete mode 100644 tests/auto/declarative/qmlvisual/webview/embedding/nesting.html delete mode 100644 tests/auto/declarative/qmlvisual/webview/embedding/nesting.qml diff --git a/src/imports/webkit/qdeclarativewebview.cpp b/src/imports/webkit/qdeclarativewebview.cpp index 9e24007..36a25f6 100644 --- a/src/imports/webkit/qdeclarativewebview.cpp +++ b/src/imports/webkit/qdeclarativewebview.cpp @@ -126,6 +126,9 @@ public: dynamically adjust to a size appropriate for the content. This width may be large for typical online web pages. + If the width or height is explictly set, the rendered website + will be clipped, not scaled, to fit into the set dimensions. + If the preferredWidth is set, the width will be this amount or larger, usually laying out the web content to fit the preferredWidth. @@ -134,8 +137,8 @@ public: WebView { url: "http://www.nokia.com" - width: 490 - height: 400 + preferredWidth: 490 + preferredHeight: 400 scale: 0.5 smooth: false smoothCache: true diff --git a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/autosize.qml b/tests/auto/declarative/qmlvisual/qfxwebview/autosize/autosize.qml deleted file mode 100644 index c4a502e..0000000 --- a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/autosize.qml +++ /dev/null @@ -1,61 +0,0 @@ -import Qt 4.7 -import org.webkit 1.0 - -// The WebView size is determined by the width, height, -// preferredWidth, and preferredHeight properties. -Rectangle { - id: rect - color: "white" - width: 200 - height: layout.height - Column { - id: layout - spacing: 2 - WebView { - html: "No width defined." - Rectangle { color: "#10000000" - anchors.fill: parent - } - } - WebView { - width: rect.width - html: "The width is full." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - WebView { - width: rect.width/2 - html: "The width is half." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - WebView { - preferredWidth: rect.width/2 - html: "The preferredWidth is half." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - WebView { - preferredWidth: rect.width/2 - html: "The_preferredWidth_is_half." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - WebView { - width: rect.width/2 - html: "The_width_is_half." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - } -} diff --git a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.0.png b/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.0.png deleted file mode 100644 index 1f28b9a..0000000 Binary files a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.0.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.qml b/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.qml deleted file mode 100644 index f4c4e29..0000000 --- a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.qml +++ /dev/null @@ -1,83 +0,0 @@ -import Qt.VisualTest 4.7 - -VisualTest { - Frame { - msec: 0 - } - Frame { - msec: 16 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 32 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 48 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 64 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 80 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 96 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 112 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 128 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 144 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 160 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 176 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 192 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 208 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 224 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 240 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 256 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 272 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 288 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 304 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } -} diff --git a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.0.png b/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.0.png deleted file mode 100644 index 1f28b9a..0000000 Binary files a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.0.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.qml b/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.qml deleted file mode 100644 index 273c2b0..0000000 --- a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.qml +++ /dev/null @@ -1,83 +0,0 @@ -import Qt.VisualTest 4.7 - -VisualTest { - Frame { - msec: 0 - } - Frame { - msec: 16 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 32 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 48 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 64 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 80 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 96 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 112 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 128 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 144 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 160 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 176 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 192 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 208 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 224 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 240 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 256 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 272 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 288 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 304 - hash: "66539e1b1983d95386b0d30d6e969904" - } -} diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/autosize.qml b/tests/auto/declarative/qmlvisual/webview/autosize/autosize.qml new file mode 100644 index 0000000..c4a502e --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/autosize.qml @@ -0,0 +1,61 @@ +import Qt 4.7 +import org.webkit 1.0 + +// The WebView size is determined by the width, height, +// preferredWidth, and preferredHeight properties. +Rectangle { + id: rect + color: "white" + width: 200 + height: layout.height + Column { + id: layout + spacing: 2 + WebView { + html: "No width defined." + Rectangle { color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: rect.width + html: "The width is full." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: rect.width/2 + html: "The width is half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + preferredWidth: rect.width/2 + html: "The preferredWidth is half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + preferredWidth: rect.width/2 + html: "The_preferredWidth_is_half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: rect.width/2 + html: "The_width_is_half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + } +} diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.0.png b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.0.png new file mode 100644 index 0000000..ed87174 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.0.png differ diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.1.png b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.1.png new file mode 100644 index 0000000..ed87174 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.1.png differ diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.2.png b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.2.png new file mode 100644 index 0000000..ed87174 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.2.png differ diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.3.png b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.3.png new file mode 100644 index 0000000..ed87174 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.3.png differ diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.4.png b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.4.png new file mode 100644 index 0000000..ed87174 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.4.png differ diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.qml b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.qml new file mode 100644 index 0000000..6122138 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.qml @@ -0,0 +1,115 @@ +import Qt.VisualTest 4.7 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "b2d863e57dee2a297d038e18acc70f92" + } + Frame { + msec: 32 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 48 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 64 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 80 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 96 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 112 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 128 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 144 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 160 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 176 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 192 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 208 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 224 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 240 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 256 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 272 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 288 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 304 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 320 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 336 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 352 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 368 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 384 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 400 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 416 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 432 + hash: "903a4c7e619abba5342c8c827f26a722" + } +} diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.0.png b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.0.png new file mode 100644 index 0000000..ed87174 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.0.png differ diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.1.png b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.1.png new file mode 100644 index 0000000..ed87174 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.1.png differ diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.2.png b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.2.png new file mode 100644 index 0000000..ed87174 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.2.png differ diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.3.png b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.3.png new file mode 100644 index 0000000..ed87174 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.3.png differ diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.4.png b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.4.png new file mode 100644 index 0000000..ed87174 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.4.png differ diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.qml b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.qml new file mode 100644 index 0000000..6122138 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.qml @@ -0,0 +1,115 @@ +import Qt.VisualTest 4.7 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "b2d863e57dee2a297d038e18acc70f92" + } + Frame { + msec: 32 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 48 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 64 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 80 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 96 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 112 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 128 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 144 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 160 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 176 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 192 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 208 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 224 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 240 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 256 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 272 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 288 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 304 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 320 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 336 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 352 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 368 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 384 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 400 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 416 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 432 + hash: "903a4c7e619abba5342c8c827f26a722" + } +} diff --git a/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.0.png b/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.0.png deleted file mode 100644 index 57de710..0000000 Binary files a/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.0.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.qml b/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.qml deleted file mode 100644 index 9664566..0000000 --- a/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.qml +++ /dev/null @@ -1,363 +0,0 @@ -import Qt.VisualTest 4.7 - -VisualTest { - Frame { - msec: 0 - } - Frame { - msec: 16 - hash: "5dc8dca7a73022fbf2116b654b709244" - } - Frame { - msec: 32 - hash: "5dc8dca7a73022fbf2116b654b709244" - } - Frame { - msec: 48 - hash: "34079c4076ab6aadd8b64fcba7d95e15" - } - Frame { - msec: 64 - hash: "5ab5fc62b49e78d0609dcb4be6c9a157" - } - Frame { - msec: 80 - hash: "063cc7438bbffae717648d98006021a8" - } - Frame { - msec: 96 - hash: "c5cd16663e48639cbeade82c3bfa0403" - } - Frame { - msec: 112 - hash: "ea7f8df84ddbad0f683fe97ddb0a0130" - } - Frame { - msec: 128 - hash: "3c353e09bdb3a1e6ff388ad6020f55ea" - } - Frame { - msec: 144 - hash: "5b6de430365d0c9824337011916b0c0b" - } - Frame { - msec: 160 - hash: "48d353ac9e7ee1ce41361d0a2b47e008" - } - Frame { - msec: 176 - hash: "c96e4d02d343ddd78e8d3dd6aa8e0198" - } - Frame { - msec: 192 - hash: "543c63d77ec635b77672ba4c5160a3d4" - } - Frame { - msec: 208 - hash: "2d56ad9c2352e555fef613d625e71151" - } - Frame { - msec: 224 - hash: "18e433c3e3ee64510f875f674791d51c" - } - Frame { - msec: 240 - hash: "56889122c1ddacdd8ebd88310c7410bc" - } - Frame { - msec: 256 - hash: "d51c85458e0109bd5bf9528b741d98d0" - } - Frame { - msec: 272 - hash: "ac54137afc29a3022c6f01df7cdf2fd6" - } - Frame { - msec: 288 - hash: "c7a42b389bae3b729ba9e6cba7f54530" - } - Frame { - msec: 304 - hash: "7583b55841e80891652c3472c658f989" - } - Frame { - msec: 320 - hash: "95a7f8d47c3788261427727f82c9ff59" - } - Frame { - msec: 336 - hash: "a87bad3e2f010680e16cd1e3f5e03e99" - } - Frame { - msec: 352 - hash: "e16bc51653f21819e0eec412b99a069f" - } - Frame { - msec: 368 - hash: "f1e869580ac148ae207141c5f0adc185" - } - Frame { - msec: 384 - hash: "7e496e44363a16d7c62e4258af9ce087" - } - Frame { - msec: 400 - hash: "19e97915c84d3554c66d5a9ad3aa6a3e" - } - Frame { - msec: 416 - hash: "181181b48a1085d1850f18ca9b163549" - } - Frame { - msec: 432 - hash: "4637cb04595a543867bd43b0c1c829ea" - } - Frame { - msec: 448 - hash: "bd0a074fed5507f8556de6110bf56aa4" - } - Frame { - msec: 464 - hash: "9547618923edac6f7f9a3ff324c4f2d8" - } - Frame { - msec: 480 - hash: "a2f90c88eacb7c66878d45e33c2a787d" - } - Frame { - msec: 496 - hash: "d5ffd3e35d0426887c106069310f84d8" - } - Frame { - msec: 512 - hash: "6bc50a5b76e2a2ef0e6bee762abeb330" - } - Frame { - msec: 528 - hash: "d4439933c842ed8432434d272fea2845" - } - Frame { - msec: 544 - hash: "61699e6ec476ac3f090e4f485430421d" - } - Frame { - msec: 560 - hash: "02d7fa9bcd697d2cab364d0a3ca4a0e2" - } - Frame { - msec: 576 - hash: "914178cbf1f6a6822cc40f81823475e4" - } - Frame { - msec: 592 - hash: "280f867ea27891ee764332998567d40d" - } - Frame { - msec: 608 - hash: "ea0d00fe54a172a89c24eac781f7ae6d" - } - Frame { - msec: 624 - hash: "4e910fb507964a710e26f318c62227bf" - } - Frame { - msec: 640 - hash: "b0c3392eb739f270dd21f552ad999c23" - } - Frame { - msec: 656 - hash: "f3698c83b0972bd66a53ad95d4fc301e" - } - Frame { - msec: 672 - hash: "0d303a0d6a9b626943ac93cc6f3fb230" - } - Frame { - msec: 688 - hash: "ba56d49e6f51aa6f1bd2a7500e3538fd" - } - Frame { - msec: 704 - hash: "273ce89d5194168e5bfd1dcefad49be2" - } - Frame { - msec: 720 - hash: "c2beef4fb7996dbccdaff4f54bdc33f1" - } - Frame { - msec: 736 - hash: "1e1aa7d84f27158a8e61bd8698ddbf2a" - } - Frame { - msec: 752 - hash: "24e82479802e710c673133ca0413be66" - } - Frame { - msec: 768 - hash: "b77e935a690bcb396e15b942d772cf1b" - } - Frame { - msec: 784 - hash: "7b729c74df1d15d6b0e8e1fc19c2d710" - } - Frame { - msec: 800 - hash: "fd6cbdca3e481baaf35022dfea76e74c" - } - Frame { - msec: 816 - hash: "c975f6eb592793aa81895ffcb74ca577" - } - Frame { - msec: 832 - hash: "677c4039a650df53b4e885f37b049ab3" - } - Frame { - msec: 848 - hash: "89563aae36552cb1749ec06567e46d9d" - } - Frame { - msec: 864 - hash: "01f57402874de6608cc02937aaf91794" - } - Frame { - msec: 880 - hash: "50c9c4e5eaaadee1ff230975390d34e3" - } - Frame { - msec: 896 - hash: "20b7d277d398afad59afdf9e6b41a57e" - } - Frame { - msec: 912 - hash: "8f9ea938a2375afeba419199de66dd52" - } - Frame { - msec: 928 - hash: "b96745888ba954bcf304c0840a030f93" - } - Frame { - msec: 944 - hash: "f5715e931274011123160f7ad10d6c52" - } - Frame { - msec: 960 - image: "nesting.0.png" - } - Frame { - msec: 976 - hash: "459fe967816c795a177a3926093fae75" - } - Frame { - msec: 992 - hash: "c599a26083068b6db628c8d8416bab60" - } - Frame { - msec: 1008 - hash: "e0aee7d1152c971b1beee9d36542acb7" - } - Frame { - msec: 1024 - hash: "2af0facdf6412f7b06979aae25e4db26" - } - Frame { - msec: 1040 - hash: "f147a92cb1826f95d4fdb7d011ba79b1" - } - Frame { - msec: 1056 - hash: "12a1cb894b0fb8e44152cccacf855c1a" - } - Frame { - msec: 1072 - hash: "c7500cf58b74fef2c3e9820d1de8f843" - } - Frame { - msec: 1088 - hash: "3a031b2206835f8b2dc9837016df6ae6" - } - Frame { - msec: 1104 - hash: "7a4796b419bbc04237764dea0b1d47d5" - } - Frame { - msec: 1120 - hash: "151d350f0064e2faf0bfb9c58bc3e4f2" - } - Frame { - msec: 1136 - hash: "d72c20a97e678908acc1d6c1f8114d9e" - } - Frame { - msec: 1152 - hash: "22da1e645640a3c31b064ff757113197" - } - Frame { - msec: 1168 - hash: "401f0bf370e2ecea5a84276fb72eb1da" - } - Frame { - msec: 1184 - hash: "c6e00d7b0ac14a5c3860b6a29901c915" - } - Frame { - msec: 1200 - hash: "f1f7dc55d7719fcb6e97157c0ca85fc0" - } - Frame { - msec: 1216 - hash: "6a112e1d79c7128c235d093e4f1f9325" - } - Frame { - msec: 1232 - hash: "14a2caf8cdca8d5147261a315059b69d" - } - Frame { - msec: 1248 - hash: "5645243aa3cfd12b0b32442f063bedb2" - } - Frame { - msec: 1264 - hash: "c7f72534a88e33c72a54cb8580534551" - } - Frame { - msec: 1280 - hash: "6cd5e2e8e0128586a682b3c649ae0631" - } - Frame { - msec: 1296 - hash: "67cefb4526b52d40a31811bc0dfaeb6a" - } - Frame { - msec: 1312 - hash: "fbe2a43a27bf490719c8b9e2b094e34f" - } - Frame { - msec: 1328 - hash: "e028aad6f51a47d8189efcf9c5d277ee" - } - Frame { - msec: 1344 - hash: "2b4cc50c37c07289fa6f9309991d36da" - } - Frame { - msec: 1360 - hash: "b67b2244cd0616d07e100d7b3b00bbe2" - } - Frame { - msec: 1376 - hash: "4e4690cffc98c49e91bdb600f1e94c79" - } - Frame { - msec: 1392 - hash: "e5215c727836a5547a170d42363bc5c8" - } - Frame { - msec: 1408 - hash: "26868e91d1794bb3f42d51f508fef613" - } - Frame { - msec: 1424 - hash: "1e5f431b125a66096ac9a4d5a211a2c4" - } -} diff --git a/tests/auto/declarative/qmlvisual/webview/embedding/egg.qml b/tests/auto/declarative/qmlvisual/webview/embedding/egg.qml deleted file mode 100644 index c569c9a..0000000 --- a/tests/auto/declarative/qmlvisual/webview/embedding/egg.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.7 - -Item { - property variant period : 250 - property variant color : "black" - id: root - - Item { - x: root.width/2 - y: root.height/2 - Rectangle { - radius: width/2 - color: root.color - x: -width/2 - y: -height/2 - width: root.width*1.5 - height: root.height*1.5 - } - rotation: NumberAnimation { - from: 0 - to: 360 - repeat: true - duration: root.period - } - } -} diff --git a/tests/auto/declarative/qmlvisual/webview/embedding/nesting.html b/tests/auto/declarative/qmlvisual/webview/embedding/nesting.html deleted file mode 100644 index 6e81689..0000000 --- a/tests/auto/declarative/qmlvisual/webview/embedding/nesting.html +++ /dev/null @@ -1,9 +0,0 @@ - -Nesting - - - -

      Nesting

      -This is a test... - -... with a spinning QML egg nested in it. diff --git a/tests/auto/declarative/qmlvisual/webview/embedding/nesting.qml b/tests/auto/declarative/qmlvisual/webview/embedding/nesting.qml deleted file mode 100644 index 9e008de..0000000 --- a/tests/auto/declarative/qmlvisual/webview/embedding/nesting.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt 4.7 -import org.webkit 1.0 - -WebView { - width: 300 - height: 200 - url: "nesting.html" - settings.pluginsEnabled: true -} -- cgit v0.12 From 761a32a67bb1d4702269ab998ffcf3772fd64d06 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 13 May 2010 23:08:38 +0200 Subject: Updated WebKit to 57d10d5c05e59bbf7de8189ff47dd18d1be996dc Disable the JIT on Symbian again, as it causes crashes. --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/JavaScriptCore/ChangeLog | 12 ------------ src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h | 3 --- src/3rdparty/webkit/VERSION | 2 +- 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index d8b4b32..14af7e9 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -57d10d5c05e59bbf7de8189ff47dd18d1be996dc +5cf023650a8da206a8cf3130e9d4820b95e1bc7c diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index 97176ef..1610036 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -21,18 +21,6 @@ * wtf/Platform.h: -2010-05-02 Laszlo Gombos - - Reviewed by Eric Seidel. - - [Qt] Enable JIT for QtWebKit on Symbian - https://bugs.webkit.org/show_bug.cgi?id=38339 - - JIT on Symbian has been stable for quite some time, it - is time to turn it on by default. - - * wtf/Platform.h: - 2010-04-28 Simon Hausmann , Kent Hansen Reviewed by Darin Adler. diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h index 8d98765..fac477e 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h @@ -937,8 +937,6 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ #define ENABLE_JIT 1 #elif CPU(ARM_TRADITIONAL) && OS(LINUX) #define ENABLE_JIT 1 -#elif CPU(ARM_TRADITIONAL) && OS(SYMBIAN) && COMPILER(RVCT) - #define ENABLE_JIT 1 #endif #endif /* PLATFORM(QT) */ @@ -1008,7 +1006,6 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ || (CPU(X86) && OS(LINUX) && GCC_VERSION >= 40100) \ || (CPU(X86_64) && OS(LINUX) && GCC_VERSION >= 40100) \ || (CPU(ARM_TRADITIONAL) && OS(LINUX)) \ - || (CPU(ARM_TRADITIONAL) && OS(SYMBIAN) && COMPILER(RVCT)) \ || (CPU(MIPS) && OS(LINUX)) \ || (CPU(X86) && OS(DARWIN)) \ || (CPU(X86_64) && OS(DARWIN)) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index c8c2aa3..b8bac54 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - dc5821c3df2ef60456d85263160852f5335cf946 + 57d10d5c05e59bbf7de8189ff47dd18d1be996dc -- cgit v0.12 From d64bd955c26af3b204df567245429ddd3f32bcb8 Mon Sep 17 00:00:00 2001 From: Iain Date: Thu, 13 May 2010 23:08:12 +0200 Subject: Update Symbian DEF files for WINSCW and EABI Reviewed-by: TrustMe --- src/s60installs/bwins/QtDeclarativeu.def | 38 +++++++++++++++++++++++--------- src/s60installs/bwins/QtGuiu.def | 3 +++ src/s60installs/bwins/QtOpenVGu.def | 3 ++- src/s60installs/eabi/QtDeclarativeu.def | 20 ++++++++--------- src/s60installs/eabi/QtGuiu.def | 3 +++ src/s60installs/eabi/QtOpenVGu.def | 2 +- 6 files changed, 47 insertions(+), 22 deletions(-) diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def index 18372a4..f43eadf 100644 --- a/src/s60installs/bwins/QtDeclarativeu.def +++ b/src/s60installs/bwins/QtDeclarativeu.def @@ -180,11 +180,11 @@ EXPORTS ??0QDeclarativeView@@QAE@ABVQUrl@@PAVQWidget@@@Z @ 179 NONAME ; QDeclarativeView::QDeclarativeView(class QUrl const &, class QWidget *) ??0QDeclarativeView@@QAE@PAVQWidget@@@Z @ 180 NONAME ; QDeclarativeView::QDeclarativeView(class QWidget *) ??0QDeclarativeViewSection@@QAE@PAVQObject@@@Z @ 181 NONAME ; QDeclarativeViewSection::QDeclarativeViewSection(class QObject *) - ??0QDeclarativeVisualDataModel@@QAE@PAVQDeclarativeContext@@@Z @ 182 NONAME ; QDeclarativeVisualDataModel::QDeclarativeVisualDataModel(class QDeclarativeContext *) + ??0QDeclarativeVisualDataModel@@QAE@PAVQDeclarativeContext@@@Z @ 182 NONAME ABSENT ; QDeclarativeVisualDataModel::QDeclarativeVisualDataModel(class QDeclarativeContext *) ??0QDeclarativeVisualDataModel@@QAE@XZ @ 183 NONAME ; QDeclarativeVisualDataModel::QDeclarativeVisualDataModel(void) - ??0QDeclarativeVisualItemModel@@QAE@XZ @ 184 NONAME ; QDeclarativeVisualItemModel::QDeclarativeVisualItemModel(void) + ??0QDeclarativeVisualItemModel@@QAE@XZ @ 184 NONAME ABSENT ; QDeclarativeVisualItemModel::QDeclarativeVisualItemModel(void) ??0QDeclarativeVisualModel@@IAE@AAVQObjectPrivate@@PAVQObject@@@Z @ 185 NONAME ; QDeclarativeVisualModel::QDeclarativeVisualModel(class QObjectPrivate &, class QObject *) - ??0QDeclarativeVisualModel@@QAE@XZ @ 186 NONAME ; QDeclarativeVisualModel::QDeclarativeVisualModel(void) + ??0QDeclarativeVisualModel@@QAE@XZ @ 186 NONAME ABSENT ; QDeclarativeVisualModel::QDeclarativeVisualModel(void) ??0QDeclarativeWebPage@@QAE@PAVQDeclarativeWebView@@@Z @ 187 NONAME ABSENT ; QDeclarativeWebPage::QDeclarativeWebPage(class QDeclarativeWebView *) ??0QDeclarativeWebView@@QAE@PAVQDeclarativeItem@@@Z @ 188 NONAME ABSENT ; QDeclarativeWebView::QDeclarativeWebView(class QDeclarativeItem *) ??0QDeclarativeXmlListModel@@QAE@PAVQObject@@@Z @ 189 NONAME ; QDeclarativeXmlListModel::QDeclarativeXmlListModel(class QObject *) @@ -1127,10 +1127,10 @@ EXPORTS ?flags@QMetaObjectBuilder@@QBE?AV?$QFlags@W4MetaObjectFlag@QMetaObjectBuilder@@@@XZ @ 1126 NONAME ; class QFlags QMetaObjectBuilder::flags(void) const ?flickDeceleration@QDeclarativeFlickable@@QBEMXZ @ 1127 NONAME ; float QDeclarativeFlickable::flickDeceleration(void) const ?flickDecelerationChanged@QDeclarativeFlickable@@IAEXXZ @ 1128 NONAME ; void QDeclarativeFlickable::flickDecelerationChanged(void) - ?flickDirection@QDeclarativeFlickable@@QBE?AW4FlickDirection@1@XZ @ 1129 NONAME ; enum QDeclarativeFlickable::FlickDirection QDeclarativeFlickable::flickDirection(void) const - ?flickDirectionChanged@QDeclarativeFlickable@@IAEXXZ @ 1130 NONAME ; void QDeclarativeFlickable::flickDirectionChanged(void) - ?flickEnded@QDeclarativeFlickable@@IAEXXZ @ 1131 NONAME ; void QDeclarativeFlickable::flickEnded(void) - ?flickStarted@QDeclarativeFlickable@@IAEXXZ @ 1132 NONAME ; void QDeclarativeFlickable::flickStarted(void) + ?flickDirection@QDeclarativeFlickable@@QBE?AW4FlickDirection@1@XZ @ 1129 NONAME ABSENT ; enum QDeclarativeFlickable::FlickDirection QDeclarativeFlickable::flickDirection(void) const + ?flickDirectionChanged@QDeclarativeFlickable@@IAEXXZ @ 1130 NONAME ABSENT ; void QDeclarativeFlickable::flickDirectionChanged(void) + ?flickEnded@QDeclarativeFlickable@@IAEXXZ @ 1131 NONAME ABSENT ; void QDeclarativeFlickable::flickEnded(void) + ?flickStarted@QDeclarativeFlickable@@IAEXXZ @ 1132 NONAME ABSENT ; void QDeclarativeFlickable::flickStarted(void) ?flickableChildren@QDeclarativeFlickable@@QAE?AU?$QDeclarativeListProperty@VQDeclarativeItem@@@@XZ @ 1133 NONAME ABSENT ; struct QDeclarativeListProperty QDeclarativeFlickable::flickableChildren(void) ?flickableData@QDeclarativeFlickable@@QAE?AU?$QDeclarativeListProperty@VQObject@@@@XZ @ 1134 NONAME ABSENT ; struct QDeclarativeListProperty QDeclarativeFlickable::flickableData(void) ?flickingChanged@QDeclarativeFlickable@@IAEXXZ @ 1135 NONAME ; void QDeclarativeFlickable::flickingChanged(void) @@ -1746,9 +1746,9 @@ EXPORTS ?moveCurrentIndexUp@QDeclarativeGridView@@QAEXXZ @ 1745 NONAME ; void QDeclarativeGridView::moveCurrentIndexUp(void) ?moveCursor@QDeclarativeTextInput@@AAEXXZ @ 1746 NONAME ; void QDeclarativeTextInput::moveCursor(void) ?moveCursorDelegate@QDeclarativeTextEdit@@AAEXXZ @ 1747 NONAME ; void QDeclarativeTextEdit::moveCursorDelegate(void) - ?movementEnded@QDeclarativeFlickable@@IAEXXZ @ 1748 NONAME ; void QDeclarativeFlickable::movementEnded(void) + ?movementEnded@QDeclarativeFlickable@@IAEXXZ @ 1748 NONAME ABSENT ; void QDeclarativeFlickable::movementEnded(void) ?movementEnding@QDeclarativeFlickable@@IAEXXZ @ 1749 NONAME ; void QDeclarativeFlickable::movementEnding(void) - ?movementStarted@QDeclarativeFlickable@@IAEXXZ @ 1750 NONAME ; void QDeclarativeFlickable::movementStarted(void) + ?movementStarted@QDeclarativeFlickable@@IAEXXZ @ 1750 NONAME ABSENT ; void QDeclarativeFlickable::movementStarted(void) ?movementStarting@QDeclarativeFlickable@@IAEXXZ @ 1751 NONAME ; void QDeclarativeFlickable::movementStarting(void) ?movieRequestFinished@QDeclarativeAnimatedImage@@AAEXXZ @ 1752 NONAME ; void QDeclarativeAnimatedImage::movieRequestFinished(void) ?movieUpdate@QDeclarativeAnimatedImage@@AAEXXZ @ 1753 NONAME ; void QDeclarativeAnimatedImage::movieUpdate(void) @@ -2416,7 +2416,7 @@ EXPORTS ?setFillMode@QDeclarativeImage@@QAEXW4FillMode@1@@Z @ 2415 NONAME ; void QDeclarativeImage::setFillMode(enum QDeclarativeImage::FillMode) ?setFlags@QMetaObjectBuilder@@QAEXV?$QFlags@W4MetaObjectFlag@QMetaObjectBuilder@@@@@Z @ 2416 NONAME ; void QMetaObjectBuilder::setFlags(class QFlags) ?setFlickDeceleration@QDeclarativeFlickable@@QAEXM@Z @ 2417 NONAME ; void QDeclarativeFlickable::setFlickDeceleration(float) - ?setFlickDirection@QDeclarativeFlickable@@QAEXW4FlickDirection@1@@Z @ 2418 NONAME ; void QDeclarativeFlickable::setFlickDirection(enum QDeclarativeFlickable::FlickDirection) + ?setFlickDirection@QDeclarativeFlickable@@QAEXW4FlickDirection@1@@Z @ 2418 NONAME ABSENT ; void QDeclarativeFlickable::setFlickDirection(enum QDeclarativeFlickable::FlickDirection) ?setFlow@QDeclarativeFlow@@QAEXW4Flow@1@@Z @ 2419 NONAME ; void QDeclarativeFlow::setFlow(enum QDeclarativeFlow::Flow) ?setFlow@QDeclarativeGridView@@QAEXW4Flow@1@@Z @ 2420 NONAME ; void QDeclarativeGridView::setFlow(enum QDeclarativeGridView::Flow) ?setFocus@QDeclarativeItem@@QAEX_N@Z @ 2421 NONAME ; void QDeclarativeItem::setFocus(bool) @@ -3994,4 +3994,22 @@ EXPORTS ?top@QDeclarativeItemPrivate@@QBE?AVQDeclarativeAnchorLine@@XZ @ 3993 NONAME ; class QDeclarativeAnchorLine QDeclarativeItemPrivate::top(void) const ?transitions@QDeclarativeItemPrivate@@QAE?AV?$QDeclarativeListProperty@VQDeclarativeTransition@@@@XZ @ 3994 NONAME ; class QDeclarativeListProperty QDeclarativeItemPrivate::transitions(void) ?verticalCenter@QDeclarativeItemPrivate@@QBE?AVQDeclarativeAnchorLine@@XZ @ 3995 NONAME ; class QDeclarativeAnchorLine QDeclarativeItemPrivate::verticalCenter(void) const + ?flickDirection@QDeclarativeFlickable@@QBE?AW4FlickableDirection@1@XZ @ 3996 NONAME ; enum QDeclarativeFlickable::FlickableDirection QDeclarativeFlickable::flickDirection(void) const + ?flickingHorizontallyChanged@QDeclarativeFlickable@@IAEXXZ @ 3997 NONAME ; void QDeclarativeFlickable::flickingHorizontallyChanged(void) + ?flickableDirection@QDeclarativeFlickable@@QBE?AW4FlickableDirection@1@XZ @ 3998 NONAME ; enum QDeclarativeFlickable::FlickableDirection QDeclarativeFlickable::flickableDirection(void) const + ?setFlickableDirection@QDeclarativeFlickable@@QAEXW4FlickableDirection@1@@Z @ 3999 NONAME ; void QDeclarativeFlickable::setFlickableDirection(enum QDeclarativeFlickable::FlickableDirection) + ?isMovingVertically@QDeclarativeFlickable@@QBE_NXZ @ 4000 NONAME ; bool QDeclarativeFlickable::isMovingVertically(void) const + ?movingHorizontallyChanged@QDeclarativeFlickable@@IAEXXZ @ 4001 NONAME ; void QDeclarativeFlickable::movingHorizontallyChanged(void) + ?d_func@QDeclarativeView@@AAEPAVQDeclarativeViewPrivate@@XZ @ 4002 NONAME ; class QDeclarativeViewPrivate * QDeclarativeView::d_func(void) + ?d_func@QDeclarativeView@@ABEPBVQDeclarativeViewPrivate@@XZ @ 4003 NONAME ; class QDeclarativeViewPrivate const * QDeclarativeView::d_func(void) const + ??0QDeclarativeVisualDataModel@@QAE@PAVQDeclarativeContext@@PAVQObject@@@Z @ 4004 NONAME ; QDeclarativeVisualDataModel::QDeclarativeVisualDataModel(class QDeclarativeContext *, class QObject *) + ?movingVerticallyChanged@QDeclarativeFlickable@@IAEXXZ @ 4005 NONAME ; void QDeclarativeFlickable::movingVerticallyChanged(void) + ?isFlickingHorizontally@QDeclarativeFlickable@@QBE_NXZ @ 4006 NONAME ; bool QDeclarativeFlickable::isFlickingHorizontally(void) const + ??0QDeclarativeVisualItemModel@@QAE@PAVQObject@@@Z @ 4007 NONAME ; QDeclarativeVisualItemModel::QDeclarativeVisualItemModel(class QObject *) + ?flickingVerticallyChanged@QDeclarativeFlickable@@IAEXXZ @ 4008 NONAME ; void QDeclarativeFlickable::flickingVerticallyChanged(void) + ?isMovingHorizontally@QDeclarativeFlickable@@QBE_NXZ @ 4009 NONAME ; bool QDeclarativeFlickable::isMovingHorizontally(void) const + ??0QDeclarativeVisualModel@@QAE@PAVQObject@@@Z @ 4010 NONAME ; QDeclarativeVisualModel::QDeclarativeVisualModel(class QObject *) + ?setFlickDirection@QDeclarativeFlickable@@QAEXW4FlickableDirection@1@@Z @ 4011 NONAME ; void QDeclarativeFlickable::setFlickDirection(enum QDeclarativeFlickable::FlickableDirection) + ?flickableDirectionChanged@QDeclarativeFlickable@@IAEXXZ @ 4012 NONAME ; void QDeclarativeFlickable::flickableDirectionChanged(void) + ?isFlickingVertically@QDeclarativeFlickable@@QBE_NXZ @ 4013 NONAME ; bool QDeclarativeFlickable::isFlickingVertically(void) const diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index e574c31..73dafee 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -12800,4 +12800,7 @@ EXPORTS ?iconName@QIconEngineV2@@QAE?AVQString@@XZ @ 12799 NONAME ; class QString QIconEngineV2::iconName(void) ?updateRectF@QGraphicsViewPrivate@@QAE_NABVQRectF@@@Z @ 12800 NONAME ; bool QGraphicsViewPrivate::updateRectF(class QRectF const &) ?updateRegion@QGraphicsViewPrivate@@QAE_NABVQRectF@@ABVQTransform@@@Z @ 12801 NONAME ; bool QGraphicsViewPrivate::updateRegion(class QRectF const &, class QTransform const &) + ?totalUsed@QPixmapCache@@SAHXZ @ 12802 NONAME ; int QPixmapCache::totalUsed(void) + ?allPixmaps@QPixmapCache@@SA?AV?$QList@U?$QPair@VQString@@VQPixmap@@@@@@XZ @ 12803 NONAME ; class QList > QPixmapCache::allPixmaps(void) + ?flushDetachedPixmaps@QPixmapCache@@SAXXZ @ 12804 NONAME ; void QPixmapCache::flushDetachedPixmaps(void) diff --git a/src/s60installs/bwins/QtOpenVGu.def b/src/s60installs/bwins/QtOpenVGu.def index 28b9e62..f398055 100644 --- a/src/s60installs/bwins/QtOpenVGu.def +++ b/src/s60installs/bwins/QtOpenVGu.def @@ -166,9 +166,10 @@ EXPORTS ?hibernate@QVGPixmapData@@UAEXXZ @ 165 NONAME ; void QVGPixmapData::hibernate(void) ?drawStaticTextItem@QVGPaintEngine@@UAEXPAVQStaticTextItem@@@Z @ 166 NONAME ; void QVGPaintEngine::drawStaticTextItem(class QStaticTextItem *) ?drawPixmapFragments@QVGPaintEngine@@UAEXPBVPixmapFragment@QPainter@@HABVQPixmap@@V?$QFlags@W4PixmapFragmentHint@QPainter@@@@@Z @ 167 NONAME ; void QVGPaintEngine::drawPixmapFragments(class QPainter::PixmapFragment const *, int, class QPixmap const &, class QFlags) - ?drawCachedGlyphs@QVGPaintEngine@@QAE_NHPBIABVQFont@@PAVQFontEngine@@ABVQPointF@@@Z @ 168 NONAME ; bool QVGPaintEngine::drawCachedGlyphs(int, unsigned int const *, class QFont const &, class QFontEngine *, class QPointF const &) + ?drawCachedGlyphs@QVGPaintEngine@@QAE_NHPBIABVQFont@@PAVQFontEngine@@ABVQPointF@@@Z @ 168 NONAME ABSENT ; bool QVGPaintEngine::drawCachedGlyphs(int, unsigned int const *, class QFont const &, class QFontEngine *, class QPointF const &) ?supportsStaticContents@QVGEGLWindowSurfaceDirect@@UBE_NXZ @ 169 NONAME ; bool QVGEGLWindowSurfaceDirect::supportsStaticContents(void) const ?scroll@QVGEGLWindowSurfacePrivate@@UAE_NPAVQWidget@@ABVQRegion@@HH@Z @ 170 NONAME ; bool QVGEGLWindowSurfacePrivate::scroll(class QWidget *, class QRegion const &, int, int) ?scroll@QVGEGLWindowSurfaceDirect@@UAE_NPAVQWidget@@ABVQRegion@@HH@Z @ 171 NONAME ; bool QVGEGLWindowSurfaceDirect::scroll(class QWidget *, class QRegion const &, int, int) ?supportsStaticContents@QVGEGLWindowSurfacePrivate@@UBE_NXZ @ 172 NONAME ; bool QVGEGLWindowSurfacePrivate::supportsStaticContents(void) const + ?drawCachedGlyphs@QVGPaintEngine@@QAE_NHPBIABVQFont@@PAVQFontEngine@@ABVQPointF@@PBUQFixedPoint@@@Z @ 173 NONAME ; bool QVGPaintEngine::drawCachedGlyphs(int, unsigned int const *, class QFont const &, class QFontEngine *, class QPointF const &, struct QFixedPoint const *) diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index e1d8e96..34f8b9e 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -1008,7 +1008,7 @@ EXPORTS _ZN21QDeclarativeDomObjectD1Ev @ 1007 NONAME _ZN21QDeclarativeDomObjectD2Ev @ 1008 NONAME _ZN21QDeclarativeDomObjectaSERKS_ @ 1009 NONAME - _ZN21QDeclarativeFlickable10flickEndedEv @ 1010 NONAME + _ZN21QDeclarativeFlickable10flickEndedEv @ 1010 NONAME ABSENT _ZN21QDeclarativeFlickable10timerEventEP11QTimerEvent @ 1011 NONAME _ZN21QDeclarativeFlickable10wheelEventEP24QGraphicsSceneWheelEvent @ 1012 NONAME _ZN21QDeclarativeFlickable11cancelFlickEv @ 1013 NONAME @@ -1018,10 +1018,10 @@ EXPORTS _ZN21QDeclarativeFlickable11setContentXEf @ 1017 NONAME _ZN21QDeclarativeFlickable11setContentYEf @ 1018 NONAME _ZN21QDeclarativeFlickable11visibleAreaEv @ 1019 NONAME - _ZN21QDeclarativeFlickable12flickStartedEv @ 1020 NONAME + _ZN21QDeclarativeFlickable12flickStartedEv @ 1020 NONAME ABSENT _ZN21QDeclarativeFlickable12setOverShootEb @ 1021 NONAME _ZN21QDeclarativeFlickable13flickableDataEv @ 1022 NONAME - _ZN21QDeclarativeFlickable13movementEndedEv @ 1023 NONAME + _ZN21QDeclarativeFlickable13movementEndedEv @ 1023 NONAME ABSENT _ZN21QDeclarativeFlickable13movingChangedEv @ 1024 NONAME _ZN21QDeclarativeFlickable13setPressDelayEi @ 1025 NONAME _ZN21QDeclarativeFlickable13viewportMovedEv @ 1026 NONAME @@ -1034,7 +1034,7 @@ EXPORTS _ZN21QDeclarativeFlickable15flickingChangedEv @ 1033 NONAME _ZN21QDeclarativeFlickable15geometryChangedERK6QRectFS2_ @ 1034 NONAME _ZN21QDeclarativeFlickable15mousePressEventEP24QGraphicsSceneMouseEvent @ 1035 NONAME - _ZN21QDeclarativeFlickable15movementStartedEv @ 1036 NONAME + _ZN21QDeclarativeFlickable15movementStartedEv @ 1036 NONAME ABSENT _ZN21QDeclarativeFlickable15setContentWidthEf @ 1037 NONAME _ZN21QDeclarativeFlickable16movementStartingEv @ 1038 NONAME _ZN21QDeclarativeFlickable16overShootChangedEv @ 1039 NONAME @@ -1044,14 +1044,14 @@ EXPORTS _ZN21QDeclarativeFlickable17flickableChildrenEv @ 1043 NONAME _ZN21QDeclarativeFlickable17mouseReleaseEventEP24QGraphicsSceneMouseEvent @ 1044 NONAME _ZN21QDeclarativeFlickable17pressDelayChangedEv @ 1045 NONAME - _ZN21QDeclarativeFlickable17setFlickDirectionENS_14FlickDirectionE @ 1046 NONAME + _ZN21QDeclarativeFlickable17setFlickDirectionENS_14FlickDirectionE @ 1046 NONAME ABSENT _ZN21QDeclarativeFlickable18interactiveChangedEv @ 1047 NONAME _ZN21QDeclarativeFlickable19contentWidthChangedEv @ 1048 NONAME _ZN21QDeclarativeFlickable19getStaticMetaObjectEv @ 1049 NONAME _ZN21QDeclarativeFlickable19isAtBoundaryChangedEv @ 1050 NONAME _ZN21QDeclarativeFlickable20contentHeightChangedEv @ 1051 NONAME _ZN21QDeclarativeFlickable20setFlickDecelerationEf @ 1052 NONAME - _ZN21QDeclarativeFlickable21flickDirectionChangedEv @ 1053 NONAME + _ZN21QDeclarativeFlickable21flickDirectionChangedEv @ 1053 NONAME ABSENT _ZN21QDeclarativeFlickable23setMaximumFlickVelocityEf @ 1054 NONAME _ZN21QDeclarativeFlickable23verticalVelocityChangedEv @ 1055 NONAME _ZN21QDeclarativeFlickable24flickDecelerationChangedEv @ 1056 NONAME @@ -1941,9 +1941,9 @@ EXPORTS _ZN27QDeclarativeVisualDataModel7setPartERK7QString @ 1940 NONAME _ZN27QDeclarativeVisualDataModel8evaluateEiRK7QStringP7QObject @ 1941 NONAME _ZN27QDeclarativeVisualDataModel8setModelERK8QVariant @ 1942 NONAME - _ZN27QDeclarativeVisualDataModelC1EP19QDeclarativeContext @ 1943 NONAME + _ZN27QDeclarativeVisualDataModelC1EP19QDeclarativeContext @ 1943 NONAME ABSENT _ZN27QDeclarativeVisualDataModelC1Ev @ 1944 NONAME - _ZN27QDeclarativeVisualDataModelC2EP19QDeclarativeContext @ 1945 NONAME + _ZN27QDeclarativeVisualDataModelC2EP19QDeclarativeContext @ 1945 NONAME ABSENT _ZN27QDeclarativeVisualDataModelC2Ev @ 1946 NONAME _ZN27QDeclarativeVisualDataModelD0Ev @ 1947 NONAME _ZN27QDeclarativeVisualDataModelD1Ev @ 1948 NONAME @@ -1960,8 +1960,8 @@ EXPORTS _ZN27QDeclarativeVisualItemModel7releaseEP16QDeclarativeItem @ 1959 NONAME _ZN27QDeclarativeVisualItemModel8childrenEv @ 1960 NONAME _ZN27QDeclarativeVisualItemModel8evaluateEiRK7QStringP7QObject @ 1961 NONAME - _ZN27QDeclarativeVisualItemModelC1Ev @ 1962 NONAME - _ZN27QDeclarativeVisualItemModelC2Ev @ 1963 NONAME + _ZN27QDeclarativeVisualItemModelC1Ev @ 1962 NONAME ABSENT + _ZN27QDeclarativeVisualItemModelC2Ev @ 1963 NONAME ABSENT _ZN28QDeclarativeCustomParserNodeC1ERKS_ @ 1964 NONAME _ZN28QDeclarativeCustomParserNodeC1Ev @ 1965 NONAME _ZN28QDeclarativeCustomParserNodeC2ERKS_ @ 1966 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 8987470..4f3200a 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -11999,4 +11999,7 @@ EXPORTS _ZNK14QWindowSurface23hasPartialUpdateSupportEv @ 11998 NONAME _ZNK5QIcon4nameEv @ 11999 NONAME _ZN20QGraphicsViewPrivate12updateRegionERK6QRectFRK10QTransform @ 12000 NONAME + _ZN12QPixmapCache10allPixmapsEv @ 12001 NONAME + _ZN12QPixmapCache20flushDetachedPixmapsEv @ 12002 NONAME + _ZN12QPixmapCache9totalUsedEv @ 12003 NONAME diff --git a/src/s60installs/eabi/QtOpenVGu.def b/src/s60installs/eabi/QtOpenVGu.def index 5db9dce..04f7876 100644 --- a/src/s60installs/eabi/QtOpenVGu.def +++ b/src/s60installs/eabi/QtOpenVGu.def @@ -196,7 +196,7 @@ EXPORTS _ZN13QVGPixmapData19detachImageFromPoolEv @ 195 NONAME _ZTI12QVGImagePool @ 196 NONAME _ZTV12QVGImagePool @ 197 NONAME - _ZN14QVGPaintEngine16drawCachedGlyphsEiPKjRK5QFontP11QFontEngineRK7QPointF @ 198 NONAME + _ZN14QVGPaintEngine16drawCachedGlyphsEiPKjRK5QFontP11QFontEngineRK7QPointF @ 198 NONAME ABSENT _ZN14QVGPaintEngine18drawStaticTextItemEP15QStaticTextItem @ 199 NONAME _ZN14QVGPaintEngine19drawPixmapFragmentsEPKN8QPainter14PixmapFragmentEiRK7QPixmap6QFlagsINS0_18PixmapFragmentHintEE @ 200 NONAME _ZN25QVGEGLWindowSurfaceDirect6scrollEP7QWidgetRK7QRegionii @ 201 NONAME -- cgit v0.12 From d7438b4761787ffdb6cee82ce0103d653d4cbd24 Mon Sep 17 00:00:00 2001 From: Peter Yard Date: Fri, 14 May 2010 10:13:57 +1000 Subject: Fixed documentation typo. --- doc/src/platforms/platform-notes.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/platforms/platform-notes.qdoc b/doc/src/platforms/platform-notes.qdoc index 8f5b6a5..16e0c0f 100644 --- a/doc/src/platforms/platform-notes.qdoc +++ b/doc/src/platforms/platform-notes.qdoc @@ -517,7 +517,7 @@ Note that some modules rely on other modules. If your application uses QtXmlPatterns, QtWebkit or QtScript it may still require \c NetworkServices - \o as these modules rely on QtNetwork to go online. + as these modules rely on QtNetwork to go online. For more information see the documentation of the individual Qt classes. If a class does not mention Symbian capabilities, it requires none. -- cgit v0.12 From dcc9a7e72fe4c283df59378d08d75aecfa3b3b05 Mon Sep 17 00:00:00 2001 From: Peter Yard Date: Fri, 14 May 2010 10:14:25 +1000 Subject: Added snippet labels to QML Dial example. --- examples/declarative/dial/content/Dial.qml | 6 ++++++ examples/declarative/dial/dial-example.qml | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/declarative/dial/content/Dial.qml b/examples/declarative/dial/content/Dial.qml index f9ab3e3..6f24801 100644 --- a/examples/declarative/dial/content/Dial.qml +++ b/examples/declarative/dial/content/Dial.qml @@ -8,6 +8,7 @@ Item { Image { source: "background.png" } +//! [needle_shadow] Image { x: 93 y: 35 @@ -17,6 +18,8 @@ Item { angle: needleRotation.angle } } +//! [needle_shadow] +//! [needle] Image { id: needle x: 95; y: 33 @@ -33,5 +36,8 @@ Item { } } } +//! [needle] +//! [overlay] Image { x: 21; y: 18; source: "overlay.png" } +//! [overlay] } diff --git a/examples/declarative/dial/dial-example.qml b/examples/declarative/dial/dial-example.qml index fd899a5..dd51435 100644 --- a/examples/declarative/dial/dial-example.qml +++ b/examples/declarative/dial/dial-example.qml @@ -1,6 +1,7 @@ import Qt 4.7 import "content" +//! [0] Rectangle { color: "#545454" width: 300; height: 300 @@ -14,7 +15,10 @@ Rectangle { Rectangle { id: container - anchors { bottom: parent.bottom; left: parent.left; right: parent.right; leftMargin: 20; rightMargin: 20; bottomMargin: 10 } + anchors { bottom: parent.bottom; left: parent.left + right: parent.right; leftMargin: 20; rightMargin: 20 + bottomMargin: 10 + } height: 16 radius: 8 @@ -37,8 +41,10 @@ Rectangle { MouseArea { anchors.fill: parent - drag.target: parent; drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: container.width - 32 + drag.target: parent; drag.axis: "XAxis"; drag.minimumX: 2 + drag.maximumX: container.width - 32 } } } } +//! [0] \ No newline at end of file -- cgit v0.12 From 8f800ea5611be333ae15f932dfea50bc80852c03 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 May 2010 10:01:07 +1000 Subject: Fix crash in ParentAnimation. When rolling-back a parent change, the actions are in reverse order. Task-number: QTBUG-10671 --- src/declarative/util/qdeclarativeanimation.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 0f7c946..195939f 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -2535,14 +2535,15 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, myAction.event = vpc; viaData->pc << vpc; viaData->actions << myAction; + int index = i; + bool invertedIndex = (direction == QDeclarativeAbstractAnimation::Forward) && action.reverseEvent; QDeclarativeAction dummyAction; - QDeclarativeAction &xAction = pc->xIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &yAction = pc->yIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &sAction = pc->scaleIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &rAction = pc->rotationIsSet() ? actions[++i] : dummyAction; - bool forward = (direction == QDeclarativeAbstractAnimation::Forward); + QDeclarativeAction &xAction = pc->xIsSet() ? actions[invertedIndex ? --index : ++i] : dummyAction; + QDeclarativeAction &yAction = pc->yIsSet() ? actions[invertedIndex ? --index : ++i] : dummyAction; + QDeclarativeAction &sAction = pc->scaleIsSet() ? actions[invertedIndex ? --index : ++i] : dummyAction; + QDeclarativeAction &rAction = pc->rotationIsSet() ? actions[invertedIndex ? --index : ++i] : dummyAction; QDeclarativeItem *target = pc->object(); - QDeclarativeItem *targetParent = forward ? pc->parent() : pc->originalParent(); + QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent(); //### this mirrors the logic in QDeclarativeParentChange. bool ok; @@ -2584,9 +2585,9 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, qreal w = target->width(); qreal h = target->height(); if (pc->widthIsSet()) - w = actions[++i].toValue.toReal(); + w = actions[invertedIndex ? --index : ++i].toValue.toReal(); if (pc->heightIsSet()) - h = actions[++i].toValue.toReal(); + h = actions[invertedIndex ? --index : ++i].toValue.toReal(); const QPointF &transformOrigin = d->computeTransformOrigin(target->transformOrigin(), w,h); qreal tempxt = transformOrigin.x(); -- cgit v0.12 From 169e7558fd731abdfceed00e5b2ca03c634e8d5d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 May 2010 10:06:40 +1000 Subject: Revert "Use raster graphicssystem for qml.app on OS X." This reverts commit d412a77d1e9a1c6810e10dfa4a0a35a81391cf29. --- tools/qml/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 003716e..116ca71 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -184,7 +184,7 @@ int main(int argc, char ** argv) atexit(showWarnings); #endif -#if defined (Q_WS_X11) || defined(Q_WS_MAC) +#if defined (Q_WS_X11) //### default to using raster graphics backend for now bool gsSpecified = false; for (int i = 0; i < argc; ++i) { -- cgit v0.12 From fe947b2050184f02c429962981397586d06f2893 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 14 May 2010 10:25:11 +1000 Subject: Remove qdbusserver from tests/auto/dbus.pro --- tests/auto/dbus.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/dbus.pro b/tests/auto/dbus.pro index 1c808df..e5f87e3 100644 --- a/tests/auto/dbus.pro +++ b/tests/auto/dbus.pro @@ -13,7 +13,6 @@ SUBDIRS=\ qdbuspendingreply \ qdbusperformance \ qdbusreply \ - qdbusserver \ qdbusservicewatcher \ qdbusthreading \ qdbusxmlparser \ -- cgit v0.12 From 1e395c0ab9676995419ae8b20e4d95ad3fe11f31 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Fri, 30 Apr 2010 15:11:11 +1000 Subject: Symbian build fix to declarative auto and benchmark tests Task-number: QTBUG-9491 Reviewed-by: Martin Jones --- tests/auto/declarative/declarative.pro | 11 +++++--- tests/auto/declarative/examples/examples.pro | 9 ++++++- .../auto/declarative/parserstress/parserstress.pro | 9 ++++++- .../declarative/parserstress/tst_parserstress.cpp | 6 ++++- .../qdeclarativeanchors/qdeclarativeanchors.pro | 9 ++++++- .../qdeclarativeanimatedimage.pro | 9 ++++++- .../qdeclarativeanimations.pro | 9 ++++++- .../qdeclarativebehaviors.pro | 9 ++++++- .../qdeclarativebinding/qdeclarativebinding.pro | 9 ++++++- .../qdeclarativeborderimage.pro | 9 ++++++- .../qdeclarativecomponent.pro | 6 ++++- .../qdeclarativeconnection.pro | 9 ++++++- .../qdeclarativecontext/qdeclarativecontext.pro | 6 ++++- .../qdeclarativedom/qdeclarativedom.pro | 9 ++++++- .../qdeclarativeengine/qdeclarativeengine.pro | 6 ++++- .../qdeclarativeerror/qdeclarativeerror.pro | 6 ++++- .../qdeclarativeflickable.pro | 9 ++++++- .../qdeclarativeflipable/qdeclarativeflipable.pro | 9 ++++++- .../qdeclarativefocusscope.pro | 9 ++++++- .../qdeclarativefontloader.pro | 9 ++++++- .../qdeclarativegridview/qdeclarativegridview.pro | 9 ++++++- .../qdeclarativeimage/qdeclarativeimage.pro | 9 ++++++- .../qdeclarativeimageprovider.pro | 9 ++++++- .../qdeclarativeinfo/qdeclarativeinfo.pro | 9 ++++++- .../qdeclarativeinstruction.pro | 6 ++++- .../qdeclarativeitem/qdeclarativeitem.pro | 9 ++++++- .../qdeclarativelanguage/qdeclarativelanguage.pro | 9 ++++++- .../qdeclarativelayoutitem.pro | 9 ++++++- .../qdeclarativelistmodel.pro | 9 ++++++- .../qdeclarativelistview/qdeclarativelistview.pro | 9 ++++++- .../qdeclarativeloader/qdeclarativeloader.pro | 9 ++++++- .../qdeclarativemetatype/qdeclarativemetatype.pro | 6 ++++- .../qdeclarativemoduleplugin/plugin/plugin.pro | 3 +++ .../tst_qdeclarativemoduleplugin.pro | 9 ++++++- .../qdeclarativemousearea.pro | 9 ++++++- .../qdeclarativeparticles.pro | 9 ++++++- .../qdeclarativepathview/qdeclarativepathview.pro | 9 ++++++- .../qdeclarativepixmapcache.pro | 9 ++++++- .../qdeclarativepositioners.pro | 9 ++++++- .../qdeclarativeproperty/qdeclarativeproperty.pro | 9 ++++++- .../declarative/qdeclarativeqt/qdeclarativeqt.pro | 9 ++++++- .../qdeclarativerepeater/qdeclarativerepeater.pro | 9 ++++++- .../qdeclarativesmoothedanimation.pro | 9 ++++++- .../qdeclarativesmoothedfollow.pro | 9 ++++++- .../qdeclarativespringfollow.pro | 9 ++++++- .../qdeclarativesqldatabase.pro | 9 ++++++- .../qdeclarativestates/qdeclarativestates.pro | 9 ++++++- .../qdeclarativesystempalette.pro | 7 +++++ .../qdeclarativetext/qdeclarativetext.pro | 9 ++++++- .../qdeclarativetextedit/qdeclarativetextedit.pro | 9 ++++++- .../qdeclarativetextinput.pro | 9 ++++++- .../qdeclarativetimer/qdeclarativetimer.pro | 6 ++++- .../qdeclarativevaluetypes.pro | 9 ++++++- .../qdeclarativeview/qdeclarativeview.pro | 9 ++++++- .../qdeclarativeviewer/qdeclarativeviewer.pro | 9 ++++++- .../qdeclarativevisualdatamodel.pro | 10 +++++-- .../qdeclarativewebview/qdeclarativewebview.pro | 9 ++++++- .../qdeclarativeworkerscript.pro | 9 ++++++- .../qdeclarativexmlhttprequest.pro | 10 +++++-- .../qdeclarativexmllistmodel.pro | 9 ++++++- tests/auto/declarative/qmlvisual/qmlvisual.pro | 31 ++++++++++++++++++++-- tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp | 2 +- .../qpacketprotocol/tst_qpacketprotocol.cpp | 2 +- tests/benchmarks/declarative/binding/binding.pro | 14 +++++----- tests/benchmarks/declarative/creation/creation.pro | 11 ++++---- .../declarative/creation/tst_creation.cpp | 6 ----- tests/benchmarks/declarative/declarative.pro | 5 +++- .../qdeclarativecomponent.pro | 18 +++++-------- .../qdeclarativeimage/qdeclarativeimage.pro | 10 ++++--- .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 6 ----- .../qdeclarativemetaproperty.pro | 9 ++++++- tests/benchmarks/declarative/script/script.pro | 9 ++++--- tests/benchmarks/declarative/script/tst_script.cpp | 6 ----- tools/qml/qml.pri | 6 +++++ tools/qml/qml.pro | 2 -- 75 files changed, 529 insertions(+), 120 deletions(-) diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 3496906..4bb3518 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -1,6 +1,12 @@ TEMPLATE = subdirs +!symbian: { SUBDIRS += \ examples \ + qdeclarativemetatype \ + qmetaobjectbuilder +} + +SUBDIRS += \ parserstress \ qdeclarativeanchors \ qdeclarativeanimatedimage \ @@ -34,7 +40,6 @@ SUBDIRS += \ qdeclarativelistreference \ qdeclarativelistview \ qdeclarativeloader \ - qdeclarativemetatype \ qdeclarativemoduleplugin \ qdeclarativemousearea \ qdeclarativeparticles \ @@ -64,8 +69,7 @@ SUBDIRS += \ qdeclarativexmlhttprequest \ qdeclarativexmllistmodel \ qmlvisual \ - qpacketprotocol \ - qmetaobjectbuilder + qpacketprotocol contains(QT_CONFIG, webkit) { SUBDIRS += \ @@ -74,4 +78,3 @@ contains(QT_CONFIG, webkit) { # Tests which should run in Pulse PULSE_TESTS = $$SUBDIRS - diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index 4c32524..92a16f1 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -6,7 +6,14 @@ SOURCES += tst_examples.cpp include(../../../../tools/qml/qml.pri) -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/parserstress/parserstress.pro b/tests/auto/declarative/parserstress/parserstress.pro index 8830511..a95a855 100644 --- a/tests/auto/declarative/parserstress/parserstress.pro +++ b/tests/auto/declarative/parserstress/parserstress.pro @@ -4,7 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_parserstress.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = ..\..\qscriptjstestsuite\tests + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp index 294f2f7..c86908b 100644 --- a/tests/auto/declarative/parserstress/tst_parserstress.cpp +++ b/tests/auto/declarative/parserstress/tst_parserstress.cpp @@ -86,12 +86,15 @@ QStringList tst_parserstress::findJSFiles(const QDir &d) void tst_parserstress::ecmascript_data() { +#ifdef Q_OS_SYMBIAN + QDir dir("tests"); +#else QDir dir(SRCDIR); dir.cdUp(); dir.cdUp(); dir.cd("qscriptjstestsuite"); dir.cd("tests"); - +#endif QStringList files = findJSFiles(dir); QTest::addColumn("file"); @@ -129,6 +132,7 @@ void tst_parserstress::ecmascript() QByteArray qmlData = qml.toUtf8(); QDeclarativeComponent component(&engine); + component.setData(qmlData, QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml"))); QFileInfo info(file); diff --git a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro index a2403f2..452ad55 100644 --- a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro +++ b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro @@ -3,7 +3,14 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativeanchors.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro index 74f9be0..7213abd 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro +++ b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro @@ -4,7 +4,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeanimatedimage.cpp ../shared/testhttpserver.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro index ce38eeb..f7ed371 100644 --- a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro +++ b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro @@ -3,7 +3,14 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativeanimations.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro index c2781b8..7137af1 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro +++ b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro @@ -3,7 +3,14 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativebehaviors.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro index 04dd6f5..04535db 100644 --- a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro +++ b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativebinding.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro index e754923..3aa2197 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro +++ b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro @@ -6,7 +6,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeborderimage.cpp ../shared/testhttpserver.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro index e58c798..98c38ad 100644 --- a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro +++ b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro @@ -5,7 +5,11 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativecomponent.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro index 959354d..bbf8630 100644 --- a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro +++ b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeconnection.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro index 5db9a9e..0e1a5b1 100644 --- a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro +++ b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro @@ -3,7 +3,11 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativecontext.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro index 466c563..9f1e50c 100644 --- a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro +++ b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro @@ -4,7 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativedom.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro index e0ea2e5..23afd07 100644 --- a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro +++ b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro @@ -5,7 +5,11 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeengine.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro index 501f32c..fae11f9 100644 --- a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro +++ b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro @@ -3,7 +3,11 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativeerror.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro index 07637c9..7a70109 100644 --- a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro +++ b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeflickable.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro index 9830b55..9b4fbc9 100644 --- a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro +++ b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeflipable.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro index 687c80c..c021fcf 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro +++ b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro @@ -3,5 +3,12 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativefocusscope.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro index 9a8a3ff..dbe0dcb 100644 --- a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro +++ b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro @@ -6,7 +6,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativefontloader.cpp ../shared/testhttpserver.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro index b069260..033e20e 100644 --- a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro +++ b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativegridview.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro index ff365ee..a8b8eca 100644 --- a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro +++ b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro @@ -6,7 +6,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeimage.cpp ../shared/testhttpserver.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro index 22be991..1b828a5 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro +++ b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro @@ -9,7 +9,14 @@ SOURCES += tst_qdeclarativeimageprovider.cpp # LIBS += -lgcov # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro index bb54d6c..c6719c0 100644 --- a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro +++ b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro @@ -4,7 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeinfo.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro index 0daa9e5..350f6c6 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro +++ b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro @@ -3,7 +3,11 @@ contains(QT_CONFIG,declarative): QT += declarative script SOURCES += tst_qdeclarativeinstruction.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro index e834a4e..f494ef1 100644 --- a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro +++ b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro @@ -4,7 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeitem.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro index 5771469..2b7eb1c 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro +++ b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro @@ -11,6 +11,13 @@ INCLUDEPATH += ../shared/ HEADERS += ../shared/testhttpserver.h SOURCES += ../shared/testhttpserver.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\"\"\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro index eeb784d..79954fe 100644 --- a/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro +++ b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro @@ -5,4 +5,11 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativelayoutitem.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} \ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro index 9f1e146..53bb9ec 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro +++ b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro @@ -6,7 +6,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativelistmodel.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro index 5d962c0..b406fde 100644 --- a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro +++ b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro @@ -5,6 +5,13 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativelistview.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro index 96fea5b..9334928 100644 --- a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro +++ b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro @@ -7,7 +7,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeloader.cpp \ ../shared/testhttpserver.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro index cf3fa65..0d32ab8 100644 --- a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro +++ b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro @@ -3,7 +3,11 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativemetatype.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro index fc77225..173a302 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro +++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro @@ -4,3 +4,6 @@ SOURCES = plugin.cpp QT = core declarative DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType +symbian: { + TARGET.EPOCALLOWDLLDATA=1 +} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro index d895ed0..29a1009 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro @@ -2,4 +2,11 @@ load(qttest_p4) SOURCES = tst_qdeclarativemoduleplugin.cpp QT += declarative CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro index 48fe025..6f9c98c 100644 --- a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro +++ b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro @@ -6,7 +6,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativemousearea.cpp ../shared/testhttpserver.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro index 8a061c3..31172a9 100644 --- a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro +++ b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeparticles.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro index 3c327d5..6bef61c 100644 --- a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro +++ b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativepathview.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro index 4b247fc..99a94bc 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro +++ b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro @@ -9,7 +9,14 @@ INCLUDEPATH += ../shared/ HEADERS += ../shared/testhttpserver.h SOURCES += ../shared/testhttpserver.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov diff --git a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro index dbe2cbee..2c5b473 100644 --- a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro +++ b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro @@ -4,7 +4,14 @@ SOURCES += tst_qdeclarativepositioners.cpp macx:CONFIG -= app_bundle # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro index 6910ccc..f37d952 100644 --- a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro +++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro @@ -4,7 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeproperty.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro index 10e10a3..b381a9b 100644 --- a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro +++ b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro @@ -3,7 +3,14 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativeqt.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov diff --git a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro index abd36e0..51667af 100644 --- a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro +++ b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro @@ -5,6 +5,13 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativerepeater.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro index 80b757d..6b98f1e 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesmoothedanimation.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro b/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro index 7f737c2..eb7d793 100644 --- a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro +++ b/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesmoothedfollow.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro index 6f400a3..6ed8924 100644 --- a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro +++ b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativespringfollow.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro b/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro index 3ff4529..9cdb884 100644 --- a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro +++ b/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro @@ -6,7 +6,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesqldatabase.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro index 706d045..6f4ecb3 100644 --- a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro +++ b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro @@ -5,6 +5,13 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativestates.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro index b2705fa..786bc1b 100644 --- a/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro +++ b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro @@ -4,5 +4,12 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesystempalette.cpp +# Define SRCDIR equal to test's source directory +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro index e70443e..51c7f43 100644 --- a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro +++ b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro @@ -9,7 +9,14 @@ INCLUDEPATH += ../shared/ HEADERS += ../shared/testhttpserver.h SOURCES += ../shared/testhttpserver.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro index 2228f11..2adb2b8 100644 --- a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro +++ b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro @@ -6,4 +6,11 @@ SOURCES += tst_qdeclarativetextedit.cpp ../shared/testhttpserver.cpp HEADERS += ../shared/testhttpserver.h # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro index 957e75c..2953567 100644 --- a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro +++ b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro @@ -5,5 +5,12 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetextinput.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro index 42604d8..d95165c 100644 --- a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro +++ b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro @@ -4,6 +4,10 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetimer.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro index d9f1c13..02c480c 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro +++ b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro @@ -7,7 +7,14 @@ HEADERS += testtypes.h SOURCES += tst_qdeclarativevaluetypes.cpp \ testtypes.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro b/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro index d6be728..ad54713 100644 --- a/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro +++ b/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro @@ -4,4 +4,11 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeview.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro index dc10f5b..9bb6161 100644 --- a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro +++ b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro @@ -6,6 +6,13 @@ include(../../../../tools/qml/qml.pri) SOURCES += tst_qdeclarativeviewer.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro b/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro index d76b582..c87171b 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro @@ -4,8 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativevisualdatamodel.cpp -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro index 956272f..8caa393 100644 --- a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro +++ b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro @@ -6,6 +6,13 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativewebview.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro index 2e3da4d..36b3449 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro +++ b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeworkerscript.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro index 160300e..b54f670 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro @@ -8,9 +8,15 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativexmlhttprequest.cpp \ ../shared/testhttpserver.cpp - # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro index 8c5052a..1bf1c58 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro +++ b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro @@ -8,7 +8,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativexmllistmodel.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qmlvisual/qmlvisual.pro b/tests/auto/declarative/qmlvisual/qmlvisual.pro index a3abbe3..dca9b04 100644 --- a/tests/auto/declarative/qmlvisual/qmlvisual.pro +++ b/tests/auto/declarative/qmlvisual/qmlvisual.pro @@ -4,7 +4,34 @@ macx:CONFIG -= app_bundle SOURCES += tst_qmlvisual.cpp -DEFINES += QT_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" +symbian: { + importFiles.path = + importFiles.sources = animation \ + fillmode \ + focusscope \ + ListView \ + qdeclarativeborderimage \ + qdeclarativeflickable \ + qdeclarativeflipable \ + qdeclarativegridview \ + qdeclarativemousearea \ + qdeclarativeparticles \ + qdeclarativepathview \ + qdeclarativepositioners \ + qdeclarativesmoothedanimation \ + qdeclarativespringfollow \ + qdeclarativetext \ + qdeclarativetextedit \ + qdeclarativetextinput \ + rect \ + repeater \ + selftest_noimages \ + webview + DEPLOYMENT = importFiles + + DEFINES += QT_TEST_SOURCE_DIR=\".\" +} else { + DEFINES += QT_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" +} CONFIG += parallel_test - diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp index 0f33a07..4aad29b 100644 --- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp +++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp @@ -82,7 +82,7 @@ QString tst_qmlvisual::viewer() #if defined(Q_WS_MAC) qmlruntime = QDir(binaries).absoluteFilePath("qml.app/Contents/MacOS/qml"); -#elif defined(Q_WS_WIN) +#elif defined(Q_WS_WIN) || defined(Q_WS_S60) qmlruntime = QDir(binaries).absoluteFilePath("qml.exe"); #else qmlruntime = QDir(binaries).absoluteFilePath("qml"); diff --git a/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp index b8e317e..7d34698 100644 --- a/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp +++ b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp @@ -225,7 +225,7 @@ void tst_QPacketProtocol::read() void tst_QPacketProtocol::device() { QPacketProtocol p(m_client); - QCOMPARE(p.device(), m_client); + QVERIFY(p.device() == m_client); } void tst_QPacketProtocol::tst_QPacket_clear() diff --git a/tests/benchmarks/declarative/binding/binding.pro b/tests/benchmarks/declarative/binding/binding.pro index 5ceaf34..268541f 100644 --- a/tests/benchmarks/declarative/binding/binding.pro +++ b/tests/benchmarks/declarative/binding/binding.pro @@ -8,11 +8,11 @@ SOURCES += tst_binding.cpp testtypes.cpp HEADERS += testtypes.h # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" - -symbian* { - data.sources = data/* - data.path = data - DEPLOYMENT = data +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" } - diff --git a/tests/benchmarks/declarative/creation/creation.pro b/tests/benchmarks/declarative/creation/creation.pro index 3e0caf6..08ad772 100644 --- a/tests/benchmarks/declarative/creation/creation.pro +++ b/tests/benchmarks/declarative/creation/creation.pro @@ -6,10 +6,11 @@ macx:CONFIG -= app_bundle SOURCES += tst_creation.cpp -symbian* { - data.sources = data/* - data.path = data - DEPLOYMENT += addFiles +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" -} \ No newline at end of file +} diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 99324f4..6e9197b 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -50,12 +50,6 @@ #include #include -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -// Application private dir is default serach path for files, so SRCDIR can be set to empty -#define SRCDIR "" -#endif - class tst_creation : public QObject { Q_OBJECT diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro index a7d426c..262247a 100644 --- a/tests/benchmarks/declarative/declarative.pro +++ b/tests/benchmarks/declarative/declarative.pro @@ -1,8 +1,11 @@ TEMPLATE = subdirs +!symbian: { + SUBDIRS += painting +} + SUBDIRS += \ binding \ creation \ - painting \ pointers \ qdeclarativecomponent \ qdeclarativeimage \ diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro index 30ef235..670e425 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro +++ b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro @@ -8,15 +8,11 @@ SOURCES += tst_qdeclarativecomponent.cpp testtypes.cpp HEADERS += testtypes.h # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" - -symbian* { - data.sources = data/* - data.path = data - samegame.sources = data/samegame/* - samegame.path = data/samegame - samegame_pics.sources = data/samegame/pics/* - samegame_pics.path = data/samegame/pics - DEPLOYMENT += data samegame samegame_pics +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" } - diff --git a/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro index bbe4e8d..fb5779a 100644 --- a/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro +++ b/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro @@ -7,10 +7,12 @@ CONFIG += release SOURCES += tst_qdeclarativeimage.cpp -symbian* { - data.sources = image.png - data.path = . - DEPLOYMENT += data +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = image.png + importFiles.path = + DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } + diff --git a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index e2e8c8a..e979f20 100644 --- a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -44,12 +44,6 @@ #include #include -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -// Application private dir is default serach path for files, so SRCDIR can be set to empty -#define SRCDIR "" -#endif - class tst_qmlgraphicsimage : public QObject { Q_OBJECT diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro index 79fdd26..55dfafe 100644 --- a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro +++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro @@ -7,4 +7,11 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativemetaproperty.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/benchmarks/declarative/script/script.pro b/tests/benchmarks/declarative/script/script.pro index 6255acc..91db871 100644 --- a/tests/benchmarks/declarative/script/script.pro +++ b/tests/benchmarks/declarative/script/script.pro @@ -7,10 +7,11 @@ CONFIG += release SOURCES += tst_script.cpp -symbian* { - data.sources = data/* - data.path = data - DEPLOYMENT += data +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp index 8ea6dcd..6dc7ed6 100644 --- a/tests/benchmarks/declarative/script/tst_script.cpp +++ b/tests/benchmarks/declarative/script/tst_script.cpp @@ -48,12 +48,6 @@ #include #include -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -// Application private dir is default serach path for files, so SRCDIR can be set to empty -#define SRCDIR "." -#endif - class tst_script : public QObject { Q_OBJECT diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index d343c76..3c86d31 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -24,6 +24,12 @@ maemo5 { } else { SOURCES += $$PWD/deviceorientation.cpp } + +symbian { + INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ + LIBS += -lesock -lcommdb -lconnmon -linsock +} + FORMS = $$PWD/recopts.ui \ $$PWD/proxysettings.ui diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index b33d48b..77a9533 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -32,9 +32,7 @@ wince* { symbian { TARGET.UID3 = 0x20021317 include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 - LIBS += -lesock -lcommdb -lconnmon -linsock TARGET.CAPABILITY = NetworkServices ReadUserData } mac { -- cgit v0.12 From dc2e494acbd0a8e371c9fd92aef2da6975c5cccb Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 14 May 2010 10:52:36 +1000 Subject: Fixed race condition compiling xmlpatterns tests. tests/auto/xmlpatterns.pro was missing some dependency information. --- tests/auto/xmlpatterns.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/xmlpatterns.pro b/tests/auto/xmlpatterns.pro index f670266..c770934 100644 --- a/tests/auto/xmlpatterns.pro +++ b/tests/auto/xmlpatterns.pro @@ -36,6 +36,7 @@ SUBDIRS=\ xmlpatternsdiagnosticsts.depends = xmlpatternssdk xmlpatternsview.depends = xmlpatternssdk xmlpatternsxslts.depends = xmlpatternssdk +xmlpatternsxqts.depends = xmlpatternssdk xmlpatternsschemats.depends = xmlpatternssdk !contains(QT_CONFIG, private_tests): SUBDIRS -= \ -- cgit v0.12 From 376ca20965e7546f0d25218858583ccde872f2fb Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 May 2010 12:16:54 +1000 Subject: Revert "Fix crash in ParentAnimation." This reverts commit 8f800ea5611be333ae15f932dfea50bc80852c03. --- src/declarative/util/qdeclarativeanimation.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 195939f..0f7c946 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -2535,15 +2535,14 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, myAction.event = vpc; viaData->pc << vpc; viaData->actions << myAction; - int index = i; - bool invertedIndex = (direction == QDeclarativeAbstractAnimation::Forward) && action.reverseEvent; QDeclarativeAction dummyAction; - QDeclarativeAction &xAction = pc->xIsSet() ? actions[invertedIndex ? --index : ++i] : dummyAction; - QDeclarativeAction &yAction = pc->yIsSet() ? actions[invertedIndex ? --index : ++i] : dummyAction; - QDeclarativeAction &sAction = pc->scaleIsSet() ? actions[invertedIndex ? --index : ++i] : dummyAction; - QDeclarativeAction &rAction = pc->rotationIsSet() ? actions[invertedIndex ? --index : ++i] : dummyAction; + QDeclarativeAction &xAction = pc->xIsSet() ? actions[++i] : dummyAction; + QDeclarativeAction &yAction = pc->yIsSet() ? actions[++i] : dummyAction; + QDeclarativeAction &sAction = pc->scaleIsSet() ? actions[++i] : dummyAction; + QDeclarativeAction &rAction = pc->rotationIsSet() ? actions[++i] : dummyAction; + bool forward = (direction == QDeclarativeAbstractAnimation::Forward); QDeclarativeItem *target = pc->object(); - QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent(); + QDeclarativeItem *targetParent = forward ? pc->parent() : pc->originalParent(); //### this mirrors the logic in QDeclarativeParentChange. bool ok; @@ -2585,9 +2584,9 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, qreal w = target->width(); qreal h = target->height(); if (pc->widthIsSet()) - w = actions[invertedIndex ? --index : ++i].toValue.toReal(); + w = actions[++i].toValue.toReal(); if (pc->heightIsSet()) - h = actions[invertedIndex ? --index : ++i].toValue.toReal(); + h = actions[++i].toValue.toReal(); const QPointF &transformOrigin = d->computeTransformOrigin(target->transformOrigin(), w,h); qreal tempxt = transformOrigin.x(); -- cgit v0.12 From 08b6114240a6c02dbeb0297d0deeb538ebc3fde9 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 13 May 2010 10:16:48 +1000 Subject: Cherry pick fix for MOBILITY-828 from Qt Mobility. Change e5f8e3069d0de428a751e8a1dd88f3585f2d3f5f from Qt Mobility. --- .../bearer/symbian/qnetworksession_impl.cpp | 369 ++++++++++++--------- src/plugins/bearer/symbian/qnetworksession_impl.h | 15 +- src/plugins/bearer/symbian/symbianengine.cpp | 248 +++++++++----- src/plugins/bearer/symbian/symbianengine.h | 27 +- tests/auto/qnetworksession/lackey/main.cpp | 24 +- .../qnetworksession/test/tst_qnetworksession.cpp | 361 ++++++++++++-------- 6 files changed, 658 insertions(+), 386 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 1b9c8cc..04853c4 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -53,15 +53,17 @@ QT_BEGIN_NAMESPACE QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) - : CActive(CActive::EPriorityStandard), engine(engine), ipConnectionNotifier(0), - iError(QNetworkSession::UnknownSessionError), - iALREnabled(0), iConnectInBackground(false) + : CActive(CActive::EPriorityStandard), engine(engine), + ipConnectionNotifier(0), iHandleStateNotificationsFromManager(false), + iFirstSync(true), iStoppedByUser(false), iClosedByUser(false), iDeprecatedConnectionId(0), + iError(QNetworkSession::UnknownSessionError), iALREnabled(0), iConnectInBackground(false) { CActiveScheduler::Add(this); #ifdef SNAP_FUNCTIONALITY_AVAILABLE iMobility = NULL; #endif + TRAP_IGNORE(iConnectionMonitor.ConnectL()); } @@ -90,18 +92,72 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() // Close global 'Open C' RConnection setdefaultif(0); - - iConnectionMonitor.CancelNotifications(); + iConnectionMonitor.Close(); } +void QNetworkSessionPrivateImpl::configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState) +{ + if (iHandleStateNotificationsFromManager) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "configurationStateChanged from manager for IAP : " << QString::number(accessPointId) + << "configurationStateChanged connMon ID : " << QString::number(connMonId) + << " : to a state: " << newState + << " whereas my current state is: " << state; +#endif + if (connMonId == iDeprecatedConnectionId) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "however status update from manager ignored because it related to already closed connection."; +#endif + return; + } + this->newState(newState, accessPointId); + } +} + +void QNetworkSessionPrivateImpl::configurationRemoved(QNetworkConfigurationPrivatePointer config) +{ + if (!publicConfig.isValid()) + return; + + SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(config); + + symbianConfig->mutex.lock(); + TUint32 configNumericId = symbianConfig->numericId; + symbianConfig->mutex.unlock(); + + symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); + + symbianConfig->mutex.lock(); + TUint32 publicNumericId = symbianConfig->numericId; + symbianConfig->mutex.unlock(); + + if (configNumericId == publicNumericId) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "configurationRemoved IAP: " << QString::number(publicNumericId) << " : going to State: Invalid"; +#endif + this->newState(QNetworkSession::Invalid, publicNumericId); + } +} + void QNetworkSessionPrivateImpl::syncStateWithInterface() { if (!publicConfig.isValid()) return; - // Start monitoring changes in IAP states - TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); + if (iFirstSync && publicConfig.isValid()) { + QObject::connect(engine, SIGNAL(configurationStateChanged(TUint32, TUint32, QNetworkSession::State)), + this, SLOT(configurationStateChanged(TUint32, TUint32, QNetworkSession::State))); + // Listen to configuration removals, so that in case the configuration + // this session is based on is removed, session knows to enter Invalid -state. + QObject::connect(engine, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); + } + // Start listening IAP state changes from QNetworkConfigurationManagerPrivate + iHandleStateNotificationsFromManager = true; // Check open connections to see if there is already // an open connection to selected IAP or SNAP @@ -137,11 +193,8 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface() } if (state != QNetworkSession::Connected) { - // There were no open connections to used IAP or SNAP - if (iError == QNetworkSession::InvalidConfigurationError) { - newState(QNetworkSession::Invalid); - } else if ((publicConfig.state() & QNetworkConfiguration::Discovered) == - QNetworkConfiguration::Discovered) { + if ((publicConfig.state() & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { newState(QNetworkSession::Disconnected); } else { newState(QNetworkSession::NotAvailable); @@ -245,13 +298,18 @@ QNetworkSession::SessionError QNetworkSessionPrivateImpl::error() const void QNetworkSessionPrivateImpl::open() { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "open() called, session state is: " << state << " and isOpen is: " + << isOpen; +#endif if (isOpen || (state == QNetworkSession::Connecting)) { return; } - - // Cancel notifications from RConnectionMonitor + + // Stop handling IAP state change signals from QNetworkConfigurationManagerPrivate // => RConnection::ProgressNotification will be used for IAP/SNAP monitoring - iConnectionMonitor.CancelNotifications(); + iHandleStateNotificationsFromManager = false; // Configuration may have been invalidated after session creation by platform // (e.g. configuration has been deleted). @@ -259,19 +317,25 @@ void QNetworkSessionPrivateImpl::open() newState(QNetworkSession::Invalid); iError = QNetworkSession::InvalidConfigurationError; emit QNetworkSessionPrivate::error(iError); - syncStateWithInterface(); return; } - // If opening a (un)defined configuration, session emits error and enters - // NotAvailable -state. - if (publicConfig.state() == QNetworkConfiguration::Undefined || - publicConfig.state() == QNetworkConfiguration::Defined) { + // If opening a undefined configuration, session emits error and enters + // NotAvailable -state. Note that we will try ones in 'defined' state to avoid excessive + // need for WLAN scans (via updateConfigurations()), because user may have walked + // into a WLAN range, but periodic background scan has not occurred yet --> + // we don't want to force application to make frequent updateConfigurations() calls + // to be able to try if e.g. home WLAN is available. + if (publicConfig.state() == QNetworkConfiguration::Undefined) { newState(QNetworkSession::NotAvailable); iError = QNetworkSession::InvalidConfigurationError; emit QNetworkSessionPrivate::error(iError); return; } - + // Clear possible previous states + iStoppedByUser = false; + iClosedByUser = false; + iDeprecatedConnectionId = 0; + TInt error = iSocketServ.Connect(); if (error != KErrNone) { // Could not open RSocketServ @@ -446,9 +510,18 @@ TUint QNetworkSessionPrivateImpl::iapClientCount(TUint aIAPId) const void QNetworkSessionPrivateImpl::close(bool allowSignals) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "close() called, session state is: " << state << " and isOpen is : " + << isOpen; +#endif if (!isOpen) { return; } + // Mark this session as closed-by-user so that we are able to report + // distinguish between stop() and close() state transitions + // when reporting. + iClosedByUser = true; SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(activeConfig)); @@ -469,8 +542,10 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) } #endif - if (ipConnectionNotifier) { + if (ipConnectionNotifier && !iHandleStateNotificationsFromManager) { ipConnectionNotifier->StopNotifications(); + // Start handling IAP state change signals from QNetworkConfigurationManagerPrivate + iHandleStateNotificationsFromManager = true; } iConnection.Close(); @@ -488,7 +563,6 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) newState(QNetworkSession::Closing); } - syncStateWithInterface(); if (allowSignals) { if (publicConfig.type() == QNetworkConfiguration::UserChoice) { newState(QNetworkSession::Disconnected); @@ -499,9 +573,19 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) void QNetworkSessionPrivateImpl::stop() { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "stop() called, session state is: " << state << " and isOpen is : " + << isOpen; +#endif if (!isOpen && publicConfig.isValid() && publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "since session is not open, using RConnectionMonitor to stop() the interface"; +#endif + iStoppedByUser = true; // If the publicConfig is type of IAP, enumerate through connections at // connection monitor. If publicConfig is active in that list, stop it. // Otherwise there is nothing to stop. Note: because this QNetworkSession is not open, @@ -532,11 +616,25 @@ void QNetworkSessionPrivateImpl::stop() ETrue); } } + // Enter disconnected state right away since the session is not even open. + // Symbian^3 connection monitor does not emit KLinkLayerClosed when + // connection is stopped via connection monitor. + newState(QNetworkSession::Disconnected); } } else if (isOpen) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "since session is open, using RConnection to stop() the interface"; +#endif // Since we are open, use RConnection to stop the interface isOpen = false; + iStoppedByUser = true; newState(QNetworkSession::Closing); + if (ipConnectionNotifier) { + ipConnectionNotifier->StopNotifications(); + // Start handling IAP state change signals from QNetworkConfigurationManagerPrivate + iHandleStateNotificationsFromManager = true; + } iConnection.Stop(RConnection::EStopAuthoritative); isOpen = true; close(false); @@ -654,6 +752,10 @@ void QNetworkSessionPrivateImpl::NewCarrierActive(TAccessPointInfo /*aNewAPInfo* void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "roaming Error() occured"; +#endif if (isOpen) { isOpen = false; activeConfig = QNetworkConfiguration(); @@ -671,6 +773,11 @@ void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) // changes immediately to Disconnected. newState(QNetworkSession::Disconnected); emit closed(); + } else if (iStoppedByUser) { + // If the user of this session has called the stop() and + // configuration is based on internet SNAP, this needs to be + // done here because platform might roam. + newState(QNetworkSession::Disconnected); } } #endif @@ -975,7 +1082,12 @@ void QNetworkSessionPrivateImpl::RunL() isOpen = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); - iError = QNetworkSession::UnknownSessionError; + if (publicConfig.state() == QNetworkConfiguration::Undefined || + publicConfig.state() == QNetworkConfiguration::Defined) { + iError = QNetworkSession::InvalidConfigurationError; + } else { + iError = QNetworkSession::UnknownSessionError; + } emit QNetworkSessionPrivate::error(iError); Cancel(); if (ipConnectionNotifier) { @@ -991,8 +1103,16 @@ void QNetworkSessionPrivateImpl::DoCancel() iConnection.Close(); } +// Enters newState if feasible according to current state. +// AccessPointId may be given as parameter. If it is zero, state-change is assumed to +// concern this session's configuration. If non-zero, the configuration is looked up +// and checked if it matches the configuration this session is based on. bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint accessPointId) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "NEW STATE, IAP ID : " << QString::number(accessPointId) << " , newState : " << QString::number(newState); +#endif // Make sure that activeConfig is always updated when SNAP is signaled to be // connected. if (isOpen && publicConfig.type() == QNetworkConfiguration::ServiceNetwork && @@ -1027,9 +1147,29 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint if (state == QNetworkSession::Roaming && newState == QNetworkSession::Connecting) { return false; } + + // Make sure that Connected state is not reported when Connection is + // already Closing. + // Note: Stopping connection results sometimes KLinkLayerOpen + // to be reported first (just before KLinkLayerClosed). + if (state == QNetworkSession::Closing && newState == QNetworkSession::Connected) { + return false; + } + + // Make sure that some lagging 'closing' state-changes do not overwrite + // if we are already disconnected or closed. + if (state == QNetworkSession::Disconnected && newState == QNetworkSession::Closing) { + return false; + } bool emitSessionClosed = false; - if (isOpen && state == QNetworkSession::Connected && newState == QNetworkSession::Disconnected) { + + // If we abruptly go down and user hasn't closed the session, we've been aborted. + // Note that session may be in 'closing' state and not in 'connected' state, because + // depending on platform the platform may report KConfigDaemonStartingDeregistration + // event before KLinkLayerClosed + if ((isOpen && state == QNetworkSession::Connected && newState == QNetworkSession::Disconnected) || + (isOpen && !iClosedByUser && newState == QNetworkSession::Disconnected)) { // Active & Connected state should change directly to Disconnected state // only when something forces connection to close (eg. when another // application or session stops connection or when network drops @@ -1043,14 +1183,17 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); } - // Start monitoring changes in IAP states - TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); + // Start handling IAP state change signals from QNetworkConfigurationManagerPrivate + iHandleStateNotificationsFromManager = true; emitSessionClosed = true; // Emit SessionClosed after state change has been reported } bool retVal = false; if (accessPointId == 0) { state = newState; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed A to: " << state; +#endif emit stateChanged(state); retVal = true; } else { @@ -1063,6 +1206,9 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint configLocker.unlock(); state = newState; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed B to: " << state; +#endif emit stateChanged(state); retVal = true; } @@ -1075,6 +1221,9 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint configLocker.unlock(); state = newState; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed C to: " << state; +#endif emit stateChanged(state); retVal = true; } @@ -1088,20 +1237,13 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint if (symbianConfig->numericId == accessPointId) { if (newState == QNetworkSession::Connected) { - // Make sure that when AccessPoint is reported to be Connected - // also state of the related configuration changes to Active. - symbianConfig->state = QNetworkConfiguration::Active; - configLocker.unlock(); - state = newState; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed D to: " << state; +#endif emit stateChanged(state); retVal = true; } else { - if (newState == QNetworkSession::Disconnected) { - // Make sure that when AccessPoint is reported to be disconnected - // also state of the related configuration changes from Active to Defined. - symbianConfig->state = QNetworkConfiguration::Defined; - } QNetworkConfiguration config = bestConfigFromSNAP(publicConfig); if ((config.state() == QNetworkConfiguration::Defined) || (config.state() == QNetworkConfiguration::Discovered)) { @@ -1109,6 +1251,9 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint configLocker.unlock(); state = newState; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed E to: " << state; +#endif emit stateChanged(state); retVal = true; } @@ -1121,6 +1266,19 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint if (emitSessionClosed) { emit closed(); } + if (state == QNetworkSession::Disconnected) { + // The connection has gone down, and processing of status updates must be + // stopped. Depending on platform, there may come 'connecting/connected' states + // considerably later (almost a second). Connection id is an increasing + // number, so this does not affect next _real_ 'conneting/connected' states. + + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + + symbianConfig->mutex.lock(); + iDeprecatedConnectionId = symbianConfig->connectionId; + symbianConfig->mutex.unlock(); + } return retVal; } @@ -1129,6 +1287,9 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne TInt aError, TUint accessPointId) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << QString::number(accessPointId) << " , status : " << QString::number(aConnectionStatus); +#endif switch (aConnectionStatus) { // Connection unitialised @@ -1167,6 +1328,7 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne case KCsdGotLoginInfo: break; + case KConfigDaemonStartingRegistration: // Creating connection (e.g. GPRS activation) case KCsdStartingConnect: case KCsdFinishedConnect: @@ -1193,6 +1355,7 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne case KDataTransferTemporarilyBlocked: break; + case KConfigDaemonStartingDeregistration: // Hangup or GRPS deactivation case KConnectionStartingClose: newState(QNetworkSession::Closing,accessPointId); @@ -1200,136 +1363,26 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne // Connection closed case KConnectionClosed: - break; - case KLinkLayerClosed: newState(QNetworkSession::Disconnected,accessPointId); + // Report manager about this to make sure this event + // is received by all interseted parties (mediated by + // manager because it does always receive all events from + // connection monitor). +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "reporting disconnection to manager."; +#endif + if (publicConfig.isValid()) { + engine->configurationStateChangeReport(toSymbianConfig(privateConfiguration(publicConfig))->numericId, QNetworkSession::Disconnected); + } break; - // Unhandled state default: break; } } -void QNetworkSessionPrivateImpl::EventL(const CConnMonEventBase& aEvent) -{ - switch (aEvent.EventType()) - { - case EConnMonConnectionStatusChange: - { - CConnMonConnectionStatusChange* realEvent; - realEvent = (CConnMonConnectionStatusChange*) &aEvent; - - TUint connectionId = realEvent->ConnectionId(); - TInt connectionStatus = realEvent->ConnectionStatus(); - - // Try to Find IAP Id using connection Id - TUint apId = 0; - if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { - QList subConfigurations = publicConfig.children(); - for (int i = 0; i < subConfigurations.count(); i++ ) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(subConfigurations[i])); - - QMutexLocker configLocker(&symbianConfig->mutex); - - if (symbianConfig->connectionId == connectionId) { - apId = symbianConfig->numericId; - break; - } - } - } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - - symbianConfig->mutex.lock(); - if (symbianConfig->connectionId == connectionId) - apId = symbianConfig->numericId; - symbianConfig->mutex.unlock(); - } - - if (apId > 0) { - handleSymbianConnectionStatusChange(connectionStatus, KErrNone, apId); - } - } - break; - - case EConnMonCreateConnection: - { - CConnMonCreateConnection* realEvent; - realEvent = (CConnMonCreateConnection*) &aEvent; - TUint apId; - TUint connectionId = realEvent->ConnectionId(); - TRequestStatus status; - iConnectionMonitor.GetUintAttribute(connectionId, 0, KIAPId, apId, status); - User::WaitForRequest(status); - if (status.Int() == KErrNone) { - // Store connection id to related AccessPoint Configuration - if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { - QList subConfigurations = publicConfig.children(); - for (int i = 0; i < subConfigurations.count(); i++ ) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(subConfigurations[i])); - - QMutexLocker configLocker(&symbianConfig->mutex); - - if (symbianConfig->numericId == apId) { - symbianConfig->connectionId = connectionId; - break; - } - } - } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - - symbianConfig->mutex.lock(); - if (symbianConfig->numericId == apId) - symbianConfig->connectionId = connectionId; - symbianConfig->mutex.unlock(); - } - } - } - break; - - case EConnMonDeleteConnection: - { - CConnMonDeleteConnection* realEvent; - realEvent = (CConnMonDeleteConnection*) &aEvent; - TUint connectionId = realEvent->ConnectionId(); - // Remove connection id from related AccessPoint Configuration - if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { - QList subConfigurations = publicConfig.children(); - for (int i = 0; i < subConfigurations.count(); i++ ) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(subConfigurations[i])); - - QMutexLocker configLocker(&symbianConfig->mutex); - - if (symbianConfig->connectionId == connectionId) { - symbianConfig->connectionId = 0; - break; - } - } - } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - - symbianConfig->mutex.lock(); - if (symbianConfig->connectionId == connectionId) - symbianConfig->connectionId = 0; - symbianConfig->mutex.unlock(); - } - } - break; - - default: - // For unrecognized events - break; - } -} - -ConnectionProgressNotifier::ConnectionProgressNotifier(QNetworkSessionPrivateImpl &owner, RConnection &connection) +ConnectionProgressNotifier::ConnectionProgressNotifier(QNetworkSessionPrivateImpl& owner, RConnection& connection) : CActive(CActive::EPriorityStandard), iOwner(owner), iConnection(connection) { CActiveScheduler::Add(this); diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index 7116519..9767293 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -75,9 +75,8 @@ class SymbianEngine; class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive, #ifdef SNAP_FUNCTIONALITY_AVAILABLE - public MMobilityProtocolResp, + public MMobilityProtocolResp #endif - public MConnectionMonitorObserver { Q_OBJECT public: @@ -130,8 +129,9 @@ protected: // From CActive void RunL(); void DoCancel(); -private: // MConnectionMonitorObserver - void EventL(const CConnMonEventBase& aEvent); +private Q_SLOTS: + void configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState); + void configurationRemoved(QNetworkConfigurationPrivatePointer config); private: TUint iapClientCount(TUint aIAPId) const; @@ -157,6 +157,13 @@ private: // data mutable RConnection iConnection; mutable RConnectionMonitor iConnectionMonitor; ConnectionProgressNotifier* ipConnectionNotifier; + + bool iHandleStateNotificationsFromManager; + bool iFirstSync; + bool iStoppedByUser; + bool iClosedByUser; + TUint32 iDeprecatedConnectionId; + #ifdef SNAP_FUNCTIONALITY_AVAILABLE CActiveCommsMobilityApiExt* iMobility; #endif diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 8e9675e..cea8b67 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -45,14 +45,14 @@ #include #include #include +#include #include #include #include // For randgen seeding #include // For randgen seeding -// #define QT_BEARERMGMT_CONFIGMGR_DEBUG -#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG #include #endif @@ -73,7 +73,9 @@ QT_BEGIN_NAMESPACE -static const int KValueThatWillBeAddedToSNAPId = 1000; +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + static const int KValueThatWillBeAddedToSNAPId = 1000; +#endif static const int KUserChoiceIAPId = 0; SymbianNetworkConfigurationPrivate::SymbianNetworkConfigurationPrivate() @@ -657,26 +659,34 @@ void SymbianEngine::updateActiveAccessPoints() iConnectionMonitor.GetConnectionCount(connectionCount, status); User::WaitForRequest(status); - // Go through all connections and set state of related IAPs to Active + // Go through all connections and set state of related IAPs to Active. + // Status needs to be checked carefully, because ConnMon lists also e.g. + // WLAN connections that are being currently tried --> we don't want to + // state these as active. TUint connectionId; TUint subConnectionCount; TUint apId; + TInt connectionStatus; if (status.Int() == KErrNone) { for (TUint i = 1; i <= connectionCount; i++) { iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount); iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); QString ident = QString::number(qHash(apId)); - QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { - online = true; - inactiveConfigs.removeOne(ident); + iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); + User::WaitForRequest(status); + if (connectionStatus == KLinkLayerOpen) { + online = true; + inactiveConfigs.removeOne(ident); - toSymbianConfig(ptr)->connectionId = connectionId; + QMutexLocker configLocker(&ptr->mutex); + toSymbianConfig(ptr)->connectionId = connectionId; - // Configuration is Active - changeConfigurationStateTo(ptr, QNetworkConfiguration::Active); + // Configuration is Active + changeConfigurationStateTo(ptr, QNetworkConfiguration::Active); + } } } } @@ -733,12 +743,12 @@ void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapIn } } - // Make sure that state of rest of the IAPs won't be Discovered or Active + // Make sure that state of rest of the IAPs won't be Active foreach (const QString &iface, unavailableConfigs) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); if (ptr) { // Configuration is Defined - changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Defined); + changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered); } } } @@ -894,21 +904,22 @@ void SymbianEngine::RunL() QMutexLocker locker(&mutex); if (iIgnoringUpdates) { -#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG - qDebug("CommsDB event handling postponed (postpone-timer running because IAPs/SNAPs were updated very recently)."); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug("QNCM CommsDB event handling postponed (postpone-timer running because IAPs/SNAPs were updated very recently)."); #endif return; } if (iStatus != KErrCancel) { RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int()); + switch (event) { case RDbNotifier::EUnlock: /** All read locks have been removed. */ case RDbNotifier::ECommit: /** A transaction has been committed. */ case RDbNotifier::ERollback: /** A transaction has been rolled back */ case RDbNotifier::ERecover: /** The database has been recovered */ -#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG - qDebug("CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug("QNCM CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); #endif iIgnoringUpdates = true; // Other events than ECommit get lower priority. In practice with those events, @@ -957,73 +968,95 @@ void SymbianEngine::DoCancel() ipCommsDB->CancelRequestNotification(); } - void SymbianEngine::EventL(const CConnMonEventBase& aEvent) { QMutexLocker locker(&mutex); switch (aEvent.EventType()) { - case EConnMonCreateConnection: + case EConnMonConnectionStatusChange: { - CConnMonCreateConnection* realEvent; - realEvent = (CConnMonCreateConnection*) &aEvent; - TUint subConnectionCount = 0; - TUint apId; - TUint connectionId = realEvent->ConnectionId(); - TRequestStatus status; - iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); - User::WaitForRequest(status); - QString ident = QString::number(qHash(apId)); - - QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); - if (ptr) { - toSymbianConfig(ptr)->connectionId = connectionId; - // Configuration is Active - if (changeConfigurationStateTo(ptr, QNetworkConfiguration::Active)) - updateStatesToSnaps(); - - if (!iOnline) { - iOnline = true; - - locker.unlock(); - emit this->onlineStateChanged(iOnline); - locker.relock(); + CConnMonConnectionStatusChange* realEvent; + realEvent = (CConnMonConnectionStatusChange*) &aEvent; + TInt connectionStatus = realEvent->ConnectionStatus(); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNCM Connection status : " << QString::number(connectionStatus) << " , connection monitor Id : " << realEvent->ConnectionId(); +#endif + if (connectionStatus == KConfigDaemonStartingRegistration) { + TUint connectionId = realEvent->ConnectionId(); + TUint subConnectionCount = 0; + TUint apId; + TRequestStatus status; + iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); + User::WaitForRequest(status); + QString ident = QString::number(qHash(apId)); + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); + if (ptr) { + QMutexLocker configLocker(&ptr->mutex); + toSymbianConfig(ptr)->connectionId = connectionId; + emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Connecting); } - } - } - break; - - case EConnMonDeleteConnection: - { - CConnMonDeleteConnection* realEvent; - realEvent = (CConnMonDeleteConnection*) &aEvent; - TUint connectionId = realEvent->ConnectionId(); - - QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); - if (ptr) { - toSymbianConfig(ptr)->connectionId = 0; - // Configuration is either Defined or Discovered - if (changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered)) - updateStatesToSnaps(); - } - - bool online = false; - foreach (const QString &iface, accessPointConfigurations.keys()) { - QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); - if (ptr->state == QNetworkConfiguration::Active) { - online = true; - break; + } else if (connectionStatus == KLinkLayerOpen) { + // Connection has been successfully opened + TUint connectionId = realEvent->ConnectionId(); + TUint subConnectionCount = 0; + TUint apId; + TRequestStatus status; + iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); + User::WaitForRequest(status); + QString ident = QString::number(qHash(apId)); + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); + if (ptr) { + QMutexLocker configLocker(&ptr->mutex); + toSymbianConfig(ptr)->connectionId = connectionId; + // Configuration is Active + if (changeConfigurationStateTo(ptr, QNetworkConfiguration::Active)) { + updateStatesToSnaps(); + } + emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Connected); + if (!iOnline) { + iOnline = true; + emit this->onlineStateChanged(iOnline); + } } - } - if (iOnline != online) { - iOnline = online; + } else if (connectionStatus == KConfigDaemonStartingDeregistration) { + TUint connectionId = realEvent->ConnectionId(); + QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); + if (ptr) { + QMutexLocker configLocker(&ptr->mutex); + emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Closing); + } + } else if (connectionStatus == KLinkLayerClosed || + connectionStatus == KConnectionClosed) { + // Connection has been closed. Which of the above events is reported, depends on the Symbian + // platform. + TUint connectionId = realEvent->ConnectionId(); + QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); + if (ptr) { + // Configuration is either Defined or Discovered + if (changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered)) { + updateStatesToSnaps(); + } - locker.unlock(); - emit this->onlineStateChanged(iOnline); - locker.relock(); + QMutexLocker configLocker(&ptr->mutex); + emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Disconnected); + } + + bool online = false; + foreach (const QString &iface, accessPointConfigurations.keys()) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); + QMutexLocker configLocker(&ptr->mutex); + if (ptr->state == QNetworkConfiguration::Active) { + online = true; + break; + } + } + if (iOnline != online) { + iOnline = online; + emit this->onlineStateChanged(iOnline); + } } } - break; + break; case EConnMonIapAvailabilityChange: { @@ -1051,21 +1084,78 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) } break; + case EConnMonCreateConnection: + { + // This event is caught to keep connection monitor IDs up-to-date. + CConnMonCreateConnection* realEvent; + realEvent = (CConnMonCreateConnection*) &aEvent; + TUint subConnectionCount = 0; + TUint apId; + TUint connectionId = realEvent->ConnectionId(); + TRequestStatus status; + iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); + User::WaitForRequest(status); + QString ident = QString::number(qHash(apId)); + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); + if (ptr) { + QMutexLocker configLocker(&ptr->mutex); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNCM updating connection monitor ID : from, to, whose: " << toSymbianConfig(ptr)->connectionId << connectionId << ptr->name; +#endif + toSymbianConfig(ptr)->connectionId = connectionId; + } + } + break; default: // For unrecognized events break; } } -// Waits for 1..4 seconds. +// Sessions may use this function to report configuration state changes, +// because on some Symbian platforms (especially Symbian^3) all state changes are not +// reported by the RConnectionMonitor, in particular in relation to stop() call, +// whereas they _are_ reported on RConnection progress notifier used by sessions --> centralize +// this data here so that other sessions may benefit from it too (not all sessions necessarily have +// RConnection progress notifiers available but they relay on having e.g. disconnected information from +// manager). Currently only 'Disconnected' state is of interest because it has proven to be troublesome. +void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetworkSession::State newState) +{ +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNCM A session reported state change for IAP ID: " << accessPointId << " whose new state is: " << newState; +#endif + switch (newState) { + case QNetworkSession::Disconnected: + { + QString ident = QString::number(qHash(accessPointId)); + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); + if (ptr) { + // Configuration is either Defined or Discovered + if (changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered)) { + updateStatesToSnaps(); + } + + QMutexLocker configLocker(&ptr->mutex); + emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, + toSymbianConfig(ptr)->connectionId, + QNetworkSession::Disconnected); + } + } + break; + default: + break; + } +} + +// Waits for 2..6 seconds. void SymbianEngine::waitRandomTime() { - iTimeToWait = (qAbs(qrand()) % 5) * 1000; - if (iTimeToWait < 1000) { - iTimeToWait = 1000; + iTimeToWait = (qAbs(qrand()) % 7) * 1000; + if (iTimeToWait < 2000) { + iTimeToWait = 2000; } -#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG - qDebug("QNetworkConfigurationManager waiting random time: %d ms", iTimeToWait); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug("QNCM waiting random time: %d ms", iTimeToWait); #endif QTimer::singleShot(iTimeToWait, iIgnoreEventLoop, SLOT(quit())); iIgnoreEventLoop->exec(); @@ -1076,11 +1166,11 @@ QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aCon QMutexLocker locker(&mutex); QNetworkConfiguration item; - QHash::const_iterator i = accessPointConfigurations.constBegin(); while (i != accessPointConfigurations.constEnd()) { QNetworkConfigurationPrivatePointer ptr = i.value(); + QMutexLocker configLocker(&ptr->mutex); if (toSymbianConfig(ptr)->connectionId == aConnectionId) return ptr; diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index afb37de..7d565db 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -52,6 +52,9 @@ #include #endif +// Uncomment and compile QtBearer to gain detailed state tracing +// #define QT_BEARERMGMT_SYMBIAN_DEBUG + class CCommsDatabase; class QEventLoop; @@ -90,7 +93,18 @@ public: Bearer bearer; + // So called IAP id from the platform. Remains constant as long as the + // platform is aware of the configuration ie. it is stored in the databases + // --> does not depend on whether connections are currently open or not. + // In practice is the same for the lifetime of the QNetworkConfiguration. TUint32 numericId; + // So called connection id, or connection monitor ID. A dynamic ID assigned + // by RConnectionMonitor whenever a new connection is opened. ConnectionID and + // numericId/IAP id have 1-to-1 mapping during the lifetime of the connection at + // connection monitor. Notably however it changes whenever a new connection to + // a given IAP is created. In a sense it is constant during the time the + // configuration remains between states Discovered..Active..Discovered, do not + // however relay on this. TUint connectionId; }; @@ -124,6 +138,9 @@ public: Q_SIGNALS: void onlineStateChanged(bool isOnline); + void configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, + QNetworkSession::State newState); + public Q_SLOTS: void updateConfigurations(); @@ -157,12 +174,17 @@ private: void startMonitoringIAPData(TUint32 aIapId); QNetworkConfigurationPrivatePointer dataByConnectionId(TUint aConnectionId); -protected: // From CActive +protected: + // From CActive void RunL(); void DoCancel(); -private: // MConnectionMonitorObserver +private: + // MConnectionMonitorObserver void EventL(const CConnMonEventBase& aEvent); + // For QNetworkSessionPrivate to indicate about state changes + void configurationStateChangeReport(TUint32 accessPointId, + QNetworkSession::State newState); private: // Data bool iFirstUpdate; @@ -181,6 +203,7 @@ private: // Data friend class QNetworkSessionPrivate; friend class AccessPointsAvailabilityScanner; + friend class QNetworkSessionPrivateImpl; #ifdef SNAP_FUNCTIONALITY_AVAILABLE RCmManager iCmManager; diff --git a/tests/auto/qnetworksession/lackey/main.cpp b/tests/auto/qnetworksession/lackey/main.cpp index 8759b52..ec2fad9 100644 --- a/tests/auto/qnetworksession/lackey/main.cpp +++ b/tests/auto/qnetworksession/lackey/main.cpp @@ -47,6 +47,8 @@ #include #include +#include +#include #include QT_USE_NAMESPACE @@ -60,15 +62,14 @@ int main(int argc, char** argv) { QCoreApplication app(argc, argv); - // Cannot read/write to processes on WinCE or Symbian. - // Easiest alternative is to use sockets for IPC. - - QLocalSocket oopSocket; - - oopSocket.connectToServer("tst_qnetworksession"); - oopSocket.waitForConnected(-1); - + // Update configurations so that everything is up to date for this process too. + // Event loop is used to wait for awhile. QNetworkConfigurationManager manager; + manager.updateConfigurations(); + QEventLoop iIgnoreEventLoop; + QTimer::singleShot(3000, &iIgnoreEventLoop, SLOT(quit())); + iIgnoreEventLoop.exec(); + QList discovered = manager.allConfigurations(QNetworkConfiguration::Discovered); @@ -82,6 +83,13 @@ int main(int argc, char** argv) return NO_DISCOVERED_CONFIGURATIONS_ERROR; } + // Cannot read/write to processes on WinCE or Symbian. + // Easiest alternative is to use sockets for IPC. + QLocalSocket oopSocket; + + oopSocket.connectToServer("tst_qnetworksession"); + oopSocket.waitForConnected(-1); + qDebug() << "Lackey started"; QNetworkSession *session = 0; diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index 23cdc6a..8ab9da2 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -100,6 +100,7 @@ private slots: private: QNetworkConfigurationManager manager; + QMap testsToRun; int inProcessSessionManagementCount; @@ -117,6 +118,7 @@ private: bool openSession(QNetworkSession *session); bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration = true); void updateConfigurations(); +void printConfigurations(); QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfiguration::Type configType); void tst_QNetworkSession::initTestCase() @@ -125,7 +127,19 @@ void tst_QNetworkSession::initTestCase() qRegisterMetaType("QNetworkSession::SessionError"); qRegisterMetaType("QNetworkConfiguration"); qRegisterMetaType("QNetworkConfiguration::Type"); - + + // If you wish to skip tests, set value as false. This is often very convinient because tests are so lengthy. + // Better way still would be to make this readable from a file. + testsToRun["robustnessBombing"] = true; + testsToRun["outOfProcessSession"] = true; + testsToRun["invalidSession"] = true; + testsToRun["repeatedOpenClose"] = true; + testsToRun["roamingErrorCodes"] = true; + testsToRun["sessionStop"] = true; + testsToRun["sessionProperties"] = true; + testsToRun["userChoiceSession"] = true; + testsToRun["sessionOpenCloseStop"] = true; + #if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) iapconf = new Maemo::IAPConf("007"); iapconf->setValue("ipv4_type", "AUTO"); @@ -238,6 +252,10 @@ void tst_QNetworkSession::cleanupTestCase() // Robustness test for calling interfaces in nonsense order / with nonsense parameters void tst_QNetworkSession::robustnessBombing() { + if (!testsToRun["robustnessBombing"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } + QNetworkConfigurationManager mgr; QNetworkSession testSession(mgr.defaultConfiguration()); // Should not reset even session is not opened @@ -253,7 +271,10 @@ void tst_QNetworkSession::robustnessBombing() void tst_QNetworkSession::invalidSession() -{ +{ + if (!testsToRun["invalidSession"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } // 1. Verify that session created with invalid configuration remains in invalid state QNetworkSession session(QNetworkConfiguration(), 0); QVERIFY(!session.isOpen()); @@ -270,11 +291,24 @@ void tst_QNetworkSession::invalidSession() QVERIFY(error == QNetworkSession::InvalidConfigurationError); QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError); QVERIFY(session.state() == QNetworkSession::Invalid); - + #ifdef QNETWORKSESSION_MANUAL_TESTS + + QNetworkConfiguration invalidatedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint); + if (invalidatedConfig.isValid()) { + // 3. Verify that invalidating a session after its successfully configured works + QNetworkSession invalidatedSession(invalidatedConfig); + qDebug() << "Delete the WLAN IAP from phone now (waiting 60 seconds): " << invalidatedConfig.name(); + QTest::qWait(60000); + QVERIFY(!invalidatedConfig.isValid()); + QVERIFY(invalidatedSession.state() == QNetworkSession::Invalid); + qDebug() << "Add the WLAN IAP back (waiting 60 seconds): " << invalidatedConfig.name(); + QTest::qWait(60000); + } + QNetworkConfiguration definedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint); if (definedConfig.isValid()) { - // 3. Verify that opening a session with defined configuration emits error and enters notavailable-state + // 4. Verify that opening a session with defined configuration emits error and enters notavailable-state // TODO these timer waits should be changed to waiting appropriate signals, now these wait excessively qDebug() << "Shutdown WLAN IAP (waiting 60 seconds): " << definedConfig.name(); QTest::qWait(60000); @@ -283,43 +317,27 @@ void tst_QNetworkSession::invalidSession() QNetworkSession definedSession(definedConfig); QSignalSpy errorSpy(&definedSession, SIGNAL(error(QNetworkSession::SessionError))); QNetworkSession::SessionError sessionError; + updateConfigurations(); definedSession.open(); +#ifdef Q_OS_SYMBIAN + // On symbian, the connection opening is tried even with defined state. + qDebug("Waiting for 10 seconds to all signals to propagate."); + QTest::qWait(10000); +#endif + updateConfigurations(); QVERIFY(definedConfig.isValid()); // Session remains valid QVERIFY(definedSession.state() == QNetworkSession::NotAvailable); // State is not available because WLAN is not in coverage QVERIFY(!errorSpy.isEmpty()); // Session tells with error about invalidated configuration sessionError = qvariant_cast (errorSpy.first().at(0)); - qDebug() << "Error code is: " << sessionError; QVERIFY(sessionError == QNetworkSession::InvalidConfigurationError); - qDebug() << "Turn the WLAN IAP back on (waiting 60 seconds): " << definedConfig.name(); QTest::qWait(60000); - updateConfigurations(); - + updateConfigurations(); QVERIFY(definedConfig.state() == QNetworkConfiguration::Discovered); } - - QNetworkConfiguration invalidatedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint); - if (invalidatedConfig.isValid()) { - // 4. Verify that invalidating a session after its successfully configured works - QNetworkSession invalidatedSession(invalidatedConfig); - QSignalSpy errorSpy(&invalidatedSession, SIGNAL(error(QNetworkSession::SessionError))); - QNetworkSession::SessionError sessionError; - - qDebug() << "Delete the WLAN IAP from phone now (waiting 60 seconds): " << invalidatedConfig.name(); - QTest::qWait(60000); - - invalidatedSession.open(); - QVERIFY(!invalidatedConfig.isValid()); - QVERIFY(invalidatedSession.state() == QNetworkSession::Invalid); - QVERIFY(!errorSpy.isEmpty()); - - sessionError = qvariant_cast (errorSpy.first().at(0)); - QVERIFY(sessionError == QNetworkSession::InvalidConfigurationError); - qDebug() << "Add the WLAN IAP back (waiting 60 seconds): " << invalidatedConfig.name(); - QTest::qWait(60000); - } + #endif } @@ -337,12 +355,12 @@ void tst_QNetworkSession::sessionProperties_data() void tst_QNetworkSession::sessionProperties() { + if (!testsToRun["sessionProperties"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } QFETCH(QNetworkConfiguration, configuration); - QNetworkSession session(configuration); - QVERIFY(session.configuration() == configuration); - QStringList validBearerNames = QStringList() << QLatin1String("Unknown") << QLatin1String("Ethernet") << QLatin1String("WLAN") @@ -356,9 +374,6 @@ void tst_QNetworkSession::sessionProperties() if (!configuration.isValid()) { QVERIFY(configuration.bearerName().isEmpty()); } else { - qDebug() << "Type:" << configuration.type() - << "Bearer:" << configuration.bearerName(); - switch (configuration.type()) { case QNetworkConfiguration::ServiceNetwork: @@ -374,9 +389,7 @@ void tst_QNetworkSession::sessionProperties() // QNetworkSession::interface() should return an invalid interface unless // session is in the connected state. - qDebug() << "Session state:" << session.state(); #ifndef QT_NO_NETWORKINTERFACE - qDebug() << "Session iface:" << session.interface().isValid() << session.interface().name(); #if !(defined(Q_OS_SYMBIAN) && defined(__WINS__)) // On Symbian emulator, the support for data bearers is limited QCOMPARE(session.state() == QNetworkSession::Connected, session.interface().isValid()); @@ -420,7 +433,12 @@ void tst_QNetworkSession::repeatedOpenClose_data() { } // Tests repeated-open close. -void tst_QNetworkSession::repeatedOpenClose() { +void tst_QNetworkSession::repeatedOpenClose() +{ + if (!testsToRun["repeatedOpenClose"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } + QFETCH(QString, bearerType); QFETCH(QNetworkConfiguration::Type, configurationType); QFETCH(int, repeatTimes); @@ -436,13 +454,20 @@ void tst_QNetworkSession::repeatedOpenClose() { !closeSession(&permanentSession)) { QSKIP("Unable to open/close session, skipping this round of repeated open-close test.", SkipSingle); } - for (int i = repeatTimes; i > 0; i--) { + for (int i = 0; i < repeatTimes; i++) { + qDebug() << "Opening, loop number " << i; QVERIFY(openSession(&permanentSession)); + qDebug() << "Closing, loop number, then waiting 5 seconds: " << i; QVERIFY(closeSession(&permanentSession)); + QTest::qWait(5000); } } -void tst_QNetworkSession::roamingErrorCodes() { +void tst_QNetworkSession::roamingErrorCodes() +{ + if (!testsToRun["roamingErrorCodes"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } #ifndef Q_OS_SYMBIAN QSKIP("Roaming supported on Symbian.", SkipAll); #else @@ -466,41 +491,11 @@ void tst_QNetworkSession::roamingErrorCodes() { adminIapSession.stop(); // requires NetworkControl capabilities QTRY_VERIFY(!errorSpy.isEmpty()); // wait for error signals QNetworkSession::SessionError error = qvariant_cast(errorSpy.first().at(0)); + QTest::qWait(2000); // Wait for a moment to all platform signals to propagate QVERIFY(error == QNetworkSession::SessionAbortedError); QVERIFY(iapSession.state() == QNetworkSession::Disconnected); QVERIFY(adminIapSession.state() == QNetworkSession::Disconnected); #endif // Q_OS_SYMBIAN - -#ifdef QNETWORKSESSION_MANUAL_TESTS - // Check for roaming error. - // Case requires that you have controllable WLAN in Internet SNAP (only). - QNetworkConfiguration snapConfig = suitableConfiguration("bearer_not_relevant_with_snaps", QNetworkConfiguration::ServiceNetwork); - if (!snapConfig.isValid()) { - QSKIP("No SNAP accessible, skipping test.", SkipAll); - } - QNetworkSession snapSession(snapConfig); - QVERIFY(openSession(&snapSession)); - QSignalSpy errorSpySnap(&snapSession, SIGNAL(error(QNetworkSession::SessionError))); - qDebug("Disconnect the WLAN now"); - QTRY_VERIFY(!errorSpySnap.isEmpty()); // wait for error signals - QVERIFY(errorSpySnap.count() == 1); - error = qvariant_cast(errorSpySnap.first().at(0)); - qDebug() << "Error received when turning off wlan on SNAP: " << error; - QVERIFY(error == QNetworkSession::RoamingError); - - qDebug("Connect the WLAN now"); - QTest::qWait(60000); // Wait for WLAN to get up - QNetworkConfiguration wlanIapConfig2 = suitableConfiguration("WLAN", QNetworkConfiguration::InternetAccessPoint); - QNetworkSession iapSession2(wlanIapConfig2); - QVERIFY(openSession(&iapSession2)); - QSignalSpy errorSpy2(&iapSession2, SIGNAL(error(QNetworkSession::SessionError))); - qDebug("Disconnect the WLAN now"); - QTRY_VERIFY(!errorSpy2.isEmpty()); // wait for error signals - QVERIFY(errorSpy2.count() == 1); - error = qvariant_cast(errorSpy2.first().at(0)); - QVERIFY(error == QNetworkSession::SessionAbortedError); - QVERIFY(iapSession2.state() == QNetworkSession::Disconnected); -#endif } @@ -515,6 +510,9 @@ void tst_QNetworkSession::sessionStop_data() { void tst_QNetworkSession::sessionStop() { + if (!testsToRun["sessionStop"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } #ifndef Q_OS_SYMBIAN QSKIP("Testcase contains mainly Symbian specific checks, because it is only platform to really support interface (IAP-level) Stop.", SkipAll); #endif @@ -522,6 +520,9 @@ void tst_QNetworkSession::sessionStop() QFETCH(QNetworkConfiguration::Type, configurationType); int configWaitdelayInMs = 2000; + + updateConfigurations(); + printConfigurations(); QNetworkConfiguration config = suitableConfiguration(bearerType, configurationType); if (!config.isValid()) { @@ -539,6 +540,9 @@ void tst_QNetworkSession::sessionStop() QSignalSpy closedSessionStateChangedSpy(&closedSession, SIGNAL(stateChanged(QNetworkSession::State))); QSignalSpy closedErrorSpy(&closedSession, SIGNAL(error(QNetworkSession::SessionError))); + QSignalSpy openedSessionClosedSpy(&openedSession, SIGNAL(closed())); + QSignalSpy openedSessionStateChangedSpy(&openedSession, SIGNAL(stateChanged(QNetworkSession::State))); + QSignalSpy innocentSessionClosedSpy(&innocentSession, SIGNAL(closed())); QSignalSpy innocentSessionStateChangedSpy(&innocentSession, SIGNAL(stateChanged(QNetworkSession::State))); QSignalSpy innocentErrorSpy(&innocentSession, SIGNAL(error(QNetworkSession::SessionError))); @@ -554,10 +558,18 @@ void tst_QNetworkSession::sessionStop() closedSessionClosedSpy.clear(); closedSessionStateChangedSpy.clear(); closedErrorSpy.clear(); + openedSessionStateChangedSpy.clear(); + openedSessionClosedSpy.clear(); + openedSession.stop(); - QVERIFY(openedSession.state() == QNetworkSession::Disconnected); + qDebug("Waiting for %d ms to get all configurationChange signals from platform.", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals + + // First to closing, then to disconnected + QVERIFY(openedSessionStateChangedSpy.count() == 2); + QVERIFY(!openedSessionClosedSpy.isEmpty()); + QVERIFY(openedSession.state() == QNetworkSession::Disconnected); QVERIFY(config.state() != QNetworkConfiguration::Active); // 2. Verify that stopping a session based on non-connected configuration does nothing @@ -583,18 +595,20 @@ void tst_QNetworkSession::sessionStop() // 3. Check that stopping a opened session affects also other opened session based on the same configuration. if (config.type() == QNetworkConfiguration::InternetAccessPoint) { qDebug("----------3. Check that stopping a opened session affects also other opened session based on the same configuration."); + QVERIFY(openSession(&openedSession)); QVERIFY(openSession(&innocentSession)); - + configChangeSpy.clear(); innocentSessionClosedSpy.clear(); innocentSessionStateChangedSpy.clear(); innocentErrorSpy.clear(); - + openedSession.stop(); qDebug("Waiting for %d ms to get all configurationChange signals from platform.", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals - + QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals + QVERIFY(!innocentSessionClosedSpy.isEmpty()); QVERIFY(!innocentSessionStateChangedSpy.isEmpty()); QVERIFY(!innocentErrorSpy.isEmpty()); @@ -614,14 +628,19 @@ void tst_QNetworkSession::sessionStop() if (config.type() == QNetworkConfiguration::ServiceNetwork) { qDebug("----------4. Skip for SNAP configuration."); } else if (config.type() == QNetworkConfiguration::InternetAccessPoint) { - qDebug("----------4. Check that stopping a non-opened session stops the other session based on the same configuration"); - QVERIFY(openSession(&innocentSession)); + qDebug("----------4. Check that stopping a non-opened session stops the other session based on the same configuration"); + qDebug("----------4.1 Opening innocent session"); + QVERIFY(openSession(&innocentSession)); qDebug("Waiting for %d ms after open to make sure all platform indications are propagated", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); + qDebug("----------4.2 Calling closedSession.stop()"); closedSession.stop(); qDebug("Waiting for %d ms to get all configurationChange signals from platform..", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals + QTest::qWait(configWaitdelayInMs); + QTest::qWait(configWaitdelayInMs); + QVERIFY(!innocentSessionClosedSpy.isEmpty()); QVERIFY(!innocentSessionStateChangedSpy.isEmpty()); QVERIFY(!innocentErrorSpy.isEmpty()); @@ -653,6 +672,9 @@ void tst_QNetworkSession::userChoiceSession_data() void tst_QNetworkSession::userChoiceSession() { + if (!testsToRun["userChoiceSession"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } QFETCH(QNetworkConfiguration, configuration); QVERIFY(configuration.type() == QNetworkConfiguration::UserChoice); @@ -786,6 +808,9 @@ void tst_QNetworkSession::sessionOpenCloseStop_data() void tst_QNetworkSession::sessionOpenCloseStop() { + if (!testsToRun["sessionOpenCloseStop"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } QFETCH(QNetworkConfiguration, configuration); QFETCH(bool, forceSessionStop); @@ -894,26 +919,30 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(session.error() == QNetworkSession::UnknownSessionError); session2.open(); - + QTRY_VERIFY(!sessionOpenedSpy2.isEmpty() || !errorSpy2.isEmpty()); + if (errorSpy2.isEmpty()) { + QVERIFY(session2.isOpen()); + QVERIFY(session2.state() == QNetworkSession::Connected); + } QVERIFY(session.isOpen()); - QVERIFY(session2.isOpen()); QVERIFY(session.state() == QNetworkSession::Connected); - QVERIFY(session2.state() == QNetworkSession::Connected); #ifndef QT_NO_NETWORKINTERFACE #if !(defined(Q_OS_SYMBIAN) && defined(__WINS__)) // On Symbian emulator, the support for data bearers is limited QVERIFY(session.interface().isValid()); #endif - QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress()); - QCOMPARE(session.interface().index(), session2.interface().index()); + if (errorSpy2.isEmpty()) { + QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress()); + QCOMPARE(session.interface().index(), session2.interface().index()); + } #endif } sessionOpenedSpy2.clear(); - if (forceSessionStop) { + if (forceSessionStop && session2.isOpen()) { // Test forcing the second session to stop the interface. QNetworkSession::State previousState = session.state(); #ifdef Q_CC_NOKIAX86 @@ -922,15 +951,17 @@ void tst_QNetworkSession::sessionOpenCloseStop() #else bool expectStateChange = previousState != QNetworkSession::Disconnected; #endif - session2.stop(); + // QNetworkSession::stop() must result either closed() signal + // or error() signal QTRY_VERIFY(!sessionClosedSpy2.isEmpty() || !errorSpy2.isEmpty()); - QVERIFY(!session2.isOpen()); if (!errorSpy2.isEmpty()) { - QVERIFY(!errorSpy.isEmpty()); + // QNetworkSession::stop() resulted error() signal for session2 + // => also session should emit error() signal + QTRY_VERIFY(!errorSpy.isEmpty()); // check for SessionAbortedError QNetworkSession::SessionError error = @@ -950,9 +981,12 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(errorSpy.isEmpty()); QVERIFY(errorSpy2.isEmpty()); - + + // Wait for Disconnected state + QTRY_NOOP(session2.state() == QNetworkSession::Disconnected); + if (expectStateChange) - QTRY_VERIFY(stateChangedSpy2.count() >= 2 || !errorSpy2.isEmpty()); + QTRY_VERIFY(stateChangedSpy2.count() >= 1 || !errorSpy2.isEmpty()); if (!errorSpy2.isEmpty()) { QVERIFY(session2.state() == previousState); @@ -996,16 +1030,29 @@ void tst_QNetworkSession::sessionOpenCloseStop() state = qvariant_cast(stateChangedSpy2.at(3).at(0)); QVERIFY(state == QNetworkSession::Disconnected); + + QTRY_VERIFY(session.state() == QNetworkSession::Roaming || + session.state() == QNetworkSession::Connected || + session.state() == QNetworkSession::Disconnected); + QTRY_VERIFY(stateChangedSpy.count() > 0); - state = qvariant_cast(stateChangedSpy.at(0).at(0)); + state = qvariant_cast(stateChangedSpy.at(stateChangedSpy.count() - 1).at(0)); + if (state == QNetworkSession::Roaming) { - QTRY_VERIFY(!errorSpy.isEmpty() || stateChangedSpy.count() > 1); - if (stateChangedSpy.count() > 1 && - qvariant_cast(stateChangedSpy.at(1).at(0)) == - QNetworkSession::Connected) { - roamedSuccessfully = true; + QTRY_VERIFY(session.state() == QNetworkSession::Connected); + QTRY_VERIFY(session2.state() == QNetworkSession::Connected); + roamedSuccessfully = true; + } else if (state == QNetworkSession::Disconnected) { + QTRY_VERIFY(!errorSpy.isEmpty()); + QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); + } else if (state == QNetworkSession::Connected) { + QTRY_VERIFY(errorSpy.isEmpty()); + if (stateChangedSpy.count() > 1) { + state = qvariant_cast(stateChangedSpy.at(stateChangedSpy.count() - 2).at(0)); + QVERIFY(state == QNetworkSession::Roaming); } - } + roamedSuccessfully = true; + } if (roamedSuccessfully) { QString configId = session.sessionProperty("ActiveConfiguration").toString(); @@ -1013,37 +1060,36 @@ void tst_QNetworkSession::sessionOpenCloseStop() QNetworkSession session3(config); QSignalSpy errorSpy3(&session3, SIGNAL(error(QNetworkSession::SessionError))); QSignalSpy sessionOpenedSpy3(&session3, SIGNAL(opened())); - session3.open(); - session3.waitForOpened(); - + session3.waitForOpened(); if (session.isOpen()) QVERIFY(!sessionOpenedSpy3.isEmpty() || !errorSpy3.isEmpty()); - session.stop(); - QTRY_VERIFY(session.state() == QNetworkSession::Disconnected); - QTRY_VERIFY(session3.state() == QNetworkSession::Disconnected); } #ifndef Q_CC_NOKIAX86 if (!roamedSuccessfully) QVERIFY(!errorSpy.isEmpty()); #endif } else { - QCOMPARE(stateChangedSpy2.count(), 2); - - QNetworkSession::State state = - qvariant_cast(stateChangedSpy2.at(0).at(0)); - QVERIFY(state == QNetworkSession::Closing); - - state = qvariant_cast(stateChangedSpy2.at(1).at(0)); - QVERIFY(state == QNetworkSession::Disconnected); + QTest::qWait(2000); // Wait awhile to get all signals from platform + + if (stateChangedSpy2.count() == 2) { + QNetworkSession::State state = + qvariant_cast(stateChangedSpy2.at(0).at(0)); + QVERIFY(state == QNetworkSession::Closing); + state = qvariant_cast(stateChangedSpy2.at(1).at(0)); + QVERIFY(state == QNetworkSession::Disconnected); + } else { // Assume .count() == 1 + QCOMPARE(stateChangedSpy2.count(), 1); + QNetworkSession::State state = qvariant_cast(stateChangedSpy2.at(0).at(0)); + // Symbian version dependant. + QVERIFY(state == QNetworkSession::Disconnected); + } } QTRY_VERIFY(!sessionClosedSpy.isEmpty()); - QTRY_VERIFY(session.state() == QNetworkSession::Disconnected); - QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); } QVERIFY(errorSpy2.isEmpty()); @@ -1062,7 +1108,7 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(!session.isOpen()); #endif QVERIFY(!session2.isOpen()); - } else { + } else if (session2.isOpen()) { // Test closing the second session. { int stateChangedCountBeforeClose = stateChangedSpy2.count(); @@ -1161,11 +1207,15 @@ QDebug operator<<(QDebug debug, const QList &list) // at Discovered -state. void tst_QNetworkSession::outOfProcessSession() { - qDebug() << "START"; - + if (!testsToRun["outOfProcessSession"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } #if defined(Q_OS_SYMBIAN) && defined(__WINS__) QSKIP("Symbian emulator does not support two [QR]PRocesses linking a dll (QtBearer.dll) with global writeable static data.", SkipAll); #endif + updateConfigurations(); + QTest::qWait(2000); + QNetworkConfigurationManager manager; // Create a QNetworkConfigurationManager to detect configuration changes made in Lackey. This // is actually the essence of this testcase - to check that platform mediates/reflects changes @@ -1182,16 +1232,15 @@ void tst_QNetworkSession::outOfProcessSession() QLocalServer::removeServer("tst_qnetworksession"); oopServer.listen("tst_qnetworksession"); - qDebug() << "starting lackey"; QProcess lackey; lackey.start("lackey/lackey"); qDebug() << lackey.error() << lackey.errorString(); QVERIFY(lackey.waitForStarted()); - qDebug() << "waiting for connection"; + QVERIFY(oopServer.waitForNewConnection(-1)); QLocalSocket *oopSocket = oopServer.nextPendingConnection(); - qDebug() << "got connection"; + do { QByteArray output; @@ -1258,7 +1307,6 @@ void tst_QNetworkSession::outOfProcessSession() default: QSKIP("Lackey failed", SkipAll); } - qDebug("STOP"); } // A convinience / helper function for testcases. Return the first matching configuration. @@ -1269,6 +1317,7 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur // Refresh configurations and derive configurations matching given parameters. QNetworkConfigurationManager mgr; QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted())); + mgr.updateConfigurations(); QTRY_NOOP(updateSpy.count() == 1); if (updateSpy.count() != 1) { @@ -1277,8 +1326,7 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur } QList discoveredConfigs = mgr.allConfigurations(QNetworkConfiguration::Discovered); foreach(QNetworkConfiguration config, discoveredConfigs) { - if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { - // qDebug() << "Dumping config because is active: " << config.name(); + if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { discoveredConfigs.removeOne(config); } else if (config.type() != configType) { // qDebug() << "Dumping config because type (IAP/SNAP) mismatches: " << config.name(); @@ -1315,9 +1363,23 @@ void updateConfigurations() QTRY_NOOP(updateSpy.count() == 1); } +// A convinience-function: updates and prints all available confiurations and their states +void printConfigurations() +{ + QNetworkConfigurationManager manager; + QList allConfigs = + manager.allConfigurations(); + qDebug("tst_QNetworkSession::printConfigurations QNetworkConfigurationManager gives following configurations: "); + foreach(QNetworkConfiguration config, allConfigs) { + qDebug() << "Name of the configuration: " << config.name(); + qDebug() << "State of the configuration: " << config.state(); + } +} + // A convinience function for test-cases: opens the given configuration and return // true if it was done gracefully. bool openSession(QNetworkSession *session) { + bool result = true; QNetworkConfigurationManager mgr; QSignalSpy openedSpy(session, SIGNAL(opened())); QSignalSpy stateChangeSpy(session, SIGNAL(stateChanged(QNetworkSession::State))); @@ -1327,43 +1389,57 @@ bool openSession(QNetworkSession *session) { // active by some other session QNetworkConfiguration::StateFlags configInitState = session->configuration().state(); QNetworkSession::State sessionInitState = session->state(); + qDebug() << "tst_QNetworkSession::openSession() name of the configuration to be opened: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::openSession() state of the configuration to be opened: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::openSession() state of the session to be opened: " << session->state(); if (session->isOpen() || !session->sessionProperty("ActiveConfiguration").toString().isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: session was already open / active."); - return false; + result = false; } else { session->open(); session->waitForOpened(120000); // Bringing interfaces up and down may take time at platform } + QTest::qWait(5000); // Wait a moment to ensure all signals are propagated // Check that connection opening went by the book. Add checks here if more strictness needed. if (!session->isOpen()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::open() failed."); - return false; + result = false; } if (openedSpy.count() != 1) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::opened() - signal not received."); - return false; + result = false; } if (!errorSpy.isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::error() - signal was detected."); - return false; + result = false; } if (sessionInitState != QNetworkSession::Connected && stateChangeSpy.isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::stateChanged() - signals not detected."); - return false; + result = false; } if (configInitState != QNetworkConfiguration::Active && configChangeSpy.isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkConfigurationManager::configurationChanged() - signals not detected."); - return false; + result = false; } if (session->configuration().state() != QNetworkConfiguration::Active) { qDebug("tst_QNetworkSession::openSession() failure: session's configuration is not in 'Active' -state."); - return false; + qDebug() << "tst_QNetworkSession::openSession() state is: " << session->configuration().state(); + result = false; + } + if (result == false) { + qDebug() << "tst_QNetworkSession::openSession() opening session failed."; + } else { + qDebug() << "tst_QNetworkSession::openSession() opening session succeeded."; } - return true; + qDebug() << "tst_QNetworkSession::openSession() name of the configuration is: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::openSession() configuration state is: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::openSession() session state is: " << session->state(); + + return result; } // Helper function for closing opened session. Performs checks that @@ -1376,6 +1452,11 @@ bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) { qDebug("tst_QNetworkSession::closeSession() failure: NULL session given"); return false; } + + qDebug() << "tst_QNetworkSession::closeSession() name of the configuration to be closed: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::closeSession() state of the configuration to be closed: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::closeSession() state of the session to be closed: " << session->state(); + if (session->state() != QNetworkSession::Connected || !session->isOpen()) { qDebug("tst_QNetworkSession::closeSession() failure: session is not opened."); @@ -1387,38 +1468,48 @@ bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) { QSignalSpy sessionErrorSpy(session, SIGNAL(error(QNetworkSession::SessionError))); QSignalSpy configChangeSpy(&mgr, SIGNAL(configurationChanged(QNetworkConfiguration))); + bool result = true; session->close(); + QTest::qWait(5000); // Wait a moment so that all signals are propagated if (!sessionErrorSpy.isEmpty()) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::error() received."); - return false; + result = false; } if (sessionClosedSpy.count() != 1) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::closed() signal not received."); - return false; + result = false; } if (lastSessionOnConfiguration && sessionStateChangedSpy.isEmpty()) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::stateChanged() signals not received."); - return false; + result = false; } if (lastSessionOnConfiguration && session->state() != QNetworkSession::Disconnected) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession is not in Disconnected -state"); - return false; + result = false; } QTRY_NOOP(!configChangeSpy.isEmpty()); if (lastSessionOnConfiguration && configChangeSpy.isEmpty()) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkConfigurationManager::configurationChanged() - signal not detected."); - return false; + result = false; } if (lastSessionOnConfiguration && session->configuration().state() == QNetworkConfiguration::Active) { qDebug("tst_QNetworkSession::closeSession() failure: session's configuration is still in active state."); - return false; + result = false; } - return true; + if (result == false) { + qDebug() << "tst_QNetworkSession::closeSession() closing session failed."; + } else { + qDebug() << "tst_QNetworkSession::closeSession() closing session succeeded."; + } + qDebug() << "tst_QNetworkSession::closeSession() name of the configuration is: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::closeSession() configuration state is: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::closeSession() session state is: " << session->state(); + return result; } void tst_QNetworkSession::sessionAutoClose_data() -- cgit v0.12 From e6efa3ea81dff9eb0ade1c2ba868c272ccfcc958 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 13 May 2010 10:49:52 +1000 Subject: Bearer management changes from Qt Mobility. 9286bfcc43d38e0cb3bfd1d3f99ac7ab5d88b7e3 --- examples/network/bearermonitor/bearermonitor.cpp | 3 +++ examples/network/bearermonitor/sessionwidget.cpp | 12 ++++++++++-- examples/network/bearermonitor/sessionwidget.h | 5 ++++- examples/network/bearermonitor/sessionwidget.ui | 2 +- .../auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp | 7 +++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp index 4a6c6ff..0d98eff 100644 --- a/examples/network/bearermonitor/bearermonitor.cpp +++ b/examples/network/bearermonitor/bearermonitor.cpp @@ -255,6 +255,7 @@ void BearerMonitor::onlineStateChanged(bool isOnline) void BearerMonitor::registerNetwork() { QTreeWidgetItem *item = treeWidget->currentItem(); + if (!item) return; QNetworkConfiguration configuration = manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString()); @@ -276,6 +277,7 @@ void BearerMonitor::registerNetwork() void BearerMonitor::unregisterNetwork() { QTreeWidgetItem *item = treeWidget->currentItem(); + if (!item) return; QNetworkConfiguration configuration = manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString()); @@ -384,6 +386,7 @@ void BearerMonitor::createSessionFor(QTreeWidgetItem *item) void BearerMonitor::createNewSession() { QTreeWidgetItem *item = treeWidget->currentItem(); + if (!item) return; createSessionFor(item); } diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp index 443f4b2..3a8e5ea 100644 --- a/examples/network/bearermonitor/sessionwidget.cpp +++ b/examples/network/bearermonitor/sessionwidget.cpp @@ -59,7 +59,7 @@ SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *paren connect(session, SIGNAL(stateChanged(QNetworkSession::State)), this, SLOT(updateSession())); connect(session, SIGNAL(error(QNetworkSession::SessionError)), - this, SLOT(updateSession())); + this, SLOT(updateSessionError(QNetworkSession::SessionError))); updateSession(); @@ -105,7 +105,6 @@ void SessionWidget::deleteSession() void SessionWidget::updateSession() { updateSessionState(session->state()); - updateSessionError(session->error()); if (session->state() == QNetworkSession::Connected) statsTimer = startTimer(1000); @@ -128,12 +127,14 @@ void SessionWidget::updateSession() void SessionWidget::openSession() { + clearError(); session->open(); updateSession(); } void SessionWidget::openSyncSession() { + clearError(); session->open(); session->waitForOpened(); updateSession(); @@ -141,12 +142,14 @@ void SessionWidget::openSyncSession() void SessionWidget::closeSession() { + clearError(); session->close(); updateSession(); } void SessionWidget::stopSession() { + clearError(); session->stop(); updateSession(); } @@ -195,3 +198,8 @@ void SessionWidget::updateSessionError(QNetworkSession::SessionError error) errorString->setText(session->errorString()); } +void SessionWidget::clearError() +{ + lastError->clear(); + errorString->clear(); +} diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h index 5e9d62c..b299b47 100644 --- a/examples/network/bearermonitor/sessionwidget.h +++ b/examples/network/bearermonitor/sessionwidget.h @@ -63,7 +63,7 @@ public: private: void updateSessionState(QNetworkSession::State state); - void updateSessionError(QNetworkSession::SessionError error); + void clearError(); private Q_SLOTS: void openSession(); @@ -71,9 +71,12 @@ private Q_SLOTS: void closeSession(); void stopSession(); void updateSession(); + void updateSessionError(QNetworkSession::SessionError error); #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) void deleteSession(); #endif + + private: QNetworkSession *session; int statsTimer; diff --git a/examples/network/bearermonitor/sessionwidget.ui b/examples/network/bearermonitor/sessionwidget.ui index 45135f5..56a2d0e 100644 --- a/examples/network/bearermonitor/sessionwidget.ui +++ b/examples/network/bearermonitor/sessionwidget.ui @@ -195,7 +195,7 @@ - Error String + Error String: diff --git a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp index ce3acb7..a3cccb2 100644 --- a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp +++ b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp @@ -45,6 +45,13 @@ #include #include +/* + Although this unit test doesn't use QNetworkAccessManager + this include is used to ensure that bearer continues to compile against + Qt 4.7+ which has a QNetworkConfiguration enabled QNetworkAccessManager +*/ +#include + #if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) #include #include -- cgit v0.12 From e75161c4d54406d137f34b9f54fed853c16a6269 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 13 May 2010 10:51:13 +1000 Subject: Cherry pick fix for MOBILITY-828 from Qt Mobility. Change 29776be110cdc121eb5a22446be6adae8ff6f4d8 from Qt Mobility. --- .../bearer/symbian/qnetworksession_impl.cpp | 4 +-- .../qnetworksession/test/tst_qnetworksession.cpp | 30 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 04853c4..f09c73a 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) - : CActive(CActive::EPriorityStandard), engine(engine), + : CActive(CActive::EPriorityUserInput), engine(engine), ipConnectionNotifier(0), iHandleStateNotificationsFromManager(false), iFirstSync(true), iStoppedByUser(false), iClosedByUser(false), iDeprecatedConnectionId(0), iError(QNetworkSession::UnknownSessionError), iALREnabled(0), iConnectInBackground(false) @@ -1383,7 +1383,7 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne } ConnectionProgressNotifier::ConnectionProgressNotifier(QNetworkSessionPrivateImpl& owner, RConnection& connection) - : CActive(CActive::EPriorityStandard), iOwner(owner), iConnection(connection) + : CActive(CActive::EPriorityUserInput), iOwner(owner), iConnection(connection) { CActiveScheduler::Add(this); } diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index 8ab9da2..934a50e 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -263,10 +263,6 @@ void tst_QNetworkSession::robustnessBombing() testSession.accept(); testSession.ignore(); testSession.reject(); - quint64 temp; - temp = testSession.bytesWritten(); - temp = testSession.bytesReceived(); - temp = testSession.activeTime(); } @@ -704,7 +700,20 @@ void tst_QNetworkSession::userChoiceSession() session.open(); +#if defined(Q_OS_SYMBIAN) + // Opening & closing multiple connections in a row sometimes + // results hanging of connection opening on Symbian devices + // => If first open fails, wait a moment and try again. + if (!session.waitForOpened()) { + qDebug("**** Session open Timeout - Wait 5 seconds and try once again ****"); + session.close(); + QTest::qWait(5000); // Wait a while before trying to open session again + session.open(); + session.waitForOpened(); + } +#else session.waitForOpened(); +#endif if (session.isOpen()) QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty()); @@ -843,7 +852,20 @@ void tst_QNetworkSession::sessionOpenCloseStop() session.open(); +#if defined(Q_OS_SYMBIAN) + // Opening & closing multiple connections in a row sometimes + // results hanging of connection opening on Symbian devices + // => If first open fails, wait a moment and try again. + if (!session.waitForOpened()) { + qDebug("**** Session open Timeout - Wait 5 seconds and try once again ****"); + session.close(); + QTest::qWait(5000); // Wait a while before trying to open session again + session.open(); + session.waitForOpened(); + } +#else session.waitForOpened(); +#endif if (session.isOpen()) QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty()); -- cgit v0.12 From 608d39c9ffee622114d9bc178d5e8ad3d1eadfb5 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 13 May 2010 10:54:01 +1000 Subject: Cherry pick fix for MOBILITY-962 from Qt Mobility. 6ea1caf2babc68d366fb6d3dc215c1bb18a76368 --- tests/manual/bearerex/bearerex.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index 19246a2..bf60dd1 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -300,8 +300,12 @@ SessionTab::SessionTab(QNetworkConfiguration* apNetworkConfiguration, SessionTab::~SessionTab() { + // Need to be nulled, because modal dialogs may return after destruction of this object and + // use already released resources. delete m_NetworkSession; + m_NetworkSession = NULL; delete m_http; + m_http = NULL; } void SessionTab::on_createQHttpButton_clicked() @@ -551,10 +555,16 @@ void SessionTab::done(bool error) msgBox.setText(QString("HTTP request finished successfully.\nReceived ")+QString::number(result.length())+QString(" bytes.")); } msgBox.exec(); - - sentRecDataLineEdit->setText(QString::number(m_NetworkSession->bytesWritten())+ - QString(" / ")+ - QString::number(m_NetworkSession->bytesReceived())); + // Check if the networksession still exists - it may have gone after returning from + // the modal dialog (in the case that app has been closed, and deleting QHttp will + // trigger the done() invokation). + if (m_NetworkSession) { + sentRecDataLineEdit->setText(QString::number(m_NetworkSession->bytesWritten())+ + QString(" / ")+ + QString::number(m_NetworkSession->bytesReceived())); + } else { + sentRecDataLineEdit->setText("Data amounts not available."); + } } // End of file -- cgit v0.12 From 75c4dea93ad415dd9c79cb57ec5598e38789b28d Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 13 May 2010 10:55:06 +1000 Subject: Cherry pick fix for MOBILITY-932 from Qt Mobility. 807e9868152bb06d37895a5e3d1a3e49908a6036 --- .../bearer/symbian/qnetworksession_impl.cpp | 32 ++++++++++------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index f09c73a..ce2203d 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -523,13 +523,6 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) // when reporting. iClosedByUser = true; - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(activeConfig)); - - symbianConfig->mutex.lock(); - TUint activeIap = symbianConfig->numericId; - symbianConfig->mutex.unlock(); - isOpen = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); @@ -554,19 +547,12 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) // Close global 'Open C' RConnection setdefaultif(0); -#ifdef Q_CC_NOKIAX86 - if ((allowSignals && iapClientCount(activeIap) <= 0) || -#else - if ((allowSignals && iapClientCount(activeIap) <= 1) || -#endif - (publicConfig.type() == QNetworkConfiguration::UserChoice)) { + if (publicConfig.type() == QNetworkConfiguration::UserChoice) { newState(QNetworkSession::Closing); + newState(QNetworkSession::Disconnected); } if (allowSignals) { - if (publicConfig.type() == QNetworkConfiguration::UserChoice) { - newState(QNetworkSession::Disconnected); - } emit closed(); } } @@ -599,7 +585,7 @@ void QNetworkSessionPrivateImpl::stop() } TUint numSubConnections; // Not used but needed by GetConnectionInfo i/f TUint connectionId; - for (TInt i = 1; i <= count; ++i) { + for (TUint i = 1; i <= count; ++i) { // Get (connection monitor's assigned) connection ID TInt ret = iConnectionMonitor.GetConnectionInfo(i, connectionId, numSubConnections); if (ret == KErrNone) { @@ -1236,7 +1222,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint QMutexLocker configLocker(&symbianConfig->mutex); if (symbianConfig->numericId == accessPointId) { - if (newState == QNetworkSession::Connected) { + if (newState != QNetworkSession::Disconnected) { state = newState; #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed D to: " << state; @@ -1256,6 +1242,16 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint #endif emit stateChanged(state); retVal = true; + } else if (config.state() == QNetworkConfiguration::Active) { + // Connection to used IAP was closed, but there is another + // IAP that's active in used SNAP + // => Change state back to Connected + state = QNetworkSession::Connected; + emit stateChanged(state); + retVal = true; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed F to: " << state; +#endif } } } -- cgit v0.12 From 5cd963d2628ed7c01d331cdad03b4d77161c8b93 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 May 2010 13:15:08 +1000 Subject: Fix crash in ParentAnimation. copyOriginals plays with the order of the revertList, which messes up the assumptions of ParentAnimation. The full fix will require some rearchitecting of how the states and transitions handle "related" actions, but for now this fixes the crash. Reverting to the base state has also been fixed. Task-number: QTBUG-10671, QTBUG-10676 --- src/declarative/util/qdeclarativeanimation.cpp | 14 +++++++------- src/declarative/util/qdeclarativepropertychanges.cpp | 4 ++-- src/declarative/util/qdeclarativestate.cpp | 3 ++- src/declarative/util/qdeclarativestate_p.h | 1 + src/declarative/util/qdeclarativestateoperations.cpp | 4 ++-- src/declarative/util/qdeclarativestateoperations_p.h | 3 ++- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 0f7c946..67440b6 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -2536,13 +2536,13 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, viaData->pc << vpc; viaData->actions << myAction; QDeclarativeAction dummyAction; - QDeclarativeAction &xAction = pc->xIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &yAction = pc->yIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &sAction = pc->scaleIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &rAction = pc->rotationIsSet() ? actions[++i] : dummyAction; + QDeclarativeAction &xAction = pc->xIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarativeAction &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarativeAction &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarativeAction &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; bool forward = (direction == QDeclarativeAbstractAnimation::Forward); QDeclarativeItem *target = pc->object(); - QDeclarativeItem *targetParent = forward ? pc->parent() : pc->originalParent(); + QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent(); //### this mirrors the logic in QDeclarativeParentChange. bool ok; @@ -2583,9 +2583,9 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) { qreal w = target->width(); qreal h = target->height(); - if (pc->widthIsSet()) + if (pc->widthIsSet() && i < actions.size() - 1) w = actions[++i].toValue.toReal(); - if (pc->heightIsSet()) + if (pc->heightIsSet() && i < actions.size() - 1) h = actions[++i].toValue.toReal(); const QPointF &transformOrigin = d->computeTransformOrigin(target->transformOrigin(), w,h); diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index a22c756..12fef36 100644 --- a/src/declarative/util/qdeclarativepropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -179,7 +179,7 @@ public: reverseExpression = rewindExpression; } - virtual void copyOriginals(QDeclarativeActionEvent *other) + /*virtual void copyOriginals(QDeclarativeActionEvent *other) { QDeclarativeReplaceSignalHandler *rsh = static_cast(other); saveCurrentValues(); @@ -190,7 +190,7 @@ public: ownedExpression = rsh->ownedExpression; rsh->ownedExpression = 0; } - } + }*/ virtual void rewind() { ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression); diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index ea209aa..b5f7900 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -390,12 +390,13 @@ void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransit if (action.event->override(event)) { found = true; - if (action.event != d->revertList.at(jj).event) { + if (action.event != d->revertList.at(jj).event && action.event->needsCopy()) { action.event->copyOriginals(d->revertList.at(jj).event); QDeclarativeSimpleAction r(action); additionalReverts << r; d->revertList.removeAt(jj); + --jj; } else if (action.event->isRewindable()) //###why needed? action.event->saveCurrentValues(); diff --git a/src/declarative/util/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h index 0ba67b0..25715c6 100644 --- a/src/declarative/util/qdeclarativestate_p.h +++ b/src/declarative/util/qdeclarativestate_p.h @@ -96,6 +96,7 @@ public: virtual bool isReversable(); virtual void reverse(Reason reason = ActualChange); virtual void saveOriginals() {} + virtual bool needsCopy() { return false; } virtual void copyOriginals(QDeclarativeActionEvent *) {} virtual bool isRewindable() { return isReversable(); } diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index a93a25d..a6fcaf3 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -408,7 +408,7 @@ void QDeclarativeParentChange::saveOriginals() d->origStackBefore = d->rewindStackBefore; } -void QDeclarativeParentChange::copyOriginals(QDeclarativeActionEvent *other) +/*void QDeclarativeParentChange::copyOriginals(QDeclarativeActionEvent *other) { Q_D(QDeclarativeParentChange); QDeclarativeParentChange *pc = static_cast(other); @@ -417,7 +417,7 @@ void QDeclarativeParentChange::copyOriginals(QDeclarativeActionEvent *other) d->origStackBefore = pc->d_func()->rewindStackBefore; saveCurrentValues(); -} +}*/ void QDeclarativeParentChange::execute(Reason) { diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h index e22c1e2..21a86f5 100644 --- a/src/declarative/util/qdeclarativestateoperations_p.h +++ b/src/declarative/util/qdeclarativestateoperations_p.h @@ -107,7 +107,7 @@ public: virtual ActionList actions(); virtual void saveOriginals(); - virtual void copyOriginals(QDeclarativeActionEvent*); + //virtual void copyOriginals(QDeclarativeActionEvent*); virtual void execute(Reason reason = ActualChange); virtual bool isReversable(); virtual void reverse(Reason reason = ActualChange); @@ -277,6 +277,7 @@ public: virtual bool override(QDeclarativeActionEvent*other); virtual bool changesBindings(); virtual void saveOriginals(); + virtual bool needsCopy() { return true; } virtual void copyOriginals(QDeclarativeActionEvent*); virtual void clearBindings(); virtual void rewind(); -- cgit v0.12 From bea52aaaaf188293a5e235d5b5f96b386efba5ac Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 14 May 2010 13:32:49 +1000 Subject: Add a "priority" property to Keys and KeyNavigation Allows intercepting keys before or after normal item key processing. Task-number: QTBUG-10467 --- .../graphicsitems/qdeclarativegridview.cpp | 7 +- src/declarative/graphicsitems/qdeclarativeitem.cpp | 200 ++++++++++++++++++--- src/declarative/graphicsitems/qdeclarativeitem.h | 4 + src/declarative/graphicsitems/qdeclarativeitem_p.h | 37 +++- .../graphicsitems/qdeclarativelistview.cpp | 7 +- .../graphicsitems/qdeclarativetextedit.cpp | 9 +- .../graphicsitems/qdeclarativetextinput.cpp | 3 + .../qdeclarativeitem/data/keyspriority.qml | 9 + .../qdeclarativeitem/tst_qdeclarativeitem.cpp | 131 +++++++++++++- 9 files changed, 361 insertions(+), 46 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index fe78c84..e1874b8 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1651,6 +1651,9 @@ qreal QDeclarativeGridView::maxXExtent() const void QDeclarativeGridView::keyPressEvent(QKeyEvent *event) { Q_D(QDeclarativeGridView); + keyPressPreHandler(event); + if (event->isAccepted()) + return; if (d->model && d->model->count() && d->interactive) { d->moveReason = QDeclarativeGridViewPrivate::SetIndex; int oldCurrent = currentIndex(); @@ -1676,10 +1679,8 @@ void QDeclarativeGridView::keyPressEvent(QKeyEvent *event) } } d->moveReason = QDeclarativeGridViewPrivate::Other; - QDeclarativeFlickable::keyPressEvent(event); - if (event->isAccepted()) - return; event->ignore(); + QDeclarativeFlickable::keyPressEvent(event); } /*! diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index f251ba1..9547884 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -375,7 +375,7 @@ void QDeclarativeContents::childAdded(QDeclarativeItem *item) } QDeclarativeItemKeyFilter::QDeclarativeItemKeyFilter(QDeclarativeItem *item) -: m_next(0) +: m_processPost(false), m_next(0) { QDeclarativeItemPrivate *p = item?static_cast(QGraphicsItemPrivate::get(item)):0; @@ -389,19 +389,19 @@ QDeclarativeItemKeyFilter::~QDeclarativeItemKeyFilter() { } -void QDeclarativeItemKeyFilter::keyPressed(QKeyEvent *event) +void QDeclarativeItemKeyFilter::keyPressed(QKeyEvent *event, bool post) { - if (m_next) m_next->keyPressed(event); + if (m_next) m_next->keyPressed(event, post); } -void QDeclarativeItemKeyFilter::keyReleased(QKeyEvent *event) +void QDeclarativeItemKeyFilter::keyReleased(QKeyEvent *event, bool post) { - if (m_next) m_next->keyReleased(event); + if (m_next) m_next->keyReleased(event, post); } -void QDeclarativeItemKeyFilter::inputMethodEvent(QInputMethodEvent *event) +void QDeclarativeItemKeyFilter::inputMethodEvent(QInputMethodEvent *event, bool post) { - if (m_next) m_next->inputMethodEvent(event); + if (m_next) m_next->inputMethodEvent(event, post); } QVariant QDeclarativeItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const @@ -463,9 +463,11 @@ void QDeclarativeItemKeyFilter::componentComplete() } \endcode - KeyNavigation receives key events after the item it is attached to. + By default KeyNavigation receives key events after the item it is attached to. If the item accepts an arrow key event, the KeyNavigation - attached property will not receive an event for that key. + attached property will not receive an event for that key. Setting the + \l priority property to KeyNavigation.BeforeItem allows handling + of the key events before normal item processing. If an item has been set for a direction and the KeyNavigation attached property receives the corresponding @@ -490,6 +492,7 @@ QDeclarativeKeyNavigationAttached::QDeclarativeKeyNavigationAttached(QObject *pa : QObject(*(new QDeclarativeKeyNavigationAttachedPrivate), parent), QDeclarativeItemKeyFilter(qobject_cast(parent)) { + m_processPost = true; } QDeclarativeKeyNavigationAttached * @@ -576,12 +579,45 @@ void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i) emit changed(); } -void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event) +/*! + \qmlproperty enumeration KeyNavigation::priority + + This property determines whether the keys are processed before + or after the attached item's own key handling. + + \list + \o KeyNavigation.BeforeItem - process the key events before normal + item key processing. If the event is accepted it will not + be passed on to the item. + \o KeyNavigation.AfterItem (default) - process the key events after normal item key + handling. If the item accepts the key event it will not be + handled by the KeyNavigation attached property handler. + \endlist +*/ +QDeclarativeKeyNavigationAttached::Priority QDeclarativeKeyNavigationAttached::priority() const { - Q_D(QDeclarativeKeyNavigationAttached); + return m_processPost ? AfterItem : BeforeItem; +} + +void QDeclarativeKeyNavigationAttached::setPriority(Priority order) +{ + bool processPost = order == AfterItem; + if (processPost != m_processPost) { + m_processPost = processPost; + emit priorityChanged(); + } +} +void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event, bool post) +{ + Q_D(QDeclarativeKeyNavigationAttached); event->ignore(); + if (post != m_processPost) { + QDeclarativeItemKeyFilter::keyPressed(event, post); + return; + } + switch(event->key()) { case Qt::Key_Left: if (d->left) { @@ -623,15 +659,19 @@ void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event) break; } - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event); + if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event, post); } -void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event) +void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) { Q_D(QDeclarativeKeyNavigationAttached); - event->ignore(); + if (post != m_processPost) { + QDeclarativeItemKeyFilter::keyReleased(event, post); + return; + } + switch(event->key()) { case Qt::Key_Left: if (d->left) { @@ -667,7 +707,7 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event) break; } - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event); + if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post); } /*! @@ -709,6 +749,28 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event) See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. + If priority is Keys.BeforeItem (default) the order of key event processing is: + + \list 1 + \o Items specified in \c forwardTo + \o specific key handlers, e.g. onReturnPressed + \o onKeyPress, onKeyRelease handlers + \o Item specific key handling, e.g. TextInput key handling + \o parent item + \endlist + + If priority is Keys.AfterItem the order of key event processing is: + \list 1 + \o Item specific key handling, e.g. TextInput key handling + \o Items specified in \c forwardTo + \o specific key handlers, e.g. onReturnPressed + \o onKeyPress, onKeyRelease handlers + \o parent item + \endlist + + If the event is accepted during any of the above steps, key + propagation stops. + \sa KeyEvent, {KeyNavigation}{KeyNavigation attached property} */ @@ -720,6 +782,22 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event) */ /*! + \qmlproperty enumeration Keys::priority + + This property determines whether the keys are processed before + or after the attached item's own key handling. + + \list + \o Keys.BeforeItem (default) - process the key events before normal + item key processing. If the event is accepted it will not + be passed on to the item. + \o Keys.AfterItem - process the key events after normal item key + handling. If the item accepts the key event it will not be + handled by the Keys attached property handler. + \endlist +*/ + +/*! \qmlproperty list Keys::forwardTo This property provides a way to forward key presses, key releases, and keyboard input @@ -1039,6 +1117,7 @@ QDeclarativeKeysAttached::QDeclarativeKeysAttached(QObject *parent) QDeclarativeItemKeyFilter(qobject_cast(parent)) { Q_D(QDeclarativeKeysAttached); + m_processPost = false; d->item = qobject_cast(parent); } @@ -1046,6 +1125,20 @@ QDeclarativeKeysAttached::~QDeclarativeKeysAttached() { } +QDeclarativeKeysAttached::Priority QDeclarativeKeysAttached::priority() const +{ + return m_processPost ? AfterItem : BeforeItem; +} + +void QDeclarativeKeysAttached::setPriority(Priority order) +{ + bool processPost = order == AfterItem; + if (processPost != m_processPost) { + m_processPost = processPost; + emit priorityChanged(); + } +} + void QDeclarativeKeysAttached::componentComplete() { Q_D(QDeclarativeKeysAttached); @@ -1060,11 +1153,12 @@ void QDeclarativeKeysAttached::componentComplete() } } -void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event) +void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event, bool post) { Q_D(QDeclarativeKeysAttached); - if (!d->enabled || d->inPress) { + if (post != m_processPost || !d->enabled || d->inPress) { event->ignore(); + QDeclarativeItemKeyFilter::keyPressed(event, post); return; } @@ -1099,14 +1193,15 @@ void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event) emit pressed(&ke); event->setAccepted(ke.isAccepted()); - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event); + if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event, post); } -void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event) +void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event, bool post) { Q_D(QDeclarativeKeysAttached); - if (!d->enabled || d->inRelease) { + if (post != m_processPost || !d->enabled || d->inRelease) { event->ignore(); + QDeclarativeItemKeyFilter::keyReleased(event, post); return; } @@ -1129,13 +1224,13 @@ void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event) emit released(&ke); event->setAccepted(ke.isAccepted()); - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event); + if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post); } -void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event) +void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post) { Q_D(QDeclarativeKeysAttached); - if (d->item && !d->inIM && d->item->scene()) { + if (post == m_processPost && d->item && !d->inIM && d->item->scene()) { d->inIM = true; for (int ii = 0; ii < d->targets.count(); ++ii) { QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); @@ -1150,7 +1245,7 @@ void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event) } d->inIM = false; } - if (!event->isAccepted()) QDeclarativeItemKeyFilter::inputMethodEvent(event); + if (!event->isAccepted()) QDeclarativeItemKeyFilter::inputMethodEvent(event, post); } class QDeclarativeItemAccessor : public QGraphicsItem @@ -1822,8 +1917,11 @@ void QDeclarativeItemPrivate::removeItemChangeListener(QDeclarativeItemChangeLis void QDeclarativeItem::keyPressEvent(QKeyEvent *event) { Q_D(QDeclarativeItem); + keyPressPreHandler(event); + if (event->isAccepted()) + return; if (d->keyHandler) - d->keyHandler->keyPressed(event); + d->keyHandler->keyPressed(event, true); else event->ignore(); } @@ -1832,8 +1930,11 @@ void QDeclarativeItem::keyPressEvent(QKeyEvent *event) void QDeclarativeItem::keyReleaseEvent(QKeyEvent *event) { Q_D(QDeclarativeItem); + keyReleasePreHandler(event); + if (event->isAccepted()) + return; if (d->keyHandler) - d->keyHandler->keyReleased(event); + d->keyHandler->keyReleased(event, true); else event->ignore(); } @@ -1842,8 +1943,11 @@ void QDeclarativeItem::keyReleaseEvent(QKeyEvent *event) void QDeclarativeItem::inputMethodEvent(QInputMethodEvent *event) { Q_D(QDeclarativeItem); + inputMethodPreHandler(event); + if (event->isAccepted()) + return; if (d->keyHandler) - d->keyHandler->inputMethodEvent(event); + d->keyHandler->inputMethodEvent(event, true); else event->ignore(); } @@ -1862,6 +1966,37 @@ QVariant QDeclarativeItem::inputMethodQuery(Qt::InputMethodQuery query) const return v; } +void QDeclarativeItem::keyPressPreHandler(QKeyEvent *event) +{ + Q_D(QDeclarativeItem); + if (d->keyHandler && !d->doneEventPreHandler) + d->keyHandler->keyPressed(event, false); + else + event->ignore(); + d->doneEventPreHandler = true; +} + +void QDeclarativeItem::keyReleasePreHandler(QKeyEvent *event) +{ + Q_D(QDeclarativeItem); + if (d->keyHandler && !d->doneEventPreHandler) + d->keyHandler->keyReleased(event, false); + else + event->ignore(); + d->doneEventPreHandler = true; +} + +void QDeclarativeItem::inputMethodPreHandler(QInputMethodEvent *event) +{ + Q_D(QDeclarativeItem); + if (d->keyHandler && !d->doneEventPreHandler) + d->keyHandler->inputMethodEvent(event, false); + else + event->ignore(); + d->doneEventPreHandler = true; +} + + /*! \internal */ @@ -2976,6 +3111,17 @@ void QDeclarativeItem::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidg */ bool QDeclarativeItem::event(QEvent *ev) { + Q_D(QDeclarativeItem); + switch (ev->type()) { + case QEvent::KeyPress: + case QEvent::KeyRelease: + case QEvent::InputMethod: + d->doneEventPreHandler = false; + break; + default: + break; + } + return QGraphicsObject::event(ev); } diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h index 3b05b09..29fd241 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.h +++ b/src/declarative/graphicsitems/qdeclarativeitem.h @@ -178,6 +178,10 @@ protected: virtual void keyReleaseEvent(QKeyEvent *event); virtual void inputMethodEvent(QInputMethodEvent *); virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; + void keyPressPreHandler(QKeyEvent *); + void keyReleasePreHandler(QKeyEvent *); + void inputMethodPreHandler(QInputMethodEvent *); + virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 516d6d0..15b34f0 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -124,7 +124,7 @@ public: _stateGroup(0), origin(QDeclarativeItem::Center), widthValid(false), heightValid(false), _componentComplete(true), _keepMouse(false), - smooth(false), transformOriginDirty(true), keyHandler(0), + smooth(false), transformOriginDirty(true), doneEventPreHandler(false), keyHandler(0), mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0) { QGraphicsItemPrivate::acceptedMouseButtons = 0; @@ -263,6 +263,7 @@ public: bool _keepMouse:1; bool smooth:1; bool transformOriginDirty : 1; + bool doneEventPreHandler : 1; QDeclarativeItemKeyFilter *keyHandler; @@ -324,12 +325,14 @@ public: QDeclarativeItemKeyFilter(QDeclarativeItem * = 0); virtual ~QDeclarativeItemKeyFilter(); - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); - virtual void inputMethodEvent(QInputMethodEvent *event); + virtual void keyPressed(QKeyEvent *event, bool post); + virtual void keyReleased(QKeyEvent *event, bool post); + virtual void inputMethodEvent(QInputMethodEvent *event, bool post); virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; virtual void componentComplete(); + bool m_processPost; + private: QDeclarativeItemKeyFilter *m_next; }; @@ -359,6 +362,9 @@ class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeIte Q_PROPERTY(QDeclarativeItem *down READ down WRITE setDown NOTIFY changed) Q_PROPERTY(QDeclarativeItem *tab READ tab WRITE setTab NOTIFY changed) Q_PROPERTY(QDeclarativeItem *backtab READ backtab WRITE setBacktab NOTIFY changed) + Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged) + + Q_ENUMS(Priority) public: QDeclarativeKeyNavigationAttached(QObject * = 0); @@ -376,14 +382,19 @@ public: QDeclarativeItem *backtab() const; void setBacktab(QDeclarativeItem *); + enum Priority { BeforeItem, AfterItem }; + Priority priority() const; + void setPriority(Priority); + static QDeclarativeKeyNavigationAttached *qmlAttachedProperties(QObject *); Q_SIGNALS: void changed(); + void priorityChanged(); private: - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); + virtual void keyPressed(QKeyEvent *event, bool post); + virtual void keyReleased(QKeyEvent *event, bool post); }; class QDeclarativeKeysAttachedPrivate : public QObjectPrivate @@ -423,6 +434,9 @@ class QDeclarativeKeysAttached : public QObject, public QDeclarativeItemKeyFilte Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(QDeclarativeListProperty forwardTo READ forwardTo) + Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged) + + Q_ENUMS(Priority) public: QDeclarativeKeysAttached(QObject *parent=0); @@ -437,6 +451,10 @@ public: } } + enum Priority { BeforeItem, AfterItem}; + Priority priority() const; + void setPriority(Priority); + QDeclarativeListProperty forwardTo() { Q_D(QDeclarativeKeysAttached); return QDeclarativeListProperty(this, d->targets); @@ -448,6 +466,7 @@ public: Q_SIGNALS: void enabledChanged(); + void priorityChanged(); void pressed(QDeclarativeKeyEvent *event); void released(QDeclarativeKeyEvent *event); void digit0Pressed(QDeclarativeKeyEvent *event); @@ -492,9 +511,9 @@ Q_SIGNALS: void volumeDownPressed(QDeclarativeKeyEvent *event); private: - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); - virtual void inputMethodEvent(QInputMethodEvent *); + virtual void keyPressed(QKeyEvent *event, bool post); + virtual void keyReleased(QKeyEvent *event, bool post); + virtual void inputMethodEvent(QInputMethodEvent *, bool post); virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; const QByteArray keyToSignal(int key) { diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 46e9ce3..bd4c386 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -2263,6 +2263,9 @@ qreal QDeclarativeListView::maxXExtent() const void QDeclarativeListView::keyPressEvent(QKeyEvent *event) { Q_D(QDeclarativeListView); + keyPressPreHandler(event); + if (event->isAccepted()) + return; if (d->model && d->model->count() && d->interactive) { if ((d->orient == QDeclarativeListView::Horizontal && event->key() == Qt::Key_Left) @@ -2287,10 +2290,8 @@ void QDeclarativeListView::keyPressEvent(QKeyEvent *event) } } } - QDeclarativeFlickable::keyPressEvent(event); - if (event->isAccepted()) - return; event->ignore(); + QDeclarativeFlickable::keyPressEvent(event); } /*! diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index db20da8..7f71dd2 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -858,8 +858,9 @@ Handles the given key \a event. void QDeclarativeTextEdit::keyPressEvent(QKeyEvent *event) { Q_D(QDeclarativeTextEdit); - d->control->processEvent(event, QPointF(0, 0)); - + keyPressPreHandler(event); + if (!event->isAccepted()) + d->control->processEvent(event, QPointF(0, 0)); if (!event->isAccepted()) QDeclarativePaintedItem::keyPressEvent(event); } @@ -871,7 +872,9 @@ Handles the given key \a event. void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event) { Q_D(QDeclarativeTextEdit); - d->control->processEvent(event, QPointF(0, 0)); + keyReleasePreHandler(event); + if (!event->isAccepted()) + d->control->processEvent(event, QPointF(0, 0)); if (!event->isAccepted()) QDeclarativePaintedItem::keyReleaseEvent(event); } diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index afbaaac..054fefd 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -863,6 +863,9 @@ void QDeclarativeTextInputPrivate::focusChanged(bool hasFocus) void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev) { Q_D(QDeclarativeTextInput); + keyPressPreHandler(ev); + if (ev->isAccepted()) + return; if (((ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down) && ev->modifiers() == Qt::NoModifier) // Don't allow MacOSX up/down support, and we don't allow a completer. || (((d->control->cursor() == 0 && ev->key() == Qt::Key_Left) || (d->control->cursor() == d->control->text().length() diff --git a/tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml b/tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml new file mode 100644 index 0000000..171536b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml @@ -0,0 +1,9 @@ +import Qt 4.7 +import Test 1.0 + +KeyTestItem { + focus: true + Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) + Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } + Keys.priority: keysTestObject.processLast ? Keys.AfterItem : Keys.BeforeItem +} diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index f4edeb2..ecc813e 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -55,7 +55,9 @@ public: tst_QDeclarativeItem(); private slots: + void initTestCase(); void keys(); + void keysProcessingOrder(); void keyNavigation(); void smooth(); void clip(); @@ -79,8 +81,11 @@ private: class KeysTestObject : public QObject { Q_OBJECT + + Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged) + public: - KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0) {} + KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {} void reset() { mKey = 0; @@ -89,6 +94,14 @@ public: mForwardedKey = 0; } + bool processLast() const { return mLast; } + void setProcessLast(bool b) { + if (b != mLast) { + mLast = b; + emit processLastChanged(); + } + } + public slots: void keyPress(int key, QString text, int modifiers) { mKey = key; @@ -104,20 +117,73 @@ public slots: mForwardedKey = key; } +signals: + void processLastChanged(); + public: int mKey; QString mText; int mModifiers; int mForwardedKey; + bool mLast; private: }; +class KeyTestItem : public QDeclarativeItem +{ + Q_OBJECT +public: + KeyTestItem(QDeclarativeItem *parent=0) : QDeclarativeItem(parent), mKey(0) {} + +protected: + void keyPressEvent(QKeyEvent *e) { + keyPressPreHandler(e); + if (e->isAccepted()) + return; + + mKey = e->key(); + + if (e->key() == Qt::Key_A) + e->accept(); + else + e->ignore(); + + if (!e->isAccepted()) + QDeclarativeItem::keyPressEvent(e); + } + + void keyReleaseEvent(QKeyEvent *e) { + keyReleasePreHandler(e); + + if (e->isAccepted()) + return; + + if (e->key() == Qt::Key_B) + e->accept(); + else + e->ignore(); + + if (!e->isAccepted()) + QDeclarativeItem::keyReleaseEvent(e); + } + +public: + int mKey; +}; + +QML_DECLARE_TYPE(KeyTestItem); + tst_QDeclarativeItem::tst_QDeclarativeItem() { } +void tst_QDeclarativeItem::initTestCase() +{ + qmlRegisterType("Test",1,0,"KeyTestItem"); +} + void tst_QDeclarativeItem::keys() { QDeclarativeView *canvas = new QDeclarativeView(0); @@ -214,6 +280,69 @@ void tst_QDeclarativeItem::keys() QCOMPARE(testObject->mKey, 0); QVERIFY(!key.isAccepted()); + canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_Return)); + QVERIFY(key.isAccepted()); + + delete canvas; + delete testObject; +} + +void tst_QDeclarativeItem::keysProcessingOrder() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setFixedSize(240,320); + + KeysTestObject *testObject = new KeysTestObject; + canvas->rootContext()->setContextProperty("keysTestObject", testObject); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keyspriority.qml")); + canvas->show(); + qApp->processEvents(); + + KeyTestItem *testItem = qobject_cast(canvas->rootObject()); + QVERIFY(testItem); + + QEvent wa(QEvent::WindowActivate); + QApplication::sendEvent(canvas, &wa); + QFocusEvent fe(QEvent::FocusIn); + QApplication::sendEvent(canvas, &fe); + + QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_A)); + QCOMPARE(testObject->mText, QLatin1String("A")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + testObject->setProcessLast(true); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, 0); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_B)); + QCOMPARE(testObject->mText, QLatin1String("B")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(!key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, 0); + QVERIFY(key.isAccepted()); + delete canvas; delete testObject; } -- cgit v0.12 From 645b9ee9dd6e0576542cc61872ecedb408ca8a89 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 14 May 2010 13:45:08 +1000 Subject: Add Qt.include() method for scoped inclusion of JavaScript files --- src/declarative/qml/qdeclarativeinclude.cpp | 255 +++++++++++++++++++++ src/declarative/qml/qdeclarativeinclude_p.h | 112 +++++++++ .../qdeclarativeecmascript/data/blank.js | 0 .../qdeclarativeecmascript/data/exception.js | 1 + .../qdeclarativeecmascript/data/include.js | 8 + .../qdeclarativeecmascript/data/include.qml | 23 ++ .../data/include_callback.js | 11 + .../data/include_callback.qml | 15 ++ .../qdeclarativeecmascript/data/include_remote.js | 26 +++ .../qdeclarativeecmascript/data/include_remote.qml | 21 ++ .../data/include_remote_missing.js | 13 ++ .../data/include_remote_missing.qml | 12 + .../qdeclarativeecmascript/data/include_shared.js | 12 + .../qdeclarativeecmascript/data/include_shared.qml | 22 ++ .../qdeclarativeecmascript/data/js/include2.js | 4 + .../qdeclarativeecmascript/data/js/include3.js | 3 + .../qdeclarativeecmascript/data/remote_file.js | 2 + 17 files changed, 540 insertions(+) create mode 100644 src/declarative/qml/qdeclarativeinclude.cpp create mode 100644 src/declarative/qml/qdeclarativeinclude_p.h create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/blank.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/exception.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp new file mode 100644 index 0000000..97af5b5 --- /dev/null +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** 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 "qdeclarativeinclude_p.h" + +#include +#include +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +QDeclarativeInclude::QDeclarativeInclude(const QUrl &url, + QDeclarativeEngine *engine, + QScriptContext *ctxt) +: QObject(engine), m_engine(engine), m_network(0), m_reply(0), m_url(url), m_redirectCount(0) +{ + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); + m_context = ep->contextClass->contextFromValue(QScriptDeclarativeClass::scopeChainValue(ctxt, -3)); + + m_scope[0] = QScriptDeclarativeClass::scopeChainValue(ctxt, -4); + m_scope[1] = QScriptDeclarativeClass::scopeChainValue(ctxt, -5); + + m_scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); + m_network = QDeclarativeScriptEngine::get(m_scriptEngine)->networkAccessManager(); + + m_result = resultValue(m_scriptEngine); + + QNetworkRequest request; + request.setUrl(url); + + m_reply = m_network->get(request); + QObject::connect(m_reply, SIGNAL(finished()), this, SLOT(finished())); +} + +QDeclarativeInclude::~QDeclarativeInclude() +{ + if (m_reply) + delete m_reply; +} + +QScriptValue QDeclarativeInclude::resultValue(QScriptEngine *engine, Status status) +{ + QScriptValue result = engine->newObject(); + result.setProperty(QLatin1String("OK"), QScriptValue(engine, Ok)); + result.setProperty(QLatin1String("LOADING"), QScriptValue(engine, Loading)); + result.setProperty(QLatin1String("NETWORK_ERROR"), QScriptValue(engine, NetworkError)); + result.setProperty(QLatin1String("EXCEPTION"), QScriptValue(engine, Exception)); + + result.setProperty(QLatin1String("status"), QScriptValue(engine, status)); + return result; +} + +QScriptValue QDeclarativeInclude::result() const +{ + return m_result; +} + +void QDeclarativeInclude::setCallback(const QScriptValue &c) +{ + m_callback = c; +} + +QScriptValue QDeclarativeInclude::callback() const +{ + return m_callback; +} + +#define INCLUDE_MAXIMUM_REDIRECT_RECURSION 15 +void QDeclarativeInclude::finished() +{ + m_redirectCount++; + + if (m_redirectCount < INCLUDE_MAXIMUM_REDIRECT_RECURSION) { + QVariant redirect = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirect.isValid()) { + m_url = m_url.resolved(redirect.toUrl()); + delete m_reply; + + QNetworkRequest request; + request.setUrl(m_url); + + m_reply = m_network->get(request); + QObject::connect(m_reply, SIGNAL(finished()), this, SLOT(finished())); + return; + } + } + + if (m_reply->error() == QNetworkReply::NoError) { + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(m_engine); + + QByteArray data = m_reply->readAll(); + + QString code = QString::fromUtf8(data); + + QString urlString = m_url.toString(); + QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(m_scriptEngine); + scriptContext->pushScope(ep->contextClass->newUrlContext(m_context, 0, urlString)); + scriptContext->pushScope(m_scope[0]); + + scriptContext->pushScope(m_scope[1]); + scriptContext->setActivationObject(m_scope[1]); + + m_scriptEngine->evaluate(code, urlString, 1); + + m_scriptEngine->popContext(); + + if (m_scriptEngine->hasUncaughtException()) { + m_result.setProperty(QLatin1String("status"), QScriptValue(m_scriptEngine, Exception)); + m_result.setProperty(QLatin1String("exception"), m_scriptEngine->uncaughtException()); + } else { + m_result.setProperty(QLatin1String("status"), QScriptValue(m_scriptEngine, Ok)); + } + } else { + m_result.setProperty(QLatin1String("status"), QScriptValue(m_scriptEngine, NetworkError)); + } + + callback(m_scriptEngine, m_callback, m_result); + + delete this; +} + +void QDeclarativeInclude::callback(QScriptEngine *engine, QScriptValue &callback, QScriptValue &status) +{ + if (callback.isValid()) { + QScriptValue args = engine->newArray(1); + args.setProperty(0, status); + callback.call(QScriptValue(), args); + } +} + +static QString toLocalFileOrQrc(const QUrl& url) +{ + if (url.scheme() == QLatin1String("qrc")) { + if (url.authority().isEmpty()) + return QLatin1Char(':') + url.path(); + return QString(); + } + return url.toLocalFile(); +} + +QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *engine) +{ + if (ctxt->argumentCount() == 0) + return engine->undefinedValue(); + + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); + + QUrl contextUrl = ep->contextClass->urlFromValue(QScriptDeclarativeClass::scopeChainValue(ctxt, -3)); + if (contextUrl.isEmpty()) + return ctxt->throwError(QLatin1String("Qt.include(): Can only be called from JavaScript files")); + + QString urlString = ctxt->argument(0).toString(); + QUrl url(ctxt->argument(0).toString()); + if (url.isRelative()) { + url = QUrl(contextUrl).resolved(url); + urlString = url.toString(); + } + + QString localFile = toLocalFileOrQrc(url); + + QScriptValue func = ctxt->argument(1); + if (!func.isFunction()) + func = QScriptValue(); + + QScriptValue result; + if (localFile.isEmpty()) { + QDeclarativeInclude *i = + new QDeclarativeInclude(url, QDeclarativeEnginePrivate::getEngine(engine), ctxt); + + if (func.isValid()) + i->setCallback(func); + + result = i->result(); + } else { + + QFile f(localFile); + if (f.open(QIODevice::ReadOnly)) { + QByteArray data = f.readAll(); + QString code = QString::fromUtf8(data); + + QDeclarativeContextData *context = + ep->contextClass->contextFromValue(QScriptDeclarativeClass::scopeChainValue(ctxt, -3)); + + QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(engine); + scriptContext->pushScope(ep->contextClass->newUrlContext(context, 0, urlString)); + scriptContext->pushScope(ep->globalClass->globalObject()); + QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -5); + scriptContext->pushScope(scope); + scriptContext->setActivationObject(scope); + + engine->evaluate(code, urlString, 1); + + engine->popContext(); + + if (engine->hasUncaughtException()) { + result = resultValue(engine, Exception); + result.setProperty(QLatin1String("exception"), engine->uncaughtException()); + } else { + result = resultValue(engine, Ok); + } + callback(engine, func, result); + } else { + result = resultValue(engine, NetworkError); + callback(engine, func, result); + } + } + + return result; +} + + + +QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeinclude_p.h b/src/declarative/qml/qdeclarativeinclude_p.h new file mode 100644 index 0000000..28c49ea --- /dev/null +++ b/src/declarative/qml/qdeclarativeinclude_p.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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 QDECLARATIVEINCLUDE_P_H +#define QDECLARATIVEINCLUDE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QDeclarativeEngine; +class QScriptContext; +class QScriptEngine; +class QNetworkAccessManager; +class QNetworkReply; +class QDeclarativeInclude : public QObject +{ + Q_OBJECT +public: + enum Status { + Ok = 0, + Loading = 1, + NetworkError = 2, + Exception = 3 + }; + + QDeclarativeInclude(const QUrl &, QDeclarativeEngine *, QScriptContext *ctxt); + ~QDeclarativeInclude(); + + void setCallback(const QScriptValue &); + QScriptValue callback() const; + + QScriptValue result() const; + + static QScriptValue resultValue(QScriptEngine *, Status status = Loading); + static void callback(QScriptEngine *, QScriptValue &callback, QScriptValue &status); + static QScriptValue include(QScriptContext *ctxt, QScriptEngine *engine); + +public slots: + void finished(); + +private: + QDeclarativeEngine *m_engine; + QScriptEngine *m_scriptEngine; + QNetworkAccessManager *m_network; + QNetworkReply *m_reply; + + QUrl m_url; + int m_redirectCount; + QScriptValue m_callback; + QScriptValue m_result; + QDeclarativeGuardedContextData m_context; + QScriptValue m_scope[2]; +}; + +QT_END_NAMESPACE + +#endif // QDECLARATIVEINCLUDE_P_H + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/blank.js b/tests/auto/declarative/qdeclarativeecmascript/data/blank.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exception.js b/tests/auto/declarative/qdeclarativeecmascript/data/exception.js new file mode 100644 index 0000000..160bbfa --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/exception.js @@ -0,0 +1 @@ +throw("Whoops!"); diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include.js b/tests/auto/declarative/qdeclarativeecmascript/data/include.js new file mode 100644 index 0000000..232fd80 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include.js @@ -0,0 +1,8 @@ +var test1 = true +var test2 = false +var test3 = false + +function go() { + Qt.include("js/include2.js"); +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include.qml new file mode 100644 index 0000000..18543b2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include.qml @@ -0,0 +1,23 @@ +import Qt 4.7 +import "include.js" as IncludeTest + +QtObject { + property int test0: 0 + property bool test1: false + property bool test2: false + property bool test2_1: false + property bool test3: false + property bool test3_1: false + + property int testValue: 99 + + Component.onCompleted: { + IncludeTest.go(); + test0 = IncludeTest.value + test1 = IncludeTest.test1 + test2 = IncludeTest.test2 + test2_1 = IncludeTest.test2_1 + test3 = IncludeTest.test3 + test3_1 = IncludeTest.test3_1 + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js new file mode 100644 index 0000000..ea19eba --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js @@ -0,0 +1,11 @@ +function go() { + var a = Qt.include("missing.js", function(o) { test2 = o.status == o.NETWORK_ERROR }); + test1 = a.status == a.NETWORK_ERROR + + var b = Qt.include("blank.js", function(o) { test4 = o.status == o.OK }); + test3 = b.status == b.OK + + var c = Qt.include("exception.js", function(o) { test6 = o.status == o.EXCEPTION }); + test5 = c.status == c.EXCEPTION +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml new file mode 100644 index 0000000..a39e821 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml @@ -0,0 +1,15 @@ +import Qt 4.7 +import "include_callback.js" as IncludeTest + +QtObject { + property bool test1: false + property bool test2: false + property bool test3: false + property bool test4: false + property bool test5: false + property bool test6: false + + Component.onCompleted: { + IncludeTest.go(); + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js new file mode 100644 index 0000000..e6a4676 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js @@ -0,0 +1,26 @@ +var myvar = 10; + +function go() +{ + var a = Qt.include("http://127.0.0.1:8111/remote_file.js", + function(o) { + test2 = o.status == o.OK + test3 = a.status == a.OK + test4 = myvar == 13 + + done = true; + }); + test1 = a.status == a.LOADING + + + var b = Qt.include("http://127.0.0.1:8111/exception.js", + function(o) { + test7 = o.status == o.EXCEPTION + test8 = b.status == a.EXCEPTION + test9 = b.exception.toString() == "Whoops!"; + test10 = o.exception.toString() == "Whoops!"; + + done2 = true; + }); + test6 = b.status == b.LOADING +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml new file mode 100644 index 0000000..06bd174 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml @@ -0,0 +1,21 @@ +import Qt 4.7 +import "include_remote.js" as IncludeTest + +QtObject { + property bool done: false + property bool done2: false + + property bool test1: false + property bool test2: false + property bool test3: false + property bool test4: false + property bool test5: false + + property bool test6: false + property bool test7: false + property bool test8: false + property bool test9: false + property bool test10: false + + Component.onCompleted: IncludeTest.go(); +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js new file mode 100644 index 0000000..cc90860 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js @@ -0,0 +1,13 @@ +function go() +{ + var a = Qt.include("http://127.0.0.1:8111/missing.js", + function(o) { + test2 = o.status == o.NETWORK_ERROR + test3 = a.status == a.NETWORK_ERROR + + done = true; + }); + + test1 = a.status == a.LOADING +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml new file mode 100644 index 0000000..8e486b2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml @@ -0,0 +1,12 @@ +import Qt 4.7 +import "include_remote_missing.js" as IncludeTest + +QtObject { + property bool done: false + + property bool test1: false + property bool test2: false + property bool test3: false + + Component.onCompleted: IncludeTest.go(); +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js new file mode 100644 index 0000000..a49c07b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js @@ -0,0 +1,12 @@ +.pragma library + +var test1 = true +var test2 = false +var test3 = false + +var testValue = 99; + +function go() { + Qt.include("js/include2.js"); +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml new file mode 100644 index 0000000..e957018 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml @@ -0,0 +1,22 @@ +import Qt 4.7 +import "include_shared.js" as IncludeTest + +QtObject { + property int test0: 0 + property bool test1: false + property bool test2: false + property bool test2_1: false + property bool test3: false + property bool test3_1: false + + Component.onCompleted: { + IncludeTest.go(); + test0 = IncludeTest.value + test1 = IncludeTest.test1 + test2 = IncludeTest.test2 + test2_1 = IncludeTest.test2_1 + test3 = IncludeTest.test3 + test3_1 = IncludeTest.test3_1 + } +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js b/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js new file mode 100644 index 0000000..2a0c039 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js @@ -0,0 +1,4 @@ +test2 = true +var test2_1 = true + +Qt.include("include3.js"); diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js b/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js new file mode 100644 index 0000000..84b2770 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js @@ -0,0 +1,3 @@ +test3 = true +var test3_1 = true +var value = testValue diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js b/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js new file mode 100644 index 0000000..1b123ae --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js @@ -0,0 +1,2 @@ +myvar = 13; +test5 = true; -- cgit v0.12 From 0d608587f35f7659376a728cf8ee6b4b71ec9d5a Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 May 2010 13:56:45 +1000 Subject: Reduce the chance of AnchorAnimation animating geometry changes it isn't responsible for. --- src/declarative/util/qdeclarativestateoperations.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index a6fcaf3..0326f6d 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -1241,24 +1241,28 @@ QList QDeclarativeAnchorChanges::additionalActions() Q_D(QDeclarativeAnchorChanges); QList extra; + QDeclarativeAnchors::Anchors combined = d->anchorSet->d_func()->usedAnchors | d->anchorSet->d_func()->resetAnchors; + bool hChange = combined & QDeclarativeAnchors::Horizontal_Mask; + bool vChange = combined & QDeclarativeAnchors::Vertical_Mask; + if (d->target) { QDeclarativeAction a; - if (d->fromX != d->toX) { + if (hChange && d->fromX != d->toX) { a.property = QDeclarativeProperty(d->target, QLatin1String("x")); a.toValue = d->toX; extra << a; } - if (d->fromY != d->toY) { + if (vChange && d->fromY != d->toY) { a.property = QDeclarativeProperty(d->target, QLatin1String("y")); a.toValue = d->toY; extra << a; } - if (d->fromWidth != d->toWidth) { + if (hChange && d->fromWidth != d->toWidth) { a.property = QDeclarativeProperty(d->target, QLatin1String("width")); a.toValue = d->toWidth; extra << a; } - if (d->fromHeight != d->toHeight) { + if (vChange && d->fromHeight != d->toHeight) { a.property = QDeclarativeProperty(d->target, QLatin1String("height")); a.toValue = d->toHeight; extra << a; -- cgit v0.12 From 17a5c63a499b10036dc14135457ec22c89270f9a Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 14 May 2010 14:00:21 +1000 Subject: Missing files from 645b9ee9dd6e0576542cc61872ecedb408ca8a89 Grrr --- src/declarative/qml/qdeclarativecontext.cpp | 4 +- .../qml/qdeclarativecontextscriptclass.cpp | 46 ++++++++- .../qml/qdeclarativecontextscriptclass_p.h | 4 + src/declarative/qml/qdeclarativeengine.cpp | 2 + .../qml/qdeclarativeglobalscriptclass_p.h | 1 + src/declarative/qml/qdeclarativeinclude.cpp | 10 +- src/declarative/qml/qdeclarativeinclude_p.h | 3 +- src/declarative/qml/qml.pri | 2 + .../qdeclarativeecmascript.pro | 11 +- .../tst_qdeclarativeecmascript.cpp | 111 +++++++++++++++++++++ 10 files changed, 182 insertions(+), 12 deletions(-) diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index b61b8cb..6a13f15 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -659,7 +659,7 @@ void QDeclarativeContextData::addImportedScript(const QDeclarativeParser::Object if (iter == enginePriv->m_sharedScriptImports.end()) { QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); - scriptContext->pushScope(enginePriv->contextClass->newContext(0, 0)); + scriptContext->pushScope(enginePriv->contextClass->newUrlContext(url)); scriptContext->pushScope(enginePriv->globalClass->globalObject()); QScriptValue scope = scriptEngine->newObject(); @@ -685,7 +685,7 @@ void QDeclarativeContextData::addImportedScript(const QDeclarativeParser::Object QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); - scriptContext->pushScope(enginePriv->contextClass->newContext(this, 0)); + scriptContext->pushScope(enginePriv->contextClass->newUrlContext(this, 0, url)); scriptContext->pushScope(enginePriv->globalClass->globalObject()); QScriptValue scope = scriptEngine->newObject(); diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp index 1336a1a..1ebedbb 100644 --- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp +++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp @@ -51,11 +51,13 @@ QT_BEGIN_NAMESPACE struct ContextData : public QScriptDeclarativeClass::Object { ContextData() : overrideObject(0), isSharedContext(true) {} - ContextData(QDeclarativeContextData *c, QObject *o) : context(c), scopeObject(o), overrideObject(0), isSharedContext(false) {} + ContextData(QDeclarativeContextData *c, QObject *o) + : context(c), scopeObject(o), overrideObject(0), isSharedContext(false), isUrlContext(false) {} QDeclarativeGuardedContextData context; QDeclarativeGuard scopeObject; QObject *overrideObject; - bool isSharedContext; + bool isSharedContext:1; + bool isUrlContext:1; QDeclarativeContextData *getContext(QDeclarativeEngine *engine) { if (isSharedContext) { @@ -74,6 +76,18 @@ struct ContextData : public QScriptDeclarativeClass::Object { } }; +struct UrlContextData : public ContextData { + UrlContextData(QDeclarativeContextData *c, QObject *o, const QString &u) + : ContextData(c, o), url(u) { + isUrlContext = true; + } + UrlContextData(const QString &u) + : ContextData(0, 0), url(u) { + isUrlContext = true; + } + QString url; +}; + /* The QDeclarativeContextScriptClass handles property access for a QDeclarativeContext via QtScript. @@ -95,6 +109,21 @@ QScriptValue QDeclarativeContextScriptClass::newContext(QDeclarativeContextData return newObject(scriptEngine, this, new ContextData(context, scopeObject)); } +QScriptValue QDeclarativeContextScriptClass::newUrlContext(QDeclarativeContextData *context, QObject *scopeObject, + const QString &url) +{ + QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); + + return newObject(scriptEngine, this, new UrlContextData(context, scopeObject, url)); +} + +QScriptValue QDeclarativeContextScriptClass::newUrlContext(const QString &url) +{ + QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); + + return newObject(scriptEngine, this, new UrlContextData(url)); +} + QScriptValue QDeclarativeContextScriptClass::newSharedContext() { QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); @@ -111,6 +140,19 @@ QDeclarativeContextData *QDeclarativeContextScriptClass::contextFromValue(const return data->getContext(engine); } +QUrl QDeclarativeContextScriptClass::urlFromValue(const QScriptValue &v) +{ + if (scriptClass(v) != this) + return QUrl(); + + ContextData *data = (ContextData *)object(v); + if (data->isUrlContext) { + return QUrl(static_cast(data)->url); + } else { + return QUrl(); + } +} + QObject *QDeclarativeContextScriptClass::setOverrideObject(QScriptValue &v, QObject *override) { if (scriptClass(v) != this) diff --git a/src/declarative/qml/qdeclarativecontextscriptclass_p.h b/src/declarative/qml/qdeclarativecontextscriptclass_p.h index 1936d38..1215b00 100644 --- a/src/declarative/qml/qdeclarativecontextscriptclass_p.h +++ b/src/declarative/qml/qdeclarativecontextscriptclass_p.h @@ -68,9 +68,13 @@ public: ~QDeclarativeContextScriptClass(); QScriptValue newContext(QDeclarativeContextData *, QObject * = 0); + QScriptValue newUrlContext(QDeclarativeContextData *, QObject *, const QString &); + QScriptValue newUrlContext(const QString &); QScriptValue newSharedContext(); QDeclarativeContextData *contextFromValue(const QScriptValue &); + QUrl urlFromValue(const QScriptValue &); + QObject *setOverrideObject(QScriptValue &, QObject *); protected: diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 94e6771..5cb59da 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -67,6 +67,7 @@ #include "qdeclarativeextensioninterface.h" #include "private/qdeclarativelist_p.h" #include "private/qdeclarativetypenamecache_p.h" +#include "private/qdeclarativeinclude_p.h" #include #include @@ -204,6 +205,7 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr // XXX used to add Qt.Sound class. //types + qtObject.setProperty(QLatin1String("include"), newFunction(QDeclarativeInclude::include, 2)); qtObject.setProperty(QLatin1String("isQtObject"), newFunction(QDeclarativeEnginePrivate::isQtObject, 1)); qtObject.setProperty(QLatin1String("rgba"), newFunction(QDeclarativeEnginePrivate::rgba, 4)); qtObject.setProperty(QLatin1String("hsla"), newFunction(QDeclarativeEnginePrivate::hsla, 4)); diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h index 1b34aee..7690edd 100644 --- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h +++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h @@ -76,6 +76,7 @@ public: void explicitSetProperty(const QString &, const QScriptValue &); const QScriptValue &globalObject() const { return m_globalObject; } + const QSet &illegalNames() const { return m_illegalNames; } private: diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp index 97af5b5..b886935 100644 --- a/src/declarative/qml/qdeclarativeinclude.cpp +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -76,8 +76,7 @@ QDeclarativeInclude::QDeclarativeInclude(const QUrl &url, QDeclarativeInclude::~QDeclarativeInclude() { - if (m_reply) - delete m_reply; + delete m_reply; } QScriptValue QDeclarativeInclude::resultValue(QScriptEngine *engine, Status status) @@ -116,7 +115,7 @@ void QDeclarativeInclude::finished() QVariant redirect = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute); if (redirect.isValid()) { m_url = m_url.resolved(redirect.toUrl()); - delete m_reply; + delete m_reply; QNetworkRequest request; request.setUrl(m_url); @@ -149,6 +148,7 @@ void QDeclarativeInclude::finished() if (m_scriptEngine->hasUncaughtException()) { m_result.setProperty(QLatin1String("status"), QScriptValue(m_scriptEngine, Exception)); m_result.setProperty(QLatin1String("exception"), m_scriptEngine->uncaughtException()); + m_scriptEngine->clearExceptions(); } else { m_result.setProperty(QLatin1String("status"), QScriptValue(m_scriptEngine, Ok)); } @@ -158,7 +158,8 @@ void QDeclarativeInclude::finished() callback(m_scriptEngine, m_callback, m_result); - delete this; + disconnect(); + deleteLater(); } void QDeclarativeInclude::callback(QScriptEngine *engine, QScriptValue &callback, QScriptValue &status) @@ -237,6 +238,7 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e if (engine->hasUncaughtException()) { result = resultValue(engine, Exception); result.setProperty(QLatin1String("exception"), engine->uncaughtException()); + engine->clearExceptions(); } else { result = resultValue(engine, Ok); } diff --git a/src/declarative/qml/qdeclarativeinclude_p.h b/src/declarative/qml/qdeclarativeinclude_p.h index 28c49ea..9678e42 100644 --- a/src/declarative/qml/qdeclarativeinclude_p.h +++ b/src/declarative/qml/qdeclarativeinclude_p.h @@ -58,6 +58,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -96,7 +97,7 @@ private: QDeclarativeEngine *m_engine; QScriptEngine *m_scriptEngine; QNetworkAccessManager *m_network; - QNetworkReply *m_reply; + QDeclarativeGuard m_reply; QUrl m_url; int m_redirectCount; diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index dab9767..12f9794 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -9,6 +9,7 @@ SOURCES += \ $$PWD/qdeclarativeproperty.cpp \ $$PWD/qdeclarativecomponent.cpp \ $$PWD/qdeclarativecontext.cpp \ + $$PWD/qdeclarativeinclude.cpp \ $$PWD/qdeclarativecustomparser.cpp \ $$PWD/qdeclarativepropertyvaluesource.cpp \ $$PWD/qdeclarativepropertyvalueinterceptor.cpp \ @@ -92,6 +93,7 @@ HEADERS += \ $$PWD/qdeclarativeinfo.h \ $$PWD/qdeclarativeproperty_p.h \ $$PWD/qdeclarativecontext_p.h \ + $$PWD/qdeclarativeinclude_p.h \ $$PWD/qdeclarativecompositetypedata_p.h \ $$PWD/qdeclarativecompositetypemanager_p.h \ $$PWD/qdeclarativelist.h \ diff --git a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro index eabed26..c907be5 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro +++ b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro @@ -1,13 +1,18 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative script +contains(QT_CONFIG,declarative): QT += declarative script network macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeecmascript.cpp \ - testtypes.cpp -HEADERS += testtypes.h + testtypes.cpp \ + ../shared/testhttpserver.cpp +HEADERS += testtypes.h \ + ../shared/testhttpserver.h +INCLUDEPATH += ../shared # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov +DEFINES += SRCDIR=\\\"$$PWD\\\" + CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 8c9290f..b8faa7c 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -51,6 +51,7 @@ #include #include #include "testtypes.h" +#include "testhttpserver.h" /* This test covers evaluation of ECMAScript expressions and bindings from within @@ -149,6 +150,8 @@ private slots: void eval(); void function(); + void include(); + void callQtInvokables(); private: QDeclarativeEngine engine; @@ -2361,6 +2364,114 @@ void tst_qdeclarativeecmascript::function() delete o; } +#define TRY_WAIT(expr) \ + do { \ + for (int ii = 0; ii < 6; ++ii) { \ + if ((expr)) break; \ + QTest::qWait(50); \ + } \ + QVERIFY((expr)); \ + } while (false) + +// Test the "Qt.include" method +void tst_qdeclarativeecmascript::include() +{ + // Non-library relative include + { + QDeclarativeComponent component(&engine, TEST_FILE("include.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test0").toInt(), 99); + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test2_1").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test3_1").toBool(), true); + + delete o; + } + + // Library relative include + { + QDeclarativeComponent component(&engine, TEST_FILE("include_shared.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test0").toInt(), 99); + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test2_1").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test3_1").toBool(), true); + + delete o; + } + + // Callback + { + QDeclarativeComponent component(&engine, TEST_FILE("include_callback.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + QCOMPARE(o->property("test6").toBool(), true); + + delete o; + } + + // Remote - success + { + TestHTTPServer server(8111); + QVERIFY(server.isValid()); + server.serveDirectory(SRCDIR "/data"); + + QDeclarativeComponent component(&engine, TEST_FILE("include_remote.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + TRY_WAIT(o->property("done").toBool() == true); + TRY_WAIT(o->property("done2").toBool() == true); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + + QCOMPARE(o->property("test6").toBool(), true); + QCOMPARE(o->property("test7").toBool(), true); + QCOMPARE(o->property("test8").toBool(), true); + QCOMPARE(o->property("test9").toBool(), true); + QCOMPARE(o->property("test10").toBool(), true); + + delete o; + } + + // Remote - error + { + TestHTTPServer server(8111); + QVERIFY(server.isValid()); + server.serveDirectory(SRCDIR "/data"); + + QDeclarativeComponent component(&engine, TEST_FILE("include_remote_missing.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + TRY_WAIT(o->property("done").toBool() == true); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + + delete o; + } +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" -- cgit v0.12 From 2f6eb60bf4012f9a185d7cd5d4c50762c3abc7f7 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 14 May 2010 15:33:48 +1000 Subject: Only add "include" property in non-workerscript threads --- src/declarative/qml/qdeclarativeengine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 5cb59da..8d3ca59 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -205,7 +205,8 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr // XXX used to add Qt.Sound class. //types - qtObject.setProperty(QLatin1String("include"), newFunction(QDeclarativeInclude::include, 2)); + if (mainthread) + qtObject.setProperty(QLatin1String("include"), newFunction(QDeclarativeInclude::include, 2)); qtObject.setProperty(QLatin1String("isQtObject"), newFunction(QDeclarativeEnginePrivate::isQtObject, 1)); qtObject.setProperty(QLatin1String("rgba"), newFunction(QDeclarativeEnginePrivate::rgba, 4)); qtObject.setProperty(QLatin1String("hsla"), newFunction(QDeclarativeEnginePrivate::hsla, 4)); -- cgit v0.12 From 3f775da6fec8b5cfb5e538100b7889401d14c410 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Fri, 14 May 2010 08:04:54 +0200 Subject: Add missing file! Amendment to 812f78e55aa3db4d51ec8617320358d80c4a71d5. --- examples/graphicsview/padnavigator/form.ui | 208 +++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 examples/graphicsview/padnavigator/form.ui diff --git a/examples/graphicsview/padnavigator/form.ui b/examples/graphicsview/padnavigator/form.ui new file mode 100644 index 0000000..fc7d123 --- /dev/null +++ b/examples/graphicsview/padnavigator/form.ui @@ -0,0 +1,208 @@ + + Form + + + + 0 + 0 + 378 + 385 + + + + BackSide + + + + + + Settings + + + true + + + true + + + + + + Title: + + + + + + + Pad Navigator Example + + + + + + + Modified: + + + + + + + Extent + + + + + + + + + 42 + + + Qt::Horizontal + + + + + + + 42 + + + + + + + + + + + + + + + Other input + + + true + + + true + + + + + + + Widgets On Graphics View + + + + + QGraphicsProxyWidget + + + + QGraphicsWidget + + + + QObject + + + + + QGraphicsItem + + + + + QGraphicsLayoutItem + + + + + + + QGraphicsGridLayout + + + + QGraphicsLayout + + + + QGraphicsLayoutItem + + + + + + + QGraphicsLinearLayout + + + + QGraphicsLayout + + + + QGraphicsLayoutItem + + + + + + + + + + + + + groupBox + hostName + dateTimeEdit + horizontalSlider + spinBox + groupBox_2 + treeWidget + + + + + horizontalSlider + valueChanged(int) + spinBox + setValue(int) + + + 184 + 125 + + + 275 + 127 + + + + + spinBox + valueChanged(int) + horizontalSlider + setValue(int) + + + 272 + 114 + + + 190 + 126 + + + + + -- cgit v0.12 From d9ab23c190de774ea093652060981e14ac5aeaf8 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 14 May 2010 17:15:08 +1000 Subject: Qt.include() support in worker scripts --- src/declarative/qml/qdeclarativeengine.cpp | 3 ++ src/declarative/qml/qdeclarativeinclude.cpp | 59 ++++++++++++++++++++++++ src/declarative/qml/qdeclarativeinclude_p.h | 2 + src/declarative/qml/qdeclarativeworkerscript.cpp | 6 ++- 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 8d3ca59..2c89abd 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -207,6 +207,9 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr //types if (mainthread) qtObject.setProperty(QLatin1String("include"), newFunction(QDeclarativeInclude::include, 2)); + else + qtObject.setProperty(QLatin1String("include"), newFunction(QDeclarativeInclude::worker_include, 2)); + qtObject.setProperty(QLatin1String("isQtObject"), newFunction(QDeclarativeEnginePrivate::isQtObject, 1)); qtObject.setProperty(QLatin1String("rgba"), newFunction(QDeclarativeEnginePrivate::rgba, 4)); qtObject.setProperty(QLatin1String("hsla"), newFunction(QDeclarativeEnginePrivate::hsla, 4)); diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp index b886935..97220f1 100644 --- a/src/declarative/qml/qdeclarativeinclude.cpp +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -252,6 +252,65 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e return result; } +QScriptValue QDeclarativeInclude::worker_include(QScriptContext *ctxt, QScriptEngine *engine) +{ + if (ctxt->argumentCount() == 0) + return engine->undefinedValue(); + + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); + + QString urlString = ctxt->argument(0).toString(); + QUrl url(ctxt->argument(0).toString()); + if (url.isRelative()) { + QString contextUrl = QScriptDeclarativeClass::scopeChainValue(ctxt, -3).data().toString(); + Q_ASSERT(!contextUrl.isEmpty()); + + url = QUrl(contextUrl).resolved(url); + urlString = url.toString(); + } + + QString localFile = toLocalFileOrQrc(url); + + QScriptValue func = ctxt->argument(1); + if (!func.isFunction()) + func = QScriptValue(); + + QScriptValue result; + if (!localFile.isEmpty()) { + + QFile f(localFile); + if (f.open(QIODevice::ReadOnly)) { + QByteArray data = f.readAll(); + QString code = QString::fromUtf8(data); + QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(engine); + QScriptValue urlContext = engine->newObject(); + urlContext.setData(QScriptValue(engine, urlString)); + scriptContext->pushScope(urlContext); + + QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -4); + scriptContext->pushScope(scope); + scriptContext->setActivationObject(scope); + + engine->evaluate(code, urlString, 1); + + engine->popContext(); + + if (engine->hasUncaughtException()) { + result = resultValue(engine, Exception); + result.setProperty(QLatin1String("exception"), engine->uncaughtException()); + engine->clearExceptions(); + } else { + result = resultValue(engine, Ok); + } + callback(engine, func, result); + } else { + result = resultValue(engine, NetworkError); + callback(engine, func, result); + } + } + + return result; +} QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeinclude_p.h b/src/declarative/qml/qdeclarativeinclude_p.h index 9678e42..3124374 100644 --- a/src/declarative/qml/qdeclarativeinclude_p.h +++ b/src/declarative/qml/qdeclarativeinclude_p.h @@ -88,7 +88,9 @@ public: static QScriptValue resultValue(QScriptEngine *, Status status = Loading); static void callback(QScriptEngine *, QScriptValue &callback, QScriptValue &status); + static QScriptValue include(QScriptContext *ctxt, QScriptEngine *engine); + static QScriptValue worker_include(QScriptContext *ctxt, QScriptEngine *engine); public slots: void finished(); diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index c55998f..4b687a9 100644 --- a/src/declarative/qml/qdeclarativeworkerscript.cpp +++ b/src/declarative/qml/qdeclarativeworkerscript.cpp @@ -289,7 +289,11 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url) QScriptValue activation = getWorker(id); - QScriptContext *ctxt = workerEngine->pushContext(); + QScriptContext *ctxt = QScriptDeclarativeClass::pushCleanContext(workerEngine); + QScriptValue urlContext = workerEngine->newObject(); + urlContext.setData(QScriptValue(workerEngine, fileName)); + ctxt->pushScope(urlContext); + ctxt->pushScope(activation); ctxt->setActivationObject(activation); workerEngine->baseUrl = url; -- cgit v0.12 From ef0a942bc57485ddaad413cd27c0283a1c90149f Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 14 May 2010 10:38:52 +0200 Subject: Updated changelog. --- dist/changes-4.7.0 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0 index 6bf7ea5..919c25a 100644 --- a/dist/changes-4.7.0 +++ b/dist/changes-4.7.0 @@ -76,6 +76,18 @@ QtGui * Fixed rendering bugs when scrolling graphics items with drop shadows. + - QGraphicsItem + * [QTBUG-8112] itemChange() is now called when transformation + properties change (setRotation, setScale, setTransformOriginPoint). + + - QGraphicsTextItem + * [QTBUG-7333] Fixed keyboard shortcuts not being triggered when the + the item has focus and something else has the same shortcut sequence. + + - QGraphicsView + * [QTBUG-7438] Fixed viewport cursor getting reset when releasing + the mouse. + - QImage * [QTBUG-9640] Prevented unneccessary copy in QImage::setAlphaChannel(). -- cgit v0.12 From aeff7ca3bdc7d4c2518f6f27f69332935ff8b104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 14 May 2010 10:42:31 +0200 Subject: Some 4.7 changes. --- dist/changes-4.7.0 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0 index 919c25a..47992f9 100644 --- a/dist/changes-4.7.0 +++ b/dist/changes-4.7.0 @@ -33,7 +33,6 @@ New features - QNetworkSession, QNetworkConfiguration, QNetworkConfigurationManager * New bearer management classes added. - Third party components ---------------------- @@ -89,11 +88,17 @@ QtGui the mouse. - QImage - * [QTBUG-9640] Prevented unneccessary copy in - QImage::setAlphaChannel(). - * Added QImage::bitPlaneCount(). (QTBUG-7982) + * [QTBUG-9640] Prevented unneccessary copy in QImage::setAlphaChannel(). + * [QTBUG-7982] Added QImage::bitPlaneCount(). + + - QPicture + * [QTBUG-4974] Printing QPictures containing text to a high resolution + QPrinter would in many cases cause incorrect character spacing. - QPainter + * Added QPainter::drawPixmapFragments(), which makes it possible to draw + pixmaps, or sub-rectangles of pixmaps, at various positions with + different scale, opacity and rotation. * [QTBUG-10018] Fixed image drawing inconsistencies when drawing 1x1 source rects with rotating / shear / perspective transforms. * Optimized various blending and rendering operations for ARM -- cgit v0.12 From cd719dee504dc70d53a6b24e746caf9e69d83ddb Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 14 May 2010 11:39:39 +0300 Subject: Support device aliases in EPOCDEVICE Qmake now understands use of device aliases in EPOCDEVICE environment variable. Task-number: QTBUG-9108 Reviewed-by: Janne Anttila --- tools/shared/symbian/epocroot.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/shared/symbian/epocroot.cpp b/tools/shared/symbian/epocroot.cpp index 071477d..064e056 100644 --- a/tools/shared/symbian/epocroot.cpp +++ b/tools/shared/symbian/epocroot.cpp @@ -153,10 +153,13 @@ QString epocRoot() while (!(xml.isEndElement() && xml.name() == "devices") && !xml.atEnd()) { xml.readNext(); if (xml.isStartElement() && xml.name() == "device") { - const bool isDefault = xml.attributes().value("default") == "yes"; + const bool isDefault = xml.attributes().value("default") == "yes"; const QString id = xml.attributes().value("id").toString(); - const QString name = xml.attributes().value("name").toString(); - const bool epocDeviceMatch = (id + ":" + name) == epocDeviceValue; + const QString name = xml.attributes().value("name").toString(); + const QString alias = xml.attributes().value("alias").toString(); + bool epocDeviceMatch = (id + ":" + name) == epocDeviceValue; + if (!alias.isEmpty()) + epocDeviceMatch |= alias == epocDeviceValue; epocDeviceFound |= epocDeviceMatch; if((epocDeviceValue.isEmpty() && isDefault) || epocDeviceMatch) { -- cgit v0.12 From 96bf7b880976f225ca390aab1cb1492e8d79ea4c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 14 May 2010 11:25:51 +0200 Subject: Updated WebKit to 5cf023650a8da206a8cf3130e9d4820b95e1bc7c Integrated changes: * Doc day API doc overhaul || || [Qt] GraphicsLayer: depth-test causes flicker in certain situations || || || [Qt] emit initialLayoutCompleted signal from FrameLoaderClientQt::dispatchDidFirstVisuallyNonEmptyLayout || || || [Qt] Detect debug mode consistently || || || [Qt] Update the Symbian version for the user agent || || || [Qt] Improve QtLauncher user agent dialog resize || || || Ignore invalid values for various CanvasRenderingContext2D properties || || || [Qt] tst_QWebPage::inputMethods failing on Maemo5 || || || [Qt] REGRESSION(r58497) tst_QGraphicsWebView::crashOnViewlessWebPages() is failing || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/ChangeLog | 9 + src/3rdparty/webkit/JavaScriptCore/ChangeLog | 12 ++ .../webkit/JavaScriptCore/JavaScriptCore.pri | 2 +- .../webkit/JavaScriptCore/JavaScriptCore.pro | 2 +- .../webkit/JavaScriptCore/qt/api/QtScript.pro | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 43 +++++ src/3rdparty/webkit/WebCore/WebCore.pro | 2 +- .../html/canvas/CanvasRenderingContext2D.cpp | 10 +- .../platform/graphics/qt/GraphicsLayerQt.cpp | 8 - src/3rdparty/webkit/WebKit.pri | 2 +- src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp | 10 +- src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp | 20 ++- src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp | 10 +- .../webkit/WebKit/qt/Api/qwebhistoryinterface.cpp | 23 ++- .../webkit/WebKit/qt/Api/qwebinspector.cpp | 45 ++--- .../webkit/WebKit/qt/Api/qwebkitversion.cpp | 66 +++++++- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 184 +++++++++++++++++---- .../webkit/WebKit/qt/Api/qwebpluginfactory.cpp | 36 +++- .../webkit/WebKit/qt/Api/qwebsecurityorigin.cpp | 24 ++- src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp | 128 +++++++------- src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h | 2 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 99 +++++++++++ .../qt/WebCoreSupport/FrameLoaderClientQt.cpp | 6 +- src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc | 109 ++++++------ .../qtwebkit_qwebinspector_snippet.cpp | 2 - .../qt/docs/webkitsnippets/webelement/main.cpp | 56 +++++++ .../qgraphicswebview/tst_qgraphicswebview.cpp | 8 +- .../WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 23 ++- 30 files changed, 718 insertions(+), 229 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 14af7e9..9d754a4 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -5cf023650a8da206a8cf3130e9d4820b95e1bc7c +3d774b9df1f963452b1cfe34f9fafad0d399372a diff --git a/src/3rdparty/webkit/ChangeLog b/src/3rdparty/webkit/ChangeLog index 70eff7d..a0cf2d0 100644 --- a/src/3rdparty/webkit/ChangeLog +++ b/src/3rdparty/webkit/ChangeLog @@ -1,3 +1,12 @@ +2010-05-12 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Detect debug mode consistently + https://bugs.webkit.org/show_bug.cgi?id=38863 + + * WebKit.pri: + 2010-04-09 Simon Hausmann Unreviewed crash fix. diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index 1610036..a3e6586 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,15 @@ +2010-05-12 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Detect debug mode consistently + https://bugs.webkit.org/show_bug.cgi?id=38863 + + * JavaScriptCore.pri: + * JavaScriptCore.pro: + * jsc.pro: + * qt/api/QtScript.pro: + 2010-05-10 Laszlo Gombos Reviewed by Darin Adler. diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri index b7f6665..b3f74a9 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri @@ -1,6 +1,6 @@ # JavaScriptCore - Qt4 build info VPATH += $$PWD -CONFIG(debug, debug|release) { +!CONFIG(release, debug|release) { # Output in JavaScriptCore/ JAVASCRIPTCORE_DESTDIR = debug # Use a config-specific target to prevent parallel builds file clashes on Mac diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro index 8e086b3..22fcc91 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro @@ -21,7 +21,7 @@ CONFIG(QTDIR_build) { # This line was extracted from qbase.pri instead of including the whole file win32|mac:!macx-xcode:CONFIG += debug_and_release } else { - CONFIG(debug, debug|release) { + !CONFIG(release, debug|release) { OBJECTS_DIR = obj/debug } else { # Release OBJECTS_DIR = obj/release diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro b/src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro index 88629c7..3c2691e 100644 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro +++ b/src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro @@ -7,7 +7,7 @@ INCLUDEPATH += $$PWD CONFIG += building-libs isEmpty(JSC_GENERATED_SOURCES_DIR):JSC_GENERATED_SOURCES_DIR = ../../generated -CONFIG(debug, debug|release) { +!CONFIG(release, debug|release) { OBJECTS_DIR = obj/debug } else { # Release OBJECTS_DIR = obj/release diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index b8bac54..a440c03 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 57d10d5c05e59bbf7de8189ff47dd18d1be996dc + 5cf023650a8da206a8cf3130e9d4820b95e1bc7c diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 76b4eff..93d00e4 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,46 @@ +2010-05-12 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Detect debug mode consistently + https://bugs.webkit.org/show_bug.cgi?id=38863 + + No new tests as there is no new functionality. + + * WebCore.pro: + +2010-05-14 Andreas Kling + + Reviewed by Darin Adler. + + Ignore invalid values for various CanvasRenderingContext2D properties + (lineWidth, miterLimit, shadowOffsetX, shadowOffsetY and shadowBlur) + + https://bugs.webkit.org/show_bug.cgi?id=38841 + + Test: fast/canvas/canvas-invalid-values.html + + * html/canvas/CanvasRenderingContext2D.cpp: + (WebCore::CanvasRenderingContext2D::setLineWidth): + (WebCore::CanvasRenderingContext2D::setMiterLimit): + (WebCore::CanvasRenderingContext2D::setShadowOffsetX): + (WebCore::CanvasRenderingContext2D::setShadowOffsetY): + (WebCore::CanvasRenderingContext2D::setShadowBlur): + +2010-05-12 Noam Rosenthal + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] GraphicsLayer: depth-test causes flicker in certain situations + + This patch removes the simplistic 2D depth test as it leads to flickering side effects. + https://bugs.webkit.org/show_bug.cgi?id=38370 + + Tested by http://webkit.org/blog-files/3d-transforms/morphing-cubes.html + + * platform/graphics/qt/GraphicsLayerQt.cpp: + (WebCore::GraphicsLayerQtImpl::updateTransform): + 2010-04-29 James Robinson Reviewed by Simon Fraser. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 254d17b..689c5ff 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -59,7 +59,7 @@ CONFIG(standalone_package) { isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = generated isEmpty(JSC_GENERATED_SOURCES_DIR):JSC_GENERATED_SOURCES_DIR = ../JavaScriptCore/generated - CONFIG(debug, debug|release) { + !CONFIG(release, debug|release) { OBJECTS_DIR = obj/debug } else { # Release OBJECTS_DIR = obj/release diff --git a/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp index 8add19c..823ab59 100644 --- a/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp +++ b/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp @@ -209,7 +209,7 @@ float CanvasRenderingContext2D::lineWidth() const void CanvasRenderingContext2D::setLineWidth(float width) { - if (!(width > 0)) + if (!(isfinite(width) && width > 0)) return; state().m_lineWidth = width; GraphicsContext* c = drawingContext(); @@ -259,7 +259,7 @@ float CanvasRenderingContext2D::miterLimit() const void CanvasRenderingContext2D::setMiterLimit(float limit) { - if (!(limit > 0)) + if (!(isfinite(limit) && limit > 0)) return; state().m_miterLimit = limit; GraphicsContext* c = drawingContext(); @@ -275,6 +275,8 @@ float CanvasRenderingContext2D::shadowOffsetX() const void CanvasRenderingContext2D::setShadowOffsetX(float x) { + if (!isfinite(x)) + return; state().m_shadowOffset.setWidth(x); applyShadow(); } @@ -286,6 +288,8 @@ float CanvasRenderingContext2D::shadowOffsetY() const void CanvasRenderingContext2D::setShadowOffsetY(float y) { + if (!isfinite(y)) + return; state().m_shadowOffset.setHeight(y); applyShadow(); } @@ -297,6 +301,8 @@ float CanvasRenderingContext2D::shadowBlur() const void CanvasRenderingContext2D::setShadowBlur(float blur) { + if (!(isfinite(blur) && blur >= 0)) + return; state().m_shadowBlur = blur; applyShadow(); } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp index 1c4c275..d9394e1 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp @@ -357,14 +357,6 @@ void GraphicsLayerQtImpl::updateTransform() return; } - // Simplistic depth test - we stack the item behind its parent if its computed z is lower than the parent's computed z at the item's center point. - if (parent) { - const QPointF centerPointMappedToRoot = rootLayer()->mapFromItem(this, m_size.width() / 2, m_size.height() / 2); - setFlag(ItemStacksBehindParent, - m_transformRelativeToRootLayer.mapPoint(FloatPoint3D(centerPointMappedToRoot.x(), centerPointMappedToRoot.y(), 0)).z() < - parent->m_transformRelativeToRootLayer.mapPoint(FloatPoint3D(centerPointMappedToRoot.x(), centerPointMappedToRoot.y(), 0)).z()); - } - // The item is front-facing or backface-visibility is on. setVisible(true); diff --git a/src/3rdparty/webkit/WebKit.pri b/src/3rdparty/webkit/WebKit.pri index e737039..a3ccd9d 100644 --- a/src/3rdparty/webkit/WebKit.pri +++ b/src/3rdparty/webkit/WebKit.pri @@ -22,7 +22,7 @@ building-libs { QMAKE_FRAMEWORKPATH = $$OUTPUT_DIR/lib $$QMAKE_FRAMEWORKPATH } else { win32-*|wince* { - CONFIG(debug, debug|release):build_pass: QTWEBKITLIBNAME = $${QTWEBKITLIBNAME}d + !CONFIG(release, debug|release):build_pass: QTWEBKITLIBNAME = $${QTWEBKITLIBNAME}d QTWEBKITLIBNAME = $${QTWEBKITLIBNAME}$${QT_MAJOR_VERSION} win32-g++: LIBS += -l$$QTWEBKITLIBNAME else: LIBS += $${QTWEBKITLIBNAME}.lib diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp index 4e8fd30..ba039c7 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp @@ -39,8 +39,10 @@ using namespace WebCore; access on a local computer through JavaScript. QWebDatabase is the C++ interface to these databases. - To get access to all databases defined by a security origin, use QWebSecurityOrigin::databases(). - Each database has an internal name(), as well as a user-friendly name, provided by displayName(). + Databases are grouped together in security origins. To get access to all databases defined by + a security origin, use QWebSecurityOrigin::databases(). Each database has an internal name(), + as well as a user-friendly name, provided by displayName(). These names are specified when + creating the database in the JavaScript code. WebKit uses SQLite to create and access the local SQL databases. The location of the database file in the local file system is returned by fileName(). You can access the database directly @@ -49,7 +51,7 @@ using namespace WebCore; For each database the web site can define an expectedSize(). The current size of the database in bytes is returned by size(). - For more information refer to the \l{http://dev.w3.org/html5/webdatabase/}{HTML 5 Draft Standard}. + For more information refer to the \l{http://dev.w3.org/html5/webdatabase/}{HTML5 Web SQL Database Draft Standard}. \sa QWebSecurityOrigin */ @@ -80,7 +82,7 @@ QString QWebDatabase::name() const } /*! - Returns the name of the database as seen by the user. + Returns the name of the database in a format that is suitable for display to the user. */ QString QWebDatabase::displayName() const { diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp index 955206d..69146a2 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp @@ -84,13 +84,27 @@ public: \snippet webkitsnippets/webelement/main.cpp Traversing with QWebElement + Individual elements can be inspected or changed using methods such as attribute() + or setAttribute(). For examle, to capture the user's input in a text field for later + use (auto-completion), a browser could do something like this: + + \snippet webkitsnippets/webelement/main.cpp autocomplete1 + + When the same page is later revisited, the browser can fill in the text field automatically + by modifying the value attribute of the input element: + + \snippet webkitsnippets/webelement/main.cpp autocomplete2 + + Another use case is to emulate a click event on an element. The following + code snippet demonstrates how to call the JavaScript DOM method click() of + a submit button: + + \snippet webkitsnippets/webelement/main.cpp Calling a DOM element method + The underlying content of QWebElement is explicitly shared. Creating a copy of a QWebElement does not create a copy of the content. Instead, both instances point to the same element. - The element's attributes can be read using attribute() and modified with - setAttribute(). - The contents of child elements can be converted to plain text with toPlainText(); to XHTML using toInnerXml(). To include the element's tag in the output, use toOuterXml(). diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp index 394ea17..44cc3b5 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp @@ -552,8 +552,10 @@ void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QWebFrame: can connect to the web page's \l{QWebPage::}{frameCreated()} signal to be notified when a new frame is created. - The hitTestContent() function can be used to programmatically examine the - contents of a frame. + There are multiple ways to programmatically examine the contents of a frame. + The hitTestContent() function can be used to find elements by coordinate. + For access to the underlying DOM tree, there is documentElement(), + findAllElements() and findFirstElement(). A QWebFrame can be printed onto a QPrinter using the print() function. This function is marked as a slot and can be conveniently connected to @@ -781,6 +783,10 @@ static inline QUrl ensureAbsoluteUrl(const QUrl &url) \property QWebFrame::url \brief the url of the frame currently viewed + Setting this property clears the view and loads the URL. + + By default, this property contains an empty, invalid URL. + \sa urlChanged() */ diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebhistoryinterface.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebhistoryinterface.cpp index 80567d1..61cf5af 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebhistoryinterface.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebhistoryinterface.cpp @@ -41,7 +41,7 @@ static void gCleanupInterface() /*! Sets a new default interface, \a defaultInterface, that will be used by all of WebKit - for managing history. + to keep track of visited links. If an interface without a parent has already been set, the old interface will be deleted. When the application exists QWebHistoryInterface will automatically delete the @@ -68,8 +68,9 @@ void QWebHistoryInterface::setDefaultInterface(QWebHistoryInterface* defaultInte } /*! - Returns the default interface that will be used by WebKit. If no - default interface has been set, QtWebkit will not track history. + Returns the default interface that will be used by WebKit. If no default interface has been set, + Webkit will not keep track of visited links and a null pointer will be returned. + \sa setDefaultInterface */ QWebHistoryInterface* QWebHistoryInterface::defaultInterface() { @@ -84,11 +85,15 @@ QWebHistoryInterface* QWebHistoryInterface::defaultInterface() \inmodule QtWebKit The QWebHistoryInterface is an interface that can be used to - implement link history. It contains two pure virtual methods that - are called by the WebKit engine. addHistoryEntry() is used to add - pages that have been visited to the interface, while - historyContains() is used to query whether this page has been - visited by the user. + keep track of visited links. It contains two pure virtual methods that + are called by the WebKit engine: addHistoryEntry() is used to add + urls that have been visited to the interface, while + historyContains() is used to query whether the given url has been + visited by the user. By default the QWebHistoryInterface is not set, so WebKit does not keep + track of visited links. + + \note The history tracked by QWebHistoryInterface is not specific to an instance of QWebPage + but applies to all pages. */ /*! @@ -100,7 +105,7 @@ QWebHistoryInterface::QWebHistoryInterface(QObject* parent) } /*! - Destructor. If this is currently the default interface it will be unset. + Destroys the interface. If this is currently the default interface it will be unset. */ QWebHistoryInterface::~QWebHistoryInterface() { diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp index c0e5277..802ea98 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp @@ -31,17 +31,23 @@ /*! \class QWebInspector \since 4.6 + \inmodule QtWebKit \brief The QWebInspector class allows the placement and control of a QWebPage's inspector. - The inspector allows you to see a page current hierarchy and loading - statistics. + The inspector can display a page's hierarchy, its loading statistics and + the current state of its individual elements. It is mostly used by web + developers. - The QWebPage to be inspected is determined with the setPage() method. + The QWebPage to be inspected must be specified using the setPage() method. A typical use of QWebInspector follows: \snippet webkitsnippets/qtwebkit_qwebinspector_snippet.cpp 0 + A QWebInspector can be made visible either programmatically using + setVisible(), or by the user through the attached QWebPage's context + menu. + \note A QWebInspector will display a blank widget if either: \list \o page() is null @@ -61,17 +67,16 @@ \section1 Inspector configuration persistence The inspector allows the user to configure some options through its - interface (e.g. the resource tracking "Always enable" option). - These settings are persisted automatically by QtWebKit using QSettings. - - However since the QSettings object is instantiated using the empty - constructor, QCoreApplication::setOrganizationName() and - QCoreApplication::setApplicationName() must be called within your - application to enable the persistence of these options. + user interface (e.g. the resource tracking "Always enable" option). + These settings will be persisted automatically by QtWebKit only if + your application previously called QCoreApplication::setOrganizationName() + and QCoreApplication::setApplicationName(). + See QSettings's default constructor documentation for an explanation + of why this is necessary. */ /*! - Constructs an empty QWebInspector with parent \a parent. + Constructs an unbound QWebInspector with \a parent as its parent. */ QWebInspector::QWebInspector(QWidget* parent) : QWidget(parent) @@ -89,16 +94,16 @@ QWebInspector::~QWebInspector() } /*! - Sets the QWebPage to be inspected. - - There can only be one QWebInspector associated with a QWebPage - and vices versa. + Bind this inspector to the QWebPage to be inspected. - Calling with \a page as null will break the current association, if any. - - If \a page is already associated to another QWebInspector, the association - will be replaced and the previous QWebInspector will have no page - associated. + \bold {Notes:} + \list + \o There can only be one QWebInspector associated with a QWebPage + and vice versa. + \o Calling this method with a null \a page will break the current association, if any. + \o If \a page is already associated to another QWebInspector, the association + will be replaced and the previous QWebInspector will become unbound + \endlist \sa page() */ diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebkitversion.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebkitversion.cpp index 062839f..181913b 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebkitversion.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebkitversion.cpp @@ -22,11 +22,21 @@ #include /*! - + \relates QWebPage + \since 4.6 Returns the version number of WebKit at run-time as a string (for - example, "531.3"). This is the version of WebKit the application - was compiled against. + example, "531.3"). + + This version is commonly used in WebKit based browsers as part + of the user agent string. Web servers and JavaScript might use + it to identify the presence of certain WebKit engine features + and behaviour. + The evolution of this version is bound to the releases of Apple's + Safari browser. For a version specific to the QtWebKit library, + see QTWEBKIT_VERSION + + \sa QWebPage::userAgentForUrl() */ QString qWebKitVersion() { @@ -34,11 +44,13 @@ QString qWebKitVersion() } /*! - + \relates QWebPage + \since 4.6 Returns the 'major' version number of WebKit at run-time as an integer (for example, 531). This is the version of WebKit the application was compiled against. + \sa qWebKitVersion() */ int qWebKitMajorVersion() { @@ -46,13 +58,57 @@ int qWebKitMajorVersion() } /*! - + \relates QWebPage + \since 4.6 Returns the 'minor' version number of WebKit at run-time as an integer (for example, 3). This is the version of WebKit the application was compiled against. + \sa qWebKitVersion() */ int qWebKitMinorVersion() { return WEBKIT_MINOR_VERSION; } + +/*! + \macro QTWEBKIT_VERSION + \relates QWebPage + + This macro expands a numeric value of the form 0xMMNNPP (MM = + major, NN = minor, PP = patch) that specifies QtWebKit's version + number. For example, if you compile your application against QtWebKit + 2.1.2, the QTWEBKIT_VERSION macro will expand to 0x020102. + + You can use QTWEBKIT_VERSION to use the latest QtWebKit API where + available. + + \sa QT_VERSION +*/ + +/*! + \macro QTWEBKIT_VERSION_STR + \relates QWebPage + + This macro expands to a string that specifies QtWebKit's version number + (for example, "2.1.2"). This is the version against which the + application is compiled. + + \sa QTWEBKIT_VERSION +*/ + +/*! + \macro QTWEBKIT_VERSION_CHECK + \relates QWebPage + + Turns the major, minor and patch numbers of a version into an + integer, 0xMMNNPP (MM = major, NN = minor, PP = patch). This can + be compared with another similarly processed version id, for example + in a preprocessor statement: + + \code + #if QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 1, 0) + // code to use API new in QtWebKit 2.1.0 + #endif + \endcode +*/ diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index e9ebce5..c5f508f 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -1627,7 +1627,7 @@ InspectorController* QWebPagePrivate::inspectorController() /*! \enum QWebPage::FindFlag - This enum describes the options available to QWebPage's findText() function. The options + This enum describes the options available to the findText() function. The options can be OR-ed together from the following list: \value FindBackward Searches backwards instead of forwards. @@ -1648,6 +1648,8 @@ InspectorController* QWebPagePrivate::inspectorController() \value DelegateExternalLinks When activating links that point to documents not stored on the local filesystem or an equivalent - such as the Qt resource system - then linkClicked() is emitted. \value DelegateAllLinks Whenever a link is activated the linkClicked() signal is emitted. + + \sa QWebPage::linkDelegationPolicy */ /*! @@ -1662,6 +1664,8 @@ InspectorController* QWebPagePrivate::inspectorController() \value NavigationTypeReload The user activated the reload action. \value NavigationTypeFormResubmitted An HTML form was submitted a second time. \value NavigationTypeOther A navigation to another document using a method not listed above. + + \sa acceptNavigationRequest() */ /*! @@ -1671,7 +1675,7 @@ InspectorController* QWebPagePrivate::inspectorController() Actions only have an effect when they are applicable. The availability of actions can be be determined by checking \l{QAction::}{isEnabled()} on the - action returned by \l{QWebPage::}{action()}. + action returned by action(). One method of enabling the text editing, cursor movement, and text selection actions is by setting \l contentEditable to true. @@ -1753,6 +1757,8 @@ InspectorController* QWebPagePrivate::inspectorController() /*! \enum QWebPage::WebWindowType + This enum describes the types of window that can be created by the createWindow() function. + \value WebBrowserWindow The window is a regular web browser window. \value WebModalDialog The window acts as modal dialog. */ @@ -1769,11 +1775,13 @@ InspectorController* QWebPagePrivate::inspectorController() to provide functionality like QWebView in a widget-less environment. QWebPage's API is very similar to QWebView, as you are still provided with - common functions like action() (known as \l{QWebView::}{pageAction()} in - QWebView), triggerAction(), findText() and settings(). More QWebView-like - functions can be found in the main frame of QWebPage, obtained via - QWebPage::mainFrame(). For example, the load(), setUrl() and setHtml() - unctions for QWebPage can be accessed using QWebFrame. + common functions like action() (known as + \l{QWebView::pageAction()}{pageAction}() in QWebView), triggerAction(), + findText() and settings(). More QWebView-like functions can be found in the + main frame of QWebPage, obtained via the mainFrame() function. For example, + the \l{QWebFrame::load()}{load}(), \l{QWebFrame::setUrl()}{setUrl}() and + \l{QWebFrame::setHtml()}{setHtml}() functions for QWebPage can be accessed + using QWebFrame. The loadStarted() signal is emitted when the page begins to load.The loadProgress() signal, on the other hand, is emitted whenever an element @@ -1877,7 +1885,8 @@ QWebFrame *QWebPage::currentFrame() const /*! \since 4.6 - Returns the frame at the given point \a pos. + Returns the frame at the given point \a pos, or 0 if there is no frame at + that position. \sa mainFrame(), currentFrame() */ @@ -1996,7 +2005,7 @@ bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg) result should be written to \a result and true should be returned. If the prompt was not cancelled by the user, the implementation should return true and the result string must not be null. - The default implementation uses QInputDialog::getText. + The default implementation uses QInputDialog::getText(). */ bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result) { @@ -2210,6 +2219,8 @@ QSize QWebPage::viewportSize() const By default, for a newly-created Web page, this property contains a size with zero width and height. + + \sa QWebFrame::render(), preferredContentsSize */ void QWebPage::setViewportSize(const QSize &size) const { @@ -2238,11 +2249,12 @@ QSize QWebPage::preferredContentsSize() const /*! \property QWebPage::preferredContentsSize \since 4.6 - \brief the size of the fixed layout + \brief the preferred size of the contents - The size affects the layout of the page in the viewport. If set to a fixed size of - 1024x768 for example then webkit will layout the page as if the viewport were that size - rather than something different. + If this property is set to a valid size, it is used to lay out the page. + If it is not set (the default), the viewport size is used instead. + + \sa viewportSize */ void QWebPage::setPreferredContentsSize(const QSize &size) const { @@ -2590,9 +2602,11 @@ QAction *QWebPage::action(WebAction action) const /*! \property QWebPage::modified - \brief whether the page contains unsubmitted form data + \brief whether the page contains unsubmitted form data, or the contents have been changed. By default, this property is false. + + \sa contentsChanged(), contentEditable, undoStack() */ bool QWebPage::isModified() const { @@ -2608,6 +2622,8 @@ bool QWebPage::isModified() const #ifndef QT_NO_UNDOSTACK /*! Returns a pointer to the undo stack used for editable content. + + \sa modified */ QUndoStack *QWebPage::undoStack() const { @@ -2730,7 +2746,7 @@ bool QWebPage::event(QEvent *ev) } /*! - Similar to QWidget::focusNextPrevChild it focuses the next focusable web element + Similar to QWidget::focusNextPrevChild() it focuses the next focusable web element if \a next is true; otherwise the previous element is focused. Returns true if it can find a new focusable element, or false if it can't. @@ -2757,6 +2773,8 @@ bool QWebPage::focusNextPrevChild(bool next) If this property is enabled the contents of the page can be edited by the user through a visible cursor. If disabled (the default) only HTML elements in the web page with their \c{contenteditable} attribute set are editable. + + \sa modified, contentsChanged(), WebAction */ void QWebPage::setContentEditable(bool editable) { @@ -2926,17 +2944,21 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) as a result of the user clicking on a "file upload" button in a HTML form where multiple file selection is allowed. - \omitvalue ErrorPageExtension (introduced in Qt 4.6) + \value ErrorPageExtension Whether the web page can provide an error page when loading fails. + (introduced in Qt 4.6) + + \sa ChooseMultipleFilesExtensionOption, ChooseMultipleFilesExtensionReturn, ErrorPageExtensionOption, ErrorPageExtensionReturn */ /*! \enum QWebPage::ErrorDomain \since 4.6 - \internal - \value QtNetwork - \value Http - \value WebKit + This enum describes the domain of an ErrorPageExtensionOption object (i.e. the layer in which the error occurred). + + \value QtNetwork The error occurred in the QtNetwork layer; the error code is of type QNetworkReply::NetworkError. + \value Http The error occurred in the HTTP layer; the error code is a HTTP status code (see QNetworkRequest::HttpStatusCodeAttribute). + \value WebKit The error is an internal WebKit error. */ /*! @@ -2946,7 +2968,18 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) \inmodule QtWebKit - \sa QWebPage::extension() + \sa QWebPage::extension() QWebPage::ExtensionReturn +*/ + + +/*! + \class QWebPage::ExtensionReturn + \since 4.4 + \brief The ExtensionReturn class provides an output result from a QWebPage's extension. + + \inmodule QtWebKit + + \sa QWebPage::extension() QWebPage::ExtensionOption */ /*! @@ -2957,12 +2990,38 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) \inmodule QtWebKit - The ErrorPageExtensionOption class holds the \a url for which an error occoured as well as + The ErrorPageExtensionOption class holds the \a url for which an error occurred as well as the associated \a frame. The error itself is reported by an error \a domain, the \a error code as well as \a errorString. - \sa QWebPage::ErrorPageExtensionReturn + \sa QWebPage::extension() QWebPage::ErrorPageExtensionReturn +*/ + +/*! + \variable QWebPage::ErrorPageExtensionOption::url + \brief the url for which an error occurred +*/ + +/*! + \variable QWebPage::ErrorPageExtensionOption::frame + \brief the frame associated with the error +*/ + +/*! + \variable QWebPage::ErrorPageExtensionOption::domain + \brief the domain that reported the error +*/ + +/*! + \variable QWebPage::ErrorPageExtensionOption::error + \brief the error code. Interpretation of the value depends on the \a domain + \sa QWebPage::ErrorDomain +*/ + +/*! + \variable QWebPage::ErrorPageExtensionOption::errorString + \brief a string that describes the error */ /*! @@ -2983,7 +3042,7 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) External objects such as stylesheets or images referenced in the HTML are located relative to \a baseUrl. - \sa QWebPage::ErrorPageExtensionOption, QString::toUtf8() + \sa QWebPage::extension() QWebPage::ErrorPageExtensionOption, QString::toUtf8() */ /*! @@ -2992,6 +3051,29 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) Constructs a new error page object. */ + +/*! + \variable QWebPage::ErrorPageExtensionReturn::contentType + \brief the error page's content type +*/ + +/*! + \variable QWebPage::ErrorPageExtensionReturn::encoding + \brief the error page encoding +*/ + +/*! + \variable QWebPage::ErrorPageExtensionReturn::baseUrl + \brief the base url + + External objects such as stylesheets or images referenced in the HTML are located relative to this url. +*/ + +/*! + \variable QWebPage::ErrorPageExtensionReturn::content + \brief the HTML content of the error page +*/ + /*! \class QWebPage::ChooseMultipleFilesExtensionOption \since 4.5 @@ -3003,7 +3085,22 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) The ChooseMultipleFilesExtensionOption class holds the frame originating the request and the suggested filenames which might be provided. - \sa QWebPage::chooseFile(), QWebPage::ChooseMultipleFilesExtensionReturn + \sa QWebPage::extension() QWebPage::chooseFile(), QWebPage::ChooseMultipleFilesExtensionReturn +*/ + +/*! + \variable QWebPage::ChooseMultipleFilesExtensionOption::parentFrame + \brief The frame in which the request originated +*/ + +/*! + \variable QWebPage::ChooseMultipleFilesExtensionOption::suggestedFileNames + \brief The suggested filenames +*/ + +/*! + \variable QWebPage::ChooseMultipleFilesExtensionReturn::fileNames + \brief The selected filenames */ /*! @@ -3017,14 +3114,17 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) The ChooseMultipleFilesExtensionReturn class holds the filenames selected by the user when the extension is invoked. - \sa QWebPage::ChooseMultipleFilesExtensionOption + \sa QWebPage::extension() QWebPage::ChooseMultipleFilesExtensionOption */ /*! This virtual function can be reimplemented in a QWebPage subclass to provide support for extensions. The \a option argument is provided as input to the extension; the output results can be stored in \a output. - The behavior of this function is determined by \a extension. + The behavior of this function is determined by \a extension. The \a option + and \a output values are typically casted to the corresponding types (for + example, ChooseMultipleFilesExtensionOption and + ChooseMultipleFilesExtensionReturn for ChooseMultipleFilesExtension). You can call supportsExtension() to check if an extension is supported by the page. @@ -3116,6 +3216,8 @@ QWebSettings *QWebPage::settings() const A suggested filename may be provided in \a suggestedFile. The frame originating the request is provided as \a parentFrame. + + \sa ChooseMultipleFilesExtension */ QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& suggestedFile) { @@ -3369,6 +3471,15 @@ QString QWebPage::userAgentForUrl(const QUrl&) const case QSysInfo::SV_9_4: firstPartTemp += QString::fromLatin1("/9.4"); break; + case QSysInfo::SV_SF_2: + firstPartTemp += QString::fromLatin1("^2"); + break; + case QSysInfo::SV_SF_3: + firstPartTemp += QString::fromLatin1("^3"); + break; + case QSysInfo::SV_SF_4: + firstPartTemp += QString::fromLatin1("^4"); + break; default: firstPartTemp += QString::fromLatin1("/Unknown"); } @@ -3479,7 +3590,7 @@ quint64 QWebPage::totalBytes() const /*! Returns the number of bytes that were received from the network to render the current page. - \sa totalBytes() + \sa totalBytes(), loadProgress() */ quint64 QWebPage::bytesReceived() const { @@ -3511,7 +3622,7 @@ quint64 QWebPage::bytesReceived() const This signal is emitted when a load of the page is finished. \a ok will indicate whether the load was successful or any error occurred. - \sa loadStarted() + \sa loadStarted(), ErrorPageExtension */ /*! @@ -3538,12 +3649,15 @@ quint64 QWebPage::bytesReceived() const \fn void QWebPage::frameCreated(QWebFrame *frame) This signal is emitted whenever the page creates a new \a frame. + + \sa currentFrame() */ /*! \fn void QWebPage::selectionChanged() - This signal is emitted whenever the selection changes. + This signal is emitted whenever the selection changes, either interactively + or programmatically (e.g. by calling triggerAction() with a selection action). \sa selectedText() */ @@ -3555,7 +3669,7 @@ quint64 QWebPage::bytesReceived() const This signal is emitted whenever the text in form elements changes as well as other editable content. - \sa contentEditable, QWebFrame::toHtml(), QWebFrame::toPlainText() + \sa contentEditable, modified, QWebFrame::toHtml(), QWebFrame::toPlainText() */ /*! @@ -3631,9 +3745,9 @@ quint64 QWebPage::bytesReceived() const \fn void QWebPage::microFocusChanged() This signal is emitted when for example the position of the cursor in an editable form - element changes. It is used inform input methods about the new on-screen position where - the user is able to enter text. This signal is usually connected to QWidget's updateMicroFocus() - slot. + element changes. It is used to inform input methods about the new on-screen position where + the user is able to enter text. This signal is usually connected to the + QWidget::updateMicroFocus() slot. */ /*! @@ -3674,6 +3788,8 @@ quint64 QWebPage::bytesReceived() const This signal is emitted whenever the web site shown in \a frame is asking to store data to the database \a databaseName and the quota allocated to that web site is exceeded. + + \sa QWebDatabase */ /*! diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp index 8ff13b1..f715430 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp @@ -23,25 +23,40 @@ /*! \class QWebPluginFactory \since 4.4 - \brief The QWebPluginFactory class creates plugins to be embedded into web - pages. + \brief The QWebPluginFactory class is used to embed custom data types in web pages. \inmodule QtWebKit - QWebPluginFactory is a factory for creating plugins for QWebPage. A plugin - factory can be installed on a QWebPage using QWebPage::setPluginFactory(). + The HTML \c{} tag is used to embed arbitrary content into a web page, + for example: + + \code + + \endcode + + QtWebkit will natively handle the most basic data types like \c{text/html} and + \c{image/jpeg}, but for any advanced or custom data types you will need to + provide a handler yourself. + + QWebPluginFactory is a factory for creating plugins for QWebPage, where each + plugin provides support for one or more data types. A plugin factory can be + installed on a QWebPage using QWebPage::setPluginFactory(). \note The plugin factory is only used if plugins are enabled through QWebSettings. - You can provide a QWebPluginFactory by implementing the plugins() and the - create() method. For plugins() it is necessary to describe the plugins the + You provide a QWebPluginFactory by implementing the plugins() and the + create() methods. For plugins() it is necessary to describe the plugins the factory can create, including a description and the supported MIME types. The MIME types each plugin can handle should match the ones specified in - in the HTML \c{} tag. + in the HTML \c{} tag of your content. The create() method is called if the requested MIME type is supported. The implementation has to return a new instance of the plugin requested for the given MIME type and the specified URL. + + The plugins themselves are subclasses of QObject, but currently only plugins + based on either QWidget or QGraphicsWidget are supported. + */ @@ -183,6 +198,7 @@ void QWebPluginFactory::refreshPlugins() /*! \enum QWebPluginFactory::Extension + \internal This enum describes the types of extensions that the plugin factory can support. Before using these extensions, you should verify that the extension is supported by calling supportsExtension(). @@ -192,6 +208,7 @@ void QWebPluginFactory::refreshPlugins() /*! \class QWebPluginFactory::ExtensionOption + \internal \since 4.4 \brief The ExtensionOption class provides an extended input argument to QWebPluginFactory's extension support. @@ -202,6 +219,7 @@ void QWebPluginFactory::refreshPlugins() /*! \class QWebPluginFactory::ExtensionReturn + \internal \since 4.4 \brief The ExtensionOption class provides an extended output argument to QWebPluginFactory's extension support. @@ -214,6 +232,8 @@ void QWebPluginFactory::refreshPlugins() This virtual function can be reimplemented in a QWebPluginFactory subclass to provide support for extensions. The \a option argument is provided as input to the extension; the output results can be stored in \a output. + \internal + The behaviour of this function is determined by \a extension. You can call supportsExtension() to check if an extension is supported by the factory. @@ -233,6 +253,8 @@ bool QWebPluginFactory::extension(Extension extension, const ExtensionOption *op /*! This virtual function returns true if the plugin factory supports \a extension; otherwise false is returned. + \internal + \sa extension() */ bool QWebPluginFactory::supportsExtension(Extension extension) const diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp index 6c26bd7..7179eaa 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp @@ -63,6 +63,16 @@ void QWEBKIT_EXPORT qt_drt_setDomainRelaxationForbiddenForURLScheme(bool forbidd \c{http://www.malicious.com/evil.html} from accessing \c{http://www.example.com/}'s resources, because they are of a different security origin. + By default local schemes like \c{file://} and \c{qrc://} are concidered to be in the same + security origin, and can access each other's resources. You can add additional local schemes + by using QWebSecurityOrigin::addLocalScheme(), or override the default same-origin behavior + by setting QWebSettings::LocalContentCanAccessFileUrls to \c{false}. + + \note Local resources are by default restricted from accessing remote content, which + means your \c{file://} will not be able to access \c{http://domain.com/foo.html}. You + can relax this restriction by setting QWebSettings::LocalContentCanAccessRemoteUrls to + \c{true}. + Call QWebFrame::securityOrigin() to get the QWebSecurityOrigin for a frame in a web page, and use host(), scheme() and port() to identify the security origin. @@ -219,7 +229,11 @@ QList QWebSecurityOrigin::databases() const \since 4.6 Adds the given \a scheme to the list of schemes that are considered equivalent - to the \c file: scheme. They are not subject to cross domain restrictions. + to the \c file: scheme. + + Cross domain restrictions depend on the two web settings QWebSettings::LocalContentCanAccessFileUrls + and QWebSettings::LocalContentCanAccessFileUrls. By default all local schemes are concidered to be + in the same security origin, and local schemes can not access remote content. */ void QWebSecurityOrigin::addLocalScheme(const QString& scheme) { @@ -231,6 +245,9 @@ void QWebSecurityOrigin::addLocalScheme(const QString& scheme) Removes the given \a scheme from the list of local schemes. + \note You can not remove the \c{file://} scheme from the list + of local schemes. + \sa addLocalScheme() */ void QWebSecurityOrigin::removeLocalScheme(const QString& scheme) @@ -240,7 +257,10 @@ void QWebSecurityOrigin::removeLocalScheme(const QString& scheme) /*! \since 4.6 - Returns a list of all the schemes that were set by the application as local schemes, + Returns a list of all the schemes concidered to be local. + + By default this is \c{file://} and \c{qrc://}. + \sa addLocalScheme(), removeLocalScheme() */ QStringList QWebSecurityOrigin::localSchemes() diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp index ae7f6a8..115f9fc 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp @@ -289,8 +289,8 @@ QWebSettings* QWebSettings::globalSettings() function. The \l{QWebSettings::WebAttribute}{WebAttribute} enum further describes each attribute. - QWebSettings also configures global properties such as the Web page memory - cache and the Web page icon database, local database storage and offline + QWebSettings also configures global properties such as the web page memory + cache, icon database, local database storage and offline applications storage. \section1 Enabling Plugins @@ -299,8 +299,8 @@ QWebSettings* QWebSettings::globalSettings() \l{QWebSettings::PluginsEnabled}{PluginsEnabled} attribute. For many applications, this attribute is enabled for all pages by setting it on the \l{globalSettings()}{global settings object}. QtWebKit will always ignore this setting - \when processing Qt plugins. The decision to allow a Qt plugin is made by the client - \in its reimplementation of QWebPage::createPlugin. + when processing Qt plugins. The decision to allow a Qt plugin is made by the client + in its reimplementation of QWebPage::createPlugin(). \section1 Web Application Support @@ -339,7 +339,7 @@ QWebSettings* QWebSettings::globalSettings() \value MinimumFontSize The hard minimum font size. \value MinimumLogicalFontSize The minimum logical font size that is applied - after zooming with QWebFrame's textSizeMultiplier(). + when zooming out with QWebFrame::setTextSizeMultiplier(). \value DefaultFontSize The default font size for regular text. \value DefaultFixedFontSize The default font size for fixed-pitch text. */ @@ -361,66 +361,74 @@ QWebSettings* QWebSettings::globalSettings() This enum describes various attributes that are configurable through QWebSettings. \value AutoLoadImages Specifies whether images are automatically loaded in - web pages. + web pages. This is enabled by default. \value DnsPrefetchEnabled Specifies whether QtWebkit will try to pre-fetch DNS entries to - speed up browsing. This only works as a global attribute. Only for Qt 4.6 and later. + speed up browsing. This only works as a global attribute. Only for Qt 4.6 and later. This is disabled by default. \value JavascriptEnabled Enables or disables the running of JavaScript - programs. + programs. This is enabled by default \value JavaEnabled Enables or disables Java applets. Currently Java applets are not supported. - \value PluginsEnabled Enables or disables plugins in Web pages. Qt plugins - with a mimetype such as "application/x-qt-plugin" are not affected by this setting. + \value PluginsEnabled Enables or disables plugins in Web pages (e.g. using NPAPI). Qt plugins + with a mimetype such as "application/x-qt-plugin" are not affected by this setting. This is disabled by default. \value PrivateBrowsingEnabled Private browsing prevents WebKit from - recording visited pages in the history and storing web page icons. + recording visited pages in the history and storing web page icons. This is disabled by default. \value JavascriptCanOpenWindows Specifies whether JavaScript programs - can open new windows. + can open new windows. This is disabled by default. \value JavascriptCanAccessClipboard Specifies whether JavaScript programs - can read or write to the clipboard. + can read or write to the clipboard. This is disabled by default. \value DeveloperExtrasEnabled Enables extra tools for Web developers. Currently this enables the "Inspect" element in the context menu as - well as the use of QWebInspector which controls the WebKit WebInspector - for web site debugging. + well as the use of QWebInspector which controls the web inspector + for web site debugging. This is disabled by default. \value SpatialNavigationEnabled Enables or disables the Spatial Navigation feature, which consists in the ability to navigate between focusable elements in a Web page, such as hyperlinks and form controls, by using - Left, Right, Up and Down arrow keys. For example, if an user presses the + Left, Right, Up and Down arrow keys. For example, if a user presses the Right key, heuristics determine whether there is an element he might be - trying to reach towards the right, and if there are multiple elements, - which element he probably wants. + trying to reach towards the right and which element he probably wants. + This is disabled by default. \value LinksIncludedInFocusChain Specifies whether hyperlinks should be - included in the keyboard focus chain. - \value ZoomTextOnly Specifies whether the zoom factor on a frame applies to - only the text or all content. + included in the keyboard focus chain. This is enabled by default. + \value ZoomTextOnly Specifies whether the zoom factor on a frame applies + only to the text or to all content. This is disabled by default. \value PrintElementBackgrounds Specifies whether the background color and images - are also drawn when the page is printed. + are also drawn when the page is printed. This is enabled by default. \value OfflineStorageDatabaseEnabled Specifies whether support for the HTML 5 - offline storage feature is enabled or not. Disabled by default. + offline storage feature is enabled or not. This is disabled by default. \value OfflineWebApplicationCacheEnabled Specifies whether support for the HTML 5 - web application cache feature is enabled or not. Disabled by default. + web application cache feature is enabled or not. This is disabled by default. \value LocalStorageEnabled Specifies whether support for the HTML 5 - local storage feature is enabled or not. Disabled by default. + local storage feature is enabled or not. This is disabled by default. \value LocalStorageDatabaseEnabled \e{This enum value is deprecated.} Use QWebSettings::LocalStorageEnabled instead. - \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are allowed to access remote urls. - \value LocalContentCanAccessFileUrls Specifies whether locally loaded documents are allowed to access other local urls. - \value XSSAuditorEnabled Specifies whether load requests should be monitored for cross-site scripting attempts. + \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are + allowed to access remote urls. This is disabled by default. For more information + about security origins and local vs. remote content see QWebSecurityOrigin. + \value LocalContentCanAccessFileUrls Specifies whether locally loaded documents are + allowed to access other local urls. This is enabled by default. For more information + about security origins and local vs. remote content see QWebSecurityOrigin. + \value XSSAuditingEnabled Specifies whether load requests should be monitored for cross-site + scripting attempts. Suspicious scripts will be blocked and reported in the inspector's + JavaScript console. Enabling this feature might have an impact on performance + and it is disabled by default. \value AcceleratedCompositingEnabled This feature, when used in conjunction with QGraphicsWebView, accelerates animations of web content. CSS animations of the transform and opacity properties will be rendered by composing the cached content of the animated elements. - This feature is enabled by default + This is enabled by default. \value TiledBackingStoreEnabled This setting enables the tiled backing store feature for a QGraphicsWebView. With the tiled backing store enabled, the web page contents in and around the current visible area is speculatively cached to bitmap tiles. The tiles are automatically kept in sync with the web page as it changes. Enabling tiling can significantly speed up painting heavy operations like scrolling. Enabling the feature increases memory consumption. It does not work well with contents using CSS fixed positioning (see also \l{QGraphicsWebView::}{resizesToContents} property). - \l{QGraphicsWebView::}{tiledBackingStoreFrozen} property allows application to temporarily freeze the contents of the backing store. + \l{QGraphicsWebView::}{tiledBackingStoreFrozen} property allows application to temporarily + freeze the contents of the backing store. This is disabled by default. \value FrameFlatteningEnabled With this setting each subframe is expanded to its contents. On touch devices, it is desired to not have any scrollable sub parts of the page as it results in a confusing user experience, with scrolling sometimes scrolling sub parts and at other times scrolling the page itself. For this reason iframes and framesets are barely usable on touch devices. This will flatten all the frames to become one scrollable page. - Disabled by default. + This is disabled by default. */ /*! @@ -525,7 +533,8 @@ void QWebSettings::resetFontSize(FontSize type) with UTF-8 and Base64 encoded data, such as: "data:text/css;charset=utf-8;base64,cCB7IGJhY2tncm91bmQtY29sb3I6IHJlZCB9Ow==" - NOTE: In case the base 64 data is not valid the style will not be applied. + + \note If the base64 data is not valid, the style will not be applied. \sa userStyleSheetUrl() */ @@ -576,9 +585,11 @@ QString QWebSettings::defaultTextEncoding() const Sets the path of the icon database to \a path. The icon database is used to store "favicons" associated with web sites. - \a path must point to an existing directory where the icons are stored. + \a path must point to an existing directory. Setting an empty path disables the icon database. + + \sa iconDatabasePath(), clearIconDatabase() */ void QWebSettings::setIconDatabasePath(const QString& path) { @@ -621,7 +632,7 @@ void QWebSettings::clearIconDatabase() /*! Returns the web site's icon for \a url. - If the web site does not specify an icon, or the icon is not in the + If the web site does not specify an icon \bold OR if the icon is not in the database, a null QIcon is returned. \note The returned icon's size is arbitrary. @@ -658,7 +669,7 @@ QWebPluginDatabase *QWebSettings::pluginDatabase() Sets \a graphic to be drawn when QtWebKit needs to draw an image of the given \a type. - For example, when an image cannot be loaded the pixmap specified by + For example, when an image cannot be loaded, the pixmap specified by \l{QWebSettings::WebGraphic}{MissingImageGraphic} is drawn instead. \sa webGraphic() @@ -676,9 +687,6 @@ void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap& graphic) Returns a previously set pixmap used to draw replacement graphics of the specified \a type. - For example, when an image cannot be loaded the pixmap specified by - \l{QWebSettings::WebGraphic}{MissingImageGraphic} is drawn instead. - \sa setWebGraphic() */ QPixmap QWebSettings::webGraphic(WebGraphic type) @@ -719,8 +727,7 @@ void QWebSettings::clearMemoryCaches() Sets the maximum number of pages to hold in the memory page cache to \a pages. The Page Cache allows for a nicer user experience when navigating forth or back - to pages in the forward/back history, by pausing and resuming up to \a pages - per page group. + to pages in the forward/back history, by pausing and resuming up to \a pages. For more information about the feature, please refer to: @@ -792,8 +799,8 @@ QString QWebSettings::fontFamily(FontFamily which) const } /*! - Resets the actual font family to the default font family, specified by - \a which. + Resets the actual font family specified by \a which to the one set + in the global QWebSettings instance. This function has no effect on the global QWebSettings instance. */ @@ -835,7 +842,9 @@ bool QWebSettings::testAttribute(WebAttribute attr) const /*! \fn void QWebSettings::resetAttribute(WebAttribute attribute) - Resets the setting of \a attribute. + Resets the setting of \a attribute to the value specified in the + global QWebSettings instance. + This function has no effect on the global QWebSettings instance. \sa globalSettings() @@ -851,12 +860,15 @@ void QWebSettings::resetAttribute(WebAttribute attr) /*! \since 4.5 - Sets the path for HTML5 offline storage to \a path. + Sets \a path as the save location for HTML5 client-side database storage data. - \a path must point to an existing directory where the databases are stored. + \a path must point to an existing directory. Setting an empty path disables the feature. + Support for client-side databases can enabled by setting the + \l{QWebSettings::OfflineStorageDatabaseEnabled}{OfflineStorageDatabaseEnabled} attribute. + \sa offlineStoragePath() */ void QWebSettings::setOfflineStoragePath(const QString& path) @@ -869,7 +881,7 @@ void QWebSettings::setOfflineStoragePath(const QString& path) /*! \since 4.5 - Returns the path of the HTML5 offline storage or an empty string if the + Returns the path of the HTML5 client-side database storage or an empty string if the feature is disabled. \sa setOfflineStoragePath() @@ -906,22 +918,24 @@ qint64 QWebSettings::offlineStorageDefaultQuota() /*! \since 4.6 - \relates QWebSettings Sets the path for HTML5 offline web application cache storage to \a path. An application cache acts like an HTTP cache in some sense. For documents - that use the application cache via JavaScript, the loader mechinery will + that use the application cache via JavaScript, the loader engine will first ask the application cache for the contents, before hitting the network. The feature is described in details at: http://dev.w3.org/html5/spec/Overview.html#appcache - \a path must point to an existing directory where the cache is stored. + \a path must point to an existing directory. Setting an empty path disables the feature. + Support for offline web application cache storage can enabled by setting the + \l{QWebSettings::OfflineWebApplicationCacheEnabled}{OfflineWebApplicationCacheEnabled} attribute. + \sa offlineWebApplicationCachePath() */ void QWebSettings::setOfflineWebApplicationCachePath(const QString& path) @@ -933,7 +947,6 @@ void QWebSettings::setOfflineWebApplicationCachePath(const QString& path) /*! \since 4.6 - \relates QWebSettings Returns the path of the HTML5 offline web application cache storage or an empty string if the feature is disabled. @@ -980,7 +993,6 @@ qint64 QWebSettings::offlineWebApplicationCacheQuota() /*! \since 4.6 - \relates QWebSettings Sets the path for HTML5 local storage to \a path. @@ -1025,7 +1037,6 @@ QUrl QWebSettings::inspectorUrl() const /*! \since 4.6 - \relates QWebSettings Returns the path for HTML5 local storage. @@ -1038,13 +1049,14 @@ QString QWebSettings::localStoragePath() const /*! \since 4.6 - \relates QWebSettings - Enables WebKit persistent data and sets the path to \a path. - If the \a path is empty the path for persistent data is set to the - user-specific data location specified by - \l{QDesktopServices::DataLocation}{DataLocation}. - + Enables WebKit data persistence and sets the path to \a path. + If \a path is empty, the user-specific data location specified by + \l{QDesktopServices::DataLocation}{DataLocation} will be used instead. + + This method will simultaneously set and enable the iconDatabasePath(), + localStoragePath(), offlineStoragePath() and offlineWebApplicationCachePath(). + \sa localStoragePath() */ void QWebSettings::enablePersistentStorage(const QString& path) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h index d2e536e..3592e2c 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h @@ -63,7 +63,7 @@ public: OfflineStorageDatabaseEnabled, OfflineWebApplicationCacheEnabled, LocalStorageEnabled, -#ifdef QT_DEPRECATED +#if defined(QT_DEPRECATED) || defined(qdoc) LocalStorageDatabaseEnabled = LocalStorageEnabled, #endif LocalContentCanAccessRemoteUrls, diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 6ddaa2b..efc8f27 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,102 @@ +2010-05-14 Kent Hansen , Jocelyn Turcotte , Tor Arne Vestbø , Henry Haverinen , Jedrzej Nowacki , Andreas Kling + + Reviewed by Simon Hausmann. + + [Qt] Merge overhaul of the QtWebKit API documentation + + Numerous improvements in wording, qdoc warning fixes and + clarifications, done in a team work effort. + + No functional changes. + + * Api/qwebdatabase.cpp: + * Api/qwebelement.cpp: + * Api/qwebframe.cpp: + * Api/qwebhistoryinterface.cpp: + * Api/qwebinspector.cpp: + * Api/qwebkitversion.cpp: + * Api/qwebpage.cpp: + * Api/qwebpluginfactory.cpp: + * Api/qwebsecurityorigin.cpp: + * Api/qwebsettings.cpp: + * Api/qwebsettings.h: + * docs/qtwebkit.qdoc: + * docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp: + (wrapInFunction): + * docs/webkitsnippets/webelement/main.cpp: + (findButtonAndClick): + (autocomplete1): + (autocomplete2): + (main): + +2010-05-14 Martin Smith + + Reviewed by Simon Hausmann. + + Documentation: Fix overview grouping. + + * docs/qtwebkit.qdoc: + +2010-05-14 Benjamin Poulain + + Reviewed by Laszlo Gombos. + + [QT] Update the Symbian version for the user agent + https://bugs.webkit.org/show_bug.cgi?id=38389 + + Update the user agent for Symbian^2 to Symbian^4 + + * Api/qwebpage.cpp: + (QWebPage::userAgentForUrl): + +2010-05-11 Antonio Gomes + + Reviewed by Kenneth Christiansen. + + [Qt] emit initialLayoutCompleted signal from FrameLoaderClientQt::dispatchDidFirstVisuallyNonEmptyLayout + https://bugs.webkit.org/show_bug.cgi?id=38921 + + Emit initialLayoutCompleted signal from FrameLoaderClientQt::dispatchDidFirstVisuallyNonEmptyLayout + instead of FrameLoaderClientQt::dispatchDidFirstLayout , because the former ensures that a + visual content layed out on the frame. + + It matches to QWebFrame::initialLayoutCompleted signal documentation at: + + "... This is the first time you will see contents displayed on the frame ..." + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDidFirstLayout): + (WebCore::FrameLoaderClientQt::dispatchDidFirstVisuallyNonEmptyLayout): + +2010-05-11 Kenneth Rohde Christiansen + + Reviewed by Laszlo Gombos. + + [Qt] REGRESSION(r58497) tst_QGraphicsWebView::crashOnViewlessWebPages() is failing + https://bugs.webkit.org/show_bug.cgi?id=38655 + + Fix double free by moving the connect till after the resize. + + The bug is causes by the fact that a resize of an empty page causes a + layout, thus deleting the qgraphicswebview before setHtml is called, + which then deletes it again, causing a double free. + + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::crashOnViewlessWebPages): + +2010-05-11 Diego Gonzalez + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] tst_QWebPage::inputMethods failing on Maemo5 + https://bugs.webkit.org/show_bug.cgi?id=38685 + + Check if the SIP (Software Input Panel) is triggered, which normally + happens on mobile platforms, when a user input form receives a mouse click. + + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::inputMethods): + 2010-05-09 Noam Rosenthal Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index 4ad008b..686bfcc 100644 --- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -414,13 +414,13 @@ void FrameLoaderClientQt::dispatchDidFinishLoad() void FrameLoaderClientQt::dispatchDidFirstLayout() { - if (m_webFrame) - emit m_webFrame->initialLayoutCompleted(); + notImplemented(); } void FrameLoaderClientQt::dispatchDidFirstVisuallyNonEmptyLayout() { - notImplemented(); + if (m_webFrame) + emit m_webFrame->initialLayoutCompleted(); } void FrameLoaderClientQt::dispatchShow() diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc index 96eb16e..c6dd550 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc +++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc @@ -7,63 +7,9 @@ \ingroup modules \ingroup technology-apis - \brief The QtWebKit module provides a web browser engine and + \brief The QtWebKit module provides a web browser engine as well as classes to render and interact with web content. - To include the definitions of the module's classes, use the - following directive: - - \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 1 - - To link against the module, add this line to your \l qmake \c - .pro file: - - \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 0 - - \section1 License Information - - This is a snapshot of the Qt port of WebKit. The exact version information - can be found in the \c{src/3rdparty/webkit/VERSION} file supplied with Qt. - - Qt Commercial Edition licensees that wish to distribute applications that - use the QtWebKit module need to be aware of their obligations under the - GNU Library General Public License (LGPL). - - Developers using the Open Source Edition can choose to redistribute - the module under the appropriate version of the GNU LGPL. - - \legalese - WebKit is licensed under the GNU Library General Public License. - Individual contributor names and copyright dates can be found - inline in the code. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - \endlegalese -*/ - -/*! - \page webintegration.html - \title Integrating Web Content with QtWebKit - \since 4.4 - - \ingroup frameworks-technologies - - \keyword Browser - \keyword Web Browser - QtWebKit provides a Web browser engine that makes it easy to embed content from the World Wide Web into your Qt application. At the same time Web content can be enhanced with native controls. @@ -85,6 +31,20 @@ QtWebKit is based on the Open Source WebKit engine. More information about WebKit itself can be found on the \l{WebKit Open Source Project} Web site. + \section1 Including In Your Project + + To include the definitions of the module's classes, use the + following directive: + + \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 1 + + To link against the module, add this line to your \l qmake \c + .pro file: + + \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 0 + + \section1 Notes + \note Building the QtWebKit module with debugging symbols is problematic on many platforms due to the size of the WebKit engine. We recommend building the module only in release mode for embedded platforms. @@ -99,10 +59,6 @@ Embedded Linux systems. See the \l{Qt for Embedded Linux Requirements} document for more information. - Topics: - - \tableofcontents - \section1 Architecture The easiest way to render content is through the QWebView class. As a @@ -195,4 +151,39 @@ \o The system \c{/Library/Internet Plug-Ins} directory \endlist \endtable + + + \section1 License Information + + This is a snapshot of the Qt port of WebKit. The exact version information + can be found in the \c{src/3rdparty/webkit/VERSION} file supplied with Qt. + + Qt Commercial Edition licensees that wish to distribute applications that + use the QtWebKit module need to be aware of their obligations under the + GNU Library General Public License (LGPL). + + Developers using the Open Source Edition can choose to redistribute + the module under the appropriate version of the GNU LGPL. + + \legalese + WebKit is licensed under the GNU Library General Public License. + Individual contributor names and copyright dates can be found + inline in the code. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + \endlegalese */ + diff --git a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp index a6b6620..07f1d45 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp +++ b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp @@ -9,8 +9,6 @@ void wrapInFunction() QWebInspector *inspector = new QWebInspector; inspector->setPage(page); - - connect(page, SIGNAL(webInspectorTriggered(QWebElement)), inspector, SLOT(show())); //! [0] } diff --git a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webelement/main.cpp b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webelement/main.cpp index 822b61c..b1781a6 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webelement/main.cpp +++ b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webelement/main.cpp @@ -36,6 +36,59 @@ static void traverse() //! [Traversing with QWebElement] } +static void findButtonAndClick() +{ + + frame->setHtml("
      " + "" + "" + "
      "); + +//! [Calling a DOM element method] + + QWebElement document = frame->documentElement(); + /* Assume that the document has the following structure: + +
      + + +
      + + */ + + QWebElement button = document.findFirst("input[type=submit]"); + button.evaluateJavaScript("click()"); + +//! [Calling a DOM element method] + + } + +static void autocomplete1() +{ + QWebElement document = frame->documentElement(); + +//! [autocomplete1] + QWebElement firstTextInput = document.findFirst("input[type=text]"); + QString storedText = firstTextInput.attribute("value"); +//! [autocomplete1] + +} + + +static void autocomplete2() +{ + + QWebElement document = frame->documentElement(); + QString storedText = "text"; + +//! [autocomplete2] + QWebElement firstTextInput = document.findFirst("input[type=text]"); + textInput.setAttribute("value", storedText); +//! [autocomplete2] + +} + + static void findAll() { //! [FindAll] @@ -65,5 +118,8 @@ int main(int argc, char *argv[]) frame = view->page()->mainFrame(); traverse(); findAll(); + findButtonAndClick(); + autocomplete1(); + autocomplete2(); return 0; } diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp index 14f5820..ebe847d 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp @@ -84,16 +84,19 @@ void tst_QGraphicsWebView::crashOnViewlessWebPages() WebPage* page = new WebPage; webView->setPage(page); page->webView = webView; - connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), page, SLOT(aborting())); - scene.addItem(webView); view.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); view.resize(600, 480); webView->resize(view.geometry().size()); + QCoreApplication::processEvents(); view.show(); + // Resizing the page will resize and layout the empty "about:blank" + // page, so we first connect the signal afterward. + connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), page, SLOT(aborting())); + page->mainFrame()->setHtml(QString("data:text/html," "" "" @@ -101,6 +104,7 @@ void tst_QGraphicsWebView::crashOnViewlessWebPages() "")); QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); + delete page; } void tst_QGraphicsWebView::microFocusCoordinates() diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 834a394..12fb9b3 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1367,7 +1368,27 @@ void tst_QWebPage::inputMethods() page->event(&evrel); #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) - QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); + // This part of the test checks if the SIP (Software Input Panel) is triggered, + // which normally happens on mobile platforms, when a user input form receives + // a mouse click. + int inputPanel = 0; + if (viewType == "QWebView") { + if (QWebView* wv = qobject_cast(view)) + inputPanel = wv->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel); + } else if (viewType == "QGraphicsWebView") { + if (QGraphicsWebView* wv = qobject_cast(view)) + inputPanel = wv->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel); + } + + // For non-mobile platforms RequestSoftwareInputPanel event is not called + // because there is no SIP (Software Input Panel) triggered. In the case of a + // mobile platform, an input panel, e.g. virtual keyboard, is usually invoked + // and the RequestSoftwareInputPanel event is called. For these two situations + // this part of the test can verified as the checks below. + if (inputPanel) + QVERIFY(viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); + else + QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); #endif viewEventSpy.clear(); -- cgit v0.12 From c25737a44fb22668c67568eefb61c72457166dfe Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 14 May 2010 11:29:35 +0200 Subject: Fix compilation of QtDeclarative module (gcc) Broke with commit 645b9ee9dd6 --- src/declarative/qml/qdeclarativeinclude.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp index 97220f1..619264a 100644 --- a/src/declarative/qml/qdeclarativeinclude.cpp +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -41,7 +41,7 @@ #include "qdeclarativeinclude_p.h" -#include +#include #include #include #include -- cgit v0.12 From 37c817ac5d19fe70e1457dddc8ba62ad6702cfdb Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 14 May 2010 11:32:01 +0200 Subject: doc: Added some \briefs to how-to docs. --- doc/src/frameworks-technologies/dbus-adaptors.qdoc | 1 + doc/src/howtos/HWacceleration.qdoc | 15 +++++++++------ doc/src/howtos/accelerators.qdoc | 1 + doc/src/howtos/appicon.qdoc | 1 + doc/src/howtos/guibooks.qdoc | 1 + doc/src/howtos/qtdesigner.qdoc | 1 + doc/src/howtos/restoring-geometry.qdoc | 2 +- doc/src/howtos/session.qdoc | 2 +- doc/src/howtos/sharedlibrary.qdoc | 2 +- doc/src/howtos/timers.qdoc | 2 +- doc/src/sql-programming/qsqldatatype-table.qdoc | 19 ++++++++++--------- 11 files changed, 28 insertions(+), 19 deletions(-) diff --git a/doc/src/frameworks-technologies/dbus-adaptors.qdoc b/doc/src/frameworks-technologies/dbus-adaptors.qdoc index 11c5998..25c6a43 100644 --- a/doc/src/frameworks-technologies/dbus-adaptors.qdoc +++ b/doc/src/frameworks-technologies/dbus-adaptors.qdoc @@ -43,6 +43,7 @@ \page usingadaptors.html \title Using QtDBus Adaptors \ingroup technology-apis + \brief How to create and use DBus adaptors in Qt. \ingroup best-practices diff --git a/doc/src/howtos/HWacceleration.qdoc b/doc/src/howtos/HWacceleration.qdoc index fbc657c..c7b1a72 100644 --- a/doc/src/howtos/HWacceleration.qdoc +++ b/doc/src/howtos/HWacceleration.qdoc @@ -41,17 +41,20 @@ /*! \page HWAcc_rendering.html - \title Using hardware acceleration on embedded platforms. + \title Hardware Acceleration & Embedded Platforms. + \brief How to use hardware acceleration for fast rendering. \ingroup best-practices \section1 Abstract + This document describes how to use hardware acceleration for fast - rendering on embedded platforms supported by Qt. In short, it explains - how the graphics pipeline works. Since there might be differences to - how the APIs are being used on different embedded platforms, a table - links to documentation dedicated to platform specific documentation - for each supported hardware acceleration API. + rendering on embedded platforms supported by Qt. In short, it + explains how the graphics pipeline works. Since there might be + differences to how the APIs are being used on different embedded + platforms, a table links to documentation dedicated to platform + specific documentation for each supported hardware acceleration + API. \input platforms/emb-hardwareacceleration.qdocinc diff --git a/doc/src/howtos/accelerators.qdoc b/doc/src/howtos/accelerators.qdoc index 65f1def..b6ef5c2 100644 --- a/doc/src/howtos/accelerators.qdoc +++ b/doc/src/howtos/accelerators.qdoc @@ -42,6 +42,7 @@ /*! \page accelerators.html \title Standard Accelerator Keys + \brief Recommended accelerator keys. \ingroup best-practices diff --git a/doc/src/howtos/appicon.qdoc b/doc/src/howtos/appicon.qdoc index dd39509..9377961 100644 --- a/doc/src/howtos/appicon.qdoc +++ b/doc/src/howtos/appicon.qdoc @@ -42,6 +42,7 @@ /*! \page appicon.html \title Setting the Application Icon + \brief How to set your application's icon. \ingroup best-practices diff --git a/doc/src/howtos/guibooks.qdoc b/doc/src/howtos/guibooks.qdoc index 1a70670..bccfbe6 100644 --- a/doc/src/howtos/guibooks.qdoc +++ b/doc/src/howtos/guibooks.qdoc @@ -43,6 +43,7 @@ \page guibooks.html \title Books about GUI Design \ingroup best-practices + \brief Some recommended books about GUI design. This is not a comprehensive list -- there are many other books worth buying. Here we mention just a few user interface books that don't diff --git a/doc/src/howtos/qtdesigner.qdoc b/doc/src/howtos/qtdesigner.qdoc index 2dd7fcf..92041f0 100644 --- a/doc/src/howtos/qtdesigner.qdoc +++ b/doc/src/howtos/qtdesigner.qdoc @@ -42,6 +42,7 @@ /*! \page qtdesigner-components.html \title Creating and Using Components for Qt Designer + \brief How to create and use custom widget plugins. \ingroup best-practices \tableofcontents diff --git a/doc/src/howtos/restoring-geometry.qdoc b/doc/src/howtos/restoring-geometry.qdoc index 36c5e4f..e72b993 100644 --- a/doc/src/howtos/restoring-geometry.qdoc +++ b/doc/src/howtos/restoring-geometry.qdoc @@ -42,7 +42,7 @@ /*! \page restoring-geometry.html \title Restoring a Window's Geometry - + \brief How to save & restore window geometry. \ingroup best-practices This document describes how to save and restore a \l{Window diff --git a/doc/src/howtos/session.qdoc b/doc/src/howtos/session.qdoc index e2e87a8..f53af04 100644 --- a/doc/src/howtos/session.qdoc +++ b/doc/src/howtos/session.qdoc @@ -42,7 +42,7 @@ /*! \page session.html \title Session Management - + \brief How to do session management with Qt. \ingroup best-practices A \e session is a group of running applications, each of which has a diff --git a/doc/src/howtos/sharedlibrary.qdoc b/doc/src/howtos/sharedlibrary.qdoc index 70fc4db..ed803ed 100644 --- a/doc/src/howtos/sharedlibrary.qdoc +++ b/doc/src/howtos/sharedlibrary.qdoc @@ -42,7 +42,7 @@ /*! \page sharedlibrary.html \title Creating Shared Libraries - + \brief How to create shared libraries. \ingroup best-practices The following sections list certain things that should be taken into diff --git a/doc/src/howtos/timers.qdoc b/doc/src/howtos/timers.qdoc index cfc2fb4..b001916 100644 --- a/doc/src/howtos/timers.qdoc +++ b/doc/src/howtos/timers.qdoc @@ -42,7 +42,7 @@ /*! \page timers.html \title Timers - \brief How to use timers in your application. + \brief How to use Qt timers in your application. \ingroup best-practices diff --git a/doc/src/sql-programming/qsqldatatype-table.qdoc b/doc/src/sql-programming/qsqldatatype-table.qdoc index fc961f5..398e659 100644 --- a/doc/src/sql-programming/qsqldatatype-table.qdoc +++ b/doc/src/sql-programming/qsqldatatype-table.qdoc @@ -41,19 +41,20 @@ /*! \page sql-types.html - \title Recommended Use of Data Types in Databases + \title Data Types for Qt-supported Database Systems + \brief Recommended data types for database systems \ingroup best-practices - \section1 Recommended Use of Types in Qt Supported Databases + \section1 Data Types for Qt Supported Database Systems - This table shows the recommended data types used when extracting data - from the databases supported in Qt. It is important to note that the - types used in Qt are not necessarily valid as input to the specific - database. One example could be that a double would work perfectly as - input for floating point records in a database, but not necessarily - as a storage format for output from the database since it would be stored - with 64-bit precision in C++. + This table shows the recommended data types for extracting data from + the databases supported in Qt. Note that types used in Qt are not + necessarily valid as input types to a specific database + system. e.g., A double might work perfectly as input for floating + point records in a particular database, but not necessarily as a + storage format for output from that database, because it would be + stored with 64-bit precision in C++. \tableofcontents -- cgit v0.12 From 23f1fa2e47f3bd4cea92510d70c2e9d0fbbcfc92 Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Fri, 14 May 2010 10:36:27 +0200 Subject: [Regression] Build failure on Mac Carbon Including objc/runtime.h when using Carbon produced problems so I protected that include via ifdef. Task-number: QTBUG-10519 Reviewed-by: Jason Mcdonald --- src/gui/kernel/qt_mac_p.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qt_mac_p.h b/src/gui/kernel/qt_mac_p.h index 3341ce1..ca9541a 100644 --- a/src/gui/kernel/qt_mac_p.h +++ b/src/gui/kernel/qt_mac_p.h @@ -57,7 +57,9 @@ #ifdef __OBJC__ #include +#ifdef QT_MAC_USE_COCOA #include +#endif // QT_MAC_USE_COCOA #endif #include -- cgit v0.12 From e0c4899b46a68b37ce743c5a1ffd17596cbaa44c Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Fri, 14 May 2010 11:41:05 +0200 Subject: Mac: restoreGeometry() The problem here is the fact that when zooming (maximizing) a window, we should update the starting position since the window is now starting at 0,0. However when restoring the window should be placed in the original position. The bug here occurs because we kept the original position and the new size. So the window was drawn were it was using the new size. This patch introduces a boolean flag that keeps track of the maximized state. We are interested in knowing if the window was maximized but not restored, so when saving the geometry we have a way to know that we need to "move" the window to 0,0. Task-number: QTBUG-10504 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qcocoawindowdelegate_mac.mm | 21 ++++++++++++++++++--- src/gui/kernel/qwidget.cpp | 22 ++++++++++++++++++++++ src/gui/kernel/qwidget_p.h | 8 ++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm index 24498f8..2b9cf85 100644 --- a/src/gui/kernel/qcocoawindowdelegate_mac.mm +++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm @@ -202,6 +202,11 @@ static void cleanupCocoaWindowDelegate() QWindowStateChangeEvent e(Qt::WindowStates(widgetData->window_state & ~Qt::WindowMaximized)); qt_sendSpontaneousEvent(qwidget, &e); + } else { + widgetData->window_state = widgetData->window_state & ~Qt::WindowMaximized; + QWindowStateChangeEvent e(Qt::WindowStates(widgetData->window_state + | Qt::WindowMaximized)); + qt_sendSpontaneousEvent(qwidget, &e); } NSRect rect = [[window contentView] frame]; const QSize newSize(rect.size.width, rect.size.height); @@ -305,9 +310,19 @@ static void cleanupCocoaWindowDelegate() Q_UNUSED(newFrame); // saving the current window geometry before the window is maximized QWidget *qwidget = m_windowHash->value(window); - if (qwidget->isWindow() && !(qwidget->windowState() & Qt::WindowMaximized)) { - QWidgetPrivate *widgetPrivate = qt_widget_private(qwidget); - widgetPrivate->topData()->normalGeometry = qwidget->geometry(); + QWidgetPrivate *widgetPrivate = qt_widget_private(qwidget); + if (qwidget->isWindow()) { + if(qwidget->windowState() & Qt::WindowMaximized) { + // Restoring + widgetPrivate->topData()->wasMaximized = false; + } else { + // Maximizing + widgetPrivate->topData()->normalGeometry = qwidget->geometry(); + // If the window was maximized we need to update the coordinates since now it will start at 0,0. + // We do this in a special field that is only used when not restoring but manually resizing the window. + // Since the coordinates are fixed we just set a boolean flag. + widgetPrivate->topData()->wasMaximized = true; + } } return YES; } diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index e39526e..420eda6 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1581,6 +1581,11 @@ void QWidgetPrivate::createTLExtra() x->inTopLevelResize = false; x->inRepaint = false; x->embedded = 0; +#ifdef Q_WS_MAC +#ifdef QT_MAC_USE_COCOA + x->wasMaximized = false; +#endif // QT_MAC_USE_COCOA +#endif // Q_WS_MAC createTLSysExtra(); #ifdef QWIDGET_EXTRA_DEBUG static int count = 0; @@ -6749,6 +6754,18 @@ void QWidget::setGeometry(const QRect &r) */ QByteArray QWidget::saveGeometry() const { +#ifdef QT_MAC_USE_COCOA + // We check if the window was maximized during this invocation. If so, we need to record the + // starting position as 0,0. + Q_D(const QWidget); + QRect newFramePosition = frameGeometry(); + QRect newNormalPosition = normalGeometry(); + if(d->topData()->wasMaximized) { + // Change the starting position + newFramePosition.moveTo(0, 0); + newNormalPosition.moveTo(0, 0); + } +#endif // QT_MAC_USE_COCOA QByteArray array; QDataStream stream(&array, QIODevice::WriteOnly); stream.setVersion(QDataStream::Qt_4_0); @@ -6758,8 +6775,13 @@ QByteArray QWidget::saveGeometry() const stream << magicNumber << majorVersion << minorVersion +#ifdef QT_MAC_USE_COCOA + << newFramePosition + << newNormalPosition +#else << frameGeometry() << normalGeometry() +#endif // QT_MAC_USE_COCOA << qint32(QApplication::desktop()->screenNumber(this)) << quint8(windowState() & Qt::WindowMaximized) << quint8(windowState() & Qt::WindowFullScreen); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index cad60b5..3f494d8 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -170,6 +170,14 @@ struct QTLWExtra { WindowGroupRef group; IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys. quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys() +#ifdef QT_MAC_USE_COCOA + // This value is just to make sure we maximize and restore to the right location, yet we allow apps to be maximized and + // manually resized. + // The name is misleading, since this is set when maximizing the window. It is a hint to saveGeometry(..) to record the + // starting position as 0,0 instead of the normal starting position. + bool wasMaximized; +#endif // QT_MAC_USE_COCOA + #elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS #ifndef QT_NO_QWS_MANAGER QWSManager *qwsManager; -- cgit v0.12 From e301c82693c33c0f96c6a756d15fe35a9d877443 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 26 Apr 2010 15:16:34 +0200 Subject: QUrl: parsing of host name with an undercore. This is not supposed to be allowed, but it work with other browsers Rask-number: QTBUG-7434 Reviewed-by: Thiago Reviewed-by: Markus Goetz (cherry picked from commit a8065da96b96fcc4baeca7615c2a4195c05cbc03) --- src/corelib/io/qurl.cpp | 4 +++- tests/auto/qurl/tst_qurl.cpp | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index bdb0cfd..eb1834c 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -2990,7 +2990,9 @@ bool qt_check_std3rules(const QChar *uc, int len) // only LDH is present if (c == '-' || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') - || (c >= 'a' && c <= 'z')) + || (c >= 'a' && c <= 'z') + //underscore is not supposed to be allowed, but other browser accept it (QTBUG-7434) + || c == '_') continue; return false; diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 8dffebb..ede6cde 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -1631,6 +1631,10 @@ void tst_QUrl::toString_data() QTest::newRow("nopath_task31320") << QString::fromLatin1("host://protocol") << uint(QUrl::None) << QString::fromLatin1("host://protocol"); + + QTest::newRow("underscore_QTBUG-7434") << QString::fromLatin1("http://foo_bar.host.com/rss.php") + << uint(QUrl::None) + << QString::fromLatin1("http://foo_bar.host.com/rss.php"); } void tst_QUrl::toString() @@ -3269,7 +3273,6 @@ void tst_QUrl::std3violations_data() QTest::newRow("question") << "foo?bar" << true; QTest::newRow("at") << "foo@bar" << true; QTest::newRow("backslash") << "foo\\bar" << false; - QTest::newRow("underline") << "foo_bar" << false; // these characters are transformed by NFKC to non-LDH characters QTest::newRow("dot-like") << QString::fromUtf8("foo\342\200\244bar") << false; // U+2024 ONE DOT LEADER @@ -3314,6 +3317,7 @@ void tst_QUrl::std3deviations_data() QTest::newRow("ending-dot") << "example.com."; QTest::newRow("ending-dot3002") << QString("example.com") + QChar(0x3002); + QTest::newRow("underline") << "foo_bar"; //QTBUG-7434 } void tst_QUrl::std3deviations() -- cgit v0.12 From aa3dc5ac75505285f7501eb75935414d309c077f Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 14 May 2010 12:59:55 +0300 Subject: Fix anomaly demo control strip icon placement Some icons overlapped in very small screens, so make icon placement little bit smarter. Task-number: QTBUG-10635 Reviewed-by: Janne Anttila --- demos/embedded/anomaly/src/ControlStrip.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/demos/embedded/anomaly/src/ControlStrip.cpp b/demos/embedded/anomaly/src/ControlStrip.cpp index dc6d5c2..c9c81c0 100644 --- a/demos/embedded/anomaly/src/ControlStrip.cpp +++ b/demos/embedded/anomaly/src/ControlStrip.cpp @@ -66,6 +66,7 @@ QSize ControlStrip::minimumSizeHint() const void ControlStrip::mousePressEvent(QMouseEvent *event) { int h = height(); + int spacing = qMin(h, (width() - h * 4) / 3); int x = event->pos().x(); if (x < h) { @@ -80,13 +81,13 @@ void ControlStrip::mousePressEvent(QMouseEvent *event) return; } - if ((x < width() - 2 * h) && (x > width() - 3 * h)) { + if ((x < width() - (h + spacing)) && (x > width() - (h * 2 + spacing))) { emit forwardClicked(); event->accept(); return; } - if ((x < width() - 3 * h) && (x > width() - 5 * h)) { + if ((x < width() - (h * 2 + spacing * 2)) && (x > width() - (h * 3 + spacing * 2))) { emit backClicked(); event->accept(); return; @@ -96,15 +97,16 @@ void ControlStrip::mousePressEvent(QMouseEvent *event) void ControlStrip::paintEvent(QPaintEvent *event) { int h = height(); - int s = (h - menuPixmap.height()) / 2; + int spacing = qMin(h, (width() - h * 4) / 3); + int s = (height() - menuPixmap.height()) / 2; QPainter p(this); p.fillRect(event->rect(), QColor(32, 32, 32, 192)); p.setCompositionMode(QPainter::CompositionMode_SourceOver); p.drawPixmap(s, s, menuPixmap); p.drawPixmap(width() - h + s, s, closePixmap); - p.drawPixmap(width() - 3 * h + s, s, forwardPixmap); - p.drawPixmap(width() - 5 * h + s, s, backPixmap); + p.drawPixmap(width() - (h * 2 + spacing) + s, s, forwardPixmap); + p.drawPixmap(width() - (h * 3 + spacing * 2) + s, s, backPixmap); p.end(); } -- cgit v0.12 From c3bec5fa2dfc53051bd09a6c3c1a50b7f239ab41 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 14 May 2010 10:35:33 +0200 Subject: Fix QUrl::isValid if the host contains invalid caracter. If the host contains invalid caracter, QUrl::isValid should return false Task-number: QTBUG-10355 Reviewed-by: thiago --- src/corelib/io/qurl.cpp | 10 ++++++++-- tests/auto/qurl/tst_qurl.cpp | 27 ++++++++++++++++++++------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index eb1834c..5119ccc 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -338,6 +338,7 @@ public: bool hasQuery; bool hasFragment; bool isValid; + bool isHostValid; char valueDelimiter; char pairDelimiter; @@ -3347,6 +3348,7 @@ QUrlPrivate::QUrlPrivate() ref = 1; port = -1; isValid = false; + isHostValid = true; parsingMode = QUrl::TolerantMode; valueDelimiter = '='; pairDelimiter = '&'; @@ -3373,6 +3375,7 @@ QUrlPrivate::QUrlPrivate(const QUrlPrivate ©) hasQuery(copy.hasQuery), hasFragment(copy.hasFragment), isValid(copy.isValid), + isHostValid(copy.isHostValid), valueDelimiter(copy.valueDelimiter), pairDelimiter(copy.pairDelimiter), stateFlags(copy.stateFlags), @@ -3403,6 +3406,8 @@ QString QUrlPrivate::canonicalHost() const that->host = host.toLower(); } else { that->host = qt_ACE_do(host, NormalizeAce); + if (that->host.isNull()) + that->isHostValid = false; } return that->host; } @@ -3479,6 +3484,7 @@ QString QUrlPrivate::authority(QUrl::FormattingOptions options) const void QUrlPrivate::setAuthority(const QString &auth) { + isHostValid = true; if (auth.isEmpty()) return; @@ -4169,7 +4175,7 @@ bool QUrl::isValid() const if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Validated)) d->validate(); - return d->isValid; + return d->isValid && d->isHostValid; } /*! @@ -4421,7 +4427,6 @@ void QUrl::setAuthority(const QString &authority) if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); detach(); QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized); - d->setAuthority(authority); } @@ -4642,6 +4647,7 @@ void QUrl::setHost(const QString &host) if (!d) d = new QUrlPrivate; if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); detach(); + d->isHostValid = true; QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized | QUrlPrivate::HostCanonicalized); d->host = host; diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index ede6cde..3cc0d78 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -1409,7 +1409,7 @@ void tst_QUrl::setUrl() void tst_QUrl::i18n_data() { QTest::addColumn("input"); - QTest::addColumn("punyOutput"); + QTest::addColumn("punyOutput"); QTest::newRow("øl") << QString::fromLatin1("http://ole:passord@www.øl.no/index.html?ole=æsemann&ilder gud=hei#top") << QByteArray("http://ole:passord@www.xn--l-4ga.no/index.html?ole=%C3%A6semann&ilder%20gud=hei#top"); @@ -2164,25 +2164,25 @@ void tst_QUrl::toPercentEncoding_data() QTest::addColumn("includeInEncoding"); QTest::newRow("test_01") << QString::fromLatin1("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") - << QByteArray("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") + << QByteArray("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") << QByteArray("") << QByteArray(""); QTest::newRow("test_02") << QString::fromLatin1("{\t\n\r^\"abc}") - << QByteArray("%7B%09%0A%0D%5E%22abc%7D") + << QByteArray("%7B%09%0A%0D%5E%22abc%7D") << QByteArray("") << QByteArray(""); QTest::newRow("test_03") << QString::fromLatin1("://?#[]@!$&'()*+,;=") - << QByteArray("%3A%2F%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D") + << QByteArray("%3A%2F%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D") << QByteArray("") << QByteArray(""); QTest::newRow("test_04") << QString::fromLatin1("://?#[]@!$&'()*+,;=") - << QByteArray("%3A%2F%2F%3F%23%5B%5D%40!$&'()*+,;=") + << QByteArray("%3A%2F%2F%3F%23%5B%5D%40!$&'()*+,;=") << QByteArray("!$&'()*+,;=") << QByteArray(""); QTest::newRow("test_05") << QString::fromLatin1("abcd") << QByteArray("a%62%63d") << QByteArray("") - << QByteArray("bc"); + << QByteArray("bc"); } void tst_QUrl::toPercentEncoding() @@ -2192,7 +2192,7 @@ void tst_QUrl::toPercentEncoding() QFETCH(QByteArray, excludeInEncoding); QFETCH(QByteArray, includeInEncoding); - QByteArray encodedUrl = QUrl::toPercentEncoding(original, excludeInEncoding, includeInEncoding); + QByteArray encodedUrl = QUrl::toPercentEncoding(original, excludeInEncoding, includeInEncoding); QCOMPARE(encodedUrl.constData(), encoded.constData()); QCOMPARE(original, QUrl::fromPercentEncoding(encodedUrl)); } @@ -2460,6 +2460,8 @@ void tst_QUrl::isValid() QUrl url = QUrl::fromEncoded("http://strange@ok-hostname/", QUrl::StrictMode); QVERIFY(!url.isValid()); // < and > are not allowed in userinfo in strict mode + url.setUserName("normal_username"); + QVERIFY(url.isValid()); } { QUrl url = QUrl::fromEncoded("http://strange@ok-hostname/"); @@ -2470,7 +2472,18 @@ void tst_QUrl::isValid() QUrl url = QUrl::fromEncoded("http://strange;hostname/here"); QVERIFY(!url.isValid()); QCOMPARE(url.path(), QString("/here")); + url.setAuthority("foobar@bar"); + QVERIFY(url.isValid()); + } + + { + QUrl url = QUrl::fromEncoded("foo://stuff;1/g"); + QVERIFY(!url.isValid()); + QCOMPARE(url.path(), QString("/g")); + url.setHost("stuff-1"); + QVERIFY(url.isValid()); } + } void tst_QUrl::schemeValidator_data() -- cgit v0.12 From c1423c03d69f51d76b3629f2fedce555696759fa Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 14 May 2010 12:41:07 +0200 Subject: QNetworkAccessManager: Backends were tried in wrong order We inversed the order. HTTP shall be tried first, file:// last. See https://bugs.webkit.org/show_bug.cgi?id=38935 Reviewed-by: Thiago --- src/network/access/qnetworkaccessbackend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index 8ac64d2..4273e10 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -72,7 +72,7 @@ Q_GLOBAL_STATIC(QNetworkAccessBackendFactoryData, factoryData) QNetworkAccessBackendFactory::QNetworkAccessBackendFactory() { QMutexLocker locker(&factoryData()->mutex); - factoryData()->prepend(this); + factoryData()->append(this); } QNetworkAccessBackendFactory::~QNetworkAccessBackendFactory() -- cgit v0.12 From 3ecb04cffdf491f5ea01eceb71de98d6ac647107 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 14 May 2010 13:21:56 +0200 Subject: QNAM HTTP: And one more testcase --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 74ed7fc..ca563ef 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -279,6 +279,8 @@ private Q_SLOTS: void getAndThenDeleteObject_data(); void getAndThenDeleteObject(); + void symbianOpenCDataUrlCrash(); + // NOTE: This test must be last! void parentingRepliesToTheApp(); }; @@ -4153,6 +4155,22 @@ void tst_QNetworkReply::getAndThenDeleteObject() } } +// see https://bugs.webkit.org/show_bug.cgi?id=38935 +void tst_QNetworkReply::symbianOpenCDataUrlCrash() +{ + QString requestUrl("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAWCAYAAAA1vze2AAAAB3RJTUUH2AUSEgolrgBvVQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAARnQU1BAACxjwv8YQUAAAHlSURBVHja5VbNShxBEK6ZaXtnHTebQPA1gngNmfaeq+QNPIlIXkC9iQdJxJNvEHLN3VkxhxxE8gTmEhAVddXZ6Z3f9Ndriz89/sHmkBQUVVT1fB9d9c3uOERUKTunIdn3HzstxGpYBDS4wZk7TAJj/wlJ90J+jnuygqs8svSj+/rGHBos3rE18XBvfU3no7NzlJfUaY/5whAwl8Lr/WDUv4ODxTMb+P5xLExe5LmO559WqTX/MQR4WZYEAtSePS4pE0qSnuhnRUcBU5Gm2k9XljU4Z26I3NRxBrd80rj2fh+KNE0FY4xevRgTjREvPFpasAK8Xli6MUbbuKw3afAGgSBXozo5u4hkmncAlkl5wx8iMGbdyQjnCFEiEwGiosj1UQA/x2rVddiVoi+l4IxE0PTDnx+mrQBvvnx9cFz3krhVvuhzFn579/aq/n5rW8fbtTqiWhIQZEo17YBvbkxOXNVndnYpTvod7AtiuN2re0+siwcB9oH8VxxrNwQQAhzyRs30n7wTI2HIN2g2QtQwjjhJIQatOq7E8bIVCLwzpl83Lvtvl+NohWWlE8UZTWEMAGCcR77fHKhPnZF5tYie6dfdxCphACmLPM+j8bYfmTryg64kV9Vh3mV8jP0b/4wO/YUPiT/8i0MLf55lSQAAAABJRU5ErkJggg=="); + QUrl url = QUrl::fromEncoded(requestUrl.toLatin1()); + QNetworkRequest req(url); + QNetworkReplyPtr reply; + + RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::GetOperation, req, reply)); + + QCOMPARE(reply->url(), url); + QCOMPARE(reply->error(), QNetworkReply::NoError); + + QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), qint64(598)); +} + // NOTE: This test must be last testcase in tst_qnetworkreply! -- cgit v0.12 From 0749d35484a4efb2202a7c2b6da7d5b796ef5b56 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 14 May 2010 14:38:31 +0300 Subject: QS60Style: In S60 3.x and 5.0 Qt itemviews behaviour is not nativelike Currently style defines QStyle::SH_ItemView_ActivateItemOnSingleClick, which leads to itemview item activation only occur on double-click (or tap). The item selection work native-like on Sym^3. As a correction, style needs to check the passed styleoption and check whether or not the state "Selected" is on. In these cases, the itemactivation can proceed. Task-number: QTBUG-10697 Reviewed-by: Miikka Heikkinen --- src/gui/itemviews/qabstractitemview.cpp | 5 ++++- src/gui/styles/qs60style.cpp | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 2faf755..b464330 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1785,7 +1785,10 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event) emit clicked(index); if (edited) return; - if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this)) + QStyleOptionViewItemV4 option = d->viewOptionsV4(); + if (d->pressedAlreadySelected) + option.state |= QStyle::State_Selected; + if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, &option, this)) emit activated(index); } } diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 924cabc..d28e1d9 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2575,7 +2575,7 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *hret) const { - int retValue = -1; + int retValue = 0; switch (sh) { case SH_RequestSoftwareInputPanel: if (QS60StylePrivate::isSingleClickUi()) @@ -2610,9 +2610,13 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_Dial_BackgroundRole: retValue = QPalette::Base; break; - case SH_ItemView_ActivateItemOnSingleClick: - retValue = QS60StylePrivate::isSingleClickUi(); + case SH_ItemView_ActivateItemOnSingleClick: { + if (QS60StylePrivate::isSingleClickUi()) + retValue = true; + else if (opt && opt->state & QStyle::State_Selected) + retValue = true; break; + } case SH_ProgressDialog_TextLabelAlignment: retValue = (QApplication::layoutDirection() == Qt::LeftToRight) ? Qt::AlignLeft : -- cgit v0.12 From 6d4e67674f0ca5824761ec29f20dd854d47b4ac7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 14 May 2010 13:42:28 +0200 Subject: define qtPrepareTool() function and use it throughout the function provides a cross-platform way to determine the exact pathname of our build tools (moc, etc.). use it in our .prf files, so we don't have to rely on qmake's unreliable path separator normalization magic in extra compiler commands, which broke on mingw+sh in silent mode. remove the bootstrap tool path setting from configure, as it is redundant now. Reviewed-by: joerg Task-number: QTBUG-10633 --- configure | 5 ----- mkspecs/features/dbusadaptors.prf | 5 +---- mkspecs/features/dbusinterfaces.prf | 5 +---- mkspecs/features/moc.prf | 5 +---- mkspecs/features/qt_functions.prf | 11 +++++++++++ mkspecs/features/resources.prf | 5 +---- mkspecs/features/uic.prf | 12 ++---------- mkspecs/features/win32/qaxcontainer.prf | 4 +--- mkspecs/features/win32/qaxserver.prf | 3 ++- tools/configure/configureapp.cpp | 5 ----- translations/translations.pri | 6 +----- translations/translations.pro | 6 +----- 12 files changed, 22 insertions(+), 50 deletions(-) diff --git a/configure b/configure index 0cf7542..057d39a 100755 --- a/configure +++ b/configure @@ -7198,11 +7198,6 @@ QMAKE_ABSOLUTE_SOURCE_ROOT = \$\$QT_SOURCE_TREE QMAKE_MOC_SRC = \$\$QT_BUILD_TREE/src/moc #local paths that cannot be queried from the QT_INSTALL_* properties while building QTDIR -QMAKE_MOC = \$\$QT_BUILD_TREE/bin/moc -QMAKE_UIC = \$\$QT_BUILD_TREE/bin/uic -QMAKE_UIC3 = \$\$QT_BUILD_TREE/bin/uic3 -QMAKE_RCC = \$\$QT_BUILD_TREE/bin/rcc -QMAKE_QDBUSXML2CPP = \$\$QT_BUILD_TREE/bin/qdbusxml2cpp QMAKE_INCDIR_QT = \$\$QT_BUILD_TREE/include QMAKE_LIBDIR_QT = \$\$QT_BUILD_TREE/lib diff --git a/mkspecs/features/dbusadaptors.prf b/mkspecs/features/dbusadaptors.prf index 241ace6..17dffa5 100644 --- a/mkspecs/features/dbusadaptors.prf +++ b/mkspecs/features/dbusadaptors.prf @@ -1,7 +1,4 @@ -isEmpty(QMAKE_QDBUSXML2CPP) { - win32:QMAKE_QDBUSXML2CPP = $$[QT_INSTALL_BINS]\qdbusxml2cpp.exe - else:QMAKE_QDBUSXML2CPP = $$[QT_INSTALL_BINS]/qdbusxml2cpp -} +qtPrepareTool(QMAKE_QDBUSXML2CPP, qdbusxml2cpp) for(DBUS_ADAPTOR, $$list($$unique(DBUS_ADAPTORS))) { diff --git a/mkspecs/features/dbusinterfaces.prf b/mkspecs/features/dbusinterfaces.prf index c32597a..412e80f 100644 --- a/mkspecs/features/dbusinterfaces.prf +++ b/mkspecs/features/dbusinterfaces.prf @@ -1,9 +1,6 @@ load(moc) -isEmpty(QMAKE_QDBUSXML2CPP) { - win32:QMAKE_QDBUSXML2CPP = $$[QT_INSTALL_BINS]\qdbusxml2cpp.exe - else:QMAKE_QDBUSXML2CPP = $$[QT_INSTALL_BINS]/qdbusxml2cpp -} +qtPrepareTool(QMAKE_QDBUSXML2CPP, qdbusxml2cpp) for(DBUS_INTERFACE, $$list($$unique(DBUS_INTERFACES))) { diff --git a/mkspecs/features/moc.prf b/mkspecs/features/moc.prf index e4b7dae..e1296ec 100644 --- a/mkspecs/features/moc.prf +++ b/mkspecs/features/moc.prf @@ -1,9 +1,6 @@ #global defaults -isEmpty(QMAKE_MOC) { - contains(QMAKE_HOST.os,Windows):QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe - else:QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -} +qtPrepareTool(QMAKE_MOC, moc) isEmpty(MOC_DIR):MOC_DIR = . isEmpty(QMAKE_H_MOD_MOC):QMAKE_H_MOD_MOC = moc_ isEmpty(QMAKE_EXT_CPP_MOC):QMAKE_EXT_CPP_MOC = .moc diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 1be6d9b..23e2616 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -78,3 +78,14 @@ defineTest(qtAddLibrary) { export(QMAKE_LFLAGS) return(true) } + +# variable, default +defineTest(qtPrepareTool) { + isEmpty($$1) { + !isEmpty(QT_BUILD_TREE):$$1 = $$QT_BUILD_TREE/bin/$$2 + else:$$1 = $$[QT_INSTALL_BINS]/$$2 + } + $$1 ~= s,[/\\\\],$$QMAKE_DIR_SEP, + contains(QMAKE_HOST.os, Windows):!contains($$1, \.exe$):$$1 = $$eval($$1).exe + export($$1) +} diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf index 8ccd576..5d00a4d 100644 --- a/mkspecs/features/resources.prf +++ b/mkspecs/features/resources.prf @@ -1,7 +1,4 @@ -isEmpty(QMAKE_RCC) { - win32:QMAKE_RCC = $$[QT_INSTALL_BINS]\rcc.exe - else:QMAKE_RCC = $$[QT_INSTALL_BINS]/rcc -} +qtPrepareTool(QMAKE_RCC, rcc) isEmpty(RCC_DIR):RCC_DIR = . isEmpty(QMAKE_RESOURCE_PREFIX):QMAKE_RESOURCE_PREFIX = /tmp/ diff --git a/mkspecs/features/uic.prf b/mkspecs/features/uic.prf index eaf373a..d108f24 100644 --- a/mkspecs/features/uic.prf +++ b/mkspecs/features/uic.prf @@ -1,13 +1,5 @@ - -isEmpty(QMAKE_UIC3) { - contains(QMAKE_HOST.os,Windows):QMAKE_UIC3 = $$[QT_INSTALL_BINS]\uic3.exe - else:QMAKE_UIC3 = $$[QT_INSTALL_BINS]/uic3 -} - -isEmpty(QMAKE_UIC) { - contains(QMAKE_HOST.os,Windows):QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe - else:QMAKE_UIC = $$[QT_INSTALL_BINS]/uic -} +qtPrepareTool(QMAKE_UIC3, uic3) +qtPrepareTool(QMAKE_UIC, uic) isEmpty(UI_DIR):UI_DIR = . isEmpty(UI_SOURCES_DIR):UI_SOURCES_DIR = $$UI_DIR diff --git a/mkspecs/features/win32/qaxcontainer.prf b/mkspecs/features/win32/qaxcontainer.prf index 49edb2a..34c6dfe 100644 --- a/mkspecs/features/win32/qaxcontainer.prf +++ b/mkspecs/features/win32/qaxcontainer.prf @@ -8,9 +8,7 @@ LIBS += -lQAxContainer } -isEmpty(QMAKE_DUMPCPP) { - win32:QMAKE_DUMPCPP = $$[QT_INSTALL_BINS]\dumpcpp.exe -} +qtPrepareTool(QMAKE_DUMPCPP, dumpcpp) dumpcpp_decl.commands = $$QMAKE_DUMPCPP ${QMAKE_FILE_IN} -o ${QMAKE_FILE_BASE} qaxcontainer_compat: dumpcpp_decl.commands += -compat diff --git a/mkspecs/features/win32/qaxserver.prf b/mkspecs/features/win32/qaxserver.prf index a18c421..1ff6825 100644 --- a/mkspecs/features/win32/qaxserver.prf +++ b/mkspecs/features/win32/qaxserver.prf @@ -14,7 +14,8 @@ equals(TEMPLATE, "vcapp"):ACTIVEQT_IDE = VisualStudio equals(TEMPLATE, "vclib"):ACTIVEQT_IDE = VisualStudio equals(ACTIVEQT_IDE, "VisualStudio") { - ACTIVEQT_IDC = $${QMAKE_IDC} + ACTIVEQT_IDC = $${QMAKE_IDC} ### Qt5: remove me + qtPrepareTool(ACTIVEQT_IDC, idc) ACTIVEQT_IDL = $${QMAKE_IDL} ACTIVEQT_TARGET = "$(TargetPath)" win32-msvc { diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index b35f454..7319844 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2755,11 +2755,6 @@ void Configure::generateCachefile() cacheStream << "DEFINES *= QT_EDITION=QT_EDITION_DESKTOP" << endl; //so that we can build without an install first (which would be impossible) - cacheStream << "QMAKE_MOC = $$QT_BUILD_TREE" << fixSeparators("/bin/moc.exe") << endl; - cacheStream << "QMAKE_UIC = $$QT_BUILD_TREE" << fixSeparators("/bin/uic.exe") << endl; - cacheStream << "QMAKE_UIC3 = $$QT_BUILD_TREE" << fixSeparators("/bin/uic3.exe") << endl; - cacheStream << "QMAKE_RCC = $$QT_BUILD_TREE" << fixSeparators("/bin/rcc.exe") << endl; - cacheStream << "QMAKE_DUMPCPP = $$QT_BUILD_TREE" << fixSeparators("/bin/dumpcpp.exe") << endl; cacheStream << "QMAKE_INCDIR_QT = $$QT_BUILD_TREE" << fixSeparators("/include") << endl; cacheStream << "QMAKE_LIBDIR_QT = $$QT_BUILD_TREE" << fixSeparators("/lib") << endl; if (dictionary["CETEST"] == "yes") { diff --git a/translations/translations.pri b/translations/translations.pri index 57089ff..30aa996 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -8,11 +8,7 @@ defineReplace(prependAll) { return ($$result) } -LUPDATE = $$QT_BUILD_TREE/bin/lupdate -win32 { - LUPDATE ~= s,/,$$QMAKE_DIR_SEP, - LUPDATE = $${LUPDATE}.exe -} +qtPrepareTool(LUPDATE, lupdate) LUPDATE += -locations relative -no-ui-lines ###### Qt Libraries diff --git a/translations/translations.pro b/translations/translations.pro index 8f37451..c6d46a3 100644 --- a/translations/translations.pro +++ b/translations/translations.pro @@ -1,10 +1,6 @@ TRANSLATIONS = $$files(*.ts) -LRELEASE = $$QT_BUILD_TREE/bin/lrelease -win32 { - LRELEASE ~= s,/,$$QMAKE_DIR_SEP, - LRELEASE = $${LRELEASE}.exe -} +qtPrepareTool(LRELEASE, lrelease) contains(TEMPLATE_PREFIX, vc):vcproj = 1 -- cgit v0.12 From f31461a35ae3d749c2d5445659ed55dad93e3b43 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 6 May 2010 17:39:30 +0200 Subject: fix QMAKE_QMAKE path separator under mingw+sh in the qmake spec this would have been a problem if someone accessed QMAKE_QMAKE from within a pro file, as that would fix the separators to the native host platform separator (as QMAKE_DIR_SEP is not processed at that point). Reviewed-by: joerg --- mkspecs/win32-g++/qmake.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf index b282f69..8881d02 100644 --- a/mkspecs/win32-g++/qmake.conf +++ b/mkspecs/win32-g++/qmake.conf @@ -75,6 +75,7 @@ QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain !isEmpty(QMAKE_SH) { MINGW_IN_SHELL = 1 QMAKE_DIR_SEP = / + QMAKE_QMAKE ~= s,\\\\,/, QMAKE_COPY = cp QMAKE_COPY_DIR = xcopy /s /q /y /i QMAKE_MOVE = mv -- cgit v0.12 From d36be1232e4f11cf5dc121bb60c628970b88ac2a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 10 May 2010 17:42:02 +0200 Subject: fix path separators in install targets for MinGW+sh Reviewed-by: ossi --- qmake/generators/makefile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index db2737b..d949b63 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1237,7 +1237,7 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs, bool n target += "\n"; do_default = false; for(QStringList::Iterator wild_it = tmp.begin(); wild_it != tmp.end(); ++wild_it) { - QString wild = Option::fixPathToLocalOS((*wild_it), false, false); + QString wild = Option::fixPathToTargetOS((*wild_it), false, false); QString dirstr = qmake_getpwd(), filestr = wild; int slsh = filestr.lastIndexOf(Option::dir_sep); if(slsh != -1) { -- cgit v0.12 From 61e66e8ce4a7c1412939efb47663078a2184ffb2 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 14 May 2010 15:02:51 +0300 Subject: Fix requires keyword handling in qmake in Symbian Now qmake doesn't generate bld.inf etc. files for projects that fail requires check. An error message is also printed. Task-number: QTBUG-10698 Reviewed-by: Iain --- qmake/generators/symbian/symmake.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index faafb20..1dee4ac 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -175,6 +175,12 @@ void SymbianMakefileGenerator::writeHeader(QTextStream &t) bool SymbianMakefileGenerator::writeMakefile(QTextStream &t) { + if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) { + fprintf(stderr, "Project files not generated because all requirements are not met:\n\t%s\n", + qPrintable(var("QMAKE_FAILED_REQUIREMENTS"))); + return false; + } + writeHeader(t); QString numberOfIcons; -- cgit v0.12 From 0f13a088538f42faa3634c6541d9cf461764ab25 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 14 May 2010 15:32:46 +0300 Subject: Omit building declarative/painting benchmark if no OpenGL configured Task-number: QTBUG-10665 Reviewed-by: Janne Anttila --- tests/benchmarks/declarative/declarative.pro | 5 ++++- tests/benchmarks/declarative/painting/painting.pro | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro index a7d426c..54b2a45 100644 --- a/tests/benchmarks/declarative/declarative.pro +++ b/tests/benchmarks/declarative/declarative.pro @@ -2,10 +2,13 @@ TEMPLATE = subdirs SUBDIRS += \ binding \ creation \ - painting \ pointers \ qdeclarativecomponent \ qdeclarativeimage \ qdeclarativemetaproperty \ script \ qmltime + +contains(QT_CONFIG, opengl): SUBDIRS += painting + + diff --git a/tests/benchmarks/declarative/painting/painting.pro b/tests/benchmarks/declarative/painting/painting.pro index a228ea7..69c0006 100644 --- a/tests/benchmarks/declarative/painting/painting.pro +++ b/tests/benchmarks/declarative/painting/painting.pro @@ -2,6 +2,8 @@ # Automatically generated by qmake (2.01a) fr 29. jan 13:57:52 2010 ###################################################################### +requires(contains(QT_CONFIG,opengl)) + TEMPLATE = app TARGET = DEPENDPATH += . -- cgit v0.12 From 02bc8c45f2cae1b6cd417631be8e98bc79c9c42d Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 14 May 2010 14:47:42 +0200 Subject: doc: Another upgrade of the top page and overviews. More to come. --- doc/src/development/developing-on-mac.qdoc | 5 +- doc/src/frameworks-technologies/accessible.qdoc | 3 + doc/src/frameworks-technologies/dbus-adaptors.qdoc | 2 +- doc/src/frameworks-technologies/phonon.qdoc | 2 + doc/src/getting-started/known-issues.qdoc | 10 +- doc/src/overviews.qdoc | 19 +- doc/src/sql-programming/qsqldatatype-table.qdoc | 2 +- doc/src/sql-programming/sql-driver.qdoc | 2 +- doc/src/sql-programming/sql-programming.qdoc | 6 + doc/src/widgets-and-layouts/styles.qdoc | 12 +- doc/src/widgets-and-layouts/widgets.qdoc | 202 ++++++++++----------- doc/src/windows-and-dialogs/mainwindow.qdoc | 14 +- 12 files changed, 141 insertions(+), 138 deletions(-) diff --git a/doc/src/development/developing-on-mac.qdoc b/doc/src/development/developing-on-mac.qdoc index 785858f..0c0af79 100644 --- a/doc/src/development/developing-on-mac.qdoc +++ b/doc/src/development/developing-on-mac.qdoc @@ -41,9 +41,8 @@ /*! \page developing-on-mac.html - \title Developing Qt Applications on Mac OS X - \brief A overview of items to be aware of when developing Qt applications - on Mac OS X + \title Developing Qt Applications for Mac OS X + \brief Information for developing Qt applications for Mac OS X \ingroup platform-specific \tableofcontents diff --git a/doc/src/frameworks-technologies/accessible.qdoc b/doc/src/frameworks-technologies/accessible.qdoc index 35f1c75..0aff214 100644 --- a/doc/src/frameworks-technologies/accessible.qdoc +++ b/doc/src/frameworks-technologies/accessible.qdoc @@ -47,7 +47,10 @@ /*! \page accessible.html \title Accessibility + \brief How to make your applications accessible to those with disabilities. + \ingroup technology-apis + \ingroup best-practices \tableofcontents diff --git a/doc/src/frameworks-technologies/dbus-adaptors.qdoc b/doc/src/frameworks-technologies/dbus-adaptors.qdoc index 25c6a43..3dd0e4d 100644 --- a/doc/src/frameworks-technologies/dbus-adaptors.qdoc +++ b/doc/src/frameworks-technologies/dbus-adaptors.qdoc @@ -42,9 +42,9 @@ /*! \page usingadaptors.html \title Using QtDBus Adaptors - \ingroup technology-apis \brief How to create and use DBus adaptors in Qt. + \ingroup technology-apis \ingroup best-practices Adaptors are special classes that are attached to any QObject-derived class diff --git a/doc/src/frameworks-technologies/phonon.qdoc b/doc/src/frameworks-technologies/phonon.qdoc index 61d7926..61b906e 100644 --- a/doc/src/frameworks-technologies/phonon.qdoc +++ b/doc/src/frameworks-technologies/phonon.qdoc @@ -42,7 +42,9 @@ /*! \page phonon-overview.html \title Phonon multimedia framework + \brief Using the Phonon multimedia framework in Qt. \ingroup technology-apis + \ingroup best-practices \tableofcontents diff --git a/doc/src/getting-started/known-issues.qdoc b/doc/src/getting-started/known-issues.qdoc index b73e15d..cedebf9 100644 --- a/doc/src/getting-started/known-issues.qdoc +++ b/doc/src/getting-started/known-issues.qdoc @@ -41,15 +41,15 @@ /*! \page known-issues.html - \title Known Issues in %VERSION% + \title Known Issues in this Qt Version \ingroup platform-specific - \brief A summary of known issues in Qt %VERSION% at the time of release. + \brief A summary of known issues in this Qt version at the time of release. - An up-to-date list of known issues with Qt %VERSION% can be found via the + An up-to-date list of known issues can be found at \l{http://bugreports.qt.nokia.com/}{Qt Bug Tracker}. - For a list list of known bugs in Qt %VERSION%, see the \l{Task Tracker} - on the Qt website. + For a list list of known bugs, see the \l{Task Tracker} at the Qt + website. An overview of known issues may also be found at: \l{http://qt.gitorious.org/qt/pages/QtKnownIssues} diff --git a/doc/src/overviews.qdoc b/doc/src/overviews.qdoc index 0b82388..c3c59af 100644 --- a/doc/src/overviews.qdoc +++ b/doc/src/overviews.qdoc @@ -117,13 +117,28 @@ */ /*! + \group qt-sql + \title Using SQL in Qt + \brief Qt API's for using SQL. + \ingroup technology-apis + \ingroup best-practices + + These pages document Qt's API's for using SQL database systems + in Qt applications. + + \generatelist{related} +*/ + +/*! \group best-practices \title How-To's and Best Practices \brief How-To Guides and Best Practices - These documents provide guidelines and best practices explaining - how to use Qt to solve specific technical problems. + These documents provide guidelines and best practices for using Qt + to solve specific technical problems. They are listed + alphabetically by the first word in the title, so scan the entire + list to find what you want. \generatelist{related} */ diff --git a/doc/src/sql-programming/qsqldatatype-table.qdoc b/doc/src/sql-programming/qsqldatatype-table.qdoc index 398e659..fb5fb49 100644 --- a/doc/src/sql-programming/qsqldatatype-table.qdoc +++ b/doc/src/sql-programming/qsqldatatype-table.qdoc @@ -44,7 +44,7 @@ \title Data Types for Qt-supported Database Systems \brief Recommended data types for database systems - \ingroup best-practices + \ingroup qt-sql \section1 Data Types for Qt Supported Database Systems diff --git a/doc/src/sql-programming/sql-driver.qdoc b/doc/src/sql-programming/sql-driver.qdoc index 6bccd83..f0e4e52 100644 --- a/doc/src/sql-programming/sql-driver.qdoc +++ b/doc/src/sql-programming/sql-driver.qdoc @@ -44,7 +44,7 @@ \title SQL Database Drivers \brief How to configure and install QtSql drivers for supported databases. - \ingroup best-practices + \ingroup qt-sql The QtSql module uses driver \l{How to Create Qt Plugins}{plugins} to communicate with the different database diff --git a/doc/src/sql-programming/sql-programming.qdoc b/doc/src/sql-programming/sql-programming.qdoc index f1f3e5e..b34810c 100644 --- a/doc/src/sql-programming/sql-programming.qdoc +++ b/doc/src/sql-programming/sql-programming.qdoc @@ -49,6 +49,7 @@ /*! \page sql-programming.html \title SQL Programming + \ingroup qt-sql \nextpage Connecting to Databases \brief Database integration for Qt applications. @@ -118,6 +119,7 @@ /*! \page sql-connecting.html \title Connecting to Databases + \ingroup qt-sql \contentspage SQL Programming \previouspage SQL Programming @@ -187,6 +189,7 @@ /*! \page sql-sqlstatements.html \title Executing SQL Statements + \ingroup qt-sql \previouspage Connecting to Databases \contentspage SQL Programming @@ -337,6 +340,7 @@ /*! \page sql-model.html \title Using the SQL Model Classes + \ingroup qt-sql \previouspage Executing SQL Statements \contentspage SQL Programming @@ -483,6 +487,7 @@ /*! \page sql-presenting.html \title Presenting Data in a Table View + \ingroup qt-sql \previouspage Using the SQL Model Classes \contentspage SQL Programming @@ -587,6 +592,7 @@ /*! \page sql-forms.html \title Creating Data-Aware Forms + \ingroup qt-sql \previouspage Presenting Data in a Table View \contentspage SQL Programming diff --git a/doc/src/widgets-and-layouts/styles.qdoc b/doc/src/widgets-and-layouts/styles.qdoc index b4bec8c..31dfe40 100644 --- a/doc/src/widgets-and-layouts/styles.qdoc +++ b/doc/src/widgets-and-layouts/styles.qdoc @@ -47,15 +47,9 @@ /*! \page style-reference.html - \title Implementing Styles and Style Aware Widgets + \title Styles and Style Aware Widgets \ingroup qt-gui-concepts - \brief An overview of styles and the styling of widgets. - - \ingroup frameworks-technologies - - \previouspage Widget Classes - \contentspage Widgets and Layouts - \nextpage {Qt Style Sheets}{Style sheets} + \brief Styles and the styling of widgets. Styles (classes that inherit QStyle) draw on behalf of widgets and encapsulate the look and feel of a GUI. The QStyle class is @@ -91,8 +85,6 @@ current style. This document shows how widgets draw themselves and which possibilities the style gives them. - \tableofcontents - \section1 Classes for Widget Styling These classes are used to customize an application's appearance and diff --git a/doc/src/widgets-and-layouts/widgets.qdoc b/doc/src/widgets-and-layouts/widgets.qdoc index ac0bf77..9fe2d69 100644 --- a/doc/src/widgets-and-layouts/widgets.qdoc +++ b/doc/src/widgets-and-layouts/widgets.qdoc @@ -40,131 +40,121 @@ ****************************************************************************/ /*! - \page widgets-and-layouts.html - \title Widgets and Layouts - \ingroup qt-gui-concepts - - \ingroup frameworks-technologies - - \nextpage Widget Classes - - The primary elements for designing user interfaces in Qt are widgets and layouts. - - \section1 Widgets - - \l{Widget Classes}{Widgets} can display data and status information, receive - user input, and provide a container for other widgets that should be grouped - together. A widget that is not embedded in a parent widget is called a - \l{Application Windows and Dialogs}{window}. - - \image parent-child-widgets.png A parent widget containing various child widgets. - - The QWidget class provides the basic capability to render to the screen, and to - handle user input events. All UI elements that Qt provides are either subclasses - of QWidget, or are used in connection with a QWidget subclass. Creating custom - widgets is done by subclassing QWidget or a suitable subclass and reimplementing - the virtual event handlers. - - \section1 Layouts - - \l{Layout Management}{Layouts} are an elegant and flexible way to automatically - arrange child widgets within their container. Each widget reports its size requirements - to the layout through the \l{QWidget::}{sizeHint} and \l{QWidget::}{sizePolicy} - properties, and the layout distributes the available space accordingly. - - \table - \row - \o \image qgridlayout-with-5-children.png - \o \image qformlayout-with-6-children.png - \endtable - - \l{Qt Designer Manual}{\QD} is a powerful tool for interactively creating and - arranging widgets in layouts. - - \section1 Widget Styles - - \l{Implementing Styles and Style Aware Widgets}{Styles} draw on behalf of widgets - and encapsulate the look and feel of a GUI. Qt's built-in widgets use the QStyle - class to perform nearly all of their drawing, ensuring that they look exactly like - the equivalent native widgets. + \page widgets-and-layouts.html + \title Widgets and Layouts + \ingroup qt-gui-concepts + \brief The primary elements for designing user interfaces in Qt. + + \section1 Widgets + + Widgets are the primary elements for creating user interfaces in Qt. + \l{Widget Classes}{Widgets} can display data and status information, + receive user input, and provide a container for other widgets that + should be grouped together. A widget that is not embedded in a + parent widget is called a \l{Application Windows and + Dialogs}{window}. + + \image parent-child-widgets.png A parent widget containing various child widgets. + + The QWidget class provides the basic capability to render to the + screen, and to handle user input events. All UI elements that Qt + provides are either subclasses of QWidget, or are used in connection + with a QWidget subclass. Creating custom widgets is done by + subclassing QWidget or a suitable subclass and reimplementing the + virtual event handlers. + + \section1 Layouts + + \l{Layout Management}{Layouts} are an elegant and flexible way to + automatically arrange child widgets within their container. Each + widget reports its size requirements to the layout through the + \l{QWidget::}{sizeHint} and \l{QWidget::}{sizePolicy} properties, + and the layout distributes the available space accordingly. + + \table + \row + \o \image qgridlayout-with-5-children.png + \o \image qformlayout-with-6-children.png + \endtable + + \l{Qt Designer Manual}{\QD} is a powerful tool for interactively creating and + arranging widgets in layouts. + + \section1 Widget Styles + + \l{Implementing Styles and Style Aware Widgets}{Styles} draw on + behalf of widgets and encapsulate the look and feel of a GUI. Qt's + built-in widgets use the QStyle class to perform nearly all of their + drawing, ensuring that they look exactly like the equivalent native + widgets. - \table - \row - \o \image windowsxp-tabwidget.png - \o \image plastique-tabwidget.png - \o \image macintosh-tabwidget.png - \endtable - - \l{Qt Style Sheets} are a powerful mechanism that allows you to customize the - appearance of widgets, in addition to what is already possible by subclassing QStyle. -*/ - -/*! - \page widget-classes.html - \title Widget Classes + \table + \row + \o \image windowsxp-tabwidget.png + \o \image plastique-tabwidget.png + \o \image macintosh-tabwidget.png + \endtable - \contentspage Widgets and Layouts - \nextpage Layout Management + \l{Qt Style Sheets} are a powerful mechanism that allows you to customize the + appearance of widgets, in addition to what is already possible by subclassing QStyle. - Below you find a list of all widget classes in Qt. You can also browse the - widget classes Qt provides in the various supported styles in the - \l{Qt Widget Gallery}. + \section1 The Widget Classes - \tableofcontents + The following sections list the widget classes. See the \l{Qt Widget + Gallery} for some examples. - \section1 Basic Widgets + \section2 Basic Widgets - These basic widgets (controls), such as buttons, comboboxes and scroll bars, are - designed for direct use. + These basic widgets (controls), e.g. buttons, comboboxes and + scroll bars, are designed for direct use. - \table - \row - \o \image windows-label.png - \o \image windowsvista-pushbutton.png - \o \image gtk-progressbar.png - \row - \o \image plastique-combobox.png - \o \image macintosh-radiobutton.png - \o \image cde-lineedit.png - \endtable + \table + \row + \o \image windows-label.png + \o \image windowsvista-pushbutton.png + \o \image gtk-progressbar.png + \row + \o \image plastique-combobox.png + \o \image macintosh-radiobutton.png + \o \image cde-lineedit.png + \endtable - \annotatedlist basicwidgets + \annotatedlist basicwidgets - \section1 Advanced Widgets + \section2 Advanced Widgets - Advanced GUI widgets such as tab widgets and progress bars provide more - complex user interface controls. + Advanced GUI widgets, e.g. tab widgets and progress bars, provide + more complex user interface controls. - \table - \row - \o \image windowsxp-treeview.png - \o \image gtk-calendarwidget.png - \o \image qundoview.png - \endtable + \table + \row + \o \image windowsxp-treeview.png + \o \image gtk-calendarwidget.png + \o \image qundoview.png + \endtable - \annotatedlist advanced + \annotatedlist advanced - \table - \row - \o \image windowsvista-tabwidget.png - \o \image macintosh-groupbox.png - \endtable + \table + \row + \o \image windowsvista-tabwidget.png + \o \image macintosh-groupbox.png + \endtable - \section1 Organizer Widgets + \section2 Organizer Widgets - Classes like splitters, tab bars, button groups, etc are used to - organize and group GUI primitives into more complex applications or - dialogs. + Classes like splitters, tab bars, button groups, etc are used for + organizing and grouping GUI primitives into more complex + applications and dialogs. - \annotatedlist organizers + \annotatedlist organizers - \section1 Abstract Widget Classes + \section2 Abstract Widget Classes - Abstract widget classes usable through subclassing. They are generally - not usable in themselves, but provide functionality that can be used - by inheriting these classes. + The abstract widget classes are base classes. They are not usable as + standalone classes but provide functionality when they are subclassed. - \annotatedlist abstractwidgets + \annotatedlist abstractwidgets */ /*! diff --git a/doc/src/windows-and-dialogs/mainwindow.qdoc b/doc/src/windows-and-dialogs/mainwindow.qdoc index b282dab..c1e66d9 100644 --- a/doc/src/windows-and-dialogs/mainwindow.qdoc +++ b/doc/src/windows-and-dialogs/mainwindow.qdoc @@ -46,12 +46,11 @@ /*! \page application-windows.html - \title Application Windows and Dialogs + \title Window and Dialog Widgets + \brief Windows and Dialogs in Qt. \ingroup qt-gui-concepts \ingroup frameworks-technologies - \nextpage The Application Main Window - A \l{Widgets Tutorial}{widget} that is not embedded in a parent widget is called a window. Usually, windows have a frame and a title bar, although it is also possible to create windows without such decoration using suitable window flags). In Qt, QMainWindow @@ -165,12 +164,9 @@ /*! \page mainwindow.html - \title The Application Main Window - \brief Everything you need for a typical modern main application window, - including menus, toolbars, workspace, etc. - - \contentspage Application Windows and Dialogs - \nextpage Dialog Windows + \title Application Main Window + \ingroup qt-gui-concepts + \brief Creating the application window. \tableofcontents -- cgit v0.12 From 60c715cd3a9eaa7f02dd93a083f51997b5303597 Mon Sep 17 00:00:00 2001 From: Iain Date: Fri, 14 May 2010 13:52:23 +0200 Subject: Re-enable suppression of --export_all_vtbl for static libraries Revert fix for QTBUG-10680 - the reasoning in the original fix was wrong. Internal typeinfo and vtable exports should be suppressed even for static libraries, as these will leak through into the final DLL when it links against that static lib (my testing at the time must have been faulty, as I thought I had found that they didn't). This change may cause problems if anyone has already frozen (internal) TI and VT symbols into their DEF files through linking with a static library. However, it should be perfectly safe to mark those symbols as ABSENT in the DEF file. An alternate solution must be found for QTBUG-10680. Task-number: QTBUG-10678 Reviewed-by: Alessandro Portale --- mkspecs/features/static.prf | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mkspecs/features/static.prf b/mkspecs/features/static.prf index ef3af07..288852d 100644 --- a/mkspecs/features/static.prf +++ b/mkspecs/features/static.prf @@ -11,9 +11,4 @@ mac { QMAKE_LFLAGS += $$QMAKE_LFLAGS_STATIC_LIB } -symbian { - # we don't care about exports from static libraries, as they don't end up in DEF files - MMP_RULES -= $$MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA -} - !static_and_shared:fix_output_dirs:fixExclusiveOutputDirs(static, shared) -- cgit v0.12 From f752b927c6f7115646da7e86209e60e7c17e7d95 Mon Sep 17 00:00:00 2001 From: Iain Date: Fri, 14 May 2010 14:32:04 +0200 Subject: Shadow building on Symbian fixes: part 1 - files to right place First in a set of fixes for shadow building on Symbian - make sure we generate all the files into the shadow directory, *not* the source directory Task-number: QTBUG-10432 Reviewed-by: Miikka Heikkinen --- qmake/generators/symbian/initprojectdeploy_symbian.cpp | 9 +++++---- qmake/generators/symbian/symbiancommon.cpp | 11 +++++------ qmake/generators/symbian/symmake.cpp | 10 ++++------ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.cpp b/qmake/generators/symbian/initprojectdeploy_symbian.cpp index 6407412..4552185 100644 --- a/qmake/generators/symbian/initprojectdeploy_symbian.cpp +++ b/qmake/generators/symbian/initprojectdeploy_symbian.cpp @@ -91,12 +91,13 @@ static void createPluginStub(const QFileInfo& info, QStringList& generatedDirs, QStringList& generatedFiles) { - QDir().mkpath(QLatin1String(PLUGIN_STUB_DIR)); - if (!generatedDirs.contains(PLUGIN_STUB_DIR)) - generatedDirs << PLUGIN_STUB_DIR; + QString pluginStubDir = Option::output_dir + QLatin1Char('/') + QLatin1String(PLUGIN_STUB_DIR); + QDir().mkpath(pluginStubDir); + if (!generatedDirs.contains(pluginStubDir)) + generatedDirs << pluginStubDir; // Plugin stubs must have different name from the actual plugins, because // the toolchain for creating ROM images cannot handle non-binary .dll files properly. - QFile stubFile(QLatin1String(PLUGIN_STUB_DIR "/") + info.completeBaseName() + "." SUFFIX_QTPLUGIN); + QFile stubFile(pluginStubDir + QLatin1Char('/') + info.completeBaseName() + QLatin1Char('.') + QLatin1String(SUFFIX_QTPLUGIN)); if (stubFile.open(QIODevice::WriteOnly)) { if (!generatedFiles.contains(stubFile.fileName())) generatedFiles << stubFile.fileName(); diff --git a/qmake/generators/symbian/symbiancommon.cpp b/qmake/generators/symbian/symbiancommon.cpp index b730d9e..adbd009 100644 --- a/qmake/generators/symbian/symbiancommon.cpp +++ b/qmake/generators/symbian/symbiancommon.cpp @@ -150,9 +150,8 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB pkgTarget = project->first("TARGET"); pkgTarget = generator->unescapeFilePath(pkgTarget); pkgTarget = removePathSeparators(pkgTarget); - QString pkgFilename = QString("%1_template.%2").arg(pkgTarget).arg("pkg"); - if (!Option::output_dir.isEmpty()) - pkgFilename = Option::output_dir + '/' + pkgFilename; + QString pkgFilename = Option::output_dir + QLatin1Char('/') + QString("%1_template.%2") + .arg(pkgTarget).arg("pkg"); QFile pkgFile(pkgFilename); if (!pkgFile.open(QIODevice::WriteOnly | QIODevice::Text)) { @@ -173,9 +172,9 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB QString dateStr = QDateTime::currentDateTime().toString(Qt::ISODate); // Header info - QString wrapperPkgFilename = QString("%1_installer.%2") - .arg(pkgTarget) - .arg("pkg"); + QString wrapperPkgFilename = Option::output_dir + QLatin1Char('/') + QString("%1_installer.%2") + .arg(pkgTarget).arg("pkg"); + QString headerComment = "; %1 generated by qmake at %2\n" "; This file is generated by qmake and should not be modified by the user\n" ";\n\n"; diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index 1dee4ac..1006e39 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -214,7 +214,7 @@ bool SymbianMakefileGenerator::writeMakefile(QTextStream &t) // Generate empty wrapper makefile here, because wrapper makefile must exist before writeMkFile, // but all required data is not yet available. bool isPrimaryMakefile = true; - QString wrapperFileName("Makefile"); + QString wrapperFileName = Option::output_dir + QLatin1Char('/') + QLatin1String("Makefile"); QString outputFileName = fileInfo(Option::output.fileName()).fileName(); if (outputFileName != BLD_INF_FILENAME) { wrapperFileName.append(".").append(outputFileName.startsWith(BLD_INF_FILENAME) @@ -246,10 +246,8 @@ bool SymbianMakefileGenerator::writeMakefile(QTextStream &t) shortProFilename.replace(0, shortProFilename.lastIndexOf("/") + 1, QString("")); shortProFilename.replace(Option::pro_ext, QString("")); - QString mmpFilename = shortProFilename; - mmpFilename.append("_"); - mmpFilename.append(uid3); - mmpFilename.append(Option::mmp_ext); + QString mmpFilename = Option::output_dir + QLatin1Char('/') + shortProFilename + QLatin1Char('_') + + uid3 + Option::mmp_ext; writeMmpFile(mmpFilename, symbianLangCodes); if (targetType == TypeExe) { @@ -270,7 +268,7 @@ void SymbianMakefileGenerator::writeCustomDefFile() { if (targetType == TypePlugin && !project->isActiveConfig("stdbinary")) { // Create custom def file for plugin - QFile ft(QLatin1String(PLUGIN_COMMON_DEF_FILE_ACTUAL)); + QFile ft(Option::output_dir + QLatin1Char('/') + QLatin1String(PLUGIN_COMMON_DEF_FILE_ACTUAL)); if (ft.open(QIODevice::WriteOnly)) { generatedFiles << ft.fileName(); -- cgit v0.12 From 217cd535974720ea082f900d9adeb06cca2c530d Mon Sep 17 00:00:00 2001 From: Iain Date: Fri, 14 May 2010 14:46:52 +0200 Subject: Shadow building on Symbian fixes: part 2 - populate bin dir correctly Second in a set of fixes for shadow building on Symbian - create links in the shadow bin dir to the Symbian specific scripts we've added to the bin directory Task-number: QTBUG-10432 Reviewed-by: Alessandro Portale --- tools/configure/configureapp.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index e264426..beaf9bd 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -195,10 +195,37 @@ Configure::Configure( int& argc, char** argv ) } } + // make patch_capabilities and createpackage scripts for Symbian that can be used from the shadow build + QFile patch_capabilities(buildPath + "/bin/patch_capabilities"); + if(patch_capabilities.open(QFile::WriteOnly)) { + QTextStream stream(&patch_capabilities); + stream << "#!/usr/bin/perl -w" << endl + << "require \"" << sourcePath + "/bin/patch_capabilities\";" << endl; + } + QFile patch_capabilities_bat(buildPath + "/bin/patch_capabilities.bat"); + if(patch_capabilities_bat.open(QFile::WriteOnly)) { + QTextStream stream(&patch_capabilities_bat); + stream << "@echo off" << endl + << "call " << fixSeparators(sourcePath) << fixSeparators("/bin/patch_capabilities.bat %*") << endl; + patch_capabilities_bat.close(); + } + QFile createpackage(buildPath + "/bin/createpackage"); + if(createpackage.open(QFile::WriteOnly)) { + QTextStream stream(&createpackage); + stream << "#!/usr/bin/perl -w" << endl + << "require \"" << sourcePath + "/bin/createpackage\";" << endl; + } + QFile createpackage_bat(buildPath + "/bin/createpackage.bat"); + if(createpackage_bat.open(QFile::WriteOnly)) { + QTextStream stream(&createpackage_bat); + stream << "@echo off" << endl + << "call " << fixSeparators(sourcePath) << fixSeparators("/bin/createpackage.bat %*") << endl; + createpackage_bat.close(); + } + // For Windows CE and shadow builds we need to copy these to the // build directory. QFile::copy(sourcePath + "/bin/setcepaths.bat" , buildPath + "/bin/setcepaths.bat"); - //copy the mkspecs buildDir.mkpath("mkspecs"); if(!Environment::cpdir(sourcePath + "/mkspecs", buildPath + "/mkspecs")){ -- cgit v0.12 From f4ffb4b082a43ba267855fbe915da9f934f59043 Mon Sep 17 00:00:00 2001 From: Iain Date: Fri, 14 May 2010 15:06:27 +0200 Subject: Shadow building on Symbian fixes: part 3 - unchanged source tree Stop symbiancommon.obj being generated in the source directory even when shadow building (make has a rule to make .obj files, and quite happily makes the .obj in the source dir when it sees it as a dependency....) Also, correct spaces instead of tabs - this is a makefile! Task-number: QTBUG-10432 Reviewed-by: Miikka Heikkinen --- qmake/Makefile.win32 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 956fa9c..b58757c 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -200,7 +200,7 @@ clean:: -del symmake.obj -del symmake_abld.obj -del symmake_sbsv2.obj - -del symbiancommon.obj + -del symbiancommon.obj -del initprojectdeploy_symbian.obj -del registry.obj -del epocroot.obj @@ -442,7 +442,7 @@ pbuilder_pbx.obj: $(SOURCE_PATH)/qmake/generators/mac/pbuilder_pbx.cpp makefiledeps.obj: $(SOURCE_PATH)/qmake/generators/makefiledeps.cpp $(CXX) $(CXXFLAGS) generators/makefiledeps.cpp -metamakefile.obj: $(SOURCE_PATH)/qmake/generators/metamakefile.cpp $(SOURCE_PATH)/qmake/generators/symbian/symbiancommon.obj +metamakefile.obj: $(SOURCE_PATH)/qmake/generators/metamakefile.cpp $(CXX) $(CXXFLAGS) generators/metamakefile.cpp xmloutput.obj: $(SOURCE_PATH)/qmake/generators/xmloutput.cpp -- cgit v0.12 From 6835055e501127a39ef78dfd5768783a75bcb156 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 14 May 2010 14:55:13 +0200 Subject: Support linked fonts (.ltt) from standard font locations. The internal font database was only populated with .ttf and .ccc files. This patch adds .ltt as file type. Without complete font type coverage in the fontstore, we may get a mismatch in the internal association of font table and fontfamily. Most probably, this will also fix the crash on SSE Satio's. SSE seems to use .ltt files already on S60 5.0. An improvement needs to be verified by an owner of such a device, however. Task-number: QTBUG-8905 Reviewed-by: Aleksandar Sasha Babic --- src/gui/text/qfontdatabase_s60.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 4171e40..40fe3b7 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -113,6 +113,7 @@ QSymbianFontDatabaseExtrasImplementation::QSymbianFontDatabaseExtrasImplementati QStringList filters; filters.append(QLatin1String("*.ttf")); filters.append(QLatin1String("*.ccc")); + filters.append(QLatin1String("*.ltt")); const QFileInfoList fontFiles = alternativeFilePaths(QLatin1String("resource\\Fonts"), filters); const TInt heapMinLength = 0x1000; -- cgit v0.12 From b8f1d7fd87985375a373ca85052c475241822b03 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 12 May 2010 16:44:20 +0200 Subject: Optimized pixmapcache key generation for icons and styles If we sacrifice the readability we can make cache keys much faster. Since there is rarely a usecase where we need these as human readable strings we can take advantage of this fact and remove almost all memory allocations while still keeping them unique. Task-number: QTBUG-9850 Reviewed-by: brad --- src/gui/image/qicon.cpp | 23 +++++++------ src/gui/styles/qgtkpainter.cpp | 16 +++++++-- src/gui/styles/qstylehelper.cpp | 74 ++++++++++++----------------------------- 3 files changed, 48 insertions(+), 65 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 891b1db..9f1eea2 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -261,16 +261,19 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height())) actualSize.scale(size, Qt::KeepAspectRatio); - QString key = QLatin1String("$qt_icon_") - + QString::number(pm.cacheKey()) - + QString::number(pe->mode) - + QString::number(QApplication::palette().cacheKey()) - + QLatin1Char('_') - + QString::number(actualSize.width()) - + QLatin1Char('_') - + QString::number(actualSize.height()) - + QLatin1Char('_'); - + int digits = sizeof(qint64)/sizeof(QChar); + quint64 tkey = pm.cacheKey(), + tmode = pe->mode, + tpalkey = QApplication::palette().cacheKey(), + twidth = actualSize.width(), + theight = actualSize.height(); + + QString key = QLatin1Literal("qt_") + % QString::fromRawData((QChar*)&tkey, digits) + % QString::fromRawData((QChar*)&tmode, digits) + % QString::fromRawData((QChar*)&tpalkey, digits) + % QString::fromRawData((QChar*)&twidth, digits) + % QString::fromRawData((QChar*)&theight, digits); if (mode == QIcon::Active) { if (QPixmapCache::find(key + QString::number(mode), pm)) diff --git a/src/gui/styles/qgtkpainter.cpp b/src/gui/styles/qgtkpainter.cpp index 1f68f2f..a6686e2 100644 --- a/src/gui/styles/qgtkpainter.cpp +++ b/src/gui/styles/qgtkpainter.cpp @@ -154,9 +154,21 @@ QGtkPainter::QGtkPainter(QPainter *_painter) static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget = 0) { + + int digits = sizeof(qint64)/sizeof(QChar); + quint64 tstate= state, + tshadow = shadow, + twidth = size.width(), + theight = size.height(), + twidget = quint64(widget); + // Note the widget arg should ideally use the widget path, though would compromise performance - QString tmp = QString(QLS("%0-%1-%2-%3x%4-%5")).arg(key).arg(uint(state)).arg(shadow) - .arg(size.width()).arg(size.height()).arg(quintptr(widget)); + QString tmp = key + % QString::fromRawData((QChar*)&tstate, digits) + % QString::fromRawData((QChar*)&tshadow, digits) + % QString::fromRawData((QChar*)&twidth, digits) + % QString::fromRawData((QChar*)&theight, digits) + % QString::fromRawData((QChar*)&twidget, digits); return tmp; } diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp index 296c51c..22f2014 100644 --- a/src/gui/styles/qstylehelper.cpp +++ b/src/gui/styles/qstylehelper.cpp @@ -58,67 +58,35 @@ QT_BEGIN_NAMESPACE -// internal helper. Converts an integer value to an unique string token -template -struct HexString -{ - inline HexString(const T t) - : val(t) - {} - - inline void write(QChar *&dest) const - { - const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - const char *c = reinterpret_cast(&val); - for (uint i = 0; i < sizeof(T); ++i) { - *dest++ = hexChars[*c & 0xf]; - *dest++ = hexChars[(*c & 0xf0) >> 4]; - ++c; - } - } - - const T val; -}; - -// specialization to enable fast concatenating of our string tokens to a string -template -struct QConcatenable > -{ - typedef HexString type; - enum { ExactSize = true }; - static int size(const HexString &str) { return sizeof(str.val) * 2; } - static inline void appendTo(const HexString &str, QChar *&out) { str.write(out); } -}; - namespace QStyleHelper { QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) { const QStyleOptionComplex *complexOption = qstyleoption_cast(option); - - QString tmp = key - % QLatin1Char('-') - % HexString(option->state) - % QLatin1Char('-') - % HexString(option->direction) - % QLatin1Char('-') - % HexString(complexOption ? uint(complexOption->activeSubControls) : 0u) - % QLatin1Char('-') - % HexString(option->palette.cacheKey()) - % QLatin1Char('-') - % HexString(size.width()) - % QLatin1Char('x') - % HexString(size.height()); + int digits = sizeof(qint64)/sizeof(QChar); + quint64 state = option->state, + direction = option->direction, + subcontrols = (complexOption ? uint(complexOption->activeSubControls) : 0u), + palettekey = option->palette.cacheKey(), + width = size.width(), + height = size.height(); + + QString tmp = key % QString::fromRawData((QChar*)&state, digits) + % QString::fromRawData((QChar*)&direction, digits) + % QString::fromRawData((QChar*)&subcontrols, digits) + % QString::fromRawData((QChar*)&palettekey, digits) + % QString::fromRawData((QChar*)&width, digits) + % QString::fromRawData((QChar*)&height, digits); #ifndef QT_NO_SPINBOX if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { - tmp = tmp - % QLatin1Char('-') - % HexString(spinBox->buttonSymbols) - % QLatin1Char('-') - % HexString(spinBox->stepEnabled) - % QLatin1Char('-') - % QLatin1Char(spinBox->frame ? '1' : '0'); + quint64 buttonsymbols = spinBox->buttonSymbols, + stepEnabled = spinBox->stepEnabled, + frame = spinBox->frame; + + tmp = tmp % QString::fromRawData((QChar*)&buttonsymbols, digits) + % QString::fromRawData((QChar*)&stepEnabled, digits) + % QString::fromRawData((QChar*)&frame, digits); } #endif // QT_NO_SPINBOX return tmp; -- cgit v0.12 From 9a69656bd64016933124813ea5403e7e5d454719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 14 May 2010 15:42:43 +0200 Subject: Added workarounds for two MBX/SGX specific GL ES bugs/problems. The workaround flags are put into the platform independent section for now, since there might be a general need for these as we expand our GL and GL ES usage. The workaround_needsFullClearOnEveryFrame flag covers the case where you get a performance penalty on PowerVR hw if all rendering buffers are not cleared. The workaround_brokenFBOReadBack flag covers the case where copying pixels from a texture (e.g. via glCopyTexSubImage2d()) bound in an FBO doesn't work. Task-number: QTBUG-10670 Reviewed-by: Gunnar --- .../gl2paintengineex/qtextureglyphcache_gl.cpp | 18 +++++------------- .../gl2paintengineex/qtextureglyphcache_gl_p.h | 2 -- src/opengl/qgl.cpp | 3 +++ src/opengl/qgl.h | 1 + src/opengl/qgl_egl.cpp | 20 +++++++++++++++++++- src/opengl/qgl_p.h | 8 +++++++- src/opengl/qglpaintdevice.cpp | 5 ++++- 7 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 452d37d..cc42c63 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -57,21 +57,13 @@ QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyph , ctx(context) , m_width(0) , m_height(0) - , m_broken_fbo_readback(false) { // broken FBO readback is a bug in the SGX 1.3 and 1.4 drivers for the N900 where // copying between FBO's is broken if the texture is either GL_ALPHA or POT. The // workaround is to use a system-memory copy of the glyph cache for this device. // Switching to NPOT and GL_RGBA would both cost a lot more graphics memory and // be slower, so that is not desireable. -#if defined QT_OPENGL_ES_2 && !defined(QT_NO_EGL) - if (QByteArray((char*) glGetString(GL_RENDERER)).contains("SGX")) { - QGLContextPrivate *ctxd = context->d_func(); - m_broken_fbo_readback = QByteArray((char *) eglQueryString(ctxd->eglContext->display(), EGL_VERSION)).contains("1.3"); - } -#endif - - if (!m_broken_fbo_readback) + if (!ctx->d_ptr->workaround_brokenFBOReadBack) glGenFramebuffers(1, &m_fbo); connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), @@ -83,7 +75,7 @@ QGLTextureGlyphCache::~QGLTextureGlyphCache() if (ctx) { QGLShareContextScope scope(ctx); - if (!m_broken_fbo_readback) + if (!ctx->d_ptr->workaround_brokenFBOReadBack) glDeleteFramebuffers(1, &m_fbo); if (m_width || m_height) @@ -96,7 +88,7 @@ void QGLTextureGlyphCache::createTextureData(int width, int height) // create in QImageTextureGlyphCache baseclass is meant to be called // only to create the initial image and does not preserve the content, // so we don't call when this function is called from resize. - if (m_broken_fbo_readback && image().isNull()) + if (ctx->d_ptr->workaround_brokenFBOReadBack && image().isNull()) QImageTextureGlyphCache::createTextureData(width, height); glGenTextures(1, &m_texture); @@ -126,7 +118,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) GLuint oldTexture = m_texture; createTextureData(width, height); - if (m_broken_fbo_readback) { + if (ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::resizeTextureData(width, height); Q_ASSERT(image().depth() == 8); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, image().constBits()); @@ -209,7 +201,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) { - if (m_broken_fbo_readback) { + if (ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::fillTexture(c, glyph); glBindTexture(GL_TEXTURE_2D, m_texture); diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index efb7435..6bcd655 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -115,8 +115,6 @@ private: int m_height; QGLShaderProgram *m_program; - - bool m_broken_fbo_readback; }; QT_END_NAMESPACE diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 7c457de..922a96c 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1612,6 +1612,9 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) current_fbo = 0; default_fbo = 0; active_engine = 0; + workaround_needsFullClearOnEveryFrame = false; + workaround_brokenFBOReadBack = false; + workaroundsCached = false; for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) vertexAttributeArraysEnabledState[i] = false; } diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 92a064f..f297009 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -431,6 +431,7 @@ private: friend class QGLFramebufferObjectPrivate; friend class QGLFBOGLPaintDevice; friend class QGLPaintDevice; + friend class QGLWidgetGLPaintDevice; friend class QX11GLPixmapData; friend class QX11GLSharedContexts; private: diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 0fbbbf9..44e8ae9 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -185,8 +185,26 @@ void QGLContext::makeCurrent() return; } - if (d->eglContext->makeCurrent(d->eglSurfaceForDevice())) + if (d->eglContext->makeCurrent(d->eglSurfaceForDevice())) { QGLContextPrivate::setCurrentContext(this); + if (!d->workaroundsCached) { + d->workaroundsCached = true; + const char *renderer = reinterpret_cast(glGetString(GL_RENDERER)); + if (strstr(renderer, "SGX") || strstr(renderer, "MBX")) { + // PowerVR MBX/SGX chips needs to clear all buffers when starting to render + // a new frame, otherwise there will be a performance penalty to pay for + // each frame. + d->workaround_needsFullClearOnEveryFrame = true; + + // Older PowerVR SGX drivers (like the one in the N900) have a + // bug which prevents glCopyTexSubImage2D() to work with a POT + // or GL_ALPHA texture bound to an FBO. The only way to + // identify that driver is to check the EGL version number for it. + if (strstr(eglQueryString(d->eglContext->display(), EGL_VERSION), "1.3")) + d->workaround_brokenFBOReadBack = true; + } + } + } } void QGLContext::doneCurrent() diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index f19e394..d92f963 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -345,7 +345,7 @@ public: HDC hbitmap_hdc; #endif #ifndef QT_NO_EGL - bool ownsEglContext; + uint ownsEglContext : 1; QEglContext *eglContext; EGLSurface eglSurface; void destroyEglSurfaceForDevice(); @@ -382,6 +382,12 @@ public: uint internal_context : 1; uint version_flags_cached : 1; uint extension_flags_cached : 1; + + // workarounds for driver/hw bugs on different platforms + uint workaround_needsFullClearOnEveryFrame : 1; + uint workaround_brokenFBOReadBack : 1; + uint workaroundsCached : 1; + QPaintDevice *paintDevice; QColor transpColor; QGLContext *q_ptr; diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index e874e85..e1dcbfd 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -175,7 +175,10 @@ void QGLWidgetGLPaintDevice::beginPaint() float alpha = c.alphaF(); glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); } - glClear(GL_COLOR_BUFFER_BIT); + if (context()->d_func()->workaround_needsFullClearOnEveryFrame) + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + else + glClear(GL_COLOR_BUFFER_BIT); } } -- cgit v0.12 From 18af9ef6074c33f7416629007ef5d24a39a55cbe Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 14 May 2010 16:37:35 +0300 Subject: Fix SRCDIR and DEPLOYMENT usage in declarative benchmarks These tests were either not compiling, were deploying incorrectly, or looking for data files from wrong place. Task-number: QTBUG-10661 Task-number: QTBUG-10666 Task-number: QTBUG-10667 Reviewed-by: Shane Kearns --- tests/benchmarks/declarative/binding/binding.pro | 12 ++++++------ tests/benchmarks/declarative/binding/tst_binding.cpp | 5 +++++ .../benchmarks/declarative/compilation/compilation.pro | 8 +++++++- .../declarative/compilation/tst_compilation.cpp | 5 ++--- tests/benchmarks/declarative/creation/creation.pro | 6 +++--- tests/benchmarks/declarative/creation/tst_creation.cpp | 8 ++++---- .../qdeclarativecomponent/qdeclarativecomponent.pro | 17 +++++++---------- .../qdeclarativecomponent/tst_qdeclarativecomponent.cpp | 4 ++++ .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 3 +-- .../qdeclarativemetaproperty.pro | 11 +++++++++-- .../tst_qdeclarativemetaproperty.cpp | 4 ++++ tests/benchmarks/declarative/qmltime/qmltime.pro | 16 ++++------------ .../declarative/typeimports/tst_typeimports.cpp | 9 ++++----- .../benchmarks/declarative/typeimports/typeimports.pro | 8 ++++---- 14 files changed, 64 insertions(+), 52 deletions(-) diff --git a/tests/benchmarks/declarative/binding/binding.pro b/tests/benchmarks/declarative/binding/binding.pro index 5ceaf34..7fc0a23 100644 --- a/tests/benchmarks/declarative/binding/binding.pro +++ b/tests/benchmarks/declarative/binding/binding.pro @@ -7,12 +7,12 @@ macx:CONFIG -= app_bundle SOURCES += tst_binding.cpp testtypes.cpp HEADERS += testtypes.h -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" - -symbian* { - data.sources = data/* - data.path = data +symbian { + data.sources = data + data.path = . DEPLOYMENT = data +} else { + # Define SRCDIR equal to test's source directory + DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/benchmarks/declarative/binding/tst_binding.cpp b/tests/benchmarks/declarative/binding/tst_binding.cpp index dbddac3..6e3e146 100644 --- a/tests/benchmarks/declarative/binding/tst_binding.cpp +++ b/tests/benchmarks/declarative/binding/tst_binding.cpp @@ -48,6 +48,11 @@ //TESTED_FILES= +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_binding : public QObject { Q_OBJECT diff --git a/tests/benchmarks/declarative/compilation/compilation.pro b/tests/benchmarks/declarative/compilation/compilation.pro index 32f4aba..9277187 100644 --- a/tests/benchmarks/declarative/compilation/compilation.pro +++ b/tests/benchmarks/declarative/compilation/compilation.pro @@ -8,4 +8,10 @@ CONFIG += release SOURCES += tst_compilation.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian { + data.sources += data + data.path = . + DEPLOYMENT += data +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/benchmarks/declarative/compilation/tst_compilation.cpp b/tests/benchmarks/declarative/compilation/tst_compilation.cpp index 5694d5b..0c6e917 100644 --- a/tests/benchmarks/declarative/compilation/tst_compilation.cpp +++ b/tests/benchmarks/declarative/compilation/tst_compilation.cpp @@ -46,8 +46,7 @@ #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir -// Application private dir is default serach path for files, so SRCDIR can be set to empty -#define SRCDIR "" +#define SRCDIR "." #endif class tst_compilation : public QObject @@ -63,7 +62,7 @@ private: QDeclarativeEngine engine; }; -tst_compilation::tst_compilation() +tst_compilation::tst_compilation() { } diff --git a/tests/benchmarks/declarative/creation/creation.pro b/tests/benchmarks/declarative/creation/creation.pro index 3e0caf6..a5df676 100644 --- a/tests/benchmarks/declarative/creation/creation.pro +++ b/tests/benchmarks/declarative/creation/creation.pro @@ -7,9 +7,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_creation.cpp symbian* { - data.sources = data/* - data.path = data - DEPLOYMENT += addFiles + data.sources = data + data.path = . + DEPLOYMENT += data } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } \ No newline at end of file diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 99324f4..a253671 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -53,7 +53,7 @@ #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir // Application private dir is default serach path for files, so SRCDIR can be set to empty -#define SRCDIR "" +#define SRCDIR "." #endif class tst_creation : public QObject @@ -97,8 +97,8 @@ public: TestType(QObject *parent = 0) : QObject(parent) {} - QDeclarativeListProperty resources() { - return QDeclarativeListProperty(this, 0, resources_append); + QDeclarativeListProperty resources() { + return QDeclarativeListProperty(this, 0, resources_append); } static void resources_append(QDeclarativeListProperty *p, QObject *o) { @@ -106,7 +106,7 @@ public: } }; -tst_creation::tst_creation() +tst_creation::tst_creation() { qmlRegisterType("Qt.test", 1, 0, "TestType"); } diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro index 30ef235..917040d 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro +++ b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro @@ -7,16 +7,13 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativecomponent.cpp testtypes.cpp HEADERS += testtypes.h -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" -symbian* { - data.sources = data/* - data.path = data - samegame.sources = data/samegame/* - samegame.path = data/samegame - samegame_pics.sources = data/samegame/pics/* - samegame_pics.path = data/samegame/pics - DEPLOYMENT += data samegame samegame_pics +symbian { + data.sources = data + data.path = . + DEPLOYMENT += data +} else { + # Define SRCDIR equal to test's source directory + DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp index 4b1456e..13420ff 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp +++ b/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp @@ -48,6 +48,10 @@ //TESTED_FILES= +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif class tst_qmlcomponent : public QObject { diff --git a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index e2e8c8a..2d9744e 100644 --- a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -46,8 +46,7 @@ #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir -// Application private dir is default serach path for files, so SRCDIR can be set to empty -#define SRCDIR "" +#define SRCDIR "." #endif class tst_qmlgraphicsimage : public QObject diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro index 79fdd26..1b72fc5 100644 --- a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro +++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro @@ -6,5 +6,12 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativemetaproperty.cpp -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian { + data.sources += data + data.path = . + DEPLOYMENT += data +} else { + # Define SRCDIR equal to test's source directory + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp b/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp index 8a5f4ae..6e71e7d 100644 --- a/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp +++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp @@ -48,6 +48,10 @@ //TESTED_FILES= +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif class tst_qmlmetaproperty : public QObject { diff --git a/tests/benchmarks/declarative/qmltime/qmltime.pro b/tests/benchmarks/declarative/qmltime/qmltime.pro index 9352f3b..6f5ad5e 100644 --- a/tests/benchmarks/declarative/qmltime/qmltime.pro +++ b/tests/benchmarks/declarative/qmltime/qmltime.pro @@ -6,18 +6,10 @@ macx:CONFIG -= app_bundle SOURCES += qmltime.cpp -symbian* { +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 + example.sources = example.qml tests + example.path = . + DEPLOYMENT += example } diff --git a/tests/benchmarks/declarative/typeimports/tst_typeimports.cpp b/tests/benchmarks/declarative/typeimports/tst_typeimports.cpp index b92ab46..f4c4c1f 100644 --- a/tests/benchmarks/declarative/typeimports/tst_typeimports.cpp +++ b/tests/benchmarks/declarative/typeimports/tst_typeimports.cpp @@ -46,8 +46,7 @@ #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir -// Application private dir is default serach path for files, so SRCDIR can be set to empty -#define SRCDIR "" +#define SRCDIR "." #endif class tst_typeimports : public QObject @@ -72,8 +71,8 @@ class TestType1 : public QObject public: TestType1(QObject *parent = 0) : QObject(parent) {} - QDeclarativeListProperty resources() { - return QDeclarativeListProperty(this, 0, resources_append); + QDeclarativeListProperty resources() { + return QDeclarativeListProperty(this, 0, resources_append); } static void resources_append(QDeclarativeListProperty *p, QObject *o) { @@ -104,7 +103,7 @@ public: }; -tst_typeimports::tst_typeimports() +tst_typeimports::tst_typeimports() { qmlRegisterType("Qt.test", 1, 0, "TestType1"); qmlRegisterType("Qt.test", 1, 0, "TestType2"); diff --git a/tests/benchmarks/declarative/typeimports/typeimports.pro b/tests/benchmarks/declarative/typeimports/typeimports.pro index 8a74e0d..a5df3f0 100644 --- a/tests/benchmarks/declarative/typeimports/typeimports.pro +++ b/tests/benchmarks/declarative/typeimports/typeimports.pro @@ -6,10 +6,10 @@ macx:CONFIG -= app_bundle SOURCES += tst_typeimports.cpp -symbian* { - data.sources = data/* - data.path = data - DEPLOYMENT += addFiles +symbian { + data.sources = data + data.path = . + DEPLOYMENT += data } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } \ No newline at end of file -- cgit v0.12 From 92ea8a1df59cb00178cd7670d2ce167bba3dd953 Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Fri, 14 May 2010 15:55:48 +0200 Subject: Fix for autotest failure in qwidget::saveRestoreGeometry() The problem was that the fix for bug QTBUG-10519 introduced a new state for saving the geometry. However there is an exception and that exception comes into play when saving a maximized window. This fixes that by making sure we only enter into that state when the window is not currently maximized. Reviewed-by: tbastian --- src/gui/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 82eb12b..1f2cd8c 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -6731,7 +6731,7 @@ QByteArray QWidget::saveGeometry() const Q_D(const QWidget); QRect newFramePosition = frameGeometry(); QRect newNormalPosition = normalGeometry(); - if(d->topData()->wasMaximized) { + if(d->topData()->wasMaximized && !(windowState() & Qt::WindowMaximized)) { // Change the starting position newFramePosition.moveTo(0, 0); newNormalPosition.moveTo(0, 0); -- cgit v0.12 From c60045ad8df097ebcb7efa89a5fc18b3a4614df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 14 May 2010 16:37:48 +0200 Subject: Limit the lower glyph texture cache size to 16x16 in GL. The SGX chip has a limitation regarding FBOs in that it doesn't support FBO sizes that are POT and less than 16 pixels in width/height. Since the FBO we use in the GL glyph cache always mirrors the size of the texture itself, we limit that instead to avoid creating invalid FBOs. Task-number: QTBUG-10645 Reviewed-by: Gunnar --- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index cc42c63..410cf21 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -91,6 +91,12 @@ void QGLTextureGlyphCache::createTextureData(int width, int height) if (ctx->d_ptr->workaround_brokenFBOReadBack && image().isNull()) QImageTextureGlyphCache::createTextureData(width, height); + // Make the lower glyph texture size 16 x 16. + if (width < 16) + width = 16; + if (height < 16) + height = 16; + glGenTextures(1, &m_texture); glBindTexture(GL_TEXTURE_2D, m_texture); @@ -115,6 +121,12 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) int oldWidth = m_width; int oldHeight = m_height; + // Make the lower glyph texture size 16 x 16. + if (width < 16) + width = 16; + if (height < 16) + height = 16; + GLuint oldTexture = m_texture; createTextureData(width, height); -- cgit v0.12 From 336feccaf4517605306844690103baf331f11d50 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 14 May 2010 08:24:00 +0200 Subject: Remove skins from qml launcher. --- tools/qml/main.cpp | 21 ---- tools/qml/qml.pri | 2 - tools/qml/qmlruntime.cpp | 244 +---------------------------------------------- tools/qml/qmlruntime.h | 6 -- 4 files changed, 2 insertions(+), 271 deletions(-) diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 116ca71..d1fc118 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -119,9 +119,6 @@ void usage() qWarning(" -maximized................................ run maximized"); qWarning(" -fullscreen............................... run fullscreen"); qWarning(" -stayontop................................ keep viewer window on top"); - qWarning(" -skin ...................... run with a skin window frame"); - qWarning(" \"list\" for a list of built-ins"); - qWarning(" -resizeview .............................. resize the view, not the skin"); qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content"); qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view"); qWarning(" -qmlbrowser .............................. use a QML-based file browser"); @@ -209,7 +206,6 @@ int main(int argc, char ** argv) QDeclarativeFolderListModel::registerTypes(); bool frameless = false; - bool resizeview = false; QString fileName; double fps = 0; int autorecord_from = 0; @@ -219,7 +215,6 @@ int main(int argc, char ** argv) QStringList recordargs; QStringList imports; QStringList plugins; - QString skin; QString script; QString scriptopts; bool runScript = false; @@ -252,11 +247,6 @@ int main(int argc, char ** argv) fullScreen = true; } else if (arg == "-stayontop") { stayOnTop = true; - } else if (arg == "-skin") { - if (lastArg) usage(); - skin = QString(argv[++i]); - } else if (arg == "-resizeview") { - resizeview = true; } else if (arg == "-netcache") { if (lastArg) usage(); cache = QString(argv[++i]).toInt(); @@ -418,21 +408,10 @@ int main(int argc, char ** argv) viewer->setNetworkCacheSize(cache); viewer->setRecordFile(recordfile); viewer->setSizeToView(sizeToView); - if (resizeview) - viewer->setScaleView(); if (fps>0) viewer->setRecordRate(fps); if (autorecord_to) viewer->setAutoRecord(autorecord_from,autorecord_to); - if (!skin.isEmpty()) { - if (skin == "list") { - foreach (QString s, viewer->builtinSkins()) - qWarning() << qPrintable(s); - exit(0); - } else { - viewer->setSkin(skin); - } - } if (devkeys) viewer->setDeviceKeys(true); viewer->setRecordDither(dither); diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index 3c86d31..a2058c7 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -32,5 +32,3 @@ symbian { FORMS = $$PWD/recopts.ui \ $$PWD/proxysettings.ui - -include(../shared/deviceskin/deviceskin.pri) diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 16b0ffb..911bf8c 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -53,7 +53,6 @@ #include "qdeclarative.h" #include #include -#include "deviceskin.h" #include #include @@ -168,89 +167,6 @@ private: QWidget *refWidget; }; - -class PreviewDeviceSkin : public DeviceSkin -{ - Q_OBJECT -public: - explicit PreviewDeviceSkin(const DeviceSkinParameters ¶meters, QWidget *parent); - - void setPreview(QWidget *formWidget); - void setPreviewAndScale(QWidget *formWidget); - - void setScreenSize(const QSize& size) - { - QMatrix fit; - fit = fit.scale(qreal(size.width())/m_screenSize.width(), - qreal(size.height())/m_screenSize.height()); - setTransform(fit); - QApplication::syncX(); - } - - QSize standardScreenSize() const { return m_screenSize; } - - QMenu* menu; - -private slots: - void slotSkinKeyPressEvent(int code, const QString& text, bool autorep); - void slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep); - void slotPopupMenu(); - -private: - const QSize m_screenSize; -}; - - -PreviewDeviceSkin::PreviewDeviceSkin(const DeviceSkinParameters ¶meters, QWidget *parent) : - DeviceSkin(parameters, parent), - m_screenSize(parameters.screenSize()) -{ - menu = new QMenu(this); - connect(this, SIGNAL(skinKeyPressEvent(int,QString,bool)), - this, SLOT(slotSkinKeyPressEvent(int,QString,bool))); - connect(this, SIGNAL(skinKeyReleaseEvent(int,QString,bool)), - this, SLOT(slotSkinKeyReleaseEvent(int,QString,bool))); - connect(this, SIGNAL(popupMenu()), this, SLOT(slotPopupMenu())); -} - -void PreviewDeviceSkin::setPreview(QWidget *formWidget) -{ - formWidget->setFixedSize(m_screenSize); - formWidget->setParent(this, Qt::SubWindow); - formWidget->setAutoFillBackground(true); - setView(formWidget); -} - -void PreviewDeviceSkin::setPreviewAndScale(QWidget *formWidget) -{ - setScreenSize(formWidget->sizeHint()); - formWidget->setParent(this, Qt::SubWindow); - formWidget->setAutoFillBackground(true); - setView(formWidget); -} - -void PreviewDeviceSkin::slotSkinKeyPressEvent(int code, const QString& text, bool autorep) -{ - if (QWidget *focusWidget = QApplication::focusWidget()) { - QKeyEvent e(QEvent::KeyPress,code,0,text,autorep); - QApplication::sendEvent(focusWidget, &e); - } - -} - -void PreviewDeviceSkin::slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep) -{ - if (QWidget *focusWidget = QApplication::focusWidget()) { - QKeyEvent e(QEvent::KeyRelease,code,0,text,autorep); - QApplication::sendEvent(focusWidget, &e); - } -} - -void PreviewDeviceSkin::slotPopupMenu() -{ - menu->exec(QCursor::pos()); -} - static struct { const char *name, *args; } ffmpegprofiles[] = { {"Maximum Quality", "-sameq"}, {"High Quality", "-qmax 2"}, @@ -463,7 +379,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags) #endif , loggerWindow(new LoggerWidget()) - , frame_stream(0), scaleSkin(true), mb(0) + , frame_stream(0), mb(0) , portraitOrientation(0), landscapeOrientation(0) , showWarningsWindow(0) , m_scriptOptions(0) @@ -475,7 +391,6 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) setWindowTitle(tr("Qt Qml Runtime")); devicemode = false; - skin = 0; canvas = 0; record_autotime = 0; record_rate = 50; @@ -653,51 +568,6 @@ void QDeclarativeViewer::createMenu(QMenuBar *menu, QMenu *flatmenu) if (flatmenu) flatmenu->addSeparator(); - QMenu *skinMenu = flatmenu ? flatmenu->addMenu(tr("&Skin")) : menu->addMenu(tr("&Skin")); - - QActionGroup *skinActions; - QAction *skinAction; - - skinActions = new QActionGroup(parent); - skinAction = new QAction(tr("Scale skin"), parent); - skinAction->setCheckable(true); - skinAction->setChecked(scaleSkin); - skinActions->addAction(skinAction); - skinMenu->addAction(skinAction); - connect(skinAction, SIGNAL(triggered()), this, SLOT(setScaleSkin())); - skinAction = new QAction(tr("Resize view"), parent); - skinAction->setCheckable(true); - skinAction->setChecked(!scaleSkin); - skinActions->addAction(skinAction); - skinMenu->addAction(skinAction); - connect(skinAction, SIGNAL(triggered()), this, SLOT(setScaleView())); - skinMenu->addSeparator(); - - skinActions = new QActionGroup(parent); - QSignalMapper *mapper = new QSignalMapper(parent); - skinAction = new QAction(tr("None"), parent); - skinAction->setCheckable(true); - if (currentSkin.isEmpty()) - skinAction->setChecked(true); - skinActions->addAction(skinAction); - skinMenu->addAction(skinAction); - mapper->setMapping(skinAction, ""); - connect(skinAction, SIGNAL(triggered()), mapper, SLOT(map())); - skinMenu->addSeparator(); - - foreach (QString name, builtinSkins()) { - skinAction = new QAction(name, parent); - skinActions->addAction(skinAction); - skinMenu->addAction(skinAction); - skinAction->setCheckable(true); - if (":skin/"+name+".skin" == currentSkin) - skinAction->setChecked(true); - mapper->setMapping(skinAction, name); - connect(skinAction, SIGNAL(triggered()), mapper, SLOT(map())); - } - connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setSkin(QString))); - - if (flatmenu) flatmenu->addSeparator(); #endif // Q_OS_SYMBIAN QMenu *settingsMenu = flatmenu ? flatmenu : menu->addMenu(tr("S&ettings")); @@ -813,31 +683,6 @@ void QDeclarativeViewer::warningsWidgetClosed() showWarningsWindow->setChecked(false); } -void QDeclarativeViewer::setScaleSkin() -{ - if (scaleSkin) - return; - scaleSkin = true; - if (skin) { - canvas->resize(initialSize); - canvas->setFixedSize(initialSize); - canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); - updateSizeHints(); - } -} - -void QDeclarativeViewer::setScaleView() -{ - if (!scaleSkin) - return; - scaleSkin = false; - if (skin) { - canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); - updateSizeHints(); - } -} - - void QDeclarativeViewer::takeSnapShot() { static int snapshotcount = 1; @@ -1091,83 +936,6 @@ void QDeclarativeViewer::startNetwork() #endif } -QStringList QDeclarativeViewer::builtinSkins() const -{ - QDir dir(":/skins/","*.skin"); - const QFileInfoList l = dir.entryInfoList(); - QStringList r; - for (QFileInfoList::const_iterator it = l.begin(); it != l.end(); ++it) { - r += (*it).baseName(); - } - return r; -} - -void QDeclarativeViewer::setSkin(const QString& skinDirOrName) -{ - QString skinDirectory = skinDirOrName; - - if (!QDir(skinDirOrName).exists() && QDir(":/skins/"+skinDirOrName+".skin").exists()) - skinDirectory = ":/skins/"+skinDirOrName+".skin"; - - if (currentSkin == skinDirectory) - return; - - currentSkin = skinDirectory; - - // XXX QWidget::setMask does not handle changes well, and we may - // XXX have been signalled from an item in a menu we're replacing, - // XXX hence some rather convoluted resetting here... - - QString err; - if (skin) { - skin->hide(); - skin->deleteLater(); - } - - DeviceSkinParameters parameters; - if (!skinDirectory.isEmpty() && parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) { - layout()->setEnabled(false); - if (mb) - mb->hide(); - if (!err.isEmpty()) - qWarning() << err; - skin = new PreviewDeviceSkin(parameters,this); - if (scaleSkin) - skin->setPreviewAndScale(canvas); - else - skin->setPreview(canvas); - createMenu(0,skin->menu); - if (scaleSkin) { - canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); - } - updateSizeHints(); - skin->show(); - } else if (skin) { - skin = 0; - clearMask(); - if ((windowFlags() & Qt::FramelessWindowHint)) { - menuBar()->clear(); - createMenu(menuBar(),0); - } - canvas->setParent(this, Qt::SubWindow); - setParent(0,windowFlags()); // recreate - mb->show(); - canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); - updateSizeHints(); - - layout()->setEnabled(true); - if (!scaleSkin) { - canvas->resize(initialSize); - canvas->setFixedSize(initialSize); - } - QSize newWindowSize = canvas->size(); - newWindowSize.setHeight(newWindowSize.height()+menuBarHeight()); - resize(newWindowSize); - show(); - } - canvas->show(); -} - void QDeclarativeViewer::setAutoRecord(int from, int to) { if (from==0) from=1; // ensure resized @@ -1496,24 +1264,16 @@ void QDeclarativeViewer::updateSizeHints() { if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) { QSize newWindowSize = canvas->sizeHint(); - if (!skin) - newWindowSize.setHeight(newWindowSize.height()+menuBarHeight()); + newWindowSize.setHeight(newWindowSize.height()+menuBarHeight()); if (!isFullScreen() && !isMaximized()) { resize(newWindowSize); setFixedSize(newWindowSize); - if (skin && scaleSkin) { - skin->setScreenSize(newWindowSize); - } } } else { // QDeclarativeView::SizeRootObjectToView canvas->setMinimumSize(QSize(0,0)); canvas->setMaximumSize(QSize(16777215,16777215)); setMinimumSize(QSize(0,0)); setMaximumSize(QSize(16777215,16777215)); - if (skin && !scaleSkin) { - canvas->setFixedSize(skin->standardScreenSize()); - skin->setScreenSize(skin->standardScreenSize()); - } } updateGeometry(); } diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index b021d0d..0416b32 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -105,7 +105,6 @@ public: void setUseNativeFileBrowser(bool); void updateSizeHints(); void setSizeToView(bool sizeToView); - QStringList builtinSkins() const; QMenuBar *menuBar() const; @@ -123,10 +122,8 @@ public slots: void toggleRecording(); void toggleRecordingWithSelection(); void ffmpegFinished(int code); - void setSkin(const QString& skinDirectory); void showProxySettings (); void proxySettingsChanged (); - void setScaleView(); void toggleOrientation(); void statusChanged(); void setSlowMode(bool); @@ -143,7 +140,6 @@ private slots: void recordFrame(); void chooseRecordingOptions(); void pickRecordingFile(); - void setScaleSkin(); void setPortrait(); void setLandscape(); void startNetwork(); @@ -159,8 +155,6 @@ private: int menuBarHeight() const; LoggerWidget *loggerWindow; - PreviewDeviceSkin *skin; - QSize skinscreensize; QDeclarativeView *canvas; QSize initialSize; QString currentFileOrUrl; -- cgit v0.12 From 77e1ef8cb41f790115ff7552717e0ba4d33c3cf0 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 14 May 2010 13:18:33 +0200 Subject: Rename QML Runtime (executable) to QML Launcher The qml executable was first referred to as QML Viewer, then QML Runtime ... however, the latter one caused much confusion (see old version of qmlruntime.qdoc). Doc changes reviewed by Leena Miettinen. --- .gitignore | 1 - doc/src/declarative/qmlruntime.qdoc | 47 +++++++++++----------- doc/src/snippets/declarative/gridview/gridview.qml | 2 +- .../snippets/declarative/listview/highlight.qml | 2 +- doc/src/snippets/declarative/listview/listview.qml | 2 +- examples/declarative/listview/highlight.qml | 2 +- src/declarative/QmlChanges.txt | 5 +++ tools/qdoc3/test/macros.qdocconf | 1 + tools/qml/content/Browser.qml | 6 +-- tools/qml/main.cpp | 14 +++---- tools/qml/qml.pro | 2 +- tools/qml/qmlruntime.cpp | 12 +++--- 12 files changed, 50 insertions(+), 46 deletions(-) diff --git a/.gitignore b/.gitignore index ad8e3ea..5707371 100644 --- a/.gitignore +++ b/.gitignore @@ -52,7 +52,6 @@ bin/Qt*.dll bin/assistant* bin/designer* bin/dumpcpp* -bin/duiviewer* bin/idc* bin/linguist* bin/lrelease* diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc index 10aeac0..b105df4 100644 --- a/doc/src/declarative/qmlruntime.qdoc +++ b/doc/src/declarative/qmlruntime.qdoc @@ -46,15 +46,14 @@ \ingroup qttools 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. + toolkit, and the \QQL which can be used to run apps + written for the runtime. The \QQL reads a declarative + user interface definition (\c .qml) file and displays the user interface it describes. - QML is a runtime, as you can run plain qml files which pull in their required modules. + 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 own 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 + from your own application (using a QDeclarativeView) or with the simple \QQL. + The launcher can be installed in a production environment, assuming that it is not already present in the system. It is generally packaged alongside Qt. To deploy an application using the QML runtime, you have two options: @@ -62,18 +61,18 @@ \list \o 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), or - \o Write a main QML file for your application, and run your application using the included \c qml tool. + \o Write a main QML file for your application, and run your application using the included \QQL. \endlist - To run an application with the \c qml tool, pass the filename as an argument: + To run an application with the \QQL, pass the filename as an argument: \code qml myQmlFile.qml \endcode - Deploying a QML application via the \c qml executable allows for QML only deployments, but can also + Deploying a QML application via the \QQL 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 + a complex application deployed via the QML runtime, it is a listing of the files that would be included in the deployment package. \code @@ -94,7 +93,7 @@ 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 + opening the file if your system has the \QQL 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: \code @@ -102,19 +101,19 @@ 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 + \section1 Qt QML Launcher functionality + The \QQL implements some additional functionality to help it supporting + myriad applications. If you implement your own 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. + QML applications and may not be necessary for a deployed application. \section2 Options - When run with the \c -help option, qml shows available options. + When run with the \c -help option, \c qml shows available options. \section2 Translations - When the runtime loads an initial QML file, it will install a translation file from + When the launcher loads an initial QML file, it will install a translation file from a "i18n" subdirectory relative to that initial QML file. The actual translation file loaded will be according to the system locale and have the form "qml_.qm", where is a two-letter ISO 639 language, @@ -126,12 +125,12 @@ See the \l{scripting.html#internationalization}{Qt Internationalization} documentation for information about how to make the JavaScript in QML files use translatable strings. - Additionally, the QML runtime will load translation files specified on the + Additionally, the launcher will load translation files specified on the command line via the \c -translation option. \section2 Dummy Data - The secondary use of the qml runtime is to allow QML files to be viewed with + The secondary use of the launcher 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 @@ -153,13 +152,13 @@ \section2 Runtime Object - All applications using the qmlruntime will have access to the 'runtime' + All applications using the launcher will have access to the 'runtime' property on the root context. This property contains several pieces of information about the runtime environment of the application. \section3 Screen Orientation - A special piece of dummy data which is integrated into the runtime is + A special piece of dummy data which is integrated into the launcher 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. @@ -173,13 +172,13 @@ } \endcode - This allows your application to respond to the orientation of the screen changing. The runtime + This allows your application to respond to the orientation of the screen changing. The launcher 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. \section3 Window Active - The runtime.isActiveWindow property tells whether the main window of the qml runtime is currently active + The runtime.isActiveWindow property tells whether the main window of the launcher is currently active or not. This is especially useful for embedded devices when you want to pause parts of your application, including animations, when your application loses focus or goes to the background. diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/declarative/gridview/gridview.qml index 1d3df97..cf345aa 100644 --- a/doc/src/snippets/declarative/gridview/gridview.qml +++ b/doc/src/snippets/declarative/gridview/gridview.qml @@ -4,7 +4,7 @@ import Qt 4.7 Rectangle { width: 240; height: 180; color: "white" // ContactModel model is defined in dummydata/ContactModel.qml - // The viewer automatically loads files in dummydata/* to assist + // The launcher automatically loads files in dummydata/* to assist // development without a real data source. // Define a delegate component. A component will be diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml index 794b3f2..1282f8d 100644 --- a/doc/src/snippets/declarative/listview/highlight.qml +++ b/doc/src/snippets/declarative/listview/highlight.qml @@ -4,7 +4,7 @@ Rectangle { width: 180; height: 200; color: "white" // ContactModel model is defined in dummydata/ContactModel.qml - // The viewer automatically loads files in dummydata/* to assist + // The launcher automatically loads files in dummydata/* to assist // development without a real data source. // Define a delegate component. A component will be diff --git a/doc/src/snippets/declarative/listview/listview.qml b/doc/src/snippets/declarative/listview/listview.qml index 61bf126..44f0540 100644 --- a/doc/src/snippets/declarative/listview/listview.qml +++ b/doc/src/snippets/declarative/listview/listview.qml @@ -5,7 +5,7 @@ Rectangle { width: 180; height: 200; color: "white" // ContactModel model is defined in dummydata/ContactModel.qml - // The viewer automatically loads files in dummydata/* to assist + // The launcher automatically loads files in dummydata/* to assist // development without a real data source. // Define a delegate component. A component will be diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml index 50ba2f7..ade355d 100644 --- a/examples/declarative/listview/highlight.qml +++ b/examples/declarative/listview/highlight.qml @@ -4,7 +4,7 @@ Rectangle { width: 400; height: 300 // MyPets model is defined in dummydata/MyPetsModel.qml - // The viewer automatically loads files in dummydata/* to assist + // The launcher automatically loads files in dummydata/* to assist // development without a real data source. // This one contains my pets. diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 604c14c..ec8f508 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -18,6 +18,11 @@ C++ API QDeclarativeExpression::value() has been renamed to QDeclarativeExpression::evaluate() +QML Launcher +------------ +The standalone executable has been renamed to qml launcher. Runtime warnings +can be now accessed via the menu (Debugging->Show Warnings). + ============================================================================= The changes below are pre Qt 4.7.0 beta 1 diff --git a/tools/qdoc3/test/macros.qdocconf b/tools/qdoc3/test/macros.qdocconf index 22db23e..e7a1dbc 100644 --- a/tools/qdoc3/test/macros.qdocconf +++ b/tools/qdoc3/test/macros.qdocconf @@ -18,6 +18,7 @@ macro.ouml.HTML = "ö" macro.QA = "\\e{Qt Assistant}" macro.QD = "\\e{Qt Designer}" macro.QL = "\\e{Qt Linguist}" +macro.QQL = "\\e{Qt QML Launcher}" macro.param = "\\e" macro.raisedaster.HTML = "*" macro.rarrow.HTML = "→" diff --git a/tools/qml/content/Browser.qml b/tools/qml/content/Browser.qml index 0912f58..c3a2cc0 100644 --- a/tools/qml/content/Browser.qml +++ b/tools/qml/content/Browser.qml @@ -12,12 +12,12 @@ Rectangle { FolderListModel { id: folders1 nameFilters: [ "*.qml" ] - folder: qmlViewerFolder + folder: qmlLauncherFolder } FolderListModel { id: folders2 nameFilters: [ "*.qml" ] - folder: qmlViewerFolder + folder: qmlLauncherFolder } SystemPalette { id: palette } @@ -62,7 +62,7 @@ Rectangle { if (folders.isFolder(index)) { down(filePath); } else { - qmlViewer.launch(filePath); + qmlLauncher.launch(filePath); } } width: root.width diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index d1fc118..380f5cc 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -86,7 +86,7 @@ QString warnings; void showWarnings() { if (!warnings.isEmpty()) { - QMessageBox::warning(0, QApplication::tr("Qt Declarative UI Runtime"), warnings); + QMessageBox::warning(0, QApplication::tr("Qt QML Launcher"), warnings); } } @@ -118,7 +118,7 @@ void usage() qWarning(" -frameless ............................... run with no window frame"); qWarning(" -maximized................................ run maximized"); qWarning(" -fullscreen............................... run fullscreen"); - qWarning(" -stayontop................................ keep viewer window on top"); + qWarning(" -stayontop................................ keep launcher window on top"); qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content"); qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view"); qWarning(" -qmlbrowser .............................. use a QML-based file browser"); @@ -157,9 +157,9 @@ void scriptOptsUsage() qWarning(" testerror ................................ test 'error' property of root item on playback"); qWarning(" snapshot ................................. file being recorded is static,"); qWarning(" only one frame will be recorded or tested"); - qWarning(" exitoncomplete ........................... cleanly exit the viewer on script completion"); - qWarning(" exitonfailure ............................ immediately exit the viewer on script failure"); - qWarning(" saveonexit ............................... save recording on viewer exit"); + qWarning(" exitoncomplete ........................... cleanly exit the launcher on script completion"); + qWarning(" exitonfailure ............................ immediately exit the launcher on script failure"); + qWarning(" saveonexit ............................... save recording on launcher exit"); qWarning(" "); qWarning(" One of record, play or both must be specified."); exit(1); @@ -197,7 +197,7 @@ int main(int argc, char ** argv) #endif QApplication app(argc, argv); - app.setApplicationName("QtQmlRuntime"); + app.setApplicationName("QtQmlLauncher"); app.setOrganizationName("Nokia"); app.setOrganizationDomain("nokia.com"); @@ -275,7 +275,7 @@ int main(int argc, char ** argv) if (lastArg) usage(); app.setStartDragDistance(QString(argv[++i]).toInt()); } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) { - qWarning("Qt Qml Runtime version %s", QT_VERSION_STR); + qWarning("Qt QML Launcher version %s", QT_VERSION_STR); exit(0); } else if (arg == "-translation") { if (lastArg) usage(); diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index 77a9533..847ed3a 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -37,5 +37,5 @@ symbian { } mac { QMAKE_INFO_PLIST=Info_mac.plist - TARGET=Qml + TARGET="QML Launcher" } diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 911bf8c..9700090 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -350,7 +350,7 @@ QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) setupProxy(manager); if (cacheSize > 0) { QNetworkDiskCache *cache = new QNetworkDiskCache; - cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-duiviewer-network-cache")); + cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-launcher-network-cache")); cache->setMaximumCacheSize(cacheSize); manager->setCache(cache); } else { @@ -388,7 +388,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) , translator(0) { QDeclarativeViewer::registerTypes(); - setWindowTitle(tr("Qt Qml Runtime")); + setWindowTitle(tr("Qt QML Launcher")); devicemode = false; canvas = 0; @@ -887,7 +887,7 @@ bool QDeclarativeViewer::open(const QString& file_or_url) url = QUrl::fromLocalFile(fi.absoluteFilePath()); else url = QUrl(file_or_url); - setWindowTitle(tr("%1 - Qt Qml Runtime").arg(file_or_url)); + setWindowTitle(tr("%1 - Qt QML Launcher").arg(file_or_url)); if (!m_script.isEmpty()) tester = new QDeclarativeTester(m_script, m_scriptOptions, canvas); @@ -895,11 +895,11 @@ bool QDeclarativeViewer::open(const QString& file_or_url) delete canvas->rootObject(); canvas->engine()->clearComponentCache(); QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("qmlViewer", this); + ctxt->setContextProperty("qmlLauncher", this); #ifdef Q_OS_SYMBIAN - ctxt->setContextProperty("qmlViewerFolder", "E:\\"); // Documents on your S60 phone + ctxt->setContextProperty("qmlLauncherFolder", "E:\\"); // Documents on your S60 phone #else - ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath()); + ctxt->setContextProperty("qmlLauncherFolder", QDir::currentPath()); #endif ctxt->setContextProperty("runtime", Runtime::instance()); -- cgit v0.12 From 1f5ae3138ea4c436fe04d2c882d6debac5b061b8 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 14 May 2010 16:24:27 +0200 Subject: Add new logo for QML Launcher (Mac OS X) --- tools/qml/Info_mac.plist | 2 ++ tools/qml/qml.icns | Bin 0 -> 196156 bytes tools/qml/qml.pro | 1 + 3 files changed, 3 insertions(+) create mode 100644 tools/qml/qml.icns diff --git a/tools/qml/Info_mac.plist b/tools/qml/Info_mac.plist index ce4ebe3..80ca6a3 100644 --- a/tools/qml/Info_mac.plist +++ b/tools/qml/Info_mac.plist @@ -2,6 +2,8 @@ + CFBundleIconFile + @ICON@ CFBundleIdentifier com.nokia.qt.qml CFBundlePackageType diff --git a/tools/qml/qml.icns b/tools/qml/qml.icns new file mode 100644 index 0000000..c760516 Binary files /dev/null and b/tools/qml/qml.icns differ diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index 847ed3a..6129639 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -38,4 +38,5 @@ symbian { mac { QMAKE_INFO_PLIST=Info_mac.plist TARGET="QML Launcher" + ICON=qml.icns } -- cgit v0.12 From be41deb3868de28187aba5743f71a71f8498e4c7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 14 May 2010 16:58:19 +0200 Subject: fix regexp --- mkspecs/features/qt_functions.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 23e2616..a49c1a6 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -86,6 +86,6 @@ defineTest(qtPrepareTool) { else:$$1 = $$[QT_INSTALL_BINS]/$$2 } $$1 ~= s,[/\\\\],$$QMAKE_DIR_SEP, - contains(QMAKE_HOST.os, Windows):!contains($$1, \.exe$):$$1 = $$eval($$1).exe + contains(QMAKE_HOST.os, Windows):!contains($$1, .*\\.exe$):$$1 = $$eval($$1).exe export($$1) } -- cgit v0.12 From f00a96efb66303a453f984e60a41120200b2c0c3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 11 May 2010 14:57:02 +0200 Subject: QtDeclarative doesn't use QtXml, so don't link to it or require others to --- src/declarative/declarative.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index 4287e25..8037a16 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -1,13 +1,13 @@ TARGET = QtDeclarative QPRO_PWD = $$PWD -QT = core gui xml script network +QT = core gui script network contains(QT_CONFIG, svg): QT += svg contains(QT_CONFIG, opengl): QT += opengl DEFINES += QT_BUILD_DECLARATIVE_LIB QT_NO_URL_CAST_FROM_STRING win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000 solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2 -unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtXml +unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui exists("qdeclarative_enable_gcov") { QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors -- cgit v0.12 From 25484ef9b55f0a017163a05228bb9b6b0e7a772d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 14 May 2010 18:04:39 +0200 Subject: More 4.7 stuff. --- dist/changes-4.7.0 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0 index 47992f9..1e3a69c 100644 --- a/dist/changes-4.7.0 +++ b/dist/changes-4.7.0 @@ -67,6 +67,9 @@ QtGui functions, and replaced them with setCopyCount(), copyCount() and supportsMultipleCopies(). + - QPrintDialog/QPrinter + * Added support for printing the current page. + - QCommonStyle * Fixed a bug that led to missing text pixels in QTabBar when using small font sizes. (QTBUG-7137) -- cgit v0.12 From 8fe40ca28e88d156b9a0ef9cc4c818a666499231 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 14 May 2010 16:59:11 +0100 Subject: Fix generation of stub sis files Convert paths in DEPLOYMENT to the rom drive (z:) Filter out unwanted parts of the header (dependencies) Task-number: QTBUG-10118 Reviewed-by: Alessandro Portale --- bin/createpackage.pl | 2 +- mkspecs/features/sis_targets.prf | 2 +- qmake/generators/symbian/symbiancommon.cpp | 83 +++++++++++++++++++++++++----- 3 files changed, 71 insertions(+), 16 deletions(-) diff --git a/bin/createpackage.pl b/bin/createpackage.pl index 7453ba5..0cc1a9c 100755 --- a/bin/createpackage.pl +++ b/bin/createpackage.pl @@ -181,7 +181,7 @@ if ($signed_sis_name eq "") { } my $unsigned_sis_name = $sisoutputbasename."_unsigned.sis"; -my $stub_sis_name = $sisoutputbasename."_stub.sis"; +my $stub_sis_name = $sisoutputbasename.".sis"; # Store some utility variables my $scriptpath = dirname(__FILE__); diff --git a/mkspecs/features/sis_targets.prf b/mkspecs/features/sis_targets.prf index 7d70fc6..da2d250 100644 --- a/mkspecs/features/sis_targets.prf +++ b/mkspecs/features/sis_targets.prf @@ -59,7 +59,7 @@ contains(TEMPLATE, app)|!count(DEPLOYMENT, 1) { ) ok_stub_sis_target.target = ok_stub_sis - ok_stub_sis_target.commands = createpackage.bat -s $(QT_SIS_OPTIONS) $$basename(TARGET)_template.pkg \ + ok_stub_sis_target.commands = createpackage.bat -s $(QT_SIS_OPTIONS) $$basename(TARGET)_stub.pkg \ $(QT_SIS_TARGET) $(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE) QMAKE_EXTRA_TARGETS += sis_target \ diff --git a/qmake/generators/symbian/symbiancommon.cpp b/qmake/generators/symbian/symbiancommon.cpp index adbd009..ce796c3 100644 --- a/qmake/generators/symbian/symbiancommon.cpp +++ b/qmake/generators/symbian/symbiancommon.cpp @@ -142,6 +142,13 @@ void SymbianCommonGenerator::removeEpocSpecialCharacters(QString& str) removeSpecialCharacters(str); } +QString romPath(const QString& path) +{ + if(path.length() > 2 && path[1] == ':') + return QLatin1String("z:") + path.mid(2); + return QLatin1String("z:") + path; +} + void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocBuild) { QMakeProject *project = generator->project; @@ -150,8 +157,8 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB pkgTarget = project->first("TARGET"); pkgTarget = generator->unescapeFilePath(pkgTarget); pkgTarget = removePathSeparators(pkgTarget); - QString pkgFilename = Option::output_dir + QLatin1Char('/') + QString("%1_template.%2") - .arg(pkgTarget).arg("pkg"); + QString pkgFilename = Option::output_dir + QLatin1Char('/') + + QString("%1_template.pkg").arg(pkgTarget); QFile pkgFile(pkgFilename); if (!pkgFile.open(QIODevice::WriteOnly | QIODevice::Text)) { @@ -159,8 +166,19 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB return; } + QString stubPkgFileName = Option::output_dir + QLatin1Char('/') + + QString("%1_stub.pkg").arg(pkgTarget); + + QFile stubPkgFile(stubPkgFileName); + if (!stubPkgFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + PRINT_FILE_CREATE_ERROR(stubPkgFileName); + return; + } + generatedFiles << pkgFile.fileName(); QTextStream t(&pkgFile); + generatedFiles << stubPkgFile.fileName(); + QTextStream ts(&stubPkgFile); QString installerSisHeader = project->values("DEPLOYMENT.installer_header").join("\n"); if (installerSisHeader.isEmpty()) @@ -180,6 +198,7 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB ";\n\n"; t << headerComment.arg(pkgFilename).arg(dateStr); tw << headerComment.arg(wrapperPkgFilename).arg(dateStr); + ts << headerComment.arg(stubPkgFileName).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 @@ -229,6 +248,7 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB t << languageRules.join("\n") << endl; tw << languageRules.join("\n") << endl; + ts << languageRules.join("\n") << endl; // name of application, UID and version QString applicationVersion = project->first("VERSION").isEmpty() ? "1,0,0" : project->first("VERSION").replace('.', ','); @@ -244,10 +264,14 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB tw << installerSisHeader << endl; } - if (headerRules.isEmpty()) + if (headerRules.isEmpty()) { t << sisHeader.arg(visualTarget).arg(uid3).arg(applicationVersion); - else + ts << sisHeader.arg(visualTarget).arg(uid3).arg(applicationVersion); + } + else { t << headerRules.join("\n") << endl; + ts << headerRules.join("\n") << endl; + } // Localized vendor name QString vendorName; @@ -262,22 +286,38 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB t << vendorName; tw << vendorName; + ts << vendorName; // PKG pre-rules - these are added before actual file installations i.e. SIS package body if (rawPkgPreRules.size()) { QString comment = "\n; Manual PKG pre-rules from PRO files\n"; t << comment; tw << comment; + ts << comment; foreach(QString item, rawPkgPreRules) { - // Only regular pkg file should have package dependencies or pkg header if that is - // defined using prerules. - if (!item.startsWith("(") && !item.startsWith("#")) { + // Only regular pkg file should have package dependencies + if (item.startsWith("(")) { + t << item << endl; + } + // stub pkg file should not have platform dependencies + else if (item.startsWith("[")) { + t << item << endl; + tw << item << endl; + } + // Only regular and stub should have pkg header if that is defined using prerules. + else if (!item.startsWith("#")) { + t << item << endl; + ts << item << endl; + } + else { + t << item << endl; + ts << item << endl; tw << item << endl; } - t << item << endl; } t << endl; + ts << endl; tw << endl; } @@ -319,41 +359,54 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB // deploy .exe file t << "; Executable and default resource files" << endl; QString exeFile = fixedTarget + ".exe"; - t << QString("\"%1/%2\" - \"%3\\%4\"") + t << QString("\"%1/%2\" - \"%3\\%4\"") .arg(destDirBin) .arg(exeFile) .arg(installPathBin) .arg(exeFile) << endl; + ts << QString("\"\" - \"%1\\%2\"") + .arg(romPath(installPathBin)) + .arg(exeFile) << endl; // deploy rsc & reg_rsc file if (!project->isActiveConfig("no_icon")) { - t << QString("\"%1/%2\" - \"%3\\%4\"") + t << QString("\"%1/%2\" - \"%3\\%4\"") .arg(destDirResource) .arg(fixedTarget + ".rsc") .arg(installPathResource) .arg(fixedTarget + ".rsc") << endl; + ts << QString("\"\" - \"%1\\%2\"") + .arg(romPath(installPathResource)) + .arg(fixedTarget + ".rsc") << endl; - t << QString("\"%1/%2\" - \"%3\\%4\"") + t << QString("\"%1/%2\" - \"%3\\%4\"") .arg(destDirRegResource) .arg(fixedTarget + "_reg.rsc") .arg(installPathRegResource) .arg(fixedTarget + "_reg.rsc") << endl; + ts << QString("\"\" - \"%1\\%2\"") + .arg(romPath(installPathRegResource)) + .arg(fixedTarget + "_reg.rsc") << endl; if (!iconFile.isEmpty()) { if (epocBuild) { - t << QString("\"%1epoc32/data/z%2\" - \"!:%3\"") + t << QString("\"%1epoc32/data/z%2\" - \"!:%3\"") .arg(epocRoot()) .arg(iconFile) .arg(QDir::toNativeSeparators(iconFile)) << endl << endl; + ts << QString("\"\" - \"%1\"") + .arg(romPath(QDir::toNativeSeparators(iconFile))) << endl << endl; } else { QDir mifIconDir(project->first("DESTDIR")); QFileInfo mifIcon(mifIconDir.relativeFilePath(project->first("TARGET"))); QString mifIconFileName = mifIcon.fileName(); mifIconFileName.append(".mif"); - t << QString("\"%1/%2\" - \"!:%3\"") + t << QString("\"%1/%2\" - \"!:%3\"") .arg(mifIcon.path()) .arg(mifIconFileName) .arg(QDir::toNativeSeparators(iconFile)) << endl << endl; + ts << QString("\"\" - \"%1\"") + .arg(romPath(QDir::toNativeSeparators(iconFile))) << endl << endl; } } } @@ -389,9 +442,11 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB } } - t << QString("\"%1\" - \"%2\"").arg(from.replace('\\','/')).arg(to) << endl; + t << QString("\"%1\" - \"%2\"").arg(from.replace('\\','/')).arg(to) << endl; + ts << QString("\"\" - \"%1\"").arg(romPath(to)) << endl; } t << endl; + ts << endl; // PKG post-rules - these are added after actual file installations i.e. SIS package body t << "; Manual PKG post-rules from PRO files" << endl; -- cgit v0.12 From 3849cd0cca618fac88a54861a3ec30780711ce75 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 14 May 2010 18:34:03 +0200 Subject: Update the dependencies in src.pro because we don't have a good buildsystem QtXml is not required by QtSvg, QtWebKit or QtDeclarative. And QtDeclarative doesn't link to QtWebKit anymore (imports do). But it does link to QtOpenGL. --- src/src.pro | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/src.pro b/src/src.pro index 9c4831c..3ceeb9c 100644 --- a/src/src.pro +++ b/src/src.pro @@ -94,7 +94,7 @@ src_declarative.target = sub-declarative src_xml.depends = src_corelib src_xmlpatterns.depends = src_corelib src_network src_dbus.depends = src_corelib src_xml - src_svg.depends = src_xml src_gui + src_svg.depends = src_corelib src_gui src_script.depends = src_corelib src_scripttools.depends = src_script src_gui src_network src_network.depends = src_corelib @@ -110,15 +110,14 @@ src_declarative.target = sub-declarative contains(QT_CONFIG, opengl):src_multimedia.depends += src_opengl src_mediaservices.depends = src_multimedia src_tools_activeqt.depends = src_tools_idc src_gui - src_declarative.depends = src_xml src_gui src_script src_network src_svg + src_declarative.depends = src_gui src_script src_network src_plugins.depends = src_gui src_sql src_svg src_multimedia src_s60installs.depends = $$TOOLS_SUBDIRS $$SRC_SUBDIRS src_imports.depends = src_gui src_declarative contains(QT_CONFIG, webkit) { - src_webkit.depends = src_gui src_sql src_network src_xml + src_webkit.depends = src_gui src_sql src_network contains(QT_CONFIG, mediaservices):src_webkit.depends += src_mediaservices contains(QT_CONFIG, xmlpatterns): src_webkit.depends += src_xmlpatterns - contains(QT_CONFIG, declarative):src_declarative.depends += src_webkit src_imports.depends += src_webkit exists($$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro): src_webkit.depends += src_javascriptcore } @@ -127,7 +126,18 @@ src_declarative.target = sub-declarative src_plugins.depends += src_dbus src_phonon.depends += src_dbus } - contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2): src_plugins.depends += src_opengl + contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2) { + src_plugins.depends += src_opengl + src_declarative.depends += src_opengl + src_webkit.depends += src_opengl + } + contains(QT_CONFIG, xmlpatterns) { + src_declarative.depends += src_xmlpatterns + src_webkit.depends += src_xmlpatterns + } + contains(QT_CONFIG, svg) { + src_declarative.depends += src_svg + } } -- cgit v0.12 From c8d2e18c4b431870560f324a17f20904bb47ae68 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 14 May 2010 18:43:20 +0200 Subject: More improvements to pixmap cache key generation HexString is actually more optimal than fromRawData since we dont need any allocations while using it. Arguably the code is also a bit nicer. Task-number: QTBUG-9850 Reviewed-by: ogoffart --- src/gui/image/qicon.cpp | 26 ++++++++++---------------- src/gui/styles/qgtkpainter.cpp | 19 ++++++------------- src/gui/styles/qstylehelper.cpp | 30 +++++++++--------------------- src/gui/styles/qstylehelper_p.h | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 50 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 9f1eea2..7696632 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -55,6 +55,7 @@ #include "qcache.h" #include "qdebug.h" #include "private/qguiplatformplugin_p.h" +#include "private/qstylehelper_p.h" #ifdef Q_WS_MAC #include @@ -261,24 +262,17 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height())) actualSize.scale(size, Qt::KeepAspectRatio); - int digits = sizeof(qint64)/sizeof(QChar); - quint64 tkey = pm.cacheKey(), - tmode = pe->mode, - tpalkey = QApplication::palette().cacheKey(), - twidth = actualSize.width(), - theight = actualSize.height(); - QString key = QLatin1Literal("qt_") - % QString::fromRawData((QChar*)&tkey, digits) - % QString::fromRawData((QChar*)&tmode, digits) - % QString::fromRawData((QChar*)&tpalkey, digits) - % QString::fromRawData((QChar*)&twidth, digits) - % QString::fromRawData((QChar*)&theight, digits); + % HexString(pm.cacheKey()) + % HexString(pe->mode) + % HexString(QApplication::palette().cacheKey()) + % HexString(actualSize.width()) + % HexString(actualSize.height()); if (mode == QIcon::Active) { - if (QPixmapCache::find(key + QString::number(mode), pm)) + if (QPixmapCache::find(key % HexString(mode), pm)) return pm; // horray - if (QPixmapCache::find(key + QString::number(QIcon::Normal), pm)) { + if (QPixmapCache::find(key % HexString(QIcon::Normal), pm)) { QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt); @@ -287,7 +281,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St } } - if (!QPixmapCache::find(key + QString::number(mode), pm)) { + if (!QPixmapCache::find(key % HexString(mode), pm)) { if (pm.size() != actualSize) pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (pe->mode != mode && mode != QIcon::Normal) { @@ -297,7 +291,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!generated.isNull()) pm = generated; } - QPixmapCache::insert(key + QString::number(mode), pm); + QPixmapCache::insert(key % HexString(mode), pm); } return pm; } diff --git a/src/gui/styles/qgtkpainter.cpp b/src/gui/styles/qgtkpainter.cpp index a6686e2..79c53e9 100644 --- a/src/gui/styles/qgtkpainter.cpp +++ b/src/gui/styles/qgtkpainter.cpp @@ -47,6 +47,7 @@ // This class is primarily a wrapper around the gtk painter functions // and takes care of converting all such calls into cached Qt pixmaps. +#include #include #include #include @@ -154,21 +155,13 @@ QGtkPainter::QGtkPainter(QPainter *_painter) static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget = 0) { - - int digits = sizeof(qint64)/sizeof(QChar); - quint64 tstate= state, - tshadow = shadow, - twidth = size.width(), - theight = size.height(), - twidget = quint64(widget); - // Note the widget arg should ideally use the widget path, though would compromise performance QString tmp = key - % QString::fromRawData((QChar*)&tstate, digits) - % QString::fromRawData((QChar*)&tshadow, digits) - % QString::fromRawData((QChar*)&twidth, digits) - % QString::fromRawData((QChar*)&theight, digits) - % QString::fromRawData((QChar*)&twidget, digits); + % HexString(state) + % HexString(shadow) + % HexString(size.width()) + % HexString(size.height()) + % HexString(quint64(widget)); return tmp; } diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp index 22f2014..d09d7fa 100644 --- a/src/gui/styles/qstylehelper.cpp +++ b/src/gui/styles/qstylehelper.cpp @@ -63,30 +63,18 @@ namespace QStyleHelper { QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) { const QStyleOptionComplex *complexOption = qstyleoption_cast(option); - int digits = sizeof(qint64)/sizeof(QChar); - quint64 state = option->state, - direction = option->direction, - subcontrols = (complexOption ? uint(complexOption->activeSubControls) : 0u), - palettekey = option->palette.cacheKey(), - width = size.width(), - height = size.height(); - - QString tmp = key % QString::fromRawData((QChar*)&state, digits) - % QString::fromRawData((QChar*)&direction, digits) - % QString::fromRawData((QChar*)&subcontrols, digits) - % QString::fromRawData((QChar*)&palettekey, digits) - % QString::fromRawData((QChar*)&width, digits) - % QString::fromRawData((QChar*)&height, digits); + QString tmp = key % HexString(option->state) + % HexString(option->direction) + % HexString(complexOption ? uint(complexOption->activeSubControls) : 0u) + % HexString(option->palette.cacheKey()) + % HexString(size.width()) + % HexString(size.height()); #ifndef QT_NO_SPINBOX if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { - quint64 buttonsymbols = spinBox->buttonSymbols, - stepEnabled = spinBox->stepEnabled, - frame = spinBox->frame; - - tmp = tmp % QString::fromRawData((QChar*)&buttonsymbols, digits) - % QString::fromRawData((QChar*)&stepEnabled, digits) - % QString::fromRawData((QChar*)&frame, digits); + tmp = tmp % HexString(spinBox->buttonSymbols) + % HexString(spinBox->stepEnabled) + % QLatin1Char(spinBox->frame ? '1' : '0'); ; } #endif // QT_NO_SPINBOX return tmp; diff --git a/src/gui/styles/qstylehelper_p.h b/src/gui/styles/qstylehelper_p.h index 31cc4ed..555ad60 100644 --- a/src/gui/styles/qstylehelper_p.h +++ b/src/gui/styles/qstylehelper_p.h @@ -41,6 +41,7 @@ #include #include +#include #include #ifndef QSTYLEHELPER_P_H @@ -79,6 +80,37 @@ namespace QStyleHelper int bottom = 0); } +// internal helper. Converts an integer value to an unique string token +template + struct HexString +{ + inline HexString(const T t) + : val(t) + {} + + inline void write(QChar *&dest) const + { + const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + const char *c = reinterpret_cast(&val); + for (uint i = 0; i < sizeof(T); ++i) { + *dest++ = hexChars[*c & 0xf]; + *dest++ = hexChars[(*c & 0xf0) >> 4]; + ++c; + } + } + const T val; +}; + +// specialization to enable fast concatenating of our string tokens to a string +template + struct QConcatenable > +{ + typedef HexString type; + enum { ExactSize = true }; + static int size(const HexString &str) { return sizeof(str.val) * 2; } + static inline void appendTo(const HexString &str, QChar *&out) { str.write(out); } +}; + QT_END_NAMESPACE #endif // QSTYLEHELPER_P_H -- cgit v0.12 From 77ddabd7fdf0c8ba2e15951e83abbcce18270285 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 14 May 2010 20:06:15 +0200 Subject: Revert "Optimize QPixmapIconEngine's pixmap() function" This reverts commit ad6dafee9be288bcef6b2c4b318b234d2995abff. This is replaced by commit c8d2e18c4b431870560f324a17f20904bb47ae68 --- src/gui/image/qicon.cpp | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 5ef0ff9..891b1db 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -261,28 +261,21 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height())) actualSize.scale(size, Qt::KeepAspectRatio); - struct { - quint64 pmc; - qint32 w; - qint32 h; - quint64 pac; - qint32 m; // Make struct size a multiple of 4, for safety's sake - } dill; - - dill.pmc = pm.cacheKey(); - dill.w = actualSize.width(); - dill.h = actualSize.height(); - dill.pac = QApplication::palette().cacheKey(); - dill.m = pe->mode; - - QString keyBase = QLatin1String("$qt_icon_") - + QString::fromRawData((QChar *)&dill, sizeof(dill)/sizeof(QChar)); - QString key = keyBase + QString::number(mode, 16); + QString key = QLatin1String("$qt_icon_") + + QString::number(pm.cacheKey()) + + QString::number(pe->mode) + + QString::number(QApplication::palette().cacheKey()) + + QLatin1Char('_') + + QString::number(actualSize.width()) + + QLatin1Char('_') + + QString::number(actualSize.height()) + + QLatin1Char('_'); + if (mode == QIcon::Active) { - if (QPixmapCache::find(key, pm)) + if (QPixmapCache::find(key + QString::number(mode), pm)) return pm; // horray - if (QPixmapCache::find(keyBase + QString::number(QIcon::Normal, 16), pm)) { + if (QPixmapCache::find(key + QString::number(QIcon::Normal), pm)) { QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt); @@ -291,7 +284,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St } } - if (!QPixmapCache::find(key, pm)) { + if (!QPixmapCache::find(key + QString::number(mode), pm)) { if (pm.size() != actualSize) pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (pe->mode != mode && mode != QIcon::Normal) { @@ -301,7 +294,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!generated.isNull()) pm = generated; } - QPixmapCache::insert(key, pm); + QPixmapCache::insert(key + QString::number(mode), pm); } return pm; } -- cgit v0.12 From b0f4dab4c825650c3a7a72b87508bf6f3e5ffd50 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 14 May 2010 23:47:37 +0200 Subject: Revert "More improvements to pixmap cache key generation" This reverts commit c8d2e18c4b431870560f324a17f20904bb47ae68. --- src/gui/image/qicon.cpp | 26 ++++++++++++++++---------- src/gui/styles/qgtkpainter.cpp | 19 +++++++++++++------ src/gui/styles/qstylehelper.cpp | 30 +++++++++++++++++++++--------- src/gui/styles/qstylehelper_p.h | 32 -------------------------------- 4 files changed, 50 insertions(+), 57 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 7696632..9f1eea2 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -55,7 +55,6 @@ #include "qcache.h" #include "qdebug.h" #include "private/qguiplatformplugin_p.h" -#include "private/qstylehelper_p.h" #ifdef Q_WS_MAC #include @@ -262,17 +261,24 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height())) actualSize.scale(size, Qt::KeepAspectRatio); + int digits = sizeof(qint64)/sizeof(QChar); + quint64 tkey = pm.cacheKey(), + tmode = pe->mode, + tpalkey = QApplication::palette().cacheKey(), + twidth = actualSize.width(), + theight = actualSize.height(); + QString key = QLatin1Literal("qt_") - % HexString(pm.cacheKey()) - % HexString(pe->mode) - % HexString(QApplication::palette().cacheKey()) - % HexString(actualSize.width()) - % HexString(actualSize.height()); + % QString::fromRawData((QChar*)&tkey, digits) + % QString::fromRawData((QChar*)&tmode, digits) + % QString::fromRawData((QChar*)&tpalkey, digits) + % QString::fromRawData((QChar*)&twidth, digits) + % QString::fromRawData((QChar*)&theight, digits); if (mode == QIcon::Active) { - if (QPixmapCache::find(key % HexString(mode), pm)) + if (QPixmapCache::find(key + QString::number(mode), pm)) return pm; // horray - if (QPixmapCache::find(key % HexString(QIcon::Normal), pm)) { + if (QPixmapCache::find(key + QString::number(QIcon::Normal), pm)) { QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt); @@ -281,7 +287,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St } } - if (!QPixmapCache::find(key % HexString(mode), pm)) { + if (!QPixmapCache::find(key + QString::number(mode), pm)) { if (pm.size() != actualSize) pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (pe->mode != mode && mode != QIcon::Normal) { @@ -291,7 +297,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!generated.isNull()) pm = generated; } - QPixmapCache::insert(key % HexString(mode), pm); + QPixmapCache::insert(key + QString::number(mode), pm); } return pm; } diff --git a/src/gui/styles/qgtkpainter.cpp b/src/gui/styles/qgtkpainter.cpp index 79c53e9..a6686e2 100644 --- a/src/gui/styles/qgtkpainter.cpp +++ b/src/gui/styles/qgtkpainter.cpp @@ -47,7 +47,6 @@ // This class is primarily a wrapper around the gtk painter functions // and takes care of converting all such calls into cached Qt pixmaps. -#include #include #include #include @@ -155,13 +154,21 @@ QGtkPainter::QGtkPainter(QPainter *_painter) static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget = 0) { + + int digits = sizeof(qint64)/sizeof(QChar); + quint64 tstate= state, + tshadow = shadow, + twidth = size.width(), + theight = size.height(), + twidget = quint64(widget); + // Note the widget arg should ideally use the widget path, though would compromise performance QString tmp = key - % HexString(state) - % HexString(shadow) - % HexString(size.width()) - % HexString(size.height()) - % HexString(quint64(widget)); + % QString::fromRawData((QChar*)&tstate, digits) + % QString::fromRawData((QChar*)&tshadow, digits) + % QString::fromRawData((QChar*)&twidth, digits) + % QString::fromRawData((QChar*)&theight, digits) + % QString::fromRawData((QChar*)&twidget, digits); return tmp; } diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp index d09d7fa..22f2014 100644 --- a/src/gui/styles/qstylehelper.cpp +++ b/src/gui/styles/qstylehelper.cpp @@ -63,18 +63,30 @@ namespace QStyleHelper { QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) { const QStyleOptionComplex *complexOption = qstyleoption_cast(option); - QString tmp = key % HexString(option->state) - % HexString(option->direction) - % HexString(complexOption ? uint(complexOption->activeSubControls) : 0u) - % HexString(option->palette.cacheKey()) - % HexString(size.width()) - % HexString(size.height()); + int digits = sizeof(qint64)/sizeof(QChar); + quint64 state = option->state, + direction = option->direction, + subcontrols = (complexOption ? uint(complexOption->activeSubControls) : 0u), + palettekey = option->palette.cacheKey(), + width = size.width(), + height = size.height(); + + QString tmp = key % QString::fromRawData((QChar*)&state, digits) + % QString::fromRawData((QChar*)&direction, digits) + % QString::fromRawData((QChar*)&subcontrols, digits) + % QString::fromRawData((QChar*)&palettekey, digits) + % QString::fromRawData((QChar*)&width, digits) + % QString::fromRawData((QChar*)&height, digits); #ifndef QT_NO_SPINBOX if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { - tmp = tmp % HexString(spinBox->buttonSymbols) - % HexString(spinBox->stepEnabled) - % QLatin1Char(spinBox->frame ? '1' : '0'); ; + quint64 buttonsymbols = spinBox->buttonSymbols, + stepEnabled = spinBox->stepEnabled, + frame = spinBox->frame; + + tmp = tmp % QString::fromRawData((QChar*)&buttonsymbols, digits) + % QString::fromRawData((QChar*)&stepEnabled, digits) + % QString::fromRawData((QChar*)&frame, digits); } #endif // QT_NO_SPINBOX return tmp; diff --git a/src/gui/styles/qstylehelper_p.h b/src/gui/styles/qstylehelper_p.h index 555ad60..31cc4ed 100644 --- a/src/gui/styles/qstylehelper_p.h +++ b/src/gui/styles/qstylehelper_p.h @@ -41,7 +41,6 @@ #include #include -#include #include #ifndef QSTYLEHELPER_P_H @@ -80,37 +79,6 @@ namespace QStyleHelper int bottom = 0); } -// internal helper. Converts an integer value to an unique string token -template - struct HexString -{ - inline HexString(const T t) - : val(t) - {} - - inline void write(QChar *&dest) const - { - const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - const char *c = reinterpret_cast(&val); - for (uint i = 0; i < sizeof(T); ++i) { - *dest++ = hexChars[*c & 0xf]; - *dest++ = hexChars[(*c & 0xf0) >> 4]; - ++c; - } - } - const T val; -}; - -// specialization to enable fast concatenating of our string tokens to a string -template - struct QConcatenable > -{ - typedef HexString type; - enum { ExactSize = true }; - static int size(const HexString &str) { return sizeof(str.val) * 2; } - static inline void appendTo(const HexString &str, QChar *&out) { str.write(out); } -}; - QT_END_NAMESPACE #endif // QSTYLEHELPER_P_H -- cgit v0.12 From b1749e9052c68dff6089bf5f0d2a41cd88dfcb50 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 15 May 2010 11:39:26 +0200 Subject: Revert "Optimized pixmapcache key generation for icons and styles" This reverts commit b8f1d7fd87985375a373ca85052c475241822b03. --- src/gui/image/qicon.cpp | 23 ++++++------- src/gui/styles/qgtkpainter.cpp | 16 ++------- src/gui/styles/qstylehelper.cpp | 74 +++++++++++++++++++++++++++++------------ 3 files changed, 65 insertions(+), 48 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 9f1eea2..891b1db 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -261,19 +261,16 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height())) actualSize.scale(size, Qt::KeepAspectRatio); - int digits = sizeof(qint64)/sizeof(QChar); - quint64 tkey = pm.cacheKey(), - tmode = pe->mode, - tpalkey = QApplication::palette().cacheKey(), - twidth = actualSize.width(), - theight = actualSize.height(); - - QString key = QLatin1Literal("qt_") - % QString::fromRawData((QChar*)&tkey, digits) - % QString::fromRawData((QChar*)&tmode, digits) - % QString::fromRawData((QChar*)&tpalkey, digits) - % QString::fromRawData((QChar*)&twidth, digits) - % QString::fromRawData((QChar*)&theight, digits); + QString key = QLatin1String("$qt_icon_") + + QString::number(pm.cacheKey()) + + QString::number(pe->mode) + + QString::number(QApplication::palette().cacheKey()) + + QLatin1Char('_') + + QString::number(actualSize.width()) + + QLatin1Char('_') + + QString::number(actualSize.height()) + + QLatin1Char('_'); + if (mode == QIcon::Active) { if (QPixmapCache::find(key + QString::number(mode), pm)) diff --git a/src/gui/styles/qgtkpainter.cpp b/src/gui/styles/qgtkpainter.cpp index a6686e2..1f68f2f 100644 --- a/src/gui/styles/qgtkpainter.cpp +++ b/src/gui/styles/qgtkpainter.cpp @@ -154,21 +154,9 @@ QGtkPainter::QGtkPainter(QPainter *_painter) static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget = 0) { - - int digits = sizeof(qint64)/sizeof(QChar); - quint64 tstate= state, - tshadow = shadow, - twidth = size.width(), - theight = size.height(), - twidget = quint64(widget); - // Note the widget arg should ideally use the widget path, though would compromise performance - QString tmp = key - % QString::fromRawData((QChar*)&tstate, digits) - % QString::fromRawData((QChar*)&tshadow, digits) - % QString::fromRawData((QChar*)&twidth, digits) - % QString::fromRawData((QChar*)&theight, digits) - % QString::fromRawData((QChar*)&twidget, digits); + QString tmp = QString(QLS("%0-%1-%2-%3x%4-%5")).arg(key).arg(uint(state)).arg(shadow) + .arg(size.width()).arg(size.height()).arg(quintptr(widget)); return tmp; } diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp index 22f2014..296c51c 100644 --- a/src/gui/styles/qstylehelper.cpp +++ b/src/gui/styles/qstylehelper.cpp @@ -58,35 +58,67 @@ QT_BEGIN_NAMESPACE +// internal helper. Converts an integer value to an unique string token +template +struct HexString +{ + inline HexString(const T t) + : val(t) + {} + + inline void write(QChar *&dest) const + { + const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + const char *c = reinterpret_cast(&val); + for (uint i = 0; i < sizeof(T); ++i) { + *dest++ = hexChars[*c & 0xf]; + *dest++ = hexChars[(*c & 0xf0) >> 4]; + ++c; + } + } + + const T val; +}; + +// specialization to enable fast concatenating of our string tokens to a string +template +struct QConcatenable > +{ + typedef HexString type; + enum { ExactSize = true }; + static int size(const HexString &str) { return sizeof(str.val) * 2; } + static inline void appendTo(const HexString &str, QChar *&out) { str.write(out); } +}; + namespace QStyleHelper { QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) { const QStyleOptionComplex *complexOption = qstyleoption_cast(option); - int digits = sizeof(qint64)/sizeof(QChar); - quint64 state = option->state, - direction = option->direction, - subcontrols = (complexOption ? uint(complexOption->activeSubControls) : 0u), - palettekey = option->palette.cacheKey(), - width = size.width(), - height = size.height(); - - QString tmp = key % QString::fromRawData((QChar*)&state, digits) - % QString::fromRawData((QChar*)&direction, digits) - % QString::fromRawData((QChar*)&subcontrols, digits) - % QString::fromRawData((QChar*)&palettekey, digits) - % QString::fromRawData((QChar*)&width, digits) - % QString::fromRawData((QChar*)&height, digits); + + QString tmp = key + % QLatin1Char('-') + % HexString(option->state) + % QLatin1Char('-') + % HexString(option->direction) + % QLatin1Char('-') + % HexString(complexOption ? uint(complexOption->activeSubControls) : 0u) + % QLatin1Char('-') + % HexString(option->palette.cacheKey()) + % QLatin1Char('-') + % HexString(size.width()) + % QLatin1Char('x') + % HexString(size.height()); #ifndef QT_NO_SPINBOX if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { - quint64 buttonsymbols = spinBox->buttonSymbols, - stepEnabled = spinBox->stepEnabled, - frame = spinBox->frame; - - tmp = tmp % QString::fromRawData((QChar*)&buttonsymbols, digits) - % QString::fromRawData((QChar*)&stepEnabled, digits) - % QString::fromRawData((QChar*)&frame, digits); + tmp = tmp + % QLatin1Char('-') + % HexString(spinBox->buttonSymbols) + % QLatin1Char('-') + % HexString(spinBox->stepEnabled) + % QLatin1Char('-') + % QLatin1Char(spinBox->frame ? '1' : '0'); } #endif // QT_NO_SPINBOX return tmp; -- cgit v0.12 From fea180d80112faa1a314e240ab07c37e4c2e0d1d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 May 2010 17:04:31 +0200 Subject: Autotest: some improvements to timeout testing of tst_QTcpSocket --- tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index cd512a1..d195d3c 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -144,6 +144,7 @@ private slots: void blockingIMAP(); void nonBlockingIMAP(); void hostNotFound(); + void timeoutConnect_data(); void timeoutConnect(); void delayedClose(); void partialRead(); @@ -544,19 +545,36 @@ void tst_QTcpSocket::hostNotFound() } //---------------------------------------------------------------------------------- +void tst_QTcpSocket::timeoutConnect_data() +{ + QTest::addColumn("address"); + QTest::newRow("host") << QtNetworkSettings::serverName(); + QTest::newRow("ip") << QtNetworkSettings::serverIP(); +} void tst_QTcpSocket::timeoutConnect() { + QFETCH(QString, address); QTcpSocket *socket = newSocket(); - // Outgoing port 53 is firewalled in the Oslo office. - socket->connectToHost("cisco.com", 53); + QElapsedTimer timer; + timer.start(); + + // Port 1357 is configured to drop packets on the test server + socket->connectToHost(address, 1357); + QVERIFY(timer.elapsed() < 50); QVERIFY(!socket->waitForConnected(200)); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); QCOMPARE(int(socket->error()), int(QTcpSocket::SocketTimeoutError)); - socket->connectToHost("cisco.com", 53); - QTest::qSleep(50); + timer.start(); + socket->connectToHost(address, 1357); + QVERIFY(timer.elapsed() < 50); + QTimer::singleShot(50, &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(socket->state() == QTcpSocket::ConnectingState + || socket->state() == QTcpSocket::HostLookupState); socket->abort(); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); QCOMPARE(socket->openMode(), QIODevice::NotOpen); -- cgit v0.12 From f8788e4202e51fb36b3dcb4a80c83e16ff389150 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 15 May 2010 18:36:56 +0200 Subject: Fix building of tst_QTcpSocket --- tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index d195d3c..31cae40 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -549,7 +549,7 @@ void tst_QTcpSocket::timeoutConnect_data() { QTest::addColumn("address"); QTest::newRow("host") << QtNetworkSettings::serverName(); - QTest::newRow("ip") << QtNetworkSettings::serverIP(); + QTest::newRow("ip") << QtNetworkSettings::serverIP().toString(); } void tst_QTcpSocket::timeoutConnect() @@ -571,7 +571,7 @@ void tst_QTcpSocket::timeoutConnect() socket->connectToHost(address, 1357); QVERIFY(timer.elapsed() < 50); QTimer::singleShot(50, &QTestEventLoop::instance(), SLOT(exitLoop())); - QTestEventLoop::enterLoop(5); + QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(socket->state() == QTcpSocket::ConnectingState || socket->state() == QTcpSocket::HostLookupState); -- cgit v0.12 From 082a1594910d294c638c571fc79f3318891387eb Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sat, 15 May 2010 22:02:30 +0200 Subject: Updated WebKit to 3d774b9df1f963452b1cfe34f9fafad0d399372a Integrated changes: || || [Qt] Rename QtLauncher to QtTestBrowser || || || [Qt] animations/dynamic-stylesheet-loading.html fails with accelerated compositing || || || VS2010 asserts a null iterator passed to std::copy in Vector::operator= || || || [Qt] use QT_MOBILE_THEME in Symbian || || || CSSParser::parseColor() shouldn't alter 'color' unless passed a valid color string. || || || JavaScript unable to invoke methods declared in QML || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/ChangeLog | 9 +++++ src/3rdparty/webkit/JavaScriptCore/ChangeLog | 12 +++++++ src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h | 12 +++++++ src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 40 ++++++++++++++++++++++ src/3rdparty/webkit/WebCore/WebCore.pro | 2 +- .../webkit/WebCore/bridge/qt/qt_instance.cpp | 2 +- .../webkit/WebCore/bridge/qt/qt_runtime.cpp | 2 +- src/3rdparty/webkit/WebCore/css/CSSParser.cpp | 1 - .../webkit/WebCore/editing/ApplyStyleCommand.cpp | 2 +- .../html/canvas/CanvasRenderingContext2D.cpp | 2 -- src/3rdparty/webkit/WebKit.pro | 2 +- 13 files changed, 80 insertions(+), 10 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 9d754a4..2fc5867 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -3d774b9df1f963452b1cfe34f9fafad0d399372a +4696beb87359fe9236d23e0791526eb38dab341d diff --git a/src/3rdparty/webkit/ChangeLog b/src/3rdparty/webkit/ChangeLog index a0cf2d0..8f9c7ac 100644 --- a/src/3rdparty/webkit/ChangeLog +++ b/src/3rdparty/webkit/ChangeLog @@ -1,3 +1,12 @@ +2010-05-14 Simon Hausmann + + Rubber-stamped by Antti Koivisto. + + [Qt] Rename QtLauncher to QtTestBrowser + https://bugs.webkit.org/show_bug.cgi?id=37665 + + * WebKit.pro: + 2010-05-12 Laszlo Gombos Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index a3e6586..af5ef5c 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,15 @@ +2010-05-10 Jocelyn Turcotte + + Reviewed by Alexey Proskuryakov. + + Fix a VS2010 assert in std::copy + https://bugs.webkit.org/show_bug.cgi?id=38630 + + The assert complains that the output iterator is null. + + * wtf/Vector.h: + (WTF::::operator): + 2010-05-12 Laszlo Gombos Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h index e495067..4d9ea61 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h @@ -686,6 +686,12 @@ namespace WTF { return *this; } +// Works around an assert in VS2010. See https://connect.microsoft.com/VisualStudio/feedback/details/558044/std-copy-should-not-check-dest-when-first-last +#if COMPILER(MSVC) && defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL + if (!begin()) + return *this; +#endif + std::copy(other.begin(), other.begin() + size(), begin()); TypeOperations::uninitializedCopy(other.begin() + size(), other.end(), end()); m_size = other.size(); @@ -709,6 +715,12 @@ namespace WTF { return *this; } +// Works around an assert in VS2010. See https://connect.microsoft.com/VisualStudio/feedback/details/558044/std-copy-should-not-check-dest-when-first-last +#if COMPILER(MSVC) && defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL + if (!begin()) + return *this; +#endif + std::copy(other.begin(), other.begin() + size(), begin()); TypeOperations::uninitializedCopy(other.begin() + size(), other.end(), end()); m_size = other.size(); diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index a440c03..5cda8f8 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 5cf023650a8da206a8cf3130e9d4820b95e1bc7c + 3d774b9df1f963452b1cfe34f9fafad0d399372a diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 93d00e4..a8c4c76 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,43 @@ +2010-05-06 Luiz Agostini + + Rubber-stamped by Simon Hausmann. + + [Qt] use QT_MOBILE_THEME in Symbian + https://bugs.webkit.org/show_bug.cgi?id=38440 + + Putting QT_MOBILE_THEME into use for Symbian. + + * WebCore.pro: + +2010-05-14 Andreas Kling + + Reviewed by Darin Adler. + + CSSParser::parseColor() shouldn't alter 'color' unless passed a valid color string. + https://bugs.webkit.org/show_bug.cgi?id=39031 + + * css/CSSParser.cpp: + (WebCore::CSSParser::parseColor): + * editing/ApplyStyleCommand.cpp: + (WebCore::StyleChange::extractTextStyles): Don't depend on old behavior. + * html/canvas/CanvasRenderingContext2D.cpp: + (WebCore::CanvasRenderingContext2D::setShadow): Remove dead code. + +2010-05-14 Aaron Kennedy + + Reviewed by Simon Hausmann. + + [Qt] JavaScript unable to invoke methods declared in QML + https://bugs.webkit.org/show_bug.cgi?id=38949 + + JavaScript code executed by webkit cannot call into QML declared + methods, as it does not check for dynamic meta objects. + + * bridge/qt/qt_instance.cpp: + (JSC::Bindings::QtInstance::stringValue): Use QMetaObject::metacall. + * bridge/qt/qt_runtime.cpp: + (JSC::Bindings::QtRuntimeMetaMethod::call): Ditto. + 2010-05-12 Laszlo Gombos Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 689c5ff..5def728 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -125,7 +125,7 @@ maemo5|symbian|embedded { DEFINES += ENABLE_FAST_MOBILE_SCROLLING=1 } -maemo5 { +maemo5|symbian { DEFINES += WTF_USE_QT_MOBILE_THEME=1 } diff --git a/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp b/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp index f6f368b..d40ab0b 100644 --- a/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp +++ b/src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp @@ -287,7 +287,7 @@ JSValue QtInstance::stringValue(ExecState* exec) const void * qargs[1]; qargs[0] = ret.data(); - if (obj->qt_metacall(QMetaObject::InvokeMetaMethod, index, qargs) < 0) { + if (QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, index, qargs) < 0) { if (ret.isValid() && ret.canConvert(QVariant::String)) { buf = ret.toString().toLatin1().constData(); // ### Latin 1? Ascii? useDefault = false; diff --git a/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp b/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp index 1775815..4524d97 100644 --- a/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp +++ b/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp @@ -1397,7 +1397,7 @@ JSValue QtRuntimeMetaMethod::call(ExecState* exec, JSObject* functionObject, JSV int methodIndex; JSObject* errorObj = 0; if ((methodIndex = findMethodIndex(exec, obj->metaObject(), d->m_signature, d->m_allowPrivate, args, vargs, (void **)qargs, &errorObj)) != -1) { - if (obj->qt_metacall(QMetaObject::InvokeMetaMethod, methodIndex, qargs) >= 0) + if (QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, methodIndex, qargs) >= 0) return jsUndefined(); if (vargs[0].isValid()) diff --git a/src/3rdparty/webkit/WebCore/css/CSSParser.cpp b/src/3rdparty/webkit/WebCore/css/CSSParser.cpp index 214fc51..a5a8b5c 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSParser.cpp +++ b/src/3rdparty/webkit/WebCore/css/CSSParser.cpp @@ -279,7 +279,6 @@ bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int id, cons // possible to set up a default color. bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) { - color = 0; CSSParser parser(true); // First try creating a color specified by name or the "#" syntax. diff --git a/src/3rdparty/webkit/WebCore/editing/ApplyStyleCommand.cpp b/src/3rdparty/webkit/WebCore/editing/ApplyStyleCommand.cpp index 1c739ec..529d9d3 100644 --- a/src/3rdparty/webkit/WebCore/editing/ApplyStyleCommand.cpp +++ b/src/3rdparty/webkit/WebCore/editing/ApplyStyleCommand.cpp @@ -212,7 +212,7 @@ void StyleChange::extractTextStyles(CSSMutableStyleDeclaration* style) if (RefPtr colorValue = style->getPropertyCSSValue(CSSPropertyColor)) { ASSERT(colorValue->isPrimitiveValue()); CSSPrimitiveValue* primitiveColor = static_cast(colorValue.get()); - RGBA32 rgba; + RGBA32 rgba = 0; if (primitiveColor->primitiveType() != CSSPrimitiveValue::CSS_RGBCOLOR) { CSSParser::parseColor(rgba, colorValue->cssText()); // Need to take care of named color such as green and black diff --git a/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp index 823ab59..398e4d8 100644 --- a/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp +++ b/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp @@ -873,8 +873,6 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur, return; RGBA32 rgba = makeRGBA32FromFloats(r, g, b, a); // default is transparent black - if (!state().m_shadowColor.isEmpty()) - CSSParser::parseColor(rgba, state().m_shadowColor); c->setShadow(IntSize(width, -height), state().m_shadowBlur, Color(rgba), DeviceColorSpace); } diff --git a/src/3rdparty/webkit/WebKit.pro b/src/3rdparty/webkit/WebKit.pro index 6d466e2..84fcb56 100644 --- a/src/3rdparty/webkit/WebKit.pro +++ b/src/3rdparty/webkit/WebKit.pro @@ -8,7 +8,7 @@ SUBDIRS += \ WebCore # If the source exists, built it -exists($$PWD/WebKitTools/QtLauncher): SUBDIRS += WebKitTools/QtLauncher +exists($$PWD/WebKitTools/QtTestBrowser): SUBDIRS += WebKitTools/QtTestBrowser exists($$PWD/JavaScriptCore/jsc.pro): SUBDIRS += JavaScriptCore/jsc.pro exists($$PWD/WebKit/qt/tests): SUBDIRS += WebKit/qt/tests exists($$PWD/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro): SUBDIRS += WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro -- cgit v0.12 From 2e3d004ba736f5c77614feeaf3594217217bd29e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 15 May 2010 23:53:16 +0200 Subject: tst_bic: Fix building on Mac 64 --- tests/auto/bic/tst_bic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index 010965c..400fcc1 100644 --- a/tests/auto/bic/tst_bic.cpp +++ b/tests/auto/bic/tst_bic.cpp @@ -191,7 +191,7 @@ void tst_Bic::sizesAndVTables_data() #elif defined Q_OS_MAC && defined(__i386__) # define FILESUFFIX "macx-gcc-ia32" #elif defined Q_OS_MAC && defined(__amd64__) -# define FILESUFFIX "macx-gcc-amd64"; +# define FILESUFFIX "macx-gcc-amd64" #elif defined Q_OS_WIN && defined Q_CC_GNU # define FILESUFFIX "win32-gcc-ia32" #else -- cgit v0.12 From e9a59ff4f650d878fd79fed1f605f3f4e9120d35 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 14 May 2010 19:04:40 +0200 Subject: Use case-insensitive comparison for the "data" scheme in URLs --- src/gui/text/qtextdocument.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index afba678..c7a9756 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1947,7 +1947,7 @@ QVariant QTextDocument::loadResource(int type, const QUrl &name) #endif // handle data: URLs - if (r.isNull() && name.scheme() == QLatin1String("data")) + if (r.isNull() && name.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) r = qDecodeDataUrl(name).second; // if resource was not loaded try to load it here -- cgit v0.12 From 8cdeb07b385f9c479cf28df0f43d5fab84d22819 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sun, 16 May 2010 10:25:37 +0200 Subject: Updated WebKit to 4696beb87359fe9236d23e0791526eb38dab341d Integrated changes: || || [Qt] GraphicsLayer caches directly composited images || || || [Qt] JSValue QtClass::fallbackObject can be optimized || || || [Qt] Target(WebCore,jsc,...) must depends on static library of JavaScriptCore || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/JavaScriptCore/ChangeLog | 16 ++++++++++++ .../webkit/JavaScriptCore/JavaScriptCore.pri | 6 ++++- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 29 ++++++++++++++++++++++ src/3rdparty/webkit/WebCore/bridge/qt/qt_class.cpp | 8 +++--- .../platform/graphics/qt/GraphicsLayerQt.cpp | 6 +++-- 7 files changed, 61 insertions(+), 8 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 2fc5867..b1b56f6 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -4696beb87359fe9236d23e0791526eb38dab341d +cacbdf18fc917122834042d77a9164a490aafde4 diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index af5ef5c..016e0dd 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,19 @@ +2010-04-20 Csaba Osztrogonác + + [Qt] Unreviewed speculative buildfix for WinCE after r57882 + https://bugs.webkit.org/show_bug.cgi?id=37701 + + * JavaScriptCore.pri: missing wince* case added. + +2010-04-20 Csaba Osztrogonác + + Reviewed by Simon Hausmann. + + [Qt] Target(WebCore,jsc,...) must depends on static library of JavaScriptCore + https://bugs.webkit.org/show_bug.cgi?id=37701 + + * JavaScriptCore.pri: dependency added. + 2010-05-10 Jocelyn Turcotte Reviewed by Alexey Proskuryakov. diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri index b3f74a9..cc4a1b3 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri @@ -75,19 +75,22 @@ defineTest(addJavaScriptCoreLib) { # Argument is the relative path to JavaScriptCore.pro's qmake output pathToJavaScriptCoreOutput = $$ARGS/$$JAVASCRIPTCORE_DESTDIR - win32-msvc* { + win32-msvc*|wince* { LIBS += -L$$pathToJavaScriptCoreOutput LIBS += -l$$JAVASCRIPTCORE_TARGET + POST_TARGETDEPS += $${pathToJavaScriptCoreOutput}$${QMAKE_DIR_SEP}$${JAVASCRIPTCORE_TARGET}.lib } else:symbian { LIBS += -l$${JAVASCRIPTCORE_TARGET}.lib # The default symbian build system does not use library paths at all. However when building with # qmake's symbian makespec that uses Makefiles QMAKE_LIBDIR += $$pathToJavaScriptCoreOutput + POST_TARGETDEPS += $${pathToJavaScriptCoreOutput}$${QMAKE_DIR_SEP}$${JAVASCRIPTCORE_TARGET}.lib } else { # Make sure jscore will be early in the list of libraries to workaround a bug in MinGW # that can't resolve symbols from QtCore if libjscore comes after. QMAKE_LIBDIR = $$pathToJavaScriptCoreOutput $$QMAKE_LIBDIR LIBS += -l$$JAVASCRIPTCORE_TARGET + POST_TARGETDEPS += $${pathToJavaScriptCoreOutput}$${QMAKE_DIR_SEP}lib$${JAVASCRIPTCORE_TARGET}.a } win32-* { @@ -101,6 +104,7 @@ defineTest(addJavaScriptCoreLib) { export(QMAKE_LIBDIR) export(LIBS) + export(POST_TARGETDEPS) export(CONFIG) return(true) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 5cda8f8..629883a 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 3d774b9df1f963452b1cfe34f9fafad0d399372a + 4696beb87359fe9236d23e0791526eb38dab341d diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index a8c4c76..ac5c388 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,32 @@ +2010-05-14 Noam Rosenthal + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] GraphicsLayer caches directly composited images + https://bugs.webkit.org/show_bug.cgi?id=38444 + + Directly-composited images and solid fills shouldn't be cached, as that cache + is never used (see GraphicsLayerQtImpl::paint). Cache is only relevant for HTML content, + but we were missing that test. + The fix makes sure we only cache HTML content. + + No new tests: this is a minor optimization. + + * platform/graphics/qt/GraphicsLayerQt.cpp: + (WebCore::GraphicsLayerQtImpl::flushChanges): + +2010-05-15 Anders Bakken + + Reviewed by Kenneth Rohde Christiansen. + + Don't unnecessarily copy data when searching for methods in QtClass. + + [Qt] JSValue QtClass::fallbackObject can be optimized + https://bugs.webkit.org/show_bug.cgi?id=37684 + + * bridge/qt/qt_class.cpp: + (JSC::Bindings::QtClass::fallbackObject): + 2010-05-06 Luiz Agostini Rubber-stamped by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/bridge/qt/qt_class.cpp b/src/3rdparty/webkit/WebCore/bridge/qt/qt_class.cpp index cfd74d9..5bbc99f 100644 --- a/src/3rdparty/webkit/WebCore/bridge/qt/qt_class.cpp +++ b/src/3rdparty/webkit/WebCore/bridge/qt/qt_class.cpp @@ -98,10 +98,12 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, const Identifie if (m.access() == QMetaMethod::Private) continue; - QByteArray signature = m.signature(); - signature.truncate(signature.indexOf('(')); + int index = 0; + const char* signature = m.signature(); + while (signature[index] && signature[index] != '(') + ++index; - if (normal == signature) { + if (normal == QByteArray::fromRawData(signature, index)) { QtRuntimeMetaMethod* val = new (exec) QtRuntimeMetaMethod(exec, identifier, static_cast(inst), index, normal, false); qtinst->m_methods.insert(name, val); return val; diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp index d9394e1..969e00a 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp @@ -599,8 +599,10 @@ void GraphicsLayerQtImpl::flushChanges(bool recursive, bool forceUpdateTransform if (m_maskEffect) m_maskEffect.data()->update(); else if (m_changeMask & DisplayChange) { - // Recache now: all the content is ready and we don't want to wait until the paint event. - recache(m_pendingContent.regionToUpdate); + // Recache now: all the content is ready and we don't want to wait until the paint event. We only need to do this for HTML content, + // there's no point in caching directly composited content like images or solid rectangles. + if (m_pendingContent.contentType == HTMLContentType) + recache(m_pendingContent.regionToUpdate); update(m_pendingContent.regionToUpdate.boundingRect()); m_pendingContent.regionToUpdate = QRegion(); } -- cgit v0.12 -- cgit v0.12 From 792a06a6c1475a96bc756b72a8d85212742afa72 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 14 May 2010 09:54:52 +1000 Subject: Doc fix --- src/declarative/graphicsitems/qdeclarativeimage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 88e8520..fe642e0 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE An Image element displays a specified \l source image: \table + \row \o \image declarative-qtlogo.png \o -- cgit v0.12 From 0aca20bf669ef7e7702ee96d0d0676392cfd1b72 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 14 May 2010 11:26:54 +1000 Subject: graphicsWidgets doc example was previously removed --- tests/auto/declarative/examples/tst_examples.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 3759cb5..1044035 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -80,7 +80,6 @@ tst_examples::tst_examples() // Add directories you want excluded here - excludedDirs << "doc/src/snippets/declarative/graphicswidgets"; #ifdef QT_NO_WEBKIT excludedDirs << "examples/declarative/webview"; -- cgit v0.12 From 82d0b03c4f81c2832975d548917c03dbaddeee72 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 14 May 2010 11:32:57 +1000 Subject: Restructure the examples. They are now organized into various subdirectories to make it easier to locate examples for certain features (e.g. animation) and to distinguish between different types of examples (e.g. very basic examples vs complex demo-like examples). --- doc/src/declarative/example-slideswitch.qdoc | 20 +- doc/src/declarative/examples.qdoc | 123 ++- doc/src/declarative/extending-examples.qdoc | 50 +- doc/src/declarative/extending.qdoc | 46 +- doc/src/declarative/globalobject.qdoc | 2 +- doc/src/declarative/integrating.qdoc | 2 +- doc/src/examples/qml-examples.qdoc | 184 +++-- doc/src/snippets/declarative/border-image.qml | 29 - doc/src/snippets/declarative/borderimage.qml | 29 + .../declarative/animation/animation.qmlproject | 16 + .../declarative/animation/basics/basics.qmlproject | 16 + .../animation/basics/color-animation.qml | 70 ++ .../animation/basics/images/face-smile.png | Bin 0 -> 15408 bytes .../declarative/animation/basics/images/moon.png | Bin 0 -> 2433 bytes .../declarative/animation/basics/images/shadow.png | Bin 0 -> 425 bytes .../declarative/animation/basics/images/star.png | Bin 0 -> 349 bytes .../declarative/animation/basics/images/sun.png | Bin 0 -> 8153 bytes .../animation/basics/property-animation.qml | 63 ++ .../declarative/animation/behaviors/SideRect.qml | 22 + .../animation/behaviors/behavior-example.qml | 79 ++ .../animation/behaviors/behaviors.qmlproject | 16 + examples/declarative/animation/easing/easing.qml | 105 +++ .../declarative/animation/easing/easing.qmlproject | 16 + examples/declarative/animation/states/states.qml | 61 ++ .../declarative/animation/states/states.qmlproject | 16 + .../declarative/animation/states/transitions.qml | 90 +++ examples/declarative/animation/states/user.png | Bin 0 -> 4886 bytes .../declarative/animations/animations.qmlproject | 16 - .../declarative/animations/color-animation.qml | 70 -- examples/declarative/animations/easing.qml | 105 --- .../declarative/animations/images/face-smile.png | Bin 15408 -> 0 bytes examples/declarative/animations/images/moon.png | Bin 2433 -> 0 bytes examples/declarative/animations/images/shadow.png | Bin 425 -> 0 bytes examples/declarative/animations/images/star.png | Bin 349 -> 0 bytes examples/declarative/animations/images/sun.png | Bin 8153 -> 0 bytes .../declarative/animations/property-animation.qml | 63 -- .../declarative/aspectratio/aspectratio.qmlproject | 16 - examples/declarative/aspectratio/face_fit.qml | 26 - .../declarative/aspectratio/face_fit_animated.qml | 28 - examples/declarative/aspectratio/pics/face.png | Bin 15408 -> 0 bytes .../declarative/aspectratio/scale_and_crop.qml | 21 - .../aspectratio/scale_and_crop_simple.qml | 20 - .../declarative/aspectratio/scale_and_sidecrop.qml | 22 - examples/declarative/aspectratio/scale_to_fit.qml | 22 - .../aspectratio/scale_to_fit_simple.qml | 20 - examples/declarative/behaviors/SideRect.qml | 22 - .../declarative/behaviors/behavior-example.qml | 79 -- .../declarative/behaviors/behaviors.qmlproject | 16 - examples/declarative/border-image/border-image.qml | 57 -- .../border-image/border-image.qmlproject | 16 - .../border-image/content/MyBorderImage.qml | 50 -- .../border-image/content/ShadowRectangle.qml | 14 - examples/declarative/border-image/content/bw.png | Bin 1357 -> 0 bytes .../border-image/content/colors-round.sci | 7 - .../border-image/content/colors-stretch.sci | 5 - .../declarative/border-image/content/colors.png | Bin 1655 -> 0 bytes .../declarative/border-image/content/shadow.png | Bin 588 -> 0 bytes examples/declarative/border-image/shadows.qml | 24 - examples/declarative/clocks/clocks.qml | 14 - examples/declarative/clocks/clocks.qmlproject | 16 - examples/declarative/clocks/content/Clock.qml | 83 -- examples/declarative/clocks/content/background.png | Bin 46895 -> 0 bytes examples/declarative/clocks/content/center.png | Bin 765 -> 0 bytes .../declarative/clocks/content/clock-night.png | Bin 23359 -> 0 bytes examples/declarative/clocks/content/clock.png | Bin 20653 -> 0 bytes examples/declarative/clocks/content/hour.png | Bin 625 -> 0 bytes examples/declarative/clocks/content/minute.png | Bin 625 -> 0 bytes examples/declarative/clocks/content/second.png | Bin 303 -> 0 bytes .../connections/connections-example.qml | 37 - .../declarative/connections/connections.qmlproject | 16 - .../declarative/connections/content/Button.qml | 12 - examples/declarative/connections/content/bg1.jpg | Bin 23771 -> 0 bytes .../connections/content/rotate-left.png | Bin 3061 -> 0 bytes .../connections/content/rotate-right.png | Bin 3115 -> 0 bytes .../declarative/cppextensions/cppextensions.pro | 10 + .../cppextensions/cppextensions.qmlproject | 16 + .../imageprovider/ImageProviderCore/qmldir | 2 + .../imageprovider/imageprovider-example.qml | 25 + .../cppextensions/imageprovider/imageprovider.cpp | 118 +++ .../cppextensions/imageprovider/imageprovider.pro | 25 + .../imageprovider/imageprovider.qmlproject | 16 + examples/declarative/cppextensions/plugins/README | 9 + .../plugins/com/nokia/TimeExample/Clock.qml | 50 ++ .../plugins/com/nokia/TimeExample/center.png | Bin 0 -> 765 bytes .../plugins/com/nokia/TimeExample/clock.png | Bin 0 -> 20653 bytes .../plugins/com/nokia/TimeExample/hour.png | Bin 0 -> 625 bytes .../plugins/com/nokia/TimeExample/minute.png | Bin 0 -> 625 bytes .../plugins/com/nokia/TimeExample/qmldir | 2 + .../declarative/cppextensions/plugins/plugin.cpp | 152 ++++ .../declarative/cppextensions/plugins/plugins.pro | 31 + .../declarative/cppextensions/plugins/plugins.qml | 11 + .../cppextensions/plugins/plugins.qmlproject | 16 + .../declarative/cppextensions/proxyviewer/main.cpp | 109 +++ .../cppextensions/proxyviewer/proxyviewer.pro | 9 + .../cppextensions/proxyviewer/proxyviewer.qrc | 5 + .../declarative/cppextensions/proxyviewer/view.qml | 7 + .../cppextensions/proxywidgets/ProxyWidgets/qmldir | 1 + .../declarative/cppextensions/proxywidgets/README | 4 + .../cppextensions/proxywidgets/proxywidgets.cpp | 97 +++ .../cppextensions/proxywidgets/proxywidgets.pro | 21 + .../cppextensions/proxywidgets/proxywidgets.qml | 70 ++ .../proxywidgets/proxywidgets.qmlproject | 16 + .../graphicsLayouts/graphicslayouts.cpp | 366 +++++++++ .../graphicsLayouts/graphicslayouts.pro | 13 + .../graphicsLayouts/graphicslayouts.qml | 77 ++ .../graphicsLayouts/graphicslayouts.qrc | 5 + .../graphicsLayouts/graphicslayouts_p.h | 303 +++++++ .../qgraphicslayouts/graphicsLayouts/main.cpp | 60 ++ .../qgraphicslayouts/layoutItem/layoutItem.pro | 13 + .../qgraphicslayouts/layoutItem/layoutItem.qml | 15 + .../qgraphicslayouts/layoutItem/layoutItem.qrc | 5 + .../qgraphicslayouts/layoutItem/main.cpp | 73 ++ .../qgraphicslayouts/qgraphicslayouts.qmlproject | 16 + .../referenceexamples/adding/adding.pro | 15 + .../referenceexamples/adding/adding.qrc | 5 + .../referenceexamples/adding/example.qml | 8 + .../referenceexamples/adding/main.cpp | 65 ++ .../referenceexamples/adding/person.cpp | 69 ++ .../referenceexamples/adding/person.h | 66 ++ .../referenceexamples/attached/attached.pro | 17 + .../referenceexamples/attached/attached.qrc | 5 + .../referenceexamples/attached/birthdayparty.cpp | 92 +++ .../referenceexamples/attached/birthdayparty.h | 87 +++ .../referenceexamples/attached/example.qml | 31 + .../referenceexamples/attached/main.cpp | 91 +++ .../referenceexamples/attached/person.cpp | 119 +++ .../referenceexamples/attached/person.h | 106 +++ .../referenceexamples/binding/binding.pro | 19 + .../referenceexamples/binding/binding.qrc | 5 + .../referenceexamples/binding/birthdayparty.cpp | 114 +++ .../referenceexamples/binding/birthdayparty.h | 103 +++ .../referenceexamples/binding/example.qml | 37 + .../binding/happybirthdaysong.cpp | 86 ++ .../referenceexamples/binding/happybirthdaysong.h | 75 ++ .../referenceexamples/binding/main.cpp | 93 +++ .../referenceexamples/binding/person.cpp | 139 ++++ .../referenceexamples/binding/person.h | 114 +++ .../referenceexamples/coercion/birthdayparty.cpp | 72 ++ .../referenceexamples/coercion/birthdayparty.h | 70 ++ .../referenceexamples/coercion/coercion.pro | 17 + .../referenceexamples/coercion/coercion.qrc | 5 + .../referenceexamples/coercion/example.qml | 15 + .../referenceexamples/coercion/main.cpp | 78 ++ .../referenceexamples/coercion/person.cpp | 80 ++ .../referenceexamples/coercion/person.h | 83 ++ .../referenceexamples/default/birthdayparty.cpp | 72 ++ .../referenceexamples/default/birthdayparty.h | 71 ++ .../referenceexamples/default/default.pro | 17 + .../referenceexamples/default/default.qrc | 5 + .../referenceexamples/default/example.qml | 14 + .../referenceexamples/default/main.cpp | 76 ++ .../referenceexamples/default/person.cpp | 79 ++ .../referenceexamples/default/person.h | 78 ++ .../referenceexamples/extended/example.qml | 7 + .../referenceexamples/extended/extended.pro | 15 + .../referenceexamples/extended/extended.qrc | 5 + .../referenceexamples/extended/lineedit.cpp | 105 +++ .../referenceexamples/extended/lineedit.h | 74 ++ .../referenceexamples/extended/main.cpp | 65 ++ .../referenceexamples/grouped/birthdayparty.cpp | 72 ++ .../referenceexamples/grouped/birthdayparty.h | 70 ++ .../referenceexamples/grouped/example.qml | 33 + .../referenceexamples/grouped/grouped.pro | 17 + .../referenceexamples/grouped/grouped.qrc | 5 + .../referenceexamples/grouped/main.cpp | 86 ++ .../referenceexamples/grouped/person.cpp | 119 +++ .../referenceexamples/grouped/person.h | 108 +++ .../referenceexamples/properties/birthdayparty.cpp | 74 ++ .../referenceexamples/properties/birthdayparty.h | 76 ++ .../referenceexamples/properties/example.qml | 15 + .../referenceexamples/properties/main.cpp | 69 ++ .../referenceexamples/properties/person.cpp | 67 ++ .../referenceexamples/properties/person.h | 64 ++ .../referenceexamples/properties/properties.pro | 18 + .../referenceexamples/properties/properties.qrc | 5 + .../referenceexamples/referenceexamples.pro | 13 + .../referenceexamples/referenceexamples.qmlproject | 16 + .../referenceexamples/signal/birthdayparty.cpp | 99 +++ .../referenceexamples/signal/birthdayparty.h | 93 +++ .../referenceexamples/signal/example.qml | 32 + .../referenceexamples/signal/main.cpp | 92 +++ .../referenceexamples/signal/person.cpp | 119 +++ .../referenceexamples/signal/person.h | 106 +++ .../referenceexamples/signal/signal.pro | 17 + .../referenceexamples/signal/signal.qrc | 5 + .../valuesource/birthdayparty.cpp | 109 +++ .../referenceexamples/valuesource/birthdayparty.h | 98 +++ .../referenceexamples/valuesource/example.qml | 36 + .../valuesource/happybirthdaysong.cpp | 81 ++ .../valuesource/happybirthdaysong.h | 80 ++ .../referenceexamples/valuesource/main.cpp | 94 +++ .../referenceexamples/valuesource/person.cpp | 119 +++ .../referenceexamples/valuesource/person.h | 106 +++ .../referenceexamples/valuesource/valuesource.pro | 19 + .../referenceexamples/valuesource/valuesource.qrc | 5 + examples/declarative/declarative.pro | 59 +- examples/declarative/dial/content/Dial.qml | 37 - examples/declarative/dial/content/background.png | Bin 35876 -> 0 bytes examples/declarative/dial/content/needle.png | Bin 342 -> 0 bytes .../declarative/dial/content/needle_shadow.png | Bin 632 -> 0 bytes examples/declarative/dial/content/overlay.png | Bin 3564 -> 0 bytes examples/declarative/dial/dial-example.qml | 44 -- examples/declarative/dial/dial.qmlproject | 16 - examples/declarative/dynamic/dynamic.qml | 176 ----- examples/declarative/dynamic/dynamic.qmlproject | 16 - examples/declarative/dynamic/images/NOTE | 1 - examples/declarative/dynamic/images/face-smile.png | Bin 15408 -> 0 bytes examples/declarative/dynamic/images/moon.png | Bin 1757 -> 0 bytes .../declarative/dynamic/images/rabbit_brown.png | Bin 1245 -> 0 bytes examples/declarative/dynamic/images/rabbit_bw.png | Bin 1759 -> 0 bytes examples/declarative/dynamic/images/star.png | Bin 349 -> 0 bytes examples/declarative/dynamic/images/sun.png | Bin 8153 -> 0 bytes examples/declarative/dynamic/images/tree_s.png | Bin 3406 -> 0 bytes examples/declarative/dynamic/qml/Button.qml | 40 - examples/declarative/dynamic/qml/PaletteItem.qml | 19 - .../declarative/dynamic/qml/PerspectiveItem.qml | 25 - examples/declarative/dynamic/qml/Sun.qml | 38 - examples/declarative/dynamic/qml/itemCreation.js | 65 -- examples/declarative/extending/adding/adding.pro | 15 - examples/declarative/extending/adding/adding.qrc | 5 - examples/declarative/extending/adding/example.qml | 8 - examples/declarative/extending/adding/main.cpp | 65 -- examples/declarative/extending/adding/person.cpp | 69 -- examples/declarative/extending/adding/person.h | 66 -- .../declarative/extending/attached/attached.pro | 17 - .../declarative/extending/attached/attached.qrc | 5 - .../extending/attached/birthdayparty.cpp | 92 --- .../declarative/extending/attached/birthdayparty.h | 87 --- .../declarative/extending/attached/example.qml | 31 - examples/declarative/extending/attached/main.cpp | 91 --- examples/declarative/extending/attached/person.cpp | 119 --- examples/declarative/extending/attached/person.h | 106 --- examples/declarative/extending/binding/binding.pro | 19 - examples/declarative/extending/binding/binding.qrc | 5 - .../extending/binding/birthdayparty.cpp | 114 --- .../declarative/extending/binding/birthdayparty.h | 103 --- examples/declarative/extending/binding/example.qml | 37 - .../extending/binding/happybirthdaysong.cpp | 86 -- .../extending/binding/happybirthdaysong.h | 75 -- examples/declarative/extending/binding/main.cpp | 93 --- examples/declarative/extending/binding/person.cpp | 139 ---- examples/declarative/extending/binding/person.h | 114 --- .../extending/coercion/birthdayparty.cpp | 72 -- .../declarative/extending/coercion/birthdayparty.h | 70 -- .../declarative/extending/coercion/coercion.pro | 17 - .../declarative/extending/coercion/coercion.qrc | 5 - .../declarative/extending/coercion/example.qml | 15 - examples/declarative/extending/coercion/main.cpp | 78 -- examples/declarative/extending/coercion/person.cpp | 80 -- examples/declarative/extending/coercion/person.h | 83 -- .../extending/default/birthdayparty.cpp | 72 -- .../declarative/extending/default/birthdayparty.h | 71 -- examples/declarative/extending/default/default.pro | 17 - examples/declarative/extending/default/default.qrc | 5 - examples/declarative/extending/default/example.qml | 14 - examples/declarative/extending/default/main.cpp | 76 -- examples/declarative/extending/default/person.cpp | 79 -- examples/declarative/extending/default/person.h | 78 -- .../declarative/extending/extended/example.qml | 7 - .../declarative/extending/extended/extended.pro | 15 - .../declarative/extending/extended/extended.qrc | 5 - .../declarative/extending/extended/lineedit.cpp | 105 --- examples/declarative/extending/extended/lineedit.h | 74 -- examples/declarative/extending/extended/main.cpp | 65 -- examples/declarative/extending/extending.pro | 13 - .../declarative/extending/extending.qmlproject | 16 - .../extending/grouped/birthdayparty.cpp | 72 -- .../declarative/extending/grouped/birthdayparty.h | 70 -- examples/declarative/extending/grouped/example.qml | 33 - examples/declarative/extending/grouped/grouped.pro | 17 - examples/declarative/extending/grouped/grouped.qrc | 5 - examples/declarative/extending/grouped/main.cpp | 86 -- examples/declarative/extending/grouped/person.cpp | 119 --- examples/declarative/extending/grouped/person.h | 108 --- .../extending/properties/birthdayparty.cpp | 74 -- .../extending/properties/birthdayparty.h | 76 -- .../declarative/extending/properties/example.qml | 15 - examples/declarative/extending/properties/main.cpp | 69 -- .../declarative/extending/properties/person.cpp | 67 -- examples/declarative/extending/properties/person.h | 64 -- .../extending/properties/properties.pro | 18 - .../extending/properties/properties.qrc | 5 - .../declarative/extending/signal/birthdayparty.cpp | 99 --- .../declarative/extending/signal/birthdayparty.h | 93 --- examples/declarative/extending/signal/example.qml | 32 - examples/declarative/extending/signal/main.cpp | 92 --- examples/declarative/extending/signal/person.cpp | 119 --- examples/declarative/extending/signal/person.h | 106 --- examples/declarative/extending/signal/signal.pro | 17 - examples/declarative/extending/signal/signal.qrc | 5 - .../extending/valuesource/birthdayparty.cpp | 109 --- .../extending/valuesource/birthdayparty.h | 98 --- .../declarative/extending/valuesource/example.qml | 36 - .../extending/valuesource/happybirthdaysong.cpp | 81 -- .../extending/valuesource/happybirthdaysong.h | 80 -- .../declarative/extending/valuesource/main.cpp | 94 --- .../declarative/extending/valuesource/person.cpp | 119 --- .../declarative/extending/valuesource/person.h | 106 --- .../extending/valuesource/valuesource.pro | 19 - .../extending/valuesource/valuesource.qrc | 5 - examples/declarative/fillmode/content/QtLogo.qml | 30 - examples/declarative/fillmode/content/qt-logo.png | Bin 5149 -> 0 bytes examples/declarative/fillmode/fillmode.qml | 22 - examples/declarative/fillmode/fillmode.qmlproject | 16 - examples/declarative/flipable/content/5_heart.png | Bin 3872 -> 0 bytes examples/declarative/flipable/content/9_club.png | Bin 6135 -> 0 bytes examples/declarative/flipable/content/Card.qml | 38 - examples/declarative/flipable/content/back.png | Bin 1418 -> 0 bytes examples/declarative/flipable/flipable-example.qml | 15 - examples/declarative/flipable/flipable.qmlproject | 16 - examples/declarative/focus/Core/ContextMenu.qml | 18 - examples/declarative/focus/Core/GridMenu.qml | 61 -- .../declarative/focus/Core/ListViewDelegate.qml | 40 - examples/declarative/focus/Core/ListViews.qml | 62 -- examples/declarative/focus/Core/images/arrow.png | Bin 583 -> 0 bytes examples/declarative/focus/Core/images/qt-logo.png | Bin 5149 -> 0 bytes examples/declarative/focus/Core/qmldir | 4 - examples/declarative/focus/focus.qml | 69 -- examples/declarative/focus/focus.qmlproject | 16 - examples/declarative/fonts/availableFonts.qml | 17 - examples/declarative/fonts/banner.qml | 21 - examples/declarative/fonts/fonts.qml | 64 -- examples/declarative/fonts/fonts.qmlproject | 16 - examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf | Bin 24544 -> 0 bytes examples/declarative/fonts/hello.qml | 38 - .../declarative/gestures/experimental-gestures.qml | 36 - examples/declarative/gestures/gestures.qmlproject | 16 - examples/declarative/gridview/gridview-example.qml | 49 -- examples/declarative/gridview/gridview.qmlproject | 16 - .../declarative/gridview/pics/AddressBook_48.png | Bin 3350 -> 0 bytes .../declarative/gridview/pics/AudioPlayer_48.png | Bin 3806 -> 0 bytes examples/declarative/gridview/pics/Camera_48.png | Bin 3540 -> 0 bytes examples/declarative/gridview/pics/DateBook_48.png | Bin 2610 -> 0 bytes examples/declarative/gridview/pics/EMail_48.png | Bin 3655 -> 0 bytes examples/declarative/gridview/pics/TodoList_48.png | Bin 3429 -> 0 bytes .../declarative/gridview/pics/VideoPlayer_48.png | Bin 4151 -> 0 bytes examples/declarative/i18n/i18n.qmlproject | 16 + .../imageelements/borderimage/borderimage.qml | 57 ++ .../borderimage/borderimage.qmlproject | 16 + .../borderimage/content/MyBorderImage.qml | 50 ++ .../borderimage/content/ShadowRectangle.qml | 14 + .../imageelements/borderimage/content/bw.png | Bin 0 -> 1357 bytes .../borderimage/content/colors-round.sci | 7 + .../borderimage/content/colors-stretch.sci | 5 + .../imageelements/borderimage/content/colors.png | Bin 0 -> 1655 bytes .../imageelements/borderimage/content/shadow.png | Bin 0 -> 588 bytes .../imageelements/borderimage/shadows.qml | 24 + .../declarative/imageelements/image/face_fit.qml | 26 + .../imageelements/image/face_fit_animated.qml | 28 + .../imageelements/image/image.qmlproject | 16 + .../declarative/imageelements/image/pics/face.png | Bin 0 -> 15408 bytes .../imageelements/image/scale_and_crop.qml | 21 + .../imageelements/image/scale_and_crop_simple.qml | 20 + .../imageelements/image/scale_and_sidecrop.qml | 22 + .../imageelements/image/scale_to_fit.qml | 22 + .../imageelements/image/scale_to_fit_simple.qml | 20 + .../imageelements/imageelements.qmlproject | 16 + .../imageprovider/ImageProviderCore/qmldir | 2 - .../imageprovider/imageprovider-example.qml | 25 - .../declarative/imageprovider/imageprovider.cpp | 118 --- .../declarative/imageprovider/imageprovider.pro | 25 - .../imageprovider/imageprovider.qmlproject | 16 - examples/declarative/images/content/lemonade.jpg | Bin 6645 -> 0 bytes examples/declarative/images/images.qml | 72 -- examples/declarative/images/images.qmlproject | 16 - .../keyinteraction/focus/Core/ContextMenu.qml | 18 + .../keyinteraction/focus/Core/GridMenu.qml | 61 ++ .../keyinteraction/focus/Core/ListViewDelegate.qml | 40 + .../keyinteraction/focus/Core/ListViews.qml | 62 ++ .../keyinteraction/focus/Core/images/arrow.png | Bin 0 -> 583 bytes .../keyinteraction/focus/Core/images/qt-logo.png | Bin 0 -> 5149 bytes .../declarative/keyinteraction/focus/Core/qmldir | 4 + .../declarative/keyinteraction/focus/focus.qml | 69 ++ .../keyinteraction/focus/focus.qmlproject | 16 + .../keyinteraction/keyinteraction.qmlproject | 16 + .../layouts/graphicsLayouts/graphicslayouts.cpp | 366 --------- .../layouts/graphicsLayouts/graphicslayouts.pro | 13 - .../layouts/graphicsLayouts/graphicslayouts.qml | 77 -- .../layouts/graphicsLayouts/graphicslayouts.qrc | 5 - .../layouts/graphicsLayouts/graphicslayouts_p.h | 303 ------- .../declarative/layouts/graphicsLayouts/main.cpp | 60 -- .../declarative/layouts/layoutItem/layoutItem.pro | 13 - .../declarative/layouts/layoutItem/layoutItem.qml | 15 - .../declarative/layouts/layoutItem/layoutItem.qrc | 5 - examples/declarative/layouts/layoutItem/main.cpp | 73 -- .../declarative/layouts/positioners/Button.qml | 38 - examples/declarative/layouts/positioners/add.png | Bin 1577 -> 0 bytes examples/declarative/layouts/positioners/del.png | Bin 1661 -> 0 bytes .../layouts/positioners/positioners.qml | 213 ----- .../layouts/positioners/positioners.qmlproject | 18 - .../positioners/positioners.qmlproject.user | 41 - .../declarative/listmodel-threaded/dataloader.js | 9 - .../listmodel-threaded.qmlproject | 16 - .../declarative/listmodel-threaded/timedisplay.qml | 32 - .../listview/content/ClickAutoRepeating.qml | 31 - .../declarative/listview/content/MediaButton.qml | 35 - examples/declarative/listview/content/pics/add.png | Bin 1577 -> 0 bytes .../listview/content/pics/archive-insert.png | Bin 896 -> 0 bytes .../listview/content/pics/archive-remove.png | Bin 1074 -> 0 bytes .../listview/content/pics/button-pressed.png | Bin 571 -> 0 bytes .../declarative/listview/content/pics/button.png | Bin 564 -> 0 bytes examples/declarative/listview/content/pics/del.png | Bin 1661 -> 0 bytes .../listview/content/pics/fruit-salad.jpg | Bin 17952 -> 0 bytes .../declarative/listview/content/pics/go-down.png | Bin 892 -> 0 bytes .../declarative/listview/content/pics/go-up.png | Bin 929 -> 0 bytes .../listview/content/pics/hamburger.jpg | Bin 8572 -> 0 bytes .../declarative/listview/content/pics/lemonade.jpg | Bin 6645 -> 0 bytes .../declarative/listview/content/pics/list-add.png | Bin 907 -> 0 bytes .../listview/content/pics/list-remove.png | Bin 498 -> 0 bytes .../declarative/listview/content/pics/moreDown.png | Bin 217 -> 0 bytes .../declarative/listview/content/pics/moreUp.png | Bin 212 -> 0 bytes .../declarative/listview/content/pics/pancakes.jpg | Bin 9163 -> 0 bytes .../declarative/listview/content/pics/trash.png | Bin 989 -> 0 bytes .../listview/content/pics/vegetable-soup.jpg | Bin 8639 -> 0 bytes .../declarative/listview/dummydata/MyPetsModel.qml | 61 -- .../declarative/listview/dummydata/Recipes.qml | 90 --- examples/declarative/listview/dynamic.qml | 208 ----- examples/declarative/listview/highlight.qml | 55 -- examples/declarative/listview/itemlist.qml | 67 -- examples/declarative/listview/listview-example.qml | 93 --- examples/declarative/listview/listview.qmlproject | 16 - examples/declarative/listview/recipes.qml | 160 ---- examples/declarative/listview/sections.qml | 71 -- .../modelviews/gridview/gridview-example.qml | 49 ++ .../modelviews/gridview/gridview.qmlproject | 16 + .../modelviews/gridview/pics/AddressBook_48.png | Bin 0 -> 3350 bytes .../modelviews/gridview/pics/AudioPlayer_48.png | Bin 0 -> 3806 bytes .../modelviews/gridview/pics/Camera_48.png | Bin 0 -> 3540 bytes .../modelviews/gridview/pics/DateBook_48.png | Bin 0 -> 2610 bytes .../modelviews/gridview/pics/EMail_48.png | Bin 0 -> 3655 bytes .../modelviews/gridview/pics/TodoList_48.png | Bin 0 -> 3429 bytes .../modelviews/gridview/pics/VideoPlayer_48.png | Bin 0 -> 4151 bytes .../listview/content/ClickAutoRepeating.qml | 31 + .../modelviews/listview/content/MediaButton.qml | 35 + .../modelviews/listview/content/pics/add.png | Bin 0 -> 1577 bytes .../listview/content/pics/archive-insert.png | Bin 0 -> 896 bytes .../listview/content/pics/archive-remove.png | Bin 0 -> 1074 bytes .../listview/content/pics/button-pressed.png | Bin 0 -> 571 bytes .../modelviews/listview/content/pics/button.png | Bin 0 -> 564 bytes .../modelviews/listview/content/pics/del.png | Bin 0 -> 1661 bytes .../listview/content/pics/fruit-salad.jpg | Bin 0 -> 17952 bytes .../modelviews/listview/content/pics/go-down.png | Bin 0 -> 892 bytes .../modelviews/listview/content/pics/go-up.png | Bin 0 -> 929 bytes .../modelviews/listview/content/pics/hamburger.jpg | Bin 0 -> 8572 bytes .../modelviews/listview/content/pics/lemonade.jpg | Bin 0 -> 6645 bytes .../modelviews/listview/content/pics/list-add.png | Bin 0 -> 907 bytes .../listview/content/pics/list-remove.png | Bin 0 -> 498 bytes .../modelviews/listview/content/pics/moreDown.png | Bin 0 -> 217 bytes .../modelviews/listview/content/pics/moreUp.png | Bin 0 -> 212 bytes .../modelviews/listview/content/pics/pancakes.jpg | Bin 0 -> 9163 bytes .../modelviews/listview/content/pics/trash.png | Bin 0 -> 989 bytes .../listview/content/pics/vegetable-soup.jpg | Bin 0 -> 8639 bytes .../modelviews/listview/dummydata/MyPetsModel.qml | 61 ++ .../modelviews/listview/dummydata/Recipes.qml | 90 +++ .../declarative/modelviews/listview/dynamic.qml | 208 +++++ .../declarative/modelviews/listview/highlight.qml | 55 ++ .../declarative/modelviews/listview/itemlist.qml | 67 ++ .../modelviews/listview/listview-example.qml | 93 +++ .../modelviews/listview/listview.qmlproject | 16 + .../declarative/modelviews/listview/recipes.qml | 160 ++++ .../declarative/modelviews/listview/sections.qml | 71 ++ examples/declarative/modelviews/modelviews.pro | 7 + .../declarative/modelviews/modelviews.qmlproject | 16 + .../modelviews/objectlistmodel/dataobject.cpp | 79 ++ .../modelviews/objectlistmodel/dataobject.h | 73 ++ .../modelviews/objectlistmodel/main.cpp | 77 ++ .../modelviews/objectlistmodel/objectlistmodel.pro | 18 + .../objectlistmodel/objectlistmodel.qmlproject | 16 + .../modelviews/objectlistmodel/objectlistmodel.qrc | 5 + .../modelviews/objectlistmodel/view.qml | 16 + .../declarative/modelviews/package/Delegate.qml | 48 ++ .../modelviews/package/package.qmlproject | 16 + examples/declarative/modelviews/package/view.qml | 35 + .../declarative/modelviews/parallax/parallax.qml | 41 + .../modelviews/parallax/parallax.qmlproject | 16 + .../modelviews/parallax/pics/background.jpg | Bin 0 -> 209814 bytes .../modelviews/parallax/pics/face-smile.png | Bin 0 -> 15408 bytes .../modelviews/parallax/pics/home-page.svg | 445 +++++++++++ .../modelviews/parallax/pics/shadow.png | Bin 0 -> 425 bytes .../modelviews/parallax/pics/yast-joystick.png | Bin 0 -> 2723 bytes .../modelviews/parallax/pics/yast-wol.png | Bin 0 -> 3769 bytes .../modelviews/parallax/qml/ParallaxView.qml | 83 ++ .../declarative/modelviews/parallax/qml/Smiley.qml | 46 ++ .../modelviews/stringlistmodel/main.cpp | 76 ++ .../modelviews/stringlistmodel/stringlistmodel.pro | 9 + .../modelviews/stringlistmodel/stringlistmodel.qrc | 5 + .../modelviews/stringlistmodel/view.qml | 15 + .../declarative/modelviews/webview/alerts.html | 5 + examples/declarative/modelviews/webview/alerts.qml | 58 ++ .../declarative/modelviews/webview/autosize.qml | 62 ++ .../modelviews/webview/content/FieldText.qml | 157 ++++ .../modelviews/webview/content/Mapping/Map.qml | 26 + .../modelviews/webview/content/Mapping/map.html | 52 ++ .../modelviews/webview/content/SpinSquare.qml | 25 + .../modelviews/webview/content/pics/cancel.png | Bin 0 -> 1038 bytes .../modelviews/webview/content/pics/ok.png | Bin 0 -> 655 bytes .../declarative/modelviews/webview/googleMaps.qml | 43 + .../declarative/modelviews/webview/inline-html.qml | 15 + .../declarative/modelviews/webview/newwindows.html | 3 + .../declarative/modelviews/webview/newwindows.qml | 31 + .../declarative/modelviews/webview/transparent.qml | 15 + .../modelviews/webview/webview.qmlproject | 16 + examples/declarative/mousearea/mouse.qml | 47 -- .../declarative/mousearea/mousearea.qmlproject | 16 - .../declarative/objectlistmodel/dataobject.cpp | 79 -- examples/declarative/objectlistmodel/dataobject.h | 73 -- examples/declarative/objectlistmodel/main.cpp | 77 -- .../objectlistmodel/objectlistmodel.pro | 18 - .../objectlistmodel/objectlistmodel.qmlproject | 16 - .../objectlistmodel/objectlistmodel.qrc | 5 - examples/declarative/objectlistmodel/view.qml | 16 - examples/declarative/package/Delegate.qml | 48 -- examples/declarative/package/package.qmlproject | 16 - examples/declarative/package/view.qml | 35 - examples/declarative/parallax/parallax.qml | 41 - examples/declarative/parallax/parallax.qmlproject | 16 - examples/declarative/parallax/pics/background.jpg | Bin 209814 -> 0 bytes examples/declarative/parallax/pics/face-smile.png | Bin 15408 -> 0 bytes examples/declarative/parallax/pics/home-page.svg | 445 ----------- examples/declarative/parallax/pics/shadow.png | Bin 425 -> 0 bytes .../declarative/parallax/pics/yast-joystick.png | Bin 2723 -> 0 bytes examples/declarative/parallax/pics/yast-wol.png | Bin 3769 -> 0 bytes examples/declarative/parallax/qml/ParallaxView.qml | 83 -- examples/declarative/parallax/qml/Smiley.qml | 46 -- examples/declarative/plugins/README | 9 - .../plugins/com/nokia/TimeExample/Clock.qml | 50 -- .../plugins/com/nokia/TimeExample/center.png | Bin 765 -> 0 bytes .../plugins/com/nokia/TimeExample/clock.png | Bin 20653 -> 0 bytes .../plugins/com/nokia/TimeExample/hour.png | Bin 625 -> 0 bytes .../plugins/com/nokia/TimeExample/minute.png | Bin 625 -> 0 bytes .../plugins/com/nokia/TimeExample/qmldir | 2 - examples/declarative/plugins/plugin.cpp | 152 ---- examples/declarative/plugins/plugins.pro | 31 - examples/declarative/plugins/plugins.qml | 11 - examples/declarative/plugins/plugins.qmlproject | 16 - examples/declarative/positioners/Button.qml | 38 + examples/declarative/positioners/add.png | Bin 0 -> 1577 bytes examples/declarative/positioners/del.png | Bin 0 -> 1661 bytes examples/declarative/positioners/positioners.qml | 213 +++++ .../declarative/positioners/positioners.qmlproject | 18 + .../positioners/positioners.qmlproject.user | 41 + .../progressbar/content/ProgressBar.qml | 43 - .../declarative/progressbar/content/background.png | Bin 426 -> 0 bytes .../declarative/progressbar/progressbar.qmlproject | 16 - examples/declarative/progressbar/progressbars.qml | 33 - examples/declarative/proxyviewer/main.cpp | 109 --- examples/declarative/proxyviewer/proxyviewer.pro | 9 - examples/declarative/proxyviewer/proxyviewer.qrc | 5 - examples/declarative/proxyviewer/view.qml | 7 - .../declarative/proxywidgets/ProxyWidgets/qmldir | 1 - examples/declarative/proxywidgets/README | 4 - examples/declarative/proxywidgets/proxywidgets.cpp | 97 --- examples/declarative/proxywidgets/proxywidgets.pro | 21 - examples/declarative/proxywidgets/proxywidgets.qml | 70 -- .../proxywidgets/proxywidgets.qmlproject | 16 - examples/declarative/scrollbar/ScrollBar.qml | 33 - examples/declarative/scrollbar/display.qml | 54 -- .../declarative/scrollbar/pics/niagara_falls.jpg | Bin 604121 -> 0 bytes .../declarative/scrollbar/scrollbar.qmlproject | 16 - examples/declarative/searchbox/SearchBox.qml | 65 -- .../images/edit-clear-locationbar-rtl.png | Bin 429 -> 0 bytes .../searchbox/images/lineedit-bg-focus.png | Bin 526 -> 0 bytes .../declarative/searchbox/images/lineedit-bg.png | Bin 426 -> 0 bytes examples/declarative/searchbox/main.qml | 15 - .../declarative/searchbox/searchbox.qmlproject | 16 - .../declarative/slideswitch/content/Switch.qml | 76 -- .../declarative/slideswitch/content/background.svg | 23 - examples/declarative/slideswitch/content/knob.svg | 867 --------------------- examples/declarative/slideswitch/slideswitch.qml | 11 - .../declarative/slideswitch/slideswitch.qmlproject | 16 - examples/declarative/spinner/content/Spinner.qml | 25 - .../declarative/spinner/content/spinner-bg.png | Bin 345 -> 0 bytes .../declarative/spinner/content/spinner-select.png | Bin 320 -> 0 bytes examples/declarative/spinner/main.qml | 18 - examples/declarative/spinner/spinner.qmlproject | 16 - examples/declarative/sql/hello.qml | 31 - examples/declarative/sql/sql.qmlproject | 16 - examples/declarative/sqllocalstorage/hello.qml | 31 + .../sqllocalstorage/sqllocalstorage.qmlproject | 16 + examples/declarative/states/states.qml | 61 -- examples/declarative/states/states.qmlproject | 16 - examples/declarative/states/transitions.qml | 90 --- examples/declarative/states/user.png | Bin 4886 -> 0 bytes examples/declarative/stringlistmodel/main.cpp | 76 -- .../stringlistmodel/stringlistmodel.pro | 9 - .../stringlistmodel/stringlistmodel.qrc | 5 - examples/declarative/stringlistmodel/view.qml | 15 - examples/declarative/tabwidget/TabWidget.qml | 57 -- examples/declarative/tabwidget/tab.png | Bin 507 -> 0 bytes examples/declarative/tabwidget/tabs.qml | 59 -- .../declarative/tabwidget/tabwidget.qmlproject | 16 - examples/declarative/text/fonts/availableFonts.qml | 17 + examples/declarative/text/fonts/banner.qml | 21 + examples/declarative/text/fonts/fonts.qml | 64 ++ examples/declarative/text/fonts/fonts.qmlproject | 16 + .../declarative/text/fonts/fonts/tarzeau_ocr_a.ttf | Bin 0 -> 24544 bytes examples/declarative/text/fonts/hello.qml | 38 + examples/declarative/text/text.qmlproject | 16 + .../threading/threadedlistmodel/dataloader.js | 9 + .../threadedlistmodel/threadedlistmodel.qmlproject | 16 + .../threading/threadedlistmodel/timedisplay.qml | 32 + .../declarative/threading/threading.qmlproject | 16 + .../threading/workerscript/workerscript.js | 15 + .../threading/workerscript/workerscript.qml | 43 + .../threading/workerscript/workerscript.qmlproject | 16 + .../declarative/tic-tac-toe/content/Button.qml | 37 - .../declarative/tic-tac-toe/content/TicTac.qml | 20 - .../declarative/tic-tac-toe/content/pics/board.png | Bin 12258 -> 0 bytes .../declarative/tic-tac-toe/content/pics/o.png | Bin 1470 -> 0 bytes .../declarative/tic-tac-toe/content/pics/x.png | Bin 1331 -> 0 bytes .../declarative/tic-tac-toe/content/tic-tac-toe.js | 145 ---- examples/declarative/tic-tac-toe/tic-tac-toe.qml | 77 -- .../declarative/tic-tac-toe/tic-tac-toe.qmlproject | 16 - .../gestures/experimental-gestures.qml | 36 + .../touchinteraction/gestures/gestures.qmlproject | 16 + .../touchinteraction/mousearea/mouse.qml | 47 ++ .../mousearea/mousearea.qmlproject | 16 + .../touchinteraction/touchinteraction.qmlproject | 16 + examples/declarative/toys/clocks/clocks.qml | 14 + examples/declarative/toys/clocks/clocks.qmlproject | 16 + examples/declarative/toys/clocks/content/Clock.qml | 83 ++ .../declarative/toys/clocks/content/background.png | Bin 0 -> 46895 bytes .../declarative/toys/clocks/content/center.png | Bin 0 -> 765 bytes .../toys/clocks/content/clock-night.png | Bin 0 -> 23359 bytes examples/declarative/toys/clocks/content/clock.png | Bin 0 -> 20653 bytes examples/declarative/toys/clocks/content/hour.png | Bin 0 -> 625 bytes .../declarative/toys/clocks/content/minute.png | Bin 0 -> 625 bytes .../declarative/toys/clocks/content/second.png | Bin 0 -> 303 bytes examples/declarative/toys/dial/content/Dial.qml | 37 + .../declarative/toys/dial/content/background.png | Bin 0 -> 35876 bytes examples/declarative/toys/dial/content/needle.png | Bin 0 -> 342 bytes .../toys/dial/content/needle_shadow.png | Bin 0 -> 632 bytes examples/declarative/toys/dial/content/overlay.png | Bin 0 -> 3564 bytes examples/declarative/toys/dial/dial-example.qml | 44 ++ examples/declarative/toys/dial/dial.qmlproject | 16 + examples/declarative/toys/dynamic/dynamic.qml | 176 +++++ .../declarative/toys/dynamic/dynamic.qmlproject | 16 + examples/declarative/toys/dynamic/images/NOTE | 1 + .../declarative/toys/dynamic/images/face-smile.png | Bin 0 -> 15408 bytes examples/declarative/toys/dynamic/images/moon.png | Bin 0 -> 1757 bytes .../toys/dynamic/images/rabbit_brown.png | Bin 0 -> 1245 bytes .../declarative/toys/dynamic/images/rabbit_bw.png | Bin 0 -> 1759 bytes examples/declarative/toys/dynamic/images/star.png | Bin 0 -> 349 bytes examples/declarative/toys/dynamic/images/sun.png | Bin 0 -> 8153 bytes .../declarative/toys/dynamic/images/tree_s.png | Bin 0 -> 3406 bytes examples/declarative/toys/dynamic/qml/Button.qml | 40 + .../declarative/toys/dynamic/qml/PaletteItem.qml | 19 + .../toys/dynamic/qml/PerspectiveItem.qml | 25 + examples/declarative/toys/dynamic/qml/Sun.qml | 38 + .../declarative/toys/dynamic/qml/itemCreation.js | 65 ++ .../toys/tic-tac-toe/content/Button.qml | 37 + .../toys/tic-tac-toe/content/TicTac.qml | 20 + .../toys/tic-tac-toe/content/pics/board.png | Bin 0 -> 12258 bytes .../toys/tic-tac-toe/content/pics/o.png | Bin 0 -> 1470 bytes .../toys/tic-tac-toe/content/pics/x.png | Bin 0 -> 1331 bytes .../toys/tic-tac-toe/content/tic-tac-toe.js | 145 ++++ .../declarative/toys/tic-tac-toe/tic-tac-toe.qml | 77 ++ .../toys/tic-tac-toe/tic-tac-toe.qmlproject | 16 + examples/declarative/toys/toys.qmlproject | 16 + examples/declarative/toys/tvtennis/tvtennis.qml | 71 ++ .../declarative/toys/tvtennis/tvtennis.qmlproject | 16 + examples/declarative/toys/velocity/Day.qml | 101 +++ examples/declarative/toys/velocity/cork.jpg | Bin 0 -> 149337 bytes examples/declarative/toys/velocity/note-yellow.png | Bin 0 -> 54559 bytes examples/declarative/toys/velocity/tack.png | Bin 0 -> 7282 bytes examples/declarative/toys/velocity/velocity.qml | 75 ++ .../declarative/toys/velocity/velocity.qmlproject | 16 + .../declarative/tutorials/extending/extending.pro | 9 + examples/declarative/tutorials/tutorials.pro | 5 + examples/declarative/tvtennis/tvtennis.qml | 71 -- examples/declarative/tvtennis/tvtennis.qmlproject | 16 - .../ui-components/flipable/content/5_heart.png | Bin 0 -> 3872 bytes .../ui-components/flipable/content/9_club.png | Bin 0 -> 6135 bytes .../ui-components/flipable/content/Card.qml | 38 + .../ui-components/flipable/content/back.png | Bin 0 -> 1418 bytes .../ui-components/flipable/flipable-example.qml | 15 + .../ui-components/flipable/flipable.qmlproject | 16 + .../progressbar/content/ProgressBar.qml | 43 + .../progressbar/content/background.png | Bin 0 -> 426 bytes .../progressbar/progressbar.qmlproject | 16 + .../ui-components/progressbar/progressbars.qml | 33 + .../ui-components/scrollbar/ScrollBar.qml | 33 + .../ui-components/scrollbar/display.qml | 54 ++ .../ui-components/scrollbar/pics/niagara_falls.jpg | Bin 0 -> 604121 bytes .../ui-components/scrollbar/scrollbar.qmlproject | 16 + .../ui-components/searchbox/SearchBox.qml | 65 ++ .../images/edit-clear-locationbar-rtl.png | Bin 0 -> 429 bytes .../searchbox/images/lineedit-bg-focus.png | Bin 0 -> 526 bytes .../ui-components/searchbox/images/lineedit-bg.png | Bin 0 -> 426 bytes .../declarative/ui-components/searchbox/main.qml | 15 + .../ui-components/searchbox/searchbox.qmlproject | 16 + .../ui-components/slideswitch/content/Switch.qml | 76 ++ .../slideswitch/content/background.svg | 23 + .../ui-components/slideswitch/content/knob.svg | 867 +++++++++++++++++++++ .../ui-components/slideswitch/slideswitch.qml | 11 + .../slideswitch/slideswitch.qmlproject | 16 + .../ui-components/spinner/content/Spinner.qml | 25 + .../ui-components/spinner/content/spinner-bg.png | Bin 0 -> 345 bytes .../spinner/content/spinner-select.png | Bin 0 -> 320 bytes .../declarative/ui-components/spinner/main.qml | 18 + .../ui-components/spinner/spinner.qmlproject | 16 + .../ui-components/tabwidget/TabWidget.qml | 57 ++ .../declarative/ui-components/tabwidget/tab.png | Bin 0 -> 507 bytes .../declarative/ui-components/tabwidget/tabs.qml | 59 ++ .../ui-components/tabwidget/tabwidget.qmlproject | 16 + .../ui-components/ui-components.qmlproject | 16 + examples/declarative/velocity/Day.qml | 101 --- examples/declarative/velocity/cork.jpg | Bin 149337 -> 0 bytes examples/declarative/velocity/note-yellow.png | Bin 54559 -> 0 bytes examples/declarative/velocity/tack.png | Bin 7282 -> 0 bytes examples/declarative/velocity/velocity.qml | 75 -- examples/declarative/velocity/velocity.qmlproject | 16 - examples/declarative/webview/alerts.html | 5 - examples/declarative/webview/alerts.qml | 58 -- examples/declarative/webview/autosize.qml | 62 -- examples/declarative/webview/content/FieldText.qml | 157 ---- .../declarative/webview/content/Mapping/Map.qml | 26 - .../declarative/webview/content/Mapping/map.html | 52 -- .../declarative/webview/content/SpinSquare.qml | 25 - .../declarative/webview/content/pics/cancel.png | Bin 1038 -> 0 bytes examples/declarative/webview/content/pics/ok.png | Bin 655 -> 0 bytes examples/declarative/webview/googleMaps.qml | 43 - examples/declarative/webview/inline-html.qml | 15 - examples/declarative/webview/newwindows.html | 3 - examples/declarative/webview/newwindows.qml | 31 - examples/declarative/webview/transparent.qml | 15 - examples/declarative/webview/webview.qmlproject | 16 - examples/declarative/workerscript/workerscript.js | 15 - examples/declarative/workerscript/workerscript.qml | 43 - .../workerscript/workerscript.qmlproject | 16 - examples/declarative/xml/xml.qmlproject | 16 + .../declarative/xml/xmldata/daringfireball.qml | 47 ++ .../declarative/xml/xmldata/xmldata.qmlproject | 16 + examples/declarative/xml/xmldata/yahoonews.qml | 83 ++ examples/declarative/xml/xmlhttprequest/test.qml | 36 + examples/declarative/xml/xmlhttprequest/test.xml | 5 + .../xml/xmlhttprequest/xmlhttprequest.qmlproject | 16 + examples/declarative/xmldata/daringfireball.qml | 47 -- examples/declarative/xmldata/xmldata.qmlproject | 16 - examples/declarative/xmldata/yahoonews.qml | 83 -- examples/declarative/xmlhttprequest/test.qml | 36 - examples/declarative/xmlhttprequest/test.xml | 5 - .../xmlhttprequest/xmlhttprequest.qmlproject | 16 - .../graphicsitems/qdeclarativeborderimage.cpp | 4 +- .../graphicsitems/qdeclarativeflickable.cpp | 2 +- .../graphicsitems/qdeclarativelistview.cpp | 2 +- src/declarative/qml/qdeclarativeengine.cpp | 4 +- .../qml/qdeclarativeextensionplugin.cpp | 2 +- src/declarative/util/qdeclarativelistmodel.cpp | 4 +- src/declarative/util/qdeclarativepackage.cpp | 4 +- src/declarative/util/qdeclarativexmllistmodel.cpp | 2 +- 751 files changed, 14589 insertions(+), 14519 deletions(-) delete mode 100644 doc/src/snippets/declarative/border-image.qml create mode 100644 doc/src/snippets/declarative/borderimage.qml create mode 100644 examples/declarative/animation/animation.qmlproject create mode 100644 examples/declarative/animation/basics/basics.qmlproject create mode 100644 examples/declarative/animation/basics/color-animation.qml create mode 100644 examples/declarative/animation/basics/images/face-smile.png create mode 100644 examples/declarative/animation/basics/images/moon.png create mode 100644 examples/declarative/animation/basics/images/shadow.png create mode 100644 examples/declarative/animation/basics/images/star.png create mode 100644 examples/declarative/animation/basics/images/sun.png create mode 100644 examples/declarative/animation/basics/property-animation.qml create mode 100644 examples/declarative/animation/behaviors/SideRect.qml create mode 100644 examples/declarative/animation/behaviors/behavior-example.qml create mode 100644 examples/declarative/animation/behaviors/behaviors.qmlproject create mode 100644 examples/declarative/animation/easing/easing.qml create mode 100644 examples/declarative/animation/easing/easing.qmlproject create mode 100644 examples/declarative/animation/states/states.qml create mode 100644 examples/declarative/animation/states/states.qmlproject create mode 100644 examples/declarative/animation/states/transitions.qml create mode 100644 examples/declarative/animation/states/user.png delete mode 100644 examples/declarative/animations/animations.qmlproject delete mode 100644 examples/declarative/animations/color-animation.qml delete mode 100644 examples/declarative/animations/easing.qml delete mode 100644 examples/declarative/animations/images/face-smile.png delete mode 100644 examples/declarative/animations/images/moon.png delete mode 100644 examples/declarative/animations/images/shadow.png delete mode 100644 examples/declarative/animations/images/star.png delete mode 100644 examples/declarative/animations/images/sun.png delete mode 100644 examples/declarative/animations/property-animation.qml delete mode 100644 examples/declarative/aspectratio/aspectratio.qmlproject delete mode 100644 examples/declarative/aspectratio/face_fit.qml delete mode 100644 examples/declarative/aspectratio/face_fit_animated.qml delete mode 100644 examples/declarative/aspectratio/pics/face.png delete mode 100644 examples/declarative/aspectratio/scale_and_crop.qml delete mode 100644 examples/declarative/aspectratio/scale_and_crop_simple.qml delete mode 100644 examples/declarative/aspectratio/scale_and_sidecrop.qml delete mode 100644 examples/declarative/aspectratio/scale_to_fit.qml delete mode 100644 examples/declarative/aspectratio/scale_to_fit_simple.qml delete mode 100644 examples/declarative/behaviors/SideRect.qml delete mode 100644 examples/declarative/behaviors/behavior-example.qml delete mode 100644 examples/declarative/behaviors/behaviors.qmlproject delete mode 100644 examples/declarative/border-image/border-image.qml delete mode 100644 examples/declarative/border-image/border-image.qmlproject delete mode 100644 examples/declarative/border-image/content/MyBorderImage.qml delete mode 100644 examples/declarative/border-image/content/ShadowRectangle.qml delete mode 100644 examples/declarative/border-image/content/bw.png delete mode 100644 examples/declarative/border-image/content/colors-round.sci delete mode 100644 examples/declarative/border-image/content/colors-stretch.sci delete mode 100644 examples/declarative/border-image/content/colors.png delete mode 100644 examples/declarative/border-image/content/shadow.png delete mode 100644 examples/declarative/border-image/shadows.qml delete mode 100644 examples/declarative/clocks/clocks.qml delete mode 100644 examples/declarative/clocks/clocks.qmlproject delete mode 100644 examples/declarative/clocks/content/Clock.qml delete mode 100644 examples/declarative/clocks/content/background.png delete mode 100755 examples/declarative/clocks/content/center.png delete mode 100755 examples/declarative/clocks/content/clock-night.png delete mode 100755 examples/declarative/clocks/content/clock.png delete mode 100755 examples/declarative/clocks/content/hour.png delete mode 100755 examples/declarative/clocks/content/minute.png delete mode 100755 examples/declarative/clocks/content/second.png delete mode 100644 examples/declarative/connections/connections-example.qml delete mode 100644 examples/declarative/connections/connections.qmlproject delete mode 100644 examples/declarative/connections/content/Button.qml delete mode 100644 examples/declarative/connections/content/bg1.jpg delete mode 100644 examples/declarative/connections/content/rotate-left.png delete mode 100644 examples/declarative/connections/content/rotate-right.png create mode 100644 examples/declarative/cppextensions/cppextensions.pro create mode 100644 examples/declarative/cppextensions/cppextensions.qmlproject create mode 100644 examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir create mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider-example.qml create mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.cpp create mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.pro create mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject create mode 100644 examples/declarative/cppextensions/plugins/README create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir create mode 100644 examples/declarative/cppextensions/plugins/plugin.cpp create mode 100644 examples/declarative/cppextensions/plugins/plugins.pro create mode 100644 examples/declarative/cppextensions/plugins/plugins.qml create mode 100644 examples/declarative/cppextensions/plugins/plugins.qmlproject create mode 100644 examples/declarative/cppextensions/proxyviewer/main.cpp create mode 100644 examples/declarative/cppextensions/proxyviewer/proxyviewer.pro create mode 100644 examples/declarative/cppextensions/proxyviewer/proxyviewer.qrc create mode 100644 examples/declarative/cppextensions/proxyviewer/view.qml create mode 100644 examples/declarative/cppextensions/proxywidgets/ProxyWidgets/qmldir create mode 100644 examples/declarative/cppextensions/proxywidgets/README create mode 100644 examples/declarative/cppextensions/proxywidgets/proxywidgets.cpp create mode 100644 examples/declarative/cppextensions/proxywidgets/proxywidgets.pro create mode 100644 examples/declarative/cppextensions/proxywidgets/proxywidgets.qml create mode 100644 examples/declarative/cppextensions/proxywidgets/proxywidgets.qmlproject create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.cpp create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qml create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qrc create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts_p.h create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/main.cpp create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.pro create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qml create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qrc create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/layoutItem/main.cpp create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.qmlproject create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/adding.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/adding.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/attached.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/attached.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/binding.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/binding.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/default/default.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/default/default.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/default/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/default/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/default/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/default/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/extended.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/extended.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/lineedit.h create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/properties.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/properties.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/referenceexamples.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/signal.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/signal.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc delete mode 100644 examples/declarative/dial/content/Dial.qml delete mode 100644 examples/declarative/dial/content/background.png delete mode 100644 examples/declarative/dial/content/needle.png delete mode 100644 examples/declarative/dial/content/needle_shadow.png delete mode 100644 examples/declarative/dial/content/overlay.png delete mode 100644 examples/declarative/dial/dial-example.qml delete mode 100644 examples/declarative/dial/dial.qmlproject delete mode 100644 examples/declarative/dynamic/dynamic.qml delete mode 100644 examples/declarative/dynamic/dynamic.qmlproject delete mode 100644 examples/declarative/dynamic/images/NOTE delete mode 100644 examples/declarative/dynamic/images/face-smile.png delete mode 100644 examples/declarative/dynamic/images/moon.png delete mode 100644 examples/declarative/dynamic/images/rabbit_brown.png delete mode 100644 examples/declarative/dynamic/images/rabbit_bw.png delete mode 100644 examples/declarative/dynamic/images/star.png delete mode 100644 examples/declarative/dynamic/images/sun.png delete mode 100644 examples/declarative/dynamic/images/tree_s.png delete mode 100644 examples/declarative/dynamic/qml/Button.qml delete mode 100644 examples/declarative/dynamic/qml/PaletteItem.qml delete mode 100644 examples/declarative/dynamic/qml/PerspectiveItem.qml delete mode 100644 examples/declarative/dynamic/qml/Sun.qml delete mode 100644 examples/declarative/dynamic/qml/itemCreation.js delete mode 100644 examples/declarative/extending/adding/adding.pro delete mode 100644 examples/declarative/extending/adding/adding.qrc delete mode 100644 examples/declarative/extending/adding/example.qml delete mode 100644 examples/declarative/extending/adding/main.cpp delete mode 100644 examples/declarative/extending/adding/person.cpp delete mode 100644 examples/declarative/extending/adding/person.h delete mode 100644 examples/declarative/extending/attached/attached.pro delete mode 100644 examples/declarative/extending/attached/attached.qrc delete mode 100644 examples/declarative/extending/attached/birthdayparty.cpp delete mode 100644 examples/declarative/extending/attached/birthdayparty.h delete mode 100644 examples/declarative/extending/attached/example.qml delete mode 100644 examples/declarative/extending/attached/main.cpp delete mode 100644 examples/declarative/extending/attached/person.cpp delete mode 100644 examples/declarative/extending/attached/person.h delete mode 100644 examples/declarative/extending/binding/binding.pro delete mode 100644 examples/declarative/extending/binding/binding.qrc delete mode 100644 examples/declarative/extending/binding/birthdayparty.cpp delete mode 100644 examples/declarative/extending/binding/birthdayparty.h delete mode 100644 examples/declarative/extending/binding/example.qml delete mode 100644 examples/declarative/extending/binding/happybirthdaysong.cpp delete mode 100644 examples/declarative/extending/binding/happybirthdaysong.h delete mode 100644 examples/declarative/extending/binding/main.cpp delete mode 100644 examples/declarative/extending/binding/person.cpp delete mode 100644 examples/declarative/extending/binding/person.h delete mode 100644 examples/declarative/extending/coercion/birthdayparty.cpp delete mode 100644 examples/declarative/extending/coercion/birthdayparty.h delete mode 100644 examples/declarative/extending/coercion/coercion.pro delete mode 100644 examples/declarative/extending/coercion/coercion.qrc delete mode 100644 examples/declarative/extending/coercion/example.qml delete mode 100644 examples/declarative/extending/coercion/main.cpp delete mode 100644 examples/declarative/extending/coercion/person.cpp delete mode 100644 examples/declarative/extending/coercion/person.h delete mode 100644 examples/declarative/extending/default/birthdayparty.cpp delete mode 100644 examples/declarative/extending/default/birthdayparty.h delete mode 100644 examples/declarative/extending/default/default.pro delete mode 100644 examples/declarative/extending/default/default.qrc delete mode 100644 examples/declarative/extending/default/example.qml delete mode 100644 examples/declarative/extending/default/main.cpp delete mode 100644 examples/declarative/extending/default/person.cpp delete mode 100644 examples/declarative/extending/default/person.h delete mode 100644 examples/declarative/extending/extended/example.qml delete mode 100644 examples/declarative/extending/extended/extended.pro delete mode 100644 examples/declarative/extending/extended/extended.qrc delete mode 100644 examples/declarative/extending/extended/lineedit.cpp delete mode 100644 examples/declarative/extending/extended/lineedit.h delete mode 100644 examples/declarative/extending/extended/main.cpp delete mode 100644 examples/declarative/extending/extending.pro delete mode 100644 examples/declarative/extending/extending.qmlproject delete mode 100644 examples/declarative/extending/grouped/birthdayparty.cpp delete mode 100644 examples/declarative/extending/grouped/birthdayparty.h delete mode 100644 examples/declarative/extending/grouped/example.qml delete mode 100644 examples/declarative/extending/grouped/grouped.pro delete mode 100644 examples/declarative/extending/grouped/grouped.qrc delete mode 100644 examples/declarative/extending/grouped/main.cpp delete mode 100644 examples/declarative/extending/grouped/person.cpp delete mode 100644 examples/declarative/extending/grouped/person.h delete mode 100644 examples/declarative/extending/properties/birthdayparty.cpp delete mode 100644 examples/declarative/extending/properties/birthdayparty.h delete mode 100644 examples/declarative/extending/properties/example.qml delete mode 100644 examples/declarative/extending/properties/main.cpp delete mode 100644 examples/declarative/extending/properties/person.cpp delete mode 100644 examples/declarative/extending/properties/person.h delete mode 100644 examples/declarative/extending/properties/properties.pro delete mode 100644 examples/declarative/extending/properties/properties.qrc delete mode 100644 examples/declarative/extending/signal/birthdayparty.cpp delete mode 100644 examples/declarative/extending/signal/birthdayparty.h delete mode 100644 examples/declarative/extending/signal/example.qml delete mode 100644 examples/declarative/extending/signal/main.cpp delete mode 100644 examples/declarative/extending/signal/person.cpp delete mode 100644 examples/declarative/extending/signal/person.h delete mode 100644 examples/declarative/extending/signal/signal.pro delete mode 100644 examples/declarative/extending/signal/signal.qrc delete mode 100644 examples/declarative/extending/valuesource/birthdayparty.cpp delete mode 100644 examples/declarative/extending/valuesource/birthdayparty.h delete mode 100644 examples/declarative/extending/valuesource/example.qml delete mode 100644 examples/declarative/extending/valuesource/happybirthdaysong.cpp delete mode 100644 examples/declarative/extending/valuesource/happybirthdaysong.h delete mode 100644 examples/declarative/extending/valuesource/main.cpp delete mode 100644 examples/declarative/extending/valuesource/person.cpp delete mode 100644 examples/declarative/extending/valuesource/person.h delete mode 100644 examples/declarative/extending/valuesource/valuesource.pro delete mode 100644 examples/declarative/extending/valuesource/valuesource.qrc delete mode 100644 examples/declarative/fillmode/content/QtLogo.qml delete mode 100644 examples/declarative/fillmode/content/qt-logo.png delete mode 100644 examples/declarative/fillmode/fillmode.qml delete mode 100644 examples/declarative/fillmode/fillmode.qmlproject delete mode 100644 examples/declarative/flipable/content/5_heart.png delete mode 100644 examples/declarative/flipable/content/9_club.png delete mode 100644 examples/declarative/flipable/content/Card.qml delete mode 100644 examples/declarative/flipable/content/back.png delete mode 100644 examples/declarative/flipable/flipable-example.qml delete mode 100644 examples/declarative/flipable/flipable.qmlproject delete mode 100644 examples/declarative/focus/Core/ContextMenu.qml delete mode 100644 examples/declarative/focus/Core/GridMenu.qml delete mode 100644 examples/declarative/focus/Core/ListViewDelegate.qml delete mode 100644 examples/declarative/focus/Core/ListViews.qml delete mode 100644 examples/declarative/focus/Core/images/arrow.png delete mode 100644 examples/declarative/focus/Core/images/qt-logo.png delete mode 100644 examples/declarative/focus/Core/qmldir delete mode 100644 examples/declarative/focus/focus.qml delete mode 100644 examples/declarative/focus/focus.qmlproject delete mode 100644 examples/declarative/fonts/availableFonts.qml delete mode 100644 examples/declarative/fonts/banner.qml delete mode 100644 examples/declarative/fonts/fonts.qml delete mode 100644 examples/declarative/fonts/fonts.qmlproject delete mode 100644 examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf delete mode 100644 examples/declarative/fonts/hello.qml delete mode 100644 examples/declarative/gestures/experimental-gestures.qml delete mode 100644 examples/declarative/gestures/gestures.qmlproject delete mode 100644 examples/declarative/gridview/gridview-example.qml delete mode 100644 examples/declarative/gridview/gridview.qmlproject delete mode 100644 examples/declarative/gridview/pics/AddressBook_48.png delete mode 100644 examples/declarative/gridview/pics/AudioPlayer_48.png delete mode 100644 examples/declarative/gridview/pics/Camera_48.png delete mode 100644 examples/declarative/gridview/pics/DateBook_48.png delete mode 100644 examples/declarative/gridview/pics/EMail_48.png delete mode 100644 examples/declarative/gridview/pics/TodoList_48.png delete mode 100644 examples/declarative/gridview/pics/VideoPlayer_48.png create mode 100644 examples/declarative/i18n/i18n.qmlproject create mode 100644 examples/declarative/imageelements/borderimage/borderimage.qml create mode 100644 examples/declarative/imageelements/borderimage/borderimage.qmlproject create mode 100644 examples/declarative/imageelements/borderimage/content/MyBorderImage.qml create mode 100644 examples/declarative/imageelements/borderimage/content/ShadowRectangle.qml create mode 100644 examples/declarative/imageelements/borderimage/content/bw.png create mode 100644 examples/declarative/imageelements/borderimage/content/colors-round.sci create mode 100644 examples/declarative/imageelements/borderimage/content/colors-stretch.sci create mode 100644 examples/declarative/imageelements/borderimage/content/colors.png create mode 100644 examples/declarative/imageelements/borderimage/content/shadow.png create mode 100644 examples/declarative/imageelements/borderimage/shadows.qml create mode 100644 examples/declarative/imageelements/image/face_fit.qml create mode 100644 examples/declarative/imageelements/image/face_fit_animated.qml create mode 100644 examples/declarative/imageelements/image/image.qmlproject create mode 100644 examples/declarative/imageelements/image/pics/face.png create mode 100644 examples/declarative/imageelements/image/scale_and_crop.qml create mode 100644 examples/declarative/imageelements/image/scale_and_crop_simple.qml create mode 100644 examples/declarative/imageelements/image/scale_and_sidecrop.qml create mode 100644 examples/declarative/imageelements/image/scale_to_fit.qml create mode 100644 examples/declarative/imageelements/image/scale_to_fit_simple.qml create mode 100644 examples/declarative/imageelements/imageelements.qmlproject delete mode 100644 examples/declarative/imageprovider/ImageProviderCore/qmldir delete mode 100644 examples/declarative/imageprovider/imageprovider-example.qml delete mode 100644 examples/declarative/imageprovider/imageprovider.cpp delete mode 100644 examples/declarative/imageprovider/imageprovider.pro delete mode 100644 examples/declarative/imageprovider/imageprovider.qmlproject delete mode 100644 examples/declarative/images/content/lemonade.jpg delete mode 100644 examples/declarative/images/images.qml delete mode 100644 examples/declarative/images/images.qmlproject create mode 100644 examples/declarative/keyinteraction/focus/Core/ContextMenu.qml create mode 100644 examples/declarative/keyinteraction/focus/Core/GridMenu.qml create mode 100644 examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml create mode 100644 examples/declarative/keyinteraction/focus/Core/ListViews.qml create mode 100644 examples/declarative/keyinteraction/focus/Core/images/arrow.png create mode 100644 examples/declarative/keyinteraction/focus/Core/images/qt-logo.png create mode 100644 examples/declarative/keyinteraction/focus/Core/qmldir create mode 100644 examples/declarative/keyinteraction/focus/focus.qml create mode 100644 examples/declarative/keyinteraction/focus/focus.qmlproject create mode 100644 examples/declarative/keyinteraction/keyinteraction.qmlproject delete mode 100644 examples/declarative/layouts/graphicsLayouts/graphicslayouts.cpp delete mode 100644 examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro delete mode 100644 examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml delete mode 100644 examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc delete mode 100644 examples/declarative/layouts/graphicsLayouts/graphicslayouts_p.h delete mode 100644 examples/declarative/layouts/graphicsLayouts/main.cpp delete mode 100644 examples/declarative/layouts/layoutItem/layoutItem.pro delete mode 100644 examples/declarative/layouts/layoutItem/layoutItem.qml delete mode 100644 examples/declarative/layouts/layoutItem/layoutItem.qrc delete mode 100644 examples/declarative/layouts/layoutItem/main.cpp delete mode 100644 examples/declarative/layouts/positioners/Button.qml delete mode 100644 examples/declarative/layouts/positioners/add.png delete mode 100644 examples/declarative/layouts/positioners/del.png delete mode 100644 examples/declarative/layouts/positioners/positioners.qml delete mode 100644 examples/declarative/layouts/positioners/positioners.qmlproject delete mode 100644 examples/declarative/layouts/positioners/positioners.qmlproject.user delete mode 100644 examples/declarative/listmodel-threaded/dataloader.js delete mode 100644 examples/declarative/listmodel-threaded/listmodel-threaded.qmlproject delete mode 100644 examples/declarative/listmodel-threaded/timedisplay.qml delete mode 100644 examples/declarative/listview/content/ClickAutoRepeating.qml delete mode 100644 examples/declarative/listview/content/MediaButton.qml delete mode 100644 examples/declarative/listview/content/pics/add.png delete mode 100644 examples/declarative/listview/content/pics/archive-insert.png delete mode 100644 examples/declarative/listview/content/pics/archive-remove.png delete mode 100644 examples/declarative/listview/content/pics/button-pressed.png delete mode 100644 examples/declarative/listview/content/pics/button.png delete mode 100644 examples/declarative/listview/content/pics/del.png delete mode 100644 examples/declarative/listview/content/pics/fruit-salad.jpg delete mode 100644 examples/declarative/listview/content/pics/go-down.png delete mode 100644 examples/declarative/listview/content/pics/go-up.png delete mode 100644 examples/declarative/listview/content/pics/hamburger.jpg delete mode 100644 examples/declarative/listview/content/pics/lemonade.jpg delete mode 100644 examples/declarative/listview/content/pics/list-add.png delete mode 100644 examples/declarative/listview/content/pics/list-remove.png delete mode 100644 examples/declarative/listview/content/pics/moreDown.png delete mode 100644 examples/declarative/listview/content/pics/moreUp.png delete mode 100644 examples/declarative/listview/content/pics/pancakes.jpg delete mode 100644 examples/declarative/listview/content/pics/trash.png delete mode 100644 examples/declarative/listview/content/pics/vegetable-soup.jpg delete mode 100644 examples/declarative/listview/dummydata/MyPetsModel.qml delete mode 100644 examples/declarative/listview/dummydata/Recipes.qml delete mode 100644 examples/declarative/listview/dynamic.qml delete mode 100644 examples/declarative/listview/highlight.qml delete mode 100644 examples/declarative/listview/itemlist.qml delete mode 100644 examples/declarative/listview/listview-example.qml delete mode 100644 examples/declarative/listview/listview.qmlproject delete mode 100644 examples/declarative/listview/recipes.qml delete mode 100644 examples/declarative/listview/sections.qml create mode 100644 examples/declarative/modelviews/gridview/gridview-example.qml create mode 100644 examples/declarative/modelviews/gridview/gridview.qmlproject create mode 100644 examples/declarative/modelviews/gridview/pics/AddressBook_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/Camera_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/DateBook_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/EMail_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/TodoList_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png create mode 100644 examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml create mode 100644 examples/declarative/modelviews/listview/content/MediaButton.qml create mode 100644 examples/declarative/modelviews/listview/content/pics/add.png create mode 100644 examples/declarative/modelviews/listview/content/pics/archive-insert.png create mode 100644 examples/declarative/modelviews/listview/content/pics/archive-remove.png create mode 100644 examples/declarative/modelviews/listview/content/pics/button-pressed.png create mode 100644 examples/declarative/modelviews/listview/content/pics/button.png create mode 100644 examples/declarative/modelviews/listview/content/pics/del.png create mode 100644 examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg create mode 100644 examples/declarative/modelviews/listview/content/pics/go-down.png create mode 100644 examples/declarative/modelviews/listview/content/pics/go-up.png create mode 100644 examples/declarative/modelviews/listview/content/pics/hamburger.jpg create mode 100644 examples/declarative/modelviews/listview/content/pics/lemonade.jpg create mode 100644 examples/declarative/modelviews/listview/content/pics/list-add.png create mode 100644 examples/declarative/modelviews/listview/content/pics/list-remove.png create mode 100644 examples/declarative/modelviews/listview/content/pics/moreDown.png create mode 100644 examples/declarative/modelviews/listview/content/pics/moreUp.png create mode 100644 examples/declarative/modelviews/listview/content/pics/pancakes.jpg create mode 100644 examples/declarative/modelviews/listview/content/pics/trash.png create mode 100644 examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg create mode 100644 examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml create mode 100644 examples/declarative/modelviews/listview/dummydata/Recipes.qml create mode 100644 examples/declarative/modelviews/listview/dynamic.qml create mode 100644 examples/declarative/modelviews/listview/highlight.qml create mode 100644 examples/declarative/modelviews/listview/itemlist.qml create mode 100644 examples/declarative/modelviews/listview/listview-example.qml create mode 100644 examples/declarative/modelviews/listview/listview.qmlproject create mode 100644 examples/declarative/modelviews/listview/recipes.qml create mode 100644 examples/declarative/modelviews/listview/sections.qml create mode 100644 examples/declarative/modelviews/modelviews.pro create mode 100644 examples/declarative/modelviews/modelviews.qmlproject create mode 100644 examples/declarative/modelviews/objectlistmodel/dataobject.cpp create mode 100644 examples/declarative/modelviews/objectlistmodel/dataobject.h create mode 100644 examples/declarative/modelviews/objectlistmodel/main.cpp create mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro create mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject create mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc create mode 100644 examples/declarative/modelviews/objectlistmodel/view.qml create mode 100644 examples/declarative/modelviews/package/Delegate.qml create mode 100644 examples/declarative/modelviews/package/package.qmlproject create mode 100644 examples/declarative/modelviews/package/view.qml create mode 100644 examples/declarative/modelviews/parallax/parallax.qml create mode 100644 examples/declarative/modelviews/parallax/parallax.qmlproject create mode 100644 examples/declarative/modelviews/parallax/pics/background.jpg create mode 100644 examples/declarative/modelviews/parallax/pics/face-smile.png create mode 100644 examples/declarative/modelviews/parallax/pics/home-page.svg create mode 100644 examples/declarative/modelviews/parallax/pics/shadow.png create mode 100644 examples/declarative/modelviews/parallax/pics/yast-joystick.png create mode 100644 examples/declarative/modelviews/parallax/pics/yast-wol.png create mode 100644 examples/declarative/modelviews/parallax/qml/ParallaxView.qml create mode 100644 examples/declarative/modelviews/parallax/qml/Smiley.qml create mode 100644 examples/declarative/modelviews/stringlistmodel/main.cpp create mode 100644 examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro create mode 100644 examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc create mode 100644 examples/declarative/modelviews/stringlistmodel/view.qml create mode 100644 examples/declarative/modelviews/webview/alerts.html create mode 100644 examples/declarative/modelviews/webview/alerts.qml create mode 100644 examples/declarative/modelviews/webview/autosize.qml create mode 100644 examples/declarative/modelviews/webview/content/FieldText.qml create mode 100644 examples/declarative/modelviews/webview/content/Mapping/Map.qml create mode 100755 examples/declarative/modelviews/webview/content/Mapping/map.html create mode 100644 examples/declarative/modelviews/webview/content/SpinSquare.qml create mode 100644 examples/declarative/modelviews/webview/content/pics/cancel.png create mode 100644 examples/declarative/modelviews/webview/content/pics/ok.png create mode 100644 examples/declarative/modelviews/webview/googleMaps.qml create mode 100644 examples/declarative/modelviews/webview/inline-html.qml create mode 100644 examples/declarative/modelviews/webview/newwindows.html create mode 100644 examples/declarative/modelviews/webview/newwindows.qml create mode 100644 examples/declarative/modelviews/webview/transparent.qml create mode 100644 examples/declarative/modelviews/webview/webview.qmlproject delete mode 100644 examples/declarative/mousearea/mouse.qml delete mode 100644 examples/declarative/mousearea/mousearea.qmlproject delete mode 100644 examples/declarative/objectlistmodel/dataobject.cpp delete mode 100644 examples/declarative/objectlistmodel/dataobject.h delete mode 100644 examples/declarative/objectlistmodel/main.cpp delete mode 100644 examples/declarative/objectlistmodel/objectlistmodel.pro delete mode 100644 examples/declarative/objectlistmodel/objectlistmodel.qmlproject delete mode 100644 examples/declarative/objectlistmodel/objectlistmodel.qrc delete mode 100644 examples/declarative/objectlistmodel/view.qml delete mode 100644 examples/declarative/package/Delegate.qml delete mode 100644 examples/declarative/package/package.qmlproject delete mode 100644 examples/declarative/package/view.qml delete mode 100644 examples/declarative/parallax/parallax.qml delete mode 100644 examples/declarative/parallax/parallax.qmlproject delete mode 100644 examples/declarative/parallax/pics/background.jpg delete mode 100644 examples/declarative/parallax/pics/face-smile.png delete mode 100644 examples/declarative/parallax/pics/home-page.svg delete mode 100644 examples/declarative/parallax/pics/shadow.png delete mode 100644 examples/declarative/parallax/pics/yast-joystick.png delete mode 100644 examples/declarative/parallax/pics/yast-wol.png delete mode 100644 examples/declarative/parallax/qml/ParallaxView.qml delete mode 100644 examples/declarative/parallax/qml/Smiley.qml delete mode 100644 examples/declarative/plugins/README delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/Clock.qml delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/center.png delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/clock.png delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/hour.png delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/minute.png delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/qmldir delete mode 100644 examples/declarative/plugins/plugin.cpp delete mode 100644 examples/declarative/plugins/plugins.pro delete mode 100644 examples/declarative/plugins/plugins.qml delete mode 100644 examples/declarative/plugins/plugins.qmlproject create mode 100644 examples/declarative/positioners/Button.qml create mode 100644 examples/declarative/positioners/add.png create mode 100644 examples/declarative/positioners/del.png create mode 100644 examples/declarative/positioners/positioners.qml create mode 100644 examples/declarative/positioners/positioners.qmlproject create mode 100644 examples/declarative/positioners/positioners.qmlproject.user delete mode 100644 examples/declarative/progressbar/content/ProgressBar.qml delete mode 100644 examples/declarative/progressbar/content/background.png delete mode 100644 examples/declarative/progressbar/progressbar.qmlproject delete mode 100644 examples/declarative/progressbar/progressbars.qml delete mode 100644 examples/declarative/proxyviewer/main.cpp delete mode 100644 examples/declarative/proxyviewer/proxyviewer.pro delete mode 100644 examples/declarative/proxyviewer/proxyviewer.qrc delete mode 100644 examples/declarative/proxyviewer/view.qml delete mode 100644 examples/declarative/proxywidgets/ProxyWidgets/qmldir delete mode 100644 examples/declarative/proxywidgets/README delete mode 100644 examples/declarative/proxywidgets/proxywidgets.cpp delete mode 100644 examples/declarative/proxywidgets/proxywidgets.pro delete mode 100644 examples/declarative/proxywidgets/proxywidgets.qml delete mode 100644 examples/declarative/proxywidgets/proxywidgets.qmlproject delete mode 100644 examples/declarative/scrollbar/ScrollBar.qml delete mode 100644 examples/declarative/scrollbar/display.qml delete mode 100644 examples/declarative/scrollbar/pics/niagara_falls.jpg delete mode 100644 examples/declarative/scrollbar/scrollbar.qmlproject delete mode 100644 examples/declarative/searchbox/SearchBox.qml delete mode 100644 examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png delete mode 100644 examples/declarative/searchbox/images/lineedit-bg-focus.png delete mode 100644 examples/declarative/searchbox/images/lineedit-bg.png delete mode 100644 examples/declarative/searchbox/main.qml delete mode 100644 examples/declarative/searchbox/searchbox.qmlproject delete mode 100644 examples/declarative/slideswitch/content/Switch.qml delete mode 100644 examples/declarative/slideswitch/content/background.svg delete mode 100644 examples/declarative/slideswitch/content/knob.svg delete mode 100644 examples/declarative/slideswitch/slideswitch.qml delete mode 100644 examples/declarative/slideswitch/slideswitch.qmlproject delete mode 100644 examples/declarative/spinner/content/Spinner.qml delete mode 100644 examples/declarative/spinner/content/spinner-bg.png delete mode 100644 examples/declarative/spinner/content/spinner-select.png delete mode 100644 examples/declarative/spinner/main.qml delete mode 100644 examples/declarative/spinner/spinner.qmlproject delete mode 100644 examples/declarative/sql/hello.qml delete mode 100644 examples/declarative/sql/sql.qmlproject create mode 100644 examples/declarative/sqllocalstorage/hello.qml create mode 100644 examples/declarative/sqllocalstorage/sqllocalstorage.qmlproject delete mode 100644 examples/declarative/states/states.qml delete mode 100644 examples/declarative/states/states.qmlproject delete mode 100644 examples/declarative/states/transitions.qml delete mode 100644 examples/declarative/states/user.png delete mode 100644 examples/declarative/stringlistmodel/main.cpp delete mode 100644 examples/declarative/stringlistmodel/stringlistmodel.pro delete mode 100644 examples/declarative/stringlistmodel/stringlistmodel.qrc delete mode 100644 examples/declarative/stringlistmodel/view.qml delete mode 100644 examples/declarative/tabwidget/TabWidget.qml delete mode 100644 examples/declarative/tabwidget/tab.png delete mode 100644 examples/declarative/tabwidget/tabs.qml delete mode 100644 examples/declarative/tabwidget/tabwidget.qmlproject create mode 100644 examples/declarative/text/fonts/availableFonts.qml create mode 100644 examples/declarative/text/fonts/banner.qml create mode 100644 examples/declarative/text/fonts/fonts.qml create mode 100644 examples/declarative/text/fonts/fonts.qmlproject create mode 100644 examples/declarative/text/fonts/fonts/tarzeau_ocr_a.ttf create mode 100644 examples/declarative/text/fonts/hello.qml create mode 100644 examples/declarative/text/text.qmlproject create mode 100644 examples/declarative/threading/threadedlistmodel/dataloader.js create mode 100644 examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject create mode 100644 examples/declarative/threading/threadedlistmodel/timedisplay.qml create mode 100644 examples/declarative/threading/threading.qmlproject create mode 100644 examples/declarative/threading/workerscript/workerscript.js create mode 100644 examples/declarative/threading/workerscript/workerscript.qml create mode 100644 examples/declarative/threading/workerscript/workerscript.qmlproject delete mode 100644 examples/declarative/tic-tac-toe/content/Button.qml delete mode 100644 examples/declarative/tic-tac-toe/content/TicTac.qml delete mode 100644 examples/declarative/tic-tac-toe/content/pics/board.png delete mode 100644 examples/declarative/tic-tac-toe/content/pics/o.png delete mode 100644 examples/declarative/tic-tac-toe/content/pics/x.png delete mode 100644 examples/declarative/tic-tac-toe/content/tic-tac-toe.js delete mode 100644 examples/declarative/tic-tac-toe/tic-tac-toe.qml delete mode 100644 examples/declarative/tic-tac-toe/tic-tac-toe.qmlproject create mode 100644 examples/declarative/touchinteraction/gestures/experimental-gestures.qml create mode 100644 examples/declarative/touchinteraction/gestures/gestures.qmlproject create mode 100644 examples/declarative/touchinteraction/mousearea/mouse.qml create mode 100644 examples/declarative/touchinteraction/mousearea/mousearea.qmlproject create mode 100644 examples/declarative/touchinteraction/touchinteraction.qmlproject create mode 100644 examples/declarative/toys/clocks/clocks.qml create mode 100644 examples/declarative/toys/clocks/clocks.qmlproject create mode 100644 examples/declarative/toys/clocks/content/Clock.qml create mode 100644 examples/declarative/toys/clocks/content/background.png create mode 100755 examples/declarative/toys/clocks/content/center.png create mode 100755 examples/declarative/toys/clocks/content/clock-night.png create mode 100755 examples/declarative/toys/clocks/content/clock.png create mode 100755 examples/declarative/toys/clocks/content/hour.png create mode 100755 examples/declarative/toys/clocks/content/minute.png create mode 100755 examples/declarative/toys/clocks/content/second.png create mode 100644 examples/declarative/toys/dial/content/Dial.qml create mode 100644 examples/declarative/toys/dial/content/background.png create mode 100644 examples/declarative/toys/dial/content/needle.png create mode 100644 examples/declarative/toys/dial/content/needle_shadow.png create mode 100644 examples/declarative/toys/dial/content/overlay.png create mode 100644 examples/declarative/toys/dial/dial-example.qml create mode 100644 examples/declarative/toys/dial/dial.qmlproject create mode 100644 examples/declarative/toys/dynamic/dynamic.qml create mode 100644 examples/declarative/toys/dynamic/dynamic.qmlproject create mode 100644 examples/declarative/toys/dynamic/images/NOTE create mode 100644 examples/declarative/toys/dynamic/images/face-smile.png create mode 100644 examples/declarative/toys/dynamic/images/moon.png create mode 100644 examples/declarative/toys/dynamic/images/rabbit_brown.png create mode 100644 examples/declarative/toys/dynamic/images/rabbit_bw.png create mode 100644 examples/declarative/toys/dynamic/images/star.png create mode 100644 examples/declarative/toys/dynamic/images/sun.png create mode 100644 examples/declarative/toys/dynamic/images/tree_s.png create mode 100644 examples/declarative/toys/dynamic/qml/Button.qml create mode 100644 examples/declarative/toys/dynamic/qml/PaletteItem.qml create mode 100644 examples/declarative/toys/dynamic/qml/PerspectiveItem.qml create mode 100644 examples/declarative/toys/dynamic/qml/Sun.qml create mode 100644 examples/declarative/toys/dynamic/qml/itemCreation.js create mode 100644 examples/declarative/toys/tic-tac-toe/content/Button.qml create mode 100644 examples/declarative/toys/tic-tac-toe/content/TicTac.qml create mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/board.png create mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/o.png create mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/x.png create mode 100644 examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js create mode 100644 examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml create mode 100644 examples/declarative/toys/tic-tac-toe/tic-tac-toe.qmlproject create mode 100644 examples/declarative/toys/toys.qmlproject create mode 100644 examples/declarative/toys/tvtennis/tvtennis.qml create mode 100644 examples/declarative/toys/tvtennis/tvtennis.qmlproject create mode 100644 examples/declarative/toys/velocity/Day.qml create mode 100644 examples/declarative/toys/velocity/cork.jpg create mode 100644 examples/declarative/toys/velocity/note-yellow.png create mode 100644 examples/declarative/toys/velocity/tack.png create mode 100644 examples/declarative/toys/velocity/velocity.qml create mode 100644 examples/declarative/toys/velocity/velocity.qmlproject create mode 100644 examples/declarative/tutorials/extending/extending.pro create mode 100644 examples/declarative/tutorials/tutorials.pro delete mode 100644 examples/declarative/tvtennis/tvtennis.qml delete mode 100644 examples/declarative/tvtennis/tvtennis.qmlproject create mode 100644 examples/declarative/ui-components/flipable/content/5_heart.png create mode 100644 examples/declarative/ui-components/flipable/content/9_club.png create mode 100644 examples/declarative/ui-components/flipable/content/Card.qml create mode 100644 examples/declarative/ui-components/flipable/content/back.png create mode 100644 examples/declarative/ui-components/flipable/flipable-example.qml create mode 100644 examples/declarative/ui-components/flipable/flipable.qmlproject create mode 100644 examples/declarative/ui-components/progressbar/content/ProgressBar.qml create mode 100644 examples/declarative/ui-components/progressbar/content/background.png create mode 100644 examples/declarative/ui-components/progressbar/progressbar.qmlproject create mode 100644 examples/declarative/ui-components/progressbar/progressbars.qml create mode 100644 examples/declarative/ui-components/scrollbar/ScrollBar.qml create mode 100644 examples/declarative/ui-components/scrollbar/display.qml create mode 100644 examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg create mode 100644 examples/declarative/ui-components/scrollbar/scrollbar.qmlproject create mode 100644 examples/declarative/ui-components/searchbox/SearchBox.qml create mode 100644 examples/declarative/ui-components/searchbox/images/edit-clear-locationbar-rtl.png create mode 100644 examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png create mode 100644 examples/declarative/ui-components/searchbox/images/lineedit-bg.png create mode 100644 examples/declarative/ui-components/searchbox/main.qml create mode 100644 examples/declarative/ui-components/searchbox/searchbox.qmlproject create mode 100644 examples/declarative/ui-components/slideswitch/content/Switch.qml create mode 100644 examples/declarative/ui-components/slideswitch/content/background.svg create mode 100644 examples/declarative/ui-components/slideswitch/content/knob.svg create mode 100644 examples/declarative/ui-components/slideswitch/slideswitch.qml create mode 100644 examples/declarative/ui-components/slideswitch/slideswitch.qmlproject create mode 100644 examples/declarative/ui-components/spinner/content/Spinner.qml create mode 100644 examples/declarative/ui-components/spinner/content/spinner-bg.png create mode 100644 examples/declarative/ui-components/spinner/content/spinner-select.png create mode 100644 examples/declarative/ui-components/spinner/main.qml create mode 100644 examples/declarative/ui-components/spinner/spinner.qmlproject create mode 100644 examples/declarative/ui-components/tabwidget/TabWidget.qml create mode 100644 examples/declarative/ui-components/tabwidget/tab.png create mode 100644 examples/declarative/ui-components/tabwidget/tabs.qml create mode 100644 examples/declarative/ui-components/tabwidget/tabwidget.qmlproject create mode 100644 examples/declarative/ui-components/ui-components.qmlproject delete mode 100644 examples/declarative/velocity/Day.qml delete mode 100644 examples/declarative/velocity/cork.jpg delete mode 100644 examples/declarative/velocity/note-yellow.png delete mode 100644 examples/declarative/velocity/tack.png delete mode 100644 examples/declarative/velocity/velocity.qml delete mode 100644 examples/declarative/velocity/velocity.qmlproject delete mode 100644 examples/declarative/webview/alerts.html delete mode 100644 examples/declarative/webview/alerts.qml delete mode 100644 examples/declarative/webview/autosize.qml delete mode 100644 examples/declarative/webview/content/FieldText.qml delete mode 100644 examples/declarative/webview/content/Mapping/Map.qml delete mode 100755 examples/declarative/webview/content/Mapping/map.html delete mode 100644 examples/declarative/webview/content/SpinSquare.qml delete mode 100644 examples/declarative/webview/content/pics/cancel.png delete mode 100644 examples/declarative/webview/content/pics/ok.png delete mode 100644 examples/declarative/webview/googleMaps.qml delete mode 100644 examples/declarative/webview/inline-html.qml delete mode 100644 examples/declarative/webview/newwindows.html delete mode 100644 examples/declarative/webview/newwindows.qml delete mode 100644 examples/declarative/webview/transparent.qml delete mode 100644 examples/declarative/webview/webview.qmlproject delete mode 100644 examples/declarative/workerscript/workerscript.js delete mode 100644 examples/declarative/workerscript/workerscript.qml delete mode 100644 examples/declarative/workerscript/workerscript.qmlproject create mode 100644 examples/declarative/xml/xml.qmlproject create mode 100644 examples/declarative/xml/xmldata/daringfireball.qml create mode 100644 examples/declarative/xml/xmldata/xmldata.qmlproject create mode 100644 examples/declarative/xml/xmldata/yahoonews.qml create mode 100644 examples/declarative/xml/xmlhttprequest/test.qml create mode 100644 examples/declarative/xml/xmlhttprequest/test.xml create mode 100644 examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject delete mode 100644 examples/declarative/xmldata/daringfireball.qml delete mode 100644 examples/declarative/xmldata/xmldata.qmlproject delete mode 100644 examples/declarative/xmldata/yahoonews.qml delete mode 100644 examples/declarative/xmlhttprequest/test.qml delete mode 100644 examples/declarative/xmlhttprequest/test.xml delete mode 100644 examples/declarative/xmlhttprequest/xmlhttprequest.qmlproject diff --git a/doc/src/declarative/example-slideswitch.qdoc b/doc/src/declarative/example-slideswitch.qdoc index c14208e..27b7f38 100644 --- a/doc/src/declarative/example-slideswitch.qdoc +++ b/doc/src/declarative/example-slideswitch.qdoc @@ -45,7 +45,7 @@ This example shows how to create a reusable switch component in QML. -The code for this example can be found in the \c $QTDIR/examples/declarative/slideswitch directory. +The code for this example can be found in the \c $QTDIR/examples/declarative/ui-components/slideswitch directory. \section1 Overview @@ -61,12 +61,12 @@ The elements that composed the switch are: \endlist \section1 Switch.qml -\snippet examples/declarative/slideswitch/content/Switch.qml 0 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 0 \section1 Walkthrough \section2 Interface -\snippet examples/declarative/slideswitch/content/Switch.qml 1 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 1 This property is the interface of the switch. By default, the switch is off and this property is \c false. It can be used to activate/disactivate the switch or to query its current state. @@ -81,14 +81,14 @@ Text { text: "The switch is on"; visible: mySwitch.on == true } the text will only be visible when the switch is on. \section2 Images and user interaction -\snippet examples/declarative/slideswitch/content/Switch.qml 4 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 4 First, we create the background image of the switch. In order for the switch to toggle when the user clicks on the background, we add a \l{MouseArea} as a child item of the image. A \c MouseArea has a \c onClicked property that is triggered when the item is clicked. For the moment we will just call a \c toggle() function. We will see what this function does in a moment. -\snippet examples/declarative/slideswitch/content/Switch.qml 5 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 5 Then, we place the image of the knob on top of the background. The interaction here is a little more complex. We want the knob to move with the finger when it is clicked. That is what the \c drag @@ -96,7 +96,7 @@ property of the \c MouseArea is for. We also want to toggle the switch if the kn in the \c dorelease() function that is called in the \c onReleased property. \section2 States -\snippet examples/declarative/slideswitch/content/Switch.qml 6 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 6 We define the two states of the switch: \list @@ -110,13 +110,13 @@ For more information on states see \l{qmlstates}{QML States}. We add two JavaScript functions to our switch: -\snippet examples/declarative/slideswitch/content/Switch.qml 2 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 2 This first function is called when the background image or the knob are clicked. We simply want the switch to toggle between the two states (\e on and \e off). -\snippet examples/declarative/slideswitch/content/Switch.qml 3 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 3 This second function is called when the knob is released and we want to make sure that the knob does not end up between states (neither \e on nor \e off). If it is the case call the \c toggle() function otherwise we do nothing. @@ -124,7 +124,7 @@ This second function is called when the knob is released and we want to make sur For more information on scripts see \l{Integrating JavaScript}. \section2 Transition -\snippet examples/declarative/slideswitch/content/Switch.qml 7 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 7 At this point, when the switch toggles between the two states the knob will instantly change its \c x position between 1 and 78. In order for the the knob to move smoothly we add a transition that will animate the \c x property with an easing curve for a duration of 200ms. @@ -133,5 +133,5 @@ For more information on transitions see \l{state-transitions}{QML Transitions}. \section1 Usage The switch can be used in a QML file, like this: -\snippet examples/declarative/slideswitch/slideswitch.qml 0 +\snippet examples/declarative/ui-components/slideswitch/slideswitch.qml 0 */ diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index 481617e..cdc308a 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -71,50 +71,92 @@ For example, from your build directory, run: \section1 Examples +\section2 Animation \list -\o \l{declarative/animations}{Animations} -\o \l{declarative/aspectratio}{Aspect Ratio} -\o \l{declarative/behaviors}{Behaviors} -\o \l{declarative/border-image}{Border Image} -\o \l{declarative/clocks}{Clocks} -\o \l{declarative/connections}{Connections} -\o \l{declarative/dial}{Dial} -\o \l{declarative/dynamic}{Dynamic} -\o \l{declarative/extending}{Extending} -\o \l{declarative/fillmode}{Fillmode} -\o \l{declarative/flipable}{Flipable} -\o \l{declarative/focus}{Focus} -\o \l{declarative/fonts}{Fonts} -\o \l{declarative/gridview}{GridView} -\o \l{declarative/imageprovider}{Image Provider} -\o \l{declarative/images}{Images} -\o \l{declarative/layouts}{Layouts} -\o \l{declarative/listmodel-threaded}{ListModel Threaded} -\o \l{declarative/listview}{ListView} -\o \l{declarative/mousearea}{Mouse Area} -\o \l{declarative/objectlistmodel}{Object ListModel} -\o \l{declarative/package}{Package} -\o \l{declarative/parallax}{Parallax} -\o \l{declarative/plugins}{Plugins} -\o \l{declarative/progressbar}{Progress Bars} -\o \l{declarative/proxywidgets}{Proxy Widgets} -\o \l{declarative/scrollbar}{Scrollbar} -\o \l{declarative/searchbox}{Search Box} -\o \l{declarative/slideswitch}{Slide Switch} -\o \l{declarative/sql}{SQL} -\o \l{declarative/states}{States} -\o \l{declarative/stringlistmodel}{String ListModel} -\o \l{declarative/tabwidget}{Tab Widget} -\o \l{declarative/tic-tac-toe}{Tic-Tac-Toe} -\o \l{declarative/tvtennis}{TV Tennis} -\o \l{declarative/velocity}{Velocity} -\o \l{declarative/webview}{WebView} -\o \l{declarative/workerscript}{WorkerScript} -\o \l{declarative/xmldata}{XML Data} -\o \l{declarative/xmlhttprequest}{XMLHttpRequest} +\o \l{declarative/animation/basics}{Basics} +\o \l{declarative/animation/behaviors}{Behaviors} +\o \l{declarative/animation/easing}{Easing} +\o \l{declarative/animation/states}{States} +\endlist + +\section2 Image Elements +\list +\o \l{declarative/imageelements/borderimage}{BorderImage} +\o \l{declarative/imageelements/image}{Image} +\endlist + +\section2 \l{declarative/positioners}{Positioners} + +\section2 Key Interaction +\list +\o \l{declarative/keyinteraction/focus}{Focus} +\endlist +\section2 Touch Interaction +\list +\o \l{declarative/touchinteraction/gestures}{Gestures} +\o \l{declarative/touchinteraction/mousearea}{MouseArea} +\endlist + +\section2 UI Components +\list +\o \l{declarative/ui-components/flipable}{Flipable} +\o \l{declarative/ui-components/progressbar}{Progress bar} +\o \l{declarative/ui-components/scrollbar}{Scroll bar} +\o \l{declarative/ui-components/searchbox}{Search box} +\o \l{declarative/ui-components/slideswitch}{Slide switch} +\o \l{declarative/ui-components/spinner}{Spinner} +\o \l{declarative/ui-components/tabwidget}{Tab widget} \endlist +\section2 Models and Views +\list +\o \l{declarative/modelviews/gridview}{GridView} +\o \l{declarative/modelviews/listview}{ListView} +\o \l{declarative/modelviews/objectlistmodel}{Object list model} +\o \l{declarative/modelviews/package}{Package} +\o \l{declarative/modelviews/parallax}{Parallax} +\o \l{declarative/modelviews/stringlistmodel}{String list model} +\o \l{declarative/modelviews/webview}{WebView} +\endlist + +\section2 XML +\list +\o \l{declarative/xml/xmldata}{XML data} +\o \l{declarative/xml/xmlhttprequest}{XmlHttpRequest} +\endlist + +\section2 \l{declarative/i18n}{Internationalization (i18n)} + +\section2 Threading +\list +\o \l{declarative/threading/threadedlistmodel}{Threaded ListModel} +\o \l{declarative/threading/workerscript}{WorkerScript} +\endlist + +\section2 \l{declarative/sqllocalstorage}{SQL Local Storage} + +\section2 C++ Extensions +\list +\o \l{declarative/cppextensions/referenceexamples}{Reference examples} (discussed in \l {Extending QML in C++}) +\o \l{declarative/cppextensions/plugins}{Plugins} +\o \l{declarative/cppextensions/proxywidgets}{QtWidgets} +\o \l{declarative/cppextensions/qgraphicslayouts}{QGraphicsLayouts} +\o \l{declarative/cppextensions/imageprovider}{Image provider} +\o \l{declarative/cppextensions/proxyviewer}{Network access manager factory} +\endlist + +\section2 Toys +\list +\o \l{declarative/toys/clocks}{Clocks} +\o \l{declarative/toys/dial}{Dial} +\o \l{declarative/toys/dynamic}{Dynamic} +\o \l{declarative/toys/tic-tac-toe}{Tic Tac Toe} +\o \l{declarative/toys/tvtennis}{TV Tennis} +\o \l{declarative/toys/velocity}{Velocity} +\endlist + + \section1 Demos \list @@ -127,3 +169,4 @@ For example, from your build directory, run: \endlist */ + diff --git a/doc/src/declarative/extending-examples.qdoc b/doc/src/declarative/extending-examples.qdoc index 611dac1..577ab78 100644 --- a/doc/src/declarative/extending-examples.qdoc +++ b/doc/src/declarative/extending-examples.qdoc @@ -40,13 +40,13 @@ ****************************************************************************/ /*! -\example declarative/extending/adding +\example declarative/cppextensions/referenceexamples/adding \title Extending QML - Adding Types Example The Adding Types Example shows how to add a new element type, \c Person, to QML. The \c Person type can be used from QML like this: -\snippet examples/declarative/extending/adding/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/adding/example.qml 0 \section1 Declare the Person class @@ -55,11 +55,11 @@ with the two properties we want accessible on the QML type - name and shoeSize. Although in this example we use the same name for the C++ class as the QML element, the C++ class can be named differently, or appear in a namespace. -\snippet examples/declarative/extending/adding/person.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/adding/person.h 0 \section1 Define the Person class -\snippet examples/declarative/extending/adding/person.cpp 0 +\snippet examples/declarative/cppextensions/referenceexamples/adding/person.cpp 0 The Person class implementation is quite basic. The property accessors simply return members of the object instance. @@ -75,7 +75,7 @@ loads and runs the QML snippet shown at the beginning of this page. */ /*! -\example declarative/extending/properties +\example declarative/cppextensions/referenceexamples/properties \title Extending QML - Object and List Property Types Example This example builds on: @@ -88,16 +88,16 @@ properties in QML. This example adds a BirthdayParty element that specifies a birthday party, consisting of a celebrant and a list of guests. People are specified using the People QML type built in the previous example. -\snippet examples/declarative/extending/properties/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/properties/example.qml 0 \section1 Declare the BirthdayParty The BirthdayParty class is declared like this: -\snippet examples/declarative/extending/properties/birthdayparty.h 0 -\snippet examples/declarative/extending/properties/birthdayparty.h 1 -\snippet examples/declarative/extending/properties/birthdayparty.h 2 -\snippet examples/declarative/extending/properties/birthdayparty.h 3 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 1 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 2 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 3 The class contains a member to store the celebrant object, and also a QList member. @@ -114,7 +114,7 @@ scenarios. The implementation of BirthdayParty property accessors is straight forward. -\snippet examples/declarative/extending/properties/birthdayparty.cpp 0 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp 0 \section1 Running the example @@ -123,7 +123,7 @@ loads and runs the QML snippet shown at the beginning of this page. */ /*! -\example declarative/extending/coercion +\example declarative/cppextensions/referenceexamples/coercion \title Extending QML - Inheritance and Coercion Example This example builds on: @@ -136,11 +136,11 @@ The Inheritance and Coercion Example shows how to use base classes to assign elements of more than one type to a property. It specializes the Person element developed in the previous examples into two elements - a \c Boy and a \c Girl. -\snippet examples/declarative/extending/coercion/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/example.qml 0 \section1 Declare Boy and Girl -\snippet examples/declarative/extending/coercion/person.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/person.h 0 The Person class remains unaltered in this example and the Boy and Girl C++ classes are trivial extensions of it. As an example, the inheritance used here @@ -155,7 +155,7 @@ previous example. However, as we have repurposed the People class as a common base for Boy and Girl, we want to prevent it from being instantiated from QML directly - an explicit Boy or Girl should be instantiated instead. -\snippet examples/declarative/extending/coercion/main.cpp 0 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/main.cpp 0 While we want to disallow instantiating Person from within QML, it still needs to be registered with the QML engine, so that it can be used as a property type @@ -165,7 +165,7 @@ and other types can be coerced to it. The implementation of Boy and Girl are trivial. -\snippet examples/declarative/extending/coercion/person.cpp 1 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/person.cpp 1 All that is necessary is to implement the constructor, and to register the types and their QML name with the QML engine. @@ -175,7 +175,7 @@ and their QML name with the QML engine. The BirthdayParty element has not changed since the previous example. The celebrant and guests property still use the People type. -\snippet examples/declarative/extending/coercion/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h 0 However, as all three types, Person, Boy and Girl, have been registered with the QML system, on assignment QML automatically (and type-safely) converts the Boy @@ -186,7 +186,7 @@ loads and runs the QML snippet shown at the beginning of this page. */ /*! -\example declarative/extending/default +\example declarative/cppextensions/referenceexamples/default \title Extending QML - Default Property Example This example builds on: @@ -200,14 +200,14 @@ The Default Property Example is a minor modification of the \l {Extending QML - Inheritance and Coercion Example} that simplifies the specification of a BirthdayParty through the use of a default property. -\snippet examples/declarative/extending/default/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/default/example.qml 0 \section1 Declaring the BirthdayParty class The only difference between this example and the last, is the addition of the \c DefaultProperty class info annotation. -\snippet examples/declarative/extending/default/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h 0 The default property specifies the property to assign to whenever an explicit property is not specified, in the case of the BirthdayParty element the guest @@ -222,7 +222,7 @@ loads and runs the QML snippet shown at the beginning of this page. */ /*! -\example declarative/extending/grouped +\example declarative/cppextensions/referenceexamples/grouped \title Extending QML - Grouped Properties Example This example builds on: @@ -236,7 +236,7 @@ This example builds on: */ /*! -\example declarative/extending/grouped +\example declarative/cppextensions/referenceexamples/grouped \title Extending QML - Attached Properties Example This example builds on: @@ -251,7 +251,7 @@ This example builds on: */ /*! -\example declarative/extending/signal +\example declarative/cppextensions/referenceexamples/signal \title Extending QML - Signal Support Example This example builds on: @@ -267,7 +267,7 @@ This example builds on: */ /*! -\example declarative/extending/valuesource +\example declarative/cppextensions/referenceexamples/valuesource \title Extending QML - Property Value Source Example This example builds on: @@ -284,7 +284,7 @@ This example builds on: */ /*! -\example declarative/extending/binding +\example declarative/cppextensions/referenceexamples/binding \title Extending QML - Binding Example This example builds on: diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 1c159e4..5b695f7 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -56,7 +56,7 @@ QML for their own independent use. \section1 Adding Types \target adding-types -\snippet examples/declarative/extending/adding/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/adding/example.qml 0 The QML snippet shown above instantiates one \c Person instance and sets the \c name and \c shoeSize properties on it. Everything in QML ultimately comes down @@ -121,7 +121,7 @@ the \c Person type. \section1 Object and List Property Types -\snippet examples/declarative/extending/properties/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/properties/example.qml 0 The QML snippet shown above assigns a \c Person object to the \c BirthdayParty's \c host property, and assigns three \c Person objects to the guests property. @@ -136,7 +136,7 @@ Properties that are pointers to objects or Qt interfaces are declared with the Q_PROPERTY() macro, just like other properties. The \c host property declaration looks like this: -\snippet examples/declarative/extending/properties/birthdayparty.h 1 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 1 As long as the property type, in this case \c Person, is registered with QML the property can be assigned. @@ -165,14 +165,14 @@ As with object properties, the type \a T must be registered with QML. The \c guest property declaration looks like this: -\snippet examples/declarative/extending/properties/birthdayparty.h 2 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 2 \l {Extending QML - Object and List Property Types Example} shows the complete code used to create the \c BirthdayParty type. \section1 Inheritance and Coercion -\snippet examples/declarative/extending/coercion/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/example.qml 0 The QML snippet shown above assigns a \c Boy object to the \c BirthdayParty's \c host property, and assigns three other objects to the \c guests property. @@ -214,7 +214,7 @@ code used to create the \c Boy and \c Girl types. \section1 Default Property -\snippet examples/declarative/extending/default/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/default/example.qml 0 The QML snippet shown above assigns a collection of objects to the \c BirthdayParty's default property. @@ -246,7 +246,7 @@ specify a default property. \section1 Grouped Properties -\snippet examples/declarative/extending/grouped/example.qml 1 +\snippet examples/declarative/cppextensions/referenceexamples/grouped/example.qml 1 The QML snippet shown above assigns a number of properties to the \c Boy object, including four properties using the grouped property syntax. @@ -259,7 +259,7 @@ different types through implementation reuse. A grouped property block is implemented as a read-only object property. The \c shoe property shown is declared like this: -\snippet examples/declarative/extending/grouped/person.h 1 +\snippet examples/declarative/cppextensions/referenceexamples/grouped/person.h 1 The \c ShoeDescription type declares the properties available to the grouped property block - in this case the \c size, \c color, \c brand and \c price properties. @@ -271,7 +271,7 @@ implement the \c shoe property grouping. \section1 Attached Properties -\snippet examples/declarative/extending/attached/example.qml 1 +\snippet examples/declarative/cppextensions/referenceexamples/attached/example.qml 1 The QML snippet shown above assigns a date to the \c rsvp property using the attached property syntax. @@ -393,8 +393,8 @@ this situation, but it must not crash. \section1 Signal Support -\snippet examples/declarative/extending/signal/example.qml 0 -\snippet examples/declarative/extending/signal/example.qml 1 +\snippet examples/declarative/cppextensions/referenceexamples/signal/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/signal/example.qml 1 The QML snippet shown above associates the evaluation of a JavaScript expression with the emission of a Qt signal. @@ -406,7 +406,7 @@ signal name: "on" is prepended, and the first letter of the signal name upper cased. For example, the signal used in the example above has the following C++ signature: -\snippet examples/declarative/extending/signal/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h 0 In classes with multiple signals with the same name, only the final signal is accessible as a signal property. Note that signals with the same name @@ -424,8 +424,8 @@ implement the onPartyStarted signal property. \section1 Property Value Sources -\snippet examples/declarative/extending/valuesource/example.qml 0 -\snippet examples/declarative/extending/valuesource/example.qml 1 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/example.qml 1 The QML snippet shown above applies a property value source to the \c announcment property. A property value source generates a value for a property that changes over time. @@ -440,7 +440,7 @@ The example shown here is rather contrived: the \c announcment property of the the \c HappyBirthdaySong value source generates the lyrics of the song "Happy Birthday". -\snippet examples/declarative/extending/valuesource/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h 0 Normally, assigning an object to a string property would not be allowed. In the case of a property value source, rather than assigning the object instance @@ -453,9 +453,9 @@ QDeclarativePropertyValueSource::setTarget(), that the QML engine invokes when associating the property value source with a property. The relevant part of the \c HappyBirthdaySong type declaration looks like this: -\snippet examples/declarative/extending/valuesource/happybirthdaysong.h 0 -\snippet examples/declarative/extending/valuesource/happybirthdaysong.h 1 -\snippet examples/declarative/extending/valuesource/happybirthdaysong.h 2 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h 1 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h 2 In all other respects, property value sources are regular QML types. They must be registered with the QML engine using the same macros as other types, and can @@ -471,8 +471,8 @@ implement the \c HappyBirthdaySong property value source. \section1 Property Binding -\snippet examples/declarative/extending/binding/example.qml 0 -\snippet examples/declarative/extending/binding/example.qml 1 +\snippet examples/declarative/cppextensions/referenceexamples/binding/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/binding/example.qml 1 The QML snippet shown above uses a property binding to ensure the \c HappyBirthdaySong's \c name property remains up to date with the \c host. @@ -492,7 +492,7 @@ the property's value. QML relies on the presence of a Here is the \c host property declaration: -\snippet examples/declarative/extending/binding/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h 0 The NOTIFY attribute is followed by a signal name. It is the responsibility of the class implementer to ensure that whenever the property's value changes, the @@ -531,7 +531,7 @@ subsequently change. The most common case of this is when a type uses only freed when the object is deleted. In these cases, the CONSTANT attribute may be added to the property declaration instead of a NOTIFY signal. -\snippet examples/declarative/extending/binding/person.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/binding/person.h 0 Extreme care must be taken here or applications using your type may misbehave. The CONSTANT attribute should only be used for properties whose value is set, @@ -543,7 +543,7 @@ include NOTIFY signals for use in binding. \section1 Extension Objects -\snippet examples/declarative/extending/extended/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/extended/example.qml 0 The QML snippet shown above adds a new property to an existing C++ type without modifying its source code. diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc index bc9830a..2a83e30 100644 --- a/doc/src/declarative/globalobject.qdoc +++ b/doc/src/declarative/globalobject.qdoc @@ -382,7 +382,7 @@ of QDeclarativeEngine::offlineStoragePath(), currently as SQLite databases. The API can be used from JavaScript functions in your QML: -\quotefile declarative/sql/hello.qml +\quotefile declarative/sqllocalstorage/hello.qml The API conforms to the Synchronous API of the HTML5 Web Database API, \link http://www.w3.org/TR/2009/WD-webdatabase-20091029/ W3C Working Draft 29 October 2009\endlink. diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc index 972976f..83380a1 100644 --- a/doc/src/declarative/integrating.qdoc +++ b/doc/src/declarative/integrating.qdoc @@ -110,7 +110,7 @@ of QML UIs: \section2 Loading QGraphicsWidget objects in QML An alternative approach is to expose your existing QGraphicsWidget objects to -QML and construct your scene in QML instead. See the \l {declarative/layouts/graphicsLayouts}{graphics layouts example} +QML and construct your scene in QML instead. See the \l {declarative/cppextensions/qgraphicslayouts}{graphics layouts example} which shows how to expose Qt's graphics layout classes to QML in order to use QGraphicsWidget with classes like QGraphicsLinearLayout and QGraphicsGridLayout. diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index 93e4a46..22113ee 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -40,79 +40,89 @@ ****************************************************************************/ /*! - \title Animations - \example declarative/animations + \title Animation basics + \example declarative/animation/basics This example shows how to use animations in QML. */ /*! - \title AspectRatio - \example declarative/aspectratio + \title Behaviors + \example declarative/animation/behaviors +*/ - This example shows how to implement different aspect ratios in QML. +/*! + \title Easing types + \example declarative/animation/easing + + This example shows the different easing modes available for animations. */ /*! - \example declarative/behaviors - \title Behaviors + \title States + \example declarative/animation/states */ /*! \title Border Image - \example declarative/border-image + \example declarative/imageelements/borderimage This example shows how to use a BorderImage in QML. */ /*! - \title Clocks - \example declarative/clocks + \title Image + \example declarative/imageelements/image - This example shows how to create a Clock component and reuse it in a grid. + This example shows uses of the \l Image element in QML. */ /*! - \title Connections - \example declarative/connections - - This example shows how to use a Connection element in QML. + \title Reference examples + \example declarative/cppextensions/referenceexamples */ /*! - \title Dial - \example declarative/dial + \title Plugins + \example declarative/cppextensions/plugins +*/ - This example shows how to implement a dial in QML. +/*! + \title QtWidgets + \example declarative/cppextensions/proxywidgets */ /*! - \title Dynamic - \example declarative/dynamic + \title QGraphicsLayouts + \example declarative/cppextensions/qgraphicslayouts +*/ - This example shows how to create dynamic objects QML. +/*! + \title Image Provider + \example declarative/cppextensions/imageprovider */ /*! - \example declarative/extending - \title Extending + \title Network access manager + \example declarative/cppextensions/proxyviewer */ /*! - \example declarative/fillmode - \title Fillmode + \title Internationlization + \example declarative/i18n */ /*! - \title Flipable - \example declarative/flipable + \title Positioners + \example declarative/positioners - This example shows how to use a Flipable element in QML. + This example shows how to use positioner elements such as Row, Column, + Grid and Flow. */ /*! \title Focus - \example declarative/focus + \example declarative/keyinteraction/focus This example shows how to handle keys and focus in QML. @@ -120,141 +130,149 @@ */ /*! - \example declarative/fonts - \title Fonts + \title GridView + \example declarative/modelviews/gridview */ /*! - \example declarative/gridview - \title GridView + \title ListView + \example declarative/modelviews/listview */ /*! - \example declarative/imageprovider - \title Image Provider + \title Object ListModel + \example declarative/modelviews/objectlistmodel */ /*! - \example declarative/images - \title Images + \title Package + \example declarative/modelviews/package */ /*! - \example declarative/layouts - \title Layouts + \title Parallax + \example declarative/modelviews/parallax */ /*! - \example declarative/listmodel-threaded - \title ListModel Threaded + \title String ListModel + \example declarative/modelviews/stringlistmodel */ /*! - \example declarative/listview - \title ListView + \title WebView + \example declarative/modelviews/webview */ /*! - \example declarative/mousearea - \title Mouse Area + \title SQL Local Storage + \example declarative/sqllocalstorage */ /*! - \example declarative/objectlistmodel - \title Object ListModel + \title Fonts + \example declarative/text/fonts */ /*! - \example declarative/package - \title Package + \title Threaded ListModel + \example declarative/threading/threadedlistmodel */ /*! - \example declarative/parallax - \title Parallax + \title WorkerScript + \example declarative/threading/workerscript */ /*! - \example declarative/plugins - \title Plugins + \title Clocks + \example declarative/toys/clocks + + This example shows how to create a Clock component and reuse it in a grid. */ /*! - \example declarative/progressbar - \title Progress Bars + \title Dial + \example declarative/toys/dial + + This example shows how to implement a dial in QML. */ /*! - \example declarative/proxywidgets - \title Proxy Widgets + \title Dynamic + \example declarative/toys/dynamic + + This example shows how to create dynamic objects QML. */ /*! - \example declarative/scrollbar - \title Scrollbar + \title Tic-Tac-Toe + \example declarative/toys/tic-tac-toe */ /*! - \example declarative/searchbox - \title Search Box + \title TV Tennis + \example declarative/toys/tvtennis */ /*! - \example declarative/slideswitch - \title Slide Switch + \title Velocity + \example declarative/toys/velocity */ /*! - \example declarative/sql - \title SQL + \title Gestures + \example declarative/touchinteraction/gestures */ /*! - \example declarative/states - \title States + \title Mouse Area + \example declarative/touchinteraction/mousearea */ /*! - \example declarative/stringlistmodel - \title String ListModel + \title Flipable + \example declarative/ui-components/flipable + + This example shows how to use a Flipable element in QML. */ /*! - \example declarative/tabwidget - \title Tab Widget + \title Progress Bars + \example declarative/ui-components/progressbar */ /*! - \example declarative/tic-tac-toe - \title Tic-Tac-Toe + \title Scrollbar + \example declarative/ui-components/scrollbar */ /*! - \example declarative/tvtennis - \title TV Tennis + \title Search Box + \example declarative/ui-components/searchbox */ /*! - \example declarative/velocity - \title Velocity + \title Slide Switch + \example declarative/ui-components/slideswitch */ /*! - \example declarative/webview - \title WebView + \title Spinner + \example declarative/ui-components/spinner */ /*! - \example declarative/workerscript - \title WorkerScript + \title Tab Widget + \example declarative/ui-components/tabwidget */ /*! - \example declarative/xmldata \title XML Data + \example declarative/xml/xmldata */ /*! - \example declarative/xmlhttprequest \title XMLHttpRequest + \example declarative/xml/xmlhttprequest */ diff --git a/doc/src/snippets/declarative/border-image.qml b/doc/src/snippets/declarative/border-image.qml deleted file mode 100644 index 9c4247e..0000000 --- a/doc/src/snippets/declarative/border-image.qml +++ /dev/null @@ -1,29 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: page - color: "white" - width: 520; height: 280 - - Row { - anchors.centerIn: parent - spacing: 50 -//! [0] -BorderImage { - width: 180; height: 180 - border { left: 30; top: 30; right: 30; bottom: 30 } - horizontalTileMode: BorderImage.Stretch - verticalTileMode: BorderImage.Stretch - source: "content/colors.png" -} - -BorderImage { - width: 180; height: 180 - border { left: 30; top: 30; right: 30; bottom: 30 } - horizontalTileMode: BorderImage.Round - verticalTileMode: BorderImage.Round - source: "content/colors.png" -} -//! [0] - } -} diff --git a/doc/src/snippets/declarative/borderimage.qml b/doc/src/snippets/declarative/borderimage.qml new file mode 100644 index 0000000..9c4247e --- /dev/null +++ b/doc/src/snippets/declarative/borderimage.qml @@ -0,0 +1,29 @@ +import Qt 4.7 + +Rectangle { + id: page + color: "white" + width: 520; height: 280 + + Row { + anchors.centerIn: parent + spacing: 50 +//! [0] +BorderImage { + width: 180; height: 180 + border { left: 30; top: 30; right: 30; bottom: 30 } + horizontalTileMode: BorderImage.Stretch + verticalTileMode: BorderImage.Stretch + source: "content/colors.png" +} + +BorderImage { + width: 180; height: 180 + border { left: 30; top: 30; right: 30; bottom: 30 } + horizontalTileMode: BorderImage.Round + verticalTileMode: BorderImage.Round + source: "content/colors.png" +} +//! [0] + } +} diff --git a/examples/declarative/animation/animation.qmlproject b/examples/declarative/animation/animation.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/animation/animation.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/animation/basics/basics.qmlproject b/examples/declarative/animation/basics/basics.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/animation/basics/basics.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/animation/basics/color-animation.qml b/examples/declarative/animation/basics/color-animation.qml new file mode 100644 index 0000000..61737e9 --- /dev/null +++ b/examples/declarative/animation/basics/color-animation.qml @@ -0,0 +1,70 @@ +import Qt 4.7 +import Qt.labs.particles 1.0 + +Item { + id: window + width: 640; height: 480 + + // Let's draw the sky... + Rectangle { + anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { + position: 0.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 } + ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 } + } + } + GradientStop { + position: 1.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 } + ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 } + } + } + } + } + + // the sun, moon, and stars + Item { + width: parent.width; height: 2 * parent.height + NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite } + Image { + source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter + rotation: -3 * parent.rotation + } + Image { + source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter + rotation: -parent.rotation + } + Particles { + x: 0; y: parent.height/2; width: parent.width; height: parent.height/2 + source: "images/star.png"; angleDeviation: 360; velocity: 0 + velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800 + SequentialAnimation on opacity { + loops: Animation.Infinite + NumberAnimation { from: 0; to: 1; duration: 5000 } + NumberAnimation { from: 1; to: 0; duration: 5000 } + } + } + } + + // ...and the ground. + Rectangle { + anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { + position: 0.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 } + ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 } + } + } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } +} diff --git a/examples/declarative/animation/basics/images/face-smile.png b/examples/declarative/animation/basics/images/face-smile.png new file mode 100644 index 0000000..3d66d72 Binary files /dev/null and b/examples/declarative/animation/basics/images/face-smile.png differ diff --git a/examples/declarative/animation/basics/images/moon.png b/examples/declarative/animation/basics/images/moon.png new file mode 100644 index 0000000..9407b2b Binary files /dev/null and b/examples/declarative/animation/basics/images/moon.png differ diff --git a/examples/declarative/animation/basics/images/shadow.png b/examples/declarative/animation/basics/images/shadow.png new file mode 100644 index 0000000..8270565 Binary files /dev/null and b/examples/declarative/animation/basics/images/shadow.png differ diff --git a/examples/declarative/animation/basics/images/star.png b/examples/declarative/animation/basics/images/star.png new file mode 100644 index 0000000..27ef924 Binary files /dev/null and b/examples/declarative/animation/basics/images/star.png differ diff --git a/examples/declarative/animation/basics/images/sun.png b/examples/declarative/animation/basics/images/sun.png new file mode 100644 index 0000000..7713ca5 Binary files /dev/null and b/examples/declarative/animation/basics/images/sun.png differ diff --git a/examples/declarative/animation/basics/property-animation.qml b/examples/declarative/animation/basics/property-animation.qml new file mode 100644 index 0000000..87ac8ec --- /dev/null +++ b/examples/declarative/animation/basics/property-animation.qml @@ -0,0 +1,63 @@ +import Qt 4.7 + +Item { + id: window + width: 320; height: 480 + + // Let's draw the sky... + Rectangle { + anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { position: 0.0; color: "DeepSkyBlue" } + GradientStop { position: 1.0; color: "LightSkyBlue" } + } + } + + // ...and the ground. + Rectangle { + anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + // The shadow for the smiley face + Image { + anchors.horizontalCenter: parent.horizontalCenter + source: "images/shadow.png"; y: smiley.minHeight + 58 + + // The scale property depends on the y position of the smiley face. + scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) + } + + Image { + id: smiley + property int maxHeight: window.height / 3 + property int minHeight: 2 * window.height / 3 + + anchors.horizontalCenter: parent.horizontalCenter + source: "images/face-smile.png"; y: minHeight + + // Animate the y property. Setting loops to Animation.Infinite makes the + // animation repeat indefinitely, otherwise it would only run once. + SequentialAnimation on y { + loops: Animation.Infinite + + // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function + NumberAnimation { + from: smiley.minHeight; to: smiley.maxHeight + easing.type: Easing.OutExpo; duration: 300 + } + + // Then move back to minHeight in 1 second, using the OutBounce easing function + NumberAnimation { + from: smiley.maxHeight; to: smiley.minHeight + easing.type: Easing.OutBounce; duration: 1000 + } + + // Then pause for 500ms + PauseAnimation { duration: 500 } + } + } +} diff --git a/examples/declarative/animation/behaviors/SideRect.qml b/examples/declarative/animation/behaviors/SideRect.qml new file mode 100644 index 0000000..d32bd7b --- /dev/null +++ b/examples/declarative/animation/behaviors/SideRect.qml @@ -0,0 +1,22 @@ +import Qt 4.7 + +Rectangle { + id: myRect + + property string text + + width: 75; height: 50 + radius: 6 + color: "#646464" + border.width: 4; border.color: "white" + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: { + focusRect.x = myRect.x; + focusRect.y = myRect.y; + focusRect.text = myRect.text; + } + } +} diff --git a/examples/declarative/animation/behaviors/behavior-example.qml b/examples/declarative/animation/behaviors/behavior-example.qml new file mode 100644 index 0000000..1f17b81 --- /dev/null +++ b/examples/declarative/animation/behaviors/behavior-example.qml @@ -0,0 +1,79 @@ +import Qt 4.7 + +Rectangle { + width: 600; height: 400 + color: "#343434" + + Rectangle { + anchors.centerIn: parent + width: 200; height: 200 + radius: 30 + color: "transparent" + border.width: 4; border.color: "white" + + + SideRect { + id: leftRect + anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left } + text: "Left" + } + + SideRect { + id: rightRect + anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right } + text: "Right" + } + + SideRect { + id: topRect + anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter } + text: "Top" + } + + SideRect { + id: bottomRect + anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter } + text: "Bottom" + } + + + Rectangle { + id: focusRect + + property string text + + x: 62.5; y: 75; width: 75; height: 50 + radius: 6 + border.width: 4; border.color: "white" + color: "firebrick" + + // Setting an 'elastic' behavior on the focusRect's x property. + Behavior on x { + NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + // Setting an 'elastic' behavior on the focusRect's y property. + Behavior on y { + NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + Text { + id: focusText + text: focusRect.text + anchors.centerIn: parent + color: "white" + font.pixelSize: 16; font.bold: true + + // Setting a behavior on the focusText's x property: + // Set the opacity to 0, set the new text value, then set the opacity back to 1. + Behavior on text { + SequentialAnimation { + NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } + PropertyAction { } + NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } + } + } + } + } + } +} diff --git a/examples/declarative/animation/behaviors/behaviors.qmlproject b/examples/declarative/animation/behaviors/behaviors.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/animation/behaviors/behaviors.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/animation/easing/easing.qml b/examples/declarative/animation/easing/easing.qml new file mode 100644 index 0000000..939d43b --- /dev/null +++ b/examples/declarative/animation/easing/easing.qml @@ -0,0 +1,105 @@ +import Qt 4.7 + +Rectangle { + id: window + width: 600; height: 460; color: "#232323" + + ListModel { + id: easingTypes + ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" } + ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" } + ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" } + ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" } + ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" } + ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" } + ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" } + ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" } + ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" } + ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" } + ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" } + ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" } + ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" } + ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" } + ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" } + ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" } + ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" } + ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" } + ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" } + ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" } + ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" } + ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" } + ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" } + ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" } + ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" } + ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" } + ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" } + ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" } + ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" } + ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" } + ListElement { name: "Easing.InElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } + ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" } + ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" } + ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" } + ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" } + ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" } + ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" } + ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" } + ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" } + ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" } + ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" } + } + + Component { + id: delegate + + Item { + height: 42; width: window.width + + Text { text: name; anchors.centerIn: parent; color: "White" } + + Rectangle { + id: slot1; color: "#121212"; x: 30; height: 32; width: 32 + border.color: "#343434"; border.width: 1; radius: 8 + anchors.verticalCenter: parent.verticalCenter + } + + Rectangle { + id: slot2; color: "#121212"; x: window.width - 62; height: 32; width: 32 + border.color: "#343434"; border.width: 1; radius: 8 + anchors.verticalCenter: parent.verticalCenter + } + + Rectangle { + id: rect; x: 30; color: "#454545" + border.color: "White"; border.width: 2 + height: 32; width: 32; radius: 8 + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + onClicked: if (rect.state == '') rect.state = "right"; else rect.state = '' + anchors.fill: parent + } + + states : State { + name: "right" + PropertyChanges { target: rect; x: window.width - 62; color: ballColor } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: type; duration: 1000 } + ColorAnimation { properties: "color"; easing.type: type; duration: 1000 } + } + } + } + } + + Flickable { + anchors.fill: parent; contentHeight: layout.height + + Column { + id: layout + anchors.left: parent.left; anchors.right: parent.right + Repeater { model: easingTypes; delegate: delegate } + } + } +} diff --git a/examples/declarative/animation/easing/easing.qmlproject b/examples/declarative/animation/easing/easing.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/animation/easing/easing.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/animation/states/states.qml b/examples/declarative/animation/states/states.qml new file mode 100644 index 0000000..4429e78 --- /dev/null +++ b/examples/declarative/animation/states/states.qml @@ -0,0 +1,61 @@ +import Qt 4.7 + +Rectangle { + id: page + width: 640; height: 480 + color: "#343434" + + Image { + id: userIcon + x: topLeftRect.x; y: topLeftRect.y + source: "user.png" + } + + Rectangle { + id: topLeftRect + + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to the default state, returning the image to + // its initial position + MouseArea { anchors.fill: parent; onClicked: page.state = '' } + } + + Rectangle { + id: middleRightRect + + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'middleRight' + MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } + } + + Rectangle { + id: bottomLeftRect + + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'bottomLeft' + MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } + } + + states: [ + // In state 'middleRight', move the image to middleRightRect + State { + name: "middleRight" + PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } + }, + + // In state 'bottomLeft', move the image to bottomLeftRect + State { + name: "bottomLeft" + PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } + } + ] +} diff --git a/examples/declarative/animation/states/states.qmlproject b/examples/declarative/animation/states/states.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/animation/states/states.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/animation/states/transitions.qml b/examples/declarative/animation/states/transitions.qml new file mode 100644 index 0000000..ccc7060 --- /dev/null +++ b/examples/declarative/animation/states/transitions.qml @@ -0,0 +1,90 @@ +import Qt 4.7 + +/* + This is exactly the same as states.qml, except that we have appended + a set of transitions to apply animations when the item changes + between each state. +*/ + +Rectangle { + id: page + width: 640; height: 480 + color: "#343434" + + Image { + id: userIcon + x: topLeftRect.x; y: topLeftRect.y + source: "user.png" + } + + Rectangle { + id: topLeftRect + + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to the default state, returning the image to + // its initial position + MouseArea { anchors.fill: parent; onClicked: page.state = '' } + } + + Rectangle { + id: middleRightRect + + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'middleRight' + MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } + } + + Rectangle { + id: bottomLeftRect + + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'bottomLeft' + MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } + } + + states: [ + // In state 'middleRight', move the image to middleRightRect + State { + name: "middleRight" + PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } + }, + + // In state 'bottomLeft', move the image to bottomLeftRect + State { + name: "bottomLeft" + PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } + } + ] + + // Transitions define how the properties change when the item moves between each state + transitions: [ + + // When transitioning to 'middleRight' move x,y over a duration of 1 second, + // with OutBounce easing function. + Transition { + from: "*"; to: "middleRight" + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 } + }, + + // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds, + // with InOutQuad easing function. + Transition { + from: "*"; to: "bottomLeft" + NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 } + }, + + // For any other state changes move x,y linearly over duration of 200ms. + Transition { + NumberAnimation { properties: "x,y"; duration: 200 } + } + ] +} diff --git a/examples/declarative/animation/states/user.png b/examples/declarative/animation/states/user.png new file mode 100644 index 0000000..dd7d7a2 Binary files /dev/null and b/examples/declarative/animation/states/user.png differ diff --git a/examples/declarative/animations/animations.qmlproject b/examples/declarative/animations/animations.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/animations/animations.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/animations/color-animation.qml b/examples/declarative/animations/color-animation.qml deleted file mode 100644 index 61737e9..0000000 --- a/examples/declarative/animations/color-animation.qml +++ /dev/null @@ -1,70 +0,0 @@ -import Qt 4.7 -import Qt.labs.particles 1.0 - -Item { - id: window - width: 640; height: 480 - - // Let's draw the sky... - Rectangle { - anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { - position: 0.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 } - ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 } - } - } - GradientStop { - position: 1.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 } - ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 } - } - } - } - } - - // the sun, moon, and stars - Item { - width: parent.width; height: 2 * parent.height - NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite } - Image { - source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter - rotation: -3 * parent.rotation - } - Image { - source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter - rotation: -parent.rotation - } - Particles { - x: 0; y: parent.height/2; width: parent.width; height: parent.height/2 - source: "images/star.png"; angleDeviation: 360; velocity: 0 - velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800 - SequentialAnimation on opacity { - loops: Animation.Infinite - NumberAnimation { from: 0; to: 1; duration: 5000 } - NumberAnimation { from: 1; to: 0; duration: 5000 } - } - } - } - - // ...and the ground. - Rectangle { - anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { - position: 0.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 } - ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 } - } - } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } -} diff --git a/examples/declarative/animations/easing.qml b/examples/declarative/animations/easing.qml deleted file mode 100644 index 939d43b..0000000 --- a/examples/declarative/animations/easing.qml +++ /dev/null @@ -1,105 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: window - width: 600; height: 460; color: "#232323" - - ListModel { - id: easingTypes - ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" } - ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" } - ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" } - ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" } - ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" } - ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" } - ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" } - ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" } - ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" } - ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" } - ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" } - ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" } - ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" } - ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" } - ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" } - ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" } - ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" } - ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" } - ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" } - ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" } - ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" } - ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" } - ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" } - ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" } - ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" } - ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" } - ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" } - ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" } - ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" } - ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" } - ListElement { name: "Easing.InElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } - ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" } - ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" } - ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" } - ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" } - ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" } - ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" } - ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" } - ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" } - ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" } - ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" } - } - - Component { - id: delegate - - Item { - height: 42; width: window.width - - Text { text: name; anchors.centerIn: parent; color: "White" } - - Rectangle { - id: slot1; color: "#121212"; x: 30; height: 32; width: 32 - border.color: "#343434"; border.width: 1; radius: 8 - anchors.verticalCenter: parent.verticalCenter - } - - Rectangle { - id: slot2; color: "#121212"; x: window.width - 62; height: 32; width: 32 - border.color: "#343434"; border.width: 1; radius: 8 - anchors.verticalCenter: parent.verticalCenter - } - - Rectangle { - id: rect; x: 30; color: "#454545" - border.color: "White"; border.width: 2 - height: 32; width: 32; radius: 8 - anchors.verticalCenter: parent.verticalCenter - - MouseArea { - onClicked: if (rect.state == '') rect.state = "right"; else rect.state = '' - anchors.fill: parent - } - - states : State { - name: "right" - PropertyChanges { target: rect; x: window.width - 62; color: ballColor } - } - - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: type; duration: 1000 } - ColorAnimation { properties: "color"; easing.type: type; duration: 1000 } - } - } - } - } - - Flickable { - anchors.fill: parent; contentHeight: layout.height - - Column { - id: layout - anchors.left: parent.left; anchors.right: parent.right - Repeater { model: easingTypes; delegate: delegate } - } - } -} diff --git a/examples/declarative/animations/images/face-smile.png b/examples/declarative/animations/images/face-smile.png deleted file mode 100644 index 3d66d72..0000000 Binary files a/examples/declarative/animations/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/animations/images/moon.png b/examples/declarative/animations/images/moon.png deleted file mode 100644 index 9407b2b..0000000 Binary files a/examples/declarative/animations/images/moon.png and /dev/null differ diff --git a/examples/declarative/animations/images/shadow.png b/examples/declarative/animations/images/shadow.png deleted file mode 100644 index 8270565..0000000 Binary files a/examples/declarative/animations/images/shadow.png and /dev/null differ diff --git a/examples/declarative/animations/images/star.png b/examples/declarative/animations/images/star.png deleted file mode 100644 index 27ef924..0000000 Binary files a/examples/declarative/animations/images/star.png and /dev/null differ diff --git a/examples/declarative/animations/images/sun.png b/examples/declarative/animations/images/sun.png deleted file mode 100644 index 7713ca5..0000000 Binary files a/examples/declarative/animations/images/sun.png and /dev/null differ diff --git a/examples/declarative/animations/property-animation.qml b/examples/declarative/animations/property-animation.qml deleted file mode 100644 index 87ac8ec..0000000 --- a/examples/declarative/animations/property-animation.qml +++ /dev/null @@ -1,63 +0,0 @@ -import Qt 4.7 - -Item { - id: window - width: 320; height: 480 - - // Let's draw the sky... - Rectangle { - anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { position: 0.0; color: "DeepSkyBlue" } - GradientStop { position: 1.0; color: "LightSkyBlue" } - } - } - - // ...and the ground. - Rectangle { - anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - // The shadow for the smiley face - Image { - anchors.horizontalCenter: parent.horizontalCenter - source: "images/shadow.png"; y: smiley.minHeight + 58 - - // The scale property depends on the y position of the smiley face. - scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) - } - - Image { - id: smiley - property int maxHeight: window.height / 3 - property int minHeight: 2 * window.height / 3 - - anchors.horizontalCenter: parent.horizontalCenter - source: "images/face-smile.png"; y: minHeight - - // Animate the y property. Setting loops to Animation.Infinite makes the - // animation repeat indefinitely, otherwise it would only run once. - SequentialAnimation on y { - loops: Animation.Infinite - - // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function - NumberAnimation { - from: smiley.minHeight; to: smiley.maxHeight - easing.type: Easing.OutExpo; duration: 300 - } - - // Then move back to minHeight in 1 second, using the OutBounce easing function - NumberAnimation { - from: smiley.maxHeight; to: smiley.minHeight - easing.type: Easing.OutBounce; duration: 1000 - } - - // Then pause for 500ms - PauseAnimation { duration: 500 } - } - } -} diff --git a/examples/declarative/aspectratio/aspectratio.qmlproject b/examples/declarative/aspectratio/aspectratio.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/aspectratio/aspectratio.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/aspectratio/face_fit.qml b/examples/declarative/aspectratio/face_fit.qml deleted file mode 100644 index 52cd4c2..0000000 --- a/examples/declarative/aspectratio/face_fit.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.7 - -// Here, we implement a hybrid of the "scale to fit" and "scale and crop" -// behaviours which will crop up to 25% from *one* dimension if necessary -// to fully scale the other. This is a realistic algorithm, for example -// when the edges of the image contain less vital information than the -// center - such as a face. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - anchors.centerIn: parent - source: "pics/face.png" - x: (parent.width-width*scale)/2 - y: (parent.height-height*scale)/2 - scale: Math.max(Math.min(parent.width/width*1.333,parent.height/height), - Math.min(parent.width/width,parent.height/height*1.333)) - } -} diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml deleted file mode 100644 index 63fc9c6..0000000 --- a/examples/declarative/aspectratio/face_fit_animated.qml +++ /dev/null @@ -1,28 +0,0 @@ -import Qt 4.7 - -// Here, we extend the "face_fit" example with animation to show how truly -// diverse and usage-specific behaviours are made possible by NOT putting a -// hard-coded aspect ratio feature into the Image primitive. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - anchors.centerIn: parent - source: "pics/face.png" - x: (parent.width-width*scale)/2 - y: (parent.height-height*scale)/2 - SpringFollow on scale { - to: Math.max(Math.min(face.parent.width/face.width*1.333,face.parent.height/face.height), - Math.min(face.parent.width/face.width,face.parent.height/face.height*1.333)) - spring: 1 - damping: 0.05 - } - } -} diff --git a/examples/declarative/aspectratio/pics/face.png b/examples/declarative/aspectratio/pics/face.png deleted file mode 100644 index 3d66d72..0000000 Binary files a/examples/declarative/aspectratio/pics/face.png and /dev/null differ diff --git a/examples/declarative/aspectratio/scale_and_crop.qml b/examples/declarative/aspectratio/scale_and_crop.qml deleted file mode 100644 index a438104..0000000 --- a/examples/declarative/aspectratio/scale_and_crop.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt 4.7 - -// Here, we implement "Scale and Crop" behaviour. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - anchors.centerIn: parent - source: "pics/face.png" - x: (parent.width-width*scale)/2 - y: (parent.height-height*scale)/2 - scale: Math.max(parent.width/width,parent.height/height) - } -} diff --git a/examples/declarative/aspectratio/scale_and_crop_simple.qml b/examples/declarative/aspectratio/scale_and_crop_simple.qml deleted file mode 100644 index 1160ec5..0000000 --- a/examples/declarative/aspectratio/scale_and_crop_simple.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.7 - -// Here, we implement "Scale to Fit" behaviour, using the -// fillMode property. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - source: "pics/face.png" - fillMode: Image.PreserveAspectCrop - anchors.fill: parent - } -} diff --git a/examples/declarative/aspectratio/scale_and_sidecrop.qml b/examples/declarative/aspectratio/scale_and_sidecrop.qml deleted file mode 100644 index 5593ab8..0000000 --- a/examples/declarative/aspectratio/scale_and_sidecrop.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.7 - -// Here, we implement a variant of "Scale and Crop" behaviour, where we -// crop the sides if necessary to fully fit vertically, but not the reverse. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - anchors.centerIn: parent - source: "pics/face.png" - x: (parent.width-width*scale)/2 - y: (parent.height-height*scale)/2 - scale: parent.height/height - } -} diff --git a/examples/declarative/aspectratio/scale_to_fit.qml b/examples/declarative/aspectratio/scale_to_fit.qml deleted file mode 100644 index 724a36e..0000000 --- a/examples/declarative/aspectratio/scale_to_fit.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.7 - -// Here, we implement "Scale to Fit" behaviour "manually", rather -// than using the preserveAspect property. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - anchors.centerIn: parent - source: "pics/face.png" - x: (parent.width-width*scale)/2 - y: (parent.height-height*scale)/2 - scale: Math.min(parent.width/width,parent.height/height) - } -} diff --git a/examples/declarative/aspectratio/scale_to_fit_simple.qml b/examples/declarative/aspectratio/scale_to_fit_simple.qml deleted file mode 100644 index 0e960b4..0000000 --- a/examples/declarative/aspectratio/scale_to_fit_simple.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.7 - -// Here, we implement "Scale to Fit" behaviour, using the -// fillMode property. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - source: "pics/face.png" - fillMode: Image.PreserveAspectFit - anchors.fill: parent - } -} diff --git a/examples/declarative/behaviors/SideRect.qml b/examples/declarative/behaviors/SideRect.qml deleted file mode 100644 index d32bd7b..0000000 --- a/examples/declarative/behaviors/SideRect.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: myRect - - property string text - - width: 75; height: 50 - radius: 6 - color: "#646464" - border.width: 4; border.color: "white" - - MouseArea { - anchors.fill: parent - hoverEnabled: true - onEntered: { - focusRect.x = myRect.x; - focusRect.y = myRect.y; - focusRect.text = myRect.text; - } - } -} diff --git a/examples/declarative/behaviors/behavior-example.qml b/examples/declarative/behaviors/behavior-example.qml deleted file mode 100644 index 1f17b81..0000000 --- a/examples/declarative/behaviors/behavior-example.qml +++ /dev/null @@ -1,79 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 600; height: 400 - color: "#343434" - - Rectangle { - anchors.centerIn: parent - width: 200; height: 200 - radius: 30 - color: "transparent" - border.width: 4; border.color: "white" - - - SideRect { - id: leftRect - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left } - text: "Left" - } - - SideRect { - id: rightRect - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right } - text: "Right" - } - - SideRect { - id: topRect - anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter } - text: "Top" - } - - SideRect { - id: bottomRect - anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter } - text: "Bottom" - } - - - Rectangle { - id: focusRect - - property string text - - x: 62.5; y: 75; width: 75; height: 50 - radius: 6 - border.width: 4; border.color: "white" - color: "firebrick" - - // Setting an 'elastic' behavior on the focusRect's x property. - Behavior on x { - NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } - } - - // Setting an 'elastic' behavior on the focusRect's y property. - Behavior on y { - NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } - } - - Text { - id: focusText - text: focusRect.text - anchors.centerIn: parent - color: "white" - font.pixelSize: 16; font.bold: true - - // Setting a behavior on the focusText's x property: - // Set the opacity to 0, set the new text value, then set the opacity back to 1. - Behavior on text { - SequentialAnimation { - NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } - PropertyAction { } - NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } - } - } - } - } - } -} diff --git a/examples/declarative/behaviors/behaviors.qmlproject b/examples/declarative/behaviors/behaviors.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/behaviors/behaviors.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/border-image/border-image.qml b/examples/declarative/border-image/border-image.qml deleted file mode 100644 index c334cea..0000000 --- a/examples/declarative/border-image/border-image.qml +++ /dev/null @@ -1,57 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - id: page - width: 1030; height: 540 - - Grid { - anchors.centerIn: parent; spacing: 20 - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round - } - } -} diff --git a/examples/declarative/border-image/border-image.qmlproject b/examples/declarative/border-image/border-image.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/border-image/border-image.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/border-image/content/MyBorderImage.qml b/examples/declarative/border-image/content/MyBorderImage.qml deleted file mode 100644 index b47df7b..0000000 --- a/examples/declarative/border-image/content/MyBorderImage.qml +++ /dev/null @@ -1,50 +0,0 @@ -import Qt 4.7 - -Item { - id: container - - property alias horizontalMode: image.horizontalTileMode - property alias verticalMode: image.verticalTileMode - property alias source: image.source - - property int minWidth - property int minHeight - property int maxWidth - property int maxHeight - property int margin - - width: 240; height: 240 - - BorderImage { - id: image; anchors.centerIn: parent - - SequentialAnimation on width { - loops: Animation.Infinite - NumberAnimation { - from: container.minWidth; to: container.maxWidth - duration: 2000; easing.type: Easing.InOutQuad - } - NumberAnimation { - from: container.maxWidth; to: container.minWidth - duration: 2000; easing.type: Easing.InOutQuad - } - } - - SequentialAnimation on height { - loops: Animation.Infinite - NumberAnimation { - from: container.minHeight; to: container.maxHeight - duration: 2000; easing.type: Easing.InOutQuad - } - NumberAnimation { - from: container.maxHeight; to: container.minHeight - duration: 2000; easing.type: Easing.InOutQuad - } - } - - border.top: container.margin - border.left: container.margin - border.bottom: container.margin - border.right: container.margin - } -} diff --git a/examples/declarative/border-image/content/ShadowRectangle.qml b/examples/declarative/border-image/content/ShadowRectangle.qml deleted file mode 100644 index 629478b..0000000 --- a/examples/declarative/border-image/content/ShadowRectangle.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.7 - -Item { - property alias color : rectangle.color - - BorderImage { - anchors.fill: rectangle - anchors { leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } - border { left: 10; top: 10; right: 10; bottom: 10 } - source: "shadow.png"; smooth: true - } - - Rectangle { id: rectangle; anchors.fill: parent } -} diff --git a/examples/declarative/border-image/content/bw.png b/examples/declarative/border-image/content/bw.png deleted file mode 100644 index 486eaae..0000000 Binary files a/examples/declarative/border-image/content/bw.png and /dev/null differ diff --git a/examples/declarative/border-image/content/colors-round.sci b/examples/declarative/border-image/content/colors-round.sci deleted file mode 100644 index 506f6f5..0000000 --- a/examples/declarative/border-image/content/colors-round.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:30 -border.top:30 -border.right:30 -border.bottom:30 -horizontalTileRule:Round -verticalTileRule:Round -source:colors.png diff --git a/examples/declarative/border-image/content/colors-stretch.sci b/examples/declarative/border-image/content/colors-stretch.sci deleted file mode 100644 index e4989a7..0000000 --- a/examples/declarative/border-image/content/colors-stretch.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left:30 -border.top:30 -border.right:30 -border.bottom:30 -source:colors.png diff --git a/examples/declarative/border-image/content/colors.png b/examples/declarative/border-image/content/colors.png deleted file mode 100644 index dfb62f3..0000000 Binary files a/examples/declarative/border-image/content/colors.png and /dev/null differ diff --git a/examples/declarative/border-image/content/shadow.png b/examples/declarative/border-image/content/shadow.png deleted file mode 100644 index 431af85..0000000 Binary files a/examples/declarative/border-image/content/shadow.png and /dev/null differ diff --git a/examples/declarative/border-image/shadows.qml b/examples/declarative/border-image/shadows.qml deleted file mode 100644 index a08d133..0000000 --- a/examples/declarative/border-image/shadows.qml +++ /dev/null @@ -1,24 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "gray" - - ShadowRectangle { - anchors.centerIn: parent; width: 250; height: 250 - color: "lightsteelblue" - } - - ShadowRectangle { - anchors.centerIn: parent; width: 200; height: 200 - color: "steelblue" - } - - ShadowRectangle { - anchors.centerIn: parent; width: 150; height: 150 - color: "thistle" - } -} diff --git a/examples/declarative/clocks/clocks.qml b/examples/declarative/clocks/clocks.qml deleted file mode 100644 index 22cf820..0000000 --- a/examples/declarative/clocks/clocks.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - width: 640; height: 240 - color: "#646464" - - Row { - anchors.centerIn: parent - Clock { city: "New York"; shift: -4 } - Clock { city: "Mumbai"; shift: 5.5 } - Clock { city: "Tokyo"; shift: 9 } - } -} diff --git a/examples/declarative/clocks/clocks.qmlproject b/examples/declarative/clocks/clocks.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/clocks/clocks.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/clocks/content/Clock.qml b/examples/declarative/clocks/content/Clock.qml deleted file mode 100644 index 3426e6a..0000000 --- a/examples/declarative/clocks/content/Clock.qml +++ /dev/null @@ -1,83 +0,0 @@ -import Qt 4.7 - -Item { - id: clock - width: 200; height: 230 - - property alias city: cityLabel.text - property variant hours - property variant minutes - property variant seconds - property variant shift : 0 - property bool night: false - - function timeChanged() { - var date = new Date; - hours = shift ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() - night = ( hours < 7 || hours > 19 ) - minutes = shift ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes() - seconds = date.getUTCSeconds(); - } - - Timer { - interval: 100; running: true; repeat: true; triggeredOnStart: true - onTriggered: clock.timeChanged() - } - - Image { id: background; source: "clock.png"; visible: clock.night == false } - Image { source: "clock-night.png"; visible: clock.night == true } - - Image { - x: 92.5; y: 27 - source: "hour.png" - smooth: true - transform: Rotation { - id: hourRotation - origin.x: 7.5; origin.y: 73; angle: 0 - SpringFollow on angle { - spring: 2; damping: 0.2; modulus: 360 - to: (clock.hours * 30) + (clock.minutes * 0.5) - } - } - } - - Image { - x: 93.5; y: 17 - source: "minute.png" - smooth: true - transform: Rotation { - id: minuteRotation - origin.x: 6.5; origin.y: 83; angle: 0 - SpringFollow on angle { - spring: 2; damping: 0.2; modulus: 360 - to: clock.minutes * 6 - } - } - } - - Image { - x: 97.5; y: 20 - source: "second.png" - smooth: true - transform: Rotation { - id: secondRotation - origin.x: 2.5; origin.y: 80; angle: 0 - SpringFollow on angle { - spring: 5; damping: 0.25; modulus: 360 - to: clock.seconds * 6 - } - } - } - - Image { - anchors.centerIn: background; source: "center.png" - } - - Text { - id: cityLabel - y: 200; anchors.horizontalCenter: parent.horizontalCenter - color: "white" - font.bold: true; font.pixelSize: 14 - style: Text.Raised; styleColor: "black" - } -} diff --git a/examples/declarative/clocks/content/background.png b/examples/declarative/clocks/content/background.png deleted file mode 100644 index a885950..0000000 Binary files a/examples/declarative/clocks/content/background.png and /dev/null differ diff --git a/examples/declarative/clocks/content/center.png b/examples/declarative/clocks/content/center.png deleted file mode 100755 index 7fbd802..0000000 Binary files a/examples/declarative/clocks/content/center.png and /dev/null differ diff --git a/examples/declarative/clocks/content/clock-night.png b/examples/declarative/clocks/content/clock-night.png deleted file mode 100755 index cc7151a..0000000 Binary files a/examples/declarative/clocks/content/clock-night.png and /dev/null differ diff --git a/examples/declarative/clocks/content/clock.png b/examples/declarative/clocks/content/clock.png deleted file mode 100755 index 462edac..0000000 Binary files a/examples/declarative/clocks/content/clock.png and /dev/null differ diff --git a/examples/declarative/clocks/content/hour.png b/examples/declarative/clocks/content/hour.png deleted file mode 100755 index f8061a1..0000000 Binary files a/examples/declarative/clocks/content/hour.png and /dev/null differ diff --git a/examples/declarative/clocks/content/minute.png b/examples/declarative/clocks/content/minute.png deleted file mode 100755 index 1297ec7..0000000 Binary files a/examples/declarative/clocks/content/minute.png and /dev/null differ diff --git a/examples/declarative/clocks/content/second.png b/examples/declarative/clocks/content/second.png deleted file mode 100755 index 4aa9fb5..0000000 Binary files a/examples/declarative/clocks/content/second.png and /dev/null differ diff --git a/examples/declarative/connections/connections-example.qml b/examples/declarative/connections/connections-example.qml deleted file mode 100644 index e65a280..0000000 --- a/examples/declarative/connections/connections-example.qml +++ /dev/null @@ -1,37 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - id: window - - property int angle: 0 - - width: 640; height: 480 - color: "#646464" - - Image { - id: image - source: "content/bg1.jpg" - anchors.centerIn: parent - rotation: window.angle - - Behavior on rotation { - NumberAnimation { easing.type: Easing.OutCubic; duration: 300 } - } - } - - Button { - id: leftButton - image: "content/rotate-left.png" - anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 10 } - } - - Button { - id: rightButton - image: "content/rotate-right.png" - anchors { right: parent.right; bottom: parent.bottom; rightMargin: 10; bottomMargin: 10 } - } - - Connections { target: leftButton; onClicked: window.angle -= 90 } - Connections { target: rightButton; onClicked: window.angle += 90 } -} diff --git a/examples/declarative/connections/connections.qmlproject b/examples/declarative/connections/connections.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/connections/connections.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/connections/content/Button.qml b/examples/declarative/connections/content/Button.qml deleted file mode 100644 index f95afbb..0000000 --- a/examples/declarative/connections/content/Button.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.7 - -Item { - id: button - width: 48; height: 48 - - property alias image: icon.source - signal clicked - - Image { id: icon } - MouseArea { anchors.fill: icon; onClicked: button.clicked() } -} diff --git a/examples/declarative/connections/content/bg1.jpg b/examples/declarative/connections/content/bg1.jpg deleted file mode 100644 index dfc7cee..0000000 Binary files a/examples/declarative/connections/content/bg1.jpg and /dev/null differ diff --git a/examples/declarative/connections/content/rotate-left.png b/examples/declarative/connections/content/rotate-left.png deleted file mode 100644 index c30387e..0000000 Binary files a/examples/declarative/connections/content/rotate-left.png and /dev/null differ diff --git a/examples/declarative/connections/content/rotate-right.png b/examples/declarative/connections/content/rotate-right.png deleted file mode 100644 index 1b05674..0000000 Binary files a/examples/declarative/connections/content/rotate-right.png and /dev/null differ diff --git a/examples/declarative/cppextensions/cppextensions.pro b/examples/declarative/cppextensions/cppextensions.pro new file mode 100644 index 0000000..caa6092 --- /dev/null +++ b/examples/declarative/cppextensions/cppextensions.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + imageprovider \ + plugins \ + proxyviewer \ + proxywidgets \ + qgraphicslayouts \ + referenceexamples + diff --git a/examples/declarative/cppextensions/cppextensions.qmlproject b/examples/declarative/cppextensions/cppextensions.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/cppextensions.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir b/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir new file mode 100644 index 0000000..1028590 --- /dev/null +++ b/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir @@ -0,0 +1,2 @@ +plugin imageprovider + diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml b/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml new file mode 100644 index 0000000..d774112 --- /dev/null +++ b/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml @@ -0,0 +1,25 @@ +import Qt 4.7 +import "ImageProviderCore" +//![0] +ListView { + width: 100; height: 100 + anchors.fill: parent + + model: myModel + + delegate: Component { + Item { + width: 100 + height: 50 + Text { + text: "Loading..." + anchors.centerIn: parent + } + Image { + source: modelData + sourceSize: "50x25" + } + } + } +} +//![0] diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.cpp b/examples/declarative/cppextensions/imageprovider/imageprovider.cpp new file mode 100644 index 0000000..4c4aa94 --- /dev/null +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** 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 demonstration applications 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 +#include + +/* + This example illustrates using a QDeclarativeImageProvider to serve + images asynchronously. +*/ + +//![0] +class ColorImageProvider : public QDeclarativeImageProvider +{ +public: + // This is run in a low priority thread. + QImage request(const QString &id, QSize *size, const QSize &req_size) + { + if (size) *size = QSize(100,50); + QImage image( + req_size.width() > 0 ? req_size.width() : 100, + req_size.height() > 0 ? req_size.height() : 50, + QImage::Format_RGB32); + image.fill(QColor(id).rgba()); + QPainter p(&image); + QFont f = p.font(); + f.setPixelSize(30); + p.setFont(f); + p.setPen(Qt::black); + if (req_size.isValid()) + p.scale(req_size.width()/100.0, req_size.height()/50.0); + p.drawText(QRectF(0,0,100,50),Qt::AlignCenter,id); + return image; + } +}; + + +class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) { + Q_UNUSED(uri); + + } + + void initializeEngine(QDeclarativeEngine *engine, const char *uri) { + Q_UNUSED(uri); + + engine->addImageProvider("colors", new ColorImageProvider); + + QStringList dataList; + dataList.append("image://colors/red"); + dataList.append("image://colors/green"); + dataList.append("image://colors/blue"); + dataList.append("image://colors/brown"); + dataList.append("image://colors/orange"); + dataList.append("image://colors/purple"); + dataList.append("image://colors/yellow"); + + QDeclarativeContext *ctxt = engine->rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); + } + +}; + +#include "imageprovider.moc" + +Q_EXPORT_PLUGIN(ImageProviderExtensionPlugin); +//![0] + diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/cppextensions/imageprovider/imageprovider.pro new file mode 100644 index 0000000..945a301 --- /dev/null +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.pro @@ -0,0 +1,25 @@ +TEMPLATE = lib +TARGET = imageprovider +QT += declarative +CONFIG += qt plugin + +TARGET = $$qtLibraryTarget($$TARGET) +DESTDIR = ImageProviderCore + +# Input +SOURCES += imageprovider.cpp + +sources.files = $$SOURCES imageprovider.qml imageprovider.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider + +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider/ImageProviderCore + +ImageProviderCore_sources.files = \ + ImageProviderCore/qmldir +ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider/ImageProviderCore + +symbian:{ + TARGET.EPOCALLOWDLLDATA=1 +} + +INSTALLS = sources ImageProviderCore_sources target diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject b/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/plugins/README b/examples/declarative/cppextensions/plugins/README new file mode 100644 index 0000000..fe519f8 --- /dev/null +++ b/examples/declarative/cppextensions/plugins/README @@ -0,0 +1,9 @@ +This example shows a module "com.nokia.TimeExample" that is implemented +by a C++ plugin (providing the "Time" type), and by QML files (providing the +"Clock" type). + +To run: + + make install + qml -I . plugins.qml + diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml new file mode 100644 index 0000000..0048372 --- /dev/null +++ b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml @@ -0,0 +1,50 @@ +import Qt 4.7 + +Rectangle { + id: clock + width: 200; height: 200; color: "gray" + + property alias city: cityLabel.text + property variant hours + property variant minutes + property variant shift : 0 + + Image { id: background; source: "clock.png" } + + Image { + x: 92.5; y: 27 + source: "hour.png" + smooth: true + transform: Rotation { + id: hourRotation + origin.x: 7.5; origin.y: 73; angle: 0 + SpringFollow on angle { + spring: 2; damping: 0.2; modulus: 360 + to: (clock.hours * 30) + (clock.minutes * 0.5) + } + } + } + + Image { + x: 93.5; y: 17 + source: "minute.png" + smooth: true + transform: Rotation { + id: minuteRotation + origin.x: 6.5; origin.y: 83; angle: 0 + SpringFollow on angle { + spring: 2; damping: 0.2; modulus: 360 + to: clock.minutes * 6 + } + } + } + + Image { + anchors.centerIn: background; source: "center.png" + } + + Text { + id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white" + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png new file mode 100644 index 0000000..7fbd802 Binary files /dev/null and b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png new file mode 100644 index 0000000..462edac Binary files /dev/null and b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png new file mode 100644 index 0000000..f8061a1 Binary files /dev/null and b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png new file mode 100644 index 0000000..1297ec7 Binary files /dev/null and b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir new file mode 100644 index 0000000..e9ef115 --- /dev/null +++ b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir @@ -0,0 +1,2 @@ +Clock 1.0 Clock.qml +plugin qtimeexampleqmlplugin diff --git a/examples/declarative/cppextensions/plugins/plugin.cpp b/examples/declarative/cppextensions/plugins/plugin.cpp new file mode 100644 index 0000000..fb51b0c --- /dev/null +++ b/examples/declarative/cppextensions/plugins/plugin.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** 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 examples 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 + +// Implements a "TimeModel" class with hour and minute properties +// that change on-the-minute yet efficiently sleep the rest +// of the time. + +class MinuteTimer : public QObject +{ + Q_OBJECT +public: + MinuteTimer(QObject *parent) : QObject(parent) + { + } + + void start() + { + if (!timer.isActive()) { + time = QTime::currentTime(); + timer.start(60000-time.second()*1000, this); + } + } + + void stop() + { + timer.stop(); + } + + int hour() const { return time.hour(); } + int minute() const { return time.minute(); } + +signals: + void timeChanged(); + +protected: + void timerEvent(QTimerEvent *) + { + QTime now = QTime::currentTime(); + if (now.second() == 59 && now.minute() == time.minute() && now.hour() == time.hour()) { + // just missed time tick over, force it, wait extra 0.5 seconds + time.addSecs(60); + timer.start(60500, this); + } else { + time = now; + timer.start(60000-time.second()*1000, this); + } + emit timeChanged(); + } + +private: + QTime time; + QBasicTimer timer; +}; + +class TimeModel : public QObject +{ + Q_OBJECT + Q_PROPERTY(int hour READ hour NOTIFY timeChanged) + Q_PROPERTY(int minute READ minute NOTIFY timeChanged) + +public: + TimeModel(QObject *parent=0) : QObject(parent) + { + if (++instances == 1) { + if (!timer) + timer = new MinuteTimer(qApp); + connect(timer, SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); + timer->start(); + } + } + + ~TimeModel() + { + if (--instances == 0) { + timer->stop(); + } + } + + int minute() const { return timer->minute(); } + int hour() const { return timer->hour(); } + +signals: + void timeChanged(); + +private: + QTime t; + static MinuteTimer *timer; + static int instances; +}; + +int TimeModel::instances=0; +MinuteTimer *TimeModel::timer=0; + +class QExampleQmlPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); + qmlRegisterType(uri, 1, 0, "Time"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(qtimeexampleqmlplugin, QExampleQmlPlugin); diff --git a/examples/declarative/cppextensions/plugins/plugins.pro b/examples/declarative/cppextensions/plugins/plugins.pro new file mode 100644 index 0000000..b501ae3 --- /dev/null +++ b/examples/declarative/cppextensions/plugins/plugins.pro @@ -0,0 +1,31 @@ +TEMPLATE = lib +DESTDIR = com/nokia/TimeExample +TARGET = qtimeexampleqmlplugin +CONFIG += qt plugin +QT += declarative + +SOURCES += plugin.cpp + +qdeclarativesources.files += \ + com/nokia/TimeExample/qmldir \ + com/nokia/TimeExample/center.png \ + com/nokia/TimeExample/clock.png \ + com/nokia/TimeExample/Clock.qml \ + com/nokia/TimeExample/hour.png \ + com/nokia/TimeExample/minute.png + +qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample + +sources.files += plugins.pro plugin.cpp plugins.qml README +sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins + +target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample + +symbian:{ + TARGET.EPOCALLOWDLLDATA=1 +} + + +INSTALLS += qdeclarativesources sources target + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/declarative/cppextensions/plugins/plugins.qml b/examples/declarative/cppextensions/plugins/plugins.qml new file mode 100644 index 0000000..449cd9a --- /dev/null +++ b/examples/declarative/cppextensions/plugins/plugins.qml @@ -0,0 +1,11 @@ +import com.nokia.TimeExample 1.0 // import types from the plugin + +Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml) + + Time { // this class is defined in C++ (plugin.cpp) + id: time + } + + hours: time.hour + minutes: time.minute +} diff --git a/examples/declarative/cppextensions/plugins/plugins.qmlproject b/examples/declarative/cppextensions/plugins/plugins.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/plugins/plugins.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/proxyviewer/main.cpp b/examples/declarative/cppextensions/proxyviewer/main.cpp new file mode 100644 index 0000000..b82d2c9 --- /dev/null +++ b/examples/declarative/cppextensions/proxyviewer/main.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** 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 demonstration applications 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 + + +/* + This example illustrates using a QNetworkAccessManagerFactory to + create a QNetworkAccessManager with a proxy. + + Usage: + proxyviewer [-host -port ] [file] +*/ + +static QString proxyHost; +static int proxyPort = 0; + +class MyNetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory +{ +public: + virtual QNetworkAccessManager *create(QObject *parent); +}; + +QNetworkAccessManager *MyNetworkAccessManagerFactory::create(QObject *parent) +{ + QNetworkAccessManager *nam = new QNetworkAccessManager(parent); + if (!proxyHost.isEmpty()) { + qDebug() << "Created QNetworkAccessManager using proxy" << (proxyHost + ":" + QString::number(proxyPort)); + QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, proxyHost, proxyPort); + nam->setProxy(proxy); + } + + return nam; +} + +int main(int argc, char ** argv) +{ + QUrl source("qrc:view.qml"); + + QApplication app(argc, argv); + + for (int i = 1; i < argc; ++i) { + QString arg(argv[i]); + if (arg == "-host" && i < argc-1) { + proxyHost = argv[++i]; + } else if (arg == "-port" && i < argc-1) { + arg = argv[++i]; + proxyPort = arg.toInt(); + } else if (arg[0] != '-') { + source = QUrl::fromLocalFile(arg); + } else { + qWarning() << "Usage: proxyviewer [-host -port ] [file]"; + exit(1); + } + } + + QDeclarativeView view; + view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); + + view.setSource(source); + view.show(); + + return app.exec(); +} + diff --git a/examples/declarative/cppextensions/proxyviewer/proxyviewer.pro b/examples/declarative/cppextensions/proxyviewer/proxyviewer.pro new file mode 100644 index 0000000..b6bfa7f --- /dev/null +++ b/examples/declarative/cppextensions/proxyviewer/proxyviewer.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = proxyviewer +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative network + +# Input +SOURCES += main.cpp +RESOURCES += proxyviewer.qrc diff --git a/examples/declarative/cppextensions/proxyviewer/proxyviewer.qrc b/examples/declarative/cppextensions/proxyviewer/proxyviewer.qrc new file mode 100644 index 0000000..17e9301 --- /dev/null +++ b/examples/declarative/cppextensions/proxyviewer/proxyviewer.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/declarative/cppextensions/proxyviewer/view.qml b/examples/declarative/cppextensions/proxyviewer/view.qml new file mode 100644 index 0000000..7f1bdef --- /dev/null +++ b/examples/declarative/cppextensions/proxyviewer/view.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +Image { + width: 100 + height: 100 + source: "http://qt.nokia.com/logo.png" +} diff --git a/examples/declarative/cppextensions/proxywidgets/ProxyWidgets/qmldir b/examples/declarative/cppextensions/proxywidgets/ProxyWidgets/qmldir new file mode 100644 index 0000000..e55267c --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/ProxyWidgets/qmldir @@ -0,0 +1 @@ +plugin proxywidgetsplugin diff --git a/examples/declarative/cppextensions/proxywidgets/README b/examples/declarative/cppextensions/proxywidgets/README new file mode 100644 index 0000000..f50fa22 --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/README @@ -0,0 +1,4 @@ +To run: + + make install + qml proxywidgets.qml diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.cpp b/examples/declarative/cppextensions/proxywidgets/proxywidgets.cpp new file mode 100644 index 0000000..067eb2c --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/proxywidgets.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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 examples 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 + +class MyPushButton : public QGraphicsProxyWidget +{ + Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) + +public: + MyPushButton(QGraphicsItem* parent = 0) + : QGraphicsProxyWidget(parent) + { + widget = new QPushButton("MyPushButton"); + widget->setAttribute(Qt::WA_NoSystemBackground); + setWidget(widget); + + QObject::connect(widget, SIGNAL(clicked(bool)), this, SIGNAL(clicked(bool))); + } + + QString text() const + { + return widget->text(); + } + + void setText(const QString& text) + { + if (text != widget->text()) { + widget->setText(text); + emit textChanged(); + } + } + +Q_SIGNALS: + void clicked(bool); + void textChanged(); + +private: + QPushButton *widget; +}; + +class ProxyWidgetsPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + qmlRegisterType(uri, 1, 0, "MyPushButton"); + } +}; + +#include "proxywidgets.moc" + +Q_EXPORT_PLUGIN2(proxywidgetsplugin, ProxyWidgetsPlugin); diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.pro b/examples/declarative/cppextensions/proxywidgets/proxywidgets.pro new file mode 100644 index 0000000..cb07d80 --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/proxywidgets.pro @@ -0,0 +1,21 @@ +TEMPLATE = lib +DESTDIR = ProxyWidgets +TARGET = proxywidgetsplugin +CONFIG += qt plugin +QT += declarative + +SOURCES += proxywidgets.cpp + +sources.files += proxywidgets.pro proxywidgets.cpp proxywidgets.qml + +sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins + +target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins + +INSTALLS += sources target + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + +symbian:{ + TARGET.EPOCALLOWDLLDATA = 1 +} \ No newline at end of file diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.qml b/examples/declarative/cppextensions/proxywidgets/proxywidgets.qml new file mode 100644 index 0000000..88de37f --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/proxywidgets.qml @@ -0,0 +1,70 @@ +import Qt 4.7 +import "ProxyWidgets" 1.0 + +Rectangle { + id: window + + property int margin: 30 + + width: 640; height: 480 + color: palette.window + + SystemPalette { id: palette } + + MyPushButton { + id: button1 + x: margin; y: margin + text: "Right" + transformOriginPoint: Qt.point(width / 2, height / 2) + + onClicked: window.state = "right" + } + + MyPushButton { + id: button2 + x: margin; y: margin + 30 + text: "Bottom" + transformOriginPoint: Qt.point(width / 2, height / 2) + + onClicked: window.state = "bottom" + } + + MyPushButton { + id: button3 + x: margin; y: margin + 60 + text: "Quit" + transformOriginPoint: Qt.point(width / 2, height / 2) + + onClicked: Qt.quit() + } + + states: [ + State { + name: "right" + PropertyChanges { target: button1; x: window.width - width - margin; text: "Left"; onClicked: window.state = "" } + PropertyChanges { target: button2; x: window.width - width - margin } + PropertyChanges { target: button3; x: window.width - width - margin } + PropertyChanges { target: window; color: Qt.darker(palette.window) } + }, + State { + name: "bottom" + PropertyChanges { target: button1; y: window.height - height - margin; rotation: 180 } + PropertyChanges { + target: button2 + x: button1.x + button1.width + 10; y: window.height - height - margin + rotation: 180 + text: "Top" + onClicked: window.state = "" + } + PropertyChanges { target: button3; x: button2.x + button2.width + 10; y: window.height - height - margin; rotation: 180 } + PropertyChanges { target: window; color: Qt.lighter(palette.window) } + } + ] + + transitions: Transition { + ParallelAnimation { + NumberAnimation { properties: "x,y,rotation"; duration: 600; easing.type: Easing.OutQuad } + ColorAnimation { target: window; duration: 600 } + } + } +} diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.qmlproject b/examples/declarative/cppextensions/proxywidgets/proxywidgets.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/proxywidgets.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.cpp b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.cpp new file mode 100644 index 0000000..25cf994 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.cpp @@ -0,0 +1,366 @@ +/**************************************************************************** +** +** 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 "graphicslayouts_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +LinearLayoutAttached::LinearLayoutAttached(QObject *parent) +: QObject(parent), _stretch(1), _alignment(Qt::AlignCenter), _spacing(0) +{ +} + +void LinearLayoutAttached::setStretchFactor(int f) +{ + if (_stretch == f) + return; + + _stretch = f; + emit stretchChanged(reinterpret_cast(parent()), _stretch); +} + +void LinearLayoutAttached::setSpacing(int s) +{ + if (_spacing == s) + return; + + _spacing = s; + emit spacingChanged(reinterpret_cast(parent()), _spacing); +} + +void LinearLayoutAttached::setAlignment(Qt::Alignment a) +{ + if (_alignment == a) + return; + + _alignment = a; + emit alignmentChanged(reinterpret_cast(parent()), _alignment); +} + +QGraphicsLinearLayoutStretchItemObject::QGraphicsLinearLayoutStretchItemObject(QObject *parent) + : QObject(parent) +{ +} + +QSizeF QGraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ +Q_UNUSED(which); +Q_UNUSED(constraint); +return QSizeF(); +} + + +QGraphicsLinearLayoutObject::QGraphicsLinearLayoutObject(QObject *parent) +: QObject(parent) +{ +} + +QGraphicsLinearLayoutObject::~QGraphicsLinearLayoutObject() +{ +} + +void QGraphicsLinearLayoutObject::insertLayoutItem(int index, QGraphicsLayoutItem *item) +{ +insertItem(index, item); + +//connect attached properties +if (LinearLayoutAttached *obj = attachedProperties.value(item)) { + setStretchFactor(item, obj->stretchFactor()); + setAlignment(item, obj->alignment()); + updateSpacing(item, obj->spacing()); + QObject::connect(obj, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)), + this, SLOT(updateStretch(QGraphicsLayoutItem*,int))); + QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), + this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); + QObject::connect(obj, SIGNAL(spacingChanged(QGraphicsLayoutItem*,int)), + this, SLOT(updateSpacing(QGraphicsLayoutItem*,int))); + //### need to disconnect when widget is removed? +} +} + +//### is there a better way to do this? +void QGraphicsLinearLayoutObject::clearChildren() +{ +for (int i = 0; i < count(); ++i) + removeAt(i); +} + +qreal QGraphicsLinearLayoutObject::contentsMargin() const +{ + qreal a,b,c,d; + getContentsMargins(&a, &b, &c, &d); + if(a==b && a==c && a==d) + return a; + return -1; +} + +void QGraphicsLinearLayoutObject::setContentsMargin(qreal m) +{ + setContentsMargins(m,m,m,m); +} + +void QGraphicsLinearLayoutObject::updateStretch(QGraphicsLayoutItem *item, int stretch) +{ +QGraphicsLinearLayout::setStretchFactor(item, stretch); +} + +void QGraphicsLinearLayoutObject::updateSpacing(QGraphicsLayoutItem* item, int spacing) +{ + for(int i=0; i < count(); i++){ + if(itemAt(i) == item){ //I do not see the reverse function, which is why we must loop over all items + QGraphicsLinearLayout::setItemSpacing(i, spacing); + return; + } + } +} + +void QGraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) +{ +QGraphicsLinearLayout::setAlignment(item, alignment); +} + +QHash QGraphicsLinearLayoutObject::attachedProperties; +LinearLayoutAttached *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj) +{ +// ### This is not allowed - you must attach to any object +if (!qobject_cast(obj)) + return 0; +LinearLayoutAttached *rv = new LinearLayoutAttached(obj); +attachedProperties.insert(qobject_cast(obj), rv); +return rv; +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// QGraphicsGridLayout-related classes +////////////////////////////////////////////////////////////////////////////////////////////////////// +GridLayoutAttached::GridLayoutAttached(QObject *parent) +: QObject(parent), _row(-1), _column(-1), _rowspan(1), _colspan(1), _alignment(-1), _rowstretch(-1), + _colstretch(-1), _rowspacing(-1), _colspacing(-1), _rowprefheight(-1), _rowmaxheight(-1), _rowminheight(-1), + _rowfixheight(-1), _colprefwidth(-1), _colmaxwidth(-1), _colminwidth(-1), _colfixwidth(-1) +{ +} + +void GridLayoutAttached::setRow(int r) +{ + if (_row == r) + return; + + _row = r; + //emit rowChanged(reinterpret_cast(parent()), _row); +} + +void GridLayoutAttached::setColumn(int c) +{ + if (_column == c) + return; + + _column = c; + //emit columnChanged(reinterpret_cast(parent()), _column); +} + +void GridLayoutAttached::setRowSpan(int rs) +{ + if (_rowspan == rs) + return; + + _rowspan = rs; + //emit rowSpanChanged(reinterpret_cast(parent()), _rowSpan); +} + +void GridLayoutAttached::setColumnSpan(int cs) +{ + if (_colspan == cs) + return; + + _colspan = cs; + //emit columnSpanChanged(reinterpret_cast(parent()), _columnSpan); +} + +void GridLayoutAttached::setAlignment(Qt::Alignment a) +{ + if (_alignment == a) + return; + + _alignment = a; + emit alignmentChanged(reinterpret_cast(parent()), _alignment); +} + +void GridLayoutAttached::setRowStretchFactor(int f) +{ + _rowstretch = f; +} + +void GridLayoutAttached::setColumnStretchFactor(int f) +{ + _colstretch = f; +} + +void GridLayoutAttached::setRowSpacing(int s) +{ + _rowspacing = s; +} + +void GridLayoutAttached::setColumnSpacing(int s) +{ + _colspacing = s; +} + + +QGraphicsGridLayoutObject::QGraphicsGridLayoutObject(QObject *parent) +: QObject(parent) +{ +} + +QGraphicsGridLayoutObject::~QGraphicsGridLayoutObject() +{ +} + +void QGraphicsGridLayoutObject::addWidget(QGraphicsWidget *wid) +{ +//use attached properties +if (QObject *obj = attachedProperties.value(qobject_cast(wid))) { + int row = static_cast(obj)->row(); + int column = static_cast(obj)->column(); + int rowSpan = static_cast(obj)->rowSpan(); + int columnSpan = static_cast(obj)->columnSpan(); + if (row == -1 || column == -1) { + qWarning() << "Must set row and column for an item in a grid layout"; + return; + } + addItem(wid, row, column, rowSpan, columnSpan); +} +} + +void QGraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item) +{ +//use attached properties +if (GridLayoutAttached *obj = attachedProperties.value(item)) { + int row = obj->row(); + int column = obj->column(); + int rowSpan = obj->rowSpan(); + int columnSpan = obj->columnSpan(); + Qt::Alignment alignment = obj->alignment(); + if (row == -1 || column == -1) { + qWarning() << "Must set row and column for an item in a grid layout"; + return; + } + if(obj->rowSpacing() != -1) + setRowSpacing(row, obj->rowSpacing()); + if(obj->columnSpacing() != -1) + setColumnSpacing(column, obj->columnSpacing()); + if(obj->rowStretchFactor() != -1) + setRowStretchFactor(row, obj->rowStretchFactor()); + if(obj->columnStretchFactor() != -1) + setColumnStretchFactor(column, obj->columnStretchFactor()); + if(obj->rowPreferredHeight() != -1) + setRowPreferredHeight(row, obj->rowPreferredHeight()); + if(obj->rowMaximumHeight() != -1) + setRowMaximumHeight(row, obj->rowMaximumHeight()); + if(obj->rowMinimumHeight() != -1) + setRowMinimumHeight(row, obj->rowMinimumHeight()); + if(obj->rowFixedHeight() != -1) + setRowFixedHeight(row, obj->rowFixedHeight()); + if(obj->columnPreferredWidth() != -1) + setColumnPreferredWidth(row, obj->columnPreferredWidth()); + if(obj->columnMaximumWidth() != -1) + setColumnMaximumWidth(row, obj->columnMaximumWidth()); + if(obj->columnMinimumWidth() != -1) + setColumnMinimumWidth(row, obj->columnMinimumWidth()); + if(obj->columnFixedWidth() != -1) + setColumnFixedWidth(row, obj->columnFixedWidth()); + addItem(item, row, column, rowSpan, columnSpan); + if (alignment != -1) + setAlignment(item,alignment); + QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), + this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); + //### need to disconnect when widget is removed? +} +} + +//### is there a better way to do this? +void QGraphicsGridLayoutObject::clearChildren() +{ +for (int i = 0; i < count(); ++i) + removeAt(i); +} + +qreal QGraphicsGridLayoutObject::spacing() const +{ +if (verticalSpacing() == horizontalSpacing()) + return verticalSpacing(); +return -1; //### +} + +qreal QGraphicsGridLayoutObject::contentsMargin() const +{ + qreal a,b,c,d; + getContentsMargins(&a, &b, &c, &d); + if(a==b && a==c && a==d) + return a; + return -1; +} + +void QGraphicsGridLayoutObject::setContentsMargin(qreal m) +{ + setContentsMargins(m,m,m,m); +} + + +void QGraphicsGridLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) +{ +QGraphicsGridLayout::setAlignment(item, alignment); +} + +QHash QGraphicsGridLayoutObject::attachedProperties; +GridLayoutAttached *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj) +{ +// ### This is not allowed - you must attach to any object +if (!qobject_cast(obj)) + return 0; +GridLayoutAttached *rv = new GridLayoutAttached(obj); +attachedProperties.insert(qobject_cast(obj), rv); +return rv; +} + +QT_END_NAMESPACE diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro new file mode 100644 index 0000000..e5d91b2 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +TARGET = graphicslayouts +QT += declarative + +SOURCES += \ + graphicslayouts.cpp \ + main.cpp + +HEADERS += \ + graphicslayouts_p.h + +RESOURCES += \ + graphicslayouts.qrc diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qml b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qml new file mode 100644 index 0000000..fcd78d5 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qml @@ -0,0 +1,77 @@ +import Qt 4.7 +import GraphicsLayouts 4.7 + +Item { + id: resizable + + width: 800 + height: 400 + + QGraphicsWidget { + size.width: parent.width/2 + size.height: parent.height + + layout: QGraphicsLinearLayout { + LayoutItem { + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "100x100" + Rectangle { color: "yellow"; anchors.fill: parent } + } + LayoutItem { + minimumSize: "100x100" + maximumSize: "400x400" + preferredSize: "200x200" + Rectangle { color: "green"; anchors.fill: parent } + } + } + } + QGraphicsWidget { + x: parent.width/2 + size.width: parent.width/2 + size.height: parent.height + + layout: QGraphicsGridLayout { + LayoutItem { + QGraphicsGridLayout.row: 0 + QGraphicsGridLayout.column: 0 + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "100x100" + Rectangle { color: "red"; anchors.fill: parent } + } + LayoutItem { + QGraphicsGridLayout.row: 1 + QGraphicsGridLayout.column: 0 + minimumSize: "100x100" + maximumSize: "200x200" + preferredSize: "100x100" + Rectangle { color: "orange"; anchors.fill: parent } + } + LayoutItem { + QGraphicsGridLayout.row: 2 + QGraphicsGridLayout.column: 0 + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "200x200" + Rectangle { color: "yellow"; anchors.fill: parent } + } + LayoutItem { + QGraphicsGridLayout.row: 0 + QGraphicsGridLayout.column: 1 + minimumSize: "100x100" + maximumSize: "200x200" + preferredSize: "200x200" + Rectangle { color: "green"; anchors.fill: parent } + } + LayoutItem { + QGraphicsGridLayout.row: 1 + QGraphicsGridLayout.column: 1 + minimumSize: "100x100" + maximumSize: "400x400" + preferredSize: "200x200" + Rectangle { color: "blue"; anchors.fill: parent } + } + } + } +} diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qrc b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qrc new file mode 100644 index 0000000..a199f8d --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qrc @@ -0,0 +1,5 @@ + + + graphicslayouts.qml + + diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts_p.h b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts_p.h new file mode 100644 index 0000000..ea9c614 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts_p.h @@ -0,0 +1,303 @@ +/**************************************************************************** +** +** 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 GRAPHICSLAYOUTS_H +#define GRAPHICSLAYOUTS_H + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QGraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem +{ + Q_OBJECT + Q_INTERFACES(QGraphicsLayoutItem) +public: + QGraphicsLinearLayoutStretchItemObject(QObject *parent = 0); + + virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const; +}; + +class LinearLayoutAttached; +class QGraphicsLinearLayoutObject : public QObject, public QGraphicsLinearLayout +{ + Q_OBJECT + Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) + + Q_PROPERTY(QDeclarativeListProperty children READ children) + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) + Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) + Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) + Q_CLASSINFO("DefaultProperty", "children") +public: + QGraphicsLinearLayoutObject(QObject * = 0); + ~QGraphicsLinearLayoutObject(); + + QDeclarativeListProperty children() { return QDeclarativeListProperty(this, 0, children_append, children_count, children_at, children_clear); } + + static LinearLayoutAttached *qmlAttachedProperties(QObject *); + + qreal contentsMargin() const; + void setContentsMargin(qreal); + +private Q_SLOTS: + void updateStretch(QGraphicsLayoutItem*,int); + void updateSpacing(QGraphicsLayoutItem*,int); + void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); + +private: + friend class LinearLayoutAttached; + void clearChildren(); + void insertLayoutItem(int, QGraphicsLayoutItem *); + static QHash attachedProperties; + + static void children_append(QDeclarativeListProperty *prop, QGraphicsLayoutItem *item) { + static_cast(prop->object)->insertLayoutItem(-1, item); + } + + static void children_clear(QDeclarativeListProperty *prop) { + static_cast(prop->object)->clearChildren(); + } + + static int children_count(QDeclarativeListProperty *prop) { + return static_cast(prop->object)->count(); + } + + static QGraphicsLayoutItem *children_at(QDeclarativeListProperty *prop, int index) { + return static_cast(prop->object)->itemAt(index); + } +}; + +class GridLayoutAttached; +class QGraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout +{ + Q_OBJECT + Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) + + Q_PROPERTY(QDeclarativeListProperty children READ children) + Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) + Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) + Q_PROPERTY(qreal verticalSpacing READ verticalSpacing WRITE setVerticalSpacing) + Q_PROPERTY(qreal horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing) + Q_CLASSINFO("DefaultProperty", "children") +public: + QGraphicsGridLayoutObject(QObject * = 0); + ~QGraphicsGridLayoutObject(); + + QDeclarativeListProperty children() { return QDeclarativeListProperty(this, 0, children_append, children_count, children_at, children_clear); } + + qreal spacing() const; + qreal contentsMargin() const; + void setContentsMargin(qreal); + + static GridLayoutAttached *qmlAttachedProperties(QObject *); + +private Q_SLOTS: + void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); + +private: + friend class GraphicsLayoutAttached; + void addWidget(QGraphicsWidget *); + void clearChildren(); + void addLayoutItem(QGraphicsLayoutItem *); + static QHash attachedProperties; + + static void children_append(QDeclarativeListProperty *prop, QGraphicsLayoutItem *item) { + static_cast(prop->object)->addLayoutItem(item); + } + + static void children_clear(QDeclarativeListProperty *prop) { + static_cast(prop->object)->clearChildren(); + } + + static int children_count(QDeclarativeListProperty *prop) { + return static_cast(prop->object)->count(); + } + + static QGraphicsLayoutItem *children_at(QDeclarativeListProperty *prop, int index) { + return static_cast(prop->object)->itemAt(index); + } +}; + +class LinearLayoutAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int stretchFactor READ stretchFactor WRITE setStretchFactor NOTIFY stretchChanged) + Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) + Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) +public: + LinearLayoutAttached(QObject *parent); + + int stretchFactor() const { return _stretch; } + void setStretchFactor(int f); + Qt::Alignment alignment() const { return _alignment; } + void setAlignment(Qt::Alignment a); + int spacing() const { return _spacing; } + void setSpacing(int s); + +Q_SIGNALS: + void stretchChanged(QGraphicsLayoutItem*,int); + void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); + void spacingChanged(QGraphicsLayoutItem*,int); + +private: + int _stretch; + Qt::Alignment _alignment; + int _spacing; +}; + +class GridLayoutAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int row READ row WRITE setRow) + Q_PROPERTY(int column READ column WRITE setColumn) + Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan) + Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan) + Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) + Q_PROPERTY(int rowStretchFactor READ rowStretchFactor WRITE setRowStretchFactor) + Q_PROPERTY(int columnStretchFactor READ columnStretchFactor WRITE setColumnStretchFactor) + Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing) + Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing) + Q_PROPERTY(int rowPreferredHeight READ rowPreferredHeight WRITE setRowPreferredHeight) + Q_PROPERTY(int rowMinimumHeight READ rowMinimumHeight WRITE setRowMinimumHeight) + Q_PROPERTY(int rowMaximumHeight READ rowMaximumHeight WRITE setRowMaximumHeight) + Q_PROPERTY(int rowFixedHeight READ rowFixedHeight WRITE setRowFixedHeight) + Q_PROPERTY(int columnPreferredWidth READ columnPreferredWidth WRITE setColumnPreferredWidth) + Q_PROPERTY(int columnMaximumWidth READ columnMaximumWidth WRITE setColumnMaximumWidth) + Q_PROPERTY(int columnMinimumWidth READ columnMinimumWidth WRITE setColumnMinimumWidth) + Q_PROPERTY(int columnFixedWidth READ columnFixedWidth WRITE setColumnFixedWidth) + +public: + GridLayoutAttached(QObject *parent); + + int row() const { return _row; } + void setRow(int r); + + int column() const { return _column; } + void setColumn(int c); + + int rowSpan() const { return _rowspan; } + void setRowSpan(int rs); + + int columnSpan() const { return _colspan; } + void setColumnSpan(int cs); + + Qt::Alignment alignment() const { return _alignment; } + void setAlignment(Qt::Alignment a); + + int rowStretchFactor() const { return _rowstretch; } + void setRowStretchFactor(int f); + int columnStretchFactor() const { return _colstretch; } + void setColumnStretchFactor(int f); + + int rowSpacing() const { return _rowspacing; } + void setRowSpacing(int s); + int columnSpacing() const { return _colspacing; } + void setColumnSpacing(int s); + + int rowPreferredHeight() const { return _rowprefheight; } + void setRowPreferredHeight(int s) { _rowprefheight = s; } + + int rowMaximumHeight() const { return _rowmaxheight; } + void setRowMaximumHeight(int s) { _rowmaxheight = s; } + + int rowMinimumHeight() const { return _rowminheight; } + void setRowMinimumHeight(int s) { _rowminheight = s; } + + int rowFixedHeight() const { return _rowfixheight; } + void setRowFixedHeight(int s) { _rowfixheight = s; } + + int columnPreferredWidth() const { return _colprefwidth; } + void setColumnPreferredWidth(int s) { _colprefwidth = s; } + + int columnMaximumWidth() const { return _colmaxwidth; } + void setColumnMaximumWidth(int s) { _colmaxwidth = s; } + + int columnMinimumWidth() const { return _colminwidth; } + void setColumnMinimumWidth(int s) { _colminwidth = s; } + + int columnFixedWidth() const { return _colfixwidth; } + void setColumnFixedWidth(int s) { _colfixwidth = s; } + +Q_SIGNALS: + void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); + +private: + int _row; + int _column; + int _rowspan; + int _colspan; + Qt::Alignment _alignment; + int _rowstretch; + int _colstretch; + int _rowspacing; + int _colspacing; + int _rowprefheight; + int _rowmaxheight; + int _rowminheight; + int _rowfixheight; + int _colprefwidth; + int _colmaxwidth; + int _colminwidth; + int _colfixwidth; +}; + +QT_END_NAMESPACE + +QML_DECLARE_INTERFACE(QGraphicsLayoutItem) +QML_DECLARE_INTERFACE(QGraphicsLayout) +QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject) +QML_DECLARE_TYPE(QGraphicsLinearLayoutObject) +QML_DECLARE_TYPEINFO(QGraphicsLinearLayoutObject, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QGraphicsGridLayoutObject) +QML_DECLARE_TYPEINFO(QGraphicsGridLayoutObject, QML_HAS_ATTACHED_PROPERTIES) + +QT_END_HEADER + +#endif // GRAPHICSLAYOUTS_H diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/main.cpp b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/main.cpp new file mode 100644 index 0000000..89b69bf --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins 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 "graphicslayouts_p.h" +#include + +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv); + QDeclarativeView view; + qmlRegisterInterface("QGraphicsLayoutItem"); + qmlRegisterInterface("QGraphicsLayout"); + qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsLinearLayoutStretchItem"); + qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsLinearLayout"); + qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsGridLayout"); + view.setSource(QUrl(":graphicslayouts.qml")); + view.show(); + return app.exec(); +}; + diff --git a/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.pro b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.pro new file mode 100644 index 0000000..4a3fc73 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.pro @@ -0,0 +1,13 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Tue May 4 13:36:26 2010 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp +RESOURCES += layoutItem.qrc diff --git a/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qml b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qml new file mode 100644 index 0000000..460c564 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qml @@ -0,0 +1,15 @@ +import Qt 4.7 + +LayoutItem {//Sized by the layout + id: resizable + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "100x100" + Rectangle { color: "yellow"; anchors.fill: parent } + Rectangle { + width: 100; height: 100; + anchors.top: parent.top; + anchors.right: parent.right; + color: "green"; + } +} diff --git a/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qrc b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qrc new file mode 100644 index 0000000..deb0fba --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qrc @@ -0,0 +1,5 @@ + + + layoutItem.qml + + diff --git a/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/main.cpp b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/main.cpp new file mode 100644 index 0000000..a104251 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/main.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 examples 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 + +/* This example demonstrates using a LayoutItem to let QML snippets integrate + nicely with existing QGraphicsView applications designed with GraphicsLayouts +*/ +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv); + //Set up a graphics scene with a QGraphicsWidget and Layout + QGraphicsView view; + QGraphicsScene scene; + QGraphicsWidget *widget = new QGraphicsWidget(); + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(); + widget->setLayout(layout); + scene.addItem(widget); + view.setScene(&scene); + //Add the QML snippet into the layout + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl(":layoutItem.qml")); + QGraphicsLayoutItem* obj = qobject_cast(c.create()); + layout->addItem(obj); + + widget->setGeometry(QRectF(0,0, 400,400)); + view.show(); + return app.exec(); +} diff --git a/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.qmlproject b/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/referenceexamples/adding/adding.pro b/examples/declarative/cppextensions/referenceexamples/adding/adding.pro new file mode 100644 index 0000000..6072de4 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/adding/adding.pro @@ -0,0 +1,15 @@ +TEMPLATE = app +TARGET = adding +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + person.cpp +HEADERS += person.h +RESOURCES += adding.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/adding +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/adding +INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/adding/adding.qrc b/examples/declarative/cppextensions/referenceexamples/adding/adding.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/adding/adding.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/adding/example.qml b/examples/declarative/cppextensions/referenceexamples/adding/example.qml new file mode 100644 index 0000000..dc891e7 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/adding/example.qml @@ -0,0 +1,8 @@ +// ![0] +import People 1.0 + +Person { + name: "Bob Jones" + shoeSize: 12 +} +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/adding/main.cpp b/examples/declarative/cppextensions/referenceexamples/adding/main.cpp new file mode 100644 index 0000000..7b33895 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/adding/main.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 examples 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 "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); +//![0] + qmlRegisterType("People", 1,0, "Person"); +//![0] + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + Person *person = qobject_cast(component.create()); + if (person) { + qWarning() << "The person's name is" << person->name(); + qWarning() << "They wear a" << person->shoeSize() << "sized shoe"; + } else { + qWarning() << "An error occured"; + } + + return 0; +} diff --git a/examples/declarative/cppextensions/referenceexamples/adding/person.cpp b/examples/declarative/cppextensions/referenceexamples/adding/person.cpp new file mode 100644 index 0000000..cdf08e0 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/adding/person.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** 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 examples 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 "person.h" + +// ![0] +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/adding/person.h b/examples/declarative/cppextensions/referenceexamples/adding/person.h new file mode 100644 index 0000000..d6de9a9 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/adding/person.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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 examples 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 PERSON_H +#define PERSON_H + +#include +// ![0] +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); + +private: + QString m_name; + int m_shoeSize; +}; +// ![0] + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/attached/attached.pro b/examples/declarative/cppextensions/referenceexamples/attached/attached.pro new file mode 100644 index 0000000..f6d76ed --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/attached.pro @@ -0,0 +1,17 @@ +TEMPLATE = app +TARGET = attached +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += attached.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/attached +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/attached +INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/attached/attached.qrc b/examples/declarative/cppextensions/referenceexamples/attached/attached.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/attached.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp new file mode 100644 index 0000000..7fa1748 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.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 examples 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 "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + m_rsvp = d; +} + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h new file mode 100644 index 0000000..1c66f8c --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** 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 examples 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 BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); +private: + Person *m_host; + QList m_guests; +}; + +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/attached/example.qml b/examples/declarative/cppextensions/referenceexamples/attached/example.qml new file mode 100644 index 0000000..50f0a32 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/example.qml @@ -0,0 +1,31 @@ +import People 1.0 + +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + // ![1] + Boy { + name: "Leo Hodges" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + + BirthdayParty.rsvp: "2009-07-06" + } + // ![1] + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } + Girl { + name: "Anne Brown" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + + BirthdayParty.rsvp: "2009-07-01" + } +} + diff --git a/examples/declarative/cppextensions/referenceexamples/attached/main.cpp b/examples/declarative/cppextensions/referenceexamples/attached/main.cpp new file mode 100644 index 0000000..f1055ae --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/main.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + QDate rsvpDate; + QObject *attached = + qmlAttachedPropertiesObject(guest, false); + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + } else { + qWarning() << "An error occured"; + } + + return 0; +} diff --git a/examples/declarative/cppextensions/referenceexamples/attached/person.cpp b/examples/declarative/cppextensions/referenceexamples/attached/person.cpp new file mode 100644 index 0000000..0a9e508 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/person.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** 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 examples 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 "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/declarative/cppextensions/referenceexamples/attached/person.h b/examples/declarative/cppextensions/referenceexamples/attached/person.h new file mode 100644 index 0000000..2f444c5 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/person.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** 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 examples 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 PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(ShoeDescription *shoe READ shoe) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/binding/binding.pro b/examples/declarative/cppextensions/referenceexamples/binding/binding.pro new file mode 100644 index 0000000..896ce25 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/binding.pro @@ -0,0 +1,19 @@ +TEMPLATE = app +TARGET = binding +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp \ + happybirthdaysong.cpp +HEADERS += person.h \ + birthdayparty.h \ + happybirthdaysong.h +RESOURCES += binding.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/binding +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/binding +INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/binding/binding.qrc b/examples/declarative/cppextensions/referenceexamples/binding/binding.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/binding.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp new file mode 100644 index 0000000..000bb1f --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + if (d != m_rsvp) { + m_rsvp = d; + emit rsvpChanged(); + } +} + + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + if (c == m_host) return; + m_host = c; + emit hostChanged(); +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::startParty() +{ + QTime time = QTime::currentTime(); + emit partyStarted(time); +} + +QString BirthdayParty::announcement() const +{ + return QString(); +} + +void BirthdayParty::setAnnouncement(const QString &speak) +{ + qWarning() << qPrintable(speak); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h new file mode 100644 index 0000000..c3f033e --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** 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 examples 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 BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +signals: + void rsvpChanged(); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] + Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged) +// ![0] + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + QString announcement() const; + void setAnnouncement(const QString &); + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + + void startParty(); +signals: + void partyStarted(const QTime &time); + void hostChanged(); + +private: + Person *m_host; + QList m_guests; +}; + +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/binding/example.qml b/examples/declarative/cppextensions/referenceexamples/binding/example.qml new file mode 100644 index 0000000..82eb3be --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/example.qml @@ -0,0 +1,37 @@ +import People 1.0 + +// ![0] +BirthdayParty { + id: theParty + + HappyBirthdaySong on announcement { name: theParty.host.name } + + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } +// ![0] + onPartyStarted: console.log("This party started rockin' at " + time); + + + Boy { + name: "Leo Hodges" + BirthdayParty.rsvp: "2009-07-06" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + } + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } + Girl { + name: "Anne Brown" + BirthdayParty.rsvp: "2009-07-01" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + } + +// ![1] +} +// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp new file mode 100644 index 0000000..a40e7fb --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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 examples 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 "happybirthdaysong.h" +#include + +HappyBirthdaySong::HappyBirthdaySong(QObject *parent) +: QObject(parent), m_line(-1) +{ + setName(QString()); + QTimer *timer = new QTimer(this); + QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); + timer->start(1000); +} + +void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) +{ + m_target = p; +} + +QString HappyBirthdaySong::name() const +{ + return m_name; +} + +void HappyBirthdaySong::setName(const QString &name) +{ + if (m_name == name) + return; + + m_name = name; + + m_lyrics.clear(); + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday dear " + m_name + ","; + m_lyrics << "Happy birthday to you!"; + m_lyrics << ""; + + emit nameChanged(); +} + +void HappyBirthdaySong::advance() +{ + m_line = (m_line + 1) % m_lyrics.count(); + + m_target.write(m_lyrics.at(m_line)); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h new file mode 100644 index 0000000..e825b86 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.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 examples 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 HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H + +#include +#include + +#include + +class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_INTERFACES(QDeclarativePropertyValueSource) +public: + HappyBirthdaySong(QObject *parent = 0); + + virtual void setTarget(const QDeclarativeProperty &); + + QString name() const; + void setName(const QString &); + +private slots: + void advance(); + +signals: + void nameChanged(); +private: + int m_line; + QStringList m_lyrics; + QDeclarativeProperty m_target; + QString m_name; +}; + +#endif // HAPPYBIRTHDAYSONG_H + diff --git a/examples/declarative/cppextensions/referenceexamples/binding/main.cpp b/examples/declarative/cppextensions/referenceexamples/binding/main.cpp new file mode 100644 index 0000000..2495676 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" +#include "happybirthdaysong.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "HappyBirthdaySong"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + QDate rsvpDate; + QObject *attached = + qmlAttachedPropertiesObject(guest, false); + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + party->startParty(); + } else { + qWarning() << "An error occured"; + } + + return app.exec(); +} diff --git a/examples/declarative/cppextensions/referenceexamples/binding/person.cpp b/examples/declarative/cppextensions/referenceexamples/binding/person.cpp new file mode 100644 index 0000000..9a2248f --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/person.cpp @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** 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 examples 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 "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + if (m_size == s) + return; + + m_size = s; + emit shoeChanged(); +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + if (m_color == c) + return; + + m_color = c; + emit shoeChanged(); +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + if (m_brand == b) + return; + + m_brand = b; + emit shoeChanged(); +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + if (m_price == p) + return; + + m_price = p; + emit shoeChanged(); +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + if (m_name == n) + return; + + m_name = n; + emit nameChanged(); +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/declarative/cppextensions/referenceexamples/binding/person.h b/examples/declarative/cppextensions/referenceexamples/binding/person.h new file mode 100644 index 0000000..2a68da0 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/person.h @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** 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 examples 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 PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize NOTIFY shoeChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY shoeChanged) + Q_PROPERTY(QString brand READ brand WRITE setBrand NOTIFY shoeChanged) + Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +signals: + void shoeChanged(); + +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +// ![0] + Q_PROPERTY(ShoeDescription *shoe READ shoe CONSTANT) +// ![0] +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +signals: + void nameChanged(); + +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp new file mode 100644 index 0000000..4f415a3 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h new file mode 100644 index 0000000..ee77e9a --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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 examples 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 BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) +// ![0] +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro b/examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro new file mode 100644 index 0000000..c8daed8 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro @@ -0,0 +1,17 @@ +TEMPLATE = app +TARGET = coercion +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += coercion.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/coercion +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/coercion +INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc b/examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/example.qml b/examples/declarative/cppextensions/referenceexamples/coercion/example.qml new file mode 100644 index 0000000..7b45950 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/example.qml @@ -0,0 +1,15 @@ +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoeSize: 12 + } + guests: [ + Boy { name: "Leo Hodges" }, + Boy { name: "Jack Smith" }, + Girl { name: "Anne Brown" } + ] +} +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp new file mode 100644 index 0000000..2c7b545 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); +// ![0] + qmlRegisterType(); +// ![0] + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) + qWarning() << " " << party->guest(ii)->name(); + } else { + qWarning() << "An error occured"; + } + + return 0; +} diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/person.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/person.cpp new file mode 100644 index 0000000..5b5203a --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/person.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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 examples 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 "person.h" + +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + +// ![1] +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + +// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/person.h b/examples/declarative/cppextensions/referenceexamples/coercion/person.h new file mode 100644 index 0000000..1c95da7 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/person.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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 examples 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 PERSON_H +#define PERSON_H + +#include + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); +private: + QString m_name; + int m_shoeSize; +}; + + +// ![0] +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +// ![0] + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp new file mode 100644 index 0000000..4f415a3 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h new file mode 100644 index 0000000..9741040 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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 examples 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 BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +// ![0] +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; +// ![0] + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/default/default.pro b/examples/declarative/cppextensions/referenceexamples/default/default.pro new file mode 100644 index 0000000..32aff0b --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/default.pro @@ -0,0 +1,17 @@ +TEMPLATE = app +TARGET = default +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += default.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/default +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/default +INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/default/default.qrc b/examples/declarative/cppextensions/referenceexamples/default/default.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/default.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/default/example.qml b/examples/declarative/cppextensions/referenceexamples/default/example.qml new file mode 100644 index 0000000..c0f3cbb --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/example.qml @@ -0,0 +1,14 @@ +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoeSize: 12 + } + + Boy { name: "Leo Hodges" } + Boy { name: "Jack Smith" } + Girl { name: "Anne Brown" } +} +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/default/main.cpp b/examples/declarative/cppextensions/referenceexamples/default/main.cpp new file mode 100644 index 0000000..2ffd180 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/main.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) + qWarning() << " " << party->guest(ii)->name(); + } else { + qWarning() << "An error occured"; + } + + return 0; +} diff --git a/examples/declarative/cppextensions/referenceexamples/default/person.cpp b/examples/declarative/cppextensions/referenceexamples/default/person.cpp new file mode 100644 index 0000000..69216d3 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/person.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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 examples 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 "person.h" + +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/declarative/cppextensions/referenceexamples/default/person.h b/examples/declarative/cppextensions/referenceexamples/default/person.h new file mode 100644 index 0000000..3e56860 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/person.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 examples 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 PERSON_H +#define PERSON_H + +#include + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); +private: + QString m_name; + int m_shoeSize; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/extended/example.qml b/examples/declarative/cppextensions/referenceexamples/extended/example.qml new file mode 100644 index 0000000..985ce20 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/extended/example.qml @@ -0,0 +1,7 @@ +import People 1.0 + +// ![0] +QLineEdit { + leftMargin: 20 +} +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/extended/extended.pro b/examples/declarative/cppextensions/referenceexamples/extended/extended.pro new file mode 100644 index 0000000..97af286 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/extended/extended.pro @@ -0,0 +1,15 @@ +TEMPLATE = app +TARGET = extended +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + lineedit.cpp +HEADERS += lineedit.h +RESOURCES += extended.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/extended +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/extended +INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/extended/extended.qrc b/examples/declarative/cppextensions/referenceexamples/extended/extended.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/extended/extended.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp b/examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp new file mode 100644 index 0000000..0e521ec --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** 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 examples 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 "lineedit.h" +#include + +LineEditExtension::LineEditExtension(QObject *object) +: QObject(object), m_lineedit(static_cast(object)) +{ +} + +int LineEditExtension::leftMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return l; +} + +void LineEditExtension::setLeftMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(m, t, r, b); +} + +int LineEditExtension::rightMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return r; +} + +void LineEditExtension::setRightMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(l, t, m, b); +} + +int LineEditExtension::topMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return t; +} + +void LineEditExtension::setTopMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(l, m, r, b); +} + +int LineEditExtension::bottomMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return b; +} + +void LineEditExtension::setBottomMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(l, t, r, m); +} + + diff --git a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.h b/examples/declarative/cppextensions/referenceexamples/extended/lineedit.h new file mode 100644 index 0000000..3a464b0 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/extended/lineedit.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 examples 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 LINEEDIT_H +#define LINEEDIT_H + +#include + +class LineEditExtension : public QObject +{ + Q_OBJECT + Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY marginsChanged) + Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY marginsChanged) + Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY marginsChanged) + Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY marginsChanged) +public: + LineEditExtension(QObject *); + + int leftMargin() const; + void setLeftMargin(int); + + int rightMargin() const; + void setRightMargin(int); + + int topMargin() const; + void setTopMargin(int); + + int bottomMargin() const; + void setBottomMargin(int); +signals: + void marginsChanged(); + +private: + QLineEdit *m_lineedit; +}; + +#endif // LINEEDIT_H diff --git a/examples/declarative/cppextensions/referenceexamples/extended/main.cpp b/examples/declarative/cppextensions/referenceexamples/extended/main.cpp new file mode 100644 index 0000000..ca7242d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/extended/main.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 examples 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 "lineedit.h" + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + qmlRegisterExtendedType("People", 1,0, "QLineEdit"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + QLineEdit *edit = qobject_cast(component.create()); + + if (edit) { + edit->show(); + return app.exec(); + } else { + qWarning() << "An error occured"; + return 0; + } +} diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp new file mode 100644 index 0000000..4f415a3 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h new file mode 100644 index 0000000..31d21b2 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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 examples 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 BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; + + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/example.qml b/examples/declarative/cppextensions/referenceexamples/grouped/example.qml new file mode 100644 index 0000000..91b7a06 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/grouped/example.qml @@ -0,0 +1,33 @@ +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + Boy { + name: "Leo Hodges" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + } + // ![1] + Boy { + name: "Jack Smith" + shoe { + size: 8 + color: "blue" + brand: "Puma" + price: 19.95 + } + } + // ![1] + Girl { + name: "Anne Brown" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + } +} +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro b/examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro new file mode 100644 index 0000000..576e1d2 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro @@ -0,0 +1,17 @@ +TEMPLATE = app +TARGET = grouped +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += grouped.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/grouped +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/grouped +INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc b/examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp new file mode 100644 index 0000000..baf32cf --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + Person *bestShoe = 0; + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + qWarning() << " " << guest->name(); + + if (!bestShoe || bestShoe->shoe()->price() < guest->shoe()->price()) + bestShoe = guest; + } + if (bestShoe) + qWarning() << bestShoe->name() << "is wearing the best shoes!"; + + } else { + qWarning() << "An error occured"; + } + + return 0; +} diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/person.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/person.cpp new file mode 100644 index 0000000..0a9e508 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/grouped/person.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** 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 examples 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 "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/person.h b/examples/declarative/cppextensions/referenceexamples/grouped/person.h new file mode 100644 index 0000000..a031e69 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/grouped/person.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** 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 examples 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 PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) +// ![1] + Q_PROPERTY(ShoeDescription *shoe READ shoe) +// ![1] +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp new file mode 100644 index 0000000..27d17a1 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +// ![0] +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} +// ![0] + diff --git a/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h new file mode 100644 index 0000000..39ce9ba --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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 examples 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 BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +// ![0] +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] +// ![1] + Q_PROPERTY(Person *host READ host WRITE setHost) +// ![1] +// ![2] + Q_PROPERTY(QDeclarativeListProperty guests READ guests) +// ![2] +// ![3] +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; +// ![3] + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/example.qml b/examples/declarative/cppextensions/referenceexamples/properties/example.qml new file mode 100644 index 0000000..35abdd6 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/example.qml @@ -0,0 +1,15 @@ +import People 1.0 + +// ![0] +BirthdayParty { + host: Person { + name: "Bob Jones" + shoeSize: 12 + } + guests: [ + Person { name: "Leo Hodges" }, + Person { name: "Jack Smith" }, + Person { name: "Anne Brown" } + ] +} +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/properties/main.cpp b/examples/declarative/cppextensions/referenceexamples/properties/main.cpp new file mode 100644 index 0000000..85e9584 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/main.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "Person"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + qWarning() << "They are inviting:"; + for (int ii = 0; ii < party->guestCount(); ++ii) + qWarning() << " " << party->guest(ii)->name(); + } else { + qWarning() << "An error occured"; + } + + return 0; +} diff --git a/examples/declarative/cppextensions/referenceexamples/properties/person.cpp b/examples/declarative/cppextensions/referenceexamples/properties/person.cpp new file mode 100644 index 0000000..92c54f5 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/person.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** 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 examples 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 "person.h" + +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + diff --git a/examples/declarative/cppextensions/referenceexamples/properties/person.h b/examples/declarative/cppextensions/referenceexamples/properties/person.h new file mode 100644 index 0000000..0029b09 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/person.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** 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 examples 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 PERSON_H +#define PERSON_H + +#include + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); +private: + QString m_name; + int m_shoeSize; +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/properties.pro b/examples/declarative/cppextensions/referenceexamples/properties/properties.pro new file mode 100644 index 0000000..a8f4301 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/properties.pro @@ -0,0 +1,18 @@ +TEMPLATE = app +TARGET = properties +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += properties.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/properties +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/properties +INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/properties/properties.qrc b/examples/declarative/cppextensions/referenceexamples/properties/properties.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/properties.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro b/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro new file mode 100644 index 0000000..169c7ab --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro @@ -0,0 +1,13 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + adding \ + attached \ + binding \ + coercion \ + default \ + extended \ + grouped \ + properties \ + signal \ + valuesource diff --git a/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject b/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp new file mode 100644 index 0000000..740c8c9 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + m_rsvp = d; +} + + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::startParty() +{ + QTime time = QTime::currentTime(); + emit partyStarted(time); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h new file mode 100644 index 0000000..ae4dd39 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 examples 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 BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + + void startParty(); +// ![0] +signals: + void partyStarted(const QTime &time); +// ![0] + +private: + Person *m_host; + QList m_guests; +}; +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/signal/example.qml b/examples/declarative/cppextensions/referenceexamples/signal/example.qml new file mode 100644 index 0000000..83d6a23 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/example.qml @@ -0,0 +1,32 @@ +import People 1.0 + +// ![0] +BirthdayParty { + onPartyStarted: console.log("This party started rockin' at " + time); +// ![0] + + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + Boy { + name: "Leo Hodges" + BirthdayParty.rsvp: "2009-07-06" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + } + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } + Girl { + name: "Anne Brown" + BirthdayParty.rsvp: "2009-07-01" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + } +// ![1] +} +// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/signal/main.cpp b/examples/declarative/cppextensions/referenceexamples/signal/main.cpp new file mode 100644 index 0000000..453f688 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/main.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 examples 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 "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + QDate rsvpDate; + QObject *attached = + qmlAttachedPropertiesObject(guest, false); + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + party->startParty(); + } else { + qWarning() << "An error occured"; + } + + return 0; +} diff --git a/examples/declarative/cppextensions/referenceexamples/signal/person.cpp b/examples/declarative/cppextensions/referenceexamples/signal/person.cpp new file mode 100644 index 0000000..0a9e508 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/person.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** 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 examples 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 "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/declarative/cppextensions/referenceexamples/signal/person.h b/examples/declarative/cppextensions/referenceexamples/signal/person.h new file mode 100644 index 0000000..2f444c5 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/person.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** 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 examples 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 PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(ShoeDescription *shoe READ shoe) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/signal/signal.pro b/examples/declarative/cppextensions/referenceexamples/signal/signal.pro new file mode 100644 index 0000000..6367a38 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/signal.pro @@ -0,0 +1,17 @@ +TEMPLATE = app +TARGET = signal +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += signal.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/signal +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/signal +INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/signal/signal.qrc b/examples/declarative/cppextensions/referenceexamples/signal/signal.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/signal.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp new file mode 100644 index 0000000..b915f4f --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + m_rsvp = d; +} + + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::startParty() +{ + QTime time = QTime::currentTime(); + emit partyStarted(time); +} + +QString BirthdayParty::announcement() const +{ + return QString(); +} + +void BirthdayParty::setAnnouncement(const QString &speak) +{ + qWarning() << qPrintable(speak); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h new file mode 100644 index 0000000..5f25781 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** 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 examples 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 BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) +// ![0] + Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) +// ![0] + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + QString announcement() const; + void setAnnouncement(const QString &); + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + + void startParty(); +signals: + void partyStarted(const QTime &time); + +private: + Person *m_host; + QList m_guests; +}; +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml b/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml new file mode 100644 index 0000000..5b8c8af --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml @@ -0,0 +1,36 @@ +import People 1.0 + +// ![0] +BirthdayParty { + HappyBirthdaySong on announcement { name: "Bob Jones" } +// ![0] + + onPartyStarted: console.log("This party started rockin' at " + time); + + + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + Boy { + name: "Leo Hodges" + BirthdayParty.rsvp: "2009-07-06" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + } + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } + Girl { + name: "Anne Brown" + BirthdayParty.rsvp: "2009-07-01" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + } + +// ![1] +} +// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp new file mode 100644 index 0000000..8ea5c2b --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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 examples 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 "happybirthdaysong.h" +#include + +HappyBirthdaySong::HappyBirthdaySong(QObject *parent) +: QObject(parent), m_line(-1) +{ + setName(QString()); + QTimer *timer = new QTimer(this); + QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); + timer->start(1000); +} + +void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) +{ + m_target = p; +} + +QString HappyBirthdaySong::name() const +{ + return m_name; +} + +void HappyBirthdaySong::setName(const QString &name) +{ + m_name = name; + + m_lyrics.clear(); + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday dear " + m_name + ","; + m_lyrics << "Happy birthday to you!"; + m_lyrics << ""; +} + +void HappyBirthdaySong::advance() +{ + m_line = (m_line + 1) % m_lyrics.count(); + + m_target.write(m_lyrics.at(m_line)); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h new file mode 100644 index 0000000..3d07909 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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 examples 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 HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H + +#include +#include +#include + +#include + +// ![0] +class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource +{ + Q_OBJECT + Q_INTERFACES(QDeclarativePropertyValueSource) +// ![0] + Q_PROPERTY(QString name READ name WRITE setName) +// ![1] +public: + HappyBirthdaySong(QObject *parent = 0); + + virtual void setTarget(const QDeclarativeProperty &); +// ![1] + + QString name() const; + void setName(const QString &); + +private slots: + void advance(); + +private: + int m_line; + QStringList m_lyrics; + QDeclarativeProperty m_target; + QString m_name; +// ![2] +}; +// ![2] + +#endif // HAPPYBIRTHDAYSONG_H + diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp new file mode 100644 index 0000000..00840ee --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** 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 examples 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 "birthdayparty.h" +#include "happybirthdaysong.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "HappyBirthdaySong"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + QDate rsvpDate; + QObject *attached = + qmlAttachedPropertiesObject(guest, false); + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + party->startParty(); + } else { + qWarning() << "An error occured"; + } + + return app.exec(); +} diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp new file mode 100644 index 0000000..0a9e508 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** 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 examples 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 "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/person.h b/examples/declarative/cppextensions/referenceexamples/valuesource/person.h new file mode 100644 index 0000000..2f444c5 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/person.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** 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 examples 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 PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(ShoeDescription *shoe READ shoe) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro new file mode 100644 index 0000000..0626c98 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro @@ -0,0 +1,19 @@ +TEMPLATE = app +TARGET = valuesource +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp \ + happybirthdaysong.cpp +HEADERS += person.h \ + birthdayparty.h \ + happybirthdaysong.h +RESOURCES += valuesource.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/valuesource +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/valuesource +INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro index 913b2b0..e3d922c 100644 --- a/examples/declarative/declarative.pro +++ b/examples/declarative/declarative.pro @@ -2,53 +2,28 @@ TEMPLATE = subdirs # These examples contain some C++ and need to be built SUBDIRS = \ - extending \ - imageprovider \ - objectlistmodel \ - stringlistmodel \ - proxyviewer \ - plugins \ - proxywidgets + cppextensions \ + modelviews \ + tutorials # plugins uses a 'Time' class that conflicts with symbian e32std.h also defining a class of the same name symbian:SUBDIRS -= plugins # These examples contain no C++ and can simply be copied sources.files = \ - animations \ - aspectratio \ - behaviors \ - border-image \ - clocks \ - connections \ - dial \ - dynamic \ - effects \ - fillmode \ - focus \ - fonts \ - gridview \ - layouts \ - listview \ - mousearea \ - package \ - parallax \ - progressbar \ - scrollbar \ - searchbox \ - slideswitch \ - spinner \ - sql \ - states \ - tabwidget \ - tic-tac-toe \ - tutorials \ - tvtennis \ - velocity \ - webview \ - workerlistmodel \ - workerscript \ - xmldata \ - xmlhttprequest + animation \ + cppextensions \ + i18n \ + imageelements \ + keyinteraction \ + positioners \ + sqllocalstorage \ + text \ + threading \ + touchinteraction \ + toys \ + ui-components \ + xml + sources.path = $$[QT_INSTALL_EXAMPLES]/declarative INSTALLS += sources diff --git a/examples/declarative/dial/content/Dial.qml b/examples/declarative/dial/content/Dial.qml deleted file mode 100644 index f9ab3e3..0000000 --- a/examples/declarative/dial/content/Dial.qml +++ /dev/null @@ -1,37 +0,0 @@ -import Qt 4.7 - -Item { - id: root - property real value : 0 - - width: 210; height: 210 - - Image { source: "background.png" } - - Image { - x: 93 - y: 35 - source: "needle_shadow.png" - transform: Rotation { - origin.x: 11; origin.y: 67 - angle: needleRotation.angle - } - } - Image { - id: needle - x: 95; y: 33 - smooth: true - source: "needle.png" - transform: Rotation { - id: needleRotation - origin.x: 7; origin.y: 65 - angle: -130 - SpringFollow on angle { - spring: 1.4 - damping: .15 - to: Math.min(Math.max(-130, root.value*2.6 - 130), 133) - } - } - } - Image { x: 21; y: 18; source: "overlay.png" } -} diff --git a/examples/declarative/dial/content/background.png b/examples/declarative/dial/content/background.png deleted file mode 100644 index 75d555d..0000000 Binary files a/examples/declarative/dial/content/background.png and /dev/null differ diff --git a/examples/declarative/dial/content/needle.png b/examples/declarative/dial/content/needle.png deleted file mode 100644 index 2d19f75..0000000 Binary files a/examples/declarative/dial/content/needle.png and /dev/null differ diff --git a/examples/declarative/dial/content/needle_shadow.png b/examples/declarative/dial/content/needle_shadow.png deleted file mode 100644 index 8d8a928..0000000 Binary files a/examples/declarative/dial/content/needle_shadow.png and /dev/null differ diff --git a/examples/declarative/dial/content/overlay.png b/examples/declarative/dial/content/overlay.png deleted file mode 100644 index 3860a7b..0000000 Binary files a/examples/declarative/dial/content/overlay.png and /dev/null differ diff --git a/examples/declarative/dial/dial-example.qml b/examples/declarative/dial/dial-example.qml deleted file mode 100644 index 2e102b0..0000000 --- a/examples/declarative/dial/dial-example.qml +++ /dev/null @@ -1,44 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - color: "#545454" - width: 300; height: 300 - - // Dial with a slider to adjust it - Dial { - id: dial - anchors.centerIn: parent - value: slider.x * 100 / (container.width - 34) - } - - Rectangle { - id: container - anchors { bottom: parent.bottom; left: parent.left; right: parent.right; leftMargin: 20; rightMargin: 20; bottomMargin: 10 } - height: 16 - - radius: 8 - opacity: 0.7 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "gray" } - GradientStop { position: 1.0; color: "white" } - } - - Rectangle { - id: slider - x: 1; y: 1; width: 30; height: 14 - radius: 6 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#424242" } - GradientStop { position: 1.0; color: "black" } - } - - MouseArea { - anchors.fill: parent - drag.target: parent; drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: container.width - 32 - } - } - } -} diff --git a/examples/declarative/dial/dial.qmlproject b/examples/declarative/dial/dial.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/dial/dial.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml deleted file mode 100644 index 52c7c1e..0000000 --- a/examples/declarative/dynamic/dynamic.qml +++ /dev/null @@ -1,176 +0,0 @@ -import Qt 4.7 -import Qt.labs.particles 1.0 -import "qml" - -Item { - id: window - - property int activeSuns: 0 - - //This is a desktop-sized example - width: 1024; height: 512 - - //This is the message box that pops up when there's an error - Rectangle { - id: dialog - - opacity: 0 - anchors.centerIn: parent - width: dialogText.width + 6; height: dialogText.height + 6 - border.color: 'black' - color: 'lightsteelblue' - z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. - - function show(str){ - dialogText.text = str; - dialogAnim.start(); - } - - Text { - id: dialogText - x: 3; y: 3 - font.pixelSize: 14 - } - - SequentialAnimation { - id: dialogAnim - NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } - PauseAnimation { duration: 5000 } - NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } - } - } - - // sky - Rectangle { - id: sky - anchors { left: parent.left; top: parent.top; right: toolbox.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } - GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } - } - } - - // stars (when there's no sun) - Particles { - id: stars - x: 0; y: 0; width: parent.width; height: parent.height / 2 - source: "images/star.png" - angleDeviation: 360 - velocity: 0; velocityDeviation: 0 - count: parent.width / 10 - fadeInDuration: 2800 - opacity: 1 - } - - // ground - Rectangle { - id: ground - z: 2 // just above the sun so that the sun can set behind it - anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.left; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - SystemPalette { id: activePalette } - - // right-hand panel - Rectangle { - id: toolbox - - width: 480 - color: activePalette.window - anchors { right: parent.right; top: parent.top; bottom: parent.bottom } - - Column { - anchors.centerIn: parent - spacing: 8 - - Text { text: "Drag an item into the scene." } - - Rectangle { - width: childrenRect.width + 10; height: childrenRect.height + 10 - border.color: "black" - - Row { - anchors.centerIn: parent - spacing: 8 - - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "Sun.qml" - image: "../images/sun.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "GenericSceneItem.qml" - image: "../images/moon.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - image: "../images/tree_s.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - image: "../images/rabbit_brown.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - image: "../images/rabbit_bw.png" - } - } - } - - Text { text: "Active Suns: " + activeSuns } - - Rectangle { width: parent.width; height: 1; color: "black" } - - Text { text: "Arbitrary QML:" } - - Rectangle { - width: 460; height: 240 - - TextEdit { - id: qmlText - anchors.fill: parent; anchors.margins: 5 - readOnly: false - focusOnPress: true - font.pixelSize: 14 - - text: "import Qt 4.7\nImage {\n id: smile\n x: 500 * Math.random()\n y: 200 * Math.random() \n source: 'images/face-smile.png'\n\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n\n Component.onCompleted: smile.destroy(1500);\n}" - } - } - - Button { - text: "Create" - onClicked: { - try { - Qt.createQmlObject(qmlText.text, window, 'CustomObject'); - } catch(err) { - dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); - } - } - } - } - } - - //Day state, for when a sun is added to the scene - states: State { - name: "Day" - when: window.activeSuns > 0 - - PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } - PropertyChanges { target: gradientStopB; color: "SkyBlue" } - PropertyChanges { target: stars; opacity: 0 } - } - - transitions: Transition { - PropertyAnimation { duration: 3000 } - ColorAnimation { duration: 3000 } - } - -} diff --git a/examples/declarative/dynamic/dynamic.qmlproject b/examples/declarative/dynamic/dynamic.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/dynamic/dynamic.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/dynamic/images/NOTE b/examples/declarative/dynamic/images/NOTE deleted file mode 100644 index fcd87f9..0000000 --- a/examples/declarative/dynamic/images/NOTE +++ /dev/null @@ -1 +0,0 @@ -Images (except star.png) are from the KDE project. diff --git a/examples/declarative/dynamic/images/face-smile.png b/examples/declarative/dynamic/images/face-smile.png deleted file mode 100644 index 3d66d72..0000000 Binary files a/examples/declarative/dynamic/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/moon.png b/examples/declarative/dynamic/images/moon.png deleted file mode 100644 index 1c0d606..0000000 Binary files a/examples/declarative/dynamic/images/moon.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/rabbit_brown.png b/examples/declarative/dynamic/images/rabbit_brown.png deleted file mode 100644 index ebfdeed..0000000 Binary files a/examples/declarative/dynamic/images/rabbit_brown.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/rabbit_bw.png b/examples/declarative/dynamic/images/rabbit_bw.png deleted file mode 100644 index 7bff9b9..0000000 Binary files a/examples/declarative/dynamic/images/rabbit_bw.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/star.png b/examples/declarative/dynamic/images/star.png deleted file mode 100644 index 27ef924..0000000 Binary files a/examples/declarative/dynamic/images/star.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/sun.png b/examples/declarative/dynamic/images/sun.png deleted file mode 100644 index 7713ca5..0000000 Binary files a/examples/declarative/dynamic/images/sun.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/tree_s.png b/examples/declarative/dynamic/images/tree_s.png deleted file mode 100644 index 6eac35a..0000000 Binary files a/examples/declarative/dynamic/images/tree_s.png and /dev/null differ diff --git a/examples/declarative/dynamic/qml/Button.qml b/examples/declarative/dynamic/qml/Button.qml deleted file mode 100644 index 963a850..0000000 --- a/examples/declarative/dynamic/qml/Button.qml +++ /dev/null @@ -1,40 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: container - - property variant text - signal clicked - - height: text.height + 10; width: text.width + 20 - border.width: 1 - radius: 4 - smooth: true - - gradient: Gradient { - GradientStop { - position: 0.0 - color: !mouseArea.pressed ? activePalette.light : activePalette.button - } - GradientStop { - position: 1.0 - color: !mouseArea.pressed ? activePalette.button : activePalette.dark - } - } - - SystemPalette { id: activePalette } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked() - } - - Text { - id: text - anchors.centerIn:parent - font.pointSize: 10 - text: parent.text - color: activePalette.buttonText - } -} diff --git a/examples/declarative/dynamic/qml/PaletteItem.qml b/examples/declarative/dynamic/qml/PaletteItem.qml deleted file mode 100644 index dcb5cc3..0000000 --- a/examples/declarative/dynamic/qml/PaletteItem.qml +++ /dev/null @@ -1,19 +0,0 @@ -import Qt 4.7 -import "itemCreation.js" as Code - -Image { - id: paletteItem - - property string componentFile - property string image - - source: image - - MouseArea { - anchors.fill: parent - - onPressed: Code.startDrag(mouse); - onPositionChanged: Code.continueDrag(mouse); - onReleased: Code.endDrag(mouse); - } -} diff --git a/examples/declarative/dynamic/qml/PerspectiveItem.qml b/examples/declarative/dynamic/qml/PerspectiveItem.qml deleted file mode 100644 index c04d3dc..0000000 --- a/examples/declarative/dynamic/qml/PerspectiveItem.qml +++ /dev/null @@ -1,25 +0,0 @@ -import Qt 4.7 - -Image { - id: rootItem - - property bool created: false - property string image - - property double scaledBottom: y + (height + height*scale) / 2 - property bool onLand: scaledBottom > window.height / 2 - - source: image - opacity: onLand ? 1 : 0.25 - scale: Math.max((y + height - 250) * 0.01, 0.3) - smooth: true - - onCreatedChanged: { - if (created && !onLand) - rootItem.destroy(); - else - z = scaledBottom; - } - - onYChanged: z = scaledBottom; -} diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml deleted file mode 100644 index 43dcb9a..0000000 --- a/examples/declarative/dynamic/qml/Sun.qml +++ /dev/null @@ -1,38 +0,0 @@ -import Qt 4.7 - -Image { - id: sun - - property bool created: false - property string image: "../images/sun.png" - - source: image - - // once item is created, start moving offscreen - NumberAnimation on y { - to: window.height / 2 - running: created - onRunningChanged: { - if (running) - duration = (window.height - sun.y) * 10; - else - state = "OffScreen" - } - } - - states: State { - name: "OffScreen" - StateChangeScript { - script: { sun.created = false; sun.destroy() } - } - } - - onCreatedChanged: { - if (created) { - sun.z = 1; // above the sky but below the ground layer - window.activeSuns++; - } else { - window.activeSuns--; - } - } -} diff --git a/examples/declarative/dynamic/qml/itemCreation.js b/examples/declarative/dynamic/qml/itemCreation.js deleted file mode 100644 index 59750f3..0000000 --- a/examples/declarative/dynamic/qml/itemCreation.js +++ /dev/null @@ -1,65 +0,0 @@ -var itemComponent = null; -var draggedItem = null; -var startingMouse; -var posnInWindow; - -function startDrag(mouse) -{ - posnInWindow = paletteItem.mapToItem(null, 0, 0); - startingMouse = { x: mouse.x, y: mouse.y } - loadComponent(); -} - -//Creation is split into two functions due to an asynchronous wait while -//possible external files are loaded. - -function loadComponent() { - if (itemComponent != null) { // component has been previously loaded - createItem(); - return; - } - - itemComponent = Qt.createComponent(paletteItem.componentFile); - if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately - component.statusChanged.connect(createItem); - else - createItem(); -} - -function createItem() { - if (itemComponent.status == Component.Ready && draggedItem == null) { - draggedItem = itemComponent.createObject(window); - draggedItem.image = paletteItem.image; - draggedItem.x = posnInWindow.x; - draggedItem.y = posnInWindow.y; - draggedItem.z = 3; // make sure created item is above the ground layer - } else if (itemComponent.status == Component.Error) { - draggedItem = null; - console.log("error creating component"); - console.log(component.errorsString()); - } -} - -function continueDrag(mouse) -{ - if (draggedItem == null) - return; - - draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; - draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; -} - -function endDrag(mouse) -{ - if (draggedItem == null) - return; - - if (draggedItem.x + draggedItem.width > toolbox.x) { //Don't drop it in the toolbox - draggedItem.destroy(); - draggedItem = null; - } else { - draggedItem.created = true; - draggedItem = null; - } -} - diff --git a/examples/declarative/extending/adding/adding.pro b/examples/declarative/extending/adding/adding.pro deleted file mode 100644 index 6072de4..0000000 --- a/examples/declarative/extending/adding/adding.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = app -TARGET = adding -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp -HEADERS += person.h -RESOURCES += adding.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/adding -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/adding -INSTALLS += target sources diff --git a/examples/declarative/extending/adding/adding.qrc b/examples/declarative/extending/adding/adding.qrc deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/adding/adding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/adding/example.qml b/examples/declarative/extending/adding/example.qml deleted file mode 100644 index dc891e7..0000000 --- a/examples/declarative/extending/adding/example.qml +++ /dev/null @@ -1,8 +0,0 @@ -// ![0] -import People 1.0 - -Person { - name: "Bob Jones" - shoeSize: 12 -} -// ![0] diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp deleted file mode 100644 index 7b33895..0000000 --- a/examples/declarative/extending/adding/main.cpp +++ /dev/null @@ -1,65 +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 examples 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 "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); -//![0] - qmlRegisterType("People", 1,0, "Person"); -//![0] - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - Person *person = qobject_cast(component.create()); - if (person) { - qWarning() << "The person's name is" << person->name(); - qWarning() << "They wear a" << person->shoeSize() << "sized shoe"; - } else { - qWarning() << "An error occured"; - } - - return 0; -} diff --git a/examples/declarative/extending/adding/person.cpp b/examples/declarative/extending/adding/person.cpp deleted file mode 100644 index cdf08e0..0000000 --- a/examples/declarative/extending/adding/person.cpp +++ /dev/null @@ -1,69 +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 examples 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 "person.h" - -// ![0] -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - -// ![0] diff --git a/examples/declarative/extending/adding/person.h b/examples/declarative/extending/adding/person.h deleted file mode 100644 index d6de9a9..0000000 --- a/examples/declarative/extending/adding/person.h +++ /dev/null @@ -1,66 +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 examples 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 PERSON_H -#define PERSON_H - -#include -// ![0] -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); - -private: - QString m_name; - int m_shoeSize; -}; -// ![0] - -#endif // PERSON_H diff --git a/examples/declarative/extending/attached/attached.pro b/examples/declarative/extending/attached/attached.pro deleted file mode 100644 index f6d76ed..0000000 --- a/examples/declarative/extending/attached/attached.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = attached -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += attached.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/attached -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/attached -INSTALLS += target sources diff --git a/examples/declarative/extending/attached/attached.qrc b/examples/declarative/extending/attached/attached.qrc deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/attached/attached.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/attached/birthdayparty.cpp b/examples/declarative/extending/attached/birthdayparty.cpp deleted file mode 100644 index 7fa1748..0000000 --- a/examples/declarative/extending/attached/birthdayparty.cpp +++ /dev/null @@ -1,92 +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 examples 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 "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/extending/attached/birthdayparty.h b/examples/declarative/extending/attached/birthdayparty.h deleted file mode 100644 index 1c66f8c..0000000 --- a/examples/declarative/extending/attached/birthdayparty.h +++ /dev/null @@ -1,87 +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 examples 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 BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); -private: - Person *m_host; - QList m_guests; -}; - -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/attached/example.qml b/examples/declarative/extending/attached/example.qml deleted file mode 100644 index 50f0a32..0000000 --- a/examples/declarative/extending/attached/example.qml +++ /dev/null @@ -1,31 +0,0 @@ -import People 1.0 - -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - // ![1] - Boy { - name: "Leo Hodges" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - - BirthdayParty.rsvp: "2009-07-06" - } - // ![1] - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - - BirthdayParty.rsvp: "2009-07-01" - } -} - diff --git a/examples/declarative/extending/attached/main.cpp b/examples/declarative/extending/attached/main.cpp deleted file mode 100644 index f1055ae..0000000 --- a/examples/declarative/extending/attached/main.cpp +++ /dev/null @@ -1,91 +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 examples 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 "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - } else { - qWarning() << "An error occured"; - } - - return 0; -} diff --git a/examples/declarative/extending/attached/person.cpp b/examples/declarative/extending/attached/person.cpp deleted file mode 100644 index 0a9e508..0000000 --- a/examples/declarative/extending/attached/person.cpp +++ /dev/null @@ -1,119 +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 examples 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 "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/extending/attached/person.h b/examples/declarative/extending/attached/person.h deleted file mode 100644 index 2f444c5..0000000 --- a/examples/declarative/extending/attached/person.h +++ /dev/null @@ -1,106 +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 examples 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 PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/binding/binding.pro b/examples/declarative/extending/binding/binding.pro deleted file mode 100644 index 896ce25..0000000 --- a/examples/declarative/extending/binding/binding.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = app -TARGET = binding -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.h -RESOURCES += binding.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/binding -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/binding -INSTALLS += target sources diff --git a/examples/declarative/extending/binding/binding.qrc b/examples/declarative/extending/binding/binding.qrc deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/binding/binding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/binding/birthdayparty.cpp b/examples/declarative/extending/binding/birthdayparty.cpp deleted file mode 100644 index 000bb1f..0000000 --- a/examples/declarative/extending/binding/birthdayparty.cpp +++ /dev/null @@ -1,114 +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 examples 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 "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - if (d != m_rsvp) { - m_rsvp = d; - emit rsvpChanged(); - } -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - if (c == m_host) return; - m_host = c; - emit hostChanged(); -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -QString BirthdayParty::announcement() const -{ - return QString(); -} - -void BirthdayParty::setAnnouncement(const QString &speak) -{ - qWarning() << qPrintable(speak); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/extending/binding/birthdayparty.h b/examples/declarative/extending/binding/birthdayparty.h deleted file mode 100644 index c3f033e..0000000 --- a/examples/declarative/extending/binding/birthdayparty.h +++ /dev/null @@ -1,103 +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 examples 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 BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -signals: - void rsvpChanged(); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] - Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged) -// ![0] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - QString announcement() const; - void setAnnouncement(const QString &); - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -signals: - void partyStarted(const QTime &time); - void hostChanged(); - -private: - Person *m_host; - QList m_guests; -}; - -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/binding/example.qml b/examples/declarative/extending/binding/example.qml deleted file mode 100644 index 82eb3be..0000000 --- a/examples/declarative/extending/binding/example.qml +++ /dev/null @@ -1,37 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - id: theParty - - HappyBirthdaySong on announcement { name: theParty.host.name } - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } -// ![0] - onPartyStarted: console.log("This party started rockin' at " + time); - - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } - -// ![1] -} -// ![1] diff --git a/examples/declarative/extending/binding/happybirthdaysong.cpp b/examples/declarative/extending/binding/happybirthdaysong.cpp deleted file mode 100644 index a40e7fb..0000000 --- a/examples/declarative/extending/binding/happybirthdaysong.cpp +++ /dev/null @@ -1,86 +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 examples 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 "happybirthdaysong.h" -#include - -HappyBirthdaySong::HappyBirthdaySong(QObject *parent) -: QObject(parent), m_line(-1) -{ - setName(QString()); - QTimer *timer = new QTimer(this); - QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); - timer->start(1000); -} - -void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) -{ - m_target = p; -} - -QString HappyBirthdaySong::name() const -{ - return m_name; -} - -void HappyBirthdaySong::setName(const QString &name) -{ - if (m_name == name) - return; - - m_name = name; - - m_lyrics.clear(); - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday dear " + m_name + ","; - m_lyrics << "Happy birthday to you!"; - m_lyrics << ""; - - emit nameChanged(); -} - -void HappyBirthdaySong::advance() -{ - m_line = (m_line + 1) % m_lyrics.count(); - - m_target.write(m_lyrics.at(m_line)); -} - diff --git a/examples/declarative/extending/binding/happybirthdaysong.h b/examples/declarative/extending/binding/happybirthdaysong.h deleted file mode 100644 index e825b86..0000000 --- a/examples/declarative/extending/binding/happybirthdaysong.h +++ /dev/null @@ -1,75 +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 examples 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 HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include - -#include - -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_INTERFACES(QDeclarativePropertyValueSource) -public: - HappyBirthdaySong(QObject *parent = 0); - - virtual void setTarget(const QDeclarativeProperty &); - - QString name() const; - void setName(const QString &); - -private slots: - void advance(); - -signals: - void nameChanged(); -private: - int m_line; - QStringList m_lyrics; - QDeclarativeProperty m_target; - QString m_name; -}; - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/declarative/extending/binding/main.cpp b/examples/declarative/extending/binding/main.cpp deleted file mode 100644 index 2495676..0000000 --- a/examples/declarative/extending/binding/main.cpp +++ /dev/null @@ -1,93 +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 examples 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 "birthdayparty.h" -#include "happybirthdaysong.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << "An error occured"; - } - - return app.exec(); -} diff --git a/examples/declarative/extending/binding/person.cpp b/examples/declarative/extending/binding/person.cpp deleted file mode 100644 index 9a2248f..0000000 --- a/examples/declarative/extending/binding/person.cpp +++ /dev/null @@ -1,139 +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 examples 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 "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - if (m_size == s) - return; - - m_size = s; - emit shoeChanged(); -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - if (m_color == c) - return; - - m_color = c; - emit shoeChanged(); -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - if (m_brand == b) - return; - - m_brand = b; - emit shoeChanged(); -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - if (m_price == p) - return; - - m_price = p; - emit shoeChanged(); -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - if (m_name == n) - return; - - m_name = n; - emit nameChanged(); -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/extending/binding/person.h b/examples/declarative/extending/binding/person.h deleted file mode 100644 index 2a68da0..0000000 --- a/examples/declarative/extending/binding/person.h +++ /dev/null @@ -1,114 +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 examples 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 PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize NOTIFY shoeChanged) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY shoeChanged) - Q_PROPERTY(QString brand READ brand WRITE setBrand NOTIFY shoeChanged) - Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -signals: - void shoeChanged(); - -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) -// ![0] - Q_PROPERTY(ShoeDescription *shoe READ shoe CONSTANT) -// ![0] -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -signals: - void nameChanged(); - -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/coercion/birthdayparty.cpp b/examples/declarative/extending/coercion/birthdayparty.cpp deleted file mode 100644 index 4f415a3..0000000 --- a/examples/declarative/extending/coercion/birthdayparty.cpp +++ /dev/null @@ -1,72 +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 examples 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 "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/extending/coercion/birthdayparty.h b/examples/declarative/extending/coercion/birthdayparty.h deleted file mode 100644 index ee77e9a..0000000 --- a/examples/declarative/extending/coercion/birthdayparty.h +++ /dev/null @@ -1,70 +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 examples 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 BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![0] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/coercion/coercion.pro b/examples/declarative/extending/coercion/coercion.pro deleted file mode 100644 index c8daed8..0000000 --- a/examples/declarative/extending/coercion/coercion.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = coercion -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += coercion.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/coercion -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/coercion -INSTALLS += target sources diff --git a/examples/declarative/extending/coercion/coercion.qrc b/examples/declarative/extending/coercion/coercion.qrc deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/coercion/coercion.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/coercion/example.qml b/examples/declarative/extending/coercion/example.qml deleted file mode 100644 index 7b45950..0000000 --- a/examples/declarative/extending/coercion/example.qml +++ /dev/null @@ -1,15 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Boy { name: "Leo Hodges" }, - Boy { name: "Jack Smith" }, - Girl { name: "Anne Brown" } - ] -} -// ![0] diff --git a/examples/declarative/extending/coercion/main.cpp b/examples/declarative/extending/coercion/main.cpp deleted file mode 100644 index 2c7b545..0000000 --- a/examples/declarative/extending/coercion/main.cpp +++ /dev/null @@ -1,78 +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 examples 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 "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); -// ![0] - qmlRegisterType(); -// ![0] - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << "An error occured"; - } - - return 0; -} diff --git a/examples/declarative/extending/coercion/person.cpp b/examples/declarative/extending/coercion/person.cpp deleted file mode 100644 index 5b5203a..0000000 --- a/examples/declarative/extending/coercion/person.cpp +++ /dev/null @@ -1,80 +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 examples 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 "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - -// ![1] -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - -// ![1] diff --git a/examples/declarative/extending/coercion/person.h b/examples/declarative/extending/coercion/person.h deleted file mode 100644 index 1c95da7..0000000 --- a/examples/declarative/extending/coercion/person.h +++ /dev/null @@ -1,83 +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 examples 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 PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - - -// ![0] -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -// ![0] - -#endif // PERSON_H diff --git a/examples/declarative/extending/default/birthdayparty.cpp b/examples/declarative/extending/default/birthdayparty.cpp deleted file mode 100644 index 4f415a3..0000000 --- a/examples/declarative/extending/default/birthdayparty.cpp +++ /dev/null @@ -1,72 +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 examples 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 "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/extending/default/birthdayparty.h b/examples/declarative/extending/default/birthdayparty.h deleted file mode 100644 index 9741040..0000000 --- a/examples/declarative/extending/default/birthdayparty.h +++ /dev/null @@ -1,71 +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 examples 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 BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -// ![0] -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![0] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/default/default.pro b/examples/declarative/extending/default/default.pro deleted file mode 100644 index 32aff0b..0000000 --- a/examples/declarative/extending/default/default.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = default -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += default.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/default -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/default -INSTALLS += target sources diff --git a/examples/declarative/extending/default/default.qrc b/examples/declarative/extending/default/default.qrc deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/default/default.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/default/example.qml b/examples/declarative/extending/default/example.qml deleted file mode 100644 index c0f3cbb..0000000 --- a/examples/declarative/extending/default/example.qml +++ /dev/null @@ -1,14 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoeSize: 12 - } - - Boy { name: "Leo Hodges" } - Boy { name: "Jack Smith" } - Girl { name: "Anne Brown" } -} -// ![0] diff --git a/examples/declarative/extending/default/main.cpp b/examples/declarative/extending/default/main.cpp deleted file mode 100644 index 2ffd180..0000000 --- a/examples/declarative/extending/default/main.cpp +++ /dev/null @@ -1,76 +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 examples 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 "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << "An error occured"; - } - - return 0; -} diff --git a/examples/declarative/extending/default/person.cpp b/examples/declarative/extending/default/person.cpp deleted file mode 100644 index 69216d3..0000000 --- a/examples/declarative/extending/default/person.cpp +++ /dev/null @@ -1,79 +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 examples 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 "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/extending/default/person.h b/examples/declarative/extending/default/person.h deleted file mode 100644 index 3e56860..0000000 --- a/examples/declarative/extending/default/person.h +++ /dev/null @@ -1,78 +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 examples 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 PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/extended/example.qml b/examples/declarative/extending/extended/example.qml deleted file mode 100644 index 985ce20..0000000 --- a/examples/declarative/extending/extended/example.qml +++ /dev/null @@ -1,7 +0,0 @@ -import People 1.0 - -// ![0] -QLineEdit { - leftMargin: 20 -} -// ![0] diff --git a/examples/declarative/extending/extended/extended.pro b/examples/declarative/extending/extended/extended.pro deleted file mode 100644 index 97af286..0000000 --- a/examples/declarative/extending/extended/extended.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = app -TARGET = extended -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - lineedit.cpp -HEADERS += lineedit.h -RESOURCES += extended.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/extended -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/extended -INSTALLS += target sources diff --git a/examples/declarative/extending/extended/extended.qrc b/examples/declarative/extending/extended/extended.qrc deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/extended/extended.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/extended/lineedit.cpp b/examples/declarative/extending/extended/lineedit.cpp deleted file mode 100644 index 0e521ec..0000000 --- a/examples/declarative/extending/extended/lineedit.cpp +++ /dev/null @@ -1,105 +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 examples 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 "lineedit.h" -#include - -LineEditExtension::LineEditExtension(QObject *object) -: QObject(object), m_lineedit(static_cast(object)) -{ -} - -int LineEditExtension::leftMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return l; -} - -void LineEditExtension::setLeftMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(m, t, r, b); -} - -int LineEditExtension::rightMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return r; -} - -void LineEditExtension::setRightMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, t, m, b); -} - -int LineEditExtension::topMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return t; -} - -void LineEditExtension::setTopMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, m, r, b); -} - -int LineEditExtension::bottomMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return b; -} - -void LineEditExtension::setBottomMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, t, r, m); -} - - diff --git a/examples/declarative/extending/extended/lineedit.h b/examples/declarative/extending/extended/lineedit.h deleted file mode 100644 index 3a464b0..0000000 --- a/examples/declarative/extending/extended/lineedit.h +++ /dev/null @@ -1,74 +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 examples 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 LINEEDIT_H -#define LINEEDIT_H - -#include - -class LineEditExtension : public QObject -{ - Q_OBJECT - Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY marginsChanged) - Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY marginsChanged) - Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY marginsChanged) - Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY marginsChanged) -public: - LineEditExtension(QObject *); - - int leftMargin() const; - void setLeftMargin(int); - - int rightMargin() const; - void setRightMargin(int); - - int topMargin() const; - void setTopMargin(int); - - int bottomMargin() const; - void setBottomMargin(int); -signals: - void marginsChanged(); - -private: - QLineEdit *m_lineedit; -}; - -#endif // LINEEDIT_H diff --git a/examples/declarative/extending/extended/main.cpp b/examples/declarative/extending/extended/main.cpp deleted file mode 100644 index ca7242d..0000000 --- a/examples/declarative/extending/extended/main.cpp +++ /dev/null @@ -1,65 +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 examples 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 "lineedit.h" - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - qmlRegisterExtendedType("People", 1,0, "QLineEdit"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - QLineEdit *edit = qobject_cast(component.create()); - - if (edit) { - edit->show(); - return app.exec(); - } else { - qWarning() << "An error occured"; - return 0; - } -} diff --git a/examples/declarative/extending/extending.pro b/examples/declarative/extending/extending.pro deleted file mode 100644 index 169c7ab..0000000 --- a/examples/declarative/extending/extending.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - adding \ - attached \ - binding \ - coercion \ - default \ - extended \ - grouped \ - properties \ - signal \ - valuesource diff --git a/examples/declarative/extending/extending.qmlproject b/examples/declarative/extending/extending.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/extending/extending.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/extending/grouped/birthdayparty.cpp b/examples/declarative/extending/grouped/birthdayparty.cpp deleted file mode 100644 index 4f415a3..0000000 --- a/examples/declarative/extending/grouped/birthdayparty.cpp +++ /dev/null @@ -1,72 +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 examples 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 "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/extending/grouped/birthdayparty.h b/examples/declarative/extending/grouped/birthdayparty.h deleted file mode 100644 index 31d21b2..0000000 --- a/examples/declarative/extending/grouped/birthdayparty.h +++ /dev/null @@ -1,70 +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 examples 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 BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/grouped/example.qml b/examples/declarative/extending/grouped/example.qml deleted file mode 100644 index 91b7a06..0000000 --- a/examples/declarative/extending/grouped/example.qml +++ /dev/null @@ -1,33 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - // ![1] - Boy { - name: "Jack Smith" - shoe { - size: 8 - color: "blue" - brand: "Puma" - price: 19.95 - } - } - // ![1] - Girl { - name: "Anne Brown" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } -} -// ![0] diff --git a/examples/declarative/extending/grouped/grouped.pro b/examples/declarative/extending/grouped/grouped.pro deleted file mode 100644 index 576e1d2..0000000 --- a/examples/declarative/extending/grouped/grouped.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = grouped -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += grouped.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/grouped -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/grouped -INSTALLS += target sources diff --git a/examples/declarative/extending/grouped/grouped.qrc b/examples/declarative/extending/grouped/grouped.qrc deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/grouped/grouped.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/grouped/main.cpp b/examples/declarative/extending/grouped/main.cpp deleted file mode 100644 index baf32cf..0000000 --- a/examples/declarative/extending/grouped/main.cpp +++ /dev/null @@ -1,86 +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 examples 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 "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - Person *bestShoe = 0; - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - qWarning() << " " << guest->name(); - - if (!bestShoe || bestShoe->shoe()->price() < guest->shoe()->price()) - bestShoe = guest; - } - if (bestShoe) - qWarning() << bestShoe->name() << "is wearing the best shoes!"; - - } else { - qWarning() << "An error occured"; - } - - return 0; -} diff --git a/examples/declarative/extending/grouped/person.cpp b/examples/declarative/extending/grouped/person.cpp deleted file mode 100644 index 0a9e508..0000000 --- a/examples/declarative/extending/grouped/person.cpp +++ /dev/null @@ -1,119 +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 examples 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 "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/extending/grouped/person.h b/examples/declarative/extending/grouped/person.h deleted file mode 100644 index a031e69..0000000 --- a/examples/declarative/extending/grouped/person.h +++ /dev/null @@ -1,108 +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 examples 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 PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) -// ![1] - Q_PROPERTY(ShoeDescription *shoe READ shoe) -// ![1] -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/properties/birthdayparty.cpp b/examples/declarative/extending/properties/birthdayparty.cpp deleted file mode 100644 index 27d17a1..0000000 --- a/examples/declarative/extending/properties/birthdayparty.cpp +++ /dev/null @@ -1,74 +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 examples 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 "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -// ![0] -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} -// ![0] - diff --git a/examples/declarative/extending/properties/birthdayparty.h b/examples/declarative/extending/properties/birthdayparty.h deleted file mode 100644 index 39ce9ba..0000000 --- a/examples/declarative/extending/properties/birthdayparty.h +++ /dev/null @@ -1,76 +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 examples 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 BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -// ![0] -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] -// ![1] - Q_PROPERTY(Person *host READ host WRITE setHost) -// ![1] -// ![2] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![2] -// ![3] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![3] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/properties/example.qml b/examples/declarative/extending/properties/example.qml deleted file mode 100644 index 35abdd6..0000000 --- a/examples/declarative/extending/properties/example.qml +++ /dev/null @@ -1,15 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - host: Person { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Person { name: "Leo Hodges" }, - Person { name: "Jack Smith" }, - Person { name: "Anne Brown" } - ] -} -// ![0] diff --git a/examples/declarative/extending/properties/main.cpp b/examples/declarative/extending/properties/main.cpp deleted file mode 100644 index 85e9584..0000000 --- a/examples/declarative/extending/properties/main.cpp +++ /dev/null @@ -1,69 +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 examples 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 "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "Person"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - qWarning() << "They are inviting:"; - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << "An error occured"; - } - - return 0; -} diff --git a/examples/declarative/extending/properties/person.cpp b/examples/declarative/extending/properties/person.cpp deleted file mode 100644 index 92c54f5..0000000 --- a/examples/declarative/extending/properties/person.cpp +++ /dev/null @@ -1,67 +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 examples 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 "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - diff --git a/examples/declarative/extending/properties/person.h b/examples/declarative/extending/properties/person.h deleted file mode 100644 index 0029b09..0000000 --- a/examples/declarative/extending/properties/person.h +++ /dev/null @@ -1,64 +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 examples 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 PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/properties/properties.pro b/examples/declarative/extending/properties/properties.pro deleted file mode 100644 index a8f4301..0000000 --- a/examples/declarative/extending/properties/properties.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = app -TARGET = properties -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += properties.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/properties -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/properties -INSTALLS += target sources diff --git a/examples/declarative/extending/properties/properties.qrc b/examples/declarative/extending/properties/properties.qrc deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/properties/properties.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/signal/birthdayparty.cpp b/examples/declarative/extending/signal/birthdayparty.cpp deleted file mode 100644 index 740c8c9..0000000 --- a/examples/declarative/extending/signal/birthdayparty.cpp +++ /dev/null @@ -1,99 +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 examples 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 "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/extending/signal/birthdayparty.h b/examples/declarative/extending/signal/birthdayparty.h deleted file mode 100644 index ae4dd39..0000000 --- a/examples/declarative/extending/signal/birthdayparty.h +++ /dev/null @@ -1,93 +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 examples 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 BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -// ![0] -signals: - void partyStarted(const QTime &time); -// ![0] - -private: - Person *m_host; - QList m_guests; -}; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/signal/example.qml b/examples/declarative/extending/signal/example.qml deleted file mode 100644 index 83d6a23..0000000 --- a/examples/declarative/extending/signal/example.qml +++ /dev/null @@ -1,32 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - onPartyStarted: console.log("This party started rockin' at " + time); -// ![0] - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } -// ![1] -} -// ![1] diff --git a/examples/declarative/extending/signal/main.cpp b/examples/declarative/extending/signal/main.cpp deleted file mode 100644 index 453f688..0000000 --- a/examples/declarative/extending/signal/main.cpp +++ /dev/null @@ -1,92 +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 examples 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 "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << "An error occured"; - } - - return 0; -} diff --git a/examples/declarative/extending/signal/person.cpp b/examples/declarative/extending/signal/person.cpp deleted file mode 100644 index 0a9e508..0000000 --- a/examples/declarative/extending/signal/person.cpp +++ /dev/null @@ -1,119 +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 examples 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 "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/extending/signal/person.h b/examples/declarative/extending/signal/person.h deleted file mode 100644 index 2f444c5..0000000 --- a/examples/declarative/extending/signal/person.h +++ /dev/null @@ -1,106 +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 examples 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 PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/signal/signal.pro b/examples/declarative/extending/signal/signal.pro deleted file mode 100644 index 6367a38..0000000 --- a/examples/declarative/extending/signal/signal.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = signal -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += signal.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/signal -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/signal -INSTALLS += target sources diff --git a/examples/declarative/extending/signal/signal.qrc b/examples/declarative/extending/signal/signal.qrc deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/signal/signal.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/valuesource/birthdayparty.cpp b/examples/declarative/extending/valuesource/birthdayparty.cpp deleted file mode 100644 index b915f4f..0000000 --- a/examples/declarative/extending/valuesource/birthdayparty.cpp +++ /dev/null @@ -1,109 +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 examples 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 "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -QString BirthdayParty::announcement() const -{ - return QString(); -} - -void BirthdayParty::setAnnouncement(const QString &speak) -{ - qWarning() << qPrintable(speak); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/extending/valuesource/birthdayparty.h b/examples/declarative/extending/valuesource/birthdayparty.h deleted file mode 100644 index 5f25781..0000000 --- a/examples/declarative/extending/valuesource/birthdayparty.h +++ /dev/null @@ -1,98 +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 examples 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 BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![0] - Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) -// ![0] - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - QString announcement() const; - void setAnnouncement(const QString &); - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -signals: - void partyStarted(const QTime &time); - -private: - Person *m_host; - QList m_guests; -}; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/valuesource/example.qml b/examples/declarative/extending/valuesource/example.qml deleted file mode 100644 index 5b8c8af..0000000 --- a/examples/declarative/extending/valuesource/example.qml +++ /dev/null @@ -1,36 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - HappyBirthdaySong on announcement { name: "Bob Jones" } -// ![0] - - onPartyStarted: console.log("This party started rockin' at " + time); - - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } - -// ![1] -} -// ![1] diff --git a/examples/declarative/extending/valuesource/happybirthdaysong.cpp b/examples/declarative/extending/valuesource/happybirthdaysong.cpp deleted file mode 100644 index 8ea5c2b..0000000 --- a/examples/declarative/extending/valuesource/happybirthdaysong.cpp +++ /dev/null @@ -1,81 +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 examples 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 "happybirthdaysong.h" -#include - -HappyBirthdaySong::HappyBirthdaySong(QObject *parent) -: QObject(parent), m_line(-1) -{ - setName(QString()); - QTimer *timer = new QTimer(this); - QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); - timer->start(1000); -} - -void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) -{ - m_target = p; -} - -QString HappyBirthdaySong::name() const -{ - return m_name; -} - -void HappyBirthdaySong::setName(const QString &name) -{ - m_name = name; - - m_lyrics.clear(); - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday dear " + m_name + ","; - m_lyrics << "Happy birthday to you!"; - m_lyrics << ""; -} - -void HappyBirthdaySong::advance() -{ - m_line = (m_line + 1) % m_lyrics.count(); - - m_target.write(m_lyrics.at(m_line)); -} - diff --git a/examples/declarative/extending/valuesource/happybirthdaysong.h b/examples/declarative/extending/valuesource/happybirthdaysong.h deleted file mode 100644 index 3d07909..0000000 --- a/examples/declarative/extending/valuesource/happybirthdaysong.h +++ /dev/null @@ -1,80 +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 examples 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 HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include -#include - -#include - -// ![0] -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource -{ - Q_OBJECT - Q_INTERFACES(QDeclarativePropertyValueSource) -// ![0] - Q_PROPERTY(QString name READ name WRITE setName) -// ![1] -public: - HappyBirthdaySong(QObject *parent = 0); - - virtual void setTarget(const QDeclarativeProperty &); -// ![1] - - QString name() const; - void setName(const QString &); - -private slots: - void advance(); - -private: - int m_line; - QStringList m_lyrics; - QDeclarativeProperty m_target; - QString m_name; -// ![2] -}; -// ![2] - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp deleted file mode 100644 index 00840ee..0000000 --- a/examples/declarative/extending/valuesource/main.cpp +++ /dev/null @@ -1,94 +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 examples 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 "birthdayparty.h" -#include "happybirthdaysong.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << "An error occured"; - } - - return app.exec(); -} diff --git a/examples/declarative/extending/valuesource/person.cpp b/examples/declarative/extending/valuesource/person.cpp deleted file mode 100644 index 0a9e508..0000000 --- a/examples/declarative/extending/valuesource/person.cpp +++ /dev/null @@ -1,119 +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 examples 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 "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/extending/valuesource/person.h b/examples/declarative/extending/valuesource/person.h deleted file mode 100644 index 2f444c5..0000000 --- a/examples/declarative/extending/valuesource/person.h +++ /dev/null @@ -1,106 +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 examples 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 PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/valuesource/valuesource.pro b/examples/declarative/extending/valuesource/valuesource.pro deleted file mode 100644 index 0626c98..0000000 --- a/examples/declarative/extending/valuesource/valuesource.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = app -TARGET = valuesource -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.h -RESOURCES += valuesource.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/valuesource -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/valuesource -INSTALLS += target sources diff --git a/examples/declarative/extending/valuesource/valuesource.qrc b/examples/declarative/extending/valuesource/valuesource.qrc deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/valuesource/valuesource.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/fillmode/content/QtLogo.qml b/examples/declarative/fillmode/content/QtLogo.qml deleted file mode 100644 index 6dd714d..0000000 --- a/examples/declarative/fillmode/content/QtLogo.qml +++ /dev/null @@ -1,30 +0,0 @@ -import Qt 4.7 - -Item { - id: qtLogo - - property alias fillMode: image.fillMode - property alias label: labelText.text - - width: ((window.width - 20) - ((grid.columns - 1) * grid.spacing)) / grid.columns - height: ((window.height - 20) - ((grid.rows - 1) * grid.spacing)) / grid.rows - - Column { - anchors.fill: parent - - Rectangle { - height: qtLogo.height - 30; width: qtLogo.width - border.color: "black"; clip: true - - Image { - id: image - anchors.fill: parent; smooth: true; source: "qt-logo.png" - } - } - - Text { - id: labelText; anchors.horizontalCenter: parent.horizontalCenter - height: 30; verticalAlignment: Text.AlignVCenter - } - } -} diff --git a/examples/declarative/fillmode/content/qt-logo.png b/examples/declarative/fillmode/content/qt-logo.png deleted file mode 100644 index 14ddf2a..0000000 Binary files a/examples/declarative/fillmode/content/qt-logo.png and /dev/null differ diff --git a/examples/declarative/fillmode/fillmode.qml b/examples/declarative/fillmode/fillmode.qml deleted file mode 100644 index e5b0336..0000000 --- a/examples/declarative/fillmode/fillmode.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - id: window - - width: 800; height: 480 - color: "#cdcdcd" - - Grid { - id: grid - anchors { fill: parent; topMargin: 10; leftMargin: 10; rightMargin: 10; bottomMargin: 10 } - columns: 3; rows: 2; spacing: 20 - - QtLogo { fillMode: Image.Stretch; label: "Stretch" } - QtLogo { fillMode: Image.PreserveAspectFit; label: "PreserveAspectFit" } - QtLogo { fillMode: Image.PreserveAspectCrop; label: "PreserveAspectCrop" } - QtLogo { fillMode: Image.Tile; label: "Tile" } - QtLogo { fillMode: Image.TileHorizontally; label: "TileHorizontally" } - QtLogo { fillMode: Image.TileVertically; label: "TileVertically" } - } -} diff --git a/examples/declarative/fillmode/fillmode.qmlproject b/examples/declarative/fillmode/fillmode.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/fillmode/fillmode.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/flipable/content/5_heart.png b/examples/declarative/flipable/content/5_heart.png deleted file mode 100644 index fb59d81..0000000 Binary files a/examples/declarative/flipable/content/5_heart.png and /dev/null differ diff --git a/examples/declarative/flipable/content/9_club.png b/examples/declarative/flipable/content/9_club.png deleted file mode 100644 index 2545001..0000000 Binary files a/examples/declarative/flipable/content/9_club.png and /dev/null differ diff --git a/examples/declarative/flipable/content/Card.qml b/examples/declarative/flipable/content/Card.qml deleted file mode 100644 index 2577d89..0000000 --- a/examples/declarative/flipable/content/Card.qml +++ /dev/null @@ -1,38 +0,0 @@ -import Qt 4.7 - -Flipable { - id: container - - property alias image: frontImage.source - property bool flipped: true - property int xAxis: 0 - property int yAxis: 0 - property int angle: 0 - - width: front.width; height: front.height; state: "back" - - front: Image { id: frontImage; smooth: true } - back: Image { source: "back.png"; smooth: true } - - MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } - - transform: Rotation { - id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 - axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 - } - - states: State { - name: "back"; when: container.flipped - PropertyChanges { target: rotation; angle: container.angle } - } - - transitions: Transition { - ParallelAnimation { - NumberAnimation { target: rotation; properties: "angle"; duration: 600 } - SequentialAnimation { - NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } - NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } - } - } - } -} diff --git a/examples/declarative/flipable/content/back.png b/examples/declarative/flipable/content/back.png deleted file mode 100644 index f715d74..0000000 Binary files a/examples/declarative/flipable/content/back.png and /dev/null differ diff --git a/examples/declarative/flipable/flipable-example.qml b/examples/declarative/flipable/flipable-example.qml deleted file mode 100644 index 4e09569..0000000 --- a/examples/declarative/flipable/flipable-example.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "darkgreen" - - Row { - anchors.centerIn: parent; spacing: 30 - Card { image: "content/9_club.png"; angle: 180; yAxis: 1 } - Card { image: "content/5_heart.png"; angle: 540; xAxis: 1 } - } -} diff --git a/examples/declarative/flipable/flipable.qmlproject b/examples/declarative/flipable/flipable.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/flipable/flipable.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/focus/Core/ContextMenu.qml b/examples/declarative/focus/Core/ContextMenu.qml deleted file mode 100644 index 49a54bc..0000000 --- a/examples/declarative/focus/Core/ContextMenu.qml +++ /dev/null @@ -1,18 +0,0 @@ -import Qt 4.7 - -FocusScope { - id: container - - property bool open: false - - Item { - anchors.fill: parent - - Rectangle { - anchors.fill: parent - color: "#D1DBBD" - focus: true - Keys.onRightPressed: mainView.focus = true - } - } -} diff --git a/examples/declarative/focus/Core/GridMenu.qml b/examples/declarative/focus/Core/GridMenu.qml deleted file mode 100644 index 3f727fd..0000000 --- a/examples/declarative/focus/Core/GridMenu.qml +++ /dev/null @@ -1,61 +0,0 @@ -import Qt 4.7 - -FocusScope { - property alias interactive: gridView.interactive - - onWantsFocusChanged: if (wantsFocus) mainView.state = "" - - Rectangle { - anchors.fill: parent - clip: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#193441" } - GradientStop { position: 1.0; color: Qt.darker("#193441") } - } - - GridView { - id: gridView - x: 20; width: parent.width - 40; height: parent.height - cellWidth: 152; cellHeight: 152 - focus: true - model: 12 - KeyNavigation.down: listViews - KeyNavigation.left: contextMenu - - delegate: Item { - id: container - width: GridView.view.cellWidth; height: GridView.view.cellHeight - - Rectangle { - id: content - color: "transparent" - smooth: true - anchors.centerIn: parent; width: container.width - 40; height: container.height - 40; radius: 10 - - Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 } - Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - GridView.view.currentIndex = index - container.forceFocus() - } - } - - states: State { - name: "active"; when: container.focus == true - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - } - - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } - } - } - } -} diff --git a/examples/declarative/focus/Core/ListViewDelegate.qml b/examples/declarative/focus/Core/ListViewDelegate.qml deleted file mode 100644 index 14e2548..0000000 --- a/examples/declarative/focus/Core/ListViewDelegate.qml +++ /dev/null @@ -1,40 +0,0 @@ -import Qt 4.7 - -Item { - id: container - x: 5; width: ListView.view.width - 10; height: 60 - - Rectangle { - id: content - anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 - color: "transparent" - smooth: true - radius: 10 - - Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 } - Text { - text: "List element " + (index + 1); color: "#193441"; font.bold: false; anchors.centerIn: parent - font.pixelSize: 14 - } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - ListView.view.currentIndex = index - container.forceFocus() - } - } - - states: State { - name: "active"; when: container.focus == true - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - } - - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } -} diff --git a/examples/declarative/focus/Core/ListViews.qml b/examples/declarative/focus/Core/ListViews.qml deleted file mode 100644 index 32a5d4c..0000000 --- a/examples/declarative/focus/Core/ListViews.qml +++ /dev/null @@ -1,62 +0,0 @@ -import Qt 4.7 - -FocusScope { - clip: true - - onWantsFocusChanged: if (wantsFocus) mainView.state = "showListViews" - - ListView { - id: list1 - y: wantsFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20 - focus: true - KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list2 - y: wantsFocus ? 10 : 40; x: parent.width / 3; width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list3 - y: wantsFocus ? 10 : 40; x: 2 * parent.width / 3; width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: gridMenu; KeyNavigation.left: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - Rectangle { width: parent.width; height: 1; color: "#D1DBBD" } - - Rectangle { - y: 1; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 0.0; color: "#3E606F" } - GradientStop { position: 1.0; color: "transparent" } - } - } - - Rectangle { - y: parent.height - 10; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 1.0; color: "#3E606F" } - GradientStop { position: 0.0; color: "transparent" } - } - } -} diff --git a/examples/declarative/focus/Core/images/arrow.png b/examples/declarative/focus/Core/images/arrow.png deleted file mode 100644 index 14978c2..0000000 Binary files a/examples/declarative/focus/Core/images/arrow.png and /dev/null differ diff --git a/examples/declarative/focus/Core/images/qt-logo.png b/examples/declarative/focus/Core/images/qt-logo.png deleted file mode 100644 index 14ddf2a..0000000 Binary files a/examples/declarative/focus/Core/images/qt-logo.png and /dev/null differ diff --git a/examples/declarative/focus/Core/qmldir b/examples/declarative/focus/Core/qmldir deleted file mode 100644 index e25d63c..0000000 --- a/examples/declarative/focus/Core/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -ContextMenu ContextMenu.qml -GridMenu GridMenu.qml -ListViews ListViews.qml -ListViewDelegate ListViewDelegate.qml diff --git a/examples/declarative/focus/focus.qml b/examples/declarative/focus/focus.qml deleted file mode 100644 index 8c992ae..0000000 --- a/examples/declarative/focus/focus.qml +++ /dev/null @@ -1,69 +0,0 @@ -import Qt 4.7 -import "Core" - -Rectangle { - id: window - - width: 800; height: 480 - color: "#3E606F" - - FocusScope { - id: mainView - - width: parent.width; height: parent.height - focus: true - - GridMenu { - id: gridMenu - - width: parent.width; height: 320 - focus: true - interactive: parent.wantsFocus - } - - ListViews { - id: listViews - y: 320; width: parent.width; height: 320 - } - - Rectangle { - id: shade - color: "black"; opacity: 0; anchors.fill: parent - } - - states: State { - name: "showListViews" - PropertyChanges { target: gridMenu; y: -160 } - PropertyChanges { target: listViews; y: 160 } - } - - transitions: Transition { - NumberAnimation { properties: "y"; duration: 600; easing.type: Easing.OutQuint } - } - } - - Image { - source: "Core/images/arrow.png" - rotation: 90 - anchors.verticalCenter: parent.verticalCenter - - MouseArea { - anchors { fill: parent; leftMargin: -10; topMargin: -10; rightMargin: -10; bottomMargin: -10 } - onClicked: window.state = "contextMenuOpen" - } - } - - ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height } - - states: State { - name: "contextMenuOpen" - when: !mainView.wantsFocus - PropertyChanges { target: contextMenu; x: 0; open: true } - PropertyChanges { target: mainView; x: 130 } - PropertyChanges { target: shade; opacity: 0.25 } - } - - transitions: Transition { - NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: Easing.OutQuint } - } -} diff --git a/examples/declarative/focus/focus.qmlproject b/examples/declarative/focus/focus.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/focus/focus.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/fonts/availableFonts.qml b/examples/declarative/fonts/availableFonts.qml deleted file mode 100644 index defa4ce..0000000 --- a/examples/declarative/fonts/availableFonts.qml +++ /dev/null @@ -1,17 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 480; height: 640; color: "steelblue" - - ListView { - anchors.fill: parent; model: Qt.fontFamilies() - - delegate: Item { - height: 40; width: ListView.view.width - Text { - anchors.centerIn: parent - text: modelData; font.family: modelData; font.pixelSize: 24; color: "white" - } - } - } -} diff --git a/examples/declarative/fonts/banner.qml b/examples/declarative/fonts/banner.qml deleted file mode 100644 index 353354a..0000000 --- a/examples/declarative/fonts/banner.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: screen - - property int pixelSize: screen.height * 1.25 - property color textColor: "lightsteelblue" - property string text: "Hello world! " - - width: 640; height: 320 - color: "steelblue" - - Row { - y: -screen.height / 4.5 - - NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite } - Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - } -} diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml deleted file mode 100644 index f3eac48..0000000 --- a/examples/declarative/fonts/fonts.qml +++ /dev/null @@ -1,64 +0,0 @@ -import Qt 4.7 - -Rectangle { - property string myText: "The quick brown fox jumps over the lazy dog." - - width: 800; height: 480 - color: "steelblue" - - FontLoader { id: fixedFont; name: "Courier" } - FontLoader { id: localFont; source: "fonts/tarzeau_ocr_a.ttf" } - FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } - - Column { - anchors { fill: parent; leftMargin: 10; rightMargin: 10 } - spacing: 15 - - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideRight - font.family: "Times"; font.pointSize: 42 - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideLeft - font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideMiddle - font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideRight - font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideLeft - font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize } - } - Text { - text: { - if (webFont.status == FontLoader.Ready) myText - else if (webFont.status == FontLoader.Loading) "Loading..." - else if (webFont.status == FontLoader.Error) "Error loading font" - } - color: "lightsteelblue" - width: parent.width - elide: Text.ElideMiddle - font.family: webFont.name; font.pointSize: 42 - } - } -} diff --git a/examples/declarative/fonts/fonts.qmlproject b/examples/declarative/fonts/fonts.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/fonts/fonts.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf b/examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf deleted file mode 100644 index cf93f96..0000000 Binary files a/examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf and /dev/null differ diff --git a/examples/declarative/fonts/hello.qml b/examples/declarative/fonts/hello.qml deleted file mode 100644 index 0d6f4cd..0000000 --- a/examples/declarative/fonts/hello.qml +++ /dev/null @@ -1,38 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: screen - - width: 800; height: 480 - color: "black" - - Item { - id: container - x: screen.width / 2; y: screen.height / 2 - - Text { - id: text - anchors.centerIn: parent - color: "white" - text: "Hello world!" - font.pixelSize: 60 - - SequentialAnimation on font.letterSpacing { - loops: Animation.Infinite; - NumberAnimation { from: 100; to: 300; easing.type: Easing.InQuad; duration: 3000 } - ScriptAction { - script: { - container.y = (screen.height / 4) + (Math.random() * screen.height / 2) - container.x = (screen.width / 4) + (Math.random() * screen.width / 2) - } - } - } - - SequentialAnimation on opacity { - loops: Animation.Infinite; - NumberAnimation { from: 1; to: 0; duration: 2600 } - PauseAnimation { duration: 400 } - } - } - } -} diff --git a/examples/declarative/gestures/experimental-gestures.qml b/examples/declarative/gestures/experimental-gestures.qml deleted file mode 100644 index cb190ea..0000000 --- a/examples/declarative/gestures/experimental-gestures.qml +++ /dev/null @@ -1,36 +0,0 @@ -import Qt 4.7 -import Qt.labs.gestures 1.0 - -// Only works on platforms with Touch support. - -Rectangle { - id: rect - width: 320 - height: 180 - - Text { - anchors.centerIn: parent - text: "Tap / TapAndHold / Pan / Pinch / Swipe\nOnly works on platforms with Touch support." - horizontalAlignment: Text.Center - } - - GestureArea { - anchors.fill: parent - focus: true - - // Only some of the many gesture properties are shown. See Gesture documentation. - - onTap: - console.log("tap pos = (",gesture.position.x,",",gesture.position.y,")") - onTapAndHold: - console.log("tap and hold pos = (",gesture.position.x,",",gesture.position.y,")") - onPan: - console.log("pan delta = (",gesture.delta.x,",",gesture.delta.y,") acceleration = ",gesture.acceleration) - onPinch: - console.log("pinch center = (",gesture.centerPoint.x,",",gesture.centerPoint.y,") rotation =",gesture.rotationAngle," scale =",gesture.scaleFactor) - onSwipe: - console.log("swipe angle=",gesture.swipeAngle) - onGesture: - console.log("gesture hot spot = (",gesture.hotSpot.x,",",gesture.hotSpot.y,")") - } -} diff --git a/examples/declarative/gestures/gestures.qmlproject b/examples/declarative/gestures/gestures.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/gestures/gestures.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/gridview/gridview-example.qml b/examples/declarative/gridview/gridview-example.qml deleted file mode 100644 index a5f41fb..0000000 --- a/examples/declarative/gridview/gridview-example.qml +++ /dev/null @@ -1,49 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 300; height: 400 - color: "white" - - ListModel { - id: appModel - ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } - ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } - ListElement { name: "Camera"; icon: "pics/Camera_48.png" } - ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } - ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } - ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } - ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } - } - - Component { - id: appDelegate - - Item { - width: 100; height: 100 - - Image { - id: myIcon - y: 20; anchors.horizontalCenter: parent.horizontalCenter - source: icon - } - Text { - anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } - text: name - } - } - } - - Component { - id: appHighlight - Rectangle { width: 80; height: 80; color: "lightsteelblue" } - } - - GridView { - anchors.fill: parent - cellWidth: 100; cellHeight: 100 - highlight: appHighlight - focus: true - model: appModel - delegate: appDelegate - } -} diff --git a/examples/declarative/gridview/gridview.qmlproject b/examples/declarative/gridview/gridview.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/gridview/gridview.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/gridview/pics/AddressBook_48.png b/examples/declarative/gridview/pics/AddressBook_48.png deleted file mode 100644 index 1ab7c8e..0000000 Binary files a/examples/declarative/gridview/pics/AddressBook_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/AudioPlayer_48.png b/examples/declarative/gridview/pics/AudioPlayer_48.png deleted file mode 100644 index f4b8689..0000000 Binary files a/examples/declarative/gridview/pics/AudioPlayer_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/Camera_48.png b/examples/declarative/gridview/pics/Camera_48.png deleted file mode 100644 index c76b524..0000000 Binary files a/examples/declarative/gridview/pics/Camera_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/DateBook_48.png b/examples/declarative/gridview/pics/DateBook_48.png deleted file mode 100644 index 58f5787..0000000 Binary files a/examples/declarative/gridview/pics/DateBook_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/EMail_48.png b/examples/declarative/gridview/pics/EMail_48.png deleted file mode 100644 index d6d84a6..0000000 Binary files a/examples/declarative/gridview/pics/EMail_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/TodoList_48.png b/examples/declarative/gridview/pics/TodoList_48.png deleted file mode 100644 index 0988448..0000000 Binary files a/examples/declarative/gridview/pics/TodoList_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/VideoPlayer_48.png b/examples/declarative/gridview/pics/VideoPlayer_48.png deleted file mode 100644 index 52638c5..0000000 Binary files a/examples/declarative/gridview/pics/VideoPlayer_48.png and /dev/null differ diff --git a/examples/declarative/i18n/i18n.qmlproject b/examples/declarative/i18n/i18n.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/i18n/i18n.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/imageelements/borderimage/borderimage.qml b/examples/declarative/imageelements/borderimage/borderimage.qml new file mode 100644 index 0000000..c334cea --- /dev/null +++ b/examples/declarative/imageelements/borderimage/borderimage.qml @@ -0,0 +1,57 @@ +import Qt 4.7 +import "content" + +Rectangle { + id: page + width: 1030; height: 540 + + Grid { + anchors.centerIn: parent; spacing: 20 + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round + } + } +} diff --git a/examples/declarative/imageelements/borderimage/borderimage.qmlproject b/examples/declarative/imageelements/borderimage/borderimage.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/imageelements/borderimage/borderimage.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/imageelements/borderimage/content/MyBorderImage.qml b/examples/declarative/imageelements/borderimage/content/MyBorderImage.qml new file mode 100644 index 0000000..b47df7b --- /dev/null +++ b/examples/declarative/imageelements/borderimage/content/MyBorderImage.qml @@ -0,0 +1,50 @@ +import Qt 4.7 + +Item { + id: container + + property alias horizontalMode: image.horizontalTileMode + property alias verticalMode: image.verticalTileMode + property alias source: image.source + + property int minWidth + property int minHeight + property int maxWidth + property int maxHeight + property int margin + + width: 240; height: 240 + + BorderImage { + id: image; anchors.centerIn: parent + + SequentialAnimation on width { + loops: Animation.Infinite + NumberAnimation { + from: container.minWidth; to: container.maxWidth + duration: 2000; easing.type: Easing.InOutQuad + } + NumberAnimation { + from: container.maxWidth; to: container.minWidth + duration: 2000; easing.type: Easing.InOutQuad + } + } + + SequentialAnimation on height { + loops: Animation.Infinite + NumberAnimation { + from: container.minHeight; to: container.maxHeight + duration: 2000; easing.type: Easing.InOutQuad + } + NumberAnimation { + from: container.maxHeight; to: container.minHeight + duration: 2000; easing.type: Easing.InOutQuad + } + } + + border.top: container.margin + border.left: container.margin + border.bottom: container.margin + border.right: container.margin + } +} diff --git a/examples/declarative/imageelements/borderimage/content/ShadowRectangle.qml b/examples/declarative/imageelements/borderimage/content/ShadowRectangle.qml new file mode 100644 index 0000000..629478b --- /dev/null +++ b/examples/declarative/imageelements/borderimage/content/ShadowRectangle.qml @@ -0,0 +1,14 @@ +import Qt 4.7 + +Item { + property alias color : rectangle.color + + BorderImage { + anchors.fill: rectangle + anchors { leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } + border { left: 10; top: 10; right: 10; bottom: 10 } + source: "shadow.png"; smooth: true + } + + Rectangle { id: rectangle; anchors.fill: parent } +} diff --git a/examples/declarative/imageelements/borderimage/content/bw.png b/examples/declarative/imageelements/borderimage/content/bw.png new file mode 100644 index 0000000..486eaae Binary files /dev/null and b/examples/declarative/imageelements/borderimage/content/bw.png differ diff --git a/examples/declarative/imageelements/borderimage/content/colors-round.sci b/examples/declarative/imageelements/borderimage/content/colors-round.sci new file mode 100644 index 0000000..506f6f5 --- /dev/null +++ b/examples/declarative/imageelements/borderimage/content/colors-round.sci @@ -0,0 +1,7 @@ +border.left:30 +border.top:30 +border.right:30 +border.bottom:30 +horizontalTileRule:Round +verticalTileRule:Round +source:colors.png diff --git a/examples/declarative/imageelements/borderimage/content/colors-stretch.sci b/examples/declarative/imageelements/borderimage/content/colors-stretch.sci new file mode 100644 index 0000000..e4989a7 --- /dev/null +++ b/examples/declarative/imageelements/borderimage/content/colors-stretch.sci @@ -0,0 +1,5 @@ +border.left:30 +border.top:30 +border.right:30 +border.bottom:30 +source:colors.png diff --git a/examples/declarative/imageelements/borderimage/content/colors.png b/examples/declarative/imageelements/borderimage/content/colors.png new file mode 100644 index 0000000..dfb62f3 Binary files /dev/null and b/examples/declarative/imageelements/borderimage/content/colors.png differ diff --git a/examples/declarative/imageelements/borderimage/content/shadow.png b/examples/declarative/imageelements/borderimage/content/shadow.png new file mode 100644 index 0000000..431af85 Binary files /dev/null and b/examples/declarative/imageelements/borderimage/content/shadow.png differ diff --git a/examples/declarative/imageelements/borderimage/shadows.qml b/examples/declarative/imageelements/borderimage/shadows.qml new file mode 100644 index 0000000..a08d133 --- /dev/null +++ b/examples/declarative/imageelements/borderimage/shadows.qml @@ -0,0 +1,24 @@ +import Qt 4.7 +import "content" + +Rectangle { + id: window + + width: 480; height: 320 + color: "gray" + + ShadowRectangle { + anchors.centerIn: parent; width: 250; height: 250 + color: "lightsteelblue" + } + + ShadowRectangle { + anchors.centerIn: parent; width: 200; height: 200 + color: "steelblue" + } + + ShadowRectangle { + anchors.centerIn: parent; width: 150; height: 150 + color: "thistle" + } +} diff --git a/examples/declarative/imageelements/image/face_fit.qml b/examples/declarative/imageelements/image/face_fit.qml new file mode 100644 index 0000000..52cd4c2 --- /dev/null +++ b/examples/declarative/imageelements/image/face_fit.qml @@ -0,0 +1,26 @@ +import Qt 4.7 + +// Here, we implement a hybrid of the "scale to fit" and "scale and crop" +// behaviours which will crop up to 25% from *one* dimension if necessary +// to fully scale the other. This is a realistic algorithm, for example +// when the edges of the image contain less vital information than the +// center - such as a face. +// +Rectangle { + // default size: whole image, unscaled + width: face.width + height: face.height + color: "gray" + clip: true + + Image { + id: face + smooth: true + anchors.centerIn: parent + source: "pics/face.png" + x: (parent.width-width*scale)/2 + y: (parent.height-height*scale)/2 + scale: Math.max(Math.min(parent.width/width*1.333,parent.height/height), + Math.min(parent.width/width,parent.height/height*1.333)) + } +} diff --git a/examples/declarative/imageelements/image/face_fit_animated.qml b/examples/declarative/imageelements/image/face_fit_animated.qml new file mode 100644 index 0000000..63fc9c6 --- /dev/null +++ b/examples/declarative/imageelements/image/face_fit_animated.qml @@ -0,0 +1,28 @@ +import Qt 4.7 + +// Here, we extend the "face_fit" example with animation to show how truly +// diverse and usage-specific behaviours are made possible by NOT putting a +// hard-coded aspect ratio feature into the Image primitive. +// +Rectangle { + // default size: whole image, unscaled + width: face.width + height: face.height + color: "gray" + clip: true + + Image { + id: face + smooth: true + anchors.centerIn: parent + source: "pics/face.png" + x: (parent.width-width*scale)/2 + y: (parent.height-height*scale)/2 + SpringFollow on scale { + to: Math.max(Math.min(face.parent.width/face.width*1.333,face.parent.height/face.height), + Math.min(face.parent.width/face.width,face.parent.height/face.height*1.333)) + spring: 1 + damping: 0.05 + } + } +} diff --git a/examples/declarative/imageelements/image/image.qmlproject b/examples/declarative/imageelements/image/image.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/imageelements/image/image.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/imageelements/image/pics/face.png b/examples/declarative/imageelements/image/pics/face.png new file mode 100644 index 0000000..3d66d72 Binary files /dev/null and b/examples/declarative/imageelements/image/pics/face.png differ diff --git a/examples/declarative/imageelements/image/scale_and_crop.qml b/examples/declarative/imageelements/image/scale_and_crop.qml new file mode 100644 index 0000000..a438104 --- /dev/null +++ b/examples/declarative/imageelements/image/scale_and_crop.qml @@ -0,0 +1,21 @@ +import Qt 4.7 + +// Here, we implement "Scale and Crop" behaviour. +// +Rectangle { + // default size: whole image, unscaled + width: face.width + height: face.height + color: "gray" + clip: true + + Image { + id: face + smooth: true + anchors.centerIn: parent + source: "pics/face.png" + x: (parent.width-width*scale)/2 + y: (parent.height-height*scale)/2 + scale: Math.max(parent.width/width,parent.height/height) + } +} diff --git a/examples/declarative/imageelements/image/scale_and_crop_simple.qml b/examples/declarative/imageelements/image/scale_and_crop_simple.qml new file mode 100644 index 0000000..1160ec5 --- /dev/null +++ b/examples/declarative/imageelements/image/scale_and_crop_simple.qml @@ -0,0 +1,20 @@ +import Qt 4.7 + +// Here, we implement "Scale to Fit" behaviour, using the +// fillMode property. +// +Rectangle { + // default size: whole image, unscaled + width: face.width + height: face.height + color: "gray" + clip: true + + Image { + id: face + smooth: true + source: "pics/face.png" + fillMode: Image.PreserveAspectCrop + anchors.fill: parent + } +} diff --git a/examples/declarative/imageelements/image/scale_and_sidecrop.qml b/examples/declarative/imageelements/image/scale_and_sidecrop.qml new file mode 100644 index 0000000..5593ab8 --- /dev/null +++ b/examples/declarative/imageelements/image/scale_and_sidecrop.qml @@ -0,0 +1,22 @@ +import Qt 4.7 + +// Here, we implement a variant of "Scale and Crop" behaviour, where we +// crop the sides if necessary to fully fit vertically, but not the reverse. +// +Rectangle { + // default size: whole image, unscaled + width: face.width + height: face.height + color: "gray" + clip: true + + Image { + id: face + smooth: true + anchors.centerIn: parent + source: "pics/face.png" + x: (parent.width-width*scale)/2 + y: (parent.height-height*scale)/2 + scale: parent.height/height + } +} diff --git a/examples/declarative/imageelements/image/scale_to_fit.qml b/examples/declarative/imageelements/image/scale_to_fit.qml new file mode 100644 index 0000000..724a36e --- /dev/null +++ b/examples/declarative/imageelements/image/scale_to_fit.qml @@ -0,0 +1,22 @@ +import Qt 4.7 + +// Here, we implement "Scale to Fit" behaviour "manually", rather +// than using the preserveAspect property. +// +Rectangle { + // default size: whole image, unscaled + width: face.width + height: face.height + color: "gray" + clip: true + + Image { + id: face + smooth: true + anchors.centerIn: parent + source: "pics/face.png" + x: (parent.width-width*scale)/2 + y: (parent.height-height*scale)/2 + scale: Math.min(parent.width/width,parent.height/height) + } +} diff --git a/examples/declarative/imageelements/image/scale_to_fit_simple.qml b/examples/declarative/imageelements/image/scale_to_fit_simple.qml new file mode 100644 index 0000000..0e960b4 --- /dev/null +++ b/examples/declarative/imageelements/image/scale_to_fit_simple.qml @@ -0,0 +1,20 @@ +import Qt 4.7 + +// Here, we implement "Scale to Fit" behaviour, using the +// fillMode property. +// +Rectangle { + // default size: whole image, unscaled + width: face.width + height: face.height + color: "gray" + clip: true + + Image { + id: face + smooth: true + source: "pics/face.png" + fillMode: Image.PreserveAspectFit + anchors.fill: parent + } +} diff --git a/examples/declarative/imageelements/imageelements.qmlproject b/examples/declarative/imageelements/imageelements.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/imageelements/imageelements.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/imageprovider/ImageProviderCore/qmldir b/examples/declarative/imageprovider/ImageProviderCore/qmldir deleted file mode 100644 index 1028590..0000000 --- a/examples/declarative/imageprovider/ImageProviderCore/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -plugin imageprovider - diff --git a/examples/declarative/imageprovider/imageprovider-example.qml b/examples/declarative/imageprovider/imageprovider-example.qml deleted file mode 100644 index d774112..0000000 --- a/examples/declarative/imageprovider/imageprovider-example.qml +++ /dev/null @@ -1,25 +0,0 @@ -import Qt 4.7 -import "ImageProviderCore" -//![0] -ListView { - width: 100; height: 100 - anchors.fill: parent - - model: myModel - - delegate: Component { - Item { - width: 100 - height: 50 - Text { - text: "Loading..." - anchors.centerIn: parent - } - Image { - source: modelData - sourceSize: "50x25" - } - } - } -} -//![0] diff --git a/examples/declarative/imageprovider/imageprovider.cpp b/examples/declarative/imageprovider/imageprovider.cpp deleted file mode 100644 index 4c4aa94..0000000 --- a/examples/declarative/imageprovider/imageprovider.cpp +++ /dev/null @@ -1,118 +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 demonstration applications 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 -#include - -/* - This example illustrates using a QDeclarativeImageProvider to serve - images asynchronously. -*/ - -//![0] -class ColorImageProvider : public QDeclarativeImageProvider -{ -public: - // This is run in a low priority thread. - QImage request(const QString &id, QSize *size, const QSize &req_size) - { - if (size) *size = QSize(100,50); - QImage image( - req_size.width() > 0 ? req_size.width() : 100, - req_size.height() > 0 ? req_size.height() : 50, - QImage::Format_RGB32); - image.fill(QColor(id).rgba()); - QPainter p(&image); - QFont f = p.font(); - f.setPixelSize(30); - p.setFont(f); - p.setPen(Qt::black); - if (req_size.isValid()) - p.scale(req_size.width()/100.0, req_size.height()/50.0); - p.drawText(QRectF(0,0,100,50),Qt::AlignCenter,id); - return image; - } -}; - - -class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) { - Q_UNUSED(uri); - - } - - void initializeEngine(QDeclarativeEngine *engine, const char *uri) { - Q_UNUSED(uri); - - engine->addImageProvider("colors", new ColorImageProvider); - - QStringList dataList; - dataList.append("image://colors/red"); - dataList.append("image://colors/green"); - dataList.append("image://colors/blue"); - dataList.append("image://colors/brown"); - dataList.append("image://colors/orange"); - dataList.append("image://colors/purple"); - dataList.append("image://colors/yellow"); - - QDeclarativeContext *ctxt = engine->rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); - } - -}; - -#include "imageprovider.moc" - -Q_EXPORT_PLUGIN(ImageProviderExtensionPlugin); -//![0] - diff --git a/examples/declarative/imageprovider/imageprovider.pro b/examples/declarative/imageprovider/imageprovider.pro deleted file mode 100644 index 945a301..0000000 --- a/examples/declarative/imageprovider/imageprovider.pro +++ /dev/null @@ -1,25 +0,0 @@ -TEMPLATE = lib -TARGET = imageprovider -QT += declarative -CONFIG += qt plugin - -TARGET = $$qtLibraryTarget($$TARGET) -DESTDIR = ImageProviderCore - -# Input -SOURCES += imageprovider.cpp - -sources.files = $$SOURCES imageprovider.qml imageprovider.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider - -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider/ImageProviderCore - -ImageProviderCore_sources.files = \ - ImageProviderCore/qmldir -ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider/ImageProviderCore - -symbian:{ - TARGET.EPOCALLOWDLLDATA=1 -} - -INSTALLS = sources ImageProviderCore_sources target diff --git a/examples/declarative/imageprovider/imageprovider.qmlproject b/examples/declarative/imageprovider/imageprovider.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/imageprovider/imageprovider.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/images/content/lemonade.jpg b/examples/declarative/images/content/lemonade.jpg deleted file mode 100644 index db445c9..0000000 Binary files a/examples/declarative/images/content/lemonade.jpg and /dev/null differ diff --git a/examples/declarative/images/images.qml b/examples/declarative/images/images.qml deleted file mode 100644 index e48ad50..0000000 --- a/examples/declarative/images/images.qml +++ /dev/null @@ -1,72 +0,0 @@ -import Qt 4.7 - -Rectangle { - color: "white" - width: grid.width + 50 - height: grid.height + 50 - - Grid { - id: grid - x: 25; y: 25 - columns: 3 - - Image { - source: "content/lemonade.jpg" - } - - Image { - sourceSize.width: 50 - sourceSize.height: 50 - source: "content/lemonade.jpg" - } - - Image { - sourceSize.width: 50 - sourceSize.height: 50 - smooth: true - source: "content/lemonade.jpg" - } - - Image { - scale: 1/3 - source: "content/lemonade.jpg" - } - - Image { - scale: 1/3 - sourceSize.width: 50 - sourceSize.height: 50 - source: "content/lemonade.jpg" - } - - Image { - scale: 1/3 - sourceSize.width: 50 - sourceSize.height: 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 } - sourceSize.width: 50 - sourceSize.height: 50 - source: "content/lemonade.jpg" - } - - Image { - width: 50; height: 50 - transform: Translate { x: 50 } - sourceSize: "50x50" // syntactic sugar - smooth: true - source: "content/lemonade.jpg" - } - } -} diff --git a/examples/declarative/images/images.qmlproject b/examples/declarative/images/images.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/images/images.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml b/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml new file mode 100644 index 0000000..49a54bc --- /dev/null +++ b/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml @@ -0,0 +1,18 @@ +import Qt 4.7 + +FocusScope { + id: container + + property bool open: false + + Item { + anchors.fill: parent + + Rectangle { + anchors.fill: parent + color: "#D1DBBD" + focus: true + Keys.onRightPressed: mainView.focus = true + } + } +} diff --git a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml new file mode 100644 index 0000000..3f727fd --- /dev/null +++ b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml @@ -0,0 +1,61 @@ +import Qt 4.7 + +FocusScope { + property alias interactive: gridView.interactive + + onWantsFocusChanged: if (wantsFocus) mainView.state = "" + + Rectangle { + anchors.fill: parent + clip: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#193441" } + GradientStop { position: 1.0; color: Qt.darker("#193441") } + } + + GridView { + id: gridView + x: 20; width: parent.width - 40; height: parent.height + cellWidth: 152; cellHeight: 152 + focus: true + model: 12 + KeyNavigation.down: listViews + KeyNavigation.left: contextMenu + + delegate: Item { + id: container + width: GridView.view.cellWidth; height: GridView.view.cellHeight + + Rectangle { + id: content + color: "transparent" + smooth: true + anchors.centerIn: parent; width: container.width - 40; height: container.height - 40; radius: 10 + + Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 } + Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + + onClicked: { + GridView.view.currentIndex = index + container.forceFocus() + } + } + + states: State { + name: "active"; when: container.focus == true + PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } + } + + transitions: Transition { + NumberAnimation { properties: "scale"; duration: 100 } + } + } + } + } +} diff --git a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml new file mode 100644 index 0000000..14e2548 --- /dev/null +++ b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml @@ -0,0 +1,40 @@ +import Qt 4.7 + +Item { + id: container + x: 5; width: ListView.view.width - 10; height: 60 + + Rectangle { + id: content + anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 + color: "transparent" + smooth: true + radius: 10 + + Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 } + Text { + text: "List element " + (index + 1); color: "#193441"; font.bold: false; anchors.centerIn: parent + font.pixelSize: 14 + } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + + onClicked: { + ListView.view.currentIndex = index + container.forceFocus() + } + } + + states: State { + name: "active"; when: container.focus == true + PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } + } + + transitions: Transition { + NumberAnimation { properties: "scale"; duration: 100 } + } +} diff --git a/examples/declarative/keyinteraction/focus/Core/ListViews.qml b/examples/declarative/keyinteraction/focus/Core/ListViews.qml new file mode 100644 index 0000000..32a5d4c --- /dev/null +++ b/examples/declarative/keyinteraction/focus/Core/ListViews.qml @@ -0,0 +1,62 @@ +import Qt 4.7 + +FocusScope { + clip: true + + onWantsFocusChanged: if (wantsFocus) mainView.state = "showListViews" + + ListView { + id: list1 + y: wantsFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20 + focus: true + KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + ListView { + id: list2 + y: wantsFocus ? 10 : 40; x: parent.width / 3; width: parent.width / 3; height: parent.height - 20 + KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + ListView { + id: list3 + y: wantsFocus ? 10 : 40; x: 2 * parent.width / 3; width: parent.width / 3; height: parent.height - 20 + KeyNavigation.up: gridMenu; KeyNavigation.left: list2 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + Rectangle { width: parent.width; height: 1; color: "#D1DBBD" } + + Rectangle { + y: 1; width: parent.width; height: 10 + gradient: Gradient { + GradientStop { position: 0.0; color: "#3E606F" } + GradientStop { position: 1.0; color: "transparent" } + } + } + + Rectangle { + y: parent.height - 10; width: parent.width; height: 10 + gradient: Gradient { + GradientStop { position: 1.0; color: "#3E606F" } + GradientStop { position: 0.0; color: "transparent" } + } + } +} diff --git a/examples/declarative/keyinteraction/focus/Core/images/arrow.png b/examples/declarative/keyinteraction/focus/Core/images/arrow.png new file mode 100644 index 0000000..14978c2 Binary files /dev/null and b/examples/declarative/keyinteraction/focus/Core/images/arrow.png differ diff --git a/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png b/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png new file mode 100644 index 0000000..14ddf2a Binary files /dev/null and b/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png differ diff --git a/examples/declarative/keyinteraction/focus/Core/qmldir b/examples/declarative/keyinteraction/focus/Core/qmldir new file mode 100644 index 0000000..e25d63c --- /dev/null +++ b/examples/declarative/keyinteraction/focus/Core/qmldir @@ -0,0 +1,4 @@ +ContextMenu ContextMenu.qml +GridMenu GridMenu.qml +ListViews ListViews.qml +ListViewDelegate ListViewDelegate.qml diff --git a/examples/declarative/keyinteraction/focus/focus.qml b/examples/declarative/keyinteraction/focus/focus.qml new file mode 100644 index 0000000..8c992ae --- /dev/null +++ b/examples/declarative/keyinteraction/focus/focus.qml @@ -0,0 +1,69 @@ +import Qt 4.7 +import "Core" + +Rectangle { + id: window + + width: 800; height: 480 + color: "#3E606F" + + FocusScope { + id: mainView + + width: parent.width; height: parent.height + focus: true + + GridMenu { + id: gridMenu + + width: parent.width; height: 320 + focus: true + interactive: parent.wantsFocus + } + + ListViews { + id: listViews + y: 320; width: parent.width; height: 320 + } + + Rectangle { + id: shade + color: "black"; opacity: 0; anchors.fill: parent + } + + states: State { + name: "showListViews" + PropertyChanges { target: gridMenu; y: -160 } + PropertyChanges { target: listViews; y: 160 } + } + + transitions: Transition { + NumberAnimation { properties: "y"; duration: 600; easing.type: Easing.OutQuint } + } + } + + Image { + source: "Core/images/arrow.png" + rotation: 90 + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + anchors { fill: parent; leftMargin: -10; topMargin: -10; rightMargin: -10; bottomMargin: -10 } + onClicked: window.state = "contextMenuOpen" + } + } + + ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height } + + states: State { + name: "contextMenuOpen" + when: !mainView.wantsFocus + PropertyChanges { target: contextMenu; x: 0; open: true } + PropertyChanges { target: mainView; x: 130 } + PropertyChanges { target: shade; opacity: 0.25 } + } + + transitions: Transition { + NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: Easing.OutQuint } + } +} diff --git a/examples/declarative/keyinteraction/focus/focus.qmlproject b/examples/declarative/keyinteraction/focus/focus.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/keyinteraction/focus/focus.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/keyinteraction/keyinteraction.qmlproject b/examples/declarative/keyinteraction/keyinteraction.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/keyinteraction/keyinteraction.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.cpp b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.cpp deleted file mode 100644 index 25cf994..0000000 --- a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.cpp +++ /dev/null @@ -1,366 +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$ -** -****************************************************************************/ - -#include "graphicslayouts_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -LinearLayoutAttached::LinearLayoutAttached(QObject *parent) -: QObject(parent), _stretch(1), _alignment(Qt::AlignCenter), _spacing(0) -{ -} - -void LinearLayoutAttached::setStretchFactor(int f) -{ - if (_stretch == f) - return; - - _stretch = f; - emit stretchChanged(reinterpret_cast(parent()), _stretch); -} - -void LinearLayoutAttached::setSpacing(int s) -{ - if (_spacing == s) - return; - - _spacing = s; - emit spacingChanged(reinterpret_cast(parent()), _spacing); -} - -void LinearLayoutAttached::setAlignment(Qt::Alignment a) -{ - if (_alignment == a) - return; - - _alignment = a; - emit alignmentChanged(reinterpret_cast(parent()), _alignment); -} - -QGraphicsLinearLayoutStretchItemObject::QGraphicsLinearLayoutStretchItemObject(QObject *parent) - : QObject(parent) -{ -} - -QSizeF QGraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -{ -Q_UNUSED(which); -Q_UNUSED(constraint); -return QSizeF(); -} - - -QGraphicsLinearLayoutObject::QGraphicsLinearLayoutObject(QObject *parent) -: QObject(parent) -{ -} - -QGraphicsLinearLayoutObject::~QGraphicsLinearLayoutObject() -{ -} - -void QGraphicsLinearLayoutObject::insertLayoutItem(int index, QGraphicsLayoutItem *item) -{ -insertItem(index, item); - -//connect attached properties -if (LinearLayoutAttached *obj = attachedProperties.value(item)) { - setStretchFactor(item, obj->stretchFactor()); - setAlignment(item, obj->alignment()); - updateSpacing(item, obj->spacing()); - QObject::connect(obj, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)), - this, SLOT(updateStretch(QGraphicsLayoutItem*,int))); - QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), - this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); - QObject::connect(obj, SIGNAL(spacingChanged(QGraphicsLayoutItem*,int)), - this, SLOT(updateSpacing(QGraphicsLayoutItem*,int))); - //### need to disconnect when widget is removed? -} -} - -//### is there a better way to do this? -void QGraphicsLinearLayoutObject::clearChildren() -{ -for (int i = 0; i < count(); ++i) - removeAt(i); -} - -qreal QGraphicsLinearLayoutObject::contentsMargin() const -{ - qreal a,b,c,d; - getContentsMargins(&a, &b, &c, &d); - if(a==b && a==c && a==d) - return a; - return -1; -} - -void QGraphicsLinearLayoutObject::setContentsMargin(qreal m) -{ - setContentsMargins(m,m,m,m); -} - -void QGraphicsLinearLayoutObject::updateStretch(QGraphicsLayoutItem *item, int stretch) -{ -QGraphicsLinearLayout::setStretchFactor(item, stretch); -} - -void QGraphicsLinearLayoutObject::updateSpacing(QGraphicsLayoutItem* item, int spacing) -{ - for(int i=0; i < count(); i++){ - if(itemAt(i) == item){ //I do not see the reverse function, which is why we must loop over all items - QGraphicsLinearLayout::setItemSpacing(i, spacing); - return; - } - } -} - -void QGraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) -{ -QGraphicsLinearLayout::setAlignment(item, alignment); -} - -QHash QGraphicsLinearLayoutObject::attachedProperties; -LinearLayoutAttached *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj) -{ -// ### This is not allowed - you must attach to any object -if (!qobject_cast(obj)) - return 0; -LinearLayoutAttached *rv = new LinearLayoutAttached(obj); -attachedProperties.insert(qobject_cast(obj), rv); -return rv; -} - -////////////////////////////////////////////////////////////////////////////////////////////////////// -// QGraphicsGridLayout-related classes -////////////////////////////////////////////////////////////////////////////////////////////////////// -GridLayoutAttached::GridLayoutAttached(QObject *parent) -: QObject(parent), _row(-1), _column(-1), _rowspan(1), _colspan(1), _alignment(-1), _rowstretch(-1), - _colstretch(-1), _rowspacing(-1), _colspacing(-1), _rowprefheight(-1), _rowmaxheight(-1), _rowminheight(-1), - _rowfixheight(-1), _colprefwidth(-1), _colmaxwidth(-1), _colminwidth(-1), _colfixwidth(-1) -{ -} - -void GridLayoutAttached::setRow(int r) -{ - if (_row == r) - return; - - _row = r; - //emit rowChanged(reinterpret_cast(parent()), _row); -} - -void GridLayoutAttached::setColumn(int c) -{ - if (_column == c) - return; - - _column = c; - //emit columnChanged(reinterpret_cast(parent()), _column); -} - -void GridLayoutAttached::setRowSpan(int rs) -{ - if (_rowspan == rs) - return; - - _rowspan = rs; - //emit rowSpanChanged(reinterpret_cast(parent()), _rowSpan); -} - -void GridLayoutAttached::setColumnSpan(int cs) -{ - if (_colspan == cs) - return; - - _colspan = cs; - //emit columnSpanChanged(reinterpret_cast(parent()), _columnSpan); -} - -void GridLayoutAttached::setAlignment(Qt::Alignment a) -{ - if (_alignment == a) - return; - - _alignment = a; - emit alignmentChanged(reinterpret_cast(parent()), _alignment); -} - -void GridLayoutAttached::setRowStretchFactor(int f) -{ - _rowstretch = f; -} - -void GridLayoutAttached::setColumnStretchFactor(int f) -{ - _colstretch = f; -} - -void GridLayoutAttached::setRowSpacing(int s) -{ - _rowspacing = s; -} - -void GridLayoutAttached::setColumnSpacing(int s) -{ - _colspacing = s; -} - - -QGraphicsGridLayoutObject::QGraphicsGridLayoutObject(QObject *parent) -: QObject(parent) -{ -} - -QGraphicsGridLayoutObject::~QGraphicsGridLayoutObject() -{ -} - -void QGraphicsGridLayoutObject::addWidget(QGraphicsWidget *wid) -{ -//use attached properties -if (QObject *obj = attachedProperties.value(qobject_cast(wid))) { - int row = static_cast(obj)->row(); - int column = static_cast(obj)->column(); - int rowSpan = static_cast(obj)->rowSpan(); - int columnSpan = static_cast(obj)->columnSpan(); - if (row == -1 || column == -1) { - qWarning() << "Must set row and column for an item in a grid layout"; - return; - } - addItem(wid, row, column, rowSpan, columnSpan); -} -} - -void QGraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item) -{ -//use attached properties -if (GridLayoutAttached *obj = attachedProperties.value(item)) { - int row = obj->row(); - int column = obj->column(); - int rowSpan = obj->rowSpan(); - int columnSpan = obj->columnSpan(); - Qt::Alignment alignment = obj->alignment(); - if (row == -1 || column == -1) { - qWarning() << "Must set row and column for an item in a grid layout"; - return; - } - if(obj->rowSpacing() != -1) - setRowSpacing(row, obj->rowSpacing()); - if(obj->columnSpacing() != -1) - setColumnSpacing(column, obj->columnSpacing()); - if(obj->rowStretchFactor() != -1) - setRowStretchFactor(row, obj->rowStretchFactor()); - if(obj->columnStretchFactor() != -1) - setColumnStretchFactor(column, obj->columnStretchFactor()); - if(obj->rowPreferredHeight() != -1) - setRowPreferredHeight(row, obj->rowPreferredHeight()); - if(obj->rowMaximumHeight() != -1) - setRowMaximumHeight(row, obj->rowMaximumHeight()); - if(obj->rowMinimumHeight() != -1) - setRowMinimumHeight(row, obj->rowMinimumHeight()); - if(obj->rowFixedHeight() != -1) - setRowFixedHeight(row, obj->rowFixedHeight()); - if(obj->columnPreferredWidth() != -1) - setColumnPreferredWidth(row, obj->columnPreferredWidth()); - if(obj->columnMaximumWidth() != -1) - setColumnMaximumWidth(row, obj->columnMaximumWidth()); - if(obj->columnMinimumWidth() != -1) - setColumnMinimumWidth(row, obj->columnMinimumWidth()); - if(obj->columnFixedWidth() != -1) - setColumnFixedWidth(row, obj->columnFixedWidth()); - addItem(item, row, column, rowSpan, columnSpan); - if (alignment != -1) - setAlignment(item,alignment); - QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), - this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); - //### need to disconnect when widget is removed? -} -} - -//### is there a better way to do this? -void QGraphicsGridLayoutObject::clearChildren() -{ -for (int i = 0; i < count(); ++i) - removeAt(i); -} - -qreal QGraphicsGridLayoutObject::spacing() const -{ -if (verticalSpacing() == horizontalSpacing()) - return verticalSpacing(); -return -1; //### -} - -qreal QGraphicsGridLayoutObject::contentsMargin() const -{ - qreal a,b,c,d; - getContentsMargins(&a, &b, &c, &d); - if(a==b && a==c && a==d) - return a; - return -1; -} - -void QGraphicsGridLayoutObject::setContentsMargin(qreal m) -{ - setContentsMargins(m,m,m,m); -} - - -void QGraphicsGridLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) -{ -QGraphicsGridLayout::setAlignment(item, alignment); -} - -QHash QGraphicsGridLayoutObject::attachedProperties; -GridLayoutAttached *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj) -{ -// ### This is not allowed - you must attach to any object -if (!qobject_cast(obj)) - return 0; -GridLayoutAttached *rv = new GridLayoutAttached(obj); -attachedProperties.insert(qobject_cast(obj), rv); -return rv; -} - -QT_END_NAMESPACE diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro deleted file mode 100644 index e5d91b2..0000000 --- a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = app -TARGET = graphicslayouts -QT += declarative - -SOURCES += \ - graphicslayouts.cpp \ - main.cpp - -HEADERS += \ - graphicslayouts_p.h - -RESOURCES += \ - graphicslayouts.qrc diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml deleted file mode 100644 index fcd78d5..0000000 --- a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml +++ /dev/null @@ -1,77 +0,0 @@ -import Qt 4.7 -import GraphicsLayouts 4.7 - -Item { - id: resizable - - width: 800 - height: 400 - - QGraphicsWidget { - size.width: parent.width/2 - size.height: parent.height - - layout: QGraphicsLinearLayout { - LayoutItem { - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { color: "yellow"; anchors.fill: parent } - } - LayoutItem { - minimumSize: "100x100" - maximumSize: "400x400" - preferredSize: "200x200" - Rectangle { color: "green"; anchors.fill: parent } - } - } - } - QGraphicsWidget { - x: parent.width/2 - size.width: parent.width/2 - size.height: parent.height - - layout: QGraphicsGridLayout { - LayoutItem { - QGraphicsGridLayout.row: 0 - QGraphicsGridLayout.column: 0 - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { color: "red"; anchors.fill: parent } - } - LayoutItem { - QGraphicsGridLayout.row: 1 - QGraphicsGridLayout.column: 0 - minimumSize: "100x100" - maximumSize: "200x200" - preferredSize: "100x100" - Rectangle { color: "orange"; anchors.fill: parent } - } - LayoutItem { - QGraphicsGridLayout.row: 2 - QGraphicsGridLayout.column: 0 - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "200x200" - Rectangle { color: "yellow"; anchors.fill: parent } - } - LayoutItem { - QGraphicsGridLayout.row: 0 - QGraphicsGridLayout.column: 1 - minimumSize: "100x100" - maximumSize: "200x200" - preferredSize: "200x200" - Rectangle { color: "green"; anchors.fill: parent } - } - LayoutItem { - QGraphicsGridLayout.row: 1 - QGraphicsGridLayout.column: 1 - minimumSize: "100x100" - maximumSize: "400x400" - preferredSize: "200x200" - Rectangle { color: "blue"; anchors.fill: parent } - } - } - } -} diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc deleted file mode 100644 index a199f8d..0000000 --- a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - graphicslayouts.qml - - diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts_p.h b/examples/declarative/layouts/graphicsLayouts/graphicslayouts_p.h deleted file mode 100644 index ea9c614..0000000 --- a/examples/declarative/layouts/graphicsLayouts/graphicslayouts_p.h +++ /dev/null @@ -1,303 +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$ -** -****************************************************************************/ - -#ifndef GRAPHICSLAYOUTS_H -#define GRAPHICSLAYOUTS_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QGraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayoutItem) -public: - QGraphicsLinearLayoutStretchItemObject(QObject *parent = 0); - - virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const; -}; - -class LinearLayoutAttached; -class QGraphicsLinearLayoutObject : public QObject, public QGraphicsLinearLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) - - Q_PROPERTY(QDeclarativeListProperty children READ children) - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) - Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsLinearLayoutObject(QObject * = 0); - ~QGraphicsLinearLayoutObject(); - - QDeclarativeListProperty children() { return QDeclarativeListProperty(this, 0, children_append, children_count, children_at, children_clear); } - - static LinearLayoutAttached *qmlAttachedProperties(QObject *); - - qreal contentsMargin() const; - void setContentsMargin(qreal); - -private Q_SLOTS: - void updateStretch(QGraphicsLayoutItem*,int); - void updateSpacing(QGraphicsLayoutItem*,int); - void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); - -private: - friend class LinearLayoutAttached; - void clearChildren(); - void insertLayoutItem(int, QGraphicsLayoutItem *); - static QHash attachedProperties; - - static void children_append(QDeclarativeListProperty *prop, QGraphicsLayoutItem *item) { - static_cast(prop->object)->insertLayoutItem(-1, item); - } - - static void children_clear(QDeclarativeListProperty *prop) { - static_cast(prop->object)->clearChildren(); - } - - static int children_count(QDeclarativeListProperty *prop) { - return static_cast(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QDeclarativeListProperty *prop, int index) { - return static_cast(prop->object)->itemAt(index); - } -}; - -class GridLayoutAttached; -class QGraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) - - Q_PROPERTY(QDeclarativeListProperty children READ children) - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) - Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) - Q_PROPERTY(qreal verticalSpacing READ verticalSpacing WRITE setVerticalSpacing) - Q_PROPERTY(qreal horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsGridLayoutObject(QObject * = 0); - ~QGraphicsGridLayoutObject(); - - QDeclarativeListProperty children() { return QDeclarativeListProperty(this, 0, children_append, children_count, children_at, children_clear); } - - qreal spacing() const; - qreal contentsMargin() const; - void setContentsMargin(qreal); - - static GridLayoutAttached *qmlAttachedProperties(QObject *); - -private Q_SLOTS: - void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); - -private: - friend class GraphicsLayoutAttached; - void addWidget(QGraphicsWidget *); - void clearChildren(); - void addLayoutItem(QGraphicsLayoutItem *); - static QHash attachedProperties; - - static void children_append(QDeclarativeListProperty *prop, QGraphicsLayoutItem *item) { - static_cast(prop->object)->addLayoutItem(item); - } - - static void children_clear(QDeclarativeListProperty *prop) { - static_cast(prop->object)->clearChildren(); - } - - static int children_count(QDeclarativeListProperty *prop) { - return static_cast(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QDeclarativeListProperty *prop, int index) { - return static_cast(prop->object)->itemAt(index); - } -}; - -class LinearLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int stretchFactor READ stretchFactor WRITE setStretchFactor NOTIFY stretchChanged) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) - Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) -public: - LinearLayoutAttached(QObject *parent); - - int stretchFactor() const { return _stretch; } - void setStretchFactor(int f); - Qt::Alignment alignment() const { return _alignment; } - void setAlignment(Qt::Alignment a); - int spacing() const { return _spacing; } - void setSpacing(int s); - -Q_SIGNALS: - void stretchChanged(QGraphicsLayoutItem*,int); - void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); - void spacingChanged(QGraphicsLayoutItem*,int); - -private: - int _stretch; - Qt::Alignment _alignment; - int _spacing; -}; - -class GridLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int row READ row WRITE setRow) - Q_PROPERTY(int column READ column WRITE setColumn) - Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan) - Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) - Q_PROPERTY(int rowStretchFactor READ rowStretchFactor WRITE setRowStretchFactor) - Q_PROPERTY(int columnStretchFactor READ columnStretchFactor WRITE setColumnStretchFactor) - Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing) - Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing) - Q_PROPERTY(int rowPreferredHeight READ rowPreferredHeight WRITE setRowPreferredHeight) - Q_PROPERTY(int rowMinimumHeight READ rowMinimumHeight WRITE setRowMinimumHeight) - Q_PROPERTY(int rowMaximumHeight READ rowMaximumHeight WRITE setRowMaximumHeight) - Q_PROPERTY(int rowFixedHeight READ rowFixedHeight WRITE setRowFixedHeight) - Q_PROPERTY(int columnPreferredWidth READ columnPreferredWidth WRITE setColumnPreferredWidth) - Q_PROPERTY(int columnMaximumWidth READ columnMaximumWidth WRITE setColumnMaximumWidth) - Q_PROPERTY(int columnMinimumWidth READ columnMinimumWidth WRITE setColumnMinimumWidth) - Q_PROPERTY(int columnFixedWidth READ columnFixedWidth WRITE setColumnFixedWidth) - -public: - GridLayoutAttached(QObject *parent); - - int row() const { return _row; } - void setRow(int r); - - int column() const { return _column; } - void setColumn(int c); - - int rowSpan() const { return _rowspan; } - void setRowSpan(int rs); - - int columnSpan() const { return _colspan; } - void setColumnSpan(int cs); - - Qt::Alignment alignment() const { return _alignment; } - void setAlignment(Qt::Alignment a); - - int rowStretchFactor() const { return _rowstretch; } - void setRowStretchFactor(int f); - int columnStretchFactor() const { return _colstretch; } - void setColumnStretchFactor(int f); - - int rowSpacing() const { return _rowspacing; } - void setRowSpacing(int s); - int columnSpacing() const { return _colspacing; } - void setColumnSpacing(int s); - - int rowPreferredHeight() const { return _rowprefheight; } - void setRowPreferredHeight(int s) { _rowprefheight = s; } - - int rowMaximumHeight() const { return _rowmaxheight; } - void setRowMaximumHeight(int s) { _rowmaxheight = s; } - - int rowMinimumHeight() const { return _rowminheight; } - void setRowMinimumHeight(int s) { _rowminheight = s; } - - int rowFixedHeight() const { return _rowfixheight; } - void setRowFixedHeight(int s) { _rowfixheight = s; } - - int columnPreferredWidth() const { return _colprefwidth; } - void setColumnPreferredWidth(int s) { _colprefwidth = s; } - - int columnMaximumWidth() const { return _colmaxwidth; } - void setColumnMaximumWidth(int s) { _colmaxwidth = s; } - - int columnMinimumWidth() const { return _colminwidth; } - void setColumnMinimumWidth(int s) { _colminwidth = s; } - - int columnFixedWidth() const { return _colfixwidth; } - void setColumnFixedWidth(int s) { _colfixwidth = s; } - -Q_SIGNALS: - void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); - -private: - int _row; - int _column; - int _rowspan; - int _colspan; - Qt::Alignment _alignment; - int _rowstretch; - int _colstretch; - int _rowspacing; - int _colspacing; - int _rowprefheight; - int _rowmaxheight; - int _rowminheight; - int _rowfixheight; - int _colprefwidth; - int _colmaxwidth; - int _colminwidth; - int _colfixwidth; -}; - -QT_END_NAMESPACE - -QML_DECLARE_INTERFACE(QGraphicsLayoutItem) -QML_DECLARE_INTERFACE(QGraphicsLayout) -QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject) -QML_DECLARE_TYPE(QGraphicsLinearLayoutObject) -QML_DECLARE_TYPEINFO(QGraphicsLinearLayoutObject, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QGraphicsGridLayoutObject) -QML_DECLARE_TYPEINFO(QGraphicsGridLayoutObject, QML_HAS_ATTACHED_PROPERTIES) - -QT_END_HEADER - -#endif // GRAPHICSLAYOUTS_H diff --git a/examples/declarative/layouts/graphicsLayouts/main.cpp b/examples/declarative/layouts/graphicsLayouts/main.cpp deleted file mode 100644 index 89b69bf..0000000 --- a/examples/declarative/layouts/graphicsLayouts/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "graphicslayouts_p.h" -#include - -int main(int argc, char* argv[]) -{ - QApplication app(argc, argv); - QDeclarativeView view; - qmlRegisterInterface("QGraphicsLayoutItem"); - qmlRegisterInterface("QGraphicsLayout"); - qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsLinearLayoutStretchItem"); - qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsLinearLayout"); - qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsGridLayout"); - view.setSource(QUrl(":graphicslayouts.qml")); - view.show(); - return app.exec(); -}; - diff --git a/examples/declarative/layouts/layoutItem/layoutItem.pro b/examples/declarative/layouts/layoutItem/layoutItem.pro deleted file mode 100644 index 4a3fc73..0000000 --- a/examples/declarative/layouts/layoutItem/layoutItem.pro +++ /dev/null @@ -1,13 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue May 4 13:36:26 2010 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp -RESOURCES += layoutItem.qrc diff --git a/examples/declarative/layouts/layoutItem/layoutItem.qml b/examples/declarative/layouts/layoutItem/layoutItem.qml deleted file mode 100644 index 460c564..0000000 --- a/examples/declarative/layouts/layoutItem/layoutItem.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 - -LayoutItem {//Sized by the layout - id: resizable - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { color: "yellow"; anchors.fill: parent } - Rectangle { - width: 100; height: 100; - anchors.top: parent.top; - anchors.right: parent.right; - color: "green"; - } -} diff --git a/examples/declarative/layouts/layoutItem/layoutItem.qrc b/examples/declarative/layouts/layoutItem/layoutItem.qrc deleted file mode 100644 index deb0fba..0000000 --- a/examples/declarative/layouts/layoutItem/layoutItem.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - layoutItem.qml - - diff --git a/examples/declarative/layouts/layoutItem/main.cpp b/examples/declarative/layouts/layoutItem/main.cpp deleted file mode 100644 index a104251..0000000 --- a/examples/declarative/layouts/layoutItem/main.cpp +++ /dev/null @@ -1,73 +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 examples 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 - -/* This example demonstrates using a LayoutItem to let QML snippets integrate - nicely with existing QGraphicsView applications designed with GraphicsLayouts -*/ -int main(int argc, char* argv[]) -{ - QApplication app(argc, argv); - //Set up a graphics scene with a QGraphicsWidget and Layout - QGraphicsView view; - QGraphicsScene scene; - QGraphicsWidget *widget = new QGraphicsWidget(); - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(); - widget->setLayout(layout); - scene.addItem(widget); - view.setScene(&scene); - //Add the QML snippet into the layout - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl(":layoutItem.qml")); - QGraphicsLayoutItem* obj = qobject_cast(c.create()); - layout->addItem(obj); - - widget->setGeometry(QRectF(0,0, 400,400)); - view.show(); - return app.exec(); -} diff --git a/examples/declarative/layouts/positioners/Button.qml b/examples/declarative/layouts/positioners/Button.qml deleted file mode 100644 index d03eeb5..0000000 --- a/examples/declarative/layouts/positioners/Button.qml +++ /dev/null @@ -1,38 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: page - - property string text - property string icon - signal clicked - - border.color: "black"; color: "steelblue"; radius: 5 - width: pix.width + textelement.width + 13 - height: pix.height + 10 - - Image { id: pix; x: 5; y:5; source: parent.icon } - - Text { - id: textelement - text: page.text; color: "white" - x: pix.width + pix.x + 3 - anchors.verticalCenter: pix.verticalCenter - } - - MouseArea { - id: mr - anchors.fill: parent - onClicked: { parent.focus = true; page.clicked() } - } - - states: State { - name: "pressed"; when: mr.pressed - PropertyChanges { target: textelement; x: 5 } - PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 } - } - - transitions: Transition { - NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 } - } -} diff --git a/examples/declarative/layouts/positioners/add.png b/examples/declarative/layouts/positioners/add.png deleted file mode 100644 index f29d84b..0000000 Binary files a/examples/declarative/layouts/positioners/add.png and /dev/null differ diff --git a/examples/declarative/layouts/positioners/del.png b/examples/declarative/layouts/positioners/del.png deleted file mode 100644 index 1d753a3..0000000 Binary files a/examples/declarative/layouts/positioners/del.png and /dev/null differ diff --git a/examples/declarative/layouts/positioners/positioners.qml b/examples/declarative/layouts/positioners/positioners.qml deleted file mode 100644 index 2cb0b8b..0000000 --- a/examples/declarative/layouts/positioners/positioners.qml +++ /dev/null @@ -1,213 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: page - width: 420; height: 420 - - Column { - id: layout1 - y: 0 - move: Transition { - NumberAnimation { properties: "y"; easing.type: Easing.OutBounce } - } - add: Transition { - NumberAnimation { properties: "y"; easing.type: Easing.OutQuad } - } - - Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueV1 - width: 100; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueV2 - width: 100; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } - } - - Row { - id: layout2 - y: 300 - move: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.OutBounce } - } - add: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.OutQuad } - } - - Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } - - Rectangle { - id: blueH1 - width: 50; height: 100 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } - - Rectangle { - id: blueH2 - width: 50; height: 100 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } - } - - Button { - x: 135; y: 90 - text: "Remove" - icon: "del.png" - - onClicked: { - blueH2.opacity = 0 - blueH1.opacity = 0 - blueV1.opacity = 0 - blueV2.opacity = 0 - blueG1.opacity = 0 - blueG2.opacity = 0 - blueG3.opacity = 0 - blueF1.opacity = 0 - blueF2.opacity = 0 - blueF3.opacity = 0 - } - } - - Button { - x: 145; y: 140 - text: "Add" - icon: "add.png" - - onClicked: { - blueH2.opacity = 1 - blueH1.opacity = 1 - blueV1.opacity = 1 - blueV2.opacity = 1 - blueG1.opacity = 1 - blueG2.opacity = 1 - blueG3.opacity = 1 - blueF1.opacity = 1 - blueF2.opacity = 1 - blueF3.opacity = 1 - } - } - - Grid { - x: 260; y: 0 - columns: 3 - - move: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - add: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG1 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG2 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG3 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - } - - Flow { - id: layout4 - x: 260; y: 250; width: 150 - - move: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - add: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF1 - width: 60; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF2 - width: 60; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF3 - width: 40; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 } - } - -} diff --git a/examples/declarative/layouts/positioners/positioners.qmlproject b/examples/declarative/layouts/positioners/positioners.qmlproject deleted file mode 100644 index e526217..0000000 --- a/examples/declarative/layouts/positioners/positioners.qmlproject +++ /dev/null @@ -1,18 +0,0 @@ -/* File generated by QtCreator */ - -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/layouts/positioners/positioners.qmlproject.user b/examples/declarative/layouts/positioners/positioners.qmlproject.user deleted file mode 100644 index 593479d..0000000 --- a/examples/declarative/layouts/positioners/positioners.qmlproject.user +++ /dev/null @@ -1,41 +0,0 @@ - - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - UTF-8 - - - - ProjectExplorer.Project.Target.0 - - QML Runtime - QmlProjectManager.QmlTarget - -1 - 0 - 0 - - QML Runtime - QmlProjectManager.QmlRunConfiguration - 127.0.0.1 - 3768 - positioners.qml - - - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 4 - - diff --git a/examples/declarative/listmodel-threaded/dataloader.js b/examples/declarative/listmodel-threaded/dataloader.js deleted file mode 100644 index d720f09..0000000 --- a/examples/declarative/listmodel-threaded/dataloader.js +++ /dev/null @@ -1,9 +0,0 @@ -// ![0] -WorkerScript.onMessage = function(msg) { - if (msg.action == 'appendCurrentTime') { - var data = {'time': new Date().toTimeString()}; - msg.model.append(data); - msg.model.sync(); // updates the changes to the list - } -} -// ![0] diff --git a/examples/declarative/listmodel-threaded/listmodel-threaded.qmlproject b/examples/declarative/listmodel-threaded/listmodel-threaded.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/listmodel-threaded/listmodel-threaded.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/listmodel-threaded/timedisplay.qml b/examples/declarative/listmodel-threaded/timedisplay.qml deleted file mode 100644 index bad7010..0000000 --- a/examples/declarative/listmodel-threaded/timedisplay.qml +++ /dev/null @@ -1,32 +0,0 @@ -// ![0] -import Qt 4.7 - -ListView { - width: 200 - height: 300 - - model: listModel - delegate: Component { - Text { text: time } - } - - ListModel { id: listModel } - - WorkerScript { - id: worker - source: "dataloader.js" - } - - Timer { - id: timer - interval: 2000; repeat: true - running: true - triggeredOnStart: true - - onTriggered: { - var msg = {'action': 'appendCurrentTime', 'model': listModel}; - worker.sendMessage(msg); - } - } -} -// ![0] diff --git a/examples/declarative/listview/content/ClickAutoRepeating.qml b/examples/declarative/listview/content/ClickAutoRepeating.qml deleted file mode 100644 index f65c2b3..0000000 --- a/examples/declarative/listview/content/ClickAutoRepeating.qml +++ /dev/null @@ -1,31 +0,0 @@ -import Qt 4.7 - -Item { - id: page - property int repeatdelay: 300 - property int repeatperiod: 75 - property bool isPressed: false - - signal pressed - signal released - signal clicked - - SequentialAnimation on isPressed { - running: false - id: autoRepeat - PropertyAction { target: page; property: "isPressed"; value: true } - ScriptAction { script: page.pressed() } - ScriptAction { script: page.clicked() } - PauseAnimation { duration: repeatdelay } - SequentialAnimation { - loops: Animation.Infinite - ScriptAction { script: page.clicked() } - PauseAnimation { duration: repeatperiod } - } - } - MouseArea { - anchors.fill: parent - onPressed: autoRepeat.start() - onReleased: { autoRepeat.stop(); parent.isPressed = false; page.released() } - } -} diff --git a/examples/declarative/listview/content/MediaButton.qml b/examples/declarative/listview/content/MediaButton.qml deleted file mode 100644 index a625b4c..0000000 --- a/examples/declarative/listview/content/MediaButton.qml +++ /dev/null @@ -1,35 +0,0 @@ -import Qt 4.7 - -Item { - property variant text - signal clicked - - id: container - Image { - id: normal - source: "pics/button.png" - } - Image { - id: pressed - source: "pics/button-pressed.png" - opacity: 0 - } - MouseArea { - id: clickRegion - anchors.fill: normal - onClicked: { container.clicked(); } - } - Text { - font.bold: true - color: "white" - anchors.centerIn: normal - text: container.text - } - width: normal.width - - states: State { - name: "Pressed" - when: clickRegion.pressed == true - PropertyChanges { target: pressed; opacity: 1 } - } -} diff --git a/examples/declarative/listview/content/pics/add.png b/examples/declarative/listview/content/pics/add.png deleted file mode 100644 index f29d84b..0000000 Binary files a/examples/declarative/listview/content/pics/add.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/archive-insert.png b/examples/declarative/listview/content/pics/archive-insert.png deleted file mode 100644 index b706248..0000000 Binary files a/examples/declarative/listview/content/pics/archive-insert.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/archive-remove.png b/examples/declarative/listview/content/pics/archive-remove.png deleted file mode 100644 index 9640f6b..0000000 Binary files a/examples/declarative/listview/content/pics/archive-remove.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/button-pressed.png b/examples/declarative/listview/content/pics/button-pressed.png deleted file mode 100644 index e434d32..0000000 Binary files a/examples/declarative/listview/content/pics/button-pressed.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/button.png b/examples/declarative/listview/content/pics/button.png deleted file mode 100644 index 56a63ce..0000000 Binary files a/examples/declarative/listview/content/pics/button.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/del.png b/examples/declarative/listview/content/pics/del.png deleted file mode 100644 index 1d753a3..0000000 Binary files a/examples/declarative/listview/content/pics/del.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/fruit-salad.jpg b/examples/declarative/listview/content/pics/fruit-salad.jpg deleted file mode 100644 index da5a6b1..0000000 Binary files a/examples/declarative/listview/content/pics/fruit-salad.jpg and /dev/null differ diff --git a/examples/declarative/listview/content/pics/go-down.png b/examples/declarative/listview/content/pics/go-down.png deleted file mode 100644 index 63331a5..0000000 Binary files a/examples/declarative/listview/content/pics/go-down.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/go-up.png b/examples/declarative/listview/content/pics/go-up.png deleted file mode 100644 index 4459024..0000000 Binary files a/examples/declarative/listview/content/pics/go-up.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/hamburger.jpg b/examples/declarative/listview/content/pics/hamburger.jpg deleted file mode 100644 index d0a15be..0000000 Binary files a/examples/declarative/listview/content/pics/hamburger.jpg and /dev/null differ diff --git a/examples/declarative/listview/content/pics/lemonade.jpg b/examples/declarative/listview/content/pics/lemonade.jpg deleted file mode 100644 index db445c9..0000000 Binary files a/examples/declarative/listview/content/pics/lemonade.jpg and /dev/null differ diff --git a/examples/declarative/listview/content/pics/list-add.png b/examples/declarative/listview/content/pics/list-add.png deleted file mode 100644 index e029787..0000000 Binary files a/examples/declarative/listview/content/pics/list-add.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/list-remove.png b/examples/declarative/listview/content/pics/list-remove.png deleted file mode 100644 index 2bb1a59..0000000 Binary files a/examples/declarative/listview/content/pics/list-remove.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/moreDown.png b/examples/declarative/listview/content/pics/moreDown.png deleted file mode 100644 index 31a35d5..0000000 Binary files a/examples/declarative/listview/content/pics/moreDown.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/moreUp.png b/examples/declarative/listview/content/pics/moreUp.png deleted file mode 100644 index fefb9c9..0000000 Binary files a/examples/declarative/listview/content/pics/moreUp.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/pancakes.jpg b/examples/declarative/listview/content/pics/pancakes.jpg deleted file mode 100644 index 60c4396..0000000 Binary files a/examples/declarative/listview/content/pics/pancakes.jpg and /dev/null differ diff --git a/examples/declarative/listview/content/pics/trash.png b/examples/declarative/listview/content/pics/trash.png deleted file mode 100644 index 2042595..0000000 Binary files a/examples/declarative/listview/content/pics/trash.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/vegetable-soup.jpg b/examples/declarative/listview/content/pics/vegetable-soup.jpg deleted file mode 100644 index 9dce332..0000000 Binary files a/examples/declarative/listview/content/pics/vegetable-soup.jpg and /dev/null differ diff --git a/examples/declarative/listview/dummydata/MyPetsModel.qml b/examples/declarative/listview/dummydata/MyPetsModel.qml deleted file mode 100644 index f15dda3..0000000 --- a/examples/declarative/listview/dummydata/MyPetsModel.qml +++ /dev/null @@ -1,61 +0,0 @@ -import Qt 4.7 - -// ListModel allows free form list models to be defined and populated. - -ListModel { - id: petsModel - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -} diff --git a/examples/declarative/listview/dummydata/Recipes.qml b/examples/declarative/listview/dummydata/Recipes.qml deleted file mode 100644 index f707c82..0000000 --- a/examples/declarative/listview/dummydata/Recipes.qml +++ /dev/null @@ -1,90 +0,0 @@ -import Qt 4.7 - -ListModel { - id: recipesModel - ListElement { - title: "Pancakes" - picture: "content/pics/pancakes.jpg" - ingredients: " -
        -
      • 1 cup (150g) self-raising flour -
      • 1 tbs caster sugar -
      • 3/4 cup (185ml) milk -
      • 1 egg -
      - " - method: " -
        -
      1. Sift flour and sugar together into a bowl. Add a pinch of salt. -
      2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. -
      3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. -
      4. Turn over and cook other side until golden. -
      - " - } - ListElement { - title: "Fruit Salad" - picture: "content/pics/fruit-salad.jpg" - ingredients: "* Seasonal Fruit" - method: "* Chop fruit and place in a bowl." - } - ListElement { - title: "Vegetable Soup" - picture: "content/pics/vegetable-soup.jpg" - ingredients: " -
        -
      • 1 onion -
      • 1 turnip -
      • 1 potato -
      • 1 carrot -
      • 1 head of celery -
      • 1 1/2 litres of water -
      - " - method: " -
        -
      1. Chop vegetables. -
      2. Boil in water until vegetables soften. -
      3. Season with salt and pepper to taste. -
      - " - } - ListElement { - title: "Hamburger" - picture: "content/pics/hamburger.jpg" - ingredients: " -
        -
      • 500g minced beef -
      • Seasoning -
      • lettuce, tomato, onion, cheese -
      • 1 hamburger bun for each burger -
      - " - method: " -
        -
      1. Mix the beef, together with seasoning, in a food processor. -
      2. Shape the beef into burgers. -
      3. Grill the burgers for about 5 mins on each side (until cooked through) -
      4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. -
      - " - } - ListElement { - title: "Lemonade" - picture: "content/pics/lemonade.jpg" - ingredients: " -
        -
      • 1 cup Lemon Juice -
      • 1 cup Sugar -
      • 6 Cups of Water (2 cups warm water, 4 cups cold water) -
      - " - method: " -
        -
      1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. -
      2. Pour in lemon juice, stir again, and add 4 cups of cold water. -
      3. Chill or serve over ice cubes. -
      - " - } -} diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml deleted file mode 100644 index 64f324e..0000000 --- a/examples/declarative/listview/dynamic.qml +++ /dev/null @@ -1,208 +0,0 @@ -import Qt 4.7 -import "content" -import "../scrollbar" - -Rectangle { - id: container - width: 640; height: 480 - color: "#343434" - - ListModel { - id: fruitModel - - ListElement { - name: "Apple"; cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Banana"; cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } - ListElement { - name: "Cumquat"; cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Durian"; cost: 9.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Smelly" } - ] - } - ListElement { - name: "Elderberry"; cost: 0.05 - attributes: [ - ListElement { description: "Berry" } - ] - } - ListElement { - name: "Fig"; cost: 0.25 - attributes: [ - ListElement { description: "Flower" } - ] - } - } - - Component { - id: fruitDelegate - - Item { - width: container.width; height: 55 - - Column { - id: moveButtons - x: 5; width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter - - Image { - source: "content/pics/go-up.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index-1,1) } - } - Image { source: "content/pics/go-down.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index+1,1) } - } - } - - Column { - anchors { right: itemButtons.left; verticalCenter: parent.verticalCenter; left: moveButtons.right; leftMargin: 10 } - - Text { - id: label - width: parent.width - color: "White" - font.bold: true; font.pixelSize: 15 - text: name; elide: Text.ElideRight - } - Row { - spacing: 5 - Repeater { - model: attributes - Component { - Text { text: description; color: "White" } - } - } - } - } - - Row { - id: itemButtons - - anchors { right: removeButton.left; rightMargin: 35; verticalCenter: parent.verticalCenter } - width: childrenRect.width - spacing: 10 - - Image { - source: "content/pics/list-add.png" - scale: clickUp.isPressed ? 0.9 : 1 - - ClickAutoRepeating { - id: clickUp - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", cost+0.25) - } - } - - Text { id: costText; text: '$'+Number(cost).toFixed(2); font.pixelSize: 15; color: "White"; font.bold: true; } - - Image { - source: "content/pics/list-remove.png" - scale: clickDown.isPressed ? 0.9 : 1 - - ClickAutoRepeating { - id: clickDown - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) - } - } - } - Image { - id: removeButton - anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: 10 } - source: "content/pics/archive-remove.png" - - MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } - } - } - } - - ListView { - id: view - anchors { top: parent.top; left: parent.left; right: parent.right; bottom: buttons.top } - model: fruitModel - delegate: fruitDelegate - } - - // Attach scrollbar to the right edge of the view. - ScrollBar { - id: verticalScrollBar - - width: 8; height: view.height; anchors.right: view.right - opacity: 0 - orientation: Qt.Vertical - position: view.visibleArea.yPosition - pageSize: view.visibleArea.heightRatio - - // Only show the scrollbar when the view is moving. - states: State { - name: "ShowBars"; when: view.movingVertically - PropertyChanges { target: verticalScrollBar; opacity: 1 } - } - transitions: Transition { - NumberAnimation { properties: "opacity"; duration: 400 } - } - } - - Row { - id: buttons - - x: 8; width: childrenRect.width; height: childrenRect.height - anchors { bottom: parent.bottom; bottomMargin: 8 } - spacing: 8 - - Image { - source: "content/pics/archive-insert.png" - - MouseArea { - anchors.fill: parent - onClicked: { - fruitModel.append({ - "name": "Pizza Margarita", - "cost": 5.95, - "attributes": [{"description": "Cheese"},{"description": "Tomato"}] - }) - } - } - } - - Image { - source: "content/pics/archive-insert.png" - - MouseArea { - anchors.fill: parent; - onClicked: { - fruitModel.insert(0, { - "name": "Pizza Supreme", - "cost": 9.95, - "attributes": [{"description": "Cheese"},{"description": "Tomato"},{"description": "The Works"}] - }) - } - } - } - - Image { - source: "content/pics/archive-remove.png" - - MouseArea { - anchors.fill: parent - onClicked: fruitModel.clear() - } - } - } -} diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml deleted file mode 100644 index ade355d..0000000 --- a/examples/declarative/listview/highlight.qml +++ /dev/null @@ -1,55 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 400; height: 300 - - // MyPets model is defined in dummydata/MyPetsModel.qml - // The launcher automatically loads files in dummydata/* to assist - // development without a real data source. - // This one contains my pets. - - // Define a delegate component. A component will be - // instantiated for each visible item in the list. - Component { - id: petDelegate - Item { - id: wrapper - width: 200; height: 50 - Column { - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } - // Use the ListView.isCurrentItem attached property to - // indent the item if it is the current item. - states: State { - name: "Current" - when: wrapper.ListView.isCurrentItem - PropertyChanges { target: wrapper; x: 10 } - } - transitions: Transition { - NumberAnimation { properties: "x"; duration: 200 } - } - } - } - // Specify a highlight with custom movement. Note that highlightFollowsCurrentItem - // is set to false in the ListView so that we can control how the - // highlight moves to the current item. - Component { - id: petHighlight - Rectangle { - width: 200; height: 50 - color: "#FFFF88" - SpringFollow on y { to: list1.currentItem.y; spring: 3; damping: 0.1 } - } - } - - ListView { - id: list1 - width: 200; height: parent.height - model: MyPetsModel - delegate: petDelegate - highlight: petHighlight; highlightFollowsCurrentItem: false - focus: true - } -} diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml deleted file mode 100644 index b73b3a3..0000000 --- a/examples/declarative/listview/itemlist.qml +++ /dev/null @@ -1,67 +0,0 @@ -// This example demonstrates placing items in a view using -// a VisualItemModel - -import Qt 4.7 - -Rectangle { - color: "lightgray" - width: 240 - height: 320 - - VisualItemModel { - id: itemModel - - Rectangle { - width: view.width; height: view.height - color: "#FFFEF0" - Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - width: view.width; height: view.height - color: "#F0FFF7" - Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - width: view.width; height: view.height - color: "#F4F0FF" - Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } - } - } - - ListView { - id: view - anchors { fill: parent; bottomMargin: 30 } - model: itemModel - preferredHighlightBegin: 0; preferredHighlightEnd: 0 - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem; flickDeceleration: 2000 - } - - Rectangle { - width: 240; height: 30 - anchors { top: view.bottom; bottom: parent.bottom } - color: "gray" - - Row { - anchors.centerIn: parent - spacing: 20 - - Repeater { - model: itemModel.count - - Rectangle { - width: 5; height: 5 - radius: 3 - color: view.currentIndex == index ? "blue" : "white" - - MouseArea { - width: 20; height: 20 - anchors.centerIn: parent - onClicked: view.currentIndex = index - } - } - } - } - } -} diff --git a/examples/declarative/listview/listview-example.qml b/examples/declarative/listview/listview-example.qml deleted file mode 100644 index 2e8cdda..0000000 --- a/examples/declarative/listview/listview-example.qml +++ /dev/null @@ -1,93 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 600; height: 300 - - // MyPets model is defined in dummydata/MyPetsModel.qml - // The viewer automatically loads files in dummydata/* to assist - // development without a real data source. - // This one contains my pets. - - // Define a delegate component. A component will be - // instantiated for each visible item in the list. - Component { - id: petDelegate - Item { - width: 200; height: 50 - Column { - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } - } - } - - // Define a highlight component. Just one of these will be instantiated - // by each ListView and placed behind the current item. - Component { - id: petHighlight - Rectangle { color: "#FFFF88" } - } - - // Show the model in three lists, with different highlight ranges. - // preferredHighlightBegin and preferredHighlightEnd set the - // range in which to attempt to maintain the highlight. - // - // Note that the second and third ListView - // set their currentIndex to be the same as the first, and that - // the first ListView is given keyboard focus. - // - // The default mode allows the currentItem to move freely - // within the visible area. If it would move outside the visible - // area, the view is scrolled to keep it visible. - // - // The second list sets a highlight range which attempts to keep the - // current item within the the bounds of the range, however - // items will not scroll beyond the beginning or end of the view, - // forcing the highlight to move outside the range at the ends. - // - // The third list sets the highlightRangeMode to StrictlyEnforceRange - // and sets a range smaller than the height of an item. This - // forces the current item to change when the view is flicked, - // since the highlight is unable to move. - // - // Note that the first ListView sets its currentIndex to be equal to - // the third ListView's currentIndex. By flicking List3 with - // the mouse, the current index of List1 will be changed. - - ListView { - id: list1 - width: 200; height: parent.height - model: MyPetsModel - delegate: petDelegate - - highlight: petHighlight - currentIndex: list3.currentIndex - focus: true - } - - ListView { - id: list2 - x: 200; width: 200; height: parent.height - model: MyPetsModel - delegate: petDelegate - - highlight: petHighlight - currentIndex: list1.currentIndex - preferredHighlightBegin: 80; preferredHighlightEnd: 220 - highlightRangeMode: ListView.ApplyRange - } - - ListView { - id: list3 - x: 400; width: 200; height: parent.height - model: MyPetsModel - delegate: petDelegate - - highlight: Rectangle { color: "lightsteelblue" } - currentIndex: list1.currentIndex - preferredHighlightBegin: 125; preferredHighlightEnd: 125 - highlightRangeMode: ListView.StrictlyEnforceRange - flickDeceleration: 1000 - } -} diff --git a/examples/declarative/listview/listview.qmlproject b/examples/declarative/listview/listview.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/listview/listview.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml deleted file mode 100644 index 990e272..0000000 --- a/examples/declarative/listview/recipes.qml +++ /dev/null @@ -1,160 +0,0 @@ -import Qt 4.7 -import "content" - -// This example illustrates expanding a list item to show a more detailed view - -Rectangle { - id: page - width: 400; height: 240 - color: "black" - - // Delegate for the recipes. This delegate has two modes: - // 1. the list mode (default), which just shows the picture and title of the recipe. - // 2. the details mode, which also shows the ingredients and method. - Component { - id: recipeDelegate - - Item { - id: wrapper - - // Create a property to contain the visibility of the details. - // We can bind multiple element's opacity to this one property, - // rather than having a "PropertyChanges" line for each element we - // want to fade. - property real detailsOpacity : 0 - - width: list.width - - // A simple rounded rectangle for the background - Rectangle { - id: background - x: 1; y: 2; width: parent.width - 2; height: parent.height - 4 - color: "#FEFFEE" - border.color: "#FFBE4F" - radius: 5 - } - - // This mouse region covers the entire delegate. - // When clicked it changes mode to 'Details'. If we are already - // in Details mode, then no change will happen. - MouseArea { - id: pageMouse - anchors.fill: parent - onClicked: wrapper.state = 'Details'; - } - - // Layout the page. Picture, title and ingredients at the top, method at the - // bottom. Note that elements that should not be visible in the list - // mode have their opacity set to wrapper.detailsOpacity. - Row { - id: topLayout - x: 10; y: 10; height: recipePic.height; width: parent.width - spacing: 10 - - Image { - id: recipePic - source: picture; width: 48; height: 48 - } - - Column { - width: background.width-recipePic.width-20; height: recipePic.height; - spacing: 5 - - Text { id: name; text: title; font.bold: true; font.pointSize: 16 } - - Text { - text: "Ingredients" - font.pointSize: 12; font.bold: true - opacity: wrapper.detailsOpacity - } - - Text { - text: ingredients - wrapMode: Text.WordWrap - width: parent.width - opacity: wrapper.detailsOpacity - } - } - } - - Item { - id: details - x: 10; width: parent.width-20 - anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } - opacity: wrapper.detailsOpacity - - Text { - id: methodTitle - anchors.top: parent.top - text: "Method" - font.pointSize: 12; font.bold: true - } - - Flickable { - id: flick - width: parent.width - anchors { top: methodTitle.bottom; bottom: parent.bottom } - contentHeight: methodText.height; clip: true - - Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } - } - - Image { - anchors { right: flick.right; top: flick.top } - source: "content/pics/moreUp.png" - opacity: flick.atYBeginning ? 0 : 1 - } - - Image { - anchors { right: flick.right; bottom: flick.bottom } - source: "content/pics/moreDown.png" - opacity: flick.atYEnd ? 0 : 1 - } - } - - // A button to close the detailed view, i.e. set the state back to default (''). - MediaButton { - y: 10; anchors { right: background.right; rightMargin: 5 } - opacity: wrapper.detailsOpacity - text: "Close" - - onClicked: wrapper.state = ''; - } - - // Set the default height to the height of the picture, plus margin. - height: 68 - - states: State { - name: "Details" - - PropertyChanges { target: background; color: "white" } - PropertyChanges { target: recipePic; width: 128; height: 128 } // Make picture bigger - PropertyChanges { target: wrapper; detailsOpacity: 1; x: 0 } // Make details visible - PropertyChanges { target: wrapper; height: list.height } // Fill the entire list area with the detailed view - - // Move the list so that this item is at the top. - PropertyChanges { target: wrapper.ListView.view; explicit: true; contentY: wrapper.y } - - // Disallow flicking while we're in detailed view - PropertyChanges { target: wrapper.ListView.view; interactive: false } - } - - transitions: Transition { - // Make the state changes smooth - ParallelAnimation { - ColorAnimation { property: "color"; duration: 500 } - NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" } - } - } - } - } - - // The actual list - ListView { - id: list - anchors.fill: parent - clip: true - model: Recipes - delegate: recipeDelegate - } -} diff --git a/examples/declarative/listview/sections.qml b/examples/declarative/listview/sections.qml deleted file mode 100644 index 21f9f03..0000000 --- a/examples/declarative/listview/sections.qml +++ /dev/null @@ -1,71 +0,0 @@ -import Qt 4.7 - -//! [0] -Rectangle { - width: 200 - height: 240 - - // MyPets model is defined in dummydata/MyPetsModel.qml - // The viewer automatically loads files in dummydata/* to assist - // development without a real data source. - // This one contains my pets. - - // Define a delegate component that includes a separator for sections. - Component { - id: petDelegate - - Item { - id: wrapper - width: 200 - height: desc.height // height is the combined height of the description and the section separator - - Item { - id: desc - x: 5; height: layout.height + 4 - - Column { - id: layout - y: 2 - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } - } - } - } - - // Define a highlight component. Just one of these will be instantiated - // by each ListView and placed behind the current item. - Component { - id: petHighlight - Rectangle { color: "#FFFF88" } - } - - // The list - ListView { - id: myList - - width: 200; height: parent.height - model: MyPetsModel - delegate: petDelegate - highlight: petHighlight - focus: true - - // The sectionExpression is simply the size of the pet. - // We use this to determine which section we are in above. - section.property: "size" - section.criteria: ViewSection.FullString - section.delegate: Rectangle { - color: "lightsteelblue" - width: 200 - height: 20 - Text { - x: 2; height: parent.height - verticalAlignment: Text.AlignVCenter - text: section - font.bold: true - } - } - } -} -//! [0] diff --git a/examples/declarative/modelviews/gridview/gridview-example.qml b/examples/declarative/modelviews/gridview/gridview-example.qml new file mode 100644 index 0000000..a5f41fb --- /dev/null +++ b/examples/declarative/modelviews/gridview/gridview-example.qml @@ -0,0 +1,49 @@ +import Qt 4.7 + +Rectangle { + width: 300; height: 400 + color: "white" + + ListModel { + id: appModel + ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } + ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } + ListElement { name: "Camera"; icon: "pics/Camera_48.png" } + ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } + ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } + ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } + ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } + } + + Component { + id: appDelegate + + Item { + width: 100; height: 100 + + Image { + id: myIcon + y: 20; anchors.horizontalCenter: parent.horizontalCenter + source: icon + } + Text { + anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } + text: name + } + } + } + + Component { + id: appHighlight + Rectangle { width: 80; height: 80; color: "lightsteelblue" } + } + + GridView { + anchors.fill: parent + cellWidth: 100; cellHeight: 100 + highlight: appHighlight + focus: true + model: appModel + delegate: appDelegate + } +} diff --git a/examples/declarative/modelviews/gridview/gridview.qmlproject b/examples/declarative/modelviews/gridview/gridview.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/gridview/gridview.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/gridview/pics/AddressBook_48.png b/examples/declarative/modelviews/gridview/pics/AddressBook_48.png new file mode 100644 index 0000000..1ab7c8e Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/AddressBook_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png b/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png new file mode 100644 index 0000000..f4b8689 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/Camera_48.png b/examples/declarative/modelviews/gridview/pics/Camera_48.png new file mode 100644 index 0000000..c76b524 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/Camera_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/DateBook_48.png b/examples/declarative/modelviews/gridview/pics/DateBook_48.png new file mode 100644 index 0000000..58f5787 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/DateBook_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/EMail_48.png b/examples/declarative/modelviews/gridview/pics/EMail_48.png new file mode 100644 index 0000000..d6d84a6 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/EMail_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/TodoList_48.png b/examples/declarative/modelviews/gridview/pics/TodoList_48.png new file mode 100644 index 0000000..0988448 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/TodoList_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png b/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png new file mode 100644 index 0000000..52638c5 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png differ diff --git a/examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml b/examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml new file mode 100644 index 0000000..f65c2b3 --- /dev/null +++ b/examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml @@ -0,0 +1,31 @@ +import Qt 4.7 + +Item { + id: page + property int repeatdelay: 300 + property int repeatperiod: 75 + property bool isPressed: false + + signal pressed + signal released + signal clicked + + SequentialAnimation on isPressed { + running: false + id: autoRepeat + PropertyAction { target: page; property: "isPressed"; value: true } + ScriptAction { script: page.pressed() } + ScriptAction { script: page.clicked() } + PauseAnimation { duration: repeatdelay } + SequentialAnimation { + loops: Animation.Infinite + ScriptAction { script: page.clicked() } + PauseAnimation { duration: repeatperiod } + } + } + MouseArea { + anchors.fill: parent + onPressed: autoRepeat.start() + onReleased: { autoRepeat.stop(); parent.isPressed = false; page.released() } + } +} diff --git a/examples/declarative/modelviews/listview/content/MediaButton.qml b/examples/declarative/modelviews/listview/content/MediaButton.qml new file mode 100644 index 0000000..a625b4c --- /dev/null +++ b/examples/declarative/modelviews/listview/content/MediaButton.qml @@ -0,0 +1,35 @@ +import Qt 4.7 + +Item { + property variant text + signal clicked + + id: container + Image { + id: normal + source: "pics/button.png" + } + Image { + id: pressed + source: "pics/button-pressed.png" + opacity: 0 + } + MouseArea { + id: clickRegion + anchors.fill: normal + onClicked: { container.clicked(); } + } + Text { + font.bold: true + color: "white" + anchors.centerIn: normal + text: container.text + } + width: normal.width + + states: State { + name: "Pressed" + when: clickRegion.pressed == true + PropertyChanges { target: pressed; opacity: 1 } + } +} diff --git a/examples/declarative/modelviews/listview/content/pics/add.png b/examples/declarative/modelviews/listview/content/pics/add.png new file mode 100644 index 0000000..f29d84b Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/add.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/archive-insert.png b/examples/declarative/modelviews/listview/content/pics/archive-insert.png new file mode 100644 index 0000000..b706248 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/archive-insert.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/archive-remove.png b/examples/declarative/modelviews/listview/content/pics/archive-remove.png new file mode 100644 index 0000000..9640f6b Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/archive-remove.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/button-pressed.png b/examples/declarative/modelviews/listview/content/pics/button-pressed.png new file mode 100644 index 0000000..e434d32 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/button-pressed.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/button.png b/examples/declarative/modelviews/listview/content/pics/button.png new file mode 100644 index 0000000..56a63ce Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/button.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/del.png b/examples/declarative/modelviews/listview/content/pics/del.png new file mode 100644 index 0000000..1d753a3 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/del.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg b/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg new file mode 100644 index 0000000..da5a6b1 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg differ diff --git a/examples/declarative/modelviews/listview/content/pics/go-down.png b/examples/declarative/modelviews/listview/content/pics/go-down.png new file mode 100644 index 0000000..63331a5 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/go-down.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/go-up.png b/examples/declarative/modelviews/listview/content/pics/go-up.png new file mode 100644 index 0000000..4459024 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/go-up.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/hamburger.jpg b/examples/declarative/modelviews/listview/content/pics/hamburger.jpg new file mode 100644 index 0000000..d0a15be Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/hamburger.jpg differ diff --git a/examples/declarative/modelviews/listview/content/pics/lemonade.jpg b/examples/declarative/modelviews/listview/content/pics/lemonade.jpg new file mode 100644 index 0000000..db445c9 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/lemonade.jpg differ diff --git a/examples/declarative/modelviews/listview/content/pics/list-add.png b/examples/declarative/modelviews/listview/content/pics/list-add.png new file mode 100644 index 0000000..e029787 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/list-add.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/list-remove.png b/examples/declarative/modelviews/listview/content/pics/list-remove.png new file mode 100644 index 0000000..2bb1a59 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/list-remove.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/moreDown.png b/examples/declarative/modelviews/listview/content/pics/moreDown.png new file mode 100644 index 0000000..31a35d5 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/moreDown.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/moreUp.png b/examples/declarative/modelviews/listview/content/pics/moreUp.png new file mode 100644 index 0000000..fefb9c9 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/moreUp.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/pancakes.jpg b/examples/declarative/modelviews/listview/content/pics/pancakes.jpg new file mode 100644 index 0000000..60c4396 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/pancakes.jpg differ diff --git a/examples/declarative/modelviews/listview/content/pics/trash.png b/examples/declarative/modelviews/listview/content/pics/trash.png new file mode 100644 index 0000000..2042595 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/trash.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg new file mode 100644 index 0000000..9dce332 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg differ diff --git a/examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml b/examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml new file mode 100644 index 0000000..f15dda3 --- /dev/null +++ b/examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml @@ -0,0 +1,61 @@ +import Qt 4.7 + +// ListModel allows free form list models to be defined and populated. + +ListModel { + id: petsModel + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/declarative/modelviews/listview/dummydata/Recipes.qml b/examples/declarative/modelviews/listview/dummydata/Recipes.qml new file mode 100644 index 0000000..f707c82 --- /dev/null +++ b/examples/declarative/modelviews/listview/dummydata/Recipes.qml @@ -0,0 +1,90 @@ +import Qt 4.7 + +ListModel { + id: recipesModel + ListElement { + title: "Pancakes" + picture: "content/pics/pancakes.jpg" + ingredients: " +
        +
      • 1 cup (150g) self-raising flour +
      • 1 tbs caster sugar +
      • 3/4 cup (185ml) milk +
      • 1 egg +
      + " + method: " +
        +
      1. Sift flour and sugar together into a bowl. Add a pinch of salt. +
      2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. +
      3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. +
      4. Turn over and cook other side until golden. +
      + " + } + ListElement { + title: "Fruit Salad" + picture: "content/pics/fruit-salad.jpg" + ingredients: "* Seasonal Fruit" + method: "* Chop fruit and place in a bowl." + } + ListElement { + title: "Vegetable Soup" + picture: "content/pics/vegetable-soup.jpg" + ingredients: " +
        +
      • 1 onion +
      • 1 turnip +
      • 1 potato +
      • 1 carrot +
      • 1 head of celery +
      • 1 1/2 litres of water +
      + " + method: " +
        +
      1. Chop vegetables. +
      2. Boil in water until vegetables soften. +
      3. Season with salt and pepper to taste. +
      + " + } + ListElement { + title: "Hamburger" + picture: "content/pics/hamburger.jpg" + ingredients: " +
        +
      • 500g minced beef +
      • Seasoning +
      • lettuce, tomato, onion, cheese +
      • 1 hamburger bun for each burger +
      + " + method: " +
        +
      1. Mix the beef, together with seasoning, in a food processor. +
      2. Shape the beef into burgers. +
      3. Grill the burgers for about 5 mins on each side (until cooked through) +
      4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. +
      + " + } + ListElement { + title: "Lemonade" + picture: "content/pics/lemonade.jpg" + ingredients: " +
        +
      • 1 cup Lemon Juice +
      • 1 cup Sugar +
      • 6 Cups of Water (2 cups warm water, 4 cups cold water) +
      + " + method: " +
        +
      1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. +
      2. Pour in lemon juice, stir again, and add 4 cups of cold water. +
      3. Chill or serve over ice cubes. +
      + " + } +} diff --git a/examples/declarative/modelviews/listview/dynamic.qml b/examples/declarative/modelviews/listview/dynamic.qml new file mode 100644 index 0000000..693e88a --- /dev/null +++ b/examples/declarative/modelviews/listview/dynamic.qml @@ -0,0 +1,208 @@ +import Qt 4.7 +import "content" +import "../../ui-components/scrollbar" + +Rectangle { + id: container + width: 640; height: 480 + color: "#343434" + + ListModel { + id: fruitModel + + ListElement { + name: "Apple"; cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Banana"; cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } + ListElement { + name: "Cumquat"; cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Durian"; cost: 9.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Smelly" } + ] + } + ListElement { + name: "Elderberry"; cost: 0.05 + attributes: [ + ListElement { description: "Berry" } + ] + } + ListElement { + name: "Fig"; cost: 0.25 + attributes: [ + ListElement { description: "Flower" } + ] + } + } + + Component { + id: fruitDelegate + + Item { + width: container.width; height: 55 + + Column { + id: moveButtons + x: 5; width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter + + Image { + source: "content/pics/go-up.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index-1,1) } + } + Image { source: "content/pics/go-down.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index+1,1) } + } + } + + Column { + anchors { right: itemButtons.left; verticalCenter: parent.verticalCenter; left: moveButtons.right; leftMargin: 10 } + + Text { + id: label + width: parent.width + color: "White" + font.bold: true; font.pixelSize: 15 + text: name; elide: Text.ElideRight + } + Row { + spacing: 5 + Repeater { + model: attributes + Component { + Text { text: description; color: "White" } + } + } + } + } + + Row { + id: itemButtons + + anchors { right: removeButton.left; rightMargin: 35; verticalCenter: parent.verticalCenter } + width: childrenRect.width + spacing: 10 + + Image { + source: "content/pics/list-add.png" + scale: clickUp.isPressed ? 0.9 : 1 + + ClickAutoRepeating { + id: clickUp + anchors.fill: parent + onClicked: fruitModel.setProperty(index, "cost", cost+0.25) + } + } + + Text { id: costText; text: '$'+Number(cost).toFixed(2); font.pixelSize: 15; color: "White"; font.bold: true; } + + Image { + source: "content/pics/list-remove.png" + scale: clickDown.isPressed ? 0.9 : 1 + + ClickAutoRepeating { + id: clickDown + anchors.fill: parent + onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) + } + } + } + Image { + id: removeButton + anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: 10 } + source: "content/pics/archive-remove.png" + + MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } + } + } + } + + ListView { + id: view + anchors { top: parent.top; left: parent.left; right: parent.right; bottom: buttons.top } + model: fruitModel + delegate: fruitDelegate + } + + // Attach scrollbar to the right edge of the view. + ScrollBar { + id: verticalScrollBar + + width: 8; height: view.height; anchors.right: view.right + opacity: 0 + orientation: Qt.Vertical + position: view.visibleArea.yPosition + pageSize: view.visibleArea.heightRatio + + // Only show the scrollbar when the view is moving. + states: State { + name: "ShowBars"; when: view.movingVertically + PropertyChanges { target: verticalScrollBar; opacity: 1 } + } + transitions: Transition { + NumberAnimation { properties: "opacity"; duration: 400 } + } + } + + Row { + id: buttons + + x: 8; width: childrenRect.width; height: childrenRect.height + anchors { bottom: parent.bottom; bottomMargin: 8 } + spacing: 8 + + Image { + source: "content/pics/archive-insert.png" + + MouseArea { + anchors.fill: parent + onClicked: { + fruitModel.append({ + "name": "Pizza Margarita", + "cost": 5.95, + "attributes": [{"description": "Cheese"},{"description": "Tomato"}] + }) + } + } + } + + Image { + source: "content/pics/archive-insert.png" + + MouseArea { + anchors.fill: parent; + onClicked: { + fruitModel.insert(0, { + "name": "Pizza Supreme", + "cost": 9.95, + "attributes": [{"description": "Cheese"},{"description": "Tomato"},{"description": "The Works"}] + }) + } + } + } + + Image { + source: "content/pics/archive-remove.png" + + MouseArea { + anchors.fill: parent + onClicked: fruitModel.clear() + } + } + } +} diff --git a/examples/declarative/modelviews/listview/highlight.qml b/examples/declarative/modelviews/listview/highlight.qml new file mode 100644 index 0000000..ade355d --- /dev/null +++ b/examples/declarative/modelviews/listview/highlight.qml @@ -0,0 +1,55 @@ +import Qt 4.7 + +Rectangle { + width: 400; height: 300 + + // MyPets model is defined in dummydata/MyPetsModel.qml + // The launcher automatically loads files in dummydata/* to assist + // development without a real data source. + // This one contains my pets. + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + Component { + id: petDelegate + Item { + id: wrapper + width: 200; height: 50 + Column { + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } + // Use the ListView.isCurrentItem attached property to + // indent the item if it is the current item. + states: State { + name: "Current" + when: wrapper.ListView.isCurrentItem + PropertyChanges { target: wrapper; x: 10 } + } + transitions: Transition { + NumberAnimation { properties: "x"; duration: 200 } + } + } + } + // Specify a highlight with custom movement. Note that highlightFollowsCurrentItem + // is set to false in the ListView so that we can control how the + // highlight moves to the current item. + Component { + id: petHighlight + Rectangle { + width: 200; height: 50 + color: "#FFFF88" + SpringFollow on y { to: list1.currentItem.y; spring: 3; damping: 0.1 } + } + } + + ListView { + id: list1 + width: 200; height: parent.height + model: MyPetsModel + delegate: petDelegate + highlight: petHighlight; highlightFollowsCurrentItem: false + focus: true + } +} diff --git a/examples/declarative/modelviews/listview/itemlist.qml b/examples/declarative/modelviews/listview/itemlist.qml new file mode 100644 index 0000000..b73b3a3 --- /dev/null +++ b/examples/declarative/modelviews/listview/itemlist.qml @@ -0,0 +1,67 @@ +// This example demonstrates placing items in a view using +// a VisualItemModel + +import Qt 4.7 + +Rectangle { + color: "lightgray" + width: 240 + height: 320 + + VisualItemModel { + id: itemModel + + Rectangle { + width: view.width; height: view.height + color: "#FFFEF0" + Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + width: view.width; height: view.height + color: "#F0FFF7" + Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + width: view.width; height: view.height + color: "#F4F0FF" + Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } + } + } + + ListView { + id: view + anchors { fill: parent; bottomMargin: 30 } + model: itemModel + preferredHighlightBegin: 0; preferredHighlightEnd: 0 + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem; flickDeceleration: 2000 + } + + Rectangle { + width: 240; height: 30 + anchors { top: view.bottom; bottom: parent.bottom } + color: "gray" + + Row { + anchors.centerIn: parent + spacing: 20 + + Repeater { + model: itemModel.count + + Rectangle { + width: 5; height: 5 + radius: 3 + color: view.currentIndex == index ? "blue" : "white" + + MouseArea { + width: 20; height: 20 + anchors.centerIn: parent + onClicked: view.currentIndex = index + } + } + } + } + } +} diff --git a/examples/declarative/modelviews/listview/listview-example.qml b/examples/declarative/modelviews/listview/listview-example.qml new file mode 100644 index 0000000..2e8cdda --- /dev/null +++ b/examples/declarative/modelviews/listview/listview-example.qml @@ -0,0 +1,93 @@ +import Qt 4.7 + +Rectangle { + width: 600; height: 300 + + // MyPets model is defined in dummydata/MyPetsModel.qml + // The viewer automatically loads files in dummydata/* to assist + // development without a real data source. + // This one contains my pets. + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + Component { + id: petDelegate + Item { + width: 200; height: 50 + Column { + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } + } + } + + // Define a highlight component. Just one of these will be instantiated + // by each ListView and placed behind the current item. + Component { + id: petHighlight + Rectangle { color: "#FFFF88" } + } + + // Show the model in three lists, with different highlight ranges. + // preferredHighlightBegin and preferredHighlightEnd set the + // range in which to attempt to maintain the highlight. + // + // Note that the second and third ListView + // set their currentIndex to be the same as the first, and that + // the first ListView is given keyboard focus. + // + // The default mode allows the currentItem to move freely + // within the visible area. If it would move outside the visible + // area, the view is scrolled to keep it visible. + // + // The second list sets a highlight range which attempts to keep the + // current item within the the bounds of the range, however + // items will not scroll beyond the beginning or end of the view, + // forcing the highlight to move outside the range at the ends. + // + // The third list sets the highlightRangeMode to StrictlyEnforceRange + // and sets a range smaller than the height of an item. This + // forces the current item to change when the view is flicked, + // since the highlight is unable to move. + // + // Note that the first ListView sets its currentIndex to be equal to + // the third ListView's currentIndex. By flicking List3 with + // the mouse, the current index of List1 will be changed. + + ListView { + id: list1 + width: 200; height: parent.height + model: MyPetsModel + delegate: petDelegate + + highlight: petHighlight + currentIndex: list3.currentIndex + focus: true + } + + ListView { + id: list2 + x: 200; width: 200; height: parent.height + model: MyPetsModel + delegate: petDelegate + + highlight: petHighlight + currentIndex: list1.currentIndex + preferredHighlightBegin: 80; preferredHighlightEnd: 220 + highlightRangeMode: ListView.ApplyRange + } + + ListView { + id: list3 + x: 400; width: 200; height: parent.height + model: MyPetsModel + delegate: petDelegate + + highlight: Rectangle { color: "lightsteelblue" } + currentIndex: list1.currentIndex + preferredHighlightBegin: 125; preferredHighlightEnd: 125 + highlightRangeMode: ListView.StrictlyEnforceRange + flickDeceleration: 1000 + } +} diff --git a/examples/declarative/modelviews/listview/listview.qmlproject b/examples/declarative/modelviews/listview/listview.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/listview/listview.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/listview/recipes.qml b/examples/declarative/modelviews/listview/recipes.qml new file mode 100644 index 0000000..990e272 --- /dev/null +++ b/examples/declarative/modelviews/listview/recipes.qml @@ -0,0 +1,160 @@ +import Qt 4.7 +import "content" + +// This example illustrates expanding a list item to show a more detailed view + +Rectangle { + id: page + width: 400; height: 240 + color: "black" + + // Delegate for the recipes. This delegate has two modes: + // 1. the list mode (default), which just shows the picture and title of the recipe. + // 2. the details mode, which also shows the ingredients and method. + Component { + id: recipeDelegate + + Item { + id: wrapper + + // Create a property to contain the visibility of the details. + // We can bind multiple element's opacity to this one property, + // rather than having a "PropertyChanges" line for each element we + // want to fade. + property real detailsOpacity : 0 + + width: list.width + + // A simple rounded rectangle for the background + Rectangle { + id: background + x: 1; y: 2; width: parent.width - 2; height: parent.height - 4 + color: "#FEFFEE" + border.color: "#FFBE4F" + radius: 5 + } + + // This mouse region covers the entire delegate. + // When clicked it changes mode to 'Details'. If we are already + // in Details mode, then no change will happen. + MouseArea { + id: pageMouse + anchors.fill: parent + onClicked: wrapper.state = 'Details'; + } + + // Layout the page. Picture, title and ingredients at the top, method at the + // bottom. Note that elements that should not be visible in the list + // mode have their opacity set to wrapper.detailsOpacity. + Row { + id: topLayout + x: 10; y: 10; height: recipePic.height; width: parent.width + spacing: 10 + + Image { + id: recipePic + source: picture; width: 48; height: 48 + } + + Column { + width: background.width-recipePic.width-20; height: recipePic.height; + spacing: 5 + + Text { id: name; text: title; font.bold: true; font.pointSize: 16 } + + Text { + text: "Ingredients" + font.pointSize: 12; font.bold: true + opacity: wrapper.detailsOpacity + } + + Text { + text: ingredients + wrapMode: Text.WordWrap + width: parent.width + opacity: wrapper.detailsOpacity + } + } + } + + Item { + id: details + x: 10; width: parent.width-20 + anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + opacity: wrapper.detailsOpacity + + Text { + id: methodTitle + anchors.top: parent.top + text: "Method" + font.pointSize: 12; font.bold: true + } + + Flickable { + id: flick + width: parent.width + anchors { top: methodTitle.bottom; bottom: parent.bottom } + contentHeight: methodText.height; clip: true + + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } + } + + Image { + anchors { right: flick.right; top: flick.top } + source: "content/pics/moreUp.png" + opacity: flick.atYBeginning ? 0 : 1 + } + + Image { + anchors { right: flick.right; bottom: flick.bottom } + source: "content/pics/moreDown.png" + opacity: flick.atYEnd ? 0 : 1 + } + } + + // A button to close the detailed view, i.e. set the state back to default (''). + MediaButton { + y: 10; anchors { right: background.right; rightMargin: 5 } + opacity: wrapper.detailsOpacity + text: "Close" + + onClicked: wrapper.state = ''; + } + + // Set the default height to the height of the picture, plus margin. + height: 68 + + states: State { + name: "Details" + + PropertyChanges { target: background; color: "white" } + PropertyChanges { target: recipePic; width: 128; height: 128 } // Make picture bigger + PropertyChanges { target: wrapper; detailsOpacity: 1; x: 0 } // Make details visible + PropertyChanges { target: wrapper; height: list.height } // Fill the entire list area with the detailed view + + // Move the list so that this item is at the top. + PropertyChanges { target: wrapper.ListView.view; explicit: true; contentY: wrapper.y } + + // Disallow flicking while we're in detailed view + PropertyChanges { target: wrapper.ListView.view; interactive: false } + } + + transitions: Transition { + // Make the state changes smooth + ParallelAnimation { + ColorAnimation { property: "color"; duration: 500 } + NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" } + } + } + } + } + + // The actual list + ListView { + id: list + anchors.fill: parent + clip: true + model: Recipes + delegate: recipeDelegate + } +} diff --git a/examples/declarative/modelviews/listview/sections.qml b/examples/declarative/modelviews/listview/sections.qml new file mode 100644 index 0000000..21f9f03 --- /dev/null +++ b/examples/declarative/modelviews/listview/sections.qml @@ -0,0 +1,71 @@ +import Qt 4.7 + +//! [0] +Rectangle { + width: 200 + height: 240 + + // MyPets model is defined in dummydata/MyPetsModel.qml + // The viewer automatically loads files in dummydata/* to assist + // development without a real data source. + // This one contains my pets. + + // Define a delegate component that includes a separator for sections. + Component { + id: petDelegate + + Item { + id: wrapper + width: 200 + height: desc.height // height is the combined height of the description and the section separator + + Item { + id: desc + x: 5; height: layout.height + 4 + + Column { + id: layout + y: 2 + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } + } + } + } + + // Define a highlight component. Just one of these will be instantiated + // by each ListView and placed behind the current item. + Component { + id: petHighlight + Rectangle { color: "#FFFF88" } + } + + // The list + ListView { + id: myList + + width: 200; height: parent.height + model: MyPetsModel + delegate: petDelegate + highlight: petHighlight + focus: true + + // The sectionExpression is simply the size of the pet. + // We use this to determine which section we are in above. + section.property: "size" + section.criteria: ViewSection.FullString + section.delegate: Rectangle { + color: "lightsteelblue" + width: 200 + height: 20 + Text { + x: 2; height: parent.height + verticalAlignment: Text.AlignVCenter + text: section + font.bold: true + } + } + } +} +//! [0] diff --git a/examples/declarative/modelviews/modelviews.pro b/examples/declarative/modelviews/modelviews.pro new file mode 100644 index 0000000..b811e44 --- /dev/null +++ b/examples/declarative/modelviews/modelviews.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + objectlistmodel \ + stringlistmodel + + diff --git a/examples/declarative/modelviews/modelviews.qmlproject b/examples/declarative/modelviews/modelviews.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/modelviews.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/objectlistmodel/dataobject.cpp b/examples/declarative/modelviews/objectlistmodel/dataobject.cpp new file mode 100644 index 0000000..14be1b9 --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/dataobject.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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 +#include "dataobject.h" + +DataObject::DataObject(QObject *parent) + : QObject(parent) +{ +} + +DataObject::DataObject(const QString &name, const QString &color, QObject *parent) + : QObject(parent), m_name(name), m_color(color) +{ +} + +QString DataObject::name() const +{ + return m_name; +} + +void DataObject::setName(const QString &name) +{ + if (name != m_name) { + m_name = name; + emit nameChanged(); + } +} + +QString DataObject::color() const +{ + return m_color; +} + +void DataObject::setColor(const QString &color) +{ + if (color != m_color) { + m_color = color; + emit colorChanged(); + } +} diff --git a/examples/declarative/modelviews/objectlistmodel/dataobject.h b/examples/declarative/modelviews/objectlistmodel/dataobject.h new file mode 100644 index 0000000..852110d --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/dataobject.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 DATAOBJECT_H +#define DATAOBJECT_H + +#include + +class DataObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) + +public: + DataObject(QObject *parent=0); + DataObject(const QString &name, const QString &color, QObject *parent=0); + + QString name() const; + void setName(const QString &name); + + QString color() const; + void setColor(const QString &color); + +signals: + void nameChanged(); + void colorChanged(); + +private: + QString m_name; + QString m_color; +}; + +#endif // DATAOBJECT_H diff --git a/examples/declarative/modelviews/objectlistmodel/main.cpp b/examples/declarative/modelviews/objectlistmodel/main.cpp new file mode 100644 index 0000000..b210570 --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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 demonstration applications 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 "dataobject.h" + +/* + This example illustrates exposing a QList as a + model in QML +*/ + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + QDeclarativeView view; + + QList dataList; + dataList.append(new DataObject("Item 1", "red")); + dataList.append(new DataObject("Item 2", "green")); + dataList.append(new DataObject("Item 3", "blue")); + dataList.append(new DataObject("Item 4", "yellow")); + + QDeclarativeContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro new file mode 100644 index 0000000..869cde3 --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro @@ -0,0 +1,18 @@ +TEMPLATE = app +TARGET = objectlistmodel +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + dataobject.cpp +HEADERS += dataobject.h +RESOURCES += objectlistmodel.qrc + +sources.files = $$SOURCES $$HEADERS $$RESOURCES objectlistmodel.pro view.qml +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/objectlistmodel +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/objectlistmodel + +INSTALLS += sources target + diff --git a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc new file mode 100644 index 0000000..17e9301 --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/declarative/modelviews/objectlistmodel/view.qml b/examples/declarative/modelviews/objectlistmodel/view.qml new file mode 100644 index 0000000..2b8383f --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/view.qml @@ -0,0 +1,16 @@ +import Qt 4.7 + +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + color: model.modelData.color + Text { text: name } + } + } +} diff --git a/examples/declarative/modelviews/package/Delegate.qml b/examples/declarative/modelviews/package/Delegate.qml new file mode 100644 index 0000000..785fde6 --- /dev/null +++ b/examples/declarative/modelviews/package/Delegate.qml @@ -0,0 +1,48 @@ +import Qt 4.7 + +//![0] +Package { + Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } + + Rectangle { + id: wrapper + width: 200; height: 25 + color: 'lightsteelblue' + + Text { text: display; anchors.centerIn: parent } + MouseArea { + anchors.fill: parent + onClicked: { + if (wrapper.state == 'inList') + wrapper.state = 'inGrid'; + else + wrapper.state = 'inList'; + } + } + + state: 'inList' + states: [ + State { + name: 'inList' + ParentChange { target: wrapper; parent: listDelegate } + }, + State { + name: 'inGrid' + ParentChange { + target: wrapper; parent: gridDelegate + x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } +} +//![0] diff --git a/examples/declarative/modelviews/package/package.qmlproject b/examples/declarative/modelviews/package/package.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/package/package.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/package/view.qml b/examples/declarative/modelviews/package/view.qml new file mode 100644 index 0000000..67f896b --- /dev/null +++ b/examples/declarative/modelviews/package/view.qml @@ -0,0 +1,35 @@ +import Qt 4.7 + +Item { + width: 400 + height: 200 + + ListModel { + id: myModel + ListElement { display: "One" } + ListElement { display: "Two" } + ListElement { display: "Three" } + ListElement { display: "Four" } + ListElement { display: "Five" } + ListElement { display: "Six" } + ListElement { display: "Seven" } + ListElement { display: "Eight" } + } + //![0] + VisualDataModel { + id: visualModel + delegate: Delegate {} + model: myModel + } + + ListView { + width: 200; height:200 + model: visualModel.parts.list + } + GridView { + x: 200; width: 200; height:200 + cellHeight: 50 + model: visualModel.parts.grid + } + //![0] +} diff --git a/examples/declarative/modelviews/parallax/parallax.qml b/examples/declarative/modelviews/parallax/parallax.qml new file mode 100644 index 0000000..110f17e --- /dev/null +++ b/examples/declarative/modelviews/parallax/parallax.qml @@ -0,0 +1,41 @@ +import Qt 4.7 +import "../../toys/clocks/content" +import "qml" + +Rectangle { + id: root + + width: 320; height: 480 + + ParallaxView { + id: parallax + anchors.fill: parent + background: "pics/background.jpg" + + Item { + property url icon: "pics/yast-wol.png" + width: 320; height: 480 + Clock { anchors.centerIn: parent } + } + + Item { + property url icon: "pics/home-page.svg" + width: 320; height: 480 + Smiley { } + } + + Item { + property url icon: "pics/yast-joystick.png" + width: 320; height: 480 + + Loader { + anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter } + width: 300; height: 400 + clip: true; + source: "../../../../demos/declarative/samegame/samegame.qml" + } + } + + currentIndex: root.currentIndex + } +} diff --git a/examples/declarative/modelviews/parallax/parallax.qmlproject b/examples/declarative/modelviews/parallax/parallax.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/parallax/parallax.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/parallax/pics/background.jpg b/examples/declarative/modelviews/parallax/pics/background.jpg new file mode 100644 index 0000000..61cca2f Binary files /dev/null and b/examples/declarative/modelviews/parallax/pics/background.jpg differ diff --git a/examples/declarative/modelviews/parallax/pics/face-smile.png b/examples/declarative/modelviews/parallax/pics/face-smile.png new file mode 100644 index 0000000..3d66d72 Binary files /dev/null and b/examples/declarative/modelviews/parallax/pics/face-smile.png differ diff --git a/examples/declarative/modelviews/parallax/pics/home-page.svg b/examples/declarative/modelviews/parallax/pics/home-page.svg new file mode 100644 index 0000000..4f16958 --- /dev/null +++ b/examples/declarative/modelviews/parallax/pics/home-page.svg @@ -0,0 +1,445 @@ + +image/svg+xmlGo HomeJakub Steinerhttp://jimmac.musichall.czhomereturngodefaultuserdirectoryTuomas Kuosmanen + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/declarative/modelviews/parallax/pics/shadow.png b/examples/declarative/modelviews/parallax/pics/shadow.png new file mode 100644 index 0000000..8270565 Binary files /dev/null and b/examples/declarative/modelviews/parallax/pics/shadow.png differ diff --git a/examples/declarative/modelviews/parallax/pics/yast-joystick.png b/examples/declarative/modelviews/parallax/pics/yast-joystick.png new file mode 100644 index 0000000..858cea0 Binary files /dev/null and b/examples/declarative/modelviews/parallax/pics/yast-joystick.png differ diff --git a/examples/declarative/modelviews/parallax/pics/yast-wol.png b/examples/declarative/modelviews/parallax/pics/yast-wol.png new file mode 100644 index 0000000..7712180 Binary files /dev/null and b/examples/declarative/modelviews/parallax/pics/yast-wol.png differ diff --git a/examples/declarative/modelviews/parallax/qml/ParallaxView.qml b/examples/declarative/modelviews/parallax/qml/ParallaxView.qml new file mode 100644 index 0000000..e869a21 --- /dev/null +++ b/examples/declarative/modelviews/parallax/qml/ParallaxView.qml @@ -0,0 +1,83 @@ +import Qt 4.7 + +Item { + id: root + + property alias background: background.source + default property alias content: visualModel.children + property int currentIndex: 0 + + Image { + id: background + fillMode: Image.TileHorizontally + x: -list.contentX / 2 + width: Math.max(list.contentWidth, parent.width) + } + + ListView { + id: list + + currentIndex: root.currentIndex + onCurrentIndexChanged: root.currentIndex = currentIndex + + orientation: Qt.Horizontal + boundsBehavior: Flickable.DragOverBounds + anchors.fill: parent + model: VisualItemModel { id: visualModel } + + highlightRangeMode: ListView.StrictlyEnforceRange + snapMode: ListView.SnapOneItem + } + + ListView { + id: selector + + Rectangle { + color: "#60FFFFFF" + x: -10; y: -10; radius: 10; z: -1 + width: parent.width + 20; height: parent.height + 20 + } + currentIndex: root.currentIndex + onCurrentIndexChanged: root.currentIndex = currentIndex + + height: 50 + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + width: Math.min(count * 50, parent.width - 20) + interactive: width == parent.width - 20 + orientation: Qt.Horizontal + + delegate: Item { + width: 50; height: 50 + id: delegateRoot + + Image { + id: image + source: modelData.icon + smooth: true + scale: 0.8 + } + + MouseArea { + anchors.fill: parent + onClicked: { root.currentIndex = index } + } + + states: State { + name: "Selected" + when: delegateRoot.ListView.isCurrentItem == true + PropertyChanges { + target: image + scale: 1 + y: -5 + } + } + transitions: Transition { + NumberAnimation { + properties: "scale,y" + } + } + } + model: visualModel.children + } +} diff --git a/examples/declarative/modelviews/parallax/qml/Smiley.qml b/examples/declarative/modelviews/parallax/qml/Smiley.qml new file mode 100644 index 0000000..662addc --- /dev/null +++ b/examples/declarative/modelviews/parallax/qml/Smiley.qml @@ -0,0 +1,46 @@ +import Qt 4.7 + +Item { + id: window + width: 320; height: 480 + + // The shadow for the smiley face + Image { + anchors.horizontalCenter: parent.horizontalCenter + source: "../pics/shadow.png"; y: smiley.minHeight + 58 + + // The scale property depends on the y position of the smiley face. + scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) + } + + Image { + id: smiley + property int maxHeight: window.height / 3 + property int minHeight: 2 * window.height / 3 + + anchors.horizontalCenter: parent.horizontalCenter + source: "../pics/face-smile.png"; y: minHeight + + // Animate the y property. Setting repeat to true makes the + // animation repeat indefinitely, otherwise it would only run once. + SequentialAnimation on y { + loops: Animation.Infinite + + // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function + NumberAnimation { + from: smiley.minHeight; to: smiley.maxHeight + easing.type: Easing.OutExpo; duration: 300 + } + + // Then move back to minHeight in 1 second, using the OutBounce easing function + NumberAnimation { + from: smiley.maxHeight; to: smiley.minHeight + easing.type: Easing.OutBounce; duration: 1000 + } + + // Then pause for 500ms + PauseAnimation { duration: 500 } + } + } +} + diff --git a/examples/declarative/modelviews/stringlistmodel/main.cpp b/examples/declarative/modelviews/stringlistmodel/main.cpp new file mode 100644 index 0000000..abbffa7 --- /dev/null +++ b/examples/declarative/modelviews/stringlistmodel/main.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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 demonstration applications 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 + + +/* + This example illustrates exposing a QStringList as a + model in QML +*/ + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + QDeclarativeView view; + + QStringList dataList; + dataList.append("Item 1"); + dataList.append("Item 2"); + dataList.append("Item 3"); + dataList.append("Item 4"); + + QDeclarativeContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro new file mode 100644 index 0000000..23dc481 --- /dev/null +++ b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = stringlistmodel +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp +RESOURCES += stringlistmodel.qrc diff --git a/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc new file mode 100644 index 0000000..17e9301 --- /dev/null +++ b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/declarative/modelviews/stringlistmodel/view.qml b/examples/declarative/modelviews/stringlistmodel/view.qml new file mode 100644 index 0000000..41c03d9 --- /dev/null +++ b/examples/declarative/modelviews/stringlistmodel/view.qml @@ -0,0 +1,15 @@ +import Qt 4.7 + +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + Text { text: modelData } + } + } +} diff --git a/examples/declarative/modelviews/webview/alerts.html b/examples/declarative/modelviews/webview/alerts.html new file mode 100644 index 0000000..82caddf --- /dev/null +++ b/examples/declarative/modelviews/webview/alerts.html @@ -0,0 +1,5 @@ + + +

      This is a web page. It fires an alert when clicked. + + diff --git a/examples/declarative/modelviews/webview/alerts.qml b/examples/declarative/modelviews/webview/alerts.qml new file mode 100644 index 0000000..7684c3e --- /dev/null +++ b/examples/declarative/modelviews/webview/alerts.qml @@ -0,0 +1,58 @@ +import Qt 4.7 +import org.webkit 1.0 + +WebView { + id: webView + width: 120 + height: 150 + url: "alerts.html" + + onAlert: popup.show(message) + + Rectangle { + id: popup + + color: "red" + border.color: "black"; border.width: 2 + radius: 4 + + y: parent.height // off "screen" + anchors.horizontalCenter: parent.horizontalCenter + width: label.width+5 + height: label.height+5 + + opacity: 0 + + function show(t) { + label.text = t + popup.state = "visible" + timer.start() + } + states: State { + name: "visible" + PropertyChanges { target: popup; opacity: 1 } + PropertyChanges { target: popup; y: (webView.height-popup.height)/2 } + } + + transitions: [ + Transition { from: ""; PropertyAnimation { properties: "opacity,y"; duration: 65 } }, + Transition { from: "visible"; PropertyAnimation { properties: "opacity,y"; duration: 500 } } + ] + + Timer { + id: timer + interval: 1000 + onTriggered: popup.state = "" + } + + Text { + id: label + anchors.centerIn: parent + color: "white" + font.pixelSize: 20 + width: webView.width*0.75 + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + } + } +} diff --git a/examples/declarative/modelviews/webview/autosize.qml b/examples/declarative/modelviews/webview/autosize.qml new file mode 100644 index 0000000..9632883 --- /dev/null +++ b/examples/declarative/modelviews/webview/autosize.qml @@ -0,0 +1,62 @@ +import Qt 4.7 +import org.webkit 1.0 + +// The WebView size is determined by the width, height, +// preferredWidth, and preferredHeight properties. +Rectangle { + id: rect + width: 200 + height: layout.height + + Column { + id: layout + spacing: 2 + WebView { + html: "No width defined." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: rect.width + html: "The width is full." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: rect.width/2 + html: "The width is half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + preferredWidth: rect.width/2 + html: "The preferredWidth is half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + preferredWidth: rect.width/2 + html: "The_preferredWidth_is_half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: rect.width/2 + html: "The_width_is_half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + } +} diff --git a/examples/declarative/modelviews/webview/content/FieldText.qml b/examples/declarative/modelviews/webview/content/FieldText.qml new file mode 100644 index 0000000..d1d003f --- /dev/null +++ b/examples/declarative/modelviews/webview/content/FieldText.qml @@ -0,0 +1,157 @@ +import Qt 4.7 + +Item { + id: fieldText + height: 30 + property string text: "" + property string label: "" + property bool mouseGrabbed: false + signal confirmed + signal cancelled + signal startEdit + + function edit() { + if (!mouseGrabbed) { + fieldText.startEdit(); + fieldText.state='editing'; + mouseGrabbed=true; + } + } + + function confirm() { + fieldText.state=''; + fieldText.text = textEdit.text; + mouseGrabbed=false; + fieldText.confirmed(); + } + + function reset() { + textEdit.text = fieldText.text; + fieldText.state=''; + mouseGrabbed=false; + fieldText.cancelled(); + } + + Image { + id: cancelIcon + width: 22 + height: 22 + anchors.right: parent.right + anchors.rightMargin: 4 + anchors.verticalCenter: parent.verticalCenter + source: "pics/cancel.png" + opacity: 0 + } + + Image { + id: confirmIcon + width: 22 + height: 22 + anchors.left: parent.left + anchors.leftMargin: 4 + anchors.verticalCenter: parent.verticalCenter + source: "pics/ok.png" + opacity: 0 + } + + TextInput { + id: textEdit + text: fieldText.text + focus: false + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.verticalCenter: parent.verticalCenter + color: "black" + font.bold: true + readOnly: true + onAccepted: confirm() + Keys.onEscapePressed: reset() + } + + Text { + id: textLabel + x: 5 + width: parent.width-10 + anchors.verticalCenter: parent.verticalCenter + horizontalAlignment: Text.AlignHCenter + color: fieldText.state == "editing" ? "#505050" : "#AAAAAA" + font.italic: true + font.bold: true + text: label + opacity: textEdit.text == '' ? 1 : 0 + Behavior on opacity { + NumberAnimation { + property: "opacity" + duration: 250 + } + } + } + + MouseArea { + anchors.fill: cancelIcon + onClicked: { reset() } + } + + MouseArea { + anchors.fill: confirmIcon + onClicked: { confirm() } + } + + MouseArea { + id: editRegion + anchors.fill: textEdit + onClicked: { edit() } + } + + states: [ + State { + name: "editing" + PropertyChanges { + target: confirmIcon + opacity: 1 + } + PropertyChanges { + target: cancelIcon + opacity: 1 + } + PropertyChanges { + target: textEdit + color: "black" + readOnly: false + focus: true + selectionStart: 0 + selectionEnd: -1 + } + PropertyChanges { + target: editRegion + opacity: 0 + } + PropertyChanges { + target: textEdit.anchors + leftMargin: 34 + } + PropertyChanges { + target: textEdit.anchors + rightMargin: 34 + } + } + ] + + transitions: [ + Transition { + from: "" + to: "*" + reversible: true + NumberAnimation { + properties: "opacity,leftMargin,rightMargin" + duration: 200 + } + ColorAnimation { + property: "color" + duration: 150 + } + } + ] +} diff --git a/examples/declarative/modelviews/webview/content/Mapping/Map.qml b/examples/declarative/modelviews/webview/content/Mapping/Map.qml new file mode 100644 index 0000000..5d3ba81 --- /dev/null +++ b/examples/declarative/modelviews/webview/content/Mapping/Map.qml @@ -0,0 +1,26 @@ +import Qt 4.7 +import org.webkit 1.0 + +Item { + id: page + property real latitude: -34.397 + property real longitude: 150.644 + property string address: "" + property alias status: js.status + WebView { + id: map + anchors.fill: parent + url: "map.html" + javaScriptWindowObjects: QtObject { + id: js + WebView.windowObjectName: "qml" + property real lat: page.latitude + property real lng: page.longitude + property string address: page.address + property string status: "Loading" + onAddressChanged: { if (map.url != "" && map.progress==1) map.evaluateJavaScript("goToAddress()") } + } + pressGrabTime: 0 + onLoadFinished: { evaluateJavaScript("goToAddress()"); } + } +} diff --git a/examples/declarative/modelviews/webview/content/Mapping/map.html b/examples/declarative/modelviews/webview/content/Mapping/map.html new file mode 100755 index 0000000..a8726fd --- /dev/null +++ b/examples/declarative/modelviews/webview/content/Mapping/map.html @@ -0,0 +1,52 @@ + + + + + + + +

      + + diff --git a/examples/declarative/modelviews/webview/content/SpinSquare.qml b/examples/declarative/modelviews/webview/content/SpinSquare.qml new file mode 100644 index 0000000..dba48d4 --- /dev/null +++ b/examples/declarative/modelviews/webview/content/SpinSquare.qml @@ -0,0 +1,25 @@ +import Qt 4.7 + +Item { + property variant period : 250 + property variant color : "black" + id: root + + Item { + x: root.width/2 + y: root.height/2 + Rectangle { + color: root.color + x: -width/2 + y: -height/2 + width: root.width + height: width + } + NumberAnimation on rotation { + from: 0 + to: 360 + loops: Animation.Infinite + duration: root.period + } + } +} diff --git a/examples/declarative/modelviews/webview/content/pics/cancel.png b/examples/declarative/modelviews/webview/content/pics/cancel.png new file mode 100644 index 0000000..ecc9533 Binary files /dev/null and b/examples/declarative/modelviews/webview/content/pics/cancel.png differ diff --git a/examples/declarative/modelviews/webview/content/pics/ok.png b/examples/declarative/modelviews/webview/content/pics/ok.png new file mode 100644 index 0000000..5795f04 Binary files /dev/null and b/examples/declarative/modelviews/webview/content/pics/ok.png differ diff --git a/examples/declarative/modelviews/webview/googleMaps.qml b/examples/declarative/modelviews/webview/googleMaps.qml new file mode 100644 index 0000000..5506012 --- /dev/null +++ b/examples/declarative/modelviews/webview/googleMaps.qml @@ -0,0 +1,43 @@ +// This example demonstrates how Web services such as Google Maps can be +// abstracted as QML types. Here we have a "Mapping" module with a "Map" +// type. The Map type has an address property. Setting that property moves +// the map. The underlying implementation uses WebView and the Google Maps +// API, but users from QML don't need to understand the implementation in +// order to create a Map. + +import Qt 4.7 +import org.webkit 1.0 +import "content/Mapping" + +Map { + id: map + width: 300 + height: 300 + address: "Paris" + + Rectangle { + x: 70 + width: input.width + 20 + height: input.height + 4 + anchors.bottom: parent.bottom; anchors.bottomMargin: 5 + radius: 5 + opacity: map.status == "Ready" ? 1 : 0 + + TextInput { + id: input + text: map.address + anchors.centerIn: parent + Keys.onReturnPressed: map.address = input.text + } + } + + Text { + id: loading + anchors.centerIn: parent + text: map.status == "Error" ? "Error" : "Loading" + opacity: map.status == "Ready" ? 0 : 1 + font.pixelSize: 30 + + Behavior on opacity { NumberAnimation{} } + } +} diff --git a/examples/declarative/modelviews/webview/inline-html.qml b/examples/declarative/modelviews/webview/inline-html.qml new file mode 100644 index 0000000..eec7fc6 --- /dev/null +++ b/examples/declarative/modelviews/webview/inline-html.qml @@ -0,0 +1,15 @@ +import Qt 4.7 +import org.webkit 1.0 + +// Inline HTML with loose formatting can be +// set on the html property. +WebView { + html:"\ + \ + \ +
      OneTwoThree\ +
      1X1X\ +
      20X0\ +
      3X1X\ +
      " +} diff --git a/examples/declarative/modelviews/webview/newwindows.html b/examples/declarative/modelviews/webview/newwindows.html new file mode 100644 index 0000000..f169599 --- /dev/null +++ b/examples/declarative/modelviews/webview/newwindows.html @@ -0,0 +1,3 @@ +

      Multiple windows...

      + +Popup! diff --git a/examples/declarative/modelviews/webview/newwindows.qml b/examples/declarative/modelviews/webview/newwindows.qml new file mode 100644 index 0000000..2e4a72e --- /dev/null +++ b/examples/declarative/modelviews/webview/newwindows.qml @@ -0,0 +1,31 @@ +// Demonstrates opening new WebViews from HTML +// +// Note that to open windows from JavaScript, you will need to +// allow it on WebView with settings.javascriptCanOpenWindows: true + +import Qt 4.7 +import org.webkit 1.0 + +Grid { + columns: 3 + id: pages + height: 300; width: 600 + + Component { + id: webViewPage + Rectangle { + width: webView.width + height: webView.height + border.color: "gray" + + WebView { + id: webView + newWindowComponent: webViewPage + newWindowParent: pages + url: "newwindows.html" + } + } + } + + Loader { sourceComponent: webViewPage } +} diff --git a/examples/declarative/modelviews/webview/transparent.qml b/examples/declarative/modelviews/webview/transparent.qml new file mode 100644 index 0000000..e4efc31 --- /dev/null +++ b/examples/declarative/modelviews/webview/transparent.qml @@ -0,0 +1,15 @@ +import Qt 4.7 +import org.webkit 1.0 + +// The WebView background is transparent +// if the HTML does not specify a background +Rectangle { + color: "green" + width: web.width + height: web.height + + WebView { + id: web + html: "Hello World!" + } +} diff --git a/examples/declarative/modelviews/webview/webview.qmlproject b/examples/declarative/modelviews/webview/webview.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/webview/webview.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/mousearea/mouse.qml b/examples/declarative/mousearea/mouse.qml deleted file mode 100644 index 06134b7..0000000 --- a/examples/declarative/mousearea/mouse.qml +++ /dev/null @@ -1,47 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 200; height: 200 - - Rectangle { - width: 50; height: 50 - color: "red" - - Text { text: "Click"; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - acceptedButtons: Qt.LeftButton | Qt.RightButton - - onPressed: console.log('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') - onReleased: console.log('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') - onClicked: console.log('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') - onDoubleClicked: console.log('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') - onPressAndHold: console.log('press and hold') - onEntered: console.log('entered ' + pressed) - onExited: console.log('exited ' + pressed) - } - } - - Rectangle { - y: 100; width: 50; height: 50 - color: "blue" - - Text { text: "Drag"; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - drag.target: parent - drag.axis: Drag.XAxis - drag.minimumX: 0 - drag.maximumX: 150 - - onPressed: console.log('press') - onReleased: console.log('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') - onClicked: console.log('click' + '(wasHeld: ' + mouse.wasHeld + ')') - onDoubleClicked: console.log('double click') - onPressAndHold: console.log('press and hold') - } - } -} diff --git a/examples/declarative/mousearea/mousearea.qmlproject b/examples/declarative/mousearea/mousearea.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/mousearea/mousearea.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/objectlistmodel/dataobject.cpp b/examples/declarative/objectlistmodel/dataobject.cpp deleted file mode 100644 index 14be1b9..0000000 --- a/examples/declarative/objectlistmodel/dataobject.cpp +++ /dev/null @@ -1,79 +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$ -** -****************************************************************************/ - -#include -#include "dataobject.h" - -DataObject::DataObject(QObject *parent) - : QObject(parent) -{ -} - -DataObject::DataObject(const QString &name, const QString &color, QObject *parent) - : QObject(parent), m_name(name), m_color(color) -{ -} - -QString DataObject::name() const -{ - return m_name; -} - -void DataObject::setName(const QString &name) -{ - if (name != m_name) { - m_name = name; - emit nameChanged(); - } -} - -QString DataObject::color() const -{ - return m_color; -} - -void DataObject::setColor(const QString &color) -{ - if (color != m_color) { - m_color = color; - emit colorChanged(); - } -} diff --git a/examples/declarative/objectlistmodel/dataobject.h b/examples/declarative/objectlistmodel/dataobject.h deleted file mode 100644 index 852110d..0000000 --- a/examples/declarative/objectlistmodel/dataobject.h +++ /dev/null @@ -1,73 +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$ -** -****************************************************************************/ - -#ifndef DATAOBJECT_H -#define DATAOBJECT_H - -#include - -class DataObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) - -public: - DataObject(QObject *parent=0); - DataObject(const QString &name, const QString &color, QObject *parent=0); - - QString name() const; - void setName(const QString &name); - - QString color() const; - void setColor(const QString &color); - -signals: - void nameChanged(); - void colorChanged(); - -private: - QString m_name; - QString m_color; -}; - -#endif // DATAOBJECT_H diff --git a/examples/declarative/objectlistmodel/main.cpp b/examples/declarative/objectlistmodel/main.cpp deleted file mode 100644 index b210570..0000000 --- a/examples/declarative/objectlistmodel/main.cpp +++ /dev/null @@ -1,77 +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 demonstration applications 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 "dataobject.h" - -/* - This example illustrates exposing a QList as a - model in QML -*/ - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - QDeclarativeView view; - - QList dataList; - dataList.append(new DataObject("Item 1", "red")); - dataList.append(new DataObject("Item 2", "green")); - dataList.append(new DataObject("Item 3", "blue")); - dataList.append(new DataObject("Item 4", "yellow")); - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/objectlistmodel/objectlistmodel.pro b/examples/declarative/objectlistmodel/objectlistmodel.pro deleted file mode 100644 index 869cde3..0000000 --- a/examples/declarative/objectlistmodel/objectlistmodel.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = app -TARGET = objectlistmodel -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - dataobject.cpp -HEADERS += dataobject.h -RESOURCES += objectlistmodel.qrc - -sources.files = $$SOURCES $$HEADERS $$RESOURCES objectlistmodel.pro view.qml -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/objectlistmodel -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/objectlistmodel - -INSTALLS += sources target - diff --git a/examples/declarative/objectlistmodel/objectlistmodel.qmlproject b/examples/declarative/objectlistmodel/objectlistmodel.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/objectlistmodel/objectlistmodel.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/objectlistmodel/objectlistmodel.qrc b/examples/declarative/objectlistmodel/objectlistmodel.qrc deleted file mode 100644 index 17e9301..0000000 --- a/examples/declarative/objectlistmodel/objectlistmodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/objectlistmodel/view.qml b/examples/declarative/objectlistmodel/view.qml deleted file mode 100644 index 2b8383f..0000000 --- a/examples/declarative/objectlistmodel/view.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.7 - -ListView { - width: 100 - height: 100 - anchors.fill: parent - model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - color: model.modelData.color - Text { text: name } - } - } -} diff --git a/examples/declarative/package/Delegate.qml b/examples/declarative/package/Delegate.qml deleted file mode 100644 index 785fde6..0000000 --- a/examples/declarative/package/Delegate.qml +++ /dev/null @@ -1,48 +0,0 @@ -import Qt 4.7 - -//![0] -Package { - Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } - Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } - - Rectangle { - id: wrapper - width: 200; height: 25 - color: 'lightsteelblue' - - Text { text: display; anchors.centerIn: parent } - MouseArea { - anchors.fill: parent - onClicked: { - if (wrapper.state == 'inList') - wrapper.state = 'inGrid'; - else - wrapper.state = 'inList'; - } - } - - state: 'inList' - states: [ - State { - name: 'inList' - ParentChange { target: wrapper; parent: listDelegate } - }, - State { - name: 'inGrid' - ParentChange { - target: wrapper; parent: gridDelegate - x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height - } - } - ] - - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } -} -//![0] diff --git a/examples/declarative/package/package.qmlproject b/examples/declarative/package/package.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/package/package.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/package/view.qml b/examples/declarative/package/view.qml deleted file mode 100644 index 67f896b..0000000 --- a/examples/declarative/package/view.qml +++ /dev/null @@ -1,35 +0,0 @@ -import Qt 4.7 - -Item { - width: 400 - height: 200 - - ListModel { - id: myModel - ListElement { display: "One" } - ListElement { display: "Two" } - ListElement { display: "Three" } - ListElement { display: "Four" } - ListElement { display: "Five" } - ListElement { display: "Six" } - ListElement { display: "Seven" } - ListElement { display: "Eight" } - } - //![0] - VisualDataModel { - id: visualModel - delegate: Delegate {} - model: myModel - } - - ListView { - width: 200; height:200 - model: visualModel.parts.list - } - GridView { - x: 200; width: 200; height:200 - cellHeight: 50 - model: visualModel.parts.grid - } - //![0] -} diff --git a/examples/declarative/parallax/parallax.qml b/examples/declarative/parallax/parallax.qml deleted file mode 100644 index ca00176..0000000 --- a/examples/declarative/parallax/parallax.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.7 -import "../clocks/content" -import "qml" - -Rectangle { - id: root - - width: 320; height: 480 - - ParallaxView { - id: parallax - anchors.fill: parent - background: "pics/background.jpg" - - Item { - property url icon: "pics/yast-wol.png" - width: 320; height: 480 - Clock { anchors.centerIn: parent } - } - - Item { - property url icon: "pics/home-page.svg" - width: 320; height: 480 - Smiley { } - } - - Item { - property url icon: "pics/yast-joystick.png" - width: 320; height: 480 - - Loader { - anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter } - width: 300; height: 400 - clip: true; - source: "../../../demos/declarative/samegame/samegame.qml" - } - } - - currentIndex: root.currentIndex - } -} diff --git a/examples/declarative/parallax/parallax.qmlproject b/examples/declarative/parallax/parallax.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/parallax/parallax.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/parallax/pics/background.jpg b/examples/declarative/parallax/pics/background.jpg deleted file mode 100644 index 61cca2f..0000000 Binary files a/examples/declarative/parallax/pics/background.jpg and /dev/null differ diff --git a/examples/declarative/parallax/pics/face-smile.png b/examples/declarative/parallax/pics/face-smile.png deleted file mode 100644 index 3d66d72..0000000 Binary files a/examples/declarative/parallax/pics/face-smile.png and /dev/null differ diff --git a/examples/declarative/parallax/pics/home-page.svg b/examples/declarative/parallax/pics/home-page.svg deleted file mode 100644 index 4f16958..0000000 --- a/examples/declarative/parallax/pics/home-page.svg +++ /dev/null @@ -1,445 +0,0 @@ - -image/svg+xmlGo HomeJakub Steinerhttp://jimmac.musichall.czhomereturngodefaultuserdirectoryTuomas Kuosmanen - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/parallax/pics/shadow.png b/examples/declarative/parallax/pics/shadow.png deleted file mode 100644 index 8270565..0000000 Binary files a/examples/declarative/parallax/pics/shadow.png and /dev/null differ diff --git a/examples/declarative/parallax/pics/yast-joystick.png b/examples/declarative/parallax/pics/yast-joystick.png deleted file mode 100644 index 858cea0..0000000 Binary files a/examples/declarative/parallax/pics/yast-joystick.png and /dev/null differ diff --git a/examples/declarative/parallax/pics/yast-wol.png b/examples/declarative/parallax/pics/yast-wol.png deleted file mode 100644 index 7712180..0000000 Binary files a/examples/declarative/parallax/pics/yast-wol.png and /dev/null differ diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml deleted file mode 100644 index e869a21..0000000 --- a/examples/declarative/parallax/qml/ParallaxView.qml +++ /dev/null @@ -1,83 +0,0 @@ -import Qt 4.7 - -Item { - id: root - - property alias background: background.source - default property alias content: visualModel.children - property int currentIndex: 0 - - Image { - id: background - fillMode: Image.TileHorizontally - x: -list.contentX / 2 - width: Math.max(list.contentWidth, parent.width) - } - - ListView { - id: list - - currentIndex: root.currentIndex - onCurrentIndexChanged: root.currentIndex = currentIndex - - orientation: Qt.Horizontal - boundsBehavior: Flickable.DragOverBounds - anchors.fill: parent - model: VisualItemModel { id: visualModel } - - highlightRangeMode: ListView.StrictlyEnforceRange - snapMode: ListView.SnapOneItem - } - - ListView { - id: selector - - Rectangle { - color: "#60FFFFFF" - x: -10; y: -10; radius: 10; z: -1 - width: parent.width + 20; height: parent.height + 20 - } - currentIndex: root.currentIndex - onCurrentIndexChanged: root.currentIndex = currentIndex - - height: 50 - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - width: Math.min(count * 50, parent.width - 20) - interactive: width == parent.width - 20 - orientation: Qt.Horizontal - - delegate: Item { - width: 50; height: 50 - id: delegateRoot - - Image { - id: image - source: modelData.icon - smooth: true - scale: 0.8 - } - - MouseArea { - anchors.fill: parent - onClicked: { root.currentIndex = index } - } - - states: State { - name: "Selected" - when: delegateRoot.ListView.isCurrentItem == true - PropertyChanges { - target: image - scale: 1 - y: -5 - } - } - transitions: Transition { - NumberAnimation { - properties: "scale,y" - } - } - } - model: visualModel.children - } -} diff --git a/examples/declarative/parallax/qml/Smiley.qml b/examples/declarative/parallax/qml/Smiley.qml deleted file mode 100644 index 662addc..0000000 --- a/examples/declarative/parallax/qml/Smiley.qml +++ /dev/null @@ -1,46 +0,0 @@ -import Qt 4.7 - -Item { - id: window - width: 320; height: 480 - - // The shadow for the smiley face - Image { - anchors.horizontalCenter: parent.horizontalCenter - source: "../pics/shadow.png"; y: smiley.minHeight + 58 - - // The scale property depends on the y position of the smiley face. - scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) - } - - Image { - id: smiley - property int maxHeight: window.height / 3 - property int minHeight: 2 * window.height / 3 - - anchors.horizontalCenter: parent.horizontalCenter - source: "../pics/face-smile.png"; y: minHeight - - // Animate the y property. Setting repeat to true makes the - // animation repeat indefinitely, otherwise it would only run once. - SequentialAnimation on y { - loops: Animation.Infinite - - // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function - NumberAnimation { - from: smiley.minHeight; to: smiley.maxHeight - easing.type: Easing.OutExpo; duration: 300 - } - - // Then move back to minHeight in 1 second, using the OutBounce easing function - NumberAnimation { - from: smiley.maxHeight; to: smiley.minHeight - easing.type: Easing.OutBounce; duration: 1000 - } - - // Then pause for 500ms - PauseAnimation { duration: 500 } - } - } -} - diff --git a/examples/declarative/plugins/README b/examples/declarative/plugins/README deleted file mode 100644 index fe519f8..0000000 --- a/examples/declarative/plugins/README +++ /dev/null @@ -1,9 +0,0 @@ -This example shows a module "com.nokia.TimeExample" that is implemented -by a C++ plugin (providing the "Time" type), and by QML files (providing the -"Clock" type). - -To run: - - make install - qml -I . plugins.qml - diff --git a/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml deleted file mode 100644 index 0048372..0000000 --- a/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml +++ /dev/null @@ -1,50 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: clock - width: 200; height: 200; color: "gray" - - property alias city: cityLabel.text - property variant hours - property variant minutes - property variant shift : 0 - - Image { id: background; source: "clock.png" } - - Image { - x: 92.5; y: 27 - source: "hour.png" - smooth: true - transform: Rotation { - id: hourRotation - origin.x: 7.5; origin.y: 73; angle: 0 - SpringFollow on angle { - spring: 2; damping: 0.2; modulus: 360 - to: (clock.hours * 30) + (clock.minutes * 0.5) - } - } - } - - Image { - x: 93.5; y: 17 - source: "minute.png" - smooth: true - transform: Rotation { - id: minuteRotation - origin.x: 6.5; origin.y: 83; angle: 0 - SpringFollow on angle { - spring: 2; damping: 0.2; modulus: 360 - to: clock.minutes * 6 - } - } - } - - Image { - anchors.centerIn: background; source: "center.png" - } - - Text { - id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white" - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/examples/declarative/plugins/com/nokia/TimeExample/center.png b/examples/declarative/plugins/com/nokia/TimeExample/center.png deleted file mode 100644 index 7fbd802..0000000 Binary files a/examples/declarative/plugins/com/nokia/TimeExample/center.png and /dev/null differ diff --git a/examples/declarative/plugins/com/nokia/TimeExample/clock.png b/examples/declarative/plugins/com/nokia/TimeExample/clock.png deleted file mode 100644 index 462edac..0000000 Binary files a/examples/declarative/plugins/com/nokia/TimeExample/clock.png and /dev/null differ diff --git a/examples/declarative/plugins/com/nokia/TimeExample/hour.png b/examples/declarative/plugins/com/nokia/TimeExample/hour.png deleted file mode 100644 index f8061a1..0000000 Binary files a/examples/declarative/plugins/com/nokia/TimeExample/hour.png and /dev/null differ diff --git a/examples/declarative/plugins/com/nokia/TimeExample/minute.png b/examples/declarative/plugins/com/nokia/TimeExample/minute.png deleted file mode 100644 index 1297ec7..0000000 Binary files a/examples/declarative/plugins/com/nokia/TimeExample/minute.png and /dev/null differ diff --git a/examples/declarative/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/plugins/com/nokia/TimeExample/qmldir deleted file mode 100644 index e9ef115..0000000 --- a/examples/declarative/plugins/com/nokia/TimeExample/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Clock 1.0 Clock.qml -plugin qtimeexampleqmlplugin diff --git a/examples/declarative/plugins/plugin.cpp b/examples/declarative/plugins/plugin.cpp deleted file mode 100644 index fb51b0c..0000000 --- a/examples/declarative/plugins/plugin.cpp +++ /dev/null @@ -1,152 +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 examples 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 - -// Implements a "TimeModel" class with hour and minute properties -// that change on-the-minute yet efficiently sleep the rest -// of the time. - -class MinuteTimer : public QObject -{ - Q_OBJECT -public: - MinuteTimer(QObject *parent) : QObject(parent) - { - } - - void start() - { - if (!timer.isActive()) { - time = QTime::currentTime(); - timer.start(60000-time.second()*1000, this); - } - } - - void stop() - { - timer.stop(); - } - - int hour() const { return time.hour(); } - int minute() const { return time.minute(); } - -signals: - void timeChanged(); - -protected: - void timerEvent(QTimerEvent *) - { - QTime now = QTime::currentTime(); - if (now.second() == 59 && now.minute() == time.minute() && now.hour() == time.hour()) { - // just missed time tick over, force it, wait extra 0.5 seconds - time.addSecs(60); - timer.start(60500, this); - } else { - time = now; - timer.start(60000-time.second()*1000, this); - } - emit timeChanged(); - } - -private: - QTime time; - QBasicTimer timer; -}; - -class TimeModel : public QObject -{ - Q_OBJECT - Q_PROPERTY(int hour READ hour NOTIFY timeChanged) - Q_PROPERTY(int minute READ minute NOTIFY timeChanged) - -public: - TimeModel(QObject *parent=0) : QObject(parent) - { - if (++instances == 1) { - if (!timer) - timer = new MinuteTimer(qApp); - connect(timer, SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); - timer->start(); - } - } - - ~TimeModel() - { - if (--instances == 0) { - timer->stop(); - } - } - - int minute() const { return timer->minute(); } - int hour() const { return timer->hour(); } - -signals: - void timeChanged(); - -private: - QTime t; - static MinuteTimer *timer; - static int instances; -}; - -int TimeModel::instances=0; -MinuteTimer *TimeModel::timer=0; - -class QExampleQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); - qmlRegisterType(uri, 1, 0, "Time"); - } -}; - -#include "plugin.moc" - -Q_EXPORT_PLUGIN2(qtimeexampleqmlplugin, QExampleQmlPlugin); diff --git a/examples/declarative/plugins/plugins.pro b/examples/declarative/plugins/plugins.pro deleted file mode 100644 index b501ae3..0000000 --- a/examples/declarative/plugins/plugins.pro +++ /dev/null @@ -1,31 +0,0 @@ -TEMPLATE = lib -DESTDIR = com/nokia/TimeExample -TARGET = qtimeexampleqmlplugin -CONFIG += qt plugin -QT += declarative - -SOURCES += plugin.cpp - -qdeclarativesources.files += \ - com/nokia/TimeExample/qmldir \ - com/nokia/TimeExample/center.png \ - com/nokia/TimeExample/clock.png \ - com/nokia/TimeExample/Clock.qml \ - com/nokia/TimeExample/hour.png \ - com/nokia/TimeExample/minute.png - -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample - -sources.files += plugins.pro plugin.cpp plugins.qml README -sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins - -target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample - -symbian:{ - TARGET.EPOCALLOWDLLDATA=1 -} - - -INSTALLS += qdeclarativesources sources target - -symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/declarative/plugins/plugins.qml b/examples/declarative/plugins/plugins.qml deleted file mode 100644 index 449cd9a..0000000 --- a/examples/declarative/plugins/plugins.qml +++ /dev/null @@ -1,11 +0,0 @@ -import com.nokia.TimeExample 1.0 // import types from the plugin - -Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml) - - Time { // this class is defined in C++ (plugin.cpp) - id: time - } - - hours: time.hour - minutes: time.minute -} diff --git a/examples/declarative/plugins/plugins.qmlproject b/examples/declarative/plugins/plugins.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/plugins/plugins.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/positioners/Button.qml b/examples/declarative/positioners/Button.qml new file mode 100644 index 0000000..d03eeb5 --- /dev/null +++ b/examples/declarative/positioners/Button.qml @@ -0,0 +1,38 @@ +import Qt 4.7 + +Rectangle { + id: page + + property string text + property string icon + signal clicked + + border.color: "black"; color: "steelblue"; radius: 5 + width: pix.width + textelement.width + 13 + height: pix.height + 10 + + Image { id: pix; x: 5; y:5; source: parent.icon } + + Text { + id: textelement + text: page.text; color: "white" + x: pix.width + pix.x + 3 + anchors.verticalCenter: pix.verticalCenter + } + + MouseArea { + id: mr + anchors.fill: parent + onClicked: { parent.focus = true; page.clicked() } + } + + states: State { + name: "pressed"; when: mr.pressed + PropertyChanges { target: textelement; x: 5 } + PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 } + } + + transitions: Transition { + NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 } + } +} diff --git a/examples/declarative/positioners/add.png b/examples/declarative/positioners/add.png new file mode 100644 index 0000000..f29d84b Binary files /dev/null and b/examples/declarative/positioners/add.png differ diff --git a/examples/declarative/positioners/del.png b/examples/declarative/positioners/del.png new file mode 100644 index 0000000..1d753a3 Binary files /dev/null and b/examples/declarative/positioners/del.png differ diff --git a/examples/declarative/positioners/positioners.qml b/examples/declarative/positioners/positioners.qml new file mode 100644 index 0000000..2cb0b8b --- /dev/null +++ b/examples/declarative/positioners/positioners.qml @@ -0,0 +1,213 @@ +import Qt 4.7 + +Rectangle { + id: page + width: 420; height: 420 + + Column { + id: layout1 + y: 0 + move: Transition { + NumberAnimation { properties: "y"; easing.type: Easing.OutBounce } + } + add: Transition { + NumberAnimation { properties: "y"; easing.type: Easing.OutQuad } + } + + Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueV1 + width: 100; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueV2 + width: 100; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } + } + + Row { + id: layout2 + y: 300 + move: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.OutBounce } + } + add: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.OutQuad } + } + + Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } + + Rectangle { + id: blueH1 + width: 50; height: 100 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } + + Rectangle { + id: blueH2 + width: 50; height: 100 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } + } + + Button { + x: 135; y: 90 + text: "Remove" + icon: "del.png" + + onClicked: { + blueH2.opacity = 0 + blueH1.opacity = 0 + blueV1.opacity = 0 + blueV2.opacity = 0 + blueG1.opacity = 0 + blueG2.opacity = 0 + blueG3.opacity = 0 + blueF1.opacity = 0 + blueF2.opacity = 0 + blueF3.opacity = 0 + } + } + + Button { + x: 145; y: 140 + text: "Add" + icon: "add.png" + + onClicked: { + blueH2.opacity = 1 + blueH1.opacity = 1 + blueV1.opacity = 1 + blueV2.opacity = 1 + blueG1.opacity = 1 + blueG2.opacity = 1 + blueG3.opacity = 1 + blueF1.opacity = 1 + blueF2.opacity = 1 + blueF3.opacity = 1 + } + } + + Grid { + x: 260; y: 0 + columns: 3 + + move: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + add: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG1 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG2 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG3 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + } + + Flow { + id: layout4 + x: 260; y: 250; width: 150 + + move: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + add: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF1 + width: 60; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF2 + width: 60; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF3 + width: 40; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 } + } + +} diff --git a/examples/declarative/positioners/positioners.qmlproject b/examples/declarative/positioners/positioners.qmlproject new file mode 100644 index 0000000..e526217 --- /dev/null +++ b/examples/declarative/positioners/positioners.qmlproject @@ -0,0 +1,18 @@ +/* File generated by QtCreator */ + +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/positioners/positioners.qmlproject.user b/examples/declarative/positioners/positioners.qmlproject.user new file mode 100644 index 0000000..593479d --- /dev/null +++ b/examples/declarative/positioners/positioners.qmlproject.user @@ -0,0 +1,41 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + UTF-8 + + + + ProjectExplorer.Project.Target.0 + + QML Runtime + QmlProjectManager.QmlTarget + -1 + 0 + 0 + + QML Runtime + QmlProjectManager.QmlRunConfiguration + 127.0.0.1 + 3768 + positioners.qml + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 4 + + diff --git a/examples/declarative/progressbar/content/ProgressBar.qml b/examples/declarative/progressbar/content/ProgressBar.qml deleted file mode 100644 index bc36df5..0000000 --- a/examples/declarative/progressbar/content/ProgressBar.qml +++ /dev/null @@ -1,43 +0,0 @@ -import Qt 4.7 - -Item { - id: progressbar - - property int minimum: 0 - property int maximum: 100 - property int value: 0 - property alias color: gradient1.color - property alias secondColor: gradient2.color - - width: 250; height: 23 - clip: true - - BorderImage { - source: "background.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - Rectangle { - id: highlight - - property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) - - width: highlight.widthDest - Behavior on width { SmoothedAnimation { velocity: 1200 } } - - anchors { left: parent.left; top: parent.top; bottom: parent.bottom; leftMargin: 3; topMargin: 3; bottomMargin: 3 } - radius: 1 - gradient: Gradient { - GradientStop { id: gradient1; position: 0.0 } - GradientStop { id: gradient2; position: 1.0 } - } - - } - Text { - anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } - color: "white" - font.bold: true - text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' - } -} diff --git a/examples/declarative/progressbar/content/background.png b/examples/declarative/progressbar/content/background.png deleted file mode 100644 index 9044226..0000000 Binary files a/examples/declarative/progressbar/content/background.png and /dev/null differ diff --git a/examples/declarative/progressbar/progressbar.qmlproject b/examples/declarative/progressbar/progressbar.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/progressbar/progressbar.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/progressbar/progressbars.qml b/examples/declarative/progressbar/progressbars.qml deleted file mode 100644 index 55fd682..0000000 --- a/examples/declarative/progressbar/progressbars.qml +++ /dev/null @@ -1,33 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - id: main - - width: 600; height: 405 - color: "#edecec" - - Flickable { - anchors.fill: parent - contentHeight: column.height + 20 - - Column { - id: column - x: 10; y: 10 - spacing: 10 - - Repeater { - model: 25 - - ProgressBar { - property int r: Math.floor(Math.random() * 5000 + 1000) - width: main.width - 20 - - NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } - ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } - ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } - } - } - } - } -} diff --git a/examples/declarative/proxyviewer/main.cpp b/examples/declarative/proxyviewer/main.cpp deleted file mode 100644 index b82d2c9..0000000 --- a/examples/declarative/proxyviewer/main.cpp +++ /dev/null @@ -1,109 +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 demonstration applications 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 - - -/* - This example illustrates using a QNetworkAccessManagerFactory to - create a QNetworkAccessManager with a proxy. - - Usage: - proxyviewer [-host -port ] [file] -*/ - -static QString proxyHost; -static int proxyPort = 0; - -class MyNetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory -{ -public: - virtual QNetworkAccessManager *create(QObject *parent); -}; - -QNetworkAccessManager *MyNetworkAccessManagerFactory::create(QObject *parent) -{ - QNetworkAccessManager *nam = new QNetworkAccessManager(parent); - if (!proxyHost.isEmpty()) { - qDebug() << "Created QNetworkAccessManager using proxy" << (proxyHost + ":" + QString::number(proxyPort)); - QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, proxyHost, proxyPort); - nam->setProxy(proxy); - } - - return nam; -} - -int main(int argc, char ** argv) -{ - QUrl source("qrc:view.qml"); - - QApplication app(argc, argv); - - for (int i = 1; i < argc; ++i) { - QString arg(argv[i]); - if (arg == "-host" && i < argc-1) { - proxyHost = argv[++i]; - } else if (arg == "-port" && i < argc-1) { - arg = argv[++i]; - proxyPort = arg.toInt(); - } else if (arg[0] != '-') { - source = QUrl::fromLocalFile(arg); - } else { - qWarning() << "Usage: proxyviewer [-host -port ] [file]"; - exit(1); - } - } - - QDeclarativeView view; - view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); - - view.setSource(source); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/proxyviewer/proxyviewer.pro b/examples/declarative/proxyviewer/proxyviewer.pro deleted file mode 100644 index b6bfa7f..0000000 --- a/examples/declarative/proxyviewer/proxyviewer.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app -TARGET = proxyviewer -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative network - -# Input -SOURCES += main.cpp -RESOURCES += proxyviewer.qrc diff --git a/examples/declarative/proxyviewer/proxyviewer.qrc b/examples/declarative/proxyviewer/proxyviewer.qrc deleted file mode 100644 index 17e9301..0000000 --- a/examples/declarative/proxyviewer/proxyviewer.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/proxyviewer/view.qml b/examples/declarative/proxyviewer/view.qml deleted file mode 100644 index 7f1bdef..0000000 --- a/examples/declarative/proxyviewer/view.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.7 - -Image { - width: 100 - height: 100 - source: "http://qt.nokia.com/logo.png" -} diff --git a/examples/declarative/proxywidgets/ProxyWidgets/qmldir b/examples/declarative/proxywidgets/ProxyWidgets/qmldir deleted file mode 100644 index e55267c..0000000 --- a/examples/declarative/proxywidgets/ProxyWidgets/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin proxywidgetsplugin diff --git a/examples/declarative/proxywidgets/README b/examples/declarative/proxywidgets/README deleted file mode 100644 index f50fa22..0000000 --- a/examples/declarative/proxywidgets/README +++ /dev/null @@ -1,4 +0,0 @@ -To run: - - make install - qml proxywidgets.qml diff --git a/examples/declarative/proxywidgets/proxywidgets.cpp b/examples/declarative/proxywidgets/proxywidgets.cpp deleted file mode 100644 index 067eb2c..0000000 --- a/examples/declarative/proxywidgets/proxywidgets.cpp +++ /dev/null @@ -1,97 +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 examples 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 - -class MyPushButton : public QGraphicsProxyWidget -{ - Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - -public: - MyPushButton(QGraphicsItem* parent = 0) - : QGraphicsProxyWidget(parent) - { - widget = new QPushButton("MyPushButton"); - widget->setAttribute(Qt::WA_NoSystemBackground); - setWidget(widget); - - QObject::connect(widget, SIGNAL(clicked(bool)), this, SIGNAL(clicked(bool))); - } - - QString text() const - { - return widget->text(); - } - - void setText(const QString& text) - { - if (text != widget->text()) { - widget->setText(text); - emit textChanged(); - } - } - -Q_SIGNALS: - void clicked(bool); - void textChanged(); - -private: - QPushButton *widget; -}; - -class ProxyWidgetsPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - qmlRegisterType(uri, 1, 0, "MyPushButton"); - } -}; - -#include "proxywidgets.moc" - -Q_EXPORT_PLUGIN2(proxywidgetsplugin, ProxyWidgetsPlugin); diff --git a/examples/declarative/proxywidgets/proxywidgets.pro b/examples/declarative/proxywidgets/proxywidgets.pro deleted file mode 100644 index cb07d80..0000000 --- a/examples/declarative/proxywidgets/proxywidgets.pro +++ /dev/null @@ -1,21 +0,0 @@ -TEMPLATE = lib -DESTDIR = ProxyWidgets -TARGET = proxywidgetsplugin -CONFIG += qt plugin -QT += declarative - -SOURCES += proxywidgets.cpp - -sources.files += proxywidgets.pro proxywidgets.cpp proxywidgets.qml - -sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins - -target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins - -INSTALLS += sources target - -symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - -symbian:{ - TARGET.EPOCALLOWDLLDATA = 1 -} \ No newline at end of file diff --git a/examples/declarative/proxywidgets/proxywidgets.qml b/examples/declarative/proxywidgets/proxywidgets.qml deleted file mode 100644 index 88de37f..0000000 --- a/examples/declarative/proxywidgets/proxywidgets.qml +++ /dev/null @@ -1,70 +0,0 @@ -import Qt 4.7 -import "ProxyWidgets" 1.0 - -Rectangle { - id: window - - property int margin: 30 - - width: 640; height: 480 - color: palette.window - - SystemPalette { id: palette } - - MyPushButton { - id: button1 - x: margin; y: margin - text: "Right" - transformOriginPoint: Qt.point(width / 2, height / 2) - - onClicked: window.state = "right" - } - - MyPushButton { - id: button2 - x: margin; y: margin + 30 - text: "Bottom" - transformOriginPoint: Qt.point(width / 2, height / 2) - - onClicked: window.state = "bottom" - } - - MyPushButton { - id: button3 - x: margin; y: margin + 60 - text: "Quit" - transformOriginPoint: Qt.point(width / 2, height / 2) - - onClicked: Qt.quit() - } - - states: [ - State { - name: "right" - PropertyChanges { target: button1; x: window.width - width - margin; text: "Left"; onClicked: window.state = "" } - PropertyChanges { target: button2; x: window.width - width - margin } - PropertyChanges { target: button3; x: window.width - width - margin } - PropertyChanges { target: window; color: Qt.darker(palette.window) } - }, - State { - name: "bottom" - PropertyChanges { target: button1; y: window.height - height - margin; rotation: 180 } - PropertyChanges { - target: button2 - x: button1.x + button1.width + 10; y: window.height - height - margin - rotation: 180 - text: "Top" - onClicked: window.state = "" - } - PropertyChanges { target: button3; x: button2.x + button2.width + 10; y: window.height - height - margin; rotation: 180 } - PropertyChanges { target: window; color: Qt.lighter(palette.window) } - } - ] - - transitions: Transition { - ParallelAnimation { - NumberAnimation { properties: "x,y,rotation"; duration: 600; easing.type: Easing.OutQuad } - ColorAnimation { target: window; duration: 600 } - } - } -} diff --git a/examples/declarative/proxywidgets/proxywidgets.qmlproject b/examples/declarative/proxywidgets/proxywidgets.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/proxywidgets/proxywidgets.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml deleted file mode 100644 index c628a20..0000000 --- a/examples/declarative/scrollbar/ScrollBar.qml +++ /dev/null @@ -1,33 +0,0 @@ -import Qt 4.7 - -Item { - id: scrollBar - - // The properties that define the scrollbar's state. - // position and pageSize are in the range 0.0 - 1.0. They are relative to the - // height of the page, i.e. a pageSize of 0.5 means that you can see 50% - // of the height of the view. - // orientation can be either Qt.Vertical or Qt.Horizontal - property real position - property real pageSize - property variant orientation : Qt.Vertical - - // A light, semi-transparent background - Rectangle { - id: background - anchors.fill: parent - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "white" - opacity: 0.3 - } - // Size the bar to the required size, depending upon the orientation. - Rectangle { - x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) - y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 - width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) - height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "black" - opacity: 0.7 - } -} diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml deleted file mode 100644 index 6b12d85..0000000 --- a/examples/declarative/scrollbar/display.qml +++ /dev/null @@ -1,54 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 640 - height: 480 - - // Create a flickable to view a large image. - Flickable { - id: view - anchors.fill: parent - contentWidth: picture.width - contentHeight: picture.height - - Image { - id: picture - source: "pics/niagara_falls.jpg" - asynchronous: true - } - - // Only show the scrollbars when the view is moving. - states: State { - name: "ShowBars" - when: view.movingVertically || view.movingHorizontally - PropertyChanges { target: verticalScrollBar; opacity: 1 } - PropertyChanges { target: horizontalScrollBar; opacity: 1 } - } - - transitions: Transition { - from: "*"; to: "*" - NumberAnimation { properties: "opacity"; duration: 400 } - } - } - - // Attach scrollbars to the right and bottom edges of the view. - ScrollBar { - id: verticalScrollBar - width: 12; height: view.height-12 - anchors.right: view.right - opacity: 0 - orientation: Qt.Vertical - position: view.visibleArea.yPosition - pageSize: view.visibleArea.heightRatio - } - - ScrollBar { - id: horizontalScrollBar - width: view.width-12; height: 12 - anchors.bottom: view.bottom - opacity: 0 - orientation: Qt.Horizontal - position: view.visibleArea.xPosition - pageSize: view.visibleArea.widthRatio - } -} diff --git a/examples/declarative/scrollbar/pics/niagara_falls.jpg b/examples/declarative/scrollbar/pics/niagara_falls.jpg deleted file mode 100644 index 618d808..0000000 Binary files a/examples/declarative/scrollbar/pics/niagara_falls.jpg and /dev/null differ diff --git a/examples/declarative/scrollbar/scrollbar.qmlproject b/examples/declarative/scrollbar/scrollbar.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/scrollbar/scrollbar.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/searchbox/SearchBox.qml b/examples/declarative/searchbox/SearchBox.qml deleted file mode 100644 index aae7ee9..0000000 --- a/examples/declarative/searchbox/SearchBox.qml +++ /dev/null @@ -1,65 +0,0 @@ -import Qt 4.7 - -FocusScope { - id: focusScope - width: 250; height: 28 - - BorderImage { - source: "images/lineedit-bg.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - BorderImage { - source: "images/lineedit-bg-focus.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - visible: parent.wantsFocus ? true : false - } - - Text { - id: typeSomething - anchors.fill: parent; anchors.leftMargin: 8 - verticalAlignment: Text.AlignVCenter - text: "Type something..." - color: "gray" - font.italic: true - } - - MouseArea { anchors.fill: parent; onClicked: focusScope.focus = true } - - TextInput { - id: textInput - anchors { left: parent.left; leftMargin: 8; verticalCenter: parent.verticalCenter } - focus: true - } - - Image { - id: clear - anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter } - source: "images/edit-clear-locationbar-rtl.png" - opacity: 0 - - MouseArea { - anchors.fill: parent - onClicked: { textInput.text = ''; focusScope.focus = true } - } - } - - states: State { - name: "hasText"; when: textInput.text != '' - PropertyChanges { target: typeSomething; opacity: 0 } - PropertyChanges { target: clear; opacity: 1 } - } - - transitions: [ - Transition { - from: ""; to: "hasText" - NumberAnimation { exclude: typeSomething; properties: "opacity" } - }, - Transition { - from: "hasText"; to: "" - NumberAnimation { properties: "opacity" } - } - ] -} diff --git a/examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png b/examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png deleted file mode 100644 index 91eb270..0000000 Binary files a/examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png and /dev/null differ diff --git a/examples/declarative/searchbox/images/lineedit-bg-focus.png b/examples/declarative/searchbox/images/lineedit-bg-focus.png deleted file mode 100644 index bbfac38..0000000 Binary files a/examples/declarative/searchbox/images/lineedit-bg-focus.png and /dev/null differ diff --git a/examples/declarative/searchbox/images/lineedit-bg.png b/examples/declarative/searchbox/images/lineedit-bg.png deleted file mode 100644 index 9044226..0000000 Binary files a/examples/declarative/searchbox/images/lineedit-bg.png and /dev/null differ diff --git a/examples/declarative/searchbox/main.qml b/examples/declarative/searchbox/main.qml deleted file mode 100644 index 9f73473..0000000 --- a/examples/declarative/searchbox/main.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 500; height: 250 - color: "#edecec" - - Column { - anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } - spacing: 10 - - SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } - SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } - SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } - } -} diff --git a/examples/declarative/searchbox/searchbox.qmlproject b/examples/declarative/searchbox/searchbox.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/searchbox/searchbox.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml deleted file mode 100644 index 526a171..0000000 --- a/examples/declarative/slideswitch/content/Switch.qml +++ /dev/null @@ -1,76 +0,0 @@ -//![0] -import Qt 4.7 - -Item { - id: toggleswitch - width: background.width; height: background.height - -//![1] - property bool on: false -//![1] - -//![2] - function toggle() { - if (toggleswitch.state == "on") - toggleswitch.state = "off"; - else toggleswitch.state = "on"; - } -//![2] - -//![3] - function dorelease() { - if (knob.x == 1) { - if (toggleswitch.state == "off") return; - } - if (knob.x == 78) { - if (toggleswitch.state == "on") return; - } - toggle(); - } -//![3] - -//![4] - Image { - id: background - source: "background.svg" - MouseArea { anchors.fill: parent; onClicked: toggle() } - } -//![4] - -//![5] - Image { - id: knob - x: 1; y: 2 - source: "knob.svg" - - MouseArea { - anchors.fill: parent - drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78 - onClicked: toggle() - onReleased: dorelease() - } - } -//![5] - -//![6] - states: [ - State { - name: "on" - PropertyChanges { target: knob; x: 78 } - PropertyChanges { target: toggleswitch; on: true } - }, - State { - name: "off" - PropertyChanges { target: knob; x: 1 } - PropertyChanges { target: toggleswitch; on: false } - } - ] -//![6] - -//![7] - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 } - } -//![7] -} -//![0] diff --git a/examples/declarative/slideswitch/content/background.svg b/examples/declarative/slideswitch/content/background.svg deleted file mode 100644 index f920d3e..0000000 --- a/examples/declarative/slideswitch/content/background.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - -]> - - - - - - - - - - - - - - diff --git a/examples/declarative/slideswitch/content/knob.svg b/examples/declarative/slideswitch/content/knob.svg deleted file mode 100644 index fb69337..0000000 --- a/examples/declarative/slideswitch/content/knob.svg +++ /dev/null @@ -1,867 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/slideswitch/slideswitch.qml b/examples/declarative/slideswitch/slideswitch.qml deleted file mode 100644 index 51c3c77..0000000 --- a/examples/declarative/slideswitch/slideswitch.qml +++ /dev/null @@ -1,11 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - color: "white" - width: 400; height: 250 - -//![0] - Switch { anchors.centerIn: parent; on: false } -//![0] -} diff --git a/examples/declarative/slideswitch/slideswitch.qmlproject b/examples/declarative/slideswitch/slideswitch.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/slideswitch/slideswitch.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/spinner/content/Spinner.qml b/examples/declarative/spinner/content/Spinner.qml deleted file mode 100644 index 8145a28..0000000 --- a/examples/declarative/spinner/content/Spinner.qml +++ /dev/null @@ -1,25 +0,0 @@ -import Qt 4.7 - -Image { - property alias model: view.model - property alias delegate: view.delegate - property alias currentIndex: view.currentIndex - property real itemHeight: 30 - source: "spinner-bg.png" - clip: true - PathView { - id: view - anchors.fill: parent - pathItemCount: height/itemHeight - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } - dragMargin: view.width/2 - path: Path { - startX: view.width/2; startY: -itemHeight/2 - PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } - } - } - Keys.onDownPressed: view.incrementCurrentIndex() - Keys.onUpPressed: view.decrementCurrentIndex() -} diff --git a/examples/declarative/spinner/content/spinner-bg.png b/examples/declarative/spinner/content/spinner-bg.png deleted file mode 100644 index b3556f1..0000000 Binary files a/examples/declarative/spinner/content/spinner-bg.png and /dev/null differ diff --git a/examples/declarative/spinner/content/spinner-select.png b/examples/declarative/spinner/content/spinner-select.png deleted file mode 100644 index 95a17a1..0000000 Binary files a/examples/declarative/spinner/content/spinner-select.png and /dev/null differ diff --git a/examples/declarative/spinner/main.qml b/examples/declarative/spinner/main.qml deleted file mode 100644 index 6be567a..0000000 --- a/examples/declarative/spinner/main.qml +++ /dev/null @@ -1,18 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - width: 240; height: 320 - Column { - y: 20; x: 20; spacing: 20 - Spinner { - id: spinner - width: 200; height: 240 - focus: true - model: 20 - itemHeight: 30 - delegate: Text { font.pixelSize: 25; text: index; height: 30 } - } - Text { text: "Current item index: " + spinner.currentIndex } - } -} diff --git a/examples/declarative/spinner/spinner.qmlproject b/examples/declarative/spinner/spinner.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/spinner/spinner.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml deleted file mode 100644 index 8b021b7..0000000 --- a/examples/declarative/sql/hello.qml +++ /dev/null @@ -1,31 +0,0 @@ -import Qt 4.7 - -Text { - text: "?" - - function findGreetings() { - var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); - - db.transaction( - function(tx) { - // Create the database if it doesn't already exist - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - - // Add (another) greeting row - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - - // Show all added greetings - var rs = tx.executeSql('SELECT * FROM Greeting'); - - var r = "" - for(var i = 0; i < rs.rows.length; i++) { - r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" - } - text = r - } - ) - } - - Component.onCompleted: findGreetings() -} - diff --git a/examples/declarative/sql/sql.qmlproject b/examples/declarative/sql/sql.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/sql/sql.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/sqllocalstorage/hello.qml b/examples/declarative/sqllocalstorage/hello.qml new file mode 100644 index 0000000..8b021b7 --- /dev/null +++ b/examples/declarative/sqllocalstorage/hello.qml @@ -0,0 +1,31 @@ +import Qt 4.7 + +Text { + text: "?" + + function findGreetings() { + var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); + + db.transaction( + function(tx) { + // Create the database if it doesn't already exist + tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); + + // Add (another) greeting row + tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); + + // Show all added greetings + var rs = tx.executeSql('SELECT * FROM Greeting'); + + var r = "" + for(var i = 0; i < rs.rows.length; i++) { + r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" + } + text = r + } + ) + } + + Component.onCompleted: findGreetings() +} + diff --git a/examples/declarative/sqllocalstorage/sqllocalstorage.qmlproject b/examples/declarative/sqllocalstorage/sqllocalstorage.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/sqllocalstorage/sqllocalstorage.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml deleted file mode 100644 index 4429e78..0000000 --- a/examples/declarative/states/states.qml +++ /dev/null @@ -1,61 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: page - width: 640; height: 480 - color: "#343434" - - Image { - id: userIcon - x: topLeftRect.x; y: topLeftRect.y - source: "user.png" - } - - Rectangle { - id: topLeftRect - - anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to the default state, returning the image to - // its initial position - MouseArea { anchors.fill: parent; onClicked: page.state = '' } - } - - Rectangle { - id: middleRightRect - - anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'middleRight' - MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } - } - - Rectangle { - id: bottomLeftRect - - anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'bottomLeft' - MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } - } - - states: [ - // In state 'middleRight', move the image to middleRightRect - State { - name: "middleRight" - PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } - }, - - // In state 'bottomLeft', move the image to bottomLeftRect - State { - name: "bottomLeft" - PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } - } - ] -} diff --git a/examples/declarative/states/states.qmlproject b/examples/declarative/states/states.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/states/states.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml deleted file mode 100644 index ccc7060..0000000 --- a/examples/declarative/states/transitions.qml +++ /dev/null @@ -1,90 +0,0 @@ -import Qt 4.7 - -/* - This is exactly the same as states.qml, except that we have appended - a set of transitions to apply animations when the item changes - between each state. -*/ - -Rectangle { - id: page - width: 640; height: 480 - color: "#343434" - - Image { - id: userIcon - x: topLeftRect.x; y: topLeftRect.y - source: "user.png" - } - - Rectangle { - id: topLeftRect - - anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to the default state, returning the image to - // its initial position - MouseArea { anchors.fill: parent; onClicked: page.state = '' } - } - - Rectangle { - id: middleRightRect - - anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'middleRight' - MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } - } - - Rectangle { - id: bottomLeftRect - - anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'bottomLeft' - MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } - } - - states: [ - // In state 'middleRight', move the image to middleRightRect - State { - name: "middleRight" - PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } - }, - - // In state 'bottomLeft', move the image to bottomLeftRect - State { - name: "bottomLeft" - PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } - } - ] - - // Transitions define how the properties change when the item moves between each state - transitions: [ - - // When transitioning to 'middleRight' move x,y over a duration of 1 second, - // with OutBounce easing function. - Transition { - from: "*"; to: "middleRight" - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 } - }, - - // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds, - // with InOutQuad easing function. - Transition { - from: "*"; to: "bottomLeft" - NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 } - }, - - // For any other state changes move x,y linearly over duration of 200ms. - Transition { - NumberAnimation { properties: "x,y"; duration: 200 } - } - ] -} diff --git a/examples/declarative/states/user.png b/examples/declarative/states/user.png deleted file mode 100644 index dd7d7a2..0000000 Binary files a/examples/declarative/states/user.png and /dev/null differ diff --git a/examples/declarative/stringlistmodel/main.cpp b/examples/declarative/stringlistmodel/main.cpp deleted file mode 100644 index abbffa7..0000000 --- a/examples/declarative/stringlistmodel/main.cpp +++ /dev/null @@ -1,76 +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 demonstration applications 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 - - -/* - This example illustrates exposing a QStringList as a - model in QML -*/ - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - QDeclarativeView view; - - QStringList dataList; - dataList.append("Item 1"); - dataList.append("Item 2"); - dataList.append("Item 3"); - dataList.append("Item 4"); - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/stringlistmodel/stringlistmodel.pro b/examples/declarative/stringlistmodel/stringlistmodel.pro deleted file mode 100644 index 23dc481..0000000 --- a/examples/declarative/stringlistmodel/stringlistmodel.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app -TARGET = stringlistmodel -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp -RESOURCES += stringlistmodel.qrc diff --git a/examples/declarative/stringlistmodel/stringlistmodel.qrc b/examples/declarative/stringlistmodel/stringlistmodel.qrc deleted file mode 100644 index 17e9301..0000000 --- a/examples/declarative/stringlistmodel/stringlistmodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/stringlistmodel/view.qml b/examples/declarative/stringlistmodel/view.qml deleted file mode 100644 index 41c03d9..0000000 --- a/examples/declarative/stringlistmodel/view.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 - -ListView { - width: 100 - height: 100 - anchors.fill: parent - model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - Text { text: modelData } - } - } -} diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml deleted file mode 100644 index 26d25b4..0000000 --- a/examples/declarative/tabwidget/TabWidget.qml +++ /dev/null @@ -1,57 +0,0 @@ -import Qt 4.7 - -Item { - id: tabWidget - - property int current: 0 - default property alias content: stack.children - - onCurrentChanged: setOpacities() - Component.onCompleted: setOpacities() - - function setOpacities() - { - for (var i = 0; i < stack.children.length; ++i) { - stack.children[i].opacity = i == current ? 1 : 0 - } - } - - Row { - id: header - Repeater { - delegate: Rectangle { - width: tabWidget.width / stack.children.length; height: 36 - - Rectangle { - width: parent.width; height: 1 - anchors { bottom: parent.bottom; bottomMargin: 1 } - color: "#acb2c2" - } - BorderImage { - anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } - border { left: 7; right: 7 } - source: "tab.png" - visible: tabWidget.current == index - } - Text { - horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter - anchors.fill: parent - text: stack.children[index].title - elide: Text.ElideRight - font.bold: tabWidget.current == index - } - MouseArea { - anchors.fill: parent - onClicked: tabWidget.current = index - } - } - model: stack.children.length - } - } - - Item { - id: stack - width: tabWidget.width - anchors.top: header.bottom; anchors.bottom: tabWidget.bottom - } -} diff --git a/examples/declarative/tabwidget/tab.png b/examples/declarative/tabwidget/tab.png deleted file mode 100644 index ad80216..0000000 Binary files a/examples/declarative/tabwidget/tab.png and /dev/null differ diff --git a/examples/declarative/tabwidget/tabs.qml b/examples/declarative/tabwidget/tabs.qml deleted file mode 100644 index fba203c..0000000 --- a/examples/declarative/tabwidget/tabs.qml +++ /dev/null @@ -1,59 +0,0 @@ -import Qt 4.7 - -TabWidget { - id: tabs - width: 640; height: 480 - - Rectangle { - property string title: "Red" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } - color: "#ff7f7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Roses are red" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Green" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } - color: "#7fff7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Flower stems are green" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Blue" - anchors.fill: parent; color: "#e3e3e3" - - Rectangle { - anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } - color: "#7f7fff" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Violets are blue" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } -} diff --git a/examples/declarative/tabwidget/tabwidget.qmlproject b/examples/declarative/tabwidget/tabwidget.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/tabwidget/tabwidget.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/text/fonts/availableFonts.qml b/examples/declarative/text/fonts/availableFonts.qml new file mode 100644 index 0000000..defa4ce --- /dev/null +++ b/examples/declarative/text/fonts/availableFonts.qml @@ -0,0 +1,17 @@ +import Qt 4.7 + +Rectangle { + width: 480; height: 640; color: "steelblue" + + ListView { + anchors.fill: parent; model: Qt.fontFamilies() + + delegate: Item { + height: 40; width: ListView.view.width + Text { + anchors.centerIn: parent + text: modelData; font.family: modelData; font.pixelSize: 24; color: "white" + } + } + } +} diff --git a/examples/declarative/text/fonts/banner.qml b/examples/declarative/text/fonts/banner.qml new file mode 100644 index 0000000..353354a --- /dev/null +++ b/examples/declarative/text/fonts/banner.qml @@ -0,0 +1,21 @@ +import Qt 4.7 + +Rectangle { + id: screen + + property int pixelSize: screen.height * 1.25 + property color textColor: "lightsteelblue" + property string text: "Hello world! " + + width: 640; height: 320 + color: "steelblue" + + Row { + y: -screen.height / 4.5 + + NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite } + Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + } +} diff --git a/examples/declarative/text/fonts/fonts.qml b/examples/declarative/text/fonts/fonts.qml new file mode 100644 index 0000000..f3eac48 --- /dev/null +++ b/examples/declarative/text/fonts/fonts.qml @@ -0,0 +1,64 @@ +import Qt 4.7 + +Rectangle { + property string myText: "The quick brown fox jumps over the lazy dog." + + width: 800; height: 480 + color: "steelblue" + + FontLoader { id: fixedFont; name: "Courier" } + FontLoader { id: localFont; source: "fonts/tarzeau_ocr_a.ttf" } + FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } + + Column { + anchors { fill: parent; leftMargin: 10; rightMargin: 10 } + spacing: 15 + + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideRight + font.family: "Times"; font.pointSize: 42 + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideLeft + font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideMiddle + font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideRight + font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideLeft + font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize } + } + Text { + text: { + if (webFont.status == FontLoader.Ready) myText + else if (webFont.status == FontLoader.Loading) "Loading..." + else if (webFont.status == FontLoader.Error) "Error loading font" + } + color: "lightsteelblue" + width: parent.width + elide: Text.ElideMiddle + font.family: webFont.name; font.pointSize: 42 + } + } +} diff --git a/examples/declarative/text/fonts/fonts.qmlproject b/examples/declarative/text/fonts/fonts.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/text/fonts/fonts.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/text/fonts/fonts/tarzeau_ocr_a.ttf b/examples/declarative/text/fonts/fonts/tarzeau_ocr_a.ttf new file mode 100644 index 0000000..cf93f96 Binary files /dev/null and b/examples/declarative/text/fonts/fonts/tarzeau_ocr_a.ttf differ diff --git a/examples/declarative/text/fonts/hello.qml b/examples/declarative/text/fonts/hello.qml new file mode 100644 index 0000000..0d6f4cd --- /dev/null +++ b/examples/declarative/text/fonts/hello.qml @@ -0,0 +1,38 @@ +import Qt 4.7 + +Rectangle { + id: screen + + width: 800; height: 480 + color: "black" + + Item { + id: container + x: screen.width / 2; y: screen.height / 2 + + Text { + id: text + anchors.centerIn: parent + color: "white" + text: "Hello world!" + font.pixelSize: 60 + + SequentialAnimation on font.letterSpacing { + loops: Animation.Infinite; + NumberAnimation { from: 100; to: 300; easing.type: Easing.InQuad; duration: 3000 } + ScriptAction { + script: { + container.y = (screen.height / 4) + (Math.random() * screen.height / 2) + container.x = (screen.width / 4) + (Math.random() * screen.width / 2) + } + } + } + + SequentialAnimation on opacity { + loops: Animation.Infinite; + NumberAnimation { from: 1; to: 0; duration: 2600 } + PauseAnimation { duration: 400 } + } + } + } +} diff --git a/examples/declarative/text/text.qmlproject b/examples/declarative/text/text.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/text/text.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/threading/threadedlistmodel/dataloader.js b/examples/declarative/threading/threadedlistmodel/dataloader.js new file mode 100644 index 0000000..d720f09 --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/dataloader.js @@ -0,0 +1,9 @@ +// ![0] +WorkerScript.onMessage = function(msg) { + if (msg.action == 'appendCurrentTime') { + var data = {'time': new Date().toTimeString()}; + msg.model.append(data); + msg.model.sync(); // updates the changes to the list + } +} +// ![0] diff --git a/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/threading/threadedlistmodel/timedisplay.qml b/examples/declarative/threading/threadedlistmodel/timedisplay.qml new file mode 100644 index 0000000..bad7010 --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/timedisplay.qml @@ -0,0 +1,32 @@ +// ![0] +import Qt 4.7 + +ListView { + width: 200 + height: 300 + + model: listModel + delegate: Component { + Text { text: time } + } + + ListModel { id: listModel } + + WorkerScript { + id: worker + source: "dataloader.js" + } + + Timer { + id: timer + interval: 2000; repeat: true + running: true + triggeredOnStart: true + + onTriggered: { + var msg = {'action': 'appendCurrentTime', 'model': listModel}; + worker.sendMessage(msg); + } + } +} +// ![0] diff --git a/examples/declarative/threading/threading.qmlproject b/examples/declarative/threading/threading.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/threading/threading.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/threading/workerscript/workerscript.js b/examples/declarative/threading/workerscript/workerscript.js new file mode 100644 index 0000000..f76471f --- /dev/null +++ b/examples/declarative/threading/workerscript/workerscript.js @@ -0,0 +1,15 @@ +var lastx = 0; +var lasty = 0; + +WorkerScript.onMessage = function(message) { + var ydiff = message.y - lasty; + var xdiff = message.x - lastx; + + var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); + + lastx = message.x; + lasty = message.y; + + WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); +} + diff --git a/examples/declarative/threading/workerscript/workerscript.qml b/examples/declarative/threading/workerscript/workerscript.qml new file mode 100644 index 0000000..2294a81 --- /dev/null +++ b/examples/declarative/threading/workerscript/workerscript.qml @@ -0,0 +1,43 @@ +import Qt 4.7 + +Rectangle { + width: 480; height: 320 + + WorkerScript { + id: myWorker + source: "workerscript.js" + + onMessage: { + console.log("Moved " + messageObject.xmove + " along the X axis."); + console.log("Moved " + messageObject.ymove + " along the Y axis."); + console.log("Moved " + messageObject.move + " pixels."); + } + } + + Rectangle { + width: 200; height: 200 + anchors.left: parent.left; anchors.leftMargin: 20 + color: "red" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); + } + } + + Rectangle { + width: 200; height: 200 + anchors.right: parent.right; anchors.rightMargin: 20 + color: "blue" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); + } + } + + Text { + text: "Click a Rectangle!" + anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } + } +} diff --git a/examples/declarative/threading/workerscript/workerscript.qmlproject b/examples/declarative/threading/workerscript/workerscript.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/threading/workerscript/workerscript.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/tic-tac-toe/content/Button.qml b/examples/declarative/tic-tac-toe/content/Button.qml deleted file mode 100644 index ecf18cd..0000000 --- a/examples/declarative/tic-tac-toe/content/Button.qml +++ /dev/null @@ -1,37 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: container - - property string text: "Button" - property bool down: false - property string mainCol: "lightgray" - property string darkCol: "darkgray" - property string lightCol: "white" - - width: buttonLabel.width + 20; height: buttonLabel.height + 6 - border { width: 1; color: Qt.darker(mainCol) } - radius: 8; - color: mainCol - smooth: true - - gradient: Gradient { - GradientStop { - id: topGrad; position: 0.0 - color: if (container.down) { darkCol } else { lightCol } - } - GradientStop { position: 1.0; color: mainCol } - } - - signal clicked - - MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() } - - Text { - id: buttonLabel - - anchors.centerIn: container - text: container.text; - font.pixelSize: 14 - } -} diff --git a/examples/declarative/tic-tac-toe/content/TicTac.qml b/examples/declarative/tic-tac-toe/content/TicTac.qml deleted file mode 100644 index d247943..0000000 --- a/examples/declarative/tic-tac-toe/content/TicTac.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.7 - -Item { - signal clicked - - states: [ - State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } }, - State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } } - ] - - Image { - id: image - anchors.centerIn: parent - } - - MouseArea { - anchors.fill: parent - onClicked: parent.clicked() - } -} diff --git a/examples/declarative/tic-tac-toe/content/pics/board.png b/examples/declarative/tic-tac-toe/content/pics/board.png deleted file mode 100644 index 7e5b7ba..0000000 Binary files a/examples/declarative/tic-tac-toe/content/pics/board.png and /dev/null differ diff --git a/examples/declarative/tic-tac-toe/content/pics/o.png b/examples/declarative/tic-tac-toe/content/pics/o.png deleted file mode 100644 index abc7ee0..0000000 Binary files a/examples/declarative/tic-tac-toe/content/pics/o.png and /dev/null differ diff --git a/examples/declarative/tic-tac-toe/content/pics/x.png b/examples/declarative/tic-tac-toe/content/pics/x.png deleted file mode 100644 index ddc65c8..0000000 Binary files a/examples/declarative/tic-tac-toe/content/pics/x.png and /dev/null differ diff --git a/examples/declarative/tic-tac-toe/content/tic-tac-toe.js b/examples/declarative/tic-tac-toe/content/tic-tac-toe.js deleted file mode 100644 index f8d6d9f..0000000 --- a/examples/declarative/tic-tac-toe/content/tic-tac-toe.js +++ /dev/null @@ -1,145 +0,0 @@ -function winner(board) -{ - for (var i=0; i<3; ++i) { - if (board.children[i].state!="" - && board.children[i].state==board.children[i+3].state - && board.children[i].state==board.children[i+6].state) - return true - - if (board.children[i*3].state!="" - && board.children[i*3].state==board.children[i*3+1].state - && board.children[i*3].state==board.children[i*3+2].state) - return true - } - - if (board.children[0].state!="" - && board.children[0].state==board.children[4].state!="" - && board.children[0].state==board.children[8].state!="") - return true - - if (board.children[2].state!="" - && board.children[2].state==board.children[4].state!="" - && board.children[2].state==board.children[6].state!="") - return true - - return false -} - -function restart() -{ - // No moves left - start again - for (var i=0; i<9; ++i) - board.children[i].state = "" -} - -function makeMove(pos,player) -{ - board.children[pos].state = player - if (winner(board)) { - win(player + " wins") - return true - } else { - return false - } -} - -function computerTurn() -{ - var r = Math.random(); - if(r < game.difficulty){ - smartAI(); - }else{ - randAI(); - } -} - -function smartAI() -{ - function boardCopy(a){ - var ret = new Object; - ret.children = new Array(9); - for(var i = 0; i<9; i++){ - ret.children[i] = new Object; - ret.children[i].state = a.children[i].state; - } - return ret; - } - for(var i=0; i<9; i++){ - var simpleBoard = boardCopy(board); - if (board.children[i].state == "") { - simpleBoard.children[i].state = "O"; - if(winner(simpleBoard)){ - makeMove(i,"O") - return - } - } - } - for(var i=0; i<9; i++){ - var simpleBoard = boardCopy(board); - if (board.children[i].state == "") { - simpleBoard.children[i].state = "X"; - if(winner(simpleBoard)){ - makeMove(i,"O") - return - } - } - } - function thwart(a,b,c){//If they are at a, try b or c - if (board.children[a].state == "X") { - if (board.children[b].state == "") { - makeMove(b,"O") - return true - }else if (board.children[c].state == "") { - makeMove(c,"O") - return true - } - } - return false; - } - if(thwart(4,0,2)) return; - if(thwart(0,4,3)) return; - if(thwart(2,4,1)) return; - if(thwart(6,4,7)) return; - if(thwart(8,4,5)) return; - if(thwart(1,4,2)) return; - if(thwart(3,4,0)) return; - if(thwart(5,4,8)) return; - if(thwart(7,4,6)) return; - for(var i =0; i<9; i++){//Backup - if (board.children[i].state == "") { - makeMove(i,"O") - return - } - } - restart(); -} - -function randAI() -{ - var open = 0; - for (var i=0; i<9; ++i) - if (board.children[i].state == "") { - open += 1; - } - if(open == 0){ - restart(); - return; - } - var openA = new Array(open);//JS doesn't have lists I can append to (i think) - var acc = 0; - for (var i=0; i<9; ++i) - if (board.children[i].state == "") { - openA[acc] = i; - acc += 1; - } - var choice = openA[Math.floor(Math.random() * open)]; - makeMove(choice, "O"); -} - -function win(s) -{ - msg.text = s - msg.opacity = 1 - endtimer.running = true -} - diff --git a/examples/declarative/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/tic-tac-toe/tic-tac-toe.qml deleted file mode 100644 index dd13052..0000000 --- a/examples/declarative/tic-tac-toe/tic-tac-toe.qml +++ /dev/null @@ -1,77 +0,0 @@ -import Qt 4.7 -import "content" -import "content/tic-tac-toe.js" as Logic - -Item { - id: game - - property bool show: false - property real difficulty: 1.0 //chance it will actually think - - width: 440 - height: 480 - anchors.fill: parent - - Image { - id: boardimage - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.horizontalCenter } - source: "content/pics/board.png" - } - - Grid { - id: board - anchors.fill: boardimage - columns: 3 - - Repeater { - model: 9 - TicTac { - width: board.width/3 - height: board.height/3 - onClicked: { - if (!endtimer.running) { - if (!Logic.makeMove(index,"X")) - Logic.computerTurn() - } - } - } - } - - Timer { - id: endtimer - interval: 1600 - onTriggered: { msg.opacity = 0; Logic.restart() } - } - } - - Row { - spacing: 4 - anchors { top: board.bottom; horizontalCenter: board.horizontalCenter } - - Button { - text: "Hard" - onClicked: game.difficulty = 1.0; - down: game.difficulty == 1.0 - } - Button { - text: "Moderate" - onClicked: game.difficulty = 0.8; - down: game.difficulty == 0.8 - } - Button { - text: "Easy" - onClicked: game.difficulty = 0.2; - down: game.difficulty == 0.2 - } - } - - Text { - id: msg - - anchors.centerIn: parent - opacity: 0 - color: "blue" - style: Text.Outline; styleColor: "white" - font.pixelSize: 50; font.bold: true - } -} diff --git a/examples/declarative/tic-tac-toe/tic-tac-toe.qmlproject b/examples/declarative/tic-tac-toe/tic-tac-toe.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/tic-tac-toe/tic-tac-toe.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/touchinteraction/gestures/experimental-gestures.qml b/examples/declarative/touchinteraction/gestures/experimental-gestures.qml new file mode 100644 index 0000000..cb190ea --- /dev/null +++ b/examples/declarative/touchinteraction/gestures/experimental-gestures.qml @@ -0,0 +1,36 @@ +import Qt 4.7 +import Qt.labs.gestures 1.0 + +// Only works on platforms with Touch support. + +Rectangle { + id: rect + width: 320 + height: 180 + + Text { + anchors.centerIn: parent + text: "Tap / TapAndHold / Pan / Pinch / Swipe\nOnly works on platforms with Touch support." + horizontalAlignment: Text.Center + } + + GestureArea { + anchors.fill: parent + focus: true + + // Only some of the many gesture properties are shown. See Gesture documentation. + + onTap: + console.log("tap pos = (",gesture.position.x,",",gesture.position.y,")") + onTapAndHold: + console.log("tap and hold pos = (",gesture.position.x,",",gesture.position.y,")") + onPan: + console.log("pan delta = (",gesture.delta.x,",",gesture.delta.y,") acceleration = ",gesture.acceleration) + onPinch: + console.log("pinch center = (",gesture.centerPoint.x,",",gesture.centerPoint.y,") rotation =",gesture.rotationAngle," scale =",gesture.scaleFactor) + onSwipe: + console.log("swipe angle=",gesture.swipeAngle) + onGesture: + console.log("gesture hot spot = (",gesture.hotSpot.x,",",gesture.hotSpot.y,")") + } +} diff --git a/examples/declarative/touchinteraction/gestures/gestures.qmlproject b/examples/declarative/touchinteraction/gestures/gestures.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/touchinteraction/gestures/gestures.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/touchinteraction/mousearea/mouse.qml b/examples/declarative/touchinteraction/mousearea/mouse.qml new file mode 100644 index 0000000..06134b7 --- /dev/null +++ b/examples/declarative/touchinteraction/mousearea/mouse.qml @@ -0,0 +1,47 @@ +import Qt 4.7 + +Rectangle { + width: 200; height: 200 + + Rectangle { + width: 50; height: 50 + color: "red" + + Text { text: "Click"; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + acceptedButtons: Qt.LeftButton | Qt.RightButton + + onPressed: console.log('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') + onReleased: console.log('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') + onClicked: console.log('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') + onDoubleClicked: console.log('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') + onPressAndHold: console.log('press and hold') + onEntered: console.log('entered ' + pressed) + onExited: console.log('exited ' + pressed) + } + } + + Rectangle { + y: 100; width: 50; height: 50 + color: "blue" + + Text { text: "Drag"; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + drag.target: parent + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: 150 + + onPressed: console.log('press') + onReleased: console.log('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') + onClicked: console.log('click' + '(wasHeld: ' + mouse.wasHeld + ')') + onDoubleClicked: console.log('double click') + onPressAndHold: console.log('press and hold') + } + } +} diff --git a/examples/declarative/touchinteraction/mousearea/mousearea.qmlproject b/examples/declarative/touchinteraction/mousearea/mousearea.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/touchinteraction/mousearea/mousearea.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/touchinteraction/touchinteraction.qmlproject b/examples/declarative/touchinteraction/touchinteraction.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/touchinteraction/touchinteraction.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/clocks/clocks.qml b/examples/declarative/toys/clocks/clocks.qml new file mode 100644 index 0000000..22cf820 --- /dev/null +++ b/examples/declarative/toys/clocks/clocks.qml @@ -0,0 +1,14 @@ +import Qt 4.7 +import "content" + +Rectangle { + width: 640; height: 240 + color: "#646464" + + Row { + anchors.centerIn: parent + Clock { city: "New York"; shift: -4 } + Clock { city: "Mumbai"; shift: 5.5 } + Clock { city: "Tokyo"; shift: 9 } + } +} diff --git a/examples/declarative/toys/clocks/clocks.qmlproject b/examples/declarative/toys/clocks/clocks.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/clocks/clocks.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/clocks/content/Clock.qml b/examples/declarative/toys/clocks/content/Clock.qml new file mode 100644 index 0000000..3426e6a --- /dev/null +++ b/examples/declarative/toys/clocks/content/Clock.qml @@ -0,0 +1,83 @@ +import Qt 4.7 + +Item { + id: clock + width: 200; height: 230 + + property alias city: cityLabel.text + property variant hours + property variant minutes + property variant seconds + property variant shift : 0 + property bool night: false + + function timeChanged() { + var date = new Date; + hours = shift ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() + night = ( hours < 7 || hours > 19 ) + minutes = shift ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes() + seconds = date.getUTCSeconds(); + } + + Timer { + interval: 100; running: true; repeat: true; triggeredOnStart: true + onTriggered: clock.timeChanged() + } + + Image { id: background; source: "clock.png"; visible: clock.night == false } + Image { source: "clock-night.png"; visible: clock.night == true } + + Image { + x: 92.5; y: 27 + source: "hour.png" + smooth: true + transform: Rotation { + id: hourRotation + origin.x: 7.5; origin.y: 73; angle: 0 + SpringFollow on angle { + spring: 2; damping: 0.2; modulus: 360 + to: (clock.hours * 30) + (clock.minutes * 0.5) + } + } + } + + Image { + x: 93.5; y: 17 + source: "minute.png" + smooth: true + transform: Rotation { + id: minuteRotation + origin.x: 6.5; origin.y: 83; angle: 0 + SpringFollow on angle { + spring: 2; damping: 0.2; modulus: 360 + to: clock.minutes * 6 + } + } + } + + Image { + x: 97.5; y: 20 + source: "second.png" + smooth: true + transform: Rotation { + id: secondRotation + origin.x: 2.5; origin.y: 80; angle: 0 + SpringFollow on angle { + spring: 5; damping: 0.25; modulus: 360 + to: clock.seconds * 6 + } + } + } + + Image { + anchors.centerIn: background; source: "center.png" + } + + Text { + id: cityLabel + y: 200; anchors.horizontalCenter: parent.horizontalCenter + color: "white" + font.bold: true; font.pixelSize: 14 + style: Text.Raised; styleColor: "black" + } +} diff --git a/examples/declarative/toys/clocks/content/background.png b/examples/declarative/toys/clocks/content/background.png new file mode 100644 index 0000000..a885950 Binary files /dev/null and b/examples/declarative/toys/clocks/content/background.png differ diff --git a/examples/declarative/toys/clocks/content/center.png b/examples/declarative/toys/clocks/content/center.png new file mode 100755 index 0000000..7fbd802 Binary files /dev/null and b/examples/declarative/toys/clocks/content/center.png differ diff --git a/examples/declarative/toys/clocks/content/clock-night.png b/examples/declarative/toys/clocks/content/clock-night.png new file mode 100755 index 0000000..cc7151a Binary files /dev/null and b/examples/declarative/toys/clocks/content/clock-night.png differ diff --git a/examples/declarative/toys/clocks/content/clock.png b/examples/declarative/toys/clocks/content/clock.png new file mode 100755 index 0000000..462edac Binary files /dev/null and b/examples/declarative/toys/clocks/content/clock.png differ diff --git a/examples/declarative/toys/clocks/content/hour.png b/examples/declarative/toys/clocks/content/hour.png new file mode 100755 index 0000000..f8061a1 Binary files /dev/null and b/examples/declarative/toys/clocks/content/hour.png differ diff --git a/examples/declarative/toys/clocks/content/minute.png b/examples/declarative/toys/clocks/content/minute.png new file mode 100755 index 0000000..1297ec7 Binary files /dev/null and b/examples/declarative/toys/clocks/content/minute.png differ diff --git a/examples/declarative/toys/clocks/content/second.png b/examples/declarative/toys/clocks/content/second.png new file mode 100755 index 0000000..4aa9fb5 Binary files /dev/null and b/examples/declarative/toys/clocks/content/second.png differ diff --git a/examples/declarative/toys/dial/content/Dial.qml b/examples/declarative/toys/dial/content/Dial.qml new file mode 100644 index 0000000..f9ab3e3 --- /dev/null +++ b/examples/declarative/toys/dial/content/Dial.qml @@ -0,0 +1,37 @@ +import Qt 4.7 + +Item { + id: root + property real value : 0 + + width: 210; height: 210 + + Image { source: "background.png" } + + Image { + x: 93 + y: 35 + source: "needle_shadow.png" + transform: Rotation { + origin.x: 11; origin.y: 67 + angle: needleRotation.angle + } + } + Image { + id: needle + x: 95; y: 33 + smooth: true + source: "needle.png" + transform: Rotation { + id: needleRotation + origin.x: 7; origin.y: 65 + angle: -130 + SpringFollow on angle { + spring: 1.4 + damping: .15 + to: Math.min(Math.max(-130, root.value*2.6 - 130), 133) + } + } + } + Image { x: 21; y: 18; source: "overlay.png" } +} diff --git a/examples/declarative/toys/dial/content/background.png b/examples/declarative/toys/dial/content/background.png new file mode 100644 index 0000000..75d555d Binary files /dev/null and b/examples/declarative/toys/dial/content/background.png differ diff --git a/examples/declarative/toys/dial/content/needle.png b/examples/declarative/toys/dial/content/needle.png new file mode 100644 index 0000000..2d19f75 Binary files /dev/null and b/examples/declarative/toys/dial/content/needle.png differ diff --git a/examples/declarative/toys/dial/content/needle_shadow.png b/examples/declarative/toys/dial/content/needle_shadow.png new file mode 100644 index 0000000..8d8a928 Binary files /dev/null and b/examples/declarative/toys/dial/content/needle_shadow.png differ diff --git a/examples/declarative/toys/dial/content/overlay.png b/examples/declarative/toys/dial/content/overlay.png new file mode 100644 index 0000000..3860a7b Binary files /dev/null and b/examples/declarative/toys/dial/content/overlay.png differ diff --git a/examples/declarative/toys/dial/dial-example.qml b/examples/declarative/toys/dial/dial-example.qml new file mode 100644 index 0000000..2e102b0 --- /dev/null +++ b/examples/declarative/toys/dial/dial-example.qml @@ -0,0 +1,44 @@ +import Qt 4.7 +import "content" + +Rectangle { + color: "#545454" + width: 300; height: 300 + + // Dial with a slider to adjust it + Dial { + id: dial + anchors.centerIn: parent + value: slider.x * 100 / (container.width - 34) + } + + Rectangle { + id: container + anchors { bottom: parent.bottom; left: parent.left; right: parent.right; leftMargin: 20; rightMargin: 20; bottomMargin: 10 } + height: 16 + + radius: 8 + opacity: 0.7 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "gray" } + GradientStop { position: 1.0; color: "white" } + } + + Rectangle { + id: slider + x: 1; y: 1; width: 30; height: 14 + radius: 6 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#424242" } + GradientStop { position: 1.0; color: "black" } + } + + MouseArea { + anchors.fill: parent + drag.target: parent; drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: container.width - 32 + } + } + } +} diff --git a/examples/declarative/toys/dial/dial.qmlproject b/examples/declarative/toys/dial/dial.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/dial/dial.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/dynamic/dynamic.qml b/examples/declarative/toys/dynamic/dynamic.qml new file mode 100644 index 0000000..52c7c1e --- /dev/null +++ b/examples/declarative/toys/dynamic/dynamic.qml @@ -0,0 +1,176 @@ +import Qt 4.7 +import Qt.labs.particles 1.0 +import "qml" + +Item { + id: window + + property int activeSuns: 0 + + //This is a desktop-sized example + width: 1024; height: 512 + + //This is the message box that pops up when there's an error + Rectangle { + id: dialog + + opacity: 0 + anchors.centerIn: parent + width: dialogText.width + 6; height: dialogText.height + 6 + border.color: 'black' + color: 'lightsteelblue' + z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. + + function show(str){ + dialogText.text = str; + dialogAnim.start(); + } + + Text { + id: dialogText + x: 3; y: 3 + font.pixelSize: 14 + } + + SequentialAnimation { + id: dialogAnim + NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } + PauseAnimation { duration: 5000 } + NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } + } + } + + // sky + Rectangle { + id: sky + anchors { left: parent.left; top: parent.top; right: toolbox.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } + GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } + } + } + + // stars (when there's no sun) + Particles { + id: stars + x: 0; y: 0; width: parent.width; height: parent.height / 2 + source: "images/star.png" + angleDeviation: 360 + velocity: 0; velocityDeviation: 0 + count: parent.width / 10 + fadeInDuration: 2800 + opacity: 1 + } + + // ground + Rectangle { + id: ground + z: 2 // just above the sun so that the sun can set behind it + anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.left; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + SystemPalette { id: activePalette } + + // right-hand panel + Rectangle { + id: toolbox + + width: 480 + color: activePalette.window + anchors { right: parent.right; top: parent.top; bottom: parent.bottom } + + Column { + anchors.centerIn: parent + spacing: 8 + + Text { text: "Drag an item into the scene." } + + Rectangle { + width: childrenRect.width + 10; height: childrenRect.height + 10 + border.color: "black" + + Row { + anchors.centerIn: parent + spacing: 8 + + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "Sun.qml" + image: "../images/sun.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "GenericSceneItem.qml" + image: "../images/moon.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + image: "../images/tree_s.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + image: "../images/rabbit_brown.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + image: "../images/rabbit_bw.png" + } + } + } + + Text { text: "Active Suns: " + activeSuns } + + Rectangle { width: parent.width; height: 1; color: "black" } + + Text { text: "Arbitrary QML:" } + + Rectangle { + width: 460; height: 240 + + TextEdit { + id: qmlText + anchors.fill: parent; anchors.margins: 5 + readOnly: false + focusOnPress: true + font.pixelSize: 14 + + text: "import Qt 4.7\nImage {\n id: smile\n x: 500 * Math.random()\n y: 200 * Math.random() \n source: 'images/face-smile.png'\n\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n\n Component.onCompleted: smile.destroy(1500);\n}" + } + } + + Button { + text: "Create" + onClicked: { + try { + Qt.createQmlObject(qmlText.text, window, 'CustomObject'); + } catch(err) { + dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); + } + } + } + } + } + + //Day state, for when a sun is added to the scene + states: State { + name: "Day" + when: window.activeSuns > 0 + + PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } + PropertyChanges { target: gradientStopB; color: "SkyBlue" } + PropertyChanges { target: stars; opacity: 0 } + } + + transitions: Transition { + PropertyAnimation { duration: 3000 } + ColorAnimation { duration: 3000 } + } + +} diff --git a/examples/declarative/toys/dynamic/dynamic.qmlproject b/examples/declarative/toys/dynamic/dynamic.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/dynamic/dynamic.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/dynamic/images/NOTE b/examples/declarative/toys/dynamic/images/NOTE new file mode 100644 index 0000000..fcd87f9 --- /dev/null +++ b/examples/declarative/toys/dynamic/images/NOTE @@ -0,0 +1 @@ +Images (except star.png) are from the KDE project. diff --git a/examples/declarative/toys/dynamic/images/face-smile.png b/examples/declarative/toys/dynamic/images/face-smile.png new file mode 100644 index 0000000..3d66d72 Binary files /dev/null and b/examples/declarative/toys/dynamic/images/face-smile.png differ diff --git a/examples/declarative/toys/dynamic/images/moon.png b/examples/declarative/toys/dynamic/images/moon.png new file mode 100644 index 0000000..1c0d606 Binary files /dev/null and b/examples/declarative/toys/dynamic/images/moon.png differ diff --git a/examples/declarative/toys/dynamic/images/rabbit_brown.png b/examples/declarative/toys/dynamic/images/rabbit_brown.png new file mode 100644 index 0000000..ebfdeed Binary files /dev/null and b/examples/declarative/toys/dynamic/images/rabbit_brown.png differ diff --git a/examples/declarative/toys/dynamic/images/rabbit_bw.png b/examples/declarative/toys/dynamic/images/rabbit_bw.png new file mode 100644 index 0000000..7bff9b9 Binary files /dev/null and b/examples/declarative/toys/dynamic/images/rabbit_bw.png differ diff --git a/examples/declarative/toys/dynamic/images/star.png b/examples/declarative/toys/dynamic/images/star.png new file mode 100644 index 0000000..27ef924 Binary files /dev/null and b/examples/declarative/toys/dynamic/images/star.png differ diff --git a/examples/declarative/toys/dynamic/images/sun.png b/examples/declarative/toys/dynamic/images/sun.png new file mode 100644 index 0000000..7713ca5 Binary files /dev/null and b/examples/declarative/toys/dynamic/images/sun.png differ diff --git a/examples/declarative/toys/dynamic/images/tree_s.png b/examples/declarative/toys/dynamic/images/tree_s.png new file mode 100644 index 0000000..6eac35a Binary files /dev/null and b/examples/declarative/toys/dynamic/images/tree_s.png differ diff --git a/examples/declarative/toys/dynamic/qml/Button.qml b/examples/declarative/toys/dynamic/qml/Button.qml new file mode 100644 index 0000000..963a850 --- /dev/null +++ b/examples/declarative/toys/dynamic/qml/Button.qml @@ -0,0 +1,40 @@ +import Qt 4.7 + +Rectangle { + id: container + + property variant text + signal clicked + + height: text.height + 10; width: text.width + 20 + border.width: 1 + radius: 4 + smooth: true + + gradient: Gradient { + GradientStop { + position: 0.0 + color: !mouseArea.pressed ? activePalette.light : activePalette.button + } + GradientStop { + position: 1.0 + color: !mouseArea.pressed ? activePalette.button : activePalette.dark + } + } + + SystemPalette { id: activePalette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked() + } + + Text { + id: text + anchors.centerIn:parent + font.pointSize: 10 + text: parent.text + color: activePalette.buttonText + } +} diff --git a/examples/declarative/toys/dynamic/qml/PaletteItem.qml b/examples/declarative/toys/dynamic/qml/PaletteItem.qml new file mode 100644 index 0000000..dcb5cc3 --- /dev/null +++ b/examples/declarative/toys/dynamic/qml/PaletteItem.qml @@ -0,0 +1,19 @@ +import Qt 4.7 +import "itemCreation.js" as Code + +Image { + id: paletteItem + + property string componentFile + property string image + + source: image + + MouseArea { + anchors.fill: parent + + onPressed: Code.startDrag(mouse); + onPositionChanged: Code.continueDrag(mouse); + onReleased: Code.endDrag(mouse); + } +} diff --git a/examples/declarative/toys/dynamic/qml/PerspectiveItem.qml b/examples/declarative/toys/dynamic/qml/PerspectiveItem.qml new file mode 100644 index 0000000..c04d3dc --- /dev/null +++ b/examples/declarative/toys/dynamic/qml/PerspectiveItem.qml @@ -0,0 +1,25 @@ +import Qt 4.7 + +Image { + id: rootItem + + property bool created: false + property string image + + property double scaledBottom: y + (height + height*scale) / 2 + property bool onLand: scaledBottom > window.height / 2 + + source: image + opacity: onLand ? 1 : 0.25 + scale: Math.max((y + height - 250) * 0.01, 0.3) + smooth: true + + onCreatedChanged: { + if (created && !onLand) + rootItem.destroy(); + else + z = scaledBottom; + } + + onYChanged: z = scaledBottom; +} diff --git a/examples/declarative/toys/dynamic/qml/Sun.qml b/examples/declarative/toys/dynamic/qml/Sun.qml new file mode 100644 index 0000000..43dcb9a --- /dev/null +++ b/examples/declarative/toys/dynamic/qml/Sun.qml @@ -0,0 +1,38 @@ +import Qt 4.7 + +Image { + id: sun + + property bool created: false + property string image: "../images/sun.png" + + source: image + + // once item is created, start moving offscreen + NumberAnimation on y { + to: window.height / 2 + running: created + onRunningChanged: { + if (running) + duration = (window.height - sun.y) * 10; + else + state = "OffScreen" + } + } + + states: State { + name: "OffScreen" + StateChangeScript { + script: { sun.created = false; sun.destroy() } + } + } + + onCreatedChanged: { + if (created) { + sun.z = 1; // above the sky but below the ground layer + window.activeSuns++; + } else { + window.activeSuns--; + } + } +} diff --git a/examples/declarative/toys/dynamic/qml/itemCreation.js b/examples/declarative/toys/dynamic/qml/itemCreation.js new file mode 100644 index 0000000..59750f3 --- /dev/null +++ b/examples/declarative/toys/dynamic/qml/itemCreation.js @@ -0,0 +1,65 @@ +var itemComponent = null; +var draggedItem = null; +var startingMouse; +var posnInWindow; + +function startDrag(mouse) +{ + posnInWindow = paletteItem.mapToItem(null, 0, 0); + startingMouse = { x: mouse.x, y: mouse.y } + loadComponent(); +} + +//Creation is split into two functions due to an asynchronous wait while +//possible external files are loaded. + +function loadComponent() { + if (itemComponent != null) { // component has been previously loaded + createItem(); + return; + } + + itemComponent = Qt.createComponent(paletteItem.componentFile); + if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately + component.statusChanged.connect(createItem); + else + createItem(); +} + +function createItem() { + if (itemComponent.status == Component.Ready && draggedItem == null) { + draggedItem = itemComponent.createObject(window); + draggedItem.image = paletteItem.image; + draggedItem.x = posnInWindow.x; + draggedItem.y = posnInWindow.y; + draggedItem.z = 3; // make sure created item is above the ground layer + } else if (itemComponent.status == Component.Error) { + draggedItem = null; + console.log("error creating component"); + console.log(component.errorsString()); + } +} + +function continueDrag(mouse) +{ + if (draggedItem == null) + return; + + draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; + draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; +} + +function endDrag(mouse) +{ + if (draggedItem == null) + return; + + if (draggedItem.x + draggedItem.width > toolbox.x) { //Don't drop it in the toolbox + draggedItem.destroy(); + draggedItem = null; + } else { + draggedItem.created = true; + draggedItem = null; + } +} + diff --git a/examples/declarative/toys/tic-tac-toe/content/Button.qml b/examples/declarative/toys/tic-tac-toe/content/Button.qml new file mode 100644 index 0000000..ecf18cd --- /dev/null +++ b/examples/declarative/toys/tic-tac-toe/content/Button.qml @@ -0,0 +1,37 @@ +import Qt 4.7 + +Rectangle { + id: container + + property string text: "Button" + property bool down: false + property string mainCol: "lightgray" + property string darkCol: "darkgray" + property string lightCol: "white" + + width: buttonLabel.width + 20; height: buttonLabel.height + 6 + border { width: 1; color: Qt.darker(mainCol) } + radius: 8; + color: mainCol + smooth: true + + gradient: Gradient { + GradientStop { + id: topGrad; position: 0.0 + color: if (container.down) { darkCol } else { lightCol } + } + GradientStop { position: 1.0; color: mainCol } + } + + signal clicked + + MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() } + + Text { + id: buttonLabel + + anchors.centerIn: container + text: container.text; + font.pixelSize: 14 + } +} diff --git a/examples/declarative/toys/tic-tac-toe/content/TicTac.qml b/examples/declarative/toys/tic-tac-toe/content/TicTac.qml new file mode 100644 index 0000000..d247943 --- /dev/null +++ b/examples/declarative/toys/tic-tac-toe/content/TicTac.qml @@ -0,0 +1,20 @@ +import Qt 4.7 + +Item { + signal clicked + + states: [ + State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } }, + State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } } + ] + + Image { + id: image + anchors.centerIn: parent + } + + MouseArea { + anchors.fill: parent + onClicked: parent.clicked() + } +} diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/board.png b/examples/declarative/toys/tic-tac-toe/content/pics/board.png new file mode 100644 index 0000000..7e5b7ba Binary files /dev/null and b/examples/declarative/toys/tic-tac-toe/content/pics/board.png differ diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/o.png b/examples/declarative/toys/tic-tac-toe/content/pics/o.png new file mode 100644 index 0000000..abc7ee0 Binary files /dev/null and b/examples/declarative/toys/tic-tac-toe/content/pics/o.png differ diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/x.png b/examples/declarative/toys/tic-tac-toe/content/pics/x.png new file mode 100644 index 0000000..ddc65c8 Binary files /dev/null and b/examples/declarative/toys/tic-tac-toe/content/pics/x.png differ diff --git a/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js b/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js new file mode 100644 index 0000000..f8d6d9f --- /dev/null +++ b/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js @@ -0,0 +1,145 @@ +function winner(board) +{ + for (var i=0; i<3; ++i) { + if (board.children[i].state!="" + && board.children[i].state==board.children[i+3].state + && board.children[i].state==board.children[i+6].state) + return true + + if (board.children[i*3].state!="" + && board.children[i*3].state==board.children[i*3+1].state + && board.children[i*3].state==board.children[i*3+2].state) + return true + } + + if (board.children[0].state!="" + && board.children[0].state==board.children[4].state!="" + && board.children[0].state==board.children[8].state!="") + return true + + if (board.children[2].state!="" + && board.children[2].state==board.children[4].state!="" + && board.children[2].state==board.children[6].state!="") + return true + + return false +} + +function restart() +{ + // No moves left - start again + for (var i=0; i<9; ++i) + board.children[i].state = "" +} + +function makeMove(pos,player) +{ + board.children[pos].state = player + if (winner(board)) { + win(player + " wins") + return true + } else { + return false + } +} + +function computerTurn() +{ + var r = Math.random(); + if(r < game.difficulty){ + smartAI(); + }else{ + randAI(); + } +} + +function smartAI() +{ + function boardCopy(a){ + var ret = new Object; + ret.children = new Array(9); + for(var i = 0; i<9; i++){ + ret.children[i] = new Object; + ret.children[i].state = a.children[i].state; + } + return ret; + } + for(var i=0; i<9; i++){ + var simpleBoard = boardCopy(board); + if (board.children[i].state == "") { + simpleBoard.children[i].state = "O"; + if(winner(simpleBoard)){ + makeMove(i,"O") + return + } + } + } + for(var i=0; i<9; i++){ + var simpleBoard = boardCopy(board); + if (board.children[i].state == "") { + simpleBoard.children[i].state = "X"; + if(winner(simpleBoard)){ + makeMove(i,"O") + return + } + } + } + function thwart(a,b,c){//If they are at a, try b or c + if (board.children[a].state == "X") { + if (board.children[b].state == "") { + makeMove(b,"O") + return true + }else if (board.children[c].state == "") { + makeMove(c,"O") + return true + } + } + return false; + } + if(thwart(4,0,2)) return; + if(thwart(0,4,3)) return; + if(thwart(2,4,1)) return; + if(thwart(6,4,7)) return; + if(thwart(8,4,5)) return; + if(thwart(1,4,2)) return; + if(thwart(3,4,0)) return; + if(thwart(5,4,8)) return; + if(thwart(7,4,6)) return; + for(var i =0; i<9; i++){//Backup + if (board.children[i].state == "") { + makeMove(i,"O") + return + } + } + restart(); +} + +function randAI() +{ + var open = 0; + for (var i=0; i<9; ++i) + if (board.children[i].state == "") { + open += 1; + } + if(open == 0){ + restart(); + return; + } + var openA = new Array(open);//JS doesn't have lists I can append to (i think) + var acc = 0; + for (var i=0; i<9; ++i) + if (board.children[i].state == "") { + openA[acc] = i; + acc += 1; + } + var choice = openA[Math.floor(Math.random() * open)]; + makeMove(choice, "O"); +} + +function win(s) +{ + msg.text = s + msg.opacity = 1 + endtimer.running = true +} + diff --git a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml new file mode 100644 index 0000000..dd13052 --- /dev/null +++ b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml @@ -0,0 +1,77 @@ +import Qt 4.7 +import "content" +import "content/tic-tac-toe.js" as Logic + +Item { + id: game + + property bool show: false + property real difficulty: 1.0 //chance it will actually think + + width: 440 + height: 480 + anchors.fill: parent + + Image { + id: boardimage + anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.horizontalCenter } + source: "content/pics/board.png" + } + + Grid { + id: board + anchors.fill: boardimage + columns: 3 + + Repeater { + model: 9 + TicTac { + width: board.width/3 + height: board.height/3 + onClicked: { + if (!endtimer.running) { + if (!Logic.makeMove(index,"X")) + Logic.computerTurn() + } + } + } + } + + Timer { + id: endtimer + interval: 1600 + onTriggered: { msg.opacity = 0; Logic.restart() } + } + } + + Row { + spacing: 4 + anchors { top: board.bottom; horizontalCenter: board.horizontalCenter } + + Button { + text: "Hard" + onClicked: game.difficulty = 1.0; + down: game.difficulty == 1.0 + } + Button { + text: "Moderate" + onClicked: game.difficulty = 0.8; + down: game.difficulty == 0.8 + } + Button { + text: "Easy" + onClicked: game.difficulty = 0.2; + down: game.difficulty == 0.2 + } + } + + Text { + id: msg + + anchors.centerIn: parent + opacity: 0 + color: "blue" + style: Text.Outline; styleColor: "white" + font.pixelSize: 50; font.bold: true + } +} diff --git a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qmlproject b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/toys.qmlproject b/examples/declarative/toys/toys.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/toys.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/tvtennis/tvtennis.qml b/examples/declarative/toys/tvtennis/tvtennis.qml new file mode 100644 index 0000000..c90d9c5 --- /dev/null +++ b/examples/declarative/toys/tvtennis/tvtennis.qml @@ -0,0 +1,71 @@ +import Qt 4.7 + +Rectangle { + id: page + width: 640; height: 480 + color: "Black" + + // Make a ball to bounce + Rectangle { + id: ball + + // Add a property for the target y coordinate + property int targetY : page.height - 10 + property variant direction : "right" + + x: 20; width: 20; height: 20; z: 1 + color: "Lime" + + // Move the ball to the right and back to the left repeatedly + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { to: page.width - 40; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "left" } + NumberAnimation { to: 20; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "right" } + } + + // Make y follow the target y coordinate, with a velocity of 200 + SpringFollow on y { to: ball.targetY; velocity: 200 } + + // Detect the ball hitting the top or bottom of the view and bounce it + onYChanged: { + if (y <= 0) { + targetY = page.height - 20; + } else if (y >= page.height - 20) { + targetY = 0; + } + } + } + + // Place bats to the left and right of the view, following the y + // coordinates of the ball. + Rectangle { + id: leftBat + color: "Lime" + x: 2; width: 20; height: 90 + SpringFollow on y { + to: ball.y - 45; velocity: 300 + enabled: ball.direction == 'left' + } + } + Rectangle { + id: rightBat + color: "Lime" + x: page.width - 22; width: 20; height: 90 + SpringFollow on y { + to: ball.y-45; velocity: 300 + enabled: ball.direction == 'right' + } + } + + // The rest, to make it look realistic, if neither ever scores... + Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } + Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } + Repeater { + model: page.height / 20 + Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } + } +} diff --git a/examples/declarative/toys/tvtennis/tvtennis.qmlproject b/examples/declarative/toys/tvtennis/tvtennis.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/tvtennis/tvtennis.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/velocity/Day.qml b/examples/declarative/toys/velocity/Day.qml new file mode 100644 index 0000000..350c1c4 --- /dev/null +++ b/examples/declarative/toys/velocity/Day.qml @@ -0,0 +1,101 @@ +import Qt 4.7 + +Component { + Item { + property variant stickies + + id: page + width: 840; height: 480 + + Image { source: "cork.jpg" } + + Text { + text: name; x: 15; y: 8; height: 40; width: 370 + font.pixelSize: 18; font.bold: true; color: "white" + style: Text.Outline; styleColor: "black" + } + + Repeater { + model: notes + Item { + id: stickyPage + + property int randomX: Math.random() * 500 + 100 + property int randomY: Math.random() * 200 + 50 + + x: randomX; y: randomY + + SpringFollow on rotation { + to: -flickable.horizontalVelocity / 100 + spring: 2.0; damping: 0.15 + } + + Item { + id: sticky + scale: 0.7 + + Image { + id: stickyImage + x: 8 + -width * 0.6 / 2; y: -20 + source: "note-yellow.png" + scale: 0.6; transformOrigin: Item.TopLeft + smooth: true + } + + TextEdit { + id: myText + x: -104; y: 36; width: 215; height: 200 + smooth: true + font.pixelSize: 24 + readOnly: false + rotation: -8 + text: noteText + } + + Item { + x: stickyImage.x; y: -20 + width: stickyImage.width * stickyImage.scale + height: stickyImage.height * stickyImage.scale + + MouseArea { + id: mouse + anchors.fill: parent + drag.target: stickyPage + drag.axis: Drag.XandYAxis + drag.minimumY: 0 + drag.maximumY: page.height - 80 + drag.minimumX: 100 + drag.maximumX: page.width - 140 + onClicked: { myText.focus = true } + } + } + } + + Image { + x: -width / 2; y: -height * 0.5 / 2 + source: "tack.png" + scale: 0.7; transformOrigin: Item.TopLeft + } + + states: State { + name: "pressed" + when: mouse.pressed + PropertyChanges { target: sticky; rotation: 8; scale: 1 } + PropertyChanges { target: page; z: 8 } + } + + transitions: Transition { + NumberAnimation { properties: "rotation,scale"; duration: 200 } + } + } + } + } +} + + + + + + + + diff --git a/examples/declarative/toys/velocity/cork.jpg b/examples/declarative/toys/velocity/cork.jpg new file mode 100644 index 0000000..160bc00 Binary files /dev/null and b/examples/declarative/toys/velocity/cork.jpg differ diff --git a/examples/declarative/toys/velocity/note-yellow.png b/examples/declarative/toys/velocity/note-yellow.png new file mode 100644 index 0000000..8ddecc8 Binary files /dev/null and b/examples/declarative/toys/velocity/note-yellow.png differ diff --git a/examples/declarative/toys/velocity/tack.png b/examples/declarative/toys/velocity/tack.png new file mode 100644 index 0000000..cef2d1c Binary files /dev/null and b/examples/declarative/toys/velocity/tack.png differ diff --git a/examples/declarative/toys/velocity/velocity.qml b/examples/declarative/toys/velocity/velocity.qml new file mode 100644 index 0000000..871bafc --- /dev/null +++ b/examples/declarative/toys/velocity/velocity.qml @@ -0,0 +1,75 @@ +import Qt 4.7 + +Rectangle { + width: 800; height: 480 + color: "#464646" + + ListModel { + id: list + + ListElement { + name: "Sunday" + notes: [ + ListElement { noteText: "Lunch" }, + ListElement { noteText: "Birthday Party" } + ] + } + + ListElement { + name: "Monday" + notes: [ + ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, + ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } + ] + } + + ListElement { + name: "Tuesday" + notes: [ + ListElement { noteText: "Walk dog" }, + ListElement { noteText: "Buy newspaper" } + ] + } + + ListElement { + name: "Wednesday" + notes: [ ListElement { noteText: "Cook dinner" } ] + } + + ListElement { + name: "Thursday" + notes: [ + ListElement { noteText: "Meeting\n5.30pm" }, + ListElement { noteText: "Weed garden" } + ] + } + + ListElement { + name: "Friday" + notes: [ + ListElement { noteText: "More work" }, + ListElement { noteText: "Grocery shopping" } + ] + } + + ListElement { + name: "Saturday" + notes: [ + ListElement { noteText: "Drink" }, + ListElement { noteText: "Download Qt\nPlay with QML" } + ] + } + } + + ListView { + id: flickable + + anchors.fill: parent + focus: true + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem + model: list + delegate: Day { } + } +} diff --git a/examples/declarative/toys/velocity/velocity.qmlproject b/examples/declarative/toys/velocity/velocity.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/velocity/velocity.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/tutorials/extending/extending.pro b/examples/declarative/tutorials/extending/extending.pro new file mode 100644 index 0000000..0c86fed --- /dev/null +++ b/examples/declarative/tutorials/extending/extending.pro @@ -0,0 +1,9 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + chapter1-basics \ + chapter2-methods \ + chapter3-bindings \ + chapter4-customPropertyTypes \ + chapter5-plugins + diff --git a/examples/declarative/tutorials/tutorials.pro b/examples/declarative/tutorials/tutorials.pro new file mode 100644 index 0000000..0a82c1e --- /dev/null +++ b/examples/declarative/tutorials/tutorials.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + extending + diff --git a/examples/declarative/tvtennis/tvtennis.qml b/examples/declarative/tvtennis/tvtennis.qml deleted file mode 100644 index c90d9c5..0000000 --- a/examples/declarative/tvtennis/tvtennis.qml +++ /dev/null @@ -1,71 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: page - width: 640; height: 480 - color: "Black" - - // Make a ball to bounce - Rectangle { - id: ball - - // Add a property for the target y coordinate - property int targetY : page.height - 10 - property variant direction : "right" - - x: 20; width: 20; height: 20; z: 1 - color: "Lime" - - // Move the ball to the right and back to the left repeatedly - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { to: page.width - 40; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "left" } - NumberAnimation { to: 20; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "right" } - } - - // Make y follow the target y coordinate, with a velocity of 200 - SpringFollow on y { to: ball.targetY; velocity: 200 } - - // Detect the ball hitting the top or bottom of the view and bounce it - onYChanged: { - if (y <= 0) { - targetY = page.height - 20; - } else if (y >= page.height - 20) { - targetY = 0; - } - } - } - - // Place bats to the left and right of the view, following the y - // coordinates of the ball. - Rectangle { - id: leftBat - color: "Lime" - x: 2; width: 20; height: 90 - SpringFollow on y { - to: ball.y - 45; velocity: 300 - enabled: ball.direction == 'left' - } - } - Rectangle { - id: rightBat - color: "Lime" - x: page.width - 22; width: 20; height: 90 - SpringFollow on y { - to: ball.y-45; velocity: 300 - enabled: ball.direction == 'right' - } - } - - // The rest, to make it look realistic, if neither ever scores... - Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } - Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } - Repeater { - model: page.height / 20 - Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } - } -} diff --git a/examples/declarative/tvtennis/tvtennis.qmlproject b/examples/declarative/tvtennis/tvtennis.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/tvtennis/tvtennis.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/ui-components/flipable/content/5_heart.png b/examples/declarative/ui-components/flipable/content/5_heart.png new file mode 100644 index 0000000..fb59d81 Binary files /dev/null and b/examples/declarative/ui-components/flipable/content/5_heart.png differ diff --git a/examples/declarative/ui-components/flipable/content/9_club.png b/examples/declarative/ui-components/flipable/content/9_club.png new file mode 100644 index 0000000..2545001 Binary files /dev/null and b/examples/declarative/ui-components/flipable/content/9_club.png differ diff --git a/examples/declarative/ui-components/flipable/content/Card.qml b/examples/declarative/ui-components/flipable/content/Card.qml new file mode 100644 index 0000000..2577d89 --- /dev/null +++ b/examples/declarative/ui-components/flipable/content/Card.qml @@ -0,0 +1,38 @@ +import Qt 4.7 + +Flipable { + id: container + + property alias image: frontImage.source + property bool flipped: true + property int xAxis: 0 + property int yAxis: 0 + property int angle: 0 + + width: front.width; height: front.height; state: "back" + + front: Image { id: frontImage; smooth: true } + back: Image { source: "back.png"; smooth: true } + + MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } + + transform: Rotation { + id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 + axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 + } + + states: State { + name: "back"; when: container.flipped + PropertyChanges { target: rotation; angle: container.angle } + } + + transitions: Transition { + ParallelAnimation { + NumberAnimation { target: rotation; properties: "angle"; duration: 600 } + SequentialAnimation { + NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } + NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } + } + } + } +} diff --git a/examples/declarative/ui-components/flipable/content/back.png b/examples/declarative/ui-components/flipable/content/back.png new file mode 100644 index 0000000..f715d74 Binary files /dev/null and b/examples/declarative/ui-components/flipable/content/back.png differ diff --git a/examples/declarative/ui-components/flipable/flipable-example.qml b/examples/declarative/ui-components/flipable/flipable-example.qml new file mode 100644 index 0000000..4e09569 --- /dev/null +++ b/examples/declarative/ui-components/flipable/flipable-example.qml @@ -0,0 +1,15 @@ +import Qt 4.7 +import "content" + +Rectangle { + id: window + + width: 480; height: 320 + color: "darkgreen" + + Row { + anchors.centerIn: parent; spacing: 30 + Card { image: "content/9_club.png"; angle: 180; yAxis: 1 } + Card { image: "content/5_heart.png"; angle: 540; xAxis: 1 } + } +} diff --git a/examples/declarative/ui-components/flipable/flipable.qmlproject b/examples/declarative/ui-components/flipable/flipable.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/flipable/flipable.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/progressbar/content/ProgressBar.qml b/examples/declarative/ui-components/progressbar/content/ProgressBar.qml new file mode 100644 index 0000000..bc36df5 --- /dev/null +++ b/examples/declarative/ui-components/progressbar/content/ProgressBar.qml @@ -0,0 +1,43 @@ +import Qt 4.7 + +Item { + id: progressbar + + property int minimum: 0 + property int maximum: 100 + property int value: 0 + property alias color: gradient1.color + property alias secondColor: gradient2.color + + width: 250; height: 23 + clip: true + + BorderImage { + source: "background.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + } + + Rectangle { + id: highlight + + property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) + + width: highlight.widthDest + Behavior on width { SmoothedAnimation { velocity: 1200 } } + + anchors { left: parent.left; top: parent.top; bottom: parent.bottom; leftMargin: 3; topMargin: 3; bottomMargin: 3 } + radius: 1 + gradient: Gradient { + GradientStop { id: gradient1; position: 0.0 } + GradientStop { id: gradient2; position: 1.0 } + } + + } + Text { + anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } + color: "white" + font.bold: true + text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' + } +} diff --git a/examples/declarative/ui-components/progressbar/content/background.png b/examples/declarative/ui-components/progressbar/content/background.png new file mode 100644 index 0000000..9044226 Binary files /dev/null and b/examples/declarative/ui-components/progressbar/content/background.png differ diff --git a/examples/declarative/ui-components/progressbar/progressbar.qmlproject b/examples/declarative/ui-components/progressbar/progressbar.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/progressbar/progressbar.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/progressbar/progressbars.qml b/examples/declarative/ui-components/progressbar/progressbars.qml new file mode 100644 index 0000000..55fd682 --- /dev/null +++ b/examples/declarative/ui-components/progressbar/progressbars.qml @@ -0,0 +1,33 @@ +import Qt 4.7 +import "content" + +Rectangle { + id: main + + width: 600; height: 405 + color: "#edecec" + + Flickable { + anchors.fill: parent + contentHeight: column.height + 20 + + Column { + id: column + x: 10; y: 10 + spacing: 10 + + Repeater { + model: 25 + + ProgressBar { + property int r: Math.floor(Math.random() * 5000 + 1000) + width: main.width - 20 + + NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } + ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } + ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } + } + } + } + } +} diff --git a/examples/declarative/ui-components/scrollbar/ScrollBar.qml b/examples/declarative/ui-components/scrollbar/ScrollBar.qml new file mode 100644 index 0000000..c628a20 --- /dev/null +++ b/examples/declarative/ui-components/scrollbar/ScrollBar.qml @@ -0,0 +1,33 @@ +import Qt 4.7 + +Item { + id: scrollBar + + // The properties that define the scrollbar's state. + // position and pageSize are in the range 0.0 - 1.0. They are relative to the + // height of the page, i.e. a pageSize of 0.5 means that you can see 50% + // of the height of the view. + // orientation can be either Qt.Vertical or Qt.Horizontal + property real position + property real pageSize + property variant orientation : Qt.Vertical + + // A light, semi-transparent background + Rectangle { + id: background + anchors.fill: parent + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "white" + opacity: 0.3 + } + // Size the bar to the required size, depending upon the orientation. + Rectangle { + x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) + y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 + width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) + height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "black" + opacity: 0.7 + } +} diff --git a/examples/declarative/ui-components/scrollbar/display.qml b/examples/declarative/ui-components/scrollbar/display.qml new file mode 100644 index 0000000..6b12d85 --- /dev/null +++ b/examples/declarative/ui-components/scrollbar/display.qml @@ -0,0 +1,54 @@ +import Qt 4.7 + +Rectangle { + width: 640 + height: 480 + + // Create a flickable to view a large image. + Flickable { + id: view + anchors.fill: parent + contentWidth: picture.width + contentHeight: picture.height + + Image { + id: picture + source: "pics/niagara_falls.jpg" + asynchronous: true + } + + // Only show the scrollbars when the view is moving. + states: State { + name: "ShowBars" + when: view.movingVertically || view.movingHorizontally + PropertyChanges { target: verticalScrollBar; opacity: 1 } + PropertyChanges { target: horizontalScrollBar; opacity: 1 } + } + + transitions: Transition { + from: "*"; to: "*" + NumberAnimation { properties: "opacity"; duration: 400 } + } + } + + // Attach scrollbars to the right and bottom edges of the view. + ScrollBar { + id: verticalScrollBar + width: 12; height: view.height-12 + anchors.right: view.right + opacity: 0 + orientation: Qt.Vertical + position: view.visibleArea.yPosition + pageSize: view.visibleArea.heightRatio + } + + ScrollBar { + id: horizontalScrollBar + width: view.width-12; height: 12 + anchors.bottom: view.bottom + opacity: 0 + orientation: Qt.Horizontal + position: view.visibleArea.xPosition + pageSize: view.visibleArea.widthRatio + } +} diff --git a/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg b/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg new file mode 100644 index 0000000..618d808 Binary files /dev/null and b/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg differ diff --git a/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject b/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/searchbox/SearchBox.qml b/examples/declarative/ui-components/searchbox/SearchBox.qml new file mode 100644 index 0000000..aae7ee9 --- /dev/null +++ b/examples/declarative/ui-components/searchbox/SearchBox.qml @@ -0,0 +1,65 @@ +import Qt 4.7 + +FocusScope { + id: focusScope + width: 250; height: 28 + + BorderImage { + source: "images/lineedit-bg.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + } + + BorderImage { + source: "images/lineedit-bg-focus.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + visible: parent.wantsFocus ? true : false + } + + Text { + id: typeSomething + anchors.fill: parent; anchors.leftMargin: 8 + verticalAlignment: Text.AlignVCenter + text: "Type something..." + color: "gray" + font.italic: true + } + + MouseArea { anchors.fill: parent; onClicked: focusScope.focus = true } + + TextInput { + id: textInput + anchors { left: parent.left; leftMargin: 8; verticalCenter: parent.verticalCenter } + focus: true + } + + Image { + id: clear + anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter } + source: "images/edit-clear-locationbar-rtl.png" + opacity: 0 + + MouseArea { + anchors.fill: parent + onClicked: { textInput.text = ''; focusScope.focus = true } + } + } + + states: State { + name: "hasText"; when: textInput.text != '' + PropertyChanges { target: typeSomething; opacity: 0 } + PropertyChanges { target: clear; opacity: 1 } + } + + transitions: [ + Transition { + from: ""; to: "hasText" + NumberAnimation { exclude: typeSomething; properties: "opacity" } + }, + Transition { + from: "hasText"; to: "" + NumberAnimation { properties: "opacity" } + } + ] +} diff --git a/examples/declarative/ui-components/searchbox/images/edit-clear-locationbar-rtl.png b/examples/declarative/ui-components/searchbox/images/edit-clear-locationbar-rtl.png new file mode 100644 index 0000000..91eb270 Binary files /dev/null and b/examples/declarative/ui-components/searchbox/images/edit-clear-locationbar-rtl.png differ diff --git a/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png new file mode 100644 index 0000000..bbfac38 Binary files /dev/null and b/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png differ diff --git a/examples/declarative/ui-components/searchbox/images/lineedit-bg.png b/examples/declarative/ui-components/searchbox/images/lineedit-bg.png new file mode 100644 index 0000000..9044226 Binary files /dev/null and b/examples/declarative/ui-components/searchbox/images/lineedit-bg.png differ diff --git a/examples/declarative/ui-components/searchbox/main.qml b/examples/declarative/ui-components/searchbox/main.qml new file mode 100644 index 0000000..9f73473 --- /dev/null +++ b/examples/declarative/ui-components/searchbox/main.qml @@ -0,0 +1,15 @@ +import Qt 4.7 + +Rectangle { + width: 500; height: 250 + color: "#edecec" + + Column { + anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } + spacing: 10 + + SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } + SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } + SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } + } +} diff --git a/examples/declarative/ui-components/searchbox/searchbox.qmlproject b/examples/declarative/ui-components/searchbox/searchbox.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/searchbox/searchbox.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/slideswitch/content/Switch.qml b/examples/declarative/ui-components/slideswitch/content/Switch.qml new file mode 100644 index 0000000..526a171 --- /dev/null +++ b/examples/declarative/ui-components/slideswitch/content/Switch.qml @@ -0,0 +1,76 @@ +//![0] +import Qt 4.7 + +Item { + id: toggleswitch + width: background.width; height: background.height + +//![1] + property bool on: false +//![1] + +//![2] + function toggle() { + if (toggleswitch.state == "on") + toggleswitch.state = "off"; + else toggleswitch.state = "on"; + } +//![2] + +//![3] + function dorelease() { + if (knob.x == 1) { + if (toggleswitch.state == "off") return; + } + if (knob.x == 78) { + if (toggleswitch.state == "on") return; + } + toggle(); + } +//![3] + +//![4] + Image { + id: background + source: "background.svg" + MouseArea { anchors.fill: parent; onClicked: toggle() } + } +//![4] + +//![5] + Image { + id: knob + x: 1; y: 2 + source: "knob.svg" + + MouseArea { + anchors.fill: parent + drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78 + onClicked: toggle() + onReleased: dorelease() + } + } +//![5] + +//![6] + states: [ + State { + name: "on" + PropertyChanges { target: knob; x: 78 } + PropertyChanges { target: toggleswitch; on: true } + }, + State { + name: "off" + PropertyChanges { target: knob; x: 1 } + PropertyChanges { target: toggleswitch; on: false } + } + ] +//![6] + +//![7] + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 } + } +//![7] +} +//![0] diff --git a/examples/declarative/ui-components/slideswitch/content/background.svg b/examples/declarative/ui-components/slideswitch/content/background.svg new file mode 100644 index 0000000..f920d3e --- /dev/null +++ b/examples/declarative/ui-components/slideswitch/content/background.svg @@ -0,0 +1,23 @@ + + + +]> + + + + + + + + + + + + + + diff --git a/examples/declarative/ui-components/slideswitch/content/knob.svg b/examples/declarative/ui-components/slideswitch/content/knob.svg new file mode 100644 index 0000000..fb69337 --- /dev/null +++ b/examples/declarative/ui-components/slideswitch/content/knob.svg @@ -0,0 +1,867 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/declarative/ui-components/slideswitch/slideswitch.qml b/examples/declarative/ui-components/slideswitch/slideswitch.qml new file mode 100644 index 0000000..51c3c77 --- /dev/null +++ b/examples/declarative/ui-components/slideswitch/slideswitch.qml @@ -0,0 +1,11 @@ +import Qt 4.7 +import "content" + +Rectangle { + color: "white" + width: 400; height: 250 + +//![0] + Switch { anchors.centerIn: parent; on: false } +//![0] +} diff --git a/examples/declarative/ui-components/slideswitch/slideswitch.qmlproject b/examples/declarative/ui-components/slideswitch/slideswitch.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/slideswitch/slideswitch.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/spinner/content/Spinner.qml b/examples/declarative/ui-components/spinner/content/Spinner.qml new file mode 100644 index 0000000..8145a28 --- /dev/null +++ b/examples/declarative/ui-components/spinner/content/Spinner.qml @@ -0,0 +1,25 @@ +import Qt 4.7 + +Image { + property alias model: view.model + property alias delegate: view.delegate + property alias currentIndex: view.currentIndex + property real itemHeight: 30 + source: "spinner-bg.png" + clip: true + PathView { + id: view + anchors.fill: parent + pathItemCount: height/itemHeight + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } + dragMargin: view.width/2 + path: Path { + startX: view.width/2; startY: -itemHeight/2 + PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } + } + } + Keys.onDownPressed: view.incrementCurrentIndex() + Keys.onUpPressed: view.decrementCurrentIndex() +} diff --git a/examples/declarative/ui-components/spinner/content/spinner-bg.png b/examples/declarative/ui-components/spinner/content/spinner-bg.png new file mode 100644 index 0000000..b3556f1 Binary files /dev/null and b/examples/declarative/ui-components/spinner/content/spinner-bg.png differ diff --git a/examples/declarative/ui-components/spinner/content/spinner-select.png b/examples/declarative/ui-components/spinner/content/spinner-select.png new file mode 100644 index 0000000..95a17a1 Binary files /dev/null and b/examples/declarative/ui-components/spinner/content/spinner-select.png differ diff --git a/examples/declarative/ui-components/spinner/main.qml b/examples/declarative/ui-components/spinner/main.qml new file mode 100644 index 0000000..6be567a --- /dev/null +++ b/examples/declarative/ui-components/spinner/main.qml @@ -0,0 +1,18 @@ +import Qt 4.7 +import "content" + +Rectangle { + width: 240; height: 320 + Column { + y: 20; x: 20; spacing: 20 + Spinner { + id: spinner + width: 200; height: 240 + focus: true + model: 20 + itemHeight: 30 + delegate: Text { font.pixelSize: 25; text: index; height: 30 } + } + Text { text: "Current item index: " + spinner.currentIndex } + } +} diff --git a/examples/declarative/ui-components/spinner/spinner.qmlproject b/examples/declarative/ui-components/spinner/spinner.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/spinner/spinner.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/tabwidget/TabWidget.qml b/examples/declarative/ui-components/tabwidget/TabWidget.qml new file mode 100644 index 0000000..26d25b4 --- /dev/null +++ b/examples/declarative/ui-components/tabwidget/TabWidget.qml @@ -0,0 +1,57 @@ +import Qt 4.7 + +Item { + id: tabWidget + + property int current: 0 + default property alias content: stack.children + + onCurrentChanged: setOpacities() + Component.onCompleted: setOpacities() + + function setOpacities() + { + for (var i = 0; i < stack.children.length; ++i) { + stack.children[i].opacity = i == current ? 1 : 0 + } + } + + Row { + id: header + Repeater { + delegate: Rectangle { + width: tabWidget.width / stack.children.length; height: 36 + + Rectangle { + width: parent.width; height: 1 + anchors { bottom: parent.bottom; bottomMargin: 1 } + color: "#acb2c2" + } + BorderImage { + anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } + border { left: 7; right: 7 } + source: "tab.png" + visible: tabWidget.current == index + } + Text { + horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter + anchors.fill: parent + text: stack.children[index].title + elide: Text.ElideRight + font.bold: tabWidget.current == index + } + MouseArea { + anchors.fill: parent + onClicked: tabWidget.current = index + } + } + model: stack.children.length + } + } + + Item { + id: stack + width: tabWidget.width + anchors.top: header.bottom; anchors.bottom: tabWidget.bottom + } +} diff --git a/examples/declarative/ui-components/tabwidget/tab.png b/examples/declarative/ui-components/tabwidget/tab.png new file mode 100644 index 0000000..ad80216 Binary files /dev/null and b/examples/declarative/ui-components/tabwidget/tab.png differ diff --git a/examples/declarative/ui-components/tabwidget/tabs.qml b/examples/declarative/ui-components/tabwidget/tabs.qml new file mode 100644 index 0000000..fba203c --- /dev/null +++ b/examples/declarative/ui-components/tabwidget/tabs.qml @@ -0,0 +1,59 @@ +import Qt 4.7 + +TabWidget { + id: tabs + width: 640; height: 480 + + Rectangle { + property string title: "Red" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } + color: "#ff7f7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Roses are red" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Green" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } + color: "#7fff7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Flower stems are green" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Blue" + anchors.fill: parent; color: "#e3e3e3" + + Rectangle { + anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } + color: "#7f7fff" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Violets are blue" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } +} diff --git a/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject b/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/ui-components.qmlproject b/examples/declarative/ui-components/ui-components.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/ui-components.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml deleted file mode 100644 index 350c1c4..0000000 --- a/examples/declarative/velocity/Day.qml +++ /dev/null @@ -1,101 +0,0 @@ -import Qt 4.7 - -Component { - Item { - property variant stickies - - id: page - width: 840; height: 480 - - Image { source: "cork.jpg" } - - Text { - text: name; x: 15; y: 8; height: 40; width: 370 - font.pixelSize: 18; font.bold: true; color: "white" - style: Text.Outline; styleColor: "black" - } - - Repeater { - model: notes - Item { - id: stickyPage - - property int randomX: Math.random() * 500 + 100 - property int randomY: Math.random() * 200 + 50 - - x: randomX; y: randomY - - SpringFollow on rotation { - to: -flickable.horizontalVelocity / 100 - spring: 2.0; damping: 0.15 - } - - Item { - id: sticky - scale: 0.7 - - Image { - id: stickyImage - x: 8 + -width * 0.6 / 2; y: -20 - source: "note-yellow.png" - scale: 0.6; transformOrigin: Item.TopLeft - smooth: true - } - - TextEdit { - id: myText - x: -104; y: 36; width: 215; height: 200 - smooth: true - font.pixelSize: 24 - readOnly: false - rotation: -8 - text: noteText - } - - Item { - x: stickyImage.x; y: -20 - width: stickyImage.width * stickyImage.scale - height: stickyImage.height * stickyImage.scale - - MouseArea { - id: mouse - anchors.fill: parent - drag.target: stickyPage - drag.axis: Drag.XandYAxis - drag.minimumY: 0 - drag.maximumY: page.height - 80 - drag.minimumX: 100 - drag.maximumX: page.width - 140 - onClicked: { myText.focus = true } - } - } - } - - Image { - x: -width / 2; y: -height * 0.5 / 2 - source: "tack.png" - scale: 0.7; transformOrigin: Item.TopLeft - } - - states: State { - name: "pressed" - when: mouse.pressed - PropertyChanges { target: sticky; rotation: 8; scale: 1 } - PropertyChanges { target: page; z: 8 } - } - - transitions: Transition { - NumberAnimation { properties: "rotation,scale"; duration: 200 } - } - } - } - } -} - - - - - - - - diff --git a/examples/declarative/velocity/cork.jpg b/examples/declarative/velocity/cork.jpg deleted file mode 100644 index 160bc00..0000000 Binary files a/examples/declarative/velocity/cork.jpg and /dev/null differ diff --git a/examples/declarative/velocity/note-yellow.png b/examples/declarative/velocity/note-yellow.png deleted file mode 100644 index 8ddecc8..0000000 Binary files a/examples/declarative/velocity/note-yellow.png and /dev/null differ diff --git a/examples/declarative/velocity/tack.png b/examples/declarative/velocity/tack.png deleted file mode 100644 index cef2d1c..0000000 Binary files a/examples/declarative/velocity/tack.png and /dev/null differ diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml deleted file mode 100644 index 871bafc..0000000 --- a/examples/declarative/velocity/velocity.qml +++ /dev/null @@ -1,75 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 800; height: 480 - color: "#464646" - - ListModel { - id: list - - ListElement { - name: "Sunday" - notes: [ - ListElement { noteText: "Lunch" }, - ListElement { noteText: "Birthday Party" } - ] - } - - ListElement { - name: "Monday" - notes: [ - ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, - ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } - ] - } - - ListElement { - name: "Tuesday" - notes: [ - ListElement { noteText: "Walk dog" }, - ListElement { noteText: "Buy newspaper" } - ] - } - - ListElement { - name: "Wednesday" - notes: [ ListElement { noteText: "Cook dinner" } ] - } - - ListElement { - name: "Thursday" - notes: [ - ListElement { noteText: "Meeting\n5.30pm" }, - ListElement { noteText: "Weed garden" } - ] - } - - ListElement { - name: "Friday" - notes: [ - ListElement { noteText: "More work" }, - ListElement { noteText: "Grocery shopping" } - ] - } - - ListElement { - name: "Saturday" - notes: [ - ListElement { noteText: "Drink" }, - ListElement { noteText: "Download Qt\nPlay with QML" } - ] - } - } - - ListView { - id: flickable - - anchors.fill: parent - focus: true - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem - model: list - delegate: Day { } - } -} diff --git a/examples/declarative/velocity/velocity.qmlproject b/examples/declarative/velocity/velocity.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/velocity/velocity.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/webview/alerts.html b/examples/declarative/webview/alerts.html deleted file mode 100644 index 82caddf..0000000 --- a/examples/declarative/webview/alerts.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

      This is a web page. It fires an alert when clicked. - - diff --git a/examples/declarative/webview/alerts.qml b/examples/declarative/webview/alerts.qml deleted file mode 100644 index 7684c3e..0000000 --- a/examples/declarative/webview/alerts.qml +++ /dev/null @@ -1,58 +0,0 @@ -import Qt 4.7 -import org.webkit 1.0 - -WebView { - id: webView - width: 120 - height: 150 - url: "alerts.html" - - onAlert: popup.show(message) - - Rectangle { - id: popup - - color: "red" - border.color: "black"; border.width: 2 - radius: 4 - - y: parent.height // off "screen" - anchors.horizontalCenter: parent.horizontalCenter - width: label.width+5 - height: label.height+5 - - opacity: 0 - - function show(t) { - label.text = t - popup.state = "visible" - timer.start() - } - states: State { - name: "visible" - PropertyChanges { target: popup; opacity: 1 } - PropertyChanges { target: popup; y: (webView.height-popup.height)/2 } - } - - transitions: [ - Transition { from: ""; PropertyAnimation { properties: "opacity,y"; duration: 65 } }, - Transition { from: "visible"; PropertyAnimation { properties: "opacity,y"; duration: 500 } } - ] - - Timer { - id: timer - interval: 1000 - onTriggered: popup.state = "" - } - - Text { - id: label - anchors.centerIn: parent - color: "white" - font.pixelSize: 20 - width: webView.width*0.75 - wrapMode: Text.WordWrap - horizontalAlignment: Text.AlignHCenter - } - } -} diff --git a/examples/declarative/webview/autosize.qml b/examples/declarative/webview/autosize.qml deleted file mode 100644 index 9632883..0000000 --- a/examples/declarative/webview/autosize.qml +++ /dev/null @@ -1,62 +0,0 @@ -import Qt 4.7 -import org.webkit 1.0 - -// The WebView size is determined by the width, height, -// preferredWidth, and preferredHeight properties. -Rectangle { - id: rect - width: 200 - height: layout.height - - Column { - id: layout - spacing: 2 - WebView { - html: "No width defined." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - WebView { - width: rect.width - html: "The width is full." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - WebView { - width: rect.width/2 - html: "The width is half." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - WebView { - preferredWidth: rect.width/2 - html: "The preferredWidth is half." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - WebView { - preferredWidth: rect.width/2 - html: "The_preferredWidth_is_half." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - WebView { - width: rect.width/2 - html: "The_width_is_half." - Rectangle { - color: "#10000000" - anchors.fill: parent - } - } - } -} diff --git a/examples/declarative/webview/content/FieldText.qml b/examples/declarative/webview/content/FieldText.qml deleted file mode 100644 index d1d003f..0000000 --- a/examples/declarative/webview/content/FieldText.qml +++ /dev/null @@ -1,157 +0,0 @@ -import Qt 4.7 - -Item { - id: fieldText - height: 30 - property string text: "" - property string label: "" - property bool mouseGrabbed: false - signal confirmed - signal cancelled - signal startEdit - - function edit() { - if (!mouseGrabbed) { - fieldText.startEdit(); - fieldText.state='editing'; - mouseGrabbed=true; - } - } - - function confirm() { - fieldText.state=''; - fieldText.text = textEdit.text; - mouseGrabbed=false; - fieldText.confirmed(); - } - - function reset() { - textEdit.text = fieldText.text; - fieldText.state=''; - mouseGrabbed=false; - fieldText.cancelled(); - } - - Image { - id: cancelIcon - width: 22 - height: 22 - anchors.right: parent.right - anchors.rightMargin: 4 - anchors.verticalCenter: parent.verticalCenter - source: "pics/cancel.png" - opacity: 0 - } - - Image { - id: confirmIcon - width: 22 - height: 22 - anchors.left: parent.left - anchors.leftMargin: 4 - anchors.verticalCenter: parent.verticalCenter - source: "pics/ok.png" - opacity: 0 - } - - TextInput { - id: textEdit - text: fieldText.text - focus: false - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.right: parent.right - anchors.rightMargin: 0 - anchors.verticalCenter: parent.verticalCenter - color: "black" - font.bold: true - readOnly: true - onAccepted: confirm() - Keys.onEscapePressed: reset() - } - - Text { - id: textLabel - x: 5 - width: parent.width-10 - anchors.verticalCenter: parent.verticalCenter - horizontalAlignment: Text.AlignHCenter - color: fieldText.state == "editing" ? "#505050" : "#AAAAAA" - font.italic: true - font.bold: true - text: label - opacity: textEdit.text == '' ? 1 : 0 - Behavior on opacity { - NumberAnimation { - property: "opacity" - duration: 250 - } - } - } - - MouseArea { - anchors.fill: cancelIcon - onClicked: { reset() } - } - - MouseArea { - anchors.fill: confirmIcon - onClicked: { confirm() } - } - - MouseArea { - id: editRegion - anchors.fill: textEdit - onClicked: { edit() } - } - - states: [ - State { - name: "editing" - PropertyChanges { - target: confirmIcon - opacity: 1 - } - PropertyChanges { - target: cancelIcon - opacity: 1 - } - PropertyChanges { - target: textEdit - color: "black" - readOnly: false - focus: true - selectionStart: 0 - selectionEnd: -1 - } - PropertyChanges { - target: editRegion - opacity: 0 - } - PropertyChanges { - target: textEdit.anchors - leftMargin: 34 - } - PropertyChanges { - target: textEdit.anchors - rightMargin: 34 - } - } - ] - - transitions: [ - Transition { - from: "" - to: "*" - reversible: true - NumberAnimation { - properties: "opacity,leftMargin,rightMargin" - duration: 200 - } - ColorAnimation { - property: "color" - duration: 150 - } - } - ] -} diff --git a/examples/declarative/webview/content/Mapping/Map.qml b/examples/declarative/webview/content/Mapping/Map.qml deleted file mode 100644 index 5d3ba81..0000000 --- a/examples/declarative/webview/content/Mapping/Map.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.7 -import org.webkit 1.0 - -Item { - id: page - property real latitude: -34.397 - property real longitude: 150.644 - property string address: "" - property alias status: js.status - WebView { - id: map - anchors.fill: parent - url: "map.html" - javaScriptWindowObjects: QtObject { - id: js - WebView.windowObjectName: "qml" - property real lat: page.latitude - property real lng: page.longitude - property string address: page.address - property string status: "Loading" - onAddressChanged: { if (map.url != "" && map.progress==1) map.evaluateJavaScript("goToAddress()") } - } - pressGrabTime: 0 - onLoadFinished: { evaluateJavaScript("goToAddress()"); } - } -} diff --git a/examples/declarative/webview/content/Mapping/map.html b/examples/declarative/webview/content/Mapping/map.html deleted file mode 100755 index a8726fd..0000000 --- a/examples/declarative/webview/content/Mapping/map.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - -

      - - diff --git a/examples/declarative/webview/content/SpinSquare.qml b/examples/declarative/webview/content/SpinSquare.qml deleted file mode 100644 index dba48d4..0000000 --- a/examples/declarative/webview/content/SpinSquare.qml +++ /dev/null @@ -1,25 +0,0 @@ -import Qt 4.7 - -Item { - property variant period : 250 - property variant color : "black" - id: root - - Item { - x: root.width/2 - y: root.height/2 - Rectangle { - color: root.color - x: -width/2 - y: -height/2 - width: root.width - height: width - } - NumberAnimation on rotation { - from: 0 - to: 360 - loops: Animation.Infinite - duration: root.period - } - } -} diff --git a/examples/declarative/webview/content/pics/cancel.png b/examples/declarative/webview/content/pics/cancel.png deleted file mode 100644 index ecc9533..0000000 Binary files a/examples/declarative/webview/content/pics/cancel.png and /dev/null differ diff --git a/examples/declarative/webview/content/pics/ok.png b/examples/declarative/webview/content/pics/ok.png deleted file mode 100644 index 5795f04..0000000 Binary files a/examples/declarative/webview/content/pics/ok.png and /dev/null differ diff --git a/examples/declarative/webview/googleMaps.qml b/examples/declarative/webview/googleMaps.qml deleted file mode 100644 index 5506012..0000000 --- a/examples/declarative/webview/googleMaps.qml +++ /dev/null @@ -1,43 +0,0 @@ -// This example demonstrates how Web services such as Google Maps can be -// abstracted as QML types. Here we have a "Mapping" module with a "Map" -// type. The Map type has an address property. Setting that property moves -// the map. The underlying implementation uses WebView and the Google Maps -// API, but users from QML don't need to understand the implementation in -// order to create a Map. - -import Qt 4.7 -import org.webkit 1.0 -import "content/Mapping" - -Map { - id: map - width: 300 - height: 300 - address: "Paris" - - Rectangle { - x: 70 - width: input.width + 20 - height: input.height + 4 - anchors.bottom: parent.bottom; anchors.bottomMargin: 5 - radius: 5 - opacity: map.status == "Ready" ? 1 : 0 - - TextInput { - id: input - text: map.address - anchors.centerIn: parent - Keys.onReturnPressed: map.address = input.text - } - } - - Text { - id: loading - anchors.centerIn: parent - text: map.status == "Error" ? "Error" : "Loading" - opacity: map.status == "Ready" ? 0 : 1 - font.pixelSize: 30 - - Behavior on opacity { NumberAnimation{} } - } -} diff --git a/examples/declarative/webview/inline-html.qml b/examples/declarative/webview/inline-html.qml deleted file mode 100644 index eec7fc6..0000000 --- a/examples/declarative/webview/inline-html.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 -import org.webkit 1.0 - -// Inline HTML with loose formatting can be -// set on the html property. -WebView { - html:"\ - \ - \ -
      OneTwoThree\ -
      1X1X\ -
      20X0\ -
      3X1X\ -
      " -} diff --git a/examples/declarative/webview/newwindows.html b/examples/declarative/webview/newwindows.html deleted file mode 100644 index f169599..0000000 --- a/examples/declarative/webview/newwindows.html +++ /dev/null @@ -1,3 +0,0 @@ -

      Multiple windows...

      - -Popup! diff --git a/examples/declarative/webview/newwindows.qml b/examples/declarative/webview/newwindows.qml deleted file mode 100644 index 2e4a72e..0000000 --- a/examples/declarative/webview/newwindows.qml +++ /dev/null @@ -1,31 +0,0 @@ -// Demonstrates opening new WebViews from HTML -// -// Note that to open windows from JavaScript, you will need to -// allow it on WebView with settings.javascriptCanOpenWindows: true - -import Qt 4.7 -import org.webkit 1.0 - -Grid { - columns: 3 - id: pages - height: 300; width: 600 - - Component { - id: webViewPage - Rectangle { - width: webView.width - height: webView.height - border.color: "gray" - - WebView { - id: webView - newWindowComponent: webViewPage - newWindowParent: pages - url: "newwindows.html" - } - } - } - - Loader { sourceComponent: webViewPage } -} diff --git a/examples/declarative/webview/transparent.qml b/examples/declarative/webview/transparent.qml deleted file mode 100644 index e4efc31..0000000 --- a/examples/declarative/webview/transparent.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 -import org.webkit 1.0 - -// The WebView background is transparent -// if the HTML does not specify a background -Rectangle { - color: "green" - width: web.width - height: web.height - - WebView { - id: web - html: "Hello World!" - } -} diff --git a/examples/declarative/webview/webview.qmlproject b/examples/declarative/webview/webview.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/webview/webview.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/workerscript/workerscript.js b/examples/declarative/workerscript/workerscript.js deleted file mode 100644 index f76471f..0000000 --- a/examples/declarative/workerscript/workerscript.js +++ /dev/null @@ -1,15 +0,0 @@ -var lastx = 0; -var lasty = 0; - -WorkerScript.onMessage = function(message) { - var ydiff = message.y - lasty; - var xdiff = message.x - lastx; - - var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); - - lastx = message.x; - lasty = message.y; - - WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); -} - diff --git a/examples/declarative/workerscript/workerscript.qml b/examples/declarative/workerscript/workerscript.qml deleted file mode 100644 index 2294a81..0000000 --- a/examples/declarative/workerscript/workerscript.qml +++ /dev/null @@ -1,43 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 480; height: 320 - - WorkerScript { - id: myWorker - source: "workerscript.js" - - onMessage: { - console.log("Moved " + messageObject.xmove + " along the X axis."); - console.log("Moved " + messageObject.ymove + " along the Y axis."); - console.log("Moved " + messageObject.move + " pixels."); - } - } - - Rectangle { - width: 200; height: 200 - anchors.left: parent.left; anchors.leftMargin: 20 - color: "red" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); - } - } - - Rectangle { - width: 200; height: 200 - anchors.right: parent.right; anchors.rightMargin: 20 - color: "blue" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); - } - } - - Text { - text: "Click a Rectangle!" - anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } - } -} diff --git a/examples/declarative/workerscript/workerscript.qmlproject b/examples/declarative/workerscript/workerscript.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/workerscript/workerscript.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/xml/xml.qmlproject b/examples/declarative/xml/xml.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/xml/xml.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/xml/xmldata/daringfireball.qml b/examples/declarative/xml/xmldata/daringfireball.qml new file mode 100644 index 0000000..480b13c --- /dev/null +++ b/examples/declarative/xml/xmldata/daringfireball.qml @@ -0,0 +1,47 @@ +import Qt 4.7 + +Rectangle { + width: 600; height: 600 + + XmlListModel { + id: feedModel + source: "http://daringfireball.net/index.xml" + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "tagline"; query: "author/name/string()" } + XmlRole { name: "content"; query: "content/string()" } + } + + Component { + id: feedDelegate + Item { + height: childrenRect.height + 20 + Text { + id: titleText + x: 10 + text: title; font.bold: true + } + Text { + anchors { left: titleText.right; leftMargin: 10 } + text: 'by ' + tagline + font.italic: true + } + Text { + x: 10 + width: 580 + anchors.top: titleText.bottom + text: content + wrapMode: Text.WordWrap + + onLinkActivated: { console.log('link clicked: ' + link) } + } + } + } + + ListView { + anchors.fill: parent + model: feedModel + delegate: feedDelegate + } +} diff --git a/examples/declarative/xml/xmldata/xmldata.qmlproject b/examples/declarative/xml/xmldata/xmldata.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/xml/xmldata/xmldata.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/xml/xmldata/yahoonews.qml b/examples/declarative/xml/xmldata/yahoonews.qml new file mode 100644 index 0000000..5bab463 --- /dev/null +++ b/examples/declarative/xml/xmldata/yahoonews.qml @@ -0,0 +1,83 @@ +import Qt 4.7 + +Rectangle { + width: 600; height: 600 + + gradient: Gradient { + GradientStop { position: 0; color: "black" } + GradientStop { position: 1.0; color: "#AAAAAA" } + } + + XmlListModel { + id: feedModel + source: "http://rss.news.yahoo.com/rss/oceania" + query: "/rss/channel/item" + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "description"; query: "description/string()" } + } + + Component { + id: feedDelegate + + Item { + id: delegate + height: wrapper.height + 10 + + MouseArea { + anchors.fill: wrapper + onPressed: delegate.ListView.view.currentIndex = index; + onClicked: if (wrapper.state == 'Details') wrapper.state = ''; else wrapper.state = 'Details'; + } + + Rectangle { + id: wrapper + + width: 580; y: 5; height: titleText.height + 10 + color: "#F0F0F0" + radius: 5 + + Text { + id: titleText + x: 10; y: 5 + text: '' + title + '' + font { bold: true; family: "Helvetica"; pointSize: 14 } + + onLinkActivated: { console.log('link clicked: ' + link) } + } + + Text { + id: descriptionText + x: 10; width: 560 + anchors.top: titleText.bottom; anchors.topMargin: 5 + text: description + wrapMode: Text.WordWrap + font.family: "Helvetica" + opacity: 0 + } + + states: State { + name: "Details" + PropertyChanges { target: wrapper; height: childrenRect.height + 10 } + PropertyChanges { target: descriptionText; opacity: 1 } + } + + transitions: Transition { + from: "*"; to: "Details"; reversible: true + SequentialAnimation { + NumberAnimation { duration: 200; properties: "height"; easing.type: Easing.OutQuad } + NumberAnimation { duration: 200; properties: "opacity" } + } + } + } + } + } + + ListView { + id: list + x: 10; y: 10 + width: parent.width - 20; height: parent.height - 20 + model: feedModel + delegate: feedDelegate + } +} diff --git a/examples/declarative/xml/xmlhttprequest/test.qml b/examples/declarative/xml/xmlhttprequest/test.qml new file mode 100644 index 0000000..c7e7e6d --- /dev/null +++ b/examples/declarative/xml/xmlhttprequest/test.qml @@ -0,0 +1,36 @@ +import Qt 4.7 + +Rectangle { + width: 800; height: 600 + + MouseArea { + anchors.fill: parent + + onClicked: { + var doc = new XMLHttpRequest(); + doc.onreadystatechange = function() { + if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { + console.log("Headers -->"); + console.log(doc.getAllResponseHeaders ()); + console.log("Last modified -->"); + console.log(doc.getResponseHeader ("Last-Modified")); + } + else if (doc.readyState == XMLHttpRequest.DONE) { + + var a = doc.responseXML.documentElement; + for (var ii = 0; ii < a.childNodes.length; ++ii) { + console.log(a.childNodes[ii].nodeName); + } + console.log("Headers -->"); + console.log(doc.getAllResponseHeaders ()); + console.log("Last modified -->"); + console.log(doc.getResponseHeader ("Last-Modified")); + + } + } + + doc.open("GET", "test.xml"); + doc.send(); + } + } +} diff --git a/examples/declarative/xml/xmlhttprequest/test.xml b/examples/declarative/xml/xmlhttprequest/test.xml new file mode 100644 index 0000000..8b7f1e1 --- /dev/null +++ b/examples/declarative/xml/xmlhttprequest/test.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject b/examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml deleted file mode 100644 index 480b13c..0000000 --- a/examples/declarative/xmldata/daringfireball.qml +++ /dev/null @@ -1,47 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 600; height: 600 - - XmlListModel { - id: feedModel - source: "http://daringfireball.net/index.xml" - query: "/feed/entry" - namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "tagline"; query: "author/name/string()" } - XmlRole { name: "content"; query: "content/string()" } - } - - Component { - id: feedDelegate - Item { - height: childrenRect.height + 20 - Text { - id: titleText - x: 10 - text: title; font.bold: true - } - Text { - anchors { left: titleText.right; leftMargin: 10 } - text: 'by ' + tagline - font.italic: true - } - Text { - x: 10 - width: 580 - anchors.top: titleText.bottom - text: content - wrapMode: Text.WordWrap - - onLinkActivated: { console.log('link clicked: ' + link) } - } - } - } - - ListView { - anchors.fill: parent - model: feedModel - delegate: feedDelegate - } -} diff --git a/examples/declarative/xmldata/xmldata.qmlproject b/examples/declarative/xmldata/xmldata.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/xmldata/xmldata.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml deleted file mode 100644 index 5bab463..0000000 --- a/examples/declarative/xmldata/yahoonews.qml +++ /dev/null @@ -1,83 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 600; height: 600 - - gradient: Gradient { - GradientStop { position: 0; color: "black" } - GradientStop { position: 1.0; color: "#AAAAAA" } - } - - XmlListModel { - id: feedModel - source: "http://rss.news.yahoo.com/rss/oceania" - query: "/rss/channel/item" - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "link"; query: "link/string()" } - XmlRole { name: "description"; query: "description/string()" } - } - - Component { - id: feedDelegate - - Item { - id: delegate - height: wrapper.height + 10 - - MouseArea { - anchors.fill: wrapper - onPressed: delegate.ListView.view.currentIndex = index; - onClicked: if (wrapper.state == 'Details') wrapper.state = ''; else wrapper.state = 'Details'; - } - - Rectangle { - id: wrapper - - width: 580; y: 5; height: titleText.height + 10 - color: "#F0F0F0" - radius: 5 - - Text { - id: titleText - x: 10; y: 5 - text: '' + title + '' - font { bold: true; family: "Helvetica"; pointSize: 14 } - - onLinkActivated: { console.log('link clicked: ' + link) } - } - - Text { - id: descriptionText - x: 10; width: 560 - anchors.top: titleText.bottom; anchors.topMargin: 5 - text: description - wrapMode: Text.WordWrap - font.family: "Helvetica" - opacity: 0 - } - - states: State { - name: "Details" - PropertyChanges { target: wrapper; height: childrenRect.height + 10 } - PropertyChanges { target: descriptionText; opacity: 1 } - } - - transitions: Transition { - from: "*"; to: "Details"; reversible: true - SequentialAnimation { - NumberAnimation { duration: 200; properties: "height"; easing.type: Easing.OutQuad } - NumberAnimation { duration: 200; properties: "opacity" } - } - } - } - } - } - - ListView { - id: list - x: 10; y: 10 - width: parent.width - 20; height: parent.height - 20 - model: feedModel - delegate: feedDelegate - } -} diff --git a/examples/declarative/xmlhttprequest/test.qml b/examples/declarative/xmlhttprequest/test.qml deleted file mode 100644 index c7e7e6d..0000000 --- a/examples/declarative/xmlhttprequest/test.qml +++ /dev/null @@ -1,36 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 800; height: 600 - - MouseArea { - anchors.fill: parent - - onClicked: { - var doc = new XMLHttpRequest(); - doc.onreadystatechange = function() { - if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - console.log("Headers -->"); - console.log(doc.getAllResponseHeaders ()); - console.log("Last modified -->"); - console.log(doc.getResponseHeader ("Last-Modified")); - } - else if (doc.readyState == XMLHttpRequest.DONE) { - - var a = doc.responseXML.documentElement; - for (var ii = 0; ii < a.childNodes.length; ++ii) { - console.log(a.childNodes[ii].nodeName); - } - console.log("Headers -->"); - console.log(doc.getAllResponseHeaders ()); - console.log("Last modified -->"); - console.log(doc.getResponseHeader ("Last-Modified")); - - } - } - - doc.open("GET", "test.xml"); - doc.send(); - } - } -} diff --git a/examples/declarative/xmlhttprequest/test.xml b/examples/declarative/xmlhttprequest/test.xml deleted file mode 100644 index 8b7f1e1..0000000 --- a/examples/declarative/xmlhttprequest/test.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/examples/declarative/xmlhttprequest/xmlhttprequest.qmlproject b/examples/declarative/xmlhttprequest/xmlhttprequest.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/xmlhttprequest/xmlhttprequest.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 018bd55..229e15b 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -70,11 +70,11 @@ QT_BEGIN_NAMESPACE \endlist Examples: - \snippet snippets/declarative/border-image.qml 0 + \snippet snippets/declarative/borderimage.qml 0 \image BorderImage.png - The \l{declarative/border-image}{BorderImage example} shows how a BorderImage can be used to simulate a shadow effect on a + The \l{declarative/imageelements/borderimage}{BorderImage example} shows how a BorderImage can be used to simulate a shadow effect on a rectangular item. */ diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index a03a51d..3c0f5a2 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -418,7 +418,7 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() \dots 4 \snippet doc/src/snippets/declarative/flickableScrollbar.qml 1 - \sa {declarative/scrollbar}{scrollbar example} + \sa {declarative/ui-components/scrollbar}{scrollbar example} */ QDeclarativeFlickable::QDeclarativeFlickable(QDeclarativeItem *parent) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 46e9ce3..b71bb7e 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1908,7 +1908,7 @@ void QDeclarativeListView::setCacheBuffer(int b) pet. The section expression is the size property. If \c ListView.section and \c ListView.prevSection differ, the item will display a section header. - \snippet examples/declarative/listview/sections.qml 0 + \snippet examples/declarative/modelviews/listview/sections.qml 0 \image ListViewSections.png */ diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 2c89abd..79f8a17 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -562,9 +562,9 @@ QNetworkAccessManager *QDeclarativeEngine::networkAccessManager() const This example creates a provider with id \e colors: - \snippet examples/declarative/imageprovider/imageprovider.cpp 0 + \snippet examples/declarative/cppextensions/imageprovider/imageprovider.cpp 0 - \snippet examples/declarative/imageprovider/imageprovider-example.qml 0 + \snippet examples/declarative/cppextensions/imageprovider/imageprovider-example.qml 0 \sa removeImageProvider() */ diff --git a/src/declarative/qml/qdeclarativeextensionplugin.cpp b/src/declarative/qml/qdeclarativeextensionplugin.cpp index 2c15385..c2e8300 100644 --- a/src/declarative/qml/qdeclarativeextensionplugin.cpp +++ b/src/declarative/qml/qdeclarativeextensionplugin.cpp @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE See \l {Tutorial: Writing QML extensions with C++} for details on creating QML extensions, including how to build a plugin with with QDeclarativeExtensionPlugin. - For a simple overview, see the \l{declarative/plugins}{plugins} example. + For a simple overview, see the \l{declarative/cppextensions/plugins}{plugins} example. Also see \l {How to Create Qt Plugins} for general Qt plugin documentation. diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index a8e1be8..6223548 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -207,11 +207,11 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM Here is an example that uses WorkerScript to periodically append the current time to a list model: - \snippet examples/declarative/listmodel-threaded/timedisplay.qml 0 + \snippet examples/declarative/threading/threadedlistmodel/timedisplay.qml 0 The included file, \tt dataloader.js, looks like this: - \snippet examples/declarative/listmodel-threaded/dataloader.js 0 + \snippet examples/declarative/threading/threadedlistmodel/dataloader.js 0 The application's \tt Timer object periodically sends a message to the worker script by calling \tt WorkerScript::sendMessage(). When this message diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp index 20e9907..9617b86 100644 --- a/src/declarative/util/qdeclarativepackage.cpp +++ b/src/declarative/util/qdeclarativepackage.cpp @@ -62,13 +62,13 @@ QT_BEGIN_NAMESPACE delegate it should appear in. This allows an item to move between views. - \snippet examples/declarative/package/Delegate.qml 0 + \snippet examples/declarative/modelviews/package/Delegate.qml 0 These named items are used as the delegates by the two views who reference the special VisualDataModel.parts property to select a model which provides the chosen delegate. - \snippet examples/declarative/package/view.qml 0 + \snippet examples/declarative/modelviews/package/view.qml 0 \sa QtDeclarative */ diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index f1a00989..4a374a5 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -536,7 +536,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty Date: Mon, 17 May 2010 10:35:45 +1000 Subject: Add missing .pro --- .../declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.pro | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.pro diff --git a/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.pro b/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.pro new file mode 100644 index 0000000..d92a6f4 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + graphicsLayouts \ + layoutItem -- cgit v0.12 From f6853d6f8521a057721a943929c96904cdb6f0c6 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 17 May 2010 11:17:27 +1000 Subject: Add \brief to TextInput --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index afbaaac..b00f724 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE /*! \qmlclass TextInput QDeclarativeTextInput \since 4.7 - The TextInput item allows you to add an editable line of text to a scene. + \brief The TextInput item allows you to add an editable line of text to a scene. TextInput can only display a single line of text, and can only display plain text. However it can provide addition input constraints on the text. -- cgit v0.12 From 029f98ee0176b34279e7cc944cca17f027fe5a0a Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 17 May 2010 11:26:51 +1000 Subject: ListModel::get() shouldn't print warnings for invalid indices since it returns undefined items for these cases anywyay. --- src/declarative/util/qdeclarativelistmodel.cpp | 5 +---- .../qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp | 14 ++++---------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 6223548..9a5c9de 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -537,10 +537,7 @@ void QDeclarativeListModel::append(const QScriptValue& valuemap) */ QScriptValue QDeclarativeListModel::get(int index) const { - // the internal flat/nested class takes care of return value for bad index - if (index >= count() || index < 0) - qmlInfo(this) << tr("get: index %1 out of range").arg(index); - + // the internal flat/nested class checks for bad index return m_flat ? m_flat->get(index) : m_nested->get(index); } diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index aed4781..26a12f0 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -184,8 +184,8 @@ void tst_qdeclarativelistmodel::dynamic_data() QTest::newRow("count") << "count" << 0 << ""; - QTest::newRow("get1") << "{get(0)}" << 0 << ": QML ListModel: get: index 0 out of range"; - QTest::newRow("get2") << "{get(-1)}" << 0 << ": QML ListModel: get: index -1 out of range"; + QTest::newRow("get1") << "{get(0)}" << 0 << ""; + QTest::newRow("get2") << "{get(-1)}" << 0 << ""; QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << ""; QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << ""; @@ -196,13 +196,13 @@ void tst_qdeclarativelistmodel::dynamic_data() QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << ""; QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << ""; - QTest::newRow("clear3") << "{append({'foo':123});clear();get(0).foo}" << 0 << ": QML ListModel: get: index 0 out of range"; + QTest::newRow("clear3") << "{append({'foo':123});clear()}" << 0 << ""; QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << ""; QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << ""; QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << ""; QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << ""; - QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << ": QML ListModel: get: index 0 out of range"; + QTest::newRow("remove3") << "{append({'foo':123});remove(0)}" << 0 << ""; QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << ": QML ListModel: remove: index -1 out of range"; QTest::newRow("remove4a") << "{remove(0)}" << 0 << ": QML ListModel: remove: index 0 out of range"; QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << ": QML ListModel: remove: index 0 out of range"; @@ -328,12 +328,6 @@ void tst_qdeclarativelistmodel::dynamic_worker() if (QByteArray(QTest::currentDataTag()).startsWith("nested")) QTest::ignoreMessage(QtWarningMsg, ": QML ListModel: Cannot add nested list values when modifying or after modification from a worker script"); - if (QByteArray(QTest::currentDataTag()).startsWith("nested-append")) { - int callsToGet = script.count(QLatin1String(";get(")); - for (int i=0; i: QML ListModel: get: index 0 out of range"); - } - QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, operations.mid(0, operations.length()-1)))); waitForWorker(item); -- cgit v0.12 From cef452a2792cc15705f677c9b9c689496eeb500f Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 17 May 2010 13:14:18 +1000 Subject: Don't crash due to recursive positioning. Also extend positioner anchor check to include fill and centerIn. Task-number: QTBUG-10731 --- .../graphicsitems/qdeclarativepositioners.cpp | 60 +++++++++++++--------- .../graphicsitems/qdeclarativepositioners_p_p.h | 5 +- .../tst_qdeclarativepositioners.cpp | 27 +++++++++- 3 files changed, 65 insertions(+), 27 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 93bff3e..8796e63 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -204,7 +204,11 @@ void QDeclarativeBasePositioner::prePositioning() if (!isComponentComplete()) return; + if (d->doingPositioning) + return; + d->queuedPositioning = false; + d->doingPositioning = true; //Need to order children by creation order modified by stacking order QList children = d->QGraphicsItemPrivate::children; qSort(children.begin(), children.end(), d->insertionOrder); @@ -242,6 +246,7 @@ void QDeclarativeBasePositioner::prePositioning() doPositioning(&contentSize); if(d->addTransition || d->moveTransition) finishApplyTransitions(); + d->doingPositioning = false; //Set implicit size to the size of its children setImplicitHeight(contentSize.height()); setImplicitWidth(contentSize.width()); @@ -339,7 +344,8 @@ Column { Note that the positioner assumes that the x and y positions of its children will not change. If you manually change the x or y properties in script, bind - the x or y properties, or use anchors on a child of a positioner, then the + the x or y properties, use anchors on a child of a positioner, or have the + height of a child depend on the position of a child, then the positioner may exhibit strange behaviour. */ @@ -437,7 +443,7 @@ void QDeclarativeColumn::doPositioning(QSizeF *contentSize) void QDeclarativeColumn::reportConflictingAnchors() { - bool childsWithConflictingAnchors(false); + QDeclarativeBasePositionerPrivate *d = static_cast(QDeclarativeBasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item) { @@ -446,15 +452,16 @@ void QDeclarativeColumn::reportConflictingAnchors() QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors(); if (usedAnchors & QDeclarativeAnchors::TopAnchor || usedAnchors & QDeclarativeAnchors::BottomAnchor || - usedAnchors & QDeclarativeAnchors::VCenterAnchor) { - childsWithConflictingAnchors = true; + usedAnchors & QDeclarativeAnchors::VCenterAnchor || + anchors->fill() || anchors->centerIn()) { + d->anchorConflict = true; break; } } } } - if (childsWithConflictingAnchors) { - qmlInfo(this) << "Cannot specify top, bottom or verticalCenter anchors for items inside Column"; + if (d->anchorConflict) { + qmlInfo(this) << "Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column"; } } @@ -486,7 +493,8 @@ Row { Note that the positioner assumes that the x and y positions of its children will not change. If you manually change the x or y properties in script, bind - the x or y properties, or use anchors on a child of a positioner, then the + the x or y properties, use anchors on a child of a positioner, or have the + width of a child depend on the position of a child, then the positioner may exhibit strange behaviour. */ @@ -574,7 +582,7 @@ void QDeclarativeRow::doPositioning(QSizeF *contentSize) void QDeclarativeRow::reportConflictingAnchors() { - bool childsWithConflictingAnchors(false); + QDeclarativeBasePositionerPrivate *d = static_cast(QDeclarativeBasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item) { @@ -583,16 +591,16 @@ void QDeclarativeRow::reportConflictingAnchors() QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors(); if (usedAnchors & QDeclarativeAnchors::LeftAnchor || usedAnchors & QDeclarativeAnchors::RightAnchor || - usedAnchors & QDeclarativeAnchors::HCenterAnchor) { - childsWithConflictingAnchors = true; + usedAnchors & QDeclarativeAnchors::HCenterAnchor || + anchors->fill() || anchors->centerIn()) { + d->anchorConflict = true; break; } } } } - if (childsWithConflictingAnchors) { - qmlInfo(this) << "Cannot specify left, right or horizontalCenter anchors for items inside Row"; - } + if (d->anchorConflict) + qmlInfo(this) << "Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row"; } /*! @@ -638,7 +646,8 @@ Grid { Note that the positioner assumes that the x and y positions of its children will not change. If you manually change the x or y properties in script, bind - the x or y properties, or use anchors on a child of a positioner, then the + the x or y properties, use anchors on a child of a positioner, or have the + width or height of a child depend on the position of a child, then the positioner may exhibit strange behaviour. */ /*! @@ -866,20 +875,19 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize) void QDeclarativeGrid::reportConflictingAnchors() { - bool childsWithConflictingAnchors(false); + QDeclarativeBasePositionerPrivate *d = static_cast(QDeclarativeBasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item) { QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors; - if (anchors && anchors->usedAnchors()) { - childsWithConflictingAnchors = true; + if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) { + d->anchorConflict = true; break; } } } - if (childsWithConflictingAnchors) { + if (d->anchorConflict) qmlInfo(this) << "Cannot specify anchors for items inside Grid"; - } } /*! @@ -888,6 +896,11 @@ void QDeclarativeGrid::reportConflictingAnchors() \brief The Flow item lines up its children side by side, wrapping as necessary. \inherits Item + Note that the positioner assumes that the x and y positions of its children + will not change. If you manually change the x or y properties in script, bind + the x or y properties, use anchors on a child of a positioner, or have the + width or height of a child depend on the position of a child, then the + positioner may exhibit strange behaviour. */ /*! @@ -1026,20 +1039,19 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize) void QDeclarativeFlow::reportConflictingAnchors() { - bool childsWithConflictingAnchors(false); + Q_D(QDeclarativeFlow); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item) { QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors; - if (anchors && anchors->usedAnchors()) { - childsWithConflictingAnchors = true; + if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) { + d->anchorConflict = true; break; } } } - if (childsWithConflictingAnchors) { + if (d->anchorConflict) qmlInfo(this) << "Cannot specify anchors for items inside Flow"; - } } QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h index 576f35b..04f0181 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h @@ -75,6 +75,7 @@ public: QDeclarativeBasePositionerPrivate() : spacing(0), type(QDeclarativeBasePositioner::None) , moveTransition(0), addTransition(0), queuedPositioning(false) + , doingPositioning(false), anchorConflict(false) { } @@ -95,7 +96,9 @@ public: void watchChanges(QDeclarativeItem *other); void unwatchChanges(QDeclarativeItem* other); - bool queuedPositioning; + bool queuedPositioning : 1; + bool doingPositioning : 1; + bool anchorConflict : 1; virtual void itemSiblingOrderChanged(QDeclarativeItem* other) { diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 7a23773..e639014 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -687,7 +687,13 @@ void tst_QDeclarativePositioners::test_conflictinganchors() component.setData("import Qt 4.7\nColumn { Item { anchors.top: parent.top } }", QUrl::fromLocalFile("")); item = qobject_cast(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom or verticalCenter anchors for items inside Column")); + QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nColumn { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column")); warningMessage.clear(); component.setData("import Qt 4.7\nColumn { Item { anchors.left: parent.left } }", QUrl::fromLocalFile("")); @@ -699,7 +705,13 @@ void tst_QDeclarativePositioners::test_conflictinganchors() component.setData("import Qt 4.7\nRow { Item { anchors.left: parent.left } }", QUrl::fromLocalFile("")); item = qobject_cast(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right or horizontalCenter anchors for items inside Row")); + QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nRow { Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row")); warningMessage.clear(); component.setData("import Qt 4.7\nRow { Item { anchors.top: parent.top } }", QUrl::fromLocalFile("")); @@ -714,10 +726,21 @@ void tst_QDeclarativePositioners::test_conflictinganchors() QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid")); warningMessage.clear(); + component.setData("import Qt 4.7\nGrid { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid")); + warningMessage.clear(); + component.setData("import Qt 4.7\nFlow { Item { anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile("")); item = qobject_cast(component.create()); QVERIFY(item); QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow")); + + component.setData("import Qt 4.7\nFlow { Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow")); } QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename) -- cgit v0.12 From fd0b25da6997553bb95ea91bbdd509fa35711b9d Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 17 May 2010 13:36:35 +1000 Subject: Fix doc for status, add Image::onLoaded. statusChanged is NOT emitted for local files, nor should it be (they are loaded synchronously, so status is *initially* Ready). Add onLoaded signal that *is* emitted. Reviewed-by: Michael Brasser --- .../graphicsitems/qdeclarativeloader.cpp | 22 ++++++++++++++++++++-- .../graphicsitems/qdeclarativeloader_p.h | 3 +++ .../qdeclarativeloader/tst_qdeclarativeloader.cpp | 9 ++++++--- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 7edd53c..cbdfd87 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -321,6 +321,7 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() emit q->statusChanged(); emit q->progressChanged(); emit q->itemChanged(); + emit q->loaded(); } } @@ -341,10 +342,13 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() of the following ways: \list \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: loader.status = Loader.Ready;} - \o Do something inside the onStatusChanged signal handler, e.g. Loader{id: loader; onStatusChanged: if(loader.status == Loader.Ready) console.log('Loaded');} + \o Do something inside the onLoaded signal handler, e.g. Loader{id: loader; onLoaded: console.log('Loaded');} \o Bind to the status variable somewhere, e.g. Text{text: if(loader.status!=Loader.Ready){'Not Loaded';}else{'Loaded';}} \endlist \sa progress + + Note that if the source is a local file, the status will initially be Ready (or Error). While + there will be no onStatusChanged signal in that case, the onLoaded will still be invoked. */ QDeclarativeLoader::Status QDeclarativeLoader::status() const @@ -360,6 +364,21 @@ QDeclarativeLoader::Status QDeclarativeLoader::status() const return d->source.isEmpty() ? Null : Error; } +void QDeclarativeLoader::componentComplete() +{ + if (status() == Ready) + emit loaded(); +} + + +/*! + \qmlsignal Loader::onLoaded() + + This handler is called when the \l status becomes Loader.Ready, or on successful + initial load. +*/ + + /*! \qmlproperty real Loader::progress @@ -382,7 +401,6 @@ qreal QDeclarativeLoader::progress() const return 0.0; } - void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged) { Q_Q(QDeclarativeLoader); diff --git a/src/declarative/graphicsitems/qdeclarativeloader_p.h b/src/declarative/graphicsitems/qdeclarativeloader_p.h index 49dfa11..ec7ffe9 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader_p.h +++ b/src/declarative/graphicsitems/qdeclarativeloader_p.h @@ -84,11 +84,14 @@ Q_SIGNALS: void sourceChanged(); void statusChanged(); void progressChanged(); + void loaded(); protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); QVariant itemChange(GraphicsItemChange change, const QVariant &value); bool eventFilter(QObject *watched, QEvent *e); + void componentComplete(); + private: Q_DISABLE_COPY(QDeclarativeLoader) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeLoader) diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index b56ff13..59580ea 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -104,13 +104,14 @@ tst_QDeclarativeLoader::tst_QDeclarativeLoader() void tst_QDeclarativeLoader::url() { QDeclarativeComponent component(&engine); - component.setData(QByteArray("import Qt 4.7\nLoader { source: \"Rect120x60.qml\" }"), TEST_FILE("")); + component.setData(QByteArray("import Qt 4.7\nLoader { property int did_load: 0; onLoaded: did_load=123; source: \"Rect120x60.qml\" }"), TEST_FILE("")); QDeclarativeLoader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); QVERIFY(loader->item()); QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml")); QCOMPARE(loader->progress(), 1.0); QCOMPARE(loader->status(), QDeclarativeLoader::Ready); + QCOMPARE(loader->property("did_load").toInt(), 123); QCOMPARE(static_cast(loader)->children().count(), 1); delete loader; @@ -427,7 +428,7 @@ void tst_QDeclarativeLoader::networkRequestUrl() server.serveDirectory(SRCDIR "/data"); QDeclarativeComponent component(&engine); - component.setData(QByteArray("import Qt 4.7\nLoader { source: \"http://127.0.0.1:14450/Rect120x60.qml\" }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml")); + component.setData(QByteArray("import Qt 4.7\nLoader { property int did_load : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: did_load=123 }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml")); if (component.isError()) qDebug() << component.errors(); QDeclarativeLoader *loader = qobject_cast(component.create()); @@ -437,6 +438,7 @@ void tst_QDeclarativeLoader::networkRequestUrl() QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->property("did_load").toInt(), 123); QCOMPARE(static_cast(loader)->children().count(), 1); delete loader; @@ -483,7 +485,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() QTest::ignoreMessage(QtWarningMsg, ": Network error for URL http://127.0.0.1:14450/IDontExist.qml"); QDeclarativeComponent component(&engine); - component.setData(QByteArray("import Qt 4.7\nLoader { source: \"http://127.0.0.1:14450/IDontExist.qml\" }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml")); + component.setData(QByteArray("import Qt 4.7\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml")); QDeclarativeLoader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); @@ -491,6 +493,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() QVERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); + QCOMPARE(loader->property("did_load").toInt(), 123); QCOMPARE(static_cast(loader)->children().count(), 0); delete loader; -- cgit v0.12 From a0c9a0feebb571e339c0ea886996f543d2d8c752 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 17 May 2010 14:44:25 +1000 Subject: Add focus docs snippets --- doc/src/declarative/focus.qdoc | 23 +---------------------- doc/src/snippets/declarative/focusscopes.qml | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 doc/src/snippets/declarative/focusscopes.qml diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index e5c1d32..e2b8bb6 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -291,28 +291,7 @@ print the name of the current list item. \table \row -\o \code -Rectangle { - color: "lightsteelblue"; width: 240; height: 320 - - ListView { - id: myView; anchors.fill: parent; focus: true - model: ListModel { - ListElement { name: "Bob" } - ListElement { name: "John" } - ListElement { name: "Michael" } - } - delegate: FocusScope { - width: contents.width; height: contents.height - Text { - focus: true - text: name - Keys.onReturnPressed: console.log(name) - } - } - } -} -\endcode +\o \snippet doc/src/snippets/declarative/focusscopes.qml 0 \o \image declarative-qmlfocus4.png \endtable diff --git a/doc/src/snippets/declarative/focusscopes.qml b/doc/src/snippets/declarative/focusscopes.qml new file mode 100644 index 0000000..686de29 --- /dev/null +++ b/doc/src/snippets/declarative/focusscopes.qml @@ -0,0 +1,27 @@ +import Qt 4.7 + +//![0] +Rectangle { + color: "lightsteelblue"; width: 240; height: 320 + + ListView { + anchors.fill: parent + focus: true + + model: ListModel { + ListElement { name: "Bob" } + ListElement { name: "John" } + ListElement { name: "Michael" } + } + + delegate: FocusScope { + width: childrenRect.width; height: childrenRect.height + TextInput { + focus: true + text: name + Keys.onReturnPressed: console.log(name) + } + } + } + } +//![0] -- cgit v0.12 From 7a738662838763e4828c6ac8957a2823b095f566 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 17 May 2010 14:44:51 +1000 Subject: Focus should be applied to focus scopes all the way up the chain, not just to the closest focus scope parent. --- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 4 +--- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 7f71dd2..45b79a7 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -906,10 +906,8 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) if (d->focusOnPress){ QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope? while(p) { - if(p->flags() & QGraphicsItem::ItemIsFocusScope){ + if (p->flags() & QGraphicsItem::ItemIsFocusScope) p->setFocus(); - break; - } p = p->parentItem(); } setFocus(true); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index db480b1..8aa7e99 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -889,10 +889,8 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) if(d->focusOnPress){ QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope? while(p) { - if(p->flags() & QGraphicsItem::ItemIsFocusScope){ + if (p->flags() & QGraphicsItem::ItemIsFocusScope) p->setFocus(); - break; - } p = p->parentItem(); } setFocus(true); -- cgit v0.12 From 58c08b1195add26e2ff96844885ea9d6c124da30 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 17 May 2010 16:22:43 +1000 Subject: Check for acquireReg() failure QTBUG-10696 --- .../qml/qdeclarativecompiledbindings.cpp | 27 ++++++++++++++++++++++ .../qdeclarativeecmascript/data/qtbug_10696.qml | 26 +++++++++++++++++++++ .../tst_qdeclarativeecmascript.cpp | 9 ++++++++ 3 files changed, 62 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp index 05b7dc6..f55d330 100644 --- a/src/declarative/qml/qdeclarativecompiledbindings.cpp +++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp @@ -1624,6 +1624,8 @@ bool QDeclarativeBindingCompilerPrivate::compile(QDeclarativeJS::AST::Node *node return false; int convertReg = acquireReg(); + if (convertReg == -1) + return false; if (destination->type == QMetaType::QReal) { Instr convert; @@ -2011,6 +2013,8 @@ bool QDeclarativeBindingCompilerPrivate::parseArith(QDeclarativeJS::AST::Node *n AST::BinaryExpression *expression = static_cast(node); type.reg = acquireReg(); + if (type.reg == -1) + return false; Result lhs; Result rhs; @@ -2062,6 +2066,8 @@ bool QDeclarativeBindingCompilerPrivate::numberArith(Result &type, const Result return false; lhsTmp = acquireReg(); + if (lhsTmp == -1) + return false; Instr conv; conv.common.type = Instr::ConvertGenericToReal; @@ -2075,6 +2081,8 @@ bool QDeclarativeBindingCompilerPrivate::numberArith(Result &type, const Result return false; rhsTmp = acquireReg(); + if (rhsTmp == -1) + return false; Instr conv; conv.common.type = Instr::ConvertGenericToReal; @@ -2123,6 +2131,8 @@ bool QDeclarativeBindingCompilerPrivate::stringArith(Result &type, const Result return false; lhsTmp = acquireReg(Instr::CleanupString); + if (lhsTmp == -1) + return false; Instr convert; convert.common.type = Instr::ConvertGenericToString; @@ -2136,6 +2146,8 @@ bool QDeclarativeBindingCompilerPrivate::stringArith(Result &type, const Result return false; rhsTmp = acquireReg(Instr::CleanupString); + if (rhsTmp == -1) + return false; Instr convert; convert.common.type = Instr::ConvertGenericToString; @@ -2145,6 +2157,9 @@ bool QDeclarativeBindingCompilerPrivate::stringArith(Result &type, const Result } type.reg = acquireReg(Instr::CleanupString); + if (type.reg == -1) + return false; + type.type = QMetaType::QString; Instr add; @@ -2185,6 +2200,9 @@ bool QDeclarativeBindingCompilerPrivate::parseLogic(QDeclarativeJS::AST::Node *n if (!parseExpression(expression->right, rhs)) return false; type.reg = acquireReg(); + if (type.reg == -1) + return false; + type.metaObject = 0; type.type = QVariant::Bool; @@ -2310,6 +2328,8 @@ bool QDeclarativeBindingCompilerPrivate::parseConstant(QDeclarativeJS::AST::Node type.metaObject = 0; type.type = -1; type.reg = acquireReg(); + if (type.reg == -1) + return false; if (node->kind == AST::Node::Kind_TrueLiteral) { type.type = QVariant::Bool; @@ -2398,6 +2418,9 @@ bool QDeclarativeBindingCompilerPrivate::parseMethod(QDeclarativeJS::AST::Node * releaseReg(r1.reg); op.binaryop.output = acquireReg(); + if (op.binaryop.output == -1) + return false; + op.binaryop.src1 = r0.reg; op.binaryop.src2 = r1.reg; bytecode << op; @@ -2473,6 +2496,8 @@ bool QDeclarativeBindingCompilerPrivate::fetch(Result &rv, const QMetaObject *mo if (rv.type == QMetaType::QString) { int tmp = acquireReg(); + if (tmp == -1) + return false; Instr copy; copy.common.type = Instr::Copy; copy.copy.reg = tmp; @@ -2549,6 +2574,8 @@ int QDeclarativeBindingCompilerPrivate::registerLiteralString(const QString &str data += strdata; int reg = acquireReg(Instr::CleanupString); + if (reg == -1) + return false; Instr string; string.common.type = Instr::String; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml new file mode 100644 index 0000000..cb5c4c9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml @@ -0,0 +1,26 @@ +import Qt 4.7 + +QtObject { + property string test: "aaaa" + + "bbbb" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc"; +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index b8faa7c..64e5b3f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -149,6 +149,7 @@ private slots: void functionAssignment(); void eval(); void function(); + void qtbug_10696(); void include(); @@ -2472,6 +2473,14 @@ void tst_qdeclarativeecmascript::include() } } +void tst_qdeclarativeecmascript::qtbug_10696() +{ + QDeclarativeComponent component(&engine, TEST_FILE("qtbug_10696.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + delete o; +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" -- cgit v0.12 From 5227833d76ee072ab7497b790e8058fc79ea8826 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 17 May 2010 16:37:32 +1000 Subject: Fix examples autotest when compiled without webkit or xmlpatterns --- tests/auto/declarative/examples/tst_examples.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 1044035..605345e 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -82,12 +82,12 @@ tst_examples::tst_examples() // Add directories you want excluded here #ifdef QT_NO_WEBKIT - excludedDirs << "examples/declarative/webview"; + excludedDirs << "examples/declarative/modelviews/webview"; excludedDirs << "demos/declarative/webbrowser"; #endif #ifdef QT_NO_XMLPATTERNS - excludedDirs << "examples/declarative/xmldata"; + excludedDirs << "examples/declarative/xml/xmldata"; excludedDirs << "demos/declarative/twitter"; excludedDirs << "demos/declarative/flickr"; excludedDirs << "demos/declarative/photoviewer"; -- cgit v0.12 From 45fe1dd88afb7b82c5fb39bfc4c70bcf16e5c0ea Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 17 May 2010 16:47:02 +1000 Subject: Don't call pure virtual method in ~QDeclarativeAbstractBinding() --- src/declarative/qml/qdeclarativebinding.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 8043ea9..3e729c2 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -286,7 +286,7 @@ QDeclarativeAbstractBinding::QDeclarativeAbstractBinding() QDeclarativeAbstractBinding::~QDeclarativeAbstractBinding() { - removeFromObject(); + Q_ASSERT(m_prevBinding == 0); if (m_mePtr) *m_mePtr = 0; } -- cgit v0.12 From ca4f1b71faf0113f5030902ee03a39c169847526 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 17 May 2010 16:55:11 +1000 Subject: Restructure QDeclarativeAbstractBinding destructor --- src/declarative/qml/qdeclarativebinding.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 3e729c2..2e905b9 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -287,12 +287,14 @@ QDeclarativeAbstractBinding::QDeclarativeAbstractBinding() QDeclarativeAbstractBinding::~QDeclarativeAbstractBinding() { Q_ASSERT(m_prevBinding == 0); - if (m_mePtr) - *m_mePtr = 0; + Q_ASSERT(m_mePtr == 0); } void QDeclarativeAbstractBinding::destroy() { + removeFromObject(); + clear(); + delete this; } -- cgit v0.12 From 9663e257f28a89f26952f5d3822a343bfe12ee6e Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 17 May 2010 17:03:13 +1000 Subject: Move Q_ENUMS to start of class declaration --- src/declarative/graphicsitems/qdeclarativegridview_p.h | 4 ++-- src/declarative/graphicsitems/qdeclarativelistview_p.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h index f5d061d..2bf154c 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview_p.h +++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h @@ -82,6 +82,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeGridView : public QDeclarativeFlickable Q_ENUMS(HighlightRangeMode) Q_ENUMS(SnapMode) + Q_ENUMS(Flow) + Q_ENUMS(PositionMode) Q_CLASSINFO("DefaultProperty", "data") public: @@ -120,7 +122,6 @@ public: qreal preferredHighlightEnd() const; void setPreferredHighlightEnd(qreal); - Q_ENUMS(Flow) enum Flow { LeftToRight, TopToBottom }; Flow flow() const; void setFlow(Flow); @@ -142,7 +143,6 @@ public: void setSnapMode(SnapMode mode); enum PositionMode { Beginning, Center, End, Visible, Contain }; - Q_ENUMS(PositionMode) Q_INVOKABLE void positionViewAtIndex(int index, int mode); Q_INVOKABLE int indexAt(int x, int y) const; diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h index 051455c..d6e8023 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview_p.h +++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h @@ -124,6 +124,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeListView : public QDeclarativeFlickable Q_ENUMS(HighlightRangeMode) Q_ENUMS(Orientation) Q_ENUMS(SnapMode) + Q_ENUMS(PositionMode) Q_CLASSINFO("DefaultProperty", "data") public: @@ -200,7 +201,6 @@ public: static QDeclarativeListViewAttached *qmlAttachedProperties(QObject *); enum PositionMode { Beginning, Center, End, Visible, Contain }; - Q_ENUMS(PositionMode) Q_INVOKABLE void positionViewAtIndex(int index, int mode); Q_INVOKABLE int indexAt(int x, int y) const; -- cgit v0.12 From 1db36a5a37dcca0e24ada3c852f2647ab2330eee Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 17 May 2010 16:45:35 +1000 Subject: Move xmldata example into rssnews demo. --- .../declarative/rssnews/content/BusyIndicator.qml | 12 +++ .../rssnews/content/CategoryDelegate.qml | 41 ++++++++++ demos/declarative/rssnews/content/NewsDelegate.qml | 29 +++++++ demos/declarative/rssnews/content/RssFeeds.qml | 18 +++++ demos/declarative/rssnews/content/ScrollBar.qml | 66 ++++++++++++++++ demos/declarative/rssnews/content/images/busy.png | Bin 0 -> 2629 bytes .../rssnews/content/images/scrollbar.png | Bin 0 -> 161 bytes demos/declarative/rssnews/rssnews.qml | 52 +++++++++++++ .../declarative/xml/xmldata/daringfireball.qml | 47 ------------ .../declarative/xml/xmldata/xmldata.qmlproject | 16 ---- examples/declarative/xml/xmldata/yahoonews.qml | 83 --------------------- 11 files changed, 218 insertions(+), 146 deletions(-) create mode 100644 demos/declarative/rssnews/content/BusyIndicator.qml create mode 100644 demos/declarative/rssnews/content/CategoryDelegate.qml create mode 100644 demos/declarative/rssnews/content/NewsDelegate.qml create mode 100644 demos/declarative/rssnews/content/RssFeeds.qml create mode 100644 demos/declarative/rssnews/content/ScrollBar.qml create mode 100644 demos/declarative/rssnews/content/images/busy.png create mode 100644 demos/declarative/rssnews/content/images/scrollbar.png create mode 100644 demos/declarative/rssnews/rssnews.qml delete mode 100644 examples/declarative/xml/xmldata/daringfireball.qml delete mode 100644 examples/declarative/xml/xmldata/xmldata.qmlproject delete mode 100644 examples/declarative/xml/xmldata/yahoonews.qml diff --git a/demos/declarative/rssnews/content/BusyIndicator.qml b/demos/declarative/rssnews/content/BusyIndicator.qml new file mode 100644 index 0000000..4be59a8 --- /dev/null +++ b/demos/declarative/rssnews/content/BusyIndicator.qml @@ -0,0 +1,12 @@ +import Qt 4.7 + +Image { + id: container + property bool on: false + + source: "images/busy.png"; visible: container.on + + NumberAnimation on rotation { + running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 + } +} diff --git a/demos/declarative/rssnews/content/CategoryDelegate.qml b/demos/declarative/rssnews/content/CategoryDelegate.qml new file mode 100644 index 0000000..1400c36 --- /dev/null +++ b/demos/declarative/rssnews/content/CategoryDelegate.qml @@ -0,0 +1,41 @@ +import Qt 4.7 + +Item { + id: delegate + + width: delegate.ListView.view.width; height: 60 + + Text { + text: name + color: delegate.ListView.isCurrentItem ? "white" : "black" + font { family: "Helvetica"; pixelSize: 16; bold: true } + anchors { + left: parent.left; leftMargin: 15 + verticalCenter: parent.verticalCenter + } + } + + BusyIndicator { + scale: 0.6 + on: delegate.ListView.isCurrentItem && window.loading + anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter } + } + + Rectangle { + width: delegate.width; height: 1; color: "#cccccc" + anchors.bottom: delegate.bottom + visible: delegate.ListView.isCurrentItem ? false : true + } + Rectangle { + width: delegate.width; height: 1; color: "white" + visible: delegate.ListView.isCurrentItem ? false : true + } + + MouseArea { + anchors.fill: delegate + onClicked: { + delegate.ListView.view.currentIndex = index + window.currentFeed = feed + } + } +} diff --git a/demos/declarative/rssnews/content/NewsDelegate.qml b/demos/declarative/rssnews/content/NewsDelegate.qml new file mode 100644 index 0000000..0d03880 --- /dev/null +++ b/demos/declarative/rssnews/content/NewsDelegate.qml @@ -0,0 +1,29 @@ +import Qt 4.7 + +Item { + id: delegate + height: childrenRect.height + 20 + width: delegate.ListView.view.width + + Column { + x: 20; y: 20 + width: parent.width - 40 + + Text { + id: titleText + text: title; width: parent.width; wrapMode: Text.WordWrap + font { bold: true; family: "Helvetica"; pointSize: 16 } + } + + Text { + id: descriptionText + width: parent.width; text: description + wrapMode: Text.WordWrap; font.family: "Helvetica" + } + } + + Rectangle { + width: parent.width; height: 1; color: "#cccccc" + anchors.bottom: parent.bottom + } +} diff --git a/demos/declarative/rssnews/content/RssFeeds.qml b/demos/declarative/rssnews/content/RssFeeds.qml new file mode 100644 index 0000000..21e59fe --- /dev/null +++ b/demos/declarative/rssnews/content/RssFeeds.qml @@ -0,0 +1,18 @@ +import Qt 4.7 + +ListModel { + id: rssFeeds + + ListElement { name: "Top Stories"; feed: "rss.news.yahoo.com/rss/topstories" } + ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" } + ListElement { name: "Europe"; feed: "rss.news.yahoo.com/rss/europe" } + ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" } + ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" } + ListElement { name: "Politics"; feed: "rss.news.yahoo.com/rss/politics" } + ListElement { name: "Business"; feed: "rss.news.yahoo.com/rss/business" } + ListElement { name: "Technology"; feed: "rss.news.yahoo.com/rss/tech" } + ListElement { name: "Entertainment"; feed: "rss.news.yahoo.com/rss/entertainment" } + ListElement { name: "Health"; feed: "rss.news.yahoo.com/rss/health" } + ListElement { name: "Science"; feed: "rss.news.yahoo.com/rss/science" } + ListElement { name: "Sports"; feed: "rss.news.yahoo.com/rss/sports" } +} diff --git a/demos/declarative/rssnews/content/ScrollBar.qml b/demos/declarative/rssnews/content/ScrollBar.qml new file mode 100644 index 0000000..d0b08dd --- /dev/null +++ b/demos/declarative/rssnews/content/ScrollBar.qml @@ -0,0 +1,66 @@ +import Qt 4.7 + +Item { + id: container + + property variant scrollArea + property variant orientation: Qt.Vertical + + opacity: 0 + + function position() + { + var ny = 0; + if (container.orientation == Qt.Vertical) + ny = scrollArea.visibleArea.yPosition * container.height; + else + ny = scrollArea.visibleArea.xPosition * container.width; + if (ny > 2) return ny; else return 2; + } + + function size() + { + var nh, ny; + + if (container.orientation == Qt.Vertical) + nh = scrollArea.visibleArea.heightRatio * container.height; + else + nh = scrollArea.visibleArea.widthRatio * container.width; + + if (container.orientation == Qt.Vertical) + ny = scrollArea.visibleArea.yPosition * container.height; + else + ny = scrollArea.visibleArea.xPosition * container.width; + + if (ny > 3) { + var t; + if (container.orientation == Qt.Vertical) + t = Math.ceil(container.height - 3 - ny); + else + t = Math.ceil(container.width - 3 - ny); + if (nh > t) return t; else return nh; + } else return nh + ny; + } + + Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 } + + BorderImage { + source: "images/scrollbar.png" + border { left: 1; right: 1; top: 1; bottom: 1 } + x: container.orientation == Qt.Vertical ? 2 : position() + width: container.orientation == Qt.Vertical ? container.width - 4 : size() + y: container.orientation == Qt.Vertical ? position() : 2 + height: container.orientation == Qt.Vertical ? size() : container.height - 4 + } + + states: State { + name: "visible" + when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally + PropertyChanges { target: container; opacity: 1.0 } + } + + transitions: Transition { + from: "visible"; to: "" + NumberAnimation { properties: "opacity"; duration: 600 } + } +} diff --git a/demos/declarative/rssnews/content/images/busy.png b/demos/declarative/rssnews/content/images/busy.png new file mode 100644 index 0000000..664c2b1 Binary files /dev/null and b/demos/declarative/rssnews/content/images/busy.png differ diff --git a/demos/declarative/rssnews/content/images/scrollbar.png b/demos/declarative/rssnews/content/images/scrollbar.png new file mode 100644 index 0000000..0228dcf Binary files /dev/null and b/demos/declarative/rssnews/content/images/scrollbar.png differ diff --git a/demos/declarative/rssnews/rssnews.qml b/demos/declarative/rssnews/rssnews.qml new file mode 100644 index 0000000..29a530f --- /dev/null +++ b/demos/declarative/rssnews/rssnews.qml @@ -0,0 +1,52 @@ +import Qt 4.7 +import "content" + +Rectangle { + id: window + width: 800; height: 480 + + property string currentFeed: "rss.news.yahoo.com/rss/topstories" + property bool loading: feedModel.status == XmlListModel.Loading + + RssFeeds { id: rssFeeds } + + XmlListModel { + id: feedModel + source: "http://" + window.currentFeed + query: "/rss/channel/item" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "description"; query: "description/string()" } + } + + Row { + Rectangle { + width: 220; height: window.height + color: "#efefef" + + ListView { + focus: true + id: categories + anchors.fill: parent + model: rssFeeds + delegate: CategoryDelegate {} + highlight: Rectangle { color: "steelblue" } + highlightMoveSpeed: 9999999 + } + ScrollBar { + scrollArea: categories; height: categories.height; width: 8 + anchors.right: categories.right + } + } + ListView { + id: list + width: window.width - 220; height: window.height + model: feedModel + delegate: NewsDelegate {} + } + } + + ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right } + Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" } +} diff --git a/examples/declarative/xml/xmldata/daringfireball.qml b/examples/declarative/xml/xmldata/daringfireball.qml deleted file mode 100644 index 480b13c..0000000 --- a/examples/declarative/xml/xmldata/daringfireball.qml +++ /dev/null @@ -1,47 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 600; height: 600 - - XmlListModel { - id: feedModel - source: "http://daringfireball.net/index.xml" - query: "/feed/entry" - namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "tagline"; query: "author/name/string()" } - XmlRole { name: "content"; query: "content/string()" } - } - - Component { - id: feedDelegate - Item { - height: childrenRect.height + 20 - Text { - id: titleText - x: 10 - text: title; font.bold: true - } - Text { - anchors { left: titleText.right; leftMargin: 10 } - text: 'by ' + tagline - font.italic: true - } - Text { - x: 10 - width: 580 - anchors.top: titleText.bottom - text: content - wrapMode: Text.WordWrap - - onLinkActivated: { console.log('link clicked: ' + link) } - } - } - } - - ListView { - anchors.fill: parent - model: feedModel - delegate: feedDelegate - } -} diff --git a/examples/declarative/xml/xmldata/xmldata.qmlproject b/examples/declarative/xml/xmldata/xmldata.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/xml/xmldata/xmldata.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/xml/xmldata/yahoonews.qml b/examples/declarative/xml/xmldata/yahoonews.qml deleted file mode 100644 index 5bab463..0000000 --- a/examples/declarative/xml/xmldata/yahoonews.qml +++ /dev/null @@ -1,83 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 600; height: 600 - - gradient: Gradient { - GradientStop { position: 0; color: "black" } - GradientStop { position: 1.0; color: "#AAAAAA" } - } - - XmlListModel { - id: feedModel - source: "http://rss.news.yahoo.com/rss/oceania" - query: "/rss/channel/item" - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "link"; query: "link/string()" } - XmlRole { name: "description"; query: "description/string()" } - } - - Component { - id: feedDelegate - - Item { - id: delegate - height: wrapper.height + 10 - - MouseArea { - anchors.fill: wrapper - onPressed: delegate.ListView.view.currentIndex = index; - onClicked: if (wrapper.state == 'Details') wrapper.state = ''; else wrapper.state = 'Details'; - } - - Rectangle { - id: wrapper - - width: 580; y: 5; height: titleText.height + 10 - color: "#F0F0F0" - radius: 5 - - Text { - id: titleText - x: 10; y: 5 - text: '' + title + '' - font { bold: true; family: "Helvetica"; pointSize: 14 } - - onLinkActivated: { console.log('link clicked: ' + link) } - } - - Text { - id: descriptionText - x: 10; width: 560 - anchors.top: titleText.bottom; anchors.topMargin: 5 - text: description - wrapMode: Text.WordWrap - font.family: "Helvetica" - opacity: 0 - } - - states: State { - name: "Details" - PropertyChanges { target: wrapper; height: childrenRect.height + 10 } - PropertyChanges { target: descriptionText; opacity: 1 } - } - - transitions: Transition { - from: "*"; to: "Details"; reversible: true - SequentialAnimation { - NumberAnimation { duration: 200; properties: "height"; easing.type: Easing.OutQuad } - NumberAnimation { duration: 200; properties: "opacity" } - } - } - } - } - } - - ListView { - id: list - x: 10; y: 10 - width: parent.width - 20; height: parent.height - 20 - model: feedModel - delegate: feedDelegate - } -} -- cgit v0.12 From d2246104b4c38cdea4c4c11a7ad715312455f368 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 17 May 2010 09:37:13 +0200 Subject: Changelog: Added Designer/uic3 changes for 4.7.0. --- dist/changes-4.7.0 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0 index 1e3a69c..41fe9d2 100644 --- a/dist/changes-4.7.0 +++ b/dist/changes-4.7.0 @@ -233,7 +233,16 @@ Qt for Windows CE - Designer - + - [QTBUG-9351] Fixed a bug that caused modified headerview-properties + of item views to be duplicated in the UI-file. + - [QTBUG-8347] Fixed a layout problem caused by embedded images in the rich + text of a QLabel. + - [QTBUG-8041], [QTBUG-8213] Fixed a crash related to undo while moving + widgets by arrow keys. + - [QTBUG-7822] Added support for the 'windowOpacity'-property. + - [QTBUG-7764] Fixed the emission of the propertyChanged()-signal of + QDesignerPropertyEditorInterface. + - [QTBUG-5492] Made widgetbox-filter match on class names, too. - Linguist - Linguist GUI @@ -251,9 +260,10 @@ Qt for Windows CE - uic - - uic3 + - [QTBUG-9207] Fixed export of image files of type XPM, added + compatibility option -limit-xpm-linelength. - qmake -- cgit v0.12 From 25ae30256bd7980ed42a65ab73a4d4395040391a Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 17 May 2010 10:11:50 +0200 Subject: Optimized pixmapcache key generation for icons and styles This re-apply commit c8d2e18c4b431870560f324a17f20904bb47ae68 from Jens that was reverted in b0f4dab4 because it did not compile. Added the missing include to make it compile on mac Task-number: QTBUG-9850 --- src/gui/image/qicon.cpp | 25 ++++++++--------- src/gui/styles/qgtkpainter.cpp | 9 ++++-- src/gui/styles/qstylehelper.cpp | 62 ++++++----------------------------------- src/gui/styles/qstylehelper_p.h | 32 +++++++++++++++++++++ 4 files changed, 59 insertions(+), 69 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 891b1db..7696632 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -55,6 +55,7 @@ #include "qcache.h" #include "qdebug.h" #include "private/qguiplatformplugin_p.h" +#include "private/qstylehelper_p.h" #ifdef Q_WS_MAC #include @@ -261,21 +262,17 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height())) actualSize.scale(size, Qt::KeepAspectRatio); - QString key = QLatin1String("$qt_icon_") - + QString::number(pm.cacheKey()) - + QString::number(pe->mode) - + QString::number(QApplication::palette().cacheKey()) - + QLatin1Char('_') - + QString::number(actualSize.width()) - + QLatin1Char('_') - + QString::number(actualSize.height()) - + QLatin1Char('_'); - + QString key = QLatin1Literal("qt_") + % HexString(pm.cacheKey()) + % HexString(pe->mode) + % HexString(QApplication::palette().cacheKey()) + % HexString(actualSize.width()) + % HexString(actualSize.height()); if (mode == QIcon::Active) { - if (QPixmapCache::find(key + QString::number(mode), pm)) + if (QPixmapCache::find(key % HexString(mode), pm)) return pm; // horray - if (QPixmapCache::find(key + QString::number(QIcon::Normal), pm)) { + if (QPixmapCache::find(key % HexString(QIcon::Normal), pm)) { QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt); @@ -284,7 +281,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St } } - if (!QPixmapCache::find(key + QString::number(mode), pm)) { + if (!QPixmapCache::find(key % HexString(mode), pm)) { if (pm.size() != actualSize) pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (pe->mode != mode && mode != QIcon::Normal) { @@ -294,7 +291,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!generated.isNull()) pm = generated; } - QPixmapCache::insert(key + QString::number(mode), pm); + QPixmapCache::insert(key % HexString(mode), pm); } return pm; } diff --git a/src/gui/styles/qgtkpainter.cpp b/src/gui/styles/qgtkpainter.cpp index 1f68f2f..79c53e9 100644 --- a/src/gui/styles/qgtkpainter.cpp +++ b/src/gui/styles/qgtkpainter.cpp @@ -47,6 +47,7 @@ // This class is primarily a wrapper around the gtk painter functions // and takes care of converting all such calls into cached Qt pixmaps. +#include #include #include #include @@ -155,8 +156,12 @@ static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType const QSize &size, GtkWidget *widget = 0) { // Note the widget arg should ideally use the widget path, though would compromise performance - QString tmp = QString(QLS("%0-%1-%2-%3x%4-%5")).arg(key).arg(uint(state)).arg(shadow) - .arg(size.width()).arg(size.height()).arg(quintptr(widget)); + QString tmp = key + % HexString(state) + % HexString(shadow) + % HexString(size.width()) + % HexString(size.height()) + % HexString(quint64(widget)); return tmp; } diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp index 296c51c..d09d7fa 100644 --- a/src/gui/styles/qstylehelper.cpp +++ b/src/gui/styles/qstylehelper.cpp @@ -58,67 +58,23 @@ QT_BEGIN_NAMESPACE -// internal helper. Converts an integer value to an unique string token -template -struct HexString -{ - inline HexString(const T t) - : val(t) - {} - - inline void write(QChar *&dest) const - { - const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - const char *c = reinterpret_cast(&val); - for (uint i = 0; i < sizeof(T); ++i) { - *dest++ = hexChars[*c & 0xf]; - *dest++ = hexChars[(*c & 0xf0) >> 4]; - ++c; - } - } - - const T val; -}; - -// specialization to enable fast concatenating of our string tokens to a string -template -struct QConcatenable > -{ - typedef HexString type; - enum { ExactSize = true }; - static int size(const HexString &str) { return sizeof(str.val) * 2; } - static inline void appendTo(const HexString &str, QChar *&out) { str.write(out); } -}; - namespace QStyleHelper { QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) { const QStyleOptionComplex *complexOption = qstyleoption_cast(option); - - QString tmp = key - % QLatin1Char('-') - % HexString(option->state) - % QLatin1Char('-') - % HexString(option->direction) - % QLatin1Char('-') - % HexString(complexOption ? uint(complexOption->activeSubControls) : 0u) - % QLatin1Char('-') - % HexString(option->palette.cacheKey()) - % QLatin1Char('-') - % HexString(size.width()) - % QLatin1Char('x') - % HexString(size.height()); + QString tmp = key % HexString(option->state) + % HexString(option->direction) + % HexString(complexOption ? uint(complexOption->activeSubControls) : 0u) + % HexString(option->palette.cacheKey()) + % HexString(size.width()) + % HexString(size.height()); #ifndef QT_NO_SPINBOX if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { - tmp = tmp - % QLatin1Char('-') - % HexString(spinBox->buttonSymbols) - % QLatin1Char('-') - % HexString(spinBox->stepEnabled) - % QLatin1Char('-') - % QLatin1Char(spinBox->frame ? '1' : '0'); + tmp = tmp % HexString(spinBox->buttonSymbols) + % HexString(spinBox->stepEnabled) + % QLatin1Char(spinBox->frame ? '1' : '0'); ; } #endif // QT_NO_SPINBOX return tmp; diff --git a/src/gui/styles/qstylehelper_p.h b/src/gui/styles/qstylehelper_p.h index 31cc4ed..555ad60 100644 --- a/src/gui/styles/qstylehelper_p.h +++ b/src/gui/styles/qstylehelper_p.h @@ -41,6 +41,7 @@ #include #include +#include #include #ifndef QSTYLEHELPER_P_H @@ -79,6 +80,37 @@ namespace QStyleHelper int bottom = 0); } +// internal helper. Converts an integer value to an unique string token +template + struct HexString +{ + inline HexString(const T t) + : val(t) + {} + + inline void write(QChar *&dest) const + { + const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + const char *c = reinterpret_cast(&val); + for (uint i = 0; i < sizeof(T); ++i) { + *dest++ = hexChars[*c & 0xf]; + *dest++ = hexChars[(*c & 0xf0) >> 4]; + ++c; + } + } + const T val; +}; + +// specialization to enable fast concatenating of our string tokens to a string +template + struct QConcatenable > +{ + typedef HexString type; + enum { ExactSize = true }; + static int size(const HexString &str) { return sizeof(str.val) * 2; } + static inline void appendTo(const HexString &str, QChar *&out) { str.write(out); } +}; + QT_END_NAMESPACE #endif // QSTYLEHELPER_P_H -- cgit v0.12 From eb79e5ebf67de67f8c7bf3db20ceae93b46252b3 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 17 May 2010 15:04:11 +0200 Subject: re-add overriding of tool paths to configure unlike originally planned, we didn't remove the setting of the tool paths from the qmake specs - for compat reasons. however, that means that they will make the QT_BUILD_TREE handling in qtPrepareTool ineffective, which meant that the qt build would try to use the tools from an installed qt ... --- configure | 5 +++++ tools/configure/configureapp.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/configure b/configure index 057d39a..0cf7542 100755 --- a/configure +++ b/configure @@ -7198,6 +7198,11 @@ QMAKE_ABSOLUTE_SOURCE_ROOT = \$\$QT_SOURCE_TREE QMAKE_MOC_SRC = \$\$QT_BUILD_TREE/src/moc #local paths that cannot be queried from the QT_INSTALL_* properties while building QTDIR +QMAKE_MOC = \$\$QT_BUILD_TREE/bin/moc +QMAKE_UIC = \$\$QT_BUILD_TREE/bin/uic +QMAKE_UIC3 = \$\$QT_BUILD_TREE/bin/uic3 +QMAKE_RCC = \$\$QT_BUILD_TREE/bin/rcc +QMAKE_QDBUSXML2CPP = \$\$QT_BUILD_TREE/bin/qdbusxml2cpp QMAKE_INCDIR_QT = \$\$QT_BUILD_TREE/include QMAKE_LIBDIR_QT = \$\$QT_BUILD_TREE/lib diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 7319844..b35f454 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2755,6 +2755,11 @@ void Configure::generateCachefile() cacheStream << "DEFINES *= QT_EDITION=QT_EDITION_DESKTOP" << endl; //so that we can build without an install first (which would be impossible) + cacheStream << "QMAKE_MOC = $$QT_BUILD_TREE" << fixSeparators("/bin/moc.exe") << endl; + cacheStream << "QMAKE_UIC = $$QT_BUILD_TREE" << fixSeparators("/bin/uic.exe") << endl; + cacheStream << "QMAKE_UIC3 = $$QT_BUILD_TREE" << fixSeparators("/bin/uic3.exe") << endl; + cacheStream << "QMAKE_RCC = $$QT_BUILD_TREE" << fixSeparators("/bin/rcc.exe") << endl; + cacheStream << "QMAKE_DUMPCPP = $$QT_BUILD_TREE" << fixSeparators("/bin/dumpcpp.exe") << endl; cacheStream << "QMAKE_INCDIR_QT = $$QT_BUILD_TREE" << fixSeparators("/include") << endl; cacheStream << "QMAKE_LIBDIR_QT = $$QT_BUILD_TREE" << fixSeparators("/lib") << endl; if (dictionary["CETEST"] == "yes") { -- cgit v0.12 From cb3d2252eaacf35a5b3c76eaa884ab4b46af74dd Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 17 May 2010 15:45:56 +0200 Subject: Compile fixes. --- .../qgraphicslayouts/graphicsLayouts/graphicsLayouts.pro | 13 +++++++++++++ .../qgraphicslayouts/graphicsLayouts/graphicslayouts.pro | 13 ------------- examples/graphicsview/padnavigator/padnavigator.h | 4 ++++ src/declarative/qml/qdeclarativeengine_p.h | 1 + 4 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicsLayouts.pro delete mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicsLayouts.pro b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicsLayouts.pro new file mode 100644 index 0000000..e5d91b2 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicsLayouts.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +TARGET = graphicslayouts +QT += declarative + +SOURCES += \ + graphicslayouts.cpp \ + main.cpp + +HEADERS += \ + graphicslayouts_p.h + +RESOURCES += \ + graphicslayouts.qrc diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro deleted file mode 100644 index e5d91b2..0000000 --- a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = app -TARGET = graphicslayouts -QT += declarative - -SOURCES += \ - graphicslayouts.cpp \ - main.cpp - -HEADERS += \ - graphicslayouts_p.h - -RESOURCES += \ - graphicslayouts.qrc diff --git a/examples/graphicsview/padnavigator/padnavigator.h b/examples/graphicsview/padnavigator/padnavigator.h index 03a1ea2..d9298ae 100644 --- a/examples/graphicsview/padnavigator/padnavigator.h +++ b/examples/graphicsview/padnavigator/padnavigator.h @@ -45,10 +45,14 @@ #include #include "ui_form.h" +QT_BEGIN_NAMESPACE + class QState; class QStateMachine; class Ui_Form; +QT_END_NAMESPACE + //! [0] class PadNavigator : public QGraphicsView { diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 531ac97..0b1c17d 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -91,6 +91,7 @@ class QDeclarativeEngine; class QDeclarativeContextPrivate; class QDeclarativeExpression; class QDeclarativeContextScriptClass; +class QDeclarativeImportDatabase; class QDeclarativeObjectScriptClass; class QDeclarativeTypeNameScriptClass; class QDeclarativeValueTypeScriptClass; -- cgit v0.12 From 25dd6dfe1c7c78370e7cbb266234f6ec5cf0eb95 Mon Sep 17 00:00:00 2001 From: kh1 Date: Mon, 17 May 2010 15:56:58 +0200 Subject: Assistant has unnecessary repaints when expand/collapse selected node. Task-number: QTBUG-10575 Reviewed-by: ck --- tools/assistant/tools/assistant/contentwindow.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index e0347c8..8afa1df 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -133,11 +133,13 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e) if (m_contentWidget && o == m_contentWidget->viewport() && e->type() == QEvent::MouseButtonRelease) { QMouseEvent *me = static_cast(e); - QModelIndex index = m_contentWidget->indexAt(me->pos()); - QItemSelectionModel *sm = m_contentWidget->selectionModel(); + const QModelIndex &index = m_contentWidget->indexAt(me->pos()); + if (!index.isValid()) + return QWidget::eventFilter(o, e); - Qt::MouseButtons button = me->button(); - if (index.isValid() && (sm && sm->isSelected(index))) { + const Qt::MouseButtons button = me->button(); + QItemSelectionModel *sm = m_contentWidget->selectionModel(); + if (sm->isSelected(index)) { if ((button == Qt::LeftButton && (me->modifiers() & Qt::ControlModifier)) || (button == Qt::MidButton)) { QHelpContentModel *contentModel = @@ -189,9 +191,11 @@ void ContentWindow::itemClicked(const QModelIndex &index) qobject_cast(m_contentWidget->model()); if (contentModel) { - QHelpContentItem *itm = contentModel->contentItemAt(index); - if (itm) - emit linkActivated(itm->url()); + if (QHelpContentItem *itm = contentModel->contentItemAt(index)) { + const QUrl &url = itm->url(); + if (url != CentralWidget::instance()->currentSource()) + emit linkActivated(url); + } } } -- cgit v0.12 From 6b5a7e8f4f33eaa6b5addca595d58f1dd4a32e7a Mon Sep 17 00:00:00 2001 From: kh1 Date: Mon, 17 May 2010 15:58:44 +0200 Subject: Print icon in doc pages has no effect. Task-number: QTBUG-10579 Reviewed-by: ck --- tools/assistant/tools/assistant/centralwidget.cpp | 1 + tools/assistant/tools/assistant/helpviewer_qwv.cpp | 1 + tools/assistant/tools/assistant/helpviewer_qwv.h | 1 + 3 files changed, 3 insertions(+) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 2359479..131fb85 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -565,6 +565,7 @@ void CentralWidget::connectSignals() SIGNAL(highlighted(QString))); connect(viewer, SIGNAL(sourceChanged(QUrl)), this, SLOT(setTabTitle(QUrl))); + connect(viewer, SIGNAL(printRequested()), this, SLOT(print())); } } diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index adaa45b..244d091 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -269,6 +269,7 @@ HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); + connect(page(), SIGNAL(printRequested(QWebFrame*)), this, SIGNAL(printRequested())); setFont(viewerFont()); setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom); diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h index a2c0389..2577828 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.h +++ b/tools/assistant/tools/assistant/helpviewer_qwv.h @@ -100,6 +100,7 @@ Q_SIGNALS: void backwardAvailable(bool enabled); void highlighted(const QString &); void sourceChanged(const QUrl &); + void printRequested(); protected: virtual void wheelEvent(QWheelEvent *); -- cgit v0.12 From 6126d5c033e669bd57fc26093eb9be368feb12e2 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 17 May 2010 16:14:32 +0200 Subject: qmake: added possibility to specify the type of an install target Before this change: target.CONFIG+=no_check_exist implies the file is a file, no way to make an install rule for a non-existing directory. Now, its possible to specify the type: target.CONFIG+=no_check_exist directory will install a directory. target.CONFIG+=no_check_exist executable will install an executable. target.CONFIG+=no_check_exist data will install a normal file. The default case, if no type is given, like in CONFIG+=no_check_exist will call QFileInfo::isExecutable() to determine, if its a data file or executable. This is the old behaviour. Task-number: QTBUG-10624 Reviewed-by: ossi --- doc/doc.pri | 4 ++-- qmake/generators/makefile.cpp | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/doc/doc.pri b/doc/doc.pri index 463c447..c6073f0 100644 --- a/doc/doc.pri +++ b/doc/doc.pri @@ -45,11 +45,11 @@ docs.depends = adp_docs qch_docs # Install rules htmldocs.files = $$QT_BUILD_TREE/doc/html htmldocs.path = $$[QT_INSTALL_DOCS] -htmldocs.CONFIG += no_check_exist +htmldocs.CONFIG += no_check_exist directory qchdocs.files= $$QT_BUILD_TREE/doc/qch qchdocs.path = $$[QT_INSTALL_DOCS] -qchdocs.CONFIG += no_check_exist +qchdocs.CONFIG += no_check_exist directory docimages.files = $$QT_BUILD_TREE/doc/src/images docimages.path = $$[QT_INSTALL_DOCS]/src diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index db2737b..6b85561 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1277,13 +1277,26 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs, bool n } QString local_dirstr = Option::fixPathToLocalOS(dirstr, true); QStringList files = QDir(local_dirstr).entryList(QStringList(filestr)); - if(project->values((*it) + ".CONFIG").indexOf("no_check_exist") != -1 && files.isEmpty()) { + const QStringList &installConfigValues = project->values((*it) + ".CONFIG"); + if (installConfigValues.contains("no_check_exist") && files.isEmpty()) { if(!target.isEmpty()) target += "\t"; QString dst_file = filePrefixRoot(root, dst); QFileInfo fi(fileInfo(wild)); - QString cmd = QString(fi.isExecutable() ? "-$(INSTALL_PROGRAM)" : "-$(INSTALL_FILE)") + " " + - wild + " " + dst_file + "\n"; + QString cmd; + if (installConfigValues.contains("directory")) { + cmd = QLatin1String("-$(INSTALL_DIR)"); + if (!dst_file.endsWith(Option::dir_sep)) + dst_file += Option::dir_sep; + dst_file += fi.fileName(); + } else if (installConfigValues.contains("executable")) { + cmd = QLatin1String("-$(INSTALL_PROGRAM)"); + } else if (installConfigValues.contains("data")) { + cmd = QLatin1String("-$(INSTALL_FILE)"); + } else { + cmd = QString(fi.isExecutable() ? "-$(INSTALL_PROGRAM)" : "-$(INSTALL_FILE)"); + } + cmd += " " + wild + " " + dst_file + "\n"; target += cmd; if(!uninst.isEmpty()) uninst.append("\n\t"); -- cgit v0.12 From 672c0d15ad07aaffeb7354e9fd8a822ee0d36ac2 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Thu, 6 May 2010 08:39:00 +0200 Subject: Fix a small typo in assistant manual: hompage -> homepage --- doc/src/development/assistant-manual.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/development/assistant-manual.qdoc b/doc/src/development/assistant-manual.qdoc index 7d56ea1..afc6361 100644 --- a/doc/src/development/assistant-manual.qdoc +++ b/doc/src/development/assistant-manual.qdoc @@ -359,7 +359,7 @@ The \menu{Options} page lets you specify the homepage \QA will display when you click the \gui{Home} button in \QA's main user interface. You can specify - the hompage by typing it here or clicking on one of the buttons below the + the homepage by typing it here or clicking on one of the buttons below the textbox. \gui{Current Page} sets the currently displayed page as your home page while \gui{Restore to default} will reset your home page to the default home page. -- cgit v0.12 From 45791722b9491076a7308a30159eba7309220664 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 17 May 2010 16:48:12 +0200 Subject: Compile with Gcc 4.1 --- src/gui/styles/qstylehelper_p.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/styles/qstylehelper_p.h b/src/gui/styles/qstylehelper_p.h index 555ad60..71fce55 100644 --- a/src/gui/styles/qstylehelper_p.h +++ b/src/gui/styles/qstylehelper_p.h @@ -43,6 +43,7 @@ #include #include #include +#include #ifndef QSTYLEHELPER_P_H #define QSTYLEHELPER_P_H -- cgit v0.12 From 01e7389086d4afde33c3e2b1ece9c6d906869e08 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 17 May 2010 17:43:16 +0200 Subject: QCompleter: fix misuse of QMap that can lead to crashes Patch providedin the task. Task-number: QTBUG-8407 --- src/gui/util/qcompleter.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index cefdb27..ce2eff5 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -527,17 +527,22 @@ void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, con QMatchData old = cache[parent].take(part); cost = cost + m.indices.cost() - old.indices.cost(); if (cost * sizeof(int) > 1024 * 1024) { - QMap::iterator it1 ; - for (it1 = cache.begin(); it1 != cache.end(); ++it1) { + QMap::iterator it1 = cache.begin(); + while (it1 != cache.end()) { CacheItem& ci = it1.value(); int sz = ci.count()/2; QMap::iterator it2 = ci.begin(); - for (int i = 0; it2 != ci.end() && i < sz; i++, ++it2) { + int i = 0; + while (it2 != ci.end() && i < sz) { cost -= it2.value().indices.cost(); - ci.erase(it2); + it2 = ci.erase(it2); + i++; + } + if (ci.count() == 0) { + it1 = cache.erase(it1); + } else { + ++it1; } - if (ci.count() == 0) - cache.erase(it1); } } -- cgit v0.12 From 8aff2b3e6f09b446f124b7023485e947ab1bf24b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 17 May 2010 17:47:00 +0200 Subject: Doc: fix typo --- src/gui/util/qcompleter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index ce2eff5..9a99abe 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -1753,7 +1753,7 @@ QStringList QCompleter::splitPath(const QString& path) const This signal is sent when an item in the popup() is highlighted by the user. It is also sent if complete() is called with the completionMode() - set to QCOmpleter::InlineCompletion. The item's \a text is given. + set to QCompleter::InlineCompletion. The item's \a text is given. */ QT_END_NAMESPACE -- cgit v0.12 From cd68abc3df40d8c6b03d9f0f1c8fc78f2e984ffe Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 17 May 2010 21:16:25 +0200 Subject: Fix 'chapter5_plugins.dll.sym contains initialized writable data' That's an error that you get when building a qml plugin for a Symbian device. Solution: Add 'TARGET.EPOCALLOWDLLDATA = 1' to the plugin .pro file --- .../tutorials/extending/chapter5-plugins/chapter5-plugins.pro | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro b/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro index 7ec68e9..a8fb565 100644 --- a/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro +++ b/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro @@ -13,3 +13,8 @@ SOURCES += musician.cpp \ DESTDIR = lib OBJECTS_DIR = tmp MOC_DIR = tmp + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.EPOCALLOWDLLDATA = 1 +} -- cgit v0.12 From 5a4329b6844277e92286fc0ae6d4ec15dece2bf6 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Tue, 18 May 2010 10:11:45 +1000 Subject: Removed mediaservices. --- bin/syncqt | 3 +- configure | 52 +- demos/demos.pro | 2 - demos/multimedia/multimedia.pro | 3 - demos/multimedia/player/main.cpp | 54 - demos/multimedia/player/player.cpp | 372 ----- demos/multimedia/player/player.h | 114 -- demos/multimedia/player/player.pro | 29 - demos/multimedia/player/playercontrols.cpp | 205 --- demos/multimedia/player/playercontrols.h | 107 -- demos/multimedia/player/playlistmodel.cpp | 160 -- demos/multimedia/player/playlistmodel.h | 95 -- demos/multimedia/player/videowidget.cpp | 78 - demos/multimedia/player/videowidget.h | 66 - mkspecs/features/qt.prf | 3 +- src/corelib/global/qglobal.h | 8 - src/imports/imports.pro | 1 - src/imports/multimedia/multimedia.cpp | 73 - src/imports/multimedia/multimedia.pro | 36 - src/imports/multimedia/qdeclarativeaudio.cpp | 357 ----- src/imports/multimedia/qdeclarativeaudio_p.h | 176 --- src/imports/multimedia/qdeclarativemediabase.cpp | 528 ------- src/imports/multimedia/qdeclarativemediabase_p.h | 181 --- src/imports/multimedia/qdeclarativevideo.cpp | 976 ------------ src/imports/multimedia/qdeclarativevideo_p.h | 207 --- .../multimedia/qmetadatacontrolmetaobject.cpp | 362 ----- .../multimedia/qmetadatacontrolmetaobject_p.h | 92 -- src/imports/multimedia/qmldir | 1 - src/multimedia/audio/audio.pri | 73 + src/multimedia/audio/qaudio.cpp | 104 ++ src/multimedia/audio/qaudio.h | 71 + src/multimedia/audio/qaudio_mac.cpp | 142 ++ src/multimedia/audio/qaudio_mac_p.h | 144 ++ src/multimedia/audio/qaudio_symbian_p.cpp | 395 +++++ src/multimedia/audio/qaudio_symbian_p.h | 156 ++ src/multimedia/audio/qaudiodevicefactory.cpp | 275 ++++ src/multimedia/audio/qaudiodevicefactory_p.h | 97 ++ src/multimedia/audio/qaudiodeviceinfo.cpp | 400 +++++ src/multimedia/audio/qaudiodeviceinfo.h | 114 ++ src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 486 ++++++ src/multimedia/audio/qaudiodeviceinfo_alsa_p.h | 117 ++ src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 357 +++++ src/multimedia/audio/qaudiodeviceinfo_mac_p.h | 97 ++ .../audio/qaudiodeviceinfo_symbian_p.cpp | 200 +++ src/multimedia/audio/qaudiodeviceinfo_symbian_p.h | 107 ++ src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 433 ++++++ src/multimedia/audio/qaudiodeviceinfo_win32_p.h | 112 ++ src/multimedia/audio/qaudioengine.cpp | 343 +++++ src/multimedia/audio/qaudioengine.h | 131 ++ src/multimedia/audio/qaudioengineplugin.cpp | 54 + src/multimedia/audio/qaudioengineplugin.h | 93 ++ src/multimedia/audio/qaudioformat.cpp | 407 +++++ src/multimedia/audio/qaudioformat.h | 107 ++ src/multimedia/audio/qaudioinput.cpp | 432 ++++++ src/multimedia/audio/qaudioinput.h | 111 ++ src/multimedia/audio/qaudioinput_alsa_p.cpp | 701 +++++++++ src/multimedia/audio/qaudioinput_alsa_p.h | 158 ++ src/multimedia/audio/qaudioinput_mac_p.cpp | 956 ++++++++++++ src/multimedia/audio/qaudioinput_mac_p.h | 169 +++ src/multimedia/audio/qaudioinput_symbian_p.cpp | 594 ++++++++ src/multimedia/audio/qaudioinput_symbian_p.h | 188 +++ src/multimedia/audio/qaudioinput_win32_p.cpp | 604 ++++++++ src/multimedia/audio/qaudioinput_win32_p.h | 160 ++ src/multimedia/audio/qaudiooutput.cpp | 411 +++++ src/multimedia/audio/qaudiooutput.h | 111 ++ src/multimedia/audio/qaudiooutput_alsa_p.cpp | 774 ++++++++++ src/multimedia/audio/qaudiooutput_alsa_p.h | 166 ++ src/multimedia/audio/qaudiooutput_mac_p.cpp | 712 +++++++++ src/multimedia/audio/qaudiooutput_mac_p.h | 167 ++ src/multimedia/audio/qaudiooutput_symbian_p.cpp | 697 +++++++++ src/multimedia/audio/qaudiooutput_symbian_p.h | 210 +++ src/multimedia/audio/qaudiooutput_win32_p.cpp | 604 ++++++++ src/multimedia/audio/qaudiooutput_win32_p.h | 157 ++ src/multimedia/mediaservices/base/base.pri | 69 - .../mediaservices/base/qgraphicsvideoitem.cpp | 442 ------ .../mediaservices/base/qgraphicsvideoitem.h | 115 -- .../base/qlocalmediaplaylistprovider.cpp | 196 --- .../base/qlocalmediaplaylistprovider.h | 87 -- .../mediaservices/base/qmediacontent.cpp | 242 --- src/multimedia/mediaservices/base/qmediacontent.h | 93 -- .../mediaservices/base/qmediacontrol.cpp | 140 -- src/multimedia/mediaservices/base/qmediacontrol.h | 82 - .../mediaservices/base/qmediacontrol_p.h | 74 - src/multimedia/mediaservices/base/qmediaobject.cpp | 419 ----- src/multimedia/mediaservices/base/qmediaobject.h | 121 -- src/multimedia/mediaservices/base/qmediaobject_p.h | 95 -- .../mediaservices/base/qmediaplaylist.cpp | 724 --------- src/multimedia/mediaservices/base/qmediaplaylist.h | 147 -- .../mediaservices/base/qmediaplaylist_p.h | 172 --- .../mediaservices/base/qmediaplaylistcontrol.cpp | 204 --- .../mediaservices/base/qmediaplaylistcontrol.h | 97 -- .../mediaservices/base/qmediaplaylistioplugin.cpp | 192 --- .../mediaservices/base/qmediaplaylistioplugin.h | 126 -- .../mediaservices/base/qmediaplaylistnavigator.cpp | 545 ------- .../mediaservices/base/qmediaplaylistnavigator.h | 116 -- .../mediaservices/base/qmediaplaylistprovider.cpp | 308 ---- .../mediaservices/base/qmediaplaylistprovider.h | 114 -- .../mediaservices/base/qmediaplaylistprovider_p.h | 75 - .../mediaservices/base/qmediapluginloader.cpp | 139 -- .../mediaservices/base/qmediapluginloader_p.h | 92 -- .../mediaservices/base/qmediaresource.cpp | 399 ----- src/multimedia/mediaservices/base/qmediaresource.h | 134 -- .../mediaservices/base/qmediaservice.cpp | 140 -- src/multimedia/mediaservices/base/qmediaservice.h | 90 -- .../mediaservices/base/qmediaservice_p.h | 75 - .../mediaservices/base/qmediaserviceprovider.cpp | 738 --------- .../mediaservices/base/qmediaserviceprovider.h | 174 --- .../base/qmediaserviceproviderplugin.h | 125 -- .../mediaservices/base/qmediatimerange.cpp | 708 --------- .../mediaservices/base/qmediatimerange.h | 135 -- .../mediaservices/base/qmetadatacontrol.cpp | 185 --- .../mediaservices/base/qmetadatacontrol.h | 92 -- .../mediaservices/base/qpaintervideosurface.cpp | 1565 ------------------- .../mediaservices/base/qpaintervideosurface_mac.mm | 283 ---- .../base/qpaintervideosurface_mac_p.h | 100 -- .../mediaservices/base/qpaintervideosurface_p.h | 178 --- .../mediaservices/base/qtmedianamespace.h | 194 --- .../mediaservices/base/qtmedianamespace.qdoc | 214 --- .../mediaservices/base/qvideodevicecontrol.cpp | 155 -- .../mediaservices/base/qvideodevicecontrol.h | 90 -- .../mediaservices/base/qvideooutputcontrol.cpp | 135 -- .../mediaservices/base/qvideooutputcontrol.h | 91 -- .../mediaservices/base/qvideorenderercontrol.cpp | 124 -- .../mediaservices/base/qvideorenderercontrol.h | 77 - src/multimedia/mediaservices/base/qvideowidget.cpp | 944 ------------ src/multimedia/mediaservices/base/qvideowidget.h | 131 -- src/multimedia/mediaservices/base/qvideowidget_p.h | 271 ---- .../mediaservices/base/qvideowidgetcontrol.cpp | 235 --- .../mediaservices/base/qvideowidgetcontrol.h | 105 -- .../mediaservices/base/qvideowindowcontrol.cpp | 275 ---- .../mediaservices/base/qvideowindowcontrol.h | 111 -- src/multimedia/mediaservices/effects/effects.pri | 26 - .../mediaservices/effects/qsoundeffect.cpp | 209 --- .../mediaservices/effects/qsoundeffect_p.h | 109 -- .../mediaservices/effects/qsoundeffect_pulse_p.cpp | 499 ------ .../mediaservices/effects/qsoundeffect_pulse_p.h | 137 -- .../effects/qsoundeffect_qmedia_p.cpp | 132 -- .../mediaservices/effects/qsoundeffect_qmedia_p.h | 103 -- .../effects/qsoundeffect_qsound_p.cpp | 131 -- .../mediaservices/effects/qsoundeffect_qsound_p.h | 102 -- .../mediaservices/effects/wavedecoder_p.cpp | 151 -- .../mediaservices/effects/wavedecoder_p.h | 133 -- src/multimedia/mediaservices/mediaservices.pro | 21 - src/multimedia/mediaservices/playback/playback.pri | 11 - .../mediaservices/playback/qmediaplayer.cpp | 996 ------------ .../mediaservices/playback/qmediaplayer.h | 203 --- .../mediaservices/playback/qmediaplayercontrol.cpp | 378 ----- .../mediaservices/playback/qmediaplayercontrol.h | 131 -- src/multimedia/multimedia.pro | 21 +- src/multimedia/multimedia/audio/audio.pri | 73 - src/multimedia/multimedia/audio/qaudio.cpp | 104 -- src/multimedia/multimedia/audio/qaudio.h | 71 - src/multimedia/multimedia/audio/qaudio_mac.cpp | 142 -- src/multimedia/multimedia/audio/qaudio_mac_p.h | 144 -- .../multimedia/audio/qaudio_symbian_p.cpp | 395 ----- src/multimedia/multimedia/audio/qaudio_symbian_p.h | 156 -- .../multimedia/audio/qaudiodevicefactory.cpp | 275 ---- .../multimedia/audio/qaudiodevicefactory_p.h | 97 -- .../multimedia/audio/qaudiodeviceinfo.cpp | 400 ----- src/multimedia/multimedia/audio/qaudiodeviceinfo.h | 114 -- .../multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 486 ------ .../multimedia/audio/qaudiodeviceinfo_alsa_p.h | 117 -- .../multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 357 ----- .../multimedia/audio/qaudiodeviceinfo_mac_p.h | 97 -- .../audio/qaudiodeviceinfo_symbian_p.cpp | 200 --- .../multimedia/audio/qaudiodeviceinfo_symbian_p.h | 107 -- .../multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 433 ------ .../multimedia/audio/qaudiodeviceinfo_win32_p.h | 112 -- src/multimedia/multimedia/audio/qaudioengine.cpp | 343 ----- src/multimedia/multimedia/audio/qaudioengine.h | 131 -- .../multimedia/audio/qaudioengineplugin.cpp | 54 - .../multimedia/audio/qaudioengineplugin.h | 93 -- src/multimedia/multimedia/audio/qaudioformat.cpp | 407 ----- src/multimedia/multimedia/audio/qaudioformat.h | 107 -- src/multimedia/multimedia/audio/qaudioinput.cpp | 432 ------ src/multimedia/multimedia/audio/qaudioinput.h | 111 -- .../multimedia/audio/qaudioinput_alsa_p.cpp | 701 --------- .../multimedia/audio/qaudioinput_alsa_p.h | 158 -- .../multimedia/audio/qaudioinput_mac_p.cpp | 956 ------------ .../multimedia/audio/qaudioinput_mac_p.h | 169 --- .../multimedia/audio/qaudioinput_symbian_p.cpp | 594 -------- .../multimedia/audio/qaudioinput_symbian_p.h | 188 --- .../multimedia/audio/qaudioinput_win32_p.cpp | 604 -------- .../multimedia/audio/qaudioinput_win32_p.h | 160 -- src/multimedia/multimedia/audio/qaudiooutput.cpp | 411 ----- src/multimedia/multimedia/audio/qaudiooutput.h | 111 -- .../multimedia/audio/qaudiooutput_alsa_p.cpp | 774 ---------- .../multimedia/audio/qaudiooutput_alsa_p.h | 166 -- .../multimedia/audio/qaudiooutput_mac_p.cpp | 712 --------- .../multimedia/audio/qaudiooutput_mac_p.h | 167 -- .../multimedia/audio/qaudiooutput_symbian_p.cpp | 697 --------- .../multimedia/audio/qaudiooutput_symbian_p.h | 210 --- .../multimedia/audio/qaudiooutput_win32_p.cpp | 604 -------- .../multimedia/audio/qaudiooutput_win32_p.h | 157 -- src/multimedia/multimedia/multimedia.pro | 19 - .../multimedia/video/qabstractvideobuffer.cpp | 200 --- .../multimedia/video/qabstractvideobuffer.h | 106 -- .../multimedia/video/qabstractvideobuffer_p.h | 73 - .../multimedia/video/qabstractvideosurface.cpp | 283 ---- .../multimedia/video/qabstractvideosurface.h | 110 -- .../multimedia/video/qabstractvideosurface_p.h | 78 - .../multimedia/video/qimagevideobuffer.cpp | 106 -- .../multimedia/video/qimagevideobuffer_p.h | 79 - .../multimedia/video/qmemoryvideobuffer.cpp | 129 -- .../multimedia/video/qmemoryvideobuffer_p.h | 83 - src/multimedia/multimedia/video/qvideoframe.cpp | 741 --------- src/multimedia/multimedia/video/qvideoframe.h | 169 --- .../multimedia/video/qvideosurfaceformat.cpp | 704 --------- .../multimedia/video/qvideosurfaceformat.h | 147 -- src/multimedia/multimedia/video/video.pri | 21 - src/multimedia/video/qabstractvideobuffer.cpp | 200 +++ src/multimedia/video/qabstractvideobuffer.h | 106 ++ src/multimedia/video/qabstractvideobuffer_p.h | 73 + src/multimedia/video/qabstractvideosurface.cpp | 283 ++++ src/multimedia/video/qabstractvideosurface.h | 110 ++ src/multimedia/video/qabstractvideosurface_p.h | 78 + src/multimedia/video/qimagevideobuffer.cpp | 106 ++ src/multimedia/video/qimagevideobuffer_p.h | 79 + src/multimedia/video/qmemoryvideobuffer.cpp | 129 ++ src/multimedia/video/qmemoryvideobuffer_p.h | 83 + src/multimedia/video/qvideoframe.cpp | 741 +++++++++ src/multimedia/video/qvideoframe.h | 169 +++ src/multimedia/video/qvideosurfaceformat.cpp | 704 +++++++++ src/multimedia/video/qvideosurfaceformat.h | 147 ++ src/multimedia/video/video.pri | 21 + .../mediaservices/directshow/directshow.pro | 14 - .../mediaservices/directshow/dsserviceplugin.cpp | 188 --- .../mediaservices/directshow/dsserviceplugin.h | 77 - .../mediaplayer/directshowaudioendpointcontrol.cpp | 166 -- .../mediaplayer/directshowaudioendpointcontrol.h | 90 -- .../directshow/mediaplayer/directshoweventloop.cpp | 161 -- .../directshow/mediaplayer/directshoweventloop.h | 83 - .../directshow/mediaplayer/directshowglobal.h | 147 -- .../directshow/mediaplayer/directshowioreader.cpp | 501 ------ .../directshow/mediaplayer/directshowioreader.h | 126 -- .../directshow/mediaplayer/directshowiosource.cpp | 639 -------- .../directshow/mediaplayer/directshowiosource.h | 157 -- .../directshow/mediaplayer/directshowmediatype.cpp | 205 --- .../directshow/mediaplayer/directshowmediatype.h | 85 -- .../mediaplayer/directshowmediatypelist.cpp | 229 --- .../mediaplayer/directshowmediatypelist.h | 78 - .../mediaplayer/directshowmetadatacontrol.cpp | 370 ----- .../mediaplayer/directshowmetadatacontrol.h | 104 -- .../directshow/mediaplayer/directshowpinenum.cpp | 140 -- .../directshow/mediaplayer/directshowpinenum.h | 81 - .../mediaplayer/directshowplayercontrol.cpp | 395 ----- .../mediaplayer/directshowplayercontrol.h | 153 -- .../mediaplayer/directshowplayerservice.cpp | 1410 ----------------- .../mediaplayer/directshowplayerservice.h | 220 --- .../mediaplayer/directshowsamplescheduler.cpp | 403 ----- .../mediaplayer/directshowsamplescheduler.h | 126 -- .../mediaplayer/directshowvideooutputcontrol.cpp | 87 -- .../mediaplayer/directshowvideooutputcontrol.h | 75 - .../mediaplayer/directshowvideorenderercontrol.cpp | 93 -- .../mediaplayer/directshowvideorenderercontrol.h | 82 - .../directshow/mediaplayer/mediaplayer.pri | 45 - .../mediaplayer/mediasamplevideobuffer.cpp | 91 -- .../mediaplayer/mediasamplevideobuffer.h | 77 - .../directshow/mediaplayer/videosurfacefilter.cpp | 633 -------- .../directshow/mediaplayer/videosurfacefilter.h | 180 --- .../mediaplayer/vmr9videowindowcontrol.cpp | 317 ---- .../mediaplayer/vmr9videowindowcontrol.h | 116 -- src/plugins/mediaservices/gstreamer/gstreamer.pro | 59 - .../gstreamer/mediaplayer/mediaplayer.pri | 17 - .../mediaplayer/qgstreamermetadataprovider.cpp | 209 --- .../mediaplayer/qgstreamermetadataprovider.h | 83 - .../mediaplayer/qgstreamerplayercontrol.cpp | 501 ------ .../mediaplayer/qgstreamerplayercontrol.h | 138 -- .../mediaplayer/qgstreamerplayerservice.cpp | 149 -- .../mediaplayer/qgstreamerplayerservice.h | 101 -- .../mediaplayer/qgstreamerplayersession.cpp | 924 ----------- .../mediaplayer/qgstreamerplayersession.h | 176 --- .../gstreamer/qgstreamerbushelper.cpp | 206 --- .../mediaservices/gstreamer/qgstreamerbushelper.h | 87 -- .../mediaservices/gstreamer/qgstreamermessage.cpp | 97 -- .../mediaservices/gstreamer/qgstreamermessage.h | 76 - .../gstreamer/qgstreamerserviceplugin.cpp | 192 --- .../gstreamer/qgstreamerserviceplugin.h | 76 - .../qgstreamervideoinputdevicecontrol.cpp | 165 -- .../gstreamer/qgstreamervideoinputdevicecontrol.h | 85 -- .../gstreamer/qgstreamervideooutputcontrol.cpp | 77 - .../gstreamer/qgstreamervideooutputcontrol.h | 86 -- .../gstreamer/qgstreamervideooverlay.cpp | 230 --- .../gstreamer/qgstreamervideooverlay.h | 114 -- .../gstreamer/qgstreamervideorenderer.cpp | 88 -- .../gstreamer/qgstreamervideorenderer.h | 78 - .../gstreamer/qgstreamervideorendererinterface.cpp | 52 - .../gstreamer/qgstreamervideorendererinterface.h | 69 - .../gstreamer/qgstreamervideowidget.cpp | 340 ----- .../gstreamer/qgstreamervideowidget.h | 110 -- .../mediaservices/gstreamer/qgstvideobuffer.cpp | 101 -- .../mediaservices/gstreamer/qgstvideobuffer.h | 80 - .../mediaservices/gstreamer/qgstxvimagebuffer.cpp | 282 ---- .../mediaservices/gstreamer/qgstxvimagebuffer.h | 131 -- .../gstreamer/qvideosurfacegstsink.cpp | 713 --------- .../mediaservices/gstreamer/qvideosurfacegstsink.h | 163 -- .../mediaservices/gstreamer/qx11videosurface.cpp | 523 ------- .../mediaservices/gstreamer/qx11videosurface.h | 120 -- src/plugins/mediaservices/mediaservices.pro | 13 - .../mediaservices/qt7/mediaplayer/mediaplayer.pri | 18 - .../qt7/mediaplayer/qt7playercontrol.h | 128 -- .../qt7/mediaplayer/qt7playercontrol.mm | 193 --- .../qt7/mediaplayer/qt7playermetadata.h | 84 - .../qt7/mediaplayer/qt7playermetadata.mm | 274 ---- .../qt7/mediaplayer/qt7playerservice.h | 90 -- .../qt7/mediaplayer/qt7playerservice.mm | 152 -- .../qt7/mediaplayer/qt7playersession.h | 151 -- .../qt7/mediaplayer/qt7playersession.mm | 552 ------- src/plugins/mediaservices/qt7/qcvdisplaylink.h | 90 -- src/plugins/mediaservices/qt7/qcvdisplaylink.mm | 158 -- src/plugins/mediaservices/qt7/qt7.pro | 47 - src/plugins/mediaservices/qt7/qt7backend.h | 68 - src/plugins/mediaservices/qt7/qt7backend.mm | 60 - .../mediaservices/qt7/qt7ciimagevideobuffer.h | 90 -- .../mediaservices/qt7/qt7ciimagevideobuffer.mm | 107 -- src/plugins/mediaservices/qt7/qt7movierenderer.h | 112 -- src/plugins/mediaservices/qt7/qt7movierenderer.mm | 465 ------ .../mediaservices/qt7/qt7movievideowidget.h | 131 -- .../mediaservices/qt7/qt7movievideowidget.mm | 425 ------ src/plugins/mediaservices/qt7/qt7movieviewoutput.h | 119 -- .../mediaservices/qt7/qt7movieviewoutput.mm | 335 ---- .../mediaservices/qt7/qt7movieviewrenderer.h | 97 -- .../mediaservices/qt7/qt7movieviewrenderer.mm | 366 ----- src/plugins/mediaservices/qt7/qt7serviceplugin.h | 64 - src/plugins/mediaservices/qt7/qt7serviceplugin.mm | 78 - .../mediaservices/qt7/qt7videooutputcontrol.h | 135 -- .../mediaservices/qt7/qt7videooutputcontrol.mm | 93 -- .../symbian/mediaplayer/mediaplayer.pri | 63 - .../symbian/mediaplayer/ms60mediaplayerresolver.h | 58 - .../symbian/mediaplayer/s60audioplayersession.cpp | 275 ---- .../symbian/mediaplayer/s60audioplayersession.h | 124 -- .../mediaplayer/s60mediametadataprovider.cpp | 185 --- .../symbian/mediaplayer/s60mediametadataprovider.h | 81 - .../s60mediaplayeraudioendpointselector.cpp | 127 -- .../s60mediaplayeraudioendpointselector.h | 81 - .../symbian/mediaplayer/s60mediaplayercontrol.cpp | 274 ---- .../symbian/mediaplayer/s60mediaplayercontrol.h | 143 -- .../symbian/mediaplayer/s60mediaplayerservice.cpp | 259 ---- .../symbian/mediaplayer/s60mediaplayerservice.h | 105 -- .../symbian/mediaplayer/s60mediaplayersession.cpp | 496 ------ .../symbian/mediaplayer/s60mediaplayersession.h | 167 -- .../symbian/mediaplayer/s60mediarecognizer.cpp | 127 -- .../symbian/mediaplayer/s60mediarecognizer.h | 83 - .../symbian/mediaplayer/s60videooverlay.cpp | 209 --- .../symbian/mediaplayer/s60videooverlay.h | 109 -- .../symbian/mediaplayer/s60videoplayersession.cpp | 486 ------ .../symbian/mediaplayer/s60videoplayersession.h | 148 -- .../symbian/mediaplayer/s60videorenderer.cpp | 69 - .../symbian/mediaplayer/s60videorenderer.h | 68 - .../symbian/mediaplayer/s60videosurface.cpp | 478 ------ .../symbian/mediaplayer/s60videosurface.h | 112 -- .../symbian/mediaplayer/s60videowidget.cpp | 208 --- .../symbian/mediaplayer/s60videowidget.h | 115 -- .../symbian/s60mediaserviceplugin.cpp | 100 -- .../mediaservices/symbian/s60mediaserviceplugin.h | 64 - .../symbian/s60videooutputcontrol.cpp | 76 - .../mediaservices/symbian/s60videooutputcontrol.h | 72 - src/plugins/mediaservices/symbian/symbian.pro | 27 - src/plugins/plugins.pro | 2 +- src/s60installs/bwins/QtMediaServicesu.def | 673 -------- src/s60installs/eabi/QtMediaServicesu.def | 674 -------- src/src.pro | 7 +- tests/auto/auto.pro | 1 - tests/auto/mediaservices.pro | 19 - tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro | 14 - .../qdeclarativeaudio/tst_qdeclarativeaudio.cpp | 1252 --------------- tests/auto/qdeclarativevideo/qdeclarativevideo.pro | 14 - .../qdeclarativevideo/tst_qdeclarativevideo.cpp | 921 ----------- .../auto/qgraphicsvideoitem/qgraphicsvideoitem.pro | 5 - .../qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp | 670 -------- tests/auto/qmediacontent/qmediacontent.pro | 6 - tests/auto/qmediacontent/tst_qmediacontent.cpp | 174 --- tests/auto/qmediaobject/qmediaobject.pro | 4 - tests/auto/qmediaobject/tst_qmediaobject.cpp | 549 ------- tests/auto/qmediaplayer/qmediaplayer.pro | 6 - tests/auto/qmediaplayer/tst_qmediaplayer.cpp | 986 ------------ tests/auto/qmediaplaylist/qmediaplaylist.pro | 6 - tests/auto/qmediaplaylist/tmp.unsupported_format | 0 tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp | 593 -------- .../qmediaplaylistnavigator.pro | 6 - .../tst_qmediaplaylistnavigator.cpp | 316 ---- .../auto/qmediapluginloader/qmediapluginloader.pro | 6 - .../qmediapluginloader/tst_qmediapluginloader.cpp | 121 -- tests/auto/qmediaresource/qmediaresource.pro | 6 - tests/auto/qmediaresource/tst_qmediaresource.cpp | 516 ------- tests/auto/qmediaservice/qmediaservice.pro | 6 - tests/auto/qmediaservice/tst_qmediaservice.cpp | 219 --- .../qmediaserviceprovider.pro | 6 - .../tst_qmediaserviceprovider.cpp | 481 ------ tests/auto/qmediatimerange/qmediatimerange.pro | 6 - tests/auto/qmediatimerange/tst_qmediatimerange.cpp | 735 --------- tests/auto/qsoundeffect/qsoundeffect.pro | 20 - tests/auto/qsoundeffect/tst_qsoundeffect.cpp | 144 -- tests/auto/qvideowidget/qvideowidget.pro | 6 - tests/auto/qvideowidget/tst_qvideowidget.cpp | 1602 -------------------- tools/configure/configureapp.cpp | 29 +- translations/qt_de.ts | 9 - translations/qt_pl.ts | 42 - 398 files changed, 16150 insertions(+), 72832 deletions(-) delete mode 100644 demos/multimedia/multimedia.pro delete mode 100644 demos/multimedia/player/main.cpp delete mode 100644 demos/multimedia/player/player.cpp delete mode 100644 demos/multimedia/player/player.h delete mode 100644 demos/multimedia/player/player.pro delete mode 100644 demos/multimedia/player/playercontrols.cpp delete mode 100644 demos/multimedia/player/playercontrols.h delete mode 100644 demos/multimedia/player/playlistmodel.cpp delete mode 100644 demos/multimedia/player/playlistmodel.h delete mode 100644 demos/multimedia/player/videowidget.cpp delete mode 100644 demos/multimedia/player/videowidget.h delete mode 100644 src/imports/multimedia/multimedia.cpp delete mode 100644 src/imports/multimedia/multimedia.pro delete mode 100644 src/imports/multimedia/qdeclarativeaudio.cpp delete mode 100644 src/imports/multimedia/qdeclarativeaudio_p.h delete mode 100644 src/imports/multimedia/qdeclarativemediabase.cpp delete mode 100644 src/imports/multimedia/qdeclarativemediabase_p.h delete mode 100644 src/imports/multimedia/qdeclarativevideo.cpp delete mode 100644 src/imports/multimedia/qdeclarativevideo_p.h delete mode 100644 src/imports/multimedia/qmetadatacontrolmetaobject.cpp delete mode 100644 src/imports/multimedia/qmetadatacontrolmetaobject_p.h delete mode 100644 src/imports/multimedia/qmldir create mode 100644 src/multimedia/audio/audio.pri create mode 100644 src/multimedia/audio/qaudio.cpp create mode 100644 src/multimedia/audio/qaudio.h create mode 100644 src/multimedia/audio/qaudio_mac.cpp create mode 100644 src/multimedia/audio/qaudio_mac_p.h create mode 100644 src/multimedia/audio/qaudio_symbian_p.cpp create mode 100644 src/multimedia/audio/qaudio_symbian_p.h create mode 100644 src/multimedia/audio/qaudiodevicefactory.cpp create mode 100644 src/multimedia/audio/qaudiodevicefactory_p.h create mode 100644 src/multimedia/audio/qaudiodeviceinfo.cpp create mode 100644 src/multimedia/audio/qaudiodeviceinfo.h create mode 100644 src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp create mode 100644 src/multimedia/audio/qaudiodeviceinfo_alsa_p.h create mode 100644 src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp create mode 100644 src/multimedia/audio/qaudiodeviceinfo_mac_p.h create mode 100644 src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp create mode 100644 src/multimedia/audio/qaudiodeviceinfo_symbian_p.h create mode 100644 src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp create mode 100644 src/multimedia/audio/qaudiodeviceinfo_win32_p.h create mode 100644 src/multimedia/audio/qaudioengine.cpp create mode 100644 src/multimedia/audio/qaudioengine.h create mode 100644 src/multimedia/audio/qaudioengineplugin.cpp create mode 100644 src/multimedia/audio/qaudioengineplugin.h create mode 100644 src/multimedia/audio/qaudioformat.cpp create mode 100644 src/multimedia/audio/qaudioformat.h create mode 100644 src/multimedia/audio/qaudioinput.cpp create mode 100644 src/multimedia/audio/qaudioinput.h create mode 100644 src/multimedia/audio/qaudioinput_alsa_p.cpp create mode 100644 src/multimedia/audio/qaudioinput_alsa_p.h create mode 100644 src/multimedia/audio/qaudioinput_mac_p.cpp create mode 100644 src/multimedia/audio/qaudioinput_mac_p.h create mode 100644 src/multimedia/audio/qaudioinput_symbian_p.cpp create mode 100644 src/multimedia/audio/qaudioinput_symbian_p.h create mode 100644 src/multimedia/audio/qaudioinput_win32_p.cpp create mode 100644 src/multimedia/audio/qaudioinput_win32_p.h create mode 100644 src/multimedia/audio/qaudiooutput.cpp create mode 100644 src/multimedia/audio/qaudiooutput.h create mode 100644 src/multimedia/audio/qaudiooutput_alsa_p.cpp create mode 100644 src/multimedia/audio/qaudiooutput_alsa_p.h create mode 100644 src/multimedia/audio/qaudiooutput_mac_p.cpp create mode 100644 src/multimedia/audio/qaudiooutput_mac_p.h create mode 100644 src/multimedia/audio/qaudiooutput_symbian_p.cpp create mode 100644 src/multimedia/audio/qaudiooutput_symbian_p.h create mode 100644 src/multimedia/audio/qaudiooutput_win32_p.cpp create mode 100644 src/multimedia/audio/qaudiooutput_win32_p.h delete mode 100644 src/multimedia/mediaservices/base/base.pri delete mode 100644 src/multimedia/mediaservices/base/qgraphicsvideoitem.cpp delete mode 100644 src/multimedia/mediaservices/base/qgraphicsvideoitem.h delete mode 100644 src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.cpp delete mode 100644 src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.h delete mode 100644 src/multimedia/mediaservices/base/qmediacontent.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediacontent.h delete mode 100644 src/multimedia/mediaservices/base/qmediacontrol.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediacontrol.h delete mode 100644 src/multimedia/mediaservices/base/qmediacontrol_p.h delete mode 100644 src/multimedia/mediaservices/base/qmediaobject.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediaobject.h delete mode 100644 src/multimedia/mediaservices/base/qmediaobject_p.h delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylist.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylist.h delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylist_p.h delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylistcontrol.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylistcontrol.h delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylistioplugin.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylistioplugin.h delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylistnavigator.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylistnavigator.h delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylistprovider.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylistprovider.h delete mode 100644 src/multimedia/mediaservices/base/qmediaplaylistprovider_p.h delete mode 100644 src/multimedia/mediaservices/base/qmediapluginloader.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediapluginloader_p.h delete mode 100644 src/multimedia/mediaservices/base/qmediaresource.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediaresource.h delete mode 100644 src/multimedia/mediaservices/base/qmediaservice.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediaservice.h delete mode 100644 src/multimedia/mediaservices/base/qmediaservice_p.h delete mode 100644 src/multimedia/mediaservices/base/qmediaserviceprovider.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediaserviceprovider.h delete mode 100644 src/multimedia/mediaservices/base/qmediaserviceproviderplugin.h delete mode 100644 src/multimedia/mediaservices/base/qmediatimerange.cpp delete mode 100644 src/multimedia/mediaservices/base/qmediatimerange.h delete mode 100644 src/multimedia/mediaservices/base/qmetadatacontrol.cpp delete mode 100644 src/multimedia/mediaservices/base/qmetadatacontrol.h delete mode 100644 src/multimedia/mediaservices/base/qpaintervideosurface.cpp delete mode 100644 src/multimedia/mediaservices/base/qpaintervideosurface_mac.mm delete mode 100644 src/multimedia/mediaservices/base/qpaintervideosurface_mac_p.h delete mode 100644 src/multimedia/mediaservices/base/qpaintervideosurface_p.h delete mode 100644 src/multimedia/mediaservices/base/qtmedianamespace.h delete mode 100644 src/multimedia/mediaservices/base/qtmedianamespace.qdoc delete mode 100644 src/multimedia/mediaservices/base/qvideodevicecontrol.cpp delete mode 100644 src/multimedia/mediaservices/base/qvideodevicecontrol.h delete mode 100644 src/multimedia/mediaservices/base/qvideooutputcontrol.cpp delete mode 100644 src/multimedia/mediaservices/base/qvideooutputcontrol.h delete mode 100644 src/multimedia/mediaservices/base/qvideorenderercontrol.cpp delete mode 100644 src/multimedia/mediaservices/base/qvideorenderercontrol.h delete mode 100644 src/multimedia/mediaservices/base/qvideowidget.cpp delete mode 100644 src/multimedia/mediaservices/base/qvideowidget.h delete mode 100644 src/multimedia/mediaservices/base/qvideowidget_p.h delete mode 100644 src/multimedia/mediaservices/base/qvideowidgetcontrol.cpp delete mode 100644 src/multimedia/mediaservices/base/qvideowidgetcontrol.h delete mode 100644 src/multimedia/mediaservices/base/qvideowindowcontrol.cpp delete mode 100644 src/multimedia/mediaservices/base/qvideowindowcontrol.h delete mode 100644 src/multimedia/mediaservices/effects/effects.pri delete mode 100644 src/multimedia/mediaservices/effects/qsoundeffect.cpp delete mode 100644 src/multimedia/mediaservices/effects/qsoundeffect_p.h delete mode 100644 src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.cpp delete mode 100644 src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.h delete mode 100644 src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.cpp delete mode 100644 src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.h delete mode 100644 src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.cpp delete mode 100644 src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.h delete mode 100644 src/multimedia/mediaservices/effects/wavedecoder_p.cpp delete mode 100644 src/multimedia/mediaservices/effects/wavedecoder_p.h delete mode 100644 src/multimedia/mediaservices/mediaservices.pro delete mode 100644 src/multimedia/mediaservices/playback/playback.pri delete mode 100644 src/multimedia/mediaservices/playback/qmediaplayer.cpp delete mode 100644 src/multimedia/mediaservices/playback/qmediaplayer.h delete mode 100644 src/multimedia/mediaservices/playback/qmediaplayercontrol.cpp delete mode 100644 src/multimedia/mediaservices/playback/qmediaplayercontrol.h delete mode 100644 src/multimedia/multimedia/audio/audio.pri delete mode 100644 src/multimedia/multimedia/audio/qaudio.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudio.h delete mode 100644 src/multimedia/multimedia/audio/qaudio_mac.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudio_mac_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudio_symbian_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudio_symbian_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudiodevicefactory.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudiodevicefactory_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudiodeviceinfo.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudiodeviceinfo.h delete mode 100644 src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudioengine.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudioengine.h delete mode 100644 src/multimedia/multimedia/audio/qaudioengineplugin.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudioengineplugin.h delete mode 100644 src/multimedia/multimedia/audio/qaudioformat.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudioformat.h delete mode 100644 src/multimedia/multimedia/audio/qaudioinput.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudioinput.h delete mode 100644 src/multimedia/multimedia/audio/qaudioinput_alsa_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudioinput_alsa_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudioinput_mac_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudioinput_mac_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudioinput_symbian_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudioinput_symbian_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudioinput_win32_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudioinput_win32_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudiooutput.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudiooutput.h delete mode 100644 src/multimedia/multimedia/audio/qaudiooutput_alsa_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudiooutput_alsa_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudiooutput_mac_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudiooutput_mac_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudiooutput_symbian_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudiooutput_symbian_p.h delete mode 100644 src/multimedia/multimedia/audio/qaudiooutput_win32_p.cpp delete mode 100644 src/multimedia/multimedia/audio/qaudiooutput_win32_p.h delete mode 100644 src/multimedia/multimedia/multimedia.pro delete mode 100644 src/multimedia/multimedia/video/qabstractvideobuffer.cpp delete mode 100644 src/multimedia/multimedia/video/qabstractvideobuffer.h delete mode 100644 src/multimedia/multimedia/video/qabstractvideobuffer_p.h delete mode 100644 src/multimedia/multimedia/video/qabstractvideosurface.cpp delete mode 100644 src/multimedia/multimedia/video/qabstractvideosurface.h delete mode 100644 src/multimedia/multimedia/video/qabstractvideosurface_p.h delete mode 100644 src/multimedia/multimedia/video/qimagevideobuffer.cpp delete mode 100644 src/multimedia/multimedia/video/qimagevideobuffer_p.h delete mode 100644 src/multimedia/multimedia/video/qmemoryvideobuffer.cpp delete mode 100644 src/multimedia/multimedia/video/qmemoryvideobuffer_p.h delete mode 100644 src/multimedia/multimedia/video/qvideoframe.cpp delete mode 100644 src/multimedia/multimedia/video/qvideoframe.h delete mode 100644 src/multimedia/multimedia/video/qvideosurfaceformat.cpp delete mode 100644 src/multimedia/multimedia/video/qvideosurfaceformat.h delete mode 100644 src/multimedia/multimedia/video/video.pri create mode 100644 src/multimedia/video/qabstractvideobuffer.cpp create mode 100644 src/multimedia/video/qabstractvideobuffer.h create mode 100644 src/multimedia/video/qabstractvideobuffer_p.h create mode 100644 src/multimedia/video/qabstractvideosurface.cpp create mode 100644 src/multimedia/video/qabstractvideosurface.h create mode 100644 src/multimedia/video/qabstractvideosurface_p.h create mode 100644 src/multimedia/video/qimagevideobuffer.cpp create mode 100644 src/multimedia/video/qimagevideobuffer_p.h create mode 100644 src/multimedia/video/qmemoryvideobuffer.cpp create mode 100644 src/multimedia/video/qmemoryvideobuffer_p.h create mode 100644 src/multimedia/video/qvideoframe.cpp create mode 100644 src/multimedia/video/qvideoframe.h create mode 100644 src/multimedia/video/qvideosurfaceformat.cpp create mode 100644 src/multimedia/video/qvideosurfaceformat.h create mode 100644 src/multimedia/video/video.pri delete mode 100644 src/plugins/mediaservices/directshow/directshow.pro delete mode 100644 src/plugins/mediaservices/directshow/dsserviceplugin.cpp delete mode 100644 src/plugins/mediaservices/directshow/dsserviceplugin.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowglobal.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/mediaplayer.pri delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.h delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp delete mode 100644 src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h delete mode 100644 src/plugins/mediaservices/gstreamer/gstreamer.pro delete mode 100644 src/plugins/mediaservices/gstreamer/mediaplayer/mediaplayer.pri delete mode 100644 src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.h delete mode 100644 src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h delete mode 100644 src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.h delete mode 100644 src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamerbushelper.h delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamermessage.h delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.h delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.h delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.h delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.h delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.h delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h delete mode 100644 src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qgstvideobuffer.h delete mode 100644 src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h delete mode 100644 src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h delete mode 100644 src/plugins/mediaservices/gstreamer/qx11videosurface.cpp delete mode 100644 src/plugins/mediaservices/gstreamer/qx11videosurface.h delete mode 100644 src/plugins/mediaservices/mediaservices.pro delete mode 100644 src/plugins/mediaservices/qt7/mediaplayer/mediaplayer.pri delete mode 100644 src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h delete mode 100644 src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm delete mode 100644 src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.h delete mode 100644 src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm delete mode 100644 src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.h delete mode 100644 src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm delete mode 100644 src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h delete mode 100644 src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm delete mode 100644 src/plugins/mediaservices/qt7/qcvdisplaylink.h delete mode 100644 src/plugins/mediaservices/qt7/qcvdisplaylink.mm delete mode 100644 src/plugins/mediaservices/qt7/qt7.pro delete mode 100644 src/plugins/mediaservices/qt7/qt7backend.h delete mode 100644 src/plugins/mediaservices/qt7/qt7backend.mm delete mode 100644 src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.h delete mode 100644 src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.mm delete mode 100644 src/plugins/mediaservices/qt7/qt7movierenderer.h delete mode 100644 src/plugins/mediaservices/qt7/qt7movierenderer.mm delete mode 100644 src/plugins/mediaservices/qt7/qt7movievideowidget.h delete mode 100644 src/plugins/mediaservices/qt7/qt7movievideowidget.mm delete mode 100644 src/plugins/mediaservices/qt7/qt7movieviewoutput.h delete mode 100644 src/plugins/mediaservices/qt7/qt7movieviewoutput.mm delete mode 100644 src/plugins/mediaservices/qt7/qt7movieviewrenderer.h delete mode 100644 src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm delete mode 100644 src/plugins/mediaservices/qt7/qt7serviceplugin.h delete mode 100644 src/plugins/mediaservices/qt7/qt7serviceplugin.mm delete mode 100644 src/plugins/mediaservices/qt7/qt7videooutputcontrol.h delete mode 100644 src/plugins/mediaservices/qt7/qt7videooutputcontrol.mm delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/mediaplayer.pri delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/ms60mediaplayerresolver.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.h delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.cpp delete mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.h delete mode 100644 src/plugins/mediaservices/symbian/s60mediaserviceplugin.cpp delete mode 100644 src/plugins/mediaservices/symbian/s60mediaserviceplugin.h delete mode 100644 src/plugins/mediaservices/symbian/s60videooutputcontrol.cpp delete mode 100644 src/plugins/mediaservices/symbian/s60videooutputcontrol.h delete mode 100644 src/plugins/mediaservices/symbian/symbian.pro delete mode 100644 src/s60installs/bwins/QtMediaServicesu.def delete mode 100644 src/s60installs/eabi/QtMediaServicesu.def delete mode 100644 tests/auto/mediaservices.pro delete mode 100644 tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro delete mode 100644 tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp delete mode 100644 tests/auto/qdeclarativevideo/qdeclarativevideo.pro delete mode 100644 tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp delete mode 100644 tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro delete mode 100644 tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp delete mode 100644 tests/auto/qmediacontent/qmediacontent.pro delete mode 100644 tests/auto/qmediacontent/tst_qmediacontent.cpp delete mode 100644 tests/auto/qmediaobject/qmediaobject.pro delete mode 100644 tests/auto/qmediaobject/tst_qmediaobject.cpp delete mode 100644 tests/auto/qmediaplayer/qmediaplayer.pro delete mode 100644 tests/auto/qmediaplayer/tst_qmediaplayer.cpp delete mode 100644 tests/auto/qmediaplaylist/qmediaplaylist.pro delete mode 100644 tests/auto/qmediaplaylist/tmp.unsupported_format delete mode 100644 tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp delete mode 100644 tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro delete mode 100644 tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp delete mode 100644 tests/auto/qmediapluginloader/qmediapluginloader.pro delete mode 100644 tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp delete mode 100644 tests/auto/qmediaresource/qmediaresource.pro delete mode 100644 tests/auto/qmediaresource/tst_qmediaresource.cpp delete mode 100644 tests/auto/qmediaservice/qmediaservice.pro delete mode 100644 tests/auto/qmediaservice/tst_qmediaservice.cpp delete mode 100644 tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro delete mode 100644 tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp delete mode 100644 tests/auto/qmediatimerange/qmediatimerange.pro delete mode 100644 tests/auto/qmediatimerange/tst_qmediatimerange.cpp delete mode 100644 tests/auto/qsoundeffect/qsoundeffect.pro delete mode 100644 tests/auto/qsoundeffect/tst_qsoundeffect.cpp delete mode 100644 tests/auto/qvideowidget/qvideowidget.pro delete mode 100644 tests/auto/qvideowidget/tst_qvideowidget.cpp diff --git a/bin/syncqt b/bin/syncqt index e36eeb6..71f2eab 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -50,8 +50,7 @@ my %modules = ( # path to module name map "QtDBus" => "$basedir/src/dbus", "QtWebKit" => "$basedir/src/3rdparty/webkit/WebCore", "phonon" => "$basedir/src/phonon", - "QtMultimedia" => "$basedir/src/multimedia/multimedia", - "QtMediaServices" => "$basedir/src/multimedia/mediaservices", + "QtMultimedia" => "$basedir/src/multimedia", ); my %moduleheaders = ( # restrict the module headers to those found in relative path "QtWebKit" => "../WebKit/qt/Api", diff --git a/configure b/configure index 6763969..035b7c1 100755 --- a/configure +++ b/configure @@ -682,8 +682,6 @@ CFG_RELEASE_QMAKE=no CFG_PHONON=auto CFG_PHONON_BACKEND=yes CFG_MULTIMEDIA=auto -CFG_MEDIASERVICES=auto -CFG_MEDIA_BACKEND=auto CFG_AUDIO_BACKEND=auto CFG_SVG=auto CFG_DECLARATIVE=auto @@ -938,7 +936,7 @@ while [ "$#" -gt 0 ]; do VAL=no ;; #Qt style yes options - -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-egl|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-carbon|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-mediaservices|-media-backend|-audio-backend|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config|-s60|-usedeffiles) + -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-egl|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-carbon|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-audio-backend|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config|-s60|-usedeffiles) VAR=`echo $1 | sed "s,^-\(.*\),\1,"` VAL=yes ;; @@ -2165,20 +2163,6 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; - mediaservices) - if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then - CFG_MEDIASERVICES="$VAL" - else - UNKNOWN_OPT=yes - fi - ;; - media-backend) - if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then - CFG_MEDIA_BACKEND="$VAL" - else - UNKNOWN_OPT=yes - fi - ;; audio-backend) if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then CFG_AUDIO_BACKEND="$VAL" @@ -3409,8 +3393,7 @@ Usage: $relconf [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir [-no-separate-debug-info] [-no-mmx] [-no-3dnow] [-no-sse] [-no-sse2] [-qtnamespace ] [-qtlibinfix ] [-separate-debug-info] [-armfpa] [-no-optimized-qmake] [-optimized-qmake] [-no-xmlpatterns] [-xmlpatterns] - [-no-multimedia] [-multimedia] [-no-mediaservices] [-mediaservices] - [-no-phonon] [-phonon] [-no-phonon-backend] [-phonon-backend] + [-no-multimedia] [-multimedia] [-no-phonon] [-phonon] [-no-phonon-backend] [-phonon-backend] [-no-media-backend] [-media-backend] [-no-audio-backend] [-audio-backend] [-no-openssl] [-openssl] [-openssl-linked] [-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit] [-no-javascript-jit] [-javascript-jit] @@ -3555,12 +3538,6 @@ fi -no-audio-backend .. Do not build the platform audio backend into QtMultimedia. + -audio-backend ..... Build the platform audio backend into QtMultimedia if available. - -no-mediaservices... Do not build the QtMediaServices module. - + -mediaservices...... Build the QtMediaServices module. - - -no-media-backend... Do not build platform mediaservices plugin. - + -media-backend..... Build the platform mediaservices plugin. - -no-phonon ......... Do not build the Phonon module. + -phonon ............ Build the Phonon module. Phonon is built if a decent C++ compiler is used. @@ -5181,21 +5158,8 @@ if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" ]; then fi fi - if [ "$CFG_GUI" = "no" ]; then - if [ "$CFG_MEDIA_BACKEND" = "auto" ]; then - CFG_MEDIA_BACKEND=no - fi - if [ "$CFG_MEDIA_BACKEND" != "no" ]; then - echo "Medias backend enabled, but GUI disabled." - echo " You might need to either enable the GUI or disable the media backend" - exit 1 - fi - elif [ "$CFG_MEDIA_BACKEND" = "auto" ]; then - CFG_MEDIA_BACKEND=yes - fi - # Auto-detect GStreamer support (needed for both Phonon & QtMultimedia) - if [ "$CFG_PHONON" != "no" -o "$CFG_MEDIASERVICES" != "no" ]; then + if [ "$CFG_PHONON" != "no" ]; then if [ "$CFG_GLIB" = "yes" -a "$CFG_GSTREAMER" != "no" ]; then if [ -n "$PKG_CONFIG" ]; then QT_CFLAGS_GSTREAMER=`$PKG_CONFIG --cflags gstreamer-0.10 gstreamer-plugins-base-0.10 2>/dev/null` @@ -6889,15 +6853,6 @@ else QT_CONFIG="$QT_CONFIG multimedia" fi -if [ "$CFG_MEDIASERVICES" = "no" ]; then - QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_MEDIASERVICES" -else - QT_CONFIG="$QT_CONFIG mediaservices" - if [ "$CFG_MEDIA_BACKEND" != "no" ]; then - QT_CONFIG="$QT_CONFIG media-backend" - fi -fi - if [ "$CFG_AUDIO_BACKEND" = "yes" ]; then QT_CONFIG="$QT_CONFIG audio-backend" fi @@ -7855,7 +7810,6 @@ echo "QtScriptTools module ... $CFG_SCRIPTTOOLS" echo "QtXmlPatterns module ... $CFG_XMLPATTERNS" echo "Phonon module .......... $CFG_PHONON" echo "Multimedia module ...... $CFG_MULTIMEDIA" -echo "Mediaservices module ... $CFG_MEDIASERVICES" echo "SVG module ............. $CFG_SVG" echo "WebKit module .......... $CFG_WEBKIT" if [ "$CFG_WEBKIT" = "yes" ]; then diff --git a/demos/demos.pro b/demos/demos.pro index 5e8a4ea..e475347 100644 --- a/demos/demos.pro +++ b/demos/demos.pro @@ -57,7 +57,6 @@ wince*:SUBDIRS += demos_sqlbrowser } contains(QT_CONFIG, phonon):!static:SUBDIRS += demos_mediaplayer contains(QT_CONFIG, webkit):contains(QT_CONFIG, svg):!symbian:SUBDIRS += demos_browser -contains(QT_CONFIG, multimedia):SUBDIRS += demos_multimedia contains(QT_CONFIG, declarative):SUBDIRS += demos_declarative # install @@ -89,7 +88,6 @@ demos_sqlbrowser.subdir = sqlbrowser demos_undo.subdir = undo demos_qtdemo.subdir = qtdemo demos_mediaplayer.subdir = qmediaplayer -demos_multimedia.subdir = multimedia demos_declarative.subdir = declarative demos_browser.subdir = browser diff --git a/demos/multimedia/multimedia.pro b/demos/multimedia/multimedia.pro deleted file mode 100644 index fa29a12..0000000 --- a/demos/multimedia/multimedia.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = subdirs -contains(QT_CONFIG, mediaservices): SUBDIRS = player - diff --git a/demos/multimedia/player/main.cpp b/demos/multimedia/player/main.cpp deleted file mode 100644 index 87c5b87..0000000 --- a/demos/multimedia/player/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications 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 "player.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - Player player; - player.show(); - - return app.exec(); -}; diff --git a/demos/multimedia/player/player.cpp b/demos/multimedia/player/player.cpp deleted file mode 100644 index bf314ee..0000000 --- a/demos/multimedia/player/player.cpp +++ /dev/null @@ -1,372 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications 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 "player.h" - -#include "playercontrols.h" -#include "playlistmodel.h" -#include "videowidget.h" - -#include -#include - -#include - -Player::Player(QWidget *parent) - : QWidget(parent) - , videoWidget(0) - , coverLabel(0) - , slider(0) - , colorDialog(0) -{ - player = new QMediaPlayer(this); - playlist = new QMediaPlaylist(this); - playlist->setMediaObject(player); - - connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64))); - connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64))); - connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged())); - connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int))); - connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - this, SLOT(statusChanged(QMediaPlayer::MediaStatus))); - connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int))); - - videoWidget = new VideoWidget; - videoWidget->setMediaObject(player); - - playlistModel = new PlaylistModel(this); - playlistModel->setPlaylist(playlist); - - playlistView = new QListView; - playlistView->setModel(playlistModel); - playlistView->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0)); - - connect(playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(jump(QModelIndex))); - - playbackModeBox = new QComboBox; - playbackModeBox->addItem(tr("Linear"), - QVariant::fromValue(QMediaPlaylist::Linear)); - playbackModeBox->addItem(tr("Loop"), - QVariant::fromValue(QMediaPlaylist::Loop)); - playbackModeBox->addItem(tr("Random"), - QVariant::fromValue(QMediaPlaylist::Random)); - playbackModeBox->addItem(tr("Current Item Once"), - QVariant::fromValue(QMediaPlaylist::CurrentItemOnce)); - playbackModeBox->addItem(tr("Current Item In Loop"), - QVariant::fromValue(QMediaPlaylist::CurrentItemInLoop)); - playbackModeBox->setCurrentIndex(0); - - connect(playbackModeBox, SIGNAL(activated(int)), SLOT(updatePlaybackMode())); - updatePlaybackMode(); - - slider = new QSlider(Qt::Horizontal); - slider->setRange(0, player->duration() / 1000); - - connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int))); - - QPushButton *openButton = new QPushButton(tr("Open")); - - connect(openButton, SIGNAL(clicked()), this, SLOT(open())); - - PlayerControls *controls = new PlayerControls; - controls->setState(player->state()); - controls->setVolume(player->volume()); - controls->setMuted(controls->isMuted()); - - connect(controls, SIGNAL(play()), player, SLOT(play())); - connect(controls, SIGNAL(pause()), player, SLOT(pause())); - connect(controls, SIGNAL(stop()), player, SLOT(stop())); - connect(controls, SIGNAL(next()), playlist, SLOT(next())); - connect(controls, SIGNAL(previous()), this, SLOT(previousClicked())); - connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int))); - connect(controls, SIGNAL(changeMuting(bool)), player, SLOT(setMuted(bool))); - connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal))); - - connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), - controls, SLOT(setState(QMediaPlayer::State))); - connect(player, SIGNAL(volumeChanged(int)), controls, SLOT(setVolume(int))); - connect(player, SIGNAL(mutedChanged(bool)), controls, SLOT(setMuted(bool))); - - QPushButton *fullScreenButton = new QPushButton(tr("FullScreen")); - fullScreenButton->setCheckable(true); - - if (videoWidget != 0) { - connect(fullScreenButton, SIGNAL(clicked(bool)), videoWidget, SLOT(setFullScreen(bool))); - connect(videoWidget, SIGNAL(fullScreenChanged(bool)), - fullScreenButton, SLOT(setChecked(bool))); - } else { - fullScreenButton->setEnabled(false); - } - - QPushButton *colorButton = new QPushButton(tr("Color Options...")); - if (videoWidget) - connect(colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog())); - else - colorButton->setEnabled(false); - - QBoxLayout *playlistLayout = new QVBoxLayout; - playlistLayout->addWidget(playlistView); - playlistLayout->addWidget(playbackModeBox); - - QBoxLayout *displayLayout = new QHBoxLayout; - if (videoWidget) - displayLayout->addWidget(videoWidget, 2); - else - displayLayout->addWidget(coverLabel, 2); - displayLayout->addLayout(playlistLayout); - - QBoxLayout *controlLayout = new QHBoxLayout; - controlLayout->setMargin(0); - controlLayout->addWidget(openButton); - controlLayout->addStretch(1); - controlLayout->addWidget(controls); - controlLayout->addStretch(1); - controlLayout->addWidget(fullScreenButton); - controlLayout->addWidget(colorButton); - - QBoxLayout *layout = new QVBoxLayout; - layout->addLayout(displayLayout); - layout->addWidget(slider); - layout->addLayout(controlLayout); - - setLayout(layout); - - metaDataChanged(); - - QStringList arguments = qApp->arguments(); - arguments.removeAt(0); - foreach (QString const &argument, arguments) { - QFileInfo fileInfo(argument); - if (fileInfo.exists()) { - QUrl url = QUrl::fromLocalFile(fileInfo.absoluteFilePath()); - if (fileInfo.suffix().toLower() == QLatin1String("m3u")) { - playlist->load(url); - } else - playlist->addMedia(url); - } else { - QUrl url(argument); - if (url.isValid()) { - playlist->addMedia(url); - } - } - } -} - -Player::~Player() -{ - delete playlist; - delete player; -} - -void Player::open() -{ - QStringList fileNames = QFileDialog::getOpenFileNames(); - foreach (QString const &fileName, fileNames) - playlist->addMedia(QUrl::fromLocalFile(fileName)); -} - -void Player::durationChanged(qint64 duration) -{ - slider->setMaximum(duration / 1000); -} - -void Player::positionChanged(qint64 progress) -{ - slider->setValue(progress / 1000); -} - -void Player::metaDataChanged() -{ - //qDebug() << "update metadata" << player->metaData(QtMediaServices::Title).toString(); - if (player->isMetaDataAvailable()) { - setTrackInfo(QString("%1 - %2") - .arg(player->metaData(QtMediaServices::AlbumArtist).toString()) - .arg(player->metaData(QtMediaServices::Title).toString())); - - if (coverLabel) { - QUrl url = player->metaData(QtMediaServices::CoverArtUrlLarge).value(); - - coverLabel->setPixmap(!url.isEmpty() - ? QPixmap(url.toString()) - : QPixmap()); - } - } -} - -void Player::previousClicked() -{ - // Go to previous track if we are within the first 5 seconds of playback - // Otherwise, seek to the beginning. - if(player->position() <= 5000) - playlist->previous(); - else - player->setPosition(0); -} - -void Player::jump(const QModelIndex &index) -{ - if (index.isValid()) { - playlist->setCurrentIndex(index.row()); - player->play(); - } -} - -void Player::playlistPositionChanged(int currentItem) -{ - playlistView->setCurrentIndex(playlistModel->index(currentItem, 0)); -} - -void Player::seek(int seconds) -{ - player->setPosition(seconds * 1000); -} - -void Player::statusChanged(QMediaPlayer::MediaStatus status) -{ - switch (status) { - case QMediaPlayer::UnknownMediaStatus: - case QMediaPlayer::NoMedia: - case QMediaPlayer::LoadedMedia: - case QMediaPlayer::BufferingMedia: - case QMediaPlayer::BufferedMedia: -#ifndef QT_NO_CURSOR - unsetCursor(); -#endif - setStatusInfo(QString()); - break; - case QMediaPlayer::LoadingMedia: -#ifndef QT_NO_CURSOR - setCursor(QCursor(Qt::BusyCursor)); -#endif - setStatusInfo(tr("Loading...")); - break; - case QMediaPlayer::StalledMedia: -#ifndef QT_NO_CURSOR - setCursor(QCursor(Qt::BusyCursor)); -#endif - break; - case QMediaPlayer::EndOfMedia: -#ifndef QT_NO_CURSOR - unsetCursor(); -#endif - setStatusInfo(QString()); - QApplication::alert(this); - break; - case QMediaPlayer::InvalidMedia: -#ifndef QT_NO_CURSOR - unsetCursor(); -#endif - setStatusInfo(player->errorString()); - break; - } -} - -void Player::bufferingProgress(int progress) -{ - setStatusInfo(tr("Buffering %4%%").arg(progress)); -} - -void Player::setTrackInfo(const QString &info) -{ - trackInfo = info; - - if (!statusInfo.isEmpty()) - setWindowTitle(QString("%1 | %2").arg(trackInfo).arg(statusInfo)); - else - setWindowTitle(trackInfo); - -} - -void Player::setStatusInfo(const QString &info) -{ - statusInfo = info; - - if (!statusInfo.isEmpty()) - setWindowTitle(QString("%1 | %2").arg(trackInfo).arg(statusInfo)); - else - setWindowTitle(trackInfo); -} - -void Player::showColorDialog() -{ - if (!colorDialog) { - QSlider *brightnessSlider = new QSlider(Qt::Horizontal); - brightnessSlider->setRange(-100, 100); - brightnessSlider->setValue(videoWidget->brightness()); - connect(brightnessSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setBrightness(int))); - connect(videoWidget, SIGNAL(brightnessChanged(int)), brightnessSlider, SLOT(setValue(int))); - - QSlider *contrastSlider = new QSlider(Qt::Horizontal); - contrastSlider->setRange(-100, 100); - contrastSlider->setValue(videoWidget->contrast()); - connect(contrastSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setContrast(int))); - connect(videoWidget, SIGNAL(contrastChanged(int)), contrastSlider, SLOT(setValue(int))); - - QSlider *hueSlider = new QSlider(Qt::Horizontal); - hueSlider->setRange(-100, 100); - hueSlider->setValue(videoWidget->hue()); - connect(hueSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setHue(int))); - connect(videoWidget, SIGNAL(hueChanged(int)), hueSlider, SLOT(setValue(int))); - - QSlider *saturationSlider = new QSlider(Qt::Horizontal); - saturationSlider->setRange(-100, 100); - saturationSlider->setValue(videoWidget->saturation()); - connect(saturationSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setSaturation(int))); - connect(videoWidget, SIGNAL(saturationChanged(int)), saturationSlider, SLOT(setValue(int))); - - QFormLayout *layout = new QFormLayout; - layout->addRow(tr("Brightness"), brightnessSlider); - layout->addRow(tr("Contrast"), contrastSlider); - layout->addRow(tr("Hue"), hueSlider); - layout->addRow(tr("Saturation"), saturationSlider); - - colorDialog = new QDialog(this); - colorDialog->setWindowTitle(tr("Color Options")); - colorDialog->setLayout(layout); - } - colorDialog->show(); -} - -void Player::updatePlaybackMode() -{ - playlist->setPlaybackMode( - playbackModeBox->itemData(playbackModeBox->currentIndex()).value()); -} diff --git a/demos/multimedia/player/player.h b/demos/multimedia/player/player.h deleted file mode 100644 index cda3eb9..0000000 --- a/demos/multimedia/player/player.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications 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 PLAYER_H -#define PLAYER_H - -#include - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QAbstractItemView; -class QLabel; -class QModelIndex; -class QSlider; -class QComboBox; -class QMediaPlayer; -class QVideoWidget; -class PlaylistModel; - -class Player : public QWidget -{ - Q_OBJECT -public: - Player(QWidget *parent = 0); - ~Player(); - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - -private slots: - void open(); - void durationChanged(qint64 duration); - void positionChanged(qint64 progress); - void metaDataChanged(); - - void previousClicked(); - - void seek(int seconds); - void jump(const QModelIndex &index); - void playlistPositionChanged(int); - - void statusChanged(QMediaPlayer::MediaStatus status); - void bufferingProgress(int progress); - - void showColorDialog(); - void updatePlaybackMode(); - -private: - void setTrackInfo(const QString &info); - void setStatusInfo(const QString &info); - - QMediaPlayer *player; - QMediaPlaylist *playlist; - QVideoWidget *videoWidget; - QLabel *coverLabel; - QSlider *slider; - QComboBox *playbackModeBox; - PlaylistModel *playlistModel; - QAbstractItemView *playlistView; - QDialog *colorDialog; - QString trackInfo; - QString statusInfo; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/demos/multimedia/player/player.pro b/demos/multimedia/player/player.pro deleted file mode 100644 index 12bdf64..0000000 --- a/demos/multimedia/player/player.pro +++ /dev/null @@ -1,29 +0,0 @@ -TEMPLATE = app -TARGET = player - -QT += gui mediaservices - -HEADERS = \ - player.h \ - playercontrols.h \ - playlistmodel.h \ - videowidget.h - -SOURCES = \ - main.cpp \ - player.cpp \ - playercontrols.cpp \ - playlistmodel.cpp \ - videowidget.cpp - -target.path = $$[QT_INSTALL_DEMOS]/multimedia/player -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_DEMOS]/multimedia/player - -INSTALLS += target sources - -symbian { - TARGET.UID3 = 0xA000E3FA - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) -} - diff --git a/demos/multimedia/player/playercontrols.cpp b/demos/multimedia/player/playercontrols.cpp deleted file mode 100644 index 3798a71..0000000 --- a/demos/multimedia/player/playercontrols.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications 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 "playercontrols.h" - -#include -#include -#include -#include -#include - -PlayerControls::PlayerControls(QWidget *parent) - : QWidget(parent) - , playerState(QMediaPlayer::StoppedState) - , playerMuted(false) - , playButton(0) - , stopButton(0) - , nextButton(0) - , previousButton(0) - , muteButton(0) - , volumeSlider(0) - , rateBox(0) -{ - playButton = new QToolButton; - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - - connect(playButton, SIGNAL(clicked()), this, SLOT(playClicked())); - - stopButton = new QToolButton; - stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop)); - stopButton->setEnabled(false); - - connect(stopButton, SIGNAL(clicked()), this, SIGNAL(stop())); - - nextButton = new QToolButton; - nextButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); - - connect(nextButton, SIGNAL(clicked()), this, SIGNAL(next())); - - previousButton = new QToolButton; - previousButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); - - connect(previousButton, SIGNAL(clicked()), this, SIGNAL(previous())); - - muteButton = new QToolButton; - muteButton->setIcon(style()->standardIcon(QStyle::SP_MediaVolume)); - - connect(muteButton, SIGNAL(clicked()), this, SLOT(muteClicked())); - - volumeSlider = new QSlider(Qt::Horizontal); - volumeSlider->setRange(0, 100); - - connect(volumeSlider, SIGNAL(sliderMoved(int)), this, SIGNAL(changeVolume(int))); - - rateBox = new QComboBox; - rateBox->addItem("0.5x", QVariant(0.5)); - rateBox->addItem("1.0x", QVariant(1.0)); - rateBox->addItem("2.0x", QVariant(2.0)); - rateBox->setCurrentIndex(1); - - connect(rateBox, SIGNAL(activated(int)), SLOT(updateRate())); - - QBoxLayout *layout = new QHBoxLayout; - layout->setMargin(0); - layout->addWidget(stopButton); - layout->addWidget(previousButton); - layout->addWidget(playButton); - layout->addWidget(nextButton); - layout->addWidget(muteButton); - layout->addWidget(volumeSlider); - layout->addWidget(rateBox); - setLayout(layout); -} - -QMediaPlayer::State PlayerControls::state() const -{ - return playerState; -} - -void PlayerControls::setState(QMediaPlayer::State state) -{ - if (state != playerState) { - playerState = state; - - switch (state) { - case QMediaPlayer::StoppedState: - stopButton->setEnabled(false); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - case QMediaPlayer::PlayingState: - stopButton->setEnabled(true); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); - break; - case QMediaPlayer::PausedState: - stopButton->setEnabled(true); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - } - } -} - -int PlayerControls::volume() const -{ - return volumeSlider->value(); -} - -void PlayerControls::setVolume(int volume) -{ - volumeSlider->setValue(volume); -} - -bool PlayerControls::isMuted() const -{ - return playerMuted; -} - -void PlayerControls::setMuted(bool muted) -{ - if (muted != playerMuted) { - playerMuted = muted; - - muteButton->setIcon(style()->standardIcon(muted - ? QStyle::SP_MediaVolumeMuted - : QStyle::SP_MediaVolume)); - } -} - -void PlayerControls::playClicked() -{ - switch (playerState) { - case QMediaPlayer::StoppedState: - case QMediaPlayer::PausedState: - emit play(); - break; - case QMediaPlayer::PlayingState: - emit pause(); - break; - } -} - -void PlayerControls::muteClicked() -{ - emit changeMuting(!playerMuted); -} - -qreal PlayerControls::playbackRate() const -{ - return rateBox->itemData(rateBox->currentIndex()).toDouble(); -} - -void PlayerControls::setPlaybackRate(float rate) -{ - for (int i=0; icount(); i++) { - if (qFuzzyCompare(rate, float(rateBox->itemData(i).toDouble()))) { - rateBox->setCurrentIndex(i); - return; - } - } - - rateBox->addItem( QString("%1x").arg(rate), QVariant(rate)); - rateBox->setCurrentIndex(rateBox->count()-1); -} - -void PlayerControls::updateRate() -{ - emit changeRate(playbackRate()); -} diff --git a/demos/multimedia/player/playercontrols.h b/demos/multimedia/player/playercontrols.h deleted file mode 100644 index d2229bd..0000000 --- a/demos/multimedia/player/playercontrols.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications 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 PLAYERCONTROLS_H -#define PLAYERCONTROLS_H - -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QAbstractButton; -class QAbstractSlider; -class QComboBox; - -class PlayerControls : public QWidget -{ - Q_OBJECT -public: - PlayerControls(QWidget *parent = 0); - - QMediaPlayer::State state() const; - - int volume() const; - bool isMuted() const; - qreal playbackRate() const; - -public slots: - void setState(QMediaPlayer::State state); - void setVolume(int volume); - void setMuted(bool muted); - void setPlaybackRate(float rate); - -signals: - void play(); - void pause(); - void stop(); - void next(); - void previous(); - void changeVolume(int volume); - void changeMuting(bool muting); - void changeRate(qreal rate); - -private slots: - void playClicked(); - void muteClicked(); - void updateRate(); - -private: - QMediaPlayer::State playerState; - bool playerMuted; - QAbstractButton *playButton; - QAbstractButton *stopButton; - QAbstractButton *nextButton; - QAbstractButton *previousButton; - QAbstractButton *muteButton; - QAbstractSlider *volumeSlider; - QComboBox *rateBox; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/demos/multimedia/player/playlistmodel.cpp b/demos/multimedia/player/playlistmodel.cpp deleted file mode 100644 index b60f914..0000000 --- a/demos/multimedia/player/playlistmodel.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications 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 "playlistmodel.h" - -#include -#include - -#include - -PlaylistModel::PlaylistModel(QObject *parent) - : QAbstractItemModel(parent) - , m_playlist(0) -{ -} - -int PlaylistModel::rowCount(const QModelIndex &parent) const -{ - return m_playlist && !parent.isValid() ? m_playlist->mediaCount() : 0; -} - -int PlaylistModel::columnCount(const QModelIndex &parent) const -{ - return !parent.isValid() ? ColumnCount : 0; -} - -QModelIndex PlaylistModel::index(int row, int column, const QModelIndex &parent) const -{ - return m_playlist && !parent.isValid() - && row >= 0 && row < m_playlist->mediaCount() - && column >= 0 && column < ColumnCount - ? createIndex(row, column) - : QModelIndex(); -} - -QModelIndex PlaylistModel::parent(const QModelIndex &child) const -{ - Q_UNUSED(child); - - return QModelIndex(); -} - -QVariant PlaylistModel::data(const QModelIndex &index, int role) const -{ - if (index.isValid() && role == Qt::DisplayRole) { - QVariant value = m_data[index]; - if (!value.isValid() && index.column() == Title) { - QUrl location = m_playlist->media(index.row()).canonicalUrl(); - return QFileInfo(location.path()).fileName(); - } - - return value; - } - return QVariant(); -} - -QMediaPlaylist *PlaylistModel::playlist() const -{ - return m_playlist; -} - -void PlaylistModel::setPlaylist(QMediaPlaylist *playlist) -{ - if (m_playlist) { - disconnect(m_playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SLOT(beginInsertItems(int,int))); - disconnect(m_playlist, SIGNAL(mediaInserted(int,int)), this, SLOT(endInsertItems())); - disconnect(m_playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SLOT(beginRemoveItems(int,int))); - disconnect(m_playlist, SIGNAL(mediaRemoved(int,int)), this, SLOT(endRemoveItems())); - disconnect(m_playlist, SIGNAL(mediaChanged(int,int)), this, SLOT(changeItems(int,int))); - } - - m_playlist = playlist; - - if (m_playlist) { - connect(m_playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SLOT(beginInsertItems(int,int))); - connect(m_playlist, SIGNAL(mediaInserted(int,int)), this, SLOT(endInsertItems())); - connect(m_playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SLOT(beginRemoveItems(int,int))); - connect(m_playlist, SIGNAL(mediaRemoved(int,int)), this, SLOT(endRemoveItems())); - connect(m_playlist, SIGNAL(mediaChanged(int,int)), this, SLOT(changeItems(int,int))); - } - - - reset(); -} - -bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - Q_UNUSED(role); - m_data[index] = value; - emit dataChanged(index, index); - return true; -} - -void PlaylistModel::beginInsertItems(int start, int end) -{ - m_data.clear(); - beginInsertRows(QModelIndex(), start, end); -} - -void PlaylistModel::endInsertItems() -{ - endInsertRows(); -} - -void PlaylistModel::beginRemoveItems(int start, int end) -{ - m_data.clear(); - beginRemoveRows(QModelIndex(), start, end); -} - -void PlaylistModel::endRemoveItems() -{ - endInsertRows(); -} - -void PlaylistModel::changeItems(int start, int end) -{ - m_data.clear(); - emit dataChanged(index(start,0), index(end,ColumnCount)); -} - - diff --git a/demos/multimedia/player/playlistmodel.h b/demos/multimedia/player/playlistmodel.h deleted file mode 100644 index 0180282..0000000 --- a/demos/multimedia/player/playlistmodel.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications 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 PLAYLISTMODEL_H -#define PLAYLISTMODEL_H - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlaylist; - -class PlaylistModel : public QAbstractItemModel -{ - Q_OBJECT -public: - enum Column - { - Title = 0, - ColumnCount - }; - - PlaylistModel(QObject *parent = 0); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - - QMediaPlaylist *playlist() const; - void setPlaylist(QMediaPlaylist *playlist); - - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole); - -private slots: - void beginInsertItems(int start, int end); - void endInsertItems(); - void beginRemoveItems(int start, int end); - void endRemoveItems(); - void changeItems(int start, int end); - -private: - QMediaPlaylist *m_playlist; - QMap m_data; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/demos/multimedia/player/videowidget.cpp b/demos/multimedia/player/videowidget.cpp deleted file mode 100644 index be864ec..0000000 --- a/demos/multimedia/player/videowidget.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications 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 "videowidget.h" - -#include - -VideoWidget::VideoWidget(QWidget *parent) - : QVideoWidget(parent) -{ - setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - - QPalette p = palette(); - p.setColor(QPalette::Window, Qt::black); - setPalette(p); - - setAttribute(Qt::WA_OpaquePaintEvent); -} - -void VideoWidget::keyPressEvent(QKeyEvent *event) -{ - if (event->key() == Qt::Key_Escape && isFullScreen()) { - showNormal(); - - event->accept(); - } else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) { - setFullScreen(!isFullScreen()); - - event->accept(); - } else { - QVideoWidget::keyPressEvent(event); - } -} - -void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event) -{ - setFullScreen(!isFullScreen()); - - event->accept(); -} diff --git a/demos/multimedia/player/videowidget.h b/demos/multimedia/player/videowidget.h deleted file mode 100644 index b5bf581..0000000 --- a/demos/multimedia/player/videowidget.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications 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 VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class VideoWidget : public QVideoWidget -{ - Q_OBJECT -public: - VideoWidget(QWidget *parent = 0); - -protected: - void keyPressEvent(QKeyEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 7b0b4af..62cce62 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -36,7 +36,7 @@ INCLUDEPATH = $$QMAKE_INCDIR_QT $$INCLUDEPATH #prepending prevents us from picki win32:INCLUDEPATH += $$QMAKE_INCDIR_QT/ActiveQt # As order does matter for static libs, we reorder the QT variable here -TMPLIBS = declarative webkit phonon mediaservices multimedia dbus testlib script scripttools svg qt3support sql xmlpatterns xml egl opengl openvg gui network core +TMPLIBS = declarative webkit phonon multimedia dbus testlib script scripttools svg qt3support sql xmlpatterns xml egl opengl openvg gui network core for(QTLIB, $$list($$TMPLIBS)) { contains(QT, $$QTLIB): QT_ORDERED += $$QTLIB } @@ -175,7 +175,6 @@ for(QTLIB, $$list($$lower($$unique(QT)))) { } } else:isEqual(QTLIB, declarative):qlib = QtDeclarative else:isEqual(QTLIB, multimedia):qlib = QtMultimedia - else:isEqual(QTLIB, mediaservices):qlib = QtMediaServices else:message("Unknown QT: $$QTLIB"):qlib = !isEmpty(qlib) { target_qt:isEqual(TARGET, qlib) { diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 8359637..3118f8f 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1243,11 +1243,6 @@ class QDataStream; # else # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT # endif -# if defined(QT_BUILD_MEDIASERVICES_LIB) -# define Q_MEDIASERVICES_EXPORT Q_DECL_EXPORT -# else -# define Q_MEDIASERVICES_EXPORT Q_DECL_IMPORT -# endif # if defined(QT_BUILD_OPENVG_LIB) # define Q_OPENVG_EXPORT Q_DECL_EXPORT # else @@ -1294,7 +1289,6 @@ class QDataStream; # define Q_CANVAS_EXPORT Q_DECL_IMPORT # define Q_OPENGL_EXPORT Q_DECL_IMPORT # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT -# define Q_MEDIASERVICES_EXPORT Q_DECL_IMPORT # define Q_OPENVG_EXPORT Q_DECL_IMPORT # define Q_XML_EXPORT Q_DECL_IMPORT # define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT @@ -1323,7 +1317,6 @@ class QDataStream; # define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT # define Q_OPENGL_EXPORT Q_DECL_EXPORT # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT -# define Q_MEDIASERVICES_EXPORT Q_DECL_EXPORT # define Q_OPENVG_EXPORT Q_DECL_EXPORT # define Q_XML_EXPORT Q_DECL_EXPORT # define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT @@ -1339,7 +1332,6 @@ class QDataStream; # define Q_DECLARATIVE_EXPORT # define Q_OPENGL_EXPORT # define Q_MULTIMEDIA_EXPORT -# define Q_MEDIASERVICES_EXPORT # define Q_XML_EXPORT # define Q_XMLPATTERNS_EXPORT # define Q_SCRIPT_EXPORT diff --git a/src/imports/imports.pro b/src/imports/imports.pro index ecde0cc..8562fb5 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -3,5 +3,4 @@ TEMPLATE = subdirs SUBDIRS += widgets particles contains(QT_CONFIG, webkit): SUBDIRS += webkit -contains(QT_CONFIG, mediaservices): SUBDIRS += multimedia diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp deleted file mode 100644 index e2a2821..0000000 --- a/src/imports/multimedia/multimedia.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qdeclarativevideo_p.h" -#include "qdeclarativeaudio_p.h" - - -QML_DECLARE_TYPE(QSoundEffect) - -QT_BEGIN_NAMESPACE - -class QMultimediaDeclarativeModule : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.multimedia")); - - qmlRegisterType(uri, 4, 7, "SoundEffect"); - qmlRegisterType(uri, 4, 7, "Audio"); - qmlRegisterType(uri, 4, 7, "Video"); - } -}; - -QT_END_NAMESPACE - -#include "multimedia.moc" - -Q_EXPORT_PLUGIN2(qmultimediadeclarativemodule, QT_PREPEND_NAMESPACE(QMultimediaDeclarativeModule)); - diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro deleted file mode 100644 index 212f7b9..0000000 --- a/src/imports/multimedia/multimedia.pro +++ /dev/null @@ -1,36 +0,0 @@ -TARGET = multimedia -TARGETPATH = Qt/multimedia -include(../qimportbase.pri) - -QT += mediaservices declarative - -HEADERS += \ - qdeclarativeaudio_p.h \ - qdeclarativemediabase_p.h \ - qdeclarativevideo_p.h \ - qmetadatacontrolmetaobject_p.h \ - -SOURCES += \ - multimedia.cpp \ - qdeclarativeaudio.cpp \ - qdeclarativemediabase.cpp \ - qdeclarativevideo.cpp \ - qmetadatacontrolmetaobject.cpp - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/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/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp deleted file mode 100644 index a163b10..0000000 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qdeclarativeaudio_p.h" - -#include - -QT_BEGIN_NAMESPACE - - -/*! - \qmlclass Audio QDeclarativeAudio - \since 4.7 - \brief The Audio element allows you to add audio playback to a scene. - - This element is part of the \bold{Qt.multimedia 4.7} module. - - \qml - import Qt 4.7 - import Qt.multimedia 4.7 - - Text { - text: "Click Me!"; - font.pointSize: 24; - width: 150; height: 50; - - Audio { - id: playMusic - source: "music.wav" - } - MouseArea { - id: playArea - anchors.fill: parent - onPressed: { playMusic.play() } - } - } - \endqml - - \sa Video -*/ - -/*! - \internal - \class QDeclarativeAudio - \brief The QDeclarativeAudio class provides an audio item that you can add to a QDeclarativeView. -*/ - -void QDeclarativeAudio::_q_error(int errorCode, const QString &errorString) -{ - m_error = QMediaPlayer::Error(errorCode); - m_errorString = errorString; - - emit error(Error(errorCode), errorString); - emit errorChanged(); -} - - -QDeclarativeAudio::QDeclarativeAudio(QObject *parent) - : QObject(parent) -{ -} - -QDeclarativeAudio::~QDeclarativeAudio() -{ - shutdown(); -} - -/*! - \qmlmethod Audio::play() - - Starts playback of the media. - - Sets the \l playing property to true, and the \l paused property to false. -*/ - -void QDeclarativeAudio::play() -{ - if (m_playerControl == 0) - return; - - setPaused(false); - setPlaying(true); -} - -/*! - \qmlmethod Audio::pause() - - Pauses playback of the media. - - Sets the \l playing and \l paused properties to true. -*/ - -void QDeclarativeAudio::pause() -{ - if (m_playerControl == 0) - return; - - setPaused(true); - setPlaying(true); -} - -/*! - \qmlmethod Audio::stop() - - Stops playback of the media. - - Sets the \l playing and \l paused properties to false. -*/ - -void QDeclarativeAudio::stop() -{ - if (m_playerControl == 0) - return; - - setPlaying(false); - setPaused(false); -} - -/*! - \qmlproperty url Audio::source - - This property holds the source URL of the media. -*/ - -/*! - \qmlproperty url Audio::autoLoad - - This property indicates if loading of media should begin immediately. - - Defaults to true, if false media will not be loaded until playback is started. -*/ - -/*! - \qmlproperty bool Audio::playing - - This property holds whether the media is playing. - - Defaults to false, and can be set to true to start playback. -*/ - -/*! - \qmlproperty bool Audio::paused - - This property holds whether the media is paused. - - Defaults to false, and can be set to true to pause playback. -*/ - -/*! - \qmlsignal Audio::onStarted() - - This handler is called when playback is started. -*/ - -/*! - \qmlsignal Audio::onResumed() - - This handler is called when playback is resumed from the paused state. -*/ - -/*! - \qmlsignal Audio::onPaused() - - This handler is called when playback is paused. -*/ - -/*! - \qmlsignal Audio::onStopped() - - This handler is called when playback is stopped. -*/ - -/*! - \qmlproperty enumeration Audio::status - - This property holds the status of media loading. It can be one of: - - \list - \o NoMedia - no media has been set. - \o Loading - the media is currently being loaded. - \o Loaded - the media has been loaded. - \o Buffering - the media is buffering data. - \o Stalled - playback has been interrupted while the media is buffering data. - \o Buffered - the media has buffered data. - \o EndOfMedia - the media has played to the end. - \o InvalidMedia - the media cannot be played. - \o UnknownStatus - the status of the media is unknown. - \endlist -*/ - -QDeclarativeAudio::Status QDeclarativeAudio::status() const -{ - return Status(m_status); -} - -/*! - \qmlsignal Audio::onLoaded() - - This handler is called when the media source has been loaded. -*/ - -/*! - \qmlsignal Audio::onBuffering() - - This handler is called when the media starts buffering. -*/ - -/*! - \qmlsignal Audio::onStalled() - - This handler is called when playback has stalled while the media buffers. -*/ - -/*! - \qmlsignal Audio::onBuffered() - - This handler is called when the media has finished buffering. -*/ - -/*! - \qmlsignal Audio::onEndOfMedia() - - This handler is called when playback stops because end of the media has been reached. -*/ -/*! - \qmlproperty int Audio::duration - - This property holds the duration of the media in milliseconds. - - If the media doesn't have a fixed duration (a live stream for example) this will be 0. -*/ - -/*! - \qmlproperty int Audio::position - - This property holds the current playback position in milliseconds. - - If the \l seekable property is true, this property can be set to seek to a new position. -*/ - -/*! - \qmlproperty real Audio::volume - - This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume). -*/ - -/*! - \qmlproperty bool Audio::muted - - This property holds whether the audio output is muted. -*/ - -/*! - \qmlproperty real Audio::bufferProgress - - This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0 - (full). -*/ - -/*! - \qmlproperty bool Audio::seekable - - This property holds whether position of the audio can be changed. - - If true; setting a \l position value will cause playback to seek to the new position. -*/ - -/*! - \qmlproperty real Audio::playbackRate - - This property holds the rate at which audio is played at as a multiple of the normal rate. -*/ - -/*! - \qmlproperty enumeration Audio::error - - This property holds the error state of the audio. It can be one of: - - \list - \o NoError - there is no current error. - \o ResourceError - the audio cannot be played due to a problem allocating resources. - \o FormatError - the audio format is not supported. - \o NetworkError - the audio cannot be played due to network issues. - \o AccessDenied - the audio cannot be played due to insufficient permissions. - \o ServiceMissing - the audio cannot be played because the media service could not be - instantiated. - \endlist -*/ - -QDeclarativeAudio::Error QDeclarativeAudio::error() const -{ - return Error(m_error); -} - -void QDeclarativeAudio::componentComplete() -{ - setObject(this); -} - - -/*! - \qmlproperty string Audio::errorString - - This property holds a string describing the current error condition in more detail. -*/ - -/*! - \qmlsignal Audio::onError(error, errorString) - - This handler is called when an \l {QMediaPlayer::Error}{error} has - occurred. The errorString parameter may contain more detailed - information about the error. -*/ - -QT_END_NAMESPACE - -#include "moc_qdeclarativeaudio_p.cpp" - - diff --git a/src/imports/multimedia/qdeclarativeaudio_p.h b/src/imports/multimedia/qdeclarativeaudio_p.h deleted file mode 100644 index 24276ea..0000000 --- a/src/imports/multimedia/qdeclarativeaudio_p.h +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QDECLARATIVEAUDIO_P_H -#define QDECLARATIVEAUDIO_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativemediabase_p.h" - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QTimerEvent; - -class QDeclarativeAudio : public QObject, public QDeclarativeMediaBase, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged) - Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged) - Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(int duration READ duration NOTIFY durationChanged) - Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged) - Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged) - Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged) - Q_PROPERTY(Error error READ error NOTIFY errorChanged) - Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged) - Q_ENUMS(Status) - Q_ENUMS(Error) - Q_INTERFACES(QDeclarativeParserStatus) -public: - enum Status - { - UnknownStatus = QMediaPlayer::UnknownMediaStatus, - NoMedia = QMediaPlayer::NoMedia, - Loading = QMediaPlayer::LoadingMedia, - Loaded = QMediaPlayer::LoadedMedia, - Stalled = QMediaPlayer::StalledMedia, - Buffering = QMediaPlayer::BufferingMedia, - Buffered = QMediaPlayer::BufferedMedia, - EndOfMedia = QMediaPlayer::EndOfMedia, - InvalidMedia = QMediaPlayer::InvalidMedia - }; - - enum Error - { - NoError = QMediaPlayer::NoError, - ResourceError = QMediaPlayer::ResourceError, - FormatError = QMediaPlayer::FormatError, - NetworkError = QMediaPlayer::NetworkError, - AccessDenied = QMediaPlayer::AccessDeniedError, - ServiceMissing = QMediaPlayer::ServiceMissingError - }; - - QDeclarativeAudio(QObject *parent = 0); - ~QDeclarativeAudio(); - - Status status() const; - Error error() const; - - void componentComplete(); - -public Q_SLOTS: - void play(); - void pause(); - void stop(); - -Q_SIGNALS: - void sourceChanged(); - void autoLoadChanged(); - void playingChanged(); - void pausedChanged(); - - void started(); - void resumed(); - void paused(); - void stopped(); - - void statusChanged(); - - void loaded(); - void buffering(); - void stalled(); - void buffered(); - void endOfMedia(); - - void durationChanged(); - void positionChanged(); - - void volumeChanged(); - void mutedChanged(); - - void bufferProgressChanged(); - - void seekableChanged(); - void playbackRateChanged(); - - void errorChanged(); - void error(QDeclarativeAudio::Error error, const QString &errorString); - -private Q_SLOTS: - void _q_error(int, const QString &); - -private: - Q_DISABLE_COPY(QDeclarativeAudio) - Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State)) - Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus)) - Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged()) - - inline QDeclarativeMediaBase *mediaBase() { return this; } -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeAudio)) - -QT_END_HEADER - -#endif diff --git a/src/imports/multimedia/qdeclarativemediabase.cpp b/src/imports/multimedia/qdeclarativemediabase.cpp deleted file mode 100644 index ee0737b..0000000 --- a/src/imports/multimedia/qdeclarativemediabase.cpp +++ /dev/null @@ -1,528 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qdeclarativemediabase_p.h" - -#include -#include - -#include -#include -#include -#include -#include "qmetadatacontrolmetaobject_p.h" - - - -QT_BEGIN_NAMESPACE - - -class QDeclarativeMediaBaseObject : public QMediaObject -{ -public: - QDeclarativeMediaBaseObject(QMediaService *service) - : QMediaObject(0, service) - { - } -}; - -class QDeclarativeMediaBasePlayerControl : public QMediaPlayerControl -{ -public: - QDeclarativeMediaBasePlayerControl(QObject *parent) - : QMediaPlayerControl(parent) - { - } - - QMediaPlayer::State state() const { return QMediaPlayer::StoppedState; } - QMediaPlayer::MediaStatus mediaStatus() const { return QMediaPlayer::NoMedia; } - - qint64 duration() const { return 0; } - qint64 position() const { return 0; } - void setPosition(qint64) {} - int volume() const { return 0; } - void setVolume(int) {} - bool isMuted() const { return false; } - void setMuted(bool) {} - int bufferStatus() const { return 0; } - bool isAudioAvailable() const { return false; } - bool isVideoAvailable() const { return false; } - bool isSeekable() const { return false; } - QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); } - qreal playbackRate() const { return 1; } - void setPlaybackRate(qreal) {} - QMediaContent media() const { return QMediaContent(); } - const QIODevice *mediaStream() const { return 0; } - void setMedia(const QMediaContent &, QIODevice *) {} - - void play() {} - void pause() {} - void stop() {} -}; - -class QDeclarativeMediaBaseAnimation : public QObject -{ -public: - QDeclarativeMediaBaseAnimation(QDeclarativeMediaBase *media) - : m_media(media) - { - } - - void start() { if (!m_timer.isActive()) m_timer.start(500, this); } - void stop() { m_timer.stop(); } - -protected: - void timerEvent(QTimerEvent *event) - { - if (event->timerId() == m_timer.timerId()) { - event->accept(); - - if (m_media->m_state == QMediaPlayer::PlayingState) - emit m_media->positionChanged(); - if (m_media->m_status == QMediaPlayer::BufferingMedia || QMediaPlayer::StalledMedia) - emit m_media->bufferProgressChanged(); - } else { - QObject::timerEvent(event); - } - } - -private: - QDeclarativeMediaBase *m_media; - QBasicTimer m_timer; -}; - -void QDeclarativeMediaBase::_q_stateChanged(QMediaPlayer::State state) -{ - if (m_state == state) - return; - - switch (state) { - case QMediaPlayer::StoppedState: { - emit stopped(); - - if (m_playing) { - m_playing = false; - emit playingChanged(); - } - } - break; - case QMediaPlayer::PausedState: { - emit paused(); - - if (!m_paused) { - m_paused = true; - emit pausedChanged(); - } - - if (m_state == QMediaPlayer::StoppedState) - emit started(); - } - break; - case QMediaPlayer::PlayingState: { - if (m_state == QMediaPlayer::PausedState) - emit resumed(); - else - emit started(); - - if (m_paused) { - m_paused = false; - emit pausedChanged(); - } - } - break; - } - - // Check - if (state == QMediaPlayer::PlayingState - || m_status == QMediaPlayer::BufferingMedia - || m_status == QMediaPlayer::StalledMedia) { - m_animation->start(); - } - else { - m_animation->stop(); - } - - m_state = state; -} - -void QDeclarativeMediaBase::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status) -{ - if (status != m_status) { - m_status = status; - - switch (status) { - case QMediaPlayer::LoadedMedia: - emit loaded(); - break; - case QMediaPlayer::BufferingMedia: - emit buffering(); - break; - case QMediaPlayer::BufferedMedia: - emit buffered(); - break; - case QMediaPlayer::StalledMedia: - emit stalled(); - break; - case QMediaPlayer::EndOfMedia: - emit endOfMedia(); - break; - default: - break; - } - - emit statusChanged(); - - if (m_state == QMediaPlayer::PlayingState - || m_status == QMediaPlayer::BufferingMedia - || m_status == QMediaPlayer::StalledMedia) { - m_animation->start(); - } else { - m_animation->stop(); - } - } -} - -void QDeclarativeMediaBase::_q_metaDataChanged() -{ - m_metaObject->metaDataChanged(); -} - -QDeclarativeMediaBase::QDeclarativeMediaBase() - : m_paused(false) - , m_playing(false) - , m_autoLoad(true) - , m_loaded(false) - , m_muted(false) - , m_position(0) - , m_vol(1.0) - , m_playbackRate(1.0) - , m_mediaService(0) - , m_playerControl(0) - , m_mediaObject(0) - , m_mediaProvider(0) - , m_metaDataControl(0) - , m_metaObject(0) - , m_animation(0) - , m_state(QMediaPlayer::StoppedState) - , m_status(QMediaPlayer::NoMedia) - , m_error(QMediaPlayer::ServiceMissingError) -{ -} - -QDeclarativeMediaBase::~QDeclarativeMediaBase() -{ -} - -void QDeclarativeMediaBase::shutdown() -{ - delete m_metaObject; - delete m_mediaObject; - - if (m_mediaProvider) - m_mediaProvider->releaseService(m_mediaService); - - delete m_animation; - -} - -void QDeclarativeMediaBase::setObject(QObject *object) -{ - if ((m_mediaProvider = QMediaServiceProvider::defaultServiceProvider())) { - if ((m_mediaService = m_mediaProvider->requestService(Q_MEDIASERVICE_MEDIAPLAYER))) { - m_playerControl = qobject_cast( - m_mediaService->control(QMediaPlayerControl_iid)); - m_metaDataControl = qobject_cast( - m_mediaService->control(QMetaDataControl_iid)); - m_mediaObject = new QDeclarativeMediaBaseObject(m_mediaService); - } - } - - if (m_playerControl) { - QObject::connect(m_playerControl, SIGNAL(stateChanged(QMediaPlayer::State)), - object, SLOT(_q_stateChanged(QMediaPlayer::State))); - QObject::connect(m_playerControl, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - object, SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus))); - QObject::connect(m_playerControl, SIGNAL(mediaChanged(QMediaContent)), - object, SIGNAL(sourceChanged())); - QObject::connect(m_playerControl, SIGNAL(durationChanged(qint64)), - object, SIGNAL(durationChanged())); - QObject::connect(m_playerControl, SIGNAL(positionChanged(qint64)), - object, SIGNAL(positionChanged())); - QObject::connect(m_playerControl, SIGNAL(volumeChanged(int)), - object, SIGNAL(volumeChanged())); - QObject::connect(m_playerControl, SIGNAL(mutedChanged(bool)), - object, SIGNAL(mutedChanged())); - QObject::connect(m_playerControl, SIGNAL(bufferStatusChanged(int)), - object, SIGNAL(bufferProgressChanged())); - QObject::connect(m_playerControl, SIGNAL(seekableChanged(bool)), - object, SIGNAL(seekableChanged())); - QObject::connect(m_playerControl, SIGNAL(playbackRateChanged(qreal)), - object, SIGNAL(playbackRateChanged())); - QObject::connect(m_playerControl, SIGNAL(error(int,QString)), - object, SLOT(_q_error(int,QString))); - - m_animation = new QDeclarativeMediaBaseAnimation(this); - m_error = QMediaPlayer::NoError; - } else { - m_playerControl = new QDeclarativeMediaBasePlayerControl(object); - } - - if (m_metaDataControl) { - m_metaObject = new QMetaDataControlMetaObject(m_metaDataControl, object); - - QObject::connect(m_metaDataControl, SIGNAL(metaDataChanged()), - object, SLOT(_q_metaDataChanged())); - } - - // Init - m_playerControl->setVolume(m_vol * 100); - m_playerControl->setMuted(m_muted); - m_playerControl->setPlaybackRate(m_playbackRate); - - if (!m_source.isEmpty() && (m_autoLoad || m_playing)) // Override autoLoad if playing set - m_playerControl->setMedia(m_source, 0); - - if (m_paused) - m_playerControl->pause(); - else if (m_playing) - m_playerControl->play(); - - if ((m_playing || m_paused) && m_position > 0) - m_playerControl->setPosition(m_position); -} - - -// Properties - -QUrl QDeclarativeMediaBase::source() const -{ - return m_source; -} - -void QDeclarativeMediaBase::setSource(const QUrl &url) -{ - if (url == m_source) - return; - - m_source = url; - m_loaded = false; - if (m_playerControl != 0 && m_autoLoad) { - if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) { - m_error = QMediaPlayer::NoError; - m_errorString = QString(); - - emit errorChanged(); - } - - m_playerControl->setMedia(m_source, 0); - m_loaded = true; - } - else - emit sourceChanged(); -} - -bool QDeclarativeMediaBase::isAutoLoad() const -{ - return m_autoLoad; -} - -void QDeclarativeMediaBase::setAutoLoad(bool autoLoad) -{ - if (m_autoLoad == autoLoad) - return; - - m_autoLoad = autoLoad; - emit autoLoadChanged(); -} - -bool QDeclarativeMediaBase::isPlaying() const -{ - return m_playing; -} - -void QDeclarativeMediaBase::setPlaying(bool playing) -{ - if (playing == m_playing) - return; - - m_playing = playing; - if (m_playerControl != 0) { - if (m_playing) { - if (!m_autoLoad && !m_loaded) { - m_playerControl->setMedia(m_source, 0); - m_playerControl->setPosition(m_position); - m_loaded = true; - } - - if (!m_paused) - m_playerControl->play(); - else - m_playerControl->pause(); - } - else if (m_state != QMediaPlayer::StoppedState) - m_playerControl->stop(); - } - - emit playingChanged(); -} - -bool QDeclarativeMediaBase::isPaused() const -{ - return m_paused; -} - -void QDeclarativeMediaBase::setPaused(bool paused) -{ - if (m_paused == paused) - return; - - m_paused = paused; - if (m_playerControl != 0) { - if (!m_autoLoad && !m_loaded) { - m_playerControl->setMedia(m_source, 0); - m_playerControl->setPosition(m_position); - m_loaded = true; - } - - if (m_paused && m_state == QMediaPlayer::PlayingState) { - m_playerControl->pause(); - } - else if (!m_paused && m_playing) { - m_playerControl->play(); - } - } - - emit pausedChanged(); -} - -int QDeclarativeMediaBase::duration() const -{ - return m_playerControl == 0 ? 0 : m_playerControl->duration(); -} - -int QDeclarativeMediaBase::position() const -{ - return m_playerControl == 0 ? m_position : m_playerControl->position(); -} - -void QDeclarativeMediaBase::setPosition(int position) -{ - if (m_position == position) - return; - - m_position = position; - if (m_playerControl != 0) - m_playerControl->setPosition(m_position); - else - emit positionChanged(); -} - -qreal QDeclarativeMediaBase::volume() const -{ - return m_playerControl == 0 ? m_vol : qreal(m_playerControl->volume()) / 100; -} - -void QDeclarativeMediaBase::setVolume(qreal volume) -{ - if (m_vol == volume) - return; - - m_vol = volume; - - if (m_playerControl != 0) - m_playerControl->setVolume(qRound(volume * 100)); - else - emit volumeChanged(); -} - -bool QDeclarativeMediaBase::isMuted() const -{ - return m_playerControl == 0 ? m_muted : m_playerControl->isMuted(); -} - -void QDeclarativeMediaBase::setMuted(bool muted) -{ - if (m_muted == muted) - return; - - m_muted = muted; - - if (m_playerControl != 0) - m_playerControl->setMuted(muted); - else - emit mutedChanged(); -} - -qreal QDeclarativeMediaBase::bufferProgress() const -{ - return m_playerControl == 0 ? 0 : qreal(m_playerControl->bufferStatus()) / 100; -} - -bool QDeclarativeMediaBase::isSeekable() const -{ - return m_playerControl == 0 ? false : m_playerControl->isSeekable(); -} - -qreal QDeclarativeMediaBase::playbackRate() const -{ - return m_playbackRate; -} - -void QDeclarativeMediaBase::setPlaybackRate(qreal rate) -{ - if (m_playbackRate == rate) - return; - - m_playbackRate = rate; - - if (m_playerControl != 0) - m_playerControl->setPlaybackRate(m_playbackRate); - else - emit playbackRateChanged(); -} - -QString QDeclarativeMediaBase::errorString() const -{ - return m_errorString; -} - -QT_END_NAMESPACE - diff --git a/src/imports/multimedia/qdeclarativemediabase_p.h b/src/imports/multimedia/qdeclarativemediabase_p.h deleted file mode 100644 index 34875f9..0000000 --- a/src/imports/multimedia/qdeclarativemediabase_p.h +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QDECLARATIVEMEDIABASE_P_H -#define QDECLARATIVEMEDIABASE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlayerControl; -class QMediaService; -class QMediaServiceProvider; -class QMetaDataControl; -class QMetaDataControlMetaObject; -class QDeclarativeMediaBaseAnimation; - -class QDeclarativeMediaBase -{ -public: - QDeclarativeMediaBase(); - virtual ~QDeclarativeMediaBase(); - - QUrl source() const; - void setSource(const QUrl &url); - - bool isAutoLoad() const; - void setAutoLoad(bool autoLoad); - - bool isPlaying() const; - void setPlaying(bool playing); - - bool isPaused() const; - void setPaused(bool paused); - - int duration() const; - - int position() const; - void setPosition(int position); - - qreal volume() const; - void setVolume(qreal volume); - - bool isMuted() const; - void setMuted(bool muted); - - qreal bufferProgress() const; - - bool isSeekable() const; - - qreal playbackRate() const; - void setPlaybackRate(qreal rate); - - QString errorString() const; - - void _q_stateChanged(QMediaPlayer::State state); - void _q_mediaStatusChanged(QMediaPlayer::MediaStatus status); - - void _q_metaDataChanged(); - - void componentComplete(); - -protected: - void shutdown(); - - void setObject(QObject *object); - - virtual void sourceChanged() = 0; - virtual void autoLoadChanged() = 0; - virtual void playingChanged() = 0; - virtual void pausedChanged() = 0; - - virtual void started() = 0; - virtual void resumed() = 0; - virtual void paused() = 0; - virtual void stopped() = 0; - - virtual void statusChanged() = 0; - - virtual void loaded() = 0; - virtual void buffering() = 0; - virtual void stalled() = 0; - virtual void buffered() = 0; - virtual void endOfMedia() = 0; - - virtual void durationChanged() = 0; - virtual void positionChanged() = 0; - - virtual void volumeChanged() = 0; - virtual void mutedChanged() = 0; - - virtual void bufferProgressChanged() = 0; - - virtual void seekableChanged() = 0; - virtual void playbackRateChanged() = 0; - - virtual void errorChanged() = 0; - - bool m_paused; - bool m_playing; - bool m_autoLoad; - bool m_loaded; - bool m_muted; - int m_position; - qreal m_vol; - qreal m_playbackRate; - QMediaService *m_mediaService; - QMediaPlayerControl *m_playerControl; - - QMediaObject *m_mediaObject; - QMediaServiceProvider *m_mediaProvider; - QMetaDataControl *m_metaDataControl; - QMetaDataControlMetaObject *m_metaObject; - QDeclarativeMediaBaseAnimation *m_animation; - - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_status; - QMediaPlayer::Error m_error; - QString m_errorString; - QUrl m_source; - - friend class QDeclarativeMediaBaseAnimation; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/imports/multimedia/qdeclarativevideo.cpp b/src/imports/multimedia/qdeclarativevideo.cpp deleted file mode 100644 index 1b51e2c..0000000 --- a/src/imports/multimedia/qdeclarativevideo.cpp +++ /dev/null @@ -1,976 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qdeclarativevideo_p.h" - -#include -#include -#include -#include -#include - - -QT_BEGIN_NAMESPACE - - -void QDeclarativeVideo::_q_nativeSizeChanged(const QSizeF &size) -{ - setImplicitWidth(size.width()); - setImplicitHeight(size.height()); -} - -void QDeclarativeVideo::_q_error(int errorCode, const QString &errorString) -{ - m_error = QMediaPlayer::Error(errorCode); - m_errorString = errorString; - - emit error(Error(errorCode), errorString); - emit errorChanged(); -} - - -/*! - \qmlclass Video QDeclarativeVideo - \since 4.7 - \brief The Video element allows you to add videos to a scene. - \inherits Item - - This element is part of the \bold{Qt.multimedia 4.7} module. - - \qml - import Qt 4.7 - import Qt.multimedia 4.7 - - Video { - id: video - width : 800 - height : 600 - source: "video.avi" - - MouseArea { - anchors.fill: parent - onClicked: { - video.play() - } - } - - focus: true - Keys.onSpacePressed: video.paused = !video.paused - Keys.onLeftPressed: video.position -= 5000 - Keys.onRightPressed: video.position += 5000 - } - \endqml - - The Video item supports untransformed, stretched, and uniformly scaled video presentation. - For a description of stretched uniformly scaled presentation, see the \l fillMode property - description. - - The Video item is only visible when the \l hasVideo property is true and the video is playing. - - \sa Audio -*/ - -/*! - \internal - \class QDeclarativeVideo - \brief The QDeclarativeVideo class provides a video item that you can add to a QDeclarativeView. -*/ - -QDeclarativeVideo::QDeclarativeVideo(QDeclarativeItem *parent) - : QDeclarativeItem(parent) - , m_graphicsItem(0) - -{ - m_graphicsItem = new QGraphicsVideoItem(this); - connect(m_graphicsItem, SIGNAL(nativeSizeChanged(QSizeF)), - this, SLOT(_q_nativeSizeChanged(QSizeF))); -} - -QDeclarativeVideo::~QDeclarativeVideo() -{ - shutdown(); - - delete m_graphicsItem; -} - -/*! - \qmlproperty url Video::source - - This property holds the source URL of the media. -*/ - -/*! - \qmlproperty url Video::autoLoad - - This property indicates if loading of media should begin immediately. - - Defaults to true, if false media will not be loaded until playback is started. -*/ - -/*! - \qmlproperty bool Video::playing - - This property holds whether the media is playing. - - Defaults to false, and can be set to true to start playback. -*/ - -/*! - \qmlproperty bool Video::paused - - This property holds whether the media is paused. - - Defaults to false, and can be set to true to pause playback. -*/ - -/*! - \qmlsignal Video::onStarted() - - This handler is called when playback is started. -*/ - -/*! - \qmlsignal Video::onResumed() - - This handler is called when playback is resumed from the paused state. -*/ - -/*! - \qmlsignal Video::onPaused() - - This handler is called when playback is paused. -*/ - -/*! - \qmlsignal Video::onStopped() - - This handler is called when playback is stopped. -*/ - -/*! - \qmlproperty enumeration Video::status - - This property holds the status of media loading. It can be one of: - - \list - \o NoMedia - no media has been set. - \o Loading - the media is currently being loaded. - \o Loaded - the media has been loaded. - \o Buffering - the media is buffering data. - \o Stalled - playback has been interrupted while the media is buffering data. - \o Buffered - the media has buffered data. - \o EndOfMedia - the media has played to the end. - \o InvalidMedia - the media cannot be played. - \o UnknownStatus - the status of the media is cannot be determined. - \endlist -*/ - -QDeclarativeVideo::Status QDeclarativeVideo::status() const -{ - return Status(m_status); -} - -/*! - \qmlsignal Video::onLoaded() - - This handler is called when the media source has been loaded. -*/ - -/*! - \qmlsignal Video::onBuffering() - - This handler is called when the media starts buffering. -*/ - -/*! - \qmlsignal Video::onStalled() - - This handler is called when playback has stalled while the media buffers. -*/ - -/*! - \qmlsignal Video::onBuffered() - - This handler is called when the media has finished buffering. -*/ - -/*! - \qmlsignal Video::onEndOfMedia() - - This handler is called when playback stops because end of the media has been reached. -*/ - -/*! - \qmlproperty int Video::duration - - This property holds the duration of the media in milliseconds. - - If the media doesn't have a fixed duration (a live stream for example) this will be 0. -*/ - -/*! - \qmlproperty int Video::position - - This property holds the current playback position in milliseconds. -*/ - -/*! - \qmlproperty real Video::volume - - This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume). -*/ - -/*! - \qmlproperty bool Video::muted - - This property holds whether the audio output is muted. -*/ - -/*! - \qmlproperty bool Video::hasAudio - - This property holds whether the media contains audio. -*/ - -bool QDeclarativeVideo::hasAudio() const -{ - return m_playerControl == 0 ? false : m_playerControl->isAudioAvailable(); -} - -/*! - \qmlproperty bool Video::hasVideo - - This property holds whether the media contains video. -*/ - -bool QDeclarativeVideo::hasVideo() const -{ - return m_playerControl == 0 ? false : m_playerControl->isVideoAvailable(); -} - -/*! - \qmlproperty real Video::bufferProgress - - This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0 - (full). -*/ - -/*! - \qmlproperty bool Video::seekable - - This property holds whether position of the video can be changed. -*/ - -/*! - \qmlproperty real Video::playbackRate - - This property holds the rate at which video is played at as a multiple of the normal rate. -*/ - -/*! - \qmlproperty enumeration Video::error - - This property holds the error state of the video. It can be one of: - - \list - \o NoError - there is no current error. - \o ResourceError - the video cannot be played due to a problem allocating resources. - \o FormatError - the video format is not supported. - \o NetworkError - the video cannot be played due to network issues. - \o AccessDenied - the video cannot be played due to insufficient permissions. - \o ServiceMissing - the video cannot be played because the media service could not be - instantiated. - \endlist -*/ - - -QDeclarativeVideo::Error QDeclarativeVideo::error() const -{ - return Error(m_error); -} - -/*! - \qmlproperty string Video::errorString - - This property holds a string describing the current error condition in more detail. -*/ - -/*! - \qmlsignal Video::onError(error, errorString) - - This handler is called when an \l {QMediaPlayer::Error}{error} has - occurred. The errorString parameter may contain more detailed - information about the error. -*/ - -/*! - \qmlproperty enumeration Video::fillMode - - Set this property to define how the video is scaled to fit the target area. - - \list - \o Stretch - the video is scaled to fit. - \o PreserveAspectFit - the video is scaled uniformly to fit without cropping - \o PreserveAspectCrop - the video is scaled uniformly to fill, cropping if necessary - \endlist - - The default fill mode is PreserveAspectFit. -*/ - -QDeclarativeVideo::FillMode QDeclarativeVideo::fillMode() const -{ - return FillMode(m_graphicsItem->aspectRatioMode()); -} - -void QDeclarativeVideo::setFillMode(FillMode mode) -{ - m_graphicsItem->setAspectRatioMode(Qt::AspectRatioMode(mode)); -} - -/*! - \qmlmethod Video::play() - - Starts playback of the media. - - Sets the \l playing property to true, and the \l paused property to false. -*/ - -void QDeclarativeVideo::play() -{ - if (m_playerControl == 0) - return; - - setPaused(false); - setPlaying(true); -} - -/*! - \qmlmethod Video::pause() - - Pauses playback of the media. - - Sets the \l playing and \l paused properties to true. -*/ - -void QDeclarativeVideo::pause() -{ - if (m_playerControl == 0) - return; - - setPaused(true); - setPlaying(true); -} - -/*! - \qmlmethod Video::stop() - - Stops playback of the media. - - Sets the \l playing and \l paused properties to false. -*/ - -void QDeclarativeVideo::stop() -{ - if (m_playerControl == 0) - return; - - setPlaying(false); - setPaused(false); -} - -void QDeclarativeVideo::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) -{ -} - -void QDeclarativeVideo::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - m_graphicsItem->setSize(newGeometry.size()); - - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); -} - -void QDeclarativeVideo::componentComplete() -{ - setObject(this); - - if (m_mediaService) { - connect(m_playerControl, SIGNAL(audioAvailableChanged(bool)), - this, SIGNAL(hasAudioChanged())); - connect(m_playerControl, SIGNAL(videoAvailableChanged(bool)), - this, SIGNAL(hasVideoChanged())); - - m_graphicsItem->setMediaObject(m_mediaObject); - } -} - -QT_END_NAMESPACE - -// *************************************** -// Documentation for meta-data properties. -// *************************************** - -/*! - \qmlproperty variant Video::title - - This property holds the tile of the media. - - \sa {QtMediaServices::Title} -*/ - -/*! - \qmlproperty variant Video::subTitle - - This property holds the sub-title of the media. - - \sa {QtMediaServices::SubTitle} -*/ - -/*! - \qmlproperty variant Video::author - - This property holds the author of the media. - - \sa {QtMediaServices::Author} -*/ - -/*! - \qmlproperty variant Video::comment - - This property holds a user comment about the media. - - \sa {QtMediaServices::Comment} -*/ - -/*! - \qmlproperty variant Video::description - - This property holds a description of the media. - - \sa {QtMediaServices::Description} -*/ - -/*! - \qmlproperty variant Video::category - - This property holds the category of the media - - \sa {QtMediaServices::Category} -*/ - -/*! - \qmlproperty variant Video::genre - - This property holds the genre of the media. - - \sa {QtMediaServices::Genre} -*/ - -/*! - \qmlproperty variant Video::year - - This property holds the year of release of the media. - - \sa {QtMediaServices::Year} -*/ - -/*! - \qmlproperty variant Video::date - - This property holds the date of the media. - - \sa {QtMediaServices::Date} -*/ - -/*! - \qmlproperty variant Video::userRating - - This property holds a user rating of the media in the range of 0 to 100. - - \sa {QtMediaServices::UserRating} -*/ - -/*! - \qmlproperty variant Video::keywords - - This property holds a list of keywords describing the media. - - \sa {QtMediaServices::Keywords} -*/ - -/*! - \qmlproperty variant Video::language - - This property holds the language of the media, as an ISO 639-2 code. - - \sa {QtMediaServices::Language} -*/ - -/*! - \qmlproperty variant Video::publisher - - This property holds the publisher of the media. - - \sa {QtMediaServices::Publisher} -*/ - -/*! - \qmlproperty variant Video::copyright - - This property holds the media's copyright notice. - - \sa {QtMediaServices::Copyright} -*/ - -/*! - \qmlproperty variant Video::parentalRating - - This property holds the parental rating of the media. - - \sa {QtMediaServices::ParentalRating} -*/ - -/*! - \qmlproperty variant Video::ratingOrganisation - - This property holds the name of the rating organisation responsible for the - parental rating of the media. - - \sa {QtMediaServices::RatingOrganisation} -*/ - -/*! - \qmlproperty variant Video::size - - This property property holds the size of the media in bytes. - - \sa {QtMediaServices::Size} -*/ - -/*! - \qmlproperty variant Video::mediaType - - This property holds the type of the media. - - \sa {QtMediaServices::MediaType} -*/ - -/*! - \qmlproperty variant Video::audioBitRate - - This property holds the bit rate of the media's audio stream ni bits per - second. - - \sa {QtMediaServices::AudioBitRate} -*/ - -/*! - \qmlproperty variant Video::audioCodec - - This property holds the encoding of the media audio stream. - - \sa {QtMediaServices::AudioCodec} -*/ - -/*! - \qmlproperty variant Video::averageLevel - - This property holds the average volume level of the media. - - \sa {QtMediaServices::AverageLevel} -*/ - -/*! - \qmlproperty variant Video::channelCount - - This property holds the number of channels in the media's audio stream. - - \sa {QtMediaServices::ChannelCount} -*/ - -/*! - \qmlproperty variant Video::peakValue - - This property holds the peak volume of media's audio stream. - - \sa {QtMediaServices::PeakValue} -*/ - -/*! - \qmlproperty variant Video::sampleRate - - This property holds the sample rate of the media's audio stream in hertz. - - \sa {QtMediaServices::SampleRate} -*/ - -/*! - \qmlproperty variant Video::albumTitle - - This property holds the title of the album the media belongs to. - - \sa {QtMediaServices::AlbumTitle} -*/ - -/*! - \qmlproperty variant Video::albumArtist - - This property holds the name of the principal artist of the album the media - belongs to. - - \sa {QtMediaServices::AlbumArtist} -*/ - -/*! - \qmlproperty variant Video::contributingArtist - - This property holds the names of artists contributing to the media. - - \sa {QtMediaServices::ContributingArtist} -*/ - -/*! - \qmlproperty variant Video::composer - - This property holds the composer of the media. - - \sa {QtMediaServices::Composer} -*/ - -/*! - \qmlproperty variant Video::conductor - - This property holds the conductor of the media. - - \sa {QtMediaServices::Conductor} -*/ - -/*! - \qmlproperty variant Video::lyrics - - This property holds the lyrics to the media. - - \sa {QtMediaServices::Lyrics} -*/ - -/*! - \qmlproperty variant Video::mood - - This property holds the mood of the media. - - \sa {QtMediaServices::Mood} -*/ - -/*! - \qmlproperty variant Video::trackNumber - - This property holds the track number of the media. - - \sa {QtMediaServices::TrackNumber} -*/ - -/*! - \qmlproperty variant Video::trackCount - - This property holds the number of track on the album containing the media. - - \sa {QtMediaServices::TrackNumber} -*/ - -/*! - \qmlproperty variant Video::coverArtUrlSmall - - This property holds the URL of a small cover art image. - - \sa {QtMediaServices::CoverArtUrlSmall} -*/ - -/*! - \qmlproperty variant Video::coverArtUrlLarge - - This property holds the URL of a large cover art image. - - \sa {QtMediaServices::CoverArtUrlLarge} -*/ - -/*! - \qmlproperty variant Video::resolution - - This property holds the dimension of an image or video. - - \sa {QtMediaServices::Resolution} -*/ - -/*! - \qmlproperty variant Video::pixelAspectRatio - - This property holds the pixel aspect ratio of an image or video. - - \sa {QtMediaServices::PixelAspectRatio} -*/ - -/*! - \qmlproperty variant Video::videoFrameRate - - This property holds the frame rate of the media's video stream. - - \sa {QtMediaServices::VideoFrameRate} -*/ - -/*! - \qmlproperty variant Video::videoBitRate - - This property holds the bit rate of the media's video stream in bits per - second. - - \sa {QtMediaServices::VideoBitRate} -*/ - -/*! - \qmlproperty variant Video::videoCodec - - This property holds the encoding of the media's video stream. - - \sa {QtMediaServices::VideoCodec} -*/ - -/*! - \qmlproperty variant Video::posterUrl - - This property holds the URL of a poster image. - - \sa {QtMediaServices::PosterUrl} -*/ - -/*! - \qmlproperty variant Video::chapterNumber - - This property holds the chapter number of the media. - - \sa {QtMediaServices::ChapterNumber} -*/ - -/*! - \qmlproperty variant Video::director - - This property holds the director of the media. - - \sa {QtMediaServices::Director} -*/ - -/*! - \qmlproperty variant Video::leadPerformer - - This property holds the lead performer in the media. - - \sa {QtMediaServices::LeadPerformer} -*/ - -/*! - \qmlproperty variant Video::writer - - This property holds the writer of the media. - - \sa {QtMediaServices::Writer} -*/ - -// The remaining properties are related to photos, and are technically -// available but will certainly never have values. -#ifndef Q_QDOC - -/*! - \qmlproperty variant Video::cameraManufacturer - - \sa {QtMediaServices::CameraManufacturer} -*/ - -/*! - \qmlproperty variant Video::cameraModel - - \sa {QtMediaServices::CameraModel} -*/ - -/*! - \qmlproperty variant Video::event - - \sa {QtMediaServices::Event} -*/ - -/*! - \qmlproperty variant Video::subject - - \sa {QtMediaServices::Subject} -*/ - -/*! - \qmlproperty variant Video::orientation - - \sa {QtMediaServices::Orientation} -*/ - -/*! - \qmlproperty variant Video::exposureTime - - \sa {QtMediaServices::ExposureTime} -*/ - -/*! - \qmlproperty variant Video::fNumber - - \sa {QtMediaServices::FNumber} -*/ - -/*! - \qmlproperty variant Video::exposureProgram - - \sa {QtMediaServices::ExposureProgram} -*/ - -/*! - \qmlproperty variant Video::isoSpeedRatings - - \sa {QtMediaServices::ISOSpeedRatings} -*/ - -/*! - \qmlproperty variant Video::exposureBiasValue - - \sa {QtMediaServices::ExposureBiasValue} -*/ - -/*! - \qmlproperty variant Video::dateTimeDigitized - - \sa {QtMediaServices::DateTimeDigitized} -*/ - -/*! - \qmlproperty variant Video::subjectDistance - - \sa {QtMediaServices::SubjectDistance} -*/ - -/*! - \qmlproperty variant Video::meteringMode - - \sa {QtMediaServices::MeteringMode} -*/ - -/*! - \qmlproperty variant Video::lightSource - - \sa {QtMediaServices::LightSource} -*/ - -/*! - \qmlproperty variant Video::flash - - \sa {QtMediaServices::Flash} -*/ - -/*! - \qmlproperty variant Video::focalLength - - \sa {QtMediaServices::FocalLength} -*/ - -/*! - \qmlproperty variant Video::exposureMode - - \sa {QtMediaServices::ExposureMode} -*/ - -/*! - \qmlproperty variant Video::whiteBalance - - \sa {QtMediaServices::WhiteBalance} -*/ - -/*! - \qmlproperty variant Video::DigitalZoomRatio - - \sa {QtMediaServices::DigitalZoomRatio} -*/ - -/*! - \qmlproperty variant Video::focalLengthIn35mmFilm - - \sa {QtMediaServices::FocalLengthIn35mmFile} -*/ - -/*! - \qmlproperty variant Video::sceneCaptureType - - \sa {QtMediaServices::SceneCaptureType} -*/ - -/*! - \qmlproperty variant Video::gainControl - - \sa {QtMediaServices::GainControl} -*/ - -/*! - \qmlproperty variant Video::contrast - - \sa {QtMediaServices::contrast} -*/ - -/*! - \qmlproperty variant Video::saturation - - \sa {QtMediaServices::Saturation} -*/ - -/*! - \qmlproperty variant Video::sharpness - - \sa {QtMediaServices::Sharpness} -*/ - -/*! - \qmlproperty variant Video::deviceSettingDescription - - \sa {QtMediaServices::DeviceSettingDescription} -*/ - -#endif - -#include "moc_qdeclarativevideo_p.cpp" diff --git a/src/imports/multimedia/qdeclarativevideo_p.h b/src/imports/multimedia/qdeclarativevideo_p.h deleted file mode 100644 index c048b7d..0000000 --- a/src/imports/multimedia/qdeclarativevideo_p.h +++ /dev/null @@ -1,207 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QDECLARATIVEVIDEO_H -#define QDECLARATIVEVIDEO_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativemediabase_p.h" - -#include - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QTimerEvent; -class QVideoSurfaceFormat; - - -class QDeclarativeVideo : public QDeclarativeItem, public QDeclarativeMediaBase -{ - Q_OBJECT - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged) - Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged) - Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(int duration READ duration NOTIFY durationChanged) - Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(bool hasAudio READ hasAudio NOTIFY hasAudioChanged) - Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged) - Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged) - Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged) - Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged) - Q_PROPERTY(Error error READ error NOTIFY errorChanged) - Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged) - Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode) - Q_ENUMS(FillMode) - Q_ENUMS(Status) - Q_ENUMS(Error) -public: - enum FillMode - { - Stretch = Qt::IgnoreAspectRatio, - PreserveAspectFit = Qt::KeepAspectRatio, - PreserveAspectCrop = Qt::KeepAspectRatioByExpanding - }; - - enum Status - { - UnknownStatus = QMediaPlayer::UnknownMediaStatus, - NoMedia = QMediaPlayer::NoMedia, - Loading = QMediaPlayer::LoadingMedia, - Loaded = QMediaPlayer::LoadedMedia, - Stalled = QMediaPlayer::StalledMedia, - Buffering = QMediaPlayer::BufferingMedia, - Buffered = QMediaPlayer::BufferedMedia, - EndOfMedia = QMediaPlayer::EndOfMedia, - InvalidMedia = QMediaPlayer::InvalidMedia - }; - - enum Error - { - NoError = QMediaPlayer::NoError, - ResourceError = QMediaPlayer::ResourceError, - FormatError = QMediaPlayer::FormatError, - NetworkError = QMediaPlayer::NetworkError, - AccessDenied = QMediaPlayer::AccessDeniedError, - ServiceMissing = QMediaPlayer::ServiceMissingError - }; - - QDeclarativeVideo(QDeclarativeItem *parent = 0); - ~QDeclarativeVideo(); - - bool hasAudio() const; - bool hasVideo() const; - - FillMode fillMode() const; - void setFillMode(FillMode mode); - - Status status() const; - Error error() const; - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - - void componentComplete(); - -public Q_SLOTS: - void play(); - void pause(); - void stop(); - -Q_SIGNALS: - void sourceChanged(); - void autoLoadChanged(); - void playingChanged(); - void pausedChanged(); - - void started(); - void resumed(); - void paused(); - void stopped(); - - void statusChanged(); - - void loaded(); - void buffering(); - void stalled(); - void buffered(); - void endOfMedia(); - - void durationChanged(); - void positionChanged(); - - void volumeChanged(); - void mutedChanged(); - void hasAudioChanged(); - void hasVideoChanged(); - - void bufferProgressChanged(); - - void seekableChanged(); - void playbackRateChanged(); - - void errorChanged(); - void error(QDeclarativeVideo::Error error, const QString &errorString); - -protected: - void geometryChanged(const QRectF &geometry, const QRectF &); - -private Q_SLOTS: - void _q_nativeSizeChanged(const QSizeF &size); - void _q_error(int, const QString &); - -private: - Q_DISABLE_COPY(QDeclarativeVideo) - - QGraphicsVideoItem *m_graphicsItem; - - Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State)) - Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus)) - Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged()) - - inline QDeclarativeMediaBase *mediaBase() { return this; } -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeVideo)) - -QT_END_HEADER - -#endif diff --git a/src/imports/multimedia/qmetadatacontrolmetaobject.cpp b/src/imports/multimedia/qmetadatacontrolmetaobject.cpp deleted file mode 100644 index 5235a87..0000000 --- a/src/imports/multimedia/qmetadatacontrolmetaobject.cpp +++ /dev/null @@ -1,362 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qmetadatacontrolmetaobject_p.h" -#include - - -QT_BEGIN_NAMESPACE - -// copied from qmetaobject.cpp -// do not touch without touching the moc as well -enum PropertyFlags { - Invalid = 0x00000000, - Readable = 0x00000001, - Writable = 0x00000002, - Resettable = 0x00000004, - EnumOrFlag = 0x00000008, - StdCppSet = 0x00000100, -// Override = 0x00000200, - Designable = 0x00001000, - ResolveDesignable = 0x00002000, - Scriptable = 0x00004000, - ResolveScriptable = 0x00008000, - Stored = 0x00010000, - ResolveStored = 0x00020000, - Editable = 0x00040000, - ResolveEditable = 0x00080000, - User = 0x00100000, - ResolveUser = 0x00200000, - Notify = 0x00400000, - Dynamic = 0x00800000 -}; - -enum MethodFlags { - AccessPrivate = 0x00, - AccessProtected = 0x01, - AccessPublic = 0x02, - AccessMask = 0x03, //mask - - MethodMethod = 0x00, - MethodSignal = 0x04, - MethodSlot = 0x08, - MethodConstructor = 0x0c, - MethodTypeMask = 0x0c, - - MethodCompatibility = 0x10, - MethodCloned = 0x20, - MethodScriptable = 0x40 -}; - -struct QMetaObjectPrivate -{ - int revision; - int className; - int classInfoCount, classInfoData; - int methodCount, methodData; - int propertyCount, propertyData; - int enumeratorCount, enumeratorData; - int constructorCount, constructorData; - int flags; -}; - -static inline const QMetaObjectPrivate *priv(const uint* m_data) -{ return reinterpret_cast(m_data); } -// end of copied lines from qmetaobject.cpp - -namespace -{ - struct MetaDataKey - { - QtMediaServices::MetaData key; - const char *name; - }; - - const MetaDataKey qt_metaDataKeys[] = - { - { QtMediaServices::Title, "title" }, - { QtMediaServices::SubTitle, "subTitle" }, - { QtMediaServices::Author, "author" }, - { QtMediaServices::Comment, "comment" }, - { QtMediaServices::Description, "description" }, - { QtMediaServices::Category, "category" }, - { QtMediaServices::Genre, "genre" }, - { QtMediaServices::Year, "year" }, - { QtMediaServices::Date, "date" }, - { QtMediaServices::UserRating, "userRating" }, - { QtMediaServices::Keywords, "keywords" }, - { QtMediaServices::Language, "language" }, - { QtMediaServices::Publisher, "publisher" }, - { QtMediaServices::Copyright, "copyright" }, - { QtMediaServices::ParentalRating, "parentalRating" }, - { QtMediaServices::RatingOrganisation, "ratingOrganisation" }, - - // Media - { QtMediaServices::Size, "size" }, - { QtMediaServices::MediaType, "mediaType" }, -// { QtMediaServices::Duration, "duration" }, - - // Audio - { QtMediaServices::AudioBitRate, "audioBitRate" }, - { QtMediaServices::AudioCodec, "audioCodec" }, - { QtMediaServices::AverageLevel, "averageLevel" }, - { QtMediaServices::ChannelCount, "channelCount" }, - { QtMediaServices::PeakValue, "peakValue" }, - { QtMediaServices::SampleRate, "sampleRate" }, - - // Music - { QtMediaServices::AlbumTitle, "albumTitle" }, - { QtMediaServices::AlbumArtist, "albumArtist" }, - { QtMediaServices::ContributingArtist, "contributingArtist" }, - { QtMediaServices::Composer, "composer" }, - { QtMediaServices::Conductor, "conductor" }, - { QtMediaServices::Lyrics, "lyrics" }, - { QtMediaServices::Mood, "mood" }, - { QtMediaServices::TrackNumber, "trackNumber" }, - { QtMediaServices::TrackCount, "trackCount" }, - - { QtMediaServices::CoverArtUrlSmall, "coverArtUrlSmall" }, - { QtMediaServices::CoverArtUrlLarge, "coverArtUrlLarge" }, - - // Image/Video - { QtMediaServices::Resolution, "resolution" }, - { QtMediaServices::PixelAspectRatio, "pixelAspectRatio" }, - - // Video - { QtMediaServices::VideoFrameRate, "videoFrameRate" }, - { QtMediaServices::VideoBitRate, "videoBitRate" }, - { QtMediaServices::VideoCodec, "videoCodec" }, - - { QtMediaServices::PosterUrl, "posterUrl" }, - - // Movie - { QtMediaServices::ChapterNumber, "chapterNumber" }, - { QtMediaServices::Director, "director" }, - { QtMediaServices::LeadPerformer, "leadPerformer" }, - { QtMediaServices::Writer, "writer" }, - - // Photos - { QtMediaServices::CameraManufacturer, "cameraManufacturer" }, - { QtMediaServices::CameraModel, "cameraModel" }, - { QtMediaServices::Event, "event" }, - { QtMediaServices::Subject, "subject" }, - { QtMediaServices::Orientation, "orientation" }, - { QtMediaServices::ExposureTime, "exposureTime" }, - { QtMediaServices::FNumber, "fNumber" }, - { QtMediaServices::ExposureProgram, "exposureProgram" }, - { QtMediaServices::ISOSpeedRatings, "isoSpeedRatings" }, - { QtMediaServices::ExposureBiasValue, "exposureBiasValue" }, - { QtMediaServices::DateTimeOriginal, "dateTimeOriginal" }, - { QtMediaServices::DateTimeDigitized, "dateTimeDigitized" }, - { QtMediaServices::SubjectDistance, "subjectDistance" }, - { QtMediaServices::MeteringMode, "meteringMode" }, - { QtMediaServices::LightSource, "lightSource" }, - { QtMediaServices::Flash, "flash" }, - { QtMediaServices::FocalLength, "focalLength" }, - { QtMediaServices::ExposureMode, "exposureMode" }, - { QtMediaServices::WhiteBalance, "whiteBalance" }, - { QtMediaServices::DigitalZoomRatio, "digitalZoomRatio" }, - { QtMediaServices::FocalLengthIn35mmFilm, "focalLengthIn35mmFilm" }, - { QtMediaServices::SceneCaptureType, "sceneCaptureType" }, - { QtMediaServices::GainControl, "gainControl" }, - { QtMediaServices::Contrast, "contrast" }, - { QtMediaServices::Saturation, "saturation" }, - { QtMediaServices::Sharpness, "sharpness" }, - { QtMediaServices::DeviceSettingDescription, "deviceSettingDescription" } - }; - - class QMetaDataControlObject : public QObject - { - public: - inline QObjectData *data() { return d_ptr.data(); } - }; -} - -QMetaDataControlMetaObject::QMetaDataControlMetaObject(QMetaDataControl *control, QObject *object) - : m_control(control) - , m_object(object) - , m_string(0) - , m_data(0) - , m_propertyOffset(0) - , m_signalOffset(0) -{ - const QMetaObject *superClass = m_object->metaObject(); - - const int propertyCount = sizeof(qt_metaDataKeys) / sizeof(MetaDataKey); - const int dataSize = sizeof(uint) - * (13 // QMetaObjectPrivate members. - + 5 // 5 members per signal. - + 4 * propertyCount // 3 members per property + 1 notify signal per property. - + 1); // Terminating value. - - m_data = reinterpret_cast(qMalloc(dataSize)); - - QMetaObjectPrivate *pMeta = reinterpret_cast(m_data); - - pMeta->revision = 3; - pMeta->className = 0; - pMeta->classInfoCount = 0; - pMeta->classInfoData = 0; - pMeta->methodCount = 1; - pMeta->methodData = 13; - pMeta->propertyCount = propertyCount; - pMeta->propertyData = 18; - pMeta->enumeratorCount = 0; - pMeta->enumeratorData = 0; - pMeta->constructorCount = 0; - pMeta->constructorData = 0; - pMeta->flags = 0x01; // Dynamic meta object flag. - - const int classNameSize = qstrlen(superClass->className()) + 1; - - int stringIndex = classNameSize + 1; - - // __metaDataChanged() signal. - static const char *changeSignal = "__metaDataChanged()"; - const int changeSignalSize = qstrlen(changeSignal) + 1; - - m_data[13] = stringIndex; // Signature. - m_data[14] = classNameSize; // Parameters. - m_data[15] = classNameSize; // Type. - m_data[16] = classNameSize; // Tag. - m_data[17] = MethodSignal | AccessProtected; // Flags. - - stringIndex += changeSignalSize; - - const char *qvariantName = "QVariant"; - const int qvariantSize = qstrlen(qvariantName) + 1; - const int qvariantIndex = stringIndex; - - stringIndex += qvariantSize; - - // Properties. - for (int i = 0; i < propertyCount; ++i) { - m_data[18 + 3 * i] = stringIndex; // Name. - m_data[19 + 3 * i] = qvariantIndex; // Type. - m_data[20 + 3 * i] - = Readable | Writable | Notify | Dynamic | (0xffffffff << 24); // Flags. - m_data[18 + propertyCount * 3 + i] = 0; // Notify signal. - - stringIndex += qstrlen(qt_metaDataKeys[i].name) + 1; - } - - // Terminating value. - m_data[18 + propertyCount * 4] = 0; - - // Build string. - m_string = reinterpret_cast(qMalloc(stringIndex + 1)); - - // Class name. - qMemCopy(m_string, superClass->className(), classNameSize); - - stringIndex = classNameSize; - - // Null m_string. - m_string[stringIndex] = '\0'; - stringIndex += 1; - - // __metaDataChanged() signal. - qMemCopy(m_string + stringIndex, changeSignal, changeSignalSize); - stringIndex += changeSignalSize; - - qMemCopy(m_string + stringIndex, qvariantName, qvariantSize); - stringIndex += qvariantSize; - - // Properties. - for (int i = 0; i < propertyCount; ++i) { - const int propertyNameSize = qstrlen(qt_metaDataKeys[i].name) + 1; - - qMemCopy(m_string + stringIndex, qt_metaDataKeys[i].name, propertyNameSize); - stringIndex += propertyNameSize; - } - - // Terminating character. - m_string[stringIndex] = '\0'; - - d.superdata = superClass; - d.stringdata = m_string; - d.data = m_data; - d.extradata = 0; - - static_cast(m_object)->data()->metaObject = this; - - m_propertyOffset = propertyOffset(); - m_signalOffset = methodOffset(); -} - -QMetaDataControlMetaObject::~QMetaDataControlMetaObject() -{ - static_cast(m_object)->data()->metaObject = 0; - - qFree(m_data); - qFree(m_string); -} - -int QMetaDataControlMetaObject::metaCall(QMetaObject::Call c, int id, void **a) -{ - if (c == QMetaObject::ReadProperty && id >= m_propertyOffset) { - int propId = id - m_propertyOffset; - - *reinterpret_cast(a[0]) = m_control->metaData(qt_metaDataKeys[propId].key); - - return -1; - } else if (c == QMetaObject::WriteProperty && id >= m_propertyOffset) { - int propId = id - m_propertyOffset; - - m_control->setMetaData(qt_metaDataKeys[propId].key, *reinterpret_cast(a[0])); - - return -1; - } else { - return m_object->qt_metacall(c, id, a); - } -} - -int QMetaDataControlMetaObject::createProperty(const char *, const char *) -{ - return -1; -} - -void QMetaDataControlMetaObject::metaDataChanged() -{ - activate(m_object, m_signalOffset, 0); -} - -QT_END_NAMESPACE diff --git a/src/imports/multimedia/qmetadatacontrolmetaobject_p.h b/src/imports/multimedia/qmetadatacontrolmetaobject_p.h deleted file mode 100644 index bbbc6fe..0000000 --- a/src/imports/multimedia/qmetadatacontrolmetaobject_p.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QMETADATACONTROLMETAOBJECT_P_H -#define QMETADATACONTROLMETAOJBECT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMetaDataControl; - -class QMetaDataControlMetaObject : public QAbstractDynamicMetaObject -{ -public: - QMetaDataControlMetaObject(QMetaDataControl *control, QObject *object); - ~QMetaDataControlMetaObject(); - - int metaCall(QMetaObject::Call call, int _id, void **arguments); - int createProperty(const char *, const char *); - - void metaDataChanged(); - -private: - QMetaDataControl *m_control; - QObject *m_object; - char *m_string; - uint *m_data; - - int m_propertyOffset; - int m_signalOffset; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/imports/multimedia/qmldir b/src/imports/multimedia/qmldir deleted file mode 100644 index 0e6f656..0000000 --- a/src/imports/multimedia/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin multimedia diff --git a/src/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri new file mode 100644 index 0000000..ae28a26 --- /dev/null +++ b/src/multimedia/audio/audio.pri @@ -0,0 +1,73 @@ +HEADERS += $$PWD/qaudio.h \ + $$PWD/qaudioformat.h \ + $$PWD/qaudioinput.h \ + $$PWD/qaudiooutput.h \ + $$PWD/qaudiodeviceinfo.h \ + $$PWD/qaudioengineplugin.h \ + $$PWD/qaudioengine.h \ + $$PWD/qaudiodevicefactory_p.h + + +SOURCES += $$PWD/qaudio.cpp \ + $$PWD/qaudioformat.cpp \ + $$PWD/qaudiodeviceinfo.cpp \ + $$PWD/qaudiooutput.cpp \ + $$PWD/qaudioinput.cpp \ + $$PWD/qaudioengineplugin.cpp \ + $$PWD/qaudioengine.cpp \ + $$PWD/qaudiodevicefactory.cpp + +contains(QT_CONFIG, audio-backend) { + +mac { + HEADERS += $$PWD/qaudioinput_mac_p.h \ + $$PWD/qaudiooutput_mac_p.h \ + $$PWD/qaudiodeviceinfo_mac_p.h \ + $$PWD/qaudio_mac_p.h + + SOURCES += $$PWD/qaudiodeviceinfo_mac_p.cpp \ + $$PWD/qaudiooutput_mac_p.cpp \ + $$PWD/qaudioinput_mac_p.cpp \ + $$PWD/qaudio_mac.cpp + + LIBS += -framework ApplicationServices -framework CoreAudio -framework AudioUnit -framework AudioToolbox + +} else:win32 { + + HEADERS += $$PWD/qaudioinput_win32_p.h $$PWD/qaudiooutput_win32_p.h $$PWD/qaudiodeviceinfo_win32_p.h + SOURCES += $$PWD/qaudiodeviceinfo_win32_p.cpp \ + $$PWD/qaudiooutput_win32_p.cpp \ + $$PWD/qaudioinput_win32_p.cpp + !wince*:LIBS += -lwinmm + wince*:LIBS += -lcoredll + +} else:symbian { + INCLUDEPATH += /epoc32/include/mmf/common + INCLUDEPATH += /epoc32/include/mmf/server + + HEADERS += $$PWD/qaudio_symbian_p.h \ + $$PWD/qaudiodeviceinfo_symbian_p.h \ + $$PWD/qaudioinput_symbian_p.h \ + $$PWD/qaudiooutput_symbian_p.h + + SOURCES += $$PWD/qaudio_symbian_p.cpp \ + $$PWD/qaudiodeviceinfo_symbian_p.cpp \ + $$PWD/qaudioinput_symbian_p.cpp \ + $$PWD/qaudiooutput_symbian_p.cpp + + LIBS += -lmmfdevsound +} else:unix { + unix:contains(QT_CONFIG, alsa) { + linux-*|freebsd-*|openbsd-*:{ + DEFINES += HAS_ALSA + HEADERS += $$PWD/qaudiooutput_alsa_p.h $$PWD/qaudioinput_alsa_p.h $$PWD/qaudiodeviceinfo_alsa_p.h + SOURCES += $$PWD/qaudiodeviceinfo_alsa_p.cpp \ + $$PWD/qaudiooutput_alsa_p.cpp \ + $$PWD/qaudioinput_alsa_p.cpp + LIBS_PRIVATE += -lasound + } + } +} +} else { + DEFINES += QT_NO_AUDIO_BACKEND +} diff --git a/src/multimedia/audio/qaudio.cpp b/src/multimedia/audio/qaudio.cpp new file mode 100644 index 0000000..e0f24ce --- /dev/null +++ b/src/multimedia/audio/qaudio.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 + + +QT_BEGIN_NAMESPACE + +namespace QAudio +{ + +class RegisterMetaTypes +{ +public: + RegisterMetaTypes() + { + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + } + +} _register; + +} + +/*! + \namespace QAudio + \brief The QAudio namespace contains enums used by the audio classes. + \inmodule QtMultimedia + \ingroup multimedia + \since 4.6 +*/ + +/*! + \enum QAudio::Error + + \value NoError No errors have occurred + \value OpenError An error opening the audio device + \value IOError An error occurred during read/write of audio device + \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate + \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. +*/ + +/*! + \enum QAudio::State + + \value ActiveState Audio data is being processed, this state is set after start() is called + and while audio data is available to be processed. + \value SuspendedState The audio device is in a suspended state, this state will only be entered + after suspend() is called. + \value StoppedState The audio device is closed, not processing any audio data + \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state + is set after start() is called and while no audio data is available to be processed. +*/ + +/*! + \enum QAudio::Mode + + \value AudioOutput audio output device + \value AudioInput audio input device +*/ + + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudio.h b/src/multimedia/audio/qaudio.h new file mode 100644 index 0000000..9ca1dff --- /dev/null +++ b/src/multimedia/audio/qaudio.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QAUDIO_H +#define QAUDIO_H + + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +namespace QAudio +{ + enum Error { NoError, OpenError, IOError, UnderrunError, FatalError }; + enum State { ActiveState, SuspendedState, StoppedState, IdleState }; + enum Mode { AudioInput, AudioOutput }; +} + +QT_END_NAMESPACE + +QT_END_HEADER + +Q_DECLARE_METATYPE(QAudio::Error) +Q_DECLARE_METATYPE(QAudio::State) +Q_DECLARE_METATYPE(QAudio::Mode) + +#endif // QAUDIO_H diff --git a/src/multimedia/audio/qaudio_mac.cpp b/src/multimedia/audio/qaudio_mac.cpp new file mode 100644 index 0000000..14fee8b --- /dev/null +++ b/src/multimedia/audio/qaudio_mac.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qaudio_mac_p.h" + +QT_BEGIN_NAMESPACE + +// Debugging +QDebug operator<<(QDebug dbg, const QAudioFormat& audioFormat) +{ + dbg.nospace() << "QAudioFormat(" << + audioFormat.frequency() << "," << + audioFormat.channels() << "," << + audioFormat.sampleSize()<< "," << + audioFormat.codec() << "," << + audioFormat.byteOrder() << "," << + audioFormat.sampleType() << ")"; + + return dbg.space(); +} + + +// Conversion +QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf) +{ + QAudioFormat audioFormat; + + audioFormat.setFrequency(sf.mSampleRate); + audioFormat.setChannels(sf.mChannelsPerFrame); + audioFormat.setSampleSize(sf.mBitsPerChannel); + audioFormat.setCodec(QString::fromLatin1("audio/pcm")); + audioFormat.setByteOrder(sf.mFormatFlags & kLinearPCMFormatFlagIsBigEndian != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian); + QAudioFormat::SampleType type = QAudioFormat::UnSignedInt; + if ((sf.mFormatFlags & kLinearPCMFormatFlagIsSignedInteger) != 0) + type = QAudioFormat::SignedInt; + else if ((sf.mFormatFlags & kLinearPCMFormatFlagIsFloat) != 0) + type = QAudioFormat::Float; + audioFormat.setSampleType(type); + + return audioFormat; +} + +AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& audioFormat) +{ + AudioStreamBasicDescription sf; + + sf.mFormatFlags = kAudioFormatFlagIsPacked; + sf.mSampleRate = audioFormat.frequency(); + sf.mFramesPerPacket = 1; + sf.mChannelsPerFrame = audioFormat.channels(); + sf.mBitsPerChannel = audioFormat.sampleSize(); + sf.mBytesPerFrame = sf.mChannelsPerFrame * (sf.mBitsPerChannel / 8); + sf.mBytesPerPacket = sf.mFramesPerPacket * sf.mBytesPerFrame; + sf.mFormatID = kAudioFormatLinearPCM; + + switch (audioFormat.sampleType()) { + case QAudioFormat::SignedInt: sf.mFormatFlags |= kAudioFormatFlagIsSignedInteger; break; + case QAudioFormat::UnSignedInt: /* default */ break; + case QAudioFormat::Float: sf.mFormatFlags |= kAudioFormatFlagIsFloat; break; + case QAudioFormat::Unknown: default: break; + } + + return sf; +} + +// QAudioRingBuffer +QAudioRingBuffer::QAudioRingBuffer(int bufferSize): + m_bufferSize(bufferSize) +{ + m_buffer = new char[m_bufferSize]; + reset(); +} + +QAudioRingBuffer::~QAudioRingBuffer() +{ + delete m_buffer; +} + +int QAudioRingBuffer::used() const +{ + return m_bufferUsed; +} + +int QAudioRingBuffer::free() const +{ + return m_bufferSize - m_bufferUsed; +} + +int QAudioRingBuffer::size() const +{ + return m_bufferSize; +} + +void QAudioRingBuffer::reset() +{ + m_readPos = 0; + m_writePos = 0; + m_bufferUsed = 0; +} + +QT_END_NAMESPACE + + diff --git a/src/multimedia/audio/qaudio_mac_p.h b/src/multimedia/audio/qaudio_mac_p.h new file mode 100644 index 0000000..4e7d688 --- /dev/null +++ b/src/multimedia/audio/qaudio_mac_p.h @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QAUDIO_MAC_P_H +#define QAUDIO_MAC_P_H + +#include + +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +extern QDebug operator<<(QDebug dbg, const QAudioFormat& audioFormat); + +extern QAudioFormat toQAudioFormat(const AudioStreamBasicDescription& streamFormat); +extern AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& audioFormat); + +class QAudioRingBuffer +{ +public: + typedef QPair Region; + + QAudioRingBuffer(int bufferSize); + ~QAudioRingBuffer(); + + Region acquireReadRegion(int size) + { + const int used = m_bufferUsed.fetchAndAddAcquire(0); + + if (used > 0) { + const int readSize = qMin(size, qMin(m_bufferSize - m_readPos, used)); + + return readSize > 0 ? Region(m_buffer + m_readPos, readSize) : Region(0, 0); + } + + return Region(0, 0); + } + + void releaseReadRegion(Region const& region) + { + m_readPos = (m_readPos + region.second) % m_bufferSize; + + m_bufferUsed.fetchAndAddRelease(-region.second); + } + + Region acquireWriteRegion(int size) + { + const int free = m_bufferSize - m_bufferUsed.fetchAndAddAcquire(0); + + if (free > 0) { + const int writeSize = qMin(size, qMin(m_bufferSize - m_writePos, free)); + + return writeSize > 0 ? Region(m_buffer + m_writePos, writeSize) : Region(0, 0); + } + + return Region(0, 0); + } + + void releaseWriteRegion(Region const& region) + { + m_writePos = (m_writePos + region.second) % m_bufferSize; + + m_bufferUsed.fetchAndAddRelease(region.second); + } + + int used() const; + int free() const; + int size() const; + + void reset(); + +private: + int m_bufferSize; + int m_readPos; + int m_writePos; + char* m_buffer; + QAtomicInt m_bufferUsed; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIO_MAC_P_H + + diff --git a/src/multimedia/audio/qaudio_symbian_p.cpp b/src/multimedia/audio/qaudio_symbian_p.cpp new file mode 100644 index 0000000..afe98f5 --- /dev/null +++ b/src/multimedia/audio/qaudio_symbian_p.cpp @@ -0,0 +1,395 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qaudio_symbian_p.h" +#include + +QT_BEGIN_NAMESPACE + +namespace SymbianAudio { + +DevSoundCapabilities::DevSoundCapabilities(CMMFDevSound &devsound, + QAudio::Mode mode) +{ + QT_TRAP_THROWING(constructL(devsound, mode)); +} + +DevSoundCapabilities::~DevSoundCapabilities() +{ + m_fourCC.Close(); +} + +void DevSoundCapabilities::constructL(CMMFDevSound &devsound, + QAudio::Mode mode) +{ + m_caps = devsound.Capabilities(); + + TMMFPrioritySettings settings; + + switch (mode) { + case QAudio::AudioOutput: + settings.iState = EMMFStatePlaying; + devsound.GetSupportedInputDataTypesL(m_fourCC, settings); + break; + + case QAudio::AudioInput: + settings.iState = EMMFStateRecording; + devsound.GetSupportedInputDataTypesL(m_fourCC, settings); + break; + + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); + } +} + +namespace Utils { + +//----------------------------------------------------------------------------- +// Static data +//----------------------------------------------------------------------------- + +// Sample rate / frequency + +typedef TMMFSampleRate SampleRateNative; +typedef int SampleRateQt; + +const int SampleRateCount = 12; + +const SampleRateNative SampleRateListNative[SampleRateCount] = { + EMMFSampleRate8000Hz + , EMMFSampleRate11025Hz + , EMMFSampleRate12000Hz + , EMMFSampleRate16000Hz + , EMMFSampleRate22050Hz + , EMMFSampleRate24000Hz + , EMMFSampleRate32000Hz + , EMMFSampleRate44100Hz + , EMMFSampleRate48000Hz + , EMMFSampleRate64000Hz + , EMMFSampleRate88200Hz + , EMMFSampleRate96000Hz +}; + +const SampleRateQt SampleRateListQt[SampleRateCount] = { + 8000 + , 11025 + , 12000 + , 16000 + , 22050 + , 24000 + , 32000 + , 44100 + , 48000 + , 64000 + , 88200 + , 96000 +}; + +// Channels + +typedef TMMFMonoStereo ChannelsNative; +typedef int ChannelsQt; + +const int ChannelsCount = 2; + +const ChannelsNative ChannelsListNative[ChannelsCount] = { + EMMFMono + , EMMFStereo +}; + +const ChannelsQt ChannelsListQt[ChannelsCount] = { + 1 + , 2 +}; + +// Encoding + +const int EncodingCount = 6; + +const TUint32 EncodingFourCC[EncodingCount] = { + KMMFFourCCCodePCM8 // 0 + , KMMFFourCCCodePCMU8 // 1 + , KMMFFourCCCodePCM16 // 2 + , KMMFFourCCCodePCMU16 // 3 + , KMMFFourCCCodePCM16B // 4 + , KMMFFourCCCodePCMU16B // 5 +}; + +// The characterised DevSound API specification states that the iEncoding +// field in TMMFCapabilities is ignored, and that the FourCC should be used +// to specify the PCM encoding. +// See "SGL.GT0287.102 Multimedia DevSound Baseline Compatibility.doc" in the +// mm_info/mm_docs repository. +const TMMFSoundEncoding EncodingNative[EncodingCount] = { + EMMFSoundEncoding16BitPCM // 0 + , EMMFSoundEncoding16BitPCM // 1 + , EMMFSoundEncoding16BitPCM // 2 + , EMMFSoundEncoding16BitPCM // 3 + , EMMFSoundEncoding16BitPCM // 4 + , EMMFSoundEncoding16BitPCM // 5 +}; + + +const int EncodingSampleSize[EncodingCount] = { + 8 // 0 + , 8 // 1 + , 16 // 2 + , 16 // 3 + , 16 // 4 + , 16 // 5 +}; + +const QAudioFormat::Endian EncodingByteOrder[EncodingCount] = { + QAudioFormat::LittleEndian // 0 + , QAudioFormat::LittleEndian // 1 + , QAudioFormat::LittleEndian // 2 + , QAudioFormat::LittleEndian // 3 + , QAudioFormat::BigEndian // 4 + , QAudioFormat::BigEndian // 5 +}; + +const QAudioFormat::SampleType EncodingSampleType[EncodingCount] = { + QAudioFormat::SignedInt // 0 + , QAudioFormat::UnSignedInt // 1 + , QAudioFormat::SignedInt // 2 + , QAudioFormat::UnSignedInt // 3 + , QAudioFormat::SignedInt // 4 + , QAudioFormat::UnSignedInt // 5 +}; + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +// Helper functions for implementing parameter conversions + +template +bool findValue(const Input *inputArray, int length, Input input, int &index) { + bool result = false; + for (int i=0; !result && i +bool convertValue(const Input *inputArray, const Output *outputArray, + int length, Input input, Output &output) { + int index; + const bool result = findValue(inputArray, length, input, index); + if (result) + output = outputArray[index]; + return result; +} + +/** + * Macro which is used to generate the implementation of the conversion + * functions. The implementation is just a wrapper around the templated + * convertValue function, e.g. + * + * CONVERSION_FUNCTION_IMPL(SampleRate, Qt, Native) + * + * expands to + * + * bool SampleRateQtToNative(int input, TMMFSampleRate &output) { + * return convertValue + * (SampleRateListQt, SampleRateListNative, SampleRateCount, + * input, output); + * } + */ +#define CONVERSION_FUNCTION_IMPL(FieldLc, Field, Input, Output) \ +bool FieldLc##Input##To##Output(Field##Input input, Field##Output &output) { \ + return convertValue(Field##List##Input, \ + Field##List##Output, Field##Count, input, output); \ +} + +//----------------------------------------------------------------------------- +// Local helper functions +//----------------------------------------------------------------------------- + +CONVERSION_FUNCTION_IMPL(sampleRate, SampleRate, Qt, Native) +CONVERSION_FUNCTION_IMPL(sampleRate, SampleRate, Native, Qt) +CONVERSION_FUNCTION_IMPL(channels, Channels, Qt, Native) +CONVERSION_FUNCTION_IMPL(channels, Channels, Native, Qt) + +bool sampleInfoQtToNative(int inputSampleSize, + QAudioFormat::Endian inputByteOrder, + QAudioFormat::SampleType inputSampleType, + TUint32 &outputFourCC, + TMMFSoundEncoding &outputEncoding) { + + bool found = false; + + for (int i=0; i &frequencies, + QList &channels, + QList &sampleSizes, + QList &byteOrders, + QList &sampleTypes) { + + frequencies.clear(); + sampleSizes.clear(); + byteOrders.clear(); + sampleTypes.clear(); + channels.clear(); + + for (int i=0; i +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace SymbianAudio { + +/** + * Default values used by audio input and output classes, when underlying + * DevSound instance has not yet been created. + */ + +const int DefaultBufferSize = 4096; // bytes +const int DefaultNotifyInterval = 1000; // ms + +/** + * Enumeration used to track state of internal DevSound instances. + * Values are translated to the corresponding QAudio::State values by + * SymbianAudio::Utils::stateNativeToQt. + */ +enum State { + ClosedState + , InitializingState + , ActiveState + , IdleState + , SuspendedState +}; + +/* + * Helper class for querying DevSound codec / format support + */ +class DevSoundCapabilities { +public: + DevSoundCapabilities(CMMFDevSound &devsound, QAudio::Mode mode); + ~DevSoundCapabilities(); + + const RArray& fourCC() const { return m_fourCC; } + const TMMFCapabilities& caps() const { return m_caps; } + +private: + void constructL(CMMFDevSound &devsound, QAudio::Mode mode); + +private: + RArray m_fourCC; + TMMFCapabilities m_caps; +}; + +namespace Utils { + +/** + * Convert native audio capabilities to QAudio lists. + */ +void capabilitiesNativeToQt(const DevSoundCapabilities &caps, + QList &frequencies, + QList &channels, + QList &sampleSizes, + QList &byteOrders, + QList &sampleTypes); + +/** + * Check whether format is supported. + */ +bool isFormatSupported(const QAudioFormat &format, + const DevSoundCapabilities &caps); + +/** + * Convert QAudioFormat to native format types. + * + * Note that, despite the name, DevSound uses TMMFCapabilities to specify + * single formats as well as capabilities. + * + * Note that this function does not modify outputFormat.iBufferSize. + */ +bool formatQtToNative(const QAudioFormat &inputFormat, + TUint32 &outputFourCC, + TMMFCapabilities &outputFormat); + +/** + * Convert internal states to QAudio states. + */ +QAudio::State stateNativeToQt(State nativeState, + QAudio::State initializingState); + +/** + * Convert data length to number of samples. + */ +qint64 bytesToSamples(const QAudioFormat &format, qint64 length); + +/** + * Convert number of samples to data length. + */ +qint64 samplesToBytes(const QAudioFormat &format, qint64 samples); + +} // namespace Utils +} // namespace SymbianAudio + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp new file mode 100644 index 0000000..96545b4 --- /dev/null +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 +#include +#include +#include +#include "qaudiodevicefactory_p.h" + +#ifndef QT_NO_AUDIO_BACKEND +#if defined(Q_OS_WIN) +#include "qaudiodeviceinfo_win32_p.h" +#include "qaudiooutput_win32_p.h" +#include "qaudioinput_win32_p.h" +#elif defined(Q_OS_MAC) +#include "qaudiodeviceinfo_mac_p.h" +#include "qaudiooutput_mac_p.h" +#include "qaudioinput_mac_p.h" +#elif defined(HAS_ALSA) +#include "qaudiodeviceinfo_alsa_p.h" +#include "qaudiooutput_alsa_p.h" +#include "qaudioinput_alsa_p.h" +#elif defined(Q_OS_SYMBIAN) +#include "qaudiodeviceinfo_symbian_p.h" +#include "qaudiooutput_symbian_p.h" +#include "qaudioinput_symbian_p.h" +#endif +#endif + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_LIBRARY +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (QAudioEngineFactoryInterface_iid, QLatin1String("/audio"), Qt::CaseInsensitive)) +#endif + +class QNullDeviceInfo : public QAbstractAudioDeviceInfo +{ +public: + QAudioFormat preferredFormat() const { qWarning()<<"using null deviceinfo, none available"; return QAudioFormat(); } + bool isFormatSupported(const QAudioFormat& ) const { return false; } + QAudioFormat nearestFormat(const QAudioFormat& ) const { return QAudioFormat(); } + QString deviceName() const { return QString(); } + QStringList codecList() { return QStringList(); } + QList frequencyList() { return QList(); } + QList channelsList() { return QList(); } + QList sampleSizeList() { return QList(); } + QList byteOrderList() { return QList(); } + QList sampleTypeList() { return QList(); } +}; + +class QNullInputDevice : public QAbstractAudioInput +{ +public: + QIODevice* start(QIODevice* ) { qWarning()<<"using null input device, none available"; return 0; } + void stop() {} + void reset() {} + void suspend() {} + void resume() {} + int bytesReady() const { return 0; } + int periodSize() const { return 0; } + void setBufferSize(int ) {} + int bufferSize() const { return 0; } + void setNotifyInterval(int ) {} + int notifyInterval() const { return 0; } + qint64 processedUSecs() const { return 0; } + qint64 elapsedUSecs() const { return 0; } + QAudio::Error error() const { return QAudio::OpenError; } + QAudio::State state() const { return QAudio::StoppedState; } + QAudioFormat format() const { return QAudioFormat(); } +}; + +class QNullOutputDevice : public QAbstractAudioOutput +{ +public: + QIODevice* start(QIODevice* ) { qWarning()<<"using null output device, none available"; return 0; } + void stop() {} + void reset() {} + void suspend() {} + void resume() {} + int bytesFree() const { return 0; } + int periodSize() const { return 0; } + void setBufferSize(int ) {} + int bufferSize() const { return 0; } + void setNotifyInterval(int ) {} + int notifyInterval() const { return 0; } + qint64 processedUSecs() const { return 0; } + qint64 elapsedUSecs() const { return 0; } + QAudio::Error error() const { return QAudio::OpenError; } + QAudio::State state() const { return QAudio::StoppedState; } + QAudioFormat format() const { return QAudioFormat(); } +}; + +QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) +{ + QList devices; +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) + foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode)) + devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); +#endif +#endif + +#ifndef QT_NO_LIBRARY + QFactoryLoader* l = loader(); + + foreach (QString const& key, l->keys()) { + QAudioEngineFactoryInterface* plugin = qobject_cast(l->instance(key)); + if (plugin) { + foreach (QByteArray const& handle, plugin->availableDevices(mode)) + devices << QAudioDeviceInfo(key, handle, mode); + } + + delete plugin; + } +#endif + + return devices; +} + +QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() +{ +#ifndef QT_NO_LIBRARY + QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); + + if (plugin) { + QList list = plugin->availableDevices(QAudio::AudioInput); + if (list.size() > 0) + return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput); + } +#endif + +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) + return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultInputDevice(), QAudio::AudioInput); +#endif +#endif + return QAudioDeviceInfo(); +} + +QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() +{ +#ifndef QT_NO_LIBRARY + QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); + + if (plugin) { + QList list = plugin->availableDevices(QAudio::AudioOutput); + if (list.size() > 0) + return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); + } +#endif + +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) + return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput); +#endif +#endif + return QAudioDeviceInfo(); +} + +QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode) +{ + QAbstractAudioDeviceInfo *rc = 0; + +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) + if (realm == QLatin1String("builtin")) + return new QAudioDeviceInfoInternal(handle, mode); +#endif +#endif + +#ifndef QT_NO_LIBRARY + QAudioEngineFactoryInterface* plugin = + qobject_cast(loader()->instance(realm)); + + if (plugin) + rc = plugin->createDeviceInfo(handle, mode); +#endif + + return rc == 0 ? new QNullDeviceInfo() : rc; +} + +QAbstractAudioInput* QAudioDeviceFactory::createDefaultInputDevice(QAudioFormat const &format) +{ + return createInputDevice(defaultInputDevice(), format); +} + +QAbstractAudioOutput* QAudioDeviceFactory::createDefaultOutputDevice(QAudioFormat const &format) +{ + return createOutputDevice(defaultOutputDevice(), format); +} + +QAbstractAudioInput* QAudioDeviceFactory::createInputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) +{ + if (deviceInfo.isNull()) + return new QNullInputDevice(); +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) + if (deviceInfo.realm() == QLatin1String("builtin")) + return new QAudioInputPrivate(deviceInfo.handle(), format); +#endif +#endif +#ifndef QT_NO_LIBRARY + QAudioEngineFactoryInterface* plugin = + qobject_cast(loader()->instance(deviceInfo.realm())); + + if (plugin) + return plugin->createInput(deviceInfo.handle(), format); +#endif + + return new QNullInputDevice(); +} + +QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) +{ + if (deviceInfo.isNull()) + return new QNullOutputDevice(); +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) + if (deviceInfo.realm() == QLatin1String("builtin")) + return new QAudioOutputPrivate(deviceInfo.handle(), format); +#endif +#endif + +#ifndef QT_NO_LIBRARY + QAudioEngineFactoryInterface* plugin = + qobject_cast(loader()->instance(deviceInfo.realm())); + + if (plugin) + return plugin->createOutput(deviceInfo.handle(), format); +#endif + + return new QNullOutputDevice(); +} + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudiodevicefactory_p.h b/src/multimedia/audio/qaudiodevicefactory_p.h new file mode 100644 index 0000000..8ee8b05 --- /dev/null +++ b/src/multimedia/audio/qaudiodevicefactory_p.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIODEVICEFACTORY_P_H +#define QAUDIODEVICEFACTORY_P_H + +#include +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QAbstractAudioInput; +class QAbstractAudioOutput; +class QAbstractAudioDeviceInfo; + +class QAudioDeviceFactory +{ +public: + static QList availableDevices(QAudio::Mode mode); + + static QAudioDeviceInfo defaultInputDevice(); + static QAudioDeviceInfo defaultOutputDevice(); + + static QAbstractAudioDeviceInfo* audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); + + static QAbstractAudioInput* createDefaultInputDevice(QAudioFormat const &format); + static QAbstractAudioOutput* createDefaultOutputDevice(QAudioFormat const &format); + + static QAbstractAudioInput* createInputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format); + static QAbstractAudioOutput* createOutputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format); + + static QAbstractAudioInput* createNullInput(); + static QAbstractAudioOutput* createNullOutput(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIODEVICEFACTORY_P_H + diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp new file mode 100644 index 0000000..ff04b4e --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -0,0 +1,400 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qaudiodevicefactory_p.h" +#include +#include + + +QT_BEGIN_NAMESPACE + +class QAudioDeviceInfoPrivate : public QSharedData +{ +public: + QAudioDeviceInfoPrivate():info(0) {} + QAudioDeviceInfoPrivate(const QString &r, const QByteArray &h, QAudio::Mode m): + realm(r), handle(h), mode(m) + { + info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); + } + + QAudioDeviceInfoPrivate(const QAudioDeviceInfoPrivate &other): + QSharedData(other), + realm(other.realm), handle(other.handle), mode(other.mode) + { + info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); + } + + QAudioDeviceInfoPrivate& operator=(const QAudioDeviceInfoPrivate &other) + { + delete info; + + realm = other.realm; + handle = other.handle; + mode = other.mode; + info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); + return *this; + } + + ~QAudioDeviceInfoPrivate() + { + delete info; + } + + QString realm; + QByteArray handle; + QAudio::Mode mode; + QAbstractAudioDeviceInfo* info; +}; + + +/*! + \class QAudioDeviceInfo + \brief The QAudioDeviceInfo class provides an interface to query audio devices and their functionality. + \inmodule QtMultimedia + \ingroup multimedia + + \since 4.6 + + QAudioDeviceInfo lets you query for audio devices--such as sound + cards and USB headsets--that are currently available on the system. + The audio devices available are dependent on the platform or audio plugins installed. + + You can also query each device for the formats it supports. A + format in this context is a set consisting of a specific byte + order, channel, codec, frequency, sample rate, and sample type. A + format is represented by the QAudioFormat class. + + The values supported by the the device for each of these + parameters can be fetched with + supportedByteOrders(), supportedChannelCounts(), supportedCodecs(), + supportedSampleRates(), supportedSampleSizes(), and + supportedSampleTypes(). The combinations supported are dependent on the platform, + audio plugins installed and the audio device capabilities. If you need a specific format, you can check if + the device supports it with isFormatSupported(), or fetch a + supported format that is as close as possible to the format with + nearestFormat(). For instance: + + \snippet doc/src/snippets/audio/main.cpp 1 + \dots 8 + \snippet doc/src/snippets/audio/main.cpp 2 + + A QAudioDeviceInfo is used by Qt to construct + classes that communicate with the device--such as + QAudioInput, and QAudioOutput. The static + functions defaultInputDevice(), defaultOutputDevice(), and + availableDevices() let you get a list of all available + devices. Devices are fetch according to the value of mode + this is specified by the QAudio::Mode enum. + The QAudioDeviceInfo returned are only valid for the QAudio::Mode. + + For instance: + + \code + foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) + qDebug() << "Device name: " << deviceInfo.deviceName(); + \endcode + + In this code sample, we loop through all devices that are able to output + sound, i.e., play an audio stream in a supported format. For each device we + find, we simply print the deviceName(). + + \sa QAudioOutput, QAudioInput +*/ + +/*! + Constructs an empty QAudioDeviceInfo object. +*/ + +QAudioDeviceInfo::QAudioDeviceInfo(): + d(new QAudioDeviceInfoPrivate) +{ +} + +/*! + Constructs a copy of \a other. +*/ + +QAudioDeviceInfo::QAudioDeviceInfo(const QAudioDeviceInfo& other): + d(other.d) +{ +} + +/*! + Destroy this audio device info. +*/ + +QAudioDeviceInfo::~QAudioDeviceInfo() +{ +} + +/*! + Sets the QAudioDeviceInfo object to be equal to \a other. +*/ + +QAudioDeviceInfo& QAudioDeviceInfo::operator=(const QAudioDeviceInfo &other) +{ + d = other.d; + return *this; +} + +/*! + Returns whether this QAudioDeviceInfo object holds a device definition. +*/ + +bool QAudioDeviceInfo::isNull() const +{ + return d->info == 0; +} + +/*! + Returns human readable name of audio device. + + Device names vary depending on platform/audio plugin being used. + + They are a unique string identifiers for the audio device. + + eg. default, Intel, U0x46d0x9a4 +*/ + +QString QAudioDeviceInfo::deviceName() const +{ + return isNull() ? QString() : d->info->deviceName(); +} + +/*! + Returns true if \a settings are supported by the audio device of this QAudioDeviceInfo. +*/ + +bool QAudioDeviceInfo::isFormatSupported(const QAudioFormat &settings) const +{ + return isNull() ? false : d->info->isFormatSupported(settings); +} + +/*! + Returns QAudioFormat of default settings. + + These settings are provided by the platform/audio plugin being used. + + They also are dependent on the QAudio::Mode being used. + + A typical audio system would provide something like: + \list + \o Input settings: 8000Hz mono 8 bit. + \o Output settings: 44100Hz stereo 16 bit little endian. + \endlist +*/ + +QAudioFormat QAudioDeviceInfo::preferredFormat() const +{ + return isNull() ? QAudioFormat() : d->info->preferredFormat(); +} + +/*! + Returns closest QAudioFormat to \a settings that system audio supports. + + These settings are provided by the platform/audio plugin being used. + + They also are dependent on the QAudio::Mode being used. +*/ + +QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const +{ + return isNull() ? QAudioFormat() : d->info->nearestFormat(settings); +} + +/*! + Returns a list of supported codecs. + + All platform and plugin implementations should provide support for: + + "audio/pcm" - Linear PCM + + For writing plugins to support additional codecs refer to: + + http://www.iana.org/assignments/media-types/audio/ +*/ + +QStringList QAudioDeviceInfo::supportedCodecs() const +{ + return isNull() ? QStringList() : d->info->codecList(); +} + +/*! + Returns a list of supported sample rates. + + \since 4.7 +*/ + +QList QAudioDeviceInfo::supportedSampleRates() const +{ + return supportedFrequencies(); +} + +/*! + \obsolete + + Use supportedSampleRates() instead. +*/ + +QList QAudioDeviceInfo::supportedFrequencies() const +{ + return isNull() ? QList() : d->info->frequencyList(); +} + +/*! + Returns a list of supported channel counts. + + \since 4.7 +*/ + +QList QAudioDeviceInfo::supportedChannelCounts() const +{ + return supportedChannels(); +} + +/*! + \obsolete + + Use supportedChannelCount() instead. +*/ + +QList QAudioDeviceInfo::supportedChannels() const +{ + return isNull() ? QList() : d->info->channelsList(); +} + +/*! + Returns a list of supported sample sizes. +*/ + +QList QAudioDeviceInfo::supportedSampleSizes() const +{ + return isNull() ? QList() : d->info->sampleSizeList(); +} + +/*! + Returns a list of supported byte orders. +*/ + +QList QAudioDeviceInfo::supportedByteOrders() const +{ + return isNull() ? QList() : d->info->byteOrderList(); +} + +/*! + Returns a list of supported sample types. +*/ + +QList QAudioDeviceInfo::supportedSampleTypes() const +{ + return isNull() ? QList() : d->info->sampleTypeList(); +} + +/*! + Returns the name of the default input audio device. + All platform and audio plugin implementations provide a default audio device to use. +*/ + +QAudioDeviceInfo QAudioDeviceInfo::defaultInputDevice() +{ + return QAudioDeviceFactory::defaultInputDevice(); +} + +/*! + Returns the name of the default output audio device. + All platform and audio plugin implementations provide a default audio device to use. +*/ + +QAudioDeviceInfo QAudioDeviceInfo::defaultOutputDevice() +{ + return QAudioDeviceFactory::defaultOutputDevice(); +} + +/*! + Returns a list of audio devices that support \a mode. +*/ + +QList QAudioDeviceInfo::availableDevices(QAudio::Mode mode) +{ + return QAudioDeviceFactory::availableDevices(mode); +} + + +/*! + \internal +*/ + +QAudioDeviceInfo::QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode): + d(new QAudioDeviceInfoPrivate(realm, handle, mode)) +{ +} + +/*! + \internal +*/ + +QString QAudioDeviceInfo::realm() const +{ + return d->realm; +} + +/*! + \internal +*/ + +QByteArray QAudioDeviceInfo::handle() const +{ + return d->handle; +} + + +/*! + \internal +*/ + +QAudio::Mode QAudioDeviceInfo::mode() const +{ + return d->mode; +} + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h new file mode 100644 index 0000000..1cc0731 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QAUDIODEVICEINFO_H +#define QAUDIODEVICEINFO_H + +#include +#include +#include +#include +#include +#include + +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QAudioDeviceFactory; + +class QAudioDeviceInfoPrivate; +class Q_MULTIMEDIA_EXPORT QAudioDeviceInfo +{ + friend class QAudioDeviceFactory; + +public: + QAudioDeviceInfo(); + QAudioDeviceInfo(const QAudioDeviceInfo& other); + ~QAudioDeviceInfo(); + + QAudioDeviceInfo& operator=(const QAudioDeviceInfo& other); + + bool isNull() const; + + QString deviceName() const; + + bool isFormatSupported(const QAudioFormat &format) const; + QAudioFormat preferredFormat() const; + QAudioFormat nearestFormat(const QAudioFormat &format) const; + + QStringList supportedCodecs() const; + QList supportedFrequencies() const; + QList supportedSampleRates() const; + QList supportedChannels() const; + QList supportedChannelCounts() const; + QList supportedSampleSizes() const; + QList supportedByteOrders() const; + QList supportedSampleTypes() const; + + static QAudioDeviceInfo defaultInputDevice(); + static QAudioDeviceInfo defaultOutputDevice(); + + static QList availableDevices(QAudio::Mode mode); + +private: + QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); + QString realm() const; + QByteArray handle() const; + QAudio::Mode mode() const; + + QSharedDataPointer d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +Q_DECLARE_METATYPE(QAudioDeviceInfo) + +#endif // QAUDIODEVICEINFO_H diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp new file mode 100644 index 0000000..36270a7 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -0,0 +1,486 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qaudiodeviceinfo_alsa_p.h" + +#include + +QT_BEGIN_NAMESPACE + +QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) +{ + handle = 0; + + device = QLatin1String(dev); + this->mode = mode; +} + +QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() +{ + close(); +} + +bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const +{ + return testSettings(format); +} + +QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const +{ + QAudioFormat nearest; + if(mode == QAudio::AudioOutput) { + nearest.setFrequency(44100); + nearest.setChannels(2); + nearest.setByteOrder(QAudioFormat::LittleEndian); + nearest.setSampleType(QAudioFormat::SignedInt); + nearest.setSampleSize(16); + nearest.setCodec(QLatin1String("audio/pcm")); + } else { + nearest.setFrequency(8000); + nearest.setChannels(1); + nearest.setSampleType(QAudioFormat::UnSignedInt); + nearest.setSampleSize(8); + nearest.setCodec(QLatin1String("audio/pcm")); + if(!testSettings(nearest)) { + nearest.setChannels(2); + nearest.setSampleSize(16); + nearest.setSampleType(QAudioFormat::SignedInt); + } + } + return nearest; +} + +QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) const +{ + if(testSettings(format)) + return format; + else + return preferredFormat(); +} + +QString QAudioDeviceInfoInternal::deviceName() const +{ + return device; +} + +QStringList QAudioDeviceInfoInternal::codecList() +{ + updateLists(); + return codecz; +} + +QList QAudioDeviceInfoInternal::frequencyList() +{ + updateLists(); + return freqz; +} + +QList QAudioDeviceInfoInternal::channelsList() +{ + updateLists(); + return channelz; +} + +QList QAudioDeviceInfoInternal::sampleSizeList() +{ + updateLists(); + return sizez; +} + +QList QAudioDeviceInfoInternal::byteOrderList() +{ + updateLists(); + return byteOrderz; +} + +QList QAudioDeviceInfoInternal::sampleTypeList() +{ + updateLists(); + return typez; +} + +bool QAudioDeviceInfoInternal::open() +{ + int err = 0; + QString dev = device; + QList devices = availableDevices(mode); + + if(dev.compare(QLatin1String("default")) == 0) { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = QLatin1String(devices.first().constData()); +#else + dev = QLatin1String("hw:0,0"); +#endif + } else { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = device; +#else + int idx = 0; + char *name; + + QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1); + + while(snd_card_get_name(idx,&name) == 0) { + if(dev.contains(QLatin1String(name))) + break; + idx++; + } + dev = QString(QLatin1String("hw:%1,0")).arg(idx); +#endif + } + if(mode == QAudio::AudioOutput) { + err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); + } else { + err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); + } + if(err < 0) { + handle = 0; + return false; + } + return true; +} + +void QAudioDeviceInfoInternal::close() +{ + if(handle) + snd_pcm_close(handle); + handle = 0; +} + +bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const +{ + // Set nearest to closest settings that do work. + // See if what is in settings will work (return value). + int err = 0; + snd_pcm_t* handle; + snd_pcm_hw_params_t *params; + QString dev = device; + + QList devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); + + if(dev.compare(QLatin1String("default")) == 0) { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = QLatin1String(devices.first().constData()); +#else + dev = QLatin1String("hw:0,0"); +#endif + } else { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = device; +#else + int idx = 0; + char *name; + + QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1); + + while(snd_card_get_name(idx,&name) == 0) { + if(shortName.compare(QLatin1String(name)) == 0) + break; + idx++; + } + dev = QString(QLatin1String("hw:%1,0")).arg(idx); +#endif + } + if(mode == QAudio::AudioOutput) { + err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); + } else { + err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); + } + if(err < 0) { + handle = 0; + return false; + } + + bool testChannel = false; + bool testCodec = false; + bool testFreq = false; + bool testType = false; + bool testSize = false; + + int dir = 0; + + snd_pcm_nonblock( handle, 0 ); + snd_pcm_hw_params_alloca( ¶ms ); + snd_pcm_hw_params_any( handle, params ); + + // set the values! + snd_pcm_hw_params_set_channels(handle,params,format.channels()); + snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); + switch(format.sampleSize()) { + case 8: + if(format.sampleType() == QAudioFormat::SignedInt) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8); + else if(format.sampleType() == QAudioFormat::UnSignedInt) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8); + break; + case 16: + if(format.sampleType() == QAudioFormat::SignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE); + } else if(format.sampleType() == QAudioFormat::UnSignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE); + } + break; + case 32: + if(format.sampleType() == QAudioFormat::SignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE); + } else if(format.sampleType() == QAudioFormat::UnSignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE); + } + } + + // For now, just accept only audio/pcm codec + if(!format.codec().startsWith(QLatin1String("audio/pcm"))) { + err=-1; + } else + testCodec = true; + + if(err>=0 && format.channels() != -1) { + err = snd_pcm_hw_params_test_channels(handle,params,format.channels()); + if(err>=0) + err = snd_pcm_hw_params_set_channels(handle,params,format.channels()); + if(err>=0) + testChannel = true; + } + + if(err>=0 && format.frequency() != -1) { + err = snd_pcm_hw_params_test_rate(handle,params,format.frequency(),0); + if(err>=0) + err = snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); + if(err>=0) + testFreq = true; + } + + if((err>=0 && format.sampleSize() != -1) && + (format.sampleType() != QAudioFormat::Unknown)) { + switch(format.sampleSize()) { + case 8: + if(format.sampleType() == QAudioFormat::SignedInt) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8); + else if(format.sampleType() == QAudioFormat::UnSignedInt) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8); + break; + case 16: + if(format.sampleType() == QAudioFormat::SignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE); + } else if(format.sampleType() == QAudioFormat::UnSignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE); + } + break; + case 32: + if(format.sampleType() == QAudioFormat::SignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE); + } else if(format.sampleType() == QAudioFormat::UnSignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE); + } + } + if(err>=0) { + testSize = true; + testType = true; + } + } + if(err>=0) + err = snd_pcm_hw_params(handle, params); + + if(err == 0) { + // settings work + // close() + if(handle) + snd_pcm_close(handle); + return true; + } + if(handle) + snd_pcm_close(handle); + + return false; +} + +void QAudioDeviceInfoInternal::updateLists() +{ + // redo all lists based on current settings + freqz.clear(); + channelz.clear(); + sizez.clear(); + byteOrderz.clear(); + typez.clear(); + codecz.clear(); + + if(!handle) + open(); + + if(!handle) + return; + + for(int i=0; i<(int)MAX_SAMPLE_RATES; i++) { + //if(snd_pcm_hw_params_test_rate(handle, params, SAMPLE_RATES[i], dir) == 0) + freqz.append(SAMPLE_RATES[i]); + } + channelz.append(1); + channelz.append(2); + sizez.append(8); + sizez.append(16); + sizez.append(32); + byteOrderz.append(QAudioFormat::LittleEndian); + byteOrderz.append(QAudioFormat::BigEndian); + typez.append(QAudioFormat::SignedInt); + typez.append(QAudioFormat::UnSignedInt); + typez.append(QAudioFormat::Float); + codecz.append(QLatin1String("audio/pcm")); + close(); +} + +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) +{ + QList allDevices; + QList devices; + QByteArray filter; + +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + // Create a list of all current audio devices that support mode + void **hints, **n; + char *name, *descr, *io; + + if(snd_device_name_hint(-1, "pcm", &hints) < 0) { + qWarning() << "no alsa devices available"; + return devices; + } + n = hints; + + if(mode == QAudio::AudioInput) { + filter = "Input"; + } else { + filter = "Output"; + } + + while (*n != NULL) { + name = snd_device_name_get_hint(*n, "NAME"); + descr = snd_device_name_get_hint(*n, "DESC"); + io = snd_device_name_get_hint(*n, "IOID"); + if((name != NULL) && (descr != NULL) && ((io == NULL) || (io == filter))) { + QString deviceName = QLatin1String(name); + QString deviceDescription = QLatin1String(descr); + allDevices.append(deviceName.toLocal8Bit().constData()); + if(deviceDescription.contains(QLatin1String("Default Audio Device"))) + devices.append(deviceName.toLocal8Bit().constData()); + } + if(name != NULL) + free(name); + if(descr != NULL) + free(descr); + if(io != NULL) + free(io); + ++n; + } + snd_device_name_free_hint(hints); + + if(devices.size() > 0) { + devices.append("default"); + } +#else + int idx = 0; + char* name; + + while(snd_card_get_name(idx,&name) == 0) { + devices.append(name); + idx++; + } + if (idx > 0) + devices.append("default"); +#endif + if (devices.size() == 0 && allDevices.size() > 0) + return allDevices; + + return devices; +} + +QByteArray QAudioDeviceInfoInternal::defaultInputDevice() +{ + QList devices = availableDevices(QAudio::AudioInput); + if(devices.size() == 0) + return QByteArray(); + + return devices.first(); +} + +QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() +{ + QList devices = availableDevices(QAudio::AudioOutput); + if(devices.size() == 0) + return QByteArray(); + + return devices.first(); +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h new file mode 100644 index 0000000..6f9a459 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QAUDIODEVICEINFOALSA_H +#define QAUDIODEVICEINFOALSA_H + +#include + +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +const unsigned int MAX_SAMPLE_RATES = 5; +const unsigned int SAMPLE_RATES[] = + { 8000, 11025, 22050, 44100, 48000 }; + +class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo +{ + Q_OBJECT +public: + QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); + ~QAudioDeviceInfoInternal(); + + bool testSettings(const QAudioFormat& format) const; + void updateLists(); + QAudioFormat preferredFormat() const; + bool isFormatSupported(const QAudioFormat& format) const; + QAudioFormat nearestFormat(const QAudioFormat& format) const; + QString deviceName() const; + QStringList codecList(); + QList frequencyList(); + QList channelsList(); + QList sampleSizeList(); + QList byteOrderList(); + QList sampleTypeList(); + static QByteArray defaultInputDevice(); + static QByteArray defaultOutputDevice(); + static QList availableDevices(QAudio::Mode); + +private: + bool open(); + void close(); + + QString device; + QAudio::Mode mode; + QAudioFormat nearest; + QList freqz; + QList channelz; + QList sizez; + QList byteOrderz; + QStringList codecz; + QList typez; + snd_pcm_t* handle; + snd_pcm_hw_params_t *params; +}; + +QT_END_NAMESPACE + +#endif + diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp new file mode 100644 index 0000000..ecd03e5 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -0,0 +1,357 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +#include +#include "qaudio_mac_p.h" +#include "qaudiodeviceinfo_mac_p.h" + + + +QT_BEGIN_NAMESPACE + + +QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray const& handle, QAudio::Mode) +{ + QDataStream ds(handle); + quint32 did, tm; + + ds >> did >> tm >> name; + deviceId = AudioDeviceID(did); + mode = QAudio::Mode(tm); +} + +bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const +{ + return format.codec() == QString::fromLatin1("audio/pcm"); +} + +QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const +{ + QAudioFormat rc; + + UInt32 propSize = 0; + + if (AudioDeviceGetPropertyInfo(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyStreams, + &propSize, + 0) == noErr) { + + const int sc = propSize / sizeof(AudioStreamID); + + if (sc > 0) { + AudioStreamID* streams = new AudioStreamID[sc]; + + if (AudioDeviceGetProperty(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyStreams, + &propSize, + streams) == noErr) { + + for (int i = 0; i < sc; ++i) { + if (AudioStreamGetPropertyInfo(streams[i], + 0, + kAudioStreamPropertyPhysicalFormat, + &propSize, + 0) == noErr) { + + AudioStreamBasicDescription sf; + + if (AudioStreamGetProperty(streams[i], + 0, + kAudioStreamPropertyPhysicalFormat, + &propSize, + &sf) == noErr) { + rc = toQAudioFormat(sf); + break; + } + } + } + } + + delete streams; + } + } + + return rc; +} + +QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) const +{ + QAudioFormat rc(format); + QAudioFormat target = preferredFormat(); + + if (!format.codec().isEmpty() && format.codec() != QString::fromLatin1("audio/pcm")) + return QAudioFormat(); + + rc.setCodec(QString::fromLatin1("audio/pcm")); + + if (rc.frequency() != target.frequency()) + rc.setFrequency(target.frequency()); + if (rc.channels() != target.channels()) + rc.setChannels(target.channels()); + if (rc.sampleSize() != target.sampleSize()) + rc.setSampleSize(target.sampleSize()); + if (rc.byteOrder() != target.byteOrder()) + rc.setByteOrder(target.byteOrder()); + if (rc.sampleType() != target.sampleType()) + rc.setSampleType(target.sampleType()); + + return rc; +} + +QString QAudioDeviceInfoInternal::deviceName() const +{ + return name; +} + +QStringList QAudioDeviceInfoInternal::codecList() +{ + return QStringList() << QString::fromLatin1("audio/pcm"); +} + +QList QAudioDeviceInfoInternal::frequencyList() +{ + QSet rc; + + // Add some common frequencies + rc << 8000 << 11025 << 22050 << 44100; + + // + UInt32 propSize = 0; + + if (AudioDeviceGetPropertyInfo(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyAvailableNominalSampleRates, + &propSize, + 0) == noErr) { + + const int pc = propSize / sizeof(AudioValueRange); + + if (pc > 0) { + AudioValueRange* vr = new AudioValueRange[pc]; + + if (AudioDeviceGetProperty(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyAvailableNominalSampleRates, + &propSize, + vr) == noErr) { + + for (int i = 0; i < pc; ++i) + rc << vr[i].mMaximum; + } + + delete vr; + } + } + + return rc.toList(); +} + +QList QAudioDeviceInfoInternal::channelsList() +{ + QList rc; + + // Can mix down to 1 channel + rc << 1; + + UInt32 propSize = 0; + int channels = 0; + + if (AudioDeviceGetPropertyInfo(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyStreamConfiguration, + &propSize, + 0) == noErr) { + + AudioBufferList* audioBufferList = static_cast(qMalloc(propSize)); + + if (audioBufferList != 0) { + if (AudioDeviceGetProperty(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyStreamConfiguration, + &propSize, + audioBufferList) == noErr) { + + for (int i = 0; i < int(audioBufferList->mNumberBuffers); ++i) { + channels += audioBufferList->mBuffers[i].mNumberChannels; + rc << channels; + } + } + + qFree(audioBufferList); + } + } + + return rc; +} + +QList QAudioDeviceInfoInternal::sampleSizeList() +{ + return QList() << 8 << 16 << 24 << 32 << 64; +} + +QList QAudioDeviceInfoInternal::byteOrderList() +{ + return QList() << QAudioFormat::LittleEndian << QAudioFormat::BigEndian; +} + +QList QAudioDeviceInfoInternal::sampleTypeList() +{ + return QList() << QAudioFormat::SignedInt << QAudioFormat::UnSignedInt << QAudioFormat::Float; +} + +static QByteArray get_device_info(AudioDeviceID audioDevice, QAudio::Mode mode) +{ + UInt32 size; + QByteArray device; + QDataStream ds(&device, QIODevice::WriteOnly); + AudioStreamBasicDescription sf; + CFStringRef name; + Boolean isInput = mode == QAudio::AudioInput; + + // Id + ds << quint32(audioDevice); + + // Mode + size = sizeof(AudioStreamBasicDescription); + if (AudioDeviceGetProperty(audioDevice, 0, isInput, kAudioDevicePropertyStreamFormat, + &size, &sf) != noErr) { + return QByteArray(); + } + ds << quint32(mode); + + // Name + size = sizeof(CFStringRef); + if (AudioDeviceGetProperty(audioDevice, 0, isInput, kAudioObjectPropertyName, + &size, &name) != noErr) { + qWarning() << "QAudioDeviceInfo: Unable to find device name"; + } + ds << QCFString::toQString(name); + + CFRelease(name); + + return device; +} + +QByteArray QAudioDeviceInfoInternal::defaultInputDevice() +{ + AudioDeviceID audioDevice; + UInt32 size = sizeof(audioDevice); + + if (AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &size, + &audioDevice) != noErr) { + qWarning() << "QAudioDeviceInfo: Unable to find default input device"; + return QByteArray(); + } + + return get_device_info(audioDevice, QAudio::AudioInput); +} + +QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() +{ + AudioDeviceID audioDevice; + UInt32 size = sizeof(audioDevice); + + if (AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, + &audioDevice) != noErr) { + qWarning() << "QAudioDeviceInfo: Unable to find default output device"; + return QByteArray(); + } + + return get_device_info(audioDevice, QAudio::AudioOutput); +} + +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) +{ + QList devices; + + UInt32 propSize = 0; + + if (AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propSize, 0) == noErr) { + + const int dc = propSize / sizeof(AudioDeviceID); + + if (dc > 0) { + AudioDeviceID* audioDevices = new AudioDeviceID[dc]; + + if (AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propSize, audioDevices) == noErr) { + for (int i = 0; i < dc; ++i) { + QByteArray info = get_device_info(audioDevices[i], mode); + if (!info.isNull()) + devices << info; + } + } + + delete audioDevices; + } + } + + return devices; +} + + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h new file mode 100644 index 0000000..e234384 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QDEVICEINFO_MAC_P_H +#define QDEVICEINFO_MAC_P_H + +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo +{ +public: + AudioDeviceID deviceId; + QString name; + QAudio::Mode mode; + + QAudioDeviceInfoInternal(QByteArray const& handle, QAudio::Mode mode); + + bool isFormatSupported(const QAudioFormat& format) const; + QAudioFormat preferredFormat() const; + QAudioFormat nearestFormat(const QAudioFormat& format) const; + + QString deviceName() const; + + QStringList codecList(); + QList frequencyList(); + QList channelsList(); + QList sampleSizeList(); + QList byteOrderList(); + QList sampleTypeList(); + + static QByteArray defaultInputDevice(); + static QByteArray defaultOutputDevice(); + + static QList availableDevices(QAudio::Mode mode); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QDEVICEINFO_MAC_P_H diff --git a/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp new file mode 100644 index 0000000..36284d3 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qaudiodeviceinfo_symbian_p.h" +#include "qaudio_symbian_p.h" + +QT_BEGIN_NAMESPACE + +QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray device, + QAudio::Mode mode) + : m_deviceName(QLatin1String(device)) + , m_mode(mode) + , m_updated(false) +{ + QT_TRAP_THROWING(m_devsound.reset(CMMFDevSound::NewL())); +} + +QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() +{ + +} + +QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const +{ + QAudioFormat format; + switch (m_mode) { + case QAudio::AudioOutput: + format.setFrequency(44100); + format.setChannels(2); + format.setSampleSize(16); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setSampleType(QAudioFormat::SignedInt); + format.setCodec(QLatin1String("audio/pcm")); + break; + + case QAudio::AudioInput: + format.setFrequency(8000); + format.setChannels(1); + format.setSampleSize(16); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setSampleType(QAudioFormat::SignedInt); + format.setCodec(QLatin1String("audio/pcm")); + break; + + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); + } + + if (!isFormatSupported(format)) { + if (m_frequencies.size()) + format.setFrequency(m_frequencies[0]); + if (m_channels.size()) + format.setChannels(m_channels[0]); + if (m_sampleSizes.size()) + format.setSampleSize(m_sampleSizes[0]); + if (m_byteOrders.size()) + format.setByteOrder(m_byteOrders[0]); + if (m_sampleTypes.size()) + format.setSampleType(m_sampleTypes[0]); + } + + return format; +} + +bool QAudioDeviceInfoInternal::isFormatSupported( + const QAudioFormat &format) const +{ + getSupportedFormats(); + const bool supported = + m_codecs.contains(format.codec()) + && m_frequencies.contains(format.frequency()) + && m_channels.contains(format.channels()) + && m_sampleSizes.contains(format.sampleSize()) + && m_byteOrders.contains(format.byteOrder()) + && m_sampleTypes.contains(format.sampleType()); + + return supported; +} + +QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat &format) const +{ + if (isFormatSupported(format)) + return format; + else + return preferredFormat(); +} + +QString QAudioDeviceInfoInternal::deviceName() const +{ + return m_deviceName; +} + +QStringList QAudioDeviceInfoInternal::codecList() +{ + getSupportedFormats(); + return m_codecs; +} + +QList QAudioDeviceInfoInternal::frequencyList() +{ + getSupportedFormats(); + return m_frequencies; +} + +QList QAudioDeviceInfoInternal::channelsList() +{ + getSupportedFormats(); + return m_channels; +} + +QList QAudioDeviceInfoInternal::sampleSizeList() +{ + getSupportedFormats(); + return m_sampleSizes; +} + +QList QAudioDeviceInfoInternal::byteOrderList() +{ + getSupportedFormats(); + return m_byteOrders; +} + +QList QAudioDeviceInfoInternal::sampleTypeList() +{ + getSupportedFormats(); + return m_sampleTypes; +} + +QByteArray QAudioDeviceInfoInternal::defaultInputDevice() +{ + return QByteArray("default"); +} + +QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() +{ + return QByteArray("default"); +} + +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode) +{ + QList result; + result += QByteArray("default"); + return result; +} + +void QAudioDeviceInfoInternal::getSupportedFormats() const +{ + if (!m_updated) { + QScopedPointer caps( + new SymbianAudio::DevSoundCapabilities(*m_devsound, m_mode)); + + SymbianAudio::Utils::capabilitiesNativeToQt(*caps, + m_frequencies, m_channels, m_sampleSizes, + m_byteOrders, m_sampleTypes); + + m_codecs.append(QLatin1String("audio/pcm")); + + m_updated = true; + } +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h new file mode 100644 index 0000000..89e539f --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIODEVICEINFO_SYMBIAN_P_H +#define QAUDIODEVICEINFO_SYMBIAN_P_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QAudioDeviceInfoInternal + : public QAbstractAudioDeviceInfo +{ + Q_OBJECT + +public: + QAudioDeviceInfoInternal(QByteArray device, QAudio::Mode mode); + ~QAudioDeviceInfoInternal(); + + // QAbstractAudioDeviceInfo + QAudioFormat preferredFormat() const; + bool isFormatSupported(const QAudioFormat &format) const; + QAudioFormat nearestFormat(const QAudioFormat &format) const; + QString deviceName() const; + QStringList codecList(); + QList frequencyList(); + QList channelsList(); + QList sampleSizeList(); + QList byteOrderList(); + QList sampleTypeList(); + static QByteArray defaultInputDevice(); + static QByteArray defaultOutputDevice(); + static QList availableDevices(QAudio::Mode); + +private: + void getSupportedFormats() const; + +private: + QScopedPointer m_devsound; + + QString m_deviceName; + QAudio::Mode m_mode; + + // Mutable to allow lazy initialization when called from const-qualified + // public functions (isFormatSupported, nearestFormat) + mutable bool m_updated; + mutable QStringList m_codecs; + mutable QList m_frequencies; + mutable QList m_channels; + mutable QList m_sampleSizes; + mutable QList m_byteOrders; + mutable QList m_sampleTypes; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp new file mode 100644 index 0000000..aee0807 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -0,0 +1,433 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#include +#include +#include "qaudiodeviceinfo_win32_p.h" + +QT_BEGIN_NAMESPACE + +// For mingw toolchain mmsystem.h only defines half the defines, so add if needed. +#ifndef WAVE_FORMAT_44M08 +#define WAVE_FORMAT_44M08 0x00000100 +#define WAVE_FORMAT_44S08 0x00000200 +#define WAVE_FORMAT_44M16 0x00000400 +#define WAVE_FORMAT_44S16 0x00000800 +#define WAVE_FORMAT_48M08 0x00001000 +#define WAVE_FORMAT_48S08 0x00002000 +#define WAVE_FORMAT_48M16 0x00004000 +#define WAVE_FORMAT_48S16 0x00008000 +#define WAVE_FORMAT_96M08 0x00010000 +#define WAVE_FORMAT_96S08 0x00020000 +#define WAVE_FORMAT_96M16 0x00040000 +#define WAVE_FORMAT_96S16 0x00080000 +#endif + + +QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) +{ + device = QLatin1String(dev); + this->mode = mode; + + updateLists(); +} + +QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() +{ + close(); +} + +bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const +{ + return testSettings(format); +} + +QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const +{ + QAudioFormat nearest; + if(mode == QAudio::AudioOutput) { + nearest.setFrequency(44100); + nearest.setChannelCount(2); + nearest.setByteOrder(QAudioFormat::LittleEndian); + nearest.setSampleType(QAudioFormat::SignedInt); + nearest.setSampleSize(16); + nearest.setCodec(QLatin1String("audio/pcm")); + } else { + nearest.setFrequency(11025); + nearest.setChannelCount(1); + nearest.setByteOrder(QAudioFormat::LittleEndian); + nearest.setSampleType(QAudioFormat::SignedInt); + nearest.setSampleSize(8); + nearest.setCodec(QLatin1String("audio/pcm")); + } + return nearest; +} + +QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) const +{ + if(testSettings(format)) + return format; + else + return preferredFormat(); +} + +QString QAudioDeviceInfoInternal::deviceName() const +{ + return device; +} + +QStringList QAudioDeviceInfoInternal::codecList() +{ + updateLists(); + return codecz; +} + +QList QAudioDeviceInfoInternal::frequencyList() +{ + updateLists(); + return freqz; +} + +QList QAudioDeviceInfoInternal::channelsList() +{ + updateLists(); + return channelz; +} + +QList QAudioDeviceInfoInternal::sampleSizeList() +{ + updateLists(); + return sizez; +} + +QList QAudioDeviceInfoInternal::byteOrderList() +{ + updateLists(); + return byteOrderz; +} + +QList QAudioDeviceInfoInternal::sampleTypeList() +{ + updateLists(); + return typez; +} + + +bool QAudioDeviceInfoInternal::open() +{ + return true; +} + +void QAudioDeviceInfoInternal::close() +{ +} + +bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const +{ + // Set nearest to closest settings that do work. + // See if what is in settings will work (return value). + + bool failed = false; + bool match = false; + + // check codec + for( int i = 0; i < codecz.count(); i++) { + if (format.codec() == codecz.at(i)) + match = true; + } + if (!match) failed = true; + + // check channel + match = false; + if (!failed) { + for( int i = 0; i < channelz.count(); i++) { + if (format.channels() == channelz.at(i)) { + match = true; + break; + } + } + } + if (!match) failed = true; + + // check frequency + match = false; + if (!failed) { + for( int i = 0; i < freqz.count(); i++) { + if (format.frequency() == freqz.at(i)) { + match = true; + break; + } + } + } + + // check sample size + match = false; + if (!failed) { + for( int i = 0; i < sizez.count(); i++) { + if (format.sampleSize() == sizez.at(i)) { + match = true; + break; + } + } + } + + // check byte order + match = false; + if (!failed) { + for( int i = 0; i < byteOrderz.count(); i++) { + if (format.byteOrder() == byteOrderz.at(i)) { + match = true; + break; + } + } + } + + // check sample type + match = false; + if (!failed) { + for( int i = 0; i < typez.count(); i++) { + if (format.sampleType() == typez.at(i)) { + match = true; + break; + } + } + } + + if(!failed) { + // settings work + return true; + } + return false; +} + +void QAudioDeviceInfoInternal::updateLists() +{ + // redo all lists based on current settings + bool base = false; + bool match = false; + DWORD fmt = NULL; + QString tmp; + + if(device.compare(QLatin1String("default")) == 0) + base = true; + + if(mode == QAudio::AudioOutput) { + WAVEOUTCAPS woc; + unsigned long iNumDevs,i; + iNumDevs = waveOutGetNumDevs(); + for(i=0;i 0) + freqz.prepend(8000); +} + +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) +{ + Q_UNUSED(mode) + + QList devices; + + if(mode == QAudio::AudioOutput) { + WAVEOUTCAPS woc; + unsigned long iNumDevs,i; + iNumDevs = waveOutGetNumDevs(); + for(i=0;i 0) + devices.append("default"); + + return devices; +} + +QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() +{ + return QByteArray("default"); +} + +QByteArray QAudioDeviceInfoInternal::defaultInputDevice() +{ + return QByteArray("default"); +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h new file mode 100644 index 0000000..cb6dd91 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QAUDIODEVICEINFOWIN_H +#define QAUDIODEVICEINFOWIN_H + +#include +#include +#include +#include + +#include +#include + + +QT_BEGIN_NAMESPACE + +const unsigned int MAX_SAMPLE_RATES = 5; +const unsigned int SAMPLE_RATES[] = { 8000, 11025, 22050, 44100, 48000 }; + +class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo +{ + Q_OBJECT + +public: + QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); + ~QAudioDeviceInfoInternal(); + + bool open(); + void close(); + + bool testSettings(const QAudioFormat& format) const; + void updateLists(); + QAudioFormat preferredFormat() const; + bool isFormatSupported(const QAudioFormat& format) const; + QAudioFormat nearestFormat(const QAudioFormat& format) const; + QString deviceName() const; + QStringList codecList(); + QList frequencyList(); + QList channelsList(); + QList sampleSizeList(); + QList byteOrderList(); + QList sampleTypeList(); + static QByteArray defaultInputDevice(); + static QByteArray defaultOutputDevice(); + static QList availableDevices(QAudio::Mode); + +private: + QAudio::Mode mode; + QString device; + QAudioFormat nearest; + QList freqz; + QList channelz; + QList sizez; + QList byteOrderz; + QStringList codecz; + QList typez; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/audio/qaudioengine.cpp b/src/multimedia/audio/qaudioengine.cpp new file mode 100644 index 0000000..7f1f5d3 --- /dev/null +++ b/src/multimedia/audio/qaudioengine.cpp @@ -0,0 +1,343 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 + +QT_BEGIN_NAMESPACE + +/*! + \class QAbstractAudioDeviceInfo + \brief The QAbstractAudioDeviceInfo class provides access for QAudioDeviceInfo to access the audio + device provided by the plugin. + \internal + + \ingroup multimedia + + This class implements the audio functionality for + QAudioDeviceInfo, i.e., QAudioDeviceInfo keeps a + QAbstractAudioDeviceInfo and routes function calls to it. For a + description of the functionality that QAbstractAudioDeviceInfo + implements, you can read the class and functions documentation of + QAudioDeviceInfo. + + \sa QAudioDeviceInfo +*/ + +/*! + \fn virtual QAudioFormat QAbstractAudioDeviceInfo::preferredFormat() const + Returns the nearest settings. +*/ + +/*! + \fn virtual bool QAbstractAudioDeviceInfo::isFormatSupported(const QAudioFormat& format) const + Returns true if \a format is available from audio device. +*/ + +/*! + \fn virtual QAudioFormat QAbstractAudioDeviceInfo::nearestFormat(const QAudioFormat& format) const + Returns the nearest settings \a format. +*/ + +/*! + \fn virtual QString QAbstractAudioDeviceInfo::deviceName() const + Returns the audio device name. +*/ + +/*! + \fn virtual QStringList QAbstractAudioDeviceInfo::codecList() + Returns the list of currently available codecs. +*/ + +/*! + \fn virtual QList QAbstractAudioDeviceInfo::frequencyList() + Returns the list of currently available frequencies. +*/ + +/*! + \fn virtual QList QAbstractAudioDeviceInfo::channelsList() + Returns the list of currently available channels. +*/ + +/*! + \fn virtual QList QAbstractAudioDeviceInfo::sampleSizeList() + Returns the list of currently available sample sizes. +*/ + +/*! + \fn virtual QList QAbstractAudioDeviceInfo::byteOrderList() + Returns the list of currently available byte orders. +*/ + +/*! + \fn virtual QList QAbstractAudioDeviceInfo::sampleTypeList() + Returns the list of currently available sample types. +*/ + +/*! + \class QAbstractAudioOutput + \brief The QAbstractAudioOutput class provides access for QAudioOutput to access the audio + device provided by the plugin. + \internal + + \ingroup multimedia + + QAbstractAudioOutput implements audio functionality for + QAudioOutput, i.e., QAudioOutput routes function calls to + QAbstractAudioOutput. For a description of the functionality that + is implemented, see the QAudioOutput class and function + descriptions. + + \sa QAudioOutput +*/ + +/*! + \fn virtual QIODevice* QAbstractAudioOutput::start(QIODevice* device) + Uses the \a device as the QIODevice to transfer data. If \a device is null then the class + creates an internal QIODevice. Returns a pointer to the QIODevice being used to handle + the data transfer. This QIODevice can be used to write() audio data directly. Passing a + QIODevice allows the data to be transfered without any extra code. +*/ + +/*! + \fn virtual void QAbstractAudioOutput::stop() + Stops the audio output. +*/ + +/*! + \fn virtual void QAbstractAudioOutput::reset() + Drops all audio data in the buffers, resets buffers to zero. +*/ + +/*! + \fn virtual void QAbstractAudioOutput::suspend() + Stops processing audio data, preserving buffered audio data. +*/ + +/*! + \fn virtual void QAbstractAudioOutput::resume() + Resumes processing audio data after a suspend() +*/ + +/*! + \fn virtual int QAbstractAudioOutput::bytesFree() const + Returns the free space available in bytes in the audio buffer. +*/ + +/*! + \fn virtual int QAbstractAudioOutput::periodSize() const + Returns the period size in bytes. +*/ + +/*! + \fn virtual void QAbstractAudioOutput::setBufferSize(int value) + Sets the audio buffer size to \a value in bytes. +*/ + +/*! + \fn virtual int QAbstractAudioOutput::bufferSize() const + Returns the audio buffer size in bytes. +*/ + +/*! + \fn virtual void QAbstractAudioOutput::setNotifyInterval(int ms) + Sets the interval for notify() signal to be emitted. This is based on the \a ms + of audio data processed not on actual real-time. The resolution of the timer + is platform specific. +*/ + +/*! + \fn virtual int QAbstractAudioOutput::notifyInterval() const + Returns the notify interval in milliseconds. +*/ + +/*! + \fn virtual qint64 QAbstractAudioOutput::processedUSecs() const + Returns the amount of audio data processed since start() was called in milliseconds. +*/ + +/*! + \fn virtual qint64 QAbstractAudioOutput::elapsedUSecs() const + Returns the milliseconds since start() was called, including time in Idle and suspend states. +*/ + +/*! + \fn virtual QAudio::Error QAbstractAudioOutput::error() const + Returns the error state. +*/ + +/*! + \fn virtual QAudio::State QAbstractAudioOutput::state() const + Returns the state of audio processing. +*/ + +/*! + \fn virtual QAudioFormat QAbstractAudioOutput::format() const + Returns the QAudioFormat being used. +*/ + +/*! + \fn QAbstractAudioOutput::stateChanged(QAudio::State state) + This signal is emitted when the device \a state has changed. +*/ + +/*! + \fn QAbstractAudioOutput::notify() + This signal is emitted when x ms of audio data has been processed + the interval set by setNotifyInterval(x). +*/ + + +/*! + \class QAbstractAudioInput + \brief The QAbstractAudioInput class provides access for QAudioInput to access the audio + device provided by the plugin. + \internal + + \ingroup multimedia + + QAudioDeviceInput keeps an instance of QAbstractAudioInput and + routes calls to functions of the same name to QAbstractAudioInput. + This means that it is QAbstractAudioInput that implements the + audio functionality. For a description of the functionality, see + the QAudioInput class description. + + \sa QAudioInput +*/ + +/*! + \fn virtual QIODevice* QAbstractAudioInput::start(QIODevice* device) + Uses the \a device as the QIODevice to transfer data. If \a device is null + then the class creates an internal QIODevice. Returns a pointer to the + QIODevice being used to handle the data transfer. This QIODevice can be used to + read() audio data directly. Passing a QIODevice allows the data to be transfered + without any extra code. +*/ + +/*! + \fn virtual void QAbstractAudioInput::stop() + Stops the audio input. +*/ + +/*! + \fn virtual void QAbstractAudioInput::reset() + Drops all audio data in the buffers, resets buffers to zero. +*/ + +/*! + \fn virtual void QAbstractAudioInput::suspend() + Stops processing audio data, preserving buffered audio data. +*/ + +/*! + \fn virtual void QAbstractAudioInput::resume() + Resumes processing audio data after a suspend(). +*/ + +/*! + \fn virtual int QAbstractAudioInput::bytesReady() const + Returns the amount of audio data available to read in bytes. +*/ + +/*! + \fn virtual int QAbstractAudioInput::periodSize() const + Returns the period size in bytes. +*/ + +/*! + \fn virtual void QAbstractAudioInput::setBufferSize(int value) + Sets the audio buffer size to \a value in milliseconds. +*/ + +/*! + \fn virtual int QAbstractAudioInput::bufferSize() const + Returns the audio buffer size in milliseconds. +*/ + +/*! + \fn virtual void QAbstractAudioInput::setNotifyInterval(int ms) + Sets the interval for notify() signal to be emitted. This is based + on the \a ms of audio data processed not on actual real-time. + The resolution of the timer is platform specific. +*/ + +/*! + \fn virtual int QAbstractAudioInput::notifyInterval() const + Returns the notify interval in milliseconds. +*/ + +/*! + \fn virtual qint64 QAbstractAudioInput::processedUSecs() const + Returns the amount of audio data processed since start() was called in milliseconds. +*/ + +/*! + \fn virtual qint64 QAbstractAudioInput::elapsedUSecs() const + Returns the milliseconds since start() was called, including time in Idle and suspend states. +*/ + +/*! + \fn virtual QAudio::Error QAbstractAudioInput::error() const + Returns the error state. +*/ + +/*! + \fn virtual QAudio::State QAbstractAudioInput::state() const + Returns the state of audio processing. +*/ + +/*! + \fn virtual QAudioFormat QAbstractAudioInput::format() const + Returns the QAudioFormat being used +*/ + +/*! + \fn QAbstractAudioInput::stateChanged(QAudio::State state) + This signal is emitted when the device \a state has changed. +*/ + +/*! + \fn QAbstractAudioInput::notify() + This signal is emitted when x ms of audio data has been processed + the interval set by setNotifyInterval(x). +*/ + + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudioengine.h b/src/multimedia/audio/qaudioengine.h new file mode 100644 index 0000000..df9d09d --- /dev/null +++ b/src/multimedia/audio/qaudioengine.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QAUDIOENGINE_H +#define QAUDIOENGINE_H + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class Q_MULTIMEDIA_EXPORT QAbstractAudioDeviceInfo : public QObject +{ + Q_OBJECT + +public: + virtual QAudioFormat preferredFormat() const = 0; + virtual bool isFormatSupported(const QAudioFormat &format) const = 0; + virtual QAudioFormat nearestFormat(const QAudioFormat &format) const = 0; + virtual QString deviceName() const = 0; + virtual QStringList codecList() = 0; + virtual QList frequencyList() = 0; + virtual QList channelsList() = 0; + virtual QList sampleSizeList() = 0; + virtual QList byteOrderList() = 0; + virtual QList sampleTypeList() = 0; +}; + +class Q_MULTIMEDIA_EXPORT QAbstractAudioOutput : public QObject +{ + Q_OBJECT + +public: + virtual QIODevice* start(QIODevice* device) = 0; + virtual void stop() = 0; + virtual void reset() = 0; + virtual void suspend() = 0; + virtual void resume() = 0; + virtual int bytesFree() const = 0; + virtual int periodSize() const = 0; + virtual void setBufferSize(int value) = 0; + virtual int bufferSize() const = 0; + virtual void setNotifyInterval(int milliSeconds) = 0; + virtual int notifyInterval() const = 0; + virtual qint64 processedUSecs() const = 0; + virtual qint64 elapsedUSecs() const = 0; + virtual QAudio::Error error() const = 0; + virtual QAudio::State state() const = 0; + virtual QAudioFormat format() const = 0; + +Q_SIGNALS: + void stateChanged(QAudio::State); + void notify(); +}; + +class Q_MULTIMEDIA_EXPORT QAbstractAudioInput : public QObject +{ + Q_OBJECT + +public: + virtual QIODevice* start(QIODevice* device) = 0; + virtual void stop() = 0; + virtual void reset() = 0; + virtual void suspend() = 0; + virtual void resume() = 0; + virtual int bytesReady() const = 0; + virtual int periodSize() const = 0; + virtual void setBufferSize(int value) = 0; + virtual int bufferSize() const = 0; + virtual void setNotifyInterval(int milliSeconds) = 0; + virtual int notifyInterval() const = 0; + virtual qint64 processedUSecs() const = 0; + virtual qint64 elapsedUSecs() const = 0; + virtual QAudio::Error error() const = 0; + virtual QAudio::State state() const = 0; + virtual QAudioFormat format() const = 0; + +Q_SIGNALS: + void stateChanged(QAudio::State); + void notify(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOENGINE_H diff --git a/src/multimedia/audio/qaudioengineplugin.cpp b/src/multimedia/audio/qaudioengineplugin.cpp new file mode 100644 index 0000000..82324b5 --- /dev/null +++ b/src/multimedia/audio/qaudioengineplugin.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 + +QT_BEGIN_NAMESPACE + +QAudioEnginePlugin::QAudioEnginePlugin(QObject* parent) : + QObject(parent) +{} + +QAudioEnginePlugin::~QAudioEnginePlugin() +{} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudioengineplugin.h b/src/multimedia/audio/qaudioengineplugin.h new file mode 100644 index 0000000..2322d2a --- /dev/null +++ b/src/multimedia/audio/qaudioengineplugin.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QAUDIOENGINEPLUGIN_H +#define QAUDIOENGINEPLUGIN_H + +#include +#include +#include + +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +struct Q_MULTIMEDIA_EXPORT QAudioEngineFactoryInterface : public QFactoryInterface +{ + virtual QList availableDevices(QAudio::Mode) const = 0; + virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; + virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; + virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; +}; + +#define QAudioEngineFactoryInterface_iid \ + "com.nokia.qt.QAudioEngineFactoryInterface" +Q_DECLARE_INTERFACE(QAudioEngineFactoryInterface, QAudioEngineFactoryInterface_iid) + +class Q_MULTIMEDIA_EXPORT QAudioEnginePlugin : public QObject, public QAudioEngineFactoryInterface +{ + Q_OBJECT + Q_INTERFACES(QAudioEngineFactoryInterface:QFactoryInterface) + +public: + QAudioEnginePlugin(QObject *parent = 0); + ~QAudioEnginePlugin(); + + virtual QStringList keys() const = 0; + virtual QList availableDevices(QAudio::Mode) const = 0; + virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; + virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; + virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOENGINEPLUGIN_H diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp new file mode 100644 index 0000000..86d72f6 --- /dev/null +++ b/src/multimedia/audio/qaudioformat.cpp @@ -0,0 +1,407 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 +#include + + +QT_BEGIN_NAMESPACE + + +class QAudioFormatPrivate : public QSharedData +{ +public: + QAudioFormatPrivate() + { + frequency = -1; + channels = -1; + sampleSize = -1; + byteOrder = QAudioFormat::Endian(QSysInfo::ByteOrder); + sampleType = QAudioFormat::Unknown; + } + + QAudioFormatPrivate(const QAudioFormatPrivate &other): + QSharedData(other), + codec(other.codec), + byteOrder(other.byteOrder), + sampleType(other.sampleType), + frequency(other.frequency), + channels(other.channels), + sampleSize(other.sampleSize) + { + } + + QAudioFormatPrivate& operator=(const QAudioFormatPrivate &other) + { + codec = other.codec; + byteOrder = other.byteOrder; + sampleType = other.sampleType; + frequency = other.frequency; + channels = other.channels; + sampleSize = other.sampleSize; + + return *this; + } + + QString codec; + QAudioFormat::Endian byteOrder; + QAudioFormat::SampleType sampleType; + int frequency; + int channels; + int sampleSize; +}; + +/*! + \class QAudioFormat + \brief The QAudioFormat class stores audio parameter information. + + \inmodule QtMultimedia + \ingroup multimedia + \since 4.6 + + An audio format specifies how data in an audio stream is arranged, + i.e, how the stream is to be interpreted. The encoding itself is + specified by the codec() used for the stream. + + In addition to the encoding, QAudioFormat contains other + parameters that further specify how the audio data is arranged. + These are the frequency, the number of channels, the sample size, + the sample type, and the byte order. The following table describes + these in more detail. + + \table + \header + \o Parameter + \o Description + \row + \o Sample Rate + \o Samples per second of audio data in Hertz. + \row + \o Number of channels + \o The number of audio channels (typically one for mono + or two for stereo) + \row + \o Sample size + \o How much data is stored in each sample (typically 8 + or 16 bits) + \row + \o Sample type + \o Numerical representation of sample (typically signed integer, + unsigned integer or float) + \row + \o Byte order + \o Byte ordering of sample (typically little endian, big endian) + \endtable + + You can obtain audio formats compatible with the audio device used + through functions in QAudioDeviceInfo. This class also lets you + query available parameter values for a device, so that you can set + the parameters yourself. See the QAudioDeviceInfo class + description for details. You need to know the format of the audio + streams you wish to play. Qt does not set up formats for you. +*/ + +/*! + Construct a new audio format. + + Values are initialized as follows: + \list + \o sampleRate() = -1 + \o channelCount() = -1 + \o sampleSize() = -1 + \o byteOrder() = QAudioFormat::Endian(QSysInfo::ByteOrder) + \o sampleType() = QAudioFormat::Unknown + \c codec() = "" + \endlist +*/ + +QAudioFormat::QAudioFormat(): + d(new QAudioFormatPrivate) +{ +} + +/*! + Construct a new audio format using \a other. +*/ + +QAudioFormat::QAudioFormat(const QAudioFormat &other): + d(other.d) +{ +} + +/*! + Destroy this audio format. +*/ + +QAudioFormat::~QAudioFormat() +{ +} + +/*! + Assigns \a other to this QAudioFormat implementation. +*/ + +QAudioFormat& QAudioFormat::operator=(const QAudioFormat &other) +{ + d = other.d; + return *this; +} + +/*! + Returns true if this QAudioFormat is equal to the \a other + QAudioFormat; otherwise returns false. + + All elements of QAudioFormat are used for the comparison. +*/ + +bool QAudioFormat::operator==(const QAudioFormat &other) const +{ + return d->frequency == other.d->frequency && + d->channels == other.d->channels && + d->sampleSize == other.d->sampleSize && + d->byteOrder == other.d->byteOrder && + d->codec == other.d->codec && + d->sampleType == other.d->sampleType; +} + +/*! + Returns true if this QAudioFormat is not equal to the \a other + QAudioFormat; otherwise returns false. + + All elements of QAudioFormat are used for the comparison. +*/ + +bool QAudioFormat::operator!=(const QAudioFormat& other) const +{ + return !(*this == other); +} + +/*! + Returns true if all of the parameters are valid. +*/ + +bool QAudioFormat::isValid() const +{ + return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 && + d->sampleType != QAudioFormat::Unknown && !d->codec.isEmpty(); +} + +/*! + Sets the sample rate to \a samplerate Hertz. + + \since 4.7 +*/ + +void QAudioFormat::setSampleRate(int samplerate) +{ + d->frequency = samplerate; +} + +/*! + \obsolete + + Use setSampleRate() instead. +*/ + +void QAudioFormat::setFrequency(int frequency) +{ + d->frequency = frequency; +} + +/*! + Returns the current sample rate in Hertz. + + \since 4.7 +*/ + +int QAudioFormat::sampleRate() const +{ + return d->frequency; +} + +/*! + \obsolete + + Use sampleRate() instead. +*/ + +int QAudioFormat::frequency() const +{ + return d->frequency; +} + +/*! + Sets the channel count to \a channels. + + \since 4.7 +*/ + +void QAudioFormat::setChannelCount(int channels) +{ + d->channels = channels; +} + +/*! + \obsolete + + Use setChannelCount() instead. +*/ + +void QAudioFormat::setChannels(int channels) +{ + d->channels = channels; +} + +/*! + Returns the current channel count value. + + \since 4.7 +*/ + +int QAudioFormat::channelCount() const +{ + return d->channels; +} + +/*! + \obsolete + + Use channelCount() instead. +*/ + +int QAudioFormat::channels() const +{ + return d->channels; +} + +/*! + Sets the sample size to the \a sampleSize specified. +*/ + +void QAudioFormat::setSampleSize(int sampleSize) +{ + d->sampleSize = sampleSize; +} + +/*! + Returns the current sample size value. +*/ + +int QAudioFormat::sampleSize() const +{ + return d->sampleSize; +} + +/*! + Sets the codec to \a codec. + + \sa QAudioDeviceInfo::supportedCodecs() +*/ + +void QAudioFormat::setCodec(const QString &codec) +{ + d->codec = codec; +} + +/*! + Returns the current codec value. + + \sa QAudioDeviceInfo::supportedCodecs() +*/ + +QString QAudioFormat::codec() const +{ + return d->codec; +} + +/*! + Sets the byteOrder to \a byteOrder. +*/ + +void QAudioFormat::setByteOrder(QAudioFormat::Endian byteOrder) +{ + d->byteOrder = byteOrder; +} + +/*! + Returns the current byteOrder value. +*/ + +QAudioFormat::Endian QAudioFormat::byteOrder() const +{ + return d->byteOrder; +} + +/*! + Sets the sampleType to \a sampleType. +*/ + +void QAudioFormat::setSampleType(QAudioFormat::SampleType sampleType) +{ + d->sampleType = sampleType; +} + +/*! + Returns the current SampleType value. +*/ + +QAudioFormat::SampleType QAudioFormat::sampleType() const +{ + return d->sampleType; +} + +/*! + \enum QAudioFormat::SampleType + + \value Unknown Not Set + \value SignedInt samples are signed integers + \value UnSignedInt samples are unsigned intergers + \value Float samples are floats +*/ + +/*! + \enum QAudioFormat::Endian + + \value BigEndian samples are big endian byte order + \value LittleEndian samples are little endian byte order +*/ + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h new file mode 100644 index 0000000..6c835b7 --- /dev/null +++ b/src/multimedia/audio/qaudioformat.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QAUDIOFORMAT_H +#define QAUDIOFORMAT_H + +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAudioFormatPrivate; + +class Q_MULTIMEDIA_EXPORT QAudioFormat +{ +public: + enum SampleType { Unknown, SignedInt, UnSignedInt, Float }; + enum Endian { BigEndian = QSysInfo::BigEndian, LittleEndian = QSysInfo::LittleEndian }; + + QAudioFormat(); + QAudioFormat(const QAudioFormat &other); + ~QAudioFormat(); + + QAudioFormat& operator=(const QAudioFormat &other); + bool operator==(const QAudioFormat &other) const; + bool operator!=(const QAudioFormat &other) const; + + bool isValid() const; + + void setFrequency(int frequency); + int frequency() const; + void setSampleRate(int sampleRate); + int sampleRate() const; + + void setChannels(int channels); + int channels() const; + void setChannelCount(int channelCount); + int channelCount() const; + + void setSampleSize(int sampleSize); + int sampleSize() const; + + void setCodec(const QString &codec); + QString codec() const; + + void setByteOrder(QAudioFormat::Endian byteOrder); + QAudioFormat::Endian byteOrder() const; + + void setSampleType(QAudioFormat::SampleType sampleType); + QAudioFormat::SampleType sampleType() const; + +private: + QSharedDataPointer d; +}; + + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOFORMAT_H diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp new file mode 100644 index 0000000..3676f64 --- /dev/null +++ b/src/multimedia/audio/qaudioinput.cpp @@ -0,0 +1,432 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 +#include +#include +#include + +#include "qaudiodevicefactory_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QAudioInput + \brief The QAudioInput class provides an interface for receiving audio data from an audio input device. + + \inmodule QtMultimedia + \ingroup multimedia + \since 4.6 + + You can construct an audio input with the system's + \l{QAudioDeviceInfo::defaultInputDevice()}{default audio input + device}. It is also possible to create QAudioInput with a + specific QAudioDeviceInfo. When you create the audio input, you + should also send in the QAudioFormat to be used for the recording + (see the QAudioFormat class description for details). + + To record to a file: + + QAudioInput lets you record audio with an audio input device. The + default constructor of this class will use the systems default + audio device, but you can also specify a QAudioDeviceInfo for a + specific device. You also need to pass in the QAudioFormat in + which you wish to record. + + Starting up the QAudioInput is simply a matter of calling start() + with a QIODevice opened for writing. For instance, to record to a + file, you can: + + \code + QFile outputFile; // class member. + QAudioInput* audio; // class member. + \endcode + + \code + { + outputFile.setFileName("/tmp/test.raw"); + outputFile.open( QIODevice::WriteOnly | QIODevice::Truncate ); + + QAudioFormat format; + // set up the format you want, eg. + format.setFrequency(8000); + format.setChannels(1); + format.setSampleSize(8); + format.setCodec("audio/pcm"); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setSampleType(QAudioFormat::UnSignedInt); + + QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice(); + if (!info.isFormatSupported(format)) { + qWarning()<<"default format not supported try to use nearest"; + format = info.nearestFormat(format); + } + + audio = new QAudioInput(format, this); + QTimer::singleShot(3000, this, SLOT(stopRecording())); + audio->start(&outputFile); + // Records audio for 3000ms + } + \endcode + + This will start recording if the format specified is supported by + the input device (you can check this with + QAudioDeviceInfo::isFormatSupported(). In case there are any + snags, use the error() function to check what went wrong. We stop + recording in the \c stopRecording() slot. + + \code + void stopRecording() + { + audio->stop(); + outputFile->close(); + delete audio; + } + \endcode + + At any point in time, QAudioInput will be in one of four states: + active, suspended, stopped, or idle. These states are specified by + the QAudio::State enum. You can request a state change directly through + suspend(), resume(), stop(), reset(), and start(). The current + state is reported by state(). QAudioOutput will also signal you + when the state changes (stateChanged()). + + QAudioInput provides several ways of measuring the time that has + passed since the start() of the recording. The \c processedUSecs() + function returns the length of the stream in microseconds written, + i.e., it leaves out the times the audio input was suspended or idle. + The elapsedUSecs() function returns the time elapsed since start() was called regardless of + which states the QAudioInput has been in. + + If an error should occur, you can fetch its reason with error(). + The possible error reasons are described by the QAudio::Error + enum. The QAudioInput will enter the \l{QAudio::}{StoppedState} when + an error is encountered. Connect to the stateChanged() signal to + handle the error: + + \snippet doc/src/snippets/audio/main.cpp 0 + + \sa QAudioOutput, QAudioDeviceInfo + + \section1 Symbian Platform Security Requirements + + On Symbian, processes which use this class must have the + \c UserEnvironment platform security capability. If the client + process lacks this capability, calls to either overload of start() + will fail. + This failure is indicated by the QAudioInput object setting + its error() value to \l{QAudio::OpenError} and then emitting a + \l{stateChanged()}{stateChanged}(\l{QAudio::StoppedState}) signal. + + Platform security capabilities are added via the + \l{qmake-variable-reference.html#target-capability}{TARGET.CAPABILITY} + qmake variable. +*/ + +/*! + Construct a new audio input and attach it to \a parent. + The default audio input device is used with the output + \a format parameters. +*/ + +QAudioInput::QAudioInput(const QAudioFormat &format, QObject *parent): + QObject(parent) +{ + d = QAudioDeviceFactory::createDefaultInputDevice(format); + connect(d, SIGNAL(notify()), SIGNAL(notify())); + connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); +} + +/*! + Construct a new audio input and attach it to \a parent. + The device referenced by \a audioDevice is used with the input + \a format parameters. +*/ + +QAudioInput::QAudioInput(const QAudioDeviceInfo &audioDevice, const QAudioFormat &format, QObject *parent): + QObject(parent) +{ + d = QAudioDeviceFactory::createInputDevice(audioDevice, format); + connect(d, SIGNAL(notify()), SIGNAL(notify())); + connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); +} + +/*! + Destroy this audio input. +*/ + +QAudioInput::~QAudioInput() +{ + delete d; +} + +/*! + Uses the \a device as the QIODevice to transfer data. + Passing a QIODevice allows the data to be transfered without any extra code. + All that is required is to open the QIODevice. + + If able to successfully get audio data from the systems audio device the + state() is set to either QAudio::ActiveState or QAudio::IdleState, + error() is set to QAudio::NoError and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + + \l{QAudioInput#Symbian Platform Security Requirements} + + \sa QIODevice +*/ + +void QAudioInput::start(QIODevice* device) +{ + d->start(device); +} + +/*! + Returns a pointer to the QIODevice being used to handle the data + transfer. This QIODevice can be used to read() audio data + directly. + + If able to access the systems audio device the state() is set to + QAudio::IdleState, error() is set to QAudio::NoError + and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + + \l{QAudioInput#Symbian Platform Security Requirements} + + \sa QIODevice +*/ + +QIODevice* QAudioInput::start() +{ + return d->start(0); +} + +/*! + Returns the QAudioFormat being used. +*/ + +QAudioFormat QAudioInput::format() const +{ + return d->format(); +} + +/*! + Stops the audio input, detaching from the system resource. + + Sets error() to QAudio::NoError, state() to QAudio::StoppedState and + emit stateChanged() signal. +*/ + +void QAudioInput::stop() +{ + d->stop(); +} + +/*! + Drops all audio data in the buffers, resets buffers to zero. +*/ + +void QAudioInput::reset() +{ + d->reset(); +} + +/*! + Stops processing audio data, preserving buffered audio data. + + Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and + emit stateChanged() signal. +*/ + +void QAudioInput::suspend() +{ + d->suspend(); +} + +/*! + Resumes processing audio data after a suspend(). + + Sets error() to QAudio::NoError. + Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). + Sets state() to QAudio::IdleState if you previously called start(). + emits stateChanged() signal. +*/ + +void QAudioInput::resume() +{ + d->resume(); +} + +/*! + Sets the audio buffer size to \a value milliseconds. + + Note: This function can be called anytime before start(), calls to this + are ignored after start(). It should not be assumed that the buffer size + set is the actual buffer size used, calling bufferSize() anytime after start() + will return the actual buffer size being used. + +*/ + +void QAudioInput::setBufferSize(int value) +{ + d->setBufferSize(value); +} + +/*! + Returns the audio buffer size in milliseconds. + + If called before start(), returns platform default value. + If called before start() but setBufferSize() was called prior, returns value set by setBufferSize(). + If called after start(), returns the actual buffer size being used. This may not be what was set previously + by setBufferSize(). + +*/ + +int QAudioInput::bufferSize() const +{ + return d->bufferSize(); +} + +/*! + Returns the amount of audio data available to read in bytes. + + NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState + state, otherwise returns zero. +*/ + +int QAudioInput::bytesReady() const +{ + /* + -If not ActiveState|IdleState, return 0 + -return amount of audio data available to read + */ + return d->bytesReady(); +} + +/*! + Returns the period size in bytes. + + Note: This is the recommended read size in bytes. +*/ + +int QAudioInput::periodSize() const +{ + return d->periodSize(); +} + +/*! + Sets the interval for notify() signal to be emitted. + This is based on the \a ms of audio data processed + not on actual real-time. + The minimum resolution of the timer is platform specific and values + should be checked with notifyInterval() to confirm actual value + being used. +*/ + +void QAudioInput::setNotifyInterval(int ms) +{ + d->setNotifyInterval(ms); +} + +/*! + Returns the notify interval in milliseconds. +*/ + +int QAudioInput::notifyInterval() const +{ + return d->notifyInterval(); +} + +/*! + Returns the amount of audio data processed since start() + was called in microseconds. +*/ + +qint64 QAudioInput::processedUSecs() const +{ + return d->processedUSecs(); +} + +/*! + Returns the microseconds since start() was called, including time in Idle and + Suspend states. +*/ + +qint64 QAudioInput::elapsedUSecs() const +{ + return d->elapsedUSecs(); +} + +/*! + Returns the error state. +*/ + +QAudio::Error QAudioInput::error() const +{ + return d->error(); +} + +/*! + Returns the state of audio processing. +*/ + +QAudio::State QAudioInput::state() const +{ + return d->state(); +} + +/*! + \fn QAudioInput::stateChanged(QAudio::State state) + This signal is emitted when the device \a state has changed. +*/ + +/*! + \fn QAudioInput::notify() + This signal is emitted when x ms of audio data has been processed + the interval set by setNotifyInterval(x). +*/ + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudioinput.h b/src/multimedia/audio/qaudioinput.h new file mode 100644 index 0000000..5be9b5a --- /dev/null +++ b/src/multimedia/audio/qaudioinput.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QAUDIOINPUT_H +#define QAUDIOINPUT_H + +#include +#include + +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAbstractAudioInput; + +class Q_MULTIMEDIA_EXPORT QAudioInput : public QObject +{ + Q_OBJECT + +public: + explicit QAudioInput(const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + explicit QAudioInput(const QAudioDeviceInfo &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + ~QAudioInput(); + + QAudioFormat format() const; + + void start(QIODevice *device); + QIODevice* start(); + + void stop(); + void reset(); + void suspend(); + void resume(); + + void setBufferSize(int bytes); + int bufferSize() const; + + int bytesReady() const; + int periodSize() const; + + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + + QAudio::Error error() const; + QAudio::State state() const; + +Q_SIGNALS: + void stateChanged(QAudio::State); + void notify(); + +private: + Q_DISABLE_COPY(QAudioInput) + + QAbstractAudioInput* d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOINPUT_H diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp new file mode 100644 index 0000000..c9a8b71 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -0,0 +1,701 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "qaudioinput_alsa_p.h" +#include "qaudiodeviceinfo_alsa_p.h" + +QT_BEGIN_NAMESPACE + +//#define DEBUG_AUDIO 1 + +QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): + settings(audioFormat) +{ + bytesAvailable = 0; + handle = 0; + ahandler = 0; + access = SND_PCM_ACCESS_RW_INTERLEAVED; + pcmformat = SND_PCM_FORMAT_S16; + buffer_size = 0; + period_size = 0; + buffer_time = 100000; + period_time = 20000; + totalTimeValue = 0; + intervalTime = 1000; + audioBuffer = 0; + errorState = QAudio::NoError; + deviceState = QAudio::StoppedState; + audioSource = 0; + pullMode = true; + resuming = false; + + m_device = device; + + timer = new QTimer(this); + connect(timer,SIGNAL(timeout()),SLOT(userFeed())); +} + +QAudioInputPrivate::~QAudioInputPrivate() +{ + close(); + disconnect(timer, SIGNAL(timeout())); + QCoreApplication::processEvents(); + delete timer; +} + +QAudio::Error QAudioInputPrivate::error() const +{ + return errorState; +} + +QAudio::State QAudioInputPrivate::state() const +{ + return deviceState; +} + + +QAudioFormat QAudioInputPrivate::format() const +{ + return settings; +} + +int QAudioInputPrivate::xrun_recovery(int err) +{ + int count = 0; + bool reset = false; + + if(err == -EPIPE) { + errorState = QAudio::UnderrunError; + err = snd_pcm_prepare(handle); + if(err < 0) + reset = true; + else { + bytesAvailable = bytesReady(); + if (bytesAvailable <= 0) + reset = true; + } + + } else if((err == -ESTRPIPE)||(err == -EIO)) { + errorState = QAudio::IOError; + while((err = snd_pcm_resume(handle)) == -EAGAIN){ + usleep(100); + count++; + if(count > 5) { + reset = true; + break; + } + } + if(err < 0) { + err = snd_pcm_prepare(handle); + if(err < 0) + reset = true; + } + } + if(reset) { + close(); + open(); + snd_pcm_prepare(handle); + return 0; + } + return err; +} + +int QAudioInputPrivate::setFormat() +{ + snd_pcm_format_t format = SND_PCM_FORMAT_S16; + + if(settings.sampleSize() == 8) { + format = SND_PCM_FORMAT_U8; + } else if(settings.sampleSize() == 16) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_S16_LE; + else + format = SND_PCM_FORMAT_S16_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_U16_LE; + else + format = SND_PCM_FORMAT_U16_BE; + } + } else if(settings.sampleSize() == 24) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_S24_LE; + else + format = SND_PCM_FORMAT_S24_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_U24_LE; + else + format = SND_PCM_FORMAT_U24_BE; + } + } else if(settings.sampleSize() == 32) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_S32_LE; + else + format = SND_PCM_FORMAT_S32_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_U32_LE; + else + format = SND_PCM_FORMAT_U32_BE; + } else if(settings.sampleType() == QAudioFormat::Float) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_FLOAT_LE; + else + format = SND_PCM_FORMAT_FLOAT_BE; + } + } else if(settings.sampleSize() == 64) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_FLOAT64_LE; + else + format = SND_PCM_FORMAT_FLOAT64_BE; + } + + return snd_pcm_hw_params_set_format( handle, hwparams, format); +} + +QIODevice* QAudioInputPrivate::start(QIODevice* device) +{ + if(deviceState != QAudio::StoppedState) + close(); + + if(!pullMode && audioSource) { + delete audioSource; + } + + if(device) { + //set to pull mode + pullMode = true; + audioSource = device; + deviceState = QAudio::ActiveState; + } else { + //set to push mode + pullMode = false; + deviceState = QAudio::IdleState; + audioSource = new InputPrivate(this); + audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered); + } + + if( !open() ) + return 0; + + emit stateChanged(deviceState); + + return audioSource; +} + +void QAudioInputPrivate::stop() +{ + if(deviceState == QAudio::StoppedState) + return; + + deviceState = QAudio::StoppedState; + + close(); + emit stateChanged(deviceState); +} + +bool QAudioInputPrivate::open() +{ +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()< devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioInput); + if(dev.compare(QLatin1String("default")) == 0) { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = QLatin1String(devices.first()); +#else + dev = QLatin1String("hw:0,0"); +#endif + } else { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = QLatin1String(m_device); +#else + int idx = 0; + char *name; + + QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData()); + + while(snd_card_get_name(idx,&name) == 0) { + if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0) + break; + idx++; + } + dev = QString(QLatin1String("hw:%1,0")).arg(idx); +#endif + } + + // Step 1: try and open the device + while((count < 5) && (err < 0)) { + err=snd_pcm_open(&handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); + if(err < 0) + count++; + } + if (( err < 0)||(handle == 0)) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + return false; + } + snd_pcm_nonblock( handle, 0 ); + + // Step 2: Set the desired HW parameters. + snd_pcm_hw_params_alloca( &hwparams ); + + bool fatal = false; + QString errMessage; + unsigned int chunks = 8; + + err = snd_pcm_hw_params_any( handle, hwparams ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_any: err = %1").arg(err); + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_rate_resample( handle, hwparams, 1 ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_rate_resample: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_access( handle, hwparams, access ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_access: err = %1").arg(err); + } + } + if ( !fatal ) { + err = setFormat(); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_format: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_channels: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &freakuency, 0 ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_rate_near: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_buffer_time_near(handle, hwparams, &buffer_time, &dir); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_buffer_time_near: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_period_time_near(handle, hwparams, &period_time, &dir); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_period_time_near: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_periods_near(handle, hwparams, &chunks, &dir); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_periods_near: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params(handle, hwparams); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params: err = %1").arg(err); + } + } + if( err < 0) { + qWarning()<start(period_time*chunks/2000); + + errorState = QAudio::NoError; + + totalTimeValue = 0; + + return true; +} + +void QAudioInputPrivate::close() +{ + timer->stop(); + + if ( handle ) { + snd_pcm_drop( handle ); + snd_pcm_close( handle ); + handle = 0; + delete [] audioBuffer; + audioBuffer=0; + } +} + +int QAudioInputPrivate::bytesReady() const +{ + if(resuming) + return period_size; + + if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) + return 0; + int frames = snd_pcm_avail_update(handle); + if (frames < 0) return frames; + if((int)frames > (int)buffer_frames) + frames = buffer_frames; + + return snd_pcm_frames_to_bytes(handle, frames); +} + +qint64 QAudioInputPrivate::read(char* data, qint64 len) +{ + Q_UNUSED(len) + + // Read in some audio data and write it to QIODevice, pull mode + if ( !handle ) + return 0; + + bytesAvailable = bytesReady(); + + if (bytesAvailable < 0) { + // bytesAvailable as negative is error code, try to recover from it. + xrun_recovery(bytesAvailable); + bytesAvailable = bytesReady(); + if (bytesAvailable < 0) { + // recovery failed must stop and set error. + close(); + errorState = QAudio::IOError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + return 0; + } + } + + int count=0, err = 0; + while(count < 5) { + int chunks = bytesAvailable/period_size; + int frames = chunks*period_frames; + if(frames > (int)buffer_frames) + frames = buffer_frames; + int readFrames = snd_pcm_readi(handle, audioBuffer, frames); + if (readFrames >= 0) { + err = snd_pcm_frames_to_bytes(handle, readFrames); +#ifdef DEBUG_AUDIO + qDebug()< 0) { + // got some send it onward +#ifdef DEBUG_AUDIO + qDebug()<<"frames to write to QIODevice = "<< + snd_pcm_bytes_to_frames( handle, (int)err )<<" ("<write(audioBuffer,err); + if(l < 0) { + close(); + errorState = QAudio::IOError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + } else if(l == 0) { + if (deviceState != QAudio::IdleState) { + errorState = QAudio::NoError; + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } + } else { + totalTimeValue += err; + resuming = false; + if (deviceState != QAudio::ActiveState) { + errorState = QAudio::NoError; + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + } + return l; + + } else { + memcpy(data,audioBuffer,err); + totalTimeValue += err; + resuming = false; + if (deviceState != QAudio::ActiveState) { + errorState = QAudio::NoError; + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + return err; + } + } + return 0; +} + +void QAudioInputPrivate::resume() +{ + if(deviceState == QAudio::SuspendedState) { + int err = 0; + + if(handle) { + err = snd_pcm_prepare( handle ); + if(err < 0) + xrun_recovery(err); + + err = snd_pcm_start(handle); + if(err < 0) + xrun_recovery(err); + + bytesAvailable = buffer_size; + } + resuming = true; + deviceState = QAudio::ActiveState; + int chunks = buffer_size/period_size; + timer->start(period_time*chunks/2000); + emit stateChanged(deviceState); + } +} + +void QAudioInputPrivate::setBufferSize(int value) +{ + buffer_size = value; +} + +int QAudioInputPrivate::bufferSize() const +{ + return buffer_size; +} + +int QAudioInputPrivate::periodSize() const +{ + return period_size; +} + +void QAudioInputPrivate::setNotifyInterval(int ms) +{ + intervalTime = qMax(0, ms); +} + +int QAudioInputPrivate::notifyInterval() const +{ + return intervalTime; +} + +qint64 QAudioInputPrivate::processedUSecs() const +{ + qint64 result = qint64(1000000) * totalTimeValue / + (settings.channels()*(settings.sampleSize()/8)) / + settings.frequency(); + + return result; +} + +void QAudioInputPrivate::suspend() +{ + if(deviceState == QAudio::ActiveState||resuming) { + timer->stop(); + deviceState = QAudio::SuspendedState; + emit stateChanged(deviceState); + } +} + +void QAudioInputPrivate::userFeed() +{ + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) + return; +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()<(audioSource); + a->trigger(); + } + bytesAvailable = bytesReady(); + + if(deviceState != QAudio::ActiveState) + return true; + + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { + emit notify(); + elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; + timeStamp.restart(); + } + return true; +} + +qint64 QAudioInputPrivate::elapsedUSecs() const +{ + if (deviceState == QAudio::StoppedState) + return 0; + + return clockStamp.elapsed()*1000; +} + +void QAudioInputPrivate::reset() +{ + if(handle) + snd_pcm_reset(handle); +} + +void QAudioInputPrivate::drain() +{ + if(handle) + snd_pcm_drain(handle); +} + +InputPrivate::InputPrivate(QAudioInputPrivate* audio) +{ + audioDevice = qobject_cast(audio); +} + +InputPrivate::~InputPrivate() +{ +} + +qint64 InputPrivate::readData( char* data, qint64 len) +{ + return audioDevice->read(data,len); +} + +qint64 InputPrivate::writeData(const char* data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + return 0; +} + +void InputPrivate::trigger() +{ + emit readyRead(); +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/audio/qaudioinput_alsa_p.h new file mode 100644 index 0000000..c907019 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_alsa_p.h @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QAUDIOINPUTALSA_H +#define QAUDIOINPUTALSA_H + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class InputPrivate; + +class QAudioInputPrivate : public QAbstractAudioInput +{ + Q_OBJECT +public: + QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat); + ~QAudioInputPrivate(); + + qint64 read(char* data, qint64 len); + + QIODevice* start(QIODevice* device = 0); + void stop(); + void reset(); + void suspend(); + void resume(); + int bytesReady() const; + int periodSize() const; + void setBufferSize(int value); + int bufferSize() const; + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + QAudio::Error error() const; + QAudio::State state() const; + QAudioFormat format() const; + bool resuming; + snd_pcm_t* handle; + qint64 totalTimeValue; + QIODevice* audioSource; + QAudioFormat settings; + QAudio::Error errorState; + QAudio::State deviceState; + +private slots: + void userFeed(); + bool deviceReady(); + +private: + int xrun_recovery(int err); + int setFormat(); + bool open(); + void close(); + void drain(); + + QTimer* timer; + QElapsedTimer timeStamp; + QElapsedTimer clockStamp; + qint64 elapsedTimeOffset; + int intervalTime; + char* audioBuffer; + int bytesAvailable; + QByteArray m_device; + bool pullMode; + int buffer_size; + int period_size; + unsigned int buffer_time; + unsigned int period_time; + snd_pcm_uframes_t buffer_frames; + snd_pcm_uframes_t period_frames; + snd_async_handler_t* ahandler; + snd_pcm_access_t access; + snd_pcm_format_t pcmformat; + snd_timestamp_t* timestamp; + snd_pcm_hw_params_t *hwparams; +}; + +class InputPrivate : public QIODevice +{ + Q_OBJECT +public: + InputPrivate(QAudioInputPrivate* audio); + ~InputPrivate(); + + qint64 readData( char* data, qint64 len); + qint64 writeData(const char* data, qint64 len); + + void trigger(); +private: + QAudioInputPrivate *audioDevice; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp new file mode 100644 index 0000000..cb65f6e --- /dev/null +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -0,0 +1,956 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +#include + +#include "qaudio_mac_p.h" +#include "qaudioinput_mac_p.h" +#include "qaudiodeviceinfo_mac_p.h" + +QT_BEGIN_NAMESPACE + + +namespace QtMultimediaInternal +{ + +static const int default_buffer_size = 4 * 1024; + +class QAudioBufferList +{ +public: + QAudioBufferList(AudioStreamBasicDescription const& streamFormat): + owner(false), + sf(streamFormat) + { + const bool isInterleaved = (sf.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0; + const int numberOfBuffers = isInterleaved ? 1 : sf.mChannelsPerFrame; + + dataSize = 0; + + bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + + (sizeof(AudioBuffer) * numberOfBuffers))); + + bfs->mNumberBuffers = numberOfBuffers; + for (int i = 0; i < numberOfBuffers; ++i) { + bfs->mBuffers[i].mNumberChannels = isInterleaved ? numberOfBuffers : 1; + bfs->mBuffers[i].mDataByteSize = 0; + bfs->mBuffers[i].mData = 0; + } + } + + QAudioBufferList(AudioStreamBasicDescription const& streamFormat, char* buffer, int bufferSize): + owner(false), + sf(streamFormat), + bfs(0) + { + dataSize = bufferSize; + + bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + sizeof(AudioBuffer))); + + bfs->mNumberBuffers = 1; + bfs->mBuffers[0].mNumberChannels = 1; + bfs->mBuffers[0].mDataByteSize = dataSize; + bfs->mBuffers[0].mData = buffer; + } + + QAudioBufferList(AudioStreamBasicDescription const& streamFormat, int framesToBuffer): + owner(true), + sf(streamFormat), + bfs(0) + { + const bool isInterleaved = (sf.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0; + const int numberOfBuffers = isInterleaved ? 1 : sf.mChannelsPerFrame; + + dataSize = framesToBuffer * sf.mBytesPerFrame; + + bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + + (sizeof(AudioBuffer) * numberOfBuffers))); + bfs->mNumberBuffers = numberOfBuffers; + for (int i = 0; i < numberOfBuffers; ++i) { + bfs->mBuffers[i].mNumberChannels = isInterleaved ? numberOfBuffers : 1; + bfs->mBuffers[i].mDataByteSize = dataSize; + bfs->mBuffers[i].mData = qMalloc(dataSize); + } + } + + ~QAudioBufferList() + { + if (owner) { + for (UInt32 i = 0; i < bfs->mNumberBuffers; ++i) + qFree(bfs->mBuffers[i].mData); + } + + qFree(bfs); + } + + AudioBufferList* audioBufferList() const + { + return bfs; + } + + char* data(int buffer = 0) const + { + return static_cast(bfs->mBuffers[buffer].mData); + } + + qint64 bufferSize(int buffer = 0) const + { + return bfs->mBuffers[buffer].mDataByteSize; + } + + int frameCount(int buffer = 0) const + { + return bfs->mBuffers[buffer].mDataByteSize / sf.mBytesPerFrame; + } + + int packetCount(int buffer = 0) const + { + return bfs->mBuffers[buffer].mDataByteSize / sf.mBytesPerPacket; + } + + int packetSize() const + { + return sf.mBytesPerPacket; + } + + void reset() + { + for (UInt32 i = 0; i < bfs->mNumberBuffers; ++i) { + bfs->mBuffers[i].mDataByteSize = dataSize; + bfs->mBuffers[i].mData = 0; + } + } + +private: + bool owner; + int dataSize; + AudioStreamBasicDescription sf; + AudioBufferList* bfs; +}; + +class QAudioPacketFeeder +{ +public: + QAudioPacketFeeder(QAudioBufferList* abl): + audioBufferList(abl) + { + totalPackets = audioBufferList->packetCount(); + position = 0; + } + + bool feed(AudioBufferList& dst, UInt32& packetCount) + { + if (position == totalPackets) { + dst.mBuffers[0].mDataByteSize = 0; + packetCount = 0; + return false; + } + + if (totalPackets - position < packetCount) + packetCount = totalPackets - position; + + dst.mBuffers[0].mDataByteSize = packetCount * audioBufferList->packetSize(); + dst.mBuffers[0].mData = audioBufferList->data() + (position * audioBufferList->packetSize()); + + position += packetCount; + + return true; + } + +private: + UInt32 totalPackets; + UInt32 position; + QAudioBufferList* audioBufferList; +}; + +class QAudioInputBuffer : public QObject +{ + Q_OBJECT + +public: + QAudioInputBuffer(int bufferSize, + int maxPeriodSize, + AudioStreamBasicDescription const& inputFormat, + AudioStreamBasicDescription const& outputFormat, + QObject* parent): + QObject(parent), + m_deviceError(false), + m_audioConverter(0), + m_inputFormat(inputFormat), + m_outputFormat(outputFormat) + { + m_maxPeriodSize = maxPeriodSize; + m_periodTime = m_maxPeriodSize / m_outputFormat.mBytesPerFrame * 1000 / m_outputFormat.mSampleRate; + m_buffer = new QAudioRingBuffer(bufferSize + (bufferSize % maxPeriodSize == 0 ? 0 : maxPeriodSize - (bufferSize % maxPeriodSize))); + m_inputBufferList = new QAudioBufferList(m_inputFormat); + + m_flushTimer = new QTimer(this); + connect(m_flushTimer, SIGNAL(timeout()), SLOT(flushBuffer())); + + if (toQAudioFormat(inputFormat) != toQAudioFormat(outputFormat)) { + if (AudioConverterNew(&m_inputFormat, &m_outputFormat, &m_audioConverter) != noErr) { + qWarning() << "QAudioInput: Unable to create an Audio Converter"; + m_audioConverter = 0; + } + } + } + + ~QAudioInputBuffer() + { + delete m_buffer; + } + + qint64 renderFromDevice(AudioUnit audioUnit, + AudioUnitRenderActionFlags* ioActionFlags, + const AudioTimeStamp* inTimeStamp, + UInt32 inBusNumber, + UInt32 inNumberFrames) + { + const bool wasEmpty = m_buffer->used() == 0; + + OSStatus err; + qint64 framesRendered = 0; + + m_inputBufferList->reset(); + err = AudioUnitRender(audioUnit, + ioActionFlags, + inTimeStamp, + inBusNumber, + inNumberFrames, + m_inputBufferList->audioBufferList()); + + if (m_audioConverter != 0) { + QAudioPacketFeeder feeder(m_inputBufferList); + + bool wecan = true; + int copied = 0; + + const int available = m_buffer->free(); + + while (err == noErr && wecan) { + QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(available); + + if (region.second > 0) { + AudioBufferList output; + output.mNumberBuffers = 1; + output.mBuffers[0].mNumberChannels = 1; + output.mBuffers[0].mDataByteSize = region.second; + output.mBuffers[0].mData = region.first; + + UInt32 packetSize = region.second / m_outputFormat.mBytesPerPacket; + err = AudioConverterFillComplexBuffer(m_audioConverter, + converterCallback, + &feeder, + &packetSize, + &output, + 0); + + region.second = output.mBuffers[0].mDataByteSize; + copied += region.second; + + m_buffer->releaseWriteRegion(region); + } + else + wecan = false; + } + + framesRendered += copied / m_outputFormat.mBytesPerFrame; + } + else { + const int available = m_inputBufferList->bufferSize(); + bool wecan = true; + int copied = 0; + + while (wecan && copied < available) { + QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(available - copied); + + if (region.second > 0) { + memcpy(region.first, m_inputBufferList->data() + copied, region.second); + copied += region.second; + } + else + wecan = false; + + m_buffer->releaseWriteRegion(region); + } + + framesRendered = copied / m_outputFormat.mBytesPerFrame; + } + + if (wasEmpty && framesRendered > 0) + emit readyRead(); + + return framesRendered; + } + + qint64 readBytes(char* data, qint64 len) + { + bool wecan = true; + qint64 bytesCopied = 0; + + len -= len % m_maxPeriodSize; + while (wecan && bytesCopied < len) { + QAudioRingBuffer::Region region = m_buffer->acquireReadRegion(len - bytesCopied); + + if (region.second > 0) { + memcpy(data + bytesCopied, region.first, region.second); + bytesCopied += region.second; + } + else + wecan = false; + + m_buffer->releaseReadRegion(region); + } + + return bytesCopied; + } + + void setFlushDevice(QIODevice* device) + { + if (m_device != device) + m_device = device; + } + + void startFlushTimer() + { + if (m_device != 0) { + m_flushTimer->start((m_buffer->size() - (m_maxPeriodSize * 2)) / m_maxPeriodSize * m_periodTime); + } + } + + void stopFlushTimer() + { + m_flushTimer->stop(); + } + + void flush(bool all = false) + { + if (m_device == 0) + return; + + const int used = m_buffer->used(); + const int readSize = all ? used : used - (used % m_maxPeriodSize); + + if (readSize > 0) { + bool wecan = true; + int flushed = 0; + + while (!m_deviceError && wecan && flushed < readSize) { + QAudioRingBuffer::Region region = m_buffer->acquireReadRegion(readSize - flushed); + + if (region.second > 0) { + int bytesWritten = m_device->write(region.first, region.second); + if (bytesWritten < 0) { + stopFlushTimer(); + m_deviceError = true; + } + else { + region.second = bytesWritten; + flushed += bytesWritten; + wecan = bytesWritten != 0; + } + } + else + wecan = false; + + m_buffer->releaseReadRegion(region); + } + } + } + + void reset() + { + m_buffer->reset(); + m_deviceError = false; + } + + int available() const + { + return m_buffer->free(); + } + + int used() const + { + return m_buffer->used(); + } + +signals: + void readyRead(); + +private slots: + void flushBuffer() + { + flush(); + } + +private: + bool m_deviceError; + int m_maxPeriodSize; + int m_periodTime; + QIODevice* m_device; + QTimer* m_flushTimer; + QAudioRingBuffer* m_buffer; + QAudioBufferList* m_inputBufferList; + AudioConverterRef m_audioConverter; + AudioStreamBasicDescription m_inputFormat; + AudioStreamBasicDescription m_outputFormat; + + const static OSStatus as_empty = 'qtem'; + + // Converter callback + static OSStatus converterCallback(AudioConverterRef inAudioConverter, + UInt32* ioNumberDataPackets, + AudioBufferList* ioData, + AudioStreamPacketDescription** outDataPacketDescription, + void* inUserData) + { + Q_UNUSED(inAudioConverter); + Q_UNUSED(outDataPacketDescription); + + QAudioPacketFeeder* feeder = static_cast(inUserData); + + if (!feeder->feed(*ioData, *ioNumberDataPackets)) + return as_empty; + + return noErr; + } +}; + + +class MacInputDevice : public QIODevice +{ + Q_OBJECT + +public: + MacInputDevice(QAudioInputBuffer* audioBuffer, QObject* parent): + QIODevice(parent), + m_audioBuffer(audioBuffer) + { + open(QIODevice::ReadOnly | QIODevice::Unbuffered); + connect(m_audioBuffer, SIGNAL(readyRead()), SIGNAL(readyRead())); + } + + qint64 readData(char* data, qint64 len) + { + return m_audioBuffer->readBytes(data, len); + } + + qint64 writeData(const char* data, qint64 len) + { + Q_UNUSED(data); + Q_UNUSED(len); + + return 0; + } + + bool isSequential() const + { + return true; + } + +private: + QAudioInputBuffer* m_audioBuffer; +}; + +} + + +QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat const& format): + audioFormat(format) +{ + QDataStream ds(device); + quint32 did, mode; + + ds >> did >> mode; + + if (QAudio::Mode(mode) == QAudio::AudioOutput) + errorCode = QAudio::OpenError; + else { + audioDeviceInfo = new QAudioDeviceInfoInternal(device, QAudio::AudioInput); + isOpen = false; + audioDeviceId = AudioDeviceID(did); + audioUnit = 0; + startTime = 0; + totalFrames = 0; + audioBuffer = 0; + internalBufferSize = QtMultimediaInternal::default_buffer_size; + clockFrequency = AudioGetHostClockFrequency() / 1000; + errorCode = QAudio::NoError; + stateCode = QAudio::StoppedState; + + intervalTimer = new QTimer(this); + intervalTimer->setInterval(1000); + connect(intervalTimer, SIGNAL(timeout()), SIGNAL(notify())); + } +} + +QAudioInputPrivate::~QAudioInputPrivate() +{ + close(); + delete audioDeviceInfo; +} + +bool QAudioInputPrivate::open() +{ + UInt32 size = 0; + + if (isOpen) + return true; + + ComponentDescription cd; + cd.componentType = kAudioUnitType_Output; + cd.componentSubType = kAudioUnitSubType_HALOutput; + cd.componentManufacturer = kAudioUnitManufacturer_Apple; + cd.componentFlags = 0; + cd.componentFlagsMask = 0; + + // Open + Component cp = FindNextComponent(NULL, &cd); + if (cp == 0) { + qWarning() << "QAudioInput: Failed to find HAL Output component"; + return false; + } + + if (OpenAComponent(cp, &audioUnit) != noErr) { + qWarning() << "QAudioInput: Unable to Open Output Component"; + return false; + } + + // Set mode + // switch to input mode + UInt32 enable = 1; + if (AudioUnitSetProperty(audioUnit, + kAudioOutputUnitProperty_EnableIO, + kAudioUnitScope_Input, + 1, + &enable, + sizeof(enable)) != noErr) { + qWarning() << "QAudioInput: Unable to switch to input mode (Enable Input)"; + return false; + } + + enable = 0; + if (AudioUnitSetProperty(audioUnit, + kAudioOutputUnitProperty_EnableIO, + kAudioUnitScope_Output, + 0, + &enable, + sizeof(enable)) != noErr) { + qWarning() << "QAudioInput: Unable to switch to input mode (Disable output)"; + return false; + } + + // register callback + AURenderCallbackStruct cb; + cb.inputProc = inputCallback; + cb.inputProcRefCon = this; + + if (AudioUnitSetProperty(audioUnit, + kAudioOutputUnitProperty_SetInputCallback, + kAudioUnitScope_Global, + 0, + &cb, + sizeof(cb)) != noErr) { + qWarning() << "QAudioInput: Failed to set AudioUnit callback"; + return false; + } + + // Set Audio Device + if (AudioUnitSetProperty(audioUnit, + kAudioOutputUnitProperty_CurrentDevice, + kAudioUnitScope_Global, + 0, + &audioDeviceId, + sizeof(audioDeviceId)) != noErr) { + qWarning() << "QAudioInput: Unable to use configured device"; + return false; + } + + // Set format + // Wanted + streamFormat = toAudioStreamBasicDescription(audioFormat); + + // Required on unit + if (audioFormat == audioDeviceInfo->preferredFormat()) { + deviceFormat = streamFormat; + AudioUnitSetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Output, + 1, + &deviceFormat, + sizeof(deviceFormat)); + } + else { + size = sizeof(deviceFormat); + if (AudioUnitGetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 1, + &deviceFormat, + &size) != noErr) { + qWarning() << "QAudioInput: Unable to retrieve device format"; + return false; + } + + if (AudioUnitSetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Output, + 1, + &deviceFormat, + sizeof(deviceFormat)) != noErr) { + qWarning() << "QAudioInput: Unable to set device format"; + return false; + } + } + + // Setup buffers + UInt32 numberOfFrames; + size = sizeof(UInt32); + if (AudioUnitGetProperty(audioUnit, + kAudioDevicePropertyBufferFrameSize, + kAudioUnitScope_Global, + 0, + &numberOfFrames, + &size) != noErr) { + qWarning() << "QAudioInput: Failed to get audio period size"; + return false; + } + + // Allocate buffer + periodSizeBytes = numberOfFrames * streamFormat.mBytesPerFrame; + + if (internalBufferSize < periodSizeBytes * 2) + internalBufferSize = periodSizeBytes * 2; + else + internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; + + audioBuffer = new QtMultimediaInternal::QAudioInputBuffer(internalBufferSize, + periodSizeBytes, + deviceFormat, + streamFormat, + this); + + audioIO = new QtMultimediaInternal::MacInputDevice(audioBuffer, this); + + // Init + if (AudioUnitInitialize(audioUnit) != noErr) { + qWarning() << "QAudioInput: Failed to initialize AudioUnit"; + return false; + } + + isOpen = true; + + return isOpen; +} + +void QAudioInputPrivate::close() +{ + if (audioUnit != 0) { + AudioOutputUnitStop(audioUnit); + AudioUnitUninitialize(audioUnit); + CloseComponent(audioUnit); + } + + delete audioBuffer; +} + +QAudioFormat QAudioInputPrivate::format() const +{ + return audioFormat; +} + +QIODevice* QAudioInputPrivate::start(QIODevice* device) +{ + QIODevice* op = device; + + if (!audioFormat.isValid() || !open()) { + stateCode = QAudio::StoppedState; + errorCode = QAudio::OpenError; + return audioIO; + } + + reset(); + audioBuffer->reset(); + audioBuffer->setFlushDevice(op); + + if (op == 0) + op = audioIO; + + // Start + startTime = AudioGetCurrentHostTime(); + totalFrames = 0; + + audioThreadStart(); + + stateCode = QAudio::ActiveState; + errorCode = QAudio::NoError; + emit stateChanged(stateCode); + + return op; +} + +void QAudioInputPrivate::stop() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StoppedState) { + audioThreadStop(); + audioBuffer->flush(true); + + errorCode = QAudio::NoError; + stateCode = QAudio::StoppedState; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioInputPrivate::reset() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StoppedState) { + audioThreadStop(); + + errorCode = QAudio::NoError; + stateCode = QAudio::StoppedState; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioInputPrivate::suspend() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) { + audioThreadStop(); + + errorCode = QAudio::NoError; + stateCode = QAudio::SuspendedState; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioInputPrivate::resume() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::SuspendedState) { + audioThreadStart(); + + errorCode = QAudio::NoError; + stateCode = QAudio::ActiveState; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +int QAudioInputPrivate::bytesReady() const +{ + return audioBuffer->used(); +} + +int QAudioInputPrivate::periodSize() const +{ + return periodSizeBytes; +} + +void QAudioInputPrivate::setBufferSize(int bs) +{ + internalBufferSize = bs; +} + +int QAudioInputPrivate::bufferSize() const +{ + return internalBufferSize; +} + +void QAudioInputPrivate::setNotifyInterval(int milliSeconds) +{ + if (intervalTimer->interval() == milliSeconds) + return; + + if (milliSeconds <= 0) + milliSeconds = 0; + + intervalTimer->setInterval(milliSeconds); +} + +int QAudioInputPrivate::notifyInterval() const +{ + return intervalTimer->interval(); +} + +qint64 QAudioInputPrivate::processedUSecs() const +{ + return totalFrames * 1000000 / audioFormat.frequency(); +} + +qint64 QAudioInputPrivate::elapsedUSecs() const +{ + if (stateCode == QAudio::StoppedState) + return 0; + + return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); +} + +QAudio::Error QAudioInputPrivate::error() const +{ + return errorCode; +} + +QAudio::State QAudioInputPrivate::state() const +{ + return stateCode; +} + +void QAudioInputPrivate::audioThreadStop() +{ + stopTimers(); + if (audioThreadState.testAndSetAcquire(Running, Stopped)) + threadFinished.wait(&mutex); +} + +void QAudioInputPrivate::audioThreadStart() +{ + startTimers(); + audioThreadState = Running; + AudioOutputUnitStart(audioUnit); +} + +void QAudioInputPrivate::audioDeviceStop() +{ + AudioOutputUnitStop(audioUnit); + audioThreadState = Stopped; + threadFinished.wakeOne(); +} + +void QAudioInputPrivate::audioDeviceFull() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState) { + audioDeviceStop(); + + errorCode = QAudio::UnderrunError; + stateCode = QAudio::IdleState; + QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); + } +} + +void QAudioInputPrivate::audioDeviceError() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState) { + audioDeviceStop(); + + errorCode = QAudio::IOError; + stateCode = QAudio::StoppedState; + QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); + } +} + +void QAudioInputPrivate::startTimers() +{ + audioBuffer->startFlushTimer(); + if (intervalTimer->interval() > 0) + intervalTimer->start(); +} + +void QAudioInputPrivate::stopTimers() +{ + audioBuffer->stopFlushTimer(); + intervalTimer->stop(); +} + +void QAudioInputPrivate::deviceStopped() +{ + stopTimers(); + emit stateChanged(stateCode); +} + +// Input callback +OSStatus QAudioInputPrivate::inputCallback(void* inRefCon, + AudioUnitRenderActionFlags* ioActionFlags, + const AudioTimeStamp* inTimeStamp, + UInt32 inBusNumber, + UInt32 inNumberFrames, + AudioBufferList* ioData) +{ + Q_UNUSED(ioData); + + QAudioInputPrivate* d = static_cast(inRefCon); + + const int threadState = d->audioThreadState.fetchAndAddAcquire(0); + if (threadState == Stopped) + d->audioDeviceStop(); + else { + qint64 framesWritten; + + framesWritten = d->audioBuffer->renderFromDevice(d->audioUnit, + ioActionFlags, + inTimeStamp, + inBusNumber, + inNumberFrames); + + if (framesWritten > 0) + d->totalFrames += framesWritten; + else if (framesWritten == 0) + d->audioDeviceFull(); + else if (framesWritten < 0) + d->audioDeviceError(); + } + + return noErr; +} + + +QT_END_NAMESPACE + +#include "qaudioinput_mac_p.moc" + diff --git a/src/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/audio/qaudioinput_mac_p.h new file mode 100644 index 0000000..7aa4168 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_mac_p.h @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QAUDIOINPUT_MAC_P_H +#define QAUDIOINPUT_MAC_P_H + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QTimer; +class QIODevice; +class QAbstractAudioDeviceInfo; + +namespace QtMultimediaInternal +{ +class QAudioInputBuffer; +} + +class QAudioInputPrivate : public QAbstractAudioInput +{ + Q_OBJECT + +public: + bool isOpen; + int periodSizeBytes; + int internalBufferSize; + qint64 totalFrames; + QAudioFormat audioFormat; + QIODevice* audioIO; + AudioUnit audioUnit; + AudioDeviceID audioDeviceId; + Float64 clockFrequency; + UInt64 startTime; + QAudio::Error errorCode; + QAudio::State stateCode; + QtMultimediaInternal::QAudioInputBuffer* audioBuffer; + QMutex mutex; + QWaitCondition threadFinished; + QAtomicInt audioThreadState; + QTimer* intervalTimer; + AudioStreamBasicDescription streamFormat; + AudioStreamBasicDescription deviceFormat; + QAbstractAudioDeviceInfo *audioDeviceInfo; + + QAudioInputPrivate(const QByteArray& device, QAudioFormat const& format); + ~QAudioInputPrivate(); + + bool open(); + void close(); + + QAudioFormat format() const; + + QIODevice* start(QIODevice* device); + void stop(); + void reset(); + void suspend(); + void resume(); + void idle(); + + int bytesReady() const; + int periodSize() const; + + void setBufferSize(int value); + int bufferSize() const; + + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + + QAudio::Error error() const; + QAudio::State state() const; + + void audioThreadStart(); + void audioThreadStop(); + + void audioDeviceStop(); + void audioDeviceFull(); + void audioDeviceError(); + + void startTimers(); + void stopTimers(); + +private slots: + void deviceStopped(); + +private: + enum { Running, Stopped }; + + // Input callback + static OSStatus inputCallback(void* inRefCon, + AudioUnitRenderActionFlags* ioActionFlags, + const AudioTimeStamp* inTimeStamp, + UInt32 inBusNumber, + UInt32 inNumberFrames, + AudioBufferList* ioData); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOINPUT_MAC_P_H diff --git a/src/multimedia/audio/qaudioinput_symbian_p.cpp b/src/multimedia/audio/qaudioinput_symbian_p.cpp new file mode 100644 index 0000000..52daa88 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_symbian_p.cpp @@ -0,0 +1,594 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qaudioinput_symbian_p.h" + +QT_BEGIN_NAMESPACE + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const int PushInterval = 50; // ms + + +//----------------------------------------------------------------------------- +// Private class +//----------------------------------------------------------------------------- + +SymbianAudioInputPrivate::SymbianAudioInputPrivate( + QAudioInputPrivate *audioDevice) + : m_audioDevice(audioDevice) +{ + +} + +SymbianAudioInputPrivate::~SymbianAudioInputPrivate() +{ + +} + +qint64 SymbianAudioInputPrivate::readData(char *data, qint64 len) +{ + qint64 totalRead = 0; + + if (m_audioDevice->state() == QAudio::ActiveState || + m_audioDevice->state() == QAudio::IdleState) { + + while (totalRead < len) { + const qint64 read = m_audioDevice->read(data + totalRead, + len - totalRead); + if (read > 0) + totalRead += read; + else + break; + } + } + + return totalRead; +} + +qint64 SymbianAudioInputPrivate::writeData(const char *data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + return 0; +} + +void SymbianAudioInputPrivate::dataReady() +{ + emit readyRead(); +} + + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, + const QAudioFormat &format) + : m_device(device) + , m_format(format) + , m_clientBufferSize(SymbianAudio::DefaultBufferSize) + , m_notifyInterval(SymbianAudio::DefaultNotifyInterval) + , m_notifyTimer(new QTimer(this)) + , m_error(QAudio::NoError) + , m_internalState(SymbianAudio::ClosedState) + , m_externalState(QAudio::StoppedState) + , m_pullMode(false) + , m_sink(0) + , m_pullTimer(new QTimer(this)) + , m_devSoundBuffer(0) + , m_devSoundBufferSize(0) + , m_totalBytesReady(0) + , m_devSoundBufferPos(0) + , m_totalSamplesRecorded(0) +{ + connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); + + SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, + m_nativeFormat); + + m_pullTimer->setInterval(PushInterval); + connect(m_pullTimer.data(), SIGNAL(timeout()), this, SLOT(pullData())); +} + +QAudioInputPrivate::~QAudioInputPrivate() +{ + close(); +} + +QIODevice* QAudioInputPrivate::start(QIODevice *device) +{ + stop(); + + open(); + if (SymbianAudio::ClosedState != m_internalState) { + if (device) { + m_pullMode = true; + m_sink = device; + } else { + m_sink = new SymbianAudioInputPrivate(this); + m_sink->open(QIODevice::ReadOnly | QIODevice::Unbuffered); + } + + m_elapsed.restart(); + } + + return m_sink; +} + +void QAudioInputPrivate::stop() +{ + close(); +} + +void QAudioInputPrivate::reset() +{ + m_totalSamplesRecorded += getSamplesRecorded(); + m_devSound->Stop(); + startRecording(); +} + +void QAudioInputPrivate::suspend() +{ + if (SymbianAudio::ActiveState == m_internalState + || SymbianAudio::IdleState == m_internalState) { + m_notifyTimer->stop(); + m_pullTimer->stop(); + m_devSound->Pause(); + const qint64 samplesRecorded = getSamplesRecorded(); + m_totalSamplesRecorded += samplesRecorded; + + if (m_devSoundBuffer) { + m_devSoundBufferQ.append(m_devSoundBuffer); + m_devSoundBuffer = 0; + } + + setState(SymbianAudio::SuspendedState); + } +} + +void QAudioInputPrivate::resume() +{ + if (SymbianAudio::SuspendedState == m_internalState) + startDataTransfer(); +} + +int QAudioInputPrivate::bytesReady() const +{ + Q_ASSERT(m_devSoundBufferPos <= m_totalBytesReady); + return m_totalBytesReady - m_devSoundBufferPos; +} + +int QAudioInputPrivate::periodSize() const +{ + return bufferSize(); +} + +void QAudioInputPrivate::setBufferSize(int value) +{ + // Note that DevSound does not allow its client to specify the buffer size. + // This functionality is available via custom interfaces, but since these + // cannot be guaranteed to work across all DevSound implementations, we + // do not use them here. + // In order to comply with the expected bevahiour of QAudioInput, we store + // the value and return it from bufferSize(), but the underlying DevSound + // buffer size remains unchanged. + if (value > 0) + m_clientBufferSize = value; +} + +int QAudioInputPrivate::bufferSize() const +{ + return m_devSoundBufferSize ? m_devSoundBufferSize : m_clientBufferSize; +} + +void QAudioInputPrivate::setNotifyInterval(int ms) +{ + if (ms > 0) { + const int oldNotifyInterval = m_notifyInterval; + m_notifyInterval = ms; + if (m_notifyTimer->isActive() && ms != oldNotifyInterval) + m_notifyTimer->start(m_notifyInterval); + } +} + +int QAudioInputPrivate::notifyInterval() const +{ + return m_notifyInterval; +} + +qint64 QAudioInputPrivate::processedUSecs() const +{ + int samplesPlayed = 0; + if (m_devSound && SymbianAudio::SuspendedState != m_internalState) + samplesPlayed = getSamplesRecorded(); + + // Protect against division by zero + Q_ASSERT_X(m_format.frequency() > 0, Q_FUNC_INFO, "Invalid frequency"); + + const qint64 result = qint64(1000000) * + (samplesPlayed + m_totalSamplesRecorded) + / m_format.frequency(); + + return result; +} + +qint64 QAudioInputPrivate::elapsedUSecs() const +{ + const qint64 result = (QAudio::StoppedState == state()) ? + 0 : m_elapsed.elapsed() * 1000; + return result; +} + +QAudio::Error QAudioInputPrivate::error() const +{ + return m_error; +} + +QAudio::State QAudioInputPrivate::state() const +{ + return m_externalState; +} + +QAudioFormat QAudioInputPrivate::format() const +{ + return m_format; +} + +//----------------------------------------------------------------------------- +// MDevSoundObserver implementation +//----------------------------------------------------------------------------- + +void QAudioInputPrivate::InitializeComplete(TInt aError) +{ + Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, + Q_FUNC_INFO, "Invalid state"); + + if (KErrNone == aError) + startRecording(); +} + +void QAudioInputPrivate::ToneFinished(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound's tone playback functions, so should + // never receive this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioInputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) +{ + Q_UNUSED(aBuffer) + // This class doesn't use DevSound in play mode, so should never receive + // this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioInputPrivate::PlayError(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound in play mode, so should never receive + // this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioInputPrivate::BufferToBeEmptied(CMMFBuffer *aBuffer) +{ + // Following receipt of this callback, DevSound should not provide another + // buffer until we have returned the current one. + Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); + + CMMFDataBuffer *const buffer = static_cast(aBuffer); + + if (!m_devSoundBufferSize) + m_devSoundBufferSize = buffer->Data().MaxLength(); + + m_totalBytesReady += buffer->Data().Length(); + + if (SymbianAudio::SuspendedState == m_internalState) { + m_devSoundBufferQ.append(buffer); + } else { + // Will be returned to DevSound by bufferEmptied(). + m_devSoundBuffer = buffer; + m_devSoundBufferPos = 0; + + if (bytesReady() && !m_pullMode) + pushData(); + } +} + +void QAudioInputPrivate::RecordError(TInt aError) +{ + Q_UNUSED(aError) + setError(QAudio::IOError); +} + +void QAudioInputPrivate::ConvertError(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound's format conversion functions, so + // should never receive this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioInputPrivate::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) +{ + Q_UNUSED(aMessageType) + Q_UNUSED(aMsg) + // Ignore this callback. +} + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void QAudioInputPrivate::open() +{ + Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, + Q_FUNC_INFO, "DevSound already opened"); + + QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) + + QScopedPointer caps( + new SymbianAudio::DevSoundCapabilities(*m_devSound, QAudio::AudioInput)); + + int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? + KErrNone : KErrNotSupported; + + if (KErrNone == err) { + setState(SymbianAudio::InitializingState); + TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, + EMMFStateRecording)); + } + + if (KErrNone != err) { + setError(QAudio::OpenError); + m_devSound.reset(); + } +} + +void QAudioInputPrivate::startRecording() +{ + const int samplesRecorded = m_devSound->SamplesRecorded(); + Q_ASSERT(samplesRecorded == 0); + + TRAPD(err, startDevSoundL()); + if (KErrNone == err) { + startDataTransfer(); + } else { + setError(QAudio::OpenError); + close(); + } +} + +void QAudioInputPrivate::startDevSoundL() +{ + TMMFCapabilities nativeFormat = m_devSound->Config(); + m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; + m_devSound->SetConfigL(m_nativeFormat); + m_devSound->RecordInitL(); +} + +void QAudioInputPrivate::startDataTransfer() +{ + m_notifyTimer->start(m_notifyInterval); + + if (m_pullMode) + m_pullTimer->start(); + + if (bytesReady()) { + setState(SymbianAudio::ActiveState); + if (!m_pullMode) + pushData(); + } else { + if (SymbianAudio::SuspendedState == m_internalState) + setState(SymbianAudio::ActiveState); + else + setState(SymbianAudio::IdleState); + } +} + +CMMFDataBuffer* QAudioInputPrivate::currentBuffer() const +{ + CMMFDataBuffer *result = m_devSoundBuffer; + if (!result && !m_devSoundBufferQ.empty()) + result = m_devSoundBufferQ.front(); + return result; +} + +void QAudioInputPrivate::pushData() +{ + Q_ASSERT_X(bytesReady(), Q_FUNC_INFO, "No data available"); + Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, "pushData called when in pull mode"); + qobject_cast(m_sink)->dataReady(); +} + +qint64 QAudioInputPrivate::read(char *data, qint64 len) +{ + // SymbianAudioInputPrivate is ready to read data + + Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, + "read called when in pull mode"); + + qint64 bytesRead = 0; + + CMMFDataBuffer *buffer = 0; + while ((buffer = currentBuffer()) && (bytesRead < len)) { + if (SymbianAudio::IdleState == m_internalState) + setState(SymbianAudio::ActiveState); + + TDesC8 &inputBuffer = buffer->Data(); + + const qint64 inputBytes = bytesReady(); + const qint64 outputBytes = len - bytesRead; + const qint64 copyBytes = outputBytes < inputBytes ? + outputBytes : inputBytes; + + memcpy(data, inputBuffer.Ptr() + m_devSoundBufferPos, copyBytes); + + m_devSoundBufferPos += copyBytes; + data += copyBytes; + bytesRead += copyBytes; + + if (!bytesReady()) + bufferEmptied(); + } + + return bytesRead; +} + +void QAudioInputPrivate::pullData() +{ + Q_ASSERT_X(m_pullMode, Q_FUNC_INFO, + "pullData called when in push mode"); + + CMMFDataBuffer *buffer = 0; + while (buffer = currentBuffer()) { + if (SymbianAudio::IdleState == m_internalState) + setState(SymbianAudio::ActiveState); + + TDesC8 &inputBuffer = buffer->Data(); + + const qint64 inputBytes = bytesReady(); + const qint64 bytesPushed = m_sink->write( + (char*)inputBuffer.Ptr() + m_devSoundBufferPos, inputBytes); + + m_devSoundBufferPos += bytesPushed; + + if (!bytesReady()) + bufferEmptied(); + + if (!bytesPushed) + break; + } +} + +void QAudioInputPrivate::bufferEmptied() +{ + m_devSoundBufferPos = 0; + + if (m_devSoundBuffer) { + m_totalBytesReady -= m_devSoundBuffer->Data().Length(); + m_devSoundBuffer = 0; + m_devSound->RecordData(); + } else { + Q_ASSERT(!m_devSoundBufferQ.empty()); + m_totalBytesReady -= m_devSoundBufferQ.front()->Data().Length(); + m_devSoundBufferQ.erase(m_devSoundBufferQ.begin()); + + // If the queue has been emptied, resume transfer from the hardware + if (m_devSoundBufferQ.empty()) + m_devSound->RecordInitL(); + } + + Q_ASSERT(m_totalBytesReady >= 0); +} + +void QAudioInputPrivate::close() +{ + m_notifyTimer->stop(); + m_pullTimer->stop(); + + m_error = QAudio::NoError; + + if (m_devSound) + m_devSound->Stop(); + m_devSound.reset(); + m_devSoundBuffer = 0; + m_devSoundBufferSize = 0; + m_totalBytesReady = 0; + + if (!m_pullMode) // m_sink is owned + delete m_sink; + m_pullMode = false; + m_sink = 0; + + m_devSoundBufferQ.clear(); + m_devSoundBufferPos = 0; + m_totalSamplesRecorded = 0; + + setState(SymbianAudio::ClosedState); +} + +qint64 QAudioInputPrivate::getSamplesRecorded() const +{ + qint64 result = 0; + if (m_devSound) + result = qint64(m_devSound->SamplesRecorded()); + return result; +} + +void QAudioInputPrivate::setError(QAudio::Error error) +{ + m_error = error; + + // Although no state transition actually occurs here, a stateChanged event + // must be emitted to inform the client that the call to start() was + // unsuccessful. + if (QAudio::OpenError == error) + emit stateChanged(QAudio::StoppedState); + + // Close the DevSound instance. This causes a transition to StoppedState. + // This must be done asynchronously in case the current function was called + // from a DevSound event handler, in which case deleting the DevSound + // instance may cause an exception. + QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); +} + +void QAudioInputPrivate::setState(SymbianAudio::State newInternalState) +{ + const QAudio::State oldExternalState = m_externalState; + m_internalState = newInternalState; + m_externalState = SymbianAudio::Utils::stateNativeToQt( + m_internalState, initializingState()); + + if (m_externalState != oldExternalState) + emit stateChanged(m_externalState); +} + +QAudio::State QAudioInputPrivate::initializingState() const +{ + return QAudio::IdleState; +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudioinput_symbian_p.h b/src/multimedia/audio/qaudioinput_symbian_p.h new file mode 100644 index 0000000..ca3ccf7 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_symbian_p.h @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIOINPUT_SYMBIAN_P_H +#define QAUDIOINPUT_SYMBIAN_P_H + +#include +#include +#include +#include +#include "qaudio_symbian_p.h" + +QT_BEGIN_NAMESPACE + +class QAudioInputPrivate; + +class SymbianAudioInputPrivate : public QIODevice +{ + friend class QAudioInputPrivate; + Q_OBJECT +public: + SymbianAudioInputPrivate(QAudioInputPrivate *audio); + ~SymbianAudioInputPrivate(); + + qint64 readData(char *data, qint64 len); + qint64 writeData(const char *data, qint64 len); + + void dataReady(); + +private: + QAudioInputPrivate *const m_audioDevice; +}; + +class QAudioInputPrivate + : public QAbstractAudioInput + , public MDevSoundObserver +{ + friend class SymbianAudioInputPrivate; + Q_OBJECT +public: + QAudioInputPrivate(const QByteArray &device, + const QAudioFormat &audioFormat); + ~QAudioInputPrivate(); + + // QAbstractAudioInput + QIODevice* start(QIODevice *device = 0); + void stop(); + void reset(); + void suspend(); + void resume(); + int bytesReady() const; + int periodSize() const; + void setBufferSize(int value); + int bufferSize() const; + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + QAudio::Error error() const; + QAudio::State state() const; + QAudioFormat format() const; + + // MDevSoundObserver + void InitializeComplete(TInt aError); + void ToneFinished(TInt aError); + void BufferToBeFilled(CMMFBuffer *aBuffer); + void PlayError(TInt aError); + void BufferToBeEmptied(CMMFBuffer *aBuffer); + void RecordError(TInt aError); + void ConvertError(TInt aError); + void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); + +private slots: + void pullData(); + +private: + void open(); + void startRecording(); + void startDevSoundL(); + void startDataTransfer(); + CMMFDataBuffer* currentBuffer() const; + void pushData(); + qint64 read(char *data, qint64 len); + void bufferEmptied(); + Q_INVOKABLE void close(); + + qint64 getSamplesRecorded() const; + + void setError(QAudio::Error error); + void setState(SymbianAudio::State state); + + QAudio::State initializingState() const; + +private: + const QByteArray m_device; + const QAudioFormat m_format; + + int m_clientBufferSize; + int m_notifyInterval; + QScopedPointer m_notifyTimer; + QTime m_elapsed; + QAudio::Error m_error; + + SymbianAudio::State m_internalState; + QAudio::State m_externalState; + + bool m_pullMode; + QIODevice *m_sink; + + QScopedPointer m_pullTimer; + + QScopedPointer m_devSound; + TUint32 m_nativeFourCC; + TMMFCapabilities m_nativeFormat; + + // Latest buffer provided by DevSound, to be empied of data. + CMMFDataBuffer *m_devSoundBuffer; + + int m_devSoundBufferSize; + + // Total amount of data in buffers provided by DevSound + int m_totalBytesReady; + + // Queue of buffers returned after call to CMMFDevSound::Pause(). + QList m_devSoundBufferQ; + + // Current read position within m_devSoundBuffer + qint64 m_devSoundBufferPos; + + // Samples recorded up to the last call to suspend(). It is necessary + // to cache this because suspend() is implemented using + // CMMFDevSound::Stop(), which resets DevSound's SamplesRecorded() counter. + quint32 m_totalSamplesRecorded; + +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp new file mode 100644 index 0000000..14a1cf3 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -0,0 +1,604 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#include "qaudioinput_win32_p.h" + +QT_BEGIN_NAMESPACE + +//#define DEBUG_AUDIO 1 + +QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): + settings(audioFormat) +{ + bytesAvailable = 0; + buffer_size = 0; + period_size = 0; + m_device = device; + totalTimeValue = 0; + intervalTime = 1000; + errorState = QAudio::NoError; + deviceState = QAudio::StoppedState; + audioSource = 0; + pullMode = true; + resuming = false; + finished = false; +} + +QAudioInputPrivate::~QAudioInputPrivate() +{ + stop(); +} + +void QT_WIN_CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg, + DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ) +{ + Q_UNUSED(dwParam1) + Q_UNUSED(dwParam2) + Q_UNUSED(hWaveIn) + + QAudioInputPrivate* qAudio; + qAudio = (QAudioInputPrivate*)(dwInstance); + if(!qAudio) + return; + + QMutexLocker(&qAudio->mutex); + + switch(uMsg) { + case WIM_OPEN: + break; + case WIM_DATA: + if(qAudio->waveFreeBlockCount > 0) + qAudio->waveFreeBlockCount--; + qAudio->feedback(); + break; + case WIM_CLOSE: + qAudio->finished = true; + break; + default: + return; + } +} + +WAVEHDR* QAudioInputPrivate::allocateBlocks(int size, int count) +{ + int i; + unsigned char* buffer; + WAVEHDR* blocks; + DWORD totalBufferSize = (size + sizeof(WAVEHDR))*count; + + if((buffer=(unsigned char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, + totalBufferSize)) == 0) { + qWarning("QAudioInput: Memory allocation error"); + return 0; + } + blocks = (WAVEHDR*)buffer; + buffer += sizeof(WAVEHDR)*count; + for(i = 0; i < count; i++) { + blocks[i].dwBufferLength = size; + blocks[i].lpData = (LPSTR)buffer; + blocks[i].dwBytesRecorded=0; + blocks[i].dwUser = 0L; + blocks[i].dwFlags = 0L; + blocks[i].dwLoops = 0L; + result = waveInPrepareHeader(hWaveIn,&blocks[i], sizeof(WAVEHDR)); + if(result != MMSYSERR_NOERROR) { + qWarning("QAudioInput: Can't prepare block %d",i); + return 0; + } + buffer += size; + } + return blocks; +} + +void QAudioInputPrivate::freeBlocks(WAVEHDR* blockArray) +{ + WAVEHDR* blocks = blockArray; + + int count = buffer_size/period_size; + + for(int i = 0; i < count; i++) { + waveInUnprepareHeader(hWaveIn,blocks, sizeof(WAVEHDR)); + blocks+=sizeof(WAVEHDR); + } + HeapFree(GetProcessHeap(), 0, blockArray); +} + +QAudio::Error QAudioInputPrivate::error() const +{ + return errorState; +} + +QAudio::State QAudioInputPrivate::state() const +{ + return deviceState; +} + +QAudioFormat QAudioInputPrivate::format() const +{ + return settings; +} + +QIODevice* QAudioInputPrivate::start(QIODevice* device) +{ + if(deviceState != QAudio::StoppedState) + close(); + + if(!pullMode && audioSource) { + delete audioSource; + } + + if(device) { + //set to pull mode + pullMode = true; + audioSource = device; + deviceState = QAudio::ActiveState; + } else { + //set to push mode + pullMode = false; + deviceState = QAudio::IdleState; + audioSource = new InputPrivate(this); + audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered); + } + + if( !open() ) + return 0; + + emit stateChanged(deviceState); + + return audioSource; +} + +void QAudioInputPrivate::stop() +{ + if(deviceState == QAudio::StoppedState) + return; + + close(); + emit stateChanged(deviceState); +} + +bool QAudioInputPrivate::open() +{ +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()<> 3) * wfx.nChannels; + wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec; + + UINT_PTR devId = WAVE_MAPPER; + + WAVEINCAPS wic; + unsigned long iNumDevs,ii; + iNumDevs = waveInGetNumDevs(); + for(ii=0;ii 0 && waveBlocks[header].dwFlags & WHDR_DONE) { + if(pullMode) { + l = audioSource->write(waveBlocks[header].lpData, + waveBlocks[header].dwBytesRecorded); +#ifdef DEBUG_AUDIO + qDebug()<<"IN: "<= buffer_size/period_size) + header = 0; + p+=l; + + mutex.lock(); + if(!pullMode) { + if(l+period_size > len && waveFreeBlockCount == buffer_size/period_size) + done = true; + } else { + if(waveFreeBlockCount == buffer_size/period_size) + done = true; + } + mutex.unlock(); + + written+=l; + } +#ifdef DEBUG_AUDIO + qDebug()<<"read in len="<(audioSource); + a->trigger(); + } + + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { + emit notify(); + elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; + timeStamp.restart(); + } + return true; +} + +qint64 QAudioInputPrivate::elapsedUSecs() const +{ + if (deviceState == QAudio::StoppedState) + return 0; + + return timeStampOpened.elapsed()*1000; +} + +void QAudioInputPrivate::reset() +{ + close(); +} + +InputPrivate::InputPrivate(QAudioInputPrivate* audio) +{ + audioDevice = qobject_cast(audio); +} + +InputPrivate::~InputPrivate() {} + +qint64 InputPrivate::readData( char* data, qint64 len) +{ + // push mode, user read() called + if(audioDevice->deviceState != QAudio::ActiveState && + audioDevice->deviceState != QAudio::IdleState) + return 0; + // Read in some audio data + return audioDevice->read(data,len); +} + +qint64 InputPrivate::writeData(const char* data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + + emit readyRead(); + return 0; +} + +void InputPrivate::trigger() +{ + emit readyRead(); +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h new file mode 100644 index 0000000..8a9b02b --- /dev/null +++ b/src/multimedia/audio/qaudioinput_win32_p.h @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIOINPUTWIN_H +#define QAUDIOINPUTWIN_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +QT_BEGIN_NAMESPACE + +class QAudioInputPrivate : public QAbstractAudioInput +{ + Q_OBJECT +public: + QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat); + ~QAudioInputPrivate(); + + qint64 read(char* data, qint64 len); + + QAudioFormat format() const; + QIODevice* start(QIODevice* device = 0); + void stop(); + void reset(); + void suspend(); + void resume(); + int bytesReady() const; + int periodSize() const; + void setBufferSize(int value); + int bufferSize() const; + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + QAudio::Error error() const; + QAudio::State state() const; + + QIODevice* audioSource; + QAudioFormat settings; + QAudio::Error errorState; + QAudio::State deviceState; + +private: + qint32 buffer_size; + qint32 period_size; + qint32 header; + QByteArray m_device; + int bytesAvailable; + int intervalTime; + QTime timeStamp; + qint64 elapsedTimeOffset; + QTime timeStampOpened; + qint64 totalTimeValue; + bool pullMode; + bool resuming; + WAVEFORMATEX wfx; + HWAVEIN hWaveIn; + MMRESULT result; + WAVEHDR* waveBlocks; + volatile bool finished; + volatile int waveFreeBlockCount; + int waveCurrentBlock; + + QMutex mutex; + static void QT_WIN_CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg, + DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); + + WAVEHDR* allocateBlocks(int size, int count); + void freeBlocks(WAVEHDR* blockArray); + bool open(); + void close(); + +private slots: + void feedback(); + bool deviceReady(); + +signals: + void processMore(); +}; + +class InputPrivate : public QIODevice +{ + Q_OBJECT +public: + InputPrivate(QAudioInputPrivate* audio); + ~InputPrivate(); + + qint64 readData( char* data, qint64 len); + qint64 writeData(const char* data, qint64 len); + + void trigger(); +private: + QAudioInputPrivate *audioDevice; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp new file mode 100644 index 0000000..b0b5244 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -0,0 +1,411 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 +#include +#include +#include + +#include "qaudiodevicefactory_p.h" + + +QT_BEGIN_NAMESPACE + +/*! + \class QAudioOutput + \brief The QAudioOutput class provides an interface for sending audio data to an audio output device. + + \inmodule QtMultimedia + \ingroup multimedia + \since 4.6 + + You can construct an audio output with the system's + \l{QAudioDeviceInfo::defaultOutputDevice()}{default audio output + device}. It is also possible to create QAudioOutput with a + specific QAudioDeviceInfo. When you create the audio output, you + should also send in the QAudioFormat to be used for the playback + (see the QAudioFormat class description for details). + + To play a file: + + Starting to play an audio stream is simply a matter of calling + start() with a QIODevice. QAudioOutput will then fetch the data it + needs from the io device. So playing back an audio file is as + simple as: + + \code + QFile inputFile; // class member. + QAudioOutput* audio; // class member. + \endcode + + \code + inputFile.setFileName("/tmp/test.raw"); + inputFile.open(QIODevice::ReadOnly); + + QAudioFormat format; + // Set up the format, eg. + format.setFrequency(8000); + format.setChannels(1); + format.setSampleSize(8); + format.setCodec("audio/pcm"); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setSampleType(QAudioFormat::UnSignedInt); + + QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); + if (!info.isFormatSupported(format)) { + qWarning()<<"raw audio format not supported by backend, cannot play audio."; + return; + } + + audio = new QAudioOutput(format, this); + connect(audio,SIGNAL(stateChanged(QAudio::State)),SLOT(finishedPlaying(QAudio::State))); + audio->start(&inputFile); + + \endcode + + The file will start playing assuming that the audio system and + output device support it. If you run out of luck, check what's + up with the error() function. + + After the file has finished playing, we need to stop the device: + + \code + void finishedPlaying(QAudio::State state) + { + if(state == QAudio::IdleState) { + audio->stop(); + inputFile.close(); + delete audio; + } + } + \endcode + + At any given time, the QAudioOutput will be in one of four states: + active, suspended, stopped, or idle. These states are described + by the QAudio::State enum. + State changes are reported through the stateChanged() signal. You + can use this signal to, for instance, update the GUI of the + application; the mundane example here being changing the state of + a \c { play/pause } button. You request a state change directly + with suspend(), stop(), reset(), resume(), and start(). + + While the stream is playing, you can set a notify interval in + milliseconds with setNotifyInterval(). This interval specifies the + time between two emissions of the notify() signal. This is + relative to the position in the stream, i.e., if the QAudioOutput + is in the SuspendedState or the IdleState, the notify() signal is + not emitted. A typical use-case would be to update a + \l{QSlider}{slider} that allows seeking in the stream. + If you want the time since playback started regardless of which + states the audio output has been in, elapsedUSecs() is the function for you. + + If an error occurs, you can fetch the \l{QAudio::Error}{error + type} with the error() function. Please see the QAudio::Error enum + for a description of the possible errors that are reported. When + an error is encountered, the state changes to QAudio::StoppedState. + You can check for errors by connecting to the stateChanged() + signal: + + \snippet doc/src/snippets/audio/main.cpp 3 + + \sa QAudioInput, QAudioDeviceInfo +*/ + +/*! + Construct a new audio output and attach it to \a parent. + The default audio output device is used with the output + \a format parameters. +*/ + +QAudioOutput::QAudioOutput(const QAudioFormat &format, QObject *parent): + QObject(parent) +{ + d = QAudioDeviceFactory::createDefaultOutputDevice(format); + connect(d, SIGNAL(notify()), SIGNAL(notify())); + connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); +} + +/*! + Construct a new audio output and attach it to \a parent. + The device referenced by \a audioDevice is used with the output + \a format parameters. +*/ + +QAudioOutput::QAudioOutput(const QAudioDeviceInfo &audioDevice, const QAudioFormat &format, QObject *parent): + QObject(parent) +{ + d = QAudioDeviceFactory::createOutputDevice(audioDevice, format); + connect(d, SIGNAL(notify()), SIGNAL(notify())); + connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); +} + +/*! + Destroys this audio output. +*/ + +QAudioOutput::~QAudioOutput() +{ + delete d; +} + +/*! + Returns the QAudioFormat being used. + +*/ + +QAudioFormat QAudioOutput::format() const +{ + return d->format(); +} + +/*! + Uses the \a device as the QIODevice to transfer data. + Passing a QIODevice allows the data to be transfered without any extra code. + All that is required is to open the QIODevice. + + If able to successfully output audio data to the systems audio device the + state() is set to QAudio::ActiveState, error() is set to QAudio::NoError + and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + + \sa QIODevice +*/ + +void QAudioOutput::start(QIODevice* device) +{ + d->start(device); +} + +/*! + Returns a pointer to the QIODevice being used to handle the data + transfer. This QIODevice can be used to write() audio data directly. + + If able to access the systems audio device the state() is set to + QAudio::IdleState, error() is set to QAudio::NoError + and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + + \sa QIODevice +*/ + +QIODevice* QAudioOutput::start() +{ + return d->start(0); +} + +/*! + Stops the audio output, detaching from the system resource. + + Sets error() to QAudio::NoError, state() to QAudio::StoppedState and + emit stateChanged() signal. +*/ + +void QAudioOutput::stop() +{ + d->stop(); +} + +/*! + Drops all audio data in the buffers, resets buffers to zero. +*/ + +void QAudioOutput::reset() +{ + d->reset(); +} + +/*! + Stops processing audio data, preserving buffered audio data. + + Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and + emit stateChanged() signal. +*/ + +void QAudioOutput::suspend() +{ + d->suspend(); +} + +/*! + Resumes processing audio data after a suspend(). + + Sets error() to QAudio::NoError. + Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). + Sets state() to QAudio::IdleState if you previously called start(). + emits stateChanged() signal. +*/ + +void QAudioOutput::resume() +{ + d->resume(); +} + +/*! + Returns the free space available in bytes in the audio buffer. + + NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState + state, otherwise returns zero. +*/ + +int QAudioOutput::bytesFree() const +{ + return d->bytesFree(); +} + +/*! + Returns the period size in bytes. + + Note: This is the recommended write size in bytes. +*/ + +int QAudioOutput::periodSize() const +{ + return d->periodSize(); +} + +/*! + Sets the audio buffer size to \a value in bytes. + + Note: This function can be called anytime before start(), calls to this + are ignored after start(). It should not be assumed that the buffer size + set is the actual buffer size used, calling bufferSize() anytime after start() + will return the actual buffer size being used. +*/ + +void QAudioOutput::setBufferSize(int value) +{ + d->setBufferSize(value); +} + +/*! + Returns the audio buffer size in bytes. + + If called before start(), returns platform default value. + If called before start() but setBufferSize() was called prior, returns value set by setBufferSize(). + If called after start(), returns the actual buffer size being used. This may not be what was set previously + by setBufferSize(). + +*/ + +int QAudioOutput::bufferSize() const +{ + return d->bufferSize(); +} + +/*! + Sets the interval for notify() signal to be emitted. + This is based on the \a ms of audio data processed + not on actual real-time. + The minimum resolution of the timer is platform specific and values + should be checked with notifyInterval() to confirm actual value + being used. +*/ + +void QAudioOutput::setNotifyInterval(int ms) +{ + d->setNotifyInterval(ms); +} + +/*! + Returns the notify interval in milliseconds. +*/ + +int QAudioOutput::notifyInterval() const +{ + return d->notifyInterval(); +} + +/*! + Returns the amount of audio data processed since start() + was called in microseconds. +*/ + +qint64 QAudioOutput::processedUSecs() const +{ + return d->processedUSecs(); +} + +/*! + Returns the microseconds since start() was called, including time in Idle and + Suspend states. +*/ + +qint64 QAudioOutput::elapsedUSecs() const +{ + return d->elapsedUSecs(); +} + +/*! + Returns the error state. +*/ + +QAudio::Error QAudioOutput::error() const +{ + return d->error(); +} + +/*! + Returns the state of audio processing. +*/ + +QAudio::State QAudioOutput::state() const +{ + return d->state(); +} + +/*! + \fn QAudioOutput::stateChanged(QAudio::State state) + This signal is emitted when the device \a state has changed. + This is the current state of the audio output. +*/ + +/*! + \fn QAudioOutput::notify() + This signal is emitted when x ms of audio data has been processed + the interval set by setNotifyInterval(x). +*/ + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiooutput.h b/src/multimedia/audio/qaudiooutput.h new file mode 100644 index 0000000..0f45b1b --- /dev/null +++ b/src/multimedia/audio/qaudiooutput.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QAUDIOOUTPUT_H +#define QAUDIOOUTPUT_H + +#include +#include + +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAbstractAudioOutput; + +class Q_MULTIMEDIA_EXPORT QAudioOutput : public QObject +{ + Q_OBJECT + +public: + explicit QAudioOutput(const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + explicit QAudioOutput(const QAudioDeviceInfo &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + ~QAudioOutput(); + + QAudioFormat format() const; + + void start(QIODevice *device); + QIODevice* start(); + + void stop(); + void reset(); + void suspend(); + void resume(); + + void setBufferSize(int bytes); + int bufferSize() const; + + int bytesFree() const; + int periodSize() const; + + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + + QAudio::Error error() const; + QAudio::State state() const; + +Q_SIGNALS: + void stateChanged(QAudio::State); + void notify(); + +private: + Q_DISABLE_COPY(QAudioOutput) + + QAbstractAudioOutput* d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOOUTPUT_H diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp new file mode 100644 index 0000000..49b32c0 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -0,0 +1,774 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "qaudiooutput_alsa_p.h" +#include "qaudiodeviceinfo_alsa_p.h" + +QT_BEGIN_NAMESPACE + +//#define DEBUG_AUDIO 1 + +QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): + settings(audioFormat) +{ + bytesAvailable = 0; + handle = 0; + ahandler = 0; + access = SND_PCM_ACCESS_RW_INTERLEAVED; + pcmformat = SND_PCM_FORMAT_S16; + buffer_frames = 0; + period_frames = 0; + buffer_size = 0; + period_size = 0; + buffer_time = 100000; + period_time = 20000; + totalTimeValue = 0; + intervalTime = 1000; + audioBuffer = 0; + errorState = QAudio::NoError; + deviceState = QAudio::StoppedState; + audioSource = 0; + pullMode = true; + resuming = false; + opened = false; + + m_device = device; + + timer = new QTimer(this); + connect(timer,SIGNAL(timeout()),SLOT(userFeed())); +} + +QAudioOutputPrivate::~QAudioOutputPrivate() +{ + close(); + disconnect(timer, SIGNAL(timeout())); + QCoreApplication::processEvents(); + delete timer; +} + +QAudio::Error QAudioOutputPrivate::error() const +{ + return errorState; +} + +QAudio::State QAudioOutputPrivate::state() const +{ + return deviceState; +} + +void QAudioOutputPrivate::async_callback(snd_async_handler_t *ahandler) +{ + QAudioOutputPrivate* audioOut; + + audioOut = static_cast + (snd_async_handler_get_callback_private(ahandler)); + + if((audioOut->deviceState==QAudio::ActiveState)||(audioOut->resuming)) + audioOut->feedback(); +} + +int QAudioOutputPrivate::xrun_recovery(int err) +{ + int count = 0; + bool reset = false; + + if(err == -EPIPE) { + errorState = QAudio::UnderrunError; + err = snd_pcm_prepare(handle); + if(err < 0) + reset = true; + + } else if((err == -ESTRPIPE)||(err == -EIO)) { + errorState = QAudio::IOError; + while((err = snd_pcm_resume(handle)) == -EAGAIN){ + usleep(100); + count++; + if(count > 5) { + reset = true; + break; + } + } + if(err < 0) { + err = snd_pcm_prepare(handle); + if(err < 0) + reset = true; + } + } + if(reset) { + close(); + open(); + snd_pcm_prepare(handle); + return 0; + } + return err; +} + +int QAudioOutputPrivate::setFormat() +{ + snd_pcm_format_t pcmformat = SND_PCM_FORMAT_S16; + + if(settings.sampleSize() == 8) { + pcmformat = SND_PCM_FORMAT_U8; + + } else if(settings.sampleSize() == 16) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_S16_LE; + else + pcmformat = SND_PCM_FORMAT_S16_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_U16_LE; + else + pcmformat = SND_PCM_FORMAT_U16_BE; + } + } else if(settings.sampleSize() == 24) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_S24_LE; + else + pcmformat = SND_PCM_FORMAT_S24_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_U24_LE; + else + pcmformat = SND_PCM_FORMAT_U24_BE; + } + } else if(settings.sampleSize() == 32) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_S32_LE; + else + pcmformat = SND_PCM_FORMAT_S32_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_U32_LE; + else + pcmformat = SND_PCM_FORMAT_U32_BE; + } else if(settings.sampleType() == QAudioFormat::Float) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_FLOAT_LE; + else + pcmformat = SND_PCM_FORMAT_FLOAT_BE; + } + } else if(settings.sampleSize() == 64) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_FLOAT64_LE; + else + pcmformat = SND_PCM_FORMAT_FLOAT64_BE; + } + + return snd_pcm_hw_params_set_format( handle, hwparams, pcmformat); +} + +QIODevice* QAudioOutputPrivate::start(QIODevice* device) +{ + if(deviceState != QAudio::StoppedState) + deviceState = QAudio::StoppedState; + + errorState = QAudio::NoError; + + // Handle change of mode + if(audioSource && pullMode && !device) { + // pull -> push + close(); + audioSource = 0; + } else if(audioSource && !pullMode && device) { + // push -> pull + close(); + delete audioSource; + audioSource = 0; + } + + if(device) { + //set to pull mode + pullMode = true; + audioSource = device; + deviceState = QAudio::ActiveState; + } else { + //set to push mode + if(!audioSource) { + audioSource = new OutputPrivate(this); + audioSource->open(QIODevice::WriteOnly|QIODevice::Unbuffered); + } + pullMode = false; + deviceState = QAudio::IdleState; + } + + open(); + + emit stateChanged(deviceState); + + return audioSource; +} + +void QAudioOutputPrivate::stop() +{ + if(deviceState == QAudio::StoppedState) + return; + errorState = QAudio::NoError; + deviceState = QAudio::StoppedState; + close(); + emit stateChanged(deviceState); +} + +bool QAudioOutputPrivate::open() +{ + if(opened) + return true; + +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()< devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); + if(dev.compare(QLatin1String("default")) == 0) { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = QLatin1String(devices.first()); +#else + dev = QLatin1String("hw:0,0"); +#endif + } else { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = QLatin1String(m_device); +#else + int idx = 0; + char *name; + + QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData()); + + while(snd_card_get_name(idx,&name) == 0) { + if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0) + break; + idx++; + } + dev = QString(QLatin1String("hw:%1,0")).arg(idx); +#endif + } + + // Step 1: try and open the device + while((count < 5) && (err < 0)) { + err=snd_pcm_open(&handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); + if(err < 0) + count++; + } + if (( err < 0)||(handle == 0)) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + return false; + } + snd_pcm_nonblock( handle, 0 ); + + // Step 2: Set the desired HW parameters. + snd_pcm_hw_params_alloca( &hwparams ); + + bool fatal = false; + QString errMessage; + unsigned int chunks = 8; + + err = snd_pcm_hw_params_any( handle, hwparams ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_any: err = %1").arg(err); + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_rate_resample( handle, hwparams, 1 ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_rate_resample: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_access( handle, hwparams, access ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_access: err = %1").arg(err); + } + } + if ( !fatal ) { + err = setFormat(); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_format: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_channels: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &freakuency, 0 ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_rate_near: err = %1").arg(err); + } + } + if ( !fatal ) { + unsigned int maxBufferTime = 0; + unsigned int minBufferTime = 0; + unsigned int maxPeriodTime = 0; + unsigned int minPeriodTime = 0; + + err = snd_pcm_hw_params_get_buffer_time_max(hwparams, &maxBufferTime, &dir); + if ( err >= 0) + err = snd_pcm_hw_params_get_buffer_time_min(hwparams, &minBufferTime, &dir); + if ( err >= 0) + err = snd_pcm_hw_params_get_period_time_max(hwparams, &maxPeriodTime, &dir); + if ( err >= 0) + err = snd_pcm_hw_params_get_period_time_min(hwparams, &minPeriodTime, &dir); + + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: buffer/period min and max: err = %1").arg(err); + } else { + if (maxBufferTime < buffer_time || buffer_time < minBufferTime || maxPeriodTime < period_time || minPeriodTime > period_time) { +#ifdef DEBUG_AUDIO + qDebug()<<"defaults out of range"; + qDebug()<<"pmin="<start(period_time/1000); + + clockStamp.restart(); + timeStamp.restart(); + elapsedTimeOffset = 0; + errorState = QAudio::NoError; + totalTimeValue = 0; + opened = true; + + return true; +} + +void QAudioOutputPrivate::close() +{ + timer->stop(); + + if ( handle ) { + snd_pcm_drain( handle ); + snd_pcm_close( handle ); + handle = 0; + delete [] audioBuffer; + audioBuffer=0; + } + if(!pullMode && audioSource) { + delete audioSource; + audioSource = 0; + } + opened = false; +} + +int QAudioOutputPrivate::bytesFree() const +{ + if(resuming) + return period_size; + + if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) + return 0; + int frames = snd_pcm_avail_update(handle); + if((int)frames > (int)buffer_frames) + frames = buffer_frames; + + return snd_pcm_frames_to_bytes(handle, frames); +} + +qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) +{ + // Write out some audio data + if ( !handle ) + return 0; +#ifdef DEBUG_AUDIO + qDebug()<<"frames to write out = "<< + snd_pcm_bytes_to_frames( handle, (int)len )<<" ("< 0) { + totalTimeValue += err; + resuming = false; + errorState = QAudio::NoError; + if (deviceState != QAudio::ActiveState) { + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + return snd_pcm_frames_to_bytes( handle, err ); + } else + err = xrun_recovery(err); + + if(err < 0) { + close(); + errorState = QAudio::FatalError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + } + return 0; +} + +int QAudioOutputPrivate::periodSize() const +{ + return period_size; +} + +void QAudioOutputPrivate::setBufferSize(int value) +{ + if(deviceState == QAudio::StoppedState) + buffer_size = value; +} + +int QAudioOutputPrivate::bufferSize() const +{ + return buffer_size; +} + +void QAudioOutputPrivate::setNotifyInterval(int ms) +{ + intervalTime = qMax(0, ms); +} + +int QAudioOutputPrivate::notifyInterval() const +{ + return intervalTime; +} + +qint64 QAudioOutputPrivate::processedUSecs() const +{ + return qint64(1000000) * totalTimeValue / settings.frequency(); +} + +void QAudioOutputPrivate::resume() +{ + if(deviceState == QAudio::SuspendedState) { + int err = 0; + + if(handle) { + err = snd_pcm_prepare( handle ); + if(err < 0) + xrun_recovery(err); + + err = snd_pcm_start(handle); + if(err < 0) + xrun_recovery(err); + + bytesAvailable = (int)snd_pcm_frames_to_bytes(handle, buffer_frames); + } + resuming = true; + + deviceState = QAudio::ActiveState; + + errorState = QAudio::NoError; + timer->start(period_time/1000); + emit stateChanged(deviceState); + } +} + +QAudioFormat QAudioOutputPrivate::format() const +{ + return settings; +} + +void QAudioOutputPrivate::suspend() +{ + if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState || resuming) { + timer->stop(); + deviceState = QAudio::SuspendedState; + errorState = QAudio::NoError; + emit stateChanged(deviceState); + } +} + +void QAudioOutputPrivate::userFeed() +{ + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) + return; +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()<acquireReadRegion((maxFrames - framesRead) * m_bytesPerFrame); + + if (region.second > 0) { + region.second -= region.second % m_bytesPerFrame; + memcpy(data + (framesRead * m_bytesPerFrame), region.first, region.second); + framesRead += region.second / m_bytesPerFrame; + } + else + wecan = false; + + m_buffer->releaseReadRegion(region); + } + + if (framesRead == 0 && m_deviceError) + framesRead = -1; + + return framesRead; + } + + qint64 writeBytes(const char* data, qint64 maxSize) + { + bool wecan = true; + qint64 bytesWritten = 0; + + maxSize -= maxSize % m_bytesPerFrame; + while (wecan && bytesWritten < maxSize) { + QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(maxSize - bytesWritten); + + if (region.second > 0) { + memcpy(region.first, data + bytesWritten, region.second); + bytesWritten += region.second; + } + else + wecan = false; + + m_buffer->releaseWriteRegion(region); + } + + if (bytesWritten > 0) + emit readyRead(); + + return bytesWritten; + } + + int available() const + { + return m_buffer->free(); + } + + void reset() + { + m_buffer->reset(); + m_deviceError = false; + } + + void setPrefetchDevice(QIODevice* device) + { + if (m_device != device) { + m_device = device; + if (m_device != 0) + fillBuffer(); + } + } + + void startFillTimer() + { + if (m_device != 0) + m_fillTimer->start(m_buffer->size() / 2 / m_maxPeriodSize * m_periodTime); + } + + void stopFillTimer() + { + m_fillTimer->stop(); + } + +signals: + void readyRead(); + +private slots: + void fillBuffer() + { + const int free = m_buffer->free(); + const int writeSize = free - (free % m_maxPeriodSize); + + if (writeSize > 0) { + bool wecan = true; + int filled = 0; + + while (!m_deviceError && wecan && filled < writeSize) { + QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(writeSize - filled); + + if (region.second > 0) { + region.second = m_device->read(region.first, region.second); + if (region.second > 0) + filled += region.second; + else if (region.second == 0) + wecan = false; + else if (region.second < 0) { + m_fillTimer->stop(); + region.second = 0; + m_deviceError = true; + } + } + else + wecan = false; + + m_buffer->releaseWriteRegion(region); + } + + if (filled > 0) + emit readyRead(); + } + } + +private: + bool m_deviceError; + int m_maxPeriodSize; + int m_bytesPerFrame; + int m_periodTime; + QIODevice* m_device; + QTimer* m_fillTimer; + QAudioRingBuffer* m_buffer; +}; + + +} + +class MacOutputDevice : public QIODevice +{ + Q_OBJECT + +public: + MacOutputDevice(QtMultimediaInternal::QAudioOutputBuffer* audioBuffer, QObject* parent): + QIODevice(parent), + m_audioBuffer(audioBuffer) + { + open(QIODevice::WriteOnly | QIODevice::Unbuffered); + } + + qint64 readData(char* data, qint64 len) + { + Q_UNUSED(data); + Q_UNUSED(len); + + return 0; + } + + qint64 writeData(const char* data, qint64 len) + { + return m_audioBuffer->writeBytes(data, len); + } + + bool isSequential() const + { + return true; + } + +private: + QtMultimediaInternal::QAudioOutputBuffer* m_audioBuffer; +}; + + +QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioFormat& format): + audioFormat(format) +{ + QDataStream ds(device); + quint32 did, mode; + + ds >> did >> mode; + + if (QAudio::Mode(mode) == QAudio::AudioInput) + errorCode = QAudio::OpenError; + else { + isOpen = false; + audioDeviceId = AudioDeviceID(did); + audioUnit = 0; + audioIO = 0; + startTime = 0; + totalFrames = 0; + audioBuffer = 0; + internalBufferSize = QtMultimediaInternal::default_buffer_size; + clockFrequency = AudioGetHostClockFrequency() / 1000; + errorCode = QAudio::NoError; + stateCode = QAudio::StoppedState; + audioThreadState = Stopped; + + intervalTimer = new QTimer(this); + intervalTimer->setInterval(1000); + connect(intervalTimer, SIGNAL(timeout()), SIGNAL(notify())); + } +} + +QAudioOutputPrivate::~QAudioOutputPrivate() +{ + close(); +} + +bool QAudioOutputPrivate::open() +{ + if (errorCode != QAudio::NoError) + return false; + + if (isOpen) + return true; + + ComponentDescription cd; + cd.componentType = kAudioUnitType_Output; + cd.componentSubType = kAudioUnitSubType_HALOutput; + cd.componentManufacturer = kAudioUnitManufacturer_Apple; + cd.componentFlags = 0; + cd.componentFlagsMask = 0; + + // Open + Component cp = FindNextComponent(NULL, &cd); + if (cp == 0) { + qWarning() << "QAudioOutput: Failed to find HAL Output component"; + return false; + } + + if (OpenAComponent(cp, &audioUnit) != noErr) { + qWarning() << "QAudioOutput: Unable to Open Output Component"; + return false; + } + + // register callback + AURenderCallbackStruct cb; + cb.inputProc = renderCallback; + cb.inputProcRefCon = this; + + if (AudioUnitSetProperty(audioUnit, + kAudioUnitProperty_SetRenderCallback, + kAudioUnitScope_Global, + 0, + &cb, + sizeof(cb)) != noErr) { + qWarning() << "QAudioOutput: Failed to set AudioUnit callback"; + return false; + } + + // Set Audio Device + if (AudioUnitSetProperty(audioUnit, + kAudioOutputUnitProperty_CurrentDevice, + kAudioUnitScope_Global, + 0, + &audioDeviceId, + sizeof(audioDeviceId)) != noErr) { + qWarning() << "QAudioOutput: Unable to use configured device"; + return false; + } + + // Set stream format + streamFormat = toAudioStreamBasicDescription(audioFormat); + + UInt32 size = sizeof(deviceFormat); + if (AudioUnitGetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 0, + &deviceFormat, + &size) != noErr) { + qWarning() << "QAudioOutput: Unable to retrieve device format"; + return false; + } + + if (AudioUnitSetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 0, + &streamFormat, + sizeof(streamFormat)) != noErr) { + qWarning() << "QAudioOutput: Unable to Set Stream information"; + return false; + } + + // Allocate buffer + UInt32 numberOfFrames = 0; + size = sizeof(UInt32); + if (AudioUnitGetProperty(audioUnit, + kAudioDevicePropertyBufferFrameSize, + kAudioUnitScope_Global, + 0, + &numberOfFrames, + &size) != noErr) { + qWarning() << "QAudioInput: Failed to get audio period size"; + return false; + } + + periodSizeBytes = (numberOfFrames * streamFormat.mSampleRate / deviceFormat.mSampleRate) * + streamFormat.mBytesPerFrame; + if (internalBufferSize < periodSizeBytes * 2) + internalBufferSize = periodSizeBytes * 2; + else + internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; + + audioBuffer = new QtMultimediaInternal::QAudioOutputBuffer(internalBufferSize, periodSizeBytes, audioFormat); + connect(audioBuffer, SIGNAL(readyRead()), SLOT(inputReady())); // Pull + + audioIO = new MacOutputDevice(audioBuffer, this); + + // Init + if (AudioUnitInitialize(audioUnit)) { + qWarning() << "QAudioOutput: Failed to initialize AudioUnit"; + return false; + } + + isOpen = true; + + return true; +} + +void QAudioOutputPrivate::close() +{ + if (audioUnit != 0) { + AudioOutputUnitStop(audioUnit); + AudioUnitUninitialize(audioUnit); + CloseComponent(audioUnit); + } + + delete audioBuffer; +} + +QAudioFormat QAudioOutputPrivate::format() const +{ + return audioFormat; +} + +QIODevice* QAudioOutputPrivate::start(QIODevice* device) +{ + QIODevice* op = device; + + if (!audioFormat.isValid() || !open()) { + stateCode = QAudio::StoppedState; + errorCode = QAudio::OpenError; + return audioIO; + } + + reset(); + audioBuffer->reset(); + audioBuffer->setPrefetchDevice(op); + + if (op == 0) { + op = audioIO; + stateCode = QAudio::IdleState; + } + else + stateCode = QAudio::ActiveState; + + // Start + errorCode = QAudio::NoError; + totalFrames = 0; + startTime = AudioGetCurrentHostTime(); + + if (stateCode == QAudio::ActiveState) + audioThreadStart(); + + emit stateChanged(stateCode); + + return op; +} + +void QAudioOutputPrivate::stop() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StoppedState) { + audioThreadDrain(); + + stateCode = QAudio::StoppedState; + errorCode = QAudio::NoError; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioOutputPrivate::reset() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StoppedState) { + audioThreadStop(); + + stateCode = QAudio::StoppedState; + errorCode = QAudio::NoError; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioOutputPrivate::suspend() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) { + audioThreadStop(); + + stateCode = QAudio::SuspendedState; + errorCode = QAudio::NoError; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioOutputPrivate::resume() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::SuspendedState) { + audioThreadStart(); + + stateCode = QAudio::ActiveState; + errorCode = QAudio::NoError; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +int QAudioOutputPrivate::bytesFree() const +{ + return audioBuffer->available(); +} + +int QAudioOutputPrivate::periodSize() const +{ + return periodSizeBytes; +} + +void QAudioOutputPrivate::setBufferSize(int bs) +{ + if (stateCode == QAudio::StoppedState) + internalBufferSize = bs; +} + +int QAudioOutputPrivate::bufferSize() const +{ + return internalBufferSize; +} + +void QAudioOutputPrivate::setNotifyInterval(int milliSeconds) +{ + if (intervalTimer->interval() == milliSeconds) + return; + + if (milliSeconds <= 0) + milliSeconds = 0; + + intervalTimer->setInterval(milliSeconds); +} + +int QAudioOutputPrivate::notifyInterval() const +{ + return intervalTimer->interval(); +} + +qint64 QAudioOutputPrivate::processedUSecs() const +{ + return totalFrames * 1000000 / audioFormat.frequency(); +} + +qint64 QAudioOutputPrivate::elapsedUSecs() const +{ + if (stateCode == QAudio::StoppedState) + return 0; + + return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); +} + +QAudio::Error QAudioOutputPrivate::error() const +{ + return errorCode; +} + +QAudio::State QAudioOutputPrivate::state() const +{ + return stateCode; +} + +void QAudioOutputPrivate::audioThreadStart() +{ + startTimers(); + audioThreadState = Running; + AudioOutputUnitStart(audioUnit); +} + +void QAudioOutputPrivate::audioThreadStop() +{ + stopTimers(); + if (audioThreadState.testAndSetAcquire(Running, Stopped)) + threadFinished.wait(&mutex); +} + +void QAudioOutputPrivate::audioThreadDrain() +{ + stopTimers(); + if (audioThreadState.testAndSetAcquire(Running, Draining)) + threadFinished.wait(&mutex); +} + +void QAudioOutputPrivate::audioDeviceStop() +{ + AudioOutputUnitStop(audioUnit); + audioThreadState = Stopped; + threadFinished.wakeOne(); +} + +void QAudioOutputPrivate::audioDeviceIdle() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState) { + audioDeviceStop(); + + errorCode = QAudio::UnderrunError; + stateCode = QAudio::IdleState; + QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); + } +} + +void QAudioOutputPrivate::audioDeviceError() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState) { + audioDeviceStop(); + + errorCode = QAudio::IOError; + stateCode = QAudio::StoppedState; + QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); + } +} + +void QAudioOutputPrivate::startTimers() +{ + audioBuffer->startFillTimer(); + if (intervalTimer->interval() > 0) + intervalTimer->start(); +} + +void QAudioOutputPrivate::stopTimers() +{ + audioBuffer->stopFillTimer(); + intervalTimer->stop(); +} + + +void QAudioOutputPrivate::deviceStopped() +{ + intervalTimer->stop(); + emit stateChanged(stateCode); +} + +void QAudioOutputPrivate::inputReady() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::IdleState) { + audioThreadStart(); + + stateCode = QAudio::ActiveState; + errorCode = QAudio::NoError; + + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + + +OSStatus QAudioOutputPrivate::renderCallback(void* inRefCon, + AudioUnitRenderActionFlags* ioActionFlags, + const AudioTimeStamp* inTimeStamp, + UInt32 inBusNumber, + UInt32 inNumberFrames, + AudioBufferList* ioData) +{ + Q_UNUSED(ioActionFlags) + Q_UNUSED(inTimeStamp) + Q_UNUSED(inBusNumber) + Q_UNUSED(inNumberFrames) + + QAudioOutputPrivate* d = static_cast(inRefCon); + + const int threadState = d->audioThreadState.fetchAndAddAcquire(0); + if (threadState == Stopped) { + ioData->mBuffers[0].mDataByteSize = 0; + d->audioDeviceStop(); + } + else { + const UInt32 bytesPerFrame = d->streamFormat.mBytesPerFrame; + qint64 framesRead; + + framesRead = d->audioBuffer->readFrames((char*)ioData->mBuffers[0].mData, + ioData->mBuffers[0].mDataByteSize / bytesPerFrame); + + if (framesRead > 0) { + ioData->mBuffers[0].mDataByteSize = framesRead * bytesPerFrame; + d->totalFrames += framesRead; + } + else { + ioData->mBuffers[0].mDataByteSize = 0; + if (framesRead == 0) { + if (threadState == Draining) + d->audioDeviceStop(); + else + d->audioDeviceIdle(); + } + else + d->audioDeviceError(); + } + } + + return noErr; +} + + +QT_END_NAMESPACE + +#include "qaudiooutput_mac_p.moc" + diff --git a/src/multimedia/audio/qaudiooutput_mac_p.h b/src/multimedia/audio/qaudiooutput_mac_p.h new file mode 100644 index 0000000..752905c --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_mac_p.h @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIOOUTPUT_MAC_P_H +#define QAUDIOOUTPUT_MAC_P_H + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QIODevice; + +namespace QtMultimediaInternal +{ +class QAudioOutputBuffer; +} + +class QAudioOutputPrivate : public QAbstractAudioOutput +{ + Q_OBJECT + +public: + bool isOpen; + int internalBufferSize; + int periodSizeBytes; + qint64 totalFrames; + QAudioFormat audioFormat; + QIODevice* audioIO; + AudioDeviceID audioDeviceId; + AudioUnit audioUnit; + Float64 clockFrequency; + UInt64 startTime; + AudioStreamBasicDescription deviceFormat; + AudioStreamBasicDescription streamFormat; + QtMultimediaInternal::QAudioOutputBuffer* audioBuffer; + QAtomicInt audioThreadState; + QWaitCondition threadFinished; + QMutex mutex; + QTimer* intervalTimer; + + QAudio::Error errorCode; + QAudio::State stateCode; + + QAudioOutputPrivate(const QByteArray& device, const QAudioFormat& format); + ~QAudioOutputPrivate(); + + bool open(); + void close(); + + QAudioFormat format() const; + + QIODevice* start(QIODevice* device); + void stop(); + void reset(); + void suspend(); + void resume(); + + int bytesFree() const; + int periodSize() const; + + void setBufferSize(int value); + int bufferSize() const; + + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + + QAudio::Error error() const; + QAudio::State state() const; + + void audioThreadStart(); + void audioThreadStop(); + void audioThreadDrain(); + + void audioDeviceStop(); + void audioDeviceIdle(); + void audioDeviceError(); + + void startTimers(); + void stopTimers(); + +private slots: + void deviceStopped(); + void inputReady(); + +private: + enum { Running, Draining, Stopped }; + + static OSStatus renderCallback(void* inRefCon, + AudioUnitRenderActionFlags* ioActionFlags, + const AudioTimeStamp* inTimeStamp, + UInt32 inBusNumber, + UInt32 inNumberFrames, + AudioBufferList* ioData); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/multimedia/audio/qaudiooutput_symbian_p.cpp b/src/multimedia/audio/qaudiooutput_symbian_p.cpp new file mode 100644 index 0000000..3f8e933 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_symbian_p.cpp @@ -0,0 +1,697 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qaudiooutput_symbian_p.h" + +QT_BEGIN_NAMESPACE + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const int UnderflowTimerInterval = 50; // ms + + +//----------------------------------------------------------------------------- +// Private class +//----------------------------------------------------------------------------- + +SymbianAudioOutputPrivate::SymbianAudioOutputPrivate( + QAudioOutputPrivate *audioDevice) + : m_audioDevice(audioDevice) +{ + +} + +SymbianAudioOutputPrivate::~SymbianAudioOutputPrivate() +{ + +} + +qint64 SymbianAudioOutputPrivate::readData(char *data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + return 0; +} + +qint64 SymbianAudioOutputPrivate::writeData(const char *data, qint64 len) +{ + qint64 totalWritten = 0; + + if (m_audioDevice->state() == QAudio::ActiveState || + m_audioDevice->state() == QAudio::IdleState) { + + while (totalWritten < len) { + const qint64 written = m_audioDevice->pushData(data + totalWritten, + len - totalWritten); + if (written > 0) + totalWritten += written; + else + break; + } + } + + return totalWritten; +} + + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, + const QAudioFormat &format) + : m_device(device) + , m_format(format) + , m_clientBufferSize(SymbianAudio::DefaultBufferSize) + , m_notifyInterval(SymbianAudio::DefaultNotifyInterval) + , m_notifyTimer(new QTimer(this)) + , m_error(QAudio::NoError) + , m_internalState(SymbianAudio::ClosedState) + , m_externalState(QAudio::StoppedState) + , m_pullMode(false) + , m_source(0) + , m_devSoundBuffer(0) + , m_devSoundBufferSize(0) + , m_bytesWritten(0) + , m_pushDataReady(false) + , m_bytesPadding(0) + , m_underflow(false) + , m_lastBuffer(false) + , m_underflowTimer(new QTimer(this)) + , m_samplesPlayed(0) + , m_totalSamplesPlayed(0) +{ + connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); + + SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, + m_nativeFormat); + + m_underflowTimer->setInterval(UnderflowTimerInterval); + connect(m_underflowTimer.data(), SIGNAL(timeout()), this, + SLOT(underflowTimerExpired())); +} + +QAudioOutputPrivate::~QAudioOutputPrivate() +{ + close(); +} + +QIODevice* QAudioOutputPrivate::start(QIODevice *device) +{ + stop(); + + // We have to set these before the call to open() because of the + // logic in initializingState() + if (device) { + m_pullMode = true; + m_source = device; + } + + open(); + + if (SymbianAudio::ClosedState != m_internalState) { + if (device) { + connect(m_source, SIGNAL(readyRead()), this, SLOT(dataReady())); + } else { + m_source = new SymbianAudioOutputPrivate(this); + m_source->open(QIODevice::WriteOnly | QIODevice::Unbuffered); + } + + m_elapsed.restart(); + } + + return m_source; +} + +void QAudioOutputPrivate::stop() +{ + close(); +} + +void QAudioOutputPrivate::reset() +{ + m_totalSamplesPlayed += getSamplesPlayed(); + m_devSound->Stop(); + m_bytesPadding = 0; + startPlayback(); +} + +void QAudioOutputPrivate::suspend() +{ + if (SymbianAudio::ActiveState == m_internalState + || SymbianAudio::IdleState == m_internalState) { + m_notifyTimer->stop(); + m_underflowTimer->stop(); + + const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples( + m_format, m_bytesWritten); + + 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(). + // Because this causes buffered data to be dropped, we replace the + // lost data with silence following a call to resume(), in order to + // ensure that processedUSecs() returns the correct value. + m_devSound->Stop(); + m_totalSamplesPlayed += samplesPlayed; + + // Calculate the amount of data dropped + const qint64 paddingSamples = samplesWritten - samplesPlayed; + m_bytesPadding = SymbianAudio::Utils::samplesToBytes(m_format, + paddingSamples); + + setState(SymbianAudio::SuspendedState); + } +} + +void QAudioOutputPrivate::resume() +{ + if (SymbianAudio::SuspendedState == m_internalState) + startPlayback(); +} + +int QAudioOutputPrivate::bytesFree() const +{ + int result = 0; + if (m_devSoundBuffer) { + const TDes8 &outputBuffer = m_devSoundBuffer->Data(); + result = outputBuffer.MaxLength() - outputBuffer.Length(); + } + return result; +} + +int QAudioOutputPrivate::periodSize() const +{ + return bufferSize(); +} + +void QAudioOutputPrivate::setBufferSize(int value) +{ + // Note that DevSound does not allow its client to specify the buffer size. + // This functionality is available via custom interfaces, but since these + // cannot be guaranteed to work across all DevSound implementations, we + // do not use them here. + // In order to comply with the expected bevahiour of QAudioOutput, we store + // the value and return it from bufferSize(), but the underlying DevSound + // buffer size remains unchanged. + if (value > 0) + m_clientBufferSize = value; +} + +int QAudioOutputPrivate::bufferSize() const +{ + return m_devSoundBufferSize ? m_devSoundBufferSize : m_clientBufferSize; +} + +void QAudioOutputPrivate::setNotifyInterval(int ms) +{ + if (ms > 0) { + const int oldNotifyInterval = m_notifyInterval; + m_notifyInterval = ms; + if (m_notifyTimer->isActive() && ms != oldNotifyInterval) + m_notifyTimer->start(m_notifyInterval); + } +} + +int QAudioOutputPrivate::notifyInterval() const +{ + return m_notifyInterval; +} + +qint64 QAudioOutputPrivate::processedUSecs() const +{ + int samplesPlayed = 0; + if (m_devSound && SymbianAudio::SuspendedState != m_internalState) + samplesPlayed = getSamplesPlayed(); + + // Protect against division by zero + Q_ASSERT_X(m_format.frequency() > 0, Q_FUNC_INFO, "Invalid frequency"); + + const qint64 result = qint64(1000000) * + (samplesPlayed + m_totalSamplesPlayed) + / m_format.frequency(); + + return result; +} + +qint64 QAudioOutputPrivate::elapsedUSecs() const +{ + const qint64 result = (QAudio::StoppedState == state()) ? + 0 : m_elapsed.elapsed() * 1000; + return result; +} + +QAudio::Error QAudioOutputPrivate::error() const +{ + return m_error; +} + +QAudio::State QAudioOutputPrivate::state() const +{ + return m_externalState; +} + +QAudioFormat QAudioOutputPrivate::format() const +{ + return m_format; +} + +//----------------------------------------------------------------------------- +// MDevSoundObserver implementation +//----------------------------------------------------------------------------- + +void QAudioOutputPrivate::InitializeComplete(TInt aError) +{ + Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, + Q_FUNC_INFO, "Invalid state"); + + if (KErrNone == aError) + startPlayback(); +} + +void QAudioOutputPrivate::ToneFinished(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound's tone playback functions, so should + // never receive this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioOutputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) +{ + // Following receipt of this callback, DevSound should not provide another + // buffer until we have returned the current one. + Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); + + // Will be returned to DevSound by bufferFilled(). + m_devSoundBuffer = static_cast(aBuffer); + + if (!m_devSoundBufferSize) + m_devSoundBufferSize = m_devSoundBuffer->Data().MaxLength(); + + writePaddingData(); + + if (m_pullMode && isDataReady() && !m_bytesPadding) + pullData(); +} + +void QAudioOutputPrivate::PlayError(TInt aError) +{ + switch (aError) { + case KErrUnderflow: + m_underflow = true; + if (m_pullMode && !m_lastBuffer) + setError(QAudio::UnderrunError); + else + setState(SymbianAudio::IdleState); + break; + default: + setError(QAudio::IOError); + break; + } +} + +void QAudioOutputPrivate::BufferToBeEmptied(CMMFBuffer *aBuffer) +{ + Q_UNUSED(aBuffer) + // This class doesn't use DevSound in record mode, so should never receive + // this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioOutputPrivate::RecordError(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound in record mode, so should never receive + // this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioOutputPrivate::ConvertError(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound's format conversion functions, so + // should never receive this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioOutputPrivate::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) +{ + Q_UNUSED(aMessageType) + Q_UNUSED(aMsg) + // Ignore this callback. +} + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void QAudioOutputPrivate::dataReady() +{ + // Client-provided QIODevice has data ready to read. + + Q_ASSERT_X(m_source->bytesAvailable(), Q_FUNC_INFO, + "readyRead signal received, but no data available"); + + if (!m_bytesPadding) + pullData(); +} + +void QAudioOutputPrivate::underflowTimerExpired() +{ + const TInt samplesPlayed = getSamplesPlayed(); + if (m_samplesPlayed && (samplesPlayed == m_samplesPlayed)) { + setError(QAudio::UnderrunError); + } else { + m_samplesPlayed = samplesPlayed; + m_underflowTimer->start(); + } +} + +void QAudioOutputPrivate::open() +{ + Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, + Q_FUNC_INFO, "DevSound already opened"); + + QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) + + QScopedPointer caps( + new SymbianAudio::DevSoundCapabilities(*m_devSound, + QAudio::AudioOutput)); + + int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? + KErrNone : KErrNotSupported; + + if (KErrNone == err) { + setState(SymbianAudio::InitializingState); + TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, + EMMFStatePlaying)); + } + + if (KErrNone != err) { + setError(QAudio::OpenError); + m_devSound.reset(); + } +} + +void QAudioOutputPrivate::startPlayback() +{ + TRAPD(err, startDevSoundL()); + if (KErrNone == err) { + if (isDataReady()) + setState(SymbianAudio::ActiveState); + else + setState(SymbianAudio::IdleState); + + m_notifyTimer->start(m_notifyInterval); + m_underflow = false; + + Q_ASSERT(m_devSound->SamplesPlayed() == 0); + + writePaddingData(); + + if (m_pullMode && m_source->bytesAvailable() && !m_bytesPadding) + dataReady(); + } else { + setError(QAudio::OpenError); + close(); + } +} + +void QAudioOutputPrivate::startDevSoundL() +{ + TMMFCapabilities nativeFormat = m_devSound->Config(); + m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; + m_devSound->SetConfigL(m_nativeFormat); + m_devSound->PlayInitL(); +} + +void QAudioOutputPrivate::writePaddingData() +{ + // See comments in suspend() + + while (m_devSoundBuffer && m_bytesPadding) { + if (SymbianAudio::IdleState == m_internalState) + setState(SymbianAudio::ActiveState); + + TDes8 &outputBuffer = m_devSoundBuffer->Data(); + const qint64 outputBytes = bytesFree(); + const qint64 paddingBytes = outputBytes < m_bytesPadding ? + outputBytes : m_bytesPadding; + unsigned char *ptr = const_cast(outputBuffer.Ptr()); + Mem::FillZ(ptr, paddingBytes); + outputBuffer.SetLength(outputBuffer.Length() + paddingBytes); + m_bytesPadding -= paddingBytes; + + if (m_pullMode && m_source->atEnd()) + lastBufferFilled(); + if (paddingBytes == outputBytes) + bufferFilled(); + } +} + +qint64 QAudioOutputPrivate::pushData(const char *data, qint64 len) +{ + // Data has been written to SymbianAudioOutputPrivate + + Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, + "pushData called when in pull mode"); + + const unsigned char *const inputPtr = + reinterpret_cast(data); + qint64 bytesWritten = 0; + + if (SymbianAudio::IdleState == m_internalState) + setState(SymbianAudio::ActiveState); + + while (m_devSoundBuffer && (bytesWritten < len)) { + // writePaddingData() is called from BufferToBeFilled(), so we should + // never have any padding data left at this point. + Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO, + "Padding bytes remaining in pushData"); + + TDes8 &outputBuffer = m_devSoundBuffer->Data(); + + const qint64 outputBytes = bytesFree(); + const qint64 inputBytes = len - bytesWritten; + const qint64 copyBytes = outputBytes < inputBytes ? + outputBytes : inputBytes; + + outputBuffer.Append(inputPtr + bytesWritten, copyBytes); + bytesWritten += copyBytes; + + bufferFilled(); + } + + m_pushDataReady = (bytesWritten < len); + + // If DevSound is still initializing (m_internalState == InitializingState), + // we cannot transition m_internalState to ActiveState, but we must emit + // an (external) state change from IdleState to ActiveState. The following + // call triggers this signal. + setState(m_internalState); + + return bytesWritten; +} + +void QAudioOutputPrivate::pullData() +{ + Q_ASSERT_X(m_pullMode, Q_FUNC_INFO, + "pullData called when in push mode"); + + if (m_bytesPadding) + m_bytesPadding = 1; + + // writePaddingData() is called by BufferToBeFilled() before pullData(), + // so we should never have any padding data left at this point. + Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO, + "Padding bytes remaining in pullData"); + + qint64 inputBytes = m_source->bytesAvailable(); + while (m_devSoundBuffer && inputBytes) { + if (SymbianAudio::IdleState == m_internalState) + setState(SymbianAudio::ActiveState); + + TDes8 &outputBuffer = m_devSoundBuffer->Data(); + + const qint64 outputBytes = bytesFree(); + const qint64 copyBytes = outputBytes < inputBytes ? + outputBytes : inputBytes; + + char *outputPtr = (char*)(outputBuffer.Ptr() + outputBuffer.Length()); + const qint64 bytesCopied = m_source->read(outputPtr, copyBytes); + Q_ASSERT(bytesCopied == copyBytes); + outputBuffer.SetLength(outputBuffer.Length() + bytesCopied); + inputBytes -= bytesCopied; + + if (m_source->atEnd()) + lastBufferFilled(); + else if (copyBytes == outputBytes) + bufferFilled(); + } +} + +void QAudioOutputPrivate::bufferFilled() +{ + Q_ASSERT_X(m_devSoundBuffer, Q_FUNC_INFO, "No buffer to return"); + + const TDes8 &outputBuffer = m_devSoundBuffer->Data(); + m_bytesWritten += outputBuffer.Length(); + + m_devSoundBuffer = 0; + + m_samplesPlayed = getSamplesPlayed(); + m_underflowTimer->start(); + + if (QAudio::UnderrunError == m_error) + m_error = QAudio::NoError; + + m_devSound->PlayData(); +} + +void QAudioOutputPrivate::lastBufferFilled() +{ + Q_ASSERT_X(m_devSoundBuffer, Q_FUNC_INFO, "No buffer to fill"); + Q_ASSERT_X(!m_lastBuffer, Q_FUNC_INFO, "Last buffer already sent"); + m_lastBuffer = true; + m_devSoundBuffer->SetLastBuffer(ETrue); + bufferFilled(); +} + +void QAudioOutputPrivate::close() +{ + m_notifyTimer->stop(); + m_underflowTimer->stop(); + + m_error = QAudio::NoError; + + if (m_devSound) + m_devSound->Stop(); + m_devSound.reset(); + m_devSoundBuffer = 0; + m_devSoundBufferSize = 0; + + if (!m_pullMode) // m_source is owned + delete m_source; + m_pullMode = false; + m_source = 0; + + m_bytesWritten = 0; + m_pushDataReady = false; + m_bytesPadding = 0; + m_underflow = false; + m_lastBuffer = false; + m_samplesPlayed = 0; + m_totalSamplesPlayed = 0; + + setState(SymbianAudio::ClosedState); +} + +qint64 QAudioOutputPrivate::getSamplesPlayed() const +{ + qint64 result = 0; + if (m_devSound) { + const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples( + m_format, m_bytesWritten); + + if (m_underflow) { + result = samplesWritten; + } else { + // This is necessary because some DevSound implementations report + // that they have played more data than has actually been provided to them + // by the client. + const qint64 devSoundSamplesPlayed(m_devSound->SamplesPlayed()); + result = qMin(devSoundSamplesPlayed, samplesWritten); + } + } + return result; +} + +void QAudioOutputPrivate::setError(QAudio::Error error) +{ + m_error = error; + + // Although no state transition actually occurs here, a stateChanged event + // must be emitted to inform the client that the call to start() was + // unsuccessful. + if (QAudio::OpenError == error) + emit stateChanged(QAudio::StoppedState); + + if (QAudio::UnderrunError == error) + setState(SymbianAudio::IdleState); + else + // Close the DevSound instance. This causes a transition to + // StoppedState. This must be done asynchronously in case the + // current function was called from a DevSound event handler, in which + // case deleting the DevSound instance may cause an exception. + QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); +} + +void QAudioOutputPrivate::setState(SymbianAudio::State newInternalState) +{ + const QAudio::State oldExternalState = m_externalState; + m_internalState = newInternalState; + m_externalState = SymbianAudio::Utils::stateNativeToQt( + m_internalState, initializingState()); + + if (m_externalState != oldExternalState) + emit stateChanged(m_externalState); +} + +bool QAudioOutputPrivate::isDataReady() const +{ + return (m_source && m_source->bytesAvailable()) + || m_bytesPadding + || m_pushDataReady; +} + +QAudio::State QAudioOutputPrivate::initializingState() const +{ + return isDataReady() ? QAudio::ActiveState : QAudio::IdleState; +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiooutput_symbian_p.h b/src/multimedia/audio/qaudiooutput_symbian_p.h new file mode 100644 index 0000000..00ccb24 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_symbian_p.h @@ -0,0 +1,210 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIOOUTPUT_SYMBIAN_P_H +#define QAUDIOOUTPUT_SYMBIAN_P_H + +#include +#include +#include +#include +#include "qaudio_symbian_p.h" + +QT_BEGIN_NAMESPACE + +class QAudioOutputPrivate; + +class SymbianAudioOutputPrivate : public QIODevice +{ + friend class QAudioOutputPrivate; + Q_OBJECT +public: + SymbianAudioOutputPrivate(QAudioOutputPrivate *audio); + ~SymbianAudioOutputPrivate(); + + qint64 readData(char *data, qint64 len); + qint64 writeData(const char *data, qint64 len); + +private: + QAudioOutputPrivate *const m_audioDevice; +}; + +class QAudioOutputPrivate + : public QAbstractAudioOutput + , public MDevSoundObserver +{ + friend class SymbianAudioOutputPrivate; + Q_OBJECT +public: + QAudioOutputPrivate(const QByteArray &device, + const QAudioFormat &audioFormat); + ~QAudioOutputPrivate(); + + // QAbstractAudioOutput + QIODevice* start(QIODevice *device = 0); + void stop(); + void reset(); + void suspend(); + void resume(); + int bytesFree() const; + int periodSize() const; + void setBufferSize(int value); + int bufferSize() const; + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + QAudio::Error error() const; + QAudio::State state() const; + QAudioFormat format() const; + + // MDevSoundObserver + void InitializeComplete(TInt aError); + void ToneFinished(TInt aError); + void BufferToBeFilled(CMMFBuffer *aBuffer); + void PlayError(TInt aError); + void BufferToBeEmptied(CMMFBuffer *aBuffer); + void RecordError(TInt aError); + void ConvertError(TInt aError); + void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); + +private slots: + void dataReady(); + void underflowTimerExpired(); + +private: + void open(); + void startPlayback(); + void startDevSoundL(); + void writePaddingData(); + qint64 pushData(const char *data, qint64 len); + void pullData(); + void bufferFilled(); + void lastBufferFilled(); + Q_INVOKABLE void close(); + + qint64 getSamplesPlayed() const; + + void setError(QAudio::Error error); + void setState(SymbianAudio::State state); + + bool isDataReady() const; + QAudio::State initializingState() const; + +private: + const QByteArray m_device; + const QAudioFormat m_format; + + int m_clientBufferSize; + int m_notifyInterval; + QScopedPointer m_notifyTimer; + QTime m_elapsed; + QAudio::Error m_error; + + SymbianAudio::State m_internalState; + QAudio::State m_externalState; + + bool m_pullMode; + QIODevice *m_source; + + QScopedPointer m_devSound; + TUint32 m_nativeFourCC; + TMMFCapabilities m_nativeFormat; + + // Buffer provided by DevSound, to be filled with data. + CMMFDataBuffer *m_devSoundBuffer; + + int m_devSoundBufferSize; + + // Number of bytes transferred from QIODevice to QAudioOutput. It is + // necessary to count this because data is dropped when suspend() is + // called. The difference between the position reported by DevSound and + // this value allows us to calculate m_bytesPadding; + quint32 m_bytesWritten; + + // True if client has provided data while the audio subsystem was not + // ready to consume it. + bool m_pushDataReady; + + // Number of zero bytes which will be written when client calls resume(). + quint32 m_bytesPadding; + + // True if PlayError(KErrUnderflow) has been called. + bool m_underflow; + + // True if a buffer marked with the "last buffer" flag has been provided + // to DevSound. + bool m_lastBuffer; + + // Some DevSound implementations ignore all underflow errors raised by the + // audio driver, unless the last buffer flag has been set by the client. + // In push-mode playback, this flag will never be set, so the underflow + // error will never be reported. In order to work around this, a timer + // is used, which gets reset every time the client provides more data. If + // the timer expires, an underflow error is raised by this object. + QScopedPointer m_underflowTimer; + + // Result of previous call to CMMFDevSound::SamplesPlayed(). This value is + // used to determine whether, when m_underflowTimer expires, an + // underflow error has actually occurred. + quint32 m_samplesPlayed; + + // Samples played up to the last call to suspend(). It is necessary + // to cache this because suspend() is implemented using + // CMMFDevSound::Stop(), which resets DevSound's SamplesPlayed() counter. + quint32 m_totalSamplesPlayed; + +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp new file mode 100644 index 0000000..a8aeb41 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -0,0 +1,604 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qaudiooutput_win32_p.h" + +//#define DEBUG_AUDIO 1 + +QT_BEGIN_NAMESPACE + +QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): + settings(audioFormat) +{ + bytesAvailable = 0; + buffer_size = 0; + period_size = 0; + m_device = device; + totalTimeValue = 0; + intervalTime = 1000; + audioBuffer = 0; + errorState = QAudio::NoError; + deviceState = QAudio::StoppedState; + audioSource = 0; + pullMode = true; + finished = false; +} + +QAudioOutputPrivate::~QAudioOutputPrivate() +{ + mutex.lock(); + finished = true; + mutex.unlock(); + + close(); +} + +void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, + DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ) +{ + Q_UNUSED(dwParam1) + Q_UNUSED(dwParam2) + Q_UNUSED(hWaveOut) + + QAudioOutputPrivate* qAudio; + qAudio = (QAudioOutputPrivate*)(dwInstance); + if(!qAudio) + return; + + QMutexLocker(&qAudio->mutex); + + switch(uMsg) { + case WOM_OPEN: + qAudio->feedback(); + break; + case WOM_CLOSE: + return; + case WOM_DONE: + if(qAudio->finished || qAudio->buffer_size == 0 || qAudio->period_size == 0) { + return; + } + qAudio->waveFreeBlockCount++; + if(qAudio->waveFreeBlockCount >= qAudio->buffer_size/qAudio->period_size) + qAudio->waveFreeBlockCount = qAudio->buffer_size/qAudio->period_size; + qAudio->feedback(); + break; + default: + return; + } +} + +WAVEHDR* QAudioOutputPrivate::allocateBlocks(int size, int count) +{ + int i; + unsigned char* buffer; + WAVEHDR* blocks; + DWORD totalBufferSize = (size + sizeof(WAVEHDR))*count; + + if((buffer=(unsigned char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, + totalBufferSize)) == 0) { + qWarning("QAudioOutput: Memory allocation error"); + return 0; + } + blocks = (WAVEHDR*)buffer; + buffer += sizeof(WAVEHDR)*count; + for(i = 0; i < count; i++) { + blocks[i].dwBufferLength = size; + blocks[i].lpData = (LPSTR)buffer; + buffer += size; + } + return blocks; +} + +void QAudioOutputPrivate::freeBlocks(WAVEHDR* blockArray) +{ + WAVEHDR* blocks = blockArray; + + int count = buffer_size/period_size; + + for(int i = 0; i < count; i++) { + waveOutUnprepareHeader(hWaveOut,blocks, sizeof(WAVEHDR)); + blocks+=sizeof(WAVEHDR); + } + HeapFree(GetProcessHeap(), 0, blockArray); +} + +QAudioFormat QAudioOutputPrivate::format() const +{ + return settings; +} + +QIODevice* QAudioOutputPrivate::start(QIODevice* device) +{ + if(deviceState != QAudio::StoppedState) + close(); + + if(!pullMode && audioSource) { + delete audioSource; + } + + if(device) { + //set to pull mode + pullMode = true; + audioSource = device; + deviceState = QAudio::ActiveState; + } else { + //set to push mode + pullMode = false; + audioSource = new OutputPrivate(this); + audioSource->open(QIODevice::WriteOnly|QIODevice::Unbuffered); + deviceState = QAudio::IdleState; + } + + if( !open() ) + return 0; + + emit stateChanged(deviceState); + + return audioSource; +} + +void QAudioOutputPrivate::stop() +{ + if(deviceState == QAudio::StoppedState) + return; + close(); + if(!pullMode && audioSource) { + delete audioSource; + audioSource = 0; + } + emit stateChanged(deviceState); +} + +bool QAudioOutputPrivate::open() +{ +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()<= 8000 && settings.frequency() <= 48000)) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + qWarning("QAudioOutput: open error, frequency out of range."); + return false; + } + if(buffer_size == 0) { + // Default buffer size, 200ms, default period size is 40ms + buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2; + period_size = buffer_size/5; + } else { + period_size = buffer_size/5; + } + waveBlocks = allocateBlocks(period_size, buffer_size/period_size); + + mutex.lock(); + waveFreeBlockCount = buffer_size/period_size; + mutex.unlock(); + + waveCurrentBlock = 0; + + if(audioBuffer == 0) + audioBuffer = new char[buffer_size]; + + timeStamp.restart(); + elapsedTimeOffset = 0; + + wfx.nSamplesPerSec = settings.frequency(); + wfx.wBitsPerSample = settings.sampleSize(); + wfx.nChannels = settings.channels(); + wfx.cbSize = 0; + + wfx.wFormatTag = WAVE_FORMAT_PCM; + wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels; + wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec; + + UINT_PTR devId = WAVE_MAPPER; + + WAVEOUTCAPS woc; + unsigned long iNumDevs,ii; + iNumDevs = waveOutGetNumDevs(); + for(ii=0;ii 0) { + mutex.lock(); + if(waveFreeBlockCount==0) { + mutex.unlock(); + break; + } + mutex.unlock(); + + if(current->dwFlags & WHDR_PREPARED) + waveOutUnprepareHeader(hWaveOut, current, sizeof(WAVEHDR)); + + if(l < period_size) + remain = l; + else + remain = period_size; + memcpy(current->lpData, p, remain); + + l -= remain; + p += remain; + current->dwBufferLength = remain; + waveOutPrepareHeader(hWaveOut, current, sizeof(WAVEHDR)); + waveOutWrite(hWaveOut, current, sizeof(WAVEHDR)); + + mutex.lock(); + waveFreeBlockCount--; +#ifdef DEBUG_AUDIO + qDebug("write out l=%d, waveFreeBlockCount=%d", + current->dwBufferLength,waveFreeBlockCount); +#endif + mutex.unlock(); + totalTimeValue += current->dwBufferLength; + waveCurrentBlock++; + waveCurrentBlock %= buffer_size/period_size; + current = &waveBlocks[waveCurrentBlock]; + current->dwUser = 0; + errorState = QAudio::NoError; + if (deviceState != QAudio::ActiveState) { + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + } + return (len-l); +} + +void QAudioOutputPrivate::resume() +{ + if(deviceState == QAudio::SuspendedState) { + deviceState = QAudio::ActiveState; + errorState = QAudio::NoError; + waveOutRestart(hWaveOut); + QTimer::singleShot(10, this, SLOT(feedback())); + emit stateChanged(deviceState); + } +} + +void QAudioOutputPrivate::suspend() +{ + if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState) { + int delay = (buffer_size-bytesFree())*1000/(settings.frequency() + *settings.channels()*(settings.sampleSize()/8)); + waveOutPause(hWaveOut); + Sleep(delay+10); + deviceState = QAudio::SuspendedState; + errorState = QAudio::NoError; + emit stateChanged(deviceState); + } +} + +void QAudioOutputPrivate::feedback() +{ +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()<= period_size) + QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection); + } +} + +bool QAudioOutputPrivate::deviceReady() +{ + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) + return false; + + if(pullMode) { + int chunks = bytesAvailable/period_size; +#ifdef DEBUG_AUDIO + qDebug()<<"deviceReady() avail="< intervalTime ) { + emit notify(); + elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; + timeStamp.restart(); + } + return true; + } + + if(startup) + waveOutPause(hWaveOut); + int input = period_size*chunks; + int l = audioSource->read(audioBuffer,input); + if(l > 0) { + int out= write(audioBuffer,l); + if(out > 0) { + if (deviceState != QAudio::ActiveState) { + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + } + if ( out < l) { + // Didnt write all data + audioSource->seek(audioSource->pos()-(l-out)); + } + if(startup) + waveOutRestart(hWaveOut); + } else if(l == 0) { + bytesAvailable = bytesFree(); + + int check = 0; + + mutex.lock(); + check = waveFreeBlockCount; + mutex.unlock(); + + if(check == buffer_size/period_size) { + if (deviceState != QAudio::IdleState) { + errorState = QAudio::UnderrunError; + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } + } + + } else if(l < 0) { + bytesAvailable = bytesFree(); + errorState = QAudio::IOError; + } + } else { + int buffered; + + mutex.lock(); + buffered = waveFreeBlockCount; + mutex.unlock(); + + if (buffered >= buffer_size/period_size && deviceState == QAudio::ActiveState) { + if (deviceState != QAudio::IdleState) { + errorState = QAudio::UnderrunError; + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } + } + } + if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) + return true; + + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { + emit notify(); + elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; + timeStamp.restart(); + } + + return true; +} + +qint64 QAudioOutputPrivate::elapsedUSecs() const +{ + if (deviceState == QAudio::StoppedState) + return 0; + + return timeStampOpened.elapsed()*1000; +} + +QAudio::Error QAudioOutputPrivate::error() const +{ + return errorState; +} + +QAudio::State QAudioOutputPrivate::state() const +{ + return deviceState; +} + +void QAudioOutputPrivate::reset() +{ + close(); +} + +OutputPrivate::OutputPrivate(QAudioOutputPrivate* audio) +{ + audioDevice = qobject_cast(audio); +} + +OutputPrivate::~OutputPrivate() {} + +qint64 OutputPrivate::readData( char* data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + + return 0; +} + +qint64 OutputPrivate::writeData(const char* data, qint64 len) +{ + int retry = 0; + qint64 written = 0; + + if((audioDevice->deviceState == QAudio::ActiveState) + ||(audioDevice->deviceState == QAudio::IdleState)) { + qint64 l = len; + while(written < l) { + int chunk = audioDevice->write(data+written,(l-written)); + if(chunk <= 0) + retry++; + else + written+=chunk; + + if(retry > 10) + return written; + } + audioDevice->deviceState = QAudio::ActiveState; + } + return written; +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h new file mode 100644 index 0000000..2d19225 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_win32_p.h @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIOOUTPUTWIN_H +#define QAUDIOOUTPUTWIN_H + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +QT_BEGIN_NAMESPACE + +class QAudioOutputPrivate : public QAbstractAudioOutput +{ + Q_OBJECT +public: + QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat); + ~QAudioOutputPrivate(); + + qint64 write( const char *data, qint64 len ); + + QAudioFormat format() const; + QIODevice* start(QIODevice* device = 0); + void stop(); + void reset(); + void suspend(); + void resume(); + int bytesFree() const; + int periodSize() const; + void setBufferSize(int value); + int bufferSize() const; + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + QAudio::Error error() const; + QAudio::State state() const; + + QIODevice* audioSource; + QAudioFormat settings; + QAudio::Error errorState; + QAudio::State deviceState; + +private slots: + void feedback(); + bool deviceReady(); + +private: + QByteArray m_device; + bool resuming; + int bytesAvailable; + QTime timeStamp; + qint64 elapsedTimeOffset; + QTime timeStampOpened; + qint32 buffer_size; + qint32 period_size; + qint64 totalTimeValue; + bool pullMode; + int intervalTime; + static void QT_WIN_CALLBACK waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, + DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); + + QMutex mutex; + + WAVEHDR* allocateBlocks(int size, int count); + void freeBlocks(WAVEHDR* blockArray); + bool open(); + void close(); + + WAVEFORMATEX wfx; + HWAVEOUT hWaveOut; + MMRESULT result; + WAVEHDR header; + WAVEHDR* waveBlocks; + volatile bool finished; + volatile int waveFreeBlockCount; + int waveCurrentBlock; + char* audioBuffer; +}; + +class OutputPrivate : public QIODevice +{ + Q_OBJECT +public: + OutputPrivate(QAudioOutputPrivate* audio); + ~OutputPrivate(); + + qint64 readData( char* data, qint64 len); + qint64 writeData(const char* data, qint64 len); + +private: + QAudioOutputPrivate *audioDevice; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/mediaservices/base/base.pri b/src/multimedia/mediaservices/base/base.pri deleted file mode 100644 index 49eca49..0000000 --- a/src/multimedia/mediaservices/base/base.pri +++ /dev/null @@ -1,69 +0,0 @@ - -QT += network -contains(QT_CONFIG, opengl):QT += opengl - -HEADERS += \ - $$PWD/qmediaresource.h \ - $$PWD/qmediacontent.h \ - $$PWD/qmediaobject.h \ - $$PWD/qmediaobject_p.h \ - $$PWD/qmediapluginloader_p.h \ - $$PWD/qmediaservice.h \ - $$PWD/qmediaservice_p.h \ - $$PWD/qmediaserviceprovider.h \ - $$PWD/qmediaserviceproviderplugin.h \ - $$PWD/qmediacontrol.h \ - $$PWD/qmediacontrol_p.h \ - $$PWD/qmetadatacontrol.h \ - $$PWD/qvideooutputcontrol.h \ - $$PWD/qvideowindowcontrol.h \ - $$PWD/qvideorenderercontrol.h \ - $$PWD/qvideodevicecontrol.h \ - $$PWD/qvideowidgetcontrol.h \ - $$PWD/qvideowidget.h \ - $$PWD/qvideowidget_p.h \ - $$PWD/qgraphicsvideoitem.h \ - $$PWD/qmediaplaylistcontrol.h \ - $$PWD/qmediaplaylist.h \ - $$PWD/qmediaplaylist_p.h \ - $$PWD/qmediaplaylistprovider.h \ - $$PWD/qmediaplaylistprovider_p.h \ - $$PWD/qmediaplaylistioplugin.h \ - $$PWD/qlocalmediaplaylistprovider.h \ - $$PWD/qmediaplaylistnavigator.h \ - $$PWD/qpaintervideosurface_p.h \ - $$PWD/qmediatimerange.h \ - $$PWD/qtmedianamespace.h - -SOURCES += \ - $$PWD/qmediaresource.cpp \ - $$PWD/qmediacontent.cpp \ - $$PWD/qmediaobject.cpp \ - $$PWD/qmediapluginloader.cpp \ - $$PWD/qmediaservice.cpp \ - $$PWD/qmediaserviceprovider.cpp \ - $$PWD/qmediacontrol.cpp \ - $$PWD/qmetadatacontrol.cpp \ - $$PWD/qvideooutputcontrol.cpp \ - $$PWD/qvideowindowcontrol.cpp \ - $$PWD/qvideorenderercontrol.cpp \ - $$PWD/qvideodevicecontrol.cpp \ - $$PWD/qvideowidgetcontrol.cpp \ - $$PWD/qvideowidget.cpp \ - $$PWD/qgraphicsvideoitem.cpp \ - $$PWD/qmediaplaylistcontrol.cpp \ - $$PWD/qmediaplaylist.cpp \ - $$PWD/qmediaplaylistprovider.cpp \ - $$PWD/qmediaplaylistioplugin.cpp \ - $$PWD/qlocalmediaplaylistprovider.cpp \ - $$PWD/qmediaplaylistnavigator.cpp \ - $$PWD/qpaintervideosurface.cpp \ - $$PWD/qmediatimerange.cpp - -mac { - HEADERS += $$PWD/qpaintervideosurface_mac_p.h - OBJECTIVE_SOURCES += $$PWD/qpaintervideosurface_mac.mm - - LIBS += -framework AppKit -framework QuartzCore -framework QTKit - -} diff --git a/src/multimedia/mediaservices/base/qgraphicsvideoitem.cpp b/src/multimedia/mediaservices/base/qgraphicsvideoitem.cpp deleted file mode 100644 index d80dec5..0000000 --- a/src/multimedia/mediaservices/base/qgraphicsvideoitem.cpp +++ /dev/null @@ -1,442 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaservies 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 - -#include -#include -#include -#include -#include -#include - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) -#include -#endif - -#ifndef QT_NO_GRAPHICSVIEW - -QT_BEGIN_NAMESPACE - - -class QGraphicsVideoItemPrivate -{ -public: - QGraphicsVideoItemPrivate() - : q_ptr(0) - , surface(0) - , mediaObject(0) - , service(0) - , outputControl(0) - , rendererControl(0) - , aspectRatioMode(Qt::KeepAspectRatio) - , updatePaintDevice(true) - , rect(0.0, 0.0, 320, 240) - { - } - - QGraphicsVideoItem *q_ptr; - - QPainterVideoSurface *surface; - QMediaObject *mediaObject; - QMediaService *service; - QVideoOutputControl *outputControl; - QVideoRendererControl *rendererControl; - Qt::AspectRatioMode aspectRatioMode; - bool updatePaintDevice; - QRectF rect; - QRectF boundingRect; - QRectF sourceRect; - QSizeF nativeSize; - - void clearService(); - void updateRects(); - - void _q_present(); - void _q_formatChanged(const QVideoSurfaceFormat &format); - void _q_serviceDestroyed(); - void _q_mediaObjectDestroyed(); -}; - -void QGraphicsVideoItemPrivate::clearService() -{ - if (outputControl) { - outputControl->setOutput(QVideoOutputControl::NoOutput); - outputControl = 0; - } - if (rendererControl) { - surface->stop(); - rendererControl->setSurface(0); - rendererControl = 0; - } - if (service) { - QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed())); - service = 0; - } -} - -void QGraphicsVideoItemPrivate::updateRects() -{ - q_ptr->prepareGeometryChange(); - - if (nativeSize.isEmpty()) { - boundingRect = QRectF(); - } else if (aspectRatioMode == Qt::IgnoreAspectRatio) { - boundingRect = rect; - sourceRect = QRectF(0, 0, 1, 1); - } else if (aspectRatioMode == Qt::KeepAspectRatio) { - QSizeF size = nativeSize; - size.scale(rect.size(), Qt::KeepAspectRatio); - - boundingRect = QRectF(0, 0, size.width(), size.height()); - boundingRect.moveCenter(rect.center()); - - sourceRect = QRectF(0, 0, 1, 1); - } else if (aspectRatioMode == Qt::KeepAspectRatioByExpanding) { - boundingRect = rect; - - QSizeF size = rect.size(); - size.scale(nativeSize, Qt::KeepAspectRatio); - - sourceRect = QRectF( - 0, 0, size.width() / nativeSize.width(), size.height() / nativeSize.height()); - sourceRect.moveCenter(QPointF(0.5, 0.5)); - } -} - -void QGraphicsVideoItemPrivate::_q_present() -{ - if (q_ptr->isObscured()) { - q_ptr->update(boundingRect); - surface->setReady(true); - } else { - q_ptr->update(boundingRect); - } -} - -void QGraphicsVideoItemPrivate::_q_formatChanged(const QVideoSurfaceFormat &format) -{ - nativeSize = format.sizeHint(); - - updateRects(); - - emit q_ptr->nativeSizeChanged(nativeSize); -} - -void QGraphicsVideoItemPrivate::_q_serviceDestroyed() -{ - rendererControl = 0; - outputControl = 0; - service = 0; - - surface->stop(); -} - -void QGraphicsVideoItemPrivate::_q_mediaObjectDestroyed() -{ - mediaObject = 0; - - clearService(); -} - -/*! - \class QGraphicsVideoItem - \brief The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaObject. - - \since 4.7 - - \ingroup multimedia - - Attaching a QGraphicsVideoItem to a QMediaObject allows it to display - the video or image output of that media object. A QGraphicsVideoItem - is attached to a media object by passing a pointer to the QMediaObject - to the setMediaObject() function. - - \code - player = new QMediaPlayer(this); - - QGraphicsVideoItem *item = new QGraphicsVideoItem; - item->setMediaObject(player); - graphicsView->scence()->addItem(item); - graphicsView->show(); - - player->setMedia(video); - player->play(); - \endcode - - \bold {Note}: Only a single display output can be attached to a media - object at one time. - - \sa QMediaObject, QMediaPlayer, QVideoWidget -*/ - -/*! - Constructs a graphics item that displays video. - - The \a parent is passed to QGraphicsItem. -*/ -QGraphicsVideoItem::QGraphicsVideoItem(QGraphicsItem *parent) - : QGraphicsObject(parent) - , d_ptr(new QGraphicsVideoItemPrivate) -{ - d_ptr->q_ptr = this; - d_ptr->surface = new QPainterVideoSurface; - - connect(d_ptr->surface, SIGNAL(frameChanged()), this, SLOT(_q_present())); - connect(d_ptr->surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SLOT(_q_formatChanged(QVideoSurfaceFormat))); -} - -/*! - Destroys a video graphics item. -*/ -QGraphicsVideoItem::~QGraphicsVideoItem() -{ - if (d_ptr->outputControl) - d_ptr->outputControl->setOutput(QVideoOutputControl::NoOutput); - - if (d_ptr->rendererControl) - d_ptr->rendererControl->setSurface(0); - - delete d_ptr->surface; - delete d_ptr; -} - -/*! - \property QGraphicsVideoItem::mediaObject - \brief the media object which provides the video displayed by a graphics - item. -*/ - -QMediaObject *QGraphicsVideoItem::mediaObject() const -{ - return d_func()->mediaObject; -} - -void QGraphicsVideoItem::setMediaObject(QMediaObject *object) -{ - Q_D(QGraphicsVideoItem); - - if (object == d->mediaObject) - return; - - d->clearService(); - - if (d->mediaObject) { - disconnect(d->mediaObject, SIGNAL(destroyed()), this, SLOT(_q_mediaObjectDestroyed())); - d->mediaObject->unbind(this); - } - - d->mediaObject = object; - - if (d->mediaObject) { - d->mediaObject->bind(this); - - connect(d->mediaObject, SIGNAL(destroyed()), this, SLOT(_q_mediaObjectDestroyed())); - - d->service = d->mediaObject->service(); - - if (d->service) { - connect(d->service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); - - d->outputControl = qobject_cast( - d->service->control(QVideoOutputControl_iid)); - d->rendererControl = qobject_cast( - d->service->control(QVideoRendererControl_iid)); - - if (d->outputControl != 0 && d->rendererControl != 0) { - d->rendererControl->setSurface(d->surface); - - if (isVisible()) - d->outputControl->setOutput(QVideoOutputControl::RendererOutput); - } - } - } -} - -/*! - \property QGraphicsVideoItem::aspectRatioMode - \brief how a video is scaled to fit the graphics item's size. -*/ - -Qt::AspectRatioMode QGraphicsVideoItem::aspectRatioMode() const -{ - return d_func()->aspectRatioMode; -} - -void QGraphicsVideoItem::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - Q_D(QGraphicsVideoItem); - - d->aspectRatioMode = mode; - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::offset - \brief the video item's offset. - - QGraphicsVideoItem will draw video using the offset for its top left - corner. -*/ - -QPointF QGraphicsVideoItem::offset() const -{ - return d_func()->rect.topLeft(); -} - -void QGraphicsVideoItem::setOffset(const QPointF &offset) -{ - Q_D(QGraphicsVideoItem); - - d->rect.moveTo(offset); - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::size - \brief the video item's size. - - QGraphicsVideoItem will draw video scaled to fit size according to its - fillMode. -*/ - -QSizeF QGraphicsVideoItem::size() const -{ - return d_func()->rect.size(); -} - -void QGraphicsVideoItem::setSize(const QSizeF &size) -{ - Q_D(QGraphicsVideoItem); - - d->rect.setSize(size.isValid() ? size : QSizeF(0, 0)); - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::nativeSize - \brief the native size of the video. -*/ - -QSizeF QGraphicsVideoItem::nativeSize() const -{ - return d_func()->nativeSize; -} - -/*! - \fn QGraphicsVideoItem::nativeSizeChanged(const QSizeF &size) - - Signals that the native \a size of the video has changed. -*/ - -/*! - \reimp -*/ -QRectF QGraphicsVideoItem::boundingRect() const -{ - return d_func()->boundingRect; -} - -/*! - \reimp -*/ -void QGraphicsVideoItem::paint( - QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_D(QGraphicsVideoItem); - - Q_UNUSED(option); - Q_UNUSED(widget); - - if (d->surface && d->surface->isActive()) { - d->surface->paint(painter, d->boundingRect, d->sourceRect); - d->surface->setReady(true); -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - } else if (d->updatePaintDevice && (painter->paintEngine()->type() == QPaintEngine::OpenGL - || painter->paintEngine()->type() == QPaintEngine::OpenGL2)) { - d->updatePaintDevice = false; - - d->surface->setGLContext(const_cast(QGLContext::currentContext())); - if (d->surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { - d->surface->setShaderType(QPainterVideoSurface::GlslShader); - } else { - d->surface->setShaderType(QPainterVideoSurface::FragmentProgramShader); - } -#endif - } -} - -/*! - \reimp - - \internal -*/ -QVariant QGraphicsVideoItem::itemChange(GraphicsItemChange change, const QVariant &value) -{ - return QGraphicsObject::itemChange(change, value); -} - -/*! - \reimp - - \internal -*/ -bool QGraphicsVideoItem::event(QEvent *event) -{ - return QGraphicsObject::event(event); -} - -/*! - \reimp - - \internal -*/ -bool QGraphicsVideoItem::sceneEvent(QEvent *event) -{ - return QGraphicsObject::sceneEvent(event); -} - -QT_END_NAMESPACE - -#endif // QT_NO_GRAPHICSVIEW - -#include "moc_qgraphicsvideoitem.cpp" diff --git a/src/multimedia/mediaservices/base/qgraphicsvideoitem.h b/src/multimedia/mediaservices/base/qgraphicsvideoitem.h deleted file mode 100644 index 679b353..0000000 --- a/src/multimedia/mediaservices/base/qgraphicsvideoitem.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QGRAPHICSVIDEOITEM_H -#define QGRAPHICSVIDEOITEM_H - -#include - -#include - -#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QVideoSurfaceFormat; - -class QGraphicsVideoItemPrivate; -class Q_MEDIASERVICES_EXPORT QGraphicsVideoItem : public QGraphicsObject -{ - Q_OBJECT - Q_PROPERTY(QMediaObject* mediaObject READ mediaObject WRITE setMediaObject) - Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode) - Q_PROPERTY(QPointF offset READ offset WRITE setOffset) - Q_PROPERTY(QSizeF size READ size WRITE setSize) - Q_PROPERTY(QSizeF nativeSize READ nativeSize NOTIFY nativeSizeChanged) -public: - QGraphicsVideoItem(QGraphicsItem *parent = 0); - ~QGraphicsVideoItem(); - - QMediaObject *mediaObject() const; - void setMediaObject(QMediaObject *object); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - QPointF offset() const; - void setOffset(const QPointF &offset); - - QSizeF size() const; - void setSize(const QSizeF &size); - - QSizeF nativeSize() const; - - QRectF boundingRect() const; - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -Q_SIGNALS: - void nativeSizeChanged(const QSizeF &size); - -protected: - bool event(QEvent *event); - bool sceneEvent(QEvent *event); - - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - - QGraphicsVideoItemPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QGraphicsVideoItem) - Q_PRIVATE_SLOT(d_func(), void _q_present()) - Q_PRIVATE_SLOT(d_func(), void _q_formatChanged(const QVideoSurfaceFormat &)) - Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) - Q_PRIVATE_SLOT(d_func(), void _q_mediaObjectDestroyed()) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QT_NO_GRAPHICSVIEW - -#endif diff --git a/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.cpp b/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.cpp deleted file mode 100644 index 51e3bfb..0000000 --- a/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include "qmediaplaylistprovider_p.h" -#include - - -QT_BEGIN_NAMESPACE - -class QLocalMediaPlaylistProviderPrivate: public QMediaPlaylistProviderPrivate -{ -public: - QList resources; -}; - -QLocalMediaPlaylistProvider::QLocalMediaPlaylistProvider(QObject *parent) - :QMediaPlaylistProvider(*new QLocalMediaPlaylistProviderPrivate, parent) -{ -} - -QLocalMediaPlaylistProvider::~QLocalMediaPlaylistProvider() -{ -} - -bool QLocalMediaPlaylistProvider::isReadOnly() const -{ - return false; -} - -int QLocalMediaPlaylistProvider::mediaCount() const -{ - return d_func()->resources.size(); -} - -QMediaContent QLocalMediaPlaylistProvider::media(int pos) const -{ - return d_func()->resources.value(pos); -} - -bool QLocalMediaPlaylistProvider::addMedia(const QMediaContent &content) -{ - Q_D(QLocalMediaPlaylistProvider); - - int pos = d->resources.count(); - - emit mediaAboutToBeInserted(pos, pos); - d->resources.append(content); - emit mediaInserted(pos, pos); - - return true; -} - -bool QLocalMediaPlaylistProvider::addMedia(const QList &items) -{ - Q_D(QLocalMediaPlaylistProvider); - - if (items.isEmpty()) - return true; - - int pos = d->resources.count(); - int end = pos+items.count()-1; - - emit mediaAboutToBeInserted(pos, end); - d->resources.append(items); - emit mediaInserted(pos, end); - - return true; -} - - -bool QLocalMediaPlaylistProvider::insertMedia(int pos, const QMediaContent &content) -{ - Q_D(QLocalMediaPlaylistProvider); - - emit mediaAboutToBeInserted(pos, pos); - d->resources.insert(pos, content); - emit mediaInserted(pos,pos); - - return true; -} - -bool QLocalMediaPlaylistProvider::insertMedia(int pos, const QList &items) -{ - Q_D(QLocalMediaPlaylistProvider); - - if (items.isEmpty()) - return true; - - const int last = pos+items.count()-1; - - emit mediaAboutToBeInserted(pos, last); - for (int i=0; iresources.insert(pos+i, items.at(i)); - emit mediaInserted(pos, last); - - return true; -} - -bool QLocalMediaPlaylistProvider::removeMedia(int fromPos, int toPos) -{ - Q_D(QLocalMediaPlaylistProvider); - - Q_ASSERT(fromPos >= 0); - Q_ASSERT(fromPos <= toPos); - Q_ASSERT(toPos < mediaCount()); - - emit mediaAboutToBeRemoved(fromPos, toPos); - d->resources.erase(d->resources.begin()+fromPos, d->resources.begin()+toPos+1); - emit mediaRemoved(fromPos, toPos); - - return true; -} - -bool QLocalMediaPlaylistProvider::removeMedia(int pos) -{ - Q_D(QLocalMediaPlaylistProvider); - - emit mediaAboutToBeRemoved(pos, pos); - d->resources.removeAt(pos); - emit mediaRemoved(pos, pos); - - return true; -} - -bool QLocalMediaPlaylistProvider::clear() -{ - Q_D(QLocalMediaPlaylistProvider); - if (!d->resources.isEmpty()) { - int lastPos = mediaCount()-1; - emit mediaAboutToBeRemoved(0, lastPos); - d->resources.clear(); - emit mediaRemoved(0, lastPos); - } - - return true; -} - -void QLocalMediaPlaylistProvider::shuffle() -{ - Q_D(QLocalMediaPlaylistProvider); - if (!d->resources.isEmpty()) { - QList resources; - - while (!d->resources.isEmpty()) { - resources.append(d->resources.takeAt(qrand() % d->resources.size())); - } - - d->resources = resources; - emit mediaChanged(0, mediaCount()-1); - } - -} - -#include "moc_qlocalmediaplaylistprovider.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.h b/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.h deleted file mode 100644 index 4dd53df..0000000 --- a/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QLOCALMEDIAPAYLISTPROVIDER_H -#define QLOCALMEDIAPAYLISTPROVIDER_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QLocalMediaPlaylistProviderPrivate; -class Q_MEDIASERVICES_EXPORT QLocalMediaPlaylistProvider : public QMediaPlaylistProvider -{ - Q_OBJECT - -public: - QLocalMediaPlaylistProvider(QObject *parent=0); - virtual ~QLocalMediaPlaylistProvider(); - - virtual int mediaCount() const; - virtual QMediaContent media(int pos) const; - - virtual bool isReadOnly() const; - - virtual bool addMedia(const QMediaContent &content); - virtual bool addMedia(const QList &items); - virtual bool insertMedia(int pos, const QMediaContent &content); - virtual bool insertMedia(int pos, const QList &items); - virtual bool removeMedia(int pos); - virtual bool removeMedia(int start, int end); - virtual bool clear(); - -public Q_SLOTS: - virtual void shuffle(); - -private: - Q_DECLARE_PRIVATE(QLocalMediaPlaylistProvider) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QLOCALMEDIAPAYLISTSOURCE_H diff --git a/src/multimedia/mediaservices/base/qmediacontent.cpp b/src/multimedia/mediaservices/base/qmediacontent.cpp deleted file mode 100644 index 50d8e46..0000000 --- a/src/multimedia/mediaservices/base/qmediacontent.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include - -#include - - -QT_BEGIN_NAMESPACE - - -class QMediaContentPrivate : public QSharedData -{ -public: - QMediaContentPrivate() {} - QMediaContentPrivate(const QMediaResourceList &r): - resources(r) {} - - QMediaContentPrivate(const QMediaContentPrivate &other): - QSharedData(other), - resources(other.resources) - {} - - bool operator==(const QMediaContentPrivate &other) const - { - return resources == other.resources; - } - - QMediaResourceList resources; - -private: - QMediaContentPrivate& operator=(const QMediaContentPrivate &other); -}; - - -/*! - \class QMediaContent - \preliminary - \brief The QMediaContent class provides access to the resources relating to a media content. - \since 4.7 - - \ingroup multimedia - - QMediaContent is used within the multimedia framework as the logical handle - to media content. A QMediaContent object is composed of one or more - \l {QMediaResource}s where each resource provides the URL and format - information of a different encoding of the content. - - A non-null QMediaContent will always have a primary or canonical reference to - the content available through the canonicalUrl() or canonicalResource() - methods, any additional resources are optional. -*/ - - -/*! - Constructs a null QMediaContent. -*/ - -QMediaContent::QMediaContent() -{ -} - -/*! - Constructs a media content with \a url providing a reference to the content. -*/ - -QMediaContent::QMediaContent(const QUrl &url): - d(new QMediaContentPrivate) -{ - d->resources << QMediaResource(url); -} - -/*! - Constructs a media content with \a request providing a reference to the content. - - This constructor can be used to reference media content via network protocols such as HTTP. - This may include additional information required to obtain the resource, such as Cookies or HTTP headers. -*/ - -QMediaContent::QMediaContent(const QNetworkRequest &request): - d(new QMediaContentPrivate) -{ - d->resources << QMediaResource(request); -} - -/*! - Constructs a media content with \a resource providing a reference to the content. -*/ - -QMediaContent::QMediaContent(const QMediaResource &resource): - d(new QMediaContentPrivate) -{ - d->resources << resource; -} - -/*! - Constructs a media content with \a resources providing a reference to the content. -*/ - -QMediaContent::QMediaContent(const QMediaResourceList &resources): - d(new QMediaContentPrivate(resources)) -{ -} - -/*! - Constructs a copy of the media content \a other. -*/ - -QMediaContent::QMediaContent(const QMediaContent &other): - d(other.d) -{ -} - -/*! - Destroys the media content object. -*/ - -QMediaContent::~QMediaContent() -{ -} - -/*! - Assigns the value of \a other to this media content. -*/ - -QMediaContent& QMediaContent::operator=(const QMediaContent &other) -{ - d = other.d; - return *this; -} - -/*! - Returns true if \a other is equivalent to this media content; false otherwise. -*/ - -bool QMediaContent::operator==(const QMediaContent &other) const -{ - return (d.constData() == 0 && other.d.constData() == 0) || - (d.constData() != 0 && other.d.constData() != 0 && - *d.constData() == *other.d.constData()); -} - -/*! - Returns true if \a other is not equivalent to this media content; false otherwise. -*/ - -bool QMediaContent::operator!=(const QMediaContent &other) const -{ - return !(*this == other); -} - -/*! - Returns true if this media content is null (uninitialized); false otherwise. -*/ - -bool QMediaContent::isNull() const -{ - return d.constData() == 0; -} - -/*! - Returns a QUrl that represents that canonical resource for this media content. -*/ - -QUrl QMediaContent::canonicalUrl() const -{ - return canonicalResource().url(); -} - -/*! - Returns a QNetworkRequest that represents that canonical resource for this media content. -*/ - -QNetworkRequest QMediaContent::canonicalRequest() const -{ - return canonicalResource().request(); -} - -/*! - Returns a QMediaResource that represents that canonical resource for this media content. -*/ - -QMediaResource QMediaContent::canonicalResource() const -{ - return d.constData() != 0 - ? d->resources.value(0) - : QMediaResource(); -} - -/*! - Returns a list of alternative resources for this media content. The first item in this list - is always the canonical resource. -*/ - -QMediaResourceList QMediaContent::resources() const -{ - return d.constData() != 0 - ? d->resources - : QMediaResourceList(); -} - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediacontent.h b/src/multimedia/mediaservices/base/qmediacontent.h deleted file mode 100644 index c00e443..0000000 --- a/src/multimedia/mediaservices/base/qmediacontent.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIACONTENT_H -#define QMEDIACONTENT_H - -#include -#include - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaContentPrivate; -class Q_MEDIASERVICES_EXPORT QMediaContent -{ -public: - QMediaContent(); - QMediaContent(const QUrl &contentUrl); - QMediaContent(const QNetworkRequest &contentRequest); - QMediaContent(const QMediaResource &contentResource); - QMediaContent(const QMediaResourceList &resources); - QMediaContent(const QMediaContent &other); - ~QMediaContent(); - - QMediaContent& operator=(const QMediaContent &other); - - bool operator==(const QMediaContent &other) const; - bool operator!=(const QMediaContent &other) const; - - bool isNull() const; - - QUrl canonicalUrl() const; - QNetworkRequest canonicalRequest() const; - QMediaResource canonicalResource() const; - - QMediaResourceList resources() const; - -private: - QSharedDataPointer d; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaContent) - -QT_END_HEADER - -#endif // QMEDIACONTENT_H diff --git a/src/multimedia/mediaservices/base/qmediacontrol.cpp b/src/multimedia/mediaservices/base/qmediacontrol.cpp deleted file mode 100644 index 09996c8..0000000 --- a/src/multimedia/mediaservices/base/qmediacontrol.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include - -#include -#include - - - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaControl - \ingroup multimedia-serv - \since 4.7 - - \preliminary - \brief The QMediaControl class provides a base interface for media service controls. - - Media controls provide an interface to individual features provided by a media service. Most - services implement a principal control which exposes the core functionality of the service and - a number optional controls which expose any additional functionality. - - A pointer to a control implemented by a media service can be obtained using the - \l {QMediaService::control()}{control()} member of QMediaService. If the service doesn't - implement a control it will instead return a null pointer. - - \code - QMediaPlayerControl *control = qobject_cast( - service->control("com.nokia.Qt.QMediaPlayerControl/1.0")); - \endcode - - Alternatively if the IId of the control has been declared using Q_MEDIA_DECLARE_CONTROL - the template version of QMediaService::control() can be used to request the service without - explicitly passing the IId. - - \code - QMediaPlayerControl *control = service->control(); - \endcode - - Most application code will not interface directly with a media service's controls, instead the - QMediaObject which owns the service acts as an intermeditary between one or more controls and - the application. - - \sa QMediaService, QMediaObject -*/ - -/*! - \macro Q_MEDIA_DECLARE_CONTROL(Class, IId) - \relates QMediaControl - - The Q_MEDIA_DECLARE_CONTROL macro declares an \a IId for a \a Class that inherits from - QMediaControl. - - Declaring an IId for a QMediaControl allows an instance of that control to be requested from - QMediaService::control() without explicitly passing the IId. - - \code - QMediaPlayerControl *control = service->control(); - \endcode - - \sa QMediaService::control() -*/ - -/*! - Destroys a media control. -*/ - -QMediaControl::~QMediaControl() -{ - delete d_ptr; -} - -/*! - Constructs a media control with the given \a parent. -*/ - -QMediaControl::QMediaControl(QObject *parent) - : QObject(parent) - , d_ptr(new QMediaControlPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - \internal -*/ - -QMediaControl::QMediaControl(QMediaControlPrivate &dd, QObject *parent) - : QObject(parent) - , d_ptr(&dd) - -{ - d_ptr->q_ptr = this; -} - -#include "moc_qmediacontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediacontrol.h b/src/multimedia/mediaservices/base/qmediacontrol.h deleted file mode 100644 index 941c004..0000000 --- a/src/multimedia/mediaservices/base/qmediacontrol.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QABSTRACTMEDIACONTROL_H -#define QABSTRACTMEDIACONTROL_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaControlPrivate; -class Q_MEDIASERVICES_EXPORT QMediaControl : public QObject -{ - Q_OBJECT - -public: - ~QMediaControl(); - -protected: - QMediaControl(QObject *parent = 0); - QMediaControl(QMediaControlPrivate &dd, QObject *parent = 0); - - QMediaControlPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QMediaControl) -}; - -template const char *qmediacontrol_iid() { return 0; } - -#define Q_MEDIA_DECLARE_CONTROL(Class, IId) \ - template <> inline const char *qmediacontrol_iid() { return IId; } - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QABSTRACTMEDIACONTROL_H diff --git a/src/multimedia/mediaservices/base/qmediacontrol_p.h b/src/multimedia/mediaservices/base/qmediacontrol_p.h deleted file mode 100644 index 3f9755b..0000000 --- a/src/multimedia/mediaservices/base/qmediacontrol_p.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QABSTRACTMEDIACONTROL_P_H -#define QABSTRACTMEDIACONTROL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaControl; - -class QMediaControlPrivate -{ -public: - virtual ~QMediaControlPrivate() {} - - QMediaControl *q_ptr; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qmediaobject.cpp b/src/multimedia/mediaservices/base/qmediaobject.cpp deleted file mode 100644 index 68fb29e..0000000 --- a/src/multimedia/mediaservices/base/qmediaobject.cpp +++ /dev/null @@ -1,419 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaservics 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 - -#include "qmediaobject_p.h" - -#include -#include - - -QT_BEGIN_NAMESPACE - -void QMediaObjectPrivate::_q_notify() -{ - Q_Q(QMediaObject); - - const QMetaObject* m = q->metaObject(); - - foreach (int pi, notifyProperties) { - QMetaProperty p = m->property(pi); - p.notifySignal().invoke( - q, QGenericArgument(QMetaType::typeName(p.userType()), p.read(q).data())); - } -} - - -/*! - \class QMediaObject - \preliminary - \brief The QMediaObject class provides a common base for multimedia objects. - \since 4.7 - - \ingroup multimedia - - QMediaObject derived classes provide access to the functionality of a - QMediaService. Each media object hosts a QMediaService and uses the - QMediaControl interfaces implemented by the service to implement its - API. Most media objects when constructed will request a new - QMediaService instance from a QMediaServiceProvider, but some like - QMediaRecorder will share a service with another object. - - QMediaObject itself provides an API for accessing a media service's \l {metaData()}{meta-data} and a means of connecting other media objects, - and peripheral classes like QVideoWidget and QMediaPlaylist. - - \sa QMediaService, QMediaControl -*/ - -/*! - Destroys a media object. -*/ - -QMediaObject::~QMediaObject() -{ - delete d_ptr; -} - -/*! - Returns the service availability error state. -*/ - -QtMediaServices::AvailabilityError QMediaObject::availabilityError() const -{ - return QtMediaServices::ServiceMissingError; -} - -/*! - Returns true if the service is available for use. -*/ - -bool QMediaObject::isAvailable() const -{ - return false; -} - -/*! - Returns the media service that provides the functionality of a multimedia object. -*/ - -QMediaService* QMediaObject::service() const -{ - return d_func()->service; -} - -int QMediaObject::notifyInterval() const -{ - return d_func()->notifyTimer->interval(); -} - -void QMediaObject::setNotifyInterval(int milliSeconds) -{ - Q_D(QMediaObject); - - if (d->notifyTimer->interval() != milliSeconds) { - d->notifyTimer->setInterval(milliSeconds); - - emit notifyIntervalChanged(milliSeconds); - } -} - -/*! - \internal -*/ -void QMediaObject::bind(QObject*) -{ -} - -/*! - \internal -*/ -void QMediaObject::unbind(QObject*) -{ -} - - -/*! - Constructs a media object which uses the functionality provided by a media \a service. - - The \a parent is passed to QObject. - - This class is meant as a base class for Multimedia objects so this - constructor is protected. -*/ - -QMediaObject::QMediaObject(QObject *parent, QMediaService *service): - QObject(parent), - d_ptr(new QMediaObjectPrivate) - -{ - Q_D(QMediaObject); - - d->q_ptr = this; - - d->notifyTimer = new QTimer(this); - d->notifyTimer->setInterval(1000); - connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); - - d->service = service; - - setupMetaData(); -} - -/*! - \internal -*/ - -QMediaObject::QMediaObject(QMediaObjectPrivate &dd, QObject *parent, - QMediaService *service): - QObject(parent), - d_ptr(&dd) -{ - Q_D(QMediaObject); - d->q_ptr = this; - - d->notifyTimer = new QTimer(this); - d->notifyTimer->setInterval(1000); - connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); - - d->service = service; - - setupMetaData(); -} - -/*! - Watch the property \a name. The property's notify signal will be emitted - once every notifyInterval milliseconds. - - \sa notifyInterval -*/ - -void QMediaObject::addPropertyWatch(QByteArray const &name) -{ - Q_D(QMediaObject); - - const QMetaObject* m = metaObject(); - - int index = m->indexOfProperty(name.constData()); - - if (index != -1 && m->property(index).hasNotifySignal()) { - d->notifyProperties.insert(index); - - if (!d->notifyTimer->isActive()) - d->notifyTimer->start(); - } -} - -/*! - Remove property \a name from the list of properties whose changes are - regularly signaled. - - \sa notifyInterval -*/ - -void QMediaObject::removePropertyWatch(QByteArray const &name) -{ - Q_D(QMediaObject); - - int index = metaObject()->indexOfProperty(name.constData()); - - if (index != -1) { - d->notifyProperties.remove(index); - - if (d->notifyProperties.isEmpty()) - d->notifyTimer->stop(); - } -} - -/*! - \property QMediaObject::notifyInterval - - The interval at which notifiable properties will update. - - The interval is expressed in milliseconds, the default value is 1000. - - \sa addPropertyWatch(), removePropertyWatch() -*/ - -/*! - \fn void QMediaObject::notifyIntervalChanged(int milliseconds) - - Signal a change in the notify interval period to \a milliseconds. -*/ - -/*! - \property QMediaObject::metaDataAvailable - \brief whether access to a media object's meta-data is available. - - If this is true there is meta-data available, otherwise there is no meta-data available. -*/ - -bool QMediaObject::isMetaDataAvailable() const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->isMetaDataAvailable() - : false; -} - -/*! - \fn QMediaObject::metaDataAvailableChanged(bool available) - - Signals that the \a available state of a media object's meta-data has changed. -*/ - -/*! - \property QMediaObject::metaDataWritable - \brief whether a media object's meta-data is writable. - - If this is true the meta-data is writable, otherwise the meta-data is read-only. -*/ - -bool QMediaObject::isMetaDataWritable() const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->isWritable() - : false; -} - -/*! - \fn QMediaObject::metaDataWritableChanged(bool writable) - - Signals that the \a writable state of a media object's meta-data has changed. -*/ - -/*! - Returns the value associated with a meta-data \a key. -*/ -QVariant QMediaObject::metaData(QtMediaServices::MetaData key) const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->metaData(key) - : QVariant(); -} - -/*! - Sets a \a value for a meta-data \a key. -*/ -void QMediaObject::setMetaData(QtMediaServices::MetaData key, const QVariant &value) -{ - Q_D(QMediaObject); - - if (d->metaDataControl) - d->metaDataControl->setMetaData(key, value); -} - -/*! - Returns a list of keys there is meta-data available for. -*/ -QList QMediaObject::availableMetaData() const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->availableMetaData() - : QList(); -} - -/*! - \fn QMediaObject::metaDataChanged() - - Signals that a media object's meta-data has changed. -*/ - -/*! - Returns the value associated with a meta-data \a key. - - The naming and type of extended meta-data is not standardized, so the values and meaning - of keys may vary between backends. -*/ -QVariant QMediaObject::extendedMetaData(const QString &key) const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->extendedMetaData(key) - : QVariant(); -} - -/*! - Sets a \a value for a meta-data \a key. - - The naming and type of extended meta-data is not standardized, so the values and meaning - of keys may vary between backends. -*/ -void QMediaObject::setExtendedMetaData(const QString &key, const QVariant &value) -{ - Q_D(QMediaObject); - - if (d->metaDataControl) - d->metaDataControl->setExtendedMetaData(key, value); -} - -/*! - Returns a list of keys there is extended meta-data available for. -*/ -QStringList QMediaObject::availableExtendedMetaData() const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->availableExtendedMetaData() - : QStringList(); -} - - -void QMediaObject::setupMetaData() -{ - Q_D(QMediaObject); - - if (d->service != 0) { - d->metaDataControl = - qobject_cast(d->service->control(QMetaDataControl_iid)); - - if (d->metaDataControl) { - connect(d->metaDataControl, SIGNAL(metaDataChanged()), SIGNAL(metaDataChanged())); - connect(d->metaDataControl, - SIGNAL(metaDataAvailableChanged(bool)), - SIGNAL(metaDataAvailableChanged(bool))); - connect(d->metaDataControl, - SIGNAL(writableChanged(bool)), - SIGNAL(metaDataWritableChanged(bool))); - } - } -} - -/*! - \fn QMediaObject::availabilityChanged(bool available) - - Signal emitted when the availability state has changed to \a available -*/ - - -#include "moc_qmediaobject.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediaobject.h b/src/multimedia/mediaservices/base/qmediaobject.h deleted file mode 100644 index 067bb56..0000000 --- a/src/multimedia/mediaservices/base/qmediaobject.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QABSTRACTMEDIAOBJECT_H -#define QABSTRACTMEDIAOBJECT_H - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaService; - -class QMediaObjectPrivate; -class Q_MEDIASERVICES_EXPORT QMediaObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int notifyInterval READ notifyInterval WRITE setNotifyInterval NOTIFY notifyIntervalChanged) - Q_PROPERTY(bool metaDataAvailable READ isMetaDataAvailable NOTIFY metaDataAvailableChanged) - Q_PROPERTY(bool metaDataWritable READ isMetaDataWritable NOTIFY metaDataWritableChanged) - -public: - ~QMediaObject(); - - virtual bool isAvailable() const; - virtual QtMediaServices::AvailabilityError availabilityError() const; - - virtual QMediaService* service() const; - - int notifyInterval() const; - void setNotifyInterval(int milliSeconds); - - virtual void bind(QObject*); - virtual void unbind(QObject*); - - bool isMetaDataAvailable() const; - bool isMetaDataWritable() const; - - QVariant metaData(QtMediaServices::MetaData key) const; - void setMetaData(QtMediaServices::MetaData key, const QVariant &value); - QList availableMetaData() const; - - QVariant extendedMetaData(const QString &key) const; - void setExtendedMetaData(const QString &key, const QVariant &value); - QStringList availableExtendedMetaData() const; - -Q_SIGNALS: - void notifyIntervalChanged(int milliSeconds); - - void metaDataAvailableChanged(bool available); - void metaDataWritableChanged(bool writable); - void metaDataChanged(); - - void availabilityChanged(bool available); - -protected: - QMediaObject(QObject *parent, QMediaService *service); - QMediaObject(QMediaObjectPrivate &dd, QObject *parent, QMediaService *service); - - void addPropertyWatch(QByteArray const &name); - void removePropertyWatch(QByteArray const &name); - - QMediaObjectPrivate *d_ptr; - -private: - void setupMetaData(); - - Q_DECLARE_PRIVATE(QMediaObject) - Q_PRIVATE_SLOT(d_func(), void _q_notify()) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QABSTRACTMEDIAOBJECT_H diff --git a/src/multimedia/mediaservices/base/qmediaobject_p.h b/src/multimedia/mediaservices/base/qmediaobject_p.h deleted file mode 100644 index c31ad46..0000000 --- a/src/multimedia/mediaservices/base/qmediaobject_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QABSTRACTMEDIAOBJECT_P_H -#define QABSTRACTMEDIAOBJECT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMetaDataControl; - -#define Q_DECLARE_NON_CONST_PUBLIC(Class) \ - inline Class* q_func() { return static_cast(q_ptr); } \ - friend class Class; - - -class QMediaObjectPrivate -{ - Q_DECLARE_PUBLIC(QMediaObject) - -public: - QMediaObjectPrivate():metaDataControl(0), notifyTimer(0) {} - virtual ~QMediaObjectPrivate() {} - - void _q_notify(); - - QMediaService *service; - QMetaDataControl *metaDataControl; - QTimer* notifyTimer; - QSet notifyProperties; - - QMediaObject *q_ptr; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qmediaplaylist.cpp b/src/multimedia/mediaservices/base/qmediaplaylist.cpp deleted file mode 100644 index 93278fe..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylist.cpp +++ /dev/null @@ -1,724 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include -#include -#include -#include - -#include -#include "qmediaplaylist_p.h" -#include -#include -#include -#include -#include -#include - -#include "qmediapluginloader_p.h" - - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, playlistIOLoader, - (QMediaPlaylistIOInterface_iid, QLatin1String("/playlistformats"), Qt::CaseInsensitive)) - - -/*! - \class QMediaPlaylist - \ingroup multimedia - \since 4.7 - - \preliminary - \brief The QMediaPlaylist class provides a list of media content to play. - - QMediaPlaylist is intended to be used with other media objects, - like QMediaPlayer or QMediaImageViewer. - QMediaPlaylist allows to access the service intrinsic playlist functionality - if available, otherwise it provides the the local memory playlist implementation. - -\code - player = new QMediaPlayer; - - playlist = new QMediaPlaylist; - playlist->setMediaObject(player); - playlist->append(QUrl("http://example.com/movie1.mp4")); - playlist->append(QUrl("http://example.com/movie2.mp4")); - playlist->append(QUrl("http://example.com/movie3.mp4")); - - playlist->setCurrentIndex(1); - - player->play(); -\endcode - - Depending on playlist source implementation, - most of playlist modifcation operations can be asynchronous. - - \sa QMediaContent -*/ - - -/*! - \enum QMediaPlaylist::PlaybackMode - - The QMediaPlaylist::PlaybackMode describes the order items in playlist are played. - - \value CurrentItemOnce The current item is played only once. - - \value CurrentItemInLoop The current item is played in the loop. - - \value Linear Playback starts from the first to the last items and stops. - next item is a null item when the last one is currently playing. - - \value Loop Playback continues from the first item after the last one finished playing. - - \value Random Play items in random order. -*/ - - - -/*! - Create a new playlist object for with the given \a parent. -*/ - -QMediaPlaylist::QMediaPlaylist(QObject *parent) - : QObject(parent) - , d_ptr(new QMediaPlaylistPrivate) -{ - Q_D(QMediaPlaylist); - - d->q_ptr = this; - d->localPlaylistControl = new QLocalMediaPlaylistControl(this); - - setMediaObject(0); -} - -/*! - Destroys the playlist. - */ - -QMediaPlaylist::~QMediaPlaylist() -{ - Q_D(QMediaPlaylist); - - if (d->mediaObject) - d->mediaObject->unbind(this); - - delete d_ptr; -} - -/*! - Returns the QMediaObject that is being used to play the contents of this playlist. -*/ - -QMediaObject *QMediaPlaylist::mediaObject() const -{ - return d_func()->mediaObject; -} - -/*! - If \a mediaObject is null or doesn't have an intrinsic playlist, - internal local memory playlist source will be created. -*/ -void QMediaPlaylist::setMediaObject(QMediaObject *mediaObject) -{ - Q_D(QMediaPlaylist); - - if (mediaObject && mediaObject == d->mediaObject) - return; - - QMediaService *service = mediaObject - ? mediaObject->service() : 0; - - QMediaPlaylistControl *newControl = 0; - - if (service) - newControl = qobject_cast(service->control(QMediaPlaylistControl_iid)); - - if (!newControl) - newControl = d->localPlaylistControl; - - if (d->control != newControl) { - int oldSize = 0; - if (d->control) { - QMediaPlaylistProvider *playlist = d->control->playlistProvider(); - oldSize = playlist->mediaCount(); - disconnect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)), - this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString))); - - disconnect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int))); - disconnect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int))); - disconnect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int))); - disconnect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int))); - disconnect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int))); - - disconnect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded())); - - disconnect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)), - this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode))); - disconnect(d->control, SIGNAL(currentIndexChanged(int)), - this, SIGNAL(currentIndexChanged(int))); - disconnect(d->control, SIGNAL(currentMediaChanged(QMediaContent)), - this, SIGNAL(currentMediaChanged(QMediaContent))); - } - - d->control = newControl; - QMediaPlaylistProvider *playlist = d->control->playlistProvider(); - connect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)), - this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString))); - - connect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int))); - connect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int))); - connect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int))); - connect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int))); - connect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int))); - - connect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded())); - - connect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)), - this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode))); - connect(d->control, SIGNAL(currentIndexChanged(int)), - this, SIGNAL(currentIndexChanged(int))); - connect(d->control, SIGNAL(currentMediaChanged(QMediaContent)), - this, SIGNAL(currentMediaChanged(QMediaContent))); - - if (oldSize) - emit mediaRemoved(0, oldSize-1); - - if (playlist->mediaCount()) { - emit mediaAboutToBeInserted(0,playlist->mediaCount()-1); - emit mediaInserted(0,playlist->mediaCount()-1); - } - } - - if (d->mediaObject) - d->mediaObject->unbind(this); - - d->mediaObject = mediaObject; - if (d->mediaObject) - d->mediaObject->bind(this); -} - -/*! - \property QMediaPlaylist::playbackMode - - This property defines the order, items in playlist are played. - - \sa QMediaPlaylist::PlaybackMode -*/ - -QMediaPlaylist::PlaybackMode QMediaPlaylist::playbackMode() const -{ - return d_func()->control->playbackMode(); -} - -void QMediaPlaylist::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) -{ - Q_D(QMediaPlaylist); - d->control->setPlaybackMode(mode); -} - -/*! - Returns position of the current media source in the playlist. -*/ -int QMediaPlaylist::currentIndex() const -{ - return d_func()->control->currentIndex(); -} - -/*! - Returns the current media content. -*/ - -QMediaContent QMediaPlaylist::currentMedia() const -{ - return d_func()->playlist()->media(currentIndex()); -} - -/*! - Returns the index of item, which were current after calling next() - \a steps times. - - Returned value depends on the size of playlist, current position - and playback mode. - - \sa QMediaPlaylist::playbackMode -*/ -int QMediaPlaylist::nextIndex(int steps) const -{ - return d_func()->control->nextIndex(steps); -} - -/*! - Returns the index of item, which were current after calling previous() - \a steps times. - - \sa QMediaPlaylist::playbackMode -*/ - -int QMediaPlaylist::previousIndex(int steps) const -{ - return d_func()->control->previousIndex(steps); -} - - -/*! - Returns the number of items in the playlist. - - \sa isEmpty() - */ -int QMediaPlaylist::mediaCount() const -{ - return d_func()->playlist()->mediaCount(); -} - -/*! - Returns true if the playlist contains no items; otherwise returns false. - \sa mediaCount() - */ -bool QMediaPlaylist::isEmpty() const -{ - return mediaCount() == 0; -} - -/*! - Returns true if the playlist can be modified; otherwise returns false. - \sa mediaCount() - */ -bool QMediaPlaylist::isReadOnly() const -{ - return d_func()->playlist()->isReadOnly(); -} - -/*! - Returns the media content at \a index in the playlist. -*/ - -QMediaContent QMediaPlaylist::media(int index) const -{ - return d_func()->playlist()->media(index); -} - -/*! - Append the media \a content to the playlist. - - Returns true if the operation is successfull, other wise return false. - */ -bool QMediaPlaylist::addMedia(const QMediaContent &content) -{ - return d_func()->control->playlistProvider()->addMedia(content); -} - -/*! - Append multiple media content \a items to the playlist. - - Returns true if the operation is successfull, other wise return false. - */ -bool QMediaPlaylist::addMedia(const QList &items) -{ - return d_func()->control->playlistProvider()->addMedia(items); -} - -/*! - Insert the media \a content to the playlist at position \a pos. - - Returns true if the operation is successful, otherwise false. -*/ - -bool QMediaPlaylist::insertMedia(int pos, const QMediaContent &content) -{ - return d_func()->playlist()->insertMedia(pos, content); -} - -/*! - Insert multiple media content \a items to the playlist at position \a pos. - - Returns true if the operation is successful, otherwise false. -*/ - -bool QMediaPlaylist::insertMedia(int pos, const QList &items) -{ - return d_func()->playlist()->insertMedia(pos, items); -} - -/*! - Remove the item from the playlist at position \a pos. - - Returns true if the operation is successfull, other wise return false. - */ -bool QMediaPlaylist::removeMedia(int pos) -{ - Q_D(QMediaPlaylist); - return d->playlist()->removeMedia(pos); -} - -/*! - Remove the items from the playlist from position \a start to \a end inclusive. - - Returns true if the operation is successfull, other wise return false. - */ -bool QMediaPlaylist::removeMedia(int start, int end) -{ - Q_D(QMediaPlaylist); - return d->playlist()->removeMedia(start, end); -} - -/*! - Remove all the items from the playlist. - - Returns true if the operation is successfull, other wise return false. - */ -bool QMediaPlaylist::clear() -{ - Q_D(QMediaPlaylist); - return d->playlist()->clear(); -} - -bool QMediaPlaylistPrivate::readItems(QMediaPlaylistReader *reader) -{ - while (!reader->atEnd()) - playlist()->addMedia(reader->readItem()); - - return true; -} - -bool QMediaPlaylistPrivate::writeItems(QMediaPlaylistWriter *writer) -{ - for (int i=0; imediaCount(); i++) { - if (!writer->writeItem(playlist()->media(i))) - return false; - } - writer->close(); - return true; -} - -/*! - Load playlist from \a location. If \a format is specified, it is used, - otherwise format is guessed from location name and data. - - New items are appended to playlist. - - QMediaPlaylist::loaded() signal is emited if playlist was loaded succesfully, - otherwise the playlist emits loadFailed(). -*/ -void QMediaPlaylist::load(const QUrl &location, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->load(location,format)) - return; - - if (isReadOnly()) { - d->error = AccessDeniedError; - d->errorString = tr("Could not add items to read only playlist."); - emit loadFailed(); - return; - } - - foreach (QString const& key, playlistIOLoader()->keys()) { - QMediaPlaylistIOInterface* plugin = qobject_cast(playlistIOLoader()->instance(key)); - if (plugin && plugin->canRead(location,format)) { - QMediaPlaylistReader *reader = plugin->createReader(location,QByteArray(format)); - if (reader && d->readItems(reader)) { - delete reader; - emit loaded(); - return; - } - delete reader; - } - } - - d->error = FormatNotSupportedError; - d->errorString = tr("Playlist format is not supported"); - emit loadFailed(); - - return; -} - -/*! - Load playlist from QIODevice \a device. If \a format is specified, it is used, - otherwise format is guessed from device data. - - New items are appended to playlist. - - QMediaPlaylist::loaded() signal is emited if playlist was loaded succesfully, - otherwise the playlist emits loadFailed(). -*/ -void QMediaPlaylist::load(QIODevice * device, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->load(device,format)) - return; - - if (isReadOnly()) { - d->error = AccessDeniedError; - d->errorString = tr("Could not add items to read only playlist."); - emit loadFailed(); - return; - } - - foreach (QString const& key, playlistIOLoader()->keys()) { - QMediaPlaylistIOInterface* plugin = qobject_cast(playlistIOLoader()->instance(key)); - if (plugin && plugin->canRead(device,format)) { - QMediaPlaylistReader *reader = plugin->createReader(device,QByteArray(format)); - if (reader && d->readItems(reader)) { - delete reader; - emit loaded(); - return; - } - delete reader; - } - } - - d->error = FormatNotSupportedError; - d->errorString = tr("Playlist format is not supported"); - emit loadFailed(); - - return; -} - -/*! - Save playlist to \a location. If \a format is specified, it is used, - otherwise format is guessed from location name. - - Returns true if playlist was saved succesfully, otherwise returns false. - */ -bool QMediaPlaylist::save(const QUrl &location, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->save(location,format)) - return true; - - QFile file(location.toLocalFile()); - - if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { - d->error = AccessDeniedError; - d->errorString = tr("The file could not be accessed."); - return false; - } - - return save(&file, format); -} - -/*! - Save playlist to QIODevice \a device using format \a format. - - Returns true if playlist was saved succesfully, otherwise returns false. -*/ -bool QMediaPlaylist::save(QIODevice * device, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->save(device,format)) - return true; - - foreach (QString const& key, playlistIOLoader()->keys()) { - QMediaPlaylistIOInterface* plugin = qobject_cast(playlistIOLoader()->instance(key)); - if (plugin && plugin->canWrite(device,format)) { - QMediaPlaylistWriter *writer = plugin->createWriter(device,QByteArray(format)); - if (writer && d->writeItems(writer)) { - delete writer; - return true; - } - delete writer; - } - } - - d->error = FormatNotSupportedError; - d->errorString = tr("Playlist format is not supported."); - - return false; -} - -/*! - Returns the last error condition. -*/ -QMediaPlaylist::Error QMediaPlaylist::error() const -{ - return d_func()->error; -} - -/*! - Returns the string describing the last error condition. -*/ -QString QMediaPlaylist::errorString() const -{ - return d_func()->errorString; -} - -/*! - Shuffle items in the playlist. -*/ -void QMediaPlaylist::shuffle() -{ - d_func()->playlist()->shuffle(); -} - - -/*! - Advance to the next media content in playlist. -*/ -void QMediaPlaylist::next() -{ - d_func()->control->next(); -} - -/*! - Return to the previous media content in playlist. -*/ -void QMediaPlaylist::previous() -{ - d_func()->control->previous(); -} - -/*! - Activate media content from playlist at position \a playlistPosition. -*/ - -void QMediaPlaylist::setCurrentIndex(int playlistPosition) -{ - d_func()->control->setCurrentIndex(playlistPosition); -} - -/*! - \fn void QMediaPlaylist::mediaInserted(int start, int end) - - This signal is emitted after media has been inserted into the playlist. - The new items are those between \a start and \a end inclusive. - */ - -/*! - \fn void QMediaPlaylist::mediaRemoved(int start, int end) - - This signal is emitted after media has been removed from the playlist. - The removed items are those between \a start and \a end inclusive. - */ - -/*! - \fn void QMediaPlaylist::mediaChanged(int start, int end) - - This signal is emitted after media has been changed in the playlist - between \a start and \a end positions inclusive. - */ - -/*! - \fn void QMediaPlaylist::currentIndexChanged(int position) - - Signal emitted when playlist position changed to \a position. -*/ - -/*! - \fn void QMediaPlaylist::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) - - Signal emitted when playback mode changed to \a mode. -*/ - -/*! - \fn void QMediaPlaylist::mediaAboutToBeInserted(int start, int end) - - Signal emitted when item to be inserted at \a start and ending at \a end. -*/ - -/*! - \fn void QMediaPlaylist::mediaAboutToBeRemoved(int start, int end) - - Signal emitted when item to de deleted ar \a start and ending at \a end. -*/ - -/*! - \fn void QMediaPlaylist::currentMediaChanged(const QMediaContent &content) - - Signal emitted when current media changes to \a content. -*/ - -/*! - \property QMediaPlaylist::currentIndex - \brief Current position. -*/ - -/*! - \property QMediaPlaylist::currentMedia - \brief Current media content. -*/ - -/*! - \fn QMediaPlaylist::loaded() - - Signal emitted when playlist finished loading. -*/ - -/*! - \fn QMediaPlaylist::loadFailed() - - Signal emitted if failed to load playlist. -*/ - -/*! - \enum QMediaPlaylist::Error - - This enum describes the QMediaPlaylist error codes. - - \value NoError No errors. - \value FormatError Format error. - \value FormatNotSupportedError Format not supported. - \value NetworkError Network error. - \value AccessDeniedError Access denied error. -*/ - -QT_END_NAMESPACE - -#include "moc_qmediaplaylist.cpp" -#include "moc_qmediaplaylist_p.cpp" diff --git a/src/multimedia/mediaservices/base/qmediaplaylist.h b/src/multimedia/mediaservices/base/qmediaplaylist.h deleted file mode 100644 index 6cae7c5..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylist.h +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIAPLAYLIST_H -#define QMEDIAPLAYLIST_H - -#include - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaPlaylistProvider; - -class QMediaPlaylistPrivate; -class Q_MEDIASERVICES_EXPORT QMediaPlaylist : public QObject -{ - Q_OBJECT - Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged) - Q_PROPERTY(QMediaContent currentMedia READ currentMedia NOTIFY currentMediaChanged) - Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) - Q_ENUMS(PlaybackMode Error) - -public: - enum PlaybackMode { CurrentItemOnce, CurrentItemInLoop, Linear, Loop, Random }; - enum Error { NoError, FormatError, FormatNotSupportedError, NetworkError, AccessDeniedError }; - - QMediaPlaylist(QObject *parent = 0); - virtual ~QMediaPlaylist(); - - QMediaObject *mediaObject() const; - void setMediaObject(QMediaObject *object); - - PlaybackMode playbackMode() const; - void setPlaybackMode(PlaybackMode mode); - - int currentIndex() const; - QMediaContent currentMedia() const; - - int nextIndex(int steps = 1) const; - int previousIndex(int steps = 1) const; - - QMediaContent media(int index) const; - - int mediaCount() const; - bool isEmpty() const; - bool isReadOnly() const; - - bool addMedia(const QMediaContent &content); - bool addMedia(const QList &items); - bool insertMedia(int index, const QMediaContent &content); - bool insertMedia(int index, const QList &items); - bool removeMedia(int pos); - bool removeMedia(int start, int end); - bool clear(); - - void load(const QUrl &location, const char *format = 0); - void load(QIODevice * device, const char *format = 0); - - bool save(const QUrl &location, const char *format = 0); - bool save(QIODevice * device, const char *format); - - Error error() const; - QString errorString() const; - -public Q_SLOTS: - void shuffle(); - - void next(); - void previous(); - - void setCurrentIndex(int index); - -Q_SIGNALS: - void currentIndexChanged(int index); - void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); - void currentMediaChanged(const QMediaContent&); - - void mediaAboutToBeInserted(int start, int end); - void mediaInserted(int start, int end); - void mediaAboutToBeRemoved(int start, int end); - void mediaRemoved(int start, int end); - void mediaChanged(int start, int end); - - void loaded(); - void loadFailed(); - -protected: - QMediaPlaylistPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QMediaPlaylist) - Q_PRIVATE_SLOT(d_func(), void _q_loadFailed(QMediaPlaylist::Error, const QString &)) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaPlaylist::PlaybackMode) -Q_DECLARE_METATYPE(QMediaPlaylist::Error) - -QT_END_HEADER - -#endif // QMEDIAPLAYLIST_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylist_p.h b/src/multimedia/mediaservices/base/qmediaplaylist_p.h deleted file mode 100644 index a5f290e..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylist_p.h +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIAPLAYLIST_P_H -#define QMEDIAPLAYLIST_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include -#include -#include "qmediaobject_p.h" - -#include - -#ifdef Q_MOC_RUN -# pragma Q_MOC_EXPAND_MACROS -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlaylistControl; -class QMediaPlaylistProvider; -class QMediaPlaylistReader; -class QMediaPlaylistWriter; -class QMediaPlayerControl; - -class QMediaPlaylistPrivate -{ - Q_DECLARE_PUBLIC(QMediaPlaylist) -public: - QMediaPlaylistPrivate() - :mediaObject(0), - control(0), - localPlaylistControl(0), - error(QMediaPlaylist::NoError) - { - } - - virtual ~QMediaPlaylistPrivate() {} - - void _q_loadFailed(QMediaPlaylist::Error error, const QString &errorString) - { - this->error = error; - this->errorString = errorString; - - emit q_ptr->loadFailed(); - } - - void _q_mediaObjectDeleted() - { - Q_Q(QMediaPlaylist); - mediaObject = 0; - if (control != localPlaylistControl) - control = 0; - q->setMediaObject(0); - } - - QMediaObject *mediaObject; - - QMediaPlaylistControl *control; - QMediaPlaylistProvider *playlist() const { return control->playlistProvider(); } - - QMediaPlaylistControl *localPlaylistControl; - - bool readItems(QMediaPlaylistReader *reader); - bool writeItems(QMediaPlaylistWriter *writer); - - QMediaPlaylist::Error error; - QString errorString; - - QMediaPlaylist *q_ptr; -}; - - -class QLocalMediaPlaylistControl : public QMediaPlaylistControl -{ - Q_OBJECT -public: - QLocalMediaPlaylistControl(QObject *parent) - :QMediaPlaylistControl(parent) - { - QMediaPlaylistProvider *playlist = new QLocalMediaPlaylistProvider(this); - m_navigator = new QMediaPlaylistNavigator(playlist,this); - m_navigator->setPlaybackMode(QMediaPlaylist::Linear); - - connect(m_navigator, SIGNAL(currentIndexChanged(int)), SIGNAL(currentIndexChanged(int))); - connect(m_navigator, SIGNAL(activated(QMediaContent)), SIGNAL(currentMediaChanged(QMediaContent))); - } - - virtual ~QLocalMediaPlaylistControl() {}; - - QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); } - bool setPlaylistProvider(QMediaPlaylistProvider *mediaPlaylist) - { - m_navigator->setPlaylist(mediaPlaylist); - emit playlistProviderChanged(); - return true; - } - - int currentIndex() const { return m_navigator->currentIndex(); } - void setCurrentIndex(int position) { m_navigator->jump(position); } - int nextIndex(int steps) const { return m_navigator->nextIndex(steps); } - int previousIndex(int steps) const { return m_navigator->previousIndex(steps); } - - void next() { m_navigator->next(); } - void previous() { m_navigator->previous(); } - - QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); } - void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) { m_navigator->setPlaybackMode(mode); } - -private: - QMediaPlaylistNavigator *m_navigator; -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLIST_P_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylistcontrol.cpp b/src/multimedia/mediaservices/base/qmediaplaylistcontrol.cpp deleted file mode 100644 index 016c55d..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistcontrol.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include "qmediacontrol_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaPlaylistControl - \ingroup multimedia-serv - \since 4.7 - - \preliminary - \brief The QMediaPlaylistControl class provides access to the playlist functionality of a - QMediaService. - - If a QMediaService contains an internal playlist it will implement QMediaPlaylistControl. This - control provides access to the contents of the \l {playlistProvider()}{playlist}, as well as the - \l {currentIndex()}{position} of the current media, and a means of navigating to the - \l {next()}{next} and \l {previous()}{previous} media. - - The functionality provided by the control is exposed to application code through the - QMediaPlaylist class. - - The interface name of QMediaPlaylistControl is \c com.nokia.Qt.QMediaPlaylistControl/1.0 as - defined in QMediaPlaylistControl_iid. - - \sa QMediaService::control(), QMediaPlayer -*/ - -/*! - \macro QMediaPlaylistControl_iid - - \c com.nokia.Qt.QMediaPlaylistControl/1.0 - - Defines the interface name of the QMediaPlaylistControl class. - - \relates QMediaPlaylistControl -*/ - -/*! - Create a new playlist control object with the given \a parent. -*/ -QMediaPlaylistControl::QMediaPlaylistControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroys the playlist control. -*/ -QMediaPlaylistControl::~QMediaPlaylistControl() -{ -} - - -/*! - \fn QMediaPlaylistControl::playlistProvider() const - - Returns the playlist used by this media player. -*/ - -/*! - \fn QMediaPlaylistControl::setPlaylistProvider(QMediaPlaylistProvider *playlist) - - Set the playlist of this media player to \a playlist. - - In many cases it is possible just to use the playlist - constructed by player, but sometimes replacing the whole - playlist allows to avoid copyting of all the items bettween playlists. - - Returns true if player can use this passed playlist; otherwise returns false. - -*/ - -/*! - \fn QMediaPlaylistControl::currentIndex() const - - Returns position of the current media source in the playlist. -*/ - -/*! - \fn QMediaPlaylistControl::setCurrentIndex(int position) - - Jump to the item at the given \a position. -*/ - -/*! - \fn QMediaPlaylistControl::nextIndex(int step) const - - Returns the index of item, which were current after calling next() - \a step times. - - Returned value depends on the size of playlist, current position - and playback mode. - - \sa QMediaPlaylist::playbackMode -*/ - -/*! - \fn QMediaPlaylistControl::previousIndex(int step) const - - Returns the index of item, which were current after calling previous() - \a step times. - - \sa QMediaPlaylist::playbackMode -*/ - -/*! - \fn QMediaPlaylistControl::next() - - Moves to the next item in playlist. -*/ - -/*! - \fn QMediaPlaylistControl::previous() - - Returns to the previous item in playlist. -*/ - -/*! - \fn QMediaPlaylistControl::playbackMode() const - - Returns the playlist navigation mode. - - \sa QMediaPlaylist::PlaybackMode -*/ - -/*! - \fn QMediaPlaylistControl::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) - - Sets the playback \a mode. - - \sa QMediaPlaylist::PlaybackMode -*/ - -/*! - \fn QMediaPlaylistControl::playlistProviderChanged() - - Signal emited when the playlist provider has changed. -*/ - -/*! - \fn QMediaPlaylistControl::currentIndexChanged(int position) - - Signal emited when the playlist \a position is changed. -*/ - -/*! - \fn QMediaPlaylistControl::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) - - Signal emited when the playback \a mode is changed. -*/ - -/*! - \fn QMediaPlaylistControl::currentMediaChanged(const QMediaContent& content) - - Signal emitted when current media changes to \a content. -*/ - -#include "moc_qmediaplaylistcontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediaplaylistcontrol.h b/src/multimedia/mediaservices/base/qmediaplaylistcontrol.h deleted file mode 100644 index 2dc4575..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistcontrol.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIAPLAYLISTCONTROL_H -#define QMEDIAPLAYLISTCONTROL_H - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylistProvider; - -class Q_MEDIASERVICES_EXPORT QMediaPlaylistControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QMediaPlaylistControl(); - - virtual QMediaPlaylistProvider* playlistProvider() const = 0; - virtual bool setPlaylistProvider(QMediaPlaylistProvider *playlist) = 0; - - virtual int currentIndex() const = 0; - virtual void setCurrentIndex(int position) = 0; - virtual int nextIndex(int steps) const = 0; - virtual int previousIndex(int steps) const = 0; - - virtual void next() = 0; - virtual void previous() = 0; - - virtual QMediaPlaylist::PlaybackMode playbackMode() const = 0; - virtual void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) = 0; - -Q_SIGNALS: - void playlistProviderChanged(); - void currentIndexChanged(int position); - void currentMediaChanged(const QMediaContent&); - void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); - -protected: - QMediaPlaylistControl(QObject* parent = 0); -}; - -#define QMediaPlaylistControl_iid "com.nokia.Qt.QMediaPlaylistControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaPlaylistControl, QMediaPlaylistControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLISTCONTROL_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylistioplugin.cpp b/src/multimedia/mediaservices/base/qmediaplaylistioplugin.cpp deleted file mode 100644 index 60e80e5..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistioplugin.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaPlaylistReader - \preliminary - \since 4.7 - \brief The QMediaPlaylistReader class provides an interface for reading a playlist file. - - \sa QMediaPlaylistIOPlugin -*/ - -/*! - Destroys a media playlist reader. -*/ -QMediaPlaylistReader::~QMediaPlaylistReader() -{ -} - -/*! - \fn QMediaPlaylistReader::atEnd() const - - Identifies if a playlist reader has reached the end of its input. - - Returns true if the reader has reached the end; and false otherwise. -*/ - -/*! - \fn QMediaPlaylistReader::readItem() - - Reads an item of media from a playlist file. - - Returns the read media, or a null QMediaContent if no more media is available. -*/ - -/*! - \fn QMediaPlaylistReader::close() - - Closes a playlist reader's input device. -*/ - -/*! - \class QMediaPlaylistWriter - \preliminary - \since 4.7 - \brief The QMediaPlaylistWriter class provides an interface for writing a playlist file. - - \sa QMediaPlaylistIOPlugin -*/ - -/*! - Destroys a media playlist writer. -*/ -QMediaPlaylistWriter::~QMediaPlaylistWriter() -{ -} - -/*! - \fn QMediaPlaylistWriter::writeItem(const QMediaContent &media) - - Writes an item of \a media to a playlist file. - - Returns true if the media was written succesfully; and false otherwise. -*/ - -/*! - \fn QMediaPlaylistWriter::close() - - Finalizes the writing of a playlist and closes the output device. -*/ - -/*! - \class QMediaPlaylistIOPlugin - \since 4.7 - \brief The QMediaPlaylistIOPlugin class provides an interface for media playlist I/O plug-ins. -*/ - -/*! - Constructs a media playlist I/O plug-in with the given \a parent. -*/ -QMediaPlaylistIOPlugin::QMediaPlaylistIOPlugin(QObject *parent) - :QObject(parent) -{ -} - -/*! - Destroys a media playlist I/O plug-in. -*/ -QMediaPlaylistIOPlugin::~QMediaPlaylistIOPlugin() -{ -} - -/*! - \fn QMediaPlaylistIOPlugin::canRead(QIODevice *device, const QByteArray &format) const - - Identifies if plug-in can read \a format data from an I/O \a device. - - Returns true if the data can be read; and false otherwise. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::canRead(const QUrl& location, const QByteArray &format) const - - Identifies if a plug-in can read \a format data from a URL \a location. - - Returns true if the data can be read; and false otherwise. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::canWrite(QIODevice *device, const QByteArray &format) const - - Identifies if a plug-in can write \a format data to an I/O \a device. - - Returns true if the data can be written; and false otherwise. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::keys() const - - Returns a list of format keys supported by a plug-in. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::createReader(QIODevice *device, const QByteArray &format) - - Returns a new QMediaPlaylistReader which reads \a format data from an I/O \a device. - - If the device is invalid or the format is unsupported this will return a null pointer. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::createReader(const QUrl& location, const QByteArray &format) - - Returns a new QMediaPlaylistReader which reads \a format data from a URL \a location. - - If the location or the format is unsupported this will return a null pointer. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::createWriter(QIODevice *device, const QByteArray &format) - - Returns a new QMediaPlaylistWriter which writes \a format data to an I/O \a device. - - If the device is invalid or the format is unsupported this will return a null pointer. -*/ - -QT_END_NAMESPACE - -#include "moc_qmediaplaylistioplugin.cpp" - diff --git a/src/multimedia/mediaservices/base/qmediaplaylistioplugin.h b/src/multimedia/mediaservices/base/qmediaplaylistioplugin.h deleted file mode 100644 index ed8e832..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistioplugin.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIAPLAYLISTIOPLUGIN_H -#define QMEDIAPLAYLISTIOPLUGIN_H - -#include -#include -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QString; -class QUrl; -class QByteArray; -class QIODevice; -class QStringList; - -class Q_MEDIASERVICES_EXPORT QMediaPlaylistReader -{ -public: - virtual ~QMediaPlaylistReader(); - - virtual bool atEnd() const = 0; - virtual QMediaContent readItem() = 0; - virtual void close() = 0; -}; - -class Q_MEDIASERVICES_EXPORT QMediaPlaylistWriter -{ -public: - virtual ~QMediaPlaylistWriter(); - - virtual bool writeItem(const QMediaContent &content) = 0; - virtual void close() = 0; -}; - -struct Q_MEDIASERVICES_EXPORT QMediaPlaylistIOInterface : public QFactoryInterface -{ - virtual bool canRead(QIODevice *device, const QByteArray &format = QByteArray() ) const = 0; - virtual bool canRead(const QUrl& location, const QByteArray &format = QByteArray()) const = 0; - - virtual bool canWrite(QIODevice *device, const QByteArray &format) const = 0; - - virtual QMediaPlaylistReader *createReader(QIODevice *device, const QByteArray &format = QByteArray()) = 0; - virtual QMediaPlaylistReader *createReader(const QUrl& location, const QByteArray &format = QByteArray()) = 0; - - virtual QMediaPlaylistWriter *createWriter(QIODevice *device, const QByteArray &format) = 0; -}; - -#define QMediaPlaylistIOInterface_iid "com.nokia.Qt.QMediaPlaylistIOInterface" -Q_DECLARE_INTERFACE(QMediaPlaylistIOInterface, QMediaPlaylistIOInterface_iid); - -class Q_MEDIASERVICES_EXPORT QMediaPlaylistIOPlugin : public QObject, public QMediaPlaylistIOInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaPlaylistIOInterface:QFactoryInterface) - -public: - explicit QMediaPlaylistIOPlugin(QObject *parent = 0); - virtual ~QMediaPlaylistIOPlugin(); - - virtual bool canRead(QIODevice *device, const QByteArray &format = QByteArray() ) const = 0; - virtual bool canRead(const QUrl& location, const QByteArray &format = QByteArray()) const = 0; - - virtual bool canWrite(QIODevice *device, const QByteArray &format) const = 0; - - virtual QStringList keys() const = 0; - - virtual QMediaPlaylistReader *createReader(QIODevice *device, const QByteArray &format = QByteArray()) = 0; - virtual QMediaPlaylistReader *createReader(const QUrl& location, const QByteArray &format = QByteArray()) = 0; - - virtual QMediaPlaylistWriter *createWriter(QIODevice *device, const QByteArray &format) = 0; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLISTIOPLUGIN_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylistnavigator.cpp b/src/multimedia/mediaservices/base/qmediaplaylistnavigator.cpp deleted file mode 100644 index e3eec5e..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistnavigator.cpp +++ /dev/null @@ -1,545 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include -#include -#include "qmediaobject_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QMediaPlaylistNullProvider : public QMediaPlaylistProvider -{ -public: - QMediaPlaylistNullProvider() :QMediaPlaylistProvider() {} - virtual ~QMediaPlaylistNullProvider() {} - virtual int mediaCount() const {return 0;} - virtual QMediaContent media(int) const { return QMediaContent(); } -}; - -Q_GLOBAL_STATIC(QMediaPlaylistNullProvider, _q_nullMediaPlaylist) - -class QMediaPlaylistNavigatorPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QMediaPlaylistNavigator) -public: - QMediaPlaylistNavigatorPrivate() - :playlist(0), - currentPos(-1), - lastValidPos(-1), - playbackMode(QMediaPlaylist::Linear), - randomPositionsOffset(-1) - { - } - - QMediaPlaylistProvider *playlist; - int currentPos; - int lastValidPos; //to be used with CurrentItemOnce playback mode - QMediaPlaylist::PlaybackMode playbackMode; - QMediaContent currentItem; - - mutable QList randomModePositions; - mutable int randomPositionsOffset; - - int nextItemPos(int steps = 1) const; - int previousItemPos(int steps = 1) const; - - void _q_mediaInserted(int start, int end); - void _q_mediaRemoved(int start, int end); - void _q_mediaChanged(int start, int end); - - QMediaPlaylistNavigator *q_ptr; -}; - - -int QMediaPlaylistNavigatorPrivate::nextItemPos(int steps) const -{ - if (playlist->mediaCount() == 0) - return -1; - - if (steps == 0) - return currentPos; - - switch (playbackMode) { - case QMediaPlaylist::CurrentItemOnce: - return /*currentPos == -1 ? lastValidPos :*/ -1; - case QMediaPlaylist::CurrentItemInLoop: - return currentPos; - case QMediaPlaylist::Linear: - { - int nextPos = currentPos+steps; - return nextPos < playlist->mediaCount() ? nextPos : -1; - } - case QMediaPlaylist::Loop: - return (currentPos+steps) % playlist->mediaCount(); - case QMediaPlaylist::Random: - { - //TODO: limit the history size - - if (randomPositionsOffset == -1) { - randomModePositions.clear(); - randomModePositions.append(currentPos); - randomPositionsOffset = 0; - } - - while (randomModePositions.size() < randomPositionsOffset+steps+1) - randomModePositions.append(-1); - int res = randomModePositions[randomPositionsOffset+steps]; - if (res<0 || res >= playlist->mediaCount()) { - res = qrand() % playlist->mediaCount(); - randomModePositions[randomPositionsOffset+steps] = res; - } - - return res; - } - } - - return -1; -} - -int QMediaPlaylistNavigatorPrivate::previousItemPos(int steps) const -{ - if (playlist->mediaCount() == 0) - return -1; - - if (steps == 0) - return currentPos; - - switch (playbackMode) { - case QMediaPlaylist::CurrentItemOnce: - return /*currentPos == -1 ? lastValidPos :*/ -1; - case QMediaPlaylist::CurrentItemInLoop: - return currentPos; - case QMediaPlaylist::Linear: - { - int prevPos = currentPos == -1 ? playlist->mediaCount() - steps : currentPos - steps; - return prevPos>=0 ? prevPos : -1; - } - case QMediaPlaylist::Loop: - { - int prevPos = currentPos - steps; - while (prevPos<0) - prevPos += playlist->mediaCount(); - return prevPos; - } - case QMediaPlaylist::Random: - { - //TODO: limit the history size - - if (randomPositionsOffset == -1) { - randomModePositions.clear(); - randomModePositions.append(currentPos); - randomPositionsOffset = 0; - } - - while (randomPositionsOffset-steps < 0) { - randomModePositions.prepend(-1); - randomPositionsOffset++; - } - - int res = randomModePositions[randomPositionsOffset-steps]; - if (res<0 || res >= playlist->mediaCount()) { - res = qrand() % playlist->mediaCount(); - randomModePositions[randomPositionsOffset-steps] = res; - } - - return res; - } - } - - return -1; -} - -/*! - \class QMediaPlaylistNavigator - \preliminary - \since 4.7 - \brief The QMediaPlaylistNavigator class provides navigation for a media playlist. - - \sa QMediaPlaylist, QMediaPlaylistProvider -*/ - - -/*! - Constructs a media playlist navigator for a \a playlist. - - The \a parent is passed to QObject. - */ -QMediaPlaylistNavigator::QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent) - : QObject(parent) - , d_ptr(new QMediaPlaylistNavigatorPrivate) -{ - d_ptr->q_ptr = this; - - setPlaylist(playlist ? playlist : _q_nullMediaPlaylist()); -} - -/*! - Destroys a media playlist navigator. - */ - -QMediaPlaylistNavigator::~QMediaPlaylistNavigator() -{ - delete d_ptr; -} - - -/*! \property QMediaPlaylistNavigator::playbackMode - Contains the playback mode. - */ -QMediaPlaylist::PlaybackMode QMediaPlaylistNavigator::playbackMode() const -{ - return d_func()->playbackMode; -} - -/*! - Sets the playback \a mode. - */ -void QMediaPlaylistNavigator::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) -{ - Q_D(QMediaPlaylistNavigator); - if (d->playbackMode == mode) - return; - - if (mode == QMediaPlaylist::Random) { - d->randomPositionsOffset = 0; - d->randomModePositions.append(d->currentPos); - } else if (d->playbackMode == QMediaPlaylist::Random) { - d->randomPositionsOffset = -1; - d->randomModePositions.clear(); - } - - d->playbackMode = mode; - - emit playbackModeChanged(mode); - emit surroundingItemsChanged(); -} - -/*! - Returns the playlist being navigated. -*/ - -QMediaPlaylistProvider *QMediaPlaylistNavigator::playlist() const -{ - return d_func()->playlist; -} - -/*! - Sets the \a playlist to navigate. -*/ -void QMediaPlaylistNavigator::setPlaylist(QMediaPlaylistProvider *playlist) -{ - Q_D(QMediaPlaylistNavigator); - - if (d->playlist == playlist) - return; - - if (d->playlist) { - d->playlist->disconnect(this); - } - - if (playlist) { - d->playlist = playlist; - } else { - //assign to shared readonly null playlist - d->playlist = _q_nullMediaPlaylist(); - } - - connect(d->playlist, SIGNAL(mediaInserted(int,int)), SLOT(_q_mediaInserted(int,int))); - connect(d->playlist, SIGNAL(mediaRemoved(int,int)), SLOT(_q_mediaRemoved(int,int))); - connect(d->playlist, SIGNAL(mediaChanged(int,int)), SLOT(_q_mediaChanged(int,int))); - - d->randomPositionsOffset = -1; - d->randomModePositions.clear(); - - if (d->currentPos != -1) { - d->currentPos = -1; - emit currentIndexChanged(-1); - } - - if (!d->currentItem.isNull()) { - d->currentItem = QMediaContent(); - emit activated(d->currentItem); //stop playback - } -} - -/*! \property QMediaPlaylistNavigator::currentItem - - Contains the media at the current position in the playlist. - - \sa currentIndex() -*/ - -QMediaContent QMediaPlaylistNavigator::currentItem() const -{ - return itemAt(d_func()->currentPos); -} - -/*! \fn QMediaContent QMediaPlaylistNavigator::nextItem(int steps) const - - Returns the media that is \a steps positions ahead of the current - position in the playlist. - - \sa nextIndex() -*/ -QMediaContent QMediaPlaylistNavigator::nextItem(int steps) const -{ - return itemAt(nextIndex(steps)); -} - -/*! - Returns the media that is \a steps positions behind the current - position in the playlist. - - \sa previousIndex() - */ -QMediaContent QMediaPlaylistNavigator::previousItem(int steps) const -{ - return itemAt(previousIndex(steps)); -} - -/*! - Returns the media at a \a position in the playlist. - */ -QMediaContent QMediaPlaylistNavigator::itemAt(int position) const -{ - return d_func()->playlist->media(position); -} - -/*! \property QMediaPlaylistNavigator::currentIndex - - Contains the position of the current media. - - If no media is current, the property contains -1. - - \sa nextIndex(), previousIndex() -*/ - -int QMediaPlaylistNavigator::currentIndex() const -{ - return d_func()->currentPos; -} - -/*! - Returns a position \a steps ahead of the current position - accounting for the playbackMode(). - - If the position is beyond the end of the playlist, this value - returned is -1. - - \sa currentIndex(), previousIndex(), playbackMode() -*/ - -int QMediaPlaylistNavigator::nextIndex(int steps) const -{ - return d_func()->nextItemPos(steps); -} - -/*! - - Returns a position \a steps behind the current position accounting - for the playbackMode(). - - If the position is prior to the beginning of the playlist this will - return -1. - - \sa currentIndex(), nextIndex(), playbackMode() -*/ -int QMediaPlaylistNavigator::previousIndex(int steps) const -{ - return d_func()->previousItemPos(steps); -} - -/*! - Advances to the next item in the playlist. - - \sa previous(), jump(), playbackMode() - */ -void QMediaPlaylistNavigator::next() -{ - Q_D(QMediaPlaylistNavigator); - - int nextPos = d->nextItemPos(); - - if ( playbackMode() == QMediaPlaylist::Random ) - d->randomPositionsOffset++; - - jump(nextPos); -} - -/*! - Returns to the previous item in the playlist, - - \sa next(), jump(), playbackMode() - */ -void QMediaPlaylistNavigator::previous() -{ - Q_D(QMediaPlaylistNavigator); - - int prevPos = d->previousItemPos(); - if ( playbackMode() == QMediaPlaylist::Random ) - d->randomPositionsOffset--; - - jump(prevPos); -} - -/*! - Jumps to a new \a position in the playlist. - */ -void QMediaPlaylistNavigator::jump(int position) -{ - Q_D(QMediaPlaylistNavigator); - - if (position<-1 || position>=d->playlist->mediaCount()) { - qWarning() << "QMediaPlaylistNavigator: Jump outside playlist range"; - position = -1; - } - - if (position != -1) - d->lastValidPos = position; - - if (playbackMode() == QMediaPlaylist::Random) { - if (d->randomModePositions[d->randomPositionsOffset] != position) { - d->randomModePositions.clear(); - d->randomModePositions.append(position); - d->randomPositionsOffset = 0; - } - } - - if (position != -1) - d->currentItem = d->playlist->media(position); - else - d->currentItem = QMediaContent(); - - if (position != d->currentPos) { - d->currentPos = position; - emit currentIndexChanged(d->currentPos); - emit surroundingItemsChanged(); - } - - emit activated(d->currentItem); -} - -/*! - \internal -*/ -void QMediaPlaylistNavigatorPrivate::_q_mediaInserted(int start, int end) -{ - Q_Q(QMediaPlaylistNavigator); - - if (currentPos >= start) { - currentPos = end-start+1; - q->jump(currentPos); - } - - //TODO: check if they really changed - emit q->surroundingItemsChanged(); -} - -/*! - \internal -*/ -void QMediaPlaylistNavigatorPrivate::_q_mediaRemoved(int start, int end) -{ - Q_Q(QMediaPlaylistNavigator); - - if (currentPos > end) { - currentPos = currentPos - end-start+1; - q->jump(currentPos); - } else if (currentPos >= start) { - //current item was removed - currentPos = qMin(start, playlist->mediaCount()-1); - q->jump(currentPos); - } - - //TODO: check if they really changed - emit q->surroundingItemsChanged(); -} - -/*! - \internal -*/ -void QMediaPlaylistNavigatorPrivate::_q_mediaChanged(int start, int end) -{ - Q_Q(QMediaPlaylistNavigator); - - if (currentPos >= start && currentPos<=end) { - QMediaContent src = playlist->media(currentPos); - if (src != currentItem) { - currentItem = src; - emit q->activated(src); - } - } - - //TODO: check if they really changed - emit q->surroundingItemsChanged(); -} - -/*! - \fn QMediaPlaylistNavigator::activated(const QMediaContent &media) - - Signals that the current \a media has changed. -*/ - -/*! - \fn QMediaPlaylistNavigator::currentIndexChanged(int position) - - Signals the \a position of the current media has changed. -*/ - -/*! - \fn QMediaPlaylistNavigator::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) - - Signals that the playback \a mode has changed. -*/ - -/*! - \fn QMediaPlaylistNavigator::surroundingItemsChanged() - - Signals that media immediately surrounding the current position has changed. -*/ - -#include "moc_qmediaplaylistnavigator.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediaplaylistnavigator.h b/src/multimedia/mediaservices/base/qmediaplaylistnavigator.h deleted file mode 100644 index 42c76f9..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistnavigator.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIAPLAYLISTNAVIGATOR_H -#define QMEDIAPLAYLISTNAVIGATOR_H - -#include - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylistNavigatorPrivate; -class Q_MEDIASERVICES_EXPORT QMediaPlaylistNavigator : public QObject -{ - Q_OBJECT - Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged) - Q_PROPERTY(int currentIndex READ currentIndex WRITE jump NOTIFY currentIndexChanged) - Q_PROPERTY(QMediaContent currentItem READ currentItem NOTIFY currentItemChanged) - -public: - QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent = 0); - virtual ~QMediaPlaylistNavigator(); - - QMediaPlaylistProvider *playlist() const; - void setPlaylist(QMediaPlaylistProvider *playlist); - - QMediaPlaylist::PlaybackMode playbackMode() const; - - QMediaContent currentItem() const; - QMediaContent nextItem(int steps = 1) const; - QMediaContent previousItem(int steps = 1) const; - - QMediaContent itemAt(int position) const; - - int currentIndex() const; - int nextIndex(int steps = 1) const; - int previousIndex(int steps = 1) const; - -public Q_SLOTS: - void next(); - void previous(); - - void jump(int); - - void setPlaybackMode(QMediaPlaylist::PlaybackMode mode); - -Q_SIGNALS: - void activated(const QMediaContent &content); - void currentIndexChanged(int); - void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); - - void surroundingItemsChanged(); - -protected: - QMediaPlaylistNavigatorPrivate *d_ptr; - -private: - Q_DISABLE_COPY(QMediaPlaylistNavigator) - Q_DECLARE_PRIVATE(QMediaPlaylistNavigator) - - Q_PRIVATE_SLOT(d_func(), void _q_mediaInserted(int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_mediaRemoved(int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_mediaChanged(int start, int end)) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLISTNAVIGATOR_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylistprovider.cpp b/src/multimedia/mediaservices/base/qmediaplaylistprovider.cpp deleted file mode 100644 index 3cd766b..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistprovider.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 - -#include -#include "qmediaplaylistprovider_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaPlaylistProvider - \preliminary - \since 4.7 - \brief The QMediaPlaylistProvider class provides an abstract list of media. - - \sa QMediaPlaylist -*/ - -/*! - Constructs a playlist provider with the given \a parent. -*/ -QMediaPlaylistProvider::QMediaPlaylistProvider(QObject *parent) - :QObject(parent), d_ptr(new QMediaPlaylistProviderPrivate) -{ -} - -/*! - \internal -*/ -QMediaPlaylistProvider::QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent) - :QObject(parent), d_ptr(&dd) -{ -} - -/*! - Destroys a playlist provider. -*/ -QMediaPlaylistProvider::~QMediaPlaylistProvider() -{ - delete d_ptr; -} - -/*! - \fn QMediaPlaylistProvider::mediaCount() const; - - Returns the size of playlist. -*/ - -/*! - \fn QMediaPlaylistProvider::media(int index) const; - - Returns the media at \a index in the playlist. - - If the index is invalid this will return a null media content. -*/ - - -/*! - Loads a playlist from from a URL \a location. If no playlist \a format is specified the loader - will inspect the URL or probe the headers to guess the format. - - New items are appended to playlist. - - Returns true if the provider supports the format and loading from the locations URL protocol, - otherwise this will return false. -*/ -bool QMediaPlaylistProvider::load(const QUrl &location, const char *format) -{ - Q_UNUSED(location); - Q_UNUSED(format); - return false; -} - -/*! - Loads a playlist from from an I/O \a device. If no playlist \a format is specified the loader - will probe the headers to guess the format. - - New items are appended to playlist. - - Returns true if the provider supports the format and loading from an I/O device, otherwise this - will return false. -*/ -bool QMediaPlaylistProvider::load(QIODevice * device, const char *format) -{ - Q_UNUSED(device); - Q_UNUSED(format); - return false; -} - -/*! - Saves the contents of a playlist to a URL \a location. If no playlist \a format is specified - the writer will inspect the URL to guess the format. - - Returns true if the playlist was saved succesfully; and false otherwise. - */ -bool QMediaPlaylistProvider::save(const QUrl &location, const char *format) -{ - Q_UNUSED(location); - Q_UNUSED(format); - return false; -} - -/*! - Saves the contents of a playlist to an I/O \a device in the specified \a format. - - Returns true if the playlist was saved succesfully; and false otherwise. -*/ -bool QMediaPlaylistProvider::save(QIODevice * device, const char *format) -{ - Q_UNUSED(device); - Q_UNUSED(format); - return false; -} - -/*! - Returns true if a playlist is read-only; otherwise returns false. -*/ -bool QMediaPlaylistProvider::isReadOnly() const -{ - return true; -} - -/*! - Append \a media to a playlist. - - Returns true if the media was appended; and false otherwise. -*/ -bool QMediaPlaylistProvider::addMedia(const QMediaContent &media) -{ - Q_UNUSED(media); - return false; -} - -/*! - Append multiple media \a items to a playlist. - - Returns true if the media items were appended; and false otherwise. -*/ -bool QMediaPlaylistProvider::addMedia(const QList &items) -{ - foreach(const QMediaContent &item, items) { - if (!addMedia(item)) - return false; - } - - return true; -} - -/*! - Inserts \a media into a playlist at \a position. - - Returns true if the media was inserted; and false otherwise. -*/ -bool QMediaPlaylistProvider::insertMedia(int position, const QMediaContent &media) -{ - Q_UNUSED(position); - Q_UNUSED(media); - return false; -} - -/*! - Inserts multiple media \a items into a playlist at \a position. - - Returns true if the media \a items were inserted; and false otherwise. -*/ -bool QMediaPlaylistProvider::insertMedia(int position, const QList &items) -{ - for (int i=0; i - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QString; - - -class QMediaPlaylistProviderPrivate; -class Q_MEDIASERVICES_EXPORT QMediaPlaylistProvider : public QObject -{ - Q_OBJECT - -public: - QMediaPlaylistProvider(QObject *parent=0); - virtual ~QMediaPlaylistProvider(); - - virtual bool load(const QUrl &location, const char *format = 0); - virtual bool load(QIODevice * device, const char *format = 0); - virtual bool save(const QUrl &location, const char *format = 0); - virtual bool save(QIODevice * device, const char *format); - - virtual int mediaCount() const = 0; - virtual QMediaContent media(int index) const = 0; - - virtual bool isReadOnly() const; - - virtual bool addMedia(const QMediaContent &content); - virtual bool addMedia(const QList &contentList); - virtual bool insertMedia(int index, const QMediaContent &content); - virtual bool insertMedia(int index, const QList &content); - virtual bool removeMedia(int pos); - virtual bool removeMedia(int start, int end); - virtual bool clear(); - -public Q_SLOTS: - virtual void shuffle(); - -Q_SIGNALS: - void mediaAboutToBeInserted(int start, int end); - void mediaInserted(int start, int end); - - void mediaAboutToBeRemoved(int start, int end); - void mediaRemoved(int start, int end); - - void mediaChanged(int start, int end); - - void loaded(); - void loadFailed(QMediaPlaylist::Error, const QString& errorMessage); - -protected: - QMediaPlaylistProviderPrivate *d_ptr; - QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent); - -private: - Q_DECLARE_PRIVATE(QMediaPlaylistProvider) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLISTPROVIDER_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylistprovider_p.h b/src/multimedia/mediaservices/base/qmediaplaylistprovider_p.h deleted file mode 100644 index 00d1cca..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistprovider_p.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIAPLAYLISTPROVIDER_P_H -#define QMEDIAPLAYLISTPROVIDER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlaylistProviderPrivate -{ -public: - QMediaPlaylistProviderPrivate() - {} - virtual ~QMediaPlaylistProviderPrivate() - {} -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLISTSOURCE_P_H diff --git a/src/multimedia/mediaservices/base/qmediapluginloader.cpp b/src/multimedia/mediaservices/base/qmediapluginloader.cpp deleted file mode 100644 index 8b0ddf4..0000000 --- a/src/multimedia/mediaservices/base/qmediapluginloader.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 "qmediapluginloader_p.h" -#include -#include -#include -#include - -#include - - -QT_BEGIN_NAMESPACE - - -typedef QMap ObjectListMap; -Q_GLOBAL_STATIC(ObjectListMap, staticMediaPlugins); - -QMediaPluginLoader::QMediaPluginLoader(const char *iid, const QString &location, Qt::CaseSensitivity): - m_iid(iid) -{ - m_location = location + QLatin1String("/"); - load(); -} - -QStringList QMediaPluginLoader::keys() const -{ - return m_instances.keys(); -} - -QObject* QMediaPluginLoader::instance(QString const &key) -{ - return m_instances.value(key); -} - -QList QMediaPluginLoader::instances(QString const &key) -{ - return m_instances.values(key); -} - -//to be used for testing purposes only -void QMediaPluginLoader::setStaticPlugins(const QString &location, const QObjectList& objects) -{ - staticMediaPlugins()->insert(location + QLatin1String("/"), objects); -} - -void QMediaPluginLoader::load() -{ - if (!m_instances.isEmpty()) - return; - - if (staticMediaPlugins() && staticMediaPlugins()->contains(m_location)) { - foreach(QObject *o, staticMediaPlugins()->value(m_location)) { - if (o != 0 && o->qt_metacast(m_iid) != 0) { - QFactoryInterface* p = qobject_cast(o); - if (p != 0) { - foreach (QString const &key, p->keys()) - m_instances.insertMulti(key, o); - } - } - } - } else { -#ifndef QT_NO_LIBRARY - QStringList paths = QCoreApplication::libraryPaths(); - - foreach (QString const &path, paths) { - QString pluginPathName(path + m_location); - QDir pluginDir(pluginPathName); - - if (!pluginDir.exists()) - continue; - - foreach (const QString &pluginLib, pluginDir.entryList(QDir::Files)) { -#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) - if (pluginLib.endsWith(QLatin1String(".debug"))) - continue; -#endif - QPluginLoader loader(pluginPathName + pluginLib); - - QObject *o = loader.instance(); - if (o != 0 && o->qt_metacast(m_iid) != 0) { - QFactoryInterface* p = qobject_cast(o); - if (p != 0) { - foreach (QString const &key, p->keys()) - m_instances.insertMulti(key, o); - } - - continue; - } else { - qWarning() << "QMediaPluginLoader: Failed to load plugin: " << pluginLib << loader.errorString(); - } - delete o; - loader.unload(); - } - } -#endif - } -} - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediapluginloader_p.h b/src/multimedia/mediaservices/base/qmediapluginloader_p.h deleted file mode 100644 index d911180..0000000 --- a/src/multimedia/mediaservices/base/qmediapluginloader_p.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIAPLUGINLOADER_H -#define QMEDIAPLUGINLOADER_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaServiceProviderPlugin; - -class Q_AUTOTEST_EXPORT QMediaPluginLoader -{ -public: - QMediaPluginLoader(const char *iid, - const QString &suffix = QString(), - Qt::CaseSensitivity = Qt::CaseSensitive); - - QStringList keys() const; - QObject* instance(QString const &key); - QList instances(QString const &key); - - static void setStaticPlugins(const QString &location, const QObjectList& objects); - -private: - void load(); - - QByteArray m_iid; - QString m_location; - QMap m_instances; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLUGINLOADER_H diff --git a/src/multimedia/mediaservices/base/qmediaresource.cpp b/src/multimedia/mediaservices/base/qmediaresource.cpp deleted file mode 100644 index 33bd396..0000000 --- a/src/multimedia/mediaservices/base/qmediaresource.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include -#include - -#include - - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaResource - \preliminary - \since 4.7 - \brief The QMediaResource class provides a description of a media resource. - \ingroup multimedia - - A media resource is composed of a \l {url()}{URL} containing the - location of the resource and a set of properties that describe the - format of the resource. The properties provide a means to assess a - resource without first attempting to load it, and in situations where - media be represented by multiple alternative representations provide a - means to select the appropriate resource. - - Media made available by a remote services can often be available in - multiple encodings or quality levels, this allows a client to select - an appropriate resource based on considerations such as codecs supported, - network bandwidth, and display constraints. QMediaResource includes - information such as the \l {mimeType()}{MIME type}, \l {audioCodec()}{audio} - and \l {videoCodec()}{video} codecs, \l {audioBitRate()}{audio} and - \l {videoBitRate()}{video} bit rates, and \l {resolution()}{resolution} - so these constraints and others can be evaluated. - - The only mandatory property of a QMediaResource is the url(). - - \sa QMediaContent -*/ - -/*! - \typedef QMediaResourceList - - Synonym for \c QList -*/ - -/*! - Constructs a null media resource. -*/ -QMediaResource::QMediaResource() -{ -} - -/*! - Constructs a media resource with the given \a mimeType from a \a url. -*/ -QMediaResource::QMediaResource(const QUrl &url, const QString &mimeType) -{ - values.insert(Url, url); - values.insert(MimeType, mimeType); -} - -/*! - Constructs a media resource with the given \a mimeType from a network \a request. -*/ -QMediaResource::QMediaResource(const QNetworkRequest &request, const QString &mimeType) -{ - values.insert(Request, QVariant::fromValue(request)); - values.insert(Url, request.url()); - values.insert(MimeType, mimeType); -} - -/*! - Constructs a copy of a media resource \a other. -*/ -QMediaResource::QMediaResource(const QMediaResource &other) - : values(other.values) -{ -} - -/*! - Assigns the value of \a other to a media resource. -*/ -QMediaResource &QMediaResource::operator =(const QMediaResource &other) -{ - values = other.values; - - return *this; -} - -/*! - Destroys a media resource. -*/ -QMediaResource::~QMediaResource() -{ -} - - -/*! - Compares a media resource to \a other. - - Returns true if the resources are identical, and false otherwise. -*/ -bool QMediaResource::operator ==(const QMediaResource &other) const -{ - return values == other.values; -} - -/*! - Compares a media resource to \a other. - - Returns true if they are different, and false otherwise. -*/ -bool QMediaResource::operator !=(const QMediaResource &other) const -{ - return values != other.values; -} - -/*! - Identifies if a media resource is null. - - Returns true if the resource is null, and false otherwise. -*/ -bool QMediaResource::isNull() const -{ - return values.isEmpty(); -} - -/*! - Returns the URL of a media resource. -*/ -QUrl QMediaResource::url() const -{ - return qvariant_cast(values.value(Url)); -} - -/*! - Returns the network request associated with this media resource. -*/ -QNetworkRequest QMediaResource::request() const -{ - if(values.contains(Request)) - return qvariant_cast(values.value(Request)); - - return QNetworkRequest(url()); -} - -/*! - Returns the MIME type of a media resource. - - This may be null if the MIME type is unknown. -*/ -QString QMediaResource::mimeType() const -{ - return qvariant_cast(values.value(MimeType)); -} - -/*! - Returns the language of a media resource as an ISO 639-2 code. - - This may be null if the language is unknown. -*/ -QString QMediaResource::language() const -{ - return qvariant_cast(values.value(Language)); -} - -/*! - Sets the \a language of a media resource. -*/ -void QMediaResource::setLanguage(const QString &language) -{ - if (!language.isNull()) - values.insert(Language, language); - else - values.remove(Language); -} - -/*! - Returns the audio codec of a media resource. - - This may be null if the media resource does not contain an audio stream, or the codec is - unknown. -*/ -QString QMediaResource::audioCodec() const -{ - return qvariant_cast(values.value(AudioCodec)); -} - -/*! - Sets the audio \a codec of a media resource. -*/ -void QMediaResource::setAudioCodec(const QString &codec) -{ - if (!codec.isNull()) - values.insert(AudioCodec, codec); - else - values.remove(AudioCodec); -} - -/*! - Returns the video codec of a media resource. - - This may be null if the media resource does not contain a video stream, or the codec is - unknonwn. -*/ -QString QMediaResource::videoCodec() const -{ - return qvariant_cast(values.value(VideoCodec)); -} - -/*! - Sets the video \a codec of media resource. -*/ -void QMediaResource::setVideoCodec(const QString &codec) -{ - if (!codec.isNull()) - values.insert(VideoCodec, codec); - else - values.remove(VideoCodec); -} - -/*! - Returns the size in bytes of a media resource. - - This may be zero if the size is unknown. -*/ -qint64 QMediaResource::dataSize() const -{ - return qvariant_cast(values.value(DataSize)); -} - -/*! - Sets the \a size in bytes of a media resource. -*/ -void QMediaResource::setDataSize(const qint64 size) -{ - if (size != 0) - values.insert(DataSize, size); - else - values.remove(DataSize); -} - -/*! - Returns the bit rate in bits per second of a media resource's audio stream. - - This may be zero if the bit rate is unknown, or the resource contains no audio stream. -*/ -int QMediaResource::audioBitRate() const -{ - return values.value(AudioBitRate).toInt(); -} - -/*! - Sets the bit \a rate in bits per second of a media resource's video stream. -*/ -void QMediaResource::setAudioBitRate(int rate) -{ - if (rate != 0) - values.insert(AudioBitRate, rate); - else - values.remove(AudioBitRate); -} - -/*! - Returns the audio sample rate of a media resource. - - This may be zero if the sample size is unknown, or the resource contains no audio stream. -*/ -int QMediaResource::sampleRate() const -{ - return qvariant_cast(values.value(SampleRate)); -} - -/*! - Sets the audio \a sampleRate of a media resource. -*/ -void QMediaResource::setSampleRate(int sampleRate) -{ - if (sampleRate != 0) - values.insert(SampleRate, sampleRate); - else - values.remove(SampleRate); -} - -/*! - Returns the number of audio channels in a media resource. - - This may be zero if the sample size is unknown, or the resource contains no audio stream. -*/ -int QMediaResource::channelCount() const -{ - return qvariant_cast(values.value(ChannelCount)); -} - -/*! - Sets the number of audio \a channels in a media resource. -*/ -void QMediaResource::setChannelCount(int channels) -{ - if (channels != 0) - values.insert(ChannelCount, channels); - else - values.remove(ChannelCount); -} - -/*! - Returns the bit rate in bits per second of a media resource's video stream. - - This may be zero if the bit rate is unknown, or the resource contains no video stream. -*/ -int QMediaResource::videoBitRate() const -{ - return values.value(VideoBitRate).toInt(); -} - -/*! - Sets the bit \a rate in bits per second of a media resource's video stream. -*/ -void QMediaResource::setVideoBitRate(int rate) -{ - if (rate != 0) - values.insert(VideoBitRate, rate); - else - values.remove(VideoBitRate); -} - -/*! - Returns the resolution in pixels of a media resource. - - This may be null is the resolution is unknown, or the resource contains no pixel data (i.e. the - resource is an audio stream. -*/ -QSize QMediaResource::resolution() const -{ - return qvariant_cast(values.value(Resolution)); -} - -/*! - Sets the \a resolution in pixels of a media resource. -*/ -void QMediaResource::setResolution(const QSize &resolution) -{ - if (resolution.width() != -1 || resolution.height() != -1) - values.insert(Resolution, resolution); - else - values.remove(Resolution); -} - -/*! - Sets the \a width and \a height in pixels of a media resource. -*/ -void QMediaResource::setResolution(int width, int height) -{ - if (width != -1 || height != -1) - values.insert(Resolution, QSize(width, height)); - else - values.remove(Resolution); -} -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediaresource.h b/src/multimedia/mediaservices/base/qmediaresource.h deleted file mode 100644 index 0ecf008..0000000 --- a/src/multimedia/mediaservices/base/qmediaresource.h +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIARESOURCE_H -#define QMEDIARESOURCE_H - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MEDIASERVICES_EXPORT QMediaResource -{ -public: - QMediaResource(); - QMediaResource(const QUrl &url, const QString &mimeType = QString()); - QMediaResource(const QNetworkRequest &request, const QString &mimeType = QString()); - QMediaResource(const QMediaResource &other); - QMediaResource &operator =(const QMediaResource &other); - ~QMediaResource(); - - bool isNull() const; - - bool operator ==(const QMediaResource &other) const; - bool operator !=(const QMediaResource &other) const; - - QUrl url() const; - QNetworkRequest request() const; - QString mimeType() const; - - QString language() const; - void setLanguage(const QString &language); - - QString audioCodec() const; - void setAudioCodec(const QString &codec); - - QString videoCodec() const; - void setVideoCodec(const QString &codec); - - qint64 dataSize() const; - void setDataSize(const qint64 size); - - int audioBitRate() const; - void setAudioBitRate(int rate); - - int sampleRate() const; - void setSampleRate(int frequency); - - int channelCount() const; - void setChannelCount(int channels); - - int videoBitRate() const; - void setVideoBitRate(int rate); - - QSize resolution() const; - void setResolution(const QSize &resolution); - void setResolution(int width, int height); - - -private: - enum Property - { - Url, - Request, - MimeType, - Language, - AudioCodec, - VideoCodec, - DataSize, - AudioBitRate, - VideoBitRate, - SampleRate, - ChannelCount, - Resolution - }; - QMap values; -}; - -typedef QList QMediaResourceList; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaResource) -Q_DECLARE_METATYPE(QMediaResourceList) - -QT_END_HEADER - - -#endif diff --git a/src/multimedia/mediaservices/base/qmediaservice.cpp b/src/multimedia/mediaservices/base/qmediaservice.cpp deleted file mode 100644 index b343887..0000000 --- a/src/multimedia/mediaservices/base/qmediaservice.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 - -#include -#include "qmediaservice_p.h" - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -/*! - \class QMediaService - \brief The QMediaService class provides a common base class for media - service implementations. - \ingroup multimedia-serv - \preliminary - \since 4.7 - - Media services provide implementations of the functionality promised - by media objects, and allow multiple providers to implement a QMediaObject. - - To provide the functionality of a QMediaObject media services implement - QMediaControl interfaces. Services typically implement one core media - control which provides the core feature of a media object, and some - number of additional controls which provide either optional features of - the media object, or features of a secondary media object or peripheral - object. - - A pointer to media service's QMediaControl implementation can be - obtained by passing the control's interface name to the control() function. - - \code - QMediaPlayerControl *control = qobject_cast( - service->control("com.nokia.Qt.QMediaPlayerControl/1.0")); - \endcode - - Media objects can use services loaded dynamically from plug-ins or - implemented statically within an applications. Plug-in based services - should also implement the QMediaServiceProviderPlugin interface. Static - services should implement the QMediaServiceProvider interface. - - \sa QMediaObject, QMediaControl, QMediaServiceProvider, QMediaServiceProviderPlugin -*/ - -/*! - Construct a media service with the given \a parent. This class is meant as a - base class for Multimedia services so this constructor is protected. -*/ - -QMediaService::QMediaService(QObject *parent) - : QObject(parent) - , d_ptr(new QMediaServicePrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - \internal -*/ -QMediaService::QMediaService(QMediaServicePrivate &dd, QObject *parent) - : QObject(parent) - , d_ptr(&dd) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys a media service. -*/ - -QMediaService::~QMediaService() -{ - delete d_ptr; -} - -/*! - \fn QMediaService::control(const char *interface) const - - Returns a pointer to the media control implementing \a interface. - - If the service does not implement the control a null pointer is returned instead. -*/ - -/*! - \fn QMediaService::control() const - - Returns a pointer to the media control of type T implemented by a media service. - - If the service does not implment the control a null pointer is returned instead. -*/ - -#include "moc_qmediaservice.cpp" - -QT_END_NAMESPACE - -QT_END_HEADER - diff --git a/src/multimedia/mediaservices/base/qmediaservice.h b/src/multimedia/mediaservices/base/qmediaservice.h deleted file mode 100644 index 5df3fd7..0000000 --- a/src/multimedia/mediaservices/base/qmediaservice.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QABSTRACTMEDIASERVICE_H -#define QABSTRACTMEDIASERVICE_H - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaServicePrivate; -class Q_MEDIASERVICES_EXPORT QMediaService : public QObject -{ - Q_OBJECT - -public: - ~QMediaService(); - - virtual QMediaControl* control(const char *name) const = 0; - -#ifndef QT_NO_MEMBER_TEMPLATES - template inline T control() const { - if (QObject *object = control(qmediacontrol_iid())) { - return qobject_cast(object); - } - return 0; - } -#endif - -protected: - QMediaService(QObject* parent); - QMediaService(QMediaServicePrivate &dd, QObject *parent); - - QMediaServicePrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QMediaService) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QABSTRACTMEDIASERVICE_H - diff --git a/src/multimedia/mediaservices/base/qmediaservice_p.h b/src/multimedia/mediaservices/base/qmediaservice_p.h deleted file mode 100644 index bebae11..0000000 --- a/src/multimedia/mediaservices/base/qmediaservice_p.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QABSTRACTMEDIASERVICE_P_H -#define QABSTRACTMEDIASERVICE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QAudioDeviceControl; - -class QMediaServicePrivate -{ -public: - QMediaServicePrivate(): q_ptr(0) {} - virtual ~QMediaServicePrivate() {} - - QMediaService *q_ptr; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qmediaserviceprovider.cpp b/src/multimedia/mediaservices/base/qmediaserviceprovider.cpp deleted file mode 100644 index f27628b..0000000 --- a/src/multimedia/mediaservices/base/qmediaserviceprovider.cpp +++ /dev/null @@ -1,738 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include - -#include -#include -#include -#include "qmediapluginloader_p.h" -#include - -QT_BEGIN_NAMESPACE - -class QMediaServiceProviderHintPrivate : public QSharedData -{ -public: - QMediaServiceProviderHintPrivate(QMediaServiceProviderHint::Type type) - :type(type), features(0) - { - } - - QMediaServiceProviderHintPrivate(const QMediaServiceProviderHintPrivate &other) - :QSharedData(other), - type(other.type), - device(other.device), - mimeType(other.mimeType), - codecs(other.codecs), - features(other.features) - { - } - - ~QMediaServiceProviderHintPrivate() - { - } - - QMediaServiceProviderHint::Type type; - QByteArray device; - QString mimeType; - QStringList codecs; - QMediaServiceProviderHint::Features features; -}; - -/*! - \class QMediaServiceProviderHint - \preliminary - \since 4.7 - \brief The QMediaServiceProviderHint class describes what is required of a QMediaService. - - \ingroup multimedia-serv - - The QMediaServiceProvider class uses hints to select an appropriate media service. -*/ - -/*! - \enum QMediaServiceProviderHint::Feature - - Enumerates features a media service may provide. - - \value LowLatencyPlayback - The service is expected to play simple audio formats, - but playback should start without significant delay. - Such playback service can be used for beeps, ringtones, etc. - - \value RecordingSupport - The service provides audio or video recording functions. - - \value StreamPlayback - The service is capable of playing QIODevice based streams. -*/ - -/*! - \enum QMediaServiceProviderHint::Type - - Enumerates the possible types of media service provider hint. - - \value Null En empty hint, use the default service. - \value ContentType Select media service most suitable for certain content type. - \value Device Select media service which supports certain device. - \value SupportedFeatures Select media service supporting the set of optional features. -*/ - - -/*! - Constructs an empty media service provider hint. -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint() - :d(new QMediaServiceProviderHintPrivate(Null)) -{ -} - -/*! - Constructs a ContentType media service provider hint. - - This type of hint describes a service that is able to play content of a specific MIME \a type - encoded with one or more of the listed \a codecs. -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(const QString &type, const QStringList& codecs) - :d(new QMediaServiceProviderHintPrivate(ContentType)) -{ - d->mimeType = type; - d->codecs = codecs; -} - -/*! - Constructs a Device media service provider hint. - - This type of hint describes a media service that utilizes a specific \a device. -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(const QByteArray &device) - :d(new QMediaServiceProviderHintPrivate(Device)) -{ - d->device = device; -} - -/*! - Constructs a SupportedFeatures media service provider hint. - - This type of hint describes a service which supports a specific set of \a features. -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(QMediaServiceProviderHint::Features features) - :d(new QMediaServiceProviderHintPrivate(SupportedFeatures)) -{ - d->features = features; -} - -/*! - Constructs a copy of the media service provider hint \a other. -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(const QMediaServiceProviderHint &other) - :d(other.d) -{ -} - -/*! - Destroys a media service provider hint. -*/ -QMediaServiceProviderHint::~QMediaServiceProviderHint() -{ -} - -/*! - Assigns the value \a other to a media service provider hint. -*/ -QMediaServiceProviderHint& QMediaServiceProviderHint::operator=(const QMediaServiceProviderHint &other) -{ - d = other.d; - return *this; -} - -/*! - Identifies if \a other is of equal value to a media service provider hint. - - Returns true if the hints are equal, and false if they are not. -*/ -bool QMediaServiceProviderHint::operator == (const QMediaServiceProviderHint &other) const -{ - return (d == other.d) || - (d->type == other.d->type && - d->device == other.d->device && - d->mimeType == other.d->mimeType && - d->codecs == other.d->codecs && - d->features == other.d->features); -} - -/*! - Identifies if \a other is not of equal value to a media service provider hint. - - Returns true if the hints are not equal, and false if they are. -*/ -bool QMediaServiceProviderHint::operator != (const QMediaServiceProviderHint &other) const -{ - return !(*this == other); -} - -/*! - Returns true if a media service provider is null. -*/ -bool QMediaServiceProviderHint::isNull() const -{ - return d->type == Null; -} - -/*! - Returns the type of a media service provider hint. -*/ -QMediaServiceProviderHint::Type QMediaServiceProviderHint::type() const -{ - return d->type; -} - -/*! - Returns the mime type of the media a service is expected to be able play. -*/ -QString QMediaServiceProviderHint::mimeType() const -{ - return d->mimeType; -} - -/*! - Returns a list of codes a media service is expected to be able to decode. -*/ -QStringList QMediaServiceProviderHint::codecs() const -{ - return d->codecs; -} - -/*! - Returns the name of a device a media service is expected to utilize. -*/ -QByteArray QMediaServiceProviderHint::device() const -{ - return d->device; -} - -/*! - Returns a set of features a media service is expected to provide. -*/ -QMediaServiceProviderHint::Features QMediaServiceProviderHint::features() const -{ - return d->features; -} - - -Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, loader, - (QMediaServiceProviderFactoryInterface_iid, QLatin1String("/mediaservices"), Qt::CaseInsensitive)) - - -class QPluginServiceProvider : public QMediaServiceProvider -{ - QMap pluginMap; - -public: - QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &hint) - { - QString key(QString::fromLatin1(type.constData(),type.length())); - - QListplugins; - foreach (QObject *obj, loader()->instances(key)) { - QMediaServiceProviderPlugin *plugin = - qobject_cast(obj); - if (plugin) - plugins << plugin; - } - - if (!plugins.isEmpty()) { - QMediaServiceProviderPlugin *plugin = 0; - - switch (hint.type()) { - case QMediaServiceProviderHint::Null: - plugin = plugins[0]; - //special case for media player, if low latency was not asked, - //prefer services not offering it, since they are likely to support - //more formats - if (type == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)) { - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QMediaServiceFeaturesInterface *iface = - qobject_cast(currentPlugin); - - if (!iface || !(iface->supportedFeatures(type) & - QMediaServiceProviderHint::LowLatencyPlayback)) { - plugin = currentPlugin; - break; - } - - } - } - break; - case QMediaServiceProviderHint::SupportedFeatures: - plugin = plugins[0]; - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QMediaServiceFeaturesInterface *iface = - qobject_cast(currentPlugin); - - if (iface) { - if ((iface->supportedFeatures(type) & hint.features()) == hint.features()) { - plugin = currentPlugin; - break; - } - } - } - break; - case QMediaServiceProviderHint::Device: { - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QMediaServiceSupportedDevicesInterface *iface = - qobject_cast(currentPlugin); - - if (!iface) { - // the plugin may support the device, - // but this choice still can be overridden - plugin = currentPlugin; - } else { - if (iface->devices(type).contains(hint.device())) { - plugin = currentPlugin; - break; - } - } - } - } - break; - case QMediaServiceProviderHint::ContentType: { - QtMediaServices::SupportEstimate estimate = QtMediaServices::NotSupported; - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QtMediaServices::SupportEstimate currentEstimate = QtMediaServices::MaybeSupported; - QMediaServiceSupportedFormatsInterface *iface = - qobject_cast(currentPlugin); - - if (iface) - currentEstimate = iface->hasSupport(hint.mimeType(), hint.codecs()); - - if (currentEstimate > estimate) { - estimate = currentEstimate; - plugin = currentPlugin; - - if (currentEstimate == QtMediaServices::PreferredService) - break; - } - } - } - break; - } - - if (plugin != 0) { - QMediaService *service = plugin->create(key); - if (service != 0) - pluginMap.insert(service, plugin); - - return service; - } - } - - qWarning() << "defaultServiceProvider::requestService(): no service found for -" << key; - return 0; - } - - void releaseService(QMediaService *service) - { - if (service != 0) { - QMediaServiceProviderPlugin *plugin = pluginMap.take(service); - - if (plugin != 0) - plugin->release(service); - } - } - - QtMediaServices::SupportEstimate hasSupport(const QByteArray &serviceType, - const QString &mimeType, - const QStringList& codecs, - int flags) const - { - QList instances = loader()->instances( - QString::fromLatin1(serviceType.constData(),serviceType.length())); - - if (instances.isEmpty()) - return QtMediaServices::NotSupported; - - bool allServicesProvideInterface = true; - QtMediaServices::SupportEstimate supportEstimate = QtMediaServices::NotSupported; - - foreach(QObject *obj, instances) { - QMediaServiceSupportedFormatsInterface *iface = - qobject_cast(obj); - - - if (flags) { - QMediaServiceFeaturesInterface *iface = - qobject_cast(obj); - - if (iface) { - QMediaServiceProviderHint::Features features = iface->supportedFeatures(serviceType); - - //if low latency playback was asked, skip services known - //not to provide low latency playback - if ((flags & QMediaPlayer::LowLatency) && - !(features & QMediaServiceProviderHint::LowLatencyPlayback)) - continue; - - //the same for QIODevice based streams support - if ((flags & QMediaPlayer::StreamPlayback) && - !(features & QMediaServiceProviderHint::StreamPlayback)) - continue; - } - } - - if (iface) - supportEstimate = qMax(supportEstimate, iface->hasSupport(mimeType, codecs)); - else - allServicesProvideInterface = false; - } - - //don't return PreferredService - supportEstimate = qMin(supportEstimate, QtMediaServices::ProbablySupported); - - //Return NotSupported only if no services are available of serviceType - //or all the services returned NotSupported, otherwise return at least MaybeSupported - if (!allServicesProvideInterface) - supportEstimate = qMax(QtMediaServices::MaybeSupported, supportEstimate); - - return supportEstimate; - } - - QStringList supportedMimeTypes(const QByteArray &serviceType, int flags) const - { - QList instances = loader()->instances( - QString::fromLatin1(serviceType.constData(),serviceType.length())); - - QStringList supportedTypes; - - foreach(QObject *obj, instances) { - QMediaServiceSupportedFormatsInterface *iface = - qobject_cast(obj); - - - if (flags & QMediaPlayer::LowLatency) { - QMediaServiceFeaturesInterface *iface = - qobject_cast(obj); - - if (iface) { - QMediaServiceProviderHint::Features features = iface->supportedFeatures(serviceType); - - // If low latency playback was asked for, skip MIME types from services known - // not to provide low latency playback - if ((flags & QMediaPlayer::LowLatency) && - !(features & QMediaServiceProviderHint::LowLatencyPlayback)) - continue; - - //the same for QIODevice based streams support - if ((flags & QMediaPlayer::StreamPlayback) && - !(features & QMediaServiceProviderHint::StreamPlayback)) - continue; - } - } - - if (iface) { - supportedTypes << iface->supportedMimeTypes(); - } - } - - // Multiple services may support the same MIME type - supportedTypes.removeDuplicates(); - - return supportedTypes; - } - - QList devices(const QByteArray &serviceType) const - { - QList res; - - foreach(QObject *obj, loader()->instances( - QString::fromLatin1(serviceType.constData(),serviceType.length()))) { - QMediaServiceSupportedDevicesInterface *iface = - qobject_cast(obj); - - if (iface) { - res.append(iface->devices(serviceType)); - } - } - - return res; - } - - QString deviceDescription(const QByteArray &serviceType, const QByteArray &device) - { - foreach(QObject *obj, loader()->instances( - QString::fromLatin1(serviceType.constData(),serviceType.length()))) { - QMediaServiceSupportedDevicesInterface *iface = - qobject_cast(obj); - - if (iface) { - if (iface->devices(serviceType).contains(device)) - return iface->deviceDescription(serviceType, device); - } - } - - return QString(); - } -}; - -Q_GLOBAL_STATIC(QPluginServiceProvider, pluginProvider); - -/*! - \class QMediaServiceProvider - \preliminary - \since 4.7 - \brief The QMediaServiceProvider class provides an abstract allocator for media services. -*/ - -/*! - \fn QMediaServiceProvider::requestService(const QByteArray &type, const QMediaServiceProviderHint &hint) - - Requests an instance of a \a type service which best matches the given \a hint. - - Returns a pointer to the requested service, or a null pointer if there is no suitable service. - - The returned service must be released with releaseService when it is finished with. -*/ - -/*! - \fn QMediaServiceProvider::releaseService(QMediaService *service) - - Releases a media \a service requested with requestService(). -*/ - -/*! - \fn QtMediaServices::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType, const QString &mimeType, const QStringList& codecs, int flags) const - - Returns how confident a media service provider is that is can provide a \a serviceType - service that is able to play media of a specific \a mimeType that is encoded using the listed - \a codecs while adhearing to constraints identified in \a flags. -*/ -QtMediaServices::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType, - const QString &mimeType, - const QStringList& codecs, - int flags) const -{ - Q_UNUSED(serviceType); - Q_UNUSED(mimeType); - Q_UNUSED(codecs); - Q_UNUSED(flags); - - return QtMediaServices::MaybeSupported; -} - -/*! - \fn QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const - - Returns a list of MIME types supported by the service provider for the specified \a serviceType. - - The resultant list is restricted to MIME types which can be supported given the constraints in \a flags. -*/ -QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const -{ - Q_UNUSED(serviceType); - Q_UNUSED(flags); - - return QStringList(); -} - -/*! - Returns the list of devices related to \a service type. -*/ -QList QMediaServiceProvider::devices(const QByteArray &service) const -{ - Q_UNUSED(service); - return QList(); -} - -/*! - Returns the description of \a device related to \a serviceType, - suitable to be displayed to user. -*/ -QString QMediaServiceProvider::deviceDescription(const QByteArray &serviceType, const QByteArray &device) -{ - Q_UNUSED(serviceType); - Q_UNUSED(device); - return QString(); -} - - -#ifdef QT_BUILD_INTERNAL - -static QMediaServiceProvider *qt_defaultMediaServiceProvider = 0; - -/*! - Sets a media service \a provider as the default. - - \internal -*/ -void QMediaServiceProvider::setDefaultServiceProvider(QMediaServiceProvider *provider) -{ - qt_defaultMediaServiceProvider = provider; -} - -#endif - -/*! - Returns a default provider of media services. -*/ -QMediaServiceProvider *QMediaServiceProvider::defaultServiceProvider() -{ -#ifdef QT_BUILD_INTERNAL - return qt_defaultMediaServiceProvider != 0 - ? qt_defaultMediaServiceProvider - : static_cast(pluginProvider()); -#else - return pluginProvider(); -#endif -} - -/*! - \class QMediaServiceProviderPlugin - \preliminary - \since 4.7 - \brief The QMediaServiceProviderPlugin class interface provides an interface for QMediaService - plug-ins. - - A media service provider plug-in may implement one or more of - QMediaServiceSupportedFormatsInterface, QMediaServiceSupportedDevicesInterface, - and QMediaServiceFeaturesInterface to identify the features it supports. -*/ - -/*! - \fn QMediaServiceProviderPlugin::keys() const - - Returns a list of keys for media services a plug-in can create. -*/ - -/*! - \fn QMediaServiceProviderPlugin::create(const QString &key) - - Constructs a new instance of the QMediaService identified by \a key. - - The QMediaService returned must be destroyed with release(). -*/ - -/*! - \fn QMediaServiceProviderPlugin::release(QMediaService *service) - - Destroys a media \a service constructed with create(). -*/ - - -/*! - \class QMediaServiceSupportedFormatsInterface - \brief The QMediaServiceSupportedFormatsInterface class interface - identifies if a media service plug-in supports a media format. - \since 4.7 - - A QMediaServiceProviderPlugin may implement this interface. -*/ - -/*! - \fn QMediaServiceSupportedFormatsInterface::~QMediaServiceSupportedFormatsInterface() - - Destroys a media service supported formats interface. -*/ - -/*! - \fn QMediaServiceSupportedFormatsInterface::hasSupport(const QString &mimeType, const QStringList& codecs) const - - Returns the level of support a media service plug-in has for a \a mimeType and set of \a codecs. -*/ - -/*! - \fn QMediaServiceSupportedFormatsInterface::supportedMimeTypes() const - - Returns a list of MIME types supported by the media service plug-in. -*/ - -/*! - \class QMediaServiceSupportedDevicesInterface - \brief The QMediaServiceSupportedDevicesInterface class interface - identifies the devices supported by a media service plug-in. - \since 4.7 - - A QMediaServiceProviderPlugin may implement this interface. -*/ - -/*! - \fn QMediaServiceSupportedDevicesInterface::~QMediaServiceSupportedDevicesInterface() - - Destroys a media service supported devices interface. -*/ - -/*! - \fn QMediaServiceSupportedDevicesInterface::devices(const QByteArray &service) const - - Returns a list of devices supported by a plug-in \a service. -*/ - -/*! - \fn QMediaServiceSupportedDevicesInterface::deviceDescription(const QByteArray &service, const QByteArray &device) - - Returns a description of a \a device supported by a plug-in \a service. -*/ - -/*! - \class QMediaServiceFeaturesInterface - \brief The QMediaServiceFeaturesInterface class interface identifies - features supported by a media service plug-in. - \since 4.7 - - A QMediaServiceProviderPlugin may implement this interface. -*/ - -/*! - \fn QMediaServiceFeaturesInterface::~QMediaServiceFeaturesInterface() - - Destroys a media service features interface. -*/ -/*! - \fn QMediaServiceFeaturesInterface::supportedFeatures(const QByteArray &service) const - - Returns a set of features supported by a plug-in \a service. -*/ - -QT_END_NAMESPACE - -#include "moc_qmediaserviceprovider.cpp" -#include "moc_qmediaserviceproviderplugin.cpp" diff --git a/src/multimedia/mediaservices/base/qmediaserviceprovider.h b/src/multimedia/mediaservices/base/qmediaserviceprovider.h deleted file mode 100644 index eeea5d2..0000000 --- a/src/multimedia/mediaservices/base/qmediaserviceprovider.h +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIASERVICEPROVIDER_H -#define QMEDIASERVICEPROVIDER_H - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaService; - -class QMediaServiceProviderHintPrivate; -class Q_MEDIASERVICES_EXPORT QMediaServiceProviderHint -{ -public: - enum Type { Null, ContentType, Device, SupportedFeatures }; - - enum Feature { - LowLatencyPlayback = 0x01, - RecordingSupport = 0x02, - StreamPlayback = 0x04 - }; - Q_DECLARE_FLAGS(Features, Feature) - - QMediaServiceProviderHint(); - QMediaServiceProviderHint(const QString &mimeType, const QStringList& codecs); - QMediaServiceProviderHint(const QByteArray &device); - QMediaServiceProviderHint(Features features); - QMediaServiceProviderHint(const QMediaServiceProviderHint &other); - ~QMediaServiceProviderHint(); - - QMediaServiceProviderHint& operator=(const QMediaServiceProviderHint &other); - - bool operator == (const QMediaServiceProviderHint &other) const; - bool operator != (const QMediaServiceProviderHint &other) const; - - bool isNull() const; - - Type type() const; - - QString mimeType() const; - QStringList codecs() const; - - QByteArray device() const; - - Features features() const; - - //to be extended, if necessary - -private: - QSharedDataPointer d; -}; - -class Q_MEDIASERVICES_EXPORT QMediaServiceProvider : public QObject -{ - Q_OBJECT - -public: - virtual QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &hint = QMediaServiceProviderHint()) = 0; - virtual void releaseService(QMediaService *service) = 0; - - virtual QtMediaServices::SupportEstimate hasSupport(const QByteArray &serviceType, - const QString &mimeType, - const QStringList& codecs, - int flags = 0) const; - virtual QStringList supportedMimeTypes(const QByteArray &serviceType, int flags = 0) const; - - virtual QList devices(const QByteArray &serviceType) const; - virtual QString deviceDescription(const QByteArray &serviceType, const QByteArray &device); - - static QMediaServiceProvider* defaultServiceProvider(); - -#ifdef QT_BUILD_INTERNAL - static void setDefaultServiceProvider(QMediaServiceProvider *provider); -#endif -}; - -/*! - Service with support for media playback - Required Controls: QMediaPlayerControl - Optional Controls: QMediaPlaylistControl, QAudioDeviceControl - Video Output Controls (used by QWideoWidget and QGraphicsVideoItem): - Required: QVideoOutputControl - Optional: QVideoWindowControl, QVideoRendererControl, QVideoWidgetControl -*/ -#define Q_MEDIASERVICE_MEDIAPLAYER "com.nokia.qt.mediaplayer" - -/*! - Service with support for recording from audio sources - Required Controls: QAudioDeviceControl - Recording Controls (QMediaRecorder): - Required: QMediaRecorderControl - Recommended: QAudioEncoderControl - Optional: QMediaContainerControl -*/ -#define Q_MEDIASERVICE_AUDIOSOURCE "com.nokia.qt.audiosource" - -/*! - Service with support for camera use. - Required Controls: QCameraControl - Optional Controls: QCameraExposureControl, QCameraFocusControl, QImageProcessingControl - Still Capture Controls: QImageCaptureControl - Recording Controls (QMediaRecorder): - Required: QMediaRecorderControl - Recommended: QAudioEncoderControl, QVideoEncoderControl, QMediaContainerControl - Viewfinder Video Output Controls (used by QWideoWidget and QGraphicsVideoItem): - Required: QVideoOutputControl - Optional: QVideoWindowControl, QVideoRendererControl, QVideoWidgetControl -*/ -#define Q_MEDIASERVICE_CAMERA "com.nokia.qt.camera" - -/*! - Service with support for radio tuning. - Required Controls: QRadioTunerControl - Recording Controls (Optional, used by QMediaRecorder): - Required: QMediaRecorderControl - Recommended: QAudioEncoderControl - Optional: QMediaContainerControl -*/ -#define Q_MEDIASERVICE_RADIO "com.nokia.qt.radio" - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIASERVICEPROVIDER_H diff --git a/src/multimedia/mediaservices/base/qmediaserviceproviderplugin.h b/src/multimedia/mediaservices/base/qmediaserviceproviderplugin.h deleted file mode 100644 index ca25f91..0000000 --- a/src/multimedia/mediaservices/base/qmediaserviceproviderplugin.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIASERVICEPROVIDERPLUGIN_H -#define QMEDIASERVICEPROVIDERPLUGIN_H - -#include -#include -#include - -#include - -#ifdef Q_MOC_RUN -# pragma Q_MOC_EXPAND_MACROS -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaService; - - -struct Q_MEDIASERVICES_EXPORT QMediaServiceProviderFactoryInterface : public QFactoryInterface -{ - virtual QStringList keys() const = 0; - virtual QMediaService* create(QString const& key) = 0; - virtual void release(QMediaService *service) = 0; -}; - -#define QMediaServiceProviderFactoryInterface_iid \ - "com.nokia.Qt.QMediaServiceProviderFactoryInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceProviderFactoryInterface, QMediaServiceProviderFactoryInterface_iid) - - -struct Q_MEDIASERVICES_EXPORT QMediaServiceSupportedFormatsInterface -{ - virtual ~QMediaServiceSupportedFormatsInterface() {} - virtual QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const = 0; - virtual QStringList supportedMimeTypes() const = 0; -}; - -#define QMediaServiceSupportedFormatsInterface_iid \ - "com.nokia.Qt.QMediaServiceSupportedFormatsInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceSupportedFormatsInterface, QMediaServiceSupportedFormatsInterface_iid) - - -struct Q_MEDIASERVICES_EXPORT QMediaServiceSupportedDevicesInterface -{ - virtual ~QMediaServiceSupportedDevicesInterface() {} - virtual QList devices(const QByteArray &service) const = 0; - virtual QString deviceDescription(const QByteArray &service, const QByteArray &device) = 0; -}; - -#define QMediaServiceSupportedDevicesInterface_iid \ - "com.nokia.Qt.QMediaServiceSupportedDevicesInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceSupportedDevicesInterface, QMediaServiceSupportedDevicesInterface_iid) - - -struct Q_MEDIASERVICES_EXPORT QMediaServiceFeaturesInterface -{ - virtual ~QMediaServiceFeaturesInterface() {} - virtual QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const = 0; -}; - -#define QMediaServiceFeaturesInterface_iid \ - "com.nokia.Qt.QMediaServiceFeaturesInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceFeaturesInterface, QMediaServiceFeaturesInterface_iid) - -class Q_MEDIASERVICES_EXPORT QMediaServiceProviderPlugin : public QObject, public QMediaServiceProviderFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceProviderFactoryInterface:QFactoryInterface) - -public: - virtual QStringList keys() const = 0; - virtual QMediaService* create(const QString& key) = 0; - virtual void release(QMediaService *service) = 0; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIASERVICEPROVIDERPLUGIN_H diff --git a/src/multimedia/mediaservices/base/qmediatimerange.cpp b/src/multimedia/mediaservices/base/qmediatimerange.cpp deleted file mode 100644 index 2dba20c..0000000 --- a/src/multimedia/mediaservices/base/qmediatimerange.cpp +++ /dev/null @@ -1,708 +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 QtMediaServices 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 - - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaTimeInterval - \brief The QMediaTimeInterval class represents a time interval with integer precision. - \ingroup multimedia - \since 4.7 - - An interval is specified by an inclusive start() and end() time. - These must be set in the constructor, as this is an immutable class. - The specific units of time represented by the class have not been defined - - it is suitable for any times which can be represented by a signed 64 bit integer. - - The isNormal() method determines if a time interval is normal - (a normal time interval has start() <= end()). An abnormal interval can be converted - in to a normal interval by calling the normalized() method. - - The contains() method determines if a specified time lies within - the time interval. - - The translated() method returns a time interval which has been translated - forwards or backwards through time by a specified offset. - - \sa QMediaTimeRange -*/ - -/*! - \fn QMediaTimeInterval::QMediaTimeInterval() - - Constructs an empty interval. -*/ -QMediaTimeInterval::QMediaTimeInterval() - : s(0) - , e(0) -{ - -} - -/*! - \fn QMediaTimeInterval::QMediaTimeInterval(qint64 start, qint64 end) - - Constructs an interval with the specified \a start and \a end times. -*/ -QMediaTimeInterval::QMediaTimeInterval(qint64 start, qint64 end) - : s(start) - , e(end) -{ - -} - -/*! - \fn QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other) - - Constructs an interval by taking a copy of \a other. -*/ -QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other) - : s(other.s) - , e(other.e) -{ - -} - -/*! - \fn QMediaTimeInterval::start() const - - Returns the start time of the interval. - - \sa end() -*/ -qint64 QMediaTimeInterval::start() const -{ - return s; -} - -/*! - \fn QMediaTimeInterval::end() const - - Returns the end time of the interval. - - \sa start() -*/ -qint64 QMediaTimeInterval::end() const -{ - return e; -} - -/*! - \fn QMediaTimeInterval::contains(qint64 time) const - - Returns true if the time interval contains the specified \a time. - That is, start() <= time <= end(). -*/ -bool QMediaTimeInterval::contains(qint64 time) const -{ - return isNormal() ? (s <= time && time <= e) - : (e <= time && time <= s); -} - -/*! - \fn QMediaTimeInterval::isNormal() const - - Returns true if this time interval is normal. - A normal time interval has start() <= end(). - - \sa normalized() -*/ -bool QMediaTimeInterval::isNormal() const -{ - return s <= e; -} - -/*! - \fn QMediaTimeInterval::normalized() const - - Returns a normalized version of this interval. - - If the start() time of the interval is greater than the end() time, - then the returned interval has the start and end times swapped. -*/ -QMediaTimeInterval QMediaTimeInterval::normalized() const -{ - if(s > e) - return QMediaTimeInterval(e, s); - - return *this; -} - -/*! - \fn QMediaTimeInterval::translated(qint64 offset) const - - Returns a copy of this time interval, translated by a value of \a offset. - An interval can be moved forward through time with a positive offset, or backward - through time with a negative offset. -*/ -QMediaTimeInterval QMediaTimeInterval::translated(qint64 offset) const -{ - return QMediaTimeInterval(s + offset, e + offset); -} - -/*! - \fn operator==(const QMediaTimeInterval &a, const QMediaTimeInterval &b) - \relates QMediaTimeRange - - Returns true if \a a is exactly equal to \a b. -*/ -bool operator==(const QMediaTimeInterval &a, const QMediaTimeInterval &b) -{ - return a.start() == b.start() && a.end() == b.end(); -} - -/*! - \fn operator!=(const QMediaTimeInterval &a, const QMediaTimeInterval &b) - \relates QMediaTimeRange - - Returns true if \a a is not exactly equal to \a b. -*/ -bool operator!=(const QMediaTimeInterval &a, const QMediaTimeInterval &b) -{ - return a.start() != b.start() || a.end() != b.end(); -} - -class QMediaTimeRangePrivate : public QSharedData -{ -public: - - QMediaTimeRangePrivate(); - QMediaTimeRangePrivate(const QMediaTimeRangePrivate &other); - QMediaTimeRangePrivate(const QMediaTimeInterval &interval); - - QList intervals; - - void addInterval(const QMediaTimeInterval &interval); - void removeInterval(const QMediaTimeInterval &interval); -}; - -QMediaTimeRangePrivate::QMediaTimeRangePrivate() - : QSharedData() -{ - -} - -QMediaTimeRangePrivate::QMediaTimeRangePrivate(const QMediaTimeRangePrivate &other) - : QSharedData() - , intervals(other.intervals) -{ - -} - -QMediaTimeRangePrivate::QMediaTimeRangePrivate(const QMediaTimeInterval &interval) - : QSharedData() -{ - if(interval.isNormal()) - intervals << interval; -} - -void QMediaTimeRangePrivate::addInterval(const QMediaTimeInterval &interval) -{ - // Handle normalized intervals only - if(!interval.isNormal()) - return; - - // Find a place to insert the interval - int i; - for (i = 0; i < intervals.count(); i++) { - // Insert before this element - if(interval.s < intervals[i].s) { - intervals.insert(i, interval); - break; - } - } - - // Interval needs to be added to the end of the list - if (i == intervals.count()) - intervals.append(interval); - - // Do we need to correct the element before us? - if(i > 0 && intervals[i - 1].e >= interval.s - 1) - i--; - - // Merge trailing ranges - while (i < intervals.count() - 1 - && intervals[i].e >= intervals[i + 1].s - 1) { - intervals[i].e = qMax(intervals[i].e, intervals[i + 1].e); - intervals.removeAt(i + 1); - } -} - -void QMediaTimeRangePrivate::removeInterval(const QMediaTimeInterval &interval) -{ - // Handle normalized intervals only - if(!interval.isNormal()) - return; - - for (int i = 0; i < intervals.count(); i++) { - QMediaTimeInterval r = intervals[i]; - - if (r.e < interval.s) { - // Before the removal interval - continue; - } else if (interval.e < r.s) { - // After the removal interval - stop here - break; - } else if (r.s < interval.s && interval.e < r.e) { - // Split case - a single range has a chunk removed - intervals[i].e = interval.s -1; - addInterval(QMediaTimeInterval(interval.e + 1, r.e)); - break; - } else if (r.s < interval.s) { - // Trimming Tail Case - intervals[i].e = interval.s - 1; - } else if (interval.e < r.e) { - // Trimming Head Case - we can stop after this - intervals[i].s = interval.e + 1; - break; - } else { - // Complete coverage case - intervals.removeAt(i); - --i; - } - } -} - -/*! - \class QMediaTimeRange - \brief The QMediaTimeRange class represents a set of zero or more disjoint - time intervals. - \ingroup multimedia - \since 4.7 - - \reentrant - - The earliestTime(), latestTime(), intervals() and isEmpty() - methods are used to get information about the current time range. - - The addInterval(), removeInterval() and clear() methods are used to modify - the current time range. - - When adding or removing intervals from the time range, existing intervals - within the range may be expanded, trimmed, deleted, merged or split to ensure - that all intervals within the time range remain distinct and disjoint. As a - consequence, all intervals added or removed from a time range must be - \l{QMediaTimeInterval::isNormal()}{normal}. - - \sa QMediaTimeInterval -*/ - -/*! - \fn QMediaTimeRange::QMediaTimeRange() - - Constructs an empty time range. -*/ -QMediaTimeRange::QMediaTimeRange() - : d(new QMediaTimeRangePrivate) -{ - -} - -/*! - \fn QMediaTimeRange::QMediaTimeRange(qint64 start, qint64 end) - - Constructs a time range that contains an initial interval from - \a start to \a end inclusive. - - If the interval is not \l{QMediaTimeInterval::isNormal()}{normal}, - the resulting time range will be empty. - - \sa addInterval() -*/ -QMediaTimeRange::QMediaTimeRange(qint64 start, qint64 end) - : d(new QMediaTimeRangePrivate(QMediaTimeInterval(start, end))) -{ - -} - -/*! - \fn QMediaTimeRange::QMediaTimeRange(const QMediaTimeInterval &interval) - - Constructs a time range that contains an intitial interval, \a interval. - - If \a interval is not \l{QMediaTimeInterval::isNormal()}{normal}, - the resulting time range will be empty. - - \sa addInterval() -*/ -QMediaTimeRange::QMediaTimeRange(const QMediaTimeInterval &interval) - : d(new QMediaTimeRangePrivate(interval)) -{ - -} - -/*! - \fn QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange &range) - - Constructs a time range by copying another time \a range. -*/ -QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange &range) - : d(range.d) -{ - -} - -/*! - \fn QMediaTimeRange::~QMediaTimeRange() - - Destructor. -*/ -QMediaTimeRange::~QMediaTimeRange() -{ - -} - -/*! - \fn QMediaTimeRange::operator=(const QMediaTimeRange &other) - - Takes a copy of the \a other time range and returns itself. -*/ -QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeRange &other) -{ - d = other.d; - return *this; -} - -/*! - \fn QMediaTimeRange::operator=(const QMediaTimeInterval &interval) - - Sets the time range to a single continuous interval, \a interval. -*/ -QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeInterval &interval) -{ - d = new QMediaTimeRangePrivate(interval); - return *this; -} - -/*! - \fn QMediaTimeRange::earliestTime() const - - Returns the earliest time within the time range. - - For empty time ranges, this value is equal to zero. - - \sa latestTime() -*/ -qint64 QMediaTimeRange::earliestTime() const -{ - if (!d->intervals.isEmpty()) - return d->intervals[0].s; - - return 0; -} - -/*! - \fn QMediaTimeRange::latestTime() const - - Returns the latest time within the time range. - - For empty time ranges, this value is equal to zero. - - \sa earliestTime() -*/ -qint64 QMediaTimeRange::latestTime() const -{ - if (!d->intervals.isEmpty()) - return d->intervals[d->intervals.count() - 1].e; - - return 0; -} - -/*! - \fn QMediaTimeRange::addInterval(qint64 start, qint64 end) - \overload - - Adds the interval specified by \a start and \a end - to the time range. - - \sa addInterval() -*/ -void QMediaTimeRange::addInterval(qint64 start, qint64 end) -{ - d->addInterval(QMediaTimeInterval(start, end)); -} - -/*! - \fn QMediaTimeRange::addInterval(const QMediaTimeInterval &interval) - - Adds the specified \a interval to the time range. - - Adding intervals which are not \l{QMediaTimeInterval::isNormal()}{normal} - is invalid, and will be ignored. - - If the specified interval is adjacent to, or overlaps existing - intervals within the time range, these intervals will be merged. - - This operation takes \l{linear time} - - \sa removeInterval() -*/ -void QMediaTimeRange::addInterval(const QMediaTimeInterval &interval) -{ - d->addInterval(interval); -} - -/*! - \fn QMediaTimeRange::addTimeRange(const QMediaTimeRange &range) - - Adds each of the intervals in \a range to this time range. - - Equivalent to calling addInterval() for each interval in \a range. -*/ -void QMediaTimeRange::addTimeRange(const QMediaTimeRange &range) -{ - foreach(const QMediaTimeInterval &i, range.intervals()) { - d->addInterval(i); - } -} - -/*! - \fn QMediaTimeRange::removeInterval(qint64 start, qint64 end) - \overload - - Removes the interval specified by \a start and \a end - from the time range. - - \sa removeInterval() -*/ -void QMediaTimeRange::removeInterval(qint64 start, qint64 end) -{ - d->removeInterval(QMediaTimeInterval(start, end)); -} - -/*! - \fn QMediaTimeRange::removeInterval(const QMediaTimeInterval &interval) - - Removes the specified \a interval from the time range. - - Removing intervals which are not \l{QMediaTimeInterval::isNormal()}{normal} - is invalid, and will be ignored. - - Intervals within the time range will be trimmed, split or deleted - such that no intervals within the time range include any part of the - target interval. - - This operation takes \l{linear time} - - \sa addInterval() -*/ -void QMediaTimeRange::removeInterval(const QMediaTimeInterval &interval) -{ - d->removeInterval(interval); -} - -/*! - \fn QMediaTimeRange::removeTimeRange(const QMediaTimeRange &range) - - Removes each of the intervals in \a range from this time range. - - Equivalent to calling removeInterval() for each interval in \a range. -*/ -void QMediaTimeRange::removeTimeRange(const QMediaTimeRange &range) -{ - foreach(const QMediaTimeInterval &i, range.intervals()) { - d->removeInterval(i); - } -} - -/*! - \fn QMediaTimeRange::operator+=(const QMediaTimeRange &other) - - Adds each interval in \a other to the time range and returns the result. -*/ -QMediaTimeRange& QMediaTimeRange::operator+=(const QMediaTimeRange &other) -{ - addTimeRange(other); - return *this; -} - -/*! - \fn QMediaTimeRange::operator+=(const QMediaTimeInterval &interval) - - Adds the specified \a interval to the time range and returns the result. -*/ -QMediaTimeRange& QMediaTimeRange::operator+=(const QMediaTimeInterval &interval) -{ - addInterval(interval); - return *this; -} - -/*! - \fn QMediaTimeRange::operator-=(const QMediaTimeRange &other) - - Removes each interval in \a other from the time range and returns the result. -*/ -QMediaTimeRange& QMediaTimeRange::operator-=(const QMediaTimeRange &other) -{ - removeTimeRange(other); - return *this; -} - -/*! - \fn QMediaTimeRange::operator-=(const QMediaTimeInterval &interval) - - Removes the specified \a interval from the time range and returns the result. -*/ -QMediaTimeRange& QMediaTimeRange::operator-=(const QMediaTimeInterval &interval) -{ - removeInterval(interval); - return *this; -} - -/*! - \fn QMediaTimeRange::clear() - - Removes all intervals from the time range. - - \sa removeInterval() -*/ -void QMediaTimeRange::clear() -{ - d->intervals.clear(); -} - -/*! - \fn QMediaTimeRange::intervals() const - - Returns the list of intervals covered by this time range. -*/ -QList QMediaTimeRange::intervals() const -{ - return d->intervals; -} - -/*! - \fn QMediaTimeRange::isEmpty() const - - Returns true if there are no intervals within the time range. - - \sa intervals() -*/ -bool QMediaTimeRange::isEmpty() const -{ - return d->intervals.isEmpty(); -} - -/*! - \fn QMediaTimeRange::isContinuous() const - - Returns true if the time range consists of a continuous interval. - That is, there is one or fewer disjoint intervals within the time range. -*/ -bool QMediaTimeRange::isContinuous() const -{ - return (d->intervals.count() <= 1); -} - -/*! - \fn QMediaTimeRange::contains(qint64 time) const - - Returns true if the specified \a time lies within the time range. -*/ -bool QMediaTimeRange::contains(qint64 time) const -{ - for (int i = 0; i < d->intervals.count(); i++) { - if (d->intervals[i].contains(time)) - return true; - - if (time < d->intervals[i].s) - break; - } - - return false; -} - -/*! - \fn operator==(const QMediaTimeRange &a, const QMediaTimeRange &b) - \relates QMediaTimeRange - - Returns true if all intervals in \a a are present in \a b. -*/ -bool operator==(const QMediaTimeRange &a, const QMediaTimeRange &b) -{ - if (a.intervals().count() != b.intervals().count()) - return false; - - for (int i = 0; i < a.intervals().count(); i++) - { - if(a.intervals()[i] != b.intervals()[i]) - return false; - } - - return true; -} - -/*! - \fn operator!=(const QMediaTimeRange &a, const QMediaTimeRange &b) - \relates QMediaTimeRange - - Returns true if one or more intervals in \a a are not present in \a b. -*/ -bool operator!=(const QMediaTimeRange &a, const QMediaTimeRange &b) -{ - return !(a == b); -} - -/*! - \fn operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2) - - Returns a time range containing the union between \a r1 and \a r2. - */ -QMediaTimeRange operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2) -{ - return (QMediaTimeRange(r1) += r2); -} - -/*! - \fn operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2) - - Returns a time range containing \a r2 subtracted from \a r1. - */ -QMediaTimeRange operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2) -{ - return (QMediaTimeRange(r1) -= r2); -} - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediatimerange.h b/src/multimedia/mediaservices/base/qmediatimerange.h deleted file mode 100644 index 5983db2..0000000 --- a/src/multimedia/mediaservices/base/qmediatimerange.h +++ /dev/null @@ -1,135 +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 QtMediaServices 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 QMEDIATIMERANGE_H -#define QMEDIATIMERANGE_H - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaTimeRangePrivate; - -class Q_MEDIASERVICES_EXPORT QMediaTimeInterval -{ -public: - QMediaTimeInterval(); - QMediaTimeInterval(qint64 start, qint64 end); - QMediaTimeInterval(const QMediaTimeInterval&); - - qint64 start() const; - qint64 end() const; - - bool contains(qint64 time) const; - - bool isNormal() const; - QMediaTimeInterval normalized() const; - QMediaTimeInterval translated(qint64 offset) const; - -private: - friend class QMediaTimeRangePrivate; - friend class QMediaTimeRange; - - qint64 s; - qint64 e; -}; - -Q_MEDIASERVICES_EXPORT bool operator==(const QMediaTimeInterval&, const QMediaTimeInterval&); -Q_MEDIASERVICES_EXPORT bool operator!=(const QMediaTimeInterval&, const QMediaTimeInterval&); - -class Q_MEDIASERVICES_EXPORT QMediaTimeRange -{ -public: - - QMediaTimeRange(); - QMediaTimeRange(qint64 start, qint64 end); - QMediaTimeRange(const QMediaTimeInterval&); - QMediaTimeRange(const QMediaTimeRange &range); - ~QMediaTimeRange(); - - QMediaTimeRange &operator=(const QMediaTimeRange&); - QMediaTimeRange &operator=(const QMediaTimeInterval&); - - qint64 earliestTime() const; - qint64 latestTime() const; - - QList intervals() const; - bool isEmpty() const; - bool isContinuous() const; - - bool contains(qint64 time) const; - - void addInterval(qint64 start, qint64 end); - void addInterval(const QMediaTimeInterval &interval); - void addTimeRange(const QMediaTimeRange&); - - void removeInterval(qint64 start, qint64 end); - void removeInterval(const QMediaTimeInterval &interval); - void removeTimeRange(const QMediaTimeRange&); - - QMediaTimeRange& operator+=(const QMediaTimeRange&); - QMediaTimeRange& operator+=(const QMediaTimeInterval&); - QMediaTimeRange& operator-=(const QMediaTimeRange&); - QMediaTimeRange& operator-=(const QMediaTimeInterval&); - - void clear(); - -private: - QSharedDataPointer d; -}; - -Q_MEDIASERVICES_EXPORT bool operator==(const QMediaTimeRange&, const QMediaTimeRange&); -Q_MEDIASERVICES_EXPORT bool operator!=(const QMediaTimeRange&, const QMediaTimeRange&); -Q_MEDIASERVICES_EXPORT QMediaTimeRange operator+(const QMediaTimeRange&, const QMediaTimeRange&); -Q_MEDIASERVICES_EXPORT QMediaTimeRange operator-(const QMediaTimeRange&, const QMediaTimeRange&); - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIATIMERANGE_H diff --git a/src/multimedia/mediaservices/base/qmetadatacontrol.cpp b/src/multimedia/mediaservices/base/qmetadatacontrol.cpp deleted file mode 100644 index 8bfec7e..0000000 --- a/src/multimedia/mediaservices/base/qmetadatacontrol.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include "qmediacontrol_p.h" - - -QT_BEGIN_NAMESPACE - - -/*! - \class QMetaDataControl - \ingroup multimedia-serv - \since 4.7 - \preliminary - \brief The QMetaDataControl class provides access to the meta-data of a - QMediaService's media. - - If a QMediaService can provide read or write access to the meta-data of - its current media it will implement QMetaDataControl. This control - provides functions for both retrieving and setting meta-data values. - Meta-data may be addressed by the well defined keys in the - QtMediaServices::MetaData enumeration using the metaData() functions, or by - string keys using the extendedMetaData() functions. - - The functionality provided by this control is exposed to application - code by the meta-data members of QMediaObject, and so meta-data access - is potentially available in any of the media object classes. Any media - service may implement QMetaDataControl. - - The interface name of QMetaDataControl is \c com.nokia.Qt.QMetaDataControl/1.0 as - defined in QMetaDataControl_iid. - - \sa QMediaService::control(), QMediaObject -*/ - -/*! - \macro QMetaDataControl_iid - - \c com.nokia.Qt.QMetaDataControl/1.0 - - Defines the interface name of the QMetaDataControl class. - - \relates QMetaDataControl -*/ - -/*! - Construct a QMetaDataControl with \a parent. This class is meant as a base class - for service specific meta data providers so this constructor is protected. -*/ - -QMetaDataControl::QMetaDataControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroy the meta-data object. -*/ - -QMetaDataControl::~QMetaDataControl() -{ -} - -/*! - \fn bool QMetaDataControl::isMetaDataAvailable() const - - Identifies if meta-data is available from a media service. - - Returns true if the meta-data is available and false otherwise. -*/ - -/*! - \fn bool QMetaDataControl::isWritable() const - - Identifies if a media service's meta-data can be edited. - - Returns true if the meta-data is writable and false otherwise. -*/ - -/*! - \fn QVariant QMetaDataControl::metaData(QtMediaServices::MetaData key) const - - Returns the meta-data for the given \a key. -*/ - -/*! - \fn void QMetaDataControl::setMetaData(QtMediaServices::MetaData key, const QVariant &value) - - Sets the \a value of the meta-data element with the given \a key. -*/ - -/*! - \fn QMetaDataControl::availableMetaData() const - - Returns a list of keys there is meta-data available for. -*/ - -/*! - \fn QMetaDataControl::extendedMetaData(const QString &key) const - - Returns the metaData for an abitrary string \a key. - - The valid selection of keys for extended meta-data is determined by the provider and the meaning - and type may differ between providers. -*/ - -/*! - \fn QMetaDataControl::setExtendedMetaData(const QString &key, const QVariant &value) - - Change the value of the meta-data element with an abitrary string \a key to \a value. - - The valid selection of keys for extended meta-data is determined by the provider and the meaning - and type may differ between providers. -*/ - -/*! - \fn QMetaDataControl::availableExtendedMetaData() const - - Returns a list of keys there is extended meta-data available for. -*/ - - -/*! - \fn void QMetaDataControl::metaDataChanged() - - Signal the changes of meta-data. -*/ - -/*! - \fn void QMetaDataControl::metaDataAvailableChanged(bool available) - - Signal the availability of meta-data has changed, \a available will - be true if the multimedia object has meta-data. -*/ - -/*! - \fn void QMetaDataControl::writableChanged(bool writable) - - Signal a change in the writable status of meta-data, \a writable will be - true if meta-data elements can be added or adjusted. -*/ - -#include "moc_qmetadatacontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmetadatacontrol.h b/src/multimedia/mediaservices/base/qmetadatacontrol.h deleted file mode 100644 index 48206fa..0000000 --- a/src/multimedia/mediaservices/base/qmetadatacontrol.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMETADATACONTROL_H -#define QMETADATACONTROL_H - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class Q_MEDIASERVICES_EXPORT QMetaDataControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QMetaDataControl(); - - virtual bool isWritable() const = 0; - virtual bool isMetaDataAvailable() const = 0; - - virtual QVariant metaData(QtMediaServices::MetaData key) const = 0; - virtual void setMetaData(QtMediaServices::MetaData key, const QVariant &value) = 0; - virtual QList availableMetaData() const = 0; - - virtual QVariant extendedMetaData(const QString &key) const = 0; - virtual void setExtendedMetaData(const QString &key, const QVariant &value) = 0; - virtual QStringList availableExtendedMetaData() const = 0; - -Q_SIGNALS: - void metaDataChanged(); - - void writableChanged(bool writable); - void metaDataAvailableChanged(bool available); - -protected: - QMetaDataControl(QObject *parent = 0); -}; - -#define QMetaDataControl_iid "com.nokia.Qt.QMetaDataControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMetaDataControl, QMetaDataControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMETADATAPROVIDER_H diff --git a/src/multimedia/mediaservices/base/qpaintervideosurface.cpp b/src/multimedia/mediaservices/base/qpaintervideosurface.cpp deleted file mode 100644 index 302e772..0000000 --- a/src/multimedia/mediaservices/base/qpaintervideosurface.cpp +++ /dev/null @@ -1,1565 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 "qpaintervideosurface_p.h" -#include "qpaintervideosurface_mac_p.h" - -#include - -#include -#include -#include - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) -#include -#endif - -#include - - -QT_BEGIN_NAMESPACE - -QVideoSurfacePainter::~QVideoSurfacePainter() -{ -} - -class QVideoSurfaceRasterPainter : public QVideoSurfacePainter -{ -public: - QVideoSurfaceRasterPainter(); - - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - - void updateColors(int brightness, int contrast, int hue, int saturation); - -private: - QList m_imagePixelFormats; - QVideoFrame m_frame; - QSize m_imageSize; - QImage::Format m_imageFormat; - QVideoSurfaceFormat::Direction m_scanLineDirection; -}; - -QVideoSurfaceRasterPainter::QVideoSurfaceRasterPainter() - : m_imageFormat(QImage::Format_Invalid) - , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) -{ - m_imagePixelFormats - << QVideoFrame::Format_RGB32 -#ifndef QT_OPENGL_ES // The raster formats should be a subset of the GL formats. - << QVideoFrame::Format_RGB24 -#endif - << QVideoFrame::Format_ARGB32 - << QVideoFrame::Format_RGB565; -} - -QList QVideoSurfaceRasterPainter::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - return handleType == QAbstractVideoBuffer::NoHandle - ? m_imagePixelFormats - : QList(); -} - -bool QVideoSurfaceRasterPainter::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const -{ - return format.handleType() == QAbstractVideoBuffer::NoHandle - && m_imagePixelFormats.contains(format.pixelFormat()) - && !format.frameSize().isEmpty(); -} - -QAbstractVideoSurface::Error QVideoSurfaceRasterPainter::start(const QVideoSurfaceFormat &format) -{ - m_frame = QVideoFrame(); - m_imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); - m_imageSize = format.frameSize(); - m_scanLineDirection = format.scanLineDirection(); - - return format.handleType() == QAbstractVideoBuffer::NoHandle - && m_imageFormat != QImage::Format_Invalid - && !m_imageSize.isEmpty() - ? QAbstractVideoSurface::NoError - : QAbstractVideoSurface::UnsupportedFormatError; -} - -void QVideoSurfaceRasterPainter::stop() -{ - m_frame = QVideoFrame(); -} - -QAbstractVideoSurface::Error QVideoSurfaceRasterPainter::setCurrentFrame(const QVideoFrame &frame) -{ - m_frame = frame; - - return QAbstractVideoSurface::NoError; -} - -QAbstractVideoSurface::Error QVideoSurfaceRasterPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { - QImage image( - m_frame.bits(), - m_imageSize.width(), - m_imageSize.height(), - m_frame.bytesPerLine(), - m_imageFormat); - - if (m_scanLineDirection == QVideoSurfaceFormat::BottomToTop) { - const QTransform oldTransform = painter->transform(); - - painter->scale(1, -1); - painter->translate(0, -target.bottom()); - painter->drawImage( - QRectF(target.x(), 0, target.width(), target.height()), image, source); - painter->setTransform(oldTransform); - } else { - painter->drawImage(target, image, source); - } - - m_frame.unmap(); - } else if (m_frame.isValid()) { - return QAbstractVideoSurface::IncorrectFormatError; - } else { - painter->fillRect(target, Qt::black); - } - return QAbstractVideoSurface::NoError; -} - -void QVideoSurfaceRasterPainter::updateColors(int, int, int, int) -{ -} - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - -#ifndef Q_WS_MAC -# ifndef APIENTRYP -# ifdef APIENTRY -# define APIENTRYP APIENTRY * -# else -# define APIENTRY -# define APIENTRYP * -# endif -# endif -#else -# define APIENTRY -# define APIENTRYP * -#endif - -#ifndef GL_TEXTURE0 -# define GL_TEXTURE0 0x84C0 -# define GL_TEXTURE1 0x84C1 -# define GL_TEXTURE2 0x84C2 -#endif -#ifndef GL_PROGRAM_ERROR_STRING_ARB -# define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#endif - -#ifndef GL_UNSIGNED_SHORT_5_6_5 -# define GL_UNSIGNED_SHORT_5_6_5 33635 -#endif - -class QVideoSurfaceGLPainter : public QVideoSurfacePainter -{ -public: - QVideoSurfaceGLPainter(QGLContext *context); - ~QVideoSurfaceGLPainter(); - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; - - QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); - - void updateColors(int brightness, int contrast, int hue, int saturation); - -protected: - void initRgbTextureInfo(GLenum internalFormat, GLuint format, GLenum type, const QSize &size); - void initYuv420PTextureInfo(const QSize &size); - void initYv12TextureInfo(const QSize &size); - -#ifndef QT_OPENGL_ES - typedef void (APIENTRY *_glActiveTexture) (GLenum); - _glActiveTexture glActiveTexture; -#endif - - QList m_imagePixelFormats; - QList m_glPixelFormats; - QMatrix4x4 m_colorMatrix; - QVideoFrame m_frame; - - QGLContext *m_context; - QAbstractVideoBuffer::HandleType m_handleType; - QVideoSurfaceFormat::Direction m_scanLineDirection; - GLenum m_textureFormat; - GLuint m_textureInternalFormat; - GLenum m_textureType; - int m_textureCount; - GLuint m_textureIds[3]; - int m_textureWidths[3]; - int m_textureHeights[3]; - int m_textureOffsets[3]; - bool m_yuv; -}; - -QVideoSurfaceGLPainter::QVideoSurfaceGLPainter(QGLContext *context) - : m_context(context) - , m_handleType(QAbstractVideoBuffer::NoHandle) - , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) - , m_textureFormat(0) - , m_textureInternalFormat(0) - , m_textureType(0) - , m_textureCount(0) - , m_yuv(false) -{ -#ifndef QT_OPENGL_ES - glActiveTexture = (_glActiveTexture)m_context->getProcAddress(QLatin1String("glActiveTexture")); -#endif -} - -QVideoSurfaceGLPainter::~QVideoSurfaceGLPainter() -{ -} - -QList QVideoSurfaceGLPainter::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - switch (handleType) { - case QAbstractVideoBuffer::NoHandle: - return m_imagePixelFormats; - case QAbstractVideoBuffer::GLTextureHandle: - return m_glPixelFormats; - default: - return QList(); - } -} - -bool QVideoSurfaceGLPainter::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const -{ - if (format.frameSize().isEmpty()) { - return false; - } else { - switch (format.handleType()) { - case QAbstractVideoBuffer::NoHandle: - return m_imagePixelFormats.contains(format.pixelFormat()); - case QAbstractVideoBuffer::GLTextureHandle: - return m_glPixelFormats.contains(format.pixelFormat()); - default: - return false; - } - } -} - -QAbstractVideoSurface::Error QVideoSurfaceGLPainter::setCurrentFrame(const QVideoFrame &frame) -{ - m_frame = frame; - - if (m_handleType == QAbstractVideoBuffer::GLTextureHandle) { - m_textureIds[0] = frame.handle().toInt(); - } else if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { - m_context->makeCurrent(); - - for (int i = 0; i < m_textureCount; ++i) { - glBindTexture(GL_TEXTURE_2D, m_textureIds[i]); - glTexImage2D( - GL_TEXTURE_2D, - 0, - m_textureInternalFormat, - m_textureWidths[i], - m_textureHeights[i], - 0, - m_textureFormat, - m_textureType, - m_frame.bits() + m_textureOffsets[i]); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - } - m_frame.unmap(); - } else if (m_frame.isValid()) { - return QAbstractVideoSurface::IncorrectFormatError; - } - - return QAbstractVideoSurface::NoError; -} - -void QVideoSurfaceGLPainter::updateColors(int brightness, int contrast, int hue, int saturation) -{ - const qreal b = brightness / 200.0; - const qreal c = contrast / 100.0 + 1.0; - const qreal h = hue / 100.0; - const qreal s = saturation / 100.0 + 1.0; - - const qreal cosH = qCos(M_PI * h); - const qreal sinH = qSin(M_PI * h); - - const qreal h11 = 0.787 * cosH - 0.213 * sinH + 0.213; - const qreal h21 = -0.213 * cosH + 0.143 * sinH + 0.213; - const qreal h31 = -0.213 * cosH - 0.787 * sinH + 0.213; - - const qreal h12 = -0.715 * cosH - 0.715 * sinH + 0.715; - const qreal h22 = 0.285 * cosH + 0.140 * sinH + 0.715; - const qreal h32 = -0.715 * cosH + 0.715 * sinH + 0.715; - - const qreal h13 = -0.072 * cosH + 0.928 * sinH + 0.072; - const qreal h23 = -0.072 * cosH - 0.283 * sinH + 0.072; - const qreal h33 = 0.928 * cosH + 0.072 * sinH + 0.072; - - const qreal sr = (1.0 - s) * 0.3086; - const qreal sg = (1.0 - s) * 0.6094; - const qreal sb = (1.0 - s) * 0.0820; - - const qreal sr_s = sr + s; - const qreal sg_s = sg + s; - const qreal sb_s = sr + s; - - const float m4 = (s + sr + sg + sb) * (0.5 - 0.5 * c + b); - - m_colorMatrix(0, 0) = c * (sr_s * h11 + sg * h21 + sb * h31); - m_colorMatrix(0, 1) = c * (sr_s * h12 + sg * h22 + sb * h32); - m_colorMatrix(0, 2) = c * (sr_s * h13 + sg * h23 + sb * h33); - m_colorMatrix(0, 3) = m4; - - m_colorMatrix(1, 0) = c * (sr * h11 + sg_s * h21 + sb * h31); - m_colorMatrix(1, 1) = c * (sr * h12 + sg_s * h22 + sb * h32); - m_colorMatrix(1, 2) = c * (sr * h13 + sg_s * h23 + sb * h33); - m_colorMatrix(1, 3) = m4; - - m_colorMatrix(2, 0) = c * (sr * h11 + sg * h21 + sb_s * h31); - m_colorMatrix(2, 1) = c * (sr * h12 + sg * h22 + sb_s * h32); - m_colorMatrix(2, 2) = c * (sr * h13 + sg * h23 + sb_s * h33); - m_colorMatrix(2, 3) = m4; - - m_colorMatrix(3, 0) = 0.0; - m_colorMatrix(3, 1) = 0.0; - m_colorMatrix(3, 2) = 0.0; - m_colorMatrix(3, 3) = 1.0; - - if (m_yuv) { - m_colorMatrix = m_colorMatrix * QMatrix4x4( - 1.0, 0.000, 1.140, -0.5700, - 1.0, -0.394, -0.581, 0.4875, - 1.0, 2.028, 0.000, -1.0140, - 0.0, 0.000, 0.000, 1.0000); - } -} - -void QVideoSurfaceGLPainter::initRgbTextureInfo( - GLenum internalFormat, GLuint format, GLenum type, const QSize &size) -{ - m_yuv = false; - m_textureInternalFormat = internalFormat; - m_textureFormat = format; - m_textureType = type; - m_textureCount = 1; - m_textureWidths[0] = size.width(); - m_textureHeights[0] = size.height(); - m_textureOffsets[0] = 0; -} - -void QVideoSurfaceGLPainter::initYuv420PTextureInfo(const QSize &size) -{ - int w = (size.width() + 3) & ~3; - int w2 = (size.width()/2 + 3) & ~3; - - m_yuv = true; - m_textureInternalFormat = GL_LUMINANCE; - m_textureFormat = GL_LUMINANCE; - m_textureType = GL_UNSIGNED_BYTE; - m_textureCount = 3; - m_textureWidths[0] = size.width(); - m_textureHeights[0] = size.height(); - m_textureOffsets[0] = 0; - m_textureWidths[1] = size.width() / 2; - m_textureHeights[1] = size.height() / 2; - m_textureOffsets[1] = w * size.height(); - m_textureWidths[2] = size.width() / 2; - m_textureHeights[2] = size.height() / 2; - m_textureOffsets[2] = w * size.height() + w2 * (size.height() / 2); -} - -void QVideoSurfaceGLPainter::initYv12TextureInfo(const QSize &size) -{ - int w = (size.width() + 3) & ~3; - int w2 = (size.width()/2 + 3) & ~3; - - m_yuv = true; - m_textureInternalFormat = GL_LUMINANCE; - m_textureFormat = GL_LUMINANCE; - m_textureType = GL_UNSIGNED_BYTE; - m_textureCount = 3; - m_textureWidths[0] = size.width(); - m_textureHeights[0] = size.height(); - m_textureOffsets[0] = 0; - m_textureWidths[1] = size.width() / 2; - m_textureHeights[1] = size.height() / 2; - m_textureOffsets[1] = w * size.height() + w2 * (size.height() / 2); - m_textureWidths[2] = size.width() / 2; - m_textureHeights[2] = size.height() / 2; - m_textureOffsets[2] = w * size.height(); -} - -#ifndef QT_OPENGL_ES - -# ifndef GL_FRAGMENT_PROGRAM_ARB -# define GL_FRAGMENT_PROGRAM_ARB 0x8804 -# define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -# endif - -// Paints an RGB32 frame -static const char *qt_arbfp_xrgbShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP xrgb;\n" - "TEX xrgb.xyz, fragment.texcoord[0], texture[0], 2D;\n" - "MOV xrgb.w, matrix[3].w;\n" - "DP4 result.color.x, xrgb.zyxw, matrix[0];\n" - "DP4 result.color.y, xrgb.zyxw, matrix[1];\n" - "DP4 result.color.z, xrgb.zyxw, matrix[2];\n" - "END"; - -// Paints an ARGB frame. -static const char *qt_arbfp_argbShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP argb;\n" - "TEX argb, fragment.texcoord[0], texture[0], 2D;\n" - "MOV argb.w, matrix[3].w;\n" - "DP4 result.color.x, argb.zyxw, matrix[0];\n" - "DP4 result.color.y, argb.zyxw, matrix[1];\n" - "DP4 result.color.z, argb.zyxw, matrix[2];\n" - "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" - "END"; - -// Paints an RGB(A) frame. -static const char *qt_arbfp_rgbShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP rgb;\n" - "TEX rgb, fragment.texcoord[0], texture[0], 2D;\n" - "MOV rgb.w, matrix[3].w;\n" - "DP4 result.color.x, rgb, matrix[0];\n" - "DP4 result.color.y, rgb, matrix[1];\n" - "DP4 result.color.z, rgb, matrix[2];\n" - "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" - "END"; - -// Paints a YUV420P or YV12 frame. -static const char *qt_arbfp_yuvPlanarShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP yuv;\n" - "TEX yuv.x, fragment.texcoord[0], texture[0], 2D;\n" - "TEX yuv.y, fragment.texcoord[0], texture[1], 2D;\n" - "TEX yuv.z, fragment.texcoord[0], texture[2], 2D;\n" - "MOV yuv.w, matrix[3].w;\n" - "DP4 result.color.x, yuv, matrix[0];\n" - "DP4 result.color.y, yuv, matrix[1];\n" - "DP4 result.color.z, yuv, matrix[2];\n" - "END"; - -// Paints a YUV444 frame. -static const char *qt_arbfp_xyuvShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP ayuv;\n" - "TEX ayuv, fragment.texcoord[0], texture[0], 2D;\n" - "MOV ayuv.x, matrix[3].w;\n" - "DP4 result.color.x, ayuv.yzwx, matrix[0];\n" - "DP4 result.color.y, ayuv.yzwx, matrix[1];\n" - "DP4 result.color.z, ayuv.yzwx, matrix[2];\n" - "END"; - -// Paints a AYUV444 frame. -static const char *qt_arbfp_ayuvShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP ayuv;\n" - "TEX ayuv, fragment.texcoord[0], texture[0], 2D;\n" - "MOV ayuv.x, matrix[3].w;\n" - "DP4 result.color.x, ayuv.yzwx, matrix[0];\n" - "DP4 result.color.y, ayuv.yzwx, matrix[1];\n" - "DP4 result.color.z, ayuv.yzwx, matrix[2];\n" - "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" - "END"; - -class QVideoSurfaceArbFpPainter : public QVideoSurfaceGLPainter -{ -public: - QVideoSurfaceArbFpPainter(QGLContext *context); - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - -private: - typedef void (APIENTRY *_glProgramStringARB) (GLenum, GLenum, GLsizei, const GLvoid *); - typedef void (APIENTRY *_glBindProgramARB) (GLenum, GLuint); - typedef void (APIENTRY *_glDeleteProgramsARB) (GLsizei, const GLuint *); - typedef void (APIENTRY *_glGenProgramsARB) (GLsizei, GLuint *); - typedef void (APIENTRY *_glProgramLocalParameter4fARB) ( - GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); - typedef void (APIENTRY *_glActiveTexture) (GLenum); - - _glProgramStringARB glProgramStringARB; - _glBindProgramARB glBindProgramARB; - _glDeleteProgramsARB glDeleteProgramsARB; - _glGenProgramsARB glGenProgramsARB; - _glProgramLocalParameter4fARB glProgramLocalParameter4fARB; - - GLuint m_programId; - QSize m_frameSize; -}; - -QVideoSurfaceArbFpPainter::QVideoSurfaceArbFpPainter(QGLContext *context) - : QVideoSurfaceGLPainter(context) - , m_programId(0) -{ - glProgramStringARB = (_glProgramStringARB) m_context->getProcAddress( - QLatin1String("glProgramStringARB")); - glBindProgramARB = (_glBindProgramARB) m_context->getProcAddress( - QLatin1String("glBindProgramARB")); - glDeleteProgramsARB = (_glDeleteProgramsARB) m_context->getProcAddress( - QLatin1String("glDeleteProgramsARB")); - glGenProgramsARB = (_glGenProgramsARB) m_context->getProcAddress( - QLatin1String("glGenProgramsARB")); - glProgramLocalParameter4fARB = (_glProgramLocalParameter4fARB) m_context->getProcAddress( - QLatin1String("glProgramLocalParameter4fARB")); - - m_imagePixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_BGR32 - << QVideoFrame::Format_ARGB32 - << QVideoFrame::Format_RGB24 - << QVideoFrame::Format_BGR24 - << QVideoFrame::Format_RGB565 - << QVideoFrame::Format_AYUV444 - << QVideoFrame::Format_YUV444 - << QVideoFrame::Format_YV12 - << QVideoFrame::Format_YUV420P; - m_glPixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_ARGB32; -} - -QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfaceFormat &format) -{ - Q_ASSERT(m_textureCount == 0); - - QAbstractVideoSurface::Error error = QAbstractVideoSurface::NoError; - - m_context->makeCurrent(); - - const char *program = 0; - - if (format.handleType() == QAbstractVideoBuffer::NoHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_xrgbShaderProgram; - break; - case QVideoFrame::Format_BGR32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_rgbShaderProgram; - break; - case QVideoFrame::Format_ARGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_argbShaderProgram; - break; - case QVideoFrame::Format_RGB24: - initRgbTextureInfo(GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_rgbShaderProgram; - break; - case QVideoFrame::Format_BGR24: - initRgbTextureInfo(GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_xrgbShaderProgram; - break; - case QVideoFrame::Format_RGB565: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format.frameSize()); - program = qt_arbfp_rgbShaderProgram; - break; - case QVideoFrame::Format_YUV444: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_xyuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_AYUV444: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_ayuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_YV12: - initYv12TextureInfo(format.frameSize()); - program = qt_arbfp_yuvPlanarShaderProgram; - break; - case QVideoFrame::Format_YUV420P: - initYuv420PTextureInfo(format.frameSize()); - program = qt_arbfp_yuvPlanarShaderProgram; - break; - default: - break; - } - } else if (format.handleType() == QAbstractVideoBuffer::GLTextureHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_ARGB32: - m_yuv = false; - m_textureCount = 1; - program = qt_arbfp_rgbShaderProgram; - break; - default: - break; - } - } - - if (!program) { - error = QAbstractVideoSurface::UnsupportedFormatError; - } else { - glGenProgramsARB(1, &m_programId); - - GLenum glError = glGetError(); - if (glError != GL_NO_ERROR) { - qWarning("QPainterVideoSurface: ARBfb Shader allocation error %x", int(glError)); - m_textureCount = 0; - m_programId = 0; - - error = QAbstractVideoSurface::ResourceError; - } else { - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_programId); - glProgramStringARB( - GL_FRAGMENT_PROGRAM_ARB, - GL_PROGRAM_FORMAT_ASCII_ARB, - qstrlen(program), - reinterpret_cast(program)); - - if ((glError = glGetError()) != GL_NO_ERROR) { - const GLubyte* errorString = glGetString(GL_PROGRAM_ERROR_STRING_ARB); - - qWarning("QPainterVideoSurface: ARBfp Shader compile error %x, %s", - int(glError), - reinterpret_cast(errorString)); - glDeleteProgramsARB(1, &m_programId); - - m_textureCount = 0; - m_programId = 0; - - error = QAbstractVideoSurface::ResourceError; - } else { - m_handleType = format.handleType(); - m_scanLineDirection = format.scanLineDirection(); - m_frameSize = format.frameSize(); - - if (m_handleType == QAbstractVideoBuffer::NoHandle) - glGenTextures(m_textureCount, m_textureIds); - } - } - } - - return error; -} - -void QVideoSurfaceArbFpPainter::stop() -{ - m_context->makeCurrent(); - - if (m_handleType != QAbstractVideoBuffer::GLTextureHandle) - glDeleteTextures(m_textureCount, m_textureIds); - glDeleteProgramsARB(1, &m_programId); - - m_textureCount = 0; - m_programId = 0; - m_handleType = QAbstractVideoBuffer::NoHandle; -} - -QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (m_frame.isValid()) { - bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); - bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); - - painter->beginNativePainting(); - - if (stencilTestEnabled) - glEnable(GL_STENCIL_TEST); - if (scissorTestEnabled) - glEnable(GL_SCISSOR_TEST); - - const float txLeft = source.left() / m_frameSize.width(); - const float txRight = source.right() / m_frameSize.width(); - const float txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.top() / m_frameSize.height() - : source.bottom() / m_frameSize.height(); - const float txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.bottom() / m_frameSize.height() - : source.top() / m_frameSize.height(); - - - const float tx_array[] = - { - txLeft , txBottom, - txRight, txBottom, - txLeft , txTop, - txRight, txTop - }; - const float v_array[] = - { - float(target.left()) , float(target.bottom() + 1), - float(target.right() + 1), float(target.bottom() + 1), - float(target.left()) , float(target.top()), - float(target.right() + 1), float(target.top()) - }; - - glEnable(GL_FRAGMENT_PROGRAM_ARB); - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_programId); - - glProgramLocalParameter4fARB( - GL_FRAGMENT_PROGRAM_ARB, - 0, - m_colorMatrix(0, 0), - m_colorMatrix(0, 1), - m_colorMatrix(0, 2), - m_colorMatrix(0, 3)); - glProgramLocalParameter4fARB( - GL_FRAGMENT_PROGRAM_ARB, - 1, - m_colorMatrix(1, 0), - m_colorMatrix(1, 1), - m_colorMatrix(1, 2), - m_colorMatrix(1, 3)); - glProgramLocalParameter4fARB( - GL_FRAGMENT_PROGRAM_ARB, - 2, - m_colorMatrix(2, 0), - m_colorMatrix(2, 1), - m_colorMatrix(2, 2), - m_colorMatrix(2, 3)); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); - - if (m_textureCount == 3) { - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, m_textureIds[1]); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, m_textureIds[2]); - glActiveTexture(GL_TEXTURE0); - } - - glVertexPointer(2, GL_FLOAT, 0, v_array); - glTexCoordPointer(2, GL_FLOAT, 0, tx_array); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - glDisable(GL_FRAGMENT_PROGRAM_ARB); - - painter->endNativePainting(); - } - return QAbstractVideoSurface::NoError; -} - -#endif - -static const char *qt_glsl_vertexShaderProgram = - "attribute highp vec4 vertexCoordArray;\n" - "attribute highp vec2 textureCoordArray;\n" - "uniform highp mat4 positionMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " gl_Position = positionMatrix * vertexCoordArray;\n" - " textureCoord = textureCoordArray;\n" - "}\n"; - -// Paints an RGB32 frame -static const char *qt_glsl_xrgbShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).bgr, 1.0);\n" - " gl_FragColor = colorMatrix * color;\n" - "}\n"; - -// Paints an ARGB frame. -static const char *qt_glsl_argbShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).bgr, 1.0);\n" - " color = colorMatrix * color;\n" - " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).a);\n" - "}\n"; - -// Paints an RGB(A) frame. -static const char *qt_glsl_rgbShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).rgb, 1.0);\n" - " color = colorMatrix * color;\n" - " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).a);\n" - "}\n"; - -// Paints a YUV420P or YV12 frame. -static const char *qt_glsl_yuvPlanarShaderProgram = - "uniform sampler2D texY;\n" - "uniform sampler2D texU;\n" - "uniform sampler2D texV;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(\n" - " texture2D(texY, textureCoord.st).r,\n" - " texture2D(texU, textureCoord.st).r,\n" - " texture2D(texV, textureCoord.st).r,\n" - " 1.0);\n" - " gl_FragColor = colorMatrix * color;\n" - "}\n"; - -// Paints a YUV444 frame. -static const char *qt_glsl_xyuvShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).gba, 1.0);\n" - " gl_FragColor = colorMatrix * color;\n" - "}\n"; - -// Paints a AYUV444 frame. -static const char *qt_glsl_ayuvShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).gba, 1.0);\n" - " color = colorMatrix * color;\n" - " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).r);\n" - "}\n"; - -class QVideoSurfaceGlslPainter : public QVideoSurfaceGLPainter -{ -public: - QVideoSurfaceGlslPainter(QGLContext *context); - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - -private: - QGLShaderProgram m_program; - QSize m_frameSize; -}; - -QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QGLContext *context) - : QVideoSurfaceGLPainter(context) - , m_program(context) -{ - m_imagePixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_BGR32 - << QVideoFrame::Format_ARGB32 -#ifndef QT_OPENGL_ES - << QVideoFrame::Format_RGB24 - << QVideoFrame::Format_BGR24 -#endif - << QVideoFrame::Format_RGB565 - << QVideoFrame::Format_YUV444 - << QVideoFrame::Format_AYUV444 - << QVideoFrame::Format_YV12 - << QVideoFrame::Format_YUV420P; - m_glPixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_ARGB32; -} - -QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurfaceFormat &format) -{ - Q_ASSERT(m_textureCount == 0); - - QAbstractVideoSurface::Error error = QAbstractVideoSurface::NoError; - - m_context->makeCurrent(); - - const char *fragmentProgram = 0; - - if (format.handleType() == QAbstractVideoBuffer::NoHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_xrgbShaderProgram; - break; - case QVideoFrame::Format_BGR32: - initRgbTextureInfo(GL_RGB, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - case QVideoFrame::Format_ARGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_argbShaderProgram; - break; -#ifndef QT_OPENGL_ES - case QVideoFrame::Format_RGB24: - initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - case QVideoFrame::Format_BGR24: - initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_argbShaderProgram; - break; -#endif - case QVideoFrame::Format_RGB565: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format.frameSize()); - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - case QVideoFrame::Format_YUV444: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_xyuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_AYUV444: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_ayuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_YV12: - initYv12TextureInfo(format.frameSize()); - fragmentProgram = qt_glsl_yuvPlanarShaderProgram; - break; - case QVideoFrame::Format_YUV420P: - initYuv420PTextureInfo(format.frameSize()); - fragmentProgram = qt_glsl_yuvPlanarShaderProgram; - break; - default: - break; - } - } else if (format.handleType() == QAbstractVideoBuffer::GLTextureHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_ARGB32: - m_yuv = false; - m_textureCount = 1; - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - default: - break; - } - } - - if (!fragmentProgram) { - error = QAbstractVideoSurface::UnsupportedFormatError; - } else if (!m_program.addShaderFromSourceCode(QGLShader::Vertex, qt_glsl_vertexShaderProgram)) { - qWarning("QPainterVideoSurface: Vertex shader compile error %s", - qPrintable(m_program.log())); - error = QAbstractVideoSurface::ResourceError; - } else if (!m_program.addShaderFromSourceCode(QGLShader::Fragment, fragmentProgram)) { - qWarning("QPainterVideoSurface: Shader compile error %s", qPrintable(m_program.log())); - error = QAbstractVideoSurface::ResourceError; - m_program.removeAllShaders(); - } else if(!m_program.link()) { - qWarning("QPainterVideoSurface: Shader link error %s", qPrintable(m_program.log())); - m_program.removeAllShaders(); - error = QAbstractVideoSurface::ResourceError; - } else { - m_handleType = format.handleType(); - m_scanLineDirection = format.scanLineDirection(); - m_frameSize = format.frameSize(); - - if (m_handleType == QAbstractVideoBuffer::NoHandle) - glGenTextures(m_textureCount, m_textureIds); - } - - return error; -} - -void QVideoSurfaceGlslPainter::stop() -{ - m_context->makeCurrent(); - - if (m_handleType != QAbstractVideoBuffer::GLTextureHandle) - glDeleteTextures(m_textureCount, m_textureIds); - m_program.removeAllShaders(); - - m_textureCount = 0; - m_handleType = QAbstractVideoBuffer::NoHandle; -} - -QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (m_frame.isValid()) { - bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); - bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); - - painter->beginNativePainting(); - - if (stencilTestEnabled) - glEnable(GL_STENCIL_TEST); - if (scissorTestEnabled) - glEnable(GL_SCISSOR_TEST); - - const int width = QGLContext::currentContext()->device()->width(); - const int height = QGLContext::currentContext()->device()->height(); - - const QTransform transform = painter->deviceTransform(); - - const GLfloat wfactor = 2.0 / width; - const GLfloat hfactor = -2.0 / height; - - const GLfloat positionMatrix[4][4] = - { - { - /*(0,0)*/ GLfloat(wfactor * transform.m11() - transform.m13()), - /*(0,1)*/ GLfloat(hfactor * transform.m12() + transform.m13()), - /*(0,2)*/ 0.0, - /*(0,3)*/ GLfloat(transform.m13()) - }, { - /*(1,0)*/ GLfloat(wfactor * transform.m21() - transform.m23()), - /*(1,1)*/ GLfloat(hfactor * transform.m22() + transform.m23()), - /*(1,2)*/ 0.0, - /*(1,3)*/ GLfloat(transform.m23()) - }, { - /*(2,0)*/ 0.0, - /*(2,1)*/ 0.0, - /*(2,2)*/ -1.0, - /*(2,3)*/ 0.0 - }, { - /*(3,0)*/ GLfloat(wfactor * transform.dx() - transform.m33()), - /*(3,1)*/ GLfloat(hfactor * transform.dy() + transform.m33()), - /*(3,2)*/ 0.0, - /*(3,3)*/ GLfloat(transform.m33()) - } - }; - - const GLfloat vertexCoordArray[] = - { - GLfloat(target.left()) , GLfloat(target.bottom() + 1), - GLfloat(target.right() + 1), GLfloat(target.bottom() + 1), - GLfloat(target.left()) , GLfloat(target.top()), - GLfloat(target.right() + 1), GLfloat(target.top()) - }; - - const GLfloat txLeft = source.left() / m_frameSize.width(); - const GLfloat txRight = source.right() / m_frameSize.width(); - const GLfloat txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.top() / m_frameSize.height() - : source.bottom() / m_frameSize.height(); - const GLfloat txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.bottom() / m_frameSize.height() - : source.top() / m_frameSize.height(); - - const GLfloat textureCoordArray[] = - { - txLeft , txBottom, - txRight, txBottom, - txLeft , txTop, - txRight, txTop - }; - - m_program.bind(); - - m_program.enableAttributeArray("vertexCoordArray"); - m_program.enableAttributeArray("textureCoordArray"); - m_program.setAttributeArray("vertexCoordArray", vertexCoordArray, 2); - m_program.setAttributeArray("textureCoordArray", textureCoordArray, 2); - m_program.setUniformValue("positionMatrix", positionMatrix); - - if (m_textureCount == 3) { - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, m_textureIds[1]); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, m_textureIds[2]); - glActiveTexture(GL_TEXTURE0); - - m_program.setUniformValue("texY", GLint(0)); - m_program.setUniformValue("texU", GLint(1)); - m_program.setUniformValue("texV", GLint(2)); - } else { - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); - - m_program.setUniformValue("texRgb", GLint(0)); - } - m_program.setUniformValue("colorMatrix", m_colorMatrix); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - m_program.release(); - - painter->endNativePainting(); - } - return QAbstractVideoSurface::NoError; -} - -#endif - -/*! - \class QPainterVideoSurface - \internal -*/ - -/*! -*/ -QPainterVideoSurface::QPainterVideoSurface(QObject *parent) - : QAbstractVideoSurface(parent) - , m_painter(0) -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - , m_glContext(0) - , m_shaderTypes(NoShaders) - , m_shaderType(NoShaders) -#endif - , m_brightness(0) - , m_contrast(0) - , m_hue(0) - , m_saturation(0) - , m_pixelFormat(QVideoFrame::Format_Invalid) - , m_colorsDirty(true) - , m_ready(false) -{ -} - -/*! -*/ -QPainterVideoSurface::~QPainterVideoSurface() -{ - if (isActive()) - m_painter->stop(); - - delete m_painter; -} - -/*! -*/ -QList QPainterVideoSurface::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - if (!m_painter) - const_cast(this)->createPainter(); - - return m_painter->supportedPixelFormats(handleType); -} - -/*! -*/ -bool QPainterVideoSurface::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const -{ - if (!m_painter) - const_cast(this)->createPainter(); - - return m_painter->isFormatSupported(format, similar); -} - -/*! -*/ -bool QPainterVideoSurface::start(const QVideoSurfaceFormat &format) -{ - if (isActive()) - m_painter->stop(); - - if (!m_painter) - createPainter(); - - if (format.frameSize().isEmpty()) { - setError(UnsupportedFormatError); - } else { - QAbstractVideoSurface::Error error = m_painter->start(format); - - if (error != QAbstractVideoSurface::NoError) { - setError(error); - } else { - m_pixelFormat = format.pixelFormat(); - m_frameSize = format.frameSize(); - m_sourceRect = format.viewport(); - m_colorsDirty = true; - m_ready = true; - - return QAbstractVideoSurface::start(format); - } - } - - QAbstractVideoSurface::stop(); - - return false; -} - -/*! -*/ -void QPainterVideoSurface::stop() -{ - if (isActive()) { - m_painter->stop(); - m_ready = false; - - QAbstractVideoSurface::stop(); - } -} - -/*! -*/ -bool QPainterVideoSurface::present(const QVideoFrame &frame) -{ - if (!m_ready) { - if (!isActive()) - setError(StoppedError); - } else if (frame.isValid() - && (frame.pixelFormat() != m_pixelFormat || frame.size() != m_frameSize)) { - setError(IncorrectFormatError); - - stop(); - } else { - QAbstractVideoSurface::Error error = m_painter->setCurrentFrame(frame); - - if (error != QAbstractVideoSurface::NoError) { - setError(error); - - stop(); - } else { - m_ready = false; - - emit frameChanged(); - - return true; - } - } - return false; -} - -/*! -*/ -int QPainterVideoSurface::brightness() const -{ - return m_brightness; -} - -/*! -*/ -void QPainterVideoSurface::setBrightness(int brightness) -{ - m_brightness = brightness; - - m_colorsDirty = true; -} - -/*! -*/ -int QPainterVideoSurface::contrast() const -{ - return m_contrast; -} - -/*! -*/ -void QPainterVideoSurface::setContrast(int contrast) -{ - m_contrast = contrast; - - m_colorsDirty = true; -} - -/*! -*/ -int QPainterVideoSurface::hue() const -{ - return m_hue; -} - -/*! -*/ -void QPainterVideoSurface::setHue(int hue) -{ - m_hue = hue; - - m_colorsDirty = true; -} - -/*! -*/ -int QPainterVideoSurface::saturation() const -{ - return m_saturation; -} - -/*! -*/ -void QPainterVideoSurface::setSaturation(int saturation) -{ - m_saturation = saturation; - - m_colorsDirty = true; -} - -/*! -*/ -bool QPainterVideoSurface::isReady() const -{ - return m_ready; -} - -/*! -*/ -void QPainterVideoSurface::setReady(bool ready) -{ - m_ready = ready; -} - -/*! -*/ -void QPainterVideoSurface::paint(QPainter *painter, const QRectF &target, const QRectF &source) -{ - if (!isActive()) { - painter->fillRect(target, QBrush(Qt::black)); - } else { - if (m_colorsDirty) { - m_painter->updateColors(m_brightness, m_contrast, m_hue, m_saturation); - m_colorsDirty = false; - } - - const QRectF sourceRect( - m_sourceRect.x() + m_sourceRect.width() * source.x(), - m_sourceRect.y() + m_sourceRect.height() * source.y(), - m_sourceRect.width() * source.width(), - m_sourceRect.height() * source.height()); - - QAbstractVideoSurface::Error error = m_painter->paint(target, painter, sourceRect); - - if (error != QAbstractVideoSurface::NoError) { - setError(error); - - stop(); - } - } -} - -/*! - \fn QPainterVideoSurface::frameChanged() -*/ - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - -/*! -*/ -const QGLContext *QPainterVideoSurface::glContext() const -{ - return m_glContext; -} - -/*! -*/ -void QPainterVideoSurface::setGLContext(QGLContext *context) -{ - if (m_glContext == context) - return; - - m_glContext = context; - - m_shaderTypes = NoShaders; - - if (m_glContext) { - m_glContext->makeCurrent(); - - const QByteArray extensions(reinterpret_cast(glGetString(GL_EXTENSIONS))); -#ifndef QT_OPENGL_ES - - if (extensions.contains("ARB_fragment_program")) - m_shaderTypes |= FragmentProgramShader; -#endif - - if (QGLShaderProgram::hasOpenGLShaderPrograms(m_glContext) - && extensions.contains("ARB_shader_objects")) - m_shaderTypes |= GlslShader; - } - - ShaderType type = (m_shaderType & m_shaderTypes) - ? m_shaderType - : NoShaders; - - if (type != m_shaderType || type != NoShaders) { - m_shaderType = type; - - if (isActive()) { - m_painter->stop(); - delete m_painter; - m_painter = 0; - m_ready = false; - - setError(ResourceError); - QAbstractVideoSurface::stop(); - } - emit supportedFormatsChanged(); - } -} - -/*! - \enum QPainterVideoSurface::ShaderType - - \value NoShaders - \value FragmentProgramShader - \value HlslShader -*/ - -/*! - \typedef QPainterVideoSurface::ShaderTypes -*/ - -/*! -*/ -QPainterVideoSurface::ShaderTypes QPainterVideoSurface::supportedShaderTypes() const -{ - return m_shaderTypes; -} - -/*! -*/ -QPainterVideoSurface::ShaderType QPainterVideoSurface::shaderType() const -{ - return m_shaderType; -} - -/*! -*/ -void QPainterVideoSurface::setShaderType(ShaderType type) -{ - if (!(type & m_shaderTypes)) - type = NoShaders; - - if (type != m_shaderType) { - m_shaderType = type; - - if (isActive()) { - m_painter->stop(); - delete m_painter; - m_painter = 0; - m_ready = false; - - setError(ResourceError); - QAbstractVideoSurface::stop(); - } else { - delete m_painter; - m_painter = 0; - } - emit supportedFormatsChanged(); - } -} - -#endif - -void QPainterVideoSurface::createPainter() -{ - Q_ASSERT(!m_painter); - -#ifdef Q_WS_MAC - if (m_glContext) - m_glContext->makeCurrent(); - - m_painter = new QVideoSurfaceCoreGraphicsPainter(m_glContext != 0); - return; -#endif - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - switch (m_shaderType) { -#ifndef QT_OPENGL_ES - case FragmentProgramShader: - Q_ASSERT(m_glContext); - m_glContext->makeCurrent(); - m_painter = new QVideoSurfaceArbFpPainter(m_glContext); - break; -#endif - case GlslShader: - Q_ASSERT(m_glContext); - m_glContext->makeCurrent(); - m_painter = new QVideoSurfaceGlslPainter(m_glContext); - break; - default: - m_painter = new QVideoSurfaceRasterPainter; - break; - } -#else - m_painter = new QVideoSurfaceRasterPainter; -#endif -} - -QT_END_NAMESPACE - -#include "moc_qpaintervideosurface_p.cpp" - - diff --git a/src/multimedia/mediaservices/base/qpaintervideosurface_mac.mm b/src/multimedia/mediaservices/base/qpaintervideosurface_mac.mm deleted file mode 100644 index 1154f86..0000000 --- a/src/multimedia/mediaservices/base/qpaintervideosurface_mac.mm +++ /dev/null @@ -1,283 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia 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 "qpaintervideosurface_mac_p.h" - -#include - -#include - -#include -#include -#include - -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -extern CGContextRef qt_mac_cg_context(const QPaintDevice *pdev); //qpaintdevice_mac.cpp - -QVideoSurfaceCoreGraphicsPainter::QVideoSurfaceCoreGraphicsPainter(bool glSupported) - : ciContext(0) - , m_imageFormat(QImage::Format_Invalid) - , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) -{ - //qDebug() << "QVideoSurfaceCoreGraphicsPainter, GL supported:" << glSupported; - ciContext = 0; - m_imagePixelFormats - << QVideoFrame::Format_RGB32; - - m_supportedHandles - << QAbstractVideoBuffer::NoHandle - << QAbstractVideoBuffer::CoreImageHandle; - - if (glSupported) - m_supportedHandles << QAbstractVideoBuffer::GLTextureHandle; -} - -QVideoSurfaceCoreGraphicsPainter::~QVideoSurfaceCoreGraphicsPainter() -{ - [(CIContext*)ciContext release]; -} - -QList QVideoSurfaceCoreGraphicsPainter::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - return m_supportedHandles.contains(handleType) - ? m_imagePixelFormats - : QList(); -} - -bool QVideoSurfaceCoreGraphicsPainter::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const -{ - return m_supportedHandles.contains(format.handleType()) - && m_imagePixelFormats.contains(format.pixelFormat()) - && !format.frameSize().isEmpty(); -} - -QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::start(const QVideoSurfaceFormat &format) -{ - m_frame = QVideoFrame(); - m_imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); - m_imageSize = format.frameSize(); - m_scanLineDirection = format.scanLineDirection(); - - return m_supportedHandles.contains(format.handleType()) - && m_imageFormat != QImage::Format_Invalid - && !m_imageSize.isEmpty() - ? QAbstractVideoSurface::NoError - : QAbstractVideoSurface::UnsupportedFormatError; -} - -void QVideoSurfaceCoreGraphicsPainter::stop() -{ - m_frame = QVideoFrame(); -} - -QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::setCurrentFrame(const QVideoFrame &frame) -{ - m_frame = frame; - - return QAbstractVideoSurface::NoError; -} - -QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (m_frame.handleType() == QAbstractVideoBuffer::CoreImageHandle) { - if (painter->paintEngine()->type() == QPaintEngine::CoreGraphics ) { - - CIImage *img = (CIImage*)(m_frame.handle().value()); - - if (img) { - CGContextRef cgContext = qt_mac_cg_context(painter->device()); - - if (cgContext) { - painter->beginNativePainting(); - - CGRect sRect = CGRectMake(source.x(), source.y(), source.width(), source.height()); - CGRect dRect = CGRectMake(target.x(), target.y(), target.width(), target.height()); - - NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithCIImage:img]; - - if (m_scanLineDirection == QVideoSurfaceFormat::TopToBottom) { - CGContextSaveGState( cgContext ); - CGContextTranslateCTM(cgContext, 0, dRect.origin.y + CGRectGetMaxY(dRect)); - CGContextScaleCTM(cgContext, 1, -1); - -#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4) - if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_4) { - CGContextDrawImage(cgContext, dRect, [bitmap CGImage]); - } -#endif - - CGContextRestoreGState(cgContext); - } else { -#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4) - if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_4) { - CGContextDrawImage(cgContext, dRect, [bitmap CGImage]); - } -#endif - } - - [bitmap release]; - - painter->endNativePainting(); - - return QAbstractVideoSurface::NoError; - } - } - } else if (painter->paintEngine()->type() == QPaintEngine::OpenGL2 || - painter->paintEngine()->type() == QPaintEngine::OpenGL) { - CIImage *img = (CIImage*)(m_frame.handle().value()); - - if (img) { - CGLContextObj cglContext = CGLGetCurrentContext(); - - if (cglContext) { - - if (!ciContext) { - CGLContextObj cglContext = CGLGetCurrentContext(); - NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat]; - CGLPixelFormatObj cglPixelFormat = static_cast([nsglPixelFormat CGLPixelFormatObj]); - - ciContext = [CIContext contextWithCGLContext:cglContext - pixelFormat:cglPixelFormat - options:nil]; - - [(CIContext*)ciContext retain]; - } - - CGRect sRect = CGRectMake(source.x(), source.y(), source.width(), source.height()); - CGRect dRect = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom ? - CGRectMake(target.x(), target.y()+target.height(), target.width(), -target.height()) : - CGRectMake(target.x(), target.y(), target.width(), target.height()); - - - painter->beginNativePainting(); - - [(CIContext*)ciContext drawImage:img inRect:dRect fromRect:sRect]; - - painter->endNativePainting(); - - return QAbstractVideoSurface::NoError; - } - } - } - } - - if (m_frame.handleType() == QAbstractVideoBuffer::GLTextureHandle && - (painter->paintEngine()->type() == QPaintEngine::OpenGL2 || - painter->paintEngine()->type() == QPaintEngine::OpenGL)) { - - painter->beginNativePainting(); - GLuint texture = m_frame.handle().toUInt(); - - glDisable(GL_CULL_FACE); - glEnable(GL_TEXTURE_2D); - - glBindTexture(GL_TEXTURE_2D, texture); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - const float txLeft = source.left() / m_frame.width(); - const float txRight = source.right() / m_frame.width(); - const float txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.top() / m_frame.height() - : source.bottom() / m_frame.height(); - const float txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.bottom() / m_frame.height() - : source.top() / m_frame.height(); - - glBegin(GL_QUADS); - QRectF rect = target; - glTexCoord2f(txLeft, txBottom); - glVertex2f(rect.topLeft().x(), rect.topLeft().y()); - glTexCoord2f(txRight, txBottom); - glVertex2f(rect.topRight().x() + 1, rect.topRight().y()); - glTexCoord2f(txRight, txTop); - glVertex2f(rect.bottomRight().x() + 1, rect.bottomRight().y() + 1); - glTexCoord2f(txLeft, txTop); - glVertex2f(rect.bottomLeft().x(), rect.bottomLeft().y() + 1); - glEnd(); - painter->endNativePainting(); - - return QAbstractVideoSurface::NoError; - } - - //fallback case, software rendering - if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { - QImage image( - m_frame.bits(), - m_imageSize.width(), - m_imageSize.height(), - m_frame.bytesPerLine(), - m_imageFormat); - - if (m_scanLineDirection == QVideoSurfaceFormat::BottomToTop) { - const QTransform oldTransform = painter->transform(); - - painter->scale(1, -1); - painter->translate(0, -target.bottom()); - painter->drawImage( - QRectF(target.x(), 0, target.width(), target.height()), image, source); - painter->setTransform(oldTransform); - } else { - painter->drawImage(target, image, source); - } - - m_frame.unmap(); - } else { - painter->fillRect(target, Qt::black); - } - return QAbstractVideoSurface::NoError; -} - -void QVideoSurfaceCoreGraphicsPainter::updateColors(int, int, int, int) -{ -} - -QT_END_NAMESPACE diff --git a/src/multimedia/mediaservices/base/qpaintervideosurface_mac_p.h b/src/multimedia/mediaservices/base/qpaintervideosurface_mac_p.h deleted file mode 100644 index 4f8a7a6..0000000 --- a/src/multimedia/mediaservices/base/qpaintervideosurface_mac_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QPAINTERVIDEOSURFACE_MAC_P_H -#define QPAINTERVIDEOSURFACE_MAC_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qpaintervideosurface_p.h" -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QVideoSurfaceCoreGraphicsPainter : public QVideoSurfacePainter -{ -public: - QVideoSurfaceCoreGraphicsPainter(bool glSupported); - ~QVideoSurfaceCoreGraphicsPainter(); - - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - - void updateColors(int brightness, int contrast, int hue, int saturation); - -private: - void* ciContext; - QList m_imagePixelFormats; - QVideoFrame m_frame; - QSize m_imageSize; - QImage::Format m_imageFormat; - QVector m_supportedHandles; - QVideoSurfaceFormat::Direction m_scanLineDirection; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qpaintervideosurface_p.h b/src/multimedia/mediaservices/base/qpaintervideosurface_p.h deleted file mode 100644 index 07b7e01..0000000 --- a/src/multimedia/mediaservices/base/qpaintervideosurface_p.h +++ /dev/null @@ -1,178 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QPAINTERVIDEOSURFACE_P_H -#define QPAINTERVIDEOSURFACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGLContext; - -class QVideoSurfacePainter -{ -public: - virtual ~QVideoSurfacePainter(); - - virtual QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const = 0; - - virtual bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const = 0; - - virtual QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format) = 0; - virtual void stop() = 0; - - virtual QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame) = 0; - - virtual QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source) = 0; - - virtual void updateColors(int brightness, int contrast, int hue, int saturation) = 0; -}; - -class Q_MEDIASERVICES_EXPORT QPainterVideoSurface : public QAbstractVideoSurface -{ - Q_OBJECT -public: - explicit QPainterVideoSurface(QObject *parent = 0); - ~QPainterVideoSurface(); - - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar = 0) const; - - bool start(const QVideoSurfaceFormat &format); - void stop(); - - bool present(const QVideoFrame &frame); - - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); - - bool isReady() const; - void setReady(bool ready); - - void paint(QPainter *painter, const QRectF &target, const QRectF &source = QRectF(0, 0, 1, 1)); - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - const QGLContext *glContext() const; - void setGLContext(QGLContext *context); - - enum ShaderType - { - NoShaders = 0x00, - FragmentProgramShader = 0x01, - GlslShader = 0x02 - }; - - Q_DECLARE_FLAGS(ShaderTypes, ShaderType) - - ShaderTypes supportedShaderTypes() const; - - ShaderType shaderType() const; - void setShaderType(ShaderType type); -#endif - -Q_SIGNALS: - void frameChanged(); - -private: - void createPainter(); - - QVideoSurfacePainter *m_painter; -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - QGLContext *m_glContext; - ShaderTypes m_shaderTypes; - ShaderType m_shaderType; -#endif - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; - - QVideoFrame::PixelFormat m_pixelFormat; - QSize m_frameSize; - QRect m_sourceRect; - bool m_colorsDirty; - bool m_ready; -}; - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) -Q_DECLARE_OPERATORS_FOR_FLAGS(QPainterVideoSurface::ShaderTypes) -#endif - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qtmedianamespace.h b/src/multimedia/mediaservices/base/qtmedianamespace.h deleted file mode 100644 index 917c646..0000000 --- a/src/multimedia/mediaservices/base/qtmedianamespace.h +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QTMEDIANAMESPACE_H -#define QTMEDIANAMESPACE_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -namespace QtMediaServices -{ - enum MetaData - { - // Common - Title, - SubTitle, - Author, - Comment, - Description, - Category, - Genre, - Year, - Date, - UserRating, - Keywords, - Language, - Publisher, - Copyright, - ParentalRating, - RatingOrganisation, - - // Media - Size, - MediaType, - Duration, - - // Audio - AudioBitRate, - AudioCodec, - AverageLevel, - ChannelCount, - PeakValue, - SampleRate, - - // Music - AlbumTitle, - AlbumArtist, - ContributingArtist, - Composer, - Conductor, - Lyrics, - Mood, - TrackNumber, - TrackCount, - - CoverArtUrlSmall, - CoverArtUrlLarge, - - // Image/Video - Resolution, - PixelAspectRatio, - - // Video - VideoFrameRate, - VideoBitRate, - VideoCodec, - - PosterUrl, - - // Movie - ChapterNumber, - Director, - LeadPerformer, - Writer, - - // Photos - CameraManufacturer, - CameraModel, - Event, - Subject, - Orientation, - ExposureTime, - FNumber, - ExposureProgram, - ISOSpeedRatings, - ExposureBiasValue, - DateTimeOriginal, - DateTimeDigitized, - SubjectDistance, - MeteringMode, - LightSource, - Flash, - FocalLength, - ExposureMode, - WhiteBalance, - DigitalZoomRatio, - FocalLengthIn35mmFilm, - SceneCaptureType, - GainControl, - Contrast, - Saturation, - Sharpness, - DeviceSettingDescription, - - PosterImage, - CoverArtImage, - ThumbnailImage - - }; - - enum SupportEstimate - { - NotSupported, - MaybeSupported, - ProbablySupported, - PreferredService - }; - - enum EncodingQuality - { - VeryLowQuality, - LowQuality, - NormalQuality, - HighQuality, - VeryHighQuality - }; - - enum EncodingMode - { - ConstantQualityEncoding, - ConstantBitRateEncoding, - AverageBitRateEncoding, - TwoPassEncoding - }; - - enum AvailabilityError - { - NoError, - ServiceMissingError, - BusyError, - ResourceError - }; - -} - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qtmedianamespace.qdoc b/src/multimedia/mediaservices/base/qtmedianamespace.qdoc deleted file mode 100644 index 54b856f..0000000 --- a/src/multimedia/mediaservices/base/qtmedianamespace.qdoc +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia 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$ -** -****************************************************************************/ - -/*! - \namespace QtMediaServices - \ingroup multimedia-serv - - \brief The QtMediaServices namespace contains miscellaneous identifiers used - throughout the Qt Media Services library. -*/ - -/*! - \enum QtMediaServices::MetaData - - This enum provides identifiers for meta-data attributes. - - Common attributes - \value Title The title of the media. QString. - \value SubTitle The sub-title of the media. QString. - \value Author The authors of the media. QStringList. - \value Comment A user comment about the media. QString. - \value Description A description of the media. QString - \value Category The category of the media. QStringList. - \value Genre The genre of the media. QStringList. - \value Year The year of release of the media. int. - \value Date The date of the media. QDate. - \value UserRating A user rating of the media. int [0..100]. - \value Keywords A list of keywords describing the media. QStringList. - \value Language The language of media, as an ISO 639-2 code. - - \value Publisher The publisher of the media. QString. - \value Copyright The media's copyright notice. QString. - \value ParentalRating The parental rating of the media. QString. - \value RatingOrganisation The organisation responsible for the parental rating of the media. - QString. - - Media attributes - \value Size The size in bytes of the media. qint64 - \value MediaType The type of the media (audio, video, etc). QString. - \value Duration The duration in millseconds of the media. qint64. - - Audio attributes - \value AudioBitRate The bit rate of the media's audio stream in bits per second. int. - \value AudioCodec The codec of the media's audio stream. QString. - \value AverageLevel The average volume level of the media. int. - \value ChannelCount The number of channels in the media's audio stream. int. - \value PeakValue The peak volume of the media's audio stream. int - \value SampleRate The sample rate of the media's audio stream in hertz. int - - Music attributes - \value AlbumTitle The title of the album the media belongs to. QString. - \value AlbumArtist The principal artist of the album the media belongs to. QString. - \value ContributingArtist The artists contributing to the media. QStringList. - \value Composer The composer of the media. QStringList. - \value Conductor The conductor of the media. QString. - \value Lyrics The lyrics to the media. QString. - \value Mood The mood of the media. QString. - \value TrackNumber The track number of the media. int. - \value TrackCount The number of tracks on the album containing the media. int. - - \value CoverArtUrlSmall The URL of a small cover art image. QUrl. - \value CoverArtUrlLarge The URL of a large cover art image. QUrl. - \value CoverArtImage An embedded cover art image. QImage. - - Image and video attributes - \value Resolution The dimensions of an image or video. QSize. - \value PixelAspectRatio The pixel aspect ratio of an image or video. QSize. - - Video attributes - \value VideoFrameRate The frame rate of the media's video stream. qreal. - \value VideoBitRate The bit rate of the media's video stream in bits per second. int. - \value VideoCodec The codec of the media's video stream. QString. - - \value PosterUrl The URL of a poster image. QUrl. - \value PosterImage An embedded poster image. QImage. - - Movie attributes - \value ChapterNumber The chapter number of the media. int. - \value Director The director of the media. QString. - \value LeadPerformer The lead performer in the media. QStringList. - \value Writer The writer of the media. QStringList. - - Photo attributes. - \value CameraManufacturer The manufacturer of the camera used to capture the media. QString. - \value CameraModel The model of the camera used to capture the media. QString. - \value Event The event during which the media was captured. QString. - \value Subject The subject of the media. QString. - \value Orientation Orientation of image. - \value ExposureTime Exposure time, given in seconds. - \value FNumber The F Number. - \value ExposureProgram - The class of the program used by the camera to set exposure when the picture is taken. - \value ISOSpeedRatings - Indicates the ISO Speed and ISO Latitude of the camera or input device as specified in ISO 12232. - \value ExposureBiasValue - The exposure bias. - The unit is the APEX (Additive System of Photographic Exposure) setting. - \value DateTimeOriginal The date and time when the original image data was generated. - \value DateTimeDigitized The date and time when the image was stored as digital data. - \value SubjectDistance The distance to the subject, given in meters. - \value MeteringMode The metering mode. - \value LightSource - The kind of light source. - \value Flash - Status of flash when the image was shot. - \value FocalLength - The actual focal length of the lens, in mm. - \value ExposureMode - Indicates the exposure mode set when the image was shot. - \value WhiteBalance - Indicates the white balance mode set when the image was shot. - \value DigitalZoomRatio - Indicates the digital zoom ratio when the image was shot. - \value FocalLengthIn35mmFilm - Indicates the equivalent focal length assuming a 35mm film camera, in mm. - \value SceneCaptureType - Indicates the type of scene that was shot. - It can also be used to record the mode in which the image was shot. - \value GainControl - Indicates the degree of overall image gain adjustment. - \value Contrast - Indicates the direction of contrast processing applied by the camera when the image was shot. - \value Saturation - Indicates the direction of saturation processing applied by the camera when the image was shot. - \value Sharpness - Indicates the direction of sharpness processing applied by the camera when the image was shot. - \value DeviceSettingDescription - Exif tag, indicates information on the picture-taking conditions of a particular camera model. QString - - \value ThumbnailImage An embedded thumbnail image. QImage. -*/ - -/*! - \enum QtMediaServices::SupportEstimate - - Enumerates the levels of support a media service provider may have for a feature. - - \value NotSupported The feature is not supported. - \value MaybeSupported The feature may be supported. - \value ProbablySupported The feature is probably supported. - \value PreferredService The service is the preferred provider of a service. -*/ - -/*! - \enum QtMediaServices::EncodingQuality - - Enumerates quality encoding levels. - - \value VeryLowQuality - \value LowQuality - \value NormalQuality - \value HighQuality - \value VeryHighQuality -*/ - -/*! - \enum QtMediaServices::EncodingMode - - Enumerates encoding modes. - - \value ConstantQualityEncoding - \value ConstantBitRateEncoding - \value AverageBitRateEncoding - \value TwoPassEncoding -*/ - -/*! - \enum QtMediaServices::AvailabilityError - - Enumerates Service status errors. - - \value NoError - \value ServiceMissingError - \value ResourceError - \value BusyError -*/ diff --git a/src/multimedia/mediaservices/base/qvideodevicecontrol.cpp b/src/multimedia/mediaservices/base/qvideodevicecontrol.cpp deleted file mode 100644 index 30c56cf..0000000 --- a/src/multimedia/mediaservices/base/qvideodevicecontrol.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoDeviceControl - \preliminary - \since 4.7 - \brief The QVideoDeviceControl class provides an video device selector media control. - \ingroup multimedia-serv - - The QVideoDeviceControl class provides descriptions of the video devices - available on a system and allows one to be selected as the endpoint of - a media service. - - The interface name of QVideoDeviceControl is \c com.nokia.Qt.VideoDeviceControl as - defined in QVideoDeviceControl_iid. -*/ - -/*! - \macro QVideoDeviceControl_iid - - \c com.nokia.Qt.VideoDeviceControl - - Defines the interface name of the QVideoDeviceControl class. - - \relates QVideoDeviceControl -*/ - -/*! - Constructs a video device control with the given \a parent. -*/ -QVideoDeviceControl::QVideoDeviceControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys a video device control. -*/ -QVideoDeviceControl::~QVideoDeviceControl() -{ -} - -/*! - \fn QVideoDeviceControl::deviceCount() const - - Returns the number of available video devices; -*/ - -/*! - \fn QVideoDeviceControl::deviceName(int index) const - - Returns the name of the video device at \a index. -*/ - -/*! - \fn QVideoDeviceControl::deviceDescription(int index) const - - Returns a description of the video device at \a index. -*/ - -/*! - \fn QVideoDeviceControl::deviceIcon(int index) const - - Returns an icon for the video device at \a index. -*/ - -/*! - \fn QVideoDeviceControl::defaultDevice() const - - Returns the index of the default video device. -*/ - -/*! - \fn QVideoDeviceControl::selectedDevice() const - - Returns the index of the selected video device. -*/ - -/*! - \fn QVideoDeviceControl::setSelectedDevice(int index) - - Sets the selected video device \a index. -*/ - -/*! - \fn QVideoDeviceControl::devicesChanged() - - Signals that the list of available video devices has changed. -*/ - -/*! - \fn QVideoDeviceControl::selectedDeviceChanged(int index) - - Signals that the selected video device \a index has changed. -*/ - -/*! - \fn QVideoDeviceControl::selectedDeviceChanged(const QString &name) - - Signals that the selected video device \a name has changed. -*/ - -QT_END_NAMESPACE - -QT_END_HEADER - -#include "moc_qvideodevicecontrol.cpp" - - diff --git a/src/multimedia/mediaservices/base/qvideodevicecontrol.h b/src/multimedia/mediaservices/base/qvideodevicecontrol.h deleted file mode 100644 index 0b9235b..0000000 --- a/src/multimedia/mediaservices/base/qvideodevicecontrol.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QVIDEODEVICECONTROL_H -#define QVIDEODEVICECONTROL_H - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class Q_MEDIASERVICES_EXPORT QVideoDeviceControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QVideoDeviceControl(); - - virtual int deviceCount() const = 0; - - virtual QString deviceName(int index) const = 0; - virtual QString deviceDescription(int index) const = 0; - virtual QIcon deviceIcon(int index) const = 0; - - virtual int defaultDevice() const = 0; - virtual int selectedDevice() const = 0; - -public Q_SLOTS: - virtual void setSelectedDevice(int index) = 0; - -Q_SIGNALS: - void selectedDeviceChanged(int index); - void selectedDeviceChanged(const QString &deviceName); - void devicesChanged(); - -protected: - QVideoDeviceControl(QObject *parent = 0); -}; - -#define QVideoDeviceControl_iid "com.nokia.Qt.QVideoDeviceControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoDeviceControl, QVideoDeviceControl_iid) - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QVIDEODEVICECONTROL_H diff --git a/src/multimedia/mediaservices/base/qvideooutputcontrol.cpp b/src/multimedia/mediaservices/base/qvideooutputcontrol.cpp deleted file mode 100644 index 532c892..0000000 --- a/src/multimedia/mediaservices/base/qvideooutputcontrol.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 - - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoOutputControl - \preliminary - \since 4.7 - \brief The QVideoOutputControl class provides a means of selecting the - active video output control. - - \ingroup multimedia-serv - - There are multiple controls which a QMediaService may use to output - video ony one of which may be active at one time, QVideoOutputControl - is the means by which this active control is selected. - - The possible output controls are QVideoRendererControl, - QVideoWindowControl, and QVideoWidgetControl. - - The interface name of QVideoOutputControl is \c com.nokia.Qt.QVideoOutputControl/1.0 as - defined in QVideoOutputControl_iid. - - \sa QMediaService::control(), QVideoWidget, QVideoRendererControl, - QVideoWindowControl, QVideoWidgetControl -*/ - -/*! - \macro QVideoOutputControl_iid - - \c com.nokia.Qt.QVideoOutputControl/1.0 - - Defines the interface name of the QVideoOutputControl class. - - \relates QVideoOutputControl -*/ - -/*! - \enum QVideoOutputControl::Output - - Identifies the possible render targets of a video output. - - \value NoOutput Video is not rendered. - \value WindowOutput Video is rendered to the target of a QVideoWindowControl. - \value RendererOutput Video is rendered to the target of a QVideoRendererControl. - \value WidgetOutput Video is rendered to a QWidget provided by QVideoWidgetControl. - \value UserOutput Start value for user defined video targets. - \value MaxUserOutput End value for user defined video targets. -*/ - -/*! - Constructs a new video output control with the given \a parent. -*/ -QVideoOutputControl::QVideoOutputControl(QObject *parent) - : QMediaControl(parent) -{ -} - -/*! - Destroys a video output control. -*/ -QVideoOutputControl::~QVideoOutputControl() -{ -} - -/*! - \fn QList QVideoOutputControl::availableOutputs() const - - Returns a list of available video output targets. -*/ - -/*! - \fn QVideoOutputControl::output() const - - Returns the current video output target. -*/ - -/*! - \fn QVideoOutputControl::setOutput(Output output) - - Sets the current video \a output target. -*/ - -/*! - \fn QVideoOutputControl::availableOutputsChanged(const QList &outputs) - - Signals that available set of video \a outputs has changed. -*/ - -#include "moc_qvideooutputcontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qvideooutputcontrol.h b/src/multimedia/mediaservices/base/qvideooutputcontrol.h deleted file mode 100644 index f87bb3c..0000000 --- a/src/multimedia/mediaservices/base/qvideooutputcontrol.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QVIDEOOUTPUTCONTROL_H -#define QVIDEOOUTPUTCONTROL_H - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MEDIASERVICES_EXPORT QVideoOutputControl : public QMediaControl -{ - Q_OBJECT - -public: - enum Output - { - NoOutput, - WindowOutput, - RendererOutput, - WidgetOutput, - UserOutput = 100, - MaxUserOutput = 1000 - }; - - ~QVideoOutputControl(); - - virtual QList availableOutputs() const = 0; - - virtual Output output() const = 0; - virtual void setOutput(Output output) = 0; - -Q_SIGNALS: - void availableOutputsChanged(const QList &outputs); - -protected: - QVideoOutputControl(QObject *parent = 0); -}; - -#define QVideoOutputControl_iid "com.nokia.Qt.QVideoOutputControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoOutputControl, QVideoOutputControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qvideorenderercontrol.cpp b/src/multimedia/mediaservices/base/qvideorenderercontrol.cpp deleted file mode 100644 index 6cc3138..0000000 --- a/src/multimedia/mediaservices/base/qvideorenderercontrol.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 - -#include "qmediacontrol_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoRendererControl - \preliminary - \since 4.7 - \brief The QVideoRendererControl class provides a control for rendering - to a video surface. - - \ingroup multimedia-serv - - Using the surface() property of QVideoRendererControl a QAbstractVideoSurface - may be set as the video render target of a QMediaService. - - \code - QVideoRendererControl *rendererControl = mediaService->control(); - rendererControl->setSurface(myVideoSurface); - \endcode - - QVideoRendererControl is one of number of possible video output controls, - in order to receive video it must be made the active video output - control by setting the output property of QVideoOutputControl to - \l {QVideoOutputControl::RendererOutput}{RendererOutput}. Consequently any - QMediaService that implements QVideoRendererControl must also implement - QVideoOutputControl. - - \code - QVideoOutputControl *outputControl = mediaService->control(); - outputControl->setOutput(QVideoOutputControl::RendererOutput); - \endcode - - The interface name of QVideoRendererControl is \c com.nokia.Qt.QVideoRendererControl/1.0 as - defined in QVideoRendererControl_iid. - - \sa QMediaService::control(), QVideoOutputControl, QVideoWidget -*/ - -/*! - \macro QVideoRendererControl_iid - - \c com.nokia.Qt.QVideoRendererControl/1.0 - - Defines the interface name of the QVideoRendererControl class. - - \relates QVideoRendererControl -*/ - -/*! - Constructs a new video renderer media end point with the given \a parent. -*/ -QVideoRendererControl::QVideoRendererControl(QObject *parent) - : QMediaControl(parent) -{ -} - -/*! - Destroys a video renderer media end point. -*/ -QVideoRendererControl::~QVideoRendererControl() -{ -} - -/*! - \fn QVideoRendererControl::surface() const - - Returns the surface a video producer renders to. -*/ - -/*! - \fn QVideoRendererControl::setSurface(QAbstractVideoSurface *surface) - - Sets the \a surface a video producer renders to. -*/ - -#include "moc_qvideorenderercontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qvideorenderercontrol.h b/src/multimedia/mediaservices/base/qvideorenderercontrol.h deleted file mode 100644 index 28e3d85..0000000 --- a/src/multimedia/mediaservices/base/qvideorenderercontrol.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QVIDEORENDERERCONTROL_H -#define QVIDEORENDERERCONTROL_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAbstractVideoSurface; - -class Q_MEDIASERVICES_EXPORT QVideoRendererControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QVideoRendererControl(); - - virtual QAbstractVideoSurface *surface() const = 0; - virtual void setSurface(QAbstractVideoSurface *surface) = 0; - -protected: - QVideoRendererControl(QObject *parent = 0); -}; - -#define QVideoRendererControl_iid "com.nokia.Qt.QVideoRendererControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoRendererControl, QVideoRendererControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QVIDEORENDERERCONTROL_H diff --git a/src/multimedia/mediaservices/base/qvideowidget.cpp b/src/multimedia/mediaservices/base/qvideowidget.cpp deleted file mode 100644 index d39b1f4..0000000 --- a/src/multimedia/mediaservices/base/qvideowidget.cpp +++ /dev/null @@ -1,944 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 "qvideowidget_p.h" - -#include -#include -#include -#include -#include - -#include "qpaintervideosurface_p.h" -#include -#include -#include - -#include -#include -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -QVideoWidgetControlBackend::QVideoWidgetControlBackend( - QVideoWidgetControl *control, QWidget *widget) - : m_widgetControl(control) -{ - connect(control, SIGNAL(brightnessChanged(int)), widget, SLOT(_q_brightnessChanged(int))); - connect(control, SIGNAL(contrastChanged(int)), widget, SLOT(_q_contrastChanged(int))); - connect(control, SIGNAL(hueChanged(int)), widget, SLOT(_q_hueChanged(int))); - connect(control, SIGNAL(saturationChanged(int)), widget, SLOT(_q_saturationChanged(int))); - connect(control, SIGNAL(fullScreenChanged(bool)), widget, SLOT(_q_fullScreenChanged(bool))); - - QBoxLayout *layout = new QVBoxLayout; - layout->setMargin(0); - layout->setSpacing(0); - layout->addWidget(control->videoWidget()); - - widget->setLayout(layout); -} - -void QVideoWidgetControlBackend::setBrightness(int brightness) -{ - m_widgetControl->setBrightness(brightness); -} - -void QVideoWidgetControlBackend::setContrast(int contrast) -{ - m_widgetControl->setContrast(contrast); -} - -void QVideoWidgetControlBackend::setHue(int hue) -{ - m_widgetControl->setHue(hue); -} - -void QVideoWidgetControlBackend::setSaturation(int saturation) -{ - m_widgetControl->setSaturation(saturation); -} - -void QVideoWidgetControlBackend::setFullScreen(bool fullScreen) -{ - m_widgetControl->setFullScreen(fullScreen); -} - - -Qt::AspectRatioMode QVideoWidgetControlBackend::aspectRatioMode() const -{ - return m_widgetControl->aspectRatioMode(); -} - -void QVideoWidgetControlBackend::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_widgetControl->setAspectRatioMode(mode); -} - -QRendererVideoWidgetBackend::QRendererVideoWidgetBackend( - QVideoRendererControl *control, QWidget *widget) - : m_rendererControl(control) - , m_widget(widget) - , m_surface(new QPainterVideoSurface) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_updatePaintDevice(true) -{ - connect(this, SIGNAL(brightnessChanged(int)), m_widget, SLOT(_q_brightnessChanged(int))); - connect(this, SIGNAL(contrastChanged(int)), m_widget, SLOT(_q_contrastChanged(int))); - connect(this, SIGNAL(hueChanged(int)), m_widget, SLOT(_q_hueChanged(int))); - connect(this, SIGNAL(saturationChanged(int)), m_widget, SLOT(_q_saturationChanged(int))); - connect(m_surface, SIGNAL(frameChanged()), this, SLOT(frameChanged())); - connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SLOT(formatChanged(QVideoSurfaceFormat))); - - m_rendererControl->setSurface(m_surface); -} - -QRendererVideoWidgetBackend::~QRendererVideoWidgetBackend() -{ - delete m_surface; -} - -void QRendererVideoWidgetBackend::clearSurface() -{ - m_rendererControl->setSurface(0); -} - -void QRendererVideoWidgetBackend::setBrightness(int brightness) -{ - m_surface->setBrightness(brightness); - - emit brightnessChanged(brightness); -} - -void QRendererVideoWidgetBackend::setContrast(int contrast) -{ - m_surface->setContrast(contrast); - - emit contrastChanged(contrast); -} - -void QRendererVideoWidgetBackend::setHue(int hue) -{ - m_surface->setHue(hue); - - emit hueChanged(hue); -} - -void QRendererVideoWidgetBackend::setSaturation(int saturation) -{ - m_surface->setSaturation(saturation); - - emit saturationChanged(saturation); -} - -Qt::AspectRatioMode QRendererVideoWidgetBackend::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void QRendererVideoWidgetBackend::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_aspectRatioMode = mode; - - m_widget->updateGeometry(); -} - -void QRendererVideoWidgetBackend::setFullScreen(bool) -{ -} - -QSize QRendererVideoWidgetBackend::sizeHint() const -{ - return m_surface->surfaceFormat().sizeHint(); -} - -void QRendererVideoWidgetBackend::showEvent() -{ -} - -void QRendererVideoWidgetBackend::hideEvent(QHideEvent *) -{ -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - m_updatePaintDevice = true; - m_surface->setGLContext(0); -#endif -} - -void QRendererVideoWidgetBackend::resizeEvent(QResizeEvent *) -{ - updateRects(); -} - -void QRendererVideoWidgetBackend::moveEvent(QMoveEvent *) -{ -} - -void QRendererVideoWidgetBackend::paintEvent(QPaintEvent *event) -{ - QPainter painter(m_widget); - - if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { - QRegion borderRegion = event->region(); - borderRegion = borderRegion.subtracted(m_boundingRect); - - QBrush brush = m_widget->palette().window(); - - QVector rects = borderRegion.rects(); - for (QVector::iterator it = rects.begin(), end = rects.end(); it != end; ++it) { - painter.fillRect(*it, brush); - } - } - - if (m_surface->isActive() && m_boundingRect.intersects(event->rect())) { - m_surface->paint(&painter, m_boundingRect, m_sourceRect); - - m_surface->setReady(true); - } else { - #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - if (m_updatePaintDevice && (painter.paintEngine()->type() == QPaintEngine::OpenGL - || painter.paintEngine()->type() == QPaintEngine::OpenGL2)) { - m_updatePaintDevice = false; - - m_surface->setGLContext(const_cast(QGLContext::currentContext())); - if (m_surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { - m_surface->setShaderType(QPainterVideoSurface::GlslShader); - } else { - m_surface->setShaderType(QPainterVideoSurface::FragmentProgramShader); - } - } -#endif - } - -} - -void QRendererVideoWidgetBackend::formatChanged(const QVideoSurfaceFormat &format) -{ - m_nativeSize = format.sizeHint(); - - updateRects(); - - m_widget->updateGeometry(); - m_widget->update(); -} - -void QRendererVideoWidgetBackend::frameChanged() -{ - m_widget->update(m_boundingRect); -} - -void QRendererVideoWidgetBackend::updateRects() -{ - QRect rect = m_widget->rect(); - - if (m_nativeSize.isEmpty()) { - m_boundingRect = QRect(); - } else if (m_aspectRatioMode == Qt::IgnoreAspectRatio) { - m_boundingRect = rect; - m_sourceRect = QRectF(0, 0, 1, 1); - } else if (m_aspectRatioMode == Qt::KeepAspectRatio) { - QSize size = m_nativeSize; - size.scale(rect.size(), Qt::KeepAspectRatio); - - m_boundingRect = QRect(0, 0, size.width(), size.height()); - m_boundingRect.moveCenter(rect.center()); - - m_sourceRect = QRectF(0, 0, 1, 1); - } else if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) { - m_boundingRect = rect; - - QSizeF size = rect.size(); - size.scale(m_nativeSize, Qt::KeepAspectRatio); - - m_sourceRect = QRectF( - 0, 0, size.width() / m_nativeSize.width(), size.height() / m_nativeSize.height()); - m_sourceRect.moveCenter(QPointF(0.5, 0.5)); - } -} - -QWindowVideoWidgetBackend::QWindowVideoWidgetBackend(QVideoWindowControl *control, QWidget *widget) - : m_windowControl(control) - , m_widget(widget) - , m_aspectRatioMode(Qt::KeepAspectRatio) -{ - connect(control, SIGNAL(brightnessChanged(int)), m_widget, SLOT(_q_brightnessChanged(int))); - connect(control, SIGNAL(contrastChanged(int)), m_widget, SLOT(_q_contrastChanged(int))); - connect(control, SIGNAL(hueChanged(int)), m_widget, SLOT(_q_hueChanged(int))); - connect(control, SIGNAL(saturationChanged(int)), m_widget, SLOT(_q_saturationChanged(int))); - connect(control, SIGNAL(fullScreenChanged(bool)), m_widget, SLOT(_q_fullScreenChanged(bool))); - connect(control, SIGNAL(nativeSizeChanged()), m_widget, SLOT(_q_dimensionsChanged())); -} - -QWindowVideoWidgetBackend::~QWindowVideoWidgetBackend() -{ -} - -void QWindowVideoWidgetBackend::setBrightness(int brightness) -{ - m_windowControl->setBrightness(brightness); -} - -void QWindowVideoWidgetBackend::setContrast(int contrast) -{ - m_windowControl->setContrast(contrast); -} - -void QWindowVideoWidgetBackend::setHue(int hue) -{ - m_windowControl->setHue(hue); -} - -void QWindowVideoWidgetBackend::setSaturation(int saturation) -{ - m_windowControl->setSaturation(saturation); -} - -void QWindowVideoWidgetBackend::setFullScreen(bool fullScreen) -{ - m_windowControl->setFullScreen(fullScreen); -} - -Qt::AspectRatioMode QWindowVideoWidgetBackend::aspectRatioMode() const -{ - return m_windowControl->aspectRatioMode(); -} - -void QWindowVideoWidgetBackend::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_windowControl->setAspectRatioMode(mode); -} - -QSize QWindowVideoWidgetBackend::sizeHint() const -{ - return m_windowControl->nativeSize(); -} - -void QWindowVideoWidgetBackend::showEvent() -{ - m_windowControl->setWinId(m_widget->winId()); - - m_windowControl->setDisplayRect(m_widget->rect()); -} - -void QWindowVideoWidgetBackend::hideEvent(QHideEvent *) -{ -} - -void QWindowVideoWidgetBackend::moveEvent(QMoveEvent *) -{ - m_windowControl->setDisplayRect(m_widget->rect()); -} - -void QWindowVideoWidgetBackend::resizeEvent(QResizeEvent *) -{ - m_windowControl->setDisplayRect(m_widget->rect()); -} - -void QWindowVideoWidgetBackend::paintEvent(QPaintEvent *event) -{ - if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { - QPainter painter(m_widget); - - painter.fillRect(event->rect(), m_widget->palette().window()); - } - - m_windowControl->repaint(); - - event->accept(); -} - -void QVideoWidgetPrivate::setCurrentControl(QVideoWidgetControlInterface *control) -{ - if (currentControl != control) { - currentControl = control; - - currentControl->setBrightness(brightness); - currentControl->setContrast(contrast); - currentControl->setHue(hue); - currentControl->setSaturation(saturation); - currentControl->setAspectRatioMode(aspectRatioMode); - } -} - -void QVideoWidgetPrivate::show() -{ - if (outputControl) { - if (widgetBackend != 0) { - setCurrentControl(widgetBackend); - outputControl->setOutput(QVideoOutputControl::WidgetOutput); - } else if (windowBackend != 0 && (q_func()->window() == 0 - || !q_func()->window()->testAttribute(Qt::WA_DontShowOnScreen))) { - windowBackend->showEvent(); - currentBackend = windowBackend; - setCurrentControl(windowBackend); - outputControl->setOutput(QVideoOutputControl::WindowOutput); - } else if (rendererBackend != 0) { - rendererBackend->showEvent(); - currentBackend = rendererBackend; - setCurrentControl(rendererBackend); - outputControl->setOutput(QVideoOutputControl::RendererOutput); - } else { - outputControl->setOutput(QVideoOutputControl::NoOutput); - } - } -} - -void QVideoWidgetPrivate::clearService() -{ - if (service) { - QObject::disconnect(service, SIGNAL(destroyed()), q_func(), SLOT(_q_serviceDestroyed())); - - if (outputControl) - outputControl->setOutput(QVideoOutputControl::NoOutput); - - if (widgetBackend) { - QLayout *layout = q_func()->layout(); - - for (QLayoutItem *item = layout->takeAt(0); item; item = layout->takeAt(0)) { - item->widget()->setParent(0); - delete item; - } - delete layout; - - delete widgetBackend; - widgetBackend = 0; - } - - delete windowBackend; - windowBackend = 0; - - if (rendererBackend) { - rendererBackend->clearSurface(); - - delete rendererBackend; - rendererBackend = 0; - } - - currentBackend = 0; - currentControl = 0; - outputControl = 0; - service = 0; - } -} - -void QVideoWidgetPrivate::_q_serviceDestroyed() -{ - if (widgetBackend) { - delete q_func()->layout(); - - delete widgetBackend; - widgetBackend = 0; - } - - delete windowBackend; - windowBackend = 0; - - delete rendererBackend; - rendererBackend = 0; - - currentControl = 0; - currentBackend = 0; - outputControl = 0; - service = 0; -} - -void QVideoWidgetPrivate::_q_mediaObjectDestroyed() -{ - mediaObject = 0; - clearService(); -} - -void QVideoWidgetPrivate::_q_brightnessChanged(int b) -{ - if (b != brightness) - emit q_func()->brightnessChanged(brightness = b); -} - -void QVideoWidgetPrivate::_q_contrastChanged(int c) -{ - if (c != contrast) - emit q_func()->contrastChanged(contrast = c); -} - -void QVideoWidgetPrivate::_q_hueChanged(int h) -{ - if (h != hue) - emit q_func()->hueChanged(hue = h); -} - -void QVideoWidgetPrivate::_q_saturationChanged(int s) -{ - if (s != saturation) - emit q_func()->saturationChanged(saturation = s); -} - - -void QVideoWidgetPrivate::_q_fullScreenChanged(bool fullScreen) -{ - if (!fullScreen && q_func()->isFullScreen()) - q_func()->showNormal(); -} - -void QVideoWidgetPrivate::_q_dimensionsChanged() -{ - q_func()->updateGeometry(); - q_func()->update(); -} - -/*! - \class QVideoWidget - \preliminary - \since 4.7 - \brief The QVideoWidget class provides a widget which presents video - produced by a media object. - \ingroup multimedia - - Attaching a QVideoWidget to a QMediaObject allows it to display the - video or image output of that media object. A QVideoWidget is attached - to media object by passing a pointer to the QMediaObject in its - constructor, and detached by destroying the QVideoWidget. - - \code - player = new QMediaPlayer; - - widget = new QVideoWidget(player); - widget->show(); - - player->setMedia(QUrl("http://example.com/movie.mp4")); - player->play(); - \endcode - - \bold {Note}: Only a single display output can be attached to a media - object at one time. - - \sa QMediaObject, QMediaPlayer, QGraphicsVideoItem -*/ - -/*! - Constructs a new video widget. - - The \a parent is passed to QWidget. -*/ -QVideoWidget::QVideoWidget(QWidget *parent) - : QWidget(parent, 0) - , d_ptr(new QVideoWidgetPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys a video widget. -*/ -QVideoWidget::~QVideoWidget() -{ - setMediaObject(0); - delete d_ptr; -} - -/*! - \property QVideoWidget::mediaObject - \brief the media object which provides the video displayed by a widget. -*/ - -QMediaObject *QVideoWidget::mediaObject() const -{ - return d_func()->mediaObject; -} - -void QVideoWidget::setMediaObject(QMediaObject *object) -{ - Q_D(QVideoWidget); - - if (object == d->mediaObject) - return; - - if (d->mediaObject) { - disconnect(d->mediaObject, SIGNAL(destroyed()), this, SLOT(_q_mediaObjectDestroyed())); - d->mediaObject->unbind(this); - } - - d->clearService(); - - d->mediaObject = object; - - if (d->mediaObject) { - d->service = d->mediaObject->service(); - - connect(d->mediaObject, SIGNAL(destroyed()), this, SLOT(_q_mediaObjectDestroyed())); - d->mediaObject->bind(this); - } - - if (d->service) { - connect(d->service, SIGNAL(destroyed()), SLOT(_q_serviceDestroyed())); - - d->outputControl = qobject_cast( - d->service->control(QVideoOutputControl_iid)); - - QVideoWidgetControl *widgetControl = qobject_cast( - d->service->control(QVideoWidgetControl_iid)); - - if (widgetControl != 0) { - d->widgetBackend = new QVideoWidgetControlBackend(widgetControl, this); - } else { - QVideoWindowControl *windowControl = qobject_cast( - d->service->control(QVideoWindowControl_iid)); - - if (windowControl != 0) - d->windowBackend = new QWindowVideoWidgetBackend(windowControl, this); - - QVideoRendererControl *rendererControl = qobject_cast( - d->service->control(QVideoRendererControl_iid)); - - if (rendererControl != 0) - d->rendererBackend = new QRendererVideoWidgetBackend(rendererControl, this); - } - - if (isVisible()) - d->show(); - } -} - -/*! - \property QVideoWidget::aspectRatioMode - \brief how video is scaled with respect to its aspect ratio. -*/ - -Qt::AspectRatioMode QVideoWidget::aspectRatioMode() const -{ - return d_func()->aspectRatioMode; -} - -void QVideoWidget::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - Q_D(QVideoWidget); - - if (d->currentControl) { - d->currentControl->setAspectRatioMode(mode); - d->aspectRatioMode = d->currentControl->aspectRatioMode(); - } else { - d->aspectRatioMode = mode; - } -} - -/*! - \property QVideoWidget::fullScreen - \brief whether video display is confined to a window or is fullScreen. -*/ - -void QVideoWidget::setFullScreen(bool fullScreen) -{ - Q_D(QVideoWidget); - - if (fullScreen) { - Qt::WindowFlags flags = windowFlags(); - - d->nonFullScreenFlags = flags & (Qt::Window | Qt::SubWindow); - flags |= Qt::Window; - flags &= ~Qt::SubWindow; - setWindowFlags(flags); - - showFullScreen(); - } else { - showNormal(); - } -} - -/*! - \fn QVideoWidget::fullScreenChanged(bool fullScreen) - - Signals that the \a fullScreen mode of a video widget has changed. - - \sa fullScreen -*/ - -/*! - \property QVideoWidget::brightness - \brief an adjustment to the brightness of displayed video. - - Valid brightness values range between -100 and 100, the default is 0. -*/ - -int QVideoWidget::brightness() const -{ - return d_func()->brightness; -} - -void QVideoWidget::setBrightness(int brightness) -{ - Q_D(QVideoWidget); - - int boundedBrightness = qBound(-100, brightness, 100); - - if (d->currentControl) - d->currentControl->setBrightness(boundedBrightness); - else if (d->brightness != boundedBrightness) - emit brightnessChanged(d->brightness = boundedBrightness); -} - -/*! - \fn QVideoWidget::brightnessChanged(int brightness) - - Signals that a video widgets's \a brightness adjustment has changed. - - \sa brightness -*/ - -/*! - \property QVideoWidget::contrast - \brief an adjustment to the contrast of displayed video. - - Valid contrast values range between -100 and 100, the default is 0. - -*/ - -int QVideoWidget::contrast() const -{ - return d_func()->contrast; -} - -void QVideoWidget::setContrast(int contrast) -{ - Q_D(QVideoWidget); - - int boundedContrast = qBound(-100, contrast, 100); - - if (d->currentControl) - d->currentControl->setContrast(boundedContrast); - else if (d->contrast != boundedContrast) - emit contrastChanged(d->contrast = boundedContrast); -} - -/*! - \fn QVideoWidget::contrastChanged(int contrast) - - Signals that a video widgets's \a contrast adjustment has changed. - - \sa contrast -*/ - -/*! - \property QVideoWidget::hue - \brief an adjustment to the hue of displayed video. - - Valid hue values range between -100 and 100, the default is 0. -*/ - -int QVideoWidget::hue() const -{ - return d_func()->hue; -} - -void QVideoWidget::setHue(int hue) -{ - Q_D(QVideoWidget); - - int boundedHue = qBound(-100, hue, 100); - - if (d->currentControl) - d->currentControl->setHue(boundedHue); - else if (d->hue != boundedHue) - emit hueChanged(d->hue = boundedHue); -} - -/*! - \fn QVideoWidget::hueChanged(int hue) - - Signals that a video widgets's \a hue has changed. - - \sa hue -*/ - -/*! - \property QVideoWidget::saturation - \brief an adjustment to the saturation of displayed video. - - Valid saturation values range between -100 and 100, the default is 0. -*/ - -int QVideoWidget::saturation() const -{ - return d_func()->saturation; -} - -void QVideoWidget::setSaturation(int saturation) -{ - Q_D(QVideoWidget); - - int boundedSaturation = qBound(-100, saturation, 100); - - if (d->currentControl) - d->currentControl->setSaturation(boundedSaturation); - else if (d->saturation != boundedSaturation) - emit saturationChanged(d->saturation = boundedSaturation); - -} - -/*! - \fn QVideoWidget::saturationChanged(int saturation) - - Signals that a video widgets's \a saturation has changed. - - \sa saturation -*/ - -/*! - Returns the size hint for the current back end, - if there is one, or else the size hint from QWidget. - */ -QSize QVideoWidget::sizeHint() const -{ - Q_D(const QVideoWidget); - - if (d->currentBackend) - return d->currentBackend->sizeHint(); - else - return QWidget::sizeHint(); - - -} - -/*! - \reimp - \internal - */ -bool QVideoWidget::event(QEvent *event) -{ - Q_D(QVideoWidget); - - if (event->type() == QEvent::WindowStateChange) { - Qt::WindowFlags flags = windowFlags(); - - if (windowState() & Qt::WindowFullScreen) { - if (d->currentControl) - d->currentControl->setFullScreen(true); - - if (!d->wasFullScreen) - emit fullScreenChanged(d->wasFullScreen = true); - } else { - if (d->currentControl) - d->currentControl->setFullScreen(false); - - if (d->wasFullScreen) { - flags &= ~(Qt::Window | Qt::SubWindow); //clear the flags... - flags |= d->nonFullScreenFlags; //then we reset the flags (window and subwindow) - setWindowFlags(flags); - - emit fullScreenChanged(d->wasFullScreen = false); - } - } - } - return QWidget::event(event); -} - -/*! - Handles the show \a event. - */ -void QVideoWidget::showEvent(QShowEvent *event) -{ - Q_D(QVideoWidget); - - QWidget::showEvent(event); - - d->show(); - -} - -/*! - - Handles the hide \a event. -*/ -void QVideoWidget::hideEvent(QHideEvent *event) -{ - Q_D(QVideoWidget); - - if (d->currentBackend) - d->currentBackend->hideEvent(event); - - QWidget::hideEvent(event); -} - -/*! - Handles the resize \a event. - */ -void QVideoWidget::resizeEvent(QResizeEvent *event) -{ - Q_D(QVideoWidget); - - QWidget::resizeEvent(event); - - if (d->currentBackend) - d->currentBackend->resizeEvent(event); -} - -/*! - Handles the move \a event. - */ -void QVideoWidget::moveEvent(QMoveEvent *event) -{ - Q_D(QVideoWidget); - - if (d->currentBackend) - d->currentBackend->moveEvent(event); -} - -/*! - Handles the paint \a event. - */ -void QVideoWidget::paintEvent(QPaintEvent *event) -{ - Q_D(QVideoWidget); - - if (d->currentBackend) { - d->currentBackend->paintEvent(event); - } else if (testAttribute(Qt::WA_OpaquePaintEvent)) { - QPainter painter(this); - - painter.fillRect(event->rect(), palette().window()); - } -} - -#include "moc_qvideowidget.cpp" -#include "moc_qvideowidget_p.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qvideowidget.h b/src/multimedia/mediaservices/base/qvideowidget.h deleted file mode 100644 index a21739a..0000000 --- a/src/multimedia/mediaservices/base/qvideowidget.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QVIDEOWIDGET_H -#define QVIDEOWIDGET_H - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaObject; - -class QVideoWidgetPrivate; -class Q_MEDIASERVICES_EXPORT QVideoWidget : public QWidget -{ - Q_OBJECT - Q_PROPERTY(QMediaObject* mediaObject READ mediaObject WRITE setMediaObject) - Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged) - Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode NOTIFY aspectRatioModeChanged) - Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) - Q_PROPERTY(int contrast READ contrast WRITE setContrast NOTIFY contrastChanged) - Q_PROPERTY(int hue READ hue WRITE setHue NOTIFY hueChanged) - Q_PROPERTY(int saturation READ saturation WRITE setSaturation NOTIFY saturationChanged) - -public: - QVideoWidget(QWidget *parent = 0); - ~QVideoWidget(); - - QMediaObject *mediaObject() const; - void setMediaObject(QMediaObject *object); - -#ifdef Q_QDOC - bool isFullScreen() const; -#endif - - Qt::AspectRatioMode aspectRatioMode() const; - - int brightness() const; - int contrast() const; - int hue() const; - int saturation() const; - - QSize sizeHint() const; - -public Q_SLOTS: - void setFullScreen(bool fullScreen); - void setAspectRatioMode(Qt::AspectRatioMode mode); - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - -protected: - bool event(QEvent *event); - void showEvent(QShowEvent *event); - void hideEvent(QHideEvent *event); - void resizeEvent(QResizeEvent *event); - void moveEvent(QMoveEvent *event); - void paintEvent(QPaintEvent *event); - -protected: - QVideoWidgetPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QVideoWidget) - Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) - Q_PRIVATE_SLOT(d_func(), void _q_mediaObjectDestroyed()) - Q_PRIVATE_SLOT(d_func(), void _q_brightnessChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_contrastChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_hueChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_saturationChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_fullScreenChanged(bool)) - Q_PRIVATE_SLOT(d_func(), void _q_dimensionsChanged()) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qvideowidget_p.h b/src/multimedia/mediaservices/base/qvideowidget_p.h deleted file mode 100644 index bb44dfa..0000000 --- a/src/multimedia/mediaservices/base/qvideowidget_p.h +++ /dev/null @@ -1,271 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QVIDEOWIDGET_P_H -#define QVIDEOWIDGET_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#ifndef QT_NO_OPENGL -#include -#endif - -#include "qpaintervideosurface_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QVideoWidgetControlInterface -{ -public: - virtual ~QVideoWidgetControlInterface() {} - - virtual void setBrightness(int brightness) = 0; - virtual void setContrast(int contrast) = 0; - virtual void setHue(int hue) = 0; - virtual void setSaturation(int saturation) = 0; - - virtual void setFullScreen(bool fullScreen) = 0; - - virtual Qt::AspectRatioMode aspectRatioMode() const = 0; - virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; -}; - -class QVideoWidgetBackend : public QObject, public QVideoWidgetControlInterface -{ - Q_OBJECT - -public: - virtual QSize sizeHint() const = 0; - - virtual void showEvent() = 0; - virtual void hideEvent(QHideEvent *event) = 0; - virtual void resizeEvent(QResizeEvent *event) = 0; - virtual void moveEvent(QMoveEvent *event) = 0; - virtual void paintEvent(QPaintEvent *event) = 0; -}; - -class QVideoWidgetControl; - -class QVideoWidgetControlBackend : public QObject, public QVideoWidgetControlInterface -{ - Q_OBJECT -public: - QVideoWidgetControlBackend(QVideoWidgetControl *control, QWidget *widget); - - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - - void setFullScreen(bool fullScreen); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - -private: - QVideoWidgetControl *m_widgetControl; -}; - - -class QVideoRendererControl; - -class QRendererVideoWidgetBackend : public QVideoWidgetBackend -{ - Q_OBJECT -public: - QRendererVideoWidgetBackend(QVideoRendererControl *control, QWidget *widget); - ~QRendererVideoWidgetBackend(); - - void clearSurface(); - - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - - void setFullScreen(bool fullScreen); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - QSize sizeHint() const; - - void showEvent(); - void hideEvent(QHideEvent *event); - void resizeEvent(QResizeEvent *event); - void moveEvent(QMoveEvent *event); - void paintEvent(QPaintEvent *event); - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - -private Q_SLOTS: - void formatChanged(const QVideoSurfaceFormat &format); - void frameChanged(); - -private: - void updateRects(); - - QVideoRendererControl *m_rendererControl; - QWidget *m_widget; - QPainterVideoSurface *m_surface; - Qt::AspectRatioMode m_aspectRatioMode; - QRect m_boundingRect; - QRectF m_sourceRect; - QSize m_nativeSize; - bool m_updatePaintDevice; -}; - -class QVideoWindowControl; - -class QWindowVideoWidgetBackend : public QVideoWidgetBackend -{ - Q_OBJECT -public: - QWindowVideoWidgetBackend(QVideoWindowControl *control, QWidget *widget); - ~QWindowVideoWidgetBackend(); - - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - - void setFullScreen(bool fullScreen); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - QSize sizeHint() const; - - void showEvent(); - void hideEvent(QHideEvent *event); - void resizeEvent(QResizeEvent *event); - void moveEvent(QMoveEvent *event); - void paintEvent(QPaintEvent *event); - -private: - QVideoWindowControl *m_windowControl; - QWidget *m_widget; - Qt::AspectRatioMode m_aspectRatioMode; - QSize m_pixelAspectRatio; -}; - -class QMediaService; -class QVideoOutputControl; - -class QVideoWidgetPrivate -{ - Q_DECLARE_PUBLIC(QVideoWidget) -public: - QVideoWidgetPrivate() - : q_ptr(0) - , mediaObject(0) - , service(0) - , outputControl(0) - , widgetBackend(0) - , windowBackend(0) - , rendererBackend(0) - , currentControl(0) - , currentBackend(0) - , brightness(0) - , contrast(0) - , hue(0) - , saturation(0) - , aspectRatioMode(Qt::KeepAspectRatio) - , nonFullScreenFlags(0) - , wasFullScreen(false) - { - } - - QVideoWidget *q_ptr; - QMediaObject *mediaObject; - QMediaService *service; - QVideoOutputControl *outputControl; - QVideoWidgetControlBackend *widgetBackend; - QWindowVideoWidgetBackend *windowBackend; - QRendererVideoWidgetBackend *rendererBackend; - QVideoWidgetControlInterface *currentControl; - QVideoWidgetBackend *currentBackend; - int brightness; - int contrast; - int hue; - int saturation; - Qt::AspectRatioMode aspectRatioMode; - Qt::WindowFlags nonFullScreenFlags; - bool wasFullScreen; - - void setCurrentControl(QVideoWidgetControlInterface *control); - void show(); - void clearService(); - - void _q_serviceDestroyed(); - void _q_mediaObjectDestroyed(); - void _q_brightnessChanged(int brightness); - void _q_contrastChanged(int contrast); - void _q_hueChanged(int hue); - void _q_saturationChanged(int saturation); - void _q_fullScreenChanged(bool fullScreen); - void _q_dimensionsChanged(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qvideowidgetcontrol.cpp b/src/multimedia/mediaservices/base/qvideowidgetcontrol.cpp deleted file mode 100644 index 538f158..0000000 --- a/src/multimedia/mediaservices/base/qvideowidgetcontrol.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include "qmediacontrol_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoWidgetControl - \preliminary - \since 4.7 - \brief The QVideoWidgetControl class provides a media control which - implements a video widget. - - \ingroup multimedia-serv - - The videoWidget() property of QVideoWidgetControl provides a pointer to - a video widget implemented by the control's media service. This widget - is owned by the media service and so care should be taken not to delete it. - - \code - QVideoWidgetControl *widgetControl = mediaService->control(); - - layout->addWidget(widgetControl->widget()); - \endcode - - QVideoWidgetControl is one of number of possible video output controls, - in order to receive video it must be made the active video output - control by setting the output property of QVideoOutputControl to \l {QVideoOutputControl::WidgetOutput}{WidgetOutput}. Consequently any - QMediaService that implements QVideoWidgetControl must also implement - QVideoOutputControl. - - The interface name of QVideoWidgetControl is \c com.nokia.Qt.QVideoWidgetControl/1.0 as - defined in QVideoWidgetControl_iid. - - \sa QMediaService::control(), QVideoOutputControl, QVideoWidget -*/ - -/*! - \macro QVideoWidgetControl_iid - - \c com.nokia.Qt.QVideoWidgetControl/1.0 - - Defines the interface name of the QVideoWidgetControl class. - - \relates QVideoWidgetControl -*/ - -/*! - Constructs a new video widget control with the given \a parent. -*/ -QVideoWidgetControl::QVideoWidgetControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys a video widget control. -*/ -QVideoWidgetControl::~QVideoWidgetControl() -{ -} - -/*! - \fn QVideoWidgetControl::isFullScreen() const - - Returns true if the video is shown using the complete screen. -*/ - -/*! - \fn QVideoWidgetControl::setFullScreen(bool fullScreen) - - Sets whether a video widget is in \a fullScreen mode. -*/ - -/*! - \fn QVideoWidgetControl::fullScreenChanged(bool fullScreen) - - Signals that the \a fullScreen state of a video widget has changed. -*/ - -/*! - \fn QVideoWidgetControl::aspectRatioMode() const - - Returns how video is scaled to fit the widget with respect to its aspect ratio. -*/ - -/*! - \fn QVideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode mode) - - Sets the aspect ratio \a mode which determines how video is scaled to the fit the widget with - respect to its aspect ratio. -*/ - -/*! - \fn QVideoWidgetControl::brightness() const - - Returns the brightness adjustment applied to a video. - - Valid brightness values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWidgetControl::setBrightness(int brightness) - - Sets a \a brightness adjustment for a video. - - Valid brightness values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWidgetControl::brightnessChanged(int brightness) - - Signals that a video widget's \a brightness adjustment has changed. -*/ - -/*! - \fn QVideoWidgetControl::contrast() const - - Returns the contrast adjustment applied to a video. - - Valid contrast values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWidgetControl::setContrast(int contrast) - - Sets the contrast adjustment for a video widget to \a contrast. - - Valid contrast values range between -100 and 100, the default is 0. -*/ - - -/*! - \fn QVideoWidgetControl::contrastChanged(int contrast) - - Signals that a video widget's \a contrast adjustment has changed. -*/ - -/*! - \fn QVideoWidgetControl::hue() const - - Returns the hue adjustment applied to a video widget. - - Value hue values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWidgetControl::setHue(int hue) - - Sets a \a hue adjustment for a video widget. - - Valid hue values range between -100 and 100, the default is 0. -*/ - - -/*! - \fn QVideoWidgetControl::hueChanged(int hue) - - Signals that a video widget's \a hue adjustment has changed. -*/ - -/*! - \fn QVideoWidgetControl::saturation() const - - Returns the saturation adjustment applied to a video widget. - - Value saturation values range between -100 and 100, the default is 0. -*/ - - -/*! - \fn QVideoWidgetControl::setSaturation(int saturation) - - Sets a \a saturation adjustment for a video widget. - - Valid saturation values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWidgetControl::saturationChanged(int saturation) - - Signals that a video widget's \a saturation adjustment has changed. -*/ - -/*! - \fn QVideoWidgetControl::videoWidget() - - Returns the QWidget. -*/ - -#include "moc_qvideowidgetcontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qvideowidgetcontrol.h b/src/multimedia/mediaservices/base/qvideowidgetcontrol.h deleted file mode 100644 index 1013beb..0000000 --- a/src/multimedia/mediaservices/base/qvideowidgetcontrol.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QVIDEOWIDGETCONTROL_H -#define QVIDEOWIDGETCONTROL_H - -#include - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QVideoWidgetControlPrivate; - -class Q_MEDIASERVICES_EXPORT QVideoWidgetControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QVideoWidgetControl(); - - virtual QWidget *videoWidget() = 0; - - virtual Qt::AspectRatioMode aspectRatioMode() const = 0; - virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; - - virtual bool isFullScreen() const = 0; - virtual void setFullScreen(bool fullScreen) = 0; - - virtual int brightness() const = 0; - virtual void setBrightness(int brightness) = 0; - - virtual int contrast() const = 0; - virtual void setContrast(int contrast) = 0; - - virtual int hue() const = 0; - virtual void setHue(int hue) = 0; - - virtual int saturation() const = 0; - virtual void setSaturation(int saturation) = 0; - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - -protected: - QVideoWidgetControl(QObject *parent = 0); -}; - -#define QVideoWidgetControl_iid "com.nokia.Qt.QVideoWidgetControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoWidgetControl, QVideoWidgetControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qvideowindowcontrol.cpp b/src/multimedia/mediaservices/base/qvideowindowcontrol.cpp deleted file mode 100644 index 967a2d6..0000000 --- a/src/multimedia/mediaservices/base/qvideowindowcontrol.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 - - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoWindowControl - \preliminary - \since 4.7 - \ingroup multimedia-serv - \brief The QVideoWindowControl class provides a media control for rendering video to a window. - - - The winId() property QVideoWindowControl allows a platform specific - window ID to be set as the video render target of a QMediaService. The - displayRect() property is used to set the region of the window the - video should be rendered to, and the aspectRatioMode() property - indicates how the video should be scaled to fit the displayRect(). - - \code - QVideoWindowControl *windowControl = mediaService->control(); - windowControl->setWinId(widget->winId()); - windowControl->setDisplayRect(widget->rect()); - windowControl->setAspectRatioMode(Qt::KeepAspectRatio); - \endcode - - QVideoWindowControl is one of number of possible video output controls, - in order to receive video it must be made the active video output - control by setting the output property of QVideoOutputControl to \l {QVideoOutputControl::WindowOutput}{WindowOutput}. - Consequently any QMediaService that implements QVideoWindowControl must - also implement QVideoOutputControl. - - \code - QVideoOutputControl *outputControl = mediaService->control(); - outputControl->setOutput(QVideoOutputControl::WindowOutput); - \endcode - - The interface name of QVideoWindowControl is \c com.nokia.Qt.QVideoWindowControl/1.0 as - defined in QVideoWindowControl_iid. - - \sa QMediaService::control(), QVideoOutputControl, QVideoWidget -*/ - -/*! - \macro QVideoWindowControl_iid - - \c com.nokia.Qt.QVideoWindowControl/1.0 - - Defines the interface name of the QVideoWindowControl class. - - \relates QVideoWindowControl -*/ - -/*! - Constructs a new video window control with the given \a parent. -*/ -QVideoWindowControl::QVideoWindowControl(QObject *parent) - : QMediaControl(parent) -{ -} - -/*! - Destroys a video window control. -*/ -QVideoWindowControl::~QVideoWindowControl() -{ -} - -/*! - \fn QVideoWindowControl::winId() const - - Returns the ID of the window a video overlay end point renders to. -*/ - -/*! - \fn QVideoWindowControl::setWinId(WId id) - - Sets the \a id of the window a video overlay end point renders to. -*/ - -/*! - \fn QVideoWindowControl::displayRect() const - Returns the sub-rect of a window where video is displayed. -*/ - -/*! - \fn QVideoWindowControl::setDisplayRect(const QRect &rect) - Sets the sub-\a rect of a window where video is displayed. -*/ - -/*! - \fn QVideoWindowControl::isFullScreen() const - - Identifies if a video overlay is a fullScreen overlay. - - Returns true if the video overlay is fullScreen, and false otherwise. -*/ - -/*! - \fn QVideoWindowControl::setFullScreen(bool fullScreen) - - Sets whether a video overlay is a \a fullScreen overlay. -*/ - -/*! - \fn QVideoWindowControl::fullScreenChanged(bool fullScreen) - - Signals that the \a fullScreen state of a video overlay has changed. -*/ - -/*! - \fn QVideoWindowControl::repaint() - - Repaints the last frame. -*/ - -/*! - \fn QVideoWindowControl::nativeSize() const - - Returns a suggested size for the video display based on the resolution and aspect ratio of the - video. -*/ - -/*! - \fn QVideoWindowControl::nativeSizeChanged() - - Signals that the native dimensions of the video have changed. -*/ - - -/*! - \fn QVideoWindowControl::aspectRatioMode() const - - Returns how video is scaled to fit the display region with respect to its aspect ratio. -*/ - -/*! - \fn QVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode) - - Sets the aspect ratio \a mode which determines how video is scaled to the fit the display region - with respect to its aspect ratio. -*/ - -/*! - \fn QVideoWindowControl::brightness() const - - Returns the brightness adjustment applied to a video overlay. - - Valid brightness values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::setBrightness(int brightness) - - Sets a \a brightness adjustment for a video overlay. - - Valid brightness values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::brightnessChanged(int brightness) - - Signals that a video overlay's \a brightness adjustment has changed. -*/ - -/*! - \fn QVideoWindowControl::contrast() const - - Returns the contrast adjustment applied to a video overlay. - - Valid contrast values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::setContrast(int contrast) - - Sets the \a contrast adjustment for a video overlay. - - Valid contrast values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::contrastChanged(int contrast) - - Signals that a video overlay's \a contrast adjustment has changed. -*/ - -/*! - \fn QVideoWindowControl::hue() const - - Returns the hue adjustment applied to a video overlay. - - Value hue values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::setHue(int hue) - - Sets a \a hue adjustment for a video overlay. - - Valid hue values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::hueChanged(int hue) - - Signals that a video overlay's \a hue adjustment has changed. -*/ - -/*! - \fn QVideoWindowControl::saturation() const - - Returns the saturation adjustment applied to a video overlay. - - Value saturation values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::setSaturation(int saturation) - Sets a \a saturation adjustment for a video overlay. - - Valid saturation values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::saturationChanged(int saturation) - - Signals that a video overlay's \a saturation adjustment has changed. -*/ - -#include "moc_qvideowindowcontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qvideowindowcontrol.h b/src/multimedia/mediaservices/base/qvideowindowcontrol.h deleted file mode 100644 index 47ba520..0000000 --- a/src/multimedia/mediaservices/base/qvideowindowcontrol.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QVIDEOWINDOWCONTROL_H -#define QVIDEOWINDOWCONTROL_H - -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MEDIASERVICES_EXPORT QVideoWindowControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QVideoWindowControl(); - - virtual WId winId() const = 0; - virtual void setWinId(WId id) = 0; - - virtual QRect displayRect() const = 0; - virtual void setDisplayRect(const QRect &rect) = 0; - - virtual bool isFullScreen() const = 0; - virtual void setFullScreen(bool fullScreen) = 0; - - virtual void repaint() = 0; - - virtual QSize nativeSize() const = 0; - - virtual Qt::AspectRatioMode aspectRatioMode() const = 0; - virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; - - virtual int brightness() const = 0; - virtual void setBrightness(int brightness) = 0; - - virtual int contrast() const = 0; - virtual void setContrast(int contrast) = 0; - - virtual int hue() const = 0; - virtual void setHue(int hue) = 0; - - virtual int saturation() const = 0; - virtual void setSaturation(int saturation) = 0; - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - void nativeSizeChanged(); - -protected: - QVideoWindowControl(QObject *parent = 0); -}; - -#define QVideoWindowControl_iid "com.nokia.Qt.QVideoWindowControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoWindowControl, QVideoWindowControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/effects/effects.pri b/src/multimedia/mediaservices/effects/effects.pri deleted file mode 100644 index 6307255..0000000 --- a/src/multimedia/mediaservices/effects/effects.pri +++ /dev/null @@ -1,26 +0,0 @@ - - -unix:!mac { - contains(QT_CONFIG, pulseaudio) { - DEFINES += QT_MULTIMEDIA_PULSEAUDIO - HEADERS += $$PWD/qsoundeffect_pulse_p.h - SOURCES += $$PWD/qsoundeffect_pulse_p.cpp - QMAKE_CXXFLAGS += $$QT_CFLAGS_PULSEAUDIO - LIBS += $$QT_LIBS_PULSEAUDIO - } else { - DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER - HEADERS += $$PWD/qsoundeffect_qmedia_p.h - SOURCES += $$PWD/qsoundeffect_qmedia_p.cpp - } -} else { - HEADERS += $$PWD/qsoundeffect_qsound_p.h - SOURCES += $$PWD/qsoundeffect_qsound_p.cpp -} - -HEADERS += \ - $$PWD/qsoundeffect_p.h \ - $$PWD/wavedecoder_p.h - -SOURCES += \ - $$PWD/qsoundeffect.cpp \ - $$PWD/wavedecoder_p.cpp diff --git a/src/multimedia/mediaservices/effects/qsoundeffect.cpp b/src/multimedia/mediaservices/effects/qsoundeffect.cpp deleted file mode 100644 index 3537566..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect.cpp +++ /dev/null @@ -1,209 +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 QtMultimedia 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 "qsoundeffect_p.h" - -#if defined(QT_MULTIMEDIA_PULSEAUDIO) -#include "qsoundeffect_pulse_p.h" -#elif(QT_MULTIMEDIA_QMEDIAPLAYER) -#include "qsoundeffect_qmedia_p.h" -#else -#include "qsoundeffect_qsound_p.h" -#endif - -QT_BEGIN_NAMESPACE - -/*! - \qmlclass SoundEffect QSoundEffect - \since 4.7 - \brief The SoundEffect element provides a way to play sound effects in QML. - - This element is part of the \bold{Qt.multimedia 4.7} module. - - The following example plays a wav file on mouse click. - - \qml - import Qt 4.7 - import Qt.multimedia 4.7 - - Text { - text: "Click Me!"; - font.pointSize: 24; - width: 150; height: 50; - - SoundEffect { - id: playSound - source: "soundeffect.wav" - } - MouseArea { - id: playArea - anchors.fill: parent - onPressed: { playSound.play() } - } - } - \endqml -*/ - -/*! - \qmlproperty url SoundEffect::source - - This property provides a way to control the sound to play. -*/ - -/*! - \qmlproperty int SoundEffect::loops - - This property provides a way to control the number of times to repeat the sound on each play(). -*/ - -/*! - \qmlproperty int SoundEffect::volume - - This property provides a way to control the volume for playback. -*/ - -/*! - \qmlproperty bool SoundEffect::muted - - This property provides a way to control muting. -*/ - -/*! - \qmlsignal SoundEffect::sourceChanged() - - This handler is called when the source has changed. -*/ - -/*! - \qmlsignal SoundEffect::loopsChanged() - - This handler is called when the number of loops has changes. -*/ - -/*! - \qmlsignal SoundEffect::volumeChanged() - - This handler is called when the volume has changed. -*/ - -/*! - \qmlsignal SoundEffect::mutedChanged() - - This handler is called when the mute state has changed. -*/ - - -QSoundEffect::QSoundEffect(QObject *parent) : - QObject(parent) -{ - d = new QSoundEffectPrivate(this); - connect(d, SIGNAL(volumeChanged()), SIGNAL(volumeChanged())); - connect(d, SIGNAL(mutedChanged()), SIGNAL(mutedChanged())); -} - -QSoundEffect::~QSoundEffect() -{ - d->deleteLater(); -} - -QUrl QSoundEffect::source() const -{ - return d->source(); -} - -void QSoundEffect::setSource(const QUrl &url) -{ - if (d->source() == url) - return; - - d->setSource(url); - - emit sourceChanged(); -} - -int QSoundEffect::loops() const -{ - return d->loopCount(); -} - -void QSoundEffect::setLoops(int loopCount) -{ - if (d->loopCount() == loopCount) - return; - - d->setLoopCount(loopCount); - emit loopsChanged(); -} - -int QSoundEffect::volume() const -{ - return d->volume(); -} - -void QSoundEffect::setVolume(int volume) -{ - if (d->volume() == volume) - return; - - d->setVolume(volume); - emit volumeChanged(); -} - -bool QSoundEffect::isMuted() const -{ - return d->isMuted(); -} - -void QSoundEffect::setMuted(bool muted) -{ - if (d->isMuted() == muted) - return; - - d->setMuted(muted); - emit mutedChanged(); -} - -void QSoundEffect::play() -{ - d->play(); -} - -QT_END_NAMESPACE diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_p.h b/src/multimedia/mediaservices/effects/qsoundeffect_p.h deleted file mode 100644 index 64ddb77..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_p.h +++ /dev/null @@ -1,109 +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 QtMediaServices 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 QSOUNDEFFECT_H -#define QSOUNDEFFECT_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QSoundEffectPrivate; -class Q_MEDIASERVICES_EXPORT QSoundEffect : public QObject -{ - Q_OBJECT - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopsChanged) - Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - -public: - explicit QSoundEffect(QObject *parent = 0); - ~QSoundEffect(); - - QUrl source() const; - void setSource(const QUrl &url); - - int loops() const; - void setLoops(int loopCount); - - int volume() const; - void setVolume(int volume); - - bool isMuted() const; - void setMuted(bool muted); - -Q_SIGNALS: - void sourceChanged(); - void loopsChanged(); - void volumeChanged(); - void mutedChanged(); - -public Q_SLOTS: - void play(); - -private: - Q_DISABLE_COPY(QSoundEffect) - QSoundEffectPrivate* d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QSOUNDEFFECT_H diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.cpp b/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.cpp deleted file mode 100644 index c856157..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.cpp +++ /dev/null @@ -1,499 +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 QtMediaServices 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include - -#include "wavedecoder_p.h" - -#include "qsoundeffect_pulse_p.h" - -#if defined(Q_WS_MAEMO_5) -#include -#endif - -#include - -// Less than ideal -#define PA_SCACHE_ENTRY_SIZE_MAX (1024*1024*16) - -QT_BEGIN_NAMESPACE - -namespace -{ -inline pa_sample_spec audioFormatToSampleSpec(const QAudioFormat &format) -{ - pa_sample_spec spec; - - spec.rate = format.frequency(); - spec.channels = format.channels(); - - if (format.sampleSize() == 8) - spec.format = PA_SAMPLE_U8; - else if (format.sampleSize() == 16) { - switch (format.byteOrder()) { - case QAudioFormat::BigEndian: spec.format = PA_SAMPLE_S16BE; break; - case QAudioFormat::LittleEndian: spec.format = PA_SAMPLE_S16LE; break; - } - } - else if (format.sampleSize() == 32) { - switch (format.byteOrder()) { - case QAudioFormat::BigEndian: spec.format = PA_SAMPLE_S32BE; break; - case QAudioFormat::LittleEndian: spec.format = PA_SAMPLE_S32LE; break; - } - } - - return spec; -} - -class PulseDaemon -{ -public: - PulseDaemon():m_prepared(false) - { - prepare(); - } - - ~PulseDaemon() - { - if (m_prepared) - release(); - } - - inline void lock() - { - pa_threaded_mainloop_lock(m_mainLoop); - } - - inline void unlock() - { - pa_threaded_mainloop_unlock(m_mainLoop); - } - - inline pa_context *context() const - { - return m_context; - } - - int volume() - { - return m_vol; - } - -private: - void prepare() - { - m_vol = 100; - - m_mainLoop = pa_threaded_mainloop_new(); - if (m_mainLoop == 0) { - qWarning("PulseAudioService: unable to create pulseaudio mainloop"); - return; - } - - if (pa_threaded_mainloop_start(m_mainLoop) != 0) { - qWarning("PulseAudioService: unable to start pulseaudio mainloop"); - pa_threaded_mainloop_free(m_mainLoop); - return; - } - - m_mainLoopApi = pa_threaded_mainloop_get_api(m_mainLoop); - - lock(); - m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtPulseAudio:%1")).arg(::getpid()).toAscii().constData()); - -#if defined(Q_WS_MAEMO_5) - pa_context_set_state_callback(m_context, context_state_callback, this); -#endif - if (m_context == 0) { - qWarning("PulseAudioService: Unable to create new pulseaudio context"); - pa_threaded_mainloop_free(m_mainLoop); - return; - } - - if (pa_context_connect(m_context, NULL, (pa_context_flags_t)0, NULL) < 0) { - qWarning("PulseAudioService: pa_context_connect() failed"); - pa_context_unref(m_context); - pa_threaded_mainloop_free(m_mainLoop); - return; - } - unlock(); - - m_prepared = true; - } - - void release() - { - if (!m_prepared) return; - pa_threaded_mainloop_stop(m_mainLoop); - pa_threaded_mainloop_free(m_mainLoop); - m_prepared = false; - } - -#if defined(Q_WS_MAEMO_5) - static void context_state_callback(pa_context *c, void *userdata) - { - PulseDaemon *self = reinterpret_cast(userdata); - switch (pa_context_get_state(c)) { - case PA_CONTEXT_CONNECTING: - case PA_CONTEXT_AUTHORIZING: - case PA_CONTEXT_SETTING_NAME: - break; - case PA_CONTEXT_READY: - pa_ext_stream_restore_set_subscribe_cb(c, &stream_restore_monitor_callback, self); - pa_ext_stream_restore_subscribe(c, 1, NULL, self); - break; - default: - break; - } - } - static void stream_restore_monitor_callback(pa_context *c, void *userdata) - { - PulseDaemon *self = reinterpret_cast(userdata); - pa_ext_stream_restore2_read(c, &stream_restore_info_callback, self); - } - static void stream_restore_info_callback(pa_context *c, const pa_ext_stream_restore2_info *info, - int eol, void *userdata) - { - Q_UNUSED(c) - - PulseDaemon *self = reinterpret_cast(userdata); - - if (!eol) { - if (QString(info->name).startsWith(QLatin1String("sink-input-by-media-role:x-maemo"))) { - const unsigned str_length = 256; - char str[str_length]; - pa_cvolume_snprint(str, str_length, &info->volume); - self->m_vol = QString(str).replace(" ","").replace("%","").mid(2).toInt(); - } - } - } -#endif - - int m_vol; - bool m_prepared; - pa_context *m_context; - pa_threaded_mainloop *m_mainLoop; - pa_mainloop_api *m_mainLoopApi; -}; -} - -Q_GLOBAL_STATIC(PulseDaemon, daemon) - - -QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): - QObject(parent), - m_retry(false), - m_muted(false), - m_playQueued(false), - m_sampleLoaded(false), - m_volume(100), - m_duration(0), - m_dataUploaded(0), - m_loopCount(1), - m_runningCount(0), - m_reply(0), - m_stream(0), - m_networkAccessManager(0) -{ -} - -QSoundEffectPrivate::~QSoundEffectPrivate() -{ - m_reply->deleteLater(); - unloadSample(); -} - -QUrl QSoundEffectPrivate::source() const -{ - return m_source; -} - -void QSoundEffectPrivate::setSource(const QUrl &url) -{ - if (url.isEmpty()) { - m_source = QUrl(); - unloadSample(); - return; - } - - m_source = url; - - if (m_networkAccessManager == 0) - m_networkAccessManager = new QNetworkAccessManager(this); - - m_stream = m_networkAccessManager->get(QNetworkRequest(m_source)); - - unloadSample(); - loadSample(); -} - -int QSoundEffectPrivate::loopCount() const -{ - return m_loopCount; -} - -void QSoundEffectPrivate::setLoopCount(int loopCount) -{ - m_loopCount = loopCount; -} - -int QSoundEffectPrivate::volume() const -{ - return m_volume; -} - -void QSoundEffectPrivate::setVolume(int volume) -{ - m_volume = volume; -} - -bool QSoundEffectPrivate::isMuted() const -{ - return m_muted; -} - -void QSoundEffectPrivate::setMuted(bool muted) -{ - m_muted = muted; -} - -void QSoundEffectPrivate::play() -{ - if (m_retry) { - m_retry = false; - setSource(m_source); - return; - } - - if (!m_sampleLoaded) { - m_playQueued = true; - return; - } - - m_runningCount += m_loopCount; - - playSample(); -} - -void QSoundEffectPrivate::decoderReady() -{ - if (m_waveDecoder->size() >= PA_SCACHE_ENTRY_SIZE_MAX) { - m_waveDecoder->deleteLater(); - qWarning("QSoundEffect(pulseaudio): Attempting to load to large a sample"); - return; - } - - if (m_name.isNull()) - m_name = QString(QLatin1String("QtPulseSample-%1-%2")).arg(::getpid()).arg(quintptr(this)).toUtf8(); - - pa_sample_spec spec = audioFormatToSampleSpec(m_waveDecoder->audioFormat()); - - daemon()->lock(); - pa_stream *stream = pa_stream_new(daemon()->context(), m_name.constData(), &spec, 0); - pa_stream_set_state_callback(stream, stream_state_callback, this); - pa_stream_set_write_callback(stream, stream_write_callback, this); - pa_stream_connect_upload(stream, (size_t)m_waveDecoder->size()); - m_pulseStream = stream; - daemon()->unlock(); -} - -void QSoundEffectPrivate::decoderError() -{ - qWarning("QSoundEffect(pulseaudio): Error decoding source"); -} - -void QSoundEffectPrivate::checkPlayTime() -{ - int elapsed = m_playbackTime.elapsed(); - - if (elapsed < m_duration) - startTimer(m_duration - elapsed); -} - -void QSoundEffectPrivate::loadSample() -{ - m_sampleLoaded = false; - m_dataUploaded = 0; - m_waveDecoder = new WaveDecoder(m_stream); - connect(m_waveDecoder, SIGNAL(formatKnown()), SLOT(decoderReady())); - connect(m_waveDecoder, SIGNAL(invalidFormat()), SLOT(decoderError())); -} - -void QSoundEffectPrivate::unloadSample() -{ - if (!m_sampleLoaded) - return; - - daemon()->lock(); - pa_context_remove_sample(daemon()->context(), m_name.constData(), NULL, NULL); - daemon()->unlock(); - - m_duration = 0; - m_dataUploaded = 0; - m_sampleLoaded = false; -} - -void QSoundEffectPrivate::uploadSample() -{ - daemon()->lock(); - - size_t bufferSize = qMin(pa_stream_writable_size(m_pulseStream), - size_t(m_waveDecoder->bytesAvailable())); - char buffer[bufferSize]; - - size_t len = 0; - while (len < (m_waveDecoder->size())) { - qint64 read = m_waveDecoder->read(buffer, qMin((int)bufferSize, - (int)(m_waveDecoder->size()-len))); - if (read > 0) { - if (pa_stream_write(m_pulseStream, buffer, size_t(read), 0, 0, PA_SEEK_RELATIVE) == 0) - len += size_t(read); - else - break; - } - } - - m_dataUploaded += len; - pa_stream_set_write_callback(m_pulseStream, NULL, NULL); - - if (m_waveDecoder->size() == m_dataUploaded) { - int err = pa_stream_finish_upload(m_pulseStream); - if(err != 0) { - qWarning("pa_stream_finish_upload() err=%d",err); - pa_stream_disconnect(m_pulseStream); - m_retry = true; - m_playQueued = false; - QMetaObject::invokeMethod(this, "play"); - daemon()->unlock(); - return; - } - m_duration = m_waveDecoder->duration(); - m_waveDecoder->deleteLater(); - m_stream->deleteLater(); - m_sampleLoaded = true; - if (m_playQueued) { - m_playQueued = false; - QMetaObject::invokeMethod(this, "play"); - } - } - daemon()->unlock(); -} - -void QSoundEffectPrivate::playSample() -{ - pa_volume_t volume = PA_VOLUME_NORM; - - daemon()->lock(); -#ifdef Q_WS_MAEMO_5 - volume = PA_VOLUME_NORM / 100 * ((daemon()->volume() + m_volume) / 2); -#endif - pa_operation_unref( - pa_context_play_sample(daemon()->context(), - m_name.constData(), - 0, - volume, - play_callback, - this) - ); - daemon()->unlock(); - - m_playbackTime.start(); -} - -void QSoundEffectPrivate::timerEvent(QTimerEvent *event) -{ - if (m_runningCount > 0) - playSample(); - - killTimer(event->timerId()); -} - -void QSoundEffectPrivate::stream_write_callback(pa_stream *s, size_t length, void *userdata) -{ - Q_UNUSED(length); - - QSoundEffectPrivate *self = reinterpret_cast(userdata); - - QMetaObject::invokeMethod(self, "uploadSample", Qt::QueuedConnection); -} - -void QSoundEffectPrivate::stream_state_callback(pa_stream *s, void *userdata) -{ - switch (pa_stream_get_state(s)) { - case PA_STREAM_CREATING: - case PA_STREAM_READY: - case PA_STREAM_TERMINATED: - break; - - case PA_STREAM_FAILED: - default: - qWarning("QSoundEffect(pulseaudio): Error in pulse audio stream"); - break; - } -} - -void QSoundEffectPrivate::play_callback(pa_context *c, int success, void *userdata) -{ - Q_UNUSED(c); - - QSoundEffectPrivate *self = reinterpret_cast(userdata); - - if (success == 1) { - self->m_runningCount--; - QMetaObject::invokeMethod(self, "checkPlayTime", Qt::QueuedConnection); - } -} - -QT_END_NAMESPACE diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.h b/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.h deleted file mode 100644 index 1327bf5..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.h +++ /dev/null @@ -1,137 +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 QtMediaServices 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 QSOUNDEFFECT_PULSE_H -#define QSOUNDEFFECT_PULSE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include "qsoundeffect_p.h" - -#include -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QNetworkReply; -class QNetworkAccessManager; -class WaveDecoder; - -class QSoundEffectPrivate : public QObject -{ - Q_OBJECT -public: - explicit QSoundEffectPrivate(QObject* parent); - ~QSoundEffectPrivate(); - - QUrl source() const; - void setSource(const QUrl &url); - int loopCount() const; - void setLoopCount(int loopCount); - int volume() const; - void setVolume(int volume); - bool isMuted() const; - void setMuted(bool muted); - -public Q_SLOTS: - void play(); - -Q_SIGNALS: - void volumeChanged(); - void mutedChanged(); - -private Q_SLOTS: - void decoderReady(); - void decoderError(); - void checkPlayTime(); - void uploadSample(); - -private: - void loadSample(); - void unloadSample(); - void playSample(); - - void timerEvent(QTimerEvent *event); - - static void stream_write_callback(pa_stream *s, size_t length, void *userdata); - static void stream_state_callback(pa_stream *s, void *userdata); - static void play_callback(pa_context *c, int success, void *userdata); - - pa_stream *m_pulseStream; - - bool m_retry; - bool m_muted; - bool m_playQueued; - bool m_sampleLoaded; - int m_volume; - int m_duration; - int m_dataUploaded; - int m_loopCount; - int m_runningCount; - QUrl m_source; - QTime m_playbackTime; - QByteArray m_name; - QNetworkReply *m_reply; - WaveDecoder *m_waveDecoder; - QIODevice *m_stream; - QNetworkAccessManager *m_networkAccessManager; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSOUNDEFFECT_PULSE_H diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.cpp b/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.cpp deleted file mode 100644 index 5e40bed..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.cpp +++ /dev/null @@ -1,132 +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 QtMediaServices 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qsoundeffect_qmedia_p.h" - -#include - -#include -#include - - -QT_BEGIN_NAMESPACE - -QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): - QObject(parent), - m_loopCount(1), - m_runningCount(0), - m_player(0) -{ - m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency); - connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(stateChanged(QMediaPlayer::State))); -} - -QSoundEffectPrivate::~QSoundEffectPrivate() -{ -} - -QUrl QSoundEffectPrivate::source() const -{ - return m_player->media().canonicalUrl(); -} - -void QSoundEffectPrivate::setSource(const QUrl &url) -{ - m_player->setMedia(url); -} - -int QSoundEffectPrivate::loopCount() const -{ - return m_loopCount; -} - -void QSoundEffectPrivate::setLoopCount(int loopCount) -{ - m_loopCount = loopCount; -} - -int QSoundEffectPrivate::volume() const -{ - return m_player->volume(); -} - -void QSoundEffectPrivate::setVolume(int volume) -{ - m_player->setVolume(volume); -} - -bool QSoundEffectPrivate::isMuted() const -{ - return m_player->isMuted(); -} - -void QSoundEffectPrivate::setMuted(bool muted) -{ - m_player->setMuted(muted); -} - -void QSoundEffectPrivate::play() -{ - m_runningCount += m_loopCount; - m_player->play(); -} - -void QSoundEffectPrivate::stateChanged(QMediaPlayer::State state) -{ - if (state == QMediaPlayer::StoppedState) { - if (--m_runningCount > 0) - m_player->play(); - } -} - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.h b/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.h deleted file mode 100644 index 82ea000..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.h +++ /dev/null @@ -1,103 +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 QtMediaServices 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 QSOUNDEFFECT_QMEDIA_H -#define QSOUNDEFFECT_QMEDIA_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QSoundEffectPrivate : public QObject -{ - Q_OBJECT -public: - explicit QSoundEffectPrivate(QObject* parent); - ~QSoundEffectPrivate(); - - QUrl source() const; - void setSource(const QUrl &url); - int loopCount() const; - void setLoopCount(int loopCount); - int volume() const; - void setVolume(int volume); - bool isMuted() const; - void setMuted(bool muted); - -public Q_SLOTS: - void play(); - -Q_SIGNALS: - void volumeChanged(); - void mutedChanged(); - -private Q_SLOTS: - void stateChanged(QMediaPlayer::State); - -private: - int m_loopCount; - int m_runningCount; - QMediaPlayer *m_player; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSOUNDEFFECT_QMEDIA_H diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.cpp b/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.cpp deleted file mode 100644 index 9247aba..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.cpp +++ /dev/null @@ -1,131 +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 QtMediaServices 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qsoundeffect_qsound_p.h" - -#include -#include - - -QT_BEGIN_NAMESPACE - -QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): - QObject(parent), - m_muted(false), - m_loopCount(1), - m_volume(100), - m_sound(0) -{ -} - -QSoundEffectPrivate::~QSoundEffectPrivate() -{ -} - -QUrl QSoundEffectPrivate::source() const -{ - return m_source; -} - -void QSoundEffectPrivate::setSource(const QUrl &url) -{ - if (url.isEmpty() || url.scheme() != QLatin1String("file")) { - m_source = QUrl(); - return; - } - - if (m_sound != 0) - delete m_sound; - - m_source = url; - m_sound = new QSound(m_source.toLocalFile(), this); - m_sound->setLoops(m_loopCount); -} - -int QSoundEffectPrivate::loopCount() const -{ - return m_loopCount; -} - -void QSoundEffectPrivate::setLoopCount(int lc) -{ - m_loopCount = lc; - if (m_sound) - m_sound->setLoops(lc); -} - -int QSoundEffectPrivate::volume() const -{ - return m_volume; -} - -void QSoundEffectPrivate::setVolume(int v) -{ - m_volume = v; -} - -bool QSoundEffectPrivate::isMuted() const -{ - return m_muted; -} - -void QSoundEffectPrivate::setMuted(bool muted) -{ - m_muted = muted; -} - -void QSoundEffectPrivate::play() -{ - m_sound->play(); -} - -QT_END_NAMESPACE diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.h b/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.h deleted file mode 100644 index dad7b6f..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.h +++ /dev/null @@ -1,102 +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 QtMediaServices 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 QSOUNDEFFECT_QSOUND_H -#define QSOUNDEFFECT_QSOUND_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QSound; - -class QSoundEffectPrivate : public QObject -{ - Q_OBJECT -public: - explicit QSoundEffectPrivate(QObject* parent); - ~QSoundEffectPrivate(); - - QUrl source() const; - void setSource(const QUrl &url); - int loopCount() const; - void setLoopCount(int loopCount); - int volume() const; - void setVolume(int volume); - bool isMuted() const; - void setMuted(bool muted); - -public Q_SLOTS: - void play(); - -Q_SIGNALS: - void volumeChanged(); - void mutedChanged(); - -private: - bool m_muted; - int m_loopCount; - int m_volume; - QSound *m_sound; - QUrl m_source; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSOUNDEFFECT_QSOUND_H diff --git a/src/multimedia/mediaservices/effects/wavedecoder_p.cpp b/src/multimedia/mediaservices/effects/wavedecoder_p.cpp deleted file mode 100644 index 1c26c8f..0000000 --- a/src/multimedia/mediaservices/effects/wavedecoder_p.cpp +++ /dev/null @@ -1,151 +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 QtMediaServices 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 "wavedecoder_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -WaveDecoder::WaveDecoder(QIODevice *s, QObject *parent): - QIODevice(parent), - haveFormat(false), - dataSize(0), - remaining(0), - source(s) -{ - open(QIODevice::ReadOnly | QIODevice::Unbuffered); - - if (source->bytesAvailable() >= qint64(sizeof(CombinedHeader) + sizeof(DATAHeader) + sizeof(quint16))) - QTimer::singleShot(0, this, SLOT(handleData())); - else - connect(source, SIGNAL(readyRead()), SLOT(handleData())); -} - -WaveDecoder::~WaveDecoder() -{ -} - -QAudioFormat WaveDecoder::audioFormat() const -{ - return format; -} - -int WaveDecoder::duration() const -{ - return size() * 1000 / (format.sampleSize() / 8) / format.channels() / format.frequency(); -} - -qint64 WaveDecoder::size() const -{ - return haveFormat ? dataSize : 0; -} - -bool WaveDecoder::isSequential() const -{ - return source->isSequential(); -} - -qint64 WaveDecoder::bytesAvailable() const -{ - return haveFormat ? source->bytesAvailable() : 0; -} - -qint64 WaveDecoder::readData(char *data, qint64 maxlen) -{ - return haveFormat ? source->read(data, maxlen) : 0; -} - -qint64 WaveDecoder::writeData(const char *data, qint64 len) -{ - Q_UNUSED(data); - Q_UNUSED(len); - - return -1; -} - -void WaveDecoder::handleData() -{ - if (source->bytesAvailable() < qint64(sizeof(CombinedHeader) + sizeof(DATAHeader) + sizeof(quint16))) - return; - - source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); - source->read((char*)&header, sizeof(CombinedHeader)); - - if (qstrncmp(header.riff.descriptor.id, "RIFF", 4) != 0 || - qstrncmp(header.riff.type, "WAVE", 4) != 0 || - qstrncmp(header.wave.descriptor.id, "fmt ", 4) != 0 || - (header.wave.audioFormat != 0 && header.wave.audioFormat != 1)) { - - emit invalidFormat(); - } - else { - DATAHeader dataHeader; - - if (qFromLittleEndian(header.wave.descriptor.size) > sizeof(WAVEHeader)) { - // Extended data available - quint16 extraFormatBytes; - source->peek((char*)&extraFormatBytes, sizeof(quint16)); - extraFormatBytes = qFromLittleEndian(extraFormatBytes); - source->read(sizeof(quint16) + extraFormatBytes); // dump it all - } - - source->read((char*)&dataHeader, sizeof(DATAHeader)); - - int bps = qFromLittleEndian(header.wave.bitsPerSample); - - format.setCodec(QLatin1String("audio/pcm")); - format.setSampleType(bps == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt); - format.setByteOrder(QAudioFormat::LittleEndian); - format.setFrequency(qFromLittleEndian(header.wave.sampleRate)); - format.setSampleSize(bps); - format.setChannels(qFromLittleEndian(header.wave.numChannels)); - - dataSize = qFromLittleEndian(dataHeader.descriptor.size); - - haveFormat = true; - connect(source, SIGNAL(readyRead()), SIGNAL(readyRead())); - emit formatKnown(); - } -} - -QT_END_NAMESPACE diff --git a/src/multimedia/mediaservices/effects/wavedecoder_p.h b/src/multimedia/mediaservices/effects/wavedecoder_p.h deleted file mode 100644 index dcc5453..0000000 --- a/src/multimedia/mediaservices/effects/wavedecoder_p.h +++ /dev/null @@ -1,133 +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 QtMediaServices 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 WAVEDECODER_H -#define WAVEDECODER_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class WaveDecoder : public QIODevice -{ - Q_OBJECT - -public: - explicit WaveDecoder(QIODevice *source, QObject *parent = 0); - ~WaveDecoder(); - - QAudioFormat audioFormat() const; - int duration() const; - - qint64 size() const; - bool isSequential() const; - qint64 bytesAvailable() const; - -Q_SIGNALS: - void formatKnown(); - void invalidFormat(); - -private Q_SLOTS: - void handleData(); - -private: - qint64 readData(char *data, qint64 maxlen); - qint64 writeData(const char *data, qint64 len); - - struct chunk - { - char id[4]; - quint32 size; - }; - struct RIFFHeader - { - chunk descriptor; - char type[4]; - }; - struct WAVEHeader - { - chunk descriptor; - quint16 audioFormat; - quint16 numChannels; - quint32 sampleRate; - quint32 byteRate; - quint16 blockAlign; - quint16 bitsPerSample; - }; - struct DATAHeader - { - chunk descriptor; - }; - struct CombinedHeader - { - RIFFHeader riff; - WAVEHeader wave; - }; - - bool haveFormat; - qint64 dataSize; - qint64 remaining; - QAudioFormat format; - QIODevice *source; - CombinedHeader header; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // WAVEDECODER_H diff --git a/src/multimedia/mediaservices/mediaservices.pro b/src/multimedia/mediaservices/mediaservices.pro deleted file mode 100644 index d5b0e4c..0000000 --- a/src/multimedia/mediaservices/mediaservices.pro +++ /dev/null @@ -1,21 +0,0 @@ -TARGET = QtMediaServices -QPRO_PWD = $$PWD -QT = core gui multimedia - -DEFINES += QT_BUILD_MEDIASERVICES_LIB QT_NO_USING_NAMESPACE - -unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtMultimedia - -include(../../qbase.pri) - -include(base/base.pri) -include(playback/playback.pri) -include(effects/effects.pri) - -symbian: { - TARGET.UID3 = 0x2001E631 - contains(CONFIG, def_files) { - DEF_FILE=../../s60installs - } -} - diff --git a/src/multimedia/mediaservices/playback/playback.pri b/src/multimedia/mediaservices/playback/playback.pri deleted file mode 100644 index 09a81c9..0000000 --- a/src/multimedia/mediaservices/playback/playback.pri +++ /dev/null @@ -1,11 +0,0 @@ - -HEADERS += \ - $$PWD/qmediaplayer.h \ - $$PWD/qmediaplayercontrol.h - -SOURCES += \ - $$PWD/qmediaplayer.cpp \ - $$PWD/qmediaplayercontrol.cpp - - - diff --git a/src/multimedia/mediaservices/playback/qmediaplayer.cpp b/src/multimedia/mediaservices/playback/qmediaplayer.cpp deleted file mode 100644 index ca1f250..0000000 --- a/src/multimedia/mediaservices/playback/qmediaplayer.cpp +++ /dev/null @@ -1,996 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -//#define DEBUG_PLAYER_STATE - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -/*! - \class QMediaPlayer - \brief The QMediaPlayer class allows the playing of a media source. - \ingroup multimedia - \since 4.7 - \preliminary - - The QMediaPlayer class is a high level media playback class. It can be used - to playback such content as songs, movies and internet radio. The content - to playback is specified as a QMediaContent, which can be thought of as a - main or canonical URL with addition information attached. When provided - with a QMediaContent playback may be able to commence. - - \code - player = new QMediaPlayer; - connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64))); - player->setMedia(QUrl::fromLocalFile("/Users/me/Music/coolsong.mp3")); - player->setVolume(50); - player->play(); - \endcode - - QVideoWidget can be used with QMediaPlayer for video rendering and QMediaPlaylist - for accessing playlist functionality. - - \code - player = new QMediaPlayer; - - playlist = new QMediaPlaylist; - playlist->setMediaObject(player); - playlist->append(QUrl("http://example.com/movie1.mp4")); - playlist->append(QUrl("http://example.com/movie2.mp4")); - - widget = new QVideoWidget; - widget->setMediaObject(player); - widget->show(); - - player->play(); - \endcode - - \sa QMediaObject, QMediaService, QVideoWidget, QMediaPlaylist -*/ - -namespace -{ -class MediaPlayerRegisterMetaTypes -{ -public: - MediaPlayerRegisterMetaTypes() - { - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - } -} _registerPlayerMetaTypes; -} - -class QMediaPlayerPrivate : public QMediaObjectPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QMediaPlayer) - -public: - QMediaPlayerPrivate() - : provider(0) - , control(0) - , playlistControl(0) - , state(QMediaPlayer::StoppedState) - , error(QMediaPlayer::NoError) - , filterStates(false) - , playlist(0) - {} - - QMediaServiceProvider *provider; - QMediaPlayerControl* control; - QMediaPlaylistControl* playlistControl; - QMediaPlayer::State state; - QMediaPlayer::Error error; - QString errorString; - bool filterStates; - - QMediaPlaylist *playlist; - QPointer videoWidget; -#ifndef QT_NO_GRAPHICSVIEW - QPointer videoItem; -#endif - - void _q_stateChanged(QMediaPlayer::State state); - void _q_mediaStatusChanged(QMediaPlayer::MediaStatus status); - void _q_error(int error, const QString &errorString); - void _q_updateMedia(const QMediaContent&); - void _q_playlistDestroyed(); -}; - -#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v))) - -void QMediaPlayerPrivate::_q_stateChanged(QMediaPlayer::State ps) -{ - Q_Q(QMediaPlayer); - -#ifdef DEBUG_PLAYER_STATE - qDebug() << "State changed:" << ENUM_NAME(QMediaPlayer, "State", ps) << (filterStates ? "(filtered)" : ""); -#endif - - if (filterStates) - return; - - if (playlist - && !playlistControl //service should do this itself - && ps != state && ps == QMediaPlayer::StoppedState - && control->mediaStatus() == QMediaPlayer::EndOfMedia) { - playlist->next(); - ps = control->state(); - } - - if (ps != state) { - state = ps; - - if (ps == QMediaPlayer::PlayingState) - q->addPropertyWatch("position"); - else - q->removePropertyWatch("position"); - - emit q->stateChanged(ps); - } -} - -void QMediaPlayerPrivate::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status) -{ - Q_Q(QMediaPlayer); - -#ifdef DEBUG_PLAYER_STATE - qDebug() << "MediaStatus changed:" << ENUM_NAME(QMediaPlayer, "MediaStatus", status); -#endif - - switch (status) { - case QMediaPlayer::StalledMedia: - case QMediaPlayer::BufferingMedia: - q->addPropertyWatch("bufferStatus"); - emit q->mediaStatusChanged(status); - break; - default: - q->removePropertyWatch("bufferStatus"); - emit q->mediaStatusChanged(status); - break; - } - -} - -void QMediaPlayerPrivate::_q_error(int error, const QString &errorString) -{ - Q_Q(QMediaPlayer); - - this->error = QMediaPlayer::Error(error); - this->errorString = errorString; - - emit q->error(this->error); -} - -void QMediaPlayerPrivate::_q_updateMedia(const QMediaContent &media) -{ - const QMediaPlayer::State currentState = state; - - filterStates = true; - control->setMedia(media, 0); - - if (!media.isNull()) { - switch (currentState) { - case QMediaPlayer::PlayingState: - control->play(); - break; - case QMediaPlayer::PausedState: - control->pause(); - break; - default: - break; - } - } - filterStates = false; - - state = control->state(); - - if (state != currentState) { -#ifdef DEBUG_PLAYER_STATE - qDebug() << "State changed:" << ENUM_NAME(QMediaPlayer, "State", state); -#endif - emit q_func()->stateChanged(state); - } -} - -void QMediaPlayerPrivate::_q_playlistDestroyed() -{ - playlist = 0; - - control->setMedia(QMediaContent(), 0); -} - -static QMediaService *playerService(QMediaPlayer::Flags flags, QMediaServiceProvider *provider) -{ - if (flags) { - QMediaServiceProviderHint::Features features = 0; - if (flags & QMediaPlayer::LowLatency) - features |= QMediaServiceProviderHint::LowLatencyPlayback; - - if (flags & QMediaPlayer::StreamPlayback) - features |= QMediaServiceProviderHint::StreamPlayback; - - return provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER, - QMediaServiceProviderHint(features)); - } else - return provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER); -} - - -/*! - Construct a QMediaPlayer that uses the playback service from \a provider, - parented to \a parent and with \a flags. - - If a playback service is not specified the system default will be used. -*/ - -QMediaPlayer::QMediaPlayer(QObject *parent, QMediaPlayer::Flags flags, QMediaServiceProvider *provider): - QMediaObject(*new QMediaPlayerPrivate, - parent, - playerService(flags,provider)) -{ - Q_D(QMediaPlayer); - - d->provider = provider; - - if (d->service == 0) { - d->error = ServiceMissingError; - } else { - d->control = qobject_cast(d->service->control(QMediaPlayerControl_iid)); - d->playlistControl = qobject_cast(d->service->control(QMediaPlaylistControl_iid)); - if (d->control != 0) { - connect(d->control, SIGNAL(mediaChanged(QMediaContent)), SIGNAL(mediaChanged(QMediaContent))); - connect(d->control, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(_q_stateChanged(QMediaPlayer::State))); - connect(d->control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus))); - connect(d->control, SIGNAL(error(int,QString)), SLOT(_q_error(int,QString))); - - connect(d->control, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64))); - connect(d->control, SIGNAL(positionChanged(qint64)), SIGNAL(positionChanged(qint64))); - connect(d->control, SIGNAL(audioAvailableChanged(bool)), SIGNAL(audioAvailableChanged(bool))); - connect(d->control, SIGNAL(videoAvailableChanged(bool)), SIGNAL(videoAvailableChanged(bool))); - connect(d->control, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int))); - connect(d->control, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool))); - connect(d->control, SIGNAL(seekableChanged(bool)), SIGNAL(seekableChanged(bool))); - connect(d->control, SIGNAL(playbackRateChanged(qreal)), SIGNAL(playbackRateChanged(qreal))); - - if (d->control->state() == PlayingState) - addPropertyWatch("position"); - - if (d->control->mediaStatus() == StalledMedia || d->control->mediaStatus() == BufferingMedia) - addPropertyWatch("bufferStatus"); - } - } -} - - -/*! - Destroys the player object. -*/ - -QMediaPlayer::~QMediaPlayer() -{ - Q_D(QMediaPlayer); - - d->provider->releaseService(d->service); -} - -QMediaContent QMediaPlayer::media() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->media(); - - return QMediaContent(); -} - -/*! - Returns the stream source of media data. - - This is only valid if a stream was passed to setMedia(). - - \sa setMedia() -*/ - -const QIODevice *QMediaPlayer::mediaStream() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->mediaStream(); - - return 0; -} - -QMediaPlayer::State QMediaPlayer::state() const -{ - return d_func()->state; -} - -QMediaPlayer::MediaStatus QMediaPlayer::mediaStatus() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->mediaStatus(); - - return QMediaPlayer::UnknownMediaStatus; -} - -qint64 QMediaPlayer::duration() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->duration(); - - return -1; -} - -qint64 QMediaPlayer::position() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->position(); - - return 0; -} - -int QMediaPlayer::volume() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->volume(); - - return 0; -} - -bool QMediaPlayer::isMuted() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isMuted(); - - return false; -} - -int QMediaPlayer::bufferStatus() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->bufferStatus(); - - return 0; -} - -bool QMediaPlayer::isAudioAvailable() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isAudioAvailable(); - - return false; -} - -bool QMediaPlayer::isVideoAvailable() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isVideoAvailable(); - - return false; -} - -bool QMediaPlayer::isSeekable() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isSeekable(); - - return false; -} - -qreal QMediaPlayer::playbackRate() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->playbackRate(); - - return 0.0; -} - -/*! - Returns the current error state. -*/ - -QMediaPlayer::Error QMediaPlayer::error() const -{ - return d_func()->error; -} - -QString QMediaPlayer::errorString() const -{ - return d_func()->errorString; -} - -//public Q_SLOTS: -/*! - Start or resume playing the current source. -*/ - -void QMediaPlayer::play() -{ - Q_D(QMediaPlayer); - - if (d->control == 0) { - QMetaObject::invokeMethod(this, "_q_error", Qt::QueuedConnection, - Q_ARG(int, QMediaPlayer::ServiceMissingError), - Q_ARG(QString, tr("The QMediaPlayer object does not have a valid service"))); - return; - } - - //if playlist control is available, the service should advance itself - if (d->playlist && !d->playlistControl && d->playlist->currentIndex() == -1 && !d->playlist->isEmpty()) - d->playlist->setCurrentIndex(0); - - // Reset error conditions - d->error = NoError; - d->errorString = QString(); - - d->control->play(); -} - -/*! - Pause playing the current source. -*/ - -void QMediaPlayer::pause() -{ - Q_D(QMediaPlayer); - - if (d->control != 0) - d->control->pause(); -} - -/*! - Stop playing, and reset the play position to the beginning. -*/ - -void QMediaPlayer::stop() -{ - Q_D(QMediaPlayer); - - if (d->control != 0) - d->control->stop(); -} - -void QMediaPlayer::setPosition(qint64 position) -{ - Q_D(QMediaPlayer); - - if (d->control == 0 || !isSeekable()) - return; - - d->control->setPosition(qBound(qint64(0), duration(), position)); -} - -void QMediaPlayer::setVolume(int v) -{ - Q_D(QMediaPlayer); - - if (d->control == 0) - return; - - int clamped = qBound(0, v, 100); - if (clamped == volume()) - return; - - d->control->setVolume(clamped); -} - -void QMediaPlayer::setMuted(bool muted) -{ - Q_D(QMediaPlayer); - - if (d->control == 0 || muted == isMuted()) - return; - - d->control->setMuted(muted); -} - -void QMediaPlayer::setPlaybackRate(qreal rate) -{ - Q_D(QMediaPlayer); - - if (d->control != 0) - d->control->setPlaybackRate(rate); -} - -/*! - Sets the current \a media source. - - If a \a stream is supplied; media data will be read from it instead of resolving the media - source. In this case the media source may still be used to resolve additional information - about the media such as mime type. - - Setting the media to a null QMediaContent will cause the player to discard all - information relating to the current media source and to cease all I/O operations related - to that media. -*/ - -void QMediaPlayer::setMedia(const QMediaContent &media, QIODevice *stream) -{ - Q_D(QMediaPlayer); - - if (d->control != 0) - d_func()->control->setMedia(media, stream); -} - -/*! - \internal -*/ - -void QMediaPlayer::bind(QObject *obj) -{ - Q_D(QMediaPlayer); - - if (d->control != 0) { - QMediaPlaylist *playlist = qobject_cast(obj); - - if (playlist) { - if (d->playlist) - d->playlist->setMediaObject(0); - - d->playlist = playlist; - connect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), - this, SLOT(_q_updateMedia(QMediaContent))); - connect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); - - setMedia(playlist->currentMedia()); - - return; - } - - QVideoWidget *videoWidget = qobject_cast(obj); -#ifndef QT_NO_GRAPHICSVIEW - QGraphicsVideoItem *videoItem = qobject_cast(obj); -#endif - - if (videoWidget -#ifndef QT_NO_GRAPHICSVIEW - || videoItem -#endif - ) { - //detach the current video output - if (d->videoWidget) { - d->videoWidget->setMediaObject(0); - d->videoWidget = 0; - } - -#ifndef QT_NO_GRAPHICSVIEW - if (d->videoItem) { - d->videoItem->setMediaObject(0); - d->videoItem = 0; - } -#endif - } - - if (videoWidget) - d->videoWidget = videoWidget; - -#ifndef QT_NO_GRAPHICSVIEW - if (videoItem) - d->videoItem = videoItem; -#endif - } -} - -/*! - \internal -*/ - -void QMediaPlayer::unbind(QObject *obj) -{ - Q_D(QMediaPlayer); - - if (obj == d->videoWidget) { - d->videoWidget = 0; -#ifndef QT_NO_GRAPHICSVIEW - } else if (obj == d->videoItem) { - d->videoItem = 0; -#endif - } else if (obj == d->playlist) { - disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), - this, SLOT(_q_updateMedia(QMediaContent))); - disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); - d->playlist = 0; - setMedia(QMediaContent()); - } -} - -/*! - Returns the level of support a media player has for a \a mimeType and a set of \a codecs. - - The \a flags argument allows additional requirements such as performance indicators to be - specified. -*/ -QtMediaServices::SupportEstimate QMediaPlayer::hasSupport(const QString &mimeType, - const QStringList& codecs, - Flags flags) -{ - return QMediaServiceProvider::defaultServiceProvider()->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), - mimeType, - codecs, - flags); -} - -/*! - Returns a list of MIME types supported by the media player. - - The \a flags argument causes the resultant list to be restricted to MIME types which can be supported - given additional requirements, such as performance indicators. -*/ -QStringList QMediaPlayer::supportedMimeTypes(Flags flags) -{ - return QMediaServiceProvider::defaultServiceProvider()->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), - flags); -} - - -// Enums -/*! - \enum QMediaPlayer::State - - Defines the current state of a media player. - - \value PlayingState The media player is currently playing content. - \value PausedState The media player has paused playback, playback of the current track will - resume from the position the player was paused at. - \value StoppedState The media player is not playing content, playback will begin from the start - of the current track. -*/ - -/*! - \enum QMediaPlayer::MediaStatus - - Defines the status of a media player's current media. - - \value UnknownMediaStatus The status of the media cannot be determined. - \value NoMedia The is no current media. The player is in the StoppedState. - \value LoadingMedia The current media is being loaded. The player may be in any state. - \value LoadedMedia The current media has been loaded. The player is in the StoppedState. - \value StalledMedia Playback of the current media has stalled due to insufficient buffering or - some other temporary interruption. The player is in the PlayingState or PausedState. - \value BufferingMedia The player is buffering data but has enough data buffered for playback to - continue for the immediate future. The player is in the PlayingState or PausedState. - \value BufferedMedia The player has fully buffered the current media. The player is in the - PlayingState or PausedState. - \value EndOfMedia Playback has reached the end of the current media. The player is in the - StoppedState. - \value InvalidMedia The current media cannot be played. The player is in the StoppedState. -*/ - -/*! - \enum QMediaPlayer::Error - - Defines a media player error condition. - - \value NoError No error has occurred. - \value ResourceError A media resource couldn't be resolved. - \value FormatError The format of a media resource isn't (fully) supported. Playback may still - be possible, but without an audio or video component. - \value NetworkError A network error occurred. - \value AccessDeniedError There are not the appropriate permissions to play a media resource. - \value ServiceMissingError A valid playback service was not found, playback cannot proceed. -*/ - -// Signals -/*! - \fn QMediaPlayer::error(QMediaPlayer::Error error) - - Signals that an \a error condition has occurred. - - \sa errorString() -*/ - -/*! - \fn void QMediaPlayer::stateChanged(State state) - - Signal the \a state of the Player object has changed. -*/ - -/*! - \fn QMediaPlayer::mediaStatusChanged(QMediaPlayer::MediaStatus status) - - Signals that the \a status of the current media has changed. - - \sa mediaStatus() -*/ - -/*! - \fn void QMediaPlayer::mediaChanged(const QMediaContent &media); - - Signals that the current playing content will be obtained from \a media. - - \sa media() -*/ - -/*! - \fn void QMediaPlayer::playbackRateChanged(qreal rate); - - Signals the playbackRate has changed to \a rate. -*/ - -/*! - \fn void QMediaPlayer::seekableChanged(bool seekable); - - Signals the \a seekable status of the player object has changed. -*/ - -// Properties -/*! - \property QMediaPlayer::state - \brief the media player's playback state. - - By default this property is QMediaPlayer::Stopped - - \sa mediaStatus(), play(), pause(), stop() -*/ - -/*! - \property QMediaPlayer::error - \brief a string describing the last error condition. - - \sa error() -*/ - -/*! - \property QMediaPlayer::media - \brief the active media source being used by the player object. - - The player object will use the QMediaContent for selection of the content to - be played. - - By default this property has a null QMediaContent. - - Setting this property to a null QMediaContent will cause the player to discard all - information relating to the current media source and to cease all I/O operations related - to that media. - - \sa QMediaContent -*/ - -/*! - \property QMediaPlayer::mediaStatus - \brief the status of the current media stream. - - The stream status describes how the playback of the current stream is - progressing. - - By default this property is QMediaPlayer::NoMedia - - \sa state -*/ - -/*! - \property QMediaPlayer::duration - \brief the duration of the current media. - - The value is the total playback time in milliseconds of the current media. - The value may change across the life time of the QMediaPlayer object and - may not be available when initial playback begins, connect to the - durationChanged() signal to receive status notifications. -*/ - -/*! - \property QMediaPlayer::position - \brief the playback position of the current media. - - The value is the current playback position, expressed in milliseconds since - the beginning of the media. Periodically changes in the position will be - indicated with the signal positionChanged(), the interval between updates - can be set with QMediaObject's method setNotifyInterval(). -*/ - -/*! - \property QMediaPlayer::volume - \brief the current playback volume. - - The playback volume is a linear in effect and the value can range from 0 - - 100, values outside this range will be clamped. -*/ - -/*! - \property QMediaPlayer::muted - \brief the muted state of the current media. - - The value will be true if the playback volume is muted; otherwise false. -*/ - -/*! - \property QMediaPlayer::bufferStatus - \brief the percentage of the temporary buffer filled before playback begins. - - When the player object is buffering; this property holds the percentage of - the temporary buffer that is filled. The buffer will need to reach 100% - filled before playback can resume, at which time the MediaStatus will be - BufferedMedia. - - \sa mediaStatus() -*/ - -/*! - \property QMediaPlayer::audioAvailable - \brief the audio availabilty status for the current media. - - As the life time of QMediaPlayer can be longer than the playback of one - QMediaContent, this property may change over time, the - audioAvailableChanged signal can be used to monitor it's status. -*/ - -/*! - \property QMediaPlayer::videoAvailable - \brief the video availability status for the current media. - - If available, the QVideoWidget class can be used to view the video. As the - life time of QMediaPlayer can be longer than the playback of one - QMediaContent, this property may change over time, the - videoAvailableChanged signal can be used to monitor it's status. - - \sa QVideoWidget, QMediaContent -*/ - -/*! - \property QMediaPlayer::seekable - \brief the seek-able status of the current media - - If seeking is supported this property will be true; false otherwise. The - status of this property may change across the life time of the QMediaPlayer - object, use the seekableChanged signal to monitor changes. -*/ - -/*! - \property QMediaPlayer::playbackRate - \brief the playback rate of the current media. - - This value is a multiplier applied to the media's standard play rate. By - default this value is 1.0, indicating that the media is playing at the - standard pace. Values higher than 1.0 will increase the rate of play. - Values less than zero can be set and indicate the media will rewind at the - multiplier of the standard pace. - - Not all playback services support change of the playback rate. It is - framework defined as to the status and quality of audio and video - while fast forwarding or rewinding. -*/ - -/*! - \fn void QMediaPlayer::durationChanged(qint64 duration) - - Signal the duration of the content has changed to \a duration, expressed in milliseconds. -*/ - -/*! - \fn void QMediaPlayer::positionChanged(qint64 position) - - Signal the position of the content has changed to \a position, expressed in - milliseconds. -*/ - -/*! - \fn void QMediaPlayer::volumeChanged(int volume) - - Signal the playback volume has changed to \a volume. -*/ - -/*! - \fn void QMediaPlayer::mutedChanged(bool muted) - - Signal the mute state has changed to \a muted. -*/ - -/*! - \fn void QMediaPlayer::audioAvailableChanged(bool available) - - Signals the availability of audio content has changed to \a available. -*/ - -/*! - \fn void QMediaPlayer::videoAvailableChanged(bool videoAvailable) - - Signal the availability of visual content has changed to \a videoAvailable. -*/ - -/*! - \fn void QMediaPlayer::bufferStatusChanged(int percentFilled) - - Signal the amount of the local buffer filled as a percentage by \a percentFilled. -*/ - -/*! - \enum QMediaPlayer::Flag - - \value LowLatency - The player is expected to be used with simple audio formats, - but playback should start without significant delay. - Such playback service can be used for beeps, ringtones, etc. - - \value StreamPlayback - The player is expected to play QIODevice based streams. - If passed to QMediaPlayer constructor, the service supporting - streams playback will be choosen. -*/ - -QT_END_NAMESPACE - -QT_END_HEADER - -#include "moc_qmediaplayer.cpp" diff --git a/src/multimedia/mediaservices/playback/qmediaplayer.h b/src/multimedia/mediaservices/playback/qmediaplayer.h deleted file mode 100644 index d75c58a..0000000 --- a/src/multimedia/mediaservices/playback/qmediaplayer.h +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIAPLAYER_H -#define QMEDIAPLAYER_H - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylist; - -class QMediaPlayerPrivate; -class Q_MEDIASERVICES_EXPORT QMediaPlayer : public QMediaObject -{ - Q_OBJECT - Q_PROPERTY(QMediaContent media READ media WRITE setMedia NOTIFY mediaChanged) - Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged) - Q_PROPERTY(qint64 position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(int bufferStatus READ bufferStatus NOTIFY bufferStatusChanged) - Q_PROPERTY(bool audioAvailable READ isAudioAvailable NOTIFY audioAvailableChanged) - Q_PROPERTY(bool videoAvailable READ isVideoAvailable NOTIFY videoAvailableChanged) - Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged) - Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged) - Q_PROPERTY(State state READ state NOTIFY stateChanged) - Q_PROPERTY(MediaStatus mediaStatus READ mediaStatus NOTIFY mediaStatusChanged) - Q_PROPERTY(QString error READ errorString) - Q_ENUMS(State) - Q_ENUMS(MediaStatus) - -public: - enum State - { - StoppedState, - PlayingState, - PausedState - }; - - enum MediaStatus - { - UnknownMediaStatus, - NoMedia, - LoadingMedia, - LoadedMedia, - StalledMedia, - BufferingMedia, - BufferedMedia, - EndOfMedia, - InvalidMedia - }; - - enum Flag - { - LowLatency = 0x01, - StreamPlayback = 0x02 - }; - Q_DECLARE_FLAGS(Flags, Flag) - - enum Error - { - NoError, - ResourceError, - FormatError, - NetworkError, - AccessDeniedError, - ServiceMissingError - }; - - QMediaPlayer(QObject *parent = 0, Flags flags = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider()); - ~QMediaPlayer(); - - static QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, - const QStringList& codecs = QStringList(), - Flags flags = 0); - static QStringList supportedMimeTypes(Flags flags = 0); - - QMediaContent media() const; - const QIODevice *mediaStream() const; - - State state() const; - MediaStatus mediaStatus() const; - - qint64 duration() const; - qint64 position() const; - - int volume() const; - bool isMuted() const; - bool isAudioAvailable() const; - bool isVideoAvailable() const; - - int bufferStatus() const; - - bool isSeekable() const; - qreal playbackRate() const; - - Error error() const; - QString errorString() const; - -public Q_SLOTS: - void play(); - void pause(); - void stop(); - - void setPosition(qint64 position); - void setVolume(int volume); - void setMuted(bool muted); - - void setPlaybackRate(qreal rate); - - void setMedia(const QMediaContent &media, QIODevice *stream = 0); - -Q_SIGNALS: - void mediaChanged(const QMediaContent &media); - - void stateChanged(QMediaPlayer::State newState); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - - void durationChanged(qint64 duration); - void positionChanged(qint64 position); - - void volumeChanged(int volume); - void mutedChanged(bool muted); - void audioAvailableChanged(bool audioAvailable); - void videoAvailableChanged(bool videoAvailable); - - void bufferStatusChanged(int percentFilled); - - void seekableChanged(bool seekable); - void playbackRateChanged(qreal rate); - - void error(QMediaPlayer::Error error); - -public: - virtual void bind(QObject*); - virtual void unbind(QObject*); - -private: - Q_DISABLE_COPY(QMediaPlayer) - Q_DECLARE_PRIVATE(QMediaPlayer) - Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QMediaPlayer::State)) - Q_PRIVATE_SLOT(d_func(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus)) - Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &)) - Q_PRIVATE_SLOT(d_func(), void _q_updateMedia(const QMediaContent&)) - Q_PRIVATE_SLOT(d_func(), void _q_playlistDestroyed()) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaPlayer::State) -Q_DECLARE_METATYPE(QMediaPlayer::MediaStatus) -Q_DECLARE_METATYPE(QMediaPlayer::Error) - -QT_END_HEADER - -#endif // QMEDIAPLAYER_H diff --git a/src/multimedia/mediaservices/playback/qmediaplayercontrol.cpp b/src/multimedia/mediaservices/playback/qmediaplayercontrol.cpp deleted file mode 100644 index ca58ce4..0000000 --- a/src/multimedia/mediaservices/playback/qmediaplayercontrol.cpp +++ /dev/null @@ -1,378 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 -#include -#include - - -QT_BEGIN_NAMESPACE - - -/*! - \class QMediaPlayerControl - \ingroup multimedia-serv - \since 4.7 - \preliminary - \brief The QMediaPlayerControl class provides access to the media playing - functionality of a QMediaService. - - If a QMediaService can play media is will implement QMediaPlayerControl. - This control provides a means to set the \l {setMedia()}{media} to play, - \l {play()}{start}, \l {pause()} {pause} and \l {stop()}{stop} playback, - \l {setPosition()}{seek}, and control the \l {setVolume()}{volume}. - It also provides feedback on the \l {duration()}{duration} of the media, - the current \l {position()}{position}, and \l {bufferStatus()}{buffering} - progress. - - The functionality provided by this control is exposed to application - code through the QMediaPlayer class. - - The interface name of QMediaPlayerControl is \c com.nokia.Qt.QMediaPlayerControl/1.0 as - defined in QMediaPlayerControl_iid. - - \sa QMediaService::control(), QMediaPlayer -*/ - -/*! - \macro QMediaPlayerControl_iid - - \c com.nokia.Qt.QMediaPlayerControl/1.0 - - Defines the interface name of the QMediaPlayerControl class. - - \relates QMediaPlayerControl -*/ - -/*! - Destroys a media player control. -*/ -QMediaPlayerControl::~QMediaPlayerControl() -{ -} - -/*! - Constructs a new media player control with the given \a parent. -*/ -QMediaPlayerControl::QMediaPlayerControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - \fn QMediaPlayerControl::state() const - - Returns the state of a player control. -*/ - -/*! - \fn QMediaPlayerControl::stateChanged(QMediaPlayer::State state) - - Signals that the \a state of a player control has changed. - - \sa state() -*/ - -/*! - \fn QMediaPlayerControl::mediaStatus() const - - Returns the status of the current media. -*/ - -/*! - \fn QMediaPlayerControl::mediaStatusChanged(QMediaPlayer::MediaStatus status) - - Signals that the \a status of the current media has changed. - - \sa mediaStatus() -*/ - - -/*! - \fn QMediaPlayerControl::duration() const - - Returns the duration of the current media in milliseconds. -*/ - -/*! - \fn QMediaPlayerControl::durationChanged(qint64 duration) - - Signals that the \a duration of the current media has changed. - - \sa duration() -*/ - -/*! - \fn QMediaPlayerControl::position() const - - Returns the current playback position in milliseconds. -*/ - -/*! - \fn QMediaPlayerControl::setPosition(qint64 position) - - Sets the playback \a position of the current media. This will initiate a seek and it may take - some time for playback to reach the position set. -*/ - -/*! - \fn QMediaPlayerControl::positionChanged(qint64 position) - - Signals the playback \a position has changed. - - This is only emitted in when there has been a discontinous change in the playback postion, such - as a seek or the position being reset. - - \sa position() -*/ - -/*! - \fn QMediaPlayerControl::volume() const - - Returns the audio volume of a player control. -*/ - -/*! - \fn QMediaPlayerControl::setVolume(int volume) - - Sets the audio \a volume of a player control. -*/ - -/*! - \fn QMediaPlayerControl::volumeChanged(int volume) - - Signals the audio \a volume of a player control has changed. - - \sa volume() -*/ - -/*! - \fn QMediaPlayerControl::isMuted() const - - Returns the mute state of a player control. -*/ - -/*! - \fn QMediaPlayerControl::setMuted(bool mute) - - Sets the \a mute state of a player control. -*/ - -/*! - \fn QMediaPlayerControl::mutedChanged(bool mute) - - Signals a change in the \a mute status of a player control. - - \sa isMuted() -*/ - -/*! - \fn QMediaPlayerControl::bufferStatus() const - - Returns the buffering progress of the current media. Progress is measured in the percentage - of the buffer filled. -*/ - -/*! - \fn QMediaPlayerControl::bufferStatusChanged(int progress) - - Signals that buffering \a progress has changed. - - \sa bufferStatus() -*/ - -/*! - \fn QMediaPlayerControl::isAudioAvailable() const - - Identifies if there is audio output available for the current media. - - Returns true if audio output is available and false otherwise. -*/ - -/*! - \fn QMediaPlayerControl::audioAvailableChanged(bool audio) - - Signals that there has been a change in the availability of \a audio output. - - \sa isAudioAvailable() -*/ - -/*! - \fn QMediaPlayerControl::isVideoAvailable() const - - Identifies if there is video output available for the current media. - - Returns true if video output is available and false otherwise. -*/ - -/*! - \fn QMediaPlayerControl::videoAvailableChanged(bool video) - - Signals that there has been a change in the availability of \a video output. - - \sa isVideoAvailable() -*/ - -/*! - \fn QMediaPlayerControl::isSeekable() const - - Identifies if the current media is seekable. - - Returns true if it possible to seek within the current media, and false otherwise. -*/ - -/*! - \fn QMediaPlayerControl::seekableChanged(bool seekable) - - Signals that the \a seekable state of a player control has changed. - - \sa isSeekable() -*/ - -/*! - \fn QMediaPlayerControl::availablePlaybackRanges() const - - Returns a range of times in milliseconds that can be played back. - - Usually for local files this is a continuous interval equal to [0..duration()] - or an empty time range if seeking is not supported, but for network sources - it refers to the buffered parts of the media. -*/ - -/*! - \fn QMediaPlayerControl::availablePlaybackRangesChanged(const QMediaTimeRange &ranges) - - Signals that the available media playback \a ranges have changed. - - \sa QMediaPlayerControl::availablePlaybackRanges() -*/ - -/*! - \fn qreal QMediaPlayerControl::playbackRate() const - - Returns the rate of playback. -*/ - -/*! - \fn QMediaPlayerControl::setPlaybackRate(qreal rate) - - Sets the \a rate of playback. -*/ - -/*! - \fn QMediaPlayerControl::media() const - - Returns the current media source. -*/ - -/*! - \fn QMediaPlayerControl::mediaStream() const - - Returns the current media stream. This is only a valid if a stream was passed to setMedia(). - - \sa setMedia() -*/ - -/*! - \fn QMediaPlayerControl::setMedia(const QMediaContent &media, QIODevice *stream) - - Sets the current \a media source. If a \a stream is supplied; data will be read from that - instead of attempting to resolve the media source. The media source may still be used to - supply media information such as mime type. - - Setting the media to a null QMediaContent will cause the control to discard all - information relating to the current media source and to cease all I/O operations related - to that media. -*/ - -/*! - \fn QMediaPlayerControl::mediaChanged(const QMediaContent& content) - - Signals that the current media \a content has changed. -*/ - -/*! - \fn QMediaPlayerControl::play() - - Starts playback of the current media. - - If successful the player control will immediately enter the \l {QMediaPlayer::PlayingState} - {playing} state. - - \sa state() -*/ - -/*! - \fn QMediaPlayerControl::pause() - - Pauses playback of the current media. - - If sucessful the player control will immediately enter the \l {QMediaPlayer::PausedState} - {paused} state. - - \sa state(), play(), stop() -*/ - -/*! - \fn QMediaPlayerControl::stop() - - Stops playback of the current media. - - If succesful the player control will immediately enter the \l {QMediaPlayer::StoppedState} - {stopped} state. -*/ - -/*! - \fn QMediaPlayerControl::error(int error, const QString &errorString) - - Signals that an \a error has occurred. The \a errorString provides a more detailed explanation. -*/ - -/*! - \fn QMediaPlayerControl::playbackRateChanged(qreal rate) - - Signal emitted when playback rate changes to \a rate. -*/ - -QT_END_NAMESPACE - -#include "moc_qmediaplayercontrol.cpp" - diff --git a/src/multimedia/mediaservices/playback/qmediaplayercontrol.h b/src/multimedia/mediaservices/playback/qmediaplayercontrol.h deleted file mode 100644 index 7a3c24e..0000000 --- a/src/multimedia/mediaservices/playback/qmediaplayercontrol.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices 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 QMEDIAPLAYERCONTROL_H -#define QMEDIAPLAYERCONTROL_H - -#include - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylist; - -class Q_MEDIASERVICES_EXPORT QMediaPlayerControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QMediaPlayerControl(); - - virtual QMediaPlayer::State state() const = 0; - - virtual QMediaPlayer::MediaStatus mediaStatus() const = 0; - - virtual qint64 duration() const = 0; - - virtual qint64 position() const = 0; - virtual void setPosition(qint64 position) = 0; - - virtual int volume() const = 0; - virtual void setVolume(int volume) = 0; - - virtual bool isMuted() const = 0; - virtual void setMuted(bool muted) = 0; - - virtual int bufferStatus() const = 0; - - virtual bool isAudioAvailable() const = 0; - virtual bool isVideoAvailable() const = 0; - - virtual bool isSeekable() const = 0; - - virtual QMediaTimeRange availablePlaybackRanges() const = 0; - - virtual qreal playbackRate() const = 0; - virtual void setPlaybackRate(qreal rate) = 0; - - virtual QMediaContent media() const = 0; - virtual const QIODevice *mediaStream() const = 0; - virtual void setMedia(const QMediaContent &media, QIODevice *stream) = 0; - - virtual void play() = 0; - virtual void pause() = 0; - virtual void stop() = 0; - -Q_SIGNALS: - void mediaChanged(const QMediaContent& content); - void durationChanged(qint64 duration); - void positionChanged(qint64 position); - void stateChanged(QMediaPlayer::State newState); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void audioAvailableChanged(bool audioAvailable); - void videoAvailableChanged(bool videoAvailable); - void bufferStatusChanged(int percentFilled); - void seekableChanged(bool); - void availablePlaybackRangesChanged(const QMediaTimeRange&); - void playbackRateChanged(qreal rate); - void error(int error, const QString &errorString); - -protected: - QMediaPlayerControl(QObject* parent = 0); -}; - -#define QMediaPlayerControl_iid "com.nokia.Qt.QMediaPlayerControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaPlayerControl, QMediaPlayerControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYERCONTROL_H - diff --git a/src/multimedia/multimedia.pro b/src/multimedia/multimedia.pro index 8cdcb38..93da612 100644 --- a/src/multimedia/multimedia.pro +++ b/src/multimedia/multimedia.pro @@ -1,8 +1,19 @@ -TEMPLATE = subdirs +TARGET = QtMultimedia +QPRO_PWD = $$PWD +QT = core gui -contains(QT_CONFIG, multimedia) { - SUBDIRS += multimedia +DEFINES += QT_BUILD_MULTIMEDIA_LIB QT_NO_USING_NAMESPACE - contains(QT_CONFIG, mediaservices):SUBDIRS += mediaservices -} +unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui + +include(../qbase.pri) +include(audio/audio.pri) +include(video/video.pri) + +symbian: { + TARGET.UID3 = 0x2001E627 + contains(CONFIG, def_files) { + DEF_FILE=../../s60installs + } +} diff --git a/src/multimedia/multimedia/audio/audio.pri b/src/multimedia/multimedia/audio/audio.pri deleted file mode 100644 index ae28a26..0000000 --- a/src/multimedia/multimedia/audio/audio.pri +++ /dev/null @@ -1,73 +0,0 @@ -HEADERS += $$PWD/qaudio.h \ - $$PWD/qaudioformat.h \ - $$PWD/qaudioinput.h \ - $$PWD/qaudiooutput.h \ - $$PWD/qaudiodeviceinfo.h \ - $$PWD/qaudioengineplugin.h \ - $$PWD/qaudioengine.h \ - $$PWD/qaudiodevicefactory_p.h - - -SOURCES += $$PWD/qaudio.cpp \ - $$PWD/qaudioformat.cpp \ - $$PWD/qaudiodeviceinfo.cpp \ - $$PWD/qaudiooutput.cpp \ - $$PWD/qaudioinput.cpp \ - $$PWD/qaudioengineplugin.cpp \ - $$PWD/qaudioengine.cpp \ - $$PWD/qaudiodevicefactory.cpp - -contains(QT_CONFIG, audio-backend) { - -mac { - HEADERS += $$PWD/qaudioinput_mac_p.h \ - $$PWD/qaudiooutput_mac_p.h \ - $$PWD/qaudiodeviceinfo_mac_p.h \ - $$PWD/qaudio_mac_p.h - - SOURCES += $$PWD/qaudiodeviceinfo_mac_p.cpp \ - $$PWD/qaudiooutput_mac_p.cpp \ - $$PWD/qaudioinput_mac_p.cpp \ - $$PWD/qaudio_mac.cpp - - LIBS += -framework ApplicationServices -framework CoreAudio -framework AudioUnit -framework AudioToolbox - -} else:win32 { - - HEADERS += $$PWD/qaudioinput_win32_p.h $$PWD/qaudiooutput_win32_p.h $$PWD/qaudiodeviceinfo_win32_p.h - SOURCES += $$PWD/qaudiodeviceinfo_win32_p.cpp \ - $$PWD/qaudiooutput_win32_p.cpp \ - $$PWD/qaudioinput_win32_p.cpp - !wince*:LIBS += -lwinmm - wince*:LIBS += -lcoredll - -} else:symbian { - INCLUDEPATH += /epoc32/include/mmf/common - INCLUDEPATH += /epoc32/include/mmf/server - - HEADERS += $$PWD/qaudio_symbian_p.h \ - $$PWD/qaudiodeviceinfo_symbian_p.h \ - $$PWD/qaudioinput_symbian_p.h \ - $$PWD/qaudiooutput_symbian_p.h - - SOURCES += $$PWD/qaudio_symbian_p.cpp \ - $$PWD/qaudiodeviceinfo_symbian_p.cpp \ - $$PWD/qaudioinput_symbian_p.cpp \ - $$PWD/qaudiooutput_symbian_p.cpp - - LIBS += -lmmfdevsound -} else:unix { - unix:contains(QT_CONFIG, alsa) { - linux-*|freebsd-*|openbsd-*:{ - DEFINES += HAS_ALSA - HEADERS += $$PWD/qaudiooutput_alsa_p.h $$PWD/qaudioinput_alsa_p.h $$PWD/qaudiodeviceinfo_alsa_p.h - SOURCES += $$PWD/qaudiodeviceinfo_alsa_p.cpp \ - $$PWD/qaudiooutput_alsa_p.cpp \ - $$PWD/qaudioinput_alsa_p.cpp - LIBS_PRIVATE += -lasound - } - } -} -} else { - DEFINES += QT_NO_AUDIO_BACKEND -} diff --git a/src/multimedia/multimedia/audio/qaudio.cpp b/src/multimedia/multimedia/audio/qaudio.cpp deleted file mode 100644 index e0f24ce..0000000 --- a/src/multimedia/multimedia/audio/qaudio.cpp +++ /dev/null @@ -1,104 +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 QtMultimedia 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 - - -QT_BEGIN_NAMESPACE - -namespace QAudio -{ - -class RegisterMetaTypes -{ -public: - RegisterMetaTypes() - { - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - } - -} _register; - -} - -/*! - \namespace QAudio - \brief The QAudio namespace contains enums used by the audio classes. - \inmodule QtMultimedia - \ingroup multimedia - \since 4.6 -*/ - -/*! - \enum QAudio::Error - - \value NoError No errors have occurred - \value OpenError An error opening the audio device - \value IOError An error occurred during read/write of audio device - \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate - \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. -*/ - -/*! - \enum QAudio::State - - \value ActiveState Audio data is being processed, this state is set after start() is called - and while audio data is available to be processed. - \value SuspendedState The audio device is in a suspended state, this state will only be entered - after suspend() is called. - \value StoppedState The audio device is closed, not processing any audio data - \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state - is set after start() is called and while no audio data is available to be processed. -*/ - -/*! - \enum QAudio::Mode - - \value AudioOutput audio output device - \value AudioInput audio input device -*/ - - -QT_END_NAMESPACE - diff --git a/src/multimedia/multimedia/audio/qaudio.h b/src/multimedia/multimedia/audio/qaudio.h deleted file mode 100644 index 9ca1dff..0000000 --- a/src/multimedia/multimedia/audio/qaudio.h +++ /dev/null @@ -1,71 +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 QtMultimedia 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 QAUDIO_H -#define QAUDIO_H - - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -namespace QAudio -{ - enum Error { NoError, OpenError, IOError, UnderrunError, FatalError }; - enum State { ActiveState, SuspendedState, StoppedState, IdleState }; - enum Mode { AudioInput, AudioOutput }; -} - -QT_END_NAMESPACE - -QT_END_HEADER - -Q_DECLARE_METATYPE(QAudio::Error) -Q_DECLARE_METATYPE(QAudio::State) -Q_DECLARE_METATYPE(QAudio::Mode) - -#endif // QAUDIO_H diff --git a/src/multimedia/multimedia/audio/qaudio_mac.cpp b/src/multimedia/multimedia/audio/qaudio_mac.cpp deleted file mode 100644 index 14fee8b..0000000 --- a/src/multimedia/multimedia/audio/qaudio_mac.cpp +++ /dev/null @@ -1,142 +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 QtMultimedia 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 "qaudio_mac_p.h" - -QT_BEGIN_NAMESPACE - -// Debugging -QDebug operator<<(QDebug dbg, const QAudioFormat& audioFormat) -{ - dbg.nospace() << "QAudioFormat(" << - audioFormat.frequency() << "," << - audioFormat.channels() << "," << - audioFormat.sampleSize()<< "," << - audioFormat.codec() << "," << - audioFormat.byteOrder() << "," << - audioFormat.sampleType() << ")"; - - return dbg.space(); -} - - -// Conversion -QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf) -{ - QAudioFormat audioFormat; - - audioFormat.setFrequency(sf.mSampleRate); - audioFormat.setChannels(sf.mChannelsPerFrame); - audioFormat.setSampleSize(sf.mBitsPerChannel); - audioFormat.setCodec(QString::fromLatin1("audio/pcm")); - audioFormat.setByteOrder(sf.mFormatFlags & kLinearPCMFormatFlagIsBigEndian != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian); - QAudioFormat::SampleType type = QAudioFormat::UnSignedInt; - if ((sf.mFormatFlags & kLinearPCMFormatFlagIsSignedInteger) != 0) - type = QAudioFormat::SignedInt; - else if ((sf.mFormatFlags & kLinearPCMFormatFlagIsFloat) != 0) - type = QAudioFormat::Float; - audioFormat.setSampleType(type); - - return audioFormat; -} - -AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& audioFormat) -{ - AudioStreamBasicDescription sf; - - sf.mFormatFlags = kAudioFormatFlagIsPacked; - sf.mSampleRate = audioFormat.frequency(); - sf.mFramesPerPacket = 1; - sf.mChannelsPerFrame = audioFormat.channels(); - sf.mBitsPerChannel = audioFormat.sampleSize(); - sf.mBytesPerFrame = sf.mChannelsPerFrame * (sf.mBitsPerChannel / 8); - sf.mBytesPerPacket = sf.mFramesPerPacket * sf.mBytesPerFrame; - sf.mFormatID = kAudioFormatLinearPCM; - - switch (audioFormat.sampleType()) { - case QAudioFormat::SignedInt: sf.mFormatFlags |= kAudioFormatFlagIsSignedInteger; break; - case QAudioFormat::UnSignedInt: /* default */ break; - case QAudioFormat::Float: sf.mFormatFlags |= kAudioFormatFlagIsFloat; break; - case QAudioFormat::Unknown: default: break; - } - - return sf; -} - -// QAudioRingBuffer -QAudioRingBuffer::QAudioRingBuffer(int bufferSize): - m_bufferSize(bufferSize) -{ - m_buffer = new char[m_bufferSize]; - reset(); -} - -QAudioRingBuffer::~QAudioRingBuffer() -{ - delete m_buffer; -} - -int QAudioRingBuffer::used() const -{ - return m_bufferUsed; -} - -int QAudioRingBuffer::free() const -{ - return m_bufferSize - m_bufferUsed; -} - -int QAudioRingBuffer::size() const -{ - return m_bufferSize; -} - -void QAudioRingBuffer::reset() -{ - m_readPos = 0; - m_writePos = 0; - m_bufferUsed = 0; -} - -QT_END_NAMESPACE - - diff --git a/src/multimedia/multimedia/audio/qaudio_mac_p.h b/src/multimedia/multimedia/audio/qaudio_mac_p.h deleted file mode 100644 index 4e7d688..0000000 --- a/src/multimedia/multimedia/audio/qaudio_mac_p.h +++ /dev/null @@ -1,144 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QAUDIO_MAC_P_H -#define QAUDIO_MAC_P_H - -#include - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -extern QDebug operator<<(QDebug dbg, const QAudioFormat& audioFormat); - -extern QAudioFormat toQAudioFormat(const AudioStreamBasicDescription& streamFormat); -extern AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& audioFormat); - -class QAudioRingBuffer -{ -public: - typedef QPair Region; - - QAudioRingBuffer(int bufferSize); - ~QAudioRingBuffer(); - - Region acquireReadRegion(int size) - { - const int used = m_bufferUsed.fetchAndAddAcquire(0); - - if (used > 0) { - const int readSize = qMin(size, qMin(m_bufferSize - m_readPos, used)); - - return readSize > 0 ? Region(m_buffer + m_readPos, readSize) : Region(0, 0); - } - - return Region(0, 0); - } - - void releaseReadRegion(Region const& region) - { - m_readPos = (m_readPos + region.second) % m_bufferSize; - - m_bufferUsed.fetchAndAddRelease(-region.second); - } - - Region acquireWriteRegion(int size) - { - const int free = m_bufferSize - m_bufferUsed.fetchAndAddAcquire(0); - - if (free > 0) { - const int writeSize = qMin(size, qMin(m_bufferSize - m_writePos, free)); - - return writeSize > 0 ? Region(m_buffer + m_writePos, writeSize) : Region(0, 0); - } - - return Region(0, 0); - } - - void releaseWriteRegion(Region const& region) - { - m_writePos = (m_writePos + region.second) % m_bufferSize; - - m_bufferUsed.fetchAndAddRelease(region.second); - } - - int used() const; - int free() const; - int size() const; - - void reset(); - -private: - int m_bufferSize; - int m_readPos; - int m_writePos; - char* m_buffer; - QAtomicInt m_bufferUsed; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIO_MAC_P_H - - diff --git a/src/multimedia/multimedia/audio/qaudio_symbian_p.cpp b/src/multimedia/multimedia/audio/qaudio_symbian_p.cpp deleted file mode 100644 index afe98f5..0000000 --- a/src/multimedia/multimedia/audio/qaudio_symbian_p.cpp +++ /dev/null @@ -1,395 +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 QtMultimedia 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 "qaudio_symbian_p.h" -#include - -QT_BEGIN_NAMESPACE - -namespace SymbianAudio { - -DevSoundCapabilities::DevSoundCapabilities(CMMFDevSound &devsound, - QAudio::Mode mode) -{ - QT_TRAP_THROWING(constructL(devsound, mode)); -} - -DevSoundCapabilities::~DevSoundCapabilities() -{ - m_fourCC.Close(); -} - -void DevSoundCapabilities::constructL(CMMFDevSound &devsound, - QAudio::Mode mode) -{ - m_caps = devsound.Capabilities(); - - TMMFPrioritySettings settings; - - switch (mode) { - case QAudio::AudioOutput: - settings.iState = EMMFStatePlaying; - devsound.GetSupportedInputDataTypesL(m_fourCC, settings); - break; - - case QAudio::AudioInput: - settings.iState = EMMFStateRecording; - devsound.GetSupportedInputDataTypesL(m_fourCC, settings); - break; - - default: - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); - } -} - -namespace Utils { - -//----------------------------------------------------------------------------- -// Static data -//----------------------------------------------------------------------------- - -// Sample rate / frequency - -typedef TMMFSampleRate SampleRateNative; -typedef int SampleRateQt; - -const int SampleRateCount = 12; - -const SampleRateNative SampleRateListNative[SampleRateCount] = { - EMMFSampleRate8000Hz - , EMMFSampleRate11025Hz - , EMMFSampleRate12000Hz - , EMMFSampleRate16000Hz - , EMMFSampleRate22050Hz - , EMMFSampleRate24000Hz - , EMMFSampleRate32000Hz - , EMMFSampleRate44100Hz - , EMMFSampleRate48000Hz - , EMMFSampleRate64000Hz - , EMMFSampleRate88200Hz - , EMMFSampleRate96000Hz -}; - -const SampleRateQt SampleRateListQt[SampleRateCount] = { - 8000 - , 11025 - , 12000 - , 16000 - , 22050 - , 24000 - , 32000 - , 44100 - , 48000 - , 64000 - , 88200 - , 96000 -}; - -// Channels - -typedef TMMFMonoStereo ChannelsNative; -typedef int ChannelsQt; - -const int ChannelsCount = 2; - -const ChannelsNative ChannelsListNative[ChannelsCount] = { - EMMFMono - , EMMFStereo -}; - -const ChannelsQt ChannelsListQt[ChannelsCount] = { - 1 - , 2 -}; - -// Encoding - -const int EncodingCount = 6; - -const TUint32 EncodingFourCC[EncodingCount] = { - KMMFFourCCCodePCM8 // 0 - , KMMFFourCCCodePCMU8 // 1 - , KMMFFourCCCodePCM16 // 2 - , KMMFFourCCCodePCMU16 // 3 - , KMMFFourCCCodePCM16B // 4 - , KMMFFourCCCodePCMU16B // 5 -}; - -// The characterised DevSound API specification states that the iEncoding -// field in TMMFCapabilities is ignored, and that the FourCC should be used -// to specify the PCM encoding. -// See "SGL.GT0287.102 Multimedia DevSound Baseline Compatibility.doc" in the -// mm_info/mm_docs repository. -const TMMFSoundEncoding EncodingNative[EncodingCount] = { - EMMFSoundEncoding16BitPCM // 0 - , EMMFSoundEncoding16BitPCM // 1 - , EMMFSoundEncoding16BitPCM // 2 - , EMMFSoundEncoding16BitPCM // 3 - , EMMFSoundEncoding16BitPCM // 4 - , EMMFSoundEncoding16BitPCM // 5 -}; - - -const int EncodingSampleSize[EncodingCount] = { - 8 // 0 - , 8 // 1 - , 16 // 2 - , 16 // 3 - , 16 // 4 - , 16 // 5 -}; - -const QAudioFormat::Endian EncodingByteOrder[EncodingCount] = { - QAudioFormat::LittleEndian // 0 - , QAudioFormat::LittleEndian // 1 - , QAudioFormat::LittleEndian // 2 - , QAudioFormat::LittleEndian // 3 - , QAudioFormat::BigEndian // 4 - , QAudioFormat::BigEndian // 5 -}; - -const QAudioFormat::SampleType EncodingSampleType[EncodingCount] = { - QAudioFormat::SignedInt // 0 - , QAudioFormat::UnSignedInt // 1 - , QAudioFormat::SignedInt // 2 - , QAudioFormat::UnSignedInt // 3 - , QAudioFormat::SignedInt // 4 - , QAudioFormat::UnSignedInt // 5 -}; - - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -// Helper functions for implementing parameter conversions - -template -bool findValue(const Input *inputArray, int length, Input input, int &index) { - bool result = false; - for (int i=0; !result && i -bool convertValue(const Input *inputArray, const Output *outputArray, - int length, Input input, Output &output) { - int index; - const bool result = findValue(inputArray, length, input, index); - if (result) - output = outputArray[index]; - return result; -} - -/** - * Macro which is used to generate the implementation of the conversion - * functions. The implementation is just a wrapper around the templated - * convertValue function, e.g. - * - * CONVERSION_FUNCTION_IMPL(SampleRate, Qt, Native) - * - * expands to - * - * bool SampleRateQtToNative(int input, TMMFSampleRate &output) { - * return convertValue - * (SampleRateListQt, SampleRateListNative, SampleRateCount, - * input, output); - * } - */ -#define CONVERSION_FUNCTION_IMPL(FieldLc, Field, Input, Output) \ -bool FieldLc##Input##To##Output(Field##Input input, Field##Output &output) { \ - return convertValue(Field##List##Input, \ - Field##List##Output, Field##Count, input, output); \ -} - -//----------------------------------------------------------------------------- -// Local helper functions -//----------------------------------------------------------------------------- - -CONVERSION_FUNCTION_IMPL(sampleRate, SampleRate, Qt, Native) -CONVERSION_FUNCTION_IMPL(sampleRate, SampleRate, Native, Qt) -CONVERSION_FUNCTION_IMPL(channels, Channels, Qt, Native) -CONVERSION_FUNCTION_IMPL(channels, Channels, Native, Qt) - -bool sampleInfoQtToNative(int inputSampleSize, - QAudioFormat::Endian inputByteOrder, - QAudioFormat::SampleType inputSampleType, - TUint32 &outputFourCC, - TMMFSoundEncoding &outputEncoding) { - - bool found = false; - - for (int i=0; i &frequencies, - QList &channels, - QList &sampleSizes, - QList &byteOrders, - QList &sampleTypes) { - - frequencies.clear(); - sampleSizes.clear(); - byteOrders.clear(); - sampleTypes.clear(); - channels.clear(); - - for (int i=0; i -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace SymbianAudio { - -/** - * Default values used by audio input and output classes, when underlying - * DevSound instance has not yet been created. - */ - -const int DefaultBufferSize = 4096; // bytes -const int DefaultNotifyInterval = 1000; // ms - -/** - * Enumeration used to track state of internal DevSound instances. - * Values are translated to the corresponding QAudio::State values by - * SymbianAudio::Utils::stateNativeToQt. - */ -enum State { - ClosedState - , InitializingState - , ActiveState - , IdleState - , SuspendedState -}; - -/* - * Helper class for querying DevSound codec / format support - */ -class DevSoundCapabilities { -public: - DevSoundCapabilities(CMMFDevSound &devsound, QAudio::Mode mode); - ~DevSoundCapabilities(); - - const RArray& fourCC() const { return m_fourCC; } - const TMMFCapabilities& caps() const { return m_caps; } - -private: - void constructL(CMMFDevSound &devsound, QAudio::Mode mode); - -private: - RArray m_fourCC; - TMMFCapabilities m_caps; -}; - -namespace Utils { - -/** - * Convert native audio capabilities to QAudio lists. - */ -void capabilitiesNativeToQt(const DevSoundCapabilities &caps, - QList &frequencies, - QList &channels, - QList &sampleSizes, - QList &byteOrders, - QList &sampleTypes); - -/** - * Check whether format is supported. - */ -bool isFormatSupported(const QAudioFormat &format, - const DevSoundCapabilities &caps); - -/** - * Convert QAudioFormat to native format types. - * - * Note that, despite the name, DevSound uses TMMFCapabilities to specify - * single formats as well as capabilities. - * - * Note that this function does not modify outputFormat.iBufferSize. - */ -bool formatQtToNative(const QAudioFormat &inputFormat, - TUint32 &outputFourCC, - TMMFCapabilities &outputFormat); - -/** - * Convert internal states to QAudio states. - */ -QAudio::State stateNativeToQt(State nativeState, - QAudio::State initializingState); - -/** - * Convert data length to number of samples. - */ -qint64 bytesToSamples(const QAudioFormat &format, qint64 length); - -/** - * Convert number of samples to data length. - */ -qint64 samplesToBytes(const QAudioFormat &format, qint64 samples); - -} // namespace Utils -} // namespace SymbianAudio - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/multimedia/audio/qaudiodevicefactory.cpp deleted file mode 100644 index 96545b4..0000000 --- a/src/multimedia/multimedia/audio/qaudiodevicefactory.cpp +++ /dev/null @@ -1,275 +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 QtMultimedia 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 -#include -#include -#include -#include "qaudiodevicefactory_p.h" - -#ifndef QT_NO_AUDIO_BACKEND -#if defined(Q_OS_WIN) -#include "qaudiodeviceinfo_win32_p.h" -#include "qaudiooutput_win32_p.h" -#include "qaudioinput_win32_p.h" -#elif defined(Q_OS_MAC) -#include "qaudiodeviceinfo_mac_p.h" -#include "qaudiooutput_mac_p.h" -#include "qaudioinput_mac_p.h" -#elif defined(HAS_ALSA) -#include "qaudiodeviceinfo_alsa_p.h" -#include "qaudiooutput_alsa_p.h" -#include "qaudioinput_alsa_p.h" -#elif defined(Q_OS_SYMBIAN) -#include "qaudiodeviceinfo_symbian_p.h" -#include "qaudiooutput_symbian_p.h" -#include "qaudioinput_symbian_p.h" -#endif -#endif - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_LIBRARY -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, - (QAudioEngineFactoryInterface_iid, QLatin1String("/audio"), Qt::CaseInsensitive)) -#endif - -class QNullDeviceInfo : public QAbstractAudioDeviceInfo -{ -public: - QAudioFormat preferredFormat() const { qWarning()<<"using null deviceinfo, none available"; return QAudioFormat(); } - bool isFormatSupported(const QAudioFormat& ) const { return false; } - QAudioFormat nearestFormat(const QAudioFormat& ) const { return QAudioFormat(); } - QString deviceName() const { return QString(); } - QStringList codecList() { return QStringList(); } - QList frequencyList() { return QList(); } - QList channelsList() { return QList(); } - QList sampleSizeList() { return QList(); } - QList byteOrderList() { return QList(); } - QList sampleTypeList() { return QList(); } -}; - -class QNullInputDevice : public QAbstractAudioInput -{ -public: - QIODevice* start(QIODevice* ) { qWarning()<<"using null input device, none available"; return 0; } - void stop() {} - void reset() {} - void suspend() {} - void resume() {} - int bytesReady() const { return 0; } - int periodSize() const { return 0; } - void setBufferSize(int ) {} - int bufferSize() const { return 0; } - void setNotifyInterval(int ) {} - int notifyInterval() const { return 0; } - qint64 processedUSecs() const { return 0; } - qint64 elapsedUSecs() const { return 0; } - QAudio::Error error() const { return QAudio::OpenError; } - QAudio::State state() const { return QAudio::StoppedState; } - QAudioFormat format() const { return QAudioFormat(); } -}; - -class QNullOutputDevice : public QAbstractAudioOutput -{ -public: - QIODevice* start(QIODevice* ) { qWarning()<<"using null output device, none available"; return 0; } - void stop() {} - void reset() {} - void suspend() {} - void resume() {} - int bytesFree() const { return 0; } - int periodSize() const { return 0; } - void setBufferSize(int ) {} - int bufferSize() const { return 0; } - void setNotifyInterval(int ) {} - int notifyInterval() const { return 0; } - qint64 processedUSecs() const { return 0; } - qint64 elapsedUSecs() const { return 0; } - QAudio::Error error() const { return QAudio::OpenError; } - QAudio::State state() const { return QAudio::StoppedState; } - QAudioFormat format() const { return QAudioFormat(); } -}; - -QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) -{ - QList devices; -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) - foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode)) - devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); -#endif -#endif - -#ifndef QT_NO_LIBRARY - QFactoryLoader* l = loader(); - - foreach (QString const& key, l->keys()) { - QAudioEngineFactoryInterface* plugin = qobject_cast(l->instance(key)); - if (plugin) { - foreach (QByteArray const& handle, plugin->availableDevices(mode)) - devices << QAudioDeviceInfo(key, handle, mode); - } - - delete plugin; - } -#endif - - return devices; -} - -QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() -{ -#ifndef QT_NO_LIBRARY - QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); - - if (plugin) { - QList list = plugin->availableDevices(QAudio::AudioInput); - if (list.size() > 0) - return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput); - } -#endif - -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) - return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultInputDevice(), QAudio::AudioInput); -#endif -#endif - return QAudioDeviceInfo(); -} - -QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() -{ -#ifndef QT_NO_LIBRARY - QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); - - if (plugin) { - QList list = plugin->availableDevices(QAudio::AudioOutput); - if (list.size() > 0) - return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); - } -#endif - -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) - return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput); -#endif -#endif - return QAudioDeviceInfo(); -} - -QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode) -{ - QAbstractAudioDeviceInfo *rc = 0; - -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) - if (realm == QLatin1String("builtin")) - return new QAudioDeviceInfoInternal(handle, mode); -#endif -#endif - -#ifndef QT_NO_LIBRARY - QAudioEngineFactoryInterface* plugin = - qobject_cast(loader()->instance(realm)); - - if (plugin) - rc = plugin->createDeviceInfo(handle, mode); -#endif - - return rc == 0 ? new QNullDeviceInfo() : rc; -} - -QAbstractAudioInput* QAudioDeviceFactory::createDefaultInputDevice(QAudioFormat const &format) -{ - return createInputDevice(defaultInputDevice(), format); -} - -QAbstractAudioOutput* QAudioDeviceFactory::createDefaultOutputDevice(QAudioFormat const &format) -{ - return createOutputDevice(defaultOutputDevice(), format); -} - -QAbstractAudioInput* QAudioDeviceFactory::createInputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) -{ - if (deviceInfo.isNull()) - return new QNullInputDevice(); -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) - if (deviceInfo.realm() == QLatin1String("builtin")) - return new QAudioInputPrivate(deviceInfo.handle(), format); -#endif -#endif -#ifndef QT_NO_LIBRARY - QAudioEngineFactoryInterface* plugin = - qobject_cast(loader()->instance(deviceInfo.realm())); - - if (plugin) - return plugin->createInput(deviceInfo.handle(), format); -#endif - - return new QNullInputDevice(); -} - -QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) -{ - if (deviceInfo.isNull()) - return new QNullOutputDevice(); -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) - if (deviceInfo.realm() == QLatin1String("builtin")) - return new QAudioOutputPrivate(deviceInfo.handle(), format); -#endif -#endif - -#ifndef QT_NO_LIBRARY - QAudioEngineFactoryInterface* plugin = - qobject_cast(loader()->instance(deviceInfo.realm())); - - if (plugin) - return plugin->createOutput(deviceInfo.handle(), format); -#endif - - return new QNullOutputDevice(); -} - -QT_END_NAMESPACE - diff --git a/src/multimedia/multimedia/audio/qaudiodevicefactory_p.h b/src/multimedia/multimedia/audio/qaudiodevicefactory_p.h deleted file mode 100644 index 8ee8b05..0000000 --- a/src/multimedia/multimedia/audio/qaudiodevicefactory_p.h +++ /dev/null @@ -1,97 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIODEVICEFACTORY_P_H -#define QAUDIODEVICEFACTORY_P_H - -#include -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QAbstractAudioInput; -class QAbstractAudioOutput; -class QAbstractAudioDeviceInfo; - -class QAudioDeviceFactory -{ -public: - static QList availableDevices(QAudio::Mode mode); - - static QAudioDeviceInfo defaultInputDevice(); - static QAudioDeviceInfo defaultOutputDevice(); - - static QAbstractAudioDeviceInfo* audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); - - static QAbstractAudioInput* createDefaultInputDevice(QAudioFormat const &format); - static QAbstractAudioOutput* createDefaultOutputDevice(QAudioFormat const &format); - - static QAbstractAudioInput* createInputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format); - static QAbstractAudioOutput* createOutputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format); - - static QAbstractAudioInput* createNullInput(); - static QAbstractAudioOutput* createNullOutput(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIODEVICEFACTORY_P_H - diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/multimedia/audio/qaudiodeviceinfo.cpp deleted file mode 100644 index ff04b4e..0000000 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo.cpp +++ /dev/null @@ -1,400 +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 QtMultimedia 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 "qaudiodevicefactory_p.h" -#include -#include - - -QT_BEGIN_NAMESPACE - -class QAudioDeviceInfoPrivate : public QSharedData -{ -public: - QAudioDeviceInfoPrivate():info(0) {} - QAudioDeviceInfoPrivate(const QString &r, const QByteArray &h, QAudio::Mode m): - realm(r), handle(h), mode(m) - { - info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); - } - - QAudioDeviceInfoPrivate(const QAudioDeviceInfoPrivate &other): - QSharedData(other), - realm(other.realm), handle(other.handle), mode(other.mode) - { - info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); - } - - QAudioDeviceInfoPrivate& operator=(const QAudioDeviceInfoPrivate &other) - { - delete info; - - realm = other.realm; - handle = other.handle; - mode = other.mode; - info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); - return *this; - } - - ~QAudioDeviceInfoPrivate() - { - delete info; - } - - QString realm; - QByteArray handle; - QAudio::Mode mode; - QAbstractAudioDeviceInfo* info; -}; - - -/*! - \class QAudioDeviceInfo - \brief The QAudioDeviceInfo class provides an interface to query audio devices and their functionality. - \inmodule QtMultimedia - \ingroup multimedia - - \since 4.6 - - QAudioDeviceInfo lets you query for audio devices--such as sound - cards and USB headsets--that are currently available on the system. - The audio devices available are dependent on the platform or audio plugins installed. - - You can also query each device for the formats it supports. A - format in this context is a set consisting of a specific byte - order, channel, codec, frequency, sample rate, and sample type. A - format is represented by the QAudioFormat class. - - The values supported by the the device for each of these - parameters can be fetched with - supportedByteOrders(), supportedChannelCounts(), supportedCodecs(), - supportedSampleRates(), supportedSampleSizes(), and - supportedSampleTypes(). The combinations supported are dependent on the platform, - audio plugins installed and the audio device capabilities. If you need a specific format, you can check if - the device supports it with isFormatSupported(), or fetch a - supported format that is as close as possible to the format with - nearestFormat(). For instance: - - \snippet doc/src/snippets/audio/main.cpp 1 - \dots 8 - \snippet doc/src/snippets/audio/main.cpp 2 - - A QAudioDeviceInfo is used by Qt to construct - classes that communicate with the device--such as - QAudioInput, and QAudioOutput. The static - functions defaultInputDevice(), defaultOutputDevice(), and - availableDevices() let you get a list of all available - devices. Devices are fetch according to the value of mode - this is specified by the QAudio::Mode enum. - The QAudioDeviceInfo returned are only valid for the QAudio::Mode. - - For instance: - - \code - foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) - qDebug() << "Device name: " << deviceInfo.deviceName(); - \endcode - - In this code sample, we loop through all devices that are able to output - sound, i.e., play an audio stream in a supported format. For each device we - find, we simply print the deviceName(). - - \sa QAudioOutput, QAudioInput -*/ - -/*! - Constructs an empty QAudioDeviceInfo object. -*/ - -QAudioDeviceInfo::QAudioDeviceInfo(): - d(new QAudioDeviceInfoPrivate) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QAudioDeviceInfo::QAudioDeviceInfo(const QAudioDeviceInfo& other): - d(other.d) -{ -} - -/*! - Destroy this audio device info. -*/ - -QAudioDeviceInfo::~QAudioDeviceInfo() -{ -} - -/*! - Sets the QAudioDeviceInfo object to be equal to \a other. -*/ - -QAudioDeviceInfo& QAudioDeviceInfo::operator=(const QAudioDeviceInfo &other) -{ - d = other.d; - return *this; -} - -/*! - Returns whether this QAudioDeviceInfo object holds a device definition. -*/ - -bool QAudioDeviceInfo::isNull() const -{ - return d->info == 0; -} - -/*! - Returns human readable name of audio device. - - Device names vary depending on platform/audio plugin being used. - - They are a unique string identifiers for the audio device. - - eg. default, Intel, U0x46d0x9a4 -*/ - -QString QAudioDeviceInfo::deviceName() const -{ - return isNull() ? QString() : d->info->deviceName(); -} - -/*! - Returns true if \a settings are supported by the audio device of this QAudioDeviceInfo. -*/ - -bool QAudioDeviceInfo::isFormatSupported(const QAudioFormat &settings) const -{ - return isNull() ? false : d->info->isFormatSupported(settings); -} - -/*! - Returns QAudioFormat of default settings. - - These settings are provided by the platform/audio plugin being used. - - They also are dependent on the QAudio::Mode being used. - - A typical audio system would provide something like: - \list - \o Input settings: 8000Hz mono 8 bit. - \o Output settings: 44100Hz stereo 16 bit little endian. - \endlist -*/ - -QAudioFormat QAudioDeviceInfo::preferredFormat() const -{ - return isNull() ? QAudioFormat() : d->info->preferredFormat(); -} - -/*! - Returns closest QAudioFormat to \a settings that system audio supports. - - These settings are provided by the platform/audio plugin being used. - - They also are dependent on the QAudio::Mode being used. -*/ - -QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const -{ - return isNull() ? QAudioFormat() : d->info->nearestFormat(settings); -} - -/*! - Returns a list of supported codecs. - - All platform and plugin implementations should provide support for: - - "audio/pcm" - Linear PCM - - For writing plugins to support additional codecs refer to: - - http://www.iana.org/assignments/media-types/audio/ -*/ - -QStringList QAudioDeviceInfo::supportedCodecs() const -{ - return isNull() ? QStringList() : d->info->codecList(); -} - -/*! - Returns a list of supported sample rates. - - \since 4.7 -*/ - -QList QAudioDeviceInfo::supportedSampleRates() const -{ - return supportedFrequencies(); -} - -/*! - \obsolete - - Use supportedSampleRates() instead. -*/ - -QList QAudioDeviceInfo::supportedFrequencies() const -{ - return isNull() ? QList() : d->info->frequencyList(); -} - -/*! - Returns a list of supported channel counts. - - \since 4.7 -*/ - -QList QAudioDeviceInfo::supportedChannelCounts() const -{ - return supportedChannels(); -} - -/*! - \obsolete - - Use supportedChannelCount() instead. -*/ - -QList QAudioDeviceInfo::supportedChannels() const -{ - return isNull() ? QList() : d->info->channelsList(); -} - -/*! - Returns a list of supported sample sizes. -*/ - -QList QAudioDeviceInfo::supportedSampleSizes() const -{ - return isNull() ? QList() : d->info->sampleSizeList(); -} - -/*! - Returns a list of supported byte orders. -*/ - -QList QAudioDeviceInfo::supportedByteOrders() const -{ - return isNull() ? QList() : d->info->byteOrderList(); -} - -/*! - Returns a list of supported sample types. -*/ - -QList QAudioDeviceInfo::supportedSampleTypes() const -{ - return isNull() ? QList() : d->info->sampleTypeList(); -} - -/*! - Returns the name of the default input audio device. - All platform and audio plugin implementations provide a default audio device to use. -*/ - -QAudioDeviceInfo QAudioDeviceInfo::defaultInputDevice() -{ - return QAudioDeviceFactory::defaultInputDevice(); -} - -/*! - Returns the name of the default output audio device. - All platform and audio plugin implementations provide a default audio device to use. -*/ - -QAudioDeviceInfo QAudioDeviceInfo::defaultOutputDevice() -{ - return QAudioDeviceFactory::defaultOutputDevice(); -} - -/*! - Returns a list of audio devices that support \a mode. -*/ - -QList QAudioDeviceInfo::availableDevices(QAudio::Mode mode) -{ - return QAudioDeviceFactory::availableDevices(mode); -} - - -/*! - \internal -*/ - -QAudioDeviceInfo::QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode): - d(new QAudioDeviceInfoPrivate(realm, handle, mode)) -{ -} - -/*! - \internal -*/ - -QString QAudioDeviceInfo::realm() const -{ - return d->realm; -} - -/*! - \internal -*/ - -QByteArray QAudioDeviceInfo::handle() const -{ - return d->handle; -} - - -/*! - \internal -*/ - -QAudio::Mode QAudioDeviceInfo::mode() const -{ - return d->mode; -} - -QT_END_NAMESPACE - diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/multimedia/audio/qaudiodeviceinfo.h deleted file mode 100644 index 1cc0731..0000000 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo.h +++ /dev/null @@ -1,114 +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 QtMultimedia 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 QAUDIODEVICEINFO_H -#define QAUDIODEVICEINFO_H - -#include -#include -#include -#include -#include -#include - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QAudioDeviceFactory; - -class QAudioDeviceInfoPrivate; -class Q_MULTIMEDIA_EXPORT QAudioDeviceInfo -{ - friend class QAudioDeviceFactory; - -public: - QAudioDeviceInfo(); - QAudioDeviceInfo(const QAudioDeviceInfo& other); - ~QAudioDeviceInfo(); - - QAudioDeviceInfo& operator=(const QAudioDeviceInfo& other); - - bool isNull() const; - - QString deviceName() const; - - bool isFormatSupported(const QAudioFormat &format) const; - QAudioFormat preferredFormat() const; - QAudioFormat nearestFormat(const QAudioFormat &format) const; - - QStringList supportedCodecs() const; - QList supportedFrequencies() const; - QList supportedSampleRates() const; - QList supportedChannels() const; - QList supportedChannelCounts() const; - QList supportedSampleSizes() const; - QList supportedByteOrders() const; - QList supportedSampleTypes() const; - - static QAudioDeviceInfo defaultInputDevice(); - static QAudioDeviceInfo defaultOutputDevice(); - - static QList availableDevices(QAudio::Mode mode); - -private: - QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); - QString realm() const; - QByteArray handle() const; - QAudio::Mode mode() const; - - QSharedDataPointer d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -Q_DECLARE_METATYPE(QAudioDeviceInfo) - -#endif // QAUDIODEVICEINFO_H diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp deleted file mode 100644 index 36270a7..0000000 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ /dev/null @@ -1,486 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qaudiodeviceinfo_alsa_p.h" - -#include - -QT_BEGIN_NAMESPACE - -QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) -{ - handle = 0; - - device = QLatin1String(dev); - this->mode = mode; -} - -QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() -{ - close(); -} - -bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const -{ - return testSettings(format); -} - -QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const -{ - QAudioFormat nearest; - if(mode == QAudio::AudioOutput) { - nearest.setFrequency(44100); - nearest.setChannels(2); - nearest.setByteOrder(QAudioFormat::LittleEndian); - nearest.setSampleType(QAudioFormat::SignedInt); - nearest.setSampleSize(16); - nearest.setCodec(QLatin1String("audio/pcm")); - } else { - nearest.setFrequency(8000); - nearest.setChannels(1); - nearest.setSampleType(QAudioFormat::UnSignedInt); - nearest.setSampleSize(8); - nearest.setCodec(QLatin1String("audio/pcm")); - if(!testSettings(nearest)) { - nearest.setChannels(2); - nearest.setSampleSize(16); - nearest.setSampleType(QAudioFormat::SignedInt); - } - } - return nearest; -} - -QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) const -{ - if(testSettings(format)) - return format; - else - return preferredFormat(); -} - -QString QAudioDeviceInfoInternal::deviceName() const -{ - return device; -} - -QStringList QAudioDeviceInfoInternal::codecList() -{ - updateLists(); - return codecz; -} - -QList QAudioDeviceInfoInternal::frequencyList() -{ - updateLists(); - return freqz; -} - -QList QAudioDeviceInfoInternal::channelsList() -{ - updateLists(); - return channelz; -} - -QList QAudioDeviceInfoInternal::sampleSizeList() -{ - updateLists(); - return sizez; -} - -QList QAudioDeviceInfoInternal::byteOrderList() -{ - updateLists(); - return byteOrderz; -} - -QList QAudioDeviceInfoInternal::sampleTypeList() -{ - updateLists(); - return typez; -} - -bool QAudioDeviceInfoInternal::open() -{ - int err = 0; - QString dev = device; - QList devices = availableDevices(mode); - - if(dev.compare(QLatin1String("default")) == 0) { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = QLatin1String(devices.first().constData()); -#else - dev = QLatin1String("hw:0,0"); -#endif - } else { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = device; -#else - int idx = 0; - char *name; - - QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1); - - while(snd_card_get_name(idx,&name) == 0) { - if(dev.contains(QLatin1String(name))) - break; - idx++; - } - dev = QString(QLatin1String("hw:%1,0")).arg(idx); -#endif - } - if(mode == QAudio::AudioOutput) { - err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); - } else { - err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); - } - if(err < 0) { - handle = 0; - return false; - } - return true; -} - -void QAudioDeviceInfoInternal::close() -{ - if(handle) - snd_pcm_close(handle); - handle = 0; -} - -bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const -{ - // Set nearest to closest settings that do work. - // See if what is in settings will work (return value). - int err = 0; - snd_pcm_t* handle; - snd_pcm_hw_params_t *params; - QString dev = device; - - QList devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); - - if(dev.compare(QLatin1String("default")) == 0) { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = QLatin1String(devices.first().constData()); -#else - dev = QLatin1String("hw:0,0"); -#endif - } else { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = device; -#else - int idx = 0; - char *name; - - QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1); - - while(snd_card_get_name(idx,&name) == 0) { - if(shortName.compare(QLatin1String(name)) == 0) - break; - idx++; - } - dev = QString(QLatin1String("hw:%1,0")).arg(idx); -#endif - } - if(mode == QAudio::AudioOutput) { - err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); - } else { - err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); - } - if(err < 0) { - handle = 0; - return false; - } - - bool testChannel = false; - bool testCodec = false; - bool testFreq = false; - bool testType = false; - bool testSize = false; - - int dir = 0; - - snd_pcm_nonblock( handle, 0 ); - snd_pcm_hw_params_alloca( ¶ms ); - snd_pcm_hw_params_any( handle, params ); - - // set the values! - snd_pcm_hw_params_set_channels(handle,params,format.channels()); - snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); - switch(format.sampleSize()) { - case 8: - if(format.sampleType() == QAudioFormat::SignedInt) - snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8); - else if(format.sampleType() == QAudioFormat::UnSignedInt) - snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8); - break; - case 16: - if(format.sampleType() == QAudioFormat::SignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE); - } else if(format.sampleType() == QAudioFormat::UnSignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE); - } - break; - case 32: - if(format.sampleType() == QAudioFormat::SignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE); - } else if(format.sampleType() == QAudioFormat::UnSignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE); - } - } - - // For now, just accept only audio/pcm codec - if(!format.codec().startsWith(QLatin1String("audio/pcm"))) { - err=-1; - } else - testCodec = true; - - if(err>=0 && format.channels() != -1) { - err = snd_pcm_hw_params_test_channels(handle,params,format.channels()); - if(err>=0) - err = snd_pcm_hw_params_set_channels(handle,params,format.channels()); - if(err>=0) - testChannel = true; - } - - if(err>=0 && format.frequency() != -1) { - err = snd_pcm_hw_params_test_rate(handle,params,format.frequency(),0); - if(err>=0) - err = snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); - if(err>=0) - testFreq = true; - } - - if((err>=0 && format.sampleSize() != -1) && - (format.sampleType() != QAudioFormat::Unknown)) { - switch(format.sampleSize()) { - case 8: - if(format.sampleType() == QAudioFormat::SignedInt) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8); - else if(format.sampleType() == QAudioFormat::UnSignedInt) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8); - break; - case 16: - if(format.sampleType() == QAudioFormat::SignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE); - } else if(format.sampleType() == QAudioFormat::UnSignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE); - } - break; - case 32: - if(format.sampleType() == QAudioFormat::SignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE); - } else if(format.sampleType() == QAudioFormat::UnSignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE); - } - } - if(err>=0) { - testSize = true; - testType = true; - } - } - if(err>=0) - err = snd_pcm_hw_params(handle, params); - - if(err == 0) { - // settings work - // close() - if(handle) - snd_pcm_close(handle); - return true; - } - if(handle) - snd_pcm_close(handle); - - return false; -} - -void QAudioDeviceInfoInternal::updateLists() -{ - // redo all lists based on current settings - freqz.clear(); - channelz.clear(); - sizez.clear(); - byteOrderz.clear(); - typez.clear(); - codecz.clear(); - - if(!handle) - open(); - - if(!handle) - return; - - for(int i=0; i<(int)MAX_SAMPLE_RATES; i++) { - //if(snd_pcm_hw_params_test_rate(handle, params, SAMPLE_RATES[i], dir) == 0) - freqz.append(SAMPLE_RATES[i]); - } - channelz.append(1); - channelz.append(2); - sizez.append(8); - sizez.append(16); - sizez.append(32); - byteOrderz.append(QAudioFormat::LittleEndian); - byteOrderz.append(QAudioFormat::BigEndian); - typez.append(QAudioFormat::SignedInt); - typez.append(QAudioFormat::UnSignedInt); - typez.append(QAudioFormat::Float); - codecz.append(QLatin1String("audio/pcm")); - close(); -} - -QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) -{ - QList allDevices; - QList devices; - QByteArray filter; - -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - // Create a list of all current audio devices that support mode - void **hints, **n; - char *name, *descr, *io; - - if(snd_device_name_hint(-1, "pcm", &hints) < 0) { - qWarning() << "no alsa devices available"; - return devices; - } - n = hints; - - if(mode == QAudio::AudioInput) { - filter = "Input"; - } else { - filter = "Output"; - } - - while (*n != NULL) { - name = snd_device_name_get_hint(*n, "NAME"); - descr = snd_device_name_get_hint(*n, "DESC"); - io = snd_device_name_get_hint(*n, "IOID"); - if((name != NULL) && (descr != NULL) && ((io == NULL) || (io == filter))) { - QString deviceName = QLatin1String(name); - QString deviceDescription = QLatin1String(descr); - allDevices.append(deviceName.toLocal8Bit().constData()); - if(deviceDescription.contains(QLatin1String("Default Audio Device"))) - devices.append(deviceName.toLocal8Bit().constData()); - } - if(name != NULL) - free(name); - if(descr != NULL) - free(descr); - if(io != NULL) - free(io); - ++n; - } - snd_device_name_free_hint(hints); - - if(devices.size() > 0) { - devices.append("default"); - } -#else - int idx = 0; - char* name; - - while(snd_card_get_name(idx,&name) == 0) { - devices.append(name); - idx++; - } - if (idx > 0) - devices.append("default"); -#endif - if (devices.size() == 0 && allDevices.size() > 0) - return allDevices; - - return devices; -} - -QByteArray QAudioDeviceInfoInternal::defaultInputDevice() -{ - QList devices = availableDevices(QAudio::AudioInput); - if(devices.size() == 0) - return QByteArray(); - - return devices.first(); -} - -QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() -{ - QList devices = availableDevices(QAudio::AudioOutput); - if(devices.size() == 0) - return QByteArray(); - - return devices.first(); -} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.h deleted file mode 100644 index 6f9a459..0000000 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.h +++ /dev/null @@ -1,117 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QAUDIODEVICEINFOALSA_H -#define QAUDIODEVICEINFOALSA_H - -#include - -#include -#include -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -const unsigned int MAX_SAMPLE_RATES = 5; -const unsigned int SAMPLE_RATES[] = - { 8000, 11025, 22050, 44100, 48000 }; - -class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo -{ - Q_OBJECT -public: - QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); - ~QAudioDeviceInfoInternal(); - - bool testSettings(const QAudioFormat& format) const; - void updateLists(); - QAudioFormat preferredFormat() const; - bool isFormatSupported(const QAudioFormat& format) const; - QAudioFormat nearestFormat(const QAudioFormat& format) const; - QString deviceName() const; - QStringList codecList(); - QList frequencyList(); - QList channelsList(); - QList sampleSizeList(); - QList byteOrderList(); - QList sampleTypeList(); - static QByteArray defaultInputDevice(); - static QByteArray defaultOutputDevice(); - static QList availableDevices(QAudio::Mode); - -private: - bool open(); - void close(); - - QString device; - QAudio::Mode mode; - QAudioFormat nearest; - QList freqz; - QList channelz; - QList sizez; - QList byteOrderz; - QStringList codecz; - QList typez; - snd_pcm_t* handle; - snd_pcm_hw_params_t *params; -}; - -QT_END_NAMESPACE - -#endif - diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.cpp deleted file mode 100644 index ecd03e5..0000000 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ /dev/null @@ -1,357 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include -#include -#include - -#include -#include "qaudio_mac_p.h" -#include "qaudiodeviceinfo_mac_p.h" - - - -QT_BEGIN_NAMESPACE - - -QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray const& handle, QAudio::Mode) -{ - QDataStream ds(handle); - quint32 did, tm; - - ds >> did >> tm >> name; - deviceId = AudioDeviceID(did); - mode = QAudio::Mode(tm); -} - -bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const -{ - return format.codec() == QString::fromLatin1("audio/pcm"); -} - -QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const -{ - QAudioFormat rc; - - UInt32 propSize = 0; - - if (AudioDeviceGetPropertyInfo(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyStreams, - &propSize, - 0) == noErr) { - - const int sc = propSize / sizeof(AudioStreamID); - - if (sc > 0) { - AudioStreamID* streams = new AudioStreamID[sc]; - - if (AudioDeviceGetProperty(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyStreams, - &propSize, - streams) == noErr) { - - for (int i = 0; i < sc; ++i) { - if (AudioStreamGetPropertyInfo(streams[i], - 0, - kAudioStreamPropertyPhysicalFormat, - &propSize, - 0) == noErr) { - - AudioStreamBasicDescription sf; - - if (AudioStreamGetProperty(streams[i], - 0, - kAudioStreamPropertyPhysicalFormat, - &propSize, - &sf) == noErr) { - rc = toQAudioFormat(sf); - break; - } - } - } - } - - delete streams; - } - } - - return rc; -} - -QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) const -{ - QAudioFormat rc(format); - QAudioFormat target = preferredFormat(); - - if (!format.codec().isEmpty() && format.codec() != QString::fromLatin1("audio/pcm")) - return QAudioFormat(); - - rc.setCodec(QString::fromLatin1("audio/pcm")); - - if (rc.frequency() != target.frequency()) - rc.setFrequency(target.frequency()); - if (rc.channels() != target.channels()) - rc.setChannels(target.channels()); - if (rc.sampleSize() != target.sampleSize()) - rc.setSampleSize(target.sampleSize()); - if (rc.byteOrder() != target.byteOrder()) - rc.setByteOrder(target.byteOrder()); - if (rc.sampleType() != target.sampleType()) - rc.setSampleType(target.sampleType()); - - return rc; -} - -QString QAudioDeviceInfoInternal::deviceName() const -{ - return name; -} - -QStringList QAudioDeviceInfoInternal::codecList() -{ - return QStringList() << QString::fromLatin1("audio/pcm"); -} - -QList QAudioDeviceInfoInternal::frequencyList() -{ - QSet rc; - - // Add some common frequencies - rc << 8000 << 11025 << 22050 << 44100; - - // - UInt32 propSize = 0; - - if (AudioDeviceGetPropertyInfo(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyAvailableNominalSampleRates, - &propSize, - 0) == noErr) { - - const int pc = propSize / sizeof(AudioValueRange); - - if (pc > 0) { - AudioValueRange* vr = new AudioValueRange[pc]; - - if (AudioDeviceGetProperty(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyAvailableNominalSampleRates, - &propSize, - vr) == noErr) { - - for (int i = 0; i < pc; ++i) - rc << vr[i].mMaximum; - } - - delete vr; - } - } - - return rc.toList(); -} - -QList QAudioDeviceInfoInternal::channelsList() -{ - QList rc; - - // Can mix down to 1 channel - rc << 1; - - UInt32 propSize = 0; - int channels = 0; - - if (AudioDeviceGetPropertyInfo(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyStreamConfiguration, - &propSize, - 0) == noErr) { - - AudioBufferList* audioBufferList = static_cast(qMalloc(propSize)); - - if (audioBufferList != 0) { - if (AudioDeviceGetProperty(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyStreamConfiguration, - &propSize, - audioBufferList) == noErr) { - - for (int i = 0; i < int(audioBufferList->mNumberBuffers); ++i) { - channels += audioBufferList->mBuffers[i].mNumberChannels; - rc << channels; - } - } - - qFree(audioBufferList); - } - } - - return rc; -} - -QList QAudioDeviceInfoInternal::sampleSizeList() -{ - return QList() << 8 << 16 << 24 << 32 << 64; -} - -QList QAudioDeviceInfoInternal::byteOrderList() -{ - return QList() << QAudioFormat::LittleEndian << QAudioFormat::BigEndian; -} - -QList QAudioDeviceInfoInternal::sampleTypeList() -{ - return QList() << QAudioFormat::SignedInt << QAudioFormat::UnSignedInt << QAudioFormat::Float; -} - -static QByteArray get_device_info(AudioDeviceID audioDevice, QAudio::Mode mode) -{ - UInt32 size; - QByteArray device; - QDataStream ds(&device, QIODevice::WriteOnly); - AudioStreamBasicDescription sf; - CFStringRef name; - Boolean isInput = mode == QAudio::AudioInput; - - // Id - ds << quint32(audioDevice); - - // Mode - size = sizeof(AudioStreamBasicDescription); - if (AudioDeviceGetProperty(audioDevice, 0, isInput, kAudioDevicePropertyStreamFormat, - &size, &sf) != noErr) { - return QByteArray(); - } - ds << quint32(mode); - - // Name - size = sizeof(CFStringRef); - if (AudioDeviceGetProperty(audioDevice, 0, isInput, kAudioObjectPropertyName, - &size, &name) != noErr) { - qWarning() << "QAudioDeviceInfo: Unable to find device name"; - } - ds << QCFString::toQString(name); - - CFRelease(name); - - return device; -} - -QByteArray QAudioDeviceInfoInternal::defaultInputDevice() -{ - AudioDeviceID audioDevice; - UInt32 size = sizeof(audioDevice); - - if (AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &size, - &audioDevice) != noErr) { - qWarning() << "QAudioDeviceInfo: Unable to find default input device"; - return QByteArray(); - } - - return get_device_info(audioDevice, QAudio::AudioInput); -} - -QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() -{ - AudioDeviceID audioDevice; - UInt32 size = sizeof(audioDevice); - - if (AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, - &audioDevice) != noErr) { - qWarning() << "QAudioDeviceInfo: Unable to find default output device"; - return QByteArray(); - } - - return get_device_info(audioDevice, QAudio::AudioOutput); -} - -QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) -{ - QList devices; - - UInt32 propSize = 0; - - if (AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propSize, 0) == noErr) { - - const int dc = propSize / sizeof(AudioDeviceID); - - if (dc > 0) { - AudioDeviceID* audioDevices = new AudioDeviceID[dc]; - - if (AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propSize, audioDevices) == noErr) { - for (int i = 0; i < dc; ++i) { - QByteArray info = get_device_info(audioDevices[i], mode); - if (!info.isNull()) - devices << info; - } - } - - delete audioDevices; - } - } - - return devices; -} - - -QT_END_NAMESPACE - diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.h b/src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.h deleted file mode 100644 index e234384..0000000 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.h +++ /dev/null @@ -1,97 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QDEVICEINFO_MAC_P_H -#define QDEVICEINFO_MAC_P_H - -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo -{ -public: - AudioDeviceID deviceId; - QString name; - QAudio::Mode mode; - - QAudioDeviceInfoInternal(QByteArray const& handle, QAudio::Mode mode); - - bool isFormatSupported(const QAudioFormat& format) const; - QAudioFormat preferredFormat() const; - QAudioFormat nearestFormat(const QAudioFormat& format) const; - - QString deviceName() const; - - QStringList codecList(); - QList frequencyList(); - QList channelsList(); - QList sampleSizeList(); - QList byteOrderList(); - QList sampleTypeList(); - - static QByteArray defaultInputDevice(); - static QByteArray defaultOutputDevice(); - - static QList availableDevices(QAudio::Mode mode); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDEVICEINFO_MAC_P_H diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp b/src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp deleted file mode 100644 index 36284d3..0000000 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp +++ /dev/null @@ -1,200 +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 QtMultimedia 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 "qaudiodeviceinfo_symbian_p.h" -#include "qaudio_symbian_p.h" - -QT_BEGIN_NAMESPACE - -QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray device, - QAudio::Mode mode) - : m_deviceName(QLatin1String(device)) - , m_mode(mode) - , m_updated(false) -{ - QT_TRAP_THROWING(m_devsound.reset(CMMFDevSound::NewL())); -} - -QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() -{ - -} - -QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const -{ - QAudioFormat format; - switch (m_mode) { - case QAudio::AudioOutput: - format.setFrequency(44100); - format.setChannels(2); - format.setSampleSize(16); - format.setByteOrder(QAudioFormat::LittleEndian); - format.setSampleType(QAudioFormat::SignedInt); - format.setCodec(QLatin1String("audio/pcm")); - break; - - case QAudio::AudioInput: - format.setFrequency(8000); - format.setChannels(1); - format.setSampleSize(16); - format.setByteOrder(QAudioFormat::LittleEndian); - format.setSampleType(QAudioFormat::SignedInt); - format.setCodec(QLatin1String("audio/pcm")); - break; - - default: - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); - } - - if (!isFormatSupported(format)) { - if (m_frequencies.size()) - format.setFrequency(m_frequencies[0]); - if (m_channels.size()) - format.setChannels(m_channels[0]); - if (m_sampleSizes.size()) - format.setSampleSize(m_sampleSizes[0]); - if (m_byteOrders.size()) - format.setByteOrder(m_byteOrders[0]); - if (m_sampleTypes.size()) - format.setSampleType(m_sampleTypes[0]); - } - - return format; -} - -bool QAudioDeviceInfoInternal::isFormatSupported( - const QAudioFormat &format) const -{ - getSupportedFormats(); - const bool supported = - m_codecs.contains(format.codec()) - && m_frequencies.contains(format.frequency()) - && m_channels.contains(format.channels()) - && m_sampleSizes.contains(format.sampleSize()) - && m_byteOrders.contains(format.byteOrder()) - && m_sampleTypes.contains(format.sampleType()); - - return supported; -} - -QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat &format) const -{ - if (isFormatSupported(format)) - return format; - else - return preferredFormat(); -} - -QString QAudioDeviceInfoInternal::deviceName() const -{ - return m_deviceName; -} - -QStringList QAudioDeviceInfoInternal::codecList() -{ - getSupportedFormats(); - return m_codecs; -} - -QList QAudioDeviceInfoInternal::frequencyList() -{ - getSupportedFormats(); - return m_frequencies; -} - -QList QAudioDeviceInfoInternal::channelsList() -{ - getSupportedFormats(); - return m_channels; -} - -QList QAudioDeviceInfoInternal::sampleSizeList() -{ - getSupportedFormats(); - return m_sampleSizes; -} - -QList QAudioDeviceInfoInternal::byteOrderList() -{ - getSupportedFormats(); - return m_byteOrders; -} - -QList QAudioDeviceInfoInternal::sampleTypeList() -{ - getSupportedFormats(); - return m_sampleTypes; -} - -QByteArray QAudioDeviceInfoInternal::defaultInputDevice() -{ - return QByteArray("default"); -} - -QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() -{ - return QByteArray("default"); -} - -QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode) -{ - QList result; - result += QByteArray("default"); - return result; -} - -void QAudioDeviceInfoInternal::getSupportedFormats() const -{ - if (!m_updated) { - QScopedPointer caps( - new SymbianAudio::DevSoundCapabilities(*m_devsound, m_mode)); - - SymbianAudio::Utils::capabilitiesNativeToQt(*caps, - m_frequencies, m_channels, m_sampleSizes, - m_byteOrders, m_sampleTypes); - - m_codecs.append(QLatin1String("audio/pcm")); - - m_updated = true; - } -} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.h b/src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.h deleted file mode 100644 index 89e539f..0000000 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.h +++ /dev/null @@ -1,107 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIODEVICEINFO_SYMBIAN_P_H -#define QAUDIODEVICEINFO_SYMBIAN_P_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QAudioDeviceInfoInternal - : public QAbstractAudioDeviceInfo -{ - Q_OBJECT - -public: - QAudioDeviceInfoInternal(QByteArray device, QAudio::Mode mode); - ~QAudioDeviceInfoInternal(); - - // QAbstractAudioDeviceInfo - QAudioFormat preferredFormat() const; - bool isFormatSupported(const QAudioFormat &format) const; - QAudioFormat nearestFormat(const QAudioFormat &format) const; - QString deviceName() const; - QStringList codecList(); - QList frequencyList(); - QList channelsList(); - QList sampleSizeList(); - QList byteOrderList(); - QList sampleTypeList(); - static QByteArray defaultInputDevice(); - static QByteArray defaultOutputDevice(); - static QList availableDevices(QAudio::Mode); - -private: - void getSupportedFormats() const; - -private: - QScopedPointer m_devsound; - - QString m_deviceName; - QAudio::Mode m_mode; - - // Mutable to allow lazy initialization when called from const-qualified - // public functions (isFormatSupported, nearestFormat) - mutable bool m_updated; - mutable QStringList m_codecs; - mutable QList m_frequencies; - mutable QList m_channels; - mutable QList m_sampleSizes; - mutable QList m_byteOrders; - mutable QList m_sampleTypes; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.cpp deleted file mode 100644 index aee0807..0000000 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ /dev/null @@ -1,433 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include -#include -#include "qaudiodeviceinfo_win32_p.h" - -QT_BEGIN_NAMESPACE - -// For mingw toolchain mmsystem.h only defines half the defines, so add if needed. -#ifndef WAVE_FORMAT_44M08 -#define WAVE_FORMAT_44M08 0x00000100 -#define WAVE_FORMAT_44S08 0x00000200 -#define WAVE_FORMAT_44M16 0x00000400 -#define WAVE_FORMAT_44S16 0x00000800 -#define WAVE_FORMAT_48M08 0x00001000 -#define WAVE_FORMAT_48S08 0x00002000 -#define WAVE_FORMAT_48M16 0x00004000 -#define WAVE_FORMAT_48S16 0x00008000 -#define WAVE_FORMAT_96M08 0x00010000 -#define WAVE_FORMAT_96S08 0x00020000 -#define WAVE_FORMAT_96M16 0x00040000 -#define WAVE_FORMAT_96S16 0x00080000 -#endif - - -QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) -{ - device = QLatin1String(dev); - this->mode = mode; - - updateLists(); -} - -QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() -{ - close(); -} - -bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const -{ - return testSettings(format); -} - -QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const -{ - QAudioFormat nearest; - if(mode == QAudio::AudioOutput) { - nearest.setFrequency(44100); - nearest.setChannelCount(2); - nearest.setByteOrder(QAudioFormat::LittleEndian); - nearest.setSampleType(QAudioFormat::SignedInt); - nearest.setSampleSize(16); - nearest.setCodec(QLatin1String("audio/pcm")); - } else { - nearest.setFrequency(11025); - nearest.setChannelCount(1); - nearest.setByteOrder(QAudioFormat::LittleEndian); - nearest.setSampleType(QAudioFormat::SignedInt); - nearest.setSampleSize(8); - nearest.setCodec(QLatin1String("audio/pcm")); - } - return nearest; -} - -QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) const -{ - if(testSettings(format)) - return format; - else - return preferredFormat(); -} - -QString QAudioDeviceInfoInternal::deviceName() const -{ - return device; -} - -QStringList QAudioDeviceInfoInternal::codecList() -{ - updateLists(); - return codecz; -} - -QList QAudioDeviceInfoInternal::frequencyList() -{ - updateLists(); - return freqz; -} - -QList QAudioDeviceInfoInternal::channelsList() -{ - updateLists(); - return channelz; -} - -QList QAudioDeviceInfoInternal::sampleSizeList() -{ - updateLists(); - return sizez; -} - -QList QAudioDeviceInfoInternal::byteOrderList() -{ - updateLists(); - return byteOrderz; -} - -QList QAudioDeviceInfoInternal::sampleTypeList() -{ - updateLists(); - return typez; -} - - -bool QAudioDeviceInfoInternal::open() -{ - return true; -} - -void QAudioDeviceInfoInternal::close() -{ -} - -bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const -{ - // Set nearest to closest settings that do work. - // See if what is in settings will work (return value). - - bool failed = false; - bool match = false; - - // check codec - for( int i = 0; i < codecz.count(); i++) { - if (format.codec() == codecz.at(i)) - match = true; - } - if (!match) failed = true; - - // check channel - match = false; - if (!failed) { - for( int i = 0; i < channelz.count(); i++) { - if (format.channels() == channelz.at(i)) { - match = true; - break; - } - } - } - if (!match) failed = true; - - // check frequency - match = false; - if (!failed) { - for( int i = 0; i < freqz.count(); i++) { - if (format.frequency() == freqz.at(i)) { - match = true; - break; - } - } - } - - // check sample size - match = false; - if (!failed) { - for( int i = 0; i < sizez.count(); i++) { - if (format.sampleSize() == sizez.at(i)) { - match = true; - break; - } - } - } - - // check byte order - match = false; - if (!failed) { - for( int i = 0; i < byteOrderz.count(); i++) { - if (format.byteOrder() == byteOrderz.at(i)) { - match = true; - break; - } - } - } - - // check sample type - match = false; - if (!failed) { - for( int i = 0; i < typez.count(); i++) { - if (format.sampleType() == typez.at(i)) { - match = true; - break; - } - } - } - - if(!failed) { - // settings work - return true; - } - return false; -} - -void QAudioDeviceInfoInternal::updateLists() -{ - // redo all lists based on current settings - bool base = false; - bool match = false; - DWORD fmt = NULL; - QString tmp; - - if(device.compare(QLatin1String("default")) == 0) - base = true; - - if(mode == QAudio::AudioOutput) { - WAVEOUTCAPS woc; - unsigned long iNumDevs,i; - iNumDevs = waveOutGetNumDevs(); - for(i=0;i 0) - freqz.prepend(8000); -} - -QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) -{ - Q_UNUSED(mode) - - QList devices; - - if(mode == QAudio::AudioOutput) { - WAVEOUTCAPS woc; - unsigned long iNumDevs,i; - iNumDevs = waveOutGetNumDevs(); - for(i=0;i 0) - devices.append("default"); - - return devices; -} - -QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() -{ - return QByteArray("default"); -} - -QByteArray QAudioDeviceInfoInternal::defaultInputDevice() -{ - return QByteArray("default"); -} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.h b/src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.h deleted file mode 100644 index cb6dd91..0000000 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.h +++ /dev/null @@ -1,112 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QAUDIODEVICEINFOWIN_H -#define QAUDIODEVICEINFOWIN_H - -#include -#include -#include -#include - -#include -#include - - -QT_BEGIN_NAMESPACE - -const unsigned int MAX_SAMPLE_RATES = 5; -const unsigned int SAMPLE_RATES[] = { 8000, 11025, 22050, 44100, 48000 }; - -class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo -{ - Q_OBJECT - -public: - QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); - ~QAudioDeviceInfoInternal(); - - bool open(); - void close(); - - bool testSettings(const QAudioFormat& format) const; - void updateLists(); - QAudioFormat preferredFormat() const; - bool isFormatSupported(const QAudioFormat& format) const; - QAudioFormat nearestFormat(const QAudioFormat& format) const; - QString deviceName() const; - QStringList codecList(); - QList frequencyList(); - QList channelsList(); - QList sampleSizeList(); - QList byteOrderList(); - QList sampleTypeList(); - static QByteArray defaultInputDevice(); - static QByteArray defaultOutputDevice(); - static QList availableDevices(QAudio::Mode); - -private: - QAudio::Mode mode; - QString device; - QAudioFormat nearest; - QList freqz; - QList channelz; - QList sizez; - QList byteOrderz; - QStringList codecz; - QList typez; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/multimedia/audio/qaudioengine.cpp b/src/multimedia/multimedia/audio/qaudioengine.cpp deleted file mode 100644 index 7f1f5d3..0000000 --- a/src/multimedia/multimedia/audio/qaudioengine.cpp +++ /dev/null @@ -1,343 +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 QtMultimedia 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 - -QT_BEGIN_NAMESPACE - -/*! - \class QAbstractAudioDeviceInfo - \brief The QAbstractAudioDeviceInfo class provides access for QAudioDeviceInfo to access the audio - device provided by the plugin. - \internal - - \ingroup multimedia - - This class implements the audio functionality for - QAudioDeviceInfo, i.e., QAudioDeviceInfo keeps a - QAbstractAudioDeviceInfo and routes function calls to it. For a - description of the functionality that QAbstractAudioDeviceInfo - implements, you can read the class and functions documentation of - QAudioDeviceInfo. - - \sa QAudioDeviceInfo -*/ - -/*! - \fn virtual QAudioFormat QAbstractAudioDeviceInfo::preferredFormat() const - Returns the nearest settings. -*/ - -/*! - \fn virtual bool QAbstractAudioDeviceInfo::isFormatSupported(const QAudioFormat& format) const - Returns true if \a format is available from audio device. -*/ - -/*! - \fn virtual QAudioFormat QAbstractAudioDeviceInfo::nearestFormat(const QAudioFormat& format) const - Returns the nearest settings \a format. -*/ - -/*! - \fn virtual QString QAbstractAudioDeviceInfo::deviceName() const - Returns the audio device name. -*/ - -/*! - \fn virtual QStringList QAbstractAudioDeviceInfo::codecList() - Returns the list of currently available codecs. -*/ - -/*! - \fn virtual QList QAbstractAudioDeviceInfo::frequencyList() - Returns the list of currently available frequencies. -*/ - -/*! - \fn virtual QList QAbstractAudioDeviceInfo::channelsList() - Returns the list of currently available channels. -*/ - -/*! - \fn virtual QList QAbstractAudioDeviceInfo::sampleSizeList() - Returns the list of currently available sample sizes. -*/ - -/*! - \fn virtual QList QAbstractAudioDeviceInfo::byteOrderList() - Returns the list of currently available byte orders. -*/ - -/*! - \fn virtual QList QAbstractAudioDeviceInfo::sampleTypeList() - Returns the list of currently available sample types. -*/ - -/*! - \class QAbstractAudioOutput - \brief The QAbstractAudioOutput class provides access for QAudioOutput to access the audio - device provided by the plugin. - \internal - - \ingroup multimedia - - QAbstractAudioOutput implements audio functionality for - QAudioOutput, i.e., QAudioOutput routes function calls to - QAbstractAudioOutput. For a description of the functionality that - is implemented, see the QAudioOutput class and function - descriptions. - - \sa QAudioOutput -*/ - -/*! - \fn virtual QIODevice* QAbstractAudioOutput::start(QIODevice* device) - Uses the \a device as the QIODevice to transfer data. If \a device is null then the class - creates an internal QIODevice. Returns a pointer to the QIODevice being used to handle - the data transfer. This QIODevice can be used to write() audio data directly. Passing a - QIODevice allows the data to be transfered without any extra code. -*/ - -/*! - \fn virtual void QAbstractAudioOutput::stop() - Stops the audio output. -*/ - -/*! - \fn virtual void QAbstractAudioOutput::reset() - Drops all audio data in the buffers, resets buffers to zero. -*/ - -/*! - \fn virtual void QAbstractAudioOutput::suspend() - Stops processing audio data, preserving buffered audio data. -*/ - -/*! - \fn virtual void QAbstractAudioOutput::resume() - Resumes processing audio data after a suspend() -*/ - -/*! - \fn virtual int QAbstractAudioOutput::bytesFree() const - Returns the free space available in bytes in the audio buffer. -*/ - -/*! - \fn virtual int QAbstractAudioOutput::periodSize() const - Returns the period size in bytes. -*/ - -/*! - \fn virtual void QAbstractAudioOutput::setBufferSize(int value) - Sets the audio buffer size to \a value in bytes. -*/ - -/*! - \fn virtual int QAbstractAudioOutput::bufferSize() const - Returns the audio buffer size in bytes. -*/ - -/*! - \fn virtual void QAbstractAudioOutput::setNotifyInterval(int ms) - Sets the interval for notify() signal to be emitted. This is based on the \a ms - of audio data processed not on actual real-time. The resolution of the timer - is platform specific. -*/ - -/*! - \fn virtual int QAbstractAudioOutput::notifyInterval() const - Returns the notify interval in milliseconds. -*/ - -/*! - \fn virtual qint64 QAbstractAudioOutput::processedUSecs() const - Returns the amount of audio data processed since start() was called in milliseconds. -*/ - -/*! - \fn virtual qint64 QAbstractAudioOutput::elapsedUSecs() const - Returns the milliseconds since start() was called, including time in Idle and suspend states. -*/ - -/*! - \fn virtual QAudio::Error QAbstractAudioOutput::error() const - Returns the error state. -*/ - -/*! - \fn virtual QAudio::State QAbstractAudioOutput::state() const - Returns the state of audio processing. -*/ - -/*! - \fn virtual QAudioFormat QAbstractAudioOutput::format() const - Returns the QAudioFormat being used. -*/ - -/*! - \fn QAbstractAudioOutput::stateChanged(QAudio::State state) - This signal is emitted when the device \a state has changed. -*/ - -/*! - \fn QAbstractAudioOutput::notify() - This signal is emitted when x ms of audio data has been processed - the interval set by setNotifyInterval(x). -*/ - - -/*! - \class QAbstractAudioInput - \brief The QAbstractAudioInput class provides access for QAudioInput to access the audio - device provided by the plugin. - \internal - - \ingroup multimedia - - QAudioDeviceInput keeps an instance of QAbstractAudioInput and - routes calls to functions of the same name to QAbstractAudioInput. - This means that it is QAbstractAudioInput that implements the - audio functionality. For a description of the functionality, see - the QAudioInput class description. - - \sa QAudioInput -*/ - -/*! - \fn virtual QIODevice* QAbstractAudioInput::start(QIODevice* device) - Uses the \a device as the QIODevice to transfer data. If \a device is null - then the class creates an internal QIODevice. Returns a pointer to the - QIODevice being used to handle the data transfer. This QIODevice can be used to - read() audio data directly. Passing a QIODevice allows the data to be transfered - without any extra code. -*/ - -/*! - \fn virtual void QAbstractAudioInput::stop() - Stops the audio input. -*/ - -/*! - \fn virtual void QAbstractAudioInput::reset() - Drops all audio data in the buffers, resets buffers to zero. -*/ - -/*! - \fn virtual void QAbstractAudioInput::suspend() - Stops processing audio data, preserving buffered audio data. -*/ - -/*! - \fn virtual void QAbstractAudioInput::resume() - Resumes processing audio data after a suspend(). -*/ - -/*! - \fn virtual int QAbstractAudioInput::bytesReady() const - Returns the amount of audio data available to read in bytes. -*/ - -/*! - \fn virtual int QAbstractAudioInput::periodSize() const - Returns the period size in bytes. -*/ - -/*! - \fn virtual void QAbstractAudioInput::setBufferSize(int value) - Sets the audio buffer size to \a value in milliseconds. -*/ - -/*! - \fn virtual int QAbstractAudioInput::bufferSize() const - Returns the audio buffer size in milliseconds. -*/ - -/*! - \fn virtual void QAbstractAudioInput::setNotifyInterval(int ms) - Sets the interval for notify() signal to be emitted. This is based - on the \a ms of audio data processed not on actual real-time. - The resolution of the timer is platform specific. -*/ - -/*! - \fn virtual int QAbstractAudioInput::notifyInterval() const - Returns the notify interval in milliseconds. -*/ - -/*! - \fn virtual qint64 QAbstractAudioInput::processedUSecs() const - Returns the amount of audio data processed since start() was called in milliseconds. -*/ - -/*! - \fn virtual qint64 QAbstractAudioInput::elapsedUSecs() const - Returns the milliseconds since start() was called, including time in Idle and suspend states. -*/ - -/*! - \fn virtual QAudio::Error QAbstractAudioInput::error() const - Returns the error state. -*/ - -/*! - \fn virtual QAudio::State QAbstractAudioInput::state() const - Returns the state of audio processing. -*/ - -/*! - \fn virtual QAudioFormat QAbstractAudioInput::format() const - Returns the QAudioFormat being used -*/ - -/*! - \fn QAbstractAudioInput::stateChanged(QAudio::State state) - This signal is emitted when the device \a state has changed. -*/ - -/*! - \fn QAbstractAudioInput::notify() - This signal is emitted when x ms of audio data has been processed - the interval set by setNotifyInterval(x). -*/ - - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudioengine.h b/src/multimedia/multimedia/audio/qaudioengine.h deleted file mode 100644 index df9d09d..0000000 --- a/src/multimedia/multimedia/audio/qaudioengine.h +++ /dev/null @@ -1,131 +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 QtMultimedia 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 QAUDIOENGINE_H -#define QAUDIOENGINE_H - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class Q_MULTIMEDIA_EXPORT QAbstractAudioDeviceInfo : public QObject -{ - Q_OBJECT - -public: - virtual QAudioFormat preferredFormat() const = 0; - virtual bool isFormatSupported(const QAudioFormat &format) const = 0; - virtual QAudioFormat nearestFormat(const QAudioFormat &format) const = 0; - virtual QString deviceName() const = 0; - virtual QStringList codecList() = 0; - virtual QList frequencyList() = 0; - virtual QList channelsList() = 0; - virtual QList sampleSizeList() = 0; - virtual QList byteOrderList() = 0; - virtual QList sampleTypeList() = 0; -}; - -class Q_MULTIMEDIA_EXPORT QAbstractAudioOutput : public QObject -{ - Q_OBJECT - -public: - virtual QIODevice* start(QIODevice* device) = 0; - virtual void stop() = 0; - virtual void reset() = 0; - virtual void suspend() = 0; - virtual void resume() = 0; - virtual int bytesFree() const = 0; - virtual int periodSize() const = 0; - virtual void setBufferSize(int value) = 0; - virtual int bufferSize() const = 0; - virtual void setNotifyInterval(int milliSeconds) = 0; - virtual int notifyInterval() const = 0; - virtual qint64 processedUSecs() const = 0; - virtual qint64 elapsedUSecs() const = 0; - virtual QAudio::Error error() const = 0; - virtual QAudio::State state() const = 0; - virtual QAudioFormat format() const = 0; - -Q_SIGNALS: - void stateChanged(QAudio::State); - void notify(); -}; - -class Q_MULTIMEDIA_EXPORT QAbstractAudioInput : public QObject -{ - Q_OBJECT - -public: - virtual QIODevice* start(QIODevice* device) = 0; - virtual void stop() = 0; - virtual void reset() = 0; - virtual void suspend() = 0; - virtual void resume() = 0; - virtual int bytesReady() const = 0; - virtual int periodSize() const = 0; - virtual void setBufferSize(int value) = 0; - virtual int bufferSize() const = 0; - virtual void setNotifyInterval(int milliSeconds) = 0; - virtual int notifyInterval() const = 0; - virtual qint64 processedUSecs() const = 0; - virtual qint64 elapsedUSecs() const = 0; - virtual QAudio::Error error() const = 0; - virtual QAudio::State state() const = 0; - virtual QAudioFormat format() const = 0; - -Q_SIGNALS: - void stateChanged(QAudio::State); - void notify(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOENGINE_H diff --git a/src/multimedia/multimedia/audio/qaudioengineplugin.cpp b/src/multimedia/multimedia/audio/qaudioengineplugin.cpp deleted file mode 100644 index 82324b5..0000000 --- a/src/multimedia/multimedia/audio/qaudioengineplugin.cpp +++ /dev/null @@ -1,54 +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 QtMultimedia 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 - -QT_BEGIN_NAMESPACE - -QAudioEnginePlugin::QAudioEnginePlugin(QObject* parent) : - QObject(parent) -{} - -QAudioEnginePlugin::~QAudioEnginePlugin() -{} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudioengineplugin.h b/src/multimedia/multimedia/audio/qaudioengineplugin.h deleted file mode 100644 index 2322d2a..0000000 --- a/src/multimedia/multimedia/audio/qaudioengineplugin.h +++ /dev/null @@ -1,93 +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 QtMultimedia 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 QAUDIOENGINEPLUGIN_H -#define QAUDIOENGINEPLUGIN_H - -#include -#include -#include - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -struct Q_MULTIMEDIA_EXPORT QAudioEngineFactoryInterface : public QFactoryInterface -{ - virtual QList availableDevices(QAudio::Mode) const = 0; - virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; - virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; - virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; -}; - -#define QAudioEngineFactoryInterface_iid \ - "com.nokia.qt.QAudioEngineFactoryInterface" -Q_DECLARE_INTERFACE(QAudioEngineFactoryInterface, QAudioEngineFactoryInterface_iid) - -class Q_MULTIMEDIA_EXPORT QAudioEnginePlugin : public QObject, public QAudioEngineFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QAudioEngineFactoryInterface:QFactoryInterface) - -public: - QAudioEnginePlugin(QObject *parent = 0); - ~QAudioEnginePlugin(); - - virtual QStringList keys() const = 0; - virtual QList availableDevices(QAudio::Mode) const = 0; - virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; - virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0; - virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOENGINEPLUGIN_H diff --git a/src/multimedia/multimedia/audio/qaudioformat.cpp b/src/multimedia/multimedia/audio/qaudioformat.cpp deleted file mode 100644 index 86d72f6..0000000 --- a/src/multimedia/multimedia/audio/qaudioformat.cpp +++ /dev/null @@ -1,407 +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 QtMultimedia 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 -#include - - -QT_BEGIN_NAMESPACE - - -class QAudioFormatPrivate : public QSharedData -{ -public: - QAudioFormatPrivate() - { - frequency = -1; - channels = -1; - sampleSize = -1; - byteOrder = QAudioFormat::Endian(QSysInfo::ByteOrder); - sampleType = QAudioFormat::Unknown; - } - - QAudioFormatPrivate(const QAudioFormatPrivate &other): - QSharedData(other), - codec(other.codec), - byteOrder(other.byteOrder), - sampleType(other.sampleType), - frequency(other.frequency), - channels(other.channels), - sampleSize(other.sampleSize) - { - } - - QAudioFormatPrivate& operator=(const QAudioFormatPrivate &other) - { - codec = other.codec; - byteOrder = other.byteOrder; - sampleType = other.sampleType; - frequency = other.frequency; - channels = other.channels; - sampleSize = other.sampleSize; - - return *this; - } - - QString codec; - QAudioFormat::Endian byteOrder; - QAudioFormat::SampleType sampleType; - int frequency; - int channels; - int sampleSize; -}; - -/*! - \class QAudioFormat - \brief The QAudioFormat class stores audio parameter information. - - \inmodule QtMultimedia - \ingroup multimedia - \since 4.6 - - An audio format specifies how data in an audio stream is arranged, - i.e, how the stream is to be interpreted. The encoding itself is - specified by the codec() used for the stream. - - In addition to the encoding, QAudioFormat contains other - parameters that further specify how the audio data is arranged. - These are the frequency, the number of channels, the sample size, - the sample type, and the byte order. The following table describes - these in more detail. - - \table - \header - \o Parameter - \o Description - \row - \o Sample Rate - \o Samples per second of audio data in Hertz. - \row - \o Number of channels - \o The number of audio channels (typically one for mono - or two for stereo) - \row - \o Sample size - \o How much data is stored in each sample (typically 8 - or 16 bits) - \row - \o Sample type - \o Numerical representation of sample (typically signed integer, - unsigned integer or float) - \row - \o Byte order - \o Byte ordering of sample (typically little endian, big endian) - \endtable - - You can obtain audio formats compatible with the audio device used - through functions in QAudioDeviceInfo. This class also lets you - query available parameter values for a device, so that you can set - the parameters yourself. See the QAudioDeviceInfo class - description for details. You need to know the format of the audio - streams you wish to play. Qt does not set up formats for you. -*/ - -/*! - Construct a new audio format. - - Values are initialized as follows: - \list - \o sampleRate() = -1 - \o channelCount() = -1 - \o sampleSize() = -1 - \o byteOrder() = QAudioFormat::Endian(QSysInfo::ByteOrder) - \o sampleType() = QAudioFormat::Unknown - \c codec() = "" - \endlist -*/ - -QAudioFormat::QAudioFormat(): - d(new QAudioFormatPrivate) -{ -} - -/*! - Construct a new audio format using \a other. -*/ - -QAudioFormat::QAudioFormat(const QAudioFormat &other): - d(other.d) -{ -} - -/*! - Destroy this audio format. -*/ - -QAudioFormat::~QAudioFormat() -{ -} - -/*! - Assigns \a other to this QAudioFormat implementation. -*/ - -QAudioFormat& QAudioFormat::operator=(const QAudioFormat &other) -{ - d = other.d; - return *this; -} - -/*! - Returns true if this QAudioFormat is equal to the \a other - QAudioFormat; otherwise returns false. - - All elements of QAudioFormat are used for the comparison. -*/ - -bool QAudioFormat::operator==(const QAudioFormat &other) const -{ - return d->frequency == other.d->frequency && - d->channels == other.d->channels && - d->sampleSize == other.d->sampleSize && - d->byteOrder == other.d->byteOrder && - d->codec == other.d->codec && - d->sampleType == other.d->sampleType; -} - -/*! - Returns true if this QAudioFormat is not equal to the \a other - QAudioFormat; otherwise returns false. - - All elements of QAudioFormat are used for the comparison. -*/ - -bool QAudioFormat::operator!=(const QAudioFormat& other) const -{ - return !(*this == other); -} - -/*! - Returns true if all of the parameters are valid. -*/ - -bool QAudioFormat::isValid() const -{ - return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 && - d->sampleType != QAudioFormat::Unknown && !d->codec.isEmpty(); -} - -/*! - Sets the sample rate to \a samplerate Hertz. - - \since 4.7 -*/ - -void QAudioFormat::setSampleRate(int samplerate) -{ - d->frequency = samplerate; -} - -/*! - \obsolete - - Use setSampleRate() instead. -*/ - -void QAudioFormat::setFrequency(int frequency) -{ - d->frequency = frequency; -} - -/*! - Returns the current sample rate in Hertz. - - \since 4.7 -*/ - -int QAudioFormat::sampleRate() const -{ - return d->frequency; -} - -/*! - \obsolete - - Use sampleRate() instead. -*/ - -int QAudioFormat::frequency() const -{ - return d->frequency; -} - -/*! - Sets the channel count to \a channels. - - \since 4.7 -*/ - -void QAudioFormat::setChannelCount(int channels) -{ - d->channels = channels; -} - -/*! - \obsolete - - Use setChannelCount() instead. -*/ - -void QAudioFormat::setChannels(int channels) -{ - d->channels = channels; -} - -/*! - Returns the current channel count value. - - \since 4.7 -*/ - -int QAudioFormat::channelCount() const -{ - return d->channels; -} - -/*! - \obsolete - - Use channelCount() instead. -*/ - -int QAudioFormat::channels() const -{ - return d->channels; -} - -/*! - Sets the sample size to the \a sampleSize specified. -*/ - -void QAudioFormat::setSampleSize(int sampleSize) -{ - d->sampleSize = sampleSize; -} - -/*! - Returns the current sample size value. -*/ - -int QAudioFormat::sampleSize() const -{ - return d->sampleSize; -} - -/*! - Sets the codec to \a codec. - - \sa QAudioDeviceInfo::supportedCodecs() -*/ - -void QAudioFormat::setCodec(const QString &codec) -{ - d->codec = codec; -} - -/*! - Returns the current codec value. - - \sa QAudioDeviceInfo::supportedCodecs() -*/ - -QString QAudioFormat::codec() const -{ - return d->codec; -} - -/*! - Sets the byteOrder to \a byteOrder. -*/ - -void QAudioFormat::setByteOrder(QAudioFormat::Endian byteOrder) -{ - d->byteOrder = byteOrder; -} - -/*! - Returns the current byteOrder value. -*/ - -QAudioFormat::Endian QAudioFormat::byteOrder() const -{ - return d->byteOrder; -} - -/*! - Sets the sampleType to \a sampleType. -*/ - -void QAudioFormat::setSampleType(QAudioFormat::SampleType sampleType) -{ - d->sampleType = sampleType; -} - -/*! - Returns the current SampleType value. -*/ - -QAudioFormat::SampleType QAudioFormat::sampleType() const -{ - return d->sampleType; -} - -/*! - \enum QAudioFormat::SampleType - - \value Unknown Not Set - \value SignedInt samples are signed integers - \value UnSignedInt samples are unsigned intergers - \value Float samples are floats -*/ - -/*! - \enum QAudioFormat::Endian - - \value BigEndian samples are big endian byte order - \value LittleEndian samples are little endian byte order -*/ - -QT_END_NAMESPACE - diff --git a/src/multimedia/multimedia/audio/qaudioformat.h b/src/multimedia/multimedia/audio/qaudioformat.h deleted file mode 100644 index 6c835b7..0000000 --- a/src/multimedia/multimedia/audio/qaudioformat.h +++ /dev/null @@ -1,107 +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 QtMultimedia 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 QAUDIOFORMAT_H -#define QAUDIOFORMAT_H - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAudioFormatPrivate; - -class Q_MULTIMEDIA_EXPORT QAudioFormat -{ -public: - enum SampleType { Unknown, SignedInt, UnSignedInt, Float }; - enum Endian { BigEndian = QSysInfo::BigEndian, LittleEndian = QSysInfo::LittleEndian }; - - QAudioFormat(); - QAudioFormat(const QAudioFormat &other); - ~QAudioFormat(); - - QAudioFormat& operator=(const QAudioFormat &other); - bool operator==(const QAudioFormat &other) const; - bool operator!=(const QAudioFormat &other) const; - - bool isValid() const; - - void setFrequency(int frequency); - int frequency() const; - void setSampleRate(int sampleRate); - int sampleRate() const; - - void setChannels(int channels); - int channels() const; - void setChannelCount(int channelCount); - int channelCount() const; - - void setSampleSize(int sampleSize); - int sampleSize() const; - - void setCodec(const QString &codec); - QString codec() const; - - void setByteOrder(QAudioFormat::Endian byteOrder); - QAudioFormat::Endian byteOrder() const; - - void setSampleType(QAudioFormat::SampleType sampleType); - QAudioFormat::SampleType sampleType() const; - -private: - QSharedDataPointer d; -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOFORMAT_H diff --git a/src/multimedia/multimedia/audio/qaudioinput.cpp b/src/multimedia/multimedia/audio/qaudioinput.cpp deleted file mode 100644 index 3676f64..0000000 --- a/src/multimedia/multimedia/audio/qaudioinput.cpp +++ /dev/null @@ -1,432 +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 QtMultimedia 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 -#include -#include -#include - -#include "qaudiodevicefactory_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QAudioInput - \brief The QAudioInput class provides an interface for receiving audio data from an audio input device. - - \inmodule QtMultimedia - \ingroup multimedia - \since 4.6 - - You can construct an audio input with the system's - \l{QAudioDeviceInfo::defaultInputDevice()}{default audio input - device}. It is also possible to create QAudioInput with a - specific QAudioDeviceInfo. When you create the audio input, you - should also send in the QAudioFormat to be used for the recording - (see the QAudioFormat class description for details). - - To record to a file: - - QAudioInput lets you record audio with an audio input device. The - default constructor of this class will use the systems default - audio device, but you can also specify a QAudioDeviceInfo for a - specific device. You also need to pass in the QAudioFormat in - which you wish to record. - - Starting up the QAudioInput is simply a matter of calling start() - with a QIODevice opened for writing. For instance, to record to a - file, you can: - - \code - QFile outputFile; // class member. - QAudioInput* audio; // class member. - \endcode - - \code - { - outputFile.setFileName("/tmp/test.raw"); - outputFile.open( QIODevice::WriteOnly | QIODevice::Truncate ); - - QAudioFormat format; - // set up the format you want, eg. - format.setFrequency(8000); - format.setChannels(1); - format.setSampleSize(8); - format.setCodec("audio/pcm"); - format.setByteOrder(QAudioFormat::LittleEndian); - format.setSampleType(QAudioFormat::UnSignedInt); - - QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice(); - if (!info.isFormatSupported(format)) { - qWarning()<<"default format not supported try to use nearest"; - format = info.nearestFormat(format); - } - - audio = new QAudioInput(format, this); - QTimer::singleShot(3000, this, SLOT(stopRecording())); - audio->start(&outputFile); - // Records audio for 3000ms - } - \endcode - - This will start recording if the format specified is supported by - the input device (you can check this with - QAudioDeviceInfo::isFormatSupported(). In case there are any - snags, use the error() function to check what went wrong. We stop - recording in the \c stopRecording() slot. - - \code - void stopRecording() - { - audio->stop(); - outputFile->close(); - delete audio; - } - \endcode - - At any point in time, QAudioInput will be in one of four states: - active, suspended, stopped, or idle. These states are specified by - the QAudio::State enum. You can request a state change directly through - suspend(), resume(), stop(), reset(), and start(). The current - state is reported by state(). QAudioOutput will also signal you - when the state changes (stateChanged()). - - QAudioInput provides several ways of measuring the time that has - passed since the start() of the recording. The \c processedUSecs() - function returns the length of the stream in microseconds written, - i.e., it leaves out the times the audio input was suspended or idle. - The elapsedUSecs() function returns the time elapsed since start() was called regardless of - which states the QAudioInput has been in. - - If an error should occur, you can fetch its reason with error(). - The possible error reasons are described by the QAudio::Error - enum. The QAudioInput will enter the \l{QAudio::}{StoppedState} when - an error is encountered. Connect to the stateChanged() signal to - handle the error: - - \snippet doc/src/snippets/audio/main.cpp 0 - - \sa QAudioOutput, QAudioDeviceInfo - - \section1 Symbian Platform Security Requirements - - On Symbian, processes which use this class must have the - \c UserEnvironment platform security capability. If the client - process lacks this capability, calls to either overload of start() - will fail. - This failure is indicated by the QAudioInput object setting - its error() value to \l{QAudio::OpenError} and then emitting a - \l{stateChanged()}{stateChanged}(\l{QAudio::StoppedState}) signal. - - Platform security capabilities are added via the - \l{qmake-variable-reference.html#target-capability}{TARGET.CAPABILITY} - qmake variable. -*/ - -/*! - Construct a new audio input and attach it to \a parent. - The default audio input device is used with the output - \a format parameters. -*/ - -QAudioInput::QAudioInput(const QAudioFormat &format, QObject *parent): - QObject(parent) -{ - d = QAudioDeviceFactory::createDefaultInputDevice(format); - connect(d, SIGNAL(notify()), SIGNAL(notify())); - connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); -} - -/*! - Construct a new audio input and attach it to \a parent. - The device referenced by \a audioDevice is used with the input - \a format parameters. -*/ - -QAudioInput::QAudioInput(const QAudioDeviceInfo &audioDevice, const QAudioFormat &format, QObject *parent): - QObject(parent) -{ - d = QAudioDeviceFactory::createInputDevice(audioDevice, format); - connect(d, SIGNAL(notify()), SIGNAL(notify())); - connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); -} - -/*! - Destroy this audio input. -*/ - -QAudioInput::~QAudioInput() -{ - delete d; -} - -/*! - Uses the \a device as the QIODevice to transfer data. - Passing a QIODevice allows the data to be transfered without any extra code. - All that is required is to open the QIODevice. - - If able to successfully get audio data from the systems audio device the - state() is set to either QAudio::ActiveState or QAudio::IdleState, - error() is set to QAudio::NoError and the stateChanged() signal is emitted. - - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. - - \l{QAudioInput#Symbian Platform Security Requirements} - - \sa QIODevice -*/ - -void QAudioInput::start(QIODevice* device) -{ - d->start(device); -} - -/*! - Returns a pointer to the QIODevice being used to handle the data - transfer. This QIODevice can be used to read() audio data - directly. - - If able to access the systems audio device the state() is set to - QAudio::IdleState, error() is set to QAudio::NoError - and the stateChanged() signal is emitted. - - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. - - \l{QAudioInput#Symbian Platform Security Requirements} - - \sa QIODevice -*/ - -QIODevice* QAudioInput::start() -{ - return d->start(0); -} - -/*! - Returns the QAudioFormat being used. -*/ - -QAudioFormat QAudioInput::format() const -{ - return d->format(); -} - -/*! - Stops the audio input, detaching from the system resource. - - Sets error() to QAudio::NoError, state() to QAudio::StoppedState and - emit stateChanged() signal. -*/ - -void QAudioInput::stop() -{ - d->stop(); -} - -/*! - Drops all audio data in the buffers, resets buffers to zero. -*/ - -void QAudioInput::reset() -{ - d->reset(); -} - -/*! - Stops processing audio data, preserving buffered audio data. - - Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and - emit stateChanged() signal. -*/ - -void QAudioInput::suspend() -{ - d->suspend(); -} - -/*! - Resumes processing audio data after a suspend(). - - Sets error() to QAudio::NoError. - Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). - Sets state() to QAudio::IdleState if you previously called start(). - emits stateChanged() signal. -*/ - -void QAudioInput::resume() -{ - d->resume(); -} - -/*! - Sets the audio buffer size to \a value milliseconds. - - Note: This function can be called anytime before start(), calls to this - are ignored after start(). It should not be assumed that the buffer size - set is the actual buffer size used, calling bufferSize() anytime after start() - will return the actual buffer size being used. - -*/ - -void QAudioInput::setBufferSize(int value) -{ - d->setBufferSize(value); -} - -/*! - Returns the audio buffer size in milliseconds. - - If called before start(), returns platform default value. - If called before start() but setBufferSize() was called prior, returns value set by setBufferSize(). - If called after start(), returns the actual buffer size being used. This may not be what was set previously - by setBufferSize(). - -*/ - -int QAudioInput::bufferSize() const -{ - return d->bufferSize(); -} - -/*! - Returns the amount of audio data available to read in bytes. - - NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState - state, otherwise returns zero. -*/ - -int QAudioInput::bytesReady() const -{ - /* - -If not ActiveState|IdleState, return 0 - -return amount of audio data available to read - */ - return d->bytesReady(); -} - -/*! - Returns the period size in bytes. - - Note: This is the recommended read size in bytes. -*/ - -int QAudioInput::periodSize() const -{ - return d->periodSize(); -} - -/*! - Sets the interval for notify() signal to be emitted. - This is based on the \a ms of audio data processed - not on actual real-time. - The minimum resolution of the timer is platform specific and values - should be checked with notifyInterval() to confirm actual value - being used. -*/ - -void QAudioInput::setNotifyInterval(int ms) -{ - d->setNotifyInterval(ms); -} - -/*! - Returns the notify interval in milliseconds. -*/ - -int QAudioInput::notifyInterval() const -{ - return d->notifyInterval(); -} - -/*! - Returns the amount of audio data processed since start() - was called in microseconds. -*/ - -qint64 QAudioInput::processedUSecs() const -{ - return d->processedUSecs(); -} - -/*! - Returns the microseconds since start() was called, including time in Idle and - Suspend states. -*/ - -qint64 QAudioInput::elapsedUSecs() const -{ - return d->elapsedUSecs(); -} - -/*! - Returns the error state. -*/ - -QAudio::Error QAudioInput::error() const -{ - return d->error(); -} - -/*! - Returns the state of audio processing. -*/ - -QAudio::State QAudioInput::state() const -{ - return d->state(); -} - -/*! - \fn QAudioInput::stateChanged(QAudio::State state) - This signal is emitted when the device \a state has changed. -*/ - -/*! - \fn QAudioInput::notify() - This signal is emitted when x ms of audio data has been processed - the interval set by setNotifyInterval(x). -*/ - -QT_END_NAMESPACE - diff --git a/src/multimedia/multimedia/audio/qaudioinput.h b/src/multimedia/multimedia/audio/qaudioinput.h deleted file mode 100644 index 5be9b5a..0000000 --- a/src/multimedia/multimedia/audio/qaudioinput.h +++ /dev/null @@ -1,111 +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 QtMultimedia 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 QAUDIOINPUT_H -#define QAUDIOINPUT_H - -#include -#include - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAbstractAudioInput; - -class Q_MULTIMEDIA_EXPORT QAudioInput : public QObject -{ - Q_OBJECT - -public: - explicit QAudioInput(const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); - explicit QAudioInput(const QAudioDeviceInfo &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); - ~QAudioInput(); - - QAudioFormat format() const; - - void start(QIODevice *device); - QIODevice* start(); - - void stop(); - void reset(); - void suspend(); - void resume(); - - void setBufferSize(int bytes); - int bufferSize() const; - - int bytesReady() const; - int periodSize() const; - - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - - QAudio::Error error() const; - QAudio::State state() const; - -Q_SIGNALS: - void stateChanged(QAudio::State); - void notify(); - -private: - Q_DISABLE_COPY(QAudioInput) - - QAbstractAudioInput* d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOINPUT_H diff --git a/src/multimedia/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/multimedia/audio/qaudioinput_alsa_p.cpp deleted file mode 100644 index c9a8b71..0000000 --- a/src/multimedia/multimedia/audio/qaudioinput_alsa_p.cpp +++ /dev/null @@ -1,701 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include "qaudioinput_alsa_p.h" -#include "qaudiodeviceinfo_alsa_p.h" - -QT_BEGIN_NAMESPACE - -//#define DEBUG_AUDIO 1 - -QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): - settings(audioFormat) -{ - bytesAvailable = 0; - handle = 0; - ahandler = 0; - access = SND_PCM_ACCESS_RW_INTERLEAVED; - pcmformat = SND_PCM_FORMAT_S16; - buffer_size = 0; - period_size = 0; - buffer_time = 100000; - period_time = 20000; - totalTimeValue = 0; - intervalTime = 1000; - audioBuffer = 0; - errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; - audioSource = 0; - pullMode = true; - resuming = false; - - m_device = device; - - timer = new QTimer(this); - connect(timer,SIGNAL(timeout()),SLOT(userFeed())); -} - -QAudioInputPrivate::~QAudioInputPrivate() -{ - close(); - disconnect(timer, SIGNAL(timeout())); - QCoreApplication::processEvents(); - delete timer; -} - -QAudio::Error QAudioInputPrivate::error() const -{ - return errorState; -} - -QAudio::State QAudioInputPrivate::state() const -{ - return deviceState; -} - - -QAudioFormat QAudioInputPrivate::format() const -{ - return settings; -} - -int QAudioInputPrivate::xrun_recovery(int err) -{ - int count = 0; - bool reset = false; - - if(err == -EPIPE) { - errorState = QAudio::UnderrunError; - err = snd_pcm_prepare(handle); - if(err < 0) - reset = true; - else { - bytesAvailable = bytesReady(); - if (bytesAvailable <= 0) - reset = true; - } - - } else if((err == -ESTRPIPE)||(err == -EIO)) { - errorState = QAudio::IOError; - while((err = snd_pcm_resume(handle)) == -EAGAIN){ - usleep(100); - count++; - if(count > 5) { - reset = true; - break; - } - } - if(err < 0) { - err = snd_pcm_prepare(handle); - if(err < 0) - reset = true; - } - } - if(reset) { - close(); - open(); - snd_pcm_prepare(handle); - return 0; - } - return err; -} - -int QAudioInputPrivate::setFormat() -{ - snd_pcm_format_t format = SND_PCM_FORMAT_S16; - - if(settings.sampleSize() == 8) { - format = SND_PCM_FORMAT_U8; - } else if(settings.sampleSize() == 16) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_S16_LE; - else - format = SND_PCM_FORMAT_S16_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_U16_LE; - else - format = SND_PCM_FORMAT_U16_BE; - } - } else if(settings.sampleSize() == 24) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_S24_LE; - else - format = SND_PCM_FORMAT_S24_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_U24_LE; - else - format = SND_PCM_FORMAT_U24_BE; - } - } else if(settings.sampleSize() == 32) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_S32_LE; - else - format = SND_PCM_FORMAT_S32_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_U32_LE; - else - format = SND_PCM_FORMAT_U32_BE; - } else if(settings.sampleType() == QAudioFormat::Float) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_FLOAT_LE; - else - format = SND_PCM_FORMAT_FLOAT_BE; - } - } else if(settings.sampleSize() == 64) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_FLOAT64_LE; - else - format = SND_PCM_FORMAT_FLOAT64_BE; - } - - return snd_pcm_hw_params_set_format( handle, hwparams, format); -} - -QIODevice* QAudioInputPrivate::start(QIODevice* device) -{ - if(deviceState != QAudio::StoppedState) - close(); - - if(!pullMode && audioSource) { - delete audioSource; - } - - if(device) { - //set to pull mode - pullMode = true; - audioSource = device; - deviceState = QAudio::ActiveState; - } else { - //set to push mode - pullMode = false; - deviceState = QAudio::IdleState; - audioSource = new InputPrivate(this); - audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered); - } - - if( !open() ) - return 0; - - emit stateChanged(deviceState); - - return audioSource; -} - -void QAudioInputPrivate::stop() -{ - if(deviceState == QAudio::StoppedState) - return; - - deviceState = QAudio::StoppedState; - - close(); - emit stateChanged(deviceState); -} - -bool QAudioInputPrivate::open() -{ -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()< devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioInput); - if(dev.compare(QLatin1String("default")) == 0) { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = QLatin1String(devices.first()); -#else - dev = QLatin1String("hw:0,0"); -#endif - } else { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = QLatin1String(m_device); -#else - int idx = 0; - char *name; - - QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData()); - - while(snd_card_get_name(idx,&name) == 0) { - if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0) - break; - idx++; - } - dev = QString(QLatin1String("hw:%1,0")).arg(idx); -#endif - } - - // Step 1: try and open the device - while((count < 5) && (err < 0)) { - err=snd_pcm_open(&handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); - if(err < 0) - count++; - } - if (( err < 0)||(handle == 0)) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - return false; - } - snd_pcm_nonblock( handle, 0 ); - - // Step 2: Set the desired HW parameters. - snd_pcm_hw_params_alloca( &hwparams ); - - bool fatal = false; - QString errMessage; - unsigned int chunks = 8; - - err = snd_pcm_hw_params_any( handle, hwparams ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_any: err = %1").arg(err); - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_rate_resample( handle, hwparams, 1 ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_rate_resample: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_access( handle, hwparams, access ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_access: err = %1").arg(err); - } - } - if ( !fatal ) { - err = setFormat(); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_format: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_channels: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &freakuency, 0 ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_rate_near: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_buffer_time_near(handle, hwparams, &buffer_time, &dir); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_buffer_time_near: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_period_time_near(handle, hwparams, &period_time, &dir); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_period_time_near: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_periods_near(handle, hwparams, &chunks, &dir); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_periods_near: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params(handle, hwparams); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params: err = %1").arg(err); - } - } - if( err < 0) { - qWarning()<start(period_time*chunks/2000); - - errorState = QAudio::NoError; - - totalTimeValue = 0; - - return true; -} - -void QAudioInputPrivate::close() -{ - timer->stop(); - - if ( handle ) { - snd_pcm_drop( handle ); - snd_pcm_close( handle ); - handle = 0; - delete [] audioBuffer; - audioBuffer=0; - } -} - -int QAudioInputPrivate::bytesReady() const -{ - if(resuming) - return period_size; - - if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) - return 0; - int frames = snd_pcm_avail_update(handle); - if (frames < 0) return frames; - if((int)frames > (int)buffer_frames) - frames = buffer_frames; - - return snd_pcm_frames_to_bytes(handle, frames); -} - -qint64 QAudioInputPrivate::read(char* data, qint64 len) -{ - Q_UNUSED(len) - - // Read in some audio data and write it to QIODevice, pull mode - if ( !handle ) - return 0; - - bytesAvailable = bytesReady(); - - if (bytesAvailable < 0) { - // bytesAvailable as negative is error code, try to recover from it. - xrun_recovery(bytesAvailable); - bytesAvailable = bytesReady(); - if (bytesAvailable < 0) { - // recovery failed must stop and set error. - close(); - errorState = QAudio::IOError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - return 0; - } - } - - int count=0, err = 0; - while(count < 5) { - int chunks = bytesAvailable/period_size; - int frames = chunks*period_frames; - if(frames > (int)buffer_frames) - frames = buffer_frames; - int readFrames = snd_pcm_readi(handle, audioBuffer, frames); - if (readFrames >= 0) { - err = snd_pcm_frames_to_bytes(handle, readFrames); -#ifdef DEBUG_AUDIO - qDebug()< 0) { - // got some send it onward -#ifdef DEBUG_AUDIO - qDebug()<<"frames to write to QIODevice = "<< - snd_pcm_bytes_to_frames( handle, (int)err )<<" ("<write(audioBuffer,err); - if(l < 0) { - close(); - errorState = QAudio::IOError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - } else if(l == 0) { - if (deviceState != QAudio::IdleState) { - errorState = QAudio::NoError; - deviceState = QAudio::IdleState; - emit stateChanged(deviceState); - } - } else { - totalTimeValue += err; - resuming = false; - if (deviceState != QAudio::ActiveState) { - errorState = QAudio::NoError; - deviceState = QAudio::ActiveState; - emit stateChanged(deviceState); - } - } - return l; - - } else { - memcpy(data,audioBuffer,err); - totalTimeValue += err; - resuming = false; - if (deviceState != QAudio::ActiveState) { - errorState = QAudio::NoError; - deviceState = QAudio::ActiveState; - emit stateChanged(deviceState); - } - return err; - } - } - return 0; -} - -void QAudioInputPrivate::resume() -{ - if(deviceState == QAudio::SuspendedState) { - int err = 0; - - if(handle) { - err = snd_pcm_prepare( handle ); - if(err < 0) - xrun_recovery(err); - - err = snd_pcm_start(handle); - if(err < 0) - xrun_recovery(err); - - bytesAvailable = buffer_size; - } - resuming = true; - deviceState = QAudio::ActiveState; - int chunks = buffer_size/period_size; - timer->start(period_time*chunks/2000); - emit stateChanged(deviceState); - } -} - -void QAudioInputPrivate::setBufferSize(int value) -{ - buffer_size = value; -} - -int QAudioInputPrivate::bufferSize() const -{ - return buffer_size; -} - -int QAudioInputPrivate::periodSize() const -{ - return period_size; -} - -void QAudioInputPrivate::setNotifyInterval(int ms) -{ - intervalTime = qMax(0, ms); -} - -int QAudioInputPrivate::notifyInterval() const -{ - return intervalTime; -} - -qint64 QAudioInputPrivate::processedUSecs() const -{ - qint64 result = qint64(1000000) * totalTimeValue / - (settings.channels()*(settings.sampleSize()/8)) / - settings.frequency(); - - return result; -} - -void QAudioInputPrivate::suspend() -{ - if(deviceState == QAudio::ActiveState||resuming) { - timer->stop(); - deviceState = QAudio::SuspendedState; - emit stateChanged(deviceState); - } -} - -void QAudioInputPrivate::userFeed() -{ - if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) - return; -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()<(audioSource); - a->trigger(); - } - bytesAvailable = bytesReady(); - - if(deviceState != QAudio::ActiveState) - return true; - - if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { - emit notify(); - elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; - timeStamp.restart(); - } - return true; -} - -qint64 QAudioInputPrivate::elapsedUSecs() const -{ - if (deviceState == QAudio::StoppedState) - return 0; - - return clockStamp.elapsed()*1000; -} - -void QAudioInputPrivate::reset() -{ - if(handle) - snd_pcm_reset(handle); -} - -void QAudioInputPrivate::drain() -{ - if(handle) - snd_pcm_drain(handle); -} - -InputPrivate::InputPrivate(QAudioInputPrivate* audio) -{ - audioDevice = qobject_cast(audio); -} - -InputPrivate::~InputPrivate() -{ -} - -qint64 InputPrivate::readData( char* data, qint64 len) -{ - return audioDevice->read(data,len); -} - -qint64 InputPrivate::writeData(const char* data, qint64 len) -{ - Q_UNUSED(data) - Q_UNUSED(len) - return 0; -} - -void InputPrivate::trigger() -{ - emit readyRead(); -} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/multimedia/audio/qaudioinput_alsa_p.h deleted file mode 100644 index c907019..0000000 --- a/src/multimedia/multimedia/audio/qaudioinput_alsa_p.h +++ /dev/null @@ -1,158 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QAUDIOINPUTALSA_H -#define QAUDIOINPUTALSA_H - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class InputPrivate; - -class QAudioInputPrivate : public QAbstractAudioInput -{ - Q_OBJECT -public: - QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat); - ~QAudioInputPrivate(); - - qint64 read(char* data, qint64 len); - - QIODevice* start(QIODevice* device = 0); - void stop(); - void reset(); - void suspend(); - void resume(); - int bytesReady() const; - int periodSize() const; - void setBufferSize(int value); - int bufferSize() const; - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - QAudio::Error error() const; - QAudio::State state() const; - QAudioFormat format() const; - bool resuming; - snd_pcm_t* handle; - qint64 totalTimeValue; - QIODevice* audioSource; - QAudioFormat settings; - QAudio::Error errorState; - QAudio::State deviceState; - -private slots: - void userFeed(); - bool deviceReady(); - -private: - int xrun_recovery(int err); - int setFormat(); - bool open(); - void close(); - void drain(); - - QTimer* timer; - QElapsedTimer timeStamp; - QElapsedTimer clockStamp; - qint64 elapsedTimeOffset; - int intervalTime; - char* audioBuffer; - int bytesAvailable; - QByteArray m_device; - bool pullMode; - int buffer_size; - int period_size; - unsigned int buffer_time; - unsigned int period_time; - snd_pcm_uframes_t buffer_frames; - snd_pcm_uframes_t period_frames; - snd_async_handler_t* ahandler; - snd_pcm_access_t access; - snd_pcm_format_t pcmformat; - snd_timestamp_t* timestamp; - snd_pcm_hw_params_t *hwparams; -}; - -class InputPrivate : public QIODevice -{ - Q_OBJECT -public: - InputPrivate(QAudioInputPrivate* audio); - ~InputPrivate(); - - qint64 readData( char* data, qint64 len); - qint64 writeData(const char* data, qint64 len); - - void trigger(); -private: - QAudioInputPrivate *audioDevice; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/multimedia/audio/qaudioinput_mac_p.cpp deleted file mode 100644 index cb65f6e..0000000 --- a/src/multimedia/multimedia/audio/qaudioinput_mac_p.cpp +++ /dev/null @@ -1,956 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - -#include - -#include "qaudio_mac_p.h" -#include "qaudioinput_mac_p.h" -#include "qaudiodeviceinfo_mac_p.h" - -QT_BEGIN_NAMESPACE - - -namespace QtMultimediaInternal -{ - -static const int default_buffer_size = 4 * 1024; - -class QAudioBufferList -{ -public: - QAudioBufferList(AudioStreamBasicDescription const& streamFormat): - owner(false), - sf(streamFormat) - { - const bool isInterleaved = (sf.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0; - const int numberOfBuffers = isInterleaved ? 1 : sf.mChannelsPerFrame; - - dataSize = 0; - - bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + - (sizeof(AudioBuffer) * numberOfBuffers))); - - bfs->mNumberBuffers = numberOfBuffers; - for (int i = 0; i < numberOfBuffers; ++i) { - bfs->mBuffers[i].mNumberChannels = isInterleaved ? numberOfBuffers : 1; - bfs->mBuffers[i].mDataByteSize = 0; - bfs->mBuffers[i].mData = 0; - } - } - - QAudioBufferList(AudioStreamBasicDescription const& streamFormat, char* buffer, int bufferSize): - owner(false), - sf(streamFormat), - bfs(0) - { - dataSize = bufferSize; - - bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + sizeof(AudioBuffer))); - - bfs->mNumberBuffers = 1; - bfs->mBuffers[0].mNumberChannels = 1; - bfs->mBuffers[0].mDataByteSize = dataSize; - bfs->mBuffers[0].mData = buffer; - } - - QAudioBufferList(AudioStreamBasicDescription const& streamFormat, int framesToBuffer): - owner(true), - sf(streamFormat), - bfs(0) - { - const bool isInterleaved = (sf.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0; - const int numberOfBuffers = isInterleaved ? 1 : sf.mChannelsPerFrame; - - dataSize = framesToBuffer * sf.mBytesPerFrame; - - bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + - (sizeof(AudioBuffer) * numberOfBuffers))); - bfs->mNumberBuffers = numberOfBuffers; - for (int i = 0; i < numberOfBuffers; ++i) { - bfs->mBuffers[i].mNumberChannels = isInterleaved ? numberOfBuffers : 1; - bfs->mBuffers[i].mDataByteSize = dataSize; - bfs->mBuffers[i].mData = qMalloc(dataSize); - } - } - - ~QAudioBufferList() - { - if (owner) { - for (UInt32 i = 0; i < bfs->mNumberBuffers; ++i) - qFree(bfs->mBuffers[i].mData); - } - - qFree(bfs); - } - - AudioBufferList* audioBufferList() const - { - return bfs; - } - - char* data(int buffer = 0) const - { - return static_cast(bfs->mBuffers[buffer].mData); - } - - qint64 bufferSize(int buffer = 0) const - { - return bfs->mBuffers[buffer].mDataByteSize; - } - - int frameCount(int buffer = 0) const - { - return bfs->mBuffers[buffer].mDataByteSize / sf.mBytesPerFrame; - } - - int packetCount(int buffer = 0) const - { - return bfs->mBuffers[buffer].mDataByteSize / sf.mBytesPerPacket; - } - - int packetSize() const - { - return sf.mBytesPerPacket; - } - - void reset() - { - for (UInt32 i = 0; i < bfs->mNumberBuffers; ++i) { - bfs->mBuffers[i].mDataByteSize = dataSize; - bfs->mBuffers[i].mData = 0; - } - } - -private: - bool owner; - int dataSize; - AudioStreamBasicDescription sf; - AudioBufferList* bfs; -}; - -class QAudioPacketFeeder -{ -public: - QAudioPacketFeeder(QAudioBufferList* abl): - audioBufferList(abl) - { - totalPackets = audioBufferList->packetCount(); - position = 0; - } - - bool feed(AudioBufferList& dst, UInt32& packetCount) - { - if (position == totalPackets) { - dst.mBuffers[0].mDataByteSize = 0; - packetCount = 0; - return false; - } - - if (totalPackets - position < packetCount) - packetCount = totalPackets - position; - - dst.mBuffers[0].mDataByteSize = packetCount * audioBufferList->packetSize(); - dst.mBuffers[0].mData = audioBufferList->data() + (position * audioBufferList->packetSize()); - - position += packetCount; - - return true; - } - -private: - UInt32 totalPackets; - UInt32 position; - QAudioBufferList* audioBufferList; -}; - -class QAudioInputBuffer : public QObject -{ - Q_OBJECT - -public: - QAudioInputBuffer(int bufferSize, - int maxPeriodSize, - AudioStreamBasicDescription const& inputFormat, - AudioStreamBasicDescription const& outputFormat, - QObject* parent): - QObject(parent), - m_deviceError(false), - m_audioConverter(0), - m_inputFormat(inputFormat), - m_outputFormat(outputFormat) - { - m_maxPeriodSize = maxPeriodSize; - m_periodTime = m_maxPeriodSize / m_outputFormat.mBytesPerFrame * 1000 / m_outputFormat.mSampleRate; - m_buffer = new QAudioRingBuffer(bufferSize + (bufferSize % maxPeriodSize == 0 ? 0 : maxPeriodSize - (bufferSize % maxPeriodSize))); - m_inputBufferList = new QAudioBufferList(m_inputFormat); - - m_flushTimer = new QTimer(this); - connect(m_flushTimer, SIGNAL(timeout()), SLOT(flushBuffer())); - - if (toQAudioFormat(inputFormat) != toQAudioFormat(outputFormat)) { - if (AudioConverterNew(&m_inputFormat, &m_outputFormat, &m_audioConverter) != noErr) { - qWarning() << "QAudioInput: Unable to create an Audio Converter"; - m_audioConverter = 0; - } - } - } - - ~QAudioInputBuffer() - { - delete m_buffer; - } - - qint64 renderFromDevice(AudioUnit audioUnit, - AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames) - { - const bool wasEmpty = m_buffer->used() == 0; - - OSStatus err; - qint64 framesRendered = 0; - - m_inputBufferList->reset(); - err = AudioUnitRender(audioUnit, - ioActionFlags, - inTimeStamp, - inBusNumber, - inNumberFrames, - m_inputBufferList->audioBufferList()); - - if (m_audioConverter != 0) { - QAudioPacketFeeder feeder(m_inputBufferList); - - bool wecan = true; - int copied = 0; - - const int available = m_buffer->free(); - - while (err == noErr && wecan) { - QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(available); - - if (region.second > 0) { - AudioBufferList output; - output.mNumberBuffers = 1; - output.mBuffers[0].mNumberChannels = 1; - output.mBuffers[0].mDataByteSize = region.second; - output.mBuffers[0].mData = region.first; - - UInt32 packetSize = region.second / m_outputFormat.mBytesPerPacket; - err = AudioConverterFillComplexBuffer(m_audioConverter, - converterCallback, - &feeder, - &packetSize, - &output, - 0); - - region.second = output.mBuffers[0].mDataByteSize; - copied += region.second; - - m_buffer->releaseWriteRegion(region); - } - else - wecan = false; - } - - framesRendered += copied / m_outputFormat.mBytesPerFrame; - } - else { - const int available = m_inputBufferList->bufferSize(); - bool wecan = true; - int copied = 0; - - while (wecan && copied < available) { - QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(available - copied); - - if (region.second > 0) { - memcpy(region.first, m_inputBufferList->data() + copied, region.second); - copied += region.second; - } - else - wecan = false; - - m_buffer->releaseWriteRegion(region); - } - - framesRendered = copied / m_outputFormat.mBytesPerFrame; - } - - if (wasEmpty && framesRendered > 0) - emit readyRead(); - - return framesRendered; - } - - qint64 readBytes(char* data, qint64 len) - { - bool wecan = true; - qint64 bytesCopied = 0; - - len -= len % m_maxPeriodSize; - while (wecan && bytesCopied < len) { - QAudioRingBuffer::Region region = m_buffer->acquireReadRegion(len - bytesCopied); - - if (region.second > 0) { - memcpy(data + bytesCopied, region.first, region.second); - bytesCopied += region.second; - } - else - wecan = false; - - m_buffer->releaseReadRegion(region); - } - - return bytesCopied; - } - - void setFlushDevice(QIODevice* device) - { - if (m_device != device) - m_device = device; - } - - void startFlushTimer() - { - if (m_device != 0) { - m_flushTimer->start((m_buffer->size() - (m_maxPeriodSize * 2)) / m_maxPeriodSize * m_periodTime); - } - } - - void stopFlushTimer() - { - m_flushTimer->stop(); - } - - void flush(bool all = false) - { - if (m_device == 0) - return; - - const int used = m_buffer->used(); - const int readSize = all ? used : used - (used % m_maxPeriodSize); - - if (readSize > 0) { - bool wecan = true; - int flushed = 0; - - while (!m_deviceError && wecan && flushed < readSize) { - QAudioRingBuffer::Region region = m_buffer->acquireReadRegion(readSize - flushed); - - if (region.second > 0) { - int bytesWritten = m_device->write(region.first, region.second); - if (bytesWritten < 0) { - stopFlushTimer(); - m_deviceError = true; - } - else { - region.second = bytesWritten; - flushed += bytesWritten; - wecan = bytesWritten != 0; - } - } - else - wecan = false; - - m_buffer->releaseReadRegion(region); - } - } - } - - void reset() - { - m_buffer->reset(); - m_deviceError = false; - } - - int available() const - { - return m_buffer->free(); - } - - int used() const - { - return m_buffer->used(); - } - -signals: - void readyRead(); - -private slots: - void flushBuffer() - { - flush(); - } - -private: - bool m_deviceError; - int m_maxPeriodSize; - int m_periodTime; - QIODevice* m_device; - QTimer* m_flushTimer; - QAudioRingBuffer* m_buffer; - QAudioBufferList* m_inputBufferList; - AudioConverterRef m_audioConverter; - AudioStreamBasicDescription m_inputFormat; - AudioStreamBasicDescription m_outputFormat; - - const static OSStatus as_empty = 'qtem'; - - // Converter callback - static OSStatus converterCallback(AudioConverterRef inAudioConverter, - UInt32* ioNumberDataPackets, - AudioBufferList* ioData, - AudioStreamPacketDescription** outDataPacketDescription, - void* inUserData) - { - Q_UNUSED(inAudioConverter); - Q_UNUSED(outDataPacketDescription); - - QAudioPacketFeeder* feeder = static_cast(inUserData); - - if (!feeder->feed(*ioData, *ioNumberDataPackets)) - return as_empty; - - return noErr; - } -}; - - -class MacInputDevice : public QIODevice -{ - Q_OBJECT - -public: - MacInputDevice(QAudioInputBuffer* audioBuffer, QObject* parent): - QIODevice(parent), - m_audioBuffer(audioBuffer) - { - open(QIODevice::ReadOnly | QIODevice::Unbuffered); - connect(m_audioBuffer, SIGNAL(readyRead()), SIGNAL(readyRead())); - } - - qint64 readData(char* data, qint64 len) - { - return m_audioBuffer->readBytes(data, len); - } - - qint64 writeData(const char* data, qint64 len) - { - Q_UNUSED(data); - Q_UNUSED(len); - - return 0; - } - - bool isSequential() const - { - return true; - } - -private: - QAudioInputBuffer* m_audioBuffer; -}; - -} - - -QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat const& format): - audioFormat(format) -{ - QDataStream ds(device); - quint32 did, mode; - - ds >> did >> mode; - - if (QAudio::Mode(mode) == QAudio::AudioOutput) - errorCode = QAudio::OpenError; - else { - audioDeviceInfo = new QAudioDeviceInfoInternal(device, QAudio::AudioInput); - isOpen = false; - audioDeviceId = AudioDeviceID(did); - audioUnit = 0; - startTime = 0; - totalFrames = 0; - audioBuffer = 0; - internalBufferSize = QtMultimediaInternal::default_buffer_size; - clockFrequency = AudioGetHostClockFrequency() / 1000; - errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; - - intervalTimer = new QTimer(this); - intervalTimer->setInterval(1000); - connect(intervalTimer, SIGNAL(timeout()), SIGNAL(notify())); - } -} - -QAudioInputPrivate::~QAudioInputPrivate() -{ - close(); - delete audioDeviceInfo; -} - -bool QAudioInputPrivate::open() -{ - UInt32 size = 0; - - if (isOpen) - return true; - - ComponentDescription cd; - cd.componentType = kAudioUnitType_Output; - cd.componentSubType = kAudioUnitSubType_HALOutput; - cd.componentManufacturer = kAudioUnitManufacturer_Apple; - cd.componentFlags = 0; - cd.componentFlagsMask = 0; - - // Open - Component cp = FindNextComponent(NULL, &cd); - if (cp == 0) { - qWarning() << "QAudioInput: Failed to find HAL Output component"; - return false; - } - - if (OpenAComponent(cp, &audioUnit) != noErr) { - qWarning() << "QAudioInput: Unable to Open Output Component"; - return false; - } - - // Set mode - // switch to input mode - UInt32 enable = 1; - if (AudioUnitSetProperty(audioUnit, - kAudioOutputUnitProperty_EnableIO, - kAudioUnitScope_Input, - 1, - &enable, - sizeof(enable)) != noErr) { - qWarning() << "QAudioInput: Unable to switch to input mode (Enable Input)"; - return false; - } - - enable = 0; - if (AudioUnitSetProperty(audioUnit, - kAudioOutputUnitProperty_EnableIO, - kAudioUnitScope_Output, - 0, - &enable, - sizeof(enable)) != noErr) { - qWarning() << "QAudioInput: Unable to switch to input mode (Disable output)"; - return false; - } - - // register callback - AURenderCallbackStruct cb; - cb.inputProc = inputCallback; - cb.inputProcRefCon = this; - - if (AudioUnitSetProperty(audioUnit, - kAudioOutputUnitProperty_SetInputCallback, - kAudioUnitScope_Global, - 0, - &cb, - sizeof(cb)) != noErr) { - qWarning() << "QAudioInput: Failed to set AudioUnit callback"; - return false; - } - - // Set Audio Device - if (AudioUnitSetProperty(audioUnit, - kAudioOutputUnitProperty_CurrentDevice, - kAudioUnitScope_Global, - 0, - &audioDeviceId, - sizeof(audioDeviceId)) != noErr) { - qWarning() << "QAudioInput: Unable to use configured device"; - return false; - } - - // Set format - // Wanted - streamFormat = toAudioStreamBasicDescription(audioFormat); - - // Required on unit - if (audioFormat == audioDeviceInfo->preferredFormat()) { - deviceFormat = streamFormat; - AudioUnitSetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Output, - 1, - &deviceFormat, - sizeof(deviceFormat)); - } - else { - size = sizeof(deviceFormat); - if (AudioUnitGetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 1, - &deviceFormat, - &size) != noErr) { - qWarning() << "QAudioInput: Unable to retrieve device format"; - return false; - } - - if (AudioUnitSetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Output, - 1, - &deviceFormat, - sizeof(deviceFormat)) != noErr) { - qWarning() << "QAudioInput: Unable to set device format"; - return false; - } - } - - // Setup buffers - UInt32 numberOfFrames; - size = sizeof(UInt32); - if (AudioUnitGetProperty(audioUnit, - kAudioDevicePropertyBufferFrameSize, - kAudioUnitScope_Global, - 0, - &numberOfFrames, - &size) != noErr) { - qWarning() << "QAudioInput: Failed to get audio period size"; - return false; - } - - // Allocate buffer - periodSizeBytes = numberOfFrames * streamFormat.mBytesPerFrame; - - if (internalBufferSize < periodSizeBytes * 2) - internalBufferSize = periodSizeBytes * 2; - else - internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; - - audioBuffer = new QtMultimediaInternal::QAudioInputBuffer(internalBufferSize, - periodSizeBytes, - deviceFormat, - streamFormat, - this); - - audioIO = new QtMultimediaInternal::MacInputDevice(audioBuffer, this); - - // Init - if (AudioUnitInitialize(audioUnit) != noErr) { - qWarning() << "QAudioInput: Failed to initialize AudioUnit"; - return false; - } - - isOpen = true; - - return isOpen; -} - -void QAudioInputPrivate::close() -{ - if (audioUnit != 0) { - AudioOutputUnitStop(audioUnit); - AudioUnitUninitialize(audioUnit); - CloseComponent(audioUnit); - } - - delete audioBuffer; -} - -QAudioFormat QAudioInputPrivate::format() const -{ - return audioFormat; -} - -QIODevice* QAudioInputPrivate::start(QIODevice* device) -{ - QIODevice* op = device; - - if (!audioFormat.isValid() || !open()) { - stateCode = QAudio::StoppedState; - errorCode = QAudio::OpenError; - return audioIO; - } - - reset(); - audioBuffer->reset(); - audioBuffer->setFlushDevice(op); - - if (op == 0) - op = audioIO; - - // Start - startTime = AudioGetCurrentHostTime(); - totalFrames = 0; - - audioThreadStart(); - - stateCode = QAudio::ActiveState; - errorCode = QAudio::NoError; - emit stateChanged(stateCode); - - return op; -} - -void QAudioInputPrivate::stop() -{ - QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { - audioThreadStop(); - audioBuffer->flush(true); - - errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioInputPrivate::reset() -{ - QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { - audioThreadStop(); - - errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioInputPrivate::suspend() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) { - audioThreadStop(); - - errorCode = QAudio::NoError; - stateCode = QAudio::SuspendedState; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioInputPrivate::resume() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::SuspendedState) { - audioThreadStart(); - - errorCode = QAudio::NoError; - stateCode = QAudio::ActiveState; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -int QAudioInputPrivate::bytesReady() const -{ - return audioBuffer->used(); -} - -int QAudioInputPrivate::periodSize() const -{ - return periodSizeBytes; -} - -void QAudioInputPrivate::setBufferSize(int bs) -{ - internalBufferSize = bs; -} - -int QAudioInputPrivate::bufferSize() const -{ - return internalBufferSize; -} - -void QAudioInputPrivate::setNotifyInterval(int milliSeconds) -{ - if (intervalTimer->interval() == milliSeconds) - return; - - if (milliSeconds <= 0) - milliSeconds = 0; - - intervalTimer->setInterval(milliSeconds); -} - -int QAudioInputPrivate::notifyInterval() const -{ - return intervalTimer->interval(); -} - -qint64 QAudioInputPrivate::processedUSecs() const -{ - return totalFrames * 1000000 / audioFormat.frequency(); -} - -qint64 QAudioInputPrivate::elapsedUSecs() const -{ - if (stateCode == QAudio::StoppedState) - return 0; - - return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); -} - -QAudio::Error QAudioInputPrivate::error() const -{ - return errorCode; -} - -QAudio::State QAudioInputPrivate::state() const -{ - return stateCode; -} - -void QAudioInputPrivate::audioThreadStop() -{ - stopTimers(); - if (audioThreadState.testAndSetAcquire(Running, Stopped)) - threadFinished.wait(&mutex); -} - -void QAudioInputPrivate::audioThreadStart() -{ - startTimers(); - audioThreadState = Running; - AudioOutputUnitStart(audioUnit); -} - -void QAudioInputPrivate::audioDeviceStop() -{ - AudioOutputUnitStop(audioUnit); - audioThreadState = Stopped; - threadFinished.wakeOne(); -} - -void QAudioInputPrivate::audioDeviceFull() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState) { - audioDeviceStop(); - - errorCode = QAudio::UnderrunError; - stateCode = QAudio::IdleState; - QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); - } -} - -void QAudioInputPrivate::audioDeviceError() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState) { - audioDeviceStop(); - - errorCode = QAudio::IOError; - stateCode = QAudio::StoppedState; - QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); - } -} - -void QAudioInputPrivate::startTimers() -{ - audioBuffer->startFlushTimer(); - if (intervalTimer->interval() > 0) - intervalTimer->start(); -} - -void QAudioInputPrivate::stopTimers() -{ - audioBuffer->stopFlushTimer(); - intervalTimer->stop(); -} - -void QAudioInputPrivate::deviceStopped() -{ - stopTimers(); - emit stateChanged(stateCode); -} - -// Input callback -OSStatus QAudioInputPrivate::inputCallback(void* inRefCon, - AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList* ioData) -{ - Q_UNUSED(ioData); - - QAudioInputPrivate* d = static_cast(inRefCon); - - const int threadState = d->audioThreadState.fetchAndAddAcquire(0); - if (threadState == Stopped) - d->audioDeviceStop(); - else { - qint64 framesWritten; - - framesWritten = d->audioBuffer->renderFromDevice(d->audioUnit, - ioActionFlags, - inTimeStamp, - inBusNumber, - inNumberFrames); - - if (framesWritten > 0) - d->totalFrames += framesWritten; - else if (framesWritten == 0) - d->audioDeviceFull(); - else if (framesWritten < 0) - d->audioDeviceError(); - } - - return noErr; -} - - -QT_END_NAMESPACE - -#include "qaudioinput_mac_p.moc" - diff --git a/src/multimedia/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/multimedia/audio/qaudioinput_mac_p.h deleted file mode 100644 index 7aa4168..0000000 --- a/src/multimedia/multimedia/audio/qaudioinput_mac_p.h +++ /dev/null @@ -1,169 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QAUDIOINPUT_MAC_P_H -#define QAUDIOINPUT_MAC_P_H - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QTimer; -class QIODevice; -class QAbstractAudioDeviceInfo; - -namespace QtMultimediaInternal -{ -class QAudioInputBuffer; -} - -class QAudioInputPrivate : public QAbstractAudioInput -{ - Q_OBJECT - -public: - bool isOpen; - int periodSizeBytes; - int internalBufferSize; - qint64 totalFrames; - QAudioFormat audioFormat; - QIODevice* audioIO; - AudioUnit audioUnit; - AudioDeviceID audioDeviceId; - Float64 clockFrequency; - UInt64 startTime; - QAudio::Error errorCode; - QAudio::State stateCode; - QtMultimediaInternal::QAudioInputBuffer* audioBuffer; - QMutex mutex; - QWaitCondition threadFinished; - QAtomicInt audioThreadState; - QTimer* intervalTimer; - AudioStreamBasicDescription streamFormat; - AudioStreamBasicDescription deviceFormat; - QAbstractAudioDeviceInfo *audioDeviceInfo; - - QAudioInputPrivate(const QByteArray& device, QAudioFormat const& format); - ~QAudioInputPrivate(); - - bool open(); - void close(); - - QAudioFormat format() const; - - QIODevice* start(QIODevice* device); - void stop(); - void reset(); - void suspend(); - void resume(); - void idle(); - - int bytesReady() const; - int periodSize() const; - - void setBufferSize(int value); - int bufferSize() const; - - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - - QAudio::Error error() const; - QAudio::State state() const; - - void audioThreadStart(); - void audioThreadStop(); - - void audioDeviceStop(); - void audioDeviceFull(); - void audioDeviceError(); - - void startTimers(); - void stopTimers(); - -private slots: - void deviceStopped(); - -private: - enum { Running, Stopped }; - - // Input callback - static OSStatus inputCallback(void* inRefCon, - AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList* ioData); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOINPUT_MAC_P_H diff --git a/src/multimedia/multimedia/audio/qaudioinput_symbian_p.cpp b/src/multimedia/multimedia/audio/qaudioinput_symbian_p.cpp deleted file mode 100644 index 52daa88..0000000 --- a/src/multimedia/multimedia/audio/qaudioinput_symbian_p.cpp +++ /dev/null @@ -1,594 +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 QtMultimedia 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 "qaudioinput_symbian_p.h" - -QT_BEGIN_NAMESPACE - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const int PushInterval = 50; // ms - - -//----------------------------------------------------------------------------- -// Private class -//----------------------------------------------------------------------------- - -SymbianAudioInputPrivate::SymbianAudioInputPrivate( - QAudioInputPrivate *audioDevice) - : m_audioDevice(audioDevice) -{ - -} - -SymbianAudioInputPrivate::~SymbianAudioInputPrivate() -{ - -} - -qint64 SymbianAudioInputPrivate::readData(char *data, qint64 len) -{ - qint64 totalRead = 0; - - if (m_audioDevice->state() == QAudio::ActiveState || - m_audioDevice->state() == QAudio::IdleState) { - - while (totalRead < len) { - const qint64 read = m_audioDevice->read(data + totalRead, - len - totalRead); - if (read > 0) - totalRead += read; - else - break; - } - } - - return totalRead; -} - -qint64 SymbianAudioInputPrivate::writeData(const char *data, qint64 len) -{ - Q_UNUSED(data) - Q_UNUSED(len) - return 0; -} - -void SymbianAudioInputPrivate::dataReady() -{ - emit readyRead(); -} - - -//----------------------------------------------------------------------------- -// Public functions -//----------------------------------------------------------------------------- - -QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, - const QAudioFormat &format) - : m_device(device) - , m_format(format) - , m_clientBufferSize(SymbianAudio::DefaultBufferSize) - , m_notifyInterval(SymbianAudio::DefaultNotifyInterval) - , m_notifyTimer(new QTimer(this)) - , m_error(QAudio::NoError) - , m_internalState(SymbianAudio::ClosedState) - , m_externalState(QAudio::StoppedState) - , m_pullMode(false) - , m_sink(0) - , m_pullTimer(new QTimer(this)) - , m_devSoundBuffer(0) - , m_devSoundBufferSize(0) - , m_totalBytesReady(0) - , m_devSoundBufferPos(0) - , m_totalSamplesRecorded(0) -{ - connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); - - SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, - m_nativeFormat); - - m_pullTimer->setInterval(PushInterval); - connect(m_pullTimer.data(), SIGNAL(timeout()), this, SLOT(pullData())); -} - -QAudioInputPrivate::~QAudioInputPrivate() -{ - close(); -} - -QIODevice* QAudioInputPrivate::start(QIODevice *device) -{ - stop(); - - open(); - if (SymbianAudio::ClosedState != m_internalState) { - if (device) { - m_pullMode = true; - m_sink = device; - } else { - m_sink = new SymbianAudioInputPrivate(this); - m_sink->open(QIODevice::ReadOnly | QIODevice::Unbuffered); - } - - m_elapsed.restart(); - } - - return m_sink; -} - -void QAudioInputPrivate::stop() -{ - close(); -} - -void QAudioInputPrivate::reset() -{ - m_totalSamplesRecorded += getSamplesRecorded(); - m_devSound->Stop(); - startRecording(); -} - -void QAudioInputPrivate::suspend() -{ - if (SymbianAudio::ActiveState == m_internalState - || SymbianAudio::IdleState == m_internalState) { - m_notifyTimer->stop(); - m_pullTimer->stop(); - m_devSound->Pause(); - const qint64 samplesRecorded = getSamplesRecorded(); - m_totalSamplesRecorded += samplesRecorded; - - if (m_devSoundBuffer) { - m_devSoundBufferQ.append(m_devSoundBuffer); - m_devSoundBuffer = 0; - } - - setState(SymbianAudio::SuspendedState); - } -} - -void QAudioInputPrivate::resume() -{ - if (SymbianAudio::SuspendedState == m_internalState) - startDataTransfer(); -} - -int QAudioInputPrivate::bytesReady() const -{ - Q_ASSERT(m_devSoundBufferPos <= m_totalBytesReady); - return m_totalBytesReady - m_devSoundBufferPos; -} - -int QAudioInputPrivate::periodSize() const -{ - return bufferSize(); -} - -void QAudioInputPrivate::setBufferSize(int value) -{ - // Note that DevSound does not allow its client to specify the buffer size. - // This functionality is available via custom interfaces, but since these - // cannot be guaranteed to work across all DevSound implementations, we - // do not use them here. - // In order to comply with the expected bevahiour of QAudioInput, we store - // the value and return it from bufferSize(), but the underlying DevSound - // buffer size remains unchanged. - if (value > 0) - m_clientBufferSize = value; -} - -int QAudioInputPrivate::bufferSize() const -{ - return m_devSoundBufferSize ? m_devSoundBufferSize : m_clientBufferSize; -} - -void QAudioInputPrivate::setNotifyInterval(int ms) -{ - if (ms > 0) { - const int oldNotifyInterval = m_notifyInterval; - m_notifyInterval = ms; - if (m_notifyTimer->isActive() && ms != oldNotifyInterval) - m_notifyTimer->start(m_notifyInterval); - } -} - -int QAudioInputPrivate::notifyInterval() const -{ - return m_notifyInterval; -} - -qint64 QAudioInputPrivate::processedUSecs() const -{ - int samplesPlayed = 0; - if (m_devSound && SymbianAudio::SuspendedState != m_internalState) - samplesPlayed = getSamplesRecorded(); - - // Protect against division by zero - Q_ASSERT_X(m_format.frequency() > 0, Q_FUNC_INFO, "Invalid frequency"); - - const qint64 result = qint64(1000000) * - (samplesPlayed + m_totalSamplesRecorded) - / m_format.frequency(); - - return result; -} - -qint64 QAudioInputPrivate::elapsedUSecs() const -{ - const qint64 result = (QAudio::StoppedState == state()) ? - 0 : m_elapsed.elapsed() * 1000; - return result; -} - -QAudio::Error QAudioInputPrivate::error() const -{ - return m_error; -} - -QAudio::State QAudioInputPrivate::state() const -{ - return m_externalState; -} - -QAudioFormat QAudioInputPrivate::format() const -{ - return m_format; -} - -//----------------------------------------------------------------------------- -// MDevSoundObserver implementation -//----------------------------------------------------------------------------- - -void QAudioInputPrivate::InitializeComplete(TInt aError) -{ - Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, - Q_FUNC_INFO, "Invalid state"); - - if (KErrNone == aError) - startRecording(); -} - -void QAudioInputPrivate::ToneFinished(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's tone playback functions, so should - // never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) -{ - Q_UNUSED(aBuffer) - // This class doesn't use DevSound in play mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::PlayError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound in play mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::BufferToBeEmptied(CMMFBuffer *aBuffer) -{ - // Following receipt of this callback, DevSound should not provide another - // buffer until we have returned the current one. - Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); - - CMMFDataBuffer *const buffer = static_cast(aBuffer); - - if (!m_devSoundBufferSize) - m_devSoundBufferSize = buffer->Data().MaxLength(); - - m_totalBytesReady += buffer->Data().Length(); - - if (SymbianAudio::SuspendedState == m_internalState) { - m_devSoundBufferQ.append(buffer); - } else { - // Will be returned to DevSound by bufferEmptied(). - m_devSoundBuffer = buffer; - m_devSoundBufferPos = 0; - - if (bytesReady() && !m_pullMode) - pushData(); - } -} - -void QAudioInputPrivate::RecordError(TInt aError) -{ - Q_UNUSED(aError) - setError(QAudio::IOError); -} - -void QAudioInputPrivate::ConvertError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's format conversion functions, so - // should never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) -{ - Q_UNUSED(aMessageType) - Q_UNUSED(aMsg) - // Ignore this callback. -} - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -void QAudioInputPrivate::open() -{ - Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, - Q_FUNC_INFO, "DevSound already opened"); - - QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) - - QScopedPointer caps( - new SymbianAudio::DevSoundCapabilities(*m_devSound, QAudio::AudioInput)); - - int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? - KErrNone : KErrNotSupported; - - if (KErrNone == err) { - setState(SymbianAudio::InitializingState); - TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, - EMMFStateRecording)); - } - - if (KErrNone != err) { - setError(QAudio::OpenError); - m_devSound.reset(); - } -} - -void QAudioInputPrivate::startRecording() -{ - const int samplesRecorded = m_devSound->SamplesRecorded(); - Q_ASSERT(samplesRecorded == 0); - - TRAPD(err, startDevSoundL()); - if (KErrNone == err) { - startDataTransfer(); - } else { - setError(QAudio::OpenError); - close(); - } -} - -void QAudioInputPrivate::startDevSoundL() -{ - TMMFCapabilities nativeFormat = m_devSound->Config(); - m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; - m_devSound->SetConfigL(m_nativeFormat); - m_devSound->RecordInitL(); -} - -void QAudioInputPrivate::startDataTransfer() -{ - m_notifyTimer->start(m_notifyInterval); - - if (m_pullMode) - m_pullTimer->start(); - - if (bytesReady()) { - setState(SymbianAudio::ActiveState); - if (!m_pullMode) - pushData(); - } else { - if (SymbianAudio::SuspendedState == m_internalState) - setState(SymbianAudio::ActiveState); - else - setState(SymbianAudio::IdleState); - } -} - -CMMFDataBuffer* QAudioInputPrivate::currentBuffer() const -{ - CMMFDataBuffer *result = m_devSoundBuffer; - if (!result && !m_devSoundBufferQ.empty()) - result = m_devSoundBufferQ.front(); - return result; -} - -void QAudioInputPrivate::pushData() -{ - Q_ASSERT_X(bytesReady(), Q_FUNC_INFO, "No data available"); - Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, "pushData called when in pull mode"); - qobject_cast(m_sink)->dataReady(); -} - -qint64 QAudioInputPrivate::read(char *data, qint64 len) -{ - // SymbianAudioInputPrivate is ready to read data - - Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, - "read called when in pull mode"); - - qint64 bytesRead = 0; - - CMMFDataBuffer *buffer = 0; - while ((buffer = currentBuffer()) && (bytesRead < len)) { - if (SymbianAudio::IdleState == m_internalState) - setState(SymbianAudio::ActiveState); - - TDesC8 &inputBuffer = buffer->Data(); - - const qint64 inputBytes = bytesReady(); - const qint64 outputBytes = len - bytesRead; - const qint64 copyBytes = outputBytes < inputBytes ? - outputBytes : inputBytes; - - memcpy(data, inputBuffer.Ptr() + m_devSoundBufferPos, copyBytes); - - m_devSoundBufferPos += copyBytes; - data += copyBytes; - bytesRead += copyBytes; - - if (!bytesReady()) - bufferEmptied(); - } - - return bytesRead; -} - -void QAudioInputPrivate::pullData() -{ - Q_ASSERT_X(m_pullMode, Q_FUNC_INFO, - "pullData called when in push mode"); - - CMMFDataBuffer *buffer = 0; - while (buffer = currentBuffer()) { - if (SymbianAudio::IdleState == m_internalState) - setState(SymbianAudio::ActiveState); - - TDesC8 &inputBuffer = buffer->Data(); - - const qint64 inputBytes = bytesReady(); - const qint64 bytesPushed = m_sink->write( - (char*)inputBuffer.Ptr() + m_devSoundBufferPos, inputBytes); - - m_devSoundBufferPos += bytesPushed; - - if (!bytesReady()) - bufferEmptied(); - - if (!bytesPushed) - break; - } -} - -void QAudioInputPrivate::bufferEmptied() -{ - m_devSoundBufferPos = 0; - - if (m_devSoundBuffer) { - m_totalBytesReady -= m_devSoundBuffer->Data().Length(); - m_devSoundBuffer = 0; - m_devSound->RecordData(); - } else { - Q_ASSERT(!m_devSoundBufferQ.empty()); - m_totalBytesReady -= m_devSoundBufferQ.front()->Data().Length(); - m_devSoundBufferQ.erase(m_devSoundBufferQ.begin()); - - // If the queue has been emptied, resume transfer from the hardware - if (m_devSoundBufferQ.empty()) - m_devSound->RecordInitL(); - } - - Q_ASSERT(m_totalBytesReady >= 0); -} - -void QAudioInputPrivate::close() -{ - m_notifyTimer->stop(); - m_pullTimer->stop(); - - m_error = QAudio::NoError; - - if (m_devSound) - m_devSound->Stop(); - m_devSound.reset(); - m_devSoundBuffer = 0; - m_devSoundBufferSize = 0; - m_totalBytesReady = 0; - - if (!m_pullMode) // m_sink is owned - delete m_sink; - m_pullMode = false; - m_sink = 0; - - m_devSoundBufferQ.clear(); - m_devSoundBufferPos = 0; - m_totalSamplesRecorded = 0; - - setState(SymbianAudio::ClosedState); -} - -qint64 QAudioInputPrivate::getSamplesRecorded() const -{ - qint64 result = 0; - if (m_devSound) - result = qint64(m_devSound->SamplesRecorded()); - return result; -} - -void QAudioInputPrivate::setError(QAudio::Error error) -{ - m_error = error; - - // Although no state transition actually occurs here, a stateChanged event - // must be emitted to inform the client that the call to start() was - // unsuccessful. - if (QAudio::OpenError == error) - emit stateChanged(QAudio::StoppedState); - - // Close the DevSound instance. This causes a transition to StoppedState. - // This must be done asynchronously in case the current function was called - // from a DevSound event handler, in which case deleting the DevSound - // instance may cause an exception. - QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); -} - -void QAudioInputPrivate::setState(SymbianAudio::State newInternalState) -{ - const QAudio::State oldExternalState = m_externalState; - m_internalState = newInternalState; - m_externalState = SymbianAudio::Utils::stateNativeToQt( - m_internalState, initializingState()); - - if (m_externalState != oldExternalState) - emit stateChanged(m_externalState); -} - -QAudio::State QAudioInputPrivate::initializingState() const -{ - return QAudio::IdleState; -} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudioinput_symbian_p.h b/src/multimedia/multimedia/audio/qaudioinput_symbian_p.h deleted file mode 100644 index ca3ccf7..0000000 --- a/src/multimedia/multimedia/audio/qaudioinput_symbian_p.h +++ /dev/null @@ -1,188 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIOINPUT_SYMBIAN_P_H -#define QAUDIOINPUT_SYMBIAN_P_H - -#include -#include -#include -#include -#include "qaudio_symbian_p.h" - -QT_BEGIN_NAMESPACE - -class QAudioInputPrivate; - -class SymbianAudioInputPrivate : public QIODevice -{ - friend class QAudioInputPrivate; - Q_OBJECT -public: - SymbianAudioInputPrivate(QAudioInputPrivate *audio); - ~SymbianAudioInputPrivate(); - - qint64 readData(char *data, qint64 len); - qint64 writeData(const char *data, qint64 len); - - void dataReady(); - -private: - QAudioInputPrivate *const m_audioDevice; -}; - -class QAudioInputPrivate - : public QAbstractAudioInput - , public MDevSoundObserver -{ - friend class SymbianAudioInputPrivate; - Q_OBJECT -public: - QAudioInputPrivate(const QByteArray &device, - const QAudioFormat &audioFormat); - ~QAudioInputPrivate(); - - // QAbstractAudioInput - QIODevice* start(QIODevice *device = 0); - void stop(); - void reset(); - void suspend(); - void resume(); - int bytesReady() const; - int periodSize() const; - void setBufferSize(int value); - int bufferSize() const; - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - QAudio::Error error() const; - QAudio::State state() const; - QAudioFormat format() const; - - // MDevSoundObserver - void InitializeComplete(TInt aError); - void ToneFinished(TInt aError); - void BufferToBeFilled(CMMFBuffer *aBuffer); - void PlayError(TInt aError); - void BufferToBeEmptied(CMMFBuffer *aBuffer); - void RecordError(TInt aError); - void ConvertError(TInt aError); - void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); - -private slots: - void pullData(); - -private: - void open(); - void startRecording(); - void startDevSoundL(); - void startDataTransfer(); - CMMFDataBuffer* currentBuffer() const; - void pushData(); - qint64 read(char *data, qint64 len); - void bufferEmptied(); - Q_INVOKABLE void close(); - - qint64 getSamplesRecorded() const; - - void setError(QAudio::Error error); - void setState(SymbianAudio::State state); - - QAudio::State initializingState() const; - -private: - const QByteArray m_device; - const QAudioFormat m_format; - - int m_clientBufferSize; - int m_notifyInterval; - QScopedPointer m_notifyTimer; - QTime m_elapsed; - QAudio::Error m_error; - - SymbianAudio::State m_internalState; - QAudio::State m_externalState; - - bool m_pullMode; - QIODevice *m_sink; - - QScopedPointer m_pullTimer; - - QScopedPointer m_devSound; - TUint32 m_nativeFourCC; - TMMFCapabilities m_nativeFormat; - - // Latest buffer provided by DevSound, to be empied of data. - CMMFDataBuffer *m_devSoundBuffer; - - int m_devSoundBufferSize; - - // Total amount of data in buffers provided by DevSound - int m_totalBytesReady; - - // Queue of buffers returned after call to CMMFDevSound::Pause(). - QList m_devSoundBufferQ; - - // Current read position within m_devSoundBuffer - qint64 m_devSoundBufferPos; - - // Samples recorded up to the last call to suspend(). It is necessary - // to cache this because suspend() is implemented using - // CMMFDevSound::Stop(), which resets DevSound's SamplesRecorded() counter. - quint32 m_totalSamplesRecorded; - -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/multimedia/audio/qaudioinput_win32_p.cpp deleted file mode 100644 index 14a1cf3..0000000 --- a/src/multimedia/multimedia/audio/qaudioinput_win32_p.cpp +++ /dev/null @@ -1,604 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include "qaudioinput_win32_p.h" - -QT_BEGIN_NAMESPACE - -//#define DEBUG_AUDIO 1 - -QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): - settings(audioFormat) -{ - bytesAvailable = 0; - buffer_size = 0; - period_size = 0; - m_device = device; - totalTimeValue = 0; - intervalTime = 1000; - errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; - audioSource = 0; - pullMode = true; - resuming = false; - finished = false; -} - -QAudioInputPrivate::~QAudioInputPrivate() -{ - stop(); -} - -void QT_WIN_CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg, - DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ) -{ - Q_UNUSED(dwParam1) - Q_UNUSED(dwParam2) - Q_UNUSED(hWaveIn) - - QAudioInputPrivate* qAudio; - qAudio = (QAudioInputPrivate*)(dwInstance); - if(!qAudio) - return; - - QMutexLocker(&qAudio->mutex); - - switch(uMsg) { - case WIM_OPEN: - break; - case WIM_DATA: - if(qAudio->waveFreeBlockCount > 0) - qAudio->waveFreeBlockCount--; - qAudio->feedback(); - break; - case WIM_CLOSE: - qAudio->finished = true; - break; - default: - return; - } -} - -WAVEHDR* QAudioInputPrivate::allocateBlocks(int size, int count) -{ - int i; - unsigned char* buffer; - WAVEHDR* blocks; - DWORD totalBufferSize = (size + sizeof(WAVEHDR))*count; - - if((buffer=(unsigned char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, - totalBufferSize)) == 0) { - qWarning("QAudioInput: Memory allocation error"); - return 0; - } - blocks = (WAVEHDR*)buffer; - buffer += sizeof(WAVEHDR)*count; - for(i = 0; i < count; i++) { - blocks[i].dwBufferLength = size; - blocks[i].lpData = (LPSTR)buffer; - blocks[i].dwBytesRecorded=0; - blocks[i].dwUser = 0L; - blocks[i].dwFlags = 0L; - blocks[i].dwLoops = 0L; - result = waveInPrepareHeader(hWaveIn,&blocks[i], sizeof(WAVEHDR)); - if(result != MMSYSERR_NOERROR) { - qWarning("QAudioInput: Can't prepare block %d",i); - return 0; - } - buffer += size; - } - return blocks; -} - -void QAudioInputPrivate::freeBlocks(WAVEHDR* blockArray) -{ - WAVEHDR* blocks = blockArray; - - int count = buffer_size/period_size; - - for(int i = 0; i < count; i++) { - waveInUnprepareHeader(hWaveIn,blocks, sizeof(WAVEHDR)); - blocks+=sizeof(WAVEHDR); - } - HeapFree(GetProcessHeap(), 0, blockArray); -} - -QAudio::Error QAudioInputPrivate::error() const -{ - return errorState; -} - -QAudio::State QAudioInputPrivate::state() const -{ - return deviceState; -} - -QAudioFormat QAudioInputPrivate::format() const -{ - return settings; -} - -QIODevice* QAudioInputPrivate::start(QIODevice* device) -{ - if(deviceState != QAudio::StoppedState) - close(); - - if(!pullMode && audioSource) { - delete audioSource; - } - - if(device) { - //set to pull mode - pullMode = true; - audioSource = device; - deviceState = QAudio::ActiveState; - } else { - //set to push mode - pullMode = false; - deviceState = QAudio::IdleState; - audioSource = new InputPrivate(this); - audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered); - } - - if( !open() ) - return 0; - - emit stateChanged(deviceState); - - return audioSource; -} - -void QAudioInputPrivate::stop() -{ - if(deviceState == QAudio::StoppedState) - return; - - close(); - emit stateChanged(deviceState); -} - -bool QAudioInputPrivate::open() -{ -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()<> 3) * wfx.nChannels; - wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec; - - UINT_PTR devId = WAVE_MAPPER; - - WAVEINCAPS wic; - unsigned long iNumDevs,ii; - iNumDevs = waveInGetNumDevs(); - for(ii=0;ii 0 && waveBlocks[header].dwFlags & WHDR_DONE) { - if(pullMode) { - l = audioSource->write(waveBlocks[header].lpData, - waveBlocks[header].dwBytesRecorded); -#ifdef DEBUG_AUDIO - qDebug()<<"IN: "<= buffer_size/period_size) - header = 0; - p+=l; - - mutex.lock(); - if(!pullMode) { - if(l+period_size > len && waveFreeBlockCount == buffer_size/period_size) - done = true; - } else { - if(waveFreeBlockCount == buffer_size/period_size) - done = true; - } - mutex.unlock(); - - written+=l; - } -#ifdef DEBUG_AUDIO - qDebug()<<"read in len="<(audioSource); - a->trigger(); - } - - if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { - emit notify(); - elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; - timeStamp.restart(); - } - return true; -} - -qint64 QAudioInputPrivate::elapsedUSecs() const -{ - if (deviceState == QAudio::StoppedState) - return 0; - - return timeStampOpened.elapsed()*1000; -} - -void QAudioInputPrivate::reset() -{ - close(); -} - -InputPrivate::InputPrivate(QAudioInputPrivate* audio) -{ - audioDevice = qobject_cast(audio); -} - -InputPrivate::~InputPrivate() {} - -qint64 InputPrivate::readData( char* data, qint64 len) -{ - // push mode, user read() called - if(audioDevice->deviceState != QAudio::ActiveState && - audioDevice->deviceState != QAudio::IdleState) - return 0; - // Read in some audio data - return audioDevice->read(data,len); -} - -qint64 InputPrivate::writeData(const char* data, qint64 len) -{ - Q_UNUSED(data) - Q_UNUSED(len) - - emit readyRead(); - return 0; -} - -void InputPrivate::trigger() -{ - emit readyRead(); -} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/multimedia/audio/qaudioinput_win32_p.h deleted file mode 100644 index 8a9b02b..0000000 --- a/src/multimedia/multimedia/audio/qaudioinput_win32_p.h +++ /dev/null @@ -1,160 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIOINPUTWIN_H -#define QAUDIOINPUTWIN_H - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -class QAudioInputPrivate : public QAbstractAudioInput -{ - Q_OBJECT -public: - QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat); - ~QAudioInputPrivate(); - - qint64 read(char* data, qint64 len); - - QAudioFormat format() const; - QIODevice* start(QIODevice* device = 0); - void stop(); - void reset(); - void suspend(); - void resume(); - int bytesReady() const; - int periodSize() const; - void setBufferSize(int value); - int bufferSize() const; - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - QAudio::Error error() const; - QAudio::State state() const; - - QIODevice* audioSource; - QAudioFormat settings; - QAudio::Error errorState; - QAudio::State deviceState; - -private: - qint32 buffer_size; - qint32 period_size; - qint32 header; - QByteArray m_device; - int bytesAvailable; - int intervalTime; - QTime timeStamp; - qint64 elapsedTimeOffset; - QTime timeStampOpened; - qint64 totalTimeValue; - bool pullMode; - bool resuming; - WAVEFORMATEX wfx; - HWAVEIN hWaveIn; - MMRESULT result; - WAVEHDR* waveBlocks; - volatile bool finished; - volatile int waveFreeBlockCount; - int waveCurrentBlock; - - QMutex mutex; - static void QT_WIN_CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg, - DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); - - WAVEHDR* allocateBlocks(int size, int count); - void freeBlocks(WAVEHDR* blockArray); - bool open(); - void close(); - -private slots: - void feedback(); - bool deviceReady(); - -signals: - void processMore(); -}; - -class InputPrivate : public QIODevice -{ - Q_OBJECT -public: - InputPrivate(QAudioInputPrivate* audio); - ~InputPrivate(); - - qint64 readData( char* data, qint64 len); - qint64 writeData(const char* data, qint64 len); - - void trigger(); -private: - QAudioInputPrivate *audioDevice; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/multimedia/audio/qaudiooutput.cpp b/src/multimedia/multimedia/audio/qaudiooutput.cpp deleted file mode 100644 index b0b5244..0000000 --- a/src/multimedia/multimedia/audio/qaudiooutput.cpp +++ /dev/null @@ -1,411 +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 QtMultimedia 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 -#include -#include -#include - -#include "qaudiodevicefactory_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \class QAudioOutput - \brief The QAudioOutput class provides an interface for sending audio data to an audio output device. - - \inmodule QtMultimedia - \ingroup multimedia - \since 4.6 - - You can construct an audio output with the system's - \l{QAudioDeviceInfo::defaultOutputDevice()}{default audio output - device}. It is also possible to create QAudioOutput with a - specific QAudioDeviceInfo. When you create the audio output, you - should also send in the QAudioFormat to be used for the playback - (see the QAudioFormat class description for details). - - To play a file: - - Starting to play an audio stream is simply a matter of calling - start() with a QIODevice. QAudioOutput will then fetch the data it - needs from the io device. So playing back an audio file is as - simple as: - - \code - QFile inputFile; // class member. - QAudioOutput* audio; // class member. - \endcode - - \code - inputFile.setFileName("/tmp/test.raw"); - inputFile.open(QIODevice::ReadOnly); - - QAudioFormat format; - // Set up the format, eg. - format.setFrequency(8000); - format.setChannels(1); - format.setSampleSize(8); - format.setCodec("audio/pcm"); - format.setByteOrder(QAudioFormat::LittleEndian); - format.setSampleType(QAudioFormat::UnSignedInt); - - QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); - if (!info.isFormatSupported(format)) { - qWarning()<<"raw audio format not supported by backend, cannot play audio."; - return; - } - - audio = new QAudioOutput(format, this); - connect(audio,SIGNAL(stateChanged(QAudio::State)),SLOT(finishedPlaying(QAudio::State))); - audio->start(&inputFile); - - \endcode - - The file will start playing assuming that the audio system and - output device support it. If you run out of luck, check what's - up with the error() function. - - After the file has finished playing, we need to stop the device: - - \code - void finishedPlaying(QAudio::State state) - { - if(state == QAudio::IdleState) { - audio->stop(); - inputFile.close(); - delete audio; - } - } - \endcode - - At any given time, the QAudioOutput will be in one of four states: - active, suspended, stopped, or idle. These states are described - by the QAudio::State enum. - State changes are reported through the stateChanged() signal. You - can use this signal to, for instance, update the GUI of the - application; the mundane example here being changing the state of - a \c { play/pause } button. You request a state change directly - with suspend(), stop(), reset(), resume(), and start(). - - While the stream is playing, you can set a notify interval in - milliseconds with setNotifyInterval(). This interval specifies the - time between two emissions of the notify() signal. This is - relative to the position in the stream, i.e., if the QAudioOutput - is in the SuspendedState or the IdleState, the notify() signal is - not emitted. A typical use-case would be to update a - \l{QSlider}{slider} that allows seeking in the stream. - If you want the time since playback started regardless of which - states the audio output has been in, elapsedUSecs() is the function for you. - - If an error occurs, you can fetch the \l{QAudio::Error}{error - type} with the error() function. Please see the QAudio::Error enum - for a description of the possible errors that are reported. When - an error is encountered, the state changes to QAudio::StoppedState. - You can check for errors by connecting to the stateChanged() - signal: - - \snippet doc/src/snippets/audio/main.cpp 3 - - \sa QAudioInput, QAudioDeviceInfo -*/ - -/*! - Construct a new audio output and attach it to \a parent. - The default audio output device is used with the output - \a format parameters. -*/ - -QAudioOutput::QAudioOutput(const QAudioFormat &format, QObject *parent): - QObject(parent) -{ - d = QAudioDeviceFactory::createDefaultOutputDevice(format); - connect(d, SIGNAL(notify()), SIGNAL(notify())); - connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); -} - -/*! - Construct a new audio output and attach it to \a parent. - The device referenced by \a audioDevice is used with the output - \a format parameters. -*/ - -QAudioOutput::QAudioOutput(const QAudioDeviceInfo &audioDevice, const QAudioFormat &format, QObject *parent): - QObject(parent) -{ - d = QAudioDeviceFactory::createOutputDevice(audioDevice, format); - connect(d, SIGNAL(notify()), SIGNAL(notify())); - connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); -} - -/*! - Destroys this audio output. -*/ - -QAudioOutput::~QAudioOutput() -{ - delete d; -} - -/*! - Returns the QAudioFormat being used. - -*/ - -QAudioFormat QAudioOutput::format() const -{ - return d->format(); -} - -/*! - Uses the \a device as the QIODevice to transfer data. - Passing a QIODevice allows the data to be transfered without any extra code. - All that is required is to open the QIODevice. - - If able to successfully output audio data to the systems audio device the - state() is set to QAudio::ActiveState, error() is set to QAudio::NoError - and the stateChanged() signal is emitted. - - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. - - \sa QIODevice -*/ - -void QAudioOutput::start(QIODevice* device) -{ - d->start(device); -} - -/*! - Returns a pointer to the QIODevice being used to handle the data - transfer. This QIODevice can be used to write() audio data directly. - - If able to access the systems audio device the state() is set to - QAudio::IdleState, error() is set to QAudio::NoError - and the stateChanged() signal is emitted. - - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. - - \sa QIODevice -*/ - -QIODevice* QAudioOutput::start() -{ - return d->start(0); -} - -/*! - Stops the audio output, detaching from the system resource. - - Sets error() to QAudio::NoError, state() to QAudio::StoppedState and - emit stateChanged() signal. -*/ - -void QAudioOutput::stop() -{ - d->stop(); -} - -/*! - Drops all audio data in the buffers, resets buffers to zero. -*/ - -void QAudioOutput::reset() -{ - d->reset(); -} - -/*! - Stops processing audio data, preserving buffered audio data. - - Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and - emit stateChanged() signal. -*/ - -void QAudioOutput::suspend() -{ - d->suspend(); -} - -/*! - Resumes processing audio data after a suspend(). - - Sets error() to QAudio::NoError. - Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). - Sets state() to QAudio::IdleState if you previously called start(). - emits stateChanged() signal. -*/ - -void QAudioOutput::resume() -{ - d->resume(); -} - -/*! - Returns the free space available in bytes in the audio buffer. - - NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState - state, otherwise returns zero. -*/ - -int QAudioOutput::bytesFree() const -{ - return d->bytesFree(); -} - -/*! - Returns the period size in bytes. - - Note: This is the recommended write size in bytes. -*/ - -int QAudioOutput::periodSize() const -{ - return d->periodSize(); -} - -/*! - Sets the audio buffer size to \a value in bytes. - - Note: This function can be called anytime before start(), calls to this - are ignored after start(). It should not be assumed that the buffer size - set is the actual buffer size used, calling bufferSize() anytime after start() - will return the actual buffer size being used. -*/ - -void QAudioOutput::setBufferSize(int value) -{ - d->setBufferSize(value); -} - -/*! - Returns the audio buffer size in bytes. - - If called before start(), returns platform default value. - If called before start() but setBufferSize() was called prior, returns value set by setBufferSize(). - If called after start(), returns the actual buffer size being used. This may not be what was set previously - by setBufferSize(). - -*/ - -int QAudioOutput::bufferSize() const -{ - return d->bufferSize(); -} - -/*! - Sets the interval for notify() signal to be emitted. - This is based on the \a ms of audio data processed - not on actual real-time. - The minimum resolution of the timer is platform specific and values - should be checked with notifyInterval() to confirm actual value - being used. -*/ - -void QAudioOutput::setNotifyInterval(int ms) -{ - d->setNotifyInterval(ms); -} - -/*! - Returns the notify interval in milliseconds. -*/ - -int QAudioOutput::notifyInterval() const -{ - return d->notifyInterval(); -} - -/*! - Returns the amount of audio data processed since start() - was called in microseconds. -*/ - -qint64 QAudioOutput::processedUSecs() const -{ - return d->processedUSecs(); -} - -/*! - Returns the microseconds since start() was called, including time in Idle and - Suspend states. -*/ - -qint64 QAudioOutput::elapsedUSecs() const -{ - return d->elapsedUSecs(); -} - -/*! - Returns the error state. -*/ - -QAudio::Error QAudioOutput::error() const -{ - return d->error(); -} - -/*! - Returns the state of audio processing. -*/ - -QAudio::State QAudioOutput::state() const -{ - return d->state(); -} - -/*! - \fn QAudioOutput::stateChanged(QAudio::State state) - This signal is emitted when the device \a state has changed. - This is the current state of the audio output. -*/ - -/*! - \fn QAudioOutput::notify() - This signal is emitted when x ms of audio data has been processed - the interval set by setNotifyInterval(x). -*/ - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudiooutput.h b/src/multimedia/multimedia/audio/qaudiooutput.h deleted file mode 100644 index 0f45b1b..0000000 --- a/src/multimedia/multimedia/audio/qaudiooutput.h +++ /dev/null @@ -1,111 +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 QtMultimedia 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 QAUDIOOUTPUT_H -#define QAUDIOOUTPUT_H - -#include -#include - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAbstractAudioOutput; - -class Q_MULTIMEDIA_EXPORT QAudioOutput : public QObject -{ - Q_OBJECT - -public: - explicit QAudioOutput(const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); - explicit QAudioOutput(const QAudioDeviceInfo &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); - ~QAudioOutput(); - - QAudioFormat format() const; - - void start(QIODevice *device); - QIODevice* start(); - - void stop(); - void reset(); - void suspend(); - void resume(); - - void setBufferSize(int bytes); - int bufferSize() const; - - int bytesFree() const; - int periodSize() const; - - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - - QAudio::Error error() const; - QAudio::State state() const; - -Q_SIGNALS: - void stateChanged(QAudio::State); - void notify(); - -private: - Q_DISABLE_COPY(QAudioOutput) - - QAbstractAudioOutput* d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOOUTPUT_H diff --git a/src/multimedia/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/multimedia/audio/qaudiooutput_alsa_p.cpp deleted file mode 100644 index 49b32c0..0000000 --- a/src/multimedia/multimedia/audio/qaudiooutput_alsa_p.cpp +++ /dev/null @@ -1,774 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include "qaudiooutput_alsa_p.h" -#include "qaudiodeviceinfo_alsa_p.h" - -QT_BEGIN_NAMESPACE - -//#define DEBUG_AUDIO 1 - -QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): - settings(audioFormat) -{ - bytesAvailable = 0; - handle = 0; - ahandler = 0; - access = SND_PCM_ACCESS_RW_INTERLEAVED; - pcmformat = SND_PCM_FORMAT_S16; - buffer_frames = 0; - period_frames = 0; - buffer_size = 0; - period_size = 0; - buffer_time = 100000; - period_time = 20000; - totalTimeValue = 0; - intervalTime = 1000; - audioBuffer = 0; - errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; - audioSource = 0; - pullMode = true; - resuming = false; - opened = false; - - m_device = device; - - timer = new QTimer(this); - connect(timer,SIGNAL(timeout()),SLOT(userFeed())); -} - -QAudioOutputPrivate::~QAudioOutputPrivate() -{ - close(); - disconnect(timer, SIGNAL(timeout())); - QCoreApplication::processEvents(); - delete timer; -} - -QAudio::Error QAudioOutputPrivate::error() const -{ - return errorState; -} - -QAudio::State QAudioOutputPrivate::state() const -{ - return deviceState; -} - -void QAudioOutputPrivate::async_callback(snd_async_handler_t *ahandler) -{ - QAudioOutputPrivate* audioOut; - - audioOut = static_cast - (snd_async_handler_get_callback_private(ahandler)); - - if((audioOut->deviceState==QAudio::ActiveState)||(audioOut->resuming)) - audioOut->feedback(); -} - -int QAudioOutputPrivate::xrun_recovery(int err) -{ - int count = 0; - bool reset = false; - - if(err == -EPIPE) { - errorState = QAudio::UnderrunError; - err = snd_pcm_prepare(handle); - if(err < 0) - reset = true; - - } else if((err == -ESTRPIPE)||(err == -EIO)) { - errorState = QAudio::IOError; - while((err = snd_pcm_resume(handle)) == -EAGAIN){ - usleep(100); - count++; - if(count > 5) { - reset = true; - break; - } - } - if(err < 0) { - err = snd_pcm_prepare(handle); - if(err < 0) - reset = true; - } - } - if(reset) { - close(); - open(); - snd_pcm_prepare(handle); - return 0; - } - return err; -} - -int QAudioOutputPrivate::setFormat() -{ - snd_pcm_format_t pcmformat = SND_PCM_FORMAT_S16; - - if(settings.sampleSize() == 8) { - pcmformat = SND_PCM_FORMAT_U8; - - } else if(settings.sampleSize() == 16) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_S16_LE; - else - pcmformat = SND_PCM_FORMAT_S16_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_U16_LE; - else - pcmformat = SND_PCM_FORMAT_U16_BE; - } - } else if(settings.sampleSize() == 24) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_S24_LE; - else - pcmformat = SND_PCM_FORMAT_S24_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_U24_LE; - else - pcmformat = SND_PCM_FORMAT_U24_BE; - } - } else if(settings.sampleSize() == 32) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_S32_LE; - else - pcmformat = SND_PCM_FORMAT_S32_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_U32_LE; - else - pcmformat = SND_PCM_FORMAT_U32_BE; - } else if(settings.sampleType() == QAudioFormat::Float) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_FLOAT_LE; - else - pcmformat = SND_PCM_FORMAT_FLOAT_BE; - } - } else if(settings.sampleSize() == 64) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_FLOAT64_LE; - else - pcmformat = SND_PCM_FORMAT_FLOAT64_BE; - } - - return snd_pcm_hw_params_set_format( handle, hwparams, pcmformat); -} - -QIODevice* QAudioOutputPrivate::start(QIODevice* device) -{ - if(deviceState != QAudio::StoppedState) - deviceState = QAudio::StoppedState; - - errorState = QAudio::NoError; - - // Handle change of mode - if(audioSource && pullMode && !device) { - // pull -> push - close(); - audioSource = 0; - } else if(audioSource && !pullMode && device) { - // push -> pull - close(); - delete audioSource; - audioSource = 0; - } - - if(device) { - //set to pull mode - pullMode = true; - audioSource = device; - deviceState = QAudio::ActiveState; - } else { - //set to push mode - if(!audioSource) { - audioSource = new OutputPrivate(this); - audioSource->open(QIODevice::WriteOnly|QIODevice::Unbuffered); - } - pullMode = false; - deviceState = QAudio::IdleState; - } - - open(); - - emit stateChanged(deviceState); - - return audioSource; -} - -void QAudioOutputPrivate::stop() -{ - if(deviceState == QAudio::StoppedState) - return; - errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; - close(); - emit stateChanged(deviceState); -} - -bool QAudioOutputPrivate::open() -{ - if(opened) - return true; - -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()< devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); - if(dev.compare(QLatin1String("default")) == 0) { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = QLatin1String(devices.first()); -#else - dev = QLatin1String("hw:0,0"); -#endif - } else { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = QLatin1String(m_device); -#else - int idx = 0; - char *name; - - QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData()); - - while(snd_card_get_name(idx,&name) == 0) { - if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0) - break; - idx++; - } - dev = QString(QLatin1String("hw:%1,0")).arg(idx); -#endif - } - - // Step 1: try and open the device - while((count < 5) && (err < 0)) { - err=snd_pcm_open(&handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); - if(err < 0) - count++; - } - if (( err < 0)||(handle == 0)) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - return false; - } - snd_pcm_nonblock( handle, 0 ); - - // Step 2: Set the desired HW parameters. - snd_pcm_hw_params_alloca( &hwparams ); - - bool fatal = false; - QString errMessage; - unsigned int chunks = 8; - - err = snd_pcm_hw_params_any( handle, hwparams ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_any: err = %1").arg(err); - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_rate_resample( handle, hwparams, 1 ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_rate_resample: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_access( handle, hwparams, access ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_access: err = %1").arg(err); - } - } - if ( !fatal ) { - err = setFormat(); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_format: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_channels: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &freakuency, 0 ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_rate_near: err = %1").arg(err); - } - } - if ( !fatal ) { - unsigned int maxBufferTime = 0; - unsigned int minBufferTime = 0; - unsigned int maxPeriodTime = 0; - unsigned int minPeriodTime = 0; - - err = snd_pcm_hw_params_get_buffer_time_max(hwparams, &maxBufferTime, &dir); - if ( err >= 0) - err = snd_pcm_hw_params_get_buffer_time_min(hwparams, &minBufferTime, &dir); - if ( err >= 0) - err = snd_pcm_hw_params_get_period_time_max(hwparams, &maxPeriodTime, &dir); - if ( err >= 0) - err = snd_pcm_hw_params_get_period_time_min(hwparams, &minPeriodTime, &dir); - - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: buffer/period min and max: err = %1").arg(err); - } else { - if (maxBufferTime < buffer_time || buffer_time < minBufferTime || maxPeriodTime < period_time || minPeriodTime > period_time) { -#ifdef DEBUG_AUDIO - qDebug()<<"defaults out of range"; - qDebug()<<"pmin="<start(period_time/1000); - - clockStamp.restart(); - timeStamp.restart(); - elapsedTimeOffset = 0; - errorState = QAudio::NoError; - totalTimeValue = 0; - opened = true; - - return true; -} - -void QAudioOutputPrivate::close() -{ - timer->stop(); - - if ( handle ) { - snd_pcm_drain( handle ); - snd_pcm_close( handle ); - handle = 0; - delete [] audioBuffer; - audioBuffer=0; - } - if(!pullMode && audioSource) { - delete audioSource; - audioSource = 0; - } - opened = false; -} - -int QAudioOutputPrivate::bytesFree() const -{ - if(resuming) - return period_size; - - if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) - return 0; - int frames = snd_pcm_avail_update(handle); - if((int)frames > (int)buffer_frames) - frames = buffer_frames; - - return snd_pcm_frames_to_bytes(handle, frames); -} - -qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) -{ - // Write out some audio data - if ( !handle ) - return 0; -#ifdef DEBUG_AUDIO - qDebug()<<"frames to write out = "<< - snd_pcm_bytes_to_frames( handle, (int)len )<<" ("< 0) { - totalTimeValue += err; - resuming = false; - errorState = QAudio::NoError; - if (deviceState != QAudio::ActiveState) { - deviceState = QAudio::ActiveState; - emit stateChanged(deviceState); - } - return snd_pcm_frames_to_bytes( handle, err ); - } else - err = xrun_recovery(err); - - if(err < 0) { - close(); - errorState = QAudio::FatalError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - } - return 0; -} - -int QAudioOutputPrivate::periodSize() const -{ - return period_size; -} - -void QAudioOutputPrivate::setBufferSize(int value) -{ - if(deviceState == QAudio::StoppedState) - buffer_size = value; -} - -int QAudioOutputPrivate::bufferSize() const -{ - return buffer_size; -} - -void QAudioOutputPrivate::setNotifyInterval(int ms) -{ - intervalTime = qMax(0, ms); -} - -int QAudioOutputPrivate::notifyInterval() const -{ - return intervalTime; -} - -qint64 QAudioOutputPrivate::processedUSecs() const -{ - return qint64(1000000) * totalTimeValue / settings.frequency(); -} - -void QAudioOutputPrivate::resume() -{ - if(deviceState == QAudio::SuspendedState) { - int err = 0; - - if(handle) { - err = snd_pcm_prepare( handle ); - if(err < 0) - xrun_recovery(err); - - err = snd_pcm_start(handle); - if(err < 0) - xrun_recovery(err); - - bytesAvailable = (int)snd_pcm_frames_to_bytes(handle, buffer_frames); - } - resuming = true; - - deviceState = QAudio::ActiveState; - - errorState = QAudio::NoError; - timer->start(period_time/1000); - emit stateChanged(deviceState); - } -} - -QAudioFormat QAudioOutputPrivate::format() const -{ - return settings; -} - -void QAudioOutputPrivate::suspend() -{ - if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState || resuming) { - timer->stop(); - deviceState = QAudio::SuspendedState; - errorState = QAudio::NoError; - emit stateChanged(deviceState); - } -} - -void QAudioOutputPrivate::userFeed() -{ - if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) - return; -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()<acquireReadRegion((maxFrames - framesRead) * m_bytesPerFrame); - - if (region.second > 0) { - region.second -= region.second % m_bytesPerFrame; - memcpy(data + (framesRead * m_bytesPerFrame), region.first, region.second); - framesRead += region.second / m_bytesPerFrame; - } - else - wecan = false; - - m_buffer->releaseReadRegion(region); - } - - if (framesRead == 0 && m_deviceError) - framesRead = -1; - - return framesRead; - } - - qint64 writeBytes(const char* data, qint64 maxSize) - { - bool wecan = true; - qint64 bytesWritten = 0; - - maxSize -= maxSize % m_bytesPerFrame; - while (wecan && bytesWritten < maxSize) { - QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(maxSize - bytesWritten); - - if (region.second > 0) { - memcpy(region.first, data + bytesWritten, region.second); - bytesWritten += region.second; - } - else - wecan = false; - - m_buffer->releaseWriteRegion(region); - } - - if (bytesWritten > 0) - emit readyRead(); - - return bytesWritten; - } - - int available() const - { - return m_buffer->free(); - } - - void reset() - { - m_buffer->reset(); - m_deviceError = false; - } - - void setPrefetchDevice(QIODevice* device) - { - if (m_device != device) { - m_device = device; - if (m_device != 0) - fillBuffer(); - } - } - - void startFillTimer() - { - if (m_device != 0) - m_fillTimer->start(m_buffer->size() / 2 / m_maxPeriodSize * m_periodTime); - } - - void stopFillTimer() - { - m_fillTimer->stop(); - } - -signals: - void readyRead(); - -private slots: - void fillBuffer() - { - const int free = m_buffer->free(); - const int writeSize = free - (free % m_maxPeriodSize); - - if (writeSize > 0) { - bool wecan = true; - int filled = 0; - - while (!m_deviceError && wecan && filled < writeSize) { - QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(writeSize - filled); - - if (region.second > 0) { - region.second = m_device->read(region.first, region.second); - if (region.second > 0) - filled += region.second; - else if (region.second == 0) - wecan = false; - else if (region.second < 0) { - m_fillTimer->stop(); - region.second = 0; - m_deviceError = true; - } - } - else - wecan = false; - - m_buffer->releaseWriteRegion(region); - } - - if (filled > 0) - emit readyRead(); - } - } - -private: - bool m_deviceError; - int m_maxPeriodSize; - int m_bytesPerFrame; - int m_periodTime; - QIODevice* m_device; - QTimer* m_fillTimer; - QAudioRingBuffer* m_buffer; -}; - - -} - -class MacOutputDevice : public QIODevice -{ - Q_OBJECT - -public: - MacOutputDevice(QtMultimediaInternal::QAudioOutputBuffer* audioBuffer, QObject* parent): - QIODevice(parent), - m_audioBuffer(audioBuffer) - { - open(QIODevice::WriteOnly | QIODevice::Unbuffered); - } - - qint64 readData(char* data, qint64 len) - { - Q_UNUSED(data); - Q_UNUSED(len); - - return 0; - } - - qint64 writeData(const char* data, qint64 len) - { - return m_audioBuffer->writeBytes(data, len); - } - - bool isSequential() const - { - return true; - } - -private: - QtMultimediaInternal::QAudioOutputBuffer* m_audioBuffer; -}; - - -QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioFormat& format): - audioFormat(format) -{ - QDataStream ds(device); - quint32 did, mode; - - ds >> did >> mode; - - if (QAudio::Mode(mode) == QAudio::AudioInput) - errorCode = QAudio::OpenError; - else { - isOpen = false; - audioDeviceId = AudioDeviceID(did); - audioUnit = 0; - audioIO = 0; - startTime = 0; - totalFrames = 0; - audioBuffer = 0; - internalBufferSize = QtMultimediaInternal::default_buffer_size; - clockFrequency = AudioGetHostClockFrequency() / 1000; - errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; - audioThreadState = Stopped; - - intervalTimer = new QTimer(this); - intervalTimer->setInterval(1000); - connect(intervalTimer, SIGNAL(timeout()), SIGNAL(notify())); - } -} - -QAudioOutputPrivate::~QAudioOutputPrivate() -{ - close(); -} - -bool QAudioOutputPrivate::open() -{ - if (errorCode != QAudio::NoError) - return false; - - if (isOpen) - return true; - - ComponentDescription cd; - cd.componentType = kAudioUnitType_Output; - cd.componentSubType = kAudioUnitSubType_HALOutput; - cd.componentManufacturer = kAudioUnitManufacturer_Apple; - cd.componentFlags = 0; - cd.componentFlagsMask = 0; - - // Open - Component cp = FindNextComponent(NULL, &cd); - if (cp == 0) { - qWarning() << "QAudioOutput: Failed to find HAL Output component"; - return false; - } - - if (OpenAComponent(cp, &audioUnit) != noErr) { - qWarning() << "QAudioOutput: Unable to Open Output Component"; - return false; - } - - // register callback - AURenderCallbackStruct cb; - cb.inputProc = renderCallback; - cb.inputProcRefCon = this; - - if (AudioUnitSetProperty(audioUnit, - kAudioUnitProperty_SetRenderCallback, - kAudioUnitScope_Global, - 0, - &cb, - sizeof(cb)) != noErr) { - qWarning() << "QAudioOutput: Failed to set AudioUnit callback"; - return false; - } - - // Set Audio Device - if (AudioUnitSetProperty(audioUnit, - kAudioOutputUnitProperty_CurrentDevice, - kAudioUnitScope_Global, - 0, - &audioDeviceId, - sizeof(audioDeviceId)) != noErr) { - qWarning() << "QAudioOutput: Unable to use configured device"; - return false; - } - - // Set stream format - streamFormat = toAudioStreamBasicDescription(audioFormat); - - UInt32 size = sizeof(deviceFormat); - if (AudioUnitGetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 0, - &deviceFormat, - &size) != noErr) { - qWarning() << "QAudioOutput: Unable to retrieve device format"; - return false; - } - - if (AudioUnitSetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 0, - &streamFormat, - sizeof(streamFormat)) != noErr) { - qWarning() << "QAudioOutput: Unable to Set Stream information"; - return false; - } - - // Allocate buffer - UInt32 numberOfFrames = 0; - size = sizeof(UInt32); - if (AudioUnitGetProperty(audioUnit, - kAudioDevicePropertyBufferFrameSize, - kAudioUnitScope_Global, - 0, - &numberOfFrames, - &size) != noErr) { - qWarning() << "QAudioInput: Failed to get audio period size"; - return false; - } - - periodSizeBytes = (numberOfFrames * streamFormat.mSampleRate / deviceFormat.mSampleRate) * - streamFormat.mBytesPerFrame; - if (internalBufferSize < periodSizeBytes * 2) - internalBufferSize = periodSizeBytes * 2; - else - internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; - - audioBuffer = new QtMultimediaInternal::QAudioOutputBuffer(internalBufferSize, periodSizeBytes, audioFormat); - connect(audioBuffer, SIGNAL(readyRead()), SLOT(inputReady())); // Pull - - audioIO = new MacOutputDevice(audioBuffer, this); - - // Init - if (AudioUnitInitialize(audioUnit)) { - qWarning() << "QAudioOutput: Failed to initialize AudioUnit"; - return false; - } - - isOpen = true; - - return true; -} - -void QAudioOutputPrivate::close() -{ - if (audioUnit != 0) { - AudioOutputUnitStop(audioUnit); - AudioUnitUninitialize(audioUnit); - CloseComponent(audioUnit); - } - - delete audioBuffer; -} - -QAudioFormat QAudioOutputPrivate::format() const -{ - return audioFormat; -} - -QIODevice* QAudioOutputPrivate::start(QIODevice* device) -{ - QIODevice* op = device; - - if (!audioFormat.isValid() || !open()) { - stateCode = QAudio::StoppedState; - errorCode = QAudio::OpenError; - return audioIO; - } - - reset(); - audioBuffer->reset(); - audioBuffer->setPrefetchDevice(op); - - if (op == 0) { - op = audioIO; - stateCode = QAudio::IdleState; - } - else - stateCode = QAudio::ActiveState; - - // Start - errorCode = QAudio::NoError; - totalFrames = 0; - startTime = AudioGetCurrentHostTime(); - - if (stateCode == QAudio::ActiveState) - audioThreadStart(); - - emit stateChanged(stateCode); - - return op; -} - -void QAudioOutputPrivate::stop() -{ - QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { - audioThreadDrain(); - - stateCode = QAudio::StoppedState; - errorCode = QAudio::NoError; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioOutputPrivate::reset() -{ - QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { - audioThreadStop(); - - stateCode = QAudio::StoppedState; - errorCode = QAudio::NoError; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioOutputPrivate::suspend() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) { - audioThreadStop(); - - stateCode = QAudio::SuspendedState; - errorCode = QAudio::NoError; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioOutputPrivate::resume() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::SuspendedState) { - audioThreadStart(); - - stateCode = QAudio::ActiveState; - errorCode = QAudio::NoError; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -int QAudioOutputPrivate::bytesFree() const -{ - return audioBuffer->available(); -} - -int QAudioOutputPrivate::periodSize() const -{ - return periodSizeBytes; -} - -void QAudioOutputPrivate::setBufferSize(int bs) -{ - if (stateCode == QAudio::StoppedState) - internalBufferSize = bs; -} - -int QAudioOutputPrivate::bufferSize() const -{ - return internalBufferSize; -} - -void QAudioOutputPrivate::setNotifyInterval(int milliSeconds) -{ - if (intervalTimer->interval() == milliSeconds) - return; - - if (milliSeconds <= 0) - milliSeconds = 0; - - intervalTimer->setInterval(milliSeconds); -} - -int QAudioOutputPrivate::notifyInterval() const -{ - return intervalTimer->interval(); -} - -qint64 QAudioOutputPrivate::processedUSecs() const -{ - return totalFrames * 1000000 / audioFormat.frequency(); -} - -qint64 QAudioOutputPrivate::elapsedUSecs() const -{ - if (stateCode == QAudio::StoppedState) - return 0; - - return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); -} - -QAudio::Error QAudioOutputPrivate::error() const -{ - return errorCode; -} - -QAudio::State QAudioOutputPrivate::state() const -{ - return stateCode; -} - -void QAudioOutputPrivate::audioThreadStart() -{ - startTimers(); - audioThreadState = Running; - AudioOutputUnitStart(audioUnit); -} - -void QAudioOutputPrivate::audioThreadStop() -{ - stopTimers(); - if (audioThreadState.testAndSetAcquire(Running, Stopped)) - threadFinished.wait(&mutex); -} - -void QAudioOutputPrivate::audioThreadDrain() -{ - stopTimers(); - if (audioThreadState.testAndSetAcquire(Running, Draining)) - threadFinished.wait(&mutex); -} - -void QAudioOutputPrivate::audioDeviceStop() -{ - AudioOutputUnitStop(audioUnit); - audioThreadState = Stopped; - threadFinished.wakeOne(); -} - -void QAudioOutputPrivate::audioDeviceIdle() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState) { - audioDeviceStop(); - - errorCode = QAudio::UnderrunError; - stateCode = QAudio::IdleState; - QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); - } -} - -void QAudioOutputPrivate::audioDeviceError() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState) { - audioDeviceStop(); - - errorCode = QAudio::IOError; - stateCode = QAudio::StoppedState; - QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); - } -} - -void QAudioOutputPrivate::startTimers() -{ - audioBuffer->startFillTimer(); - if (intervalTimer->interval() > 0) - intervalTimer->start(); -} - -void QAudioOutputPrivate::stopTimers() -{ - audioBuffer->stopFillTimer(); - intervalTimer->stop(); -} - - -void QAudioOutputPrivate::deviceStopped() -{ - intervalTimer->stop(); - emit stateChanged(stateCode); -} - -void QAudioOutputPrivate::inputReady() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::IdleState) { - audioThreadStart(); - - stateCode = QAudio::ActiveState; - errorCode = QAudio::NoError; - - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - - -OSStatus QAudioOutputPrivate::renderCallback(void* inRefCon, - AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList* ioData) -{ - Q_UNUSED(ioActionFlags) - Q_UNUSED(inTimeStamp) - Q_UNUSED(inBusNumber) - Q_UNUSED(inNumberFrames) - - QAudioOutputPrivate* d = static_cast(inRefCon); - - const int threadState = d->audioThreadState.fetchAndAddAcquire(0); - if (threadState == Stopped) { - ioData->mBuffers[0].mDataByteSize = 0; - d->audioDeviceStop(); - } - else { - const UInt32 bytesPerFrame = d->streamFormat.mBytesPerFrame; - qint64 framesRead; - - framesRead = d->audioBuffer->readFrames((char*)ioData->mBuffers[0].mData, - ioData->mBuffers[0].mDataByteSize / bytesPerFrame); - - if (framesRead > 0) { - ioData->mBuffers[0].mDataByteSize = framesRead * bytesPerFrame; - d->totalFrames += framesRead; - } - else { - ioData->mBuffers[0].mDataByteSize = 0; - if (framesRead == 0) { - if (threadState == Draining) - d->audioDeviceStop(); - else - d->audioDeviceIdle(); - } - else - d->audioDeviceError(); - } - } - - return noErr; -} - - -QT_END_NAMESPACE - -#include "qaudiooutput_mac_p.moc" - diff --git a/src/multimedia/multimedia/audio/qaudiooutput_mac_p.h b/src/multimedia/multimedia/audio/qaudiooutput_mac_p.h deleted file mode 100644 index 752905c..0000000 --- a/src/multimedia/multimedia/audio/qaudiooutput_mac_p.h +++ /dev/null @@ -1,167 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIOOUTPUT_MAC_P_H -#define QAUDIOOUTPUT_MAC_P_H - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QIODevice; - -namespace QtMultimediaInternal -{ -class QAudioOutputBuffer; -} - -class QAudioOutputPrivate : public QAbstractAudioOutput -{ - Q_OBJECT - -public: - bool isOpen; - int internalBufferSize; - int periodSizeBytes; - qint64 totalFrames; - QAudioFormat audioFormat; - QIODevice* audioIO; - AudioDeviceID audioDeviceId; - AudioUnit audioUnit; - Float64 clockFrequency; - UInt64 startTime; - AudioStreamBasicDescription deviceFormat; - AudioStreamBasicDescription streamFormat; - QtMultimediaInternal::QAudioOutputBuffer* audioBuffer; - QAtomicInt audioThreadState; - QWaitCondition threadFinished; - QMutex mutex; - QTimer* intervalTimer; - - QAudio::Error errorCode; - QAudio::State stateCode; - - QAudioOutputPrivate(const QByteArray& device, const QAudioFormat& format); - ~QAudioOutputPrivate(); - - bool open(); - void close(); - - QAudioFormat format() const; - - QIODevice* start(QIODevice* device); - void stop(); - void reset(); - void suspend(); - void resume(); - - int bytesFree() const; - int periodSize() const; - - void setBufferSize(int value); - int bufferSize() const; - - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - - QAudio::Error error() const; - QAudio::State state() const; - - void audioThreadStart(); - void audioThreadStop(); - void audioThreadDrain(); - - void audioDeviceStop(); - void audioDeviceIdle(); - void audioDeviceError(); - - void startTimers(); - void stopTimers(); - -private slots: - void deviceStopped(); - void inputReady(); - -private: - enum { Running, Draining, Stopped }; - - static OSStatus renderCallback(void* inRefCon, - AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList* ioData); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/multimedia/audio/qaudiooutput_symbian_p.cpp b/src/multimedia/multimedia/audio/qaudiooutput_symbian_p.cpp deleted file mode 100644 index 3f8e933..0000000 --- a/src/multimedia/multimedia/audio/qaudiooutput_symbian_p.cpp +++ /dev/null @@ -1,697 +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 QtMultimedia 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 "qaudiooutput_symbian_p.h" - -QT_BEGIN_NAMESPACE - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const int UnderflowTimerInterval = 50; // ms - - -//----------------------------------------------------------------------------- -// Private class -//----------------------------------------------------------------------------- - -SymbianAudioOutputPrivate::SymbianAudioOutputPrivate( - QAudioOutputPrivate *audioDevice) - : m_audioDevice(audioDevice) -{ - -} - -SymbianAudioOutputPrivate::~SymbianAudioOutputPrivate() -{ - -} - -qint64 SymbianAudioOutputPrivate::readData(char *data, qint64 len) -{ - Q_UNUSED(data) - Q_UNUSED(len) - return 0; -} - -qint64 SymbianAudioOutputPrivate::writeData(const char *data, qint64 len) -{ - qint64 totalWritten = 0; - - if (m_audioDevice->state() == QAudio::ActiveState || - m_audioDevice->state() == QAudio::IdleState) { - - while (totalWritten < len) { - const qint64 written = m_audioDevice->pushData(data + totalWritten, - len - totalWritten); - if (written > 0) - totalWritten += written; - else - break; - } - } - - return totalWritten; -} - - -//----------------------------------------------------------------------------- -// Public functions -//----------------------------------------------------------------------------- - -QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, - const QAudioFormat &format) - : m_device(device) - , m_format(format) - , m_clientBufferSize(SymbianAudio::DefaultBufferSize) - , m_notifyInterval(SymbianAudio::DefaultNotifyInterval) - , m_notifyTimer(new QTimer(this)) - , m_error(QAudio::NoError) - , m_internalState(SymbianAudio::ClosedState) - , m_externalState(QAudio::StoppedState) - , m_pullMode(false) - , m_source(0) - , m_devSoundBuffer(0) - , m_devSoundBufferSize(0) - , m_bytesWritten(0) - , m_pushDataReady(false) - , m_bytesPadding(0) - , m_underflow(false) - , m_lastBuffer(false) - , m_underflowTimer(new QTimer(this)) - , m_samplesPlayed(0) - , m_totalSamplesPlayed(0) -{ - connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); - - SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, - m_nativeFormat); - - m_underflowTimer->setInterval(UnderflowTimerInterval); - connect(m_underflowTimer.data(), SIGNAL(timeout()), this, - SLOT(underflowTimerExpired())); -} - -QAudioOutputPrivate::~QAudioOutputPrivate() -{ - close(); -} - -QIODevice* QAudioOutputPrivate::start(QIODevice *device) -{ - stop(); - - // We have to set these before the call to open() because of the - // logic in initializingState() - if (device) { - m_pullMode = true; - m_source = device; - } - - open(); - - if (SymbianAudio::ClosedState != m_internalState) { - if (device) { - connect(m_source, SIGNAL(readyRead()), this, SLOT(dataReady())); - } else { - m_source = new SymbianAudioOutputPrivate(this); - m_source->open(QIODevice::WriteOnly | QIODevice::Unbuffered); - } - - m_elapsed.restart(); - } - - return m_source; -} - -void QAudioOutputPrivate::stop() -{ - close(); -} - -void QAudioOutputPrivate::reset() -{ - m_totalSamplesPlayed += getSamplesPlayed(); - m_devSound->Stop(); - m_bytesPadding = 0; - startPlayback(); -} - -void QAudioOutputPrivate::suspend() -{ - if (SymbianAudio::ActiveState == m_internalState - || SymbianAudio::IdleState == m_internalState) { - m_notifyTimer->stop(); - m_underflowTimer->stop(); - - const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples( - m_format, m_bytesWritten); - - 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(). - // Because this causes buffered data to be dropped, we replace the - // lost data with silence following a call to resume(), in order to - // ensure that processedUSecs() returns the correct value. - m_devSound->Stop(); - m_totalSamplesPlayed += samplesPlayed; - - // Calculate the amount of data dropped - const qint64 paddingSamples = samplesWritten - samplesPlayed; - m_bytesPadding = SymbianAudio::Utils::samplesToBytes(m_format, - paddingSamples); - - setState(SymbianAudio::SuspendedState); - } -} - -void QAudioOutputPrivate::resume() -{ - if (SymbianAudio::SuspendedState == m_internalState) - startPlayback(); -} - -int QAudioOutputPrivate::bytesFree() const -{ - int result = 0; - if (m_devSoundBuffer) { - const TDes8 &outputBuffer = m_devSoundBuffer->Data(); - result = outputBuffer.MaxLength() - outputBuffer.Length(); - } - return result; -} - -int QAudioOutputPrivate::periodSize() const -{ - return bufferSize(); -} - -void QAudioOutputPrivate::setBufferSize(int value) -{ - // Note that DevSound does not allow its client to specify the buffer size. - // This functionality is available via custom interfaces, but since these - // cannot be guaranteed to work across all DevSound implementations, we - // do not use them here. - // In order to comply with the expected bevahiour of QAudioOutput, we store - // the value and return it from bufferSize(), but the underlying DevSound - // buffer size remains unchanged. - if (value > 0) - m_clientBufferSize = value; -} - -int QAudioOutputPrivate::bufferSize() const -{ - return m_devSoundBufferSize ? m_devSoundBufferSize : m_clientBufferSize; -} - -void QAudioOutputPrivate::setNotifyInterval(int ms) -{ - if (ms > 0) { - const int oldNotifyInterval = m_notifyInterval; - m_notifyInterval = ms; - if (m_notifyTimer->isActive() && ms != oldNotifyInterval) - m_notifyTimer->start(m_notifyInterval); - } -} - -int QAudioOutputPrivate::notifyInterval() const -{ - return m_notifyInterval; -} - -qint64 QAudioOutputPrivate::processedUSecs() const -{ - int samplesPlayed = 0; - if (m_devSound && SymbianAudio::SuspendedState != m_internalState) - samplesPlayed = getSamplesPlayed(); - - // Protect against division by zero - Q_ASSERT_X(m_format.frequency() > 0, Q_FUNC_INFO, "Invalid frequency"); - - const qint64 result = qint64(1000000) * - (samplesPlayed + m_totalSamplesPlayed) - / m_format.frequency(); - - return result; -} - -qint64 QAudioOutputPrivate::elapsedUSecs() const -{ - const qint64 result = (QAudio::StoppedState == state()) ? - 0 : m_elapsed.elapsed() * 1000; - return result; -} - -QAudio::Error QAudioOutputPrivate::error() const -{ - return m_error; -} - -QAudio::State QAudioOutputPrivate::state() const -{ - return m_externalState; -} - -QAudioFormat QAudioOutputPrivate::format() const -{ - return m_format; -} - -//----------------------------------------------------------------------------- -// MDevSoundObserver implementation -//----------------------------------------------------------------------------- - -void QAudioOutputPrivate::InitializeComplete(TInt aError) -{ - Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, - Q_FUNC_INFO, "Invalid state"); - - if (KErrNone == aError) - startPlayback(); -} - -void QAudioOutputPrivate::ToneFinished(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's tone playback functions, so should - // never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioOutputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) -{ - // Following receipt of this callback, DevSound should not provide another - // buffer until we have returned the current one. - Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); - - // Will be returned to DevSound by bufferFilled(). - m_devSoundBuffer = static_cast(aBuffer); - - if (!m_devSoundBufferSize) - m_devSoundBufferSize = m_devSoundBuffer->Data().MaxLength(); - - writePaddingData(); - - if (m_pullMode && isDataReady() && !m_bytesPadding) - pullData(); -} - -void QAudioOutputPrivate::PlayError(TInt aError) -{ - switch (aError) { - case KErrUnderflow: - m_underflow = true; - if (m_pullMode && !m_lastBuffer) - setError(QAudio::UnderrunError); - else - setState(SymbianAudio::IdleState); - break; - default: - setError(QAudio::IOError); - break; - } -} - -void QAudioOutputPrivate::BufferToBeEmptied(CMMFBuffer *aBuffer) -{ - Q_UNUSED(aBuffer) - // This class doesn't use DevSound in record mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioOutputPrivate::RecordError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound in record mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioOutputPrivate::ConvertError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's format conversion functions, so - // should never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioOutputPrivate::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) -{ - Q_UNUSED(aMessageType) - Q_UNUSED(aMsg) - // Ignore this callback. -} - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -void QAudioOutputPrivate::dataReady() -{ - // Client-provided QIODevice has data ready to read. - - Q_ASSERT_X(m_source->bytesAvailable(), Q_FUNC_INFO, - "readyRead signal received, but no data available"); - - if (!m_bytesPadding) - pullData(); -} - -void QAudioOutputPrivate::underflowTimerExpired() -{ - const TInt samplesPlayed = getSamplesPlayed(); - if (m_samplesPlayed && (samplesPlayed == m_samplesPlayed)) { - setError(QAudio::UnderrunError); - } else { - m_samplesPlayed = samplesPlayed; - m_underflowTimer->start(); - } -} - -void QAudioOutputPrivate::open() -{ - Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, - Q_FUNC_INFO, "DevSound already opened"); - - QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) - - QScopedPointer caps( - new SymbianAudio::DevSoundCapabilities(*m_devSound, - QAudio::AudioOutput)); - - int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? - KErrNone : KErrNotSupported; - - if (KErrNone == err) { - setState(SymbianAudio::InitializingState); - TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, - EMMFStatePlaying)); - } - - if (KErrNone != err) { - setError(QAudio::OpenError); - m_devSound.reset(); - } -} - -void QAudioOutputPrivate::startPlayback() -{ - TRAPD(err, startDevSoundL()); - if (KErrNone == err) { - if (isDataReady()) - setState(SymbianAudio::ActiveState); - else - setState(SymbianAudio::IdleState); - - m_notifyTimer->start(m_notifyInterval); - m_underflow = false; - - Q_ASSERT(m_devSound->SamplesPlayed() == 0); - - writePaddingData(); - - if (m_pullMode && m_source->bytesAvailable() && !m_bytesPadding) - dataReady(); - } else { - setError(QAudio::OpenError); - close(); - } -} - -void QAudioOutputPrivate::startDevSoundL() -{ - TMMFCapabilities nativeFormat = m_devSound->Config(); - m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; - m_devSound->SetConfigL(m_nativeFormat); - m_devSound->PlayInitL(); -} - -void QAudioOutputPrivate::writePaddingData() -{ - // See comments in suspend() - - while (m_devSoundBuffer && m_bytesPadding) { - if (SymbianAudio::IdleState == m_internalState) - setState(SymbianAudio::ActiveState); - - TDes8 &outputBuffer = m_devSoundBuffer->Data(); - const qint64 outputBytes = bytesFree(); - const qint64 paddingBytes = outputBytes < m_bytesPadding ? - outputBytes : m_bytesPadding; - unsigned char *ptr = const_cast(outputBuffer.Ptr()); - Mem::FillZ(ptr, paddingBytes); - outputBuffer.SetLength(outputBuffer.Length() + paddingBytes); - m_bytesPadding -= paddingBytes; - - if (m_pullMode && m_source->atEnd()) - lastBufferFilled(); - if (paddingBytes == outputBytes) - bufferFilled(); - } -} - -qint64 QAudioOutputPrivate::pushData(const char *data, qint64 len) -{ - // Data has been written to SymbianAudioOutputPrivate - - Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, - "pushData called when in pull mode"); - - const unsigned char *const inputPtr = - reinterpret_cast(data); - qint64 bytesWritten = 0; - - if (SymbianAudio::IdleState == m_internalState) - setState(SymbianAudio::ActiveState); - - while (m_devSoundBuffer && (bytesWritten < len)) { - // writePaddingData() is called from BufferToBeFilled(), so we should - // never have any padding data left at this point. - Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO, - "Padding bytes remaining in pushData"); - - TDes8 &outputBuffer = m_devSoundBuffer->Data(); - - const qint64 outputBytes = bytesFree(); - const qint64 inputBytes = len - bytesWritten; - const qint64 copyBytes = outputBytes < inputBytes ? - outputBytes : inputBytes; - - outputBuffer.Append(inputPtr + bytesWritten, copyBytes); - bytesWritten += copyBytes; - - bufferFilled(); - } - - m_pushDataReady = (bytesWritten < len); - - // If DevSound is still initializing (m_internalState == InitializingState), - // we cannot transition m_internalState to ActiveState, but we must emit - // an (external) state change from IdleState to ActiveState. The following - // call triggers this signal. - setState(m_internalState); - - return bytesWritten; -} - -void QAudioOutputPrivate::pullData() -{ - Q_ASSERT_X(m_pullMode, Q_FUNC_INFO, - "pullData called when in push mode"); - - if (m_bytesPadding) - m_bytesPadding = 1; - - // writePaddingData() is called by BufferToBeFilled() before pullData(), - // so we should never have any padding data left at this point. - Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO, - "Padding bytes remaining in pullData"); - - qint64 inputBytes = m_source->bytesAvailable(); - while (m_devSoundBuffer && inputBytes) { - if (SymbianAudio::IdleState == m_internalState) - setState(SymbianAudio::ActiveState); - - TDes8 &outputBuffer = m_devSoundBuffer->Data(); - - const qint64 outputBytes = bytesFree(); - const qint64 copyBytes = outputBytes < inputBytes ? - outputBytes : inputBytes; - - char *outputPtr = (char*)(outputBuffer.Ptr() + outputBuffer.Length()); - const qint64 bytesCopied = m_source->read(outputPtr, copyBytes); - Q_ASSERT(bytesCopied == copyBytes); - outputBuffer.SetLength(outputBuffer.Length() + bytesCopied); - inputBytes -= bytesCopied; - - if (m_source->atEnd()) - lastBufferFilled(); - else if (copyBytes == outputBytes) - bufferFilled(); - } -} - -void QAudioOutputPrivate::bufferFilled() -{ - Q_ASSERT_X(m_devSoundBuffer, Q_FUNC_INFO, "No buffer to return"); - - const TDes8 &outputBuffer = m_devSoundBuffer->Data(); - m_bytesWritten += outputBuffer.Length(); - - m_devSoundBuffer = 0; - - m_samplesPlayed = getSamplesPlayed(); - m_underflowTimer->start(); - - if (QAudio::UnderrunError == m_error) - m_error = QAudio::NoError; - - m_devSound->PlayData(); -} - -void QAudioOutputPrivate::lastBufferFilled() -{ - Q_ASSERT_X(m_devSoundBuffer, Q_FUNC_INFO, "No buffer to fill"); - Q_ASSERT_X(!m_lastBuffer, Q_FUNC_INFO, "Last buffer already sent"); - m_lastBuffer = true; - m_devSoundBuffer->SetLastBuffer(ETrue); - bufferFilled(); -} - -void QAudioOutputPrivate::close() -{ - m_notifyTimer->stop(); - m_underflowTimer->stop(); - - m_error = QAudio::NoError; - - if (m_devSound) - m_devSound->Stop(); - m_devSound.reset(); - m_devSoundBuffer = 0; - m_devSoundBufferSize = 0; - - if (!m_pullMode) // m_source is owned - delete m_source; - m_pullMode = false; - m_source = 0; - - m_bytesWritten = 0; - m_pushDataReady = false; - m_bytesPadding = 0; - m_underflow = false; - m_lastBuffer = false; - m_samplesPlayed = 0; - m_totalSamplesPlayed = 0; - - setState(SymbianAudio::ClosedState); -} - -qint64 QAudioOutputPrivate::getSamplesPlayed() const -{ - qint64 result = 0; - if (m_devSound) { - const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples( - m_format, m_bytesWritten); - - if (m_underflow) { - result = samplesWritten; - } else { - // This is necessary because some DevSound implementations report - // that they have played more data than has actually been provided to them - // by the client. - const qint64 devSoundSamplesPlayed(m_devSound->SamplesPlayed()); - result = qMin(devSoundSamplesPlayed, samplesWritten); - } - } - return result; -} - -void QAudioOutputPrivate::setError(QAudio::Error error) -{ - m_error = error; - - // Although no state transition actually occurs here, a stateChanged event - // must be emitted to inform the client that the call to start() was - // unsuccessful. - if (QAudio::OpenError == error) - emit stateChanged(QAudio::StoppedState); - - if (QAudio::UnderrunError == error) - setState(SymbianAudio::IdleState); - else - // Close the DevSound instance. This causes a transition to - // StoppedState. This must be done asynchronously in case the - // current function was called from a DevSound event handler, in which - // case deleting the DevSound instance may cause an exception. - QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); -} - -void QAudioOutputPrivate::setState(SymbianAudio::State newInternalState) -{ - const QAudio::State oldExternalState = m_externalState; - m_internalState = newInternalState; - m_externalState = SymbianAudio::Utils::stateNativeToQt( - m_internalState, initializingState()); - - if (m_externalState != oldExternalState) - emit stateChanged(m_externalState); -} - -bool QAudioOutputPrivate::isDataReady() const -{ - return (m_source && m_source->bytesAvailable()) - || m_bytesPadding - || m_pushDataReady; -} - -QAudio::State QAudioOutputPrivate::initializingState() const -{ - return isDataReady() ? QAudio::ActiveState : QAudio::IdleState; -} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudiooutput_symbian_p.h b/src/multimedia/multimedia/audio/qaudiooutput_symbian_p.h deleted file mode 100644 index 00ccb24..0000000 --- a/src/multimedia/multimedia/audio/qaudiooutput_symbian_p.h +++ /dev/null @@ -1,210 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIOOUTPUT_SYMBIAN_P_H -#define QAUDIOOUTPUT_SYMBIAN_P_H - -#include -#include -#include -#include -#include "qaudio_symbian_p.h" - -QT_BEGIN_NAMESPACE - -class QAudioOutputPrivate; - -class SymbianAudioOutputPrivate : public QIODevice -{ - friend class QAudioOutputPrivate; - Q_OBJECT -public: - SymbianAudioOutputPrivate(QAudioOutputPrivate *audio); - ~SymbianAudioOutputPrivate(); - - qint64 readData(char *data, qint64 len); - qint64 writeData(const char *data, qint64 len); - -private: - QAudioOutputPrivate *const m_audioDevice; -}; - -class QAudioOutputPrivate - : public QAbstractAudioOutput - , public MDevSoundObserver -{ - friend class SymbianAudioOutputPrivate; - Q_OBJECT -public: - QAudioOutputPrivate(const QByteArray &device, - const QAudioFormat &audioFormat); - ~QAudioOutputPrivate(); - - // QAbstractAudioOutput - QIODevice* start(QIODevice *device = 0); - void stop(); - void reset(); - void suspend(); - void resume(); - int bytesFree() const; - int periodSize() const; - void setBufferSize(int value); - int bufferSize() const; - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - QAudio::Error error() const; - QAudio::State state() const; - QAudioFormat format() const; - - // MDevSoundObserver - void InitializeComplete(TInt aError); - void ToneFinished(TInt aError); - void BufferToBeFilled(CMMFBuffer *aBuffer); - void PlayError(TInt aError); - void BufferToBeEmptied(CMMFBuffer *aBuffer); - void RecordError(TInt aError); - void ConvertError(TInt aError); - void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); - -private slots: - void dataReady(); - void underflowTimerExpired(); - -private: - void open(); - void startPlayback(); - void startDevSoundL(); - void writePaddingData(); - qint64 pushData(const char *data, qint64 len); - void pullData(); - void bufferFilled(); - void lastBufferFilled(); - Q_INVOKABLE void close(); - - qint64 getSamplesPlayed() const; - - void setError(QAudio::Error error); - void setState(SymbianAudio::State state); - - bool isDataReady() const; - QAudio::State initializingState() const; - -private: - const QByteArray m_device; - const QAudioFormat m_format; - - int m_clientBufferSize; - int m_notifyInterval; - QScopedPointer m_notifyTimer; - QTime m_elapsed; - QAudio::Error m_error; - - SymbianAudio::State m_internalState; - QAudio::State m_externalState; - - bool m_pullMode; - QIODevice *m_source; - - QScopedPointer m_devSound; - TUint32 m_nativeFourCC; - TMMFCapabilities m_nativeFormat; - - // Buffer provided by DevSound, to be filled with data. - CMMFDataBuffer *m_devSoundBuffer; - - int m_devSoundBufferSize; - - // Number of bytes transferred from QIODevice to QAudioOutput. It is - // necessary to count this because data is dropped when suspend() is - // called. The difference between the position reported by DevSound and - // this value allows us to calculate m_bytesPadding; - quint32 m_bytesWritten; - - // True if client has provided data while the audio subsystem was not - // ready to consume it. - bool m_pushDataReady; - - // Number of zero bytes which will be written when client calls resume(). - quint32 m_bytesPadding; - - // True if PlayError(KErrUnderflow) has been called. - bool m_underflow; - - // True if a buffer marked with the "last buffer" flag has been provided - // to DevSound. - bool m_lastBuffer; - - // Some DevSound implementations ignore all underflow errors raised by the - // audio driver, unless the last buffer flag has been set by the client. - // In push-mode playback, this flag will never be set, so the underflow - // error will never be reported. In order to work around this, a timer - // is used, which gets reset every time the client provides more data. If - // the timer expires, an underflow error is raised by this object. - QScopedPointer m_underflowTimer; - - // Result of previous call to CMMFDevSound::SamplesPlayed(). This value is - // used to determine whether, when m_underflowTimer expires, an - // underflow error has actually occurred. - quint32 m_samplesPlayed; - - // Samples played up to the last call to suspend(). It is necessary - // to cache this because suspend() is implemented using - // CMMFDevSound::Stop(), which resets DevSound's SamplesPlayed() counter. - quint32 m_totalSamplesPlayed; - -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/multimedia/audio/qaudiooutput_win32_p.cpp deleted file mode 100644 index a8aeb41..0000000 --- a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.cpp +++ /dev/null @@ -1,604 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qaudiooutput_win32_p.h" - -//#define DEBUG_AUDIO 1 - -QT_BEGIN_NAMESPACE - -QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): - settings(audioFormat) -{ - bytesAvailable = 0; - buffer_size = 0; - period_size = 0; - m_device = device; - totalTimeValue = 0; - intervalTime = 1000; - audioBuffer = 0; - errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; - audioSource = 0; - pullMode = true; - finished = false; -} - -QAudioOutputPrivate::~QAudioOutputPrivate() -{ - mutex.lock(); - finished = true; - mutex.unlock(); - - close(); -} - -void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, - DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ) -{ - Q_UNUSED(dwParam1) - Q_UNUSED(dwParam2) - Q_UNUSED(hWaveOut) - - QAudioOutputPrivate* qAudio; - qAudio = (QAudioOutputPrivate*)(dwInstance); - if(!qAudio) - return; - - QMutexLocker(&qAudio->mutex); - - switch(uMsg) { - case WOM_OPEN: - qAudio->feedback(); - break; - case WOM_CLOSE: - return; - case WOM_DONE: - if(qAudio->finished || qAudio->buffer_size == 0 || qAudio->period_size == 0) { - return; - } - qAudio->waveFreeBlockCount++; - if(qAudio->waveFreeBlockCount >= qAudio->buffer_size/qAudio->period_size) - qAudio->waveFreeBlockCount = qAudio->buffer_size/qAudio->period_size; - qAudio->feedback(); - break; - default: - return; - } -} - -WAVEHDR* QAudioOutputPrivate::allocateBlocks(int size, int count) -{ - int i; - unsigned char* buffer; - WAVEHDR* blocks; - DWORD totalBufferSize = (size + sizeof(WAVEHDR))*count; - - if((buffer=(unsigned char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, - totalBufferSize)) == 0) { - qWarning("QAudioOutput: Memory allocation error"); - return 0; - } - blocks = (WAVEHDR*)buffer; - buffer += sizeof(WAVEHDR)*count; - for(i = 0; i < count; i++) { - blocks[i].dwBufferLength = size; - blocks[i].lpData = (LPSTR)buffer; - buffer += size; - } - return blocks; -} - -void QAudioOutputPrivate::freeBlocks(WAVEHDR* blockArray) -{ - WAVEHDR* blocks = blockArray; - - int count = buffer_size/period_size; - - for(int i = 0; i < count; i++) { - waveOutUnprepareHeader(hWaveOut,blocks, sizeof(WAVEHDR)); - blocks+=sizeof(WAVEHDR); - } - HeapFree(GetProcessHeap(), 0, blockArray); -} - -QAudioFormat QAudioOutputPrivate::format() const -{ - return settings; -} - -QIODevice* QAudioOutputPrivate::start(QIODevice* device) -{ - if(deviceState != QAudio::StoppedState) - close(); - - if(!pullMode && audioSource) { - delete audioSource; - } - - if(device) { - //set to pull mode - pullMode = true; - audioSource = device; - deviceState = QAudio::ActiveState; - } else { - //set to push mode - pullMode = false; - audioSource = new OutputPrivate(this); - audioSource->open(QIODevice::WriteOnly|QIODevice::Unbuffered); - deviceState = QAudio::IdleState; - } - - if( !open() ) - return 0; - - emit stateChanged(deviceState); - - return audioSource; -} - -void QAudioOutputPrivate::stop() -{ - if(deviceState == QAudio::StoppedState) - return; - close(); - if(!pullMode && audioSource) { - delete audioSource; - audioSource = 0; - } - emit stateChanged(deviceState); -} - -bool QAudioOutputPrivate::open() -{ -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()<= 8000 && settings.frequency() <= 48000)) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - qWarning("QAudioOutput: open error, frequency out of range."); - return false; - } - if(buffer_size == 0) { - // Default buffer size, 200ms, default period size is 40ms - buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2; - period_size = buffer_size/5; - } else { - period_size = buffer_size/5; - } - waveBlocks = allocateBlocks(period_size, buffer_size/period_size); - - mutex.lock(); - waveFreeBlockCount = buffer_size/period_size; - mutex.unlock(); - - waveCurrentBlock = 0; - - if(audioBuffer == 0) - audioBuffer = new char[buffer_size]; - - timeStamp.restart(); - elapsedTimeOffset = 0; - - wfx.nSamplesPerSec = settings.frequency(); - wfx.wBitsPerSample = settings.sampleSize(); - wfx.nChannels = settings.channels(); - wfx.cbSize = 0; - - wfx.wFormatTag = WAVE_FORMAT_PCM; - wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels; - wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec; - - UINT_PTR devId = WAVE_MAPPER; - - WAVEOUTCAPS woc; - unsigned long iNumDevs,ii; - iNumDevs = waveOutGetNumDevs(); - for(ii=0;ii 0) { - mutex.lock(); - if(waveFreeBlockCount==0) { - mutex.unlock(); - break; - } - mutex.unlock(); - - if(current->dwFlags & WHDR_PREPARED) - waveOutUnprepareHeader(hWaveOut, current, sizeof(WAVEHDR)); - - if(l < period_size) - remain = l; - else - remain = period_size; - memcpy(current->lpData, p, remain); - - l -= remain; - p += remain; - current->dwBufferLength = remain; - waveOutPrepareHeader(hWaveOut, current, sizeof(WAVEHDR)); - waveOutWrite(hWaveOut, current, sizeof(WAVEHDR)); - - mutex.lock(); - waveFreeBlockCount--; -#ifdef DEBUG_AUDIO - qDebug("write out l=%d, waveFreeBlockCount=%d", - current->dwBufferLength,waveFreeBlockCount); -#endif - mutex.unlock(); - totalTimeValue += current->dwBufferLength; - waveCurrentBlock++; - waveCurrentBlock %= buffer_size/period_size; - current = &waveBlocks[waveCurrentBlock]; - current->dwUser = 0; - errorState = QAudio::NoError; - if (deviceState != QAudio::ActiveState) { - deviceState = QAudio::ActiveState; - emit stateChanged(deviceState); - } - } - return (len-l); -} - -void QAudioOutputPrivate::resume() -{ - if(deviceState == QAudio::SuspendedState) { - deviceState = QAudio::ActiveState; - errorState = QAudio::NoError; - waveOutRestart(hWaveOut); - QTimer::singleShot(10, this, SLOT(feedback())); - emit stateChanged(deviceState); - } -} - -void QAudioOutputPrivate::suspend() -{ - if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState) { - int delay = (buffer_size-bytesFree())*1000/(settings.frequency() - *settings.channels()*(settings.sampleSize()/8)); - waveOutPause(hWaveOut); - Sleep(delay+10); - deviceState = QAudio::SuspendedState; - errorState = QAudio::NoError; - emit stateChanged(deviceState); - } -} - -void QAudioOutputPrivate::feedback() -{ -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()<= period_size) - QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection); - } -} - -bool QAudioOutputPrivate::deviceReady() -{ - if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) - return false; - - if(pullMode) { - int chunks = bytesAvailable/period_size; -#ifdef DEBUG_AUDIO - qDebug()<<"deviceReady() avail="< intervalTime ) { - emit notify(); - elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; - timeStamp.restart(); - } - return true; - } - - if(startup) - waveOutPause(hWaveOut); - int input = period_size*chunks; - int l = audioSource->read(audioBuffer,input); - if(l > 0) { - int out= write(audioBuffer,l); - if(out > 0) { - if (deviceState != QAudio::ActiveState) { - deviceState = QAudio::ActiveState; - emit stateChanged(deviceState); - } - } - if ( out < l) { - // Didnt write all data - audioSource->seek(audioSource->pos()-(l-out)); - } - if(startup) - waveOutRestart(hWaveOut); - } else if(l == 0) { - bytesAvailable = bytesFree(); - - int check = 0; - - mutex.lock(); - check = waveFreeBlockCount; - mutex.unlock(); - - if(check == buffer_size/period_size) { - if (deviceState != QAudio::IdleState) { - errorState = QAudio::UnderrunError; - deviceState = QAudio::IdleState; - emit stateChanged(deviceState); - } - } - - } else if(l < 0) { - bytesAvailable = bytesFree(); - errorState = QAudio::IOError; - } - } else { - int buffered; - - mutex.lock(); - buffered = waveFreeBlockCount; - mutex.unlock(); - - if (buffered >= buffer_size/period_size && deviceState == QAudio::ActiveState) { - if (deviceState != QAudio::IdleState) { - errorState = QAudio::UnderrunError; - deviceState = QAudio::IdleState; - emit stateChanged(deviceState); - } - } - } - if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) - return true; - - if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { - emit notify(); - elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; - timeStamp.restart(); - } - - return true; -} - -qint64 QAudioOutputPrivate::elapsedUSecs() const -{ - if (deviceState == QAudio::StoppedState) - return 0; - - return timeStampOpened.elapsed()*1000; -} - -QAudio::Error QAudioOutputPrivate::error() const -{ - return errorState; -} - -QAudio::State QAudioOutputPrivate::state() const -{ - return deviceState; -} - -void QAudioOutputPrivate::reset() -{ - close(); -} - -OutputPrivate::OutputPrivate(QAudioOutputPrivate* audio) -{ - audioDevice = qobject_cast(audio); -} - -OutputPrivate::~OutputPrivate() {} - -qint64 OutputPrivate::readData( char* data, qint64 len) -{ - Q_UNUSED(data) - Q_UNUSED(len) - - return 0; -} - -qint64 OutputPrivate::writeData(const char* data, qint64 len) -{ - int retry = 0; - qint64 written = 0; - - if((audioDevice->deviceState == QAudio::ActiveState) - ||(audioDevice->deviceState == QAudio::IdleState)) { - qint64 l = len; - while(written < l) { - int chunk = audioDevice->write(data+written,(l-written)); - if(chunk <= 0) - retry++; - else - written+=chunk; - - if(retry > 10) - return written; - } - audioDevice->deviceState = QAudio::ActiveState; - } - return written; -} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/multimedia/audio/qaudiooutput_win32_p.h deleted file mode 100644 index 2d19225..0000000 --- a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.h +++ /dev/null @@ -1,157 +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 QtMultimedia 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIOOUTPUTWIN_H -#define QAUDIOOUTPUTWIN_H - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -class QAudioOutputPrivate : public QAbstractAudioOutput -{ - Q_OBJECT -public: - QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat); - ~QAudioOutputPrivate(); - - qint64 write( const char *data, qint64 len ); - - QAudioFormat format() const; - QIODevice* start(QIODevice* device = 0); - void stop(); - void reset(); - void suspend(); - void resume(); - int bytesFree() const; - int periodSize() const; - void setBufferSize(int value); - int bufferSize() const; - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - QAudio::Error error() const; - QAudio::State state() const; - - QIODevice* audioSource; - QAudioFormat settings; - QAudio::Error errorState; - QAudio::State deviceState; - -private slots: - void feedback(); - bool deviceReady(); - -private: - QByteArray m_device; - bool resuming; - int bytesAvailable; - QTime timeStamp; - qint64 elapsedTimeOffset; - QTime timeStampOpened; - qint32 buffer_size; - qint32 period_size; - qint64 totalTimeValue; - bool pullMode; - int intervalTime; - static void QT_WIN_CALLBACK waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, - DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); - - QMutex mutex; - - WAVEHDR* allocateBlocks(int size, int count); - void freeBlocks(WAVEHDR* blockArray); - bool open(); - void close(); - - WAVEFORMATEX wfx; - HWAVEOUT hWaveOut; - MMRESULT result; - WAVEHDR header; - WAVEHDR* waveBlocks; - volatile bool finished; - volatile int waveFreeBlockCount; - int waveCurrentBlock; - char* audioBuffer; -}; - -class OutputPrivate : public QIODevice -{ - Q_OBJECT -public: - OutputPrivate(QAudioOutputPrivate* audio); - ~OutputPrivate(); - - qint64 readData( char* data, qint64 len); - qint64 writeData(const char* data, qint64 len); - -private: - QAudioOutputPrivate *audioDevice; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/multimedia/multimedia.pro b/src/multimedia/multimedia/multimedia.pro deleted file mode 100644 index ee700b6..0000000 --- a/src/multimedia/multimedia/multimedia.pro +++ /dev/null @@ -1,19 +0,0 @@ -TARGET = QtMultimedia -QPRO_PWD = $$PWD -QT = core gui - -DEFINES += QT_BUILD_MULTIMEDIA_LIB QT_NO_USING_NAMESPACE - -unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui - -include(../../qbase.pri) - -include(audio/audio.pri) -include(video/video.pri) - -symbian: { - TARGET.UID3 = 0x2001E627 - contains(CONFIG, def_files) { - DEF_FILE=../../s60installs - } -} diff --git a/src/multimedia/multimedia/video/qabstractvideobuffer.cpp b/src/multimedia/multimedia/video/qabstractvideobuffer.cpp deleted file mode 100644 index e9d30d0..0000000 --- a/src/multimedia/multimedia/video/qabstractvideobuffer.cpp +++ /dev/null @@ -1,200 +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 QtMultimedia 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 "qabstractvideobuffer_p.h" - -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QAbstractVideoBuffer - \brief The QAbstractVideoBuffer class is an abstraction for video data. - \since 4.6 - - The QVideoFrame class makes use of a QAbstractVideoBuffer internally to reference a buffer of - video data. Creating a subclass of QAbstractVideoBuffer will allow you to construct video - frames from preallocated or static buffers. - - The contents of a buffer can be accessed by mapping the buffer to memory using the map() - function which returns a pointer to memory containing the contents of the the video buffer. - The memory returned by map() is released by calling the unmap() function. - - The handle() of a buffer may also be used to manipulate it's contents using type specific APIs. - The type of a buffer's handle is given by the handleType() function. - - \sa QVideoFrame -*/ - -/*! - \enum QAbstractVideoBuffer::HandleType - - Identifies the type of a video buffers handle. - - \value NoHandle The buffer has no handle, its data can only be accessed by mapping the buffer. - \value GLTextureHandle The handle of the buffer is an OpenGL texture ID. - \value XvShmImageHandle The handle contains pointer to shared memory XVideo image. - \value CoreImageHandle The handle contains pointer to Mac OS X CIImage. - \value UserHandle Start value for user defined handle types. - - \sa handleType() -*/ - -/*! - \enum QAbstractVideoBuffer::MapMode - - Enumerates how a video buffer's data is mapped to memory. - - \value NotMapped The video buffer has is not mapped to memory. - \value ReadOnly The mapped memory is populated with data from the video buffer when mapped, but - the content of the mapped memory may be discarded when unmapped. - \value WriteOnly The mapped memory in unitialized when mapped, and the content will be used to - populate the video buffer when unmapped. - \value ReadWrite The mapped memory is populated with data from the video buffer, and the - video buffer is repopulated with the content of the mapped memory. - - \sa mapMode(), map() -*/ - -/*! - Constructs an abstract video buffer of the given \a type. -*/ - -QAbstractVideoBuffer::QAbstractVideoBuffer(HandleType type) - : d_ptr(new QAbstractVideoBufferPrivate) -{ - Q_D(QAbstractVideoBuffer); - - d->handleType = type; -} - -/*! - \internal -*/ - -QAbstractVideoBuffer::QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, HandleType type) - : d_ptr(&dd) -{ - Q_D(QAbstractVideoBuffer); - - d->handleType = type; -} - -/*! - Destroys an abstract video buffer. -*/ - -QAbstractVideoBuffer::~QAbstractVideoBuffer() -{ - delete d_ptr; -} - -/*! - Returns the type of a video buffer's handle. - - \sa handle() -*/ - -QAbstractVideoBuffer::HandleType QAbstractVideoBuffer::handleType() const -{ - return d_func()->handleType; -} - -/*! - \fn QAbstractVideoBuffer::mapMode() const - - Returns the mode a video buffer is mapped in. - - \sa map() -*/ - -/*! - \fn QAbstractVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) - - Maps the contents of a video buffer to memory. - - The map \a mode indicates whether the contents of the mapped memory should be read from and/or - written to the buffer. If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the - mapped memory will be populated with the content of the video buffer when mapped. If the map - mode includes the QAbstractVideoBuffer::WriteOnly flag the content of the mapped memory will be - persisted in the buffer when unmapped. - - When access to the data is no longer needed be sure to call the unmap() function to release the - mapped memory. - - Returns a pointer to the mapped memory region, or a null pointer if the mapping failed. The - size in bytes of the mapped memory region is returned in \a numBytes, and the line stride in \a - bytesPerLine. - - When access to the data is no longer needed be sure to unmap() the buffer. - - \note Writing to memory that is mapped as read-only is undefined, and may result in changes - to shared data. - - \sa unmap(), mapMode() -*/ - -/*! - \fn QAbstractVideoBuffer::unmap() - - Releases the memory mapped by the map() function - - If the \l {QAbstractVideoBuffer::MapMode}{MapMode} included the QAbstractVideoBuffer::WriteOnly - flag this will persist the current content of the mapped memory to the video frame. - - \sa map() -*/ - -/*! - Returns a type specific handle to the data buffer. - - The type of the handle is given by handleType() function. - - \sa handleType() -*/ - -QVariant QAbstractVideoBuffer::handle() const -{ - return QVariant(); -} - - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/video/qabstractvideobuffer.h b/src/multimedia/multimedia/video/qabstractvideobuffer.h deleted file mode 100644 index a8389db..0000000 --- a/src/multimedia/multimedia/video/qabstractvideobuffer.h +++ /dev/null @@ -1,106 +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 QtMultimedia 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 QABSTRACTVIDEOBUFFER_H -#define QABSTRACTVIDEOBUFFER_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QVariant; - -class QAbstractVideoBufferPrivate; - -class Q_MULTIMEDIA_EXPORT QAbstractVideoBuffer -{ -public: - enum HandleType - { - NoHandle, - GLTextureHandle, - XvShmImageHandle, - CoreImageHandle, - UserHandle = 1000 - }; - - enum MapMode - { - NotMapped = 0x00, - ReadOnly = 0x01, - WriteOnly = 0x02, - ReadWrite = ReadOnly | WriteOnly - }; - - QAbstractVideoBuffer(HandleType type); - virtual ~QAbstractVideoBuffer(); - - HandleType handleType() const; - - virtual MapMode mapMode() const = 0; - - virtual uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) = 0; - virtual void unmap() = 0; - - virtual QVariant handle() const; - -protected: - QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, HandleType type); - - QAbstractVideoBufferPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QAbstractVideoBuffer) - Q_DISABLE_COPY(QAbstractVideoBuffer) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QAbstractVideoBuffer::HandleType) -Q_DECLARE_METATYPE(QAbstractVideoBuffer::MapMode) - -QT_END_HEADER - -#endif diff --git a/src/multimedia/multimedia/video/qabstractvideobuffer_p.h b/src/multimedia/multimedia/video/qabstractvideobuffer_p.h deleted file mode 100644 index c72f303..0000000 --- a/src/multimedia/multimedia/video/qabstractvideobuffer_p.h +++ /dev/null @@ -1,73 +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 QtMultimedia 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 QABSTRACTVIDEOBUFFER_P_H -#define QABSTRACTVIDEOBUFFER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -class QAbstractVideoBufferPrivate -{ -public: - QAbstractVideoBufferPrivate() - : handleType(QAbstractVideoBuffer::NoHandle) - {} - - QAbstractVideoBuffer::HandleType handleType; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/multimedia/video/qabstractvideosurface.cpp b/src/multimedia/multimedia/video/qabstractvideosurface.cpp deleted file mode 100644 index 3dabb6b..0000000 --- a/src/multimedia/multimedia/video/qabstractvideosurface.cpp +++ /dev/null @@ -1,283 +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 QtMultimedia 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 "qabstractvideosurface_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QAbstractVideoSurface - \brief The QAbstractVideoSurface class is a base class for video presentation surfaces. - \since 4.6 - - The QAbstractVideoSurface class defines the standard interface that video producers use to - inter-operate with video presentation surfaces. It is not supposed to be instantiated directly. - Instead, you should subclass it to create new video surfaces. - - A video surface presents a continuous stream of identically formatted frames, where the format - of each frame is compatible with a stream format supplied when starting a presentation. - - A list of pixel formats a surface can present is given by the supportedPixelFormats() function, - and the isFormatSupported() function will test if a video surface format is supported. If a - format is not supported the nearestFormat() function may be able to suggest a similar format. - For example if a surface supports fixed set of resolutions it may suggest the smallest - supported resolution that contains the proposed resolution. - - The start() function takes a supported format and enables a video surface. Once started a - surface will begin displaying the frames it receives in the present() function. Surfaces may - hold a reference to the buffer of a presented video frame until a new frame is presented or - streaming is stopped. The stop() function will disable a surface and a release any video - buffers it holds references to. -*/ - -/*! - \enum QAbstractVideoSurface::Error - This enum describes the errors that may be returned by the error() function. - - \value NoError No error occurred. - \value UnsupportedFormatError A video format was not supported. - \value IncorrectFormatError A video frame was not compatible with the format of the surface. - \value StoppedError The surface has not been started. - \value ResourceError The surface could not allocate some resource. -*/ - -/*! - Constructs a video surface with the given \a parent. -*/ - -QAbstractVideoSurface::QAbstractVideoSurface(QObject *parent) - : QObject(*new QAbstractVideoSurfacePrivate, parent) -{ -} - -/*! - \internal -*/ - -QAbstractVideoSurface::QAbstractVideoSurface(QAbstractVideoSurfacePrivate &dd, QObject *parent) - : QObject(dd, parent) -{ -} - -/*! - Destroys a video surface. -*/ - -QAbstractVideoSurface::~QAbstractVideoSurface() -{ -} - -/*! - \fn QAbstractVideoSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType type) const - - Returns a list of pixel formats a video surface can present for a given handle \a type. - - The pixel formats returned for the QAbstractVideoBuffer::NoHandle type are valid for any buffer - that can be mapped in read-only mode. - - Types that are first in the list can be assumed to be faster to render. -*/ - -/*! - Tests a video surface \a format to determine if a surface can accept it. - - Returns true if the format is supported by the surface, and false otherwise. -*/ - -bool QAbstractVideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const -{ - return supportedPixelFormats(format.handleType()).contains(format.pixelFormat()); -} - -/*! - Returns a supported video surface format that is similar to \a format. - - A similar surface format is one that has the same \l {QVideoSurfaceFormat::pixelFormat()}{pixel - format} and \l {QVideoSurfaceFormat::handleType()}{handle type} but differs in some of the other - properties. For example if there are restrictions on the \l {QVideoSurfaceFormat::frameSize()} - {frame sizes} a video surface can accept it may suggest a format with a larger frame size and - a \l {QVideoSurfaceFormat::viewport()}{viewport} the size of the original frame size. - - If the format is already supported it will be returned unchanged, or if there is no similar - supported format an invalid format will be returned. -*/ - -QVideoSurfaceFormat QAbstractVideoSurface::nearestFormat(const QVideoSurfaceFormat &format) const -{ - return isFormatSupported(format) - ? format - : QVideoSurfaceFormat(); -} - -/*! - \fn QAbstractVideoSurface::supportedFormatsChanged() - - Signals that the set of formats supported by a video surface has changed. - - \sa supportedPixelFormats(), isFormatSupported() -*/ - -/*! - Returns the format of a video surface. -*/ - -QVideoSurfaceFormat QAbstractVideoSurface::surfaceFormat() const -{ - return d_func()->format; -} - -/*! - \fn QAbstractVideoSurface::surfaceFormatChanged(const QVideoSurfaceFormat &format) - - Signals that the configured \a format of a video surface has changed. - - \sa surfaceFormat(), start() -*/ - -/*! - Starts a video surface presenting \a format frames. - - Returns true if the surface was started, and false if an error occurred. - - \sa isActive(), stop() -*/ - -bool QAbstractVideoSurface::start(const QVideoSurfaceFormat &format) -{ - Q_D(QAbstractVideoSurface); - - bool wasActive = d->active; - - d->active = true; - d->format = format; - d->error = NoError; - - emit surfaceFormatChanged(d->format); - - if (!wasActive) - emit activeChanged(true); - - return true; -} - -/*! - Stops a video surface presenting frames and releases any resources acquired in start(). - - \sa isActive(), start() -*/ - -void QAbstractVideoSurface::stop() -{ - Q_D(QAbstractVideoSurface); - - if (d->active) { - d->format = QVideoSurfaceFormat(); - d->active = false; - - emit activeChanged(false); - emit surfaceFormatChanged(d->format); - } -} - -/*! - Indicates whether a video surface has been started. - - Returns true if the surface has been started, and false otherwise. -*/ - -bool QAbstractVideoSurface::isActive() const -{ - return d_func()->active; -} - -/*! - \fn QAbstractVideoSurface::activeChanged(bool active) - - Signals that the \a active state of a video surface has changed. - - \sa isActive(), start(), stop() -*/ - -/*! - \fn QAbstractVideoSurface::present(const QVideoFrame &frame) - - Presents a video \a frame. - - Returns true if the frame was presented, and false if an error occurred. - - Not all surfaces will block until the presentation of a frame has completed. Calling present() - on a non-blocking surface may fail if called before the presentation of a previous frame has - completed. In such cases the surface may not return to a ready state until it's had an - opportunity to process events. - - If present() fails for any other reason the surface will immediately enter the stopped state - and an error() value will be set. - - A video surface must be in the started state for present() to succeed, and the format of the - video frame must be compatible with the current video surface format. - - \sa error() -*/ - -/*! - Returns the last error that occurred. - - If a surface fails to start(), or stops unexpectedly this function can be called to discover - what error occurred. -*/ - -QAbstractVideoSurface::Error QAbstractVideoSurface::error() const -{ - return d_func()->error; -} - -/*! - Sets the value of error() to \a error. -*/ - -void QAbstractVideoSurface::setError(Error error) -{ - Q_D(QAbstractVideoSurface); - - d->error = error; -} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/video/qabstractvideosurface.h b/src/multimedia/multimedia/video/qabstractvideosurface.h deleted file mode 100644 index f2cae17..0000000 --- a/src/multimedia/multimedia/video/qabstractvideosurface.h +++ /dev/null @@ -1,110 +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 QtMultimedia 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 QABSTRACTVIDEOSURFACE_H -#define QABSTRACTVIDEOSURFACE_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QRectF; -class QVideoSurfaceFormat; - -class QAbstractVideoSurfacePrivate; - -class Q_MULTIMEDIA_EXPORT QAbstractVideoSurface : public QObject -{ - Q_OBJECT - -public: - enum Error - { - NoError, - UnsupportedFormatError, - IncorrectFormatError, - StoppedError, - ResourceError - }; - - explicit QAbstractVideoSurface(QObject *parent = 0); - ~QAbstractVideoSurface(); - - virtual QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const = 0; - virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const; - virtual QVideoSurfaceFormat nearestFormat(const QVideoSurfaceFormat &format) const; - - QVideoSurfaceFormat surfaceFormat() const; - - virtual bool start(const QVideoSurfaceFormat &format); - virtual void stop(); - - bool isActive() const; - - virtual bool present(const QVideoFrame &frame) = 0; - - Error error() const; - -Q_SIGNALS: - void activeChanged(bool active); - void surfaceFormatChanged(const QVideoSurfaceFormat &format); - void supportedFormatsChanged(); - -protected: - QAbstractVideoSurface(QAbstractVideoSurfacePrivate &dd, QObject *parent); - - void setError(Error error); - -private: - Q_DECLARE_PRIVATE(QAbstractVideoSurface) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/multimedia/video/qabstractvideosurface_p.h b/src/multimedia/multimedia/video/qabstractvideosurface_p.h deleted file mode 100644 index 42df112..0000000 --- a/src/multimedia/multimedia/video/qabstractvideosurface_p.h +++ /dev/null @@ -1,78 +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 QtMultimedia 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 QABSTRACTVIDEOSURFACE_P_H -#define QABSTRACTVIDEOSURFACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QAbstractVideoSurfacePrivate : public QObjectPrivate -{ -public: - QAbstractVideoSurfacePrivate() - : error(QAbstractVideoSurface::NoError) - , active(false) - { - } - - mutable QAbstractVideoSurface::Error error; - QVideoSurfaceFormat format; - bool active; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/multimedia/video/qimagevideobuffer.cpp b/src/multimedia/multimedia/video/qimagevideobuffer.cpp deleted file mode 100644 index e3e1585..0000000 --- a/src/multimedia/multimedia/video/qimagevideobuffer.cpp +++ /dev/null @@ -1,106 +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 QtMultimedia 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 "qimagevideobuffer_p.h" - -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QImageVideoBufferPrivate : public QAbstractVideoBufferPrivate -{ -public: - QImageVideoBufferPrivate() - : mapMode(QAbstractVideoBuffer::NotMapped) - { - } - - QAbstractVideoBuffer::MapMode mapMode; - QImage image; -}; - -QImageVideoBuffer::QImageVideoBuffer(const QImage &image) - : QAbstractVideoBuffer(*new QImageVideoBufferPrivate, NoHandle) -{ - Q_D(QImageVideoBuffer); - - d->image = image; -} - -QImageVideoBuffer::~QImageVideoBuffer() -{ -} - -QAbstractVideoBuffer::MapMode QImageVideoBuffer::mapMode() const -{ - return d_func()->mapMode; -} - -uchar *QImageVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) -{ - Q_D(QImageVideoBuffer); - - if (d->mapMode == NotMapped && d->image.bits() && mode != NotMapped) { - d->mapMode = mode; - - if (numBytes) - *numBytes = d->image.byteCount(); - - if (bytesPerLine) - *bytesPerLine = d->image.bytesPerLine(); - - return d->image.bits(); - } else { - return 0; - } -} - -void QImageVideoBuffer::unmap() -{ - Q_D(QImageVideoBuffer); - - d->mapMode = NotMapped; -} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/video/qimagevideobuffer_p.h b/src/multimedia/multimedia/video/qimagevideobuffer_p.h deleted file mode 100644 index 82075d7..0000000 --- a/src/multimedia/multimedia/video/qimagevideobuffer_p.h +++ /dev/null @@ -1,79 +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 QtMultimedia 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 QIMAGEVIDEOBUFFER_P_H -#define QIMAGEVIDEOBUFFER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -class QImage; - -class QImageVideoBufferPrivate; - -class Q_MULTIMEDIA_EXPORT QImageVideoBuffer : public QAbstractVideoBuffer -{ - Q_DECLARE_PRIVATE(QImageVideoBuffer) -public: - QImageVideoBuffer(const QImage &image); - ~QImageVideoBuffer(); - - MapMode mapMode() const; - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); - void unmap(); -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/multimedia/video/qmemoryvideobuffer.cpp b/src/multimedia/multimedia/video/qmemoryvideobuffer.cpp deleted file mode 100644 index 2e892b7..0000000 --- a/src/multimedia/multimedia/video/qmemoryvideobuffer.cpp +++ /dev/null @@ -1,129 +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 QtMultimedia 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 "qmemoryvideobuffer_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -class QMemoryVideoBufferPrivate : public QAbstractVideoBufferPrivate -{ -public: - QMemoryVideoBufferPrivate() - : bytesPerLine(0) - , mapMode(QAbstractVideoBuffer::NotMapped) - { - } - - int bytesPerLine; - QAbstractVideoBuffer::MapMode mapMode; - QByteArray data; -}; - -/*! - \class QMemoryVideoBuffer - \brief The QMemoryVideoBuffer class provides a system memory allocated video data buffer. - \internal - - QMemoryVideoBuffer is the default video buffer for allocating system memory. It may be used to - allocate memory for a QVideoFrame without implementing your own QAbstractVideoBuffer. -*/ - -/*! - Constructs a video buffer with an image stride of \a bytesPerLine from a byte \a array. -*/ -QMemoryVideoBuffer::QMemoryVideoBuffer(const QByteArray &array, int bytesPerLine) - : QAbstractVideoBuffer(*new QMemoryVideoBufferPrivate, NoHandle) -{ - Q_D(QMemoryVideoBuffer); - - d->data = array; - d->bytesPerLine = bytesPerLine; -} - -/*! - Destroys a system memory allocated video buffer. -*/ -QMemoryVideoBuffer::~QMemoryVideoBuffer() -{ -} - -/*! - \reimp -*/ -QAbstractVideoBuffer::MapMode QMemoryVideoBuffer::mapMode() const -{ - return d_func()->mapMode; -} - -/*! - \reimp -*/ -uchar *QMemoryVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) -{ - Q_D(QMemoryVideoBuffer); - - if (d->mapMode == NotMapped && d->data.data() && mode != NotMapped) { - d->mapMode = mode; - - if (numBytes) - *numBytes = d->data.size(); - - if (bytesPerLine) - *bytesPerLine = d->bytesPerLine; - - return reinterpret_cast(d->data.data()); - } else { - return 0; - } -} - -/*! - \reimp -*/ -void QMemoryVideoBuffer::unmap() -{ - d_func()->mapMode = NotMapped; -} - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/video/qmemoryvideobuffer_p.h b/src/multimedia/multimedia/video/qmemoryvideobuffer_p.h deleted file mode 100644 index c66cf93..0000000 --- a/src/multimedia/multimedia/video/qmemoryvideobuffer_p.h +++ /dev/null @@ -1,83 +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 QtMultimedia 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 QMEMORYVIDEOBUFFER_P_H -#define QMEMORYVIDEOBUFFER_P_H - -#include - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMemoryVideoBufferPrivate; - -class Q_MULTIMEDIA_EXPORT QMemoryVideoBuffer : public QAbstractVideoBuffer -{ - Q_DECLARE_PRIVATE(QMemoryVideoBuffer) -public: - QMemoryVideoBuffer(const QByteArray &data, int bytesPerLine); - ~QMemoryVideoBuffer(); - - MapMode mapMode() const; - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); - void unmap(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/multimedia/video/qvideoframe.cpp b/src/multimedia/multimedia/video/qvideoframe.cpp deleted file mode 100644 index 2d66d9e..0000000 --- a/src/multimedia/multimedia/video/qvideoframe.cpp +++ /dev/null @@ -1,741 +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 QtMultimedia 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 "qvideoframe.h" - -#include -#include - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QVideoFramePrivate : public QSharedData -{ -public: - QVideoFramePrivate() - : startTime(-1) - , endTime(-1) - , data(0) - , mappedBytes(0) - , bytesPerLine(0) - , pixelFormat(QVideoFrame::Format_Invalid) - , fieldType(QVideoFrame::ProgressiveFrame) - , buffer(0) - { - } - - QVideoFramePrivate(const QSize &size, QVideoFrame::PixelFormat format) - : size(size) - , startTime(-1) - , endTime(-1) - , data(0) - , mappedBytes(0) - , bytesPerLine(0) - , pixelFormat(format) - , fieldType(QVideoFrame::ProgressiveFrame) - , buffer(0) - { - } - - ~QVideoFramePrivate() - { - delete buffer; - } - - QSize size; - qint64 startTime; - qint64 endTime; - uchar *data; - int mappedBytes; - int bytesPerLine; - QVideoFrame::PixelFormat pixelFormat; - QVideoFrame::FieldType fieldType; - QAbstractVideoBuffer *buffer; - -private: - Q_DISABLE_COPY(QVideoFramePrivate) -}; - -/*! - \class QVideoFrame - \brief The QVideoFrame class provides a representation of a frame of video data. - \since 4.6 - - A QVideoFrame encapsulates the data of a video frame, and information about the frame. - - The contents of a video frame can be mapped to memory using the map() function. While - mapped the video data can accessed using the bits() function which returns a pointer to a - buffer, the total size of which is given by the mappedBytes(), and the size of each line is given - by bytesPerLine(). The return value of the handle() function may be used to access frame data - using the internal buffer's native APIs. - - The video data in a QVideoFrame is encapsulated in a QAbstractVideoBuffer. A QVideoFrame - may be constructed from any buffer type by subclassing the QAbstractVideoBuffer class. - - \note QVideoFrame is explicitly shared, any change made to video frame will also apply to any - copies. -*/ - -/*! - \enum QVideoFrame::PixelFormat - - Enumerates video data types. - - \value Format_Invalid - The frame is invalid. - - \value Format_ARGB32 - The frame is stored using a 32-bit ARGB format (0xAARRGGBB). This is equivalent to - QImage::Format_ARGB32. - - \value Format_ARGB32_Premultiplied - The frame stored using a premultiplied 32-bit ARGB format (0xAARRGGBB). This is equivalent - to QImage::Format_ARGB32_Premultiplied. - - \value Format_RGB32 - The frame stored using a 32-bit RGB format (0xffRRGGBB). This is equivalent to - QImage::Format_RGB32 - - \value Format_RGB24 - The frame is stored using a 24-bit RGB format (8-8-8). This is equivalent to - QImage::Format_RGB888 - - \value Format_RGB565 - The frame is stored using a 16-bit RGB format (5-6-5). This is equivalent to - QImage::Format_RGB16. - - \value Format_RGB555 - The frame is stored using a 16-bit RGB format (5-5-5). This is equivalent to - QImage::Format_RGB555. - - \value Format_ARGB8565_Premultiplied - The frame is stored using a 24-bit premultiplied ARGB format (8-6-6-5). - - \value Format_BGRA32 - The frame is stored using a 32-bit ARGB format (0xBBGGRRAA). - - \value Format_BGRA32_Premultiplied - The frame is stored using a premultiplied 32bit BGRA format. - - \value Format_BGR32 - The frame is stored using a 32-bit BGR format (0xBBGGRRff). - - \value Format_BGR24 - The frame is stored using a 24-bit BGR format (0xBBGGRR). - - \value Format_BGR565 - The frame is stored using a 16-bit BGR format (5-6-5). - - \value Format_BGR555 - The frame is stored using a 16-bit BGR format (5-5-5). - - \value Format_BGRA5658_Premultiplied - The frame is stored using a 24-bit premultiplied BGRA format (5-6-5-8). - - \value Format_AYUV444 - The frame is stored using a packed 32-bit AYUV format (0xAAYYUUVV). - - \value Format_AYUV444_Premultiplied - The frame is stored using a packed premultiplied 32-bit AYUV format (0xAAYYUUVV). - - \value Format_YUV444 - The frame is stored using a 24-bit packed YUV format (8-8-8). - - \value Format_YUV420P - The frame is stored using an 8-bit per component planar YUV format with the U and V planes - horizontally and vertically sub-sampled, i.e. the height and width of the U and V planes are - half that of the Y plane. - - \value Format_YV12 - The frame is stored using an 8-bit per component planar YVU format with the V and U planes - horizontally and vertically sub-sampled, i.e. the height and width of the V and U planes are - half that of the Y plane. - - \value Format_UYVY - The frame is stored using an 8-bit per component packed YUV format with the U and V planes - horizontally sub-sampled (U-Y-V-Y), i.e. two horizontally adjacent pixels are stored as a 32-bit - macropixel which has a Y value for each pixel and common U and V values. - - \value Format_YUYV - The frame is stored using an 8-bit per component packed YUV format with the U and V planes - horizontally sub-sampled (Y-U-Y-V), i.e. two horizontally adjacent pixels are stored as a 32-bit - macropixel which has a Y value for each pixel and common U and V values. - - \value Format_NV12 - The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) - followed by a horizontally and vertically sub-sampled, packed UV plane (U-V). - - \value Format_NV21 - The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) - followed by a horizontally and vertically sub-sampled, packed VU plane (V-U). - - \value Format_IMC1 - The frame is stored using an 8-bit per component planar YUV format with the U and V planes - horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except - that the bytes per line of the U and V planes are padded out to the same stride as the Y plane. - - \value Format_IMC2 - The frame is stored using an 8-bit per component planar YUV format with the U and V planes - horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except - that the lines of the U and V planes are interleaved, i.e. each line of U data is followed by a - line of V data creating a single line of the same stride as the Y data. - - \value Format_IMC3 - The frame is stored using an 8-bit per component planar YVU format with the V and U planes - horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that - the bytes per line of the V and U planes are padded out to the same stride as the Y plane. - - \value Format_IMC4 - The frame is stored using an 8-bit per component planar YVU format with the V and U planes - horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that - the lines of the V and U planes are interleaved, i.e. each line of V data is followed by a line - of U data creating a single line of the same stride as the Y data. - - \value Format_Y8 - The frame is stored using an 8-bit greyscale format. - - \value Format_Y16 - The frame is stored using a 16-bit linear greyscale format. Little endian. - - \value Format_User - Start value for user defined pixel formats. -*/ - -/*! - \enum QVideoFrame::FieldType - - Specifies the field an interlaced video frame belongs to. - - \value ProgressiveFrame The frame is not interlaced. - \value TopField The frame contains a top field. - \value BottomField The frame contains a bottom field. - \value InterlacedFrame The frame contains a merged top and bottom field. -*/ - -/*! - Constructs a null video frame. -*/ - -QVideoFrame::QVideoFrame() - : d(new QVideoFramePrivate) -{ -} - -/*! - Constructs a video frame from a \a buffer of the given pixel \a format and \a size in pixels. - - \note This doesn't increment the reference count of the video buffer. -*/ - -QVideoFrame::QVideoFrame( - QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format) - : d(new QVideoFramePrivate(size, format)) -{ - d->buffer = buffer; -} - -/*! - Constructs a video frame of the given pixel \a format and \a size in pixels. - - The \a bytesPerLine (stride) is the length of each scan line in bytes, and \a bytes is the total - number of bytes that must be allocated for the frame. -*/ - -QVideoFrame::QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format) - : d(new QVideoFramePrivate(size, format)) -{ - if (bytes > 0) { - QByteArray data; - data.resize(bytes); - - // Check the memory was successfully allocated. - if (!data.isEmpty()) - d->buffer = new QMemoryVideoBuffer(data, bytesPerLine); - } -} - -/*! - Constructs a video frame from an \a image. - - \note This will construct an invalid video frame if there is no frame type equivalent to the - image format. - - \sa pixelFormatFromImageFormat() -*/ - -QVideoFrame::QVideoFrame(const QImage &image) - : d(new QVideoFramePrivate( - image.size(), pixelFormatFromImageFormat(image.format()))) -{ - if (d->pixelFormat != Format_Invalid) - d->buffer = new QImageVideoBuffer(image); -} - -/*! - Constructs a copy of \a other. -*/ - -QVideoFrame::QVideoFrame(const QVideoFrame &other) - : d(other.d) -{ -} - -/*! - Assigns the contents of \a other to a video frame. -*/ - -QVideoFrame &QVideoFrame::operator =(const QVideoFrame &other) -{ - d = other.d; - - return *this; -} - -/*! - Destroys a video frame. -*/ - -QVideoFrame::~QVideoFrame() -{ -} - -/*! - Identifies whether a video frame is valid. - - An invalid frame has no video buffer associated with it. - - Returns true if the frame is valid, and false if it is not. -*/ - -bool QVideoFrame::isValid() const -{ - return d->buffer != 0; -} - -/*! - Returns the color format of a video frame. -*/ - -QVideoFrame::PixelFormat QVideoFrame::pixelFormat() const -{ - return d->pixelFormat; -} - -/*! - Returns the type of a video frame's handle. -*/ - -QAbstractVideoBuffer::HandleType QVideoFrame::handleType() const -{ - return d->buffer ? d->buffer->handleType() : QAbstractVideoBuffer::NoHandle; -} - -/*! - Returns the size of a video frame. -*/ - -QSize QVideoFrame::size() const -{ - return d->size; -} - -/*! - Returns the width of a video frame. -*/ - -int QVideoFrame::width() const -{ - return d->size.width(); -} - -/*! - Returns the height of a video frame. -*/ - -int QVideoFrame::height() const -{ - return d->size.height(); -} - -/*! - Returns the field an interlaced video frame belongs to. - - If the video is not interlaced this will return WholeFrame. -*/ - -QVideoFrame::FieldType QVideoFrame::fieldType() const -{ - return d->fieldType; -} - -/*! - Sets the \a field an interlaced video frame belongs to. -*/ - -void QVideoFrame::setFieldType(QVideoFrame::FieldType field) -{ - d->fieldType = field; -} - -/*! - Identifies if a video frame's contents are currently mapped to system memory. - - This is a convenience function which checks that the \l {QAbstractVideoBuffer::MapMode}{MapMode} - of the frame is not equal to QAbstractVideoBuffer::NotMapped. - - Returns true if the contents of the video frame are mapped to system memory, and false - otherwise. - - \sa mapMode() QAbstractVideoBuffer::MapMode -*/ - -bool QVideoFrame::isMapped() const -{ - return d->buffer != 0 && d->buffer->mapMode() != QAbstractVideoBuffer::NotMapped; -} - -/*! - Identifies if the mapped contents of a video frame will be persisted when the frame is unmapped. - - This is a convenience function which checks if the \l {QAbstractVideoBuffer::MapMode}{MapMode} - contains the QAbstractVideoBuffer::WriteOnly flag. - - Returns true if the video frame will be updated when unmapped, and false otherwise. - - \note The result of altering the data of a frame that is mapped in read-only mode is undefined. - Depending on the buffer implementation the changes may be persisted, or worse alter a shared - buffer. - - \sa mapMode(), QAbstractVideoBuffer::MapMode -*/ - -bool QVideoFrame::isWritable() const -{ - return d->buffer != 0 && (d->buffer->mapMode() & QAbstractVideoBuffer::WriteOnly); -} - -/*! - Identifies if the mapped contents of a video frame were read from the frame when it was mapped. - - This is a convenience function which checks if the \l {QAbstractVideoBuffer::MapMode}{MapMode} - contains the QAbstractVideoBuffer::WriteOnly flag. - - Returns true if the contents of the mapped memory were read from the video frame, and false - otherwise. - - \sa mapMode(), QAbstractVideoBuffer::MapMode -*/ - -bool QVideoFrame::isReadable() const -{ - return d->buffer != 0 && (d->buffer->mapMode() & QAbstractVideoBuffer::ReadOnly); -} - -/*! - Returns the mode a video frame was mapped to system memory in. - - \sa map(), QAbstractVideoBuffer::MapMode -*/ - -QAbstractVideoBuffer::MapMode QVideoFrame::mapMode() const -{ - return d->buffer != 0 ? d->buffer->mapMode() : QAbstractVideoBuffer::NotMapped; -} - -/*! - Maps the contents of a video frame to memory. - - The map \a mode indicates whether the contents of the mapped memory should be read from and/or - written to the frame. If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the - mapped memory will be populated with the content of the video frame when mapped. If the map - mode inclues the QAbstractVideoBuffer::WriteOnly flag the content of the mapped memory will be - persisted in the frame when unmapped. - - While mapped the contents of a video frame can be accessed directly through the pointer returned - by the bits() function. - - When access to the data is no longer needed be sure to call the unmap() function to release the - mapped memory. - - Returns true if the buffer was mapped to memory in the given \a mode and false otherwise. - - \sa unmap(), mapMode(), bits() -*/ - -bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) -{ - if (d->buffer != 0 && d->data == 0) { - Q_ASSERT(d->bytesPerLine == 0); - Q_ASSERT(d->mappedBytes == 0); - - d->data = d->buffer->map(mode, &d->mappedBytes, &d->bytesPerLine); - - return d->data != 0; - } - - return false; -} - -/*! - Releases the memory mapped by the map() function. - - If the \l {QAbstractVideoBuffer::MapMode}{MapMode} included the QAbstractVideoBuffer::WriteOnly - flag this will persist the current content of the mapped memory to the video frame. - - \sa map() -*/ - -void QVideoFrame::unmap() -{ - if (d->data != 0) { - d->mappedBytes = 0; - d->bytesPerLine = 0; - d->data = 0; - - d->buffer->unmap(); - } -} - -/*! - Returns the number of bytes in a scan line. - - \note This is the bytes per line of the first plane only. The bytes per line of subsequent - planes should be calculated as per the frame type. - - This value is only valid while the frame data is \l {map()}{mapped}. - - \sa bits(), map(), mappedBytes() -*/ - -int QVideoFrame::bytesPerLine() const -{ - return d->bytesPerLine; -} - -/*! - Returns a pointer to the start of the frame data buffer. - - This value is only valid while the frame data is \l {map()}{mapped}. - - \sa map(), mappedBytes(), bytesPerLine() -*/ - -uchar *QVideoFrame::bits() -{ - return d->data; -} - -/*! - Returns a pointer to the start of the frame data buffer. - - This value is only valid while the frame data is \l {map()}{mapped}. - - \sa map(), mappedBytes(), bytesPerLine() -*/ - -const uchar *QVideoFrame::bits() const -{ - return d->data; -} - -/*! - Returns the number of bytes occupied by the mapped frame data. - - This value is only valid while the frame data is \l {map()}{mapped}. - - \sa map() -*/ - -int QVideoFrame::mappedBytes() const -{ - return d->mappedBytes; -} - -/*! - Returns a type specific handle to a video frame's buffer. - - For an OpenGL texture this would be the texture ID. - - \sa QAbstractVideoBuffer::handle() -*/ - -QVariant QVideoFrame::handle() const -{ - return d->buffer != 0 ? d->buffer->handle() : QVariant(); -} - -/*! - Returns the presentation time when the frame should be displayed. -*/ - -qint64 QVideoFrame::startTime() const -{ - return d->startTime; -} - -/*! - Sets the presentation \a time when the frame should be displayed. -*/ - -void QVideoFrame::setStartTime(qint64 time) -{ - d->startTime = time; -} - -/*! - Returns the presentation time when a frame should stop being displayed. -*/ - -qint64 QVideoFrame::endTime() const -{ - return d->endTime; -} - -/*! - Sets the presentation \a time when a frame should stop being displayed. -*/ - -void QVideoFrame::setEndTime(qint64 time) -{ - d->endTime = time; -} - -/*! - Returns an video pixel format equivalent to an image \a format. If there is no equivalent - format QVideoFrame::InvalidType is returned instead. -*/ - -QVideoFrame::PixelFormat QVideoFrame::pixelFormatFromImageFormat(QImage::Format format) -{ - switch (format) { - case QImage::Format_Invalid: - case QImage::Format_Mono: - case QImage::Format_MonoLSB: - case QImage::Format_Indexed8: - return Format_Invalid; - case QImage::Format_RGB32: - return Format_RGB32; - case QImage::Format_ARGB32: - return Format_ARGB32; - case QImage::Format_ARGB32_Premultiplied: - return Format_ARGB32_Premultiplied; - case QImage::Format_RGB16: - return Format_RGB565; - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_RGB666: - case QImage::Format_ARGB6666_Premultiplied: - return Format_Invalid; - case QImage::Format_RGB555: - return Format_RGB555; - case QImage::Format_ARGB8555_Premultiplied: - return Format_Invalid; - case QImage::Format_RGB888: - return Format_RGB24; - case QImage::Format_RGB444: - case QImage::Format_ARGB4444_Premultiplied: - return Format_Invalid; - case QImage::NImageFormats: - return Format_Invalid; - } - return Format_Invalid; -} - -/*! - Returns an image format equivalent to a video frame pixel \a format. If there is no equivalent - format QImage::Format_Invalid is returned instead. -*/ - -QImage::Format QVideoFrame::imageFormatFromPixelFormat(PixelFormat format) -{ - switch (format) { - case Format_Invalid: - return QImage::Format_Invalid; - case Format_ARGB32: - return QImage::Format_ARGB32; - case Format_ARGB32_Premultiplied: - return QImage::Format_ARGB32_Premultiplied; - case Format_RGB32: - return QImage::Format_RGB32; - case Format_RGB24: - return QImage::Format_RGB888; - case Format_RGB565: - return QImage::Format_RGB16; - case Format_RGB555: - return QImage::Format_RGB555; - case Format_ARGB8565_Premultiplied: - return QImage::Format_ARGB8565_Premultiplied; - case Format_BGRA32: - case Format_BGRA32_Premultiplied: - case Format_BGR32: - case Format_BGR24: - return QImage::Format_Invalid; - case Format_BGR565: - case Format_BGR555: - case Format_BGRA5658_Premultiplied: - case Format_AYUV444: - case Format_AYUV444_Premultiplied: - case Format_YUV444: - case Format_YUV420P: - case Format_YV12: - case Format_UYVY: - case Format_YUYV: - case Format_NV12: - case Format_NV21: - case Format_IMC1: - case Format_IMC2: - case Format_IMC3: - case Format_IMC4: - case Format_Y8: - case Format_Y16: - return QImage::Format_Invalid; - case Format_User: - return QImage::Format_Invalid; - } - return QImage::Format_Invalid; -} - -QT_END_NAMESPACE - diff --git a/src/multimedia/multimedia/video/qvideoframe.h b/src/multimedia/multimedia/video/qvideoframe.h deleted file mode 100644 index 668a738..0000000 --- a/src/multimedia/multimedia/video/qvideoframe.h +++ /dev/null @@ -1,169 +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 QtMultimedia 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 QVIDEOFRAME_H -#define QVIDEOFRAME_H - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QSize; -class QVariant; - -class QVideoFramePrivate; - -class Q_MULTIMEDIA_EXPORT QVideoFrame -{ -public: - enum FieldType - { - ProgressiveFrame, - TopField, - BottomField, - InterlacedFrame - }; - - enum PixelFormat - { - Format_Invalid, - Format_ARGB32, - Format_ARGB32_Premultiplied, - Format_RGB32, - Format_RGB24, - Format_RGB565, - Format_RGB555, - Format_ARGB8565_Premultiplied, - Format_BGRA32, - Format_BGRA32_Premultiplied, - Format_BGR32, - Format_BGR24, - Format_BGR565, - Format_BGR555, - Format_BGRA5658_Premultiplied, - - Format_AYUV444, - Format_AYUV444_Premultiplied, - Format_YUV444, - Format_YUV420P, - Format_YV12, - Format_UYVY, - Format_YUYV, - Format_NV12, - Format_NV21, - Format_IMC1, - Format_IMC2, - Format_IMC3, - Format_IMC4, - Format_Y8, - Format_Y16, - - Format_User = 1000 - }; - - QVideoFrame(); - QVideoFrame(QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format); - QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format); - QVideoFrame(const QImage &image); - QVideoFrame(const QVideoFrame &other); - ~QVideoFrame(); - - QVideoFrame &operator =(const QVideoFrame &other); - - bool isValid() const; - - PixelFormat pixelFormat() const; - - QAbstractVideoBuffer::HandleType handleType() const; - - QSize size() const; - int width() const; - int height() const; - - FieldType fieldType() const; - void setFieldType(FieldType); - - bool isMapped() const; - bool isReadable() const; - bool isWritable() const; - - QAbstractVideoBuffer::MapMode mapMode() const; - - bool map(QAbstractVideoBuffer::MapMode mode); - void unmap(); - - int bytesPerLine() const; - - uchar *bits(); - const uchar *bits() const; - int mappedBytes() const; - - QVariant handle() const; - - qint64 startTime() const; - void setStartTime(qint64 time); - - qint64 endTime() const; - void setEndTime(qint64 time); - - static PixelFormat pixelFormatFromImageFormat(QImage::Format format); - static QImage::Format imageFormatFromPixelFormat(PixelFormat format); - -private: - QExplicitlySharedDataPointer d; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QVideoFrame::FieldType) -Q_DECLARE_METATYPE(QVideoFrame::PixelFormat) - -QT_END_HEADER - -#endif - diff --git a/src/multimedia/multimedia/video/qvideosurfaceformat.cpp b/src/multimedia/multimedia/video/qvideosurfaceformat.cpp deleted file mode 100644 index 1fc13a6..0000000 --- a/src/multimedia/multimedia/video/qvideosurfaceformat.cpp +++ /dev/null @@ -1,704 +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 QtMultimedia 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 "qvideosurfaceformat.h" - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QVideoSurfaceFormatPrivate : public QSharedData -{ -public: - QVideoSurfaceFormatPrivate() - : pixelFormat(QVideoFrame::Format_Invalid) - , handleType(QAbstractVideoBuffer::NoHandle) - , scanLineDirection(QVideoSurfaceFormat::TopToBottom) - , pixelAspectRatio(1, 1) - , ycbcrColorSpace(QVideoSurfaceFormat::YCbCr_Undefined) - , frameRate(0.0) - { - } - - QVideoSurfaceFormatPrivate( - const QSize &size, - QVideoFrame::PixelFormat format, - QAbstractVideoBuffer::HandleType type) - : pixelFormat(format) - , handleType(type) - , scanLineDirection(QVideoSurfaceFormat::TopToBottom) - , frameSize(size) - , pixelAspectRatio(1, 1) - , ycbcrColorSpace(QVideoSurfaceFormat::YCbCr_Undefined) - , viewport(QPoint(0, 0), size) - , frameRate(0.0) - { - } - - QVideoSurfaceFormatPrivate(const QVideoSurfaceFormatPrivate &other) - : QSharedData(other) - , pixelFormat(other.pixelFormat) - , handleType(other.handleType) - , scanLineDirection(other.scanLineDirection) - , frameSize(other.frameSize) - , pixelAspectRatio(other.pixelAspectRatio) - , ycbcrColorSpace(other.ycbcrColorSpace) - , viewport(other.viewport) - , frameRate(other.frameRate) - , propertyNames(other.propertyNames) - , propertyValues(other.propertyValues) - { - } - - bool operator ==(const QVideoSurfaceFormatPrivate &other) const - { - if (pixelFormat == other.pixelFormat - && handleType == other.handleType - && scanLineDirection == other.scanLineDirection - && frameSize == other.frameSize - && pixelAspectRatio == other.pixelAspectRatio - && viewport == other.viewport - && frameRatesEqual(frameRate, other.frameRate) - && ycbcrColorSpace == other.ycbcrColorSpace - && propertyNames.count() == other.propertyNames.count()) { - for (int i = 0; i < propertyNames.count(); ++i) { - int j = other.propertyNames.indexOf(propertyNames.at(i)); - - if (j == -1 || propertyValues.at(i) != other.propertyValues.at(j)) - return false; - } - return true; - } else { - return false; - } - } - - inline static bool frameRatesEqual(qreal r1, qreal r2) - { - return qAbs(r1 - r2) <= 0.00001 * qMin(qAbs(r1), qAbs(r2)); - } - - QVideoFrame::PixelFormat pixelFormat; - QAbstractVideoBuffer::HandleType handleType; - QVideoSurfaceFormat::Direction scanLineDirection; - QSize frameSize; - QSize pixelAspectRatio; - QVideoSurfaceFormat::YCbCrColorSpace ycbcrColorSpace; - QRect viewport; - qreal frameRate; - QList propertyNames; - QList propertyValues; -}; - -/*! - \class QVideoSurfaceFormat - \brief The QVideoSurfaceFormat class specifies the stream format of a video presentation - surface. - \since 4.6 - - A video surface presents a stream of video frames. The surface's format describes the type of - the frames and determines how they should be presented. - - The core properties of a video stream required to setup a video surface are the pixel format - given by pixelFormat(), and the frame dimensions given by frameSize(). - - If the surface is to present frames using a frame's handle a surface format will also include - a handle type which is given by the handleType() function. - - The region of a frame that is actually displayed on a video surface is given by the viewport(). - A stream may have a viewport less than the entire region of a frame to allow for videos smaller - than the nearest optimal size of a video frame. For example the width of a frame may be - extended so that the start of each scan line is eight byte aligned. - - Other common properties are the pixelAspectRatio(), scanLineDirection(), and frameRate(). - Additionally a stream may have some additional type specific properties which are listed by the - dynamicPropertyNames() function and can be accessed using the property(), and setProperty() - functions. -*/ - -/*! - \enum QVideoSurfaceFormat::Direction - - Enumerates the layout direction of video scan lines. - - \value TopToBottom Scan lines are arranged from the top of the frame to the bottom. - \value BottomToTop Scan lines are arranged from the bottom of the frame to the top. -*/ - -/*! - \enum QVideoSurfaceFormat::YCbCrColorSpace - - Enumerates the Y'CbCr color space of video frames. - - \value YCbCr_Undefined - No color space is specified. - - \value YCbCr_BT601 - A Y'CbCr color space defined by ITU-R recommendation BT.601 - with Y value range from 16 to 235, and Cb/Cr range from 16 to 240. - Used in standard definition video. - - \value YCbCr_BT709 - A Y'CbCr color space defined by ITU-R BT.709 with the same values range as YCbCr_BT601. Used - for HDTV. - - \value YCbCr_xvYCC601 - The BT.601 color space with the value range extended to 0 to 255. - It is backward compatibile with BT.601 and uses values outside BT.601 range to represent - wider colors range. - - \value YCbCr_xvYCC709 - The BT.709 color space with the value range extended to 0 to 255. - - \value YCbCr_JPEG - The full range Y'CbCr color space used in JPEG files. -*/ - -/*! - Constructs a null video stream format. -*/ - -QVideoSurfaceFormat::QVideoSurfaceFormat() - : d(new QVideoSurfaceFormatPrivate) -{ -} - -/*! - Contructs a description of stream which receives stream of \a type buffers with given frame - \a size and pixel \a format. -*/ - -QVideoSurfaceFormat::QVideoSurfaceFormat( - const QSize& size, QVideoFrame::PixelFormat format, QAbstractVideoBuffer::HandleType type) - : d(new QVideoSurfaceFormatPrivate(size, format, type)) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QVideoSurfaceFormat::QVideoSurfaceFormat(const QVideoSurfaceFormat &other) - : d(other.d) -{ -} - -/*! - Assigns the values of \a other to a video stream description. -*/ - -QVideoSurfaceFormat &QVideoSurfaceFormat::operator =(const QVideoSurfaceFormat &other) -{ - d = other.d; - - return *this; -} - -/*! - Destroys a video stream description. -*/ - -QVideoSurfaceFormat::~QVideoSurfaceFormat() -{ -} - -/*! - Identifies if a video surface format has a valid pixel format and frame size. - - Returns true if the format is valid, and false otherwise. -*/ - -bool QVideoSurfaceFormat::isValid() const -{ - return d->pixelFormat == QVideoFrame::Format_Invalid && d->frameSize.isValid(); -} - -/*! - Returns true if \a other is the same as a video format, and false if they are the different. -*/ - -bool QVideoSurfaceFormat::operator ==(const QVideoSurfaceFormat &other) const -{ - return d == other.d || *d == *other.d; -} - -/*! - Returns true if \a other is different to a video format, and false if they are the same. -*/ - -bool QVideoSurfaceFormat::operator !=(const QVideoSurfaceFormat &other) const -{ - return d != other.d && !(*d == *other.d); -} - -/*! - Returns the pixel format of frames in a video stream. -*/ - -QVideoFrame::PixelFormat QVideoSurfaceFormat::pixelFormat() const -{ - return d->pixelFormat; -} - -/*! - Returns the type of handle the surface uses to present the frame data. - - If the handle type is QAbstractVideoBuffer::NoHandle buffers with any handle type are valid - provided they can be \l {QAbstractVideoBuffer::map()}{mapped} with the - QAbstractVideoBuffer::ReadOnly flag. If the handleType() is not QAbstractVideoBuffer::NoHandle - then the handle type of the buffer be the same as that of the surface format. -*/ - -QAbstractVideoBuffer::HandleType QVideoSurfaceFormat::handleType() const -{ - return d->handleType; -} - -/*! - Returns the size of frames in a video stream. - - \sa frameWidth(), frameHeight() -*/ - -QSize QVideoSurfaceFormat::frameSize() const -{ - return d->frameSize; -} - -/*! - Returns the width of frames in a video stream. - - \sa frameSize(), frameHeight() -*/ - -int QVideoSurfaceFormat::frameWidth() const -{ - return d->frameSize.width(); -} - -/*! - Returns the height of frame in a video stream. -*/ - -int QVideoSurfaceFormat::frameHeight() const -{ - return d->frameSize.height(); -} - -/*! - Sets the size of frames in a video stream to \a size. - - This will reset the viewport() to fill the entire frame. -*/ - -void QVideoSurfaceFormat::setFrameSize(const QSize &size) -{ - d->frameSize = size; - d->viewport = QRect(QPoint(0, 0), size); -} - -/*! - \overload - - Sets the \a width and \a height of frames in a video stream. - - This will reset the viewport() to fill the entire frame. -*/ - -void QVideoSurfaceFormat::setFrameSize(int width, int height) -{ - d->frameSize = QSize(width, height); - d->viewport = QRect(0, 0, width, height); -} - -/*! - Returns the viewport of a video stream. - - The viewport is the region of a video frame that is actually displayed. - - By default the viewport covers an entire frame. -*/ - -QRect QVideoSurfaceFormat::viewport() const -{ - return d->viewport; -} - -/*! - Sets the viewport of a video stream to \a viewport. -*/ - -void QVideoSurfaceFormat::setViewport(const QRect &viewport) -{ - d->viewport = viewport; -} - -/*! - Returns the direction of scan lines. -*/ - -QVideoSurfaceFormat::Direction QVideoSurfaceFormat::scanLineDirection() const -{ - return d->scanLineDirection; -} - -/*! - Sets the \a direction of scan lines. -*/ - -void QVideoSurfaceFormat::setScanLineDirection(Direction direction) -{ - d->scanLineDirection = direction; -} - -/*! - Returns the frame rate of a video stream in frames per second. -*/ - -qreal QVideoSurfaceFormat::frameRate() const -{ - return d->frameRate; -} - -/*! - Sets the frame \a rate of a video stream in frames per second. -*/ - -void QVideoSurfaceFormat::setFrameRate(qreal rate) -{ - d->frameRate = rate; -} - -/*! - Returns a video stream's pixel aspect ratio. -*/ - -QSize QVideoSurfaceFormat::pixelAspectRatio() const -{ - return d->pixelAspectRatio; -} - -/*! - Sets a video stream's pixel aspect \a ratio. -*/ - -void QVideoSurfaceFormat::setPixelAspectRatio(const QSize &ratio) -{ - d->pixelAspectRatio = ratio; -} - -/*! - \overload - - Sets the \a horizontal and \a vertical elements of a video stream's pixel aspect ratio. -*/ - -void QVideoSurfaceFormat::setPixelAspectRatio(int horizontal, int vertical) -{ - d->pixelAspectRatio = QSize(horizontal, vertical); -} - -/*! - Returns the Y'CbCr color space of a video stream. -*/ - -QVideoSurfaceFormat::YCbCrColorSpace QVideoSurfaceFormat::yCbCrColorSpace() const -{ - return d->ycbcrColorSpace; -} - -/*! - Sets the Y'CbCr color \a space of a video stream. - It is only used with raw YUV frame types. -*/ - -void QVideoSurfaceFormat::setYCbCrColorSpace(QVideoSurfaceFormat::YCbCrColorSpace space) -{ - d->ycbcrColorSpace = space; -} - -/*! - Returns a suggested size in pixels for the video stream. - - This is the size of the viewport scaled according to the pixel aspect ratio. -*/ - -QSize QVideoSurfaceFormat::sizeHint() const -{ - QSize size = d->viewport.size(); - - if (d->pixelAspectRatio.height() != 0) - size.setWidth(size.width() * d->pixelAspectRatio.width() / d->pixelAspectRatio.height()); - - return size; -} - -/*! - Returns a list of video format dynamic property names. -*/ - -QList QVideoSurfaceFormat::propertyNames() const -{ - return (QList() - << "handleType" - << "pixelFormat" - << "frameSize" - << "frameWidth" - << "viewport" - << "scanLineDirection" - << "frameRate" - << "pixelAspectRatio" - << "sizeHint" - << "yCbCrColorSpace") - + d->propertyNames; -} - -/*! - Returns the value of the video format's \a name property. -*/ - -QVariant QVideoSurfaceFormat::property(const char *name) const -{ - if (qstrcmp(name, "handleType") == 0) { - return qVariantFromValue(d->handleType); - } else if (qstrcmp(name, "pixelFormat") == 0) { - return qVariantFromValue(d->pixelFormat); - } else if (qstrcmp(name, "handleType") == 0) { - return qVariantFromValue(d->handleType); - } else if (qstrcmp(name, "frameSize") == 0) { - return d->frameSize; - } else if (qstrcmp(name, "frameWidth") == 0) { - return d->frameSize.width(); - } else if (qstrcmp(name, "frameHeight") == 0) { - return d->frameSize.height(); - } else if (qstrcmp(name, "viewport") == 0) { - return d->viewport; - } else if (qstrcmp(name, "scanLineDirection") == 0) { - return qVariantFromValue(d->scanLineDirection); - } else if (qstrcmp(name, "frameRate") == 0) { - return qVariantFromValue(d->frameRate); - } else if (qstrcmp(name, "pixelAspectRatio") == 0) { - return qVariantFromValue(d->pixelAspectRatio); - } else if (qstrcmp(name, "sizeHint") == 0) { - return sizeHint(); - } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { - return qVariantFromValue(d->ycbcrColorSpace); - } else { - int id = 0; - for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {} - - return id < d->propertyValues.count() - ? d->propertyValues.at(id) - : QVariant(); - } -} - -/*! - Sets the video format's \a name property to \a value. -*/ - -void QVideoSurfaceFormat::setProperty(const char *name, const QVariant &value) -{ - if (qstrcmp(name, "handleType") == 0) { - // read only. - } else if (qstrcmp(name, "pixelFormat") == 0) { - // read only. - } else if (qstrcmp(name, "frameSize") == 0) { - if (qVariantCanConvert(value)) { - d->frameSize = qvariant_cast(value); - d->viewport = QRect(QPoint(0, 0), d->frameSize); - } - } else if (qstrcmp(name, "frameWidth") == 0) { - // read only. - } else if (qstrcmp(name, "frameHeight") == 0) { - // read only. - } else if (qstrcmp(name, "viewport") == 0) { - if (qVariantCanConvert(value)) - d->viewport = qvariant_cast(value); - } else if (qstrcmp(name, "scanLineDirection") == 0) { - if (qVariantCanConvert(value)) - d->scanLineDirection = qvariant_cast(value); - } else if (qstrcmp(name, "frameRate") == 0) { - if (qVariantCanConvert(value)) - d->frameRate = qvariant_cast(value); - } else if (qstrcmp(name, "pixelAspectRatio") == 0) { - if (qVariantCanConvert(value)) - d->pixelAspectRatio = qvariant_cast(value); - } else if (qstrcmp(name, "sizeHint") == 0) { - // read only. - } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { - if (qVariantCanConvert(value)) - d->ycbcrColorSpace = qvariant_cast(value); - } else { - int id = 0; - for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {} - - if (id < d->propertyValues.count()) { - if (value.isNull()) { - d->propertyNames.removeAt(id); - d->propertyValues.removeAt(id); - } else { - d->propertyValues[id] = value; - } - } else if (!value.isNull()) { - d->propertyNames.append(QByteArray(name)); - d->propertyValues.append(value); - } - } -} - - -#ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QVideoSurfaceFormat &f) -{ - QString typeName; - switch (f.pixelFormat()) { - case QVideoFrame::Format_Invalid: - typeName = QLatin1String("Format_Invalid"); - break; - case QVideoFrame::Format_ARGB32: - typeName = QLatin1String("Format_ARGB32"); - break; - case QVideoFrame::Format_ARGB32_Premultiplied: - typeName = QLatin1String("Format_ARGB32_Premultiplied"); - break; - case QVideoFrame::Format_RGB32: - typeName = QLatin1String("Format_RGB32"); - break; - case QVideoFrame::Format_RGB24: - typeName = QLatin1String("Format_RGB24"); - break; - case QVideoFrame::Format_RGB565: - typeName = QLatin1String("Format_RGB565"); - break; - case QVideoFrame::Format_RGB555: - typeName = QLatin1String("Format_RGB555"); - break; - case QVideoFrame::Format_ARGB8565_Premultiplied: - typeName = QLatin1String("Format_ARGB8565_Premultiplied"); - break; - case QVideoFrame::Format_BGRA32: - typeName = QLatin1String("Format_BGRA32"); - break; - case QVideoFrame::Format_BGRA32_Premultiplied: - typeName = QLatin1String("Format_BGRA32_Premultiplied"); - break; - case QVideoFrame::Format_BGR32: - typeName = QLatin1String("Format_BGR32"); - break; - case QVideoFrame::Format_BGR24: - typeName = QLatin1String("Format_BGR24"); - break; - case QVideoFrame::Format_BGR565: - typeName = QLatin1String("Format_BGR565"); - break; - case QVideoFrame::Format_BGR555: - typeName = QLatin1String("Format_BGR555"); - break; - case QVideoFrame::Format_BGRA5658_Premultiplied: - typeName = QLatin1String("Format_BGRA5658_Premultiplied"); - break; - case QVideoFrame::Format_AYUV444: - typeName = QLatin1String("Format_AYUV444"); - break; - case QVideoFrame::Format_AYUV444_Premultiplied: - typeName = QLatin1String("Format_AYUV444_Premultiplied"); - break; - case QVideoFrame::Format_YUV444: - typeName = QLatin1String("Format_YUV444"); - break; - case QVideoFrame::Format_YUV420P: - typeName = QLatin1String("Format_YUV420P"); - break; - case QVideoFrame::Format_YV12: - typeName = QLatin1String("Format_YV12"); - break; - case QVideoFrame::Format_UYVY: - typeName = QLatin1String("Format_UYVY"); - break; - case QVideoFrame::Format_YUYV: - typeName = QLatin1String("Format_YUYV"); - break; - case QVideoFrame::Format_NV12: - typeName = QLatin1String("Format_NV12"); - break; - case QVideoFrame::Format_NV21: - typeName = QLatin1String("Format_NV21"); - break; - case QVideoFrame::Format_IMC1: - typeName = QLatin1String("Format_IMC1"); - break; - case QVideoFrame::Format_IMC2: - typeName = QLatin1String("Format_IMC2"); - break; - case QVideoFrame::Format_IMC3: - typeName = QLatin1String("Format_IMC3"); - break; - case QVideoFrame::Format_IMC4: - typeName = QLatin1String("Format_IMC4"); - break; - case QVideoFrame::Format_Y8: - typeName = QLatin1String("Format_Y8"); - break; - case QVideoFrame::Format_Y16: - typeName = QLatin1String("Format_Y16"); - default: - typeName = QString(QLatin1String("UserType(%1)" )).arg(int(f.pixelFormat())); - } - - dbg.nospace() << "QVideoSurfaceFormat(" << typeName; - dbg.nospace() << ", " << f.frameSize(); - dbg.nospace() << ", viewport=" << f.viewport(); - dbg.nospace() << ", pixelAspectRatio=" << f.pixelAspectRatio(); - dbg.nospace() << ")"; - - foreach(const QByteArray& propertyName, f.propertyNames()) - dbg << "\n " << propertyName.data() << " = " << f.property(propertyName.data()); - - return dbg.space(); -} -#endif - -QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/video/qvideosurfaceformat.h b/src/multimedia/multimedia/video/qvideosurfaceformat.h deleted file mode 100644 index 9c73f5f..0000000 --- a/src/multimedia/multimedia/video/qvideosurfaceformat.h +++ /dev/null @@ -1,147 +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 QtMultimedia 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 QVIDEOSURFACEFORMAT_H -#define QVIDEOSURFACEFORMAT_H - -#include -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QDebug; - -class QVideoSurfaceFormatPrivate; - -class Q_MULTIMEDIA_EXPORT QVideoSurfaceFormat -{ -public: - enum Direction - { - TopToBottom, - BottomToTop - }; - - enum YCbCrColorSpace - { - YCbCr_Undefined, - YCbCr_BT601, - YCbCr_BT709, - YCbCr_xvYCC601, - YCbCr_xvYCC709, - YCbCr_JPEG, -#ifndef qdoc - YCbCr_CustomMatrix -#endif - }; - - QVideoSurfaceFormat(); - QVideoSurfaceFormat( - const QSize &size, - QVideoFrame::PixelFormat pixelFormat, - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle); - QVideoSurfaceFormat(const QVideoSurfaceFormat &format); - ~QVideoSurfaceFormat(); - - QVideoSurfaceFormat &operator =(const QVideoSurfaceFormat &format); - - bool operator ==(const QVideoSurfaceFormat &format) const; - bool operator !=(const QVideoSurfaceFormat &format) const; - - bool isValid() const; - - QVideoFrame::PixelFormat pixelFormat() const; - QAbstractVideoBuffer::HandleType handleType() const; - - QSize frameSize() const; - void setFrameSize(const QSize &size); - void setFrameSize(int width, int height); - - int frameWidth() const; - int frameHeight() const; - - QRect viewport() const; - void setViewport(const QRect &viewport); - - Direction scanLineDirection() const; - void setScanLineDirection(Direction direction); - - qreal frameRate() const; - void setFrameRate(qreal rate); - - QSize pixelAspectRatio() const; - void setPixelAspectRatio(const QSize &ratio); - void setPixelAspectRatio(int width, int height); - - YCbCrColorSpace yCbCrColorSpace() const; - void setYCbCrColorSpace(YCbCrColorSpace colorSpace); - - QSize sizeHint() const; - - QList propertyNames() const; - QVariant property(const char *name) const; - void setProperty(const char *name, const QVariant &value); - -private: - QSharedDataPointer d; -}; - -#ifndef QT_NO_DEBUG_STREAM -Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QVideoSurfaceFormat &); -#endif - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QVideoSurfaceFormat::Direction) -Q_DECLARE_METATYPE(QVideoSurfaceFormat::YCbCrColorSpace) - -QT_END_HEADER - -#endif - diff --git a/src/multimedia/multimedia/video/video.pri b/src/multimedia/multimedia/video/video.pri deleted file mode 100644 index 0547a4c..0000000 --- a/src/multimedia/multimedia/video/video.pri +++ /dev/null @@ -1,21 +0,0 @@ - -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/qabstractvideobuffer.h \ - $$PWD/qabstractvideobuffer_p.h \ - $$PWD/qabstractvideosurface.h \ - $$PWD/qabstractvideosurface_p.h \ - $$PWD/qimagevideobuffer_p.h \ - $$PWD/qmemoryvideobuffer_p.h \ - $$PWD/qvideoframe.h \ - $$PWD/qvideosurfaceformat.h - -SOURCES += \ - $$PWD/qabstractvideobuffer.cpp \ - $$PWD/qabstractvideosurface.cpp \ - $$PWD/qimagevideobuffer.cpp \ - $$PWD/qmemoryvideobuffer.cpp \ - $$PWD/qvideoframe.cpp \ - $$PWD/qvideosurfaceformat.cpp - diff --git a/src/multimedia/video/qabstractvideobuffer.cpp b/src/multimedia/video/qabstractvideobuffer.cpp new file mode 100644 index 0000000..e9d30d0 --- /dev/null +++ b/src/multimedia/video/qabstractvideobuffer.cpp @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qabstractvideobuffer_p.h" + +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QAbstractVideoBuffer + \brief The QAbstractVideoBuffer class is an abstraction for video data. + \since 4.6 + + The QVideoFrame class makes use of a QAbstractVideoBuffer internally to reference a buffer of + video data. Creating a subclass of QAbstractVideoBuffer will allow you to construct video + frames from preallocated or static buffers. + + The contents of a buffer can be accessed by mapping the buffer to memory using the map() + function which returns a pointer to memory containing the contents of the the video buffer. + The memory returned by map() is released by calling the unmap() function. + + The handle() of a buffer may also be used to manipulate it's contents using type specific APIs. + The type of a buffer's handle is given by the handleType() function. + + \sa QVideoFrame +*/ + +/*! + \enum QAbstractVideoBuffer::HandleType + + Identifies the type of a video buffers handle. + + \value NoHandle The buffer has no handle, its data can only be accessed by mapping the buffer. + \value GLTextureHandle The handle of the buffer is an OpenGL texture ID. + \value XvShmImageHandle The handle contains pointer to shared memory XVideo image. + \value CoreImageHandle The handle contains pointer to Mac OS X CIImage. + \value UserHandle Start value for user defined handle types. + + \sa handleType() +*/ + +/*! + \enum QAbstractVideoBuffer::MapMode + + Enumerates how a video buffer's data is mapped to memory. + + \value NotMapped The video buffer has is not mapped to memory. + \value ReadOnly The mapped memory is populated with data from the video buffer when mapped, but + the content of the mapped memory may be discarded when unmapped. + \value WriteOnly The mapped memory in unitialized when mapped, and the content will be used to + populate the video buffer when unmapped. + \value ReadWrite The mapped memory is populated with data from the video buffer, and the + video buffer is repopulated with the content of the mapped memory. + + \sa mapMode(), map() +*/ + +/*! + Constructs an abstract video buffer of the given \a type. +*/ + +QAbstractVideoBuffer::QAbstractVideoBuffer(HandleType type) + : d_ptr(new QAbstractVideoBufferPrivate) +{ + Q_D(QAbstractVideoBuffer); + + d->handleType = type; +} + +/*! + \internal +*/ + +QAbstractVideoBuffer::QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, HandleType type) + : d_ptr(&dd) +{ + Q_D(QAbstractVideoBuffer); + + d->handleType = type; +} + +/*! + Destroys an abstract video buffer. +*/ + +QAbstractVideoBuffer::~QAbstractVideoBuffer() +{ + delete d_ptr; +} + +/*! + Returns the type of a video buffer's handle. + + \sa handle() +*/ + +QAbstractVideoBuffer::HandleType QAbstractVideoBuffer::handleType() const +{ + return d_func()->handleType; +} + +/*! + \fn QAbstractVideoBuffer::mapMode() const + + Returns the mode a video buffer is mapped in. + + \sa map() +*/ + +/*! + \fn QAbstractVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) + + Maps the contents of a video buffer to memory. + + The map \a mode indicates whether the contents of the mapped memory should be read from and/or + written to the buffer. If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the + mapped memory will be populated with the content of the video buffer when mapped. If the map + mode includes the QAbstractVideoBuffer::WriteOnly flag the content of the mapped memory will be + persisted in the buffer when unmapped. + + When access to the data is no longer needed be sure to call the unmap() function to release the + mapped memory. + + Returns a pointer to the mapped memory region, or a null pointer if the mapping failed. The + size in bytes of the mapped memory region is returned in \a numBytes, and the line stride in \a + bytesPerLine. + + When access to the data is no longer needed be sure to unmap() the buffer. + + \note Writing to memory that is mapped as read-only is undefined, and may result in changes + to shared data. + + \sa unmap(), mapMode() +*/ + +/*! + \fn QAbstractVideoBuffer::unmap() + + Releases the memory mapped by the map() function + + If the \l {QAbstractVideoBuffer::MapMode}{MapMode} included the QAbstractVideoBuffer::WriteOnly + flag this will persist the current content of the mapped memory to the video frame. + + \sa map() +*/ + +/*! + Returns a type specific handle to the data buffer. + + The type of the handle is given by handleType() function. + + \sa handleType() +*/ + +QVariant QAbstractVideoBuffer::handle() const +{ + return QVariant(); +} + + +QT_END_NAMESPACE diff --git a/src/multimedia/video/qabstractvideobuffer.h b/src/multimedia/video/qabstractvideobuffer.h new file mode 100644 index 0000000..a8389db --- /dev/null +++ b/src/multimedia/video/qabstractvideobuffer.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QABSTRACTVIDEOBUFFER_H +#define QABSTRACTVIDEOBUFFER_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QVariant; + +class QAbstractVideoBufferPrivate; + +class Q_MULTIMEDIA_EXPORT QAbstractVideoBuffer +{ +public: + enum HandleType + { + NoHandle, + GLTextureHandle, + XvShmImageHandle, + CoreImageHandle, + UserHandle = 1000 + }; + + enum MapMode + { + NotMapped = 0x00, + ReadOnly = 0x01, + WriteOnly = 0x02, + ReadWrite = ReadOnly | WriteOnly + }; + + QAbstractVideoBuffer(HandleType type); + virtual ~QAbstractVideoBuffer(); + + HandleType handleType() const; + + virtual MapMode mapMode() const = 0; + + virtual uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) = 0; + virtual void unmap() = 0; + + virtual QVariant handle() const; + +protected: + QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, HandleType type); + + QAbstractVideoBufferPrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(QAbstractVideoBuffer) + Q_DISABLE_COPY(QAbstractVideoBuffer) +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QAbstractVideoBuffer::HandleType) +Q_DECLARE_METATYPE(QAbstractVideoBuffer::MapMode) + +QT_END_HEADER + +#endif diff --git a/src/multimedia/video/qabstractvideobuffer_p.h b/src/multimedia/video/qabstractvideobuffer_p.h new file mode 100644 index 0000000..c72f303 --- /dev/null +++ b/src/multimedia/video/qabstractvideobuffer_p.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QABSTRACTVIDEOBUFFER_P_H +#define QABSTRACTVIDEOBUFFER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QAbstractVideoBufferPrivate +{ +public: + QAbstractVideoBufferPrivate() + : handleType(QAbstractVideoBuffer::NoHandle) + {} + + QAbstractVideoBuffer::HandleType handleType; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/video/qabstractvideosurface.cpp b/src/multimedia/video/qabstractvideosurface.cpp new file mode 100644 index 0000000..3dabb6b --- /dev/null +++ b/src/multimedia/video/qabstractvideosurface.cpp @@ -0,0 +1,283 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qabstractvideosurface_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QAbstractVideoSurface + \brief The QAbstractVideoSurface class is a base class for video presentation surfaces. + \since 4.6 + + The QAbstractVideoSurface class defines the standard interface that video producers use to + inter-operate with video presentation surfaces. It is not supposed to be instantiated directly. + Instead, you should subclass it to create new video surfaces. + + A video surface presents a continuous stream of identically formatted frames, where the format + of each frame is compatible with a stream format supplied when starting a presentation. + + A list of pixel formats a surface can present is given by the supportedPixelFormats() function, + and the isFormatSupported() function will test if a video surface format is supported. If a + format is not supported the nearestFormat() function may be able to suggest a similar format. + For example if a surface supports fixed set of resolutions it may suggest the smallest + supported resolution that contains the proposed resolution. + + The start() function takes a supported format and enables a video surface. Once started a + surface will begin displaying the frames it receives in the present() function. Surfaces may + hold a reference to the buffer of a presented video frame until a new frame is presented or + streaming is stopped. The stop() function will disable a surface and a release any video + buffers it holds references to. +*/ + +/*! + \enum QAbstractVideoSurface::Error + This enum describes the errors that may be returned by the error() function. + + \value NoError No error occurred. + \value UnsupportedFormatError A video format was not supported. + \value IncorrectFormatError A video frame was not compatible with the format of the surface. + \value StoppedError The surface has not been started. + \value ResourceError The surface could not allocate some resource. +*/ + +/*! + Constructs a video surface with the given \a parent. +*/ + +QAbstractVideoSurface::QAbstractVideoSurface(QObject *parent) + : QObject(*new QAbstractVideoSurfacePrivate, parent) +{ +} + +/*! + \internal +*/ + +QAbstractVideoSurface::QAbstractVideoSurface(QAbstractVideoSurfacePrivate &dd, QObject *parent) + : QObject(dd, parent) +{ +} + +/*! + Destroys a video surface. +*/ + +QAbstractVideoSurface::~QAbstractVideoSurface() +{ +} + +/*! + \fn QAbstractVideoSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType type) const + + Returns a list of pixel formats a video surface can present for a given handle \a type. + + The pixel formats returned for the QAbstractVideoBuffer::NoHandle type are valid for any buffer + that can be mapped in read-only mode. + + Types that are first in the list can be assumed to be faster to render. +*/ + +/*! + Tests a video surface \a format to determine if a surface can accept it. + + Returns true if the format is supported by the surface, and false otherwise. +*/ + +bool QAbstractVideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const +{ + return supportedPixelFormats(format.handleType()).contains(format.pixelFormat()); +} + +/*! + Returns a supported video surface format that is similar to \a format. + + A similar surface format is one that has the same \l {QVideoSurfaceFormat::pixelFormat()}{pixel + format} and \l {QVideoSurfaceFormat::handleType()}{handle type} but differs in some of the other + properties. For example if there are restrictions on the \l {QVideoSurfaceFormat::frameSize()} + {frame sizes} a video surface can accept it may suggest a format with a larger frame size and + a \l {QVideoSurfaceFormat::viewport()}{viewport} the size of the original frame size. + + If the format is already supported it will be returned unchanged, or if there is no similar + supported format an invalid format will be returned. +*/ + +QVideoSurfaceFormat QAbstractVideoSurface::nearestFormat(const QVideoSurfaceFormat &format) const +{ + return isFormatSupported(format) + ? format + : QVideoSurfaceFormat(); +} + +/*! + \fn QAbstractVideoSurface::supportedFormatsChanged() + + Signals that the set of formats supported by a video surface has changed. + + \sa supportedPixelFormats(), isFormatSupported() +*/ + +/*! + Returns the format of a video surface. +*/ + +QVideoSurfaceFormat QAbstractVideoSurface::surfaceFormat() const +{ + return d_func()->format; +} + +/*! + \fn QAbstractVideoSurface::surfaceFormatChanged(const QVideoSurfaceFormat &format) + + Signals that the configured \a format of a video surface has changed. + + \sa surfaceFormat(), start() +*/ + +/*! + Starts a video surface presenting \a format frames. + + Returns true if the surface was started, and false if an error occurred. + + \sa isActive(), stop() +*/ + +bool QAbstractVideoSurface::start(const QVideoSurfaceFormat &format) +{ + Q_D(QAbstractVideoSurface); + + bool wasActive = d->active; + + d->active = true; + d->format = format; + d->error = NoError; + + emit surfaceFormatChanged(d->format); + + if (!wasActive) + emit activeChanged(true); + + return true; +} + +/*! + Stops a video surface presenting frames and releases any resources acquired in start(). + + \sa isActive(), start() +*/ + +void QAbstractVideoSurface::stop() +{ + Q_D(QAbstractVideoSurface); + + if (d->active) { + d->format = QVideoSurfaceFormat(); + d->active = false; + + emit activeChanged(false); + emit surfaceFormatChanged(d->format); + } +} + +/*! + Indicates whether a video surface has been started. + + Returns true if the surface has been started, and false otherwise. +*/ + +bool QAbstractVideoSurface::isActive() const +{ + return d_func()->active; +} + +/*! + \fn QAbstractVideoSurface::activeChanged(bool active) + + Signals that the \a active state of a video surface has changed. + + \sa isActive(), start(), stop() +*/ + +/*! + \fn QAbstractVideoSurface::present(const QVideoFrame &frame) + + Presents a video \a frame. + + Returns true if the frame was presented, and false if an error occurred. + + Not all surfaces will block until the presentation of a frame has completed. Calling present() + on a non-blocking surface may fail if called before the presentation of a previous frame has + completed. In such cases the surface may not return to a ready state until it's had an + opportunity to process events. + + If present() fails for any other reason the surface will immediately enter the stopped state + and an error() value will be set. + + A video surface must be in the started state for present() to succeed, and the format of the + video frame must be compatible with the current video surface format. + + \sa error() +*/ + +/*! + Returns the last error that occurred. + + If a surface fails to start(), or stops unexpectedly this function can be called to discover + what error occurred. +*/ + +QAbstractVideoSurface::Error QAbstractVideoSurface::error() const +{ + return d_func()->error; +} + +/*! + Sets the value of error() to \a error. +*/ + +void QAbstractVideoSurface::setError(Error error) +{ + Q_D(QAbstractVideoSurface); + + d->error = error; +} + +QT_END_NAMESPACE diff --git a/src/multimedia/video/qabstractvideosurface.h b/src/multimedia/video/qabstractvideosurface.h new file mode 100644 index 0000000..f2cae17 --- /dev/null +++ b/src/multimedia/video/qabstractvideosurface.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QABSTRACTVIDEOSURFACE_H +#define QABSTRACTVIDEOSURFACE_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QRectF; +class QVideoSurfaceFormat; + +class QAbstractVideoSurfacePrivate; + +class Q_MULTIMEDIA_EXPORT QAbstractVideoSurface : public QObject +{ + Q_OBJECT + +public: + enum Error + { + NoError, + UnsupportedFormatError, + IncorrectFormatError, + StoppedError, + ResourceError + }; + + explicit QAbstractVideoSurface(QObject *parent = 0); + ~QAbstractVideoSurface(); + + virtual QList supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const = 0; + virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const; + virtual QVideoSurfaceFormat nearestFormat(const QVideoSurfaceFormat &format) const; + + QVideoSurfaceFormat surfaceFormat() const; + + virtual bool start(const QVideoSurfaceFormat &format); + virtual void stop(); + + bool isActive() const; + + virtual bool present(const QVideoFrame &frame) = 0; + + Error error() const; + +Q_SIGNALS: + void activeChanged(bool active); + void surfaceFormatChanged(const QVideoSurfaceFormat &format); + void supportedFormatsChanged(); + +protected: + QAbstractVideoSurface(QAbstractVideoSurfacePrivate &dd, QObject *parent); + + void setError(Error error); + +private: + Q_DECLARE_PRIVATE(QAbstractVideoSurface) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/multimedia/video/qabstractvideosurface_p.h b/src/multimedia/video/qabstractvideosurface_p.h new file mode 100644 index 0000000..42df112 --- /dev/null +++ b/src/multimedia/video/qabstractvideosurface_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QABSTRACTVIDEOSURFACE_P_H +#define QABSTRACTVIDEOSURFACE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QAbstractVideoSurfacePrivate : public QObjectPrivate +{ +public: + QAbstractVideoSurfacePrivate() + : error(QAbstractVideoSurface::NoError) + , active(false) + { + } + + mutable QAbstractVideoSurface::Error error; + QVideoSurfaceFormat format; + bool active; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/video/qimagevideobuffer.cpp b/src/multimedia/video/qimagevideobuffer.cpp new file mode 100644 index 0000000..e3e1585 --- /dev/null +++ b/src/multimedia/video/qimagevideobuffer.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qimagevideobuffer_p.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QImageVideoBufferPrivate : public QAbstractVideoBufferPrivate +{ +public: + QImageVideoBufferPrivate() + : mapMode(QAbstractVideoBuffer::NotMapped) + { + } + + QAbstractVideoBuffer::MapMode mapMode; + QImage image; +}; + +QImageVideoBuffer::QImageVideoBuffer(const QImage &image) + : QAbstractVideoBuffer(*new QImageVideoBufferPrivate, NoHandle) +{ + Q_D(QImageVideoBuffer); + + d->image = image; +} + +QImageVideoBuffer::~QImageVideoBuffer() +{ +} + +QAbstractVideoBuffer::MapMode QImageVideoBuffer::mapMode() const +{ + return d_func()->mapMode; +} + +uchar *QImageVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) +{ + Q_D(QImageVideoBuffer); + + if (d->mapMode == NotMapped && d->image.bits() && mode != NotMapped) { + d->mapMode = mode; + + if (numBytes) + *numBytes = d->image.byteCount(); + + if (bytesPerLine) + *bytesPerLine = d->image.bytesPerLine(); + + return d->image.bits(); + } else { + return 0; + } +} + +void QImageVideoBuffer::unmap() +{ + Q_D(QImageVideoBuffer); + + d->mapMode = NotMapped; +} + +QT_END_NAMESPACE diff --git a/src/multimedia/video/qimagevideobuffer_p.h b/src/multimedia/video/qimagevideobuffer_p.h new file mode 100644 index 0000000..82075d7 --- /dev/null +++ b/src/multimedia/video/qimagevideobuffer_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QIMAGEVIDEOBUFFER_P_H +#define QIMAGEVIDEOBUFFER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QImage; + +class QImageVideoBufferPrivate; + +class Q_MULTIMEDIA_EXPORT QImageVideoBuffer : public QAbstractVideoBuffer +{ + Q_DECLARE_PRIVATE(QImageVideoBuffer) +public: + QImageVideoBuffer(const QImage &image); + ~QImageVideoBuffer(); + + MapMode mapMode() const; + + uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); + void unmap(); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/video/qmemoryvideobuffer.cpp b/src/multimedia/video/qmemoryvideobuffer.cpp new file mode 100644 index 0000000..2e892b7 --- /dev/null +++ b/src/multimedia/video/qmemoryvideobuffer.cpp @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qmemoryvideobuffer_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +class QMemoryVideoBufferPrivate : public QAbstractVideoBufferPrivate +{ +public: + QMemoryVideoBufferPrivate() + : bytesPerLine(0) + , mapMode(QAbstractVideoBuffer::NotMapped) + { + } + + int bytesPerLine; + QAbstractVideoBuffer::MapMode mapMode; + QByteArray data; +}; + +/*! + \class QMemoryVideoBuffer + \brief The QMemoryVideoBuffer class provides a system memory allocated video data buffer. + \internal + + QMemoryVideoBuffer is the default video buffer for allocating system memory. It may be used to + allocate memory for a QVideoFrame without implementing your own QAbstractVideoBuffer. +*/ + +/*! + Constructs a video buffer with an image stride of \a bytesPerLine from a byte \a array. +*/ +QMemoryVideoBuffer::QMemoryVideoBuffer(const QByteArray &array, int bytesPerLine) + : QAbstractVideoBuffer(*new QMemoryVideoBufferPrivate, NoHandle) +{ + Q_D(QMemoryVideoBuffer); + + d->data = array; + d->bytesPerLine = bytesPerLine; +} + +/*! + Destroys a system memory allocated video buffer. +*/ +QMemoryVideoBuffer::~QMemoryVideoBuffer() +{ +} + +/*! + \reimp +*/ +QAbstractVideoBuffer::MapMode QMemoryVideoBuffer::mapMode() const +{ + return d_func()->mapMode; +} + +/*! + \reimp +*/ +uchar *QMemoryVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) +{ + Q_D(QMemoryVideoBuffer); + + if (d->mapMode == NotMapped && d->data.data() && mode != NotMapped) { + d->mapMode = mode; + + if (numBytes) + *numBytes = d->data.size(); + + if (bytesPerLine) + *bytesPerLine = d->bytesPerLine; + + return reinterpret_cast(d->data.data()); + } else { + return 0; + } +} + +/*! + \reimp +*/ +void QMemoryVideoBuffer::unmap() +{ + d_func()->mapMode = NotMapped; +} + +QT_END_NAMESPACE diff --git a/src/multimedia/video/qmemoryvideobuffer_p.h b/src/multimedia/video/qmemoryvideobuffer_p.h new file mode 100644 index 0000000..c66cf93 --- /dev/null +++ b/src/multimedia/video/qmemoryvideobuffer_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QMEMORYVIDEOBUFFER_P_H +#define QMEMORYVIDEOBUFFER_P_H + +#include + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QMemoryVideoBufferPrivate; + +class Q_MULTIMEDIA_EXPORT QMemoryVideoBuffer : public QAbstractVideoBuffer +{ + Q_DECLARE_PRIVATE(QMemoryVideoBuffer) +public: + QMemoryVideoBuffer(const QByteArray &data, int bytesPerLine); + ~QMemoryVideoBuffer(); + + MapMode mapMode() const; + + uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); + void unmap(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp new file mode 100644 index 0000000..2d66d9e --- /dev/null +++ b/src/multimedia/video/qvideoframe.cpp @@ -0,0 +1,741 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qvideoframe.h" + +#include +#include + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QVideoFramePrivate : public QSharedData +{ +public: + QVideoFramePrivate() + : startTime(-1) + , endTime(-1) + , data(0) + , mappedBytes(0) + , bytesPerLine(0) + , pixelFormat(QVideoFrame::Format_Invalid) + , fieldType(QVideoFrame::ProgressiveFrame) + , buffer(0) + { + } + + QVideoFramePrivate(const QSize &size, QVideoFrame::PixelFormat format) + : size(size) + , startTime(-1) + , endTime(-1) + , data(0) + , mappedBytes(0) + , bytesPerLine(0) + , pixelFormat(format) + , fieldType(QVideoFrame::ProgressiveFrame) + , buffer(0) + { + } + + ~QVideoFramePrivate() + { + delete buffer; + } + + QSize size; + qint64 startTime; + qint64 endTime; + uchar *data; + int mappedBytes; + int bytesPerLine; + QVideoFrame::PixelFormat pixelFormat; + QVideoFrame::FieldType fieldType; + QAbstractVideoBuffer *buffer; + +private: + Q_DISABLE_COPY(QVideoFramePrivate) +}; + +/*! + \class QVideoFrame + \brief The QVideoFrame class provides a representation of a frame of video data. + \since 4.6 + + A QVideoFrame encapsulates the data of a video frame, and information about the frame. + + The contents of a video frame can be mapped to memory using the map() function. While + mapped the video data can accessed using the bits() function which returns a pointer to a + buffer, the total size of which is given by the mappedBytes(), and the size of each line is given + by bytesPerLine(). The return value of the handle() function may be used to access frame data + using the internal buffer's native APIs. + + The video data in a QVideoFrame is encapsulated in a QAbstractVideoBuffer. A QVideoFrame + may be constructed from any buffer type by subclassing the QAbstractVideoBuffer class. + + \note QVideoFrame is explicitly shared, any change made to video frame will also apply to any + copies. +*/ + +/*! + \enum QVideoFrame::PixelFormat + + Enumerates video data types. + + \value Format_Invalid + The frame is invalid. + + \value Format_ARGB32 + The frame is stored using a 32-bit ARGB format (0xAARRGGBB). This is equivalent to + QImage::Format_ARGB32. + + \value Format_ARGB32_Premultiplied + The frame stored using a premultiplied 32-bit ARGB format (0xAARRGGBB). This is equivalent + to QImage::Format_ARGB32_Premultiplied. + + \value Format_RGB32 + The frame stored using a 32-bit RGB format (0xffRRGGBB). This is equivalent to + QImage::Format_RGB32 + + \value Format_RGB24 + The frame is stored using a 24-bit RGB format (8-8-8). This is equivalent to + QImage::Format_RGB888 + + \value Format_RGB565 + The frame is stored using a 16-bit RGB format (5-6-5). This is equivalent to + QImage::Format_RGB16. + + \value Format_RGB555 + The frame is stored using a 16-bit RGB format (5-5-5). This is equivalent to + QImage::Format_RGB555. + + \value Format_ARGB8565_Premultiplied + The frame is stored using a 24-bit premultiplied ARGB format (8-6-6-5). + + \value Format_BGRA32 + The frame is stored using a 32-bit ARGB format (0xBBGGRRAA). + + \value Format_BGRA32_Premultiplied + The frame is stored using a premultiplied 32bit BGRA format. + + \value Format_BGR32 + The frame is stored using a 32-bit BGR format (0xBBGGRRff). + + \value Format_BGR24 + The frame is stored using a 24-bit BGR format (0xBBGGRR). + + \value Format_BGR565 + The frame is stored using a 16-bit BGR format (5-6-5). + + \value Format_BGR555 + The frame is stored using a 16-bit BGR format (5-5-5). + + \value Format_BGRA5658_Premultiplied + The frame is stored using a 24-bit premultiplied BGRA format (5-6-5-8). + + \value Format_AYUV444 + The frame is stored using a packed 32-bit AYUV format (0xAAYYUUVV). + + \value Format_AYUV444_Premultiplied + The frame is stored using a packed premultiplied 32-bit AYUV format (0xAAYYUUVV). + + \value Format_YUV444 + The frame is stored using a 24-bit packed YUV format (8-8-8). + + \value Format_YUV420P + The frame is stored using an 8-bit per component planar YUV format with the U and V planes + horizontally and vertically sub-sampled, i.e. the height and width of the U and V planes are + half that of the Y plane. + + \value Format_YV12 + The frame is stored using an 8-bit per component planar YVU format with the V and U planes + horizontally and vertically sub-sampled, i.e. the height and width of the V and U planes are + half that of the Y plane. + + \value Format_UYVY + The frame is stored using an 8-bit per component packed YUV format with the U and V planes + horizontally sub-sampled (U-Y-V-Y), i.e. two horizontally adjacent pixels are stored as a 32-bit + macropixel which has a Y value for each pixel and common U and V values. + + \value Format_YUYV + The frame is stored using an 8-bit per component packed YUV format with the U and V planes + horizontally sub-sampled (Y-U-Y-V), i.e. two horizontally adjacent pixels are stored as a 32-bit + macropixel which has a Y value for each pixel and common U and V values. + + \value Format_NV12 + The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) + followed by a horizontally and vertically sub-sampled, packed UV plane (U-V). + + \value Format_NV21 + The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) + followed by a horizontally and vertically sub-sampled, packed VU plane (V-U). + + \value Format_IMC1 + The frame is stored using an 8-bit per component planar YUV format with the U and V planes + horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except + that the bytes per line of the U and V planes are padded out to the same stride as the Y plane. + + \value Format_IMC2 + The frame is stored using an 8-bit per component planar YUV format with the U and V planes + horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except + that the lines of the U and V planes are interleaved, i.e. each line of U data is followed by a + line of V data creating a single line of the same stride as the Y data. + + \value Format_IMC3 + The frame is stored using an 8-bit per component planar YVU format with the V and U planes + horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that + the bytes per line of the V and U planes are padded out to the same stride as the Y plane. + + \value Format_IMC4 + The frame is stored using an 8-bit per component planar YVU format with the V and U planes + horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that + the lines of the V and U planes are interleaved, i.e. each line of V data is followed by a line + of U data creating a single line of the same stride as the Y data. + + \value Format_Y8 + The frame is stored using an 8-bit greyscale format. + + \value Format_Y16 + The frame is stored using a 16-bit linear greyscale format. Little endian. + + \value Format_User + Start value for user defined pixel formats. +*/ + +/*! + \enum QVideoFrame::FieldType + + Specifies the field an interlaced video frame belongs to. + + \value ProgressiveFrame The frame is not interlaced. + \value TopField The frame contains a top field. + \value BottomField The frame contains a bottom field. + \value InterlacedFrame The frame contains a merged top and bottom field. +*/ + +/*! + Constructs a null video frame. +*/ + +QVideoFrame::QVideoFrame() + : d(new QVideoFramePrivate) +{ +} + +/*! + Constructs a video frame from a \a buffer of the given pixel \a format and \a size in pixels. + + \note This doesn't increment the reference count of the video buffer. +*/ + +QVideoFrame::QVideoFrame( + QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format) + : d(new QVideoFramePrivate(size, format)) +{ + d->buffer = buffer; +} + +/*! + Constructs a video frame of the given pixel \a format and \a size in pixels. + + The \a bytesPerLine (stride) is the length of each scan line in bytes, and \a bytes is the total + number of bytes that must be allocated for the frame. +*/ + +QVideoFrame::QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format) + : d(new QVideoFramePrivate(size, format)) +{ + if (bytes > 0) { + QByteArray data; + data.resize(bytes); + + // Check the memory was successfully allocated. + if (!data.isEmpty()) + d->buffer = new QMemoryVideoBuffer(data, bytesPerLine); + } +} + +/*! + Constructs a video frame from an \a image. + + \note This will construct an invalid video frame if there is no frame type equivalent to the + image format. + + \sa pixelFormatFromImageFormat() +*/ + +QVideoFrame::QVideoFrame(const QImage &image) + : d(new QVideoFramePrivate( + image.size(), pixelFormatFromImageFormat(image.format()))) +{ + if (d->pixelFormat != Format_Invalid) + d->buffer = new QImageVideoBuffer(image); +} + +/*! + Constructs a copy of \a other. +*/ + +QVideoFrame::QVideoFrame(const QVideoFrame &other) + : d(other.d) +{ +} + +/*! + Assigns the contents of \a other to a video frame. +*/ + +QVideoFrame &QVideoFrame::operator =(const QVideoFrame &other) +{ + d = other.d; + + return *this; +} + +/*! + Destroys a video frame. +*/ + +QVideoFrame::~QVideoFrame() +{ +} + +/*! + Identifies whether a video frame is valid. + + An invalid frame has no video buffer associated with it. + + Returns true if the frame is valid, and false if it is not. +*/ + +bool QVideoFrame::isValid() const +{ + return d->buffer != 0; +} + +/*! + Returns the color format of a video frame. +*/ + +QVideoFrame::PixelFormat QVideoFrame::pixelFormat() const +{ + return d->pixelFormat; +} + +/*! + Returns the type of a video frame's handle. +*/ + +QAbstractVideoBuffer::HandleType QVideoFrame::handleType() const +{ + return d->buffer ? d->buffer->handleType() : QAbstractVideoBuffer::NoHandle; +} + +/*! + Returns the size of a video frame. +*/ + +QSize QVideoFrame::size() const +{ + return d->size; +} + +/*! + Returns the width of a video frame. +*/ + +int QVideoFrame::width() const +{ + return d->size.width(); +} + +/*! + Returns the height of a video frame. +*/ + +int QVideoFrame::height() const +{ + return d->size.height(); +} + +/*! + Returns the field an interlaced video frame belongs to. + + If the video is not interlaced this will return WholeFrame. +*/ + +QVideoFrame::FieldType QVideoFrame::fieldType() const +{ + return d->fieldType; +} + +/*! + Sets the \a field an interlaced video frame belongs to. +*/ + +void QVideoFrame::setFieldType(QVideoFrame::FieldType field) +{ + d->fieldType = field; +} + +/*! + Identifies if a video frame's contents are currently mapped to system memory. + + This is a convenience function which checks that the \l {QAbstractVideoBuffer::MapMode}{MapMode} + of the frame is not equal to QAbstractVideoBuffer::NotMapped. + + Returns true if the contents of the video frame are mapped to system memory, and false + otherwise. + + \sa mapMode() QAbstractVideoBuffer::MapMode +*/ + +bool QVideoFrame::isMapped() const +{ + return d->buffer != 0 && d->buffer->mapMode() != QAbstractVideoBuffer::NotMapped; +} + +/*! + Identifies if the mapped contents of a video frame will be persisted when the frame is unmapped. + + This is a convenience function which checks if the \l {QAbstractVideoBuffer::MapMode}{MapMode} + contains the QAbstractVideoBuffer::WriteOnly flag. + + Returns true if the video frame will be updated when unmapped, and false otherwise. + + \note The result of altering the data of a frame that is mapped in read-only mode is undefined. + Depending on the buffer implementation the changes may be persisted, or worse alter a shared + buffer. + + \sa mapMode(), QAbstractVideoBuffer::MapMode +*/ + +bool QVideoFrame::isWritable() const +{ + return d->buffer != 0 && (d->buffer->mapMode() & QAbstractVideoBuffer::WriteOnly); +} + +/*! + Identifies if the mapped contents of a video frame were read from the frame when it was mapped. + + This is a convenience function which checks if the \l {QAbstractVideoBuffer::MapMode}{MapMode} + contains the QAbstractVideoBuffer::WriteOnly flag. + + Returns true if the contents of the mapped memory were read from the video frame, and false + otherwise. + + \sa mapMode(), QAbstractVideoBuffer::MapMode +*/ + +bool QVideoFrame::isReadable() const +{ + return d->buffer != 0 && (d->buffer->mapMode() & QAbstractVideoBuffer::ReadOnly); +} + +/*! + Returns the mode a video frame was mapped to system memory in. + + \sa map(), QAbstractVideoBuffer::MapMode +*/ + +QAbstractVideoBuffer::MapMode QVideoFrame::mapMode() const +{ + return d->buffer != 0 ? d->buffer->mapMode() : QAbstractVideoBuffer::NotMapped; +} + +/*! + Maps the contents of a video frame to memory. + + The map \a mode indicates whether the contents of the mapped memory should be read from and/or + written to the frame. If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the + mapped memory will be populated with the content of the video frame when mapped. If the map + mode inclues the QAbstractVideoBuffer::WriteOnly flag the content of the mapped memory will be + persisted in the frame when unmapped. + + While mapped the contents of a video frame can be accessed directly through the pointer returned + by the bits() function. + + When access to the data is no longer needed be sure to call the unmap() function to release the + mapped memory. + + Returns true if the buffer was mapped to memory in the given \a mode and false otherwise. + + \sa unmap(), mapMode(), bits() +*/ + +bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) +{ + if (d->buffer != 0 && d->data == 0) { + Q_ASSERT(d->bytesPerLine == 0); + Q_ASSERT(d->mappedBytes == 0); + + d->data = d->buffer->map(mode, &d->mappedBytes, &d->bytesPerLine); + + return d->data != 0; + } + + return false; +} + +/*! + Releases the memory mapped by the map() function. + + If the \l {QAbstractVideoBuffer::MapMode}{MapMode} included the QAbstractVideoBuffer::WriteOnly + flag this will persist the current content of the mapped memory to the video frame. + + \sa map() +*/ + +void QVideoFrame::unmap() +{ + if (d->data != 0) { + d->mappedBytes = 0; + d->bytesPerLine = 0; + d->data = 0; + + d->buffer->unmap(); + } +} + +/*! + Returns the number of bytes in a scan line. + + \note This is the bytes per line of the first plane only. The bytes per line of subsequent + planes should be calculated as per the frame type. + + This value is only valid while the frame data is \l {map()}{mapped}. + + \sa bits(), map(), mappedBytes() +*/ + +int QVideoFrame::bytesPerLine() const +{ + return d->bytesPerLine; +} + +/*! + Returns a pointer to the start of the frame data buffer. + + This value is only valid while the frame data is \l {map()}{mapped}. + + \sa map(), mappedBytes(), bytesPerLine() +*/ + +uchar *QVideoFrame::bits() +{ + return d->data; +} + +/*! + Returns a pointer to the start of the frame data buffer. + + This value is only valid while the frame data is \l {map()}{mapped}. + + \sa map(), mappedBytes(), bytesPerLine() +*/ + +const uchar *QVideoFrame::bits() const +{ + return d->data; +} + +/*! + Returns the number of bytes occupied by the mapped frame data. + + This value is only valid while the frame data is \l {map()}{mapped}. + + \sa map() +*/ + +int QVideoFrame::mappedBytes() const +{ + return d->mappedBytes; +} + +/*! + Returns a type specific handle to a video frame's buffer. + + For an OpenGL texture this would be the texture ID. + + \sa QAbstractVideoBuffer::handle() +*/ + +QVariant QVideoFrame::handle() const +{ + return d->buffer != 0 ? d->buffer->handle() : QVariant(); +} + +/*! + Returns the presentation time when the frame should be displayed. +*/ + +qint64 QVideoFrame::startTime() const +{ + return d->startTime; +} + +/*! + Sets the presentation \a time when the frame should be displayed. +*/ + +void QVideoFrame::setStartTime(qint64 time) +{ + d->startTime = time; +} + +/*! + Returns the presentation time when a frame should stop being displayed. +*/ + +qint64 QVideoFrame::endTime() const +{ + return d->endTime; +} + +/*! + Sets the presentation \a time when a frame should stop being displayed. +*/ + +void QVideoFrame::setEndTime(qint64 time) +{ + d->endTime = time; +} + +/*! + Returns an video pixel format equivalent to an image \a format. If there is no equivalent + format QVideoFrame::InvalidType is returned instead. +*/ + +QVideoFrame::PixelFormat QVideoFrame::pixelFormatFromImageFormat(QImage::Format format) +{ + switch (format) { + case QImage::Format_Invalid: + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + case QImage::Format_Indexed8: + return Format_Invalid; + case QImage::Format_RGB32: + return Format_RGB32; + case QImage::Format_ARGB32: + return Format_ARGB32; + case QImage::Format_ARGB32_Premultiplied: + return Format_ARGB32_Premultiplied; + case QImage::Format_RGB16: + return Format_RGB565; + case QImage::Format_ARGB8565_Premultiplied: + case QImage::Format_RGB666: + case QImage::Format_ARGB6666_Premultiplied: + return Format_Invalid; + case QImage::Format_RGB555: + return Format_RGB555; + case QImage::Format_ARGB8555_Premultiplied: + return Format_Invalid; + case QImage::Format_RGB888: + return Format_RGB24; + case QImage::Format_RGB444: + case QImage::Format_ARGB4444_Premultiplied: + return Format_Invalid; + case QImage::NImageFormats: + return Format_Invalid; + } + return Format_Invalid; +} + +/*! + Returns an image format equivalent to a video frame pixel \a format. If there is no equivalent + format QImage::Format_Invalid is returned instead. +*/ + +QImage::Format QVideoFrame::imageFormatFromPixelFormat(PixelFormat format) +{ + switch (format) { + case Format_Invalid: + return QImage::Format_Invalid; + case Format_ARGB32: + return QImage::Format_ARGB32; + case Format_ARGB32_Premultiplied: + return QImage::Format_ARGB32_Premultiplied; + case Format_RGB32: + return QImage::Format_RGB32; + case Format_RGB24: + return QImage::Format_RGB888; + case Format_RGB565: + return QImage::Format_RGB16; + case Format_RGB555: + return QImage::Format_RGB555; + case Format_ARGB8565_Premultiplied: + return QImage::Format_ARGB8565_Premultiplied; + case Format_BGRA32: + case Format_BGRA32_Premultiplied: + case Format_BGR32: + case Format_BGR24: + return QImage::Format_Invalid; + case Format_BGR565: + case Format_BGR555: + case Format_BGRA5658_Premultiplied: + case Format_AYUV444: + case Format_AYUV444_Premultiplied: + case Format_YUV444: + case Format_YUV420P: + case Format_YV12: + case Format_UYVY: + case Format_YUYV: + case Format_NV12: + case Format_NV21: + case Format_IMC1: + case Format_IMC2: + case Format_IMC3: + case Format_IMC4: + case Format_Y8: + case Format_Y16: + return QImage::Format_Invalid; + case Format_User: + return QImage::Format_Invalid; + } + return QImage::Format_Invalid; +} + +QT_END_NAMESPACE + diff --git a/src/multimedia/video/qvideoframe.h b/src/multimedia/video/qvideoframe.h new file mode 100644 index 0000000..668a738 --- /dev/null +++ b/src/multimedia/video/qvideoframe.h @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QVIDEOFRAME_H +#define QVIDEOFRAME_H + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QSize; +class QVariant; + +class QVideoFramePrivate; + +class Q_MULTIMEDIA_EXPORT QVideoFrame +{ +public: + enum FieldType + { + ProgressiveFrame, + TopField, + BottomField, + InterlacedFrame + }; + + enum PixelFormat + { + Format_Invalid, + Format_ARGB32, + Format_ARGB32_Premultiplied, + Format_RGB32, + Format_RGB24, + Format_RGB565, + Format_RGB555, + Format_ARGB8565_Premultiplied, + Format_BGRA32, + Format_BGRA32_Premultiplied, + Format_BGR32, + Format_BGR24, + Format_BGR565, + Format_BGR555, + Format_BGRA5658_Premultiplied, + + Format_AYUV444, + Format_AYUV444_Premultiplied, + Format_YUV444, + Format_YUV420P, + Format_YV12, + Format_UYVY, + Format_YUYV, + Format_NV12, + Format_NV21, + Format_IMC1, + Format_IMC2, + Format_IMC3, + Format_IMC4, + Format_Y8, + Format_Y16, + + Format_User = 1000 + }; + + QVideoFrame(); + QVideoFrame(QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format); + QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format); + QVideoFrame(const QImage &image); + QVideoFrame(const QVideoFrame &other); + ~QVideoFrame(); + + QVideoFrame &operator =(const QVideoFrame &other); + + bool isValid() const; + + PixelFormat pixelFormat() const; + + QAbstractVideoBuffer::HandleType handleType() const; + + QSize size() const; + int width() const; + int height() const; + + FieldType fieldType() const; + void setFieldType(FieldType); + + bool isMapped() const; + bool isReadable() const; + bool isWritable() const; + + QAbstractVideoBuffer::MapMode mapMode() const; + + bool map(QAbstractVideoBuffer::MapMode mode); + void unmap(); + + int bytesPerLine() const; + + uchar *bits(); + const uchar *bits() const; + int mappedBytes() const; + + QVariant handle() const; + + qint64 startTime() const; + void setStartTime(qint64 time); + + qint64 endTime() const; + void setEndTime(qint64 time); + + static PixelFormat pixelFormatFromImageFormat(QImage::Format format); + static QImage::Format imageFormatFromPixelFormat(PixelFormat format); + +private: + QExplicitlySharedDataPointer d; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QVideoFrame::FieldType) +Q_DECLARE_METATYPE(QVideoFrame::PixelFormat) + +QT_END_HEADER + +#endif + diff --git a/src/multimedia/video/qvideosurfaceformat.cpp b/src/multimedia/video/qvideosurfaceformat.cpp new file mode 100644 index 0000000..1fc13a6 --- /dev/null +++ b/src/multimedia/video/qvideosurfaceformat.cpp @@ -0,0 +1,704 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 "qvideosurfaceformat.h" + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QVideoSurfaceFormatPrivate : public QSharedData +{ +public: + QVideoSurfaceFormatPrivate() + : pixelFormat(QVideoFrame::Format_Invalid) + , handleType(QAbstractVideoBuffer::NoHandle) + , scanLineDirection(QVideoSurfaceFormat::TopToBottom) + , pixelAspectRatio(1, 1) + , ycbcrColorSpace(QVideoSurfaceFormat::YCbCr_Undefined) + , frameRate(0.0) + { + } + + QVideoSurfaceFormatPrivate( + const QSize &size, + QVideoFrame::PixelFormat format, + QAbstractVideoBuffer::HandleType type) + : pixelFormat(format) + , handleType(type) + , scanLineDirection(QVideoSurfaceFormat::TopToBottom) + , frameSize(size) + , pixelAspectRatio(1, 1) + , ycbcrColorSpace(QVideoSurfaceFormat::YCbCr_Undefined) + , viewport(QPoint(0, 0), size) + , frameRate(0.0) + { + } + + QVideoSurfaceFormatPrivate(const QVideoSurfaceFormatPrivate &other) + : QSharedData(other) + , pixelFormat(other.pixelFormat) + , handleType(other.handleType) + , scanLineDirection(other.scanLineDirection) + , frameSize(other.frameSize) + , pixelAspectRatio(other.pixelAspectRatio) + , ycbcrColorSpace(other.ycbcrColorSpace) + , viewport(other.viewport) + , frameRate(other.frameRate) + , propertyNames(other.propertyNames) + , propertyValues(other.propertyValues) + { + } + + bool operator ==(const QVideoSurfaceFormatPrivate &other) const + { + if (pixelFormat == other.pixelFormat + && handleType == other.handleType + && scanLineDirection == other.scanLineDirection + && frameSize == other.frameSize + && pixelAspectRatio == other.pixelAspectRatio + && viewport == other.viewport + && frameRatesEqual(frameRate, other.frameRate) + && ycbcrColorSpace == other.ycbcrColorSpace + && propertyNames.count() == other.propertyNames.count()) { + for (int i = 0; i < propertyNames.count(); ++i) { + int j = other.propertyNames.indexOf(propertyNames.at(i)); + + if (j == -1 || propertyValues.at(i) != other.propertyValues.at(j)) + return false; + } + return true; + } else { + return false; + } + } + + inline static bool frameRatesEqual(qreal r1, qreal r2) + { + return qAbs(r1 - r2) <= 0.00001 * qMin(qAbs(r1), qAbs(r2)); + } + + QVideoFrame::PixelFormat pixelFormat; + QAbstractVideoBuffer::HandleType handleType; + QVideoSurfaceFormat::Direction scanLineDirection; + QSize frameSize; + QSize pixelAspectRatio; + QVideoSurfaceFormat::YCbCrColorSpace ycbcrColorSpace; + QRect viewport; + qreal frameRate; + QList propertyNames; + QList propertyValues; +}; + +/*! + \class QVideoSurfaceFormat + \brief The QVideoSurfaceFormat class specifies the stream format of a video presentation + surface. + \since 4.6 + + A video surface presents a stream of video frames. The surface's format describes the type of + the frames and determines how they should be presented. + + The core properties of a video stream required to setup a video surface are the pixel format + given by pixelFormat(), and the frame dimensions given by frameSize(). + + If the surface is to present frames using a frame's handle a surface format will also include + a handle type which is given by the handleType() function. + + The region of a frame that is actually displayed on a video surface is given by the viewport(). + A stream may have a viewport less than the entire region of a frame to allow for videos smaller + than the nearest optimal size of a video frame. For example the width of a frame may be + extended so that the start of each scan line is eight byte aligned. + + Other common properties are the pixelAspectRatio(), scanLineDirection(), and frameRate(). + Additionally a stream may have some additional type specific properties which are listed by the + dynamicPropertyNames() function and can be accessed using the property(), and setProperty() + functions. +*/ + +/*! + \enum QVideoSurfaceFormat::Direction + + Enumerates the layout direction of video scan lines. + + \value TopToBottom Scan lines are arranged from the top of the frame to the bottom. + \value BottomToTop Scan lines are arranged from the bottom of the frame to the top. +*/ + +/*! + \enum QVideoSurfaceFormat::YCbCrColorSpace + + Enumerates the Y'CbCr color space of video frames. + + \value YCbCr_Undefined + No color space is specified. + + \value YCbCr_BT601 + A Y'CbCr color space defined by ITU-R recommendation BT.601 + with Y value range from 16 to 235, and Cb/Cr range from 16 to 240. + Used in standard definition video. + + \value YCbCr_BT709 + A Y'CbCr color space defined by ITU-R BT.709 with the same values range as YCbCr_BT601. Used + for HDTV. + + \value YCbCr_xvYCC601 + The BT.601 color space with the value range extended to 0 to 255. + It is backward compatibile with BT.601 and uses values outside BT.601 range to represent + wider colors range. + + \value YCbCr_xvYCC709 + The BT.709 color space with the value range extended to 0 to 255. + + \value YCbCr_JPEG + The full range Y'CbCr color space used in JPEG files. +*/ + +/*! + Constructs a null video stream format. +*/ + +QVideoSurfaceFormat::QVideoSurfaceFormat() + : d(new QVideoSurfaceFormatPrivate) +{ +} + +/*! + Contructs a description of stream which receives stream of \a type buffers with given frame + \a size and pixel \a format. +*/ + +QVideoSurfaceFormat::QVideoSurfaceFormat( + const QSize& size, QVideoFrame::PixelFormat format, QAbstractVideoBuffer::HandleType type) + : d(new QVideoSurfaceFormatPrivate(size, format, type)) +{ +} + +/*! + Constructs a copy of \a other. +*/ + +QVideoSurfaceFormat::QVideoSurfaceFormat(const QVideoSurfaceFormat &other) + : d(other.d) +{ +} + +/*! + Assigns the values of \a other to a video stream description. +*/ + +QVideoSurfaceFormat &QVideoSurfaceFormat::operator =(const QVideoSurfaceFormat &other) +{ + d = other.d; + + return *this; +} + +/*! + Destroys a video stream description. +*/ + +QVideoSurfaceFormat::~QVideoSurfaceFormat() +{ +} + +/*! + Identifies if a video surface format has a valid pixel format and frame size. + + Returns true if the format is valid, and false otherwise. +*/ + +bool QVideoSurfaceFormat::isValid() const +{ + return d->pixelFormat == QVideoFrame::Format_Invalid && d->frameSize.isValid(); +} + +/*! + Returns true if \a other is the same as a video format, and false if they are the different. +*/ + +bool QVideoSurfaceFormat::operator ==(const QVideoSurfaceFormat &other) const +{ + return d == other.d || *d == *other.d; +} + +/*! + Returns true if \a other is different to a video format, and false if they are the same. +*/ + +bool QVideoSurfaceFormat::operator !=(const QVideoSurfaceFormat &other) const +{ + return d != other.d && !(*d == *other.d); +} + +/*! + Returns the pixel format of frames in a video stream. +*/ + +QVideoFrame::PixelFormat QVideoSurfaceFormat::pixelFormat() const +{ + return d->pixelFormat; +} + +/*! + Returns the type of handle the surface uses to present the frame data. + + If the handle type is QAbstractVideoBuffer::NoHandle buffers with any handle type are valid + provided they can be \l {QAbstractVideoBuffer::map()}{mapped} with the + QAbstractVideoBuffer::ReadOnly flag. If the handleType() is not QAbstractVideoBuffer::NoHandle + then the handle type of the buffer be the same as that of the surface format. +*/ + +QAbstractVideoBuffer::HandleType QVideoSurfaceFormat::handleType() const +{ + return d->handleType; +} + +/*! + Returns the size of frames in a video stream. + + \sa frameWidth(), frameHeight() +*/ + +QSize QVideoSurfaceFormat::frameSize() const +{ + return d->frameSize; +} + +/*! + Returns the width of frames in a video stream. + + \sa frameSize(), frameHeight() +*/ + +int QVideoSurfaceFormat::frameWidth() const +{ + return d->frameSize.width(); +} + +/*! + Returns the height of frame in a video stream. +*/ + +int QVideoSurfaceFormat::frameHeight() const +{ + return d->frameSize.height(); +} + +/*! + Sets the size of frames in a video stream to \a size. + + This will reset the viewport() to fill the entire frame. +*/ + +void QVideoSurfaceFormat::setFrameSize(const QSize &size) +{ + d->frameSize = size; + d->viewport = QRect(QPoint(0, 0), size); +} + +/*! + \overload + + Sets the \a width and \a height of frames in a video stream. + + This will reset the viewport() to fill the entire frame. +*/ + +void QVideoSurfaceFormat::setFrameSize(int width, int height) +{ + d->frameSize = QSize(width, height); + d->viewport = QRect(0, 0, width, height); +} + +/*! + Returns the viewport of a video stream. + + The viewport is the region of a video frame that is actually displayed. + + By default the viewport covers an entire frame. +*/ + +QRect QVideoSurfaceFormat::viewport() const +{ + return d->viewport; +} + +/*! + Sets the viewport of a video stream to \a viewport. +*/ + +void QVideoSurfaceFormat::setViewport(const QRect &viewport) +{ + d->viewport = viewport; +} + +/*! + Returns the direction of scan lines. +*/ + +QVideoSurfaceFormat::Direction QVideoSurfaceFormat::scanLineDirection() const +{ + return d->scanLineDirection; +} + +/*! + Sets the \a direction of scan lines. +*/ + +void QVideoSurfaceFormat::setScanLineDirection(Direction direction) +{ + d->scanLineDirection = direction; +} + +/*! + Returns the frame rate of a video stream in frames per second. +*/ + +qreal QVideoSurfaceFormat::frameRate() const +{ + return d->frameRate; +} + +/*! + Sets the frame \a rate of a video stream in frames per second. +*/ + +void QVideoSurfaceFormat::setFrameRate(qreal rate) +{ + d->frameRate = rate; +} + +/*! + Returns a video stream's pixel aspect ratio. +*/ + +QSize QVideoSurfaceFormat::pixelAspectRatio() const +{ + return d->pixelAspectRatio; +} + +/*! + Sets a video stream's pixel aspect \a ratio. +*/ + +void QVideoSurfaceFormat::setPixelAspectRatio(const QSize &ratio) +{ + d->pixelAspectRatio = ratio; +} + +/*! + \overload + + Sets the \a horizontal and \a vertical elements of a video stream's pixel aspect ratio. +*/ + +void QVideoSurfaceFormat::setPixelAspectRatio(int horizontal, int vertical) +{ + d->pixelAspectRatio = QSize(horizontal, vertical); +} + +/*! + Returns the Y'CbCr color space of a video stream. +*/ + +QVideoSurfaceFormat::YCbCrColorSpace QVideoSurfaceFormat::yCbCrColorSpace() const +{ + return d->ycbcrColorSpace; +} + +/*! + Sets the Y'CbCr color \a space of a video stream. + It is only used with raw YUV frame types. +*/ + +void QVideoSurfaceFormat::setYCbCrColorSpace(QVideoSurfaceFormat::YCbCrColorSpace space) +{ + d->ycbcrColorSpace = space; +} + +/*! + Returns a suggested size in pixels for the video stream. + + This is the size of the viewport scaled according to the pixel aspect ratio. +*/ + +QSize QVideoSurfaceFormat::sizeHint() const +{ + QSize size = d->viewport.size(); + + if (d->pixelAspectRatio.height() != 0) + size.setWidth(size.width() * d->pixelAspectRatio.width() / d->pixelAspectRatio.height()); + + return size; +} + +/*! + Returns a list of video format dynamic property names. +*/ + +QList QVideoSurfaceFormat::propertyNames() const +{ + return (QList() + << "handleType" + << "pixelFormat" + << "frameSize" + << "frameWidth" + << "viewport" + << "scanLineDirection" + << "frameRate" + << "pixelAspectRatio" + << "sizeHint" + << "yCbCrColorSpace") + + d->propertyNames; +} + +/*! + Returns the value of the video format's \a name property. +*/ + +QVariant QVideoSurfaceFormat::property(const char *name) const +{ + if (qstrcmp(name, "handleType") == 0) { + return qVariantFromValue(d->handleType); + } else if (qstrcmp(name, "pixelFormat") == 0) { + return qVariantFromValue(d->pixelFormat); + } else if (qstrcmp(name, "handleType") == 0) { + return qVariantFromValue(d->handleType); + } else if (qstrcmp(name, "frameSize") == 0) { + return d->frameSize; + } else if (qstrcmp(name, "frameWidth") == 0) { + return d->frameSize.width(); + } else if (qstrcmp(name, "frameHeight") == 0) { + return d->frameSize.height(); + } else if (qstrcmp(name, "viewport") == 0) { + return d->viewport; + } else if (qstrcmp(name, "scanLineDirection") == 0) { + return qVariantFromValue(d->scanLineDirection); + } else if (qstrcmp(name, "frameRate") == 0) { + return qVariantFromValue(d->frameRate); + } else if (qstrcmp(name, "pixelAspectRatio") == 0) { + return qVariantFromValue(d->pixelAspectRatio); + } else if (qstrcmp(name, "sizeHint") == 0) { + return sizeHint(); + } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { + return qVariantFromValue(d->ycbcrColorSpace); + } else { + int id = 0; + for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {} + + return id < d->propertyValues.count() + ? d->propertyValues.at(id) + : QVariant(); + } +} + +/*! + Sets the video format's \a name property to \a value. +*/ + +void QVideoSurfaceFormat::setProperty(const char *name, const QVariant &value) +{ + if (qstrcmp(name, "handleType") == 0) { + // read only. + } else if (qstrcmp(name, "pixelFormat") == 0) { + // read only. + } else if (qstrcmp(name, "frameSize") == 0) { + if (qVariantCanConvert(value)) { + d->frameSize = qvariant_cast(value); + d->viewport = QRect(QPoint(0, 0), d->frameSize); + } + } else if (qstrcmp(name, "frameWidth") == 0) { + // read only. + } else if (qstrcmp(name, "frameHeight") == 0) { + // read only. + } else if (qstrcmp(name, "viewport") == 0) { + if (qVariantCanConvert(value)) + d->viewport = qvariant_cast(value); + } else if (qstrcmp(name, "scanLineDirection") == 0) { + if (qVariantCanConvert(value)) + d->scanLineDirection = qvariant_cast(value); + } else if (qstrcmp(name, "frameRate") == 0) { + if (qVariantCanConvert(value)) + d->frameRate = qvariant_cast(value); + } else if (qstrcmp(name, "pixelAspectRatio") == 0) { + if (qVariantCanConvert(value)) + d->pixelAspectRatio = qvariant_cast(value); + } else if (qstrcmp(name, "sizeHint") == 0) { + // read only. + } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { + if (qVariantCanConvert(value)) + d->ycbcrColorSpace = qvariant_cast(value); + } else { + int id = 0; + for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {} + + if (id < d->propertyValues.count()) { + if (value.isNull()) { + d->propertyNames.removeAt(id); + d->propertyValues.removeAt(id); + } else { + d->propertyValues[id] = value; + } + } else if (!value.isNull()) { + d->propertyNames.append(QByteArray(name)); + d->propertyValues.append(value); + } + } +} + + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QVideoSurfaceFormat &f) +{ + QString typeName; + switch (f.pixelFormat()) { + case QVideoFrame::Format_Invalid: + typeName = QLatin1String("Format_Invalid"); + break; + case QVideoFrame::Format_ARGB32: + typeName = QLatin1String("Format_ARGB32"); + break; + case QVideoFrame::Format_ARGB32_Premultiplied: + typeName = QLatin1String("Format_ARGB32_Premultiplied"); + break; + case QVideoFrame::Format_RGB32: + typeName = QLatin1String("Format_RGB32"); + break; + case QVideoFrame::Format_RGB24: + typeName = QLatin1String("Format_RGB24"); + break; + case QVideoFrame::Format_RGB565: + typeName = QLatin1String("Format_RGB565"); + break; + case QVideoFrame::Format_RGB555: + typeName = QLatin1String("Format_RGB555"); + break; + case QVideoFrame::Format_ARGB8565_Premultiplied: + typeName = QLatin1String("Format_ARGB8565_Premultiplied"); + break; + case QVideoFrame::Format_BGRA32: + typeName = QLatin1String("Format_BGRA32"); + break; + case QVideoFrame::Format_BGRA32_Premultiplied: + typeName = QLatin1String("Format_BGRA32_Premultiplied"); + break; + case QVideoFrame::Format_BGR32: + typeName = QLatin1String("Format_BGR32"); + break; + case QVideoFrame::Format_BGR24: + typeName = QLatin1String("Format_BGR24"); + break; + case QVideoFrame::Format_BGR565: + typeName = QLatin1String("Format_BGR565"); + break; + case QVideoFrame::Format_BGR555: + typeName = QLatin1String("Format_BGR555"); + break; + case QVideoFrame::Format_BGRA5658_Premultiplied: + typeName = QLatin1String("Format_BGRA5658_Premultiplied"); + break; + case QVideoFrame::Format_AYUV444: + typeName = QLatin1String("Format_AYUV444"); + break; + case QVideoFrame::Format_AYUV444_Premultiplied: + typeName = QLatin1String("Format_AYUV444_Premultiplied"); + break; + case QVideoFrame::Format_YUV444: + typeName = QLatin1String("Format_YUV444"); + break; + case QVideoFrame::Format_YUV420P: + typeName = QLatin1String("Format_YUV420P"); + break; + case QVideoFrame::Format_YV12: + typeName = QLatin1String("Format_YV12"); + break; + case QVideoFrame::Format_UYVY: + typeName = QLatin1String("Format_UYVY"); + break; + case QVideoFrame::Format_YUYV: + typeName = QLatin1String("Format_YUYV"); + break; + case QVideoFrame::Format_NV12: + typeName = QLatin1String("Format_NV12"); + break; + case QVideoFrame::Format_NV21: + typeName = QLatin1String("Format_NV21"); + break; + case QVideoFrame::Format_IMC1: + typeName = QLatin1String("Format_IMC1"); + break; + case QVideoFrame::Format_IMC2: + typeName = QLatin1String("Format_IMC2"); + break; + case QVideoFrame::Format_IMC3: + typeName = QLatin1String("Format_IMC3"); + break; + case QVideoFrame::Format_IMC4: + typeName = QLatin1String("Format_IMC4"); + break; + case QVideoFrame::Format_Y8: + typeName = QLatin1String("Format_Y8"); + break; + case QVideoFrame::Format_Y16: + typeName = QLatin1String("Format_Y16"); + default: + typeName = QString(QLatin1String("UserType(%1)" )).arg(int(f.pixelFormat())); + } + + dbg.nospace() << "QVideoSurfaceFormat(" << typeName; + dbg.nospace() << ", " << f.frameSize(); + dbg.nospace() << ", viewport=" << f.viewport(); + dbg.nospace() << ", pixelAspectRatio=" << f.pixelAspectRatio(); + dbg.nospace() << ")"; + + foreach(const QByteArray& propertyName, f.propertyNames()) + dbg << "\n " << propertyName.data() << " = " << f.property(propertyName.data()); + + return dbg.space(); +} +#endif + +QT_END_NAMESPACE diff --git a/src/multimedia/video/qvideosurfaceformat.h b/src/multimedia/video/qvideosurfaceformat.h new file mode 100644 index 0000000..9c73f5f --- /dev/null +++ b/src/multimedia/video/qvideosurfaceformat.h @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** 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 QtMultimedia 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 QVIDEOSURFACEFORMAT_H +#define QVIDEOSURFACEFORMAT_H + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QDebug; + +class QVideoSurfaceFormatPrivate; + +class Q_MULTIMEDIA_EXPORT QVideoSurfaceFormat +{ +public: + enum Direction + { + TopToBottom, + BottomToTop + }; + + enum YCbCrColorSpace + { + YCbCr_Undefined, + YCbCr_BT601, + YCbCr_BT709, + YCbCr_xvYCC601, + YCbCr_xvYCC709, + YCbCr_JPEG, +#ifndef qdoc + YCbCr_CustomMatrix +#endif + }; + + QVideoSurfaceFormat(); + QVideoSurfaceFormat( + const QSize &size, + QVideoFrame::PixelFormat pixelFormat, + QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle); + QVideoSurfaceFormat(const QVideoSurfaceFormat &format); + ~QVideoSurfaceFormat(); + + QVideoSurfaceFormat &operator =(const QVideoSurfaceFormat &format); + + bool operator ==(const QVideoSurfaceFormat &format) const; + bool operator !=(const QVideoSurfaceFormat &format) const; + + bool isValid() const; + + QVideoFrame::PixelFormat pixelFormat() const; + QAbstractVideoBuffer::HandleType handleType() const; + + QSize frameSize() const; + void setFrameSize(const QSize &size); + void setFrameSize(int width, int height); + + int frameWidth() const; + int frameHeight() const; + + QRect viewport() const; + void setViewport(const QRect &viewport); + + Direction scanLineDirection() const; + void setScanLineDirection(Direction direction); + + qreal frameRate() const; + void setFrameRate(qreal rate); + + QSize pixelAspectRatio() const; + void setPixelAspectRatio(const QSize &ratio); + void setPixelAspectRatio(int width, int height); + + YCbCrColorSpace yCbCrColorSpace() const; + void setYCbCrColorSpace(YCbCrColorSpace colorSpace); + + QSize sizeHint() const; + + QList propertyNames() const; + QVariant property(const char *name) const; + void setProperty(const char *name, const QVariant &value); + +private: + QSharedDataPointer d; +}; + +#ifndef QT_NO_DEBUG_STREAM +Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QVideoSurfaceFormat &); +#endif + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QVideoSurfaceFormat::Direction) +Q_DECLARE_METATYPE(QVideoSurfaceFormat::YCbCrColorSpace) + +QT_END_HEADER + +#endif + diff --git a/src/multimedia/video/video.pri b/src/multimedia/video/video.pri new file mode 100644 index 0000000..0547a4c --- /dev/null +++ b/src/multimedia/video/video.pri @@ -0,0 +1,21 @@ + +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qabstractvideobuffer.h \ + $$PWD/qabstractvideobuffer_p.h \ + $$PWD/qabstractvideosurface.h \ + $$PWD/qabstractvideosurface_p.h \ + $$PWD/qimagevideobuffer_p.h \ + $$PWD/qmemoryvideobuffer_p.h \ + $$PWD/qvideoframe.h \ + $$PWD/qvideosurfaceformat.h + +SOURCES += \ + $$PWD/qabstractvideobuffer.cpp \ + $$PWD/qabstractvideosurface.cpp \ + $$PWD/qimagevideobuffer.cpp \ + $$PWD/qmemoryvideobuffer.cpp \ + $$PWD/qvideoframe.cpp \ + $$PWD/qvideosurfaceformat.cpp + diff --git a/src/plugins/mediaservices/directshow/directshow.pro b/src/plugins/mediaservices/directshow/directshow.pro deleted file mode 100644 index 065e391..0000000 --- a/src/plugins/mediaservices/directshow/directshow.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qdsengine -include(../../qpluginbase.pri) - -QT += multimedia mediaservices - -HEADERS += dsserviceplugin.h -SOURCES += dsserviceplugin.cpp - -include(mediaplayer/mediaplayer.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mediaservices -target.path = $$[QT_INSTALL_PLUGINS]/mediaservices -INSTALLS += target - diff --git a/src/plugins/mediaservices/directshow/dsserviceplugin.cpp b/src/plugins/mediaservices/directshow/dsserviceplugin.cpp deleted file mode 100644 index c482fd5..0000000 --- a/src/plugins/mediaservices/directshow/dsserviceplugin.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "dsserviceplugin.h" - -#ifdef QMEDIA_DIRECTSHOW_CAMERA -#include "dscameraservice.h" -#endif - -#ifdef QMEDIA_DIRECTSHOW_PLAYER -#include "directshowplayerservice.h" -#endif - -#include - - -#ifdef QMEDIA_DIRECTSHOW_CAMERA -#ifndef _STRSAFE_H_INCLUDED_ -#include -#endif -#include -#include -#include -#pragma comment(lib, "strmiids.lib") -#pragma comment(lib, "ole32.lib") -#include -#endif - - -QT_BEGIN_NAMESPACE - -QStringList DSServicePlugin::keys() const -{ - return QStringList() -#ifdef QMEDIA_DIRECTSHOW_CAMERA - << QLatin1String(Q_MEDIASERVICE_CAMERA) -#endif -#ifdef QMEDIA_DIRECTSHOW_PLAYER - << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER) -#endif - ; -} - -QMediaService* DSServicePlugin::create(QString const& key) -{ -#ifdef QMEDIA_DIRECTSHOW_CAMERA - if (key == QLatin1String(Q_MEDIASERVICE_CAMERA)) - return new DSCameraService; -#endif -#ifdef QMEDIA_DIRECTSHOW_PLAYER - if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) - return new DirectShowPlayerService; -#endif - - qWarning() << "DirectShow service plugin: unsupported service -" << key; - return 0; -} - -void DSServicePlugin::release(QMediaService *service) -{ - delete service; -} - -QList DSServicePlugin::devices(const QByteArray &service) const -{ -#ifdef QMEDIA_DIRECTSHOW_CAMERA - if (service == Q_MEDIASERVICE_CAMERA) { - if (m_cameraDevices.isEmpty()) - updateDevices(); - - return m_cameraDevices; - } -#endif - - return QList(); -} - -QString DSServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device) -{ -#ifdef QMEDIA_DIRECTSHOW_CAMERA - if (service == Q_MEDIASERVICE_CAMERA) { - if (m_cameraDevices.isEmpty()) - updateDevices(); - - for (int i=0; i(&pDevEnum)); - if(SUCCEEDED(hr)) { - // Create the enumerator for the video capture category - hr = pDevEnum->CreateClassEnumerator( - CLSID_VideoInputDeviceCategory, &pEnum, 0); - pEnum->Reset(); - // go through and find all video capture devices - IMoniker* pMoniker = NULL; - while(pEnum->Next(1, &pMoniker, NULL) == S_OK) { - IPropertyBag *pPropBag; - hr = pMoniker->BindToStorage(0,0,IID_IPropertyBag, - (void**)(&pPropBag)); - if(FAILED(hr)) { - pMoniker->Release(); - continue; // skip this one - } - // Find the description - WCHAR str[120]; - VARIANT varName; - varName.vt = VT_BSTR; - hr = pPropBag->Read(L"FriendlyName", &varName, 0); - if(SUCCEEDED(hr)) { - StringCchCopyW(str,sizeof(str)/sizeof(str[0]),varName.bstrVal); - QString temp(QString::fromUtf16((unsigned short*)str)); - m_cameraDevices.append(QString("ds:%1").arg(temp).toLocal8Bit().constData()); - hr = pPropBag->Read(L"Description", &varName, 0); - StringCchCopyW(str,sizeof(str)/sizeof(str[0]),varName.bstrVal); - QString temp2(QString::fromUtf16((unsigned short*)str)); - m_cameraDescriptions.append(temp2); - } - pPropBag->Release(); - pMoniker->Release(); - } - } - CoUninitialize(); -} -#endif - -QT_END_NAMESPACE - -Q_EXPORT_PLUGIN2(dsengine, DSServicePlugin); - diff --git a/src/plugins/mediaservices/directshow/dsserviceplugin.h b/src/plugins/mediaservices/directshow/dsserviceplugin.h deleted file mode 100644 index 3c6f1b8..0000000 --- a/src/plugins/mediaservices/directshow/dsserviceplugin.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DSSERVICEPLUGIN_H -#define DSSERVICEPLUGIN_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class DSServicePlugin : public QMediaServiceProviderPlugin, public QMediaServiceSupportedDevicesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedDevicesInterface) -public: - QStringList keys() const; - QMediaService* create(QString const& key); - void release(QMediaService *service); - - QList devices(const QByteArray &service) const; - QString deviceDescription(const QByteArray &service, const QByteArray &device); - -private: -#ifdef QMEDIA_DIRECTSHOW_CAMERA - void updateDevices() const; - - mutable QList m_cameraDevices; - mutable QStringList m_cameraDescriptions; -#endif -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // DSSERVICEPLUGIN_H diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.cpp deleted file mode 100644 index 5f72ca6..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowaudioendpointcontrol.h" - -#include "directshowglobal.h" -#include "directshowplayerservice.h" - - -QT_BEGIN_NAMESPACE - -DirectShowAudioEndpointControl::DirectShowAudioEndpointControl( - DirectShowPlayerService *service, QObject *parent) - : QMediaControl(parent) - , m_service(service) - , m_bindContext(0) - , m_deviceEnumerator(0) -{ - if (CreateBindCtx(0, &m_bindContext) == S_OK) { - m_deviceEnumerator = com_new(CLSID_SystemDeviceEnum, IID_ICreateDevEnum); - - updateEndpoints(); - - setActiveEndpoint(m_defaultEndpoint); - } -} - -DirectShowAudioEndpointControl::~DirectShowAudioEndpointControl() -{ - foreach (IMoniker *moniker, m_devices) - moniker->Release(); - - if (m_bindContext) - m_bindContext->Release(); - - if (m_deviceEnumerator) - m_deviceEnumerator->Release(); -} - -QList DirectShowAudioEndpointControl::availableEndpoints() const -{ - return m_devices.keys(); -} - -QString DirectShowAudioEndpointControl::endpointDescription(const QString &name) const -{ -#ifdef __IPropertyBag_INTERFACE_DEFINED__ - QString description; - - if (IMoniker *moniker = m_devices.value(name, 0)) { - IPropertyBag *propertyBag = 0; - if (SUCCEEDED(moniker->BindToStorage( - 0, 0, IID_IPropertyBag, reinterpret_cast(&propertyBag)))) { - VARIANT name; - VariantInit(&name); - if (SUCCEEDED(propertyBag->Read(L"FriendlyName", &name, 0))) - description = QString::fromWCharArray(name.bstrVal); - VariantClear(&name); - propertyBag->Release(); - } - } - - return description; -#else - return name.section(QLatin1Char('\\'), -1); -#endif -} - -QString DirectShowAudioEndpointControl::defaultEndpoint() const -{ - return m_defaultEndpoint; -} - -QString DirectShowAudioEndpointControl::activeEndpoint() const -{ - return m_activeEndpoint; -} - -void DirectShowAudioEndpointControl::setActiveEndpoint(const QString &name) -{ - if (m_activeEndpoint == name) - return; - - if (IMoniker *moniker = m_devices.value(name, 0)) { - IBaseFilter *filter = 0; - - if (moniker->BindToObject( - m_bindContext, - 0, - IID_IBaseFilter, - reinterpret_cast(&filter)) == S_OK) { - m_service->setAudioOutput(filter); - - filter->Release(); - } - } -} - -void DirectShowAudioEndpointControl::updateEndpoints() -{ - IMalloc *oleMalloc = 0; - if (m_deviceEnumerator && CoGetMalloc(1, &oleMalloc) == S_OK) { - IEnumMoniker *monikers = 0; - - if (m_deviceEnumerator->CreateClassEnumerator( - CLSID_AudioRendererCategory, &monikers, 0) == S_OK) { - for (IMoniker *moniker = 0; monikers->Next(1, &moniker, 0) == S_OK; moniker->Release()) { - OLECHAR *string = 0; - if (moniker->GetDisplayName(m_bindContext, 0, &string) == S_OK) { - QString deviceId = QString::fromWCharArray(string); - oleMalloc->Free(string); - - moniker->AddRef(); - m_devices.insert(deviceId, moniker); - - if (m_defaultEndpoint.isEmpty() - || deviceId.endsWith(QLatin1String("Default DirectSound Device"))) { - m_defaultEndpoint = deviceId; - } - } - } - monikers->Release(); - } - oleMalloc->Release(); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.h deleted file mode 100644 index 8d23751..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWAUDIOENDPOINTCONTROL_H -#define DIRECTSHOWAUDIOENDPOINTCONTROL_H - -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowPlayerService; - -class DirectShowAudioEndpointControl : public QMediaControl -{ - Q_OBJECT -public: - DirectShowAudioEndpointControl(DirectShowPlayerService *service, QObject *parent = 0); - ~DirectShowAudioEndpointControl(); - - QList availableEndpoints() const; - - QString endpointDescription(const QString &name) const; - - QString defaultEndpoint() const; - QString activeEndpoint() const; - - void setActiveEndpoint(const QString& name); - -private: - void updateEndpoints(); - - DirectShowPlayerService *m_service; - IBindCtx *m_bindContext; - ICreateDevEnum *m_deviceEnumerator; - - QMap m_devices; - QString m_defaultEndpoint; - QString m_activeEndpoint; -}; - -#define QAudioEndpointSelector_iid "com.nokia.Qt.QAudioEndpointSelector/1.0" - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif - diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.cpp deleted file mode 100644 index 07541c2..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 - - -QT_BEGIN_NAMESPACE - - -class DirectShowPostedEvent -{ -public: - DirectShowPostedEvent(QObject *receiver, QEvent *event) - : receiver(receiver) - , event(event) - , next(0) - { - } - - ~DirectShowPostedEvent() - { - delete event; - } - - QObject *receiver; - QEvent *event; - DirectShowPostedEvent *next; -}; - -DirectShowEventLoop::DirectShowEventLoop(QObject *parent) - : QWinEventNotifier(parent) - , m_postsHead(0) - , m_postsTail(0) - , m_eventHandle(::CreateEvent(0, 0, 0, 0)) - , m_waitHandle(::CreateEvent(0, 0, 0, 0)) -{ - setHandle(m_eventHandle); - setEnabled(true); -} - -DirectShowEventLoop::~DirectShowEventLoop() -{ - setEnabled(false); - - ::CloseHandle(m_eventHandle); - ::CloseHandle(m_waitHandle); - - for (DirectShowPostedEvent *post = m_postsHead; post; post = m_postsHead) { - m_postsHead = m_postsHead->next; - - delete post; - } -} - -void DirectShowEventLoop::wait(QMutex *mutex) -{ - ::ResetEvent(m_waitHandle); - - mutex->unlock(); - - HANDLE handles[] = { m_eventHandle, m_waitHandle }; - while (::WaitForMultipleObjects(2, handles, false, INFINITE) == WAIT_OBJECT_0) - processEvents(); - - mutex->lock(); -} - -void DirectShowEventLoop::wake() -{ - ::SetEvent(m_waitHandle); -} - -void DirectShowEventLoop::postEvent(QObject *receiver, QEvent *event) -{ - QMutexLocker locker(&m_mutex); - - DirectShowPostedEvent *post = new DirectShowPostedEvent(receiver, event); - - if (m_postsTail) - m_postsTail->next = post; - else - m_postsHead = post; - - m_postsTail = post; - - ::SetEvent(m_eventHandle); -} - -bool DirectShowEventLoop::event(QEvent *event) -{ - if (event->type() == QEvent::WinEventAct) { - processEvents(); - - return true; - } else { - return QWinEventNotifier::event(event); - } -} - -void DirectShowEventLoop::processEvents() -{ - QMutexLocker locker(&m_mutex); - - while(m_postsHead) { - ::ResetEvent(m_eventHandle); - - DirectShowPostedEvent *post = m_postsHead; - m_postsHead = m_postsHead->next; - - if (!m_postsHead) - m_postsTail = 0; - - locker.unlock(); - QCoreApplication::sendEvent(post->receiver, post->event); - delete post; - locker.relock(); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.h b/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.h deleted file mode 100644 index f46e65a..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWEVENTLOOP_H -#define DIRECTSHOWEVENTLOOP_H - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowPostedEvent; - -class DirectShowEventLoop : public QWinEventNotifier -{ - Q_OBJECT -public: - DirectShowEventLoop(QObject *parent = 0); - ~DirectShowEventLoop(); - - void wait(QMutex *mutex); - void wake(); - - void postEvent(QObject *object, QEvent *event); - - bool event(QEvent *event); - -private: - void processEvents(); - - DirectShowPostedEvent *m_postsHead; - DirectShowPostedEvent *m_postsTail; - HANDLE m_eventHandle; - HANDLE m_waitHandle; - QMutex m_mutex; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowglobal.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowglobal.h deleted file mode 100644 index e43e2a7..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowglobal.h +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWGLOBAL_H -#define DIRECTSHOWGLOBAL_H - -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -template T *com_cast(IUnknown *unknown, const IID &iid) -{ - T *iface = 0; - return unknown && unknown->QueryInterface(iid, reinterpret_cast(&iface)) == S_OK - ? iface - : 0; -} - -template T *com_new(const IID &clsid, const IID &iid) -{ - T *object = 0; - return CoCreateInstance( - clsid, - NULL, - CLSCTX_INPROC_SERVER, - iid, - reinterpret_cast(&object)) == S_OK - ? object - : 0; -} - -QT_END_NAMESPACE - -QT_END_HEADER - -#ifndef __IFilterGraph2_INTERFACE_DEFINED__ -#define __IFilterGraph2_INTERFACE_DEFINED__ -#define INTERFACE IFilterGraph2 -DECLARE_INTERFACE_(IFilterGraph2 ,IGraphBuilder) -{ - STDMETHOD(AddSourceFilterForMoniker)(THIS_ IMoniker *, IBindCtx *, LPCWSTR,IBaseFilter **) PURE; - STDMETHOD(ReconnectEx)(THIS_ IPin *, const AM_MEDIA_TYPE *) PURE; - STDMETHOD(RenderEx)(IPin *, DWORD, DWORD *) PURE; -}; -#undef INTERFACE -#endif - -#ifndef __IAMFilterMiscFlags_INTERFACE_DEFINED__ -#define __IAMFilterMiscFlags_INTERFACE_DEFINED__ -#define INTERFACE IAMFilterMiscFlags -DECLARE_INTERFACE_(IAMFilterMiscFlags ,IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD_(ULONG,GetMiscFlags)(THIS) PURE; -}; -#undef INTERFACE -#endif - -#ifndef __IFileSourceFilter_INTERFACE_DEFINED__ -#define __IFileSourceFilter_INTERFACE_DEFINED__ -#define INTERFACE IFileSourceFilter -DECLARE_INTERFACE_(IFileSourceFilter ,IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(Load)(THIS_ LPCOLESTR, const AM_MEDIA_TYPE *) PURE; - STDMETHOD(GetCurFile)(THIS_ LPOLESTR *ppszFileName, AM_MEDIA_TYPE *) PURE; -}; -#undef INTERFACE -#endif - -#ifndef __IAMOpenProgress_INTERFACE_DEFINED__ -#define __IAMOpenProgress_INTERFACE_DEFINED__ -#define INTERFACE IAMOpenProgress -DECLARE_INTERFACE_(IAMOpenProgress ,IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(QueryProgress)(THIS_ LONGLONG *, LONGLONG *) PURE; - STDMETHOD(AbortOperation)(THIS) PURE; -}; -#undef INTERFACE -#endif - -#ifndef __IFilterChain_INTERFACE_DEFINED__ -#define __IFilterChain_INTERFACE_DEFINED__ -#define INTERFACE IFilterChain -DECLARE_INTERFACE_(IFilterChain ,IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(StartChain)(IBaseFilter *, IBaseFilter *) PURE; - STDMETHOD(PauseChain)(IBaseFilter *, IBaseFilter *) PURE; - STDMETHOD(StopChain)(IBaseFilter *, IBaseFilter *) PURE; - STDMETHOD(RemoveChain)(IBaseFilter *, IBaseFilter *) PURE; -}; -#undef INTERFACE -#endif - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.cpp deleted file mode 100644 index 7369099..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.cpp +++ /dev/null @@ -1,501 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowioreader.h" - -#include "directshoweventloop.h" -#include "directshowglobal.h" -#include "directshowiosource.h" - -#include -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -class DirectShowSampleRequest -{ -public: - DirectShowSampleRequest( - IMediaSample *sample, DWORD_PTR userData, LONGLONG position, LONG length, BYTE *buffer) - : next(0) - , sample(sample) - , userData(userData) - , position(position) - , length(length) - , buffer(buffer) - , result(S_FALSE) - { - } - - DirectShowSampleRequest *remove() { DirectShowSampleRequest *n = next; delete this; return n; } - - DirectShowSampleRequest *next; - IMediaSample *sample; - DWORD_PTR userData; - LONGLONG position; - LONG length; - BYTE *buffer; - HRESULT result; -}; - -DirectShowIOReader::DirectShowIOReader( - QIODevice *device, DirectShowIOSource *source, DirectShowEventLoop *loop) - : m_source(source) - , m_device(device) - , m_loop(loop) - , m_pendingHead(0) - , m_pendingTail(0) - , m_readyHead(0) - , m_readyTail(0) - , m_synchronousPosition(0) - , m_synchronousLength(0) - , m_synchronousBytesRead(0) - , m_synchronousBuffer(0) - , m_synchronousResult(S_OK) - , m_totalLength(0) - , m_availableLength(0) - , m_flushing(false) -{ - moveToThread(device->thread()); - - connect(device, SIGNAL(readyRead()), this, SLOT(readyRead())); -} - -DirectShowIOReader::~DirectShowIOReader() -{ - flushRequests(); -} - -HRESULT DirectShowIOReader::QueryInterface(REFIID riid, void **ppvObject) -{ - return m_source->QueryInterface(riid, ppvObject); -} - -ULONG DirectShowIOReader::AddRef() -{ - return m_source->AddRef(); -} - -ULONG DirectShowIOReader::Release() -{ - return m_source->Release(); -} - -// IAsyncReader -HRESULT DirectShowIOReader::RequestAllocator( - IMemAllocator *pPreferred, ALLOCATOR_PROPERTIES *pProps, IMemAllocator **ppActual) -{ - if (!ppActual || !pProps) { - return E_POINTER; - } else { - ALLOCATOR_PROPERTIES actualProperties; - - if (pProps->cbAlign == 0) - pProps->cbAlign = 1; - - if (pPreferred && pPreferred->SetProperties(pProps, &actualProperties) == S_OK) { - pPreferred->AddRef(); - - *ppActual = pPreferred; - - m_source->setAllocator(*ppActual); - - return S_OK; - } else { - *ppActual = com_new(CLSID_MemoryAllocator, IID_IMemAllocator); - - if (*ppActual) { - if ((*ppActual)->SetProperties(pProps, &actualProperties) != S_OK) { - (*ppActual)->Release(); - } else { - m_source->setAllocator(*ppActual); - - return S_OK; - } - } - } - ppActual = 0; - - return E_FAIL; - } -} - -HRESULT DirectShowIOReader::Request(IMediaSample *pSample, DWORD_PTR dwUser) -{ - QMutexLocker locker(&m_mutex); - - if (!pSample) { - return E_POINTER; - } else if (m_flushing) { - return VFW_E_WRONG_STATE; - } else { - REFERENCE_TIME startTime = 0; - REFERENCE_TIME endTime = 0; - BYTE *buffer; - - if (pSample->GetTime(&startTime, &endTime) != S_OK - || pSample->GetPointer(&buffer) != S_OK) { - return VFW_E_SAMPLE_TIME_NOT_SET; - } else { - LONGLONG position = startTime / 10000000; - LONG length = (endTime - startTime) / 10000000; - - DirectShowSampleRequest *request = new DirectShowSampleRequest( - pSample, dwUser, position, length, buffer); - - if (m_pendingTail) { - m_pendingTail->next = request; - } else { - m_pendingHead = request; - - m_loop->postEvent(this, new QEvent(QEvent::User)); - } - m_pendingTail = request; - - return S_OK; - } - } -} - -HRESULT DirectShowIOReader::WaitForNext( - DWORD dwTimeout, IMediaSample **ppSample, DWORD_PTR *pdwUser) -{ - if (!ppSample || !pdwUser) - return E_POINTER; - - QMutexLocker locker(&m_mutex); - - do { - if (m_readyHead) { - DirectShowSampleRequest *request = m_readyHead; - - *ppSample = request->sample; - *pdwUser = request->userData; - - HRESULT hr = request->result; - - m_readyHead = request->next; - - if (!m_readyHead) - m_readyTail = 0; - - delete request; - - return hr; - } else if (m_flushing) { - *ppSample = 0; - *pdwUser = 0; - - return VFW_E_WRONG_STATE; - } - } while (m_wait.wait(&m_mutex, dwTimeout)); - - *ppSample = 0; - *pdwUser = 0; - - return VFW_E_TIMEOUT; -} - -HRESULT DirectShowIOReader::SyncReadAligned(IMediaSample *pSample) -{ - if (!pSample) { - return E_POINTER; - } else { - REFERENCE_TIME startTime = 0; - REFERENCE_TIME endTime = 0; - BYTE *buffer; - - if (pSample->GetTime(&startTime, &endTime) != S_OK - || pSample->GetPointer(&buffer) != S_OK) { - return VFW_E_SAMPLE_TIME_NOT_SET; - } else { - LONGLONG position = startTime / 10000000; - LONG length = (endTime - startTime) / 10000000; - - QMutexLocker locker(&m_mutex); - - if (thread() == QThread::currentThread()) { - qint64 bytesRead = 0; - - HRESULT hr = blockingRead(position, length, buffer, &bytesRead); - - if (SUCCEEDED(hr)) - pSample->SetActualDataLength(bytesRead); - - return hr; - } else { - m_synchronousPosition = position; - m_synchronousLength = length; - m_synchronousBuffer = buffer; - - m_loop->postEvent(this, new QEvent(QEvent::User)); - - m_wait.wait(&m_mutex); - - m_synchronousBuffer = 0; - - if (SUCCEEDED(m_synchronousResult)) - pSample->SetActualDataLength(m_synchronousBytesRead); - - return m_synchronousResult; - } - } - } -} - -HRESULT DirectShowIOReader::SyncRead(LONGLONG llPosition, LONG lLength, BYTE *pBuffer) -{ - if (!pBuffer) { - return E_POINTER; - } else { - if (thread() == QThread::currentThread()) { - qint64 bytesRead; - - return blockingRead(llPosition, lLength, pBuffer, &bytesRead); - } else { - QMutexLocker locker(&m_mutex); - - m_synchronousPosition = llPosition; - m_synchronousLength = lLength; - m_synchronousBuffer = pBuffer; - - m_loop->postEvent(this, new QEvent(QEvent::User)); - - m_wait.wait(&m_mutex); - - m_synchronousBuffer = 0; - - return m_synchronousResult; - } - } -} - -HRESULT DirectShowIOReader::Length(LONGLONG *pTotal, LONGLONG *pAvailable) -{ - if (!pTotal || !pAvailable) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - *pTotal = m_totalLength; - *pAvailable = m_availableLength; - - return S_OK; - } -} - - -HRESULT DirectShowIOReader::BeginFlush() -{ - QMutexLocker locker(&m_mutex); - - if (m_flushing) - return S_FALSE; - - m_flushing = true; - - flushRequests(); - - m_wait.wakeAll(); - - return S_OK; -} - -HRESULT DirectShowIOReader::EndFlush() -{ - QMutexLocker locker(&m_mutex); - - if (!m_flushing) - return S_FALSE; - - m_flushing = false; - - return S_OK; -} - -void DirectShowIOReader::customEvent(QEvent *event) -{ - if (event->type() == QEvent::User) { - readyRead(); - } else { - QObject::customEvent(event); - } -} - -void DirectShowIOReader::readyRead() -{ - QMutexLocker locker(&m_mutex); - - m_availableLength = m_device->bytesAvailable() + m_device->pos(); - m_totalLength = m_device->size(); - - if (m_synchronousBuffer) { - if (nonBlockingRead( - m_synchronousPosition, - m_synchronousLength, - m_synchronousBuffer, - &m_synchronousBytesRead, - &m_synchronousResult)) { - m_wait.wakeAll(); - } - } else { - qint64 bytesRead = 0; - - while (m_pendingHead && nonBlockingRead( - m_pendingHead->position, - m_pendingHead->length, - m_pendingHead->buffer, - &bytesRead, - &m_pendingHead->result)) { - m_pendingHead->sample->SetActualDataLength(bytesRead); - - if (m_readyTail) - m_readyTail->next = m_pendingHead; - m_readyTail = m_pendingHead; - - m_pendingHead = m_pendingHead->next; - - m_readyTail->next = 0; - - if (!m_pendingHead) - m_pendingTail = 0; - - if (!m_readyHead) - m_readyHead = m_readyTail; - - m_wait.wakeAll(); - } - } -} - -HRESULT DirectShowIOReader::blockingRead( - LONGLONG position, LONG length, BYTE *buffer, qint64 *bytesRead) -{ - *bytesRead = 0; - - if (qint64(position) > m_device->size()) - return S_FALSE; - - const qint64 maxSize = qMin(m_device->size(), position + length); - - while (m_device->bytesAvailable() + m_device->pos() < maxSize) { - if (!m_device->waitForReadyRead(-1)) - return S_FALSE; - } - - if (m_device->pos() != position && !m_device->seek(position)) - return S_FALSE; - - const qint64 maxBytes = qMin(length, m_device->bytesAvailable()); - - *bytesRead = m_device->read(reinterpret_cast(buffer), maxBytes); - - if (*bytesRead != length) { - qMemSet(buffer + *bytesRead, 0, length - *bytesRead); - - return S_FALSE; - } else { - return S_OK; - } -} - -bool DirectShowIOReader::nonBlockingRead( - LONGLONG position, LONG length, BYTE *buffer, qint64 *bytesRead, HRESULT *result) -{ - const qint64 maxSize = qMin(m_device->size(), position + length); - - if (position > m_device->size()) { - *bytesRead = 0; - *result = S_FALSE; - - return true; - } else if (m_device->bytesAvailable() + m_device->pos() >= maxSize) { - if (m_device->pos() != position && !m_device->seek(position)) { - *bytesRead = 0; - *result = S_FALSE; - - return true; - } else { - const qint64 maxBytes = qMin(length, m_device->bytesAvailable()); - - *bytesRead = m_device->read(reinterpret_cast(buffer), maxBytes); - - if (*bytesRead != length) { - qMemSet(buffer + *bytesRead, 0, length - *bytesRead); - - *result = S_FALSE; - } else { - *result = S_OK; - } - - return true; - } - } else { - return false; - } -} - -void DirectShowIOReader::flushRequests() -{ - while (m_pendingHead) { - m_pendingHead->result = VFW_E_WRONG_STATE; - - if (m_readyTail) - m_readyTail->next = m_pendingHead; - - m_readyTail = m_pendingHead; - - m_pendingHead = m_pendingHead->next; - - m_readyTail->next = 0; - - if (!m_pendingHead) - m_pendingTail = 0; - - if (!m_readyHead) - m_readyHead = m_readyTail; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.h deleted file mode 100644 index 8cbc2f1..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWIOREADER_H -#define DIRECTSHOWIOREADER_H - -#include -#include -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QIODevice; - -class DirectShowEventLoop; -class DirectShowIOSource; -class DirectShowSampleRequest; - -class DirectShowIOReader : public QObject, public IAsyncReader -{ - Q_OBJECT -public: - DirectShowIOReader(QIODevice *device, DirectShowIOSource *source, DirectShowEventLoop *loop); - ~DirectShowIOReader(); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IAsyncReader - HRESULT STDMETHODCALLTYPE RequestAllocator( - IMemAllocator *pPreferred, ALLOCATOR_PROPERTIES *pProps, IMemAllocator **ppActual); - - HRESULT STDMETHODCALLTYPE Request(IMediaSample *pSample, DWORD_PTR dwUser); - - HRESULT STDMETHODCALLTYPE WaitForNext( - DWORD dwTimeout, IMediaSample **ppSample, DWORD_PTR *pdwUser); - - HRESULT STDMETHODCALLTYPE SyncReadAligned(IMediaSample *pSample); - - HRESULT STDMETHODCALLTYPE SyncRead(LONGLONG llPosition, LONG lLength, BYTE *pBuffer); - - HRESULT STDMETHODCALLTYPE Length(LONGLONG *pTotal, LONGLONG *pAvailable); - - HRESULT STDMETHODCALLTYPE BeginFlush(); - HRESULT STDMETHODCALLTYPE EndFlush(); - -protected: - void customEvent(QEvent *event); - -private Q_SLOTS: - void readyRead(); - -private: - HRESULT blockingRead(LONGLONG position, LONG length, BYTE *buffer, qint64 *bytesRead); - bool nonBlockingRead( - LONGLONG position, LONG length, BYTE *buffer, qint64 *bytesRead, HRESULT *result); - void flushRequests(); - - DirectShowIOSource *m_source; - QIODevice *m_device; - DirectShowEventLoop *m_loop; - DirectShowSampleRequest *m_pendingHead; - DirectShowSampleRequest *m_pendingTail; - DirectShowSampleRequest *m_readyHead; - DirectShowSampleRequest *m_readyTail; - LONGLONG m_synchronousPosition; - LONG m_synchronousLength; - qint64 m_synchronousBytesRead; - BYTE *m_synchronousBuffer; - HRESULT m_synchronousResult; - LONGLONG m_totalLength; - LONGLONG m_availableLength; - bool m_flushing; - QMutex m_mutex; - QWaitCondition m_wait; -}; - -QT_END_NAMESPACE - -QT_END_HEADER -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.cpp deleted file mode 100644 index 7b66d56..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.cpp +++ /dev/null @@ -1,639 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowiosource.h" - -#include "directshowglobal.h" -#include "directshowmediatype.h" -#include "directshowpinenum.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -static const GUID directshow_subtypes[] = -{ - MEDIASUBTYPE_Avi, - MEDIASUBTYPE_WAVE, - MEDIASUBTYPE_NULL -}; - -DirectShowIOSource::DirectShowIOSource(DirectShowEventLoop *loop) - : m_ref(1) - , m_state(State_Stopped) - , m_reader(0) - , m_loop(loop) - , m_graph(0) - , m_clock(0) - , m_allocator(0) - , m_peerPin(0) - , m_pinId(QLatin1String("Data")) -{ - QVector mediaTypes; - - AM_MEDIA_TYPE type = - { - MEDIATYPE_Stream, // majortype - MEDIASUBTYPE_NULL, // subtype - TRUE, // bFixedSizeSamples - FALSE, // bTemporalCompression - 1, // lSampleSize - GUID_NULL, // formattype - 0, // pUnk - 0, // cbFormat - 0, // pbFormat - }; - - static const int count = sizeof(directshow_subtypes) / sizeof(GUID); - - for (int i = 0; i < count; ++i) { - type.subtype = directshow_subtypes[i]; - mediaTypes.append(type); - } - - setMediaTypes(mediaTypes); -} - -DirectShowIOSource::~DirectShowIOSource() -{ - Q_ASSERT(m_ref == 0); - - delete m_reader; -} - -void DirectShowIOSource::setDevice(QIODevice *device) -{ - Q_ASSERT(!m_reader); - - m_reader = new DirectShowIOReader(device, this, m_loop); -} - -void DirectShowIOSource::setAllocator(IMemAllocator *allocator) -{ - if (m_allocator) - m_allocator->Release(); - - m_allocator = allocator; - - if (m_allocator) - m_allocator->AddRef(); -} - -// IUnknown -HRESULT DirectShowIOSource::QueryInterface(REFIID riid, void **ppvObject) -{ - // 2dd74950-a890-11d1-abe8-00a0c905f375 - static const GUID iid_IAmFilterMiscFlags = { - 0x2dd74950, 0xa890, 0x11d1, {0xab, 0xe8, 0x00, 0xa0, 0xc9, 0x05, 0xf3, 0x75}}; - - if (!ppvObject) { - return E_POINTER; - } else if (riid == IID_IUnknown - || riid == IID_IPersist - || riid == IID_IMediaFilter - || riid == IID_IBaseFilter) { - *ppvObject = static_cast(this); - } else if (riid == iid_IAmFilterMiscFlags) { - *ppvObject = static_cast(this); - } else if (riid == IID_IPin) { - *ppvObject = static_cast(this); - } else if (riid == IID_IAsyncReader) { - *ppvObject = static_cast(m_reader); - } else { - *ppvObject = 0; - - return E_NOINTERFACE; - } - - AddRef(); - - return S_OK; -} - -ULONG DirectShowIOSource::AddRef() -{ - return InterlockedIncrement(&m_ref); -} - -ULONG DirectShowIOSource::Release() -{ - ULONG ref = InterlockedDecrement(&m_ref); - - if (ref == 0) { - delete this; - } - - return ref; -} - -// IPersist -HRESULT DirectShowIOSource::GetClassID(CLSID *pClassID) -{ - *pClassID = CLSID_NULL; - - return S_OK; -} - -// IMediaFilter -HRESULT DirectShowIOSource::Run(REFERENCE_TIME tStart) -{ - QMutexLocker locker(&m_mutex); - - m_state = State_Running; - - return S_OK; -} - -HRESULT DirectShowIOSource::Pause() -{ - QMutexLocker locker(&m_mutex); - - m_state = State_Paused; - - return S_OK; -} - -HRESULT DirectShowIOSource::Stop() -{ - QMutexLocker locker(&m_mutex); - - m_state = State_Stopped; - - return S_OK; -} - -HRESULT DirectShowIOSource::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *pState) -{ - Q_UNUSED(dwMilliSecsTimeout); - - if (!pState) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - *pState = m_state; - - return S_OK; - } -} - -HRESULT DirectShowIOSource::SetSyncSource(IReferenceClock *pClock) -{ - QMutexLocker locker(&m_mutex); - - if (m_clock) - m_clock->Release(); - - m_clock = pClock; - - if (m_clock) - m_clock->AddRef(); - - return S_OK; -} - -HRESULT DirectShowIOSource::GetSyncSource(IReferenceClock **ppClock) -{ - if (!ppClock) { - return E_POINTER; - } else { - if (!m_clock) { - *ppClock = 0; - - return S_FALSE; - } else { - m_clock->AddRef(); - - *ppClock = m_clock; - - return S_OK; - } - } -} - -// IBaseFilter -HRESULT DirectShowIOSource::EnumPins(IEnumPins **ppEnum) -{ - if (!ppEnum) { - return E_POINTER; - } else { - *ppEnum = new DirectShowPinEnum(QList() << this); - - return S_OK; - } -} - -HRESULT DirectShowIOSource::FindPin(LPCWSTR Id, IPin **ppPin) -{ - if (!ppPin || !Id) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - if (QString::fromWCharArray(Id) == m_pinId) { - AddRef(); - - *ppPin = this; - - return S_OK; - } else { - *ppPin = 0; - - return VFW_E_NOT_FOUND; - } - } -} - -HRESULT DirectShowIOSource::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName) -{ - QMutexLocker locker(&m_mutex); - - m_graph = pGraph; - m_filterName = QString::fromWCharArray(pName); - - return S_OK; -} - -HRESULT DirectShowIOSource::QueryFilterInfo(FILTER_INFO *pInfo) -{ - if (!pInfo) { - return E_POINTER; - } else { - QString name = m_filterName; - - if (name.length() >= MAX_FILTER_NAME) - name.truncate(MAX_FILTER_NAME - 1); - - int length = name.toWCharArray(pInfo->achName); - pInfo->achName[length] = '\0'; - - if (m_graph) - m_graph->AddRef(); - - pInfo->pGraph = m_graph; - - return S_OK; - } -} - -HRESULT DirectShowIOSource::QueryVendorInfo(LPWSTR *pVendorInfo) -{ - Q_UNUSED(pVendorInfo); - - return E_NOTIMPL; -} - -// IAMFilterMiscFlags -ULONG DirectShowIOSource::GetMiscFlags() -{ - return AM_FILTER_MISC_FLAGS_IS_SOURCE; -} - -// IPin -HRESULT DirectShowIOSource::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) -{ - QMutexLocker locker(&m_mutex); - if (!pReceivePin) { - return E_POINTER; - } else if (m_state != State_Stopped) { - return VFW_E_NOT_STOPPED; - } else if (m_peerPin) { - return VFW_E_ALREADY_CONNECTED; - } else { - HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED; - - m_peerPin = pReceivePin; - m_peerPin->AddRef(); - - if (!pmt) { - IEnumMediaTypes *mediaTypes = 0; - if (pReceivePin->EnumMediaTypes(&mediaTypes) == S_OK) { - for (AM_MEDIA_TYPE *type = 0; - mediaTypes->Next(1, &type, 0) == S_OK; - DirectShowMediaType::deleteType(type)) { - switch (tryConnect(pReceivePin, type)) { - case S_OK: - DirectShowMediaType::freeData(type); - mediaTypes->Release(); - return S_OK; - case VFW_E_NO_TRANSPORT: - hr = VFW_E_NO_TRANSPORT; - break; - default: - break; - } - } - mediaTypes->Release(); - } - AM_MEDIA_TYPE type = - { - MEDIATYPE_Stream, // majortype - MEDIASUBTYPE_NULL, // subtype - TRUE, // bFixedSizeSamples - FALSE, // bTemporalCompression - 1, // lSampleSize - GUID_NULL, // formattype - 0, // pUnk - 0, // cbFormat - 0, // pbFormat - }; - - static const int count = sizeof(directshow_subtypes) / sizeof(GUID); - - for (int i = 0; i < count; ++i) { - type.subtype = directshow_subtypes[i]; - - switch (tryConnect(pReceivePin, &type)) { - case S_OK: - return S_OK; - case VFW_E_NO_TRANSPORT: - hr = VFW_E_NO_TRANSPORT; - break; - default: - break; - } - } - } else if (pmt->majortype == MEDIATYPE_Stream && (hr = tryConnect(pReceivePin, pmt))) { - return S_OK; - } - - m_peerPin->Release(); - m_peerPin = 0; - - m_mediaType.clear(); - - return hr; - } -} - -HRESULT DirectShowIOSource::tryConnect(IPin *pin, const AM_MEDIA_TYPE *type) -{ - m_mediaType = *type; - - HRESULT hr = pin->ReceiveConnection(this, type); - - if (!SUCCEEDED(hr)) { - if (m_allocator) { - m_allocator->Release(); - m_allocator = 0; - } - } else if (!m_allocator) { - hr = VFW_E_NO_TRANSPORT; - - if (IMemInputPin *memPin = com_cast(pin, IID_IMemInputPin)) { - if ((m_allocator = com_new(CLSID_MemoryAllocator, IID_IMemAllocator))) { - ALLOCATOR_PROPERTIES properties; - if (memPin->GetAllocatorRequirements(&properties) == S_OK - || m_allocator->GetProperties(&properties) == S_OK) { - if (properties.cbAlign == 0) - properties.cbAlign = 1; - - ALLOCATOR_PROPERTIES actualProperties; - if (SUCCEEDED(hr = m_allocator->SetProperties(&properties, &actualProperties))) - hr = memPin->NotifyAllocator(m_allocator, TRUE); - } - if (!SUCCEEDED(hr)) { - m_allocator->Release(); - m_allocator = 0; - } - } - memPin->Release(); - } - if (!SUCCEEDED(hr)) - pin->Disconnect(); - } - return hr; -} - -HRESULT DirectShowIOSource::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) -{ - Q_UNUSED(pConnector); - Q_UNUSED(pmt); - // Output pin. - return E_NOTIMPL; -} - -HRESULT DirectShowIOSource::Disconnect() -{ - if (!m_peerPin) { - return S_FALSE; - } else if (m_state != State_Stopped) { - return VFW_E_NOT_STOPPED; - } else { - HRESULT hr = m_peerPin->Disconnect(); - - if (!SUCCEEDED(hr)) - return hr; - - if (m_allocator) { - m_allocator->Release(); - m_allocator = 0; - } - - m_peerPin->Release(); - m_peerPin = 0; - - m_mediaType.clear(); - - return S_OK; - } -} - -HRESULT DirectShowIOSource::ConnectedTo(IPin **ppPin) -{ - if (!ppPin) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) { - *ppPin = 0; - - return VFW_E_NOT_CONNECTED; - } else { - m_peerPin->AddRef(); - - *ppPin = m_peerPin; - - return S_OK; - } - } -} - -HRESULT DirectShowIOSource::ConnectionMediaType(AM_MEDIA_TYPE *pmt) -{ - if (!pmt) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) { - pmt = 0; - - return VFW_E_NOT_CONNECTED; - } else { - DirectShowMediaType::copy(pmt, m_mediaType); - - return S_OK; - } - } -} - -HRESULT DirectShowIOSource::QueryPinInfo(PIN_INFO *pInfo) -{ - if (!pInfo) { - return E_POINTER; - } else { - AddRef(); - - pInfo->pFilter = this; - pInfo->dir = PINDIR_OUTPUT; - - const int bytes = qMin(MAX_FILTER_NAME, (m_pinId.length() + 1) * 2); - - qMemCopy(pInfo->achName, m_pinId.utf16(), bytes); - - return S_OK; - } -} - -HRESULT DirectShowIOSource::QueryId(LPWSTR *Id) -{ - if (!Id) { - return E_POINTER; - } else { - const int bytes = (m_pinId.length() + 1) * 2; - - *Id = static_cast(::CoTaskMemAlloc(bytes)); - - qMemCopy(*Id, m_pinId.utf16(), bytes); - - return S_OK; - } -} - -HRESULT DirectShowIOSource::QueryAccept(const AM_MEDIA_TYPE *pmt) -{ - if (!pmt) { - return E_POINTER; - } else if (pmt->majortype == MEDIATYPE_Stream) { - return S_OK; - } else { - return S_FALSE; - } -} - -HRESULT DirectShowIOSource::EnumMediaTypes(IEnumMediaTypes **ppEnum) -{ - if (!ppEnum) { - return E_POINTER; - } else { - *ppEnum = createMediaTypeEnum(); - - return S_OK; - } -} - -HRESULT DirectShowIOSource::QueryInternalConnections(IPin **apPin, ULONG *nPin) -{ - Q_UNUSED(apPin); - Q_UNUSED(nPin); - - return E_NOTIMPL; -} - -HRESULT DirectShowIOSource::EndOfStream() -{ - return S_OK; -} - -HRESULT DirectShowIOSource::BeginFlush() -{ - return m_reader->BeginFlush(); -} - -HRESULT DirectShowIOSource::EndFlush() -{ - return m_reader->EndFlush(); -} - -HRESULT DirectShowIOSource::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) -{ - Q_UNUSED(tStart); - Q_UNUSED(tStop); - Q_UNUSED(dRate); - - return S_OK; -} - -HRESULT DirectShowIOSource::QueryDirection(PIN_DIRECTION *pPinDir) -{ - if (!pPinDir) { - return E_POINTER; - } else { - *pPinDir = PINDIR_OUTPUT; - - return S_OK; - } -} - -QT_END_NAMESPACE - -DirectShowRcSource::DirectShowRcSource(DirectShowEventLoop *loop) - : DirectShowIOSource(loop) -{ -} - -bool DirectShowRcSource::open(const QUrl &url) -{ - m_file.moveToThread(QCoreApplication::instance()->thread()); - - m_file.setFileName(QLatin1Char(':') + url.path()); - - if (m_file.open(QIODevice::ReadOnly)) { - - setDevice(&m_file); - - return true; - } else { - return false; - } -} diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.h deleted file mode 100644 index 1d917df..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.h +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWIOSOURCE_H -#define DIRECTSHOWIOSOURCE_H - -#include "directshowglobal.h" -#include "directshowioreader.h" -#include "directshowmediatype.h" -#include "directshowmediatypelist.h" - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowIOSource - : public DirectShowMediaTypeList - , public IBaseFilter - , public IAMFilterMiscFlags - , public IPin -{ -public: - DirectShowIOSource(DirectShowEventLoop *loop); - ~DirectShowIOSource(); - - void setDevice(QIODevice *device); - void setAllocator(IMemAllocator *allocator); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IPersist - HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID); - - // IMediaFilter - HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart); - HRESULT STDMETHODCALLTYPE Pause(); - HRESULT STDMETHODCALLTYPE Stop(); - - HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *pState); - - HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock); - HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock **ppClock); - - // IBaseFilter - HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins **ppEnum); - HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin **ppPin); - - HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName); - - HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO *pInfo); - HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR *pVendorInfo); - - // IAMFilterMiscFlags - ULONG STDMETHODCALLTYPE GetMiscFlags(); - - // IPin - HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); - HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); - HRESULT STDMETHODCALLTYPE Disconnect(); - HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **ppPin); - - HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); - - HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); - HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); - - HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); - - HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); - - HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); - - HRESULT STDMETHODCALLTYPE EndOfStream(); - - HRESULT STDMETHODCALLTYPE BeginFlush(); - HRESULT STDMETHODCALLTYPE EndFlush(); - - HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); - - HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); - -private: - HRESULT tryConnect(IPin *pin, const AM_MEDIA_TYPE *type); - - volatile LONG m_ref; - FILTER_STATE m_state; - DirectShowIOReader *m_reader; - DirectShowEventLoop *m_loop; - IFilterGraph *m_graph; - IReferenceClock *m_clock; - IMemAllocator *m_allocator; - IPin *m_peerPin; - DirectShowMediaType m_mediaType; - QString m_filterName; - const QString m_pinId; - QMutex m_mutex; -}; - -class DirectShowRcSource : public DirectShowIOSource -{ -public: - DirectShowRcSource(DirectShowEventLoop *loop); - - bool open(const QUrl &url); - -private: - QFile m_file; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp deleted file mode 100644 index f8f519d..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowmediatype.h" - - -QT_BEGIN_NAMESPACE - -namespace -{ - struct TypeLookup - { - QVideoFrame::PixelFormat pixelFormat; - GUID mediaType; - }; - - static const TypeLookup qt_typeLookup[] = - { - { QVideoFrame::Format_RGB32, /*MEDIASUBTYPE_RGB32*/ {0xe436eb7e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} }, - { QVideoFrame::Format_BGR24, /*MEDIASUBTYPE_RGB24*/ {0xe436eb7d, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} }, - { QVideoFrame::Format_RGB565, /*MEDIASUBTYPE_RGB565*/ {0xe436eb7b, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} }, - { QVideoFrame::Format_RGB555, /*MEDIASUBTYPE_RGB555*/ {0xe436eb7c, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} }, - { QVideoFrame::Format_AYUV444, /*MEDIASUBTYPE_AYUV*/ {0x56555941, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_YUYV, /*MEDIASUBTYPE_YUY2*/ {0x32595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_UYVY, /*MEDIASUBTYPE_UYVY*/ {0x59565955, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_IMC1, /*MEDIASUBTYPE_IMC1*/ {0x31434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_IMC2, /*MEDIASUBTYPE_IMC2*/ {0x32434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_IMC3, /*MEDIASUBTYPE_IMC3*/ {0x33434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_IMC4, /*MEDIASUBTYPE_IMC4*/ {0x34434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_YV12, /*MEDIASUBTYPE_YV12*/ {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_NV12, /*MEDIASUBTYPE_NV12*/ {0x3231564E, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_YUV420P, /*MEDIASUBTYPE_IYUV*/ {0x56555949, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} } - }; -} - -void DirectShowMediaType::copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE &source) -{ - *target = source; - - if (source.cbFormat > 0) { - target->pbFormat = reinterpret_cast(CoTaskMemAlloc(source.cbFormat)); - memcpy(target->pbFormat, source.pbFormat, source.cbFormat); - } - if (target->pUnk) - target->pUnk->AddRef(); -} - -void DirectShowMediaType::deleteType(AM_MEDIA_TYPE *type) -{ - freeData(type); - - CoTaskMemFree(type); -} - -void DirectShowMediaType::freeData(AM_MEDIA_TYPE *type) -{ - if (type->cbFormat > 0) - CoTaskMemFree(type->pbFormat); - - if (type->pUnk) - type->pUnk->Release(); -} - - -GUID DirectShowMediaType::convertPixelFormat(QVideoFrame::PixelFormat format) -{ - // MEDIASUBTYPE_None; - static const GUID none = { - 0xe436eb8e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70} }; - - const int count = sizeof(qt_typeLookup) / sizeof(TypeLookup); - - for (int i = 0; i < count; ++i) - if (qt_typeLookup[i].pixelFormat == format) - return qt_typeLookup[i].mediaType; - return none; -} - -QVideoSurfaceFormat DirectShowMediaType::formatFromType(const AM_MEDIA_TYPE &type) -{ - const int count = sizeof(qt_typeLookup) / sizeof(TypeLookup); - - for (int i = 0; i < count; ++i) { - if (IsEqualGUID(qt_typeLookup[i].mediaType, type.subtype) && type.cbFormat > 0) { - if (IsEqualGUID(type.formattype, FORMAT_VideoInfo)) { - VIDEOINFOHEADER *header = reinterpret_cast(type.pbFormat); - - QVideoSurfaceFormat format( - QSize(header->bmiHeader.biWidth, qAbs(header->bmiHeader.biHeight)), - qt_typeLookup[i].pixelFormat); - - if (header->AvgTimePerFrame > 0) - format.setFrameRate(10000 /header->AvgTimePerFrame); - - switch (qt_typeLookup[i].pixelFormat) { - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_BGR24: - case QVideoFrame::Format_RGB565: - case QVideoFrame::Format_RGB555: - if (header->bmiHeader.biHeight >= 0) - format.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); - break; - default: - break; - } - - return format; - } else if (IsEqualGUID(type.formattype, FORMAT_VideoInfo2)) { - VIDEOINFOHEADER2 *header = reinterpret_cast(type.pbFormat); - - QVideoSurfaceFormat format( - QSize(header->bmiHeader.biWidth, qAbs(header->bmiHeader.biHeight)), - qt_typeLookup[i].pixelFormat); - - if (header->AvgTimePerFrame > 0) - format.setFrameRate(10000 / header->AvgTimePerFrame); - - switch (qt_typeLookup[i].pixelFormat) { - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_BGR24: - case QVideoFrame::Format_RGB565: - case QVideoFrame::Format_RGB555: - if (header->bmiHeader.biHeight >= 0) - format.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); - break; - default: - break; - } - - return format; - } - } - } - return QVideoSurfaceFormat(); -} - -int DirectShowMediaType::bytesPerLine(const QVideoSurfaceFormat &format) -{ - switch (format.pixelFormat()) { - // 32 bpp packed formats. - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_AYUV444: - return format.frameWidth() * 4; - // 24 bpp packed formats. - case QVideoFrame::Format_RGB24: - return format.frameWidth() * 3 + 3 - format.frameWidth() % 4; - // 16 bpp packed formats. - case QVideoFrame::Format_RGB565: - case QVideoFrame::Format_RGB555: - case QVideoFrame::Format_YUYV: - case QVideoFrame::Format_UYVY: - return format.frameWidth() * 2 + 3 - format.frameWidth() % 4; - // Planar formats. - case QVideoFrame::Format_IMC1: - case QVideoFrame::Format_IMC2: - case QVideoFrame::Format_IMC3: - case QVideoFrame::Format_IMC4: - case QVideoFrame::Format_YV12: - case QVideoFrame::Format_NV12: - case QVideoFrame::Format_YUV420P: - return format.frameWidth() + 3 - format.frameWidth() % 4; - default: - return 0; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.h deleted file mode 100644 index 3cc7307..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWMEDIATYPE_H -#define DIRECTSHOWMEDIATYPE_H - -#include - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class DirectShowMediaType : public AM_MEDIA_TYPE -{ -public: - DirectShowMediaType() { memset(this, 0, sizeof(DirectShowMediaType)); } - DirectShowMediaType(const AM_MEDIA_TYPE &type) { copy(this, type); } - DirectShowMediaType(const DirectShowMediaType &other) { copy(this, other); } - DirectShowMediaType &operator =(const AM_MEDIA_TYPE &type) { - freeData(this); copy(this, type); return *this; } - DirectShowMediaType &operator =(const DirectShowMediaType &other) { - freeData(this); copy(this, other); return *this; } - ~DirectShowMediaType() { freeData(this); } - - void clear() { freeData(this); memset(this, 0, sizeof(DirectShowMediaType)); } - - static void copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE &source); - static void freeData(AM_MEDIA_TYPE *type); - static void deleteType(AM_MEDIA_TYPE *type); - - static GUID convertPixelFormat(QVideoFrame::PixelFormat format); - static QVideoSurfaceFormat formatFromType(const AM_MEDIA_TYPE &type); - - static int bytesPerLine(const QVideoSurfaceFormat &format); -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.cpp deleted file mode 100644 index f67794a..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowmediatypelist.h" - -#include "directshowmediatype.h" -#include "videosurfacefilter.h" - - -QT_BEGIN_NAMESPACE - -class DirectShowMediaTypeEnum : public IEnumMediaTypes -{ -public: - DirectShowMediaTypeEnum(DirectShowMediaTypeList *list, int token, int index = 0); - ~DirectShowMediaTypeEnum(); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IEnumMediaTypes - HRESULT STDMETHODCALLTYPE Next( - ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched); - HRESULT STDMETHODCALLTYPE Skip(ULONG cMediaTypes); - HRESULT STDMETHODCALLTYPE Reset(); - - HRESULT STDMETHODCALLTYPE Clone(IEnumMediaTypes **ppEnum); - -private: - LONG m_ref; - DirectShowMediaTypeList *m_list; - int m_mediaTypeToken; - int m_index; -}; - - -DirectShowMediaTypeEnum::DirectShowMediaTypeEnum( - DirectShowMediaTypeList *list, int token, int index) - : m_ref(1) - , m_list(list) - , m_mediaTypeToken(token) - , m_index(index) -{ - m_list->AddRef(); -} - -DirectShowMediaTypeEnum::~DirectShowMediaTypeEnum() -{ - m_list->Release(); -} - -HRESULT DirectShowMediaTypeEnum::QueryInterface(REFIID riid, void **ppvObject) -{ - if (!ppvObject) { - return E_POINTER; - } else if (riid == IID_IUnknown - || riid == IID_IEnumMediaTypes) { - *ppvObject = static_cast(this); - } else { - *ppvObject = 0; - - return E_NOINTERFACE; - } - - AddRef(); - - return S_OK; -} - -ULONG DirectShowMediaTypeEnum::AddRef() -{ - return InterlockedIncrement(&m_ref); -} - -ULONG DirectShowMediaTypeEnum::Release() -{ - ULONG ref = InterlockedDecrement(&m_ref); - - if (ref == 0) { - delete this; - } - - return ref; -} - -HRESULT DirectShowMediaTypeEnum::Next( - ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched) -{ - return m_list->nextMediaType(m_mediaTypeToken, &m_index, cMediaTypes, ppMediaTypes, pcFetched); -} - -HRESULT DirectShowMediaTypeEnum::Skip(ULONG cMediaTypes) -{ - return m_list->skipMediaType(m_mediaTypeToken, &m_index, cMediaTypes); -} - -HRESULT DirectShowMediaTypeEnum::Reset() -{ - m_mediaTypeToken = m_list->currentMediaTypeToken(); - m_index = 0; - - return S_OK; -} - -HRESULT DirectShowMediaTypeEnum::Clone(IEnumMediaTypes **ppEnum) -{ - return m_list->cloneMediaType(m_mediaTypeToken, m_index, ppEnum); -} - - -DirectShowMediaTypeList::DirectShowMediaTypeList() - : m_mediaTypeToken(0) -{ -} - -IEnumMediaTypes *DirectShowMediaTypeList::createMediaTypeEnum() -{ - return new DirectShowMediaTypeEnum(this, m_mediaTypeToken, 0); -} - - -void DirectShowMediaTypeList::setMediaTypes(const QVector &types) -{ - ++m_mediaTypeToken; - - m_mediaTypes = types; -} - - -int DirectShowMediaTypeList::currentMediaTypeToken() -{ - return m_mediaTypeToken; -} - -HRESULT DirectShowMediaTypeList::nextMediaType( - int token, int *index, ULONG count, AM_MEDIA_TYPE **types, ULONG *fetchedCount) -{ - if (!types || (count != 1 && !fetchedCount)) { - return E_POINTER; - } else if (m_mediaTypeToken != token) { - return VFW_E_ENUM_OUT_OF_SYNC; - } else { - int boundedCount = qBound(0, count, m_mediaTypes.count() - *index); - - for (int i = 0; i < boundedCount; ++i, ++(*index)) { - types[i] = reinterpret_cast(CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))); - - if (types[i]) { - DirectShowMediaType::copy(types[i], m_mediaTypes.at(*index)); - } else { - for (--i; i >= 0; --i) - CoTaskMemFree(types[i]); - - if (fetchedCount) - *fetchedCount = 0; - - return E_OUTOFMEMORY; - } - } - if (fetchedCount) - *fetchedCount = boundedCount; - - return boundedCount == count ? S_OK : S_FALSE; - } -} - -HRESULT DirectShowMediaTypeList::skipMediaType(int token, int *index, ULONG count) -{ - if (m_mediaTypeToken != token) { - return VFW_E_ENUM_OUT_OF_SYNC; - } else { - *index = qMin(*index + count, m_mediaTypes.size()); - - return *index < m_mediaTypes.size() ? S_OK : S_FALSE; - } -} - -HRESULT DirectShowMediaTypeList::cloneMediaType(int token, int index, IEnumMediaTypes **enumeration) -{ - if (m_mediaTypeToken != token) { - return VFW_E_ENUM_OUT_OF_SYNC; - } else { - *enumeration = new DirectShowMediaTypeEnum(this, token, index); - - return S_OK; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.h deleted file mode 100644 index b49f24c..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWMEDIATYPELIST_H -#define DIRECTSHOWMEDIATYPELIST_H - -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowMediaTypeList : public IUnknown -{ -public: - DirectShowMediaTypeList(); - - IEnumMediaTypes *createMediaTypeEnum(); - - void setMediaTypes(const QVector &types); - - virtual int currentMediaTypeToken(); - virtual HRESULT nextMediaType( - int token, int *index, ULONG count, AM_MEDIA_TYPE **types, ULONG *fetchedCount); - virtual HRESULT skipMediaType(int token, int *index, ULONG count); - virtual HRESULT cloneMediaType(int token, int index, IEnumMediaTypes **enumeration); - -private: - int m_mediaTypeToken; - QVector m_mediaTypes; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.cpp deleted file mode 100644 index 7f67a82..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowmetadatacontrol.h" - -#include "directshowplayerservice.h" - -#include - - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_WMSDK -namespace -{ - struct QWMMetaDataKeyLookup - { - QtMediaServices::MetaData key; - const wchar_t *token; - }; -} - -static const QWMMetaDataKeyLookup qt_wmMetaDataKeys[] = -{ - { QtMediaServices::Title, L"Title" }, - { QtMediaServices::SubTitle, L"WM/SubTitle" }, - { QtMediaServices::Author, L"Author" }, - { QtMediaServices::Comment, L"Comment" }, - { QtMediaServices::Description, L"Description" }, - { QtMediaServices::Category, L"WM/Category" }, - { QtMediaServices::Genre, L"WM/Genre" }, - //{ QtMediaServices::Date, 0 }, - { QtMediaServices::Year, L"WM/Year" }, - { QtMediaServices::UserRating, L"UserRating" }, - //{ QtMediaServices::MetaDatawords, 0 }, - { QtMediaServices::Language, L"Language" }, - { QtMediaServices::Publisher, L"WM/Publisher" }, - { QtMediaServices::Copyright, L"Copyright" }, - { QtMediaServices::ParentalRating, L"ParentalRating" }, - { QtMediaServices::RatingOrganisation, L"RatingOrganisation" }, - - // Media - { QtMediaServices::Size, L"FileSize" }, - { QtMediaServices::MediaType, L"MediaType" }, - { QtMediaServices::Duration, L"Duration" }, - - // Audio - { QtMediaServices::AudioBitRate, L"AudioBitRate" }, - { QtMediaServices::AudioCodec, L"AudioCodec" }, - { QtMediaServices::ChannelCount, L"ChannelCount" }, - { QtMediaServices::SampleRate, L"Frequency" }, - - // Music - { QtMediaServices::AlbumTitle, L"WM/AlbumTitle" }, - { QtMediaServices::AlbumArtist, L"WM/AlbumArtist" }, - { QtMediaServices::ContributingArtist, L"Author" }, - { QtMediaServices::Composer, L"WM/Composer" }, - { QtMediaServices::Conductor, L"WM/Conductor" }, - { QtMediaServices::Lyrics, L"WM/Lyrics" }, - { QtMediaServices::Mood, L"WM/Mood" }, - { QtMediaServices::TrackNumber, L"WM/TrackNumber" }, - //{ QtMediaServices::TrackCount, 0 }, - //{ QtMediaServices::CoverArtUriSmall, 0 }, - //{ QtMediaServices::CoverArtUriLarge, 0 }, - - // Image/Video - //{ QtMediaServices::Resolution, 0 }, - //{ QtMediaServices::PixelAspectRatio, 0 }, - - // Video - //{ QtMediaServices::FrameRate, 0 }, - { QtMediaServices::VideoBitRate, L"VideoBitRate" }, - { QtMediaServices::VideoCodec, L"VideoCodec" }, - - //{ QtMediaServices::PosterUri, 0 }, - - // Movie - { QtMediaServices::ChapterNumber, L"ChapterNumber" }, - { QtMediaServices::Director, L"WM/Director" }, - { QtMediaServices::LeadPerformer, L"LeadPerformer" }, - { QtMediaServices::Writer, L"WM/Writer" }, - - // Photos - { QtMediaServices::CameraManufacturer, L"CameraManufacturer" }, - { QtMediaServices::CameraModel, L"CameraModel" }, - { QtMediaServices::Event, L"Event" }, - { QtMediaServices::Subject, L"Subject" } -}; - -static QVariant getValue(IWMHeaderInfo *header, const wchar_t *key) -{ - WORD streamNumber = 0; - WMT_ATTR_DATATYPE type = WMT_TYPE_DWORD; - WORD size = 0; - - if (header->GetAttributeByName(&streamNumber, key, &type, 0, &size) == S_OK) { - switch (type) { - case WMT_TYPE_DWORD: - if (size == sizeof(DWORD)) { - DWORD word; - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast(&word), - &size) == S_OK) { - return int(word); - } - } - break; - case WMT_TYPE_STRING: - { - QString string; - string.resize(size / 2 - 1); - - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast(const_cast(string.utf16())), - &size) == S_OK) { - return string; - } - } - break; - case WMT_TYPE_BINARY: - { - QByteArray bytes; - bytes.resize(size); - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast(bytes.data()), - &size) == S_OK) { - return bytes; - } - } - break; - case WMT_TYPE_BOOL: - if (size == sizeof(DWORD)) { - DWORD word; - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast(&word), - &size) == S_OK) { - return bool(word); - } - } - break; - case WMT_TYPE_QWORD: - if (size == sizeof(QWORD)) { - QWORD word; - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast(&word), - &size) == S_OK) { - return qint64(word); - } - } - break; - case WMT_TYPE_WORD: - if (size == sizeof(WORD)){ - WORD word; - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast(&word), - &size) == S_OK) { - return short(word); - } - } - break; - case WMT_TYPE_GUID: - if (size == 16) { - } - break; - default: - break; - } - } - return QVariant(); -} -#endif - -DirectShowMetaDataControl::DirectShowMetaDataControl(QObject *parent) - : QMetaDataControl(parent) - , m_content(0) -#ifndef QT_NO_WMSDK - , m_headerInfo(0) -#endif -{ -} - -DirectShowMetaDataControl::~DirectShowMetaDataControl() -{ -} - -bool DirectShowMetaDataControl::isWritable() const -{ - return false; -} - -bool DirectShowMetaDataControl::isMetaDataAvailable() const -{ -#ifndef QT_NO_WMSDK - return m_content || m_headerInfo; -#else - return m_content; -#endif -} - -QVariant DirectShowMetaDataControl::metaData(QtMediaServices::MetaData key) const -{ - QVariant value; - -#ifndef QT_NO_WMSDK - if (m_headerInfo) { - static const int count = sizeof(qt_wmMetaDataKeys) / sizeof(QWMMetaDataKeyLookup); - for (int i = 0; i < count; ++i) { - if (qt_wmMetaDataKeys[i].key == key) { - value = getValue(m_headerInfo, qt_wmMetaDataKeys[i].token); - break; - } - } - } else if (m_content) { -#else - if (m_content) { -#endif - BSTR string = 0; - - switch (key) { - case QtMediaServices::Author: - m_content->get_AuthorName(&string); - break; - case QtMediaServices::Title: - m_content->get_Title(&string); - break; - case QtMediaServices::ParentalRating: - m_content->get_Rating(&string); - break; - case QtMediaServices::Description: - m_content->get_Description(&string); - break; - case QtMediaServices::Copyright: - m_content->get_Copyright(&string); - break; - default: - break; - } - - if (string) { - value = QString::fromUtf16(reinterpret_cast(string), ::SysStringLen(string)); - - ::SysFreeString(string); - } - } - return value; -} - -void DirectShowMetaDataControl::setMetaData(QtMediaServices::MetaData, const QVariant &) -{ -} - -QList DirectShowMetaDataControl::availableMetaData() const -{ - return QList(); -} - -QVariant DirectShowMetaDataControl::extendedMetaData(const QString &) const -{ - return QVariant(); -} - -void DirectShowMetaDataControl::setExtendedMetaData(const QString &, const QVariant &) -{ -} - -QStringList DirectShowMetaDataControl::availableExtendedMetaData() const -{ - return QStringList(); -} - -void DirectShowMetaDataControl::updateGraph(IFilterGraph2 *graph, IBaseFilter *source) -{ - if (m_content) - m_content->Release(); - - if (!graph || graph->QueryInterface( - IID_IAMMediaContent, reinterpret_cast(&m_content)) != S_OK) { - m_content = 0; - } - -#ifdef QT_NO_WMSDK - Q_UNUSED(source); -#else - if (m_headerInfo) - m_headerInfo->Release(); - - m_headerInfo = com_cast(source, IID_IWMHeaderInfo); -#endif - // DirectShowMediaPlayerService holds a lock at this point so defer emitting signals to a later - // time. - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(MetaDataChanged))); -} - -void DirectShowMetaDataControl::customEvent(QEvent *event) -{ - if (event->type() == QEvent::Type(MetaDataChanged)) { - event->accept(); - - emit metaDataChanged(); -#ifndef QT_NO_WMSDK - emit metaDataAvailableChanged(m_content || m_headerInfo); -#else - emit metaDataAvailableChanged(m_content); -#endif - } else { - QMetaDataControl::customEvent(event); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.h deleted file mode 100644 index e368f00..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWMETADATACONTROL_H -#define DIRECTSHOWMETADATACONTROL_H - -#include "directshowglobal.h" - -#include - -#include - -#ifndef QT_NO_WMSDK -#include -#endif - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowPlayerService; - - -class DirectShowMetaDataControl : public QMetaDataControl -{ - Q_OBJECT -public: - DirectShowMetaDataControl(QObject *parent = 0); - ~DirectShowMetaDataControl(); - - bool isWritable() const; - bool isMetaDataAvailable() const; - - QVariant metaData(QtMediaServices::MetaData key) const; - void setMetaData(QtMediaServices::MetaData key, const QVariant &value); - QList availableMetaData() const; - - QVariant extendedMetaData(const QString &key) const; - void setExtendedMetaData(const QString &key, const QVariant &value); - QStringList availableExtendedMetaData() const; - - void updateGraph(IFilterGraph2 *graph, IBaseFilter *source); - -protected: - void customEvent(QEvent *event); - -private: - enum Event - { - MetaDataChanged = QEvent::User - }; - - IAMMediaContent *m_content; -#ifndef QT_NO_WMSDK - IWMHeaderInfo *m_headerInfo; -#endif -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.cpp deleted file mode 100644 index 02b1a3b..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowpinenum.h" - -#include - - -QT_BEGIN_NAMESPACE - -DirectShowPinEnum::DirectShowPinEnum(const QList &pins) - : m_ref(1) - , m_pins(pins) - , m_index(0) -{ - foreach (IPin *pin, m_pins) - pin->AddRef(); -} - -DirectShowPinEnum::~DirectShowPinEnum() -{ - foreach (IPin *pin, m_pins) - pin->Release(); -} - -HRESULT DirectShowPinEnum::QueryInterface(REFIID riid, void **ppvObject) -{ - if (riid == IID_IUnknown - || riid == IID_IEnumPins) { - AddRef(); - - *ppvObject = static_cast(this); - - return S_OK; - } else { - *ppvObject = 0; - - return E_NOINTERFACE; - } -} - -ULONG DirectShowPinEnum::AddRef() -{ - return InterlockedIncrement(&m_ref); -} - -ULONG DirectShowPinEnum::Release() -{ - ULONG ref = InterlockedDecrement(&m_ref); - - if (ref == 0) { - delete this; - } - - return ref; -} - -HRESULT DirectShowPinEnum::Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched) -{ - if (ppPins && (pcFetched || cPins == 1)) { - ULONG count = qBound(0, cPins, m_pins.count() - m_index); - - for (ULONG i = 0; i < count; ++i, ++m_index) { - ppPins[i] = m_pins.at(m_index); - ppPins[i]->AddRef(); - } - - if (pcFetched) - *pcFetched = count; - - return count == cPins ? S_OK : S_FALSE; - } else { - return E_POINTER; - } -} - -HRESULT DirectShowPinEnum::Skip(ULONG cPins) -{ - m_index = qMin(int(m_index + cPins), m_pins.count()); - - return m_index < m_pins.count() ? S_OK : S_FALSE; -} - -HRESULT DirectShowPinEnum::Reset() -{ - m_index = 0; - - return S_OK; -} - -HRESULT DirectShowPinEnum::Clone(IEnumPins **ppEnum) -{ - if (ppEnum) { - *ppEnum = new DirectShowPinEnum(m_pins); - - return S_OK; - } else { - return E_POINTER; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.h deleted file mode 100644 index 40d99ea..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWPINENUM_H -#define DIRECTSHOWPINENUM_H - -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowPinEnum : public IEnumPins -{ -public: - DirectShowPinEnum(const QList &pins); - ~DirectShowPinEnum(); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IEnumPins - HRESULT STDMETHODCALLTYPE Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched); - HRESULT STDMETHODCALLTYPE Skip(ULONG cPins); - HRESULT STDMETHODCALLTYPE Reset(); - HRESULT STDMETHODCALLTYPE Clone(IEnumPins **ppEnum); - -private: - LONG m_ref; - QList m_pins; - int m_index; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.cpp deleted file mode 100644 index 67d07e1..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.cpp +++ /dev/null @@ -1,395 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowplayercontrol.h" - -#include "directshowplayerservice.h" - -#include -#include - - -QT_BEGIN_NAMESPACE - -static int volumeToDecibels(int volume) -{ - if (volume == 0) { - return -10000; - } else if (volume == 100) { - return 0; -#ifdef QT_USE_MATH_H_FLOATS - } else if (sizeof(qreal) == sizeof(float)) { - return qRound(::log10f(float(volume) / 100) * 5000); -#endif - } else { - return qRound(::log10(qreal(volume) / 100) * 5000); - } -} - -static int decibelsToVolume(int dB) -{ - if (dB == -10000) { - return 0; - } else if (dB == 0) { - return 100; - } else { - return qRound(100 * qPow(10, qreal(dB) / 5000)); - } -} - -DirectShowPlayerControl::DirectShowPlayerControl(DirectShowPlayerService *service, QObject *parent) - : QMediaPlayerControl(parent) - , m_service(service) - , m_audio(0) - , m_updateProperties(0) - , m_state(QMediaPlayer::StoppedState) - , m_status(QMediaPlayer::UnknownMediaStatus) - , m_error(QMediaPlayer::NoError) - , m_streamTypes(0) - , m_muteVolume(-1) - , m_position(0) - , m_duration(0) - , m_playbackRate(1.0) - , m_seekable(false) -{ -} - -DirectShowPlayerControl::~DirectShowPlayerControl() -{ - if (m_audio) - m_audio->Release(); -} - -QMediaPlayer::State DirectShowPlayerControl::state() const -{ - return m_state; -} - -QMediaPlayer::MediaStatus DirectShowPlayerControl::mediaStatus() const -{ - return m_status; -} - -qint64 DirectShowPlayerControl::duration() const -{ - return m_duration; -} - -qint64 DirectShowPlayerControl::position() const -{ - return const_cast(m_position) = m_service->position(); -} - -void DirectShowPlayerControl::setPosition(qint64 position) -{ - m_service->seek(position); -} - -int DirectShowPlayerControl::volume() const -{ - if (m_muteVolume >= 0) { - return m_muteVolume; - } else if (m_audio) { - long dB = 0; - - m_audio->get_Volume(&dB); - - return decibelsToVolume(dB); - } else { - return 0; - } -} - -void DirectShowPlayerControl::setVolume(int volume) -{ - int boundedVolume = qBound(0, volume, 100); - - if (m_muteVolume >= 0) { - m_muteVolume = boundedVolume; - - emit volumeChanged(m_muteVolume); - } else if (m_audio) { - m_audio->put_Volume(volumeToDecibels(volume)); - - emit volumeChanged(boundedVolume); - } -} - -bool DirectShowPlayerControl::isMuted() const -{ - return m_muteVolume >= 0; -} - -void DirectShowPlayerControl::setMuted(bool muted) -{ - if (muted && m_muteVolume < 0) { - if (m_audio) { - long dB = 0; - - m_audio->get_Volume(&dB); - - m_muteVolume = decibelsToVolume(dB); - - m_audio->put_Volume(-10000); - } else { - m_muteVolume = 0; - } - - emit mutedChanged(muted); - } else if (!muted && m_muteVolume >= 0) { - if (m_audio) { - m_audio->put_Volume(volumeToDecibels(m_muteVolume)); - } - m_muteVolume = -1; - - emit mutedChanged(muted); - } -} - -int DirectShowPlayerControl::bufferStatus() const -{ - return m_service->bufferStatus(); -} - -bool DirectShowPlayerControl::isAudioAvailable() const -{ - return m_streamTypes & DirectShowPlayerService::AudioStream; -} - -bool DirectShowPlayerControl::isVideoAvailable() const -{ - return m_streamTypes & DirectShowPlayerService::VideoStream; -} - -bool DirectShowPlayerControl::isSeekable() const -{ - return m_seekable; -} - -QMediaTimeRange DirectShowPlayerControl::availablePlaybackRanges() const -{ - return m_service->availablePlaybackRanges(); -} - -qreal DirectShowPlayerControl::playbackRate() const -{ - return m_playbackRate; -} - -void DirectShowPlayerControl::setPlaybackRate(qreal rate) -{ - if (m_playbackRate != rate) { - m_service->setRate(rate); - - emit playbackRateChanged(m_playbackRate = rate); - } -} - -QMediaContent DirectShowPlayerControl::media() const -{ - return m_media; -} - -const QIODevice *DirectShowPlayerControl::mediaStream() const -{ - return m_stream; -} - -void DirectShowPlayerControl::setMedia(const QMediaContent &media, QIODevice *stream) -{ - m_media = media; - m_stream = stream; - - m_updateProperties &= PlaybackRateProperty; - - m_service->load(media, stream); - - emitPropertyChanges(); -} - -void DirectShowPlayerControl::play() -{ - m_service->play(); - emit stateChanged(m_state = QMediaPlayer::PlayingState); -} - -void DirectShowPlayerControl::pause() -{ - m_service->pause(); - emit stateChanged(m_state = QMediaPlayer::PausedState); -} - -void DirectShowPlayerControl::stop() -{ - m_service->stop(); - emit stateChanged(m_state = QMediaPlayer::StoppedState); -} - -void DirectShowPlayerControl::customEvent(QEvent *event) -{ - if (event->type() == QEvent::Type(PropertiesChanged)) { - emitPropertyChanges(); - - event->accept(); - } else { - QMediaPlayerControl::customEvent(event); - } -} - -void DirectShowPlayerControl::emitPropertyChanges() -{ - int properties = m_updateProperties; - m_updateProperties = 0; - - if ((properties & ErrorProperty) && m_error != QMediaPlayer::NoError) - emit error(m_error, m_errorString); - - if (properties & PlaybackRateProperty) - emit playbackRateChanged(m_playbackRate); - - if (properties & StreamTypesProperty) { - emit audioAvailableChanged(m_streamTypes & DirectShowPlayerService::AudioStream); - emit videoAvailableChanged(m_streamTypes & DirectShowPlayerService::VideoStream); - } - - if (properties & PositionProperty) - emit positionChanged(m_position); - - if (properties & DurationProperty) - emit durationChanged(m_duration); - - if (properties & SeekableProperty) - emit seekableChanged(m_seekable); - - if (properties & StatusProperty) - emit mediaStatusChanged(m_status); - - if (properties & StateProperty) - emit stateChanged(m_state); -} - -void DirectShowPlayerControl::scheduleUpdate(int properties) -{ - if (m_updateProperties == 0) - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(PropertiesChanged))); - - m_updateProperties |= properties; -} - -void DirectShowPlayerControl::updateState(QMediaPlayer::State state) -{ - if (m_state != state) { - m_state = state; - - scheduleUpdate(StateProperty); - } -} - -void DirectShowPlayerControl::updateStatus(QMediaPlayer::MediaStatus status) -{ - if (m_status != status) { - m_status = status; - - scheduleUpdate(StatusProperty); - } -} - -void DirectShowPlayerControl::updateMediaInfo(qint64 duration, int streamTypes, bool seekable) -{ - int properties = 0; - - if (m_duration != duration) { - m_duration = duration; - - properties |= DurationProperty; - } - if (m_streamTypes != streamTypes) { - m_streamTypes = streamTypes; - - properties |= StreamTypesProperty; - } - - if (m_seekable != seekable) { - m_seekable = seekable; - - properties |= SeekableProperty; - } - - if (properties != 0) - scheduleUpdate(properties); -} - -void DirectShowPlayerControl::updatePlaybackRate(qreal rate) -{ - if (m_playbackRate != rate) { - m_playbackRate = rate; - - scheduleUpdate(PlaybackRateProperty); - } -} - -void DirectShowPlayerControl::updateAudioOutput(IBaseFilter *filter) -{ - if (m_audio) - m_audio->Release(); - - m_audio = com_cast(filter, IID_IBasicAudio); -} - -void DirectShowPlayerControl::updateError(QMediaPlayer::Error error, const QString &errorString) -{ - m_error = error; - m_errorString = errorString; - - if (m_error != QMediaPlayer::NoError) - scheduleUpdate(ErrorProperty); -} - -void DirectShowPlayerControl::updatePosition(qint64 position) -{ - if (m_position != position) { - m_position = position; - - scheduleUpdate(PositionProperty); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.h deleted file mode 100644 index 6b5203e..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.h +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWPLAYERCONTROL_H -#define DIRECTSHOWPLAYERCONTROL_H - -#include -#include - -#include - -#include "directshowplayerservice.h" - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowPlayerControl : public QMediaPlayerControl -{ - Q_OBJECT -public: - DirectShowPlayerControl(DirectShowPlayerService *service, QObject *parent = 0); - ~DirectShowPlayerControl(); - - QMediaPlayer::State state() const; - - QMediaPlayer::MediaStatus mediaStatus() const; - - qint64 duration() const; - - qint64 position() const; - void setPosition(qint64 position); - - int volume() const; - void setVolume(int volume); - - bool isMuted() const; - void setMuted(bool muted); - - int bufferStatus() const; - - bool isAudioAvailable() const; - bool isVideoAvailable() const; - - bool isSeekable() const; - - QMediaTimeRange availablePlaybackRanges() const; - - qreal playbackRate() const; - void setPlaybackRate(qreal rate); - - QMediaContent media() const; - const QIODevice *mediaStream() const; - void setMedia(const QMediaContent &media, QIODevice *stream); - - void play(); - void pause(); - void stop(); - - void updateState(QMediaPlayer::State state); - void updateStatus(QMediaPlayer::MediaStatus status); - void updateMediaInfo(qint64 duration, int streamTypes, bool seekable); - void updatePlaybackRate(qreal rate); - void updateAudioOutput(IBaseFilter *filter); - void updateError(QMediaPlayer::Error error, const QString &errorString); - void updatePosition(qint64 position); - -protected: - void customEvent(QEvent *event); - -private: - enum Properties - { - StateProperty = 0x01, - StatusProperty = 0x02, - StreamTypesProperty = 0x04, - DurationProperty = 0x08, - PlaybackRateProperty = 0x10, - SeekableProperty = 0x20, - ErrorProperty = 0x40, - PositionProperty = 0x80 - }; - - enum Event - { - PropertiesChanged = QEvent::User - }; - - void scheduleUpdate(int properties); - void emitPropertyChanges(); - - DirectShowPlayerService *m_service; - IBasicAudio *m_audio; - QIODevice *m_stream; - int m_updateProperties; - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_status; - QMediaPlayer::Error m_error; - int m_streamTypes; - int m_muteVolume; - qint64 m_position; - qint64 m_duration; - qreal m_playbackRate; - bool m_seekable; - QMediaContent m_media; - QString m_errorString; - -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp deleted file mode 100644 index 8ad8cff..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp +++ /dev/null @@ -1,1410 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowplayerservice.h" - -#include "directshowaudioendpointcontrol.h" -#include "directshowiosource.h" -#include "directshowmetadatacontrol.h" -#include "directshowplayercontrol.h" -#include "directshowvideooutputcontrol.h" -#include "directshowvideorenderercontrol.h" -#include "vmr9videowindowcontrol.h" - -#include - -#include -#include -#include -#include - -Q_GLOBAL_STATIC(DirectShowEventLoop, qt_directShowEventLoop) - -QT_BEGIN_NAMESPACE - -class DirectShowPlayerServiceThread : public QThread -{ -public: - DirectShowPlayerServiceThread(DirectShowPlayerService *service) - : m_service(service) - { - } - -protected: - void run() { m_service->run(); } - -private: - DirectShowPlayerService *m_service; -}; - -DirectShowPlayerService::DirectShowPlayerService(QObject *parent) - : QMediaService(parent) - , m_playerControl(0) - , m_metaDataControl(0) - , m_videoOutputControl(0) - , m_videoRendererControl(0) - , m_videoWindowControl(0) - , m_audioEndpointControl(0) - , m_taskThread(0) - , m_loop(qt_directShowEventLoop()) - , m_pendingTasks(0) - , m_executingTask(0) - , m_executedTasks(0) - , m_taskHandle(::CreateEvent(0, 0, 0, 0)) - , m_eventHandle(0) - , m_graphStatus(NoMedia) - , m_stream(0) - , m_graph(0) - , m_source(0) - , m_audioOutput(0) - , m_videoOutput(0) - , m_rate(1.0) - , m_position(0) - , m_duration(0) - , m_buffering(false) - , m_seekable(false) - , m_atEnd(false) -{ - m_playerControl = new DirectShowPlayerControl(this); - m_metaDataControl = new DirectShowMetaDataControl(this); - m_videoOutputControl = new DirectShowVideoOutputControl; - m_audioEndpointControl = new DirectShowAudioEndpointControl(this); - m_videoRendererControl = new DirectShowVideoRendererControl(m_loop); - m_videoWindowControl = new Vmr9VideoWindowControl; - - m_taskThread = new DirectShowPlayerServiceThread(this); - m_taskThread->start(); - - connect(m_videoOutputControl, SIGNAL(outputChanged()), this, SLOT(videoOutputChanged())); - connect(m_videoRendererControl, SIGNAL(filterChanged()), this, SLOT(videoOutputChanged())); -} - -DirectShowPlayerService::~DirectShowPlayerService() -{ - { - QMutexLocker locker(&m_mutex); - - releaseGraph(); - - m_pendingTasks = Shutdown; - ::SetEvent(m_taskHandle); - } - - m_taskThread->wait(); - delete m_taskThread; - - if (m_audioOutput) { - m_audioOutput->Release(); - m_audioOutput = 0; - } - - if (m_videoOutput) { - m_videoOutput->Release(); - m_videoOutput = 0; - } - - delete m_playerControl; - delete m_audioEndpointControl; - delete m_metaDataControl; - delete m_videoOutputControl; - delete m_videoRendererControl; - delete m_videoWindowControl; - - ::CloseHandle(m_taskHandle); -} - -QMediaControl *DirectShowPlayerService::control(const char *name) const -{ - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return m_playerControl; - else if (qstrcmp(name, QAudioEndpointSelector_iid) == 0) - return m_audioEndpointControl; - else if (qstrcmp(name, QMetaDataControl_iid) == 0) - return m_metaDataControl; - else if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return m_videoOutputControl; - else if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return m_videoRendererControl; - else if (qstrcmp(name, QVideoWindowControl_iid) == 0) - return m_videoWindowControl; - else - return 0; -} - -void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream) -{ - QMutexLocker locker(&m_mutex); - - m_pendingTasks = 0; - - if (m_graph) - releaseGraph(); - - m_resources = media.resources(); - m_stream = stream; - m_error = QMediaPlayer::NoError; - m_errorString = QString(); - m_position = 0; - m_duration = 0; - m_streamTypes = 0; - m_executedTasks = 0; - m_buffering = false; - m_seekable = false; - m_atEnd = false; - m_metaDataControl->updateGraph(0, 0); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(VideoOutputChange))); - - if (m_resources.isEmpty() && !stream) { - m_pendingTasks = 0; - m_graphStatus = NoMedia; - - m_url.clear(); - } else if (stream && (!stream->isReadable() || stream->isSequential())) { - m_pendingTasks = 0; - m_graphStatus = InvalidMedia; - m_error = QMediaPlayer::ResourceError; - } else { - // {36b73882-c2c8-11cf-8b46-00805f6cef60} - static const GUID iid_IFilterGraph2 = { - 0x36b73882, 0xc2c8, 0x11cf, {0x8b, 0x46, 0x00, 0x80, 0x5f, 0x6c, 0xef, 0x60} }; - m_graphStatus = Loading; - - m_graph = com_new(CLSID_FilterGraph, iid_IFilterGraph2); - - if (stream) - m_pendingTasks = SetStreamSource; - else - m_pendingTasks = SetUrlSource; - - ::SetEvent(m_taskHandle); - } - - m_playerControl->updateError(m_error, m_errorString); - m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); - m_playerControl->updateState(QMediaPlayer::StoppedState); - m_playerControl->updatePosition(m_position); - updateStatus(); -} - -void DirectShowPlayerService::doSetUrlSource(QMutexLocker *locker) -{ - IBaseFilter *source = 0; - - QMediaResource resource = m_resources.takeFirst(); - QUrl url = resource.url(); - - HRESULT hr = E_FAIL; - - if (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("https")) { - static const GUID clsid_WMAsfReader = { - 0x187463a0, 0x5bb7, 0x11d3, {0xac, 0xbe, 0x00, 0x80, 0xc7, 0x5e, 0x24, 0x6e} }; - - // {56a868a6-0ad4-11ce-b03a-0020af0ba770} - static const GUID iid_IFileSourceFilter = { - 0x56a868a6, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70} }; - - if (IFileSourceFilter *fileSource = com_new( - clsid_WMAsfReader, iid_IFileSourceFilter)) { - locker->unlock(); - hr = fileSource->Load(reinterpret_cast(url.toString().utf16()), 0); - locker->relock(); - - if (SUCCEEDED(hr)) { - source = com_cast(fileSource, IID_IBaseFilter); - - if (!SUCCEEDED(hr = m_graph->AddFilter(source, L"Source")) && source) { - source->Release(); - source = 0; - } - } - - fileSource->Release(); - } - } else if (url.scheme() == QLatin1String("qrc")) { - DirectShowRcSource *rcSource = new DirectShowRcSource(m_loop); - - if (rcSource->open(url) && SUCCEEDED(hr = m_graph->AddFilter(rcSource, L"Source"))) - source = rcSource; - else - rcSource->Release(); - } - - if (!SUCCEEDED(hr)) { - locker->unlock(); - hr = m_graph->AddSourceFilter( - reinterpret_cast(url.toString().utf16()), L"Source", &source); - locker->relock(); - } - - if (SUCCEEDED(hr)) { - m_executedTasks |= SetSource; - m_pendingTasks |= Render; - - if (m_audioOutput) - m_pendingTasks |= SetAudioOutput; - if (m_videoOutput) - m_pendingTasks |= SetVideoOutput; - - if (m_rate != 1.0 && m_rate != 0.0) - m_pendingTasks |= SetRate; - - m_source = source; - } else if (!m_resources.isEmpty()) { - m_pendingTasks |= SetUrlSource; - } else { - m_pendingTasks = 0; - m_graphStatus = InvalidMedia; - - switch (hr) { - case VFW_E_UNKNOWN_FILE_TYPE: - m_error = QMediaPlayer::FormatError; - m_errorString = QString(); - break; - case E_OUTOFMEMORY: - case VFW_E_CANNOT_LOAD_SOURCE_FILTER: - case VFW_E_NOT_FOUND: - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - default: - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - qWarning("DirectShowPlayerService::doSetUrlSource: Unresolved error code %x", uint(hr)); - break; - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(Error))); - } -} - -void DirectShowPlayerService::doSetStreamSource(QMutexLocker *locker) -{ - DirectShowIOSource *source = new DirectShowIOSource(m_loop); - source->setDevice(m_stream); - - if (SUCCEEDED(m_graph->AddFilter(source, L"Source"))) { - m_executedTasks |= SetSource; - m_pendingTasks |= Render; - - if (m_audioOutput) - m_pendingTasks |= SetAudioOutput; - if (m_videoOutput) - m_pendingTasks |= SetVideoOutput; - - if (m_rate != 1.0 && m_rate != 0.0) - m_pendingTasks |= SetRate; - - m_source = source; - } else { - source->Release(); - - m_pendingTasks = 0; - m_graphStatus = InvalidMedia; - - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(Error))); - } -} - -void DirectShowPlayerService::doRender(QMutexLocker *locker) -{ - if (m_executedTasks & Pause) - m_pendingTasks |= Pause; - else if (m_executedTasks & Play && m_rate != 0.0) - m_pendingTasks |= Play; - - if (IMediaControl *control = com_cast(m_graph, IID_IMediaControl)) { - control->Stop(); - control->Release(); - } - - if (m_pendingTasks & SetAudioOutput) { - m_graph->AddFilter(m_audioOutput, L"AudioOutput"); - - m_pendingTasks ^= SetAudioOutput; - m_executedTasks |= SetAudioOutput; - } - if (m_pendingTasks & SetVideoOutput) { - m_graph->AddFilter(m_videoOutput, L"VideoOutput"); - - m_pendingTasks ^= SetVideoOutput; - m_executedTasks |= SetVideoOutput; - } - - IFilterGraph2 *graph = m_graph; - graph->AddRef(); - - QVarLengthArray filters; - m_source->AddRef(); - filters.append(m_source); - - bool rendered = false; - - HRESULT renderHr = S_OK; - - while (!filters.isEmpty()) { - IEnumPins *pins = 0; - IBaseFilter *filter = filters[filters.size() - 1]; - filters.removeLast(); - - if (!(m_pendingTasks & ReleaseFilters) && SUCCEEDED(filter->EnumPins(&pins))) { - int outputs = 0; - for (IPin *pin = 0; pins->Next(1, &pin, 0) == S_OK; pin->Release()) { - PIN_DIRECTION direction; - if (pin->QueryDirection(&direction) == S_OK && direction == PINDIR_OUTPUT) { - ++outputs; - - IPin *peer = 0; - if (pin->ConnectedTo(&peer) == S_OK) { - PIN_INFO peerInfo; - if (SUCCEEDED(peer->QueryPinInfo(&peerInfo))) - filters.append(peerInfo.pFilter); - peer->Release(); - } else { - locker->unlock(); - HRESULT hr; - if (SUCCEEDED(hr = graph->RenderEx( - pin, /*AM_RENDEREX_RENDERTOEXISTINGRENDERERS*/ 1, 0))) { - rendered = true; - } else if (renderHr == S_OK || renderHr == VFW_E_NO_DECOMPRESSOR){ - renderHr = hr; - } - locker->relock(); - } - } - } - - pins->Release(); - - if (outputs == 0) - rendered = true; - } - filter->Release(); - } - - if (m_audioOutput && !isConnected(m_audioOutput, PINDIR_INPUT)) { - graph->RemoveFilter(m_audioOutput); - - m_executedTasks &= ~SetAudioOutput; - } - - if (m_videoOutput && !isConnected(m_videoOutput, PINDIR_INPUT)) { - graph->RemoveFilter(m_videoOutput); - - m_executedTasks &= ~SetVideoOutput; - } - - graph->Release(); - - if (!(m_pendingTasks & ReleaseFilters)) { - if (rendered) { - if (!(m_executedTasks & FinalizeLoad)) - m_pendingTasks |= FinalizeLoad; - } else { - m_pendingTasks = 0; - - m_graphStatus = InvalidMedia; - - if (!m_audioOutput && !m_videoOutput) { - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - } else { - switch (renderHr) { - case VFW_E_UNSUPPORTED_AUDIO: - case VFW_E_UNSUPPORTED_VIDEO: - case VFW_E_UNSUPPORTED_STREAM: - m_error = QMediaPlayer::FormatError; - m_errorString = QString(); - default: - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - qWarning("DirectShowPlayerService::doRender: Unresolved error code %x", - uint(renderHr)); - } - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(Error))); - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(VideoOutputChange))); - - m_executedTasks |= Render; - } -} - -void DirectShowPlayerService::doFinalizeLoad(QMutexLocker *locker) -{ - if (m_graphStatus != Loaded) { - if (IMediaEvent *event = com_cast(m_graph, IID_IMediaEvent)) { - event->GetEventHandle(reinterpret_cast(&m_eventHandle)); - event->Release(); - } - if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { - LONGLONG duration = 0; - seeking->GetDuration(&duration); - m_duration = duration / 10; - - DWORD capabilities = 0; - seeking->GetCapabilities(&capabilities); - m_seekable = capabilities & AM_SEEKING_CanSeekAbsolute; - - seeking->Release(); - } - } - - if ((m_executedTasks & SetOutputs) == SetOutputs) { - m_streamTypes = AudioStream | VideoStream; - } else { - m_streamTypes = findStreamTypes(m_source); - } - - m_executedTasks |= FinalizeLoad; - - m_graphStatus = Loaded; - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(FinalizedLoad))); -} - -void DirectShowPlayerService::releaseGraph() -{ - if (m_graph) { - if (m_executingTask != 0) { - // {8E1C39A1-DE53-11cf-AA63-0080C744528D} - static const GUID iid_IAMOpenProgress = { - 0x8E1C39A1, 0xDE53, 0x11cf, {0xAA, 0x63, 0x00, 0x80, 0xC7, 0x44, 0x52, 0x8D} }; - - if (IAMOpenProgress *progress = com_cast( - m_graph, iid_IAMOpenProgress)) { - progress->AbortOperation(); - progress->Release(); - } - m_graph->Abort(); - } - - m_pendingTasks = ReleaseGraph; - - ::SetEvent(m_taskHandle); - - m_loop->wait(&m_mutex); - } -} - -void DirectShowPlayerService::doReleaseGraph(QMutexLocker *locker) -{ - Q_UNUSED(locker); - - if (IMediaControl *control = com_cast(m_graph, IID_IMediaControl)) { - control->Stop(); - control->Release(); - } - - if (m_source) { - m_source->Release(); - m_source = 0; - } - - m_eventHandle = 0; - - m_graph->Release(); - m_graph = 0; - - m_loop->wake(); -} - -int DirectShowPlayerService::findStreamTypes(IBaseFilter *source) const -{ - QVarLengthArray filters; - source->AddRef(); - filters.append(source); - - int streamTypes = 0; - - while (!filters.isEmpty()) { - IEnumPins *pins = 0; - IBaseFilter *filter = filters[filters.size() - 1]; - filters.removeLast(); - - if (SUCCEEDED(filter->EnumPins(&pins))) { - for (IPin *pin = 0; pins->Next(1, &pin, 0) == S_OK; pin->Release()) { - PIN_DIRECTION direction; - if (pin->QueryDirection(&direction) == S_OK && direction == PINDIR_OUTPUT) { - AM_MEDIA_TYPE connectionType; - if (SUCCEEDED(pin->ConnectionMediaType(&connectionType))) { - IPin *peer = 0; - - if (connectionType.majortype == MEDIATYPE_Audio) { - streamTypes |= AudioStream; - } else if (connectionType.majortype == MEDIATYPE_Video) { - streamTypes |= VideoStream; - } else if (SUCCEEDED(pin->ConnectedTo(&peer))) { - PIN_INFO peerInfo; - if (SUCCEEDED(peer->QueryPinInfo(&peerInfo))) - filters.append(peerInfo.pFilter); - peer->Release(); - } - } else { - streamTypes |= findStreamType(pin); - } - } - } - } - filter->Release(); - } - return streamTypes; -} - -int DirectShowPlayerService::findStreamType(IPin *pin) const -{ - IEnumMediaTypes *types; - - if (SUCCEEDED(pin->EnumMediaTypes(&types))) { - bool video = false; - bool audio = false; - bool other = false; - - for (AM_MEDIA_TYPE *type = 0; - types->Next(1, &type, 0) == S_OK; - DirectShowMediaType::deleteType(type)) { - if (type->majortype == MEDIATYPE_Audio) - audio = true; - else if (type->majortype == MEDIATYPE_Video) - video = true; - else - other = true; - } - types->Release(); - - if (other) - return 0; - else if (audio && !video) - return AudioStream; - else if (!audio && video) - return VideoStream; - else - return 0; - } else { - return 0; - } -} - -void DirectShowPlayerService::play() -{ - QMutexLocker locker(&m_mutex); - - if (m_rate != 0.0) { - m_pendingTasks &= ~Pause; - m_pendingTasks |= Play; - } else { - m_pendingTasks |= Pause; - m_executedTasks |= Play; - } - - if (m_executedTasks & Render) { - if (m_executedTasks & Stop) { - m_atEnd = false; - m_position = 0; - m_pendingTasks |= Seek; - m_executedTasks ^= Stop; - } - - ::SetEvent(m_taskHandle); - } -} - -void DirectShowPlayerService::doPlay(QMutexLocker *locker) -{ - if (IMediaControl *control = com_cast(m_graph, IID_IMediaControl)) { - locker->unlock(); - HRESULT hr = control->Run(); - locker->relock(); - - control->Release(); - - if (SUCCEEDED(hr)) { - m_executedTasks |= Play; - m_executedTasks &= ~Pause; - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(StatusChange))); - } else { - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - qWarning("DirectShowPlayerService::doPlay: Unresolved error code %x", uint(hr)); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(Error))); - } - } -} - -void DirectShowPlayerService::pause() -{ - QMutexLocker locker(&m_mutex); - - m_pendingTasks &= ~Play; - m_pendingTasks |= Pause; - - if (m_executedTasks & Render) { - if (m_executedTasks & Stop) { - m_atEnd = false; - m_position = 0; - m_pendingTasks |= Seek; - m_executedTasks ^= Stop; - } - - ::SetEvent(m_taskHandle); - } -} - -void DirectShowPlayerService::doPause(QMutexLocker *locker) -{ - if (IMediaControl *control = com_cast(m_graph, IID_IMediaControl)) { - locker->unlock(); - HRESULT hr = control->Pause(); - locker->relock(); - - control->Release(); - - if (SUCCEEDED(hr)) { - if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { - LONGLONG position = 0; - - seeking->GetCurrentPosition(&position); - seeking->Release(); - - m_position = position / 10; - } else { - m_position = 0; - } - - m_executedTasks |= Pause; - - if (m_rate != 0.0) - m_executedTasks &= ~Play; - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(StatusChange))); - } else { - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - qWarning("DirectShowPlayerService::doPause: Unresolved error code %x", uint(hr)); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(Error))); - } - } -} - -void DirectShowPlayerService::stop() -{ - QMutexLocker locker(&m_mutex); - - m_pendingTasks &= ~(Play | Pause | Seek); - - if ((m_executingTask | m_executedTasks) & (Play | Pause | Seek)) { - m_pendingTasks |= Stop; - - ::SetEvent(m_taskHandle); - - m_loop->wait(&m_mutex); - } - -} - -void DirectShowPlayerService::doStop(QMutexLocker *locker) -{ - if (m_executedTasks & (Play | Pause)) { - if (IMediaControl *control = com_cast(m_graph, IID_IMediaControl)) { - control->Stop(); - control->Release(); - } - - if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { - LONGLONG position = 0; - - seeking->GetCurrentPosition(&position); - seeking->Release(); - - m_position = position / 10; - } else { - m_position = 0; - } - - m_executedTasks &= ~(Play | Pause); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(StatusChange))); - } - - m_executedTasks |= Stop; - - m_loop->wake(); -} - -void DirectShowPlayerService::setRate(qreal rate) -{ - QMutexLocker locker(&m_mutex); - - if (m_rate == rate) - return; - - if (rate == 0.0) { - if (m_pendingTasks & Play) { - m_executedTasks |= Play; - m_pendingTasks &= ~(Play | SetRate); - - if (!((m_executingTask | m_executedTasks) & Pause)) - m_pendingTasks |= Pause; - } else if ((m_executingTask | m_executedTasks) & Play) { - m_pendingTasks |= Pause; - } - } else { - m_pendingTasks |= SetRate; - - if (m_rate == 0.0 && (m_executedTasks & Play) && !(m_executingTask & Play)) - m_pendingTasks |= Play; - } - - m_rate = rate; - - if (m_executedTasks & FinalizeLoad) - ::SetEvent(m_taskHandle); -} - -void DirectShowPlayerService::doSetRate(QMutexLocker *locker) -{ - if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { - // Cache current values as we can't query IMediaSeeking during a seek due to the - // possibility of a deadlock when flushing the VideoSurfaceFilter. - LONGLONG currentPosition = 0; - seeking->GetCurrentPosition(¤tPosition); - m_position = currentPosition / 10; - - LONGLONG minimum = 0; - LONGLONG maximum = 0; - m_playbackRange = SUCCEEDED(seeking->GetAvailable(&minimum, &maximum)) - ? QMediaTimeRange(minimum / 10, maximum / 10) - : QMediaTimeRange(); - - locker->unlock(); - HRESULT hr = seeking->SetRate(m_rate); - locker->relock(); - - if (!SUCCEEDED(hr)) { - double rate = 0.0; - m_rate = seeking->GetRate(&rate) - ? rate - : 1.0; - } - - seeking->Release(); - } else if (m_rate != 1.0) { - m_rate = 1.0; - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(RateChange))); -} - -qint64 DirectShowPlayerService::position() const -{ - QMutexLocker locker(const_cast(&m_mutex)); - - if (m_graphStatus == Loaded) { - if (m_executingTask == Seek || m_executingTask == SetRate) { - return m_position; - } else if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { - LONGLONG position = 0; - - seeking->GetCurrentPosition(&position); - seeking->Release(); - - const_cast(m_position) = position / 10; - - return m_position; - } - } - return 0; -} - -QMediaTimeRange DirectShowPlayerService::availablePlaybackRanges() const -{ - QMutexLocker locker(const_cast(&m_mutex)); - - if (m_graphStatus == Loaded) { - if (m_executingTask == Seek || m_executingTask == SetRate) { - return m_playbackRange; - } else if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { - LONGLONG minimum = 0; - LONGLONG maximum = 0; - - HRESULT hr = seeking->GetAvailable(&minimum, &maximum); - seeking->Release(); - - if (SUCCEEDED(hr)) - return QMediaTimeRange(minimum, maximum); - } - } - return QMediaTimeRange(); -} - -void DirectShowPlayerService::seek(qint64 position) -{ - QMutexLocker locker(&m_mutex); - - m_position = position; - - m_pendingTasks |= Seek; - - if (m_executedTasks & FinalizeLoad) - ::SetEvent(m_taskHandle); -} - -void DirectShowPlayerService::doSeek(QMutexLocker *locker) -{ - if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { - LONGLONG seekPosition = LONGLONG(m_position) * 10; - - // Cache current values as we can't query IMediaSeeking during a seek due to the - // possibility of a deadlock when flushing the VideoSurfaceFilter. - LONGLONG currentPosition = 0; - seeking->GetCurrentPosition(¤tPosition); - m_position = currentPosition / 10; - - LONGLONG minimum = 0; - LONGLONG maximum = 0; - m_playbackRange = SUCCEEDED(seeking->GetAvailable(&minimum, &maximum)) - ? QMediaTimeRange(minimum / 10, maximum / 10) - : QMediaTimeRange(); - - locker->unlock(); - seeking->SetPositions( - &seekPosition, AM_SEEKING_AbsolutePositioning, 0, AM_SEEKING_NoPositioning); - locker->relock(); - - seeking->GetCurrentPosition(¤tPosition); - m_position = currentPosition / 10; - - seeking->Release(); - } else { - m_position = 0; - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(PositionChange))); -} - -int DirectShowPlayerService::bufferStatus() const -{ -#ifndef QT_NO_WMSDK - QMutexLocker locker(const_cast(&m_mutex)); - - if (IWMReaderAdvanced2 *reader = com_cast( - m_source, IID_IWMReaderAdvanced2)) { - DWORD percentage = 0; - - reader->GetBufferProgress(&percentage, 0); - reader->Release(); - - return percentage; - } else { - return 0; - } -#else - return 0; -#endif -} - -void DirectShowPlayerService::setAudioOutput(IBaseFilter *filter) -{ - QMutexLocker locker(&m_mutex); - - if (m_graph) { - if (m_audioOutput) { - if (m_executedTasks & SetAudioOutput) { - m_pendingTasks |= ReleaseAudioOutput; - - ::SetEvent(m_taskHandle); - - m_loop->wait(&m_mutex); - } - m_audioOutput->Release(); - } - - m_audioOutput = filter; - - if (m_audioOutput) { - m_audioOutput->AddRef(); - - m_pendingTasks |= SetAudioOutput; - - if (m_executedTasks & SetSource) { - m_pendingTasks |= Render; - - ::SetEvent(m_taskHandle); - } - } else { - m_pendingTasks &= ~ SetAudioOutput; - } - } else { - if (m_audioOutput) - m_audioOutput->Release(); - - m_audioOutput = filter; - - if (m_audioOutput) - m_audioOutput->AddRef(); - } - - m_playerControl->updateAudioOutput(m_audioOutput); -} - -void DirectShowPlayerService::doReleaseAudioOutput(QMutexLocker *locker) -{ - m_pendingTasks |= m_executedTasks & (Play | Pause); - - if (IMediaControl *control = com_cast(m_graph, IID_IMediaControl)) { - control->Stop(); - control->Release(); - } - - IBaseFilter *decoder = getConnected(m_audioOutput, PINDIR_INPUT); - if (!decoder) { - decoder = m_audioOutput; - decoder->AddRef(); - } - - // {DCFBDCF6-0DC2-45f5-9AB2-7C330EA09C29} - static const GUID iid_IFilterChain = { - 0xDCFBDCF6, 0x0DC2, 0x45f5, {0x9A, 0xB2, 0x7C, 0x33, 0x0E, 0xA0, 0x9C, 0x29} }; - - if (IFilterChain *chain = com_cast(m_graph, iid_IFilterChain)) { - chain->RemoveChain(decoder, m_audioOutput); - chain->Release(); - } else { - m_graph->RemoveFilter(m_audioOutput); - } - - decoder->Release(); - - m_executedTasks &= ~SetAudioOutput; - - m_loop->wake(); -} - -void DirectShowPlayerService::setVideoOutput(IBaseFilter *filter) -{ - QMutexLocker locker(&m_mutex); - - if (m_graph) { - if (m_videoOutput) { - if (m_executedTasks & SetVideoOutput) { - m_pendingTasks |= ReleaseVideoOutput; - - ::SetEvent(m_taskHandle); - - m_loop->wait(&m_mutex); - } - m_videoOutput->Release(); - } - - m_videoOutput = filter; - - if (m_videoOutput) { - m_videoOutput->AddRef(); - - m_pendingTasks |= SetVideoOutput; - - if (m_executedTasks & SetSource) { - m_pendingTasks |= Render; - - ::SetEvent(m_taskHandle); - } - } - } else { - if (m_videoOutput) - m_videoOutput->Release(); - - m_videoOutput = filter; - - if (m_videoOutput) - m_videoOutput->AddRef(); - } -} - -void DirectShowPlayerService::doReleaseVideoOutput(QMutexLocker *locker) -{ - m_pendingTasks |= m_executedTasks & (Play | Pause); - - if (IMediaControl *control = com_cast(m_graph, IID_IMediaControl)) { - control->Stop(); - control->Release(); - } - - IBaseFilter *intermediate = 0; - if (!SUCCEEDED(m_graph->FindFilterByName(L"Color Space Converter", &intermediate))) { - intermediate = m_videoOutput; - intermediate->AddRef(); - } - - IBaseFilter *decoder = getConnected(intermediate, PINDIR_INPUT); - if (!decoder) { - decoder = intermediate; - decoder->AddRef(); - } - - // {DCFBDCF6-0DC2-45f5-9AB2-7C330EA09C29} - static const GUID iid_IFilterChain = { - 0xDCFBDCF6, 0x0DC2, 0x45f5, {0x9A, 0xB2, 0x7C, 0x33, 0x0E, 0xA0, 0x9C, 0x29} }; - - if (IFilterChain *chain = com_cast(m_graph, iid_IFilterChain)) { - chain->RemoveChain(decoder, m_videoOutput); - chain->Release(); - } else { - m_graph->RemoveFilter(m_videoOutput); - } - - intermediate->Release(); - decoder->Release(); - - m_executedTasks &= ~SetVideoOutput; - - m_loop->wake(); -} - -void DirectShowPlayerService::customEvent(QEvent *event) -{ - if (event->type() == QEvent::Type(FinalizedLoad)) { - QMutexLocker locker(&m_mutex); - - m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); - m_metaDataControl->updateGraph(m_graph, m_source); - - updateStatus(); - } else if (event->type() == QEvent::Type(Error)) { - QMutexLocker locker(&m_mutex); - - if (m_error != QMediaPlayer::NoError) { - m_playerControl->updateError(m_error, m_errorString); - m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); - m_playerControl->updateState(QMediaPlayer::StoppedState); - updateStatus(); - } - } else if (event->type() == QEvent::Type(RateChange)) { - QMutexLocker locker(&m_mutex); - - m_playerControl->updatePlaybackRate(m_rate); - } else if (event->type() == QEvent::Type(StatusChange)) { - QMutexLocker locker(&m_mutex); - - updateStatus(); - m_playerControl->updatePosition(m_position); - } else if (event->type() == QEvent::Type(DurationChange)) { - QMutexLocker locker(&m_mutex); - - m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); - } else if (event->type() == QEvent::Type(EndOfMedia)) { - QMutexLocker locker(&m_mutex); - - if (m_atEnd) { - m_playerControl->updateState(QMediaPlayer::StoppedState); - m_playerControl->updateStatus(QMediaPlayer::EndOfMedia); - m_playerControl->updatePosition(m_position); - } - } else if (event->type() == QEvent::Type(PositionChange)) { - QMutexLocker locker(&m_mutex); - - m_playerControl->updatePosition(m_position); - } else if (event->type() == QEvent::Type(VideoOutputChange)) { - if (m_videoWindowControl) - m_videoWindowControl->updateNativeSize(); - } else { - QMediaService::customEvent(event); - } -} - -void DirectShowPlayerService::videoOutputChanged() -{ - IBaseFilter *videoOutput = 0; - - switch (m_videoOutputControl->output()) { - case QVideoOutputControl::RendererOutput: - videoOutput = m_videoRendererControl->filter(); - break; - case QVideoOutputControl::WindowOutput: - videoOutput = m_videoWindowControl->filter(); - break; - default: - break; - } - - setVideoOutput(videoOutput); -} - -void DirectShowPlayerService::graphEvent(QMutexLocker *locker) -{ - if (IMediaEvent *event = com_cast(m_graph, IID_IMediaEvent)) { - long eventCode; - LONG_PTR param1; - LONG_PTR param2; - - while (event->GetEvent(&eventCode, ¶m1, ¶m2, 0) == S_OK) { - switch (eventCode) { - case EC_BUFFERING_DATA: - m_buffering = param1; - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(StatusChange))); - break; - case EC_COMPLETE: - m_executedTasks &= ~(Play | Pause); - m_executedTasks |= Stop; - - m_buffering = false; - m_atEnd = true; - - if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { - LONGLONG position = 0; - - seeking->GetCurrentPosition(&position); - seeking->Release(); - - m_position = position / 10; - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(EndOfMedia))); - break; - case EC_LENGTH_CHANGED: - if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { - LONGLONG duration = 0; - seeking->GetDuration(&duration); - m_duration = duration / 10; - - DWORD capabilities = 0; - seeking->GetCapabilities(&capabilities); - m_seekable = capabilities & AM_SEEKING_CanSeekAbsolute; - - seeking->Release(); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(DurationChange))); - } - break; - default: - break; - } - - event->FreeEventParams(eventCode, param1, param2); - } - event->Release(); - } -} - -void DirectShowPlayerService::updateStatus() -{ - switch (m_graphStatus) { - case NoMedia: - m_playerControl->updateStatus(QMediaPlayer::NoMedia); - break; - case Loading: - m_playerControl->updateStatus(QMediaPlayer::LoadingMedia); - break; - case Loaded: - if ((m_pendingTasks | m_executingTask | m_executedTasks) & (Play | Pause)) { - if (m_buffering) - m_playerControl->updateStatus(QMediaPlayer::BufferingMedia); - else - m_playerControl->updateStatus(QMediaPlayer::BufferedMedia); - } else { - m_playerControl->updateStatus(QMediaPlayer::LoadedMedia); - } - break; - case InvalidMedia: - m_playerControl->updateStatus(QMediaPlayer::InvalidMedia); - break; - default: - m_playerControl->updateStatus(QMediaPlayer::UnknownMediaStatus); - } -} - -bool DirectShowPlayerService::isConnected(IBaseFilter *filter, PIN_DIRECTION direction) const -{ - bool connected = false; - - IEnumPins *pins = 0; - - if (SUCCEEDED(filter->EnumPins(&pins))) { - for (IPin *pin = 0; pins->Next(1, &pin, 0) == S_OK; pin->Release()) { - PIN_DIRECTION dir; - if (SUCCEEDED(pin->QueryDirection(&dir)) && dir == direction) { - IPin *peer = 0; - if (SUCCEEDED(pin->ConnectedTo(&peer))) { - connected = true; - - peer->Release(); - } - } - } - pins->Release(); - } - return connected; -} - -IBaseFilter *DirectShowPlayerService::getConnected( - IBaseFilter *filter, PIN_DIRECTION direction) const -{ - IBaseFilter *connected = 0; - - IEnumPins *pins = 0; - - if (SUCCEEDED(filter->EnumPins(&pins))) { - for (IPin *pin = 0; pins->Next(1, &pin, 0) == S_OK; pin->Release()) { - PIN_DIRECTION dir; - if (SUCCEEDED(pin->QueryDirection(&dir)) && dir == direction) { - IPin *peer = 0; - if (SUCCEEDED(pin->ConnectedTo(&peer))) { - PIN_INFO info; - - if (SUCCEEDED(peer->QueryPinInfo(&info))) { - if (connected) { - qWarning("DirectShowPlayerService::getConnected: " - "Multiple connected filters"); - connected->Release(); - } - connected = info.pFilter; - } - peer->Release(); - } - } - } - pins->Release(); - } - return connected; -} - -void DirectShowPlayerService::run() -{ - QMutexLocker locker(&m_mutex); - - for (;;) { - ::ResetEvent(m_taskHandle); - - while (m_pendingTasks == 0) { - DWORD result = 0; - - locker.unlock(); - if (m_eventHandle) { - HANDLE handles[] = { m_taskHandle, m_eventHandle }; - - result = ::WaitForMultipleObjects(2, handles, false, INFINITE); - } else { - result = ::WaitForSingleObject(m_taskHandle, INFINITE); - } - locker.relock(); - - if (result == WAIT_OBJECT_0 + 1) { - graphEvent(&locker); - } - } - - if (m_pendingTasks & ReleaseGraph) { - m_pendingTasks ^= ReleaseGraph; - m_executingTask = ReleaseGraph; - - doReleaseGraph(&locker); - } else if (m_pendingTasks & Shutdown) { - return; - } else if (m_pendingTasks & ReleaseAudioOutput) { - m_pendingTasks ^= ReleaseAudioOutput; - m_executingTask = ReleaseAudioOutput; - - doReleaseAudioOutput(&locker); - } else if (m_pendingTasks & ReleaseVideoOutput) { - m_pendingTasks ^= ReleaseVideoOutput; - m_executingTask = ReleaseVideoOutput; - - doReleaseVideoOutput(&locker); - } else if (m_pendingTasks & SetUrlSource) { - m_pendingTasks ^= SetUrlSource; - m_executingTask = SetUrlSource; - - doSetUrlSource(&locker); - } else if (m_pendingTasks & SetStreamSource) { - m_pendingTasks ^= SetStreamSource; - m_executingTask = SetStreamSource; - - doSetStreamSource(&locker); - } else if (m_pendingTasks & Render) { - m_pendingTasks ^= Render; - m_executingTask = Render; - - doRender(&locker); - } else if (!(m_executedTasks & Render)) { - m_pendingTasks &= ~(FinalizeLoad | SetRate | Stop | Pause | Seek | Play); - } else if (m_pendingTasks & FinalizeLoad) { - m_pendingTasks ^= FinalizeLoad; - m_executingTask = FinalizeLoad; - - doFinalizeLoad(&locker); - } else if (m_pendingTasks & Stop) { - m_pendingTasks ^= Stop; - m_executingTask = Stop; - - doStop(&locker); - } else if (m_pendingTasks & Pause) { - m_pendingTasks ^= Pause; - m_executingTask = Pause; - - doPause(&locker); - } else if (m_pendingTasks & SetRate) { - m_pendingTasks ^= SetRate; - m_executingTask = SetRate; - - doSetRate(&locker); - } else if (m_pendingTasks & Seek) { - m_pendingTasks ^= Seek; - m_executingTask = Seek; - - doSeek(&locker); - } else if (m_pendingTasks & Play) { - m_pendingTasks ^= Play; - m_executingTask = Play; - - doPlay(&locker); - } - m_executingTask = 0; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h deleted file mode 100644 index a3f94e1..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h +++ /dev/null @@ -1,220 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWPLAYERSERVICE_H -#define DIRECTSHOWPLAYERSERVICE_H - -#include -#include -#include -#include - -#include "directshoweventloop.h" -#include "directshowglobal.h" - -#include -#include -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowAudioEndpointControl; -class DirectShowMetaDataControl; -class DirectShowPlayerControl; -class DirectShowVideoOutputControl; -class DirectShowVideoRendererControl; -class Vmr9VideoWindowControl; - -class DirectShowPlayerService : public QMediaService -{ - Q_OBJECT -public: - enum StreamType - { - AudioStream = 0x01, - VideoStream = 0x02 - }; - - DirectShowPlayerService(QObject *parent = 0); - ~DirectShowPlayerService(); - - QMediaControl* control(const char *name) const; - - void load(const QMediaContent &media, QIODevice *stream); - void play(); - void pause(); - void stop(); - - qint64 position() const; - QMediaTimeRange availablePlaybackRanges() const; - - void seek(qint64 position); - void setRate(qreal rate); - - int bufferStatus() const; - - void setAudioOutput(IBaseFilter *filter); - void setVideoOutput(IBaseFilter *filter); - -protected: - void customEvent(QEvent *event); - -private Q_SLOTS: - void videoOutputChanged(); - -private: - void releaseGraph(); - void updateStatus(); - - int findStreamTypes(IBaseFilter *source) const; - int findStreamType(IPin *pin) const; - - bool isConnected(IBaseFilter *filter, PIN_DIRECTION direction) const; - IBaseFilter *getConnected(IBaseFilter *filter, PIN_DIRECTION direction) const; - - void run(); - - void doSetUrlSource(QMutexLocker *locker); - void doSetStreamSource(QMutexLocker *locker); - void doRender(QMutexLocker *locker); - void doFinalizeLoad(QMutexLocker *locker); - void doSetRate(QMutexLocker *locker); - void doSeek(QMutexLocker *locker); - void doPlay(QMutexLocker *locker); - void doPause(QMutexLocker *locker); - void doStop(QMutexLocker *locker); - void doReleaseAudioOutput(QMutexLocker *locker); - void doReleaseVideoOutput(QMutexLocker *locker); - void doReleaseGraph(QMutexLocker *locker); - - void graphEvent(QMutexLocker *locker); - - enum Task - { - Shutdown = 0x0001, - SetUrlSource = 0x0002, - SetStreamSource = 0x0004, - SetSource = SetUrlSource | SetStreamSource, - SetAudioOutput = 0x0008, - SetVideoOutput = 0x0010, - SetOutputs = SetAudioOutput | SetVideoOutput, - Render = 0x0020, - FinalizeLoad = 0x0040, - SetRate = 0x0080, - Seek = 0x0100, - Play = 0x0200, - Pause = 0x0400, - Stop = 0x0800, - ReleaseGraph = 0x1000, - ReleaseAudioOutput = 0x2000, - ReleaseVideoOutput = 0x4000, - ReleaseFilters = ReleaseGraph | ReleaseAudioOutput | ReleaseVideoOutput - }; - - enum Event - { - FinalizedLoad = QEvent::User, - Error, - RateChange, - Started, - Paused, - DurationChange, - StatusChange, - EndOfMedia, - PositionChange, - VideoOutputChange - }; - - enum GraphStatus - { - NoMedia, - Loading, - Loaded, - InvalidMedia - }; - - DirectShowPlayerControl *m_playerControl; - DirectShowMetaDataControl *m_metaDataControl; - DirectShowVideoOutputControl *m_videoOutputControl; - DirectShowVideoRendererControl *m_videoRendererControl; - Vmr9VideoWindowControl *m_videoWindowControl; - DirectShowAudioEndpointControl *m_audioEndpointControl; - - QThread *m_taskThread; - DirectShowEventLoop *m_loop; - int m_pendingTasks; - int m_executingTask; - int m_executedTasks; - HANDLE m_taskHandle; - HANDLE m_eventHandle; - GraphStatus m_graphStatus; - QMediaPlayer::Error m_error; - QIODevice *m_stream; - IFilterGraph2 *m_graph; - IBaseFilter *m_source; - IBaseFilter *m_audioOutput; - IBaseFilter *m_videoOutput; - int m_streamTypes; - qreal m_rate; - qint64 m_position; - qint64 m_duration; - bool m_buffering; - bool m_seekable; - bool m_atEnd; - QMediaTimeRange m_playbackRange; - QUrl m_url; - QMediaResourceList m_resources; - QString m_errorString; - QMutex m_mutex; - - friend class DirectShowPlayerServiceThread; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp deleted file mode 100644 index 23675fb..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp +++ /dev/null @@ -1,403 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowsamplescheduler.h" - -#include - - -QT_BEGIN_NAMESPACE - -class DirectShowTimedSample -{ -public: - DirectShowTimedSample(IMediaSample *sample) - : m_next(0) - , m_sample(sample) - , m_cookie(0) - , m_lastSample(false) - { - m_sample->AddRef(); - } - - ~DirectShowTimedSample() - { - m_sample->Release(); - } - - IMediaSample *sample() const { return m_sample; } - - DirectShowTimedSample *nextSample() const { return m_next; } - void setNextSample(DirectShowTimedSample *sample) { Q_ASSERT(!m_next); m_next = sample; } - - DirectShowTimedSample *remove() { - DirectShowTimedSample *next = m_next; delete this; return next; } - - bool schedule(IReferenceClock *clock, REFERENCE_TIME startTime, HANDLE handle); - void unschedule(IReferenceClock *clock); - - bool isReady(IReferenceClock *clock) const; - - bool isLast() const { return m_lastSample; } - void setLast() { m_lastSample = true; } - -private: - DirectShowTimedSample *m_next; - IMediaSample *m_sample; - DWORD_PTR m_cookie; - bool m_lastSample; -}; - -bool DirectShowTimedSample::schedule( - IReferenceClock *clock, REFERENCE_TIME startTime, HANDLE handle) -{ - REFERENCE_TIME sampleStartTime; - REFERENCE_TIME sampleEndTime; - if (m_sample->GetTime(&sampleStartTime, &sampleEndTime) == S_OK) { - if (clock->AdviseTime( - startTime, sampleStartTime, reinterpret_cast(handle), &m_cookie) == S_OK) { - return true; - } - } - return false; -} - -void DirectShowTimedSample::unschedule(IReferenceClock *clock) -{ - clock->Unadvise(m_cookie); -} - -bool DirectShowTimedSample::isReady(IReferenceClock *clock) const -{ - REFERENCE_TIME sampleStartTime; - REFERENCE_TIME sampleEndTime; - REFERENCE_TIME currentTime; - if (m_sample->GetTime(&sampleStartTime, &sampleEndTime) == S_OK) { - if (clock->GetTime(¤tTime) == S_OK) - return currentTime >= sampleStartTime; - } - return true; -} - -DirectShowSampleScheduler::DirectShowSampleScheduler(IUnknown *pin, QObject *parent) - : QObject(parent) - , m_pin(pin) - , m_clock(0) - , m_allocator(0) - , m_head(0) - , m_tail(0) - , m_maximumSamples(2) - , m_state(Stopped) - , m_startTime(0) - , m_timeoutEvent(::CreateEvent(0, 0, 0, 0)) -{ - m_semaphore.release(m_maximumSamples); - - m_eventNotifier.setHandle(m_timeoutEvent); - m_eventNotifier.setEnabled(true); - - connect(&m_eventNotifier, SIGNAL(activated(HANDLE)), this, SIGNAL(sampleReady())); -} - -DirectShowSampleScheduler::~DirectShowSampleScheduler() -{ - m_eventNotifier.setEnabled(false); - - ::CloseHandle(m_timeoutEvent); - - Q_ASSERT(!m_clock); - Q_ASSERT(!m_allocator); -} - -HRESULT DirectShowSampleScheduler::QueryInterface(REFIID riid, void **ppvObject) -{ - return m_pin->QueryInterface(riid, ppvObject); -} - -ULONG DirectShowSampleScheduler::AddRef() -{ - return m_pin->AddRef(); -} - -ULONG DirectShowSampleScheduler::Release() -{ - return m_pin->Release(); -} - -// IMemInputPin -HRESULT DirectShowSampleScheduler::GetAllocator(IMemAllocator **ppAllocator) -{ - if (!ppAllocator) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_allocator) { - return VFW_E_NO_ALLOCATOR; - } else { - *ppAllocator = m_allocator; - - return S_OK; - } - } -} - -HRESULT DirectShowSampleScheduler::NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly) -{ - Q_UNUSED(bReadOnly); - - HRESULT hr; - ALLOCATOR_PROPERTIES properties; - - if (!pAllocator) { - if (m_allocator) - m_allocator->Release(); - - m_allocator = 0; - - return S_OK; - } else if ((hr = pAllocator->GetProperties(&properties)) != S_OK) { - return hr; - } else { - if (properties.cBuffers == 1) { - ALLOCATOR_PROPERTIES actual; - - properties.cBuffers = 2; - if ((hr = pAllocator->SetProperties(&properties, &actual)) != S_OK) - return hr; - } - - QMutexLocker locker(&m_mutex); - - if (m_allocator) - m_allocator->Release(); - - m_allocator = pAllocator; - m_allocator->AddRef(); - - return S_OK; - } -} - -HRESULT DirectShowSampleScheduler::GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps) -{ - if (!pProps) - return E_POINTER; - - pProps->cBuffers = 2; - - return S_OK; -} - -HRESULT DirectShowSampleScheduler::Receive(IMediaSample *pSample) -{ - if (!pSample) - return E_POINTER; - - m_semaphore.acquire(1); - - QMutexLocker locker(&m_mutex); - - if (m_state & Flushing) { - m_semaphore.release(1); - - return S_FALSE; - } else if (m_state == Stopped) { - m_semaphore.release(); - - return VFW_E_WRONG_STATE; - } else { - DirectShowTimedSample *timedSample = new DirectShowTimedSample(pSample); - - if (m_tail) - m_tail->setNextSample(timedSample); - else - m_head = timedSample; - - m_tail = timedSample; - - if (m_state == Running) { - if (!timedSample->schedule(m_clock, m_startTime, m_timeoutEvent)) { - // Timing information is unavailable, so schedule frames immediately. - QMetaObject::invokeMethod(this, "sampleReady", Qt::QueuedConnection); - } - } else if (m_tail == m_head) { - // If this is the first frame make is available. - QMetaObject::invokeMethod(this, "sampleReady", Qt::QueuedConnection); - } - - return S_OK; - } -} - -HRESULT DirectShowSampleScheduler::ReceiveMultiple( - IMediaSample **pSamples, long nSamples, long *nSamplesProcessed) -{ - if (!pSamples || !nSamplesProcessed) - return E_POINTER; - - for (*nSamplesProcessed = 0; *nSamplesProcessed < nSamples; ++(*nSamplesProcessed)) { - HRESULT hr = Receive(pSamples[*nSamplesProcessed]); - - if (hr != S_OK) - return hr; - } - return S_OK; -} - -HRESULT DirectShowSampleScheduler::ReceiveCanBlock() -{ - return S_OK; -} - -void DirectShowSampleScheduler::run(REFERENCE_TIME startTime) -{ - QMutexLocker locker(&m_mutex); - - m_state = (m_state & Flushing) | Running; - m_startTime = startTime; - - for (DirectShowTimedSample *sample = m_head; sample; sample = sample->nextSample()) { - sample->schedule(m_clock, m_startTime, m_timeoutEvent); - } -} - -void DirectShowSampleScheduler::pause() -{ - QMutexLocker locker(&m_mutex); - - m_state = (m_state & Flushing) | Paused; - - for (DirectShowTimedSample *sample = m_head; sample; sample = sample->nextSample()) - sample->unschedule(m_clock); -} - -void DirectShowSampleScheduler::stop() -{ - QMutexLocker locker(&m_mutex); - - m_state = m_state & Flushing; - - for (DirectShowTimedSample *sample = m_head; sample; sample = sample->remove()) { - sample->unschedule(m_clock); - - m_semaphore.release(1); - } - - m_head = 0; - m_tail = 0; -} - -void DirectShowSampleScheduler::setFlushing(bool flushing) -{ - QMutexLocker locker(&m_mutex); - - const bool isFlushing = m_state & Flushing; - - if (isFlushing != flushing) { - if (flushing) { - m_state |= Flushing; - - for (DirectShowTimedSample *sample = m_head; sample; sample = sample->remove()) { - sample->unschedule(m_clock); - - m_semaphore.release(1); - } - m_head = 0; - m_tail = 0; - } else { - m_state &= ~Flushing; - } - } -} - -void DirectShowSampleScheduler::setClock(IReferenceClock *clock) -{ - QMutexLocker locker(&m_mutex); - - if (m_clock) - m_clock->Release(); - - m_clock = clock; - - if (m_clock) - m_clock->AddRef(); -} - -IMediaSample *DirectShowSampleScheduler::takeSample(bool *eos) -{ - QMutexLocker locker(&m_mutex); - - if (m_head && m_head->isReady(m_clock)) { - IMediaSample *sample = m_head->sample(); - sample->AddRef(); - - if (m_state == Running) { - *eos = m_head->isLast(); - - m_head = m_head->remove(); - - if (!m_head) - m_tail = 0; - - m_semaphore.release(1); - } - - return sample; - } else { - return 0; - } -} - -bool DirectShowSampleScheduler::scheduleEndOfStream() -{ - QMutexLocker locker(&m_mutex); - - if (m_tail) { - m_tail->setLast(); - - return true; - } else { - return false; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h deleted file mode 100644 index 21823c3..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWSAMPLESCHEDULER_H -#define DIRECTSHOWSAMPLESCHEDULER_H - -#include -#include -#include - -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowTimedSample; - -class DirectShowSampleScheduler : public QObject, public IMemInputPin -{ - Q_OBJECT -public: - - enum State - { - Stopped = 0x00, - Running = 0x01, - Paused = 0x02, - RunMask = 0x03, - Flushing = 0x04 - }; - - DirectShowSampleScheduler(IUnknown *pin, QObject *parent = 0); - ~DirectShowSampleScheduler(); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IMemInputPin - HRESULT STDMETHODCALLTYPE GetAllocator(IMemAllocator **ppAllocator); - HRESULT STDMETHODCALLTYPE NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly); - HRESULT STDMETHODCALLTYPE GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps); - - HRESULT STDMETHODCALLTYPE Receive(IMediaSample *pSample); - HRESULT STDMETHODCALLTYPE ReceiveMultiple(IMediaSample **pSamples, long nSamples, long *nSamplesProcessed); - HRESULT STDMETHODCALLTYPE ReceiveCanBlock(); - - void run(REFERENCE_TIME startTime); - void pause(); - void stop(); - void setFlushing(bool flushing); - - IReferenceClock *clock() const { return m_clock; } - void setClock(IReferenceClock *clock); - - bool schedule(IMediaSample *sample); - bool scheduleEndOfStream(); - - IMediaSample *takeSample(bool *eos); - -Q_SIGNALS: - void sampleReady(); - -private: - IUnknown *m_pin; - IReferenceClock *m_clock; - IMemAllocator *m_allocator; - DirectShowTimedSample *m_head; - DirectShowTimedSample *m_tail; - int m_maximumSamples; - int m_state; - REFERENCE_TIME m_startTime; - HANDLE m_timeoutEvent; - QSemaphore m_semaphore; - QMutex m_mutex; - QWinEventNotifier m_eventNotifier; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.cpp deleted file mode 100644 index ee2bea8..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowvideooutputcontrol.h" - - -QT_BEGIN_NAMESPACE - -DirectShowVideoOutputControl::DirectShowVideoOutputControl(QObject *parent) - : QVideoOutputControl(parent) - , m_output(NoOutput) -{ - -} - -DirectShowVideoOutputControl::~DirectShowVideoOutputControl() -{ -} - -QList DirectShowVideoOutputControl::availableOutputs() const -{ - return QList() - << RendererOutput - << WindowOutput; -} - - -QVideoOutputControl::Output DirectShowVideoOutputControl::output() const -{ - return m_output; -} - -void DirectShowVideoOutputControl::setOutput(Output output) -{ - if (output != m_output) { - switch (output) { - case NoOutput: - case RendererOutput: - case WindowOutput: - m_output = output; - emit outputChanged(); - break; - default: - break; - } - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.h deleted file mode 100644 index 9b857ce..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWVIDEOUTPUTCONTROL_H -#define DIRECTSHOWVIDEOOUPUTCONTROL_H - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowVideoOutputControl : public QVideoOutputControl -{ - Q_OBJECT -public: - DirectShowVideoOutputControl(QObject *parent = 0); - ~DirectShowVideoOutputControl(); - - QList availableOutputs() const; - - Output output() const; - void setOutput(Output output); - -Q_SIGNALS: - void outputChanged(); - -private: - Output m_output; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.cpp deleted file mode 100644 index f27cb10..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "directshowvideorenderercontrol.h" - -#include "videosurfacefilter.h" - - -QT_BEGIN_NAMESPACE - - -DirectShowVideoRendererControl::DirectShowVideoRendererControl(DirectShowEventLoop *loop, QObject *parent) - : QVideoRendererControl(parent) - , m_loop(loop) - , m_surface(0) - , m_filter(0) -{ -} - -DirectShowVideoRendererControl::~DirectShowVideoRendererControl() -{ - delete m_filter; -} - -QAbstractVideoSurface *DirectShowVideoRendererControl::surface() const -{ - return m_surface; -} - -void DirectShowVideoRendererControl::setSurface(QAbstractVideoSurface *surface) -{ - if (surface != m_surface) { - m_surface = surface; - - VideoSurfaceFilter *existingFilter = m_filter; - - if (surface) { - m_filter = new VideoSurfaceFilter(surface, m_loop); - } else { - m_filter = 0; - } - - emit filterChanged(); - - delete existingFilter; - } -} - -IBaseFilter *DirectShowVideoRendererControl::filter() -{ - return m_filter; -} - - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.h deleted file mode 100644 index adaa0f8..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 DIRECTSHOWVIDEORENDERERCONTROL_H -#define DIRECTSHOWVIDEORENDERERCONTROL_H - -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowEventLoop; -class VideoSurfaceFilter; - -class DirectShowVideoRendererControl : public QVideoRendererControl -{ - Q_OBJECT -public: - DirectShowVideoRendererControl(DirectShowEventLoop *loop, QObject *parent = 0); - ~DirectShowVideoRendererControl(); - - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); - - IBaseFilter *filter(); - -Q_SIGNALS: - void filterChanged(); - -private: - DirectShowEventLoop *m_loop; - QAbstractVideoSurface *m_surface; - VideoSurfaceFilter *m_filter; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/mediaplayer.pri b/src/plugins/mediaservices/directshow/mediaplayer/mediaplayer.pri deleted file mode 100644 index 99a1191..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/mediaplayer.pri +++ /dev/null @@ -1,45 +0,0 @@ -INCLUDEPATH += $$PWD - -DEFINES += QMEDIA_DIRECTSHOW_PLAYER - -!contains(QT_CONFIG, wmsdk): DEFINES += QT_NO_WMSDK - -HEADERS += \ - $$PWD/directshowaudioendpointcontrol.h \ - $$PWD/directshoweventloop.h \ - $$PWD/directshowglobal.h \ - $$PWD/directshowioreader.h \ - $$PWD/directshowiosource.h \ - $$PWD/directshowmediatype.h \ - $$PWD/directshowmediatypelist.h \ - $$PWD/directshowmetadatacontrol.h \ - $$PWD/directshowpinenum.h \ - $$PWD/directshowplayercontrol.h \ - $$PWD/directshowplayerservice.h \ - $$PWD/directshowsamplescheduler.h \ - $$PWD/directshowvideooutputcontrol.h \ - $$PWD/directshowvideorenderercontrol.h \ - $$PWD/mediasamplevideobuffer.h \ - $$PWD/videosurfacefilter.h \ - $$PWD/vmr9videowindowcontrol.h - -SOURCES += \ - $$PWD/directshowaudioendpointcontrol.cpp \ - $$PWD/directshoweventloop.cpp \ - $$PWD/directshowioreader.cpp \ - $$PWD/directshowiosource.cpp \ - $$PWD/directshowmediatype.cpp \ - $$PWD/directshowmediatypelist.cpp \ - $$PWD/directshowmetadatacontrol.cpp \ - $$PWD/directshowpinenum.cpp \ - $$PWD/directshowplayercontrol.cpp \ - $$PWD/directshowplayerservice.cpp \ - $$PWD/directshowsamplescheduler.cpp \ - $$PWD/directshowvideooutputcontrol.cpp \ - $$PWD/directshowvideorenderercontrol.cpp \ - $$PWD/mediasamplevideobuffer.cpp \ - $$PWD/videosurfacefilter.cpp \ - $$PWD/vmr9videowindowcontrol.cpp - -LIBS += -lstrmiids -ldmoguids -luuid -lmsdmo -lole32 -loleaut32 - diff --git a/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.cpp b/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.cpp deleted file mode 100644 index 7eff226..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "mediasamplevideobuffer.h" - - -QT_BEGIN_NAMESPACE - -MediaSampleVideoBuffer::MediaSampleVideoBuffer(IMediaSample *sample, int bytesPerLine) - : QAbstractVideoBuffer(NoHandle) - , m_sample(sample) - , m_bytesPerLine(m_bytesPerLine) - , m_mapMode(NotMapped) -{ - m_sample->AddRef(); -} - -MediaSampleVideoBuffer::~MediaSampleVideoBuffer() -{ - m_sample->Release(); -} - -uchar *MediaSampleVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) -{ - if (m_mapMode == NotMapped && mode != NotMapped) { - if (numBytes) - *numBytes = m_sample->GetActualDataLength(); - - if (bytesPerLine) - *bytesPerLine = m_bytesPerLine; - - BYTE *bytes = 0; - - if (m_sample->GetPointer(&bytes) == S_OK) { - m_mapMode = mode; - - return reinterpret_cast(bytes); - } - } - return 0; -} - -void MediaSampleVideoBuffer::unmap() -{ - m_mapMode = NotMapped; -} - -QAbstractVideoBuffer::MapMode MediaSampleVideoBuffer::mapMode() const -{ - return m_mapMode; -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.h b/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.h deleted file mode 100644 index 06dc31c..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 MEDIASAMPLEVIDEOBUFFER_H -#define MEDIASAMPLEVIDEOBUFFER_H - -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class MediaSampleVideoBuffer : public QAbstractVideoBuffer -{ -public: - MediaSampleVideoBuffer(IMediaSample *sample, int bytesPerLine); - ~MediaSampleVideoBuffer(); - - IMediaSample *sample() { return m_sample; } - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); - void unmap(); - - MapMode mapMode() const; - -private: - IMediaSample *m_sample; - int m_bytesPerLine; - MapMode m_mapMode; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.cpp b/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.cpp deleted file mode 100644 index a471c68..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.cpp +++ /dev/null @@ -1,633 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "videosurfacefilter.h" - -#include "directshoweventloop.h" -#include "directshowglobal.h" -#include "directshowpinenum.h" -#include "mediasamplevideobuffer.h" - -#include -#include -#include -#include - -#include - - -QT_BEGIN_NAMESPACE - -// { e23cad72-153d-406c-bf3f-4c4b523d96f2 } -DEFINE_GUID(CLSID_VideoSurfaceFilter, -0xe23cad72, 0x153d, 0x406c, 0xbf, 0x3f, 0x4c, 0x4b, 0x52, 0x3d, 0x96, 0xf2); - -VideoSurfaceFilter::VideoSurfaceFilter( - QAbstractVideoSurface *surface, DirectShowEventLoop *loop, QObject *parent) - : QObject(parent) - , m_ref(1) - , m_state(State_Stopped) - , m_surface(surface) - , m_loop(loop) - , m_graph(0) - , m_peerPin(0) - , m_bytesPerLine(0) - , m_startResult(S_OK) - , m_pinId(QString::fromLatin1("reference")) - , m_sampleScheduler(static_cast(this)) -{ - connect(surface, SIGNAL(supportedFormatsChanged()), this, SLOT(supportedFormatsChanged())); - connect(&m_sampleScheduler, SIGNAL(sampleReady()), this, SLOT(sampleReady())); -} - -VideoSurfaceFilter::~VideoSurfaceFilter() -{ - Q_ASSERT(m_ref == 1); -} - -HRESULT VideoSurfaceFilter::QueryInterface(REFIID riid, void **ppvObject) -{ - // 2dd74950-a890-11d1-abe8-00a0c905f375 - static const GUID iid_IAmFilterMiscFlags = { - 0x2dd74950, 0xa890, 0x11d1, {0xab, 0xe8, 0x00, 0xa0, 0xc9, 0x05, 0xf3, 0x75} }; - - if (!ppvObject) { - return E_POINTER; - } else if (riid == IID_IUnknown - || riid == IID_IPersist - || riid == IID_IMediaFilter - || riid == IID_IBaseFilter) { - *ppvObject = static_cast(this); - } else if (riid == iid_IAmFilterMiscFlags) { - *ppvObject = static_cast(this); - } else if (riid == IID_IPin) { - *ppvObject = static_cast(this); - } else if (riid == IID_IMemInputPin) { - *ppvObject = static_cast(&m_sampleScheduler); - } else { - *ppvObject = 0; - - return E_NOINTERFACE; - } - - AddRef(); - - return S_OK; -} - -ULONG VideoSurfaceFilter::AddRef() -{ - return InterlockedIncrement(&m_ref); -} - -ULONG VideoSurfaceFilter::Release() -{ - ULONG ref = InterlockedDecrement(&m_ref); - - Q_ASSERT(ref != 0); - - return ref; -} - -HRESULT VideoSurfaceFilter::GetClassID(CLSID *pClassID) -{ - *pClassID = CLSID_VideoSurfaceFilter; - - return S_OK; -} - -HRESULT VideoSurfaceFilter::Run(REFERENCE_TIME tStart) -{ - m_state = State_Running; - - m_sampleScheduler.run(tStart); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::Pause() -{ - m_state = State_Paused; - - m_sampleScheduler.pause(); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::Stop() -{ - m_state = State_Stopped; - - m_sampleScheduler.stop(); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *pState) -{ - if (!pState) - return E_POINTER; - - *pState = m_state; - - return S_OK; -} - -HRESULT VideoSurfaceFilter::SetSyncSource(IReferenceClock *pClock) -{ - - m_sampleScheduler.setClock(pClock); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::GetSyncSource(IReferenceClock **ppClock) -{ - if (!ppClock) { - return E_POINTER; - } else { - *ppClock = m_sampleScheduler.clock(); - - if (*ppClock) { - (*ppClock)->AddRef(); - - return S_OK; - } else { - return S_FALSE; - } - } -} - -HRESULT VideoSurfaceFilter::EnumPins(IEnumPins **ppEnum) -{ - if (ppEnum) { - *ppEnum = new DirectShowPinEnum(QList() << this); - - return S_OK; - } else { - return E_POINTER; - } -} - -HRESULT VideoSurfaceFilter::FindPin(LPCWSTR pId, IPin **ppPin) -{ - if (!ppPin || !pId) { - return E_POINTER; - } else if (QString::fromWCharArray(pId) == m_pinId) { - AddRef(); - - *ppPin = this; - - return S_OK; - } else { - return VFW_E_NOT_FOUND; - } -} - -HRESULT VideoSurfaceFilter::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName) -{ - m_graph = pGraph; - m_name = QString::fromWCharArray(pName); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::QueryFilterInfo(FILTER_INFO *pInfo) -{ - if (pInfo) { - QString name = m_name; - - if (name.length() >= MAX_FILTER_NAME) - name.truncate(MAX_FILTER_NAME - 1); - - int length = name.toWCharArray(pInfo->achName); - pInfo->achName[length] = '\0'; - - if (m_graph) - m_graph->AddRef(); - - pInfo->pGraph = m_graph; - - return S_OK; - } else { - return E_POINTER; - } -} - -HRESULT VideoSurfaceFilter::QueryVendorInfo(LPWSTR *pVendorInfo) -{ - Q_UNUSED(pVendorInfo); - - return E_NOTIMPL; -} - -ULONG VideoSurfaceFilter::GetMiscFlags() -{ - return AM_FILTER_MISC_FLAGS_IS_RENDERER; -} - - -HRESULT VideoSurfaceFilter::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) -{ - // This is an input pin, you shouldn't be calling Connect on it. - return E_POINTER; -} - -HRESULT VideoSurfaceFilter::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) -{ - if (!pConnector) { - return E_POINTER; - } else if (!pmt) { - return E_POINTER; - } else { - HRESULT hr; - QMutexLocker locker(&m_mutex); - - if (m_peerPin) { - hr = VFW_E_ALREADY_CONNECTED; - } else if (pmt->majortype != MEDIATYPE_Video) { - hr = VFW_E_TYPE_NOT_ACCEPTED; - } else { - m_surfaceFormat = DirectShowMediaType::formatFromType(*pmt); - m_bytesPerLine = DirectShowMediaType::bytesPerLine(m_surfaceFormat); - - if (thread() == QThread::currentThread()) { - hr = start(); - } else { - m_loop->postEvent(this, new QEvent(QEvent::Type(StartSurface))); - - m_wait.wait(&m_mutex); - - hr = m_startResult; - } - } - if (hr == S_OK) { - m_peerPin = pConnector; - m_peerPin->AddRef(); - - DirectShowMediaType::copy(&m_mediaType, *pmt); - } - return hr; - } -} - -HRESULT VideoSurfaceFilter::start() -{ - if (!m_surface->start(m_surfaceFormat)) { - return VFW_E_TYPE_NOT_ACCEPTED; - } else { - return S_OK; - } -} - -HRESULT VideoSurfaceFilter::Disconnect() -{ - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) - return S_FALSE; - - if (thread() == QThread::currentThread()) { - stop(); - } else { - m_loop->postEvent(this, new QEvent(QEvent::Type(StopSurface))); - - m_wait.wait(&m_mutex); - } - - m_mediaType.clear(); - - m_sampleScheduler.NotifyAllocator(0, FALSE); - - m_peerPin->Release(); - m_peerPin = 0; - - return S_OK; -} - -void VideoSurfaceFilter::stop() -{ - m_surface->stop(); -} - -HRESULT VideoSurfaceFilter::ConnectedTo(IPin **ppPin) -{ - if (!ppPin) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) { - return VFW_E_NOT_CONNECTED; - } else { - m_peerPin->AddRef(); - - *ppPin = m_peerPin; - - return S_OK; - } - } -} - -HRESULT VideoSurfaceFilter::ConnectionMediaType(AM_MEDIA_TYPE *pmt) -{ - if (!pmt) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) { - return VFW_E_NOT_CONNECTED; - } else { - DirectShowMediaType::copy(pmt, m_mediaType); - - return S_OK; - } - } -} - -HRESULT VideoSurfaceFilter::QueryPinInfo(PIN_INFO *pInfo) -{ - if (!pInfo) { - return E_POINTER; - } else { - AddRef(); - - pInfo->pFilter = this; - pInfo->dir = PINDIR_INPUT; - - const int bytes = qMin(MAX_FILTER_NAME, (m_pinId.length() + 1) * 2); - - qMemCopy(pInfo->achName, m_pinId.utf16(), bytes); - - return S_OK; - } -} - -HRESULT VideoSurfaceFilter::QueryId(LPWSTR *Id) -{ - if (!Id) { - return E_POINTER; - } else { - const int bytes = (m_pinId.length() + 1) * 2; - - *Id = static_cast(::CoTaskMemAlloc(bytes)); - - qMemCopy(*Id, m_pinId.utf16(), bytes); - - return S_OK; - } -} - -HRESULT VideoSurfaceFilter::QueryAccept(const AM_MEDIA_TYPE *pmt) -{ - return !m_surface->isFormatSupported(DirectShowMediaType::formatFromType(*pmt)) - ? S_OK - : S_FALSE; -} - -HRESULT VideoSurfaceFilter::EnumMediaTypes(IEnumMediaTypes **ppEnum) -{ - if (!ppEnum) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - *ppEnum = createMediaTypeEnum(); - - return S_OK; - } -} - -HRESULT VideoSurfaceFilter::QueryInternalConnections(IPin **apPin, ULONG *nPin) -{ - Q_UNUSED(apPin); - Q_UNUSED(nPin); - - return E_NOTIMPL; -} - -HRESULT VideoSurfaceFilter::EndOfStream() -{ - QMutexLocker locker(&m_mutex); - - if (!m_sampleScheduler.scheduleEndOfStream()) { - if (IMediaEventSink *sink = com_cast(m_graph, IID_IMediaEventSink)) { - sink->Notify( - EC_COMPLETE, - S_OK, - reinterpret_cast(static_cast(this))); - sink->Release(); - } - } - - return S_OK; -} - -HRESULT VideoSurfaceFilter::BeginFlush() -{ - QMutexLocker locker(&m_mutex); - - m_sampleScheduler.setFlushing(true); - - if (thread() == QThread::currentThread()) { - flush(); - } else { - m_loop->postEvent(this, new QEvent(QEvent::Type(FlushSurface))); - - m_wait.wait(&m_mutex); - } - - return S_OK; -} - -HRESULT VideoSurfaceFilter::EndFlush() -{ - QMutexLocker locker(&m_mutex); - - m_sampleScheduler.setFlushing(false); - - return S_OK; -} - -void VideoSurfaceFilter::flush() -{ - m_surface->present(QVideoFrame()); - - m_wait.wakeAll(); -} - -HRESULT VideoSurfaceFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) -{ - Q_UNUSED(tStart); - Q_UNUSED(tStop); - Q_UNUSED(dRate); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::QueryDirection(PIN_DIRECTION *pPinDir) -{ - if (!pPinDir) { - return E_POINTER; - } else { - *pPinDir = PINDIR_INPUT; - - return S_OK; - } -} - -int VideoSurfaceFilter::currentMediaTypeToken() -{ - QMutexLocker locker(&m_mutex); - - return DirectShowMediaTypeList::currentMediaTypeToken(); -} - -HRESULT VideoSurfaceFilter::nextMediaType( - int token, int *index, ULONG count, AM_MEDIA_TYPE **types, ULONG *fetchedCount) -{ - QMutexLocker locker(&m_mutex); - - return DirectShowMediaTypeList::nextMediaType(token, index, count, types, fetchedCount); - -} - -HRESULT VideoSurfaceFilter::skipMediaType(int token, int *index, ULONG count) -{ - QMutexLocker locker(&m_mutex); - - return DirectShowMediaTypeList::skipMediaType(token, index, count); -} - -HRESULT VideoSurfaceFilter::cloneMediaType(int token, int index, IEnumMediaTypes **enumeration) -{ - QMutexLocker locker(&m_mutex); - - return DirectShowMediaTypeList::cloneMediaType(token, index, enumeration); -} - -void VideoSurfaceFilter::customEvent(QEvent *event) -{ - if (event->type() == StartSurface) { - QMutexLocker locker(&m_mutex); - - m_startResult = start(); - - m_wait.wakeAll(); - } else if (event->type() == StopSurface) { - QMutexLocker locker(&m_mutex); - - stop(); - - m_wait.wakeAll(); - } else if (event->type() == FlushSurface) { - QMutexLocker locker(&m_mutex); - - flush(); - - m_wait.wakeAll(); - } else { - QObject::customEvent(event); - } -} - -void VideoSurfaceFilter::supportedFormatsChanged() -{ - QMutexLocker locker(&m_mutex); - - // MEDIASUBTYPE_None; - static const GUID none = { - 0xe436eb8e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70} }; - - QList formats = m_surface->supportedPixelFormats(); - - QVector mediaTypes; - mediaTypes.reserve(formats.count()); - - AM_MEDIA_TYPE type; - type.majortype = MEDIATYPE_Video; - type.bFixedSizeSamples = TRUE; - type.bTemporalCompression = FALSE; - type.lSampleSize = 0; - type.formattype = GUID_NULL; - type.pUnk = 0; - type.cbFormat = 0; - type.pbFormat = 0; - - foreach (QVideoFrame::PixelFormat format, formats) { - type.subtype = DirectShowMediaType::convertPixelFormat(format); - - if (type.subtype != none) - mediaTypes.append(type); - } - - setMediaTypes(mediaTypes); -} - -void VideoSurfaceFilter::sampleReady() -{ - bool eos = false; - - IMediaSample *sample = m_sampleScheduler.takeSample(&eos); - - if (sample) { - m_surface->present(QVideoFrame( - new MediaSampleVideoBuffer(sample, m_bytesPerLine), - m_surfaceFormat.frameSize(), - m_surfaceFormat.pixelFormat())); - - sample->Release(); - - if (eos) { - if (IMediaEventSink *sink = com_cast(m_graph, IID_IMediaEventSink)) { - sink->Notify( - EC_COMPLETE, - S_OK, - reinterpret_cast(static_cast(this))); - sink->Release(); - } - } - } -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.h b/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.h deleted file mode 100644 index 0607fd3..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.h +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 VIDEOSURFACEFILTER_H -#define VIDEOSURFACEFILTER_H - -#include "directshowglobal.h" -#include "directshowmediatypelist.h" -#include "directshowsamplescheduler.h" -#include "directshowmediatype.h" - -#include -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QAbstractVideoSurface; - -class DirectShowEventLoop; - -class VideoSurfaceFilter - : public QObject - , public DirectShowMediaTypeList - , public IBaseFilter - , public IAMFilterMiscFlags - , public IPin -{ - Q_OBJECT -public: - VideoSurfaceFilter( - QAbstractVideoSurface *surface, DirectShowEventLoop *loop, QObject *parent = 0); - ~VideoSurfaceFilter(); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IPersist - HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID); - - // IMediaFilter - HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart); - HRESULT STDMETHODCALLTYPE Pause(); - HRESULT STDMETHODCALLTYPE Stop(); - - HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *pState); - - HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock); - HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock **ppClock); - - // IBaseFilter - HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins **ppEnum); - HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin **ppPin); - - HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName); - - HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO *pInfo); - HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR *pVendorInfo); - - // IAMFilterMiscFlags - ULONG STDMETHODCALLTYPE GetMiscFlags(); - - // IPin - HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); - HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); - HRESULT STDMETHODCALLTYPE Disconnect(); - HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **ppPin); - - HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); - - HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); - HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); - - HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); - - HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); - - HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); - - HRESULT STDMETHODCALLTYPE EndOfStream(); - - HRESULT STDMETHODCALLTYPE BeginFlush(); - HRESULT STDMETHODCALLTYPE EndFlush(); - - HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); - - HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); - - int currentMediaTypeToken(); - HRESULT nextMediaType( - int token, int *index, ULONG count, AM_MEDIA_TYPE **types, ULONG *fetchedCount); - HRESULT skipMediaType(int token, int *index, ULONG count); - HRESULT cloneMediaType(int token, int index, IEnumMediaTypes **enumeration); - -protected: - void customEvent(QEvent *event); - -private Q_SLOTS: - void supportedFormatsChanged(); - void sampleReady(); - -private: - HRESULT start(); - void stop(); - void flush(); - - enum - { - StartSurface = QEvent::User, - StopSurface, - FlushSurface - }; - - LONG m_ref; - FILTER_STATE m_state; - QAbstractVideoSurface *m_surface; - DirectShowEventLoop *m_loop; - IFilterGraph *m_graph; - IPin *m_peerPin; - int m_bytesPerLine; - HRESULT m_startResult; - QString m_name; - QString m_pinId; - DirectShowMediaType m_mediaType; - QVideoSurfaceFormat m_surfaceFormat; - QMutex m_mutex; - QWaitCondition m_wait; - DirectShowSampleScheduler m_sampleScheduler; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp deleted file mode 100644 index 1c6df2c..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "vmr9videowindowcontrol.h" - -#include "directshowglobal.h" - - -QT_BEGIN_NAMESPACE - -Vmr9VideoWindowControl::Vmr9VideoWindowControl(QObject *parent) - : QVideoWindowControl(parent) - , m_filter(com_new(CLSID_VideoMixingRenderer9, IID_IBaseFilter)) - , m_windowId(0) - , m_dirtyValues(0) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_brightness(0) - , m_contrast(0) - , m_hue(0) - , m_saturation(0) - , m_fullScreen(false) -{ - if (IVMRFilterConfig9 *config = com_cast(m_filter, IID_IVMRFilterConfig9)) { - config->SetRenderingMode(VMR9Mode_Windowless); - config->SetNumberOfStreams(1); - config->SetRenderingPrefs(RenderPrefs9_DoNotRenderBorder); - config->Release(); - } -} - -Vmr9VideoWindowControl::~Vmr9VideoWindowControl() -{ - if (m_filter) - m_filter->Release(); -} - - -WId Vmr9VideoWindowControl::winId() const -{ - return m_windowId; - -} - -void Vmr9VideoWindowControl::setWinId(WId id) -{ - m_windowId = id; - - if (IVMRWindowlessControl9 *control = com_cast( - m_filter, IID_IVMRWindowlessControl9)) { - control->SetVideoClippingWindow(m_windowId); - control->Release(); - } -} - -QRect Vmr9VideoWindowControl::displayRect() const -{ - return m_displayRect; -} - -void Vmr9VideoWindowControl::setDisplayRect(const QRect &rect) -{ - m_displayRect = rect; - - if (IVMRWindowlessControl9 *control = com_cast( - m_filter, IID_IVMRWindowlessControl9)) { - RECT sourceRect = { 0, 0, 0, 0 }; - RECT displayRect = { rect.left(), rect.top(), rect.right(), rect.bottom() }; - - control->GetNativeVideoSize(&sourceRect.right, &sourceRect.bottom, 0, 0); - - if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) { - QSize clippedSize = rect.size(); - clippedSize.scale(sourceRect.right, sourceRect.bottom, Qt::KeepAspectRatio); - - sourceRect.left = (sourceRect.right - clippedSize.width()) / 2; - sourceRect.top = (sourceRect.bottom - clippedSize.height()) / 2; - sourceRect.right = sourceRect.left + clippedSize.width(); - sourceRect.bottom = sourceRect.top + clippedSize.height(); - } - - control->SetVideoPosition(&sourceRect, &displayRect); - control->Release(); - } -} - -bool Vmr9VideoWindowControl::isFullScreen() const -{ - return m_fullScreen; -} - -void Vmr9VideoWindowControl::setFullScreen(bool fullScreen) -{ - emit fullScreenChanged(m_fullScreen = fullScreen); -} - -void Vmr9VideoWindowControl::repaint() -{ - if (QWidget *widget = QWidget::find(m_windowId)) { - HDC dc = widget->getDC(); - if (IVMRWindowlessControl9 *control = com_cast( - m_filter, IID_IVMRWindowlessControl9)) { - control->RepaintVideo(m_windowId, dc); - control->Release(); - } - widget->releaseDC(dc); - } -} - -QSize Vmr9VideoWindowControl::nativeSize() const -{ - QSize size; - - if (IVMRWindowlessControl9 *control = com_cast( - m_filter, IID_IVMRWindowlessControl9)) { - LONG width; - LONG height; - - if (control->GetNativeVideoSize(&width, &height, 0, 0) == S_OK) - size = QSize(width, height); - control->Release(); - } - return size; -} - -Qt::AspectRatioMode Vmr9VideoWindowControl::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void Vmr9VideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_aspectRatioMode = mode; - - if (IVMRWindowlessControl9 *control = com_cast( - m_filter, IID_IVMRWindowlessControl9)) { - switch (mode) { - case Qt::IgnoreAspectRatio: - control->SetAspectRatioMode(VMR9ARMode_None); - break; - case Qt::KeepAspectRatio: - control->SetAspectRatioMode(VMR9ARMode_LetterBox); - break; - case Qt::KeepAspectRatioByExpanding: - control->SetAspectRatioMode(VMR9ARMode_LetterBox); - break; - default: - break; - } - control->Release(); - - setDisplayRect(m_displayRect); - } -} - -int Vmr9VideoWindowControl::brightness() const -{ - return m_brightness; -} - -void Vmr9VideoWindowControl::setBrightness(int brightness) -{ - m_brightness = brightness; - - m_dirtyValues |= ProcAmpControl9_Brightness; - - setProcAmpValues(); - - emit brightnessChanged(brightness); -} - -int Vmr9VideoWindowControl::contrast() const -{ - return m_contrast; -} - -void Vmr9VideoWindowControl::setContrast(int contrast) -{ - m_contrast = contrast; - - m_dirtyValues |= ProcAmpControl9_Contrast; - - setProcAmpValues(); - - emit contrastChanged(contrast); -} - -int Vmr9VideoWindowControl::hue() const -{ - return m_hue; -} - -void Vmr9VideoWindowControl::setHue(int hue) -{ - m_hue = hue; - - m_dirtyValues |= ProcAmpControl9_Hue; - - setProcAmpValues(); - - emit hueChanged(hue); -} - -int Vmr9VideoWindowControl::saturation() const -{ - return m_saturation; -} - -void Vmr9VideoWindowControl::setSaturation(int saturation) -{ - m_saturation = saturation; - - m_dirtyValues |= ProcAmpControl9_Saturation; - - setProcAmpValues(); - - emit saturationChanged(saturation); -} - -void Vmr9VideoWindowControl::updateNativeSize() -{ - setDisplayRect(m_displayRect); - - emit nativeSizeChanged(); -} - -void Vmr9VideoWindowControl::setProcAmpValues() -{ - if (IVMRMixerControl9 *control = com_cast(m_filter, IID_IVMRMixerControl9)) { - VMR9ProcAmpControl procAmp; - procAmp.dwSize = sizeof(VMR9ProcAmpControl); - procAmp.dwFlags = m_dirtyValues; - - if (m_dirtyValues & ProcAmpControl9_Brightness) { - procAmp.Brightness = scaleProcAmpValue( - control, ProcAmpControl9_Brightness, m_brightness); - } - if (m_dirtyValues & ProcAmpControl9_Contrast) { - procAmp.Contrast = scaleProcAmpValue( - control, ProcAmpControl9_Contrast, m_contrast); - } - if (m_dirtyValues & ProcAmpControl9_Hue) { - procAmp.Hue = scaleProcAmpValue( - control, ProcAmpControl9_Hue, m_hue); - } - if (m_dirtyValues & ProcAmpControl9_Saturation) { - procAmp.Saturation = scaleProcAmpValue( - control, ProcAmpControl9_Saturation, m_saturation); - } - - if (SUCCEEDED(control->SetProcAmpControl(0, &procAmp))) { - m_dirtyValues = 0; - } - - control->Release(); - } -} - -float Vmr9VideoWindowControl::scaleProcAmpValue( - IVMRMixerControl9 *control, VMR9ProcAmpControlFlags property, int value) const -{ - float scaledValue = 0.0; - - VMR9ProcAmpControlRange range; - range.dwSize = sizeof(VMR9ProcAmpControlRange); - range.dwProperty = property; - - if (SUCCEEDED(control->GetProcAmpControlRange(0, &range))) { - scaledValue = range.DefaultValue; - if (value > 0) - scaledValue += float(value) * (range.MaxValue - range.DefaultValue) / 100; - else if (value < 0) - scaledValue -= float(value) * (range.MinValue - range.DefaultValue) / 100; - } - - return scaledValue; -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h deleted file mode 100644 index 702dfd6..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 VMR9VIDEOWINDOWCONTROL_H -#define VMR9VIDEOWINDOWCONTROL_H - -#include - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class Vmr9VideoWindowControl : public QVideoWindowControl -{ - Q_OBJECT -public: - Vmr9VideoWindowControl(QObject *parent = 0); - ~Vmr9VideoWindowControl(); - - IBaseFilter *filter() const { return m_filter; } - - WId winId() const; - void setWinId(WId id); - - QRect displayRect() const; - void setDisplayRect(const QRect &rect); - - bool isFullScreen() const; - void setFullScreen(bool fullScreen); - - void repaint(); - - QSize nativeSize() const; - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); - - void updateNativeSize(); - -private: - void setProcAmpValues(); - float scaleProcAmpValue( - IVMRMixerControl9 *control, VMR9ProcAmpControlFlags property, int value) const; - - IBaseFilter *m_filter; - WId m_windowId; - DWORD m_dirtyValues; - Qt::AspectRatioMode m_aspectRatioMode; - QRect m_displayRect; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; - bool m_fullScreen; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/gstreamer/gstreamer.pro b/src/plugins/mediaservices/gstreamer/gstreamer.pro deleted file mode 100644 index 6e05120..0000000 --- a/src/plugins/mediaservices/gstreamer/gstreamer.pro +++ /dev/null @@ -1,59 +0,0 @@ -TARGET = qgstengine -include(../../qpluginbase.pri) - -QT += mediaservices - -unix:contains(QT_CONFIG, alsa) { - DEFINES += HAVE_ALSA - LIBS += -lasound -} - -QMAKE_CXXFLAGS += $$QT_CFLAGS_GSTREAMER -LIBS += $$QT_LIBS_GSTREAMER -lgstinterfaces-0.10 -lgstvideo-0.10 -lgstbase-0.10 -lgstaudio-0.10 - -# Input -HEADERS += \ - qgstreamermessage.h \ - qgstreamerbushelper.h \ - qgstreamervideooutputcontrol.h \ - qgstreamervideorendererinterface.h \ - qgstreamerserviceplugin.h \ - qgstreamervideoinputdevicecontrol.h \ - qgstreamervideorenderer.h \ - qgstvideobuffer.h \ - qvideosurfacegstsink.h - - -SOURCES += \ - qgstreamermessage.cpp \ - qgstreamerbushelper.cpp \ - qgstreamervideooutputcontrol.cpp \ - qgstreamervideorendererinterface.cpp \ - qgstreamerserviceplugin.cpp \ - qgstreamervideoinputdevicecontrol.cpp \ - qgstreamervideorenderer.cpp \ - qgstvideobuffer.cpp \ - qvideosurfacegstsink.cpp - - -!win32:!embedded:!mac:!symbian { - LIBS += -lXv - - HEADERS += \ - qgstreamervideooverlay.h \ - qgstreamervideowidget.h \ - qx11videosurface.h \ - qgstxvimagebuffer.h - - SOURCES += \ - qgstreamervideooverlay.cpp \ - qgstreamervideowidget.cpp \ - qx11videosurface.cpp \ - qgstxvimagebuffer.cpp -} - -include(mediaplayer/mediaplayer.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mediaservices -target.path = $$[QT_INSTALL_PLUGINS]/mediaservices -INSTALLS += target diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/mediaplayer.pri b/src/plugins/mediaservices/gstreamer/mediaplayer/mediaplayer.pri deleted file mode 100644 index 19ff034..0000000 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/mediaplayer.pri +++ /dev/null @@ -1,17 +0,0 @@ -INCLUDEPATH += $$PWD - -DEFINES += QMEDIA_GSTREAMER_PLAYER - -HEADERS += \ - $$PWD/qgstreamerplayercontrol.h \ - $$PWD/qgstreamerplayerservice.h \ - $$PWD/qgstreamerplayersession.h \ - $$PWD/qgstreamermetadataprovider.h - -SOURCES += \ - $$PWD/qgstreamerplayercontrol.cpp \ - $$PWD/qgstreamerplayerservice.cpp \ - $$PWD/qgstreamerplayersession.cpp \ - $$PWD/qgstreamermetadataprovider.cpp - - diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp deleted file mode 100644 index f51d024..0000000 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamermetadataprovider.h" -#include "qgstreamerplayersession.h" -#include - -#include - -QT_BEGIN_NAMESPACE - -struct QGstreamerMetaDataKeyLookup -{ - QtMediaServices::MetaData key; - const char *token; -}; - -static const QGstreamerMetaDataKeyLookup qt_gstreamerMetaDataKeys[] = -{ - { QtMediaServices::Title, GST_TAG_TITLE }, - //{ QtMediaServices::SubTitle, 0 }, - //{ QtMediaServices::Author, 0 }, - { QtMediaServices::Comment, GST_TAG_COMMENT }, - { QtMediaServices::Description, GST_TAG_DESCRIPTION }, - //{ QtMediaServices::Category, 0 }, - { QtMediaServices::Genre, GST_TAG_GENRE }, - { QtMediaServices::Year, "year" }, - //{ QtMediaServices::UserRating, 0 }, - - { QtMediaServices::Language, GST_TAG_LANGUAGE_CODE }, - - { QtMediaServices::Publisher, GST_TAG_ORGANIZATION }, - { QtMediaServices::Copyright, GST_TAG_COPYRIGHT }, - //{ QtMediaServices::ParentalRating, 0 }, - //{ QtMediaServices::RatingOrganisation, 0 }, - - // Media - //{ QtMediaServices::Size, 0 }, - //{ QtMediaServices::MediaType, 0 }, - { QtMediaServices::Duration, GST_TAG_DURATION }, - - // Audio - { QtMediaServices::AudioBitRate, GST_TAG_BITRATE }, - { QtMediaServices::AudioCodec, GST_TAG_AUDIO_CODEC }, - //{ QtMediaServices::ChannelCount, 0 }, - //{ QtMediaServices::Frequency, 0 }, - - // Music - { QtMediaServices::AlbumTitle, GST_TAG_ALBUM }, - { QtMediaServices::AlbumArtist, GST_TAG_ARTIST}, - { QtMediaServices::ContributingArtist, GST_TAG_PERFORMER }, -#if (GST_VERSION_MAJOR >= 0) && (GST_VERSION_MINOR >= 10) && (GST_VERSION_MICRO >= 19) - { QtMediaServices::Composer, GST_TAG_COMPOSER }, -#endif - //{ QtMediaServices::Conductor, 0 }, - //{ QtMediaServices::Lyrics, 0 }, - //{ QtMediaServices::Mood, 0 }, - { QtMediaServices::TrackNumber, GST_TAG_TRACK_NUMBER }, - - //{ QtMediaServices::CoverArtUrlSmall, 0 }, - //{ QtMediaServices::CoverArtUrlLarge, 0 }, - - // Image/Video - //{ QtMediaServices::Resolution, 0 }, - //{ QtMediaServices::PixelAspectRatio, 0 }, - - // Video - //{ QtMediaServices::VideoFrameRate, 0 }, - //{ QtMediaServices::VideoBitRate, 0 }, - { QtMediaServices::VideoCodec, GST_TAG_VIDEO_CODEC }, - - //{ QtMediaServices::PosterUrl, 0 }, - - // Movie - //{ QtMediaServices::ChapterNumber, 0 }, - //{ QtMediaServices::Director, 0 }, - { QtMediaServices::LeadPerformer, GST_TAG_PERFORMER }, - //{ QtMediaServices::Writer, 0 }, - - // Photos - //{ QtMediaServices::CameraManufacturer, 0 }, - //{ QtMediaServices::CameraModel, 0 }, - //{ QtMediaServices::Event, 0 }, - //{ QtMediaServices::Subject, 0 } -}; - -QGstreamerMetaDataProvider::QGstreamerMetaDataProvider(QGstreamerPlayerSession *session, QObject *parent) - :QMetaDataControl(parent), m_session(session) -{ - connect(m_session, SIGNAL(tagsChanged()), SLOT(updateTags())); -} - -QGstreamerMetaDataProvider::~QGstreamerMetaDataProvider() -{ -} - -bool QGstreamerMetaDataProvider::isMetaDataAvailable() const -{ - return !m_session->tags().isEmpty(); -} - -bool QGstreamerMetaDataProvider::isWritable() const -{ - return false; -} - -QVariant QGstreamerMetaDataProvider::metaData(QtMediaServices::MetaData key) const -{ - static const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); - - for (int i = 0; i < count; ++i) { - if (qt_gstreamerMetaDataKeys[i].key == key) { - return m_session->tags().value(QByteArray(qt_gstreamerMetaDataKeys[i].token)); - } - } - return QVariant(); -} - -void QGstreamerMetaDataProvider::setMetaData(QtMediaServices::MetaData key, QVariant const &value) -{ - Q_UNUSED(key); - Q_UNUSED(value); -} - -QList QGstreamerMetaDataProvider::availableMetaData() const -{ - static QMap keysMap; - if (keysMap.isEmpty()) { - const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); - for (int i = 0; i < count; ++i) { - keysMap[QByteArray(qt_gstreamerMetaDataKeys[i].token)] = qt_gstreamerMetaDataKeys[i].key; - } - } - - QList res; - foreach (const QByteArray &key, m_session->tags().keys()) { - QtMediaServices::MetaData tag = keysMap.value(key, QtMediaServices::MetaData(-1)); - if (tag != -1) - res.append(tag); - } - - return res; -} - -QVariant QGstreamerMetaDataProvider::extendedMetaData(const QString &key) const -{ - return m_session->tags().value(key.toLatin1()); -} - -void QGstreamerMetaDataProvider::setExtendedMetaData(const QString &key, QVariant const &value) -{ - Q_UNUSED(key); - Q_UNUSED(value); -} - -QStringList QGstreamerMetaDataProvider::availableExtendedMetaData() const -{ - QStringList res; - foreach (const QByteArray &key, m_session->tags().keys()) - res.append(QString(key)); - - return res; -} - -void QGstreamerMetaDataProvider::updateTags() -{ - emit metaDataChanged(); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.h deleted file mode 100644 index 4cf716a..0000000 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERMETADATAPROVIDER_H -#define QGSTREAMERMETADATAPROVIDER_H - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGstreamerPlayerSession; - -class QGstreamerMetaDataProvider : public QMetaDataControl -{ - Q_OBJECT -public: - QGstreamerMetaDataProvider( QGstreamerPlayerSession *session, QObject *parent ); - virtual ~QGstreamerMetaDataProvider(); - - bool isMetaDataAvailable() const; - bool isWritable() const; - - QVariant metaData(QtMediaServices::MetaData key) const; - void setMetaData(QtMediaServices::MetaData key, const QVariant &value); - QList availableMetaData() const; - - QVariant extendedMetaData(const QString &key) const ; - void setExtendedMetaData(const QString &key, const QVariant &value); - QStringList availableExtendedMetaData() const; - -private slots: - void updateTags(); - -private: - QGstreamerPlayerSession *m_session; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGSTREAMERMETADATAPROVIDER_H diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp deleted file mode 100644 index 6dd914a..0000000 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp +++ /dev/null @@ -1,501 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamerplayercontrol.h" -#include "qgstreamerplayersession.h" - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QGstreamerPlayerControl::QGstreamerPlayerControl(QGstreamerPlayerSession *session, QObject *parent) - : QMediaPlayerControl(parent) - , m_session(session) - , m_state(QMediaPlayer::StoppedState) - , m_mediaStatus(QMediaPlayer::NoMedia) - , m_bufferProgress(-1) - , m_seekToStartPending(false) - , m_stream(0) - , m_fifoNotifier(0) - , m_fifoCanWrite(false) - , m_bufferSize(0) - , m_bufferOffset(0) -{ - m_fifoFd[0] = -1; - m_fifoFd[1] = -1; - - connect(m_session, SIGNAL(positionChanged(qint64)), - this, SIGNAL(positionChanged(qint64))); - connect(m_session, SIGNAL(durationChanged(qint64)), - this, SIGNAL(durationChanged(qint64))); - connect(m_session, SIGNAL(mutedStateChanged(bool)), - this, SIGNAL(mutedChanged(bool))); - connect(m_session, SIGNAL(volumeChanged(int)), - this, SIGNAL(volumeChanged(int))); - connect(m_session, SIGNAL(stateChanged(QMediaPlayer::State)), - this, SLOT(updateState(QMediaPlayer::State))); - connect(m_session,SIGNAL(bufferingProgressChanged(int)), - this, SLOT(setBufferProgress(int))); - connect(m_session, SIGNAL(playbackFinished()), - this, SLOT(processEOS())); - connect(m_session, SIGNAL(audioAvailableChanged(bool)), - this, SIGNAL(audioAvailableChanged(bool))); - connect(m_session, SIGNAL(videoAvailableChanged(bool)), - this, SIGNAL(videoAvailableChanged(bool))); - connect(m_session, SIGNAL(seekableChanged(bool)), - this, SIGNAL(seekableChanged(bool))); - connect(m_session, SIGNAL(error(int,QString)), - this, SIGNAL(error(int,QString))); -} - -QGstreamerPlayerControl::~QGstreamerPlayerControl() -{ - if (m_fifoFd[0] >= 0) { - ::close(m_fifoFd[0]); - ::close(m_fifoFd[1]); - m_fifoFd[0] = -1; - m_fifoFd[1] = -1; - } -} - -qint64 QGstreamerPlayerControl::position() const -{ - return m_seekToStartPending ? 0 : m_session->position(); -} - -qint64 QGstreamerPlayerControl::duration() const -{ - return m_session->duration(); -} - -QMediaPlayer::State QGstreamerPlayerControl::state() const -{ - return m_state; -} - -QMediaPlayer::MediaStatus QGstreamerPlayerControl::mediaStatus() const -{ - return m_mediaStatus; -} - -int QGstreamerPlayerControl::bufferStatus() const -{ - if (m_bufferProgress == -1) { - return m_session->state() == QMediaPlayer::StoppedState ? 0 : 100; - } else - return m_bufferProgress; -} - -int QGstreamerPlayerControl::volume() const -{ - return m_session->volume(); -} - -bool QGstreamerPlayerControl::isMuted() const -{ - return m_session->isMuted(); -} - -bool QGstreamerPlayerControl::isSeekable() const -{ - return m_session->isSeekable(); -} - -QMediaTimeRange QGstreamerPlayerControl::availablePlaybackRanges() const -{ - QMediaTimeRange ranges; - - if (m_session->isSeekable()) - ranges.addInterval(0, m_session->duration()); - - return ranges; -} - -qreal QGstreamerPlayerControl::playbackRate() const -{ - return m_session->playbackRate(); -} - -void QGstreamerPlayerControl::setPlaybackRate(qreal rate) -{ - m_session->setPlaybackRate(rate); -} - -void QGstreamerPlayerControl::setPosition(qint64 pos) -{ - if (m_mediaStatus == QMediaPlayer::EndOfMedia) { - m_mediaStatus = QMediaPlayer::LoadedMedia; - emit mediaStatusChanged(m_mediaStatus); - } - - if (m_session->seek(pos)) - m_seekToStartPending = false; -} - -void QGstreamerPlayerControl::play() -{ - playOrPause(QMediaPlayer::PlayingState); -} - -void QGstreamerPlayerControl::pause() -{ - playOrPause(QMediaPlayer::PausedState); -} - -void QGstreamerPlayerControl::playOrPause(QMediaPlayer::State newState) -{ - QMediaPlayer::State oldState = m_state; - QMediaPlayer::MediaStatus oldMediaStatus = m_mediaStatus; - - if (m_mediaStatus == QMediaPlayer::EndOfMedia) - m_mediaStatus = QMediaPlayer::BufferedMedia; - - if (m_seekToStartPending) { - m_session->pause(); - if (!m_session->seek(0)) { - m_bufferProgress = -1; - m_session->stop(); - m_mediaStatus = QMediaPlayer::LoadingMedia; - } - m_seekToStartPending = false; - } - - bool ok = false; - if (newState == QMediaPlayer::PlayingState) - ok = m_session->play(); - else - ok = m_session->pause(); - - if (!ok) - return; - - m_state = newState; - - if (m_mediaStatus == QMediaPlayer::EndOfMedia || m_mediaStatus == QMediaPlayer::LoadedMedia) { - if (m_bufferProgress == -1 || m_bufferProgress == 100) - m_mediaStatus = QMediaPlayer::BufferedMedia; - else - m_mediaStatus = QMediaPlayer::BufferingMedia; - } - - if (m_state != oldState) - emit stateChanged(m_state); - if (m_mediaStatus != oldMediaStatus) - emit mediaStatusChanged(m_mediaStatus); - -} - -void QGstreamerPlayerControl::stop() -{ - if (m_state != QMediaPlayer::StoppedState) { - m_state = QMediaPlayer::StoppedState; - m_session->pause(); - m_seekToStartPending = true; - updateState(m_session->state()); - emit positionChanged(0); - emit stateChanged(m_state); - } -} - -void QGstreamerPlayerControl::setVolume(int volume) -{ - m_session->setVolume(volume); -} - -void QGstreamerPlayerControl::setMuted(bool muted) -{ - m_session->setMuted(muted); -} - -QMediaContent QGstreamerPlayerControl::media() const -{ - return m_currentResource; -} - -const QIODevice *QGstreamerPlayerControl::mediaStream() const -{ - return m_stream; -} - -void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice *stream) -{ - QMediaPlayer::State oldState = m_state; - m_state = QMediaPlayer::StoppedState; - m_session->stop(); - - if (m_bufferProgress != -1) { - m_bufferProgress = -1; - emit bufferStatusChanged(0); - } - - if (m_stream) { - closeFifo(); - - disconnect(m_stream, SIGNAL(readyRead()), this, SLOT(writeFifo())); - m_stream = 0; - } - - m_currentResource = content; - m_stream = stream; - m_seekToStartPending = false; - - QUrl url; - - if (m_stream) { - if (m_stream->isReadable() && openFifo()) { - url = QUrl(QString(QLatin1String("fd://%1")).arg(m_fifoFd[0])); - } - } else if (!content.isNull()) { - url = content.canonicalUrl(); - } - - m_session->load(url); - - if (m_fifoFd[1] >= 0) { - m_fifoCanWrite = true; - - writeFifo(); - } - - if (!url.isEmpty()) { - if (m_mediaStatus != QMediaPlayer::LoadingMedia) - emit mediaStatusChanged(m_mediaStatus = QMediaPlayer::LoadingMedia); - m_session->pause(); - } else { - if (m_mediaStatus != QMediaPlayer::NoMedia) - emit mediaStatusChanged(m_mediaStatus = QMediaPlayer::NoMedia); - setBufferProgress(0); - } - - emit mediaChanged(m_currentResource); - if (m_state != oldState) - emit stateChanged(m_state); -} - -void QGstreamerPlayerControl::setVideoOutput(QObject *output) -{ - m_session->setVideoRenderer(output); -} - -bool QGstreamerPlayerControl::isAudioAvailable() const -{ - return m_session->isAudioAvailable(); -} - -bool QGstreamerPlayerControl::isVideoAvailable() const -{ - return m_session->isVideoAvailable(); -} - -void QGstreamerPlayerControl::updateState(QMediaPlayer::State state) -{ - QMediaPlayer::MediaStatus oldStatus = m_mediaStatus; - QMediaPlayer::State oldState = m_state; - - switch (state) { - case QMediaPlayer::StoppedState: - m_state = QMediaPlayer::StoppedState; - if (m_currentResource.isNull()) - m_mediaStatus = QMediaPlayer::NoMedia; - else - m_mediaStatus = QMediaPlayer::LoadingMedia; - break; - - case QMediaPlayer::PlayingState: - case QMediaPlayer::PausedState: - if (m_state == QMediaPlayer::StoppedState) { - m_mediaStatus = QMediaPlayer::LoadedMedia; - } else { - if (m_bufferProgress == -1 || m_bufferProgress == 100) - m_mediaStatus = QMediaPlayer::BufferedMedia; - } - break; - } - - //EndOfMedia status should be kept, until reset by pause, play or setMedia - if (oldStatus == QMediaPlayer::EndOfMedia) - m_mediaStatus = QMediaPlayer::EndOfMedia; - - if (m_state != oldState) - emit stateChanged(m_state); - if (m_mediaStatus != oldStatus) - emit mediaStatusChanged(m_mediaStatus); -} - -void QGstreamerPlayerControl::processEOS() -{ - m_mediaStatus = QMediaPlayer::EndOfMedia; - stop(); - emit mediaStatusChanged(m_mediaStatus); -} - -void QGstreamerPlayerControl::setBufferProgress(int progress) -{ - if (m_bufferProgress == progress || m_mediaStatus == QMediaPlayer::NoMedia) - return; - - QMediaPlayer::MediaStatus oldStatus = m_mediaStatus; - - m_bufferProgress = progress; - - if (m_state == QMediaPlayer::StoppedState) { - m_mediaStatus = QMediaPlayer::LoadedMedia; - } else { - if (m_bufferProgress < 100) { - m_mediaStatus = QMediaPlayer::StalledMedia; - m_session->pause(); - } else { - m_mediaStatus = QMediaPlayer::BufferedMedia; - if (m_state == QMediaPlayer::PlayingState) - m_session->play(); - } - } - - if (m_mediaStatus != oldStatus) - emit mediaStatusChanged(m_mediaStatus); - - emit bufferStatusChanged(m_bufferProgress); -} - -void QGstreamerPlayerControl::writeFifo() -{ - if (m_fifoCanWrite) { - qint64 bytesToRead = qMin( - m_stream->bytesAvailable(), PIPE_BUF - m_bufferSize); - - if (bytesToRead > 0) { - int bytesRead = m_stream->read(&m_buffer[m_bufferOffset + m_bufferSize], bytesToRead); - - if (bytesRead > 0) - m_bufferSize += bytesRead; - } - - if (m_bufferSize > 0) { - int bytesWritten = ::write(m_fifoFd[1], &m_buffer[m_bufferOffset], size_t(m_bufferSize)); - - if (bytesWritten > 0) { - m_bufferOffset += bytesWritten; - m_bufferSize -= bytesWritten; - - if (m_bufferSize == 0) - m_bufferOffset = 0; - } else if (errno == EAGAIN) { - m_fifoCanWrite = false; - } else { - closeFifo(); - } - } - } - - m_fifoNotifier->setEnabled(m_stream->bytesAvailable() > 0); -} - -void QGstreamerPlayerControl::fifoReadyWrite(int socket) -{ - if (socket == m_fifoFd[1]) { - m_fifoCanWrite = true; - - writeFifo(); - } -} - -bool QGstreamerPlayerControl::openFifo() -{ - Q_ASSERT(m_fifoFd[0] < 0); - Q_ASSERT(m_fifoFd[1] < 0); - - if (::pipe(m_fifoFd) == 0) { - int flags = ::fcntl(m_fifoFd[1], F_GETFD); - - if (::fcntl(m_fifoFd[1], F_SETFD, flags | O_NONBLOCK) >= 0) { - m_fifoNotifier = new QSocketNotifier(m_fifoFd[1], QSocketNotifier::Write); - - connect(m_fifoNotifier, SIGNAL(activated(int)), this, SLOT(fifoReadyWrite(int))); - - return true; - } else { - qWarning("Failed to make pipe non blocking %d", errno); - - ::close(m_fifoFd[0]); - ::close(m_fifoFd[1]); - - m_fifoFd[0] = -1; - m_fifoFd[1] = -1; - - return false; - } - } else { - qWarning("Failed to create pipe %d", errno); - - return false; - } -} - -void QGstreamerPlayerControl::closeFifo() -{ - if (m_fifoFd[0] >= 0) { - delete m_fifoNotifier; - m_fifoNotifier = 0; - - ::close(m_fifoFd[0]); - ::close(m_fifoFd[1]); - m_fifoFd[0] = -1; - m_fifoFd[1] = -1; - - m_fifoCanWrite = false; - - m_bufferSize = 0; - m_bufferOffset = 0; - } -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h deleted file mode 100644 index c95f37a..0000000 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERPLAYERCONTROL_H -#define QGSTREAMERPLAYERCONTROL_H - -#include - -#include -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlaylist; -class QGstreamerPlayerSession; -class QGstreamerPlayerService; -class QMediaPlaylistNavigator; -class QSocketNotifier; - -class QGstreamerPlayerControl : public QMediaPlayerControl -{ - Q_OBJECT - -public: - QGstreamerPlayerControl(QGstreamerPlayerSession *session, QObject *parent = 0); - ~QGstreamerPlayerControl(); - - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; - - qint64 position() const; - qint64 duration() const; - - int bufferStatus() const; - - int volume() const; - bool isMuted() const; - - bool isAudioAvailable() const; - bool isVideoAvailable() const; - void setVideoOutput(QObject *output); - - bool isSeekable() const; - QMediaTimeRange availablePlaybackRanges() const; - - qreal playbackRate() const; - void setPlaybackRate(qreal rate); - - QMediaContent media() const; - const QIODevice *mediaStream() const; - void setMedia(const QMediaContent&, QIODevice *); - -public Q_SLOTS: - void setPosition(qint64 pos); - - void play(); - void pause(); - void stop(); - - void setVolume(int volume); - void setMuted(bool muted); - -private Q_SLOTS: - void writeFifo(); - void fifoReadyWrite(int socket); - - void updateState(QMediaPlayer::State); - void processEOS(); - void setBufferProgress(int progress); - -private: - bool openFifo(); - void closeFifo(); - void playOrPause(QMediaPlayer::State state); - - QGstreamerPlayerSession *m_session; - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_mediaStatus; - int m_bufferProgress; - bool m_seekToStartPending; - QMediaContent m_currentResource; - QIODevice *m_stream; - QSocketNotifier *m_fifoNotifier; - int m_fifoFd[2]; - bool m_fifoCanWrite; - int m_bufferSize; - int m_bufferOffset; - char m_buffer[PIPE_BUF]; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp deleted file mode 100644 index 3228722..0000000 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamerplayerservice.h" -#include "qgstreamerplayercontrol.h" -#include "qgstreamerplayersession.h" -#include "qgstreamermetadataprovider.h" -#include "qgstreamervideooutputcontrol.h" - -#include "qgstreamervideooverlay.h" -#include "qgstreamervideorenderer.h" - -#include "qgstreamervideowidget.h" -//#include "qgstreamerstreamscontrol.h" - -#include -#include - - -QT_BEGIN_NAMESPACE - - -QGstreamerPlayerService::QGstreamerPlayerService(QObject *parent): - QMediaService(parent), - m_videoRenderer(0), - m_videoWindow(0), - m_videoWidget(0) -{ - m_session = new QGstreamerPlayerSession(this); - m_control = new QGstreamerPlayerControl(m_session, this); - m_metaData = new QGstreamerMetaDataProvider(m_session, this); - m_videoOutput = new QGstreamerVideoOutputControl(this); -// m_streamsControl = new QGstreamerStreamsControl(m_session,this); - - connect(m_videoOutput, SIGNAL(outputChanged(QVideoOutputControl::Output)), - this, SLOT(videoOutputChanged(QVideoOutputControl::Output))); - m_videoRenderer = new QGstreamerVideoRenderer(this); - -#ifdef Q_WS_X11 - m_videoWindow = new QGstreamerVideoOverlay(this); - m_videoWidget = new QGstreamerVideoWidgetControl(this); -#endif - - QList outputs; - - if (m_videoRenderer) - outputs << QVideoOutputControl::RendererOutput; - if (m_videoWidget) - outputs << QVideoOutputControl::WidgetOutput; - if (m_videoWindow) - outputs << QVideoOutputControl::WindowOutput; - - m_videoOutput->setAvailableOutputs(outputs); -} - -QGstreamerPlayerService::~QGstreamerPlayerService() -{ -} - -QMediaControl *QGstreamerPlayerService::control(const char *name) const -{ - if (qstrcmp(name,QMediaPlayerControl_iid) == 0) - return m_control; - - if (qstrcmp(name,QMetaDataControl_iid) == 0) - return m_metaData; - -// if (qstrcmp(name,QMediaStreamsControl_iid) == 0) -// return m_streamsControl; - - if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return m_videoOutput; - - if (qstrcmp(name, QVideoWidgetControl_iid) == 0) - return m_videoWidget; - - if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return m_videoRenderer; - - if (qstrcmp(name, QVideoWindowControl_iid) == 0) - return m_videoWindow; - - return 0; -} - -void QGstreamerPlayerService::videoOutputChanged(QVideoOutputControl::Output output) -{ - switch (output) { - case QVideoOutputControl::NoOutput: - m_control->setVideoOutput(0); - break; - case QVideoOutputControl::RendererOutput: - m_control->setVideoOutput(m_videoRenderer); - break; - case QVideoOutputControl::WindowOutput: - m_control->setVideoOutput(m_videoWindow); - break; - case QVideoOutputControl::WidgetOutput: - m_control->setVideoOutput(m_videoWidget); - break; - default: - qWarning("Invalid video output selection"); - break; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.h deleted file mode 100644 index 1283966..0000000 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERPLAYERSERVICE_H -#define QGSTREAMERPLAYERSERVICE_H - -#include -#include - -#include - -#include "qgstreamervideooutputcontrol.h" - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaMetaData; -class QMediaPlayerControl; -class QMediaPlaylist; -class QMediaPlaylistNavigator; -class QGstreamerMetaData; -class QGstreamerPlayerControl; -class QGstreamerPlayerSession; -class QGstreamerMetaDataProvider; -class QGstreamerStreamsControl; -class QGstreamerVideoRenderer; -class QGstreamerVideoOverlay; -class QGstreamerVideoWidgetControl; - - -class QGstreamerPlayerService : public QMediaService -{ - Q_OBJECT -public: - QGstreamerPlayerService(QObject *parent = 0); - ~QGstreamerPlayerService(); - - //void setVideoOutput(QObject *output); - - QMediaControl *control(const char *name) const; - -private slots: - void videoOutputChanged(QVideoOutputControl::Output output); - -private: - QGstreamerPlayerControl *m_control; - QGstreamerPlayerSession *m_session; - QGstreamerMetaDataProvider *m_metaData; - QGstreamerVideoOutputControl *m_videoOutput; - QGstreamerStreamsControl *m_streamsControl; - - QGstreamerVideoRenderer *m_videoRenderer; - QGstreamerVideoOverlay *m_videoWindow; - QGstreamerVideoWidgetControl *m_videoWidget; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp deleted file mode 100644 index 6a44aa1..0000000 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp +++ /dev/null @@ -1,924 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamerplayersession.h" -#include "qgstreamerbushelper.h" - -#include "qgstreamervideorendererinterface.h" - -#include - -#include -#include - -//#define USE_PLAYBIN2 - -//#define DEBUG_VO_BIN_DUMP -//#define DEBUG_PLAYBIN_STATES - - -QT_BEGIN_NAMESPACE - -QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent) - :QObject(parent), - m_state(QMediaPlayer::StoppedState), - m_busHelper(0), - m_playbin(0), - m_videoSink(0), - m_pendingVideoSink(0), - m_nullVideoSink(0), - m_bus(0), - m_renderer(0), - m_volume(100), - m_playbackRate(1.0), - m_muted(false), - m_audioAvailable(false), - m_videoAvailable(false), - m_seekable(false), - m_lastPosition(0), - m_duration(-1) -{ - static bool initialized = false; - if (!initialized) { - initialized = true; - gst_init(NULL, NULL); - } - -#ifdef USE_PLAYBIN2 - m_playbin = gst_element_factory_make("playbin2", NULL); -#else - m_playbin = gst_element_factory_make("playbin", NULL); -#endif - - m_videoOutputBin = gst_bin_new("video-output-bin"); - gst_object_ref(GST_OBJECT(m_videoOutputBin)); - - m_videoIdentity = gst_element_factory_make("identity", "identity-vo"); - m_colorSpace = gst_element_factory_make("ffmpegcolorspace", "ffmpegcolorspace-vo"); - m_videoScale = gst_element_factory_make("videoscale","videoscale-vo"); - m_nullVideoSink = gst_element_factory_make("fakesink", NULL); - gst_object_ref(GST_OBJECT(m_nullVideoSink)); - gst_bin_add_many(GST_BIN(m_videoOutputBin), m_videoIdentity, m_colorSpace, m_videoScale, m_nullVideoSink, NULL); - gst_element_link_many(m_videoIdentity, m_colorSpace, m_videoScale, m_nullVideoSink, NULL); - - m_videoSink = m_nullVideoSink; - - // add ghostpads - GstPad *pad = gst_element_get_static_pad(m_videoIdentity,"sink"); - gst_element_add_pad(GST_ELEMENT(m_videoOutputBin), gst_ghost_pad_new("videosink", pad)); - gst_object_unref(GST_OBJECT(pad)); - - - if (m_playbin != 0) { - // Sort out messages - m_bus = gst_element_get_bus(m_playbin); - m_busHelper = new QGstreamerBusHelper(m_bus, this); - connect(m_busHelper, SIGNAL(message(QGstreamerMessage)), SLOT(busMessage(QGstreamerMessage))); - m_busHelper->installSyncEventFilter(this); - - g_object_set(G_OBJECT(m_playbin), "video-sink", m_videoOutputBin, NULL); - - // Initial volume - double volume = 1.0; - g_object_get(G_OBJECT(m_playbin), "volume", &volume, NULL); - m_volume = int(volume*100); - } -} - -QGstreamerPlayerSession::~QGstreamerPlayerSession() -{ - if (m_playbin) { - stop(); - - delete m_busHelper; - gst_object_unref(GST_OBJECT(m_bus)); - gst_object_unref(GST_OBJECT(m_playbin)); - gst_object_unref(GST_OBJECT(m_nullVideoSink)); - gst_object_unref(GST_OBJECT(m_videoOutputBin)); - } -} - -void QGstreamerPlayerSession::load(const QUrl &url) -{ - m_url = url; - - if (m_playbin) { - m_tags.clear(); - emit tagsChanged(); - - g_object_set(G_OBJECT(m_playbin), "uri", m_url.toEncoded().constData(), NULL); - -// if (!m_streamTypes.isEmpty()) { -// m_streamProperties.clear(); -// m_streamTypes.clear(); -// -// emit streamsChanged(); -// } - } -} - -qint64 QGstreamerPlayerSession::duration() const -{ - return m_duration; -} - -qint64 QGstreamerPlayerSession::position() const -{ - GstFormat format = GST_FORMAT_TIME; - gint64 position = 0; - - if ( m_playbin && gst_element_query_position(m_playbin, &format, &position)) - return position / 1000000; - else - return 0; -} - -qreal QGstreamerPlayerSession::playbackRate() const -{ - return m_playbackRate; -} - -void QGstreamerPlayerSession::setPlaybackRate(qreal rate) -{ - if (!qFuzzyCompare(m_playbackRate, rate)) { - m_playbackRate = rate; - if (m_playbin) { - gst_element_seek(m_playbin, rate, GST_FORMAT_TIME, - GstSeekFlags(GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH), - GST_SEEK_TYPE_NONE,0, - GST_SEEK_TYPE_NONE,0 ); - } - } -} - - -//int QGstreamerPlayerSession::activeStream(QMediaStreamsControl::StreamType streamType) const -//{ -// int streamNumber = -1; -// if (m_playbin) { -// switch (streamType) { -// case QMediaStreamsControl::AudioStream: -// g_object_set(G_OBJECT(m_playbin), "current-audio", streamNumber, NULL); -// break; -// case QMediaStreamsControl::VideoStream: -// g_object_set(G_OBJECT(m_playbin), "current-video", streamNumber, NULL); -// break; -// case QMediaStreamsControl::SubPictureStream: -// g_object_set(G_OBJECT(m_playbin), "current-text", streamNumber, NULL); -// break; -// default: -// break; -// } -// } -// -//#ifdef USE_PLAYBIN2 -// streamNumber += m_playbin2StreamOffset.value(streamType,0); -//#endif -// -// return streamNumber; -//} - -//void QGstreamerPlayerSession::setActiveStream(QMediaStreamsControl::StreamType streamType, int streamNumber) -//{ -//#ifdef USE_PLAYBIN2 -// streamNumber -= m_playbin2StreamOffset.value(streamType,0); -//#endif -// -// if (m_playbin) { -// switch (streamType) { -// case QMediaStreamsControl::AudioStream: -// g_object_get(G_OBJECT(m_playbin), "current-audio", &streamNumber, NULL); -// break; -// case QMediaStreamsControl::VideoStream: -// g_object_get(G_OBJECT(m_playbin), "current-video", &streamNumber, NULL); -// break; -// case QMediaStreamsControl::SubPictureStream: -// g_object_get(G_OBJECT(m_playbin), "current-text", &streamNumber, NULL); -// break; -// default: -// break; -// } -// } -//} - - -bool QGstreamerPlayerSession::isBuffering() const -{ - return false; -} - -int QGstreamerPlayerSession::bufferingProgress() const -{ - return 0; -} - -int QGstreamerPlayerSession::volume() const -{ - return m_volume; -} - -bool QGstreamerPlayerSession::isMuted() const -{ - return m_muted; -} - -bool QGstreamerPlayerSession::isAudioAvailable() const -{ - return m_audioAvailable; -} - -static void block_pad_cb(GstPad *pad, gboolean blocked, gpointer user_data) -{ - Q_UNUSED(pad); - //qDebug() << "block_pad_cb" << blocked; - - if (blocked && user_data) { - QGstreamerPlayerSession *session = reinterpret_cast(user_data); - QMetaObject::invokeMethod(session, "finishVideoOutputChange", Qt::QueuedConnection); - } -} - -#ifdef DEBUG_VO_BIN_DUMP - static int dumpNum = 0; -#endif - -void QGstreamerPlayerSession::setVideoRenderer(QObject *videoOutput) -{ - QGstreamerVideoRendererInterface* renderer = qobject_cast(videoOutput); - - if (m_renderer == renderer) - return; - -#ifdef DEBUG_VO_BIN_DUMP - dumpNum++; - - _gst_debug_bin_to_dot_file(GST_BIN(m_videoOutputBin), - GstDebugGraphDetails(GST_DEBUG_GRAPH_SHOW_ALL /* GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE | GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS | GST_DEBUG_GRAPH_SHOW_STATES*/), - QString("video_output_change_%1_set").arg(dumpNum).toAscii().constData()); -#endif - - m_renderer = renderer; - - GstElement *videoSink = m_renderer ? m_renderer->videoSink() : m_nullVideoSink; - - if (m_state == QMediaPlayer::StoppedState) { - m_pendingVideoSink = 0; - gst_element_unlink(m_videoScale, m_videoSink); - - gst_bin_remove(GST_BIN(m_videoOutputBin), m_videoSink); - - m_videoSink = videoSink; - - gst_bin_add(GST_BIN(m_videoOutputBin), m_videoSink); - gst_element_link(m_videoScale, m_videoSink); - - } else { - if (m_pendingVideoSink) { - m_pendingVideoSink = videoSink; - return; - } - - m_pendingVideoSink = videoSink; - - //block pads, async to avoid locking in paused state - GstPad *srcPad = gst_element_get_static_pad(m_videoIdentity, "src"); - gst_pad_set_blocked_async(srcPad, true, &block_pad_cb, this); - gst_object_unref(GST_OBJECT(srcPad)); - } -} - -void QGstreamerPlayerSession::finishVideoOutputChange() -{ - if (!m_pendingVideoSink) - return; - - GstPad *srcPad = gst_element_get_static_pad(m_videoIdentity, "src"); - - if (!gst_pad_is_blocked(srcPad)) { - //pad is not blocked, it's possible to swap outputs only in the null state - GstState identityElementState = GST_STATE_NULL; - gst_element_get_state(m_videoIdentity, &identityElementState, NULL, GST_CLOCK_TIME_NONE); - if (identityElementState != GST_STATE_NULL) { - gst_object_unref(GST_OBJECT(srcPad)); - return; //can't change vo yet, received async call from the previous change - } - - } - - if (m_pendingVideoSink == m_videoSink) { - //video output was change back to the current one, - //no need to torment the pipeline, just unblock the pad - if (gst_pad_is_blocked(srcPad)) - gst_pad_set_blocked_async(srcPad, false, &block_pad_cb, 0); - - m_pendingVideoSink = 0; - gst_object_unref(GST_OBJECT(srcPad)); - return; - } - - gst_element_set_state(m_colorSpace, GST_STATE_NULL); - gst_element_set_state(m_videoScale, GST_STATE_NULL); - gst_element_set_state(m_videoSink, GST_STATE_NULL); - - gst_element_unlink(m_videoScale, m_videoSink); - - gst_bin_remove(GST_BIN(m_videoOutputBin), m_videoSink); - - m_videoSink = m_pendingVideoSink; - m_pendingVideoSink = 0; - - gst_bin_add(GST_BIN(m_videoOutputBin), m_videoSink); - if (!gst_element_link(m_videoScale, m_videoSink)) - qWarning() << "Linking video output element failed"; - - GstState state; - - switch (m_state) { - case QMediaPlayer::StoppedState: - state = GST_STATE_NULL; - break; - case QMediaPlayer::PausedState: - state = GST_STATE_PAUSED; - break; - case QMediaPlayer::PlayingState: - state = GST_STATE_PLAYING; - break; - } - - gst_element_set_state(m_colorSpace, state); - gst_element_set_state(m_videoScale, state); - gst_element_set_state(m_videoSink, state); - - //don't have to wait here, it will unblock eventually - if (gst_pad_is_blocked(srcPad)) - gst_pad_set_blocked_async(srcPad, false, &block_pad_cb, 0); - gst_object_unref(GST_OBJECT(srcPad)); - -#ifdef DEBUG_VO_BIN_DUMP - dumpNum++; - - _gst_debug_bin_to_dot_file(GST_BIN(m_videoOutputBin), - GstDebugGraphDetails(/*GST_DEBUG_GRAPH_SHOW_ALL */ GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE | GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS | GST_DEBUG_GRAPH_SHOW_STATES), - QString("video_output_change_%1_finish").arg(dumpNum).toAscii().constData()); -#endif - -} - -bool QGstreamerPlayerSession::isVideoAvailable() const -{ - return m_videoAvailable; -} - -bool QGstreamerPlayerSession::isSeekable() const -{ - return m_seekable; -} - -bool QGstreamerPlayerSession::play() -{ - if (m_playbin) { - if (gst_element_set_state(m_playbin, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { - qWarning() << "GStreamer; Unable to play -" << m_url.toString(); - m_state = QMediaPlayer::StoppedState; - - emit stateChanged(m_state); - emit error(int(QMediaPlayer::ResourceError), tr("Unable to play %1").arg(m_url.path())); - } else - return true; - } - - return false; -} - -bool QGstreamerPlayerSession::pause() -{ - if (m_playbin) { - if (gst_element_set_state(m_playbin, GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) { - qWarning() << "GStreamer; Unable to play -" << m_url.toString(); - m_state = QMediaPlayer::StoppedState; - - emit stateChanged(m_state); - emit error(int(QMediaPlayer::ResourceError), tr("Unable to play %1").arg(m_url.path())); - } else - return true; - } - - return false; -} - -void QGstreamerPlayerSession::stop() -{ - if (m_playbin) { - gst_element_set_state(m_playbin, GST_STATE_NULL); - - QMediaPlayer::State oldState = QMediaPlayer::StoppedState; - m_state = QMediaPlayer::StoppedState; - - finishVideoOutputChange(); - - //we have to do it here, since gstreamer will not emit bus messages any more - if (oldState != m_state) - emit stateChanged(m_state); - } -} - -bool QGstreamerPlayerSession::seek(qint64 ms) -{ - //seek locks when the video output sink is changing and pad is blocked - if (m_playbin && !m_pendingVideoSink && m_state != QMediaPlayer::StoppedState) { - - gint64 position = qMax(ms,qint64(0)) * 1000000; - return gst_element_seek(m_playbin, - m_playbackRate, - GST_FORMAT_TIME, - GstSeekFlags(GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH), - GST_SEEK_TYPE_SET, - position, - GST_SEEK_TYPE_NONE, - 0); - } - - return false; -} - -void QGstreamerPlayerSession::setVolume(int volume) -{ - if (m_volume != volume) { - m_volume = volume; - - if (m_playbin) { -#ifndef USE_PLAYBIN2 - if(!m_muted) -#endif - g_object_set(G_OBJECT(m_playbin), "volume", m_volume/100.0, NULL); - } - - emit volumeChanged(m_volume); - } - -} - -void QGstreamerPlayerSession::setMuted(bool muted) -{ - if (m_muted != muted) { - m_muted = muted; - -#ifdef USE_PLAYBIN2 - g_object_set(G_OBJECT(m_playbin), "mute", m_muted, NULL); -#else - g_object_set(G_OBJECT(m_playbin), "volume", (m_muted ? 0 : m_volume/100.0), NULL); -#endif - emit mutedStateChanged(m_muted); - } -} - -static void addTagToMap(const GstTagList *list, - const gchar *tag, - gpointer user_data) -{ - QMap *map = reinterpret_cast* >(user_data); - - GValue val; - val.g_type = 0; - gst_tag_list_copy_value(&val,list,tag); - - switch( G_VALUE_TYPE(&val) ) { - case G_TYPE_STRING: - { - const gchar *str_value = g_value_get_string(&val); - map->insert(QByteArray(tag), QString::fromUtf8(str_value)); - break; - } - case G_TYPE_INT: - map->insert(QByteArray(tag), g_value_get_int(&val)); - break; - case G_TYPE_UINT: - map->insert(QByteArray(tag), g_value_get_uint(&val)); - break; - case G_TYPE_LONG: - map->insert(QByteArray(tag), qint64(g_value_get_long(&val))); - break; - case G_TYPE_BOOLEAN: - map->insert(QByteArray(tag), g_value_get_boolean(&val)); - break; - case G_TYPE_CHAR: - map->insert(QByteArray(tag), g_value_get_char(&val)); - break; - case G_TYPE_DOUBLE: - map->insert(QByteArray(tag), g_value_get_double(&val)); - break; - default: - // GST_TYPE_DATE is a function, not a constant, so pull it out of the switch - if (G_VALUE_TYPE(&val) == GST_TYPE_DATE) { - const GDate *date = gst_value_get_date(&val); - if (g_date_valid(date)) { - int year = g_date_get_year(date); - int month = g_date_get_month(date); - int day = g_date_get_day(date); - map->insert(QByteArray(tag), QDate(year,month,day)); - if (!map->contains("year")) - map->insert("year", year); - } - } else if (G_VALUE_TYPE(&val) == GST_TYPE_FRACTION) { - int nom = gst_value_get_fraction_numerator(&val); - int denom = gst_value_get_fraction_denominator(&val); - - if (denom > 0) { - map->insert(QByteArray(tag), double(nom)/denom); - } - } - break; - } - - g_value_unset(&val); -} - -void QGstreamerPlayerSession::setSeekable(bool seekable) -{ - if (seekable != m_seekable) { - m_seekable = seekable; - emit seekableChanged(m_seekable); - } -} - -bool QGstreamerPlayerSession::processSyncMessage(const QGstreamerMessage &message) -{ - GstMessage* gm = message.rawMessage(); - - if (gm && - GST_MESSAGE_TYPE(gm) == GST_MESSAGE_ELEMENT && - gst_structure_has_name(gm->structure, "prepare-xwindow-id")) - { - if (m_renderer) - m_renderer->precessNewStream(); - return true; - } - - return false; -} - -void QGstreamerPlayerSession::busMessage(const QGstreamerMessage &message) -{ - GstMessage* gm = message.rawMessage(); - - if (gm == 0) { - // Null message, query current position - quint32 newPos = position(); - - if (newPos/1000 != m_lastPosition) { - m_lastPosition = newPos/1000; - emit positionChanged(newPos); - } - - } else { - //tag message comes from elements inside playbin, not from playbin itself - if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_TAG) { - //qDebug() << "tag message"; - GstTagList *tag_list; - gst_message_parse_tag(gm, &tag_list); - gst_tag_list_foreach(tag_list, addTagToMap, &m_tags); - - //qDebug() << m_tags; - - emit tagsChanged(); - } - - if (GST_MESSAGE_SRC(gm) == GST_OBJECT_CAST(m_playbin)) { - switch (GST_MESSAGE_TYPE(gm)) { - case GST_MESSAGE_STATE_CHANGED: - { - GstState oldState; - GstState newState; - GstState pending; - - gst_message_parse_state_changed(gm, &oldState, &newState, &pending); - -#ifdef DEBUG_PLAYBIN_STATES - QStringList states; - states << "GST_STATE_VOID_PENDING" << "GST_STATE_NULL" << "GST_STATE_READY" << "GST_STATE_PAUSED" << "GST_STATE_PLAYING"; - - qDebug() << QString("state changed: old: %1 new: %2 pending: %3") \ - .arg(states[oldState]) \ - .arg(states[newState]) \ - .arg(states[pending]); -#endif - - switch (newState) { - case GST_STATE_VOID_PENDING: - case GST_STATE_NULL: - setSeekable(false); - if (m_state != QMediaPlayer::StoppedState) - emit stateChanged(m_state = QMediaPlayer::StoppedState); - break; - case GST_STATE_READY: - setSeekable(false); - if (m_state != QMediaPlayer::StoppedState) - emit stateChanged(m_state = QMediaPlayer::StoppedState); - break; - case GST_STATE_PAUSED: - if (m_state != QMediaPlayer::PausedState) - emit stateChanged(m_state = QMediaPlayer::PausedState); - - //check for seekable - if (oldState == GST_STATE_READY) { - /* - //gst_element_seek_simple doesn't work reliably here, have to find a better solution - - GstFormat format = GST_FORMAT_TIME; - gint64 position = 0; - bool seekable = false; - if (gst_element_query_position(m_playbin, &format, &position)) { - seekable = gst_element_seek_simple(m_playbin, format, GST_SEEK_FLAG_NONE, position); - } - - setSeekable(seekable); - */ - - setSeekable(true); - - if (!qFuzzyCompare(m_playbackRate, qreal(1.0))) { - qreal rate = m_playbackRate; - m_playbackRate = 1.0; - setPlaybackRate(rate); - } - - if (m_renderer) - m_renderer->precessNewStream(); - - } - - - break; - case GST_STATE_PLAYING: - if (oldState == GST_STATE_PAUSED) - getStreamsInfo(); - - if (m_state != QMediaPlayer::PlayingState) - emit stateChanged(m_state = QMediaPlayer::PlayingState); - - break; - } - } - break; - - case GST_MESSAGE_EOS: - emit playbackFinished(); - break; - - case GST_MESSAGE_TAG: - case GST_MESSAGE_STREAM_STATUS: - case GST_MESSAGE_UNKNOWN: - break; - case GST_MESSAGE_ERROR: - { - GError *err; - gchar *debug; - gst_message_parse_error (gm, &err, &debug); - emit error(int(QMediaPlayer::ResourceError), QString::fromUtf8(err->message)); - qWarning() << "Error:" << QString::fromUtf8(err->message); - g_error_free (err); - g_free (debug); - } - break; - case GST_MESSAGE_WARNING: - case GST_MESSAGE_INFO: - break; - case GST_MESSAGE_BUFFERING: - { - int progress = 0; - gst_message_parse_buffering(gm, &progress); - emit bufferingProgressChanged(progress); - } - break; - case GST_MESSAGE_STATE_DIRTY: - case GST_MESSAGE_STEP_DONE: - case GST_MESSAGE_CLOCK_PROVIDE: - case GST_MESSAGE_CLOCK_LOST: - case GST_MESSAGE_NEW_CLOCK: - case GST_MESSAGE_STRUCTURE_CHANGE: - case GST_MESSAGE_APPLICATION: - case GST_MESSAGE_ELEMENT: - break; - case GST_MESSAGE_SEGMENT_START: - { - const GstStructure *structure = gst_message_get_structure(gm); - qint64 position = g_value_get_int64(gst_structure_get_value(structure, "position")); - position /= 1000000; - m_lastPosition = position; - emit positionChanged(position); - } - break; - case GST_MESSAGE_SEGMENT_DONE: - break; - case GST_MESSAGE_DURATION: - { - GstFormat format = GST_FORMAT_TIME; - gint64 duration = 0; - - if (gst_element_query_duration(m_playbin, &format, &duration)) { - int newDuration = duration / 1000000; - if (m_duration != newDuration) { - m_duration = newDuration; - emit durationChanged(m_duration); - } - } - } - break; - case GST_MESSAGE_LATENCY: -#if (GST_VERSION_MAJOR >= 0) && (GST_VERSION_MINOR >= 10) && (GST_VERSION_MICRO >= 13) - case GST_MESSAGE_ASYNC_START: - case GST_MESSAGE_ASYNC_DONE: -#if GST_VERSION_MICRO >= 23 - case GST_MESSAGE_REQUEST_STATE: -#endif -#endif - case GST_MESSAGE_ANY: - break; - } - } - } -} - -void QGstreamerPlayerSession::getStreamsInfo() -{ - GstFormat format = GST_FORMAT_TIME; - gint64 duration = 0; - - if (gst_element_query_duration(m_playbin, &format, &duration)) { - int newDuration = duration / 1000000; - if (m_duration != newDuration) { - m_duration = newDuration; - emit durationChanged(m_duration); - } - } - - //check if video is available: - bool haveAudio = false; - bool haveVideo = false; -// m_streamProperties.clear(); -// m_streamTypes.clear(); - -#ifdef USE_PLAYBIN2 - gint audioStreamsCount = 0; - gint videoStreamsCount = 0; - gint textStreamsCount = 0; - - g_object_get(G_OBJECT(m_playbin), "n-audio", &audioStreamsCount, NULL); - g_object_get(G_OBJECT(m_playbin), "n-video", &videoStreamsCount, NULL); - g_object_get(G_OBJECT(m_playbin), "n-text", &textStreamsCount, NULL); - - haveAudio = audioStreamsCount > 0; - haveVideo = videoStreamsCount > 0; - - /*m_playbin2StreamOffset[QMediaStreamsControl::AudioStream] = 0; - m_playbin2StreamOffset[QMediaStreamsControl::VideoStream] = audioStreamsCount; - m_playbin2StreamOffset[QMediaStreamsControl::SubPictureStream] = audioStreamsCount+videoStreamsCount; - - for (int i=0; i streamProperties; - - int streamIndex = i - m_playbin2StreamOffset[streamType]; - - GstTagList *tags = 0; - switch (streamType) { - case QMediaStreamsControl::AudioStream: - g_signal_emit_by_name(G_OBJECT(m_playbin), "get-audio-tags", streamIndex, &tags); - break; - case QMediaStreamsControl::VideoStream: - g_signal_emit_by_name(G_OBJECT(m_playbin), "get-video-tags", streamIndex, &tags); - break; - case QMediaStreamsControl::SubPictureStream: - g_signal_emit_by_name(G_OBJECT(m_playbin), "get-text-tags", streamIndex, &tags); - break; - default: - break; - } - - if (tags && gst_is_tag_list(tags)) { - gchar *languageCode = 0; - if (gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &languageCode)) - streamProperties[QtMediaServices::Language] = QString::fromUtf8(languageCode); - - //qDebug() << "language for setream" << i << QString::fromUtf8(languageCode); - g_free (languageCode); - } - - m_streamProperties.append(streamProperties); - - } - */ - -#else - enum { - GST_STREAM_TYPE_UNKNOWN, - GST_STREAM_TYPE_AUDIO, - GST_STREAM_TYPE_VIDEO, - GST_STREAM_TYPE_TEXT, - GST_STREAM_TYPE_SUBPICTURE, - GST_STREAM_TYPE_ELEMENT - }; - - GList* streamInfo; - g_object_get(G_OBJECT(m_playbin), "stream-info", &streamInfo, NULL); - - for (; streamInfo != 0; streamInfo = g_list_next(streamInfo)) { - gint type; - gchar *languageCode = 0; - - GObject* obj = G_OBJECT(streamInfo->data); - - g_object_get(obj, "type", &type, NULL); - g_object_get(obj, "language-code", &languageCode, NULL); - - if (type == GST_STREAM_TYPE_VIDEO) - haveVideo = true; - else if (type == GST_STREAM_TYPE_AUDIO) - haveAudio = true; - -// QMediaStreamsControl::StreamType streamType = QMediaStreamsControl::UnknownStream; -// -// switch (type) { -// case GST_STREAM_TYPE_VIDEO: -// streamType = QMediaStreamsControl::VideoStream; -// break; -// case GST_STREAM_TYPE_AUDIO: -// streamType = QMediaStreamsControl::AudioStream; -// break; -// case GST_STREAM_TYPE_SUBPICTURE: -// streamType = QMediaStreamsControl::SubPictureStream; -// break; -// default: -// streamType = QMediaStreamsControl::UnknownStream; -// break; -// } -// -// QMap streamProperties; -// streamProperties[QtMediaServices::Language] = QString::fromUtf8(languageCode); -// -// m_streamProperties.append(streamProperties); -// m_streamTypes.append(streamType); - } -#endif - - if (haveAudio != m_audioAvailable) { - m_audioAvailable = haveAudio; - emit audioAvailableChanged(m_audioAvailable); - } - if (haveVideo != m_videoAvailable) { - m_videoAvailable = haveVideo; - emit videoAvailableChanged(m_videoAvailable); - } - - emit streamsChanged(); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h deleted file mode 100644 index 6499a84..0000000 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERPLAYERSESSION_H -#define QGSTREAMERPLAYERSESSION_H - -#include -#include -#include "qgstreamerplayercontrol.h" -#include "qgstreamerbushelper.h" -#include -//#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGstreamerBusHelper; -class QGstreamerMessage; -class QGstreamerVideoRendererInterface; - -class QGstreamerPlayerSession : public QObject, public QGstreamerSyncEventFilter -{ -Q_OBJECT - -public: - QGstreamerPlayerSession(QObject *parent); - virtual ~QGstreamerPlayerSession(); - - QUrl url() const; - - QMediaPlayer::State state() const { return m_state; } - - qint64 duration() const; - qint64 position() const; - - bool isBuffering() const; - - int bufferingProgress() const; - - int volume() const; - bool isMuted() const; - - void setVideoRenderer(QObject *renderer); - bool isAudioAvailable() const; - bool isVideoAvailable() const; - - bool isSeekable() const; - - qreal playbackRate() const; - void setPlaybackRate(qreal rate); - - QMap tags() const { return m_tags; } - QMap streamProperties(int streamNumber) const { return m_streamProperties[streamNumber]; } -// int streamCount() const { return m_streamProperties.count(); } -// QMediaStreamsControl::StreamType streamType(int streamNumber) { return m_streamTypes.value(streamNumber, QMediaStreamsControl::UnknownStream); } -// -// int activeStream(QMediaStreamsControl::StreamType streamType) const; -// void setActiveStream(QMediaStreamsControl::StreamType streamType, int streamNumber); - - bool processSyncMessage(const QGstreamerMessage &message); - -public slots: - void load(const QUrl &url); - - bool play(); - bool pause(); - void stop(); - - bool seek(qint64 pos); - - void setVolume(int volume); - void setMuted(bool muted); - -signals: - void durationChanged(qint64 duration); - void positionChanged(qint64 position); - void stateChanged(QMediaPlayer::State state); - void volumeChanged(int volume); - void mutedStateChanged(bool muted); - void audioAvailableChanged(bool audioAvailable); - void videoAvailableChanged(bool videoAvailable); - void bufferingChanged(bool buffering); - void bufferingProgressChanged(int percentFilled); - void playbackFinished(); - void tagsChanged(); - void streamsChanged(); - void seekableChanged(bool); - void error(int error, const QString &errorString); - -private slots: - void busMessage(const QGstreamerMessage &message); - void getStreamsInfo(); - void setSeekable(bool); - void finishVideoOutputChange(); - -private: - QUrl m_url; - QMediaPlayer::State m_state; - QGstreamerBusHelper* m_busHelper; - GstElement* m_playbin; - - GstElement* m_videoOutputBin; - GstElement* m_videoIdentity; - GstElement* m_colorSpace; - GstElement* m_videoScale; - GstElement* m_videoSink; - GstElement* m_pendingVideoSink; - GstElement* m_nullVideoSink; - - GstBus* m_bus; - QGstreamerVideoRendererInterface *m_renderer; - - QMap m_tags; - QList< QMap > m_streamProperties; -// QList m_streamTypes; -// QMap m_playbin2StreamOffset; - - - int m_volume; - qreal m_playbackRate; - bool m_muted; - bool m_audioAvailable; - bool m_videoAvailable; - bool m_seekable; - - qint64 m_lastPosition; - qint64 m_duration; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGSTREAMERPLAYERSESSION_H diff --git a/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp b/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp deleted file mode 100644 index 5049fa1..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamerbushelper.h" - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_GLIB -class QGstreamerBusHelperPrivate : public QObject -{ - Q_OBJECT - -public: - void addWatch(GstBus* bus, QGstreamerBusHelper* helper) - { - setParent(helper); - m_tag = gst_bus_add_watch_full(bus, 0, busCallback, this, NULL); - m_helper = helper; - filter = 0; - } - - void removeWatch(QGstreamerBusHelper* helper) - { - Q_UNUSED(helper); - g_source_remove(m_tag); - } - - static QGstreamerBusHelperPrivate* instance() - { - return new QGstreamerBusHelperPrivate; - } - -private: - void processMessage(GstBus* bus, GstMessage* message) - { - Q_UNUSED(bus); - emit m_helper->message(message); - } - - static gboolean busCallback(GstBus *bus, GstMessage *message, gpointer data) - { - reinterpret_cast(data)->processMessage(bus, message); - return TRUE; - } - - guint m_tag; - QGstreamerBusHelper* m_helper; - -public: - GstBus* bus; - QGstreamerSyncEventFilter *filter; - QMutex filterMutex; -}; - -#else - -class QGstreamerBusHelperPrivate : public QObject -{ - Q_OBJECT - typedef QMap HelperMap; - -public: - void addWatch(GstBus* bus, QGstreamerBusHelper* helper) - { - m_helperMap.insert(helper, bus); - - if (m_helperMap.size() == 1) - m_intervalTimer->start(); - } - - void removeWatch(QGstreamerBusHelper* helper) - { - m_helperMap.remove(helper); - - if (m_helperMap.size() == 0) - m_intervalTimer->stop(); - } - - static QGstreamerBusHelperPrivate* instance() - { - static QGstreamerBusHelperPrivate self; - - return &self; - } - -private slots: - void interval() - { - for (HelperMap::iterator it = m_helperMap.begin(); it != m_helperMap.end(); ++it) { - GstMessage* message; - - while ((message = gst_bus_poll(it.value(), GST_MESSAGE_ANY, 0)) != 0) { - emit it.key()->message(message); - gst_message_unref(message); - } - - emit it.key()->message(QGstreamerMessage()); - } - } - -private: - QGstreamerBusHelperPrivate() - { - m_intervalTimer = new QTimer(this); - m_intervalTimer->setInterval(250); - - connect(m_intervalTimer, SIGNAL(timeout()), SLOT(interval())); - } - - HelperMap m_helperMap; - QTimer* m_intervalTimer; - -public: - GstBus* bus; - QGstreamerSyncEventFilter *filter; - QMutex filterMutex; -}; -#endif - - -static GstBusSyncReply syncGstBusFilter(GstBus* bus, GstMessage* message, QGstreamerBusHelperPrivate *d) -{ - Q_UNUSED(bus); - QMutexLocker lock(&d->filterMutex); - - bool res = false; - - if (d->filter) - res = d->filter->processSyncMessage(QGstreamerMessage(message)); - - return res ? GST_BUS_DROP : GST_BUS_PASS; -} - - -/*! - \class QGstreamerBusHelper - \internal -*/ - -QGstreamerBusHelper::QGstreamerBusHelper(GstBus* bus, QObject* parent): - QObject(parent), - d(QGstreamerBusHelperPrivate::instance()) -{ - d->bus = bus; - d->addWatch(bus, this); - - gst_bus_set_sync_handler(bus, (GstBusSyncHandler)syncGstBusFilter, d); -} - -QGstreamerBusHelper::~QGstreamerBusHelper() -{ - d->removeWatch(this); - gst_bus_set_sync_handler(d->bus,0,0); -} - -void QGstreamerBusHelper::installSyncEventFilter(QGstreamerSyncEventFilter *filter) -{ - QMutexLocker lock(&d->filterMutex); - d->filter = filter; -} - -QT_END_NAMESPACE - -#include "qgstreamerbushelper.moc" diff --git a/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.h b/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.h deleted file mode 100644 index 8600015..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERBUSHELPER_H -#define QGSTREAMERBUSHELPER_H - -#include - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGstreamerSyncEventFilter { -public: - //returns true if message was processed and should be dropped, false otherwise - virtual bool processSyncMessage(const QGstreamerMessage &message) = 0; -}; - -class QGstreamerBusHelperPrivate; - -class QGstreamerBusHelper : public QObject -{ - Q_OBJECT - friend class QGstreamerBusHelperPrivate; - -public: - QGstreamerBusHelper(GstBus* bus, QObject* parent = 0); - ~QGstreamerBusHelper(); - - void installSyncEventFilter(QGstreamerSyncEventFilter *filter); - -signals: - void message(QGstreamerMessage const& message); - - -private: - QGstreamerBusHelperPrivate* d; -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp b/src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp deleted file mode 100644 index d52aa75..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamermessage.h" - - -QT_BEGIN_NAMESPACE - -static int wuchi = qRegisterMetaType(); - - -/*! - \class QGstreamerMessage - \internal -*/ - -QGstreamerMessage::QGstreamerMessage(): - m_message(0) -{ -} - -QGstreamerMessage::QGstreamerMessage(GstMessage* message): - m_message(message) -{ - gst_message_ref(m_message); -} - -QGstreamerMessage::QGstreamerMessage(QGstreamerMessage const& m): - m_message(m.m_message) -{ - gst_message_ref(m_message); -} - - -QGstreamerMessage::~QGstreamerMessage() -{ - if (m_message != 0) - gst_message_unref(m_message); -} - -GstMessage* QGstreamerMessage::rawMessage() const -{ - return m_message; -} - -QGstreamerMessage& QGstreamerMessage::operator=(QGstreamerMessage const& rhs) -{ - if (m_message != 0) - gst_message_unref(m_message); - - if ((m_message = rhs.m_message) != 0) - gst_message_ref(m_message); - - return *this; -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/gstreamer/qgstreamermessage.h b/src/plugins/mediaservices/gstreamer/qgstreamermessage.h deleted file mode 100644 index 4680903..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamermessage.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERMESSAGE_H -#define QGSTREAMERMESSAGE_H - -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGstreamerMessage -{ -public: - QGstreamerMessage(); - QGstreamerMessage(GstMessage* message); - QGstreamerMessage(QGstreamerMessage const& m); - ~QGstreamerMessage(); - - GstMessage* rawMessage() const; - - QGstreamerMessage& operator=(QGstreamerMessage const& rhs); - -private: - GstMessage* m_message; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QGstreamerMessage); - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp b/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp deleted file mode 100644 index 0ca7d54..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamerserviceplugin.h" - -#ifdef QMEDIA_GSTREAMER_PLAYER -#include "qgstreamerplayerservice.h" -#endif -#ifdef QMEDIA_GSTREAMER_CAPTURE -#include "qgstreamercaptureservice.h" -#endif -#include - -#ifdef QMEDIA_GSTREAMER_CAPTURE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - - -QT_BEGIN_NAMESPACE - - -QStringList QGstreamerServicePlugin::keys() const -{ - return QStringList() -#ifdef QMEDIA_GSTREAMER_PLAYER - << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER) -#endif -#ifdef QMEDIA_GSTREAMER_CAPTURE - << QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE) - << QLatin1String(Q_MEDIASERVICE_CAMERA) -#endif - ; -} - -QMediaService* QGstreamerServicePlugin::create(const QString &key) -{ -#ifdef QMEDIA_GSTREAMER_PLAYER - if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) - return new QGstreamerPlayerService; -#endif -#ifdef QMEDIA_GSTREAMER_CAPTURE - if (key == QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE)) - return new QGstreamerCaptureService(key); - - if (key == QLatin1String(Q_MEDIASERVICE_CAMERA)) - return new QGstreamerCaptureService(key); -#endif - - qWarning() << "GStreamer service plugin: unsupported service -" << key; - return 0; -} - -void QGstreamerServicePlugin::release(QMediaService *service) -{ - delete service; -} - -QList QGstreamerServicePlugin::devices(const QByteArray &service) const -{ -#ifdef QMEDIA_GSTREAMER_CAPTURE - if (service == Q_MEDIASERVICE_CAMERA) { - if (m_cameraDevices.isEmpty()) - updateDevices(); - - return m_cameraDevices; - } -#endif - - return QList(); -} - -QString QGstreamerServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device) -{ -#ifdef QMEDIA_GSTREAMER_CAPTURE - if (service == Q_MEDIASERVICE_CAMERA) { - if (m_cameraDevices.isEmpty()) - updateDevices(); - - for (int i=0; i= 0; ++input.index) { - if(input.type == V4L2_INPUT_TYPE_CAMERA || input.type == 0) { - isCamera = ::ioctl(fd, VIDIOC_S_INPUT, input.index) != 0; - break; - } - } - - if (isCamera) { - // find out its driver "name" - QString name; - struct v4l2_capability vcap; - memset(&vcap, 0, sizeof(struct v4l2_capability)); - - if (ioctl(fd, VIDIOC_QUERYCAP, &vcap) != 0) - name = entryInfo.fileName(); - else - name = QString((const char*)vcap.card); -// qDebug() << "found camera: " << name; - - m_cameraDevices.append(entryInfo.filePath().toLocal8Bit()); - m_cameraDescriptions.append(name); - } - ::close(fd); - } -#endif -} - -Q_EXPORT_PLUGIN2(gstengine, QGstreamerServicePlugin); - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.h b/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.h deleted file mode 100644 index e0a5dfd..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERSERVICEPLUGIN_H -#define QGSTREAMERSERVICEPLUGIN_H - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGstreamerServicePlugin : public QMediaServiceProviderPlugin, public QMediaServiceSupportedDevicesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedDevicesInterface) -public: - QStringList keys() const; - QMediaService* create(QString const& key); - void release(QMediaService *service); - - QList devices(const QByteArray &service) const; - QString deviceDescription(const QByteArray &service, const QByteArray &device); - -private: - void updateDevices() const; - - mutable QList m_cameraDevices; - mutable QStringList m_cameraDescriptions; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGSTREAMERSERVICEPLUGIN_H diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp deleted file mode 100644 index 4ecf10b..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamervideoinputdevicecontrol.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -QGstreamerVideoInputDeviceControl::QGstreamerVideoInputDeviceControl(QObject *parent) - :QVideoDeviceControl(parent), m_selectedDevice(0) -{ - update(); -} - -QGstreamerVideoInputDeviceControl::~QGstreamerVideoInputDeviceControl() -{ -} - -int QGstreamerVideoInputDeviceControl::deviceCount() const -{ - return m_names.size(); -} - -QString QGstreamerVideoInputDeviceControl::deviceName(int index) const -{ - return m_names[index]; -} - -QString QGstreamerVideoInputDeviceControl::deviceDescription(int index) const -{ - return m_descriptions[index]; -} - -QIcon QGstreamerVideoInputDeviceControl::deviceIcon(int index) const -{ - Q_UNUSED(index); - return QIcon(); -} - -int QGstreamerVideoInputDeviceControl::defaultDevice() const -{ - return 0; -} - -int QGstreamerVideoInputDeviceControl::selectedDevice() const -{ - return m_selectedDevice; -} - - -void QGstreamerVideoInputDeviceControl::setSelectedDevice(int index) -{ - if (index != m_selectedDevice) { - m_selectedDevice = index; - emit selectedDeviceChanged(index); - emit selectedDeviceChanged(deviceName(index)); - } -} - - -void QGstreamerVideoInputDeviceControl::update() -{ - m_names.clear(); - m_descriptions.clear(); - -#ifdef QMEDIA_GSTREAMER_CAPTURE - QDir devDir("/dev"); - devDir.setFilter(QDir::System); - - QFileInfoList entries = devDir.entryInfoList(QStringList() << "video*"); - - foreach( const QFileInfo &entryInfo, entries ) { -// qDebug() << "Try" << entryInfo.filePath(); - - int fd = ::open(entryInfo.filePath().toLatin1().constData(), O_RDWR ); - if (fd == -1) - continue; - - bool isCamera = false; - - v4l2_input input; - memset(&input, 0, sizeof(input)); - for (; ::ioctl(fd, VIDIOC_ENUMINPUT, &input) >= 0; ++input.index) { - if(input.type == V4L2_INPUT_TYPE_CAMERA || input.type == 0) { - isCamera = ::ioctl(fd, VIDIOC_S_INPUT, input.index) != 0; - break; - } - } - - if (isCamera) { - // find out its driver "name" - QString name; - struct v4l2_capability vcap; - memset(&vcap, 0, sizeof(struct v4l2_capability)); - - if (ioctl(fd, VIDIOC_QUERYCAP, &vcap) != 0) - name = entryInfo.fileName(); - else - name = QString((const char*)vcap.card); -// qDebug() << "found camera: " << name; - - m_names.append(entryInfo.filePath()); - m_descriptions.append(name); - } - ::close(fd); - } -#endif -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.h b/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.h deleted file mode 100644 index 7994f9c..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERVIDEOINPUTDEVICECONTROL_H -#define QGSTREAMERVIDEOINPUTDEVICECONTROL_H - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QGstreamerVideoInputDeviceControl : public QVideoDeviceControl -{ -Q_OBJECT -public: - QGstreamerVideoInputDeviceControl(QObject *parent); - ~QGstreamerVideoInputDeviceControl(); - - int deviceCount() const; - - QString deviceName(int index) const; - QString deviceDescription(int index) const; - QIcon deviceIcon(int index) const; - - int defaultDevice() const; - int selectedDevice() const; - -public Q_SLOTS: - void setSelectedDevice(int index); - -private: - void update(); - - int m_selectedDevice; - QStringList m_names; - QStringList m_descriptions; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGSTREAMERAUDIOINPUTDEVICECONTROL_H diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp deleted file mode 100644 index f406bff..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamervideooutputcontrol.h" - -QT_BEGIN_NAMESPACE - -QGstreamerVideoOutputControl::QGstreamerVideoOutputControl(QObject *parent) - : QVideoOutputControl(parent) - , m_output(NoOutput) -{ -} - -QList QGstreamerVideoOutputControl::availableOutputs() const -{ - return m_outputs; -} - -void QGstreamerVideoOutputControl::setAvailableOutputs(const QList &outputs) -{ - emit availableOutputsChanged(m_outputs = outputs); -} - -QVideoOutputControl::Output QGstreamerVideoOutputControl::output() const -{ - return m_output; -} - -void QGstreamerVideoOutputControl::setOutput(Output output) -{ - if (!m_outputs.contains(output)) - output = NoOutput; - - if (m_output != output) - emit outputChanged(m_output = output); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.h b/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.h deleted file mode 100644 index 6d7d47f..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERVIDEOOUTPUTCONTROL_H -#define QGSTREAMERVIDEOOUTPUTCONTROL_H - -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGstreamerVideoRendererInterface -{ -public: - virtual ~QGstreamerVideoRendererInterface(); - virtual GstElement *videoSink() = 0; - virtual void precessNewStream() {} -}; - -class QGstreamerVideoOutputControl : public QVideoOutputControl -{ - Q_OBJECT -public: - QGstreamerVideoOutputControl(QObject *parent = 0); - - QList availableOutputs() const; - void setAvailableOutputs(const QList &outputs); - - Output output() const; - void setOutput(Output output); - -Q_SIGNALS: - void outputChanged(QVideoOutputControl::Output output); - -private: - QList m_outputs; - Output m_output; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp deleted file mode 100644 index f381f7f..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamervideooverlay.h" -#include "qvideosurfacegstsink.h" - -#include - -#include "qx11videosurface.h" - -QT_BEGIN_NAMESPACE - -QGstreamerVideoOverlay::QGstreamerVideoOverlay(QObject *parent) - : QVideoWindowControl(parent) - , m_surface(new QX11VideoSurface) - , m_videoSink(reinterpret_cast(QVideoSurfaceGstSink::createSink(m_surface))) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_fullScreen(false) -{ - if (m_videoSink) { - gst_object_ref(GST_OBJECT(m_videoSink)); //Take ownership - gst_object_sink(GST_OBJECT(m_videoSink)); - } - - connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SLOT(surfaceFormatChanged())); -} - -QGstreamerVideoOverlay::~QGstreamerVideoOverlay() -{ - if (m_videoSink) - gst_object_unref(GST_OBJECT(m_videoSink)); - - delete m_surface; -} - -WId QGstreamerVideoOverlay::winId() const -{ - return m_surface->winId(); -} - -void QGstreamerVideoOverlay::setWinId(WId id) -{ - m_surface->setWinId(id); -} - -QRect QGstreamerVideoOverlay::displayRect() const -{ - return m_displayRect; -} - -void QGstreamerVideoOverlay::setDisplayRect(const QRect &rect) -{ - m_displayRect = rect; - - setScaledDisplayRect(); -} - -Qt::AspectRatioMode QGstreamerVideoOverlay::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void QGstreamerVideoOverlay::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_aspectRatioMode = mode; - - setScaledDisplayRect(); -} - -void QGstreamerVideoOverlay::repaint() -{ -} - -int QGstreamerVideoOverlay::brightness() const -{ - return m_surface->brightness(); -} - -void QGstreamerVideoOverlay::setBrightness(int brightness) -{ - m_surface->setBrightness(brightness); - - emit brightnessChanged(m_surface->brightness()); -} - -int QGstreamerVideoOverlay::contrast() const -{ - return m_surface->contrast(); -} - -void QGstreamerVideoOverlay::setContrast(int contrast) -{ - m_surface->setContrast(contrast); - - emit contrastChanged(m_surface->contrast()); -} - -int QGstreamerVideoOverlay::hue() const -{ - return m_surface->hue(); -} - -void QGstreamerVideoOverlay::setHue(int hue) -{ - m_surface->setHue(hue); - - emit hueChanged(m_surface->hue()); -} - -int QGstreamerVideoOverlay::saturation() const -{ - return m_surface->saturation(); -} - -void QGstreamerVideoOverlay::setSaturation(int saturation) -{ - m_surface->setSaturation(saturation); - - emit saturationChanged(m_surface->saturation()); -} - -bool QGstreamerVideoOverlay::isFullScreen() const -{ - return m_fullScreen; -} - -void QGstreamerVideoOverlay::setFullScreen(bool fullScreen) -{ - emit fullScreenChanged(m_fullScreen = fullScreen); -} - -QSize QGstreamerVideoOverlay::nativeSize() const -{ - return m_surface->surfaceFormat().sizeHint(); -} - -QAbstractVideoSurface *QGstreamerVideoOverlay::surface() const -{ - return m_surface; -} - -GstElement *QGstreamerVideoOverlay::videoSink() -{ - return m_videoSink; -} - -void QGstreamerVideoOverlay::surfaceFormatChanged() -{ - setScaledDisplayRect(); - - emit nativeSizeChanged(); -} - -void QGstreamerVideoOverlay::setScaledDisplayRect() -{ - QRect formatViewport = m_surface->surfaceFormat().viewport(); - - switch (m_aspectRatioMode) { - case Qt::KeepAspectRatio: - { - QSize size = m_surface->surfaceFormat().sizeHint(); - size.scale(m_displayRect.size(), Qt::KeepAspectRatio); - - QRect rect(QPoint(0, 0), size); - rect.moveCenter(m_displayRect.center()); - - m_surface->setDisplayRect(rect); - m_surface->setViewport(formatViewport); - } - break; - case Qt::IgnoreAspectRatio: - m_surface->setDisplayRect(m_displayRect); - m_surface->setViewport(formatViewport); - break; - case Qt::KeepAspectRatioByExpanding: - { - QSize size = m_displayRect.size(); - size.scale(m_surface->surfaceFormat().sizeHint(), Qt::KeepAspectRatio); - - QRect viewport(QPoint(0, 0), size); - viewport.moveCenter(formatViewport.center()); - - m_surface->setDisplayRect(m_displayRect); - m_surface->setViewport(viewport); - } - break; - }; -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.h b/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.h deleted file mode 100644 index f44c25b..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERVIDEOOVERLAY_H -#define QGSTREAMERVIDEOOVERLAY_H - -#include - -#include "qgstreamervideorendererinterface.h" - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QAbstractVideoSurface; -class QX11VideoSurface; - -class QGstreamerVideoOverlay : public QVideoWindowControl, public QGstreamerVideoRendererInterface -{ - Q_OBJECT - Q_INTERFACES(QGstreamerVideoRendererInterface) -public: - QGstreamerVideoOverlay(QObject *parent = 0); - ~QGstreamerVideoOverlay(); - - WId winId() const; - void setWinId(WId id); - - QRect displayRect() const; - void setDisplayRect(const QRect &rect); - - bool isFullScreen() const; - void setFullScreen(bool fullScreen); - - QSize nativeSize() const; - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - void repaint(); - - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); - - QAbstractVideoSurface *surface() const; - - GstElement *videoSink(); - -private slots: - void surfaceFormatChanged(); - -private: - void setScaledDisplayRect(); - - QX11VideoSurface *m_surface; - GstElement *m_videoSink; - Qt::AspectRatioMode m_aspectRatioMode; - QRect m_displayRect; - bool m_fullScreen; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp deleted file mode 100644 index 1f03990..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamervideorenderer.h" -#include "qvideosurfacegstsink.h" - -#include -#include - -#include - - -QT_BEGIN_NAMESPACE - -QGstreamerVideoRenderer::QGstreamerVideoRenderer(QObject *parent) - :QVideoRendererControl(parent),m_videoSink(0) -{ -} - -QGstreamerVideoRenderer::~QGstreamerVideoRenderer() -{ - if (m_videoSink) - gst_object_unref(GST_OBJECT(m_videoSink)); -} - -GstElement *QGstreamerVideoRenderer::videoSink() -{ - if (!m_videoSink) { - m_videoSink = reinterpret_cast(QVideoSurfaceGstSink::createSink(m_surface)); - gst_object_ref(GST_OBJECT(m_videoSink)); //Take ownership - gst_object_sink(GST_OBJECT(m_videoSink)); - } - - return m_videoSink; -} - - -QAbstractVideoSurface *QGstreamerVideoRenderer::surface() const -{ - return m_surface; -} - -void QGstreamerVideoRenderer::setSurface(QAbstractVideoSurface *surface) -{ - m_surface = surface; -} - -QT_END_NAMESPACE - - diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.h b/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.h deleted file mode 100644 index 0fbbd63..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERVIDEORENDERER_H -#define QGSTREAMERVIDEORENDERER_H - -#include -#include "qvideosurfacegstsink.h" - -#include "qgstreamervideorendererinterface.h" - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGstreamerVideoRenderer : public QVideoRendererControl, public QGstreamerVideoRendererInterface -{ - Q_OBJECT - Q_INTERFACES(QGstreamerVideoRendererInterface) -public: - QGstreamerVideoRenderer(QObject *parent = 0); - virtual ~QGstreamerVideoRenderer(); - - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); - - GstElement *videoSink(); - void precessNewStream() {} - -private: - GstElement *m_videoSink; - QAbstractVideoSurface *m_surface; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGSTREAMERVIDEORENDRER_H diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp deleted file mode 100644 index 886a064..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamervideorendererinterface.h" - - -QT_BEGIN_NAMESPACE - -QGstreamerVideoRendererInterface::~QGstreamerVideoRendererInterface() -{ -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h b/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h deleted file mode 100644 index c63a757..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERVIDEOOUTPUTCONTROL_H -#define QGSTREAMERVIDEOOUTPUTCONTROL_H - -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGstreamerVideoRendererInterface -{ -public: - virtual ~QGstreamerVideoRendererInterface(); - virtual GstElement *videoSink() = 0; - virtual void precessNewStream() {} -}; - -#define QGstreamerVideoRendererInterface_iid "com.nokia.Qt.QGstreamerVideoRendererInterface/1.0" -Q_DECLARE_INTERFACE(QGstreamerVideoRendererInterface, QGstreamerVideoRendererInterface_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp deleted file mode 100644 index 763f7f1..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstreamervideowidget.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -class QGstreamerVideoWidget : public QWidget -{ -public: - QGstreamerVideoWidget(QWidget *parent = 0) - :QWidget(parent) - { - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - QPalette palette; - palette.setColor(QPalette::Background, Qt::black); - setPalette(palette); - } - - virtual ~QGstreamerVideoWidget() {} - - QSize sizeHint() const - { - return m_nativeSize; - } - - void setNativeSize( const QSize &size) - { - if (size != m_nativeSize) { - m_nativeSize = size; - if (size.isEmpty()) - setMinimumSize(0,0); - else - setMinimumSize(160,120); - - updateGeometry(); - } - } - -protected: - void paintEvent(QPaintEvent *) - { - QPainter painter(this); - painter.fillRect(rect(), palette().background()); - } - - QSize m_nativeSize; -}; - -QGstreamerVideoWidgetControl::QGstreamerVideoWidgetControl(QObject *parent) - : QVideoWidgetControl(parent) - , m_videoSink(0) - , m_widget(0) - , m_fullScreen(false) -{ -} - -QGstreamerVideoWidgetControl::~QGstreamerVideoWidgetControl() -{ - if (m_videoSink) - gst_object_unref(GST_OBJECT(m_videoSink)); - - delete m_widget; -} - -void QGstreamerVideoWidgetControl::createVideoWidget() -{ - if (m_widget) - return; - - m_widget = new QGstreamerVideoWidget; - - m_widget->installEventFilter(this); - m_windowId = m_widget->winId(); - - m_videoSink = gst_element_factory_make ("xvimagesink", NULL); - if (m_videoSink) { - // Check if the xv sink is usable - if (gst_element_set_state(m_videoSink, GST_STATE_READY) != GST_STATE_CHANGE_SUCCESS) { - gst_object_unref(GST_OBJECT(m_videoSink)); - m_videoSink = 0; - } else { - gst_element_set_state(m_videoSink, GST_STATE_NULL); - - g_object_set(G_OBJECT(m_videoSink), "force-aspect-ratio", 1, (const char*)NULL); - } - } - - if (!m_videoSink) - m_videoSink = gst_element_factory_make ("ximagesink", NULL); - - gst_object_ref (GST_OBJECT (m_videoSink)); //Take ownership - gst_object_sink (GST_OBJECT (m_videoSink)); -} - -GstElement *QGstreamerVideoWidgetControl::videoSink() -{ - createVideoWidget(); - return m_videoSink; -} - -bool QGstreamerVideoWidgetControl::eventFilter(QObject *object, QEvent *e) -{ - if (m_widget && object == m_widget) { - if (e->type() == QEvent::ParentChange || e->type() == QEvent::Show) { - WId newWId = m_widget->winId(); - if (newWId != m_windowId) { - m_windowId = newWId; - // Even if we have created a winId at this point, other X applications - // need to be aware of it. - QApplication::syncX(); - setOverlay(); - } - } - - if (e->type() == QEvent::Show) { - // Setting these values ensures smooth resizing since it - // will prevent the system from clearing the background - m_widget->setAttribute(Qt::WA_NoSystemBackground, true); - m_widget->setAttribute(Qt::WA_PaintOnScreen, true); - } else if (e->type() == QEvent::Resize) { - // This is a workaround for missing background repaints - // when reducing window size - windowExposed(); - } - } - - return false; -} - -void QGstreamerVideoWidgetControl::precessNewStream() -{ - setOverlay(); - QMetaObject::invokeMethod(this, "updateNativeVideoSize", Qt::QueuedConnection); -} - -void QGstreamerVideoWidgetControl::setOverlay() -{ - if (m_videoSink && GST_IS_X_OVERLAY(m_videoSink)) { - gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(m_videoSink), m_windowId); - } -} - -void QGstreamerVideoWidgetControl::updateNativeVideoSize() -{ - if (m_videoSink) { - //find video native size to update video widget size hint - GstPad *pad = gst_element_get_static_pad(m_videoSink,"sink"); - GstCaps *caps = gst_pad_get_negotiated_caps(pad); - - if (caps) { - GstStructure *str; - gint width, height; - - if ((str = gst_caps_get_structure (caps, 0))) { - if (gst_structure_get_int (str, "width", &width) && gst_structure_get_int (str, "height", &height)) { - gint aspectNum = 0; - gint aspectDenum = 0; - if (gst_structure_get_fraction(str, "pixel-aspect-ratio", &aspectNum, &aspectDenum)) { - if (aspectDenum > 0) - width = width*aspectNum/aspectDenum; - } - m_widget->setNativeSize(QSize(width, height)); - } - } - gst_caps_unref(caps); - } - } else { - if (m_widget) - m_widget->setNativeSize(QSize()); - } -} - - -void QGstreamerVideoWidgetControl::windowExposed() -{ - if (m_videoSink && GST_IS_X_OVERLAY(m_videoSink)) - gst_x_overlay_expose(GST_X_OVERLAY(m_videoSink)); -} - -QWidget *QGstreamerVideoWidgetControl::videoWidget() -{ - createVideoWidget(); - return m_widget; -} - -Qt::AspectRatioMode QGstreamerVideoWidgetControl::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void QGstreamerVideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - if (m_videoSink) { - g_object_set(G_OBJECT(m_videoSink), - "force-aspect-ratio", - (mode == Qt::KeepAspectRatio), - (const char*)NULL); - } - - m_aspectRatioMode = mode; -} - -bool QGstreamerVideoWidgetControl::isFullScreen() const -{ - return m_fullScreen; -} - -void QGstreamerVideoWidgetControl::setFullScreen(bool fullScreen) -{ - emit fullScreenChanged(m_fullScreen = fullScreen); -} - -int QGstreamerVideoWidgetControl::brightness() const -{ - int brightness = 0; - - if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness")) - g_object_get(G_OBJECT(m_videoSink), "brightness", &brightness, NULL); - - return brightness / 10; -} - -void QGstreamerVideoWidgetControl::setBrightness(int brightness) -{ - if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness")) { - g_object_set(G_OBJECT(m_videoSink), "brightness", brightness * 10, NULL); - - emit brightnessChanged(brightness); - } -} - -int QGstreamerVideoWidgetControl::contrast() const -{ - int contrast = 0; - - if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast")) - g_object_get(G_OBJECT(m_videoSink), "contrast", &contrast, NULL); - - return contrast / 10; -} - -void QGstreamerVideoWidgetControl::setContrast(int contrast) -{ - if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast")) { - g_object_set(G_OBJECT(m_videoSink), "contrast", contrast * 10, NULL); - - emit contrastChanged(contrast); - } -} - -int QGstreamerVideoWidgetControl::hue() const -{ - int hue = 0; - - if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue")) - g_object_get(G_OBJECT(m_videoSink), "hue", &hue, NULL); - - return hue / 10; -} - -void QGstreamerVideoWidgetControl::setHue(int hue) -{ - if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue")) { - g_object_set(G_OBJECT(m_videoSink), "hue", hue * 10, NULL); - - emit hueChanged(hue); - } -} - -int QGstreamerVideoWidgetControl::saturation() const -{ - int saturation = 0; - - if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation")) - g_object_get(G_OBJECT(m_videoSink), "saturation", &saturation, NULL); - - return saturation / 10; -} - -void QGstreamerVideoWidgetControl::setSaturation(int saturation) -{ - if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation")) { - g_object_set(G_OBJECT(m_videoSink), "saturation", saturation * 10, NULL); - - emit saturationChanged(saturation); - } -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h deleted file mode 100644 index d54a1fc..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTREAMERVIDEOWIDGET_H -#define QGSTREAMERVIDEOWIDGET_H - -#include - -#include "qgstreamervideorendererinterface.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGstreamerVideoWidget; - -class QGstreamerVideoWidgetControl - : public QVideoWidgetControl - , public QGstreamerVideoRendererInterface -{ - Q_OBJECT - Q_INTERFACES(QGstreamerVideoRendererInterface) -public: - QGstreamerVideoWidgetControl(QObject *parent = 0); - virtual ~QGstreamerVideoWidgetControl(); - - GstElement *videoSink(); - void precessNewStream(); - - QWidget *videoWidget(); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - bool isFullScreen() const; - void setFullScreen(bool fullScreen); - - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); - - void setOverlay(); - - bool eventFilter(QObject *object, QEvent *event); - -public slots: - void updateNativeVideoSize(); - -private: - void createVideoWidget(); - void windowExposed(); - - GstElement *m_videoSink; - QGstreamerVideoWidget *m_widget; - WId m_windowId; - Qt::AspectRatioMode m_aspectRatioMode; - bool m_fullScreen; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGSTREAMERVIDEOWIDGET_H diff --git a/src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp b/src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp deleted file mode 100644 index 76289bf..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstvideobuffer.h" - - -QT_BEGIN_NAMESPACE - -QGstVideoBuffer::QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine) - : QAbstractVideoBuffer(NoHandle) - , m_buffer(buffer) - , m_bytesPerLine(bytesPerLine) - , m_mode(NotMapped) -{ - gst_buffer_ref(m_buffer); -} - -QGstVideoBuffer::QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine, - QGstVideoBuffer::HandleType handleType, - const QVariant &handle) - : QAbstractVideoBuffer(handleType) - , m_buffer(buffer) - , m_bytesPerLine(bytesPerLine) - , m_mode(NotMapped) - , m_handle(handle) -{ - gst_buffer_ref(m_buffer); -} - -QGstVideoBuffer::~QGstVideoBuffer() -{ - gst_buffer_unref(m_buffer); -} - - -QAbstractVideoBuffer::MapMode QGstVideoBuffer::mapMode() const -{ - return m_mode; -} - -uchar *QGstVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) -{ - if (mode != NotMapped && m_mode == NotMapped) { - if (numBytes) - *numBytes = m_buffer->size; - - if (bytesPerLine) - *bytesPerLine = m_bytesPerLine; - - m_mode = mode; - - return m_buffer->data; - } else { - return 0; - } -} -void QGstVideoBuffer::unmap() -{ - m_mode = NotMapped; -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/gstreamer/qgstvideobuffer.h b/src/plugins/mediaservices/gstreamer/qgstvideobuffer.h deleted file mode 100644 index 5133e2e..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstvideobuffer.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTVIDEOBUFFER_H -#define QGSTVIDEOBUFFER_H - -#include -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGstVideoBuffer : public QAbstractVideoBuffer -{ -public: - QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine); - QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine, - HandleType handleType, const QVariant &handle); - ~QGstVideoBuffer(); - - MapMode mapMode() const; - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); - void unmap(); - - QVariant handle() const { return m_handle; } -private: - GstBuffer *m_buffer; - int m_bytesPerLine; - MapMode m_mode; - QVariant m_handle; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp b/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp deleted file mode 100644 index b2e633d..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstxvimagebuffer.h" -#include "qvideosurfacegstsink.h" - - -QT_BEGIN_NAMESPACE - -GstBufferClass *QGstXvImageBuffer::parent_class = NULL; - -GType QGstXvImageBuffer::get_type(void) -{ - static GType buffer_type = 0; - - if (buffer_type == 0) { - static const GTypeInfo buffer_info = { - sizeof (GstBufferClass), - NULL, - NULL, - QGstXvImageBuffer::class_init, - NULL, - NULL, - sizeof(QGstXvImageBuffer), - 0, - (GInstanceInitFunc)QGstXvImageBuffer::buffer_init, - NULL - }; - buffer_type = g_type_register_static(GST_TYPE_BUFFER, - "QGstXvImageBuffer", &buffer_info, GTypeFlags(0)); - } - return buffer_type; -} - -void QGstXvImageBuffer::class_init(gpointer g_class, gpointer class_data) -{ - Q_UNUSED(class_data); - GST_MINI_OBJECT_CLASS(g_class)->finalize = - (GstMiniObjectFinalizeFunction)buffer_finalize; - parent_class = (GstBufferClass*)g_type_class_peek_parent(g_class); -} - -void QGstXvImageBuffer::buffer_init(QGstXvImageBuffer *xvImage, gpointer g_class) -{ - Q_UNUSED(g_class); - xvImage->pool = 0; - xvImage->shmInfo.shmaddr = ((char *) -1); - xvImage->shmInfo.shmid = -1; - xvImage->markedForDeletion = false; -} - -void QGstXvImageBuffer::buffer_finalize(QGstXvImageBuffer * xvImage) -{ - if (xvImage->pool) { - if (xvImage->markedForDeletion) - xvImage->pool->destroyBuffer(xvImage); - else - xvImage->pool->recycleBuffer(xvImage); - } -} - - -QGstXvImageBufferPool::QGstXvImageBufferPool(QObject *parent) - :QObject(parent) -{ -} - -QGstXvImageBufferPool::~QGstXvImageBufferPool() -{ -} - -bool QGstXvImageBufferPool::isFormatSupported(const QVideoSurfaceFormat &surfaceFormat) -{ - bool ok = true; - surfaceFormat.property("portId").toULongLong(&ok); - if (!ok) - return false; - - int xvFormatId = surfaceFormat.property("xvFormatId").toInt(&ok); - if (!ok || xvFormatId < 0) - return false; - - int dataSize = surfaceFormat.property("dataSize").toInt(&ok); - if (!ok || dataSize<=0) - return false; - - return true; -} - -QGstXvImageBuffer *QGstXvImageBufferPool::takeBuffer(const QVideoSurfaceFormat &format, GstCaps *caps) -{ - m_poolMutex.lock(); - - m_caps = caps; - if (format != m_format) { - doClear(); - m_format = format; - } - - - if (m_pool.isEmpty()) { - //qDebug() << "QGstXvImageBufferPool::takeBuffer: no buffer available, allocate the new one"; - if (QThread::currentThread() == thread()) { - m_poolMutex.unlock(); - queuedAlloc(); - m_poolMutex.lock(); - } else { - QMetaObject::invokeMethod(this, "queuedAlloc", Qt::QueuedConnection); - m_allocWaitCondition.wait(&m_poolMutex, 300); - } - } - QGstXvImageBuffer *res = 0; - - if (!m_pool.isEmpty()) { - res = m_pool.takeLast(); - } - - m_poolMutex.unlock(); - - return res; -} - -void QGstXvImageBufferPool::queuedAlloc() -{ - QMutexLocker lock(&m_poolMutex); - - Q_ASSERT(QThread::currentThread() == thread()); - - QGstXvImageBuffer *xvBuffer = (QGstXvImageBuffer *)gst_mini_object_new(QGstXvImageBuffer::get_type()); - - quint64 portId = m_format.property("portId").toULongLong(); - int xvFormatId = m_format.property("xvFormatId").toInt(); - - xvBuffer->xvImage = XvShmCreateImage( - QX11Info::display(), - portId, - xvFormatId, - 0, - m_format.frameWidth(), - m_format.frameHeight(), - &xvBuffer->shmInfo - ); - - if (!xvBuffer->xvImage) { -// qDebug() << "QGstXvImageBufferPool: XvShmCreateImage failed"; - m_allocWaitCondition.wakeOne(); - return; - } - - xvBuffer->shmInfo.shmid = shmget(IPC_PRIVATE, xvBuffer->xvImage->data_size, IPC_CREAT | 0777); - xvBuffer->shmInfo.shmaddr = xvBuffer->xvImage->data = (char*)shmat(xvBuffer->shmInfo.shmid, 0, 0); - xvBuffer->shmInfo.readOnly = False; - - if (!XShmAttach(QX11Info::display(), &xvBuffer->shmInfo)) { -// qDebug() << "QGstXvImageBufferPool: XShmAttach failed"; - m_allocWaitCondition.wakeOne(); - return; - } - - shmctl (xvBuffer->shmInfo.shmid, IPC_RMID, NULL); - - xvBuffer->pool = this; - GST_MINI_OBJECT_CAST(xvBuffer)->flags = 0; - gst_buffer_set_caps(GST_BUFFER_CAST(xvBuffer), m_caps); - GST_BUFFER_DATA(xvBuffer) = (uchar*)xvBuffer->xvImage->data; - GST_BUFFER_SIZE(xvBuffer) = xvBuffer->xvImage->data_size; - - m_allBuffers.append(xvBuffer); - m_pool.append(xvBuffer); - - m_allocWaitCondition.wakeOne(); -} - - -void QGstXvImageBufferPool::clear() -{ - QMutexLocker lock(&m_poolMutex); - doClear(); -} - -void QGstXvImageBufferPool::doClear() -{ - foreach (QGstXvImageBuffer *xvBuffer, m_allBuffers) { - xvBuffer->markedForDeletion = true; - } - m_allBuffers.clear(); - - foreach (QGstXvImageBuffer *xvBuffer, m_pool) { - gst_buffer_unref(GST_BUFFER(xvBuffer)); - } - m_pool.clear(); - - m_format = QVideoSurfaceFormat(); -} - -void QGstXvImageBufferPool::queuedDestroy() -{ - QMutexLocker lock(&m_destroyMutex); - - foreach(XvShmImage xvImage, m_imagesToDestroy) { - if (xvImage.shmInfo.shmaddr != ((void *) -1)) { - XShmDetach(QX11Info::display(), &xvImage.shmInfo); - XSync(QX11Info::display(), false); - - shmdt(xvImage.shmInfo.shmaddr); - } - - if (xvImage.xvImage) - XFree(xvImage.xvImage); - } - - m_imagesToDestroy.clear(); - - XSync(QX11Info::display(), false); -} - -void QGstXvImageBufferPool::recycleBuffer(QGstXvImageBuffer *xvBuffer) -{ - QMutexLocker lock(&m_poolMutex); - gst_buffer_ref(GST_BUFFER_CAST(xvBuffer)); - m_pool.append(xvBuffer); -} - -void QGstXvImageBufferPool::destroyBuffer(QGstXvImageBuffer *xvBuffer) -{ - XvShmImage imageToDestroy; - imageToDestroy.xvImage = xvBuffer->xvImage; - imageToDestroy.shmInfo = xvBuffer->shmInfo; - - m_destroyMutex.lock(); - m_imagesToDestroy.append(imageToDestroy); - m_destroyMutex.unlock(); - - if (m_imagesToDestroy.size() == 1) - QMetaObject::invokeMethod(this, "queuedDestroy", Qt::QueuedConnection); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h b/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h deleted file mode 100644 index 30f77d1..0000000 --- a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QGSTXVIMAGEBUFFER_H -#define QGSTXVIMAGEBUFFER_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGstXvImageBufferPool; - -struct QGstXvImageBuffer { - GstBuffer buffer; - QGstXvImageBufferPool *pool; - XvImage *xvImage; - XShmSegmentInfo shmInfo; - bool markedForDeletion; - - static GType get_type(void); - static void class_init(gpointer g_class, gpointer class_data); - static void buffer_init(QGstXvImageBuffer *xvimage, gpointer g_class); - static void buffer_finalize(QGstXvImageBuffer * xvimage); - static GstBufferClass *parent_class; -}; - -const QAbstractVideoBuffer::HandleType XvHandleType = QAbstractVideoBuffer::HandleType(4); - - - -class QGstXvImageBufferPool : public QObject { -Q_OBJECT -friend class QGstXvImageBuffer; -public: - QGstXvImageBufferPool(QObject *parent = 0); - virtual ~QGstXvImageBufferPool(); - - bool isFormatSupported(const QVideoSurfaceFormat &format); - - QGstXvImageBuffer *takeBuffer(const QVideoSurfaceFormat &format, GstCaps *caps); - void clear(); - -private slots: - void queuedAlloc(); - void queuedDestroy(); - - void doClear(); - - void recycleBuffer(QGstXvImageBuffer *); - void destroyBuffer(QGstXvImageBuffer *); - -private: - struct XvShmImage { - XvImage *xvImage; - XShmSegmentInfo shmInfo; - }; - - QMutex m_poolMutex; - QMutex m_allocMutex; - QWaitCondition m_allocWaitCondition; - QMutex m_destroyMutex; - QVideoSurfaceFormat m_format; - GstCaps *m_caps; - QList m_pool; - QList m_allBuffers; - QList m_imagesToDestroy; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(::XvImage*) - -QT_END_HEADER - - -#endif diff --git a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp deleted file mode 100644 index 596e39d..0000000 --- a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp +++ /dev/null @@ -1,713 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qgstvideobuffer.h" - -#ifdef Q_WS_X11 -#include -#include "qgstxvimagebuffer.h" -#endif - -#include "qvideosurfacegstsink.h" - - - - -Q_DECLARE_METATYPE(QVideoSurfaceFormat) - -QT_BEGIN_NAMESPACE - -QVideoSurfaceGstDelegate::QVideoSurfaceGstDelegate(QAbstractVideoSurface *surface) - : m_surface(surface) - , m_renderReturn(GST_FLOW_ERROR) - , m_bytesPerLine(0) -{ - m_supportedPixelFormats = m_surface->supportedPixelFormats(); - - connect(m_surface, SIGNAL(supportedFormatsChanged()), this, SLOT(supportedFormatsChanged())); -} - -QList QVideoSurfaceGstDelegate::supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const -{ - QMutexLocker locker(const_cast(&m_mutex)); - - if (handleType == QAbstractVideoBuffer::NoHandle) - return m_supportedPixelFormats; - else - return m_surface->supportedPixelFormats(handleType); -} - -QVideoSurfaceFormat QVideoSurfaceGstDelegate::surfaceFormat() const -{ - QMutexLocker locker(const_cast(&m_mutex)); - return m_format; -} - -bool QVideoSurfaceGstDelegate::start(const QVideoSurfaceFormat &format, int bytesPerLine) -{ - QMutexLocker locker(&m_mutex); - - m_format = format; - m_bytesPerLine = bytesPerLine; - - if (QThread::currentThread() == thread()) { - m_started = !m_surface.isNull() ? m_surface->start(m_format) : false; - } else { - QMetaObject::invokeMethod(this, "queuedStart", Qt::QueuedConnection); - - m_setupCondition.wait(&m_mutex); - } - - m_format = m_surface->surfaceFormat(); - - return m_started; -} - -void QVideoSurfaceGstDelegate::stop() -{ - QMutexLocker locker(&m_mutex); - - if (QThread::currentThread() == thread()) { - if (!m_surface.isNull()) - m_surface->stop(); - } else { - QMetaObject::invokeMethod(this, "queuedStop", Qt::QueuedConnection); - - m_setupCondition.wait(&m_mutex); - } - - m_started = false; -} - -bool QVideoSurfaceGstDelegate::isActive() -{ - QMutexLocker locker(&m_mutex); - return m_surface->isActive(); -} - -GstFlowReturn QVideoSurfaceGstDelegate::render(GstBuffer *buffer) -{ - QMutexLocker locker(&m_mutex); - - QGstVideoBuffer *videoBuffer = 0; - -#ifdef Q_WS_X11 - if (G_TYPE_CHECK_INSTANCE_TYPE(buffer, QGstXvImageBuffer::get_type())) { - QGstXvImageBuffer *xvBuffer = reinterpret_cast(buffer); - QVariant handle = QVariant::fromValue(xvBuffer->xvImage); - videoBuffer = new QGstVideoBuffer(buffer, m_bytesPerLine, XvHandleType, handle); - } else -#endif - videoBuffer = new QGstVideoBuffer(buffer, m_bytesPerLine); - - m_frame = QVideoFrame( - videoBuffer, - m_format.frameSize(), - m_format.pixelFormat()); - - qint64 startTime = GST_BUFFER_TIMESTAMP(buffer); - - if (startTime >= 0) { - m_frame.setStartTime(startTime/G_GINT64_CONSTANT (1000000)); - - qint64 duration = GST_BUFFER_DURATION(buffer); - - if (duration >= 0) - m_frame.setEndTime((startTime + duration)/G_GINT64_CONSTANT (1000000)); - } - - QMetaObject::invokeMethod(this, "queuedRender", Qt::QueuedConnection); - - if (!m_renderCondition.wait(&m_mutex, 300)) { - m_frame = QVideoFrame(); - - return GST_FLOW_OK; - } else { - return m_renderReturn; - } -} - -void QVideoSurfaceGstDelegate::queuedStart() -{ - QMutexLocker locker(&m_mutex); - - m_started = m_surface->start(m_format); - - m_setupCondition.wakeAll(); -} - -void QVideoSurfaceGstDelegate::queuedStop() -{ - QMutexLocker locker(&m_mutex); - - m_surface->stop(); - - m_setupCondition.wakeAll(); -} - -void QVideoSurfaceGstDelegate::queuedRender() -{ - QMutexLocker locker(&m_mutex); - - if (m_surface.isNull()) { - m_renderReturn = GST_FLOW_ERROR; - } else if (m_surface->present(m_frame)) { - m_renderReturn = GST_FLOW_OK; - } else { - switch (m_surface->error()) { - case QAbstractVideoSurface::NoError: - m_renderReturn = GST_FLOW_OK; - break; - case QAbstractVideoSurface::StoppedError: - m_renderReturn = GST_FLOW_NOT_NEGOTIATED; - break; - default: - m_renderReturn = GST_FLOW_ERROR; - break; - } - } - - m_renderCondition.wakeAll(); -} - -void QVideoSurfaceGstDelegate::supportedFormatsChanged() -{ - QMutexLocker locker(&m_mutex); - - m_supportedPixelFormats = m_surface->supportedPixelFormats(); -} - -struct YuvFormat -{ - QVideoFrame::PixelFormat pixelFormat; - guint32 fourcc; - int bitsPerPixel; -}; - -static const YuvFormat qt_yuvColorLookup[] = -{ - { QVideoFrame::Format_YUV420P, GST_MAKE_FOURCC('I','4','2','0'), 8 }, - { QVideoFrame::Format_YV12, GST_MAKE_FOURCC('Y','V','1','2'), 8 }, - { QVideoFrame::Format_UYVY, GST_MAKE_FOURCC('U','Y','V','Y'), 16 }, - { QVideoFrame::Format_YUYV, GST_MAKE_FOURCC('Y','U','Y','2'), 16 }, - { QVideoFrame::Format_NV12, GST_MAKE_FOURCC('N','V','1','2'), 8 }, - { QVideoFrame::Format_NV21, GST_MAKE_FOURCC('N','V','2','1'), 8 }, - { QVideoFrame::Format_AYUV444, GST_MAKE_FOURCC('A','Y','U','V'), 32 } -}; - -static int indexOfYuvColor(QVideoFrame::PixelFormat format) -{ - const int count = sizeof(qt_yuvColorLookup) / sizeof(YuvFormat); - - for (int i = 0; i < count; ++i) - if (qt_yuvColorLookup[i].pixelFormat == format) - return i; - - return -1; -} - -static int indexOfYuvColor(guint32 fourcc) -{ - const int count = sizeof(qt_yuvColorLookup) / sizeof(YuvFormat); - - for (int i = 0; i < count; ++i) - if (qt_yuvColorLookup[i].fourcc == fourcc) - return i; - - return -1; -} - -struct RgbFormat -{ - QVideoFrame::PixelFormat pixelFormat; - int bitsPerPixel; - int depth; - int endianness; - int red; - int green; - int blue; - int alpha; -}; - -static const RgbFormat qt_rgbColorLookup[] = -{ - { QVideoFrame::Format_RGB32 , 32, 24, 4321, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000 }, - { QVideoFrame::Format_RGB32 , 32, 24, 1234, 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }, - { QVideoFrame::Format_BGR32 , 32, 24, 4321, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x00000000 }, - { QVideoFrame::Format_BGR32 , 32, 24, 1234, 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 }, - { QVideoFrame::Format_ARGB32, 32, 24, 4321, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF }, - { QVideoFrame::Format_ARGB32, 32, 24, 1234, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 }, - { QVideoFrame::Format_RGB24 , 24, 24, 4321, 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }, - { QVideoFrame::Format_BGR24 , 24, 24, 4321, 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 }, - { QVideoFrame::Format_RGB565, 16, 16, 1234, 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 } -}; - -static int indexOfRgbColor( - int bits, int depth, int endianness, int red, int green, int blue, int alpha) -{ - const int count = sizeof(qt_rgbColorLookup) / sizeof(RgbFormat); - - for (int i = 0; i < count; ++i) { - if (qt_rgbColorLookup[i].bitsPerPixel == bits - && qt_rgbColorLookup[i].depth == depth - && qt_rgbColorLookup[i].endianness == endianness - && qt_rgbColorLookup[i].red == red - && qt_rgbColorLookup[i].green == green - && qt_rgbColorLookup[i].blue == blue - && qt_rgbColorLookup[i].alpha == alpha) { - return i; - } - } - return -1; -} - -static GstVideoSinkClass *sink_parent_class; - -#define VO_SINK(s) QVideoSurfaceGstSink *sink(reinterpret_cast(s)) - -QVideoSurfaceGstSink *QVideoSurfaceGstSink::createSink(QAbstractVideoSurface *surface) -{ - QVideoSurfaceGstSink *sink = reinterpret_cast( - g_object_new(QVideoSurfaceGstSink::get_type(), 0)); - - sink->delegate = new QVideoSurfaceGstDelegate(surface); - - return sink; -} - -GType QVideoSurfaceGstSink::get_type() -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = - { - sizeof(QVideoSurfaceGstSinkClass), // class_size - base_init, // base_init - NULL, // base_finalize - class_init, // class_init - NULL, // class_finalize - NULL, // class_data - sizeof(QVideoSurfaceGstSink), // instance_size - 0, // n_preallocs - instance_init, // instance_init - 0 // value_table - }; - - type = g_type_register_static( - GST_TYPE_VIDEO_SINK, "QVideoSurfaceGstSink", &info, GTypeFlags(0)); - } - - return type; -} - -void QVideoSurfaceGstSink::class_init(gpointer g_class, gpointer class_data) -{ - Q_UNUSED(class_data); - - sink_parent_class = reinterpret_cast(g_type_class_peek_parent(g_class)); - - GstBaseSinkClass *base_sink_class = reinterpret_cast(g_class); - base_sink_class->get_caps = QVideoSurfaceGstSink::get_caps; - base_sink_class->set_caps = QVideoSurfaceGstSink::set_caps; - base_sink_class->buffer_alloc = QVideoSurfaceGstSink::buffer_alloc; - base_sink_class->start = QVideoSurfaceGstSink::start; - base_sink_class->stop = QVideoSurfaceGstSink::stop; - // base_sink_class->unlock = QVideoSurfaceGstSink::unlock; // Not implemented. - // base_sink_class->event = QVideoSurfaceGstSink::event; // Not implemented. - base_sink_class->preroll = QVideoSurfaceGstSink::preroll; - base_sink_class->render = QVideoSurfaceGstSink::render; - - GstElementClass *element_class = reinterpret_cast(g_class); - element_class->change_state = QVideoSurfaceGstSink::change_state; - - GObjectClass *object_class = reinterpret_cast(g_class); - object_class->finalize = QVideoSurfaceGstSink::finalize; -} - -void QVideoSurfaceGstSink::base_init(gpointer g_class) -{ - static GstStaticPadTemplate sink_pad_template = GST_STATIC_PAD_TEMPLATE( - "sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS( - "video/x-raw-rgb, " - "framerate = (fraction) [ 0, MAX ], " - "width = (int) [ 1, MAX ], " - "height = (int) [ 1, MAX ]; " - "video/x-raw-yuv, " - "framerate = (fraction) [ 0, MAX ], " - "width = (int) [ 1, MAX ], " - "height = (int) [ 1, MAX ]")); - - gst_element_class_add_pad_template( - GST_ELEMENT_CLASS(g_class), gst_static_pad_template_get(&sink_pad_template)); -} - -void QVideoSurfaceGstSink::instance_init(GTypeInstance *instance, gpointer g_class) -{ - VO_SINK(instance); - - Q_UNUSED(g_class); - - sink->delegate = 0; -#ifdef Q_WS_X11 - sink->pool = new QGstXvImageBufferPool(); -#endif - sink->lastRequestedCaps = 0; - sink->lastBufferCaps = 0; - sink->lastSurfaceFormat = new QVideoSurfaceFormat; -} - -void QVideoSurfaceGstSink::finalize(GObject *object) -{ - VO_SINK(object); -#ifdef Q_WS_X11 - delete sink->pool; - sink->pool = 0; -#endif - - delete sink->lastSurfaceFormat; - sink->lastSurfaceFormat = 0; - - if (sink->lastBufferCaps) - gst_caps_unref(sink->lastBufferCaps); - sink->lastBufferCaps = 0; - - if (sink->lastRequestedCaps) - gst_caps_unref(sink->lastRequestedCaps); - sink->lastRequestedCaps = 0; -} - -GstStateChangeReturn QVideoSurfaceGstSink::change_state( - GstElement *element, GstStateChange transition) -{ - Q_UNUSED(element); - - return GST_ELEMENT_CLASS(sink_parent_class)->change_state( - element, transition); -} - -GstCaps *QVideoSurfaceGstSink::get_caps(GstBaseSink *base) -{ - VO_SINK(base); - - GstCaps *caps = gst_caps_new_empty(); - - foreach (QVideoFrame::PixelFormat format, sink->delegate->supportedPixelFormats()) { - int index = indexOfYuvColor(format); - - if (index != -1) { - gst_caps_append_structure(caps, gst_structure_new( - "video/x-raw-yuv", - "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, INT_MAX, 1, - "width" , GST_TYPE_INT_RANGE, 1, INT_MAX, - "height" , GST_TYPE_INT_RANGE, 1, INT_MAX, - "format" , GST_TYPE_FOURCC, qt_yuvColorLookup[index].fourcc, - NULL)); - continue; - } - - const int count = sizeof(qt_rgbColorLookup) / sizeof(RgbFormat); - - for (int i = 0; i < count; ++i) { - if (qt_rgbColorLookup[i].pixelFormat == format) { - GstStructure *structure = gst_structure_new( - "video/x-raw-rgb", - "framerate" , GST_TYPE_FRACTION_RANGE, 0, 1, INT_MAX, 1, - "width" , GST_TYPE_INT_RANGE, 1, INT_MAX, - "height" , GST_TYPE_INT_RANGE, 1, INT_MAX, - "bpp" , G_TYPE_INT, qt_rgbColorLookup[i].bitsPerPixel, - "depth" , G_TYPE_INT, qt_rgbColorLookup[i].depth, - "endianness", G_TYPE_INT, qt_rgbColorLookup[i].endianness, - "red_mask" , G_TYPE_INT, qt_rgbColorLookup[i].red, - "green_mask", G_TYPE_INT, qt_rgbColorLookup[i].green, - "blue_mask" , G_TYPE_INT, qt_rgbColorLookup[i].blue, - NULL); - - if (qt_rgbColorLookup[i].alpha != 0) { - gst_structure_set( - structure, "alpha_mask", G_TYPE_INT, qt_rgbColorLookup[i].alpha, NULL); - } - gst_caps_append_structure(caps, structure); - } - } - } - - return caps; -} - -gboolean QVideoSurfaceGstSink::set_caps(GstBaseSink *base, GstCaps *caps) -{ - VO_SINK(base); - - //qDebug() << "set_caps"; - //qDebug() << gst_caps_to_string(caps); - - if (!caps) { - sink->delegate->stop(); - - return TRUE; - } else { - int bytesPerLine = 0; - QVideoSurfaceFormat format = formatForCaps(caps, &bytesPerLine); - - if (sink->delegate->isActive()) { - QVideoSurfaceFormat surfaceFormst = sink->delegate->surfaceFormat(); - - if (format.pixelFormat() == surfaceFormst.pixelFormat() && - format.frameSize() == surfaceFormst.frameSize()) - return TRUE; - else - sink->delegate->stop(); - } - - if (sink->lastRequestedCaps) - gst_caps_unref(sink->lastRequestedCaps); - sink->lastRequestedCaps = 0; - - //qDebug() << "Staring video surface:"; - //qDebug() << format; - //qDebug() << bytesPerLine; - - if (sink->delegate->start(format, bytesPerLine)) - return TRUE; - - } - - return FALSE; -} - -QVideoSurfaceFormat QVideoSurfaceGstSink::formatForCaps(GstCaps *caps, int *bytesPerLine) -{ - const GstStructure *structure = gst_caps_get_structure(caps, 0); - - QVideoFrame::PixelFormat pixelFormat = QVideoFrame::Format_Invalid; - int bitsPerPixel = 0; - - QSize size; - gst_structure_get_int(structure, "width", &size.rwidth()); - gst_structure_get_int(structure, "height", &size.rheight()); - - if (qstrcmp(gst_structure_get_name(structure), "video/x-raw-yuv") == 0) { - guint32 fourcc = 0; - gst_structure_get_fourcc(structure, "format", &fourcc); - - int index = indexOfYuvColor(fourcc); - if (index != -1) { - pixelFormat = qt_yuvColorLookup[index].pixelFormat; - bitsPerPixel = qt_yuvColorLookup[index].bitsPerPixel; - } - } else if (qstrcmp(gst_structure_get_name(structure), "video/x-raw-rgb") == 0) { - int depth = 0; - int endianness = 0; - int red = 0; - int green = 0; - int blue = 0; - int alpha = 0; - - gst_structure_get_int(structure, "bpp", &bitsPerPixel); - gst_structure_get_int(structure, "depth", &depth); - gst_structure_get_int(structure, "endianness", &endianness); - gst_structure_get_int(structure, "red_mask", &red); - gst_structure_get_int(structure, "green_mask", &green); - gst_structure_get_int(structure, "blue_mask", &blue); - gst_structure_get_int(structure, "alpha_mask", &alpha); - - int index = indexOfRgbColor(bitsPerPixel, depth, endianness, red, green, blue, alpha); - - if (index != -1) - pixelFormat = qt_rgbColorLookup[index].pixelFormat; - } - - if (pixelFormat != QVideoFrame::Format_Invalid) { - QVideoSurfaceFormat format(size, pixelFormat); - - QPair rate; - gst_structure_get_fraction(structure, "framerate", &rate.first, &rate.second); - - if (rate.second) - format.setFrameRate(qreal(rate.first)/rate.second); - - gint aspectNum = 0; - gint aspectDenum = 0; - if (gst_structure_get_fraction( - structure, "pixel-aspect-ratio", &aspectNum, &aspectDenum)) { - if (aspectDenum > 0) - format.setPixelAspectRatio(aspectNum, aspectDenum); - } - - if (bytesPerLine) - *bytesPerLine = ((size.width() * bitsPerPixel / 8) + 3) & ~3; - - return format; - } - - return QVideoSurfaceFormat(); -} - - -GstFlowReturn QVideoSurfaceGstSink::buffer_alloc( - GstBaseSink *base, guint64 offset, guint size, GstCaps *caps, GstBuffer **buffer) -{ - VO_SINK(base); - - Q_UNUSED(offset); - Q_UNUSED(size); - - *buffer = 0; - -#ifdef Q_WS_X11 - - if (sink->lastRequestedCaps && gst_caps_is_equal(sink->lastRequestedCaps, caps)) { - //qDebug() << "reusing last caps"; - *buffer = GST_BUFFER(sink->pool->takeBuffer(*sink->lastSurfaceFormat, sink->lastBufferCaps)); - return GST_FLOW_OK; - } - - if (sink->delegate->supportedPixelFormats(XvHandleType).isEmpty()) { - //qDebug() << "sink doesn't support Xv buffers, skip buffers allocation"; - return GST_FLOW_OK; - } - - GstCaps *intersection = gst_caps_intersect(get_caps(GST_BASE_SINK(sink)), caps); - - if (gst_caps_is_empty (intersection)) { - gst_caps_unref(intersection); - return GST_FLOW_NOT_NEGOTIATED; - } - - if (sink->delegate->isActive()) { - //if format was changed, restart the surface - QVideoSurfaceFormat format = formatForCaps(intersection); - QVideoSurfaceFormat surfaceFormat = sink->delegate->surfaceFormat(); - - if (format.pixelFormat() != surfaceFormat.pixelFormat() || - format.frameSize() != surfaceFormat.frameSize()) { - //qDebug() << "new format requested, restart video surface"; - sink->delegate->stop(); - } - } - - if (!sink->delegate->isActive()) { - int bytesPerLine = 0; - QVideoSurfaceFormat format = formatForCaps(intersection, &bytesPerLine); - - if (!sink->delegate->start(format, bytesPerLine)) { - qDebug() << "failed to start video surface"; - return GST_FLOW_NOT_NEGOTIATED; - } - } - - QVideoSurfaceFormat surfaceFormat = sink->delegate->surfaceFormat(); - - if (!sink->pool->isFormatSupported(surfaceFormat)) { - //qDebug() << "sink doesn't provide Xv buffer details, skip buffers allocation"; - return GST_FLOW_OK; - } - - if (sink->lastRequestedCaps) - gst_caps_unref(sink->lastRequestedCaps); - sink->lastRequestedCaps = caps; - gst_caps_ref(sink->lastRequestedCaps); - - if (sink->lastBufferCaps) - gst_caps_unref(sink->lastBufferCaps); - sink->lastBufferCaps = intersection; - gst_caps_ref(sink->lastBufferCaps); - - *sink->lastSurfaceFormat = surfaceFormat; - - *buffer = GST_BUFFER(sink->pool->takeBuffer(surfaceFormat, intersection)); - -#endif - return GST_FLOW_OK; -} - -gboolean QVideoSurfaceGstSink::start(GstBaseSink *base) -{ - Q_UNUSED(base); - - return TRUE; -} - -gboolean QVideoSurfaceGstSink::stop(GstBaseSink *base) -{ - Q_UNUSED(base); - - return TRUE; -} - -gboolean QVideoSurfaceGstSink::unlock(GstBaseSink *base) -{ - Q_UNUSED(base); - - return TRUE; -} - -gboolean QVideoSurfaceGstSink::event(GstBaseSink *base, GstEvent *event) -{ - Q_UNUSED(base); - Q_UNUSED(event); - - return TRUE; -} - -GstFlowReturn QVideoSurfaceGstSink::preroll(GstBaseSink *base, GstBuffer *buffer) -{ - VO_SINK(base); - - return sink->delegate->render(buffer); -} - -GstFlowReturn QVideoSurfaceGstSink::render(GstBaseSink *base, GstBuffer *buffer) -{ - VO_SINK(base); - return sink->delegate->render(buffer); -} - -QT_END_NAMESPACE - - diff --git a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h deleted file mode 100644 index 75fa854..0000000 --- a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 VIDEOSURFACEGSTSINK_H -#define VIDEOSURFACEGSTSINK_H - -#include - -#include -#include -#include -#include -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QAbstractVideoSurface; - -#ifdef Q_WS_X11 -class QGstXvImageBuffer; -class QGstXvImageBufferPool; -#endif - - -class QVideoSurfaceGstDelegate : public QObject -{ - Q_OBJECT -public: - QVideoSurfaceGstDelegate(QAbstractVideoSurface *surface); - - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; - - QVideoSurfaceFormat surfaceFormat() const; - - - bool start(const QVideoSurfaceFormat &format, int bytesPerLine); - void stop(); - - bool isActive(); - - GstFlowReturn render(GstBuffer *buffer); - -private slots: - void queuedStart(); - void queuedStop(); - void queuedRender(); - - void supportedFormatsChanged(); - -private: - QPointer m_surface; - QList m_supportedPixelFormats; - QMutex m_mutex; - QWaitCondition m_setupCondition; - QWaitCondition m_renderCondition; - QVideoSurfaceFormat m_format; - QVideoFrame m_frame; - GstFlowReturn m_renderReturn; - int m_bytesPerLine; - bool m_started; -}; - -class QVideoSurfaceGstSink -{ -public: - GstVideoSink parent; - - static QVideoSurfaceGstSink *createSink(QAbstractVideoSurface *surface); - static QVideoSurfaceFormat formatForCaps(GstCaps *caps, int *bytesPerLine = 0); - -private: - static GType get_type(); - static void class_init(gpointer g_class, gpointer class_data); - static void base_init(gpointer g_class); - static void instance_init(GTypeInstance *instance, gpointer g_class); - - static void finalize(GObject *object); - - static GstStateChangeReturn change_state(GstElement *element, GstStateChange transition); - - static GstCaps *get_caps(GstBaseSink *sink); - static gboolean set_caps(GstBaseSink *sink, GstCaps *caps); - - static GstFlowReturn buffer_alloc( - GstBaseSink *sink, guint64 offset, guint size, GstCaps *caps, GstBuffer **buffer); - - static gboolean start(GstBaseSink *sink); - static gboolean stop(GstBaseSink *sink); - - static gboolean unlock(GstBaseSink *sink); - - static gboolean event(GstBaseSink *sink, GstEvent *event); - static GstFlowReturn preroll(GstBaseSink *sink, GstBuffer *buffer); - static GstFlowReturn render(GstBaseSink *sink, GstBuffer *buffer); - -private: - QVideoSurfaceGstDelegate *delegate; - -#ifdef Q_WS_X11 - QGstXvImageBufferPool *pool; -#endif - - GstCaps *lastRequestedCaps; - GstCaps *lastBufferCaps; - QVideoSurfaceFormat *lastSurfaceFormat; -}; - - -class QVideoSurfaceGstSinkClass -{ -public: - GstVideoSinkClass parent_class; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp b/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp deleted file mode 100644 index 70b8527..0000000 --- a/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp +++ /dev/null @@ -1,523 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qx11videosurface.h" - -Q_DECLARE_METATYPE(::XvImage*); - -QT_BEGIN_NAMESPACE - -static QAbstractVideoBuffer::HandleType XvHandleType = QAbstractVideoBuffer::HandleType(4); - -struct XvFormatRgb -{ - QVideoFrame::PixelFormat pixelFormat; - int bits_per_pixel; - int format; - int num_planes; - - int depth; - unsigned int red_mask; - unsigned int green_mask; - unsigned int blue_mask; - -}; - -bool operator ==(const XvImageFormatValues &format, const XvFormatRgb &rgb) -{ - return format.type == XvRGB - && format.bits_per_pixel == rgb.bits_per_pixel - && format.format == rgb.format - && format.num_planes == rgb.num_planes - && format.depth == rgb.depth - && format.red_mask == rgb.red_mask - && format.blue_mask == rgb.blue_mask; -} - -static const XvFormatRgb qt_xvRgbLookup[] = -{ - { QVideoFrame::Format_ARGB32, 32, XvPacked, 1, 32, 0x00FF0000, 0x0000FF00, 0x000000FF }, - { QVideoFrame::Format_RGB32 , 32, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, - { QVideoFrame::Format_RGB24 , 24, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, - { QVideoFrame::Format_RGB565, 16, XvPacked, 1, 16, 0x0000F800, 0x000007E0, 0x0000001F }, - { QVideoFrame::Format_BGRA32, 32, XvPacked, 1, 32, 0xFF000000, 0x00FF0000, 0x0000FF00 }, - { QVideoFrame::Format_BGR32 , 32, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, - { QVideoFrame::Format_BGR24 , 24, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, - { QVideoFrame::Format_BGR565, 16, XvPacked, 1, 16, 0x0000F800, 0x000007E0, 0x0000001F } -}; - -struct XvFormatYuv -{ - QVideoFrame::PixelFormat pixelFormat; - int bits_per_pixel; - int format; - int num_planes; - - unsigned int y_sample_bits; - unsigned int u_sample_bits; - unsigned int v_sample_bits; - unsigned int horz_y_period; - unsigned int horz_u_period; - unsigned int horz_v_period; - unsigned int vert_y_period; - unsigned int vert_u_period; - unsigned int vert_v_period; - char component_order[32]; -}; - -bool operator ==(const XvImageFormatValues &format, const XvFormatYuv &yuv) -{ - return format.type == XvYUV - && format.bits_per_pixel == yuv.bits_per_pixel - && format.format == yuv.format - && format.num_planes == yuv.num_planes - && format.y_sample_bits == yuv.y_sample_bits - && format.u_sample_bits == yuv.u_sample_bits - && format.v_sample_bits == yuv.v_sample_bits - && format.horz_y_period == yuv.horz_y_period - && format.horz_u_period == yuv.horz_u_period - && format.horz_v_period == yuv.horz_v_period - && format.horz_y_period == yuv.vert_y_period - && format.vert_u_period == yuv.vert_u_period - && format.vert_v_period == yuv.vert_v_period - && qstrncmp(format.component_order, yuv.component_order, 32) == 0; -} - -static const XvFormatYuv qt_xvYuvLookup[] = -{ - { QVideoFrame::Format_YUV444 , 24, XvPacked, 1, 8, 8, 8, 1, 1, 1, 1, 1, 1, "YUV" }, - { QVideoFrame::Format_YUV420P, 12, XvPlanar, 3, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YUV" }, - { QVideoFrame::Format_YV12 , 12, XvPlanar, 3, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YVU" }, - { QVideoFrame::Format_UYVY , 16, XvPacked, 1, 8, 8, 8, 1, 2, 2, 1, 1, 1, "UYVY" }, - { QVideoFrame::Format_YUYV , 16, XvPacked, 1, 8, 8, 8, 1, 2, 2, 1, 1, 1, "YUY2" }, - { QVideoFrame::Format_YUYV , 16, XvPacked, 1, 8, 8, 8, 1, 2, 2, 1, 1, 1, "YUYV" }, - { QVideoFrame::Format_NV12 , 12, XvPlanar, 2, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YUV" }, - { QVideoFrame::Format_NV12 , 12, XvPlanar, 2, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YVU" }, - { QVideoFrame::Format_Y8 , 8 , XvPlanar, 1, 8, 0, 0, 1, 0, 0, 1, 0, 0, "Y" } -}; - -QX11VideoSurface::QX11VideoSurface(QObject *parent) - : QAbstractVideoSurface(parent) - , m_winId(0) - , m_portId(0) - , m_gc(0) - , m_image(0) -{ -} - -QX11VideoSurface::~QX11VideoSurface() -{ - if (m_gc) - XFreeGC(QX11Info::display(), m_gc); - - if (m_portId != 0) - XvUngrabPort(QX11Info::display(), m_portId, 0); -} - -WId QX11VideoSurface::winId() const -{ - return m_winId; -} - -void QX11VideoSurface::setWinId(WId id) -{ - if (id == m_winId) - return; - - if (m_image) - XFree(m_image); - - if (m_gc) { - XFreeGC(QX11Info::display(), m_gc); - m_gc = 0; - } - - if (m_portId != 0) - XvUngrabPort(QX11Info::display(), m_portId, 0); - - m_supportedPixelFormats.clear(); - m_formatIds.clear(); - - m_winId = id; - - if (m_winId && findPort()) { - querySupportedFormats(); - - m_gc = XCreateGC(QX11Info::display(), m_winId, 0, 0); - - if (m_image) { - m_image = 0; - - if (!start(surfaceFormat())) - QAbstractVideoSurface::stop(); - } - } else if (m_image) { - m_image = 0; - - QAbstractVideoSurface::stop(); - } - - emit supportedFormatsChanged(); -} - -QRect QX11VideoSurface::displayRect() const -{ - return m_displayRect; -} - -void QX11VideoSurface::setDisplayRect(const QRect &rect) -{ - m_displayRect = rect; -} - -QRect QX11VideoSurface::viewport() const -{ - return m_viewport; -} - -void QX11VideoSurface::setViewport(const QRect &rect) -{ - m_viewport = rect; -} - -int QX11VideoSurface::brightness() const -{ - return getAttribute("XV_BRIGHTNESS", m_brightnessRange.first, m_brightnessRange.second); -} - -void QX11VideoSurface::setBrightness(int brightness) -{ - setAttribute("XV_BRIGHTNESS", brightness, m_brightnessRange.first, m_brightnessRange.second); -} - -int QX11VideoSurface::contrast() const -{ - return getAttribute("XV_CONTRAST", m_contrastRange.first, m_contrastRange.second); -} - -void QX11VideoSurface::setContrast(int contrast) -{ - setAttribute("XV_CONTRAST", contrast, m_contrastRange.first, m_contrastRange.second); -} - -int QX11VideoSurface::hue() const -{ - return getAttribute("XV_HUE", m_hueRange.first, m_hueRange.second); -} - -void QX11VideoSurface::setHue(int hue) -{ - setAttribute("XV_HUE", hue, m_hueRange.first, m_hueRange.second); -} - -int QX11VideoSurface::saturation() const -{ - return getAttribute("XV_SATURATION", m_saturationRange.first, m_saturationRange.second); -} - -void QX11VideoSurface::setSaturation(int saturation) -{ - setAttribute("XV_SATURATION", saturation, m_saturationRange.first, m_saturationRange.second); -} - -int QX11VideoSurface::getAttribute(const char *attribute, int minimum, int maximum) const -{ - if (m_portId != 0) { - Display *display = QX11Info::display(); - - Atom atom = XInternAtom(display, attribute, True); - - int value = 0; - - XvGetPortAttribute(display, m_portId, atom, &value); - - return redistribute(value, minimum, maximum, -100, 100); - } else { - return 0; - } -} - -void QX11VideoSurface::setAttribute(const char *attribute, int value, int minimum, int maximum) -{ - if (m_portId != 0) { - Display *display = QX11Info::display(); - - Atom atom = XInternAtom(display, attribute, True); - - XvSetPortAttribute( - display, m_portId, atom, redistribute(value, -100, 100, minimum, maximum)); - } -} - -int QX11VideoSurface::redistribute( - int value, int fromLower, int fromUpper, int toLower, int toUpper) -{ - return fromUpper != fromLower - ? ((value - fromLower) * (toUpper - toLower) / (fromUpper - fromLower)) + toLower - : 0; -} - -QList QX11VideoSurface::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - return handleType == QAbstractVideoBuffer::NoHandle || handleType == XvHandleType - ? m_supportedPixelFormats - : QList(); -} - -bool QX11VideoSurface::start(const QVideoSurfaceFormat &format) -{ - if (m_image) - XFree(m_image); - - int xvFormatId = 0; - for (int i = 0; i < m_supportedPixelFormats.count(); ++i) { - if (m_supportedPixelFormats.at(i) == format.pixelFormat()) { - xvFormatId = m_formatIds.at(i); - break; - } - } - - if (xvFormatId == 0) { - setError(UnsupportedFormatError); - } else { - XvImage *image = XvCreateImage( - QX11Info::display(), - m_portId, - xvFormatId, - 0, - format.frameWidth(), - format.frameHeight()); - - if (!image) { - setError(ResourceError); - } else { - m_viewport = format.viewport(); - m_image = image; - - QVideoSurfaceFormat newFormat = format; - newFormat.setProperty("portId", QVariant(quint64(m_portId))); - newFormat.setProperty("xvFormatId", xvFormatId); - newFormat.setProperty("dataSize", image->data_size); - - return QAbstractVideoSurface::start(newFormat); - } - } - - if (m_image) { - m_image = 0; - - QAbstractVideoSurface::stop(); - } - - return false; -} - -void QX11VideoSurface::stop() -{ - if (m_image) { - XFree(m_image); - m_image = 0; - - QAbstractVideoSurface::stop(); - } -} - -bool QX11VideoSurface::present(const QVideoFrame &frame) -{ - if (!m_image) { - setError(StoppedError); - return false; - } else if (m_image->width != frame.width() || m_image->height != frame.height()) { - setError(IncorrectFormatError); - return false; - } else { - QVideoFrame frameCopy(frame); - - if (!frameCopy.map(QAbstractVideoBuffer::ReadOnly)) { - setError(IncorrectFormatError); - return false; - } else { - bool presented = false; - - if (frame.handleType() != XvHandleType && - m_image->data_size > frame.mappedBytes()) { - qWarning("Insufficient frame buffer size"); - setError(IncorrectFormatError); - } else if (frame.handleType() != XvHandleType && - m_image->num_planes > 0 && - m_image->pitches[0] != frame.bytesPerLine()) { - qWarning("Incompatible frame pitches"); - setError(IncorrectFormatError); - } else { - if (frame.handleType() != XvHandleType) { - m_image->data = reinterpret_cast(frameCopy.bits()); - - //qDebug() << "copy frame"; - XvPutImage( - QX11Info::display(), - m_portId, - m_winId, - m_gc, - m_image, - m_viewport.x(), - m_viewport.y(), - m_viewport.width(), - m_viewport.height(), - m_displayRect.x(), - m_displayRect.y(), - m_displayRect.width(), - m_displayRect.height()); - - m_image->data = 0; - } else { - XvImage *img = frame.handle().value(); - - //qDebug() << "render directly"; - if (img) - XvShmPutImage( - QX11Info::display(), - m_portId, - m_winId, - m_gc, - img, - m_viewport.x(), - m_viewport.y(), - m_viewport.width(), - m_viewport.height(), - m_displayRect.x(), - m_displayRect.y(), - m_displayRect.width(), - m_displayRect.height(), - false); - } - - presented = true; - } - - frameCopy.unmap(); - - return presented; - } - } -} - -bool QX11VideoSurface::findPort() -{ - unsigned int count = 0; - XvAdaptorInfo *adaptors = 0; - bool portFound = false; - - if (XvQueryAdaptors(QX11Info::display(), m_winId, &count, &adaptors) == Success) { - for (unsigned int i = 0; i < count && !portFound; ++i) { - if (adaptors[i].type & XvImageMask) { - m_portId = adaptors[i].base_id; - - for (unsigned int j = 0; j < adaptors[i].num_ports && !portFound; ++j, ++m_portId) - portFound = XvGrabPort(QX11Info::display(), m_portId, 0) == Success; - } - } - XvFreeAdaptorInfo(adaptors); - } - - return portFound; -} - -void QX11VideoSurface::querySupportedFormats() -{ - int count = 0; - if (XvImageFormatValues *imageFormats = XvListImageFormats( - QX11Info::display(), m_portId, &count)) { - const int rgbCount = sizeof(qt_xvRgbLookup) / sizeof(XvFormatRgb); - const int yuvCount = sizeof(qt_xvYuvLookup) / sizeof(XvFormatYuv); - - for (int i = 0; i < count; ++i) { - switch (imageFormats[i].type) { - case XvRGB: - for (int j = 0; j < rgbCount; ++j) { - if (imageFormats[i] == qt_xvRgbLookup[j]) { - m_supportedPixelFormats.append(qt_xvRgbLookup[j].pixelFormat); - m_formatIds.append(imageFormats[i].id); - break; - } - } - break; - case XvYUV: - for (int j = 0; j < yuvCount; ++j) { - if (imageFormats[i] == qt_xvYuvLookup[j]) { - m_supportedPixelFormats.append(qt_xvYuvLookup[j].pixelFormat); - m_formatIds.append(imageFormats[i].id); - break; - } - } - break; - } - } - XFree(imageFormats); - } - - m_brightnessRange = qMakePair(0, 0); - m_contrastRange = qMakePair(0, 0); - m_hueRange = qMakePair(0, 0); - m_saturationRange = qMakePair(0, 0); - - if (XvAttribute *attributes = XvQueryPortAttributes(QX11Info::display(), m_portId, &count)) { - for (int i = 0; i < count; ++i) { - if (qstrcmp(attributes[i].name, "XV_BRIGHTNESS") == 0) - m_brightnessRange = qMakePair(attributes[i].min_value, attributes[i].max_value); - else if (qstrcmp(attributes[i].name, "XV_CONTRAST") == 0) - m_contrastRange = qMakePair(attributes[i].min_value, attributes[i].max_value); - else if (qstrcmp(attributes[i].name, "XV_HUE") == 0) - m_hueRange = qMakePair(attributes[i].min_value, attributes[i].max_value); - else if (qstrcmp(attributes[i].name, "XV_SATURATION") == 0) - m_saturationRange = qMakePair(attributes[i].min_value, attributes[i].max_value); - } - - XFree(attributes); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/gstreamer/qx11videosurface.h b/src/plugins/mediaservices/gstreamer/qx11videosurface.h deleted file mode 100644 index 10f79a6..0000000 --- a/src/plugins/mediaservices/gstreamer/qx11videosurface.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QX11VIDEOSURFACE_H -#define QX11VIDEOSURFACE_H - -#include -#include - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QX11VideoSurface : public QAbstractVideoSurface -{ - Q_OBJECT -public: - QX11VideoSurface(QObject *parent = 0); - ~QX11VideoSurface(); - - WId winId() const; - void setWinId(WId id); - - QRect displayRect() const; - void setDisplayRect(const QRect &rect); - - QRect viewport() const; - void setViewport(const QRect &rect); - - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); - - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; - - bool start(const QVideoSurfaceFormat &format); - void stop(); - - bool present(const QVideoFrame &frame); - -private: - WId m_winId; - XvPortID m_portId; - GC m_gc; - XvImage *m_image; - QList m_supportedPixelFormats; - QVector m_formatIds; - QRect m_viewport; - QRect m_displayRect; - QPair m_brightnessRange; - QPair m_contrastRange; - QPair m_hueRange; - QPair m_saturationRange; - - bool findPort(); - void querySupportedFormats(); - - int getAttribute(const char *attribute, int minimum, int maximum) const; - void setAttribute(const char *attribute, int value, int minimum, int maximum); - - static int redistribute(int value, int fromLower, int fromUpper, int toLower, int toUpper); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/mediaservices.pro b/src/plugins/mediaservices/mediaservices.pro deleted file mode 100644 index 27f05bc..0000000 --- a/src/plugins/mediaservices/mediaservices.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = subdirs - -contains(QT_CONFIG, media-backend) { - win32:!wince*: SUBDIRS += directshow - - mac: SUBDIRS += qt7 - - unix:!mac:!symbian:contains(QT_CONFIG, gstreamer) { - SUBDIRS += gstreamer - } - - symbian:SUBDIRS += symbian -} diff --git a/src/plugins/mediaservices/qt7/mediaplayer/mediaplayer.pri b/src/plugins/mediaservices/qt7/mediaplayer/mediaplayer.pri deleted file mode 100644 index 577209e..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/mediaplayer.pri +++ /dev/null @@ -1,18 +0,0 @@ -INCLUDEPATH += $$PWD - -DEFINES += QMEDIA_QT7_PLAYER - -HEADERS += \ - $$PWD/qt7playercontrol.h \ - $$PWD/qt7playermetadata.h \ - $$PWD/qt7playerservice.h \ - $$PWD/qt7playersession.h - -OBJECTIVE_SOURCES += \ - $$PWD/qt7playercontrol.mm \ - $$PWD/qt7playermetadata.mm \ - $$PWD/qt7playerservice.mm \ - $$PWD/qt7playersession.mm - - - diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h deleted file mode 100644 index 5ac97b1..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7PLAYERCONTROL_H -#define QT7PLAYERCONTROL_H - -#include -#include - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QT7PlayerSession; -class QT7PlayerService; -class QMediaPlaylist; -class QMediaPlaylistNavigator; - -class QT7PlayerControl : public QMediaPlayerControl -{ -Q_OBJECT -public: - QT7PlayerControl(QObject *parent = 0); - ~QT7PlayerControl(); - - void setSession(QT7PlayerSession *session); - - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; - - QMediaContent media() const; - const QIODevice *mediaStream() const; - void setMedia(const QMediaContent &content, QIODevice *stream); - - qint64 position() const; - qint64 duration() const; - - int bufferStatus() const; - - int volume() const; - bool isMuted() const; - - bool isAudioAvailable() const; - bool isVideoAvailable() const; - - bool isSeekable() const; - - QMediaTimeRange availablePlaybackRanges() const; - - qreal playbackRate() const; - void setPlaybackRate(qreal rate); - -public Q_SLOTS: - void setPosition(qint64 pos); - - void play(); - void pause(); - void stop(); - - void setVolume(int volume); - void setMuted(bool muted); - -Q_SIGNALS: - void mediaChanged(const QMediaContent& content); - void durationChanged(qint64 duration); - void positionChanged(qint64 position); - void stateChanged(QMediaPlayer::State newState); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void videoAvailableChanged(bool videoAvailable); - void bufferStatusChanged(int percentFilled); - void seekableChanged(bool); - void seekRangeChanged(const QPair&); - void playbackRateChanged(qreal rate); - void error(int error, const QString &errorString); - -private: - QT7PlayerSession *m_session; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm deleted file mode 100644 index ba22552..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qt7playercontrol.h" -#include "qt7playersession.h" - -#include - -#include -#include - - -QT_BEGIN_NAMESPACE - -QT7PlayerControl::QT7PlayerControl(QObject *parent) - : QMediaPlayerControl(parent) -{ -} - -QT7PlayerControl::~QT7PlayerControl() -{ -} - -void QT7PlayerControl::setSession(QT7PlayerSession *session) -{ - m_session = session; - - connect(m_session, SIGNAL(positionChanged(qint64)), this, SIGNAL(positionChanged(qint64))); - connect(m_session, SIGNAL(durationChanged(qint64)), this, SIGNAL(durationChanged(qint64))); - connect(m_session, SIGNAL(stateChanged(QMediaPlayer::State)), - this, SIGNAL(stateChanged(QMediaPlayer::State))); - connect(m_session, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - this, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - connect(m_session, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int))); - connect(m_session, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool))); - connect(m_session, SIGNAL(audioAvailableChanged(bool)), this, SIGNAL(audioAvailableChanged(bool))); - connect(m_session, SIGNAL(videoAvailableChanged(bool)), this, SIGNAL(videoAvailableChanged(bool))); - connect(m_session, SIGNAL(error(int,QString)), this, SIGNAL(error(int,QString))); -} - -qint64 QT7PlayerControl::position() const -{ - return m_session->position(); -} - -qint64 QT7PlayerControl::duration() const -{ - return m_session->duration(); -} - -QMediaPlayer::State QT7PlayerControl::state() const -{ - return m_session->state(); -} - -QMediaPlayer::MediaStatus QT7PlayerControl::mediaStatus() const -{ - return m_session->mediaStatus(); -} - -int QT7PlayerControl::bufferStatus() const -{ - return m_session->bufferStatus(); -} - -int QT7PlayerControl::volume() const -{ - return m_session->volume(); -} - -bool QT7PlayerControl::isMuted() const -{ - return m_session->isMuted(); -} - -bool QT7PlayerControl::isSeekable() const -{ - return m_session->isSeekable(); -} - -QMediaTimeRange QT7PlayerControl::availablePlaybackRanges() const -{ - return isSeekable() ? QMediaTimeRange(0, duration()) : QMediaTimeRange(); -} - -qreal QT7PlayerControl::playbackRate() const -{ - return m_session->playbackRate(); -} - -void QT7PlayerControl::setPlaybackRate(qreal rate) -{ - m_session->setPlaybackRate(rate); -} - -void QT7PlayerControl::setPosition(qint64 pos) -{ - m_session->setPosition(pos); -} - -void QT7PlayerControl::play() -{ - m_session->play(); -} - -void QT7PlayerControl::pause() -{ - m_session->pause(); -} - -void QT7PlayerControl::stop() -{ - m_session->stop(); -} - -void QT7PlayerControl::setVolume(int volume) -{ - m_session->setVolume(volume); -} - -void QT7PlayerControl::setMuted(bool muted) -{ - m_session->setMuted(muted); -} - -QMediaContent QT7PlayerControl::media() const -{ - return m_session->media(); -} - -const QIODevice *QT7PlayerControl::mediaStream() const -{ - return m_session->mediaStream(); -} - -void QT7PlayerControl::setMedia(const QMediaContent &content, QIODevice *stream) -{ - m_session->setMedia(content, stream); - - emit mediaChanged(content); -} - -bool QT7PlayerControl::isAudioAvailable() const -{ - return m_session->isAudioAvailable(); -} - -bool QT7PlayerControl::isVideoAvailable() const -{ - return m_session->isVideoAvailable(); -} - -#include "moc_qt7playercontrol.cpp" - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.h deleted file mode 100644 index 8cbc29a..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7PLAYERMETADATACONTROL_H -#define QT7PLAYERMETADATACONTROL_H - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QT7PlayerSession; - -class QT7PlayerMetaDataControl : public QMetaDataControl -{ - Q_OBJECT -public: - QT7PlayerMetaDataControl(QT7PlayerSession *session, QObject *parent); - virtual ~QT7PlayerMetaDataControl(); - - bool isMetaDataAvailable() const; - bool isWritable() const; - - QVariant metaData(QtMediaServices::MetaData key) const; - void setMetaData(QtMediaServices::MetaData key, const QVariant &value); - QList availableMetaData() const; - - QVariant extendedMetaData(const QString &key) const ; - void setExtendedMetaData(const QString &key, const QVariant &value); - QStringList availableExtendedMetaData() const; - -private slots: - void updateTags(); - -private: - QT7PlayerSession *m_session; - QMap m_tags; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm deleted file mode 100644 index 2ea778d..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qt7backend.h" -#include "qt7playermetadata.h" -#include "qt7playersession.h" -#include - -#import - -#ifdef QUICKTIME_C_API_AVAILABLE - #include - #undef check // avoid name clash; -#endif - -QT_BEGIN_NAMESPACE - -QT7PlayerMetaDataControl::QT7PlayerMetaDataControl(QT7PlayerSession *session, QObject *parent) - :QMetaDataControl(parent), m_session(session) -{ -} - -QT7PlayerMetaDataControl::~QT7PlayerMetaDataControl() -{ -} - -bool QT7PlayerMetaDataControl::isMetaDataAvailable() const -{ - return !m_tags.isEmpty(); -} - -bool QT7PlayerMetaDataControl::isWritable() const -{ - return false; -} - -QVariant QT7PlayerMetaDataControl::metaData(QtMediaServices::MetaData key) const -{ - return m_tags.value(key); -} - -void QT7PlayerMetaDataControl::setMetaData(QtMediaServices::MetaData key, QVariant const &value) -{ - Q_UNUSED(key); - Q_UNUSED(value); -} - -QList QT7PlayerMetaDataControl::availableMetaData() const -{ - return m_tags.keys(); -} - -QVariant QT7PlayerMetaDataControl::extendedMetaData(const QString &key) const -{ - Q_UNUSED(key); - return QVariant(); -} - -void QT7PlayerMetaDataControl::setExtendedMetaData(const QString &key, QVariant const &value) -{ - Q_UNUSED(key); - Q_UNUSED(value); -} - -QStringList QT7PlayerMetaDataControl::availableExtendedMetaData() const -{ - return QStringList(); -} - -#ifdef QUICKTIME_C_API_AVAILABLE - -static QString stripCopyRightSymbol(const QString &key) -{ - return key.right(key.length()-1); -} - -static QString convertQuickTimeKeyToUserKey(const QString &key) -{ - if (key == QLatin1String("com.apple.quicktime.displayname")) - return QLatin1String("nam"); - else if (key == QLatin1String("com.apple.quicktime.album")) - return QLatin1String("alb"); - else if (key == QLatin1String("com.apple.quicktime.artist")) - return QLatin1String("ART"); - else - return QLatin1String("???"); -} - -static OSStatus readMetaValue(QTMetaDataRef metaDataRef, QTMetaDataItem item, QTPropertyClass propClass, - QTPropertyID id, QTPropertyValuePtr *value, ByteCount *size) -{ - QTPropertyValueType type; - ByteCount propSize; - UInt32 propFlags; - OSStatus err = QTMetaDataGetItemPropertyInfo(metaDataRef, item, propClass, id, &type, &propSize, &propFlags); - - if (err == noErr) { - *value = malloc(propSize); - if (*value != 0) { - err = QTMetaDataGetItemProperty(metaDataRef, item, propClass, id, propSize, *value, size); - - if (err == noErr && (type == 'code' || type == 'itsk' || type == 'itlk')) { - // convert from native endian to big endian - OSTypePtr pType = (OSTypePtr)*value; - *pType = EndianU32_NtoB(*pType); - } - } - else - return -1; - } - - return err; -} - -static UInt32 getMetaType(QTMetaDataRef metaDataRef, QTMetaDataItem item) -{ - QTPropertyValuePtr value = 0; - ByteCount ignore = 0; - OSStatus err = readMetaValue( - metaDataRef, item, kPropertyClass_MetaDataItem, kQTMetaDataItemPropertyID_DataType, &value, &ignore); - - if (err == noErr) { - UInt32 type = *((UInt32 *) value); - if (value) - free(value); - return type; - } - - return 0; -} - -static QString cFStringToQString(CFStringRef str) -{ - if(!str) - return QString(); - CFIndex length = CFStringGetLength(str); - const UniChar *chars = CFStringGetCharactersPtr(str); - if (chars) - return QString(reinterpret_cast(chars), length); - - QVarLengthArray buffer(length); - CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data()); - return QString(reinterpret_cast(buffer.constData()), length); -} - - -static QString getMetaValue(QTMetaDataRef metaDataRef, QTMetaDataItem item, SInt32 id) -{ - QTPropertyValuePtr value = 0; - ByteCount size = 0; - OSStatus err = readMetaValue(metaDataRef, item, kPropertyClass_MetaDataItem, id, &value, &size); - QString string; - - if (err == noErr) { - UInt32 dataType = getMetaType(metaDataRef, item); - switch (dataType){ - case kQTMetaDataTypeUTF8: - case kQTMetaDataTypeMacEncodedText: - string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF8, false)); - break; - case kQTMetaDataTypeUTF16BE: - string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF16BE, false)); - break; - default: - break; - } - - if (value) - free(value); - } - - return string; -} - - -static void readFormattedData(QTMetaDataRef metaDataRef, OSType format, QMultiMap &result) -{ - QTMetaDataItem item = kQTMetaDataItemUninitialized; - OSStatus err = QTMetaDataGetNextItem(metaDataRef, format, item, kQTMetaDataKeyFormatWildcard, 0, 0, &item); - while (err == noErr){ - QString key = getMetaValue(metaDataRef, item, kQTMetaDataItemPropertyID_Key); - if (format == kQTMetaDataStorageFormatQuickTime) - key = convertQuickTimeKeyToUserKey(key); - else - key = stripCopyRightSymbol(key); - - if (!result.contains(key)){ - QString val = getMetaValue(metaDataRef, item, kQTMetaDataItemPropertyID_Value); - result.insert(key, val); - } - err = QTMetaDataGetNextItem(metaDataRef, format, item, kQTMetaDataKeyFormatWildcard, 0, 0, &item); - } -} -#endif - - -void QT7PlayerMetaDataControl::updateTags() -{ - bool wasEmpty = m_tags.isEmpty(); - m_tags.clear(); - - QTMovie *movie = (QTMovie*)m_session->movie(); - - if (movie) { - QMultiMap metaMap; - -#ifdef QUICKTIME_C_API_AVAILABLE - QTMetaDataRef metaDataRef; - OSStatus err = QTCopyMovieMetaData([movie quickTimeMovie], &metaDataRef); - if (err == noErr) { - readFormattedData(metaDataRef, kQTMetaDataStorageFormatUserData, metaMap); - readFormattedData(metaDataRef, kQTMetaDataStorageFormatQuickTime, metaMap); - readFormattedData(metaDataRef, kQTMetaDataStorageFormatiTunes, metaMap); - } -#else - AutoReleasePool pool; - NSString *name = [movie attributeForKey:@"QTMovieDisplayNameAttribute"]; - metaMap.insert(QLatin1String("nam"), QString::fromUtf8([name UTF8String])); -#endif // QUICKTIME_C_API_AVAILABLE - - m_tags.insert(QtMediaServices::AlbumArtist, metaMap.value(QLatin1String("ART"))); - m_tags.insert(QtMediaServices::AlbumTitle, metaMap.value(QLatin1String("alb"))); - m_tags.insert(QtMediaServices::Title, metaMap.value(QLatin1String("nam"))); - m_tags.insert(QtMediaServices::Date, metaMap.value(QLatin1String("day"))); - m_tags.insert(QtMediaServices::Genre, metaMap.value(QLatin1String("gnre"))); - m_tags.insert(QtMediaServices::TrackNumber, metaMap.value(QLatin1String("trk"))); - m_tags.insert(QtMediaServices::Description, metaMap.value(QLatin1String("des"))); - } - - if (!wasEmpty || !m_tags.isEmpty()) - emit metaDataChanged(); -} - -QT_END_NAMESPACE - -#include "moc_qt7playermetadata.cpp" diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.h deleted file mode 100644 index 9a22c31..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7PLAYERSERVICE_H -#define QT7PLAYERSERVICE_H - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaMetaData; -class QMediaPlayerControl; -class QMediaPlaylist; -class QMediaPlaylistNavigator; -class QT7PlayerControl; -class QT7PlayerMetaDataControl; -class QT7VideoOutputControl; -class QT7VideoWindowControl; -class QT7VideoWidgetControl; -class QT7VideoRendererControl; -class QT7VideoOutput; -class QT7PlayerSession; - -class QT7PlayerService : public QMediaService -{ -Q_OBJECT -public: - QT7PlayerService(QObject *parent = 0); - ~QT7PlayerService(); - - QMediaControl *control(const char *name) const; - -private slots: - void updateVideoOutput(); - -private: - QT7PlayerSession *m_session; - QT7PlayerControl *m_control; - QT7VideoOutputControl *m_videoOutputControl; - QT7VideoWindowControl *m_videoWidnowControl; - QT7VideoWidgetControl *m_videoWidgetControl; - QT7VideoRendererControl *m_videoRendererControl; - QT7PlayerMetaDataControl *m_playerMetaDataControl; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm deleted file mode 100644 index cf79622..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qt7backend.h" -#include "qt7playerservice.h" -#include "qt7playercontrol.h" -#include "qt7playersession.h" -#include "qt7videooutputcontrol.h" -#include "qt7movieviewoutput.h" -#include "qt7movieviewrenderer.h" -#include "qt7movierenderer.h" -#include "qt7movievideowidget.h" -#include "qt7playermetadata.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -QT7PlayerService::QT7PlayerService(QObject *parent): - QMediaService(parent) -{ - m_session = new QT7PlayerSession(this); - - m_control = new QT7PlayerControl(this); - m_control->setSession(m_session); - - m_playerMetaDataControl = new QT7PlayerMetaDataControl(m_session, this); - connect(m_control, SIGNAL(mediaChanged(QMediaContent)), m_playerMetaDataControl, SLOT(updateTags())); - - m_videoOutputControl = new QT7VideoOutputControl(this); - - m_videoWidnowControl = 0; - m_videoWidgetControl = 0; - m_videoRendererControl = 0; - -#if defined(QT_MAC_USE_COCOA) - m_videoWidnowControl = new QT7MovieViewOutput(this); - m_videoOutputControl->enableOutput(QVideoOutputControl::WindowOutput); -// qDebug() << "Using cocoa"; -#endif - -#ifdef QUICKTIME_C_API_AVAILABLE - m_videoRendererControl = new QT7MovieRenderer(this); - m_videoOutputControl->enableOutput(QVideoOutputControl::RendererOutput); - - m_videoWidgetControl = new QT7MovieVideoWidget(this); - m_videoOutputControl->enableOutput(QVideoOutputControl::WidgetOutput); -// qDebug() << "QuickTime C API is available"; -#else - m_videoRendererControl = new QT7MovieViewRenderer(this); - m_videoOutputControl->enableOutput(QVideoOutputControl::RendererOutput); -// qDebug() << "QuickTime C API is not available"; -#endif - - - connect(m_videoOutputControl, SIGNAL(videoOutputChanged(QVideoOutputControl::Output)), - this, SLOT(updateVideoOutput())); -} - -QT7PlayerService::~QT7PlayerService() -{ - m_session->setVideoOutput(0); -} - -QMediaControl *QT7PlayerService::control(const char *name) const -{ - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return m_control; - - if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return m_videoOutputControl; - - if (qstrcmp(name, QVideoWindowControl_iid) == 0) - return m_videoWidnowControl; - - if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return m_videoRendererControl; - - if (qstrcmp(name, QVideoWidgetControl_iid) == 0) - return m_videoWidgetControl; - - if (qstrcmp(name, QMetaDataControl_iid) == 0) - return m_playerMetaDataControl; - - return 0; -} - -void QT7PlayerService::updateVideoOutput() -{ -// qDebug() << "QT7PlayerService::updateVideoOutput" << m_videoOutputControl->output(); - - switch (m_videoOutputControl->output()) { - case QVideoOutputControl::WindowOutput: - m_session->setVideoOutput(m_videoWidnowControl); - break; - case QVideoOutputControl::RendererOutput: - m_session->setVideoOutput(m_videoRendererControl); - break; - case QVideoOutputControl::WidgetOutput: - m_session->setVideoOutput(m_videoWidgetControl); - break; - default: - m_session->setVideoOutput(0); - } -} - -QT_END_NAMESPACE - -#include "moc_qt7playerservice.cpp" diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h deleted file mode 100644 index 2450cf8..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7PLAYERSESSION_H -#define QT7PLAYERSESSION_H - -#include -#include - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QT7PlayerControl; -class QMediaPlaylist; -class QMediaPlaylistNavigator; -class QT7VideoOutput; -class QT7PlayerSession; -class QT7PlayerService; - -class QT7PlayerSession : public QObject -{ -Q_OBJECT -public: - QT7PlayerSession(QObject *parent = 0); - ~QT7PlayerSession(); - - void *movie() const; - - void setControl(QT7PlayerControl *control); - void setVideoOutput(QT7VideoOutput *output); - - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; - - QMediaContent media() const; - const QIODevice *mediaStream() const; - void setMedia(const QMediaContent &content, QIODevice *stream); - - qint64 position() const; - qint64 duration() const; - - int bufferStatus() const; - - int volume() const; - bool isMuted() const; - - bool isAudioAvailable() const; - bool isVideoAvailable() const; - - bool isSeekable() const; - - qreal playbackRate() const; - -public slots: - void setPlaybackRate(qreal rate); - - void setPosition(qint64 pos); - - void play(); - void pause(); - void stop(); - - void setVolume(int volume); - void setMuted(bool muted); - - void processEOS(); - void processLoadStateChange(); - void processVolumeChange(); - void processNaturalSizeChange(); - -signals: - void positionChanged(qint64 position); - void durationChanged(qint64 duration); - void stateChanged(QMediaPlayer::State newState); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void audioAvailableChanged(bool audioAvailable); - void videoAvailableChanged(bool videoAvailable); - void error(int error, const QString &errorString); - -private: - void *m_QTMovie; - void *m_movieObserver; - - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_mediaStatus; - QIODevice *m_mediaStream; - QMediaContent m_resources; - - QT7VideoOutput *m_videoOutput; - - mutable qint64 m_currentTime; - - bool m_muted; - int m_volume; - qreal m_rate; - - qint64 m_duration; - bool m_videoAvailable; - bool m_audioAvailable; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm deleted file mode 100644 index 0405bbd..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm +++ /dev/null @@ -1,552 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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$ -** -****************************************************************************/ - -#import -#import - -#include "qt7backend.h" - -#include "qt7playersession.h" -#include "qt7playercontrol.h" -#include "qt7videooutputcontrol.h" - -#include -#include - -#include -#include - -#include -#include -#include - -@interface QTMovieObserver : NSObject -{ -@private - QT7PlayerSession *m_session; - QTMovie *m_movie; -} - -- (QTMovieObserver *) initWithPlayerSession:(QT7PlayerSession*)session; -- (void) setMovie:(QTMovie *)movie; -- (void) processEOS:(NSNotification *)notification; -- (void) processLoadStateChange:(NSNotification *)notification; -- (void) processVolumeChange:(NSNotification *)notification; -- (void) processNaturalSizeChange :(NSNotification *)notification; -@end - -@implementation QTMovieObserver - -- (QTMovieObserver *) initWithPlayerSession:(QT7PlayerSession*)session -{ - if (!(self = [super init])) - return nil; - - self->m_session = session; - return self; -} - -- (void) setMovie:(QTMovie *)movie -{ - if (m_movie == movie) - return; - - if (m_movie) { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - [m_movie release]; - } - - m_movie = movie; - - if (movie) { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(processEOS:) - name:QTMovieDidEndNotification - object:m_movie]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(processLoadStateChange:) - name:QTMovieLoadStateDidChangeNotification - object:m_movie]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(processVolumeChange:) - name:QTMovieVolumeDidChangeNotification - object:m_movie]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(processNaturalSizeChange:) - name: -#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6) - QTMovieNaturalSizeDidChangeNotification -#else - QTMovieEditedNotification -#endif - object:m_movie]; - [movie retain]; - } -} - -- (void) processEOS:(NSNotification *)notification -{ - Q_UNUSED(notification); - QMetaObject::invokeMethod(m_session, "processEOS", Qt::AutoConnection); -} - -- (void) processLoadStateChange:(NSNotification *)notification -{ - Q_UNUSED(notification); - QMetaObject::invokeMethod(m_session, "processLoadStateChange", Qt::AutoConnection); -} - -- (void) processVolumeChange:(NSNotification *)notification -{ - Q_UNUSED(notification); - QMetaObject::invokeMethod(m_session, "processVolumeChange", Qt::AutoConnection); -} - -- (void) processNaturalSizeChange :(NSNotification *)notification -{ - Q_UNUSED(notification); - QMetaObject::invokeMethod(m_session, "processNaturalSizeChange", Qt::AutoConnection); -} - -@end - -QT_BEGIN_NAMESPACE - -static inline NSString *qString2CFStringRef(const QString &string) -{ - return [NSString stringWithCharacters:reinterpret_cast(string.unicode()) length:string.length()]; -} - -QT7PlayerSession::QT7PlayerSession(QObject *parent) - : QObject(parent) - , m_QTMovie(0) - , m_state(QMediaPlayer::StoppedState) - , m_mediaStatus(QMediaPlayer::NoMedia) - , m_mediaStream(0) - , m_videoOutput(0) - , m_muted(false) - , m_volume(100) - , m_rate(1.0) - , m_duration(0) - , m_videoAvailable(false) - , m_audioAvailable(false) -{ - m_movieObserver = [[QTMovieObserver alloc] initWithPlayerSession:this]; -} - -QT7PlayerSession::~QT7PlayerSession() -{ - [(QTMovieObserver*)m_movieObserver setMovie:nil]; - [(QTMovieObserver*)m_movieObserver release]; - [(QTMovie*)m_QTMovie release]; -} - -void *QT7PlayerSession::movie() const -{ - return m_QTMovie; -} - -void QT7PlayerSession::setVideoOutput(QT7VideoOutput *output) -{ - if (m_videoOutput == output) - return; - - if (m_videoOutput) - m_videoOutput->setMovie(0); - - m_videoOutput = output; - - if (m_videoOutput && m_state != QMediaPlayer::StoppedState) - m_videoOutput->setMovie(m_QTMovie); -} - - -qint64 QT7PlayerSession::position() const -{ - if (!m_QTMovie || m_state == QMediaPlayer::PausedState) - return m_currentTime; - - AutoReleasePool pool; - - QTTime qtTime = [(QTMovie*)m_QTMovie currentTime]; - quint64 t = static_cast(float(qtTime.timeValue) / float(qtTime.timeScale) * 1000.0f); - m_currentTime = t; - - return m_currentTime; -} - -qint64 QT7PlayerSession::duration() const -{ - if (!m_QTMovie) - return 0; - - AutoReleasePool pool; - - QTTime qtTime = [(QTMovie*)m_QTMovie duration]; - - return static_cast(float(qtTime.timeValue) / float(qtTime.timeScale) * 1000.0f); -} - -QMediaPlayer::State QT7PlayerSession::state() const -{ - return m_state; -} - -QMediaPlayer::MediaStatus QT7PlayerSession::mediaStatus() const -{ - return m_mediaStatus; -} - -int QT7PlayerSession::bufferStatus() const -{ - return 100; -} - -int QT7PlayerSession::volume() const -{ - return m_volume; -} - -bool QT7PlayerSession::isMuted() const -{ - return m_muted; -} - -bool QT7PlayerSession::isSeekable() const -{ - return true; -} - -qreal QT7PlayerSession::playbackRate() const -{ - return m_rate; -} - -void QT7PlayerSession::setPlaybackRate(qreal rate) -{ - if (qFuzzyCompare(m_rate, rate)) - return; - - m_rate = rate; - - if (m_QTMovie && m_state == QMediaPlayer::PlayingState) { - float preferredRate = [[(QTMovie*)m_QTMovie attributeForKey:@"QTMoviePreferredRateAttribute"] floatValue]; - [(QTMovie*)m_QTMovie setRate:preferredRate*m_rate]; - } -} - -void QT7PlayerSession::setPosition(qint64 pos) -{ - if ( !isSeekable() || pos == position()) - return; - - AutoReleasePool pool; - - pos = qMin(pos, duration()); - - QTTime newQTTime = [(QTMovie*)m_QTMovie currentTime]; - newQTTime.timeValue = (pos / 1000.0f) * newQTTime.timeScale; - [(QTMovie*)m_QTMovie setCurrentTime:newQTTime]; -} - -void QT7PlayerSession::play() -{ - if (m_videoOutput) - m_videoOutput->setMovie(m_QTMovie); - - float preferredRate = [[(QTMovie*)m_QTMovie attributeForKey:@"QTMoviePreferredRateAttribute"] floatValue]; - [(QTMovie*)m_QTMovie setRate:preferredRate*m_rate]; - - if (m_state != QMediaPlayer::PlayingState) - emit stateChanged(m_state = QMediaPlayer::PlayingState); -} - -void QT7PlayerSession::pause() -{ - if (m_videoOutput) - m_videoOutput->setMovie(m_QTMovie); - - m_state = QMediaPlayer::PausedState; - - [(QTMovie*)m_QTMovie setRate:0]; - - emit stateChanged(m_state); -} - -void QT7PlayerSession::stop() -{ - m_state = QMediaPlayer::StoppedState; - - [(QTMovie*)m_QTMovie setRate:0]; - setPosition(0); - - if (m_videoOutput) - m_videoOutput->setMovie(0); - - if (m_state == QMediaPlayer::StoppedState) - emit stateChanged(m_state); -} - -void QT7PlayerSession::setVolume(int volume) -{ - if (m_QTMovie) { - m_volume = volume; - [(QTMovie*)m_QTMovie setVolume:(volume/100.0f)]; - } -} - -void QT7PlayerSession::setMuted(bool muted) -{ - if (m_muted != muted) { - m_muted = muted; - - if (m_QTMovie) - [(QTMovie*)m_QTMovie setMuted:m_muted]; - - emit mutedChanged(muted); - } -} - -QMediaContent QT7PlayerSession::media() const -{ - return m_resources; -} - -const QIODevice *QT7PlayerSession::mediaStream() const -{ - return m_mediaStream; -} - -void QT7PlayerSession::setMedia(const QMediaContent &content, QIODevice *stream) -{ - AutoReleasePool pool; - - if (m_QTMovie) { - [(QTMovieObserver*)m_movieObserver setMovie:nil]; - - if (m_videoOutput) - m_videoOutput->setMovie(0); - - [(QTMovie*)m_QTMovie release]; - m_QTMovie = 0; - } - - m_resources = content; - m_mediaStream = stream; - m_mediaStatus = QMediaPlayer::NoMedia; - - QNetworkRequest request; - - if (!content.isNull()) - request = content.canonicalResource().request(); - else - return; - - QVariant cookies = request.header(QNetworkRequest::CookieHeader); - if (cookies.isValid()) { - NSHTTPCookieStorage *store = [NSHTTPCookieStorage sharedHTTPCookieStorage]; - QList cookieList = cookies.value >(); - - foreach (const QNetworkCookie &requestCookie, cookieList) { - NSMutableDictionary *p = [NSMutableDictionary dictionaryWithObjectsAndKeys: - qString2CFStringRef(requestCookie.name()), NSHTTPCookieName, - qString2CFStringRef(requestCookie.value()), NSHTTPCookieValue, - qString2CFStringRef(requestCookie.domain()), NSHTTPCookieDomain, - qString2CFStringRef(requestCookie.path()), NSHTTPCookiePath, - nil - ]; - if (requestCookie.isSessionCookie()) - [p setObject:[NSString stringWithUTF8String:"TRUE"] forKey:NSHTTPCookieDiscard]; - else - [p setObject:[NSDate dateWithTimeIntervalSince1970:requestCookie.expirationDate().toTime_t()] forKey:NSHTTPCookieExpires]; - - [store setCookie:[NSHTTPCookie cookieWithProperties:p]]; - } - } - - NSError *err = 0; - NSString *urlString = qString2CFStringRef(request.url().toString()); - - NSDictionary *attr = [NSDictionary dictionaryWithObjectsAndKeys: - [NSURL URLWithString:urlString], QTMovieURLAttribute, - [NSNumber numberWithBool:YES], QTMovieOpenAsyncOKAttribute, - [NSNumber numberWithBool:YES], QTMovieIsActiveAttribute, - [NSNumber numberWithBool:YES], QTMovieResolveDataRefsAttribute, - [NSNumber numberWithBool:YES], QTMovieDontInteractWithUserAttribute, - nil]; - - m_QTMovie = [[QTMovie movieWithAttributes:attr error:&err] retain]; - - if (err) { - [(QTMovie*)m_QTMovie release]; - m_QTMovie = 0; - QString description = QString::fromUtf8([[err localizedDescription] UTF8String]); - - emit error(QMediaPlayer::FormatError, description ); - } else { - [(QTMovieObserver*)m_movieObserver setMovie:(QTMovie*)m_QTMovie]; - - if (m_videoOutput && m_state != QMediaPlayer::StoppedState) - m_videoOutput->setMovie(m_QTMovie); - - processLoadStateChange(); - - [(QTMovie*)m_QTMovie setMuted:m_muted]; - setVolume(m_volume); - } -} - -bool QT7PlayerSession::isAudioAvailable() const -{ - if (!m_QTMovie) - return false; - - AutoReleasePool pool; - return [[(QTMovie*)m_QTMovie attributeForKey:@"QTMovieHasAudioAttribute"] boolValue] == YES; -} - -bool QT7PlayerSession::isVideoAvailable() const -{ - if (!m_QTMovie) - return false; - - AutoReleasePool pool; - return [[(QTMovie*)m_QTMovie attributeForKey:@"QTMovieHasVideoAttribute"] boolValue] == YES; -} - -void QT7PlayerSession::processEOS() -{ - m_mediaStatus = QMediaPlayer::EndOfMedia; - if (m_videoOutput) - m_videoOutput->setMovie(0); - emit stateChanged(m_state = QMediaPlayer::StoppedState); - emit mediaStatusChanged(m_mediaStatus); -} - -void QT7PlayerSession::processLoadStateChange() -{ - if (!m_QTMovie) - return; - - signed long state = [[(QTMovie*)m_QTMovie attributeForKey:QTMovieLoadStateAttribute] - longValue]; -// qDebug() << "Moview load state changed:" << state; - -#ifndef QUICKTIME_C_API_AVAILABLE - enum { - kMovieLoadStateError = -1L, - kMovieLoadStateLoading = 1000, - kMovieLoadStateLoaded = 2000, - kMovieLoadStatePlayable = 10000, - kMovieLoadStatePlaythroughOK = 20000, - kMovieLoadStateComplete = 100000 - }; -#endif - - QMediaPlayer::MediaStatus newStatus = QMediaPlayer::NoMedia; - bool isPlaying = (m_state != QMediaPlayer::StoppedState); - - if (state >= kMovieLoadStateComplete) { - newStatus = isPlaying ? QMediaPlayer::BufferedMedia : QMediaPlayer::LoadedMedia; - } else if (state >= kMovieLoadStatePlayable) - newStatus = isPlaying ? QMediaPlayer::BufferingMedia : QMediaPlayer::LoadingMedia; - else if (state >= kMovieLoadStateLoading) - newStatus = isPlaying ? QMediaPlayer::StalledMedia : QMediaPlayer::LoadingMedia; - - if (state == kMovieLoadStateError) { - newStatus = QMediaPlayer::InvalidMedia; - if (m_videoOutput) - m_videoOutput->setMovie(0); - - emit error(QMediaPlayer::FormatError, tr("Failed to load media")); - emit stateChanged(m_state = QMediaPlayer::StoppedState); - } - - if (state >= kMovieLoadStatePlayable && - m_state == QMediaPlayer::PlayingState && - [(QTMovie*)m_QTMovie rate] == 0) { - QMetaObject::invokeMethod(this, "play", Qt::QueuedConnection); - } - - if (state >= kMovieLoadStateLoaded) { - qint64 currentDuration = duration(); - if (m_duration != currentDuration) - emit durationChanged(m_duration = currentDuration); - - if (m_audioAvailable != isAudioAvailable()) - emit audioAvailableChanged(m_audioAvailable = !m_audioAvailable); - - if (m_videoAvailable != isVideoAvailable()) - emit videoAvailableChanged(m_videoAvailable = !m_videoAvailable); - } - - if (newStatus != m_mediaStatus) - emit mediaStatusChanged(m_mediaStatus = newStatus); -} - -void QT7PlayerSession::processVolumeChange() -{ - if (!m_QTMovie) - return; - - int newVolume = qRound(100.0f*[((QTMovie*)m_QTMovie) volume]); - - if (newVolume != m_volume) { - emit volumeChanged(m_volume = newVolume); - } -} - -void QT7PlayerSession::processNaturalSizeChange() -{ - if (m_videoOutput) { - NSSize size = [[(QTMovie*)m_QTMovie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; -// qDebug() << "Native size changed:" << QSize(size.width, size.height); - m_videoOutput->updateNaturalSize(QSize(size.width, size.height)); - } -} - -#include "moc_qt7playersession.cpp" - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/qt7/qcvdisplaylink.h b/src/plugins/mediaservices/qt7/qcvdisplaylink.h deleted file mode 100644 index 5a1180d..0000000 --- a/src/plugins/mediaservices/qt7/qcvdisplaylink.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QCVDISPLAYLINK_H -#define QCVDISPLAYLINK_H - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QCvDisplayLink : public QObject -{ -Q_OBJECT -public: - QCvDisplayLink(QObject *parent = 0); - virtual ~QCvDisplayLink(); - - bool isValid(); - bool isActive() const; - -public slots: - void start(); - void stop(); - -signals: - void tick(const CVTimeStamp &ts); - -public: - void displayLinkEvent(const CVTimeStamp *); - -protected: - virtual bool event(QEvent *); - -private: - CVDisplayLinkRef m_displayLink; - QMutex m_displayLinkMutex; - bool m_pendingDisplayLinkEvent; - bool m_isActive; - CVTimeStamp m_frameTimeStamp; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif - diff --git a/src/plugins/mediaservices/qt7/qcvdisplaylink.mm b/src/plugins/mediaservices/qt7/qcvdisplaylink.mm deleted file mode 100644 index 00b4dc5..0000000 --- a/src/plugins/mediaservices/qt7/qcvdisplaylink.mm +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qcvdisplaylink.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -static CVReturn CVDisplayLinkCallback(CVDisplayLinkRef displayLink, - const CVTimeStamp *inNow, - const CVTimeStamp *inOutputTime, - CVOptionFlags flagsIn, - CVOptionFlags *flagsOut, - void *displayLinkContext) -{ - Q_UNUSED(displayLink); - Q_UNUSED(inNow); - Q_UNUSED(flagsIn); - Q_UNUSED(flagsOut); - - QCvDisplayLink *link = (QCvDisplayLink *)displayLinkContext; - - link->displayLinkEvent(inOutputTime); - return kCVReturnSuccess; -} - - -QCvDisplayLink::QCvDisplayLink(QObject *parent) - :QObject(parent), - m_pendingDisplayLinkEvent(false), - m_isActive(false) -{ - // create display link for the main display - CVDisplayLinkCreateWithCGDisplay(kCGDirectMainDisplay, &m_displayLink); - if (m_displayLink) { - // set the current display of a display link. - CVDisplayLinkSetCurrentCGDisplay(m_displayLink, kCGDirectMainDisplay); - - // set the renderer output callback function - CVDisplayLinkSetOutputCallback(m_displayLink, &CVDisplayLinkCallback, this); - } -} - -QCvDisplayLink::~QCvDisplayLink() -{ - if (m_displayLink) { - CVDisplayLinkStop(m_displayLink); - CVDisplayLinkRelease(m_displayLink); - m_displayLink = NULL; - } -} - -bool QCvDisplayLink::isValid() -{ - return m_displayLink != 0; -} - -bool QCvDisplayLink::isActive() const -{ - return m_isActive; -} - -void QCvDisplayLink::start() -{ - if (m_displayLink && !m_isActive) { - CVDisplayLinkStart(m_displayLink); - m_isActive = true; - } -} - -void QCvDisplayLink::stop() -{ - if (m_displayLink && m_isActive) { - CVDisplayLinkStop(m_displayLink); - m_isActive = false; - } -} - -void QCvDisplayLink::displayLinkEvent(const CVTimeStamp *ts) -{ - // 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_frameTimeStamp = *ts; - m_displayLinkMutex.unlock(); - - if (!pending) - qApp->postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority); -} - -bool QCvDisplayLink::event(QEvent *event) -{ - switch (event->type()){ - case QEvent::User: { - m_displayLinkMutex.lock(); - m_pendingDisplayLinkEvent = false; - CVTimeStamp ts = m_frameTimeStamp; - m_displayLinkMutex.unlock(); - - emit tick(ts); - - return false; - } - break; - default: - break; - } - return QObject::event(event); -} - -QT_END_NAMESPACE - -#include "moc_qcvdisplaylink.cpp" - diff --git a/src/plugins/mediaservices/qt7/qt7.pro b/src/plugins/mediaservices/qt7/qt7.pro deleted file mode 100644 index baac224..0000000 --- a/src/plugins/mediaservices/qt7/qt7.pro +++ /dev/null @@ -1,47 +0,0 @@ -TARGET = qqt7 -include(../../qpluginbase.pri) - -QT += opengl mediaservices - -LIBS += -framework AppKit -framework AudioUnit \ - -framework AudioToolbox -framework CoreAudio \ - -framework QuartzCore -framework QTKit - -# The Quicktime framework is only awailable for 32-bit builds, so we -# need to check for this before linking against it. -# QMAKE_MAC_XARCH is not awailable on Tiger, but at the same time, -# we never build for 64-bit architechtures on Tiger either: -contains(QMAKE_MAC_XARCH, no) { - LIBS += -framework QuickTime -} else { - LIBS += -Xarch_i386 -framework QuickTime -Xarch_ppc -framework QuickTime -} - -HEADERS += \ - qt7backend.h \ - qt7videooutputcontrol.h \ - qt7movieviewoutput.h \ - qt7movievideowidget.h \ - qt7movieviewrenderer.h \ - qt7serviceplugin.h \ - qt7movierenderer.h \ - qt7ciimagevideobuffer.h \ - qcvdisplaylink.h - -OBJECTIVE_SOURCES += \ - qt7backend.mm \ - qt7serviceplugin.mm \ - qt7movieviewoutput.mm \ - qt7movievideowidget.mm \ - qt7movieviewrenderer.mm \ - qt7movierenderer.mm \ - qt7videooutputcontrol.mm \ - qt7ciimagevideobuffer.mm \ - qcvdisplaylink.mm - -include(mediaplayer/mediaplayer.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mediaservices -target.path = $$[QT_INSTALL_PLUGINS]/mediaservices -INSTALLS += target - diff --git a/src/plugins/mediaservices/qt7/qt7backend.h b/src/plugins/mediaservices/qt7/qt7backend.h deleted file mode 100644 index 5668965..0000000 --- a/src/plugins/mediaservices/qt7/qt7backend.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7BACKEND_H -#define QT7BACKEND_H - -#include - -#ifndef Q_WS_MAC64 -#define QUICKTIME_C_API_AVAILABLE -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class AutoReleasePool -{ -private: - void *pool; -public: - AutoReleasePool(); - ~AutoReleasePool(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7backend.mm b/src/plugins/mediaservices/qt7/qt7backend.mm deleted file mode 100644 index 478589b..0000000 --- a/src/plugins/mediaservices/qt7/qt7backend.mm +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qt7backend.h" - -#import -#include - - -QT_BEGIN_NAMESPACE - -AutoReleasePool::AutoReleasePool() -{ - pool = (void*)[[NSAutoreleasePool alloc] init]; -} - -AutoReleasePool::~AutoReleasePool() -{ - [(NSAutoreleasePool*)pool release]; -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.h b/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.h deleted file mode 100644 index 669724f..0000000 --- a/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7CIIMAGEVIDEOBUFFER_H -#define QT7CIIMAGEVIDEOBUFFER_H - -#include "qt7backend.h" -#import - -#include -#include - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QT7CIImageVideoBuffer : public QAbstractVideoBuffer -{ -public: - QT7CIImageVideoBuffer(CIImage *image); - - virtual ~QT7CIImageVideoBuffer(); - - MapMode mapMode() const; - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); - void unmap(); - QVariant handle() const; - -private: - CIImage *m_image; - NSBitmapImageRep *m_buffer; - MapMode m_mode; -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.mm b/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.mm deleted file mode 100644 index 7c02f9f..0000000 --- a/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.mm +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qt7ciimagevideobuffer.h" - -#include -#include - -QT7CIImageVideoBuffer::QT7CIImageVideoBuffer(CIImage *image) - : QAbstractVideoBuffer(CoreImageHandle) - , m_image(image) - , m_buffer(0) - , m_mode(NotMapped) -{ - [m_image retain]; -} - -QT7CIImageVideoBuffer::~QT7CIImageVideoBuffer() -{ - [m_image release]; - [m_buffer release]; -} - -QAbstractVideoBuffer::MapMode QT7CIImageVideoBuffer::mapMode() const -{ - return m_mode; -} - -uchar *QT7CIImageVideoBuffer::map(QAbstractVideoBuffer::MapMode mode, int *numBytes, int *bytesPerLine) -{ - if (mode == NotMapped || m_mode != NotMapped || !m_image) - return 0; - - if (!m_buffer) { - //swap R and B channels - CIFilter *colorSwapFilter = [CIFilter filterWithName: @"CIColorMatrix" keysAndValues: - @"inputImage", m_image, - @"inputRVector", [CIVector vectorWithX: 0 Y: 0 Z: 1 W: 0], - @"inputGVector", [CIVector vectorWithX: 0 Y: 1 Z: 0 W: 0], - @"inputBVector", [CIVector vectorWithX: 1 Y: 0 Z: 0 W: 0], - @"inputAVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 1], - @"inputBiasVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 0], - nil]; - CIImage *img = [colorSwapFilter valueForKey: @"outputImage"]; - - m_buffer = [[NSBitmapImageRep alloc] initWithCIImage:img]; - } - - if (numBytes) - *numBytes = [m_buffer bytesPerPlane]; - - if (bytesPerLine) - *bytesPerLine = [m_buffer bytesPerRow]; - - m_mode = mode; - - return [m_buffer bitmapData]; -} - -void QT7CIImageVideoBuffer::unmap() -{ - m_mode = NotMapped; -} - -QVariant QT7CIImageVideoBuffer::handle() const -{ - return QVariant::fromValue(m_image); -} - diff --git a/src/plugins/mediaservices/qt7/qt7movierenderer.h b/src/plugins/mediaservices/qt7/qt7movierenderer.h deleted file mode 100644 index 5953b54..0000000 --- a/src/plugins/mediaservices/qt7/qt7movierenderer.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7MOVIERENDERER_H -#define QT7MOVIERENDERER_H - -#include "qt7backend.h" - -#include -#include - -#include -#include - -#include -#include "qt7videooutputcontrol.h" - -#include -#include - - -QT_BEGIN_HEADER - -class QGLContext; - -QT_BEGIN_NAMESPACE - -class QCvDisplayLink; -class QT7PlayerSession; -class QT7PlayerService; - -class QT7MovieRenderer : public QT7VideoRendererControl -{ -Q_OBJECT -public: - QT7MovieRenderer(QObject *parent = 0); - virtual ~QT7MovieRenderer(); - - void setMovie(void *movie); - void updateNaturalSize(const QSize &newSize); - - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); - - QSize nativeSize() const; - -private slots: - void updateVideoFrame(const CVTimeStamp &ts); - -private: - void setupVideoOutput(); - bool createPixelBufferVisualContext(); - bool createGLVisualContext(); - - void *m_movie; - - QMutex m_mutex; - - QCvDisplayLink *m_displayLink; -#ifdef QUICKTIME_C_API_AVAILABLE - QTVisualContextRef m_visualContext; - bool m_usingGLContext; - const QGLContext *m_currentGLContext; - QSize m_pixelBufferContextGeometry; -#endif - QAbstractVideoSurface *m_surface; - QSize m_nativeSize; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7movierenderer.mm b/src/plugins/mediaservices/qt7/qt7movierenderer.mm deleted file mode 100644 index 95f5d4c..0000000 --- a/src/plugins/mediaservices/qt7/qt7movierenderer.mm +++ /dev/null @@ -1,465 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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$ -** -****************************************************************************/ - -#import - -#include "qt7backend.h" - -#include "qt7playercontrol.h" -#include "qt7movierenderer.h" -#include "qt7playersession.h" -#include "qt7ciimagevideobuffer.h" -#include "qcvdisplaylink.h" -#include -#include - -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -//#define USE_MAIN_MONITOR_COLOR_SPACE 1 - -class CVGLTextureVideoBuffer : public QAbstractVideoBuffer -{ -public: - CVGLTextureVideoBuffer(CVOpenGLTextureRef buffer) - : QAbstractVideoBuffer(GLTextureHandle) - , m_buffer(buffer) - , m_mode(NotMapped) - { - CVOpenGLTextureRetain(m_buffer); - } - - virtual ~CVGLTextureVideoBuffer() - { - CVOpenGLTextureRelease(m_buffer); - } - - QVariant handle() const - { - GLuint id = CVOpenGLTextureGetName(m_buffer); - return QVariant(int(id)); - } - - MapMode mapMode() const { return m_mode; } - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) - { - if (numBytes) - *numBytes = 0; - - if (bytesPerLine) - *bytesPerLine = 0; - - m_mode = mode; - return 0; - } - - void unmap() { m_mode = NotMapped; } - -private: - CVOpenGLTextureRef m_buffer; - MapMode m_mode; -}; - - -class CVPixelBufferVideoBuffer : public QAbstractVideoBuffer -{ -public: - CVPixelBufferVideoBuffer(CVPixelBufferRef buffer) - : QAbstractVideoBuffer(NoHandle) - , m_buffer(buffer) - , m_mode(NotMapped) - { - CVPixelBufferRetain(m_buffer); - } - - virtual ~CVPixelBufferVideoBuffer() - { - CVPixelBufferRelease(m_buffer); - } - - MapMode mapMode() const { return m_mode; } - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) - { - if (mode != NotMapped && m_mode == NotMapped) { - CVPixelBufferLockBaseAddress(m_buffer, 0); - - if (numBytes) - *numBytes = CVPixelBufferGetDataSize(m_buffer); - - if (bytesPerLine) - *bytesPerLine = CVPixelBufferGetBytesPerRow(m_buffer); - - m_mode = mode; - - return (uchar*)CVPixelBufferGetBaseAddress(m_buffer); - } else { - return 0; - } - } - - void unmap() - { - if (m_mode != NotMapped) { - m_mode = NotMapped; - CVPixelBufferUnlockBaseAddress(m_buffer, 0); - } - } - -private: - CVPixelBufferRef m_buffer; - MapMode m_mode; -}; - - - -QT7MovieRenderer::QT7MovieRenderer(QObject *parent) - :QT7VideoRendererControl(parent), - m_movie(0), -#ifdef QUICKTIME_C_API_AVAILABLE - m_visualContext(0), - m_usingGLContext(false), - m_currentGLContext(0), -#endif - m_surface(0) -{ -// qDebug() << "QT7MovieRenderer"; - - m_displayLink = new QCvDisplayLink(this); - connect(m_displayLink, SIGNAL(tick(CVTimeStamp)), SLOT(updateVideoFrame(CVTimeStamp))); -} - - -bool QT7MovieRenderer::createGLVisualContext() -{ -#ifdef QUICKTIME_C_API_AVAILABLE - AutoReleasePool pool; - CGLContextObj cglContext = CGLGetCurrentContext(); - NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat]; - CGLPixelFormatObj cglPixelFormat = static_cast([nsglPixelFormat CGLPixelFormatObj]); - - OSStatus err = QTOpenGLTextureContextCreate(kCFAllocatorDefault, cglContext, - cglPixelFormat, NULL, &m_visualContext); - if (err != noErr) - qWarning() << "Could not create visual context (OpenGL)"; - - return (err == noErr); -#endif // QUICKTIME_C_API_AVAILABLE - - return false; -} - -#ifdef QUICKTIME_C_API_AVAILABLE -static bool DictionarySetValue(CFMutableDictionaryRef dict, CFStringRef key, SInt32 value) -{ - CFNumberRef number = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value); - - if (number) { - CFDictionarySetValue( dict, key, number ); - CFRelease( number ); - return true; - } - return false; -} -#endif // QUICKTIME_C_API_AVAILABLE - -bool QT7MovieRenderer::createPixelBufferVisualContext() -{ -#ifdef QUICKTIME_C_API_AVAILABLE - if (m_visualContext) { - QTVisualContextRelease(m_visualContext); - m_visualContext = 0; - } - - m_pixelBufferContextGeometry = m_nativeSize; - - CFMutableDictionaryRef pixelBufferOptions = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - //DictionarySetValue(pixelBufferOptions, kCVPixelBufferPixelFormatTypeKey, k32ARGBPixelFormat ); - DictionarySetValue(pixelBufferOptions, kCVPixelBufferPixelFormatTypeKey, k32BGRAPixelFormat ); - DictionarySetValue(pixelBufferOptions, kCVPixelBufferWidthKey, m_nativeSize.width() ); - DictionarySetValue(pixelBufferOptions, kCVPixelBufferHeightKey, m_nativeSize.height() ); - DictionarySetValue(pixelBufferOptions, kCVPixelBufferBytesPerRowAlignmentKey, 16); - //CFDictionarySetValue(pixelBufferOptions, kCVPixelBufferOpenGLCompatibilityKey, kCFBooleanTrue); - - CFMutableDictionaryRef visualContextOptions = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - CFDictionarySetValue(visualContextOptions, kQTVisualContextPixelBufferAttributesKey, pixelBufferOptions); - - CGColorSpaceRef colorSpace = NULL; - -#if USE_MAIN_MONITOR_COLOR_SPACE - CMProfileRef sysprof = NULL; - - // Get the Systems Profile for the main display - if (CMGetSystemProfile(&sysprof) == noErr) { - // Create a colorspace with the systems profile - colorSpace = CGColorSpaceCreateWithPlatformColorSpace(sysprof); - CMCloseProfile(sysprof); - } -#endif - - if (!colorSpace) - colorSpace = CGColorSpaceCreateDeviceRGB(); - - CFDictionarySetValue(visualContextOptions, kQTVisualContextOutputColorSpaceKey, colorSpace); - - OSStatus err = QTPixelBufferContextCreate(kCFAllocatorDefault, - visualContextOptions, - &m_visualContext); - CFRelease(pixelBufferOptions); - CFRelease(visualContextOptions); - - if (err != noErr) { - qWarning() << "Could not create visual context (PixelBuffer)"; - return false; - } - - return true; -#endif // QUICKTIME_C_API_AVAILABLE - - return false; -} - - -QT7MovieRenderer::~QT7MovieRenderer() -{ - m_displayLink->stop(); -} - -void QT7MovieRenderer::setupVideoOutput() -{ - AutoReleasePool pool; - -// qDebug() << "QT7MovieRenderer::setupVideoOutput" << m_movie; - - if (m_movie == 0 || m_surface == 0) { - m_displayLink->stop(); - return; - } - - NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; - m_nativeSize = QSize(size.width, size.height); - -#ifdef QUICKTIME_C_API_AVAILABLE - bool usedGLContext = m_usingGLContext; - - if (!m_nativeSize.isEmpty()) { - - bool glSupported = !m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle).isEmpty(); - - //Try rendering using opengl textures first: - if (glSupported) { - QVideoSurfaceFormat format(m_nativeSize, QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle); - - if (m_surface->isActive()) - m_surface->stop(); - -// qDebug() << "Starting the surface with format" << format; - if (!m_surface->start(format)) { -// qDebug() << "failed to start video surface" << m_surface->error(); - glSupported = false; - } else { - m_usingGLContext = true; - } - - } - - if (!glSupported) { - m_usingGLContext = false; - QVideoSurfaceFormat format(m_nativeSize, QVideoFrame::Format_RGB32); - - if (m_surface->isActive() && m_surface->surfaceFormat() != format) { -// qDebug() << "Surface format was changed, stop the surface."; - m_surface->stop(); - } - - if (!m_surface->isActive()) { -// qDebug() << "Starting the surface with format" << format; - m_surface->start(format); -// if (!m_surface->start(format)) -// qDebug() << "failed to start video surface" << m_surface->error(); - } - } - } - - - if (m_visualContext) { - //check if the visual context still can be reused - if (usedGLContext != m_usingGLContext || - (m_usingGLContext && (m_currentGLContext != QGLContext::currentContext())) || - (!m_usingGLContext && (m_pixelBufferContextGeometry != m_nativeSize))) { - QTVisualContextRelease(m_visualContext); - m_pixelBufferContextGeometry = QSize(); - m_visualContext = 0; - } - } - - if (!m_nativeSize.isEmpty()) { - if (!m_visualContext) { - if (m_usingGLContext) { -// qDebug() << "Building OpenGL visual context" << m_nativeSize; - m_currentGLContext = QGLContext::currentContext(); - if (!createGLVisualContext()) { - qWarning() << "QT7MovieRenderer: failed to create visual context"; - return; - } - } else { -// qDebug() << "Building Pixel Buffer visual context" << m_nativeSize; - if (!createPixelBufferVisualContext()) { - qWarning() << "QT7MovieRenderer: failed to create visual context"; - return; - } - } - } - - // targets a Movie to render into a visual context - SetMovieVisualContext([(QTMovie*)m_movie quickTimeMovie], m_visualContext); - - m_displayLink->start(); - } -#endif - -} - -void QT7MovieRenderer::setMovie(void *movie) -{ -// qDebug() << "QT7MovieRenderer::setMovie" << movie; - -#ifdef QUICKTIME_C_API_AVAILABLE - QMutexLocker locker(&m_mutex); - - if (m_movie != movie) { - if (m_movie) { - //ensure the old movie doesn't hold the visual context, otherwise it can't be reused - SetMovieVisualContext([(QTMovie*)m_movie quickTimeMovie], nil); - [(QTMovie*)m_movie release]; - } - - m_movie = movie; - [(QTMovie*)m_movie retain]; - - setupVideoOutput(); - } -#endif -} - -void QT7MovieRenderer::updateNaturalSize(const QSize &newSize) -{ - if (m_nativeSize != newSize) { - m_nativeSize = newSize; - setupVideoOutput(); - } -} - -QAbstractVideoSurface *QT7MovieRenderer::surface() const -{ - return m_surface; -} - -void QT7MovieRenderer::setSurface(QAbstractVideoSurface *surface) -{ -// qDebug() << "Set video surface" << surface; - - if (surface == m_surface) - return; - - QMutexLocker locker(&m_mutex); - - if (m_surface && m_surface->isActive()) - m_surface->stop(); - - m_surface = surface; - setupVideoOutput(); -} - - -QSize QT7MovieRenderer::nativeSize() const -{ - return m_nativeSize; -} - -void QT7MovieRenderer::updateVideoFrame(const CVTimeStamp &ts) -{ -#ifdef QUICKTIME_C_API_AVAILABLE - - QMutexLocker locker(&m_mutex); - - if (m_surface && m_surface->isActive() && - m_visualContext && QTVisualContextIsNewImageAvailable(m_visualContext, &ts)) { - - CVImageBufferRef imageBuffer = NULL; - - OSStatus status = QTVisualContextCopyImageForTime(m_visualContext, NULL, &ts, &imageBuffer); - - if (status == noErr && imageBuffer) { - QAbstractVideoBuffer *buffer = 0; - - if (m_usingGLContext) { - buffer = new QT7CIImageVideoBuffer([CIImage imageWithCVImageBuffer:imageBuffer]); - CVOpenGLTextureRelease((CVOpenGLTextureRef)imageBuffer); - } else { - buffer = new CVPixelBufferVideoBuffer((CVPixelBufferRef)imageBuffer); - //buffer = new QT7CIImageVideoBuffer( [CIImage imageWithCVImageBuffer:imageBuffer] ); - CVPixelBufferRelease((CVPixelBufferRef)imageBuffer); - } - - QVideoFrame frame(buffer, m_nativeSize, QVideoFrame::Format_RGB32); - m_surface->present(frame); - QTVisualContextTask(m_visualContext); - } - } -#else - Q_UNUSED(ts); -#endif -} - -#include "moc_qt7movierenderer.cpp" - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/qt7movievideowidget.h b/src/plugins/mediaservices/qt7/qt7movievideowidget.h deleted file mode 100644 index 3ff14f5..0000000 --- a/src/plugins/mediaservices/qt7/qt7movievideowidget.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7MOVIEVIDEOWIDGET_H -#define QT7MOVIEVIDEOWIDGET_H - -#include -#include - -#include -#include - -#include -#include "qt7videooutputcontrol.h" - -#include -#include - - -QT_BEGIN_HEADER - - -QT_BEGIN_NAMESPACE - -class GLVideoWidget; -class QCvDisplayLink; -class QT7PlayerSession; -class QT7PlayerService; - -class QT7MovieVideoWidget : public QT7VideoWidgetControl -{ -Q_OBJECT -public: - QT7MovieVideoWidget(QObject *parent = 0); - virtual ~QT7MovieVideoWidget(); - - void setMovie(void *movie); - void updateNaturalSize(const QSize &newSize); - - QWidget *videoWidget(); - - bool isFullScreen() const; - void setFullScreen(bool fullScreen); - - QSize nativeSize() const; - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); - -private slots: - void updateVideoFrame(const CVTimeStamp &ts); - -private: - void setupVideoOutput(); - bool createVisualContext(); - - void updateColors(); - - void *m_movie; - GLVideoWidget *m_videoWidget; - - QCvDisplayLink *m_displayLink; - -#ifdef QUICKTIME_C_API_AVAILABLE - QTVisualContextRef m_visualContext; -#endif - - bool m_fullscreen; - QSize m_nativeSize; - Qt::AspectRatioMode m_aspectRatioMode; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7movievideowidget.mm b/src/plugins/mediaservices/qt7/qt7movievideowidget.mm deleted file mode 100644 index 648d6b4..0000000 --- a/src/plugins/mediaservices/qt7/qt7movievideowidget.mm +++ /dev/null @@ -1,425 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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$ -** -****************************************************************************/ - -#import - -#include "qt7backend.h" - -#include "qt7playercontrol.h" -#include "qt7movievideowidget.h" -#include "qt7playersession.h" -#include "qcvdisplaylink.h" -#include -#include - -#include - -#import - -#include "math.h" - -QT_BEGIN_NAMESPACE - -class GLVideoWidget : public QGLWidget -{ -public: - - GLVideoWidget(QWidget *parent, const QGLFormat &format) - : QGLWidget(format, parent), - m_texRef(0), - m_nativeSize(640,480), - m_aspectRatioMode(Qt::KeepAspectRatio) - { - setAutoFillBackground(false); - } - - void initializeGL() - { - QColor bgColor = palette().color(QPalette::Background); - glClearColor(bgColor.redF(), bgColor.greenF(), bgColor.blueF(), bgColor.alphaF()); - } - - void resizeGL(int w, int h) - { - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glViewport(0, 0, GLsizei(w), GLsizei(h)); - gluOrtho2D(0, GLsizei(w), 0, GLsizei(h)); - updateGL(); - } - - void paintGL() - { - glClear(GL_COLOR_BUFFER_BIT); - if (!m_texRef) - return; - - glPushMatrix(); - glDisable(GL_CULL_FACE); - GLenum target = CVOpenGLTextureGetTarget(m_texRef); - glEnable(target); - - glBindTexture(target, CVOpenGLTextureGetName(m_texRef)); - glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - GLfloat lowerLeft[2], lowerRight[2], upperRight[2], upperLeft[2]; - CVOpenGLTextureGetCleanTexCoords(m_texRef, lowerLeft, lowerRight, upperRight, upperLeft); - - glBegin(GL_QUADS); - QRect rect = displayRect(); - glTexCoord2f(lowerLeft[0], lowerLeft[1]); - glVertex2i(rect.topLeft().x(), rect.topLeft().y()); - glTexCoord2f(lowerRight[0], lowerRight[1]); - glVertex2i(rect.topRight().x() + 1, rect.topRight().y()); - glTexCoord2f(upperRight[0], upperRight[1]); - glVertex2i(rect.bottomRight().x() + 1, rect.bottomRight().y() + 1); - glTexCoord2f(upperLeft[0], upperLeft[1]); - glVertex2i(rect.bottomLeft().x(), rect.bottomLeft().y() + 1); - glEnd(); - glPopMatrix(); - } - - void setCVTexture(CVOpenGLTextureRef texRef) - { - if (m_texRef) - CVOpenGLTextureRelease(m_texRef); - - m_texRef = texRef; - - if (m_texRef) - CVOpenGLTextureRetain(m_texRef); - - if (isVisible()) { - makeCurrent(); - paintGL(); - swapBuffers(); - } - } - - QSize sizeHint() const - { - return m_nativeSize; - } - - void setNativeSize(const QSize &size) - { - m_nativeSize = size; - } - - void setAspectRatioMode(Qt::AspectRatioMode mode) - { - if (m_aspectRatioMode != mode) { - m_aspectRatioMode = mode; - update(); - } - } - -private: - QRect displayRect() const - { - QRect displayRect = rect(); - - if (m_aspectRatioMode == Qt::KeepAspectRatio) { - QSize size = m_nativeSize; - size.scale(displayRect.size(), Qt::KeepAspectRatio); - - displayRect = QRect(QPoint(0, 0), size); - displayRect.moveCenter(rect().center()); - } - return displayRect; - } - - CVOpenGLTextureRef m_texRef; - QSize m_nativeSize; - Qt::AspectRatioMode m_aspectRatioMode; -}; - -QT7MovieVideoWidget::QT7MovieVideoWidget(QObject *parent) - :QT7VideoWidgetControl(parent), - m_movie(0), - m_videoWidget(0), - m_fullscreen(false), - m_aspectRatioMode(Qt::KeepAspectRatio), - m_brightness(0), - m_contrast(0), - m_hue(0), - m_saturation(0) -{ -// qDebug() << "QT7MovieVideoWidget"; - - QGLFormat format = QGLFormat::defaultFormat(); - format.setSwapInterval(1); // Vertical sync (avoid tearing) - m_videoWidget = new GLVideoWidget(0, format); - - m_displayLink = new QCvDisplayLink(this); - - connect(m_displayLink, SIGNAL(tick(CVTimeStamp)), SLOT(updateVideoFrame(CVTimeStamp))); - - if (!createVisualContext()) { - qWarning() << "QT7MovieVideoWidget: failed to create visual context"; - } -} - -bool QT7MovieVideoWidget::createVisualContext() -{ -#ifdef QUICKTIME_C_API_AVAILABLE - m_videoWidget->makeCurrent(); - - AutoReleasePool pool; - CGLContextObj cglContext = CGLGetCurrentContext(); - NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat]; - CGLPixelFormatObj cglPixelFormat = static_cast([nsglPixelFormat CGLPixelFormatObj]); - - CFTypeRef keys[] = { kQTVisualContextOutputColorSpaceKey }; - CGColorSpaceRef colorSpace = NULL; - CMProfileRef sysprof = NULL; - - // Get the Systems Profile for the main display - if (CMGetSystemProfile(&sysprof) == noErr) { - // Create a colorspace with the systems profile - colorSpace = CGColorSpaceCreateWithPlatformColorSpace(sysprof); - CMCloseProfile(sysprof); - } - - if (!colorSpace) - colorSpace = CGColorSpaceCreateDeviceRGB(); - - CFDictionaryRef textureContextAttributes = CFDictionaryCreate(kCFAllocatorDefault, - (const void **)keys, - (const void **)&colorSpace, 1, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - - OSStatus err = QTOpenGLTextureContextCreate(kCFAllocatorDefault, - cglContext, - cglPixelFormat, - textureContextAttributes, - &m_visualContext); - if (err != noErr) - qWarning() << "Could not create visual context (OpenGL)"; - - - return (err == noErr); -#endif // QUICKTIME_C_API_AVAILABLE - - return false; -} - -QT7MovieVideoWidget::~QT7MovieVideoWidget() -{ - m_displayLink->stop(); - [(QTMovie*)m_movie release]; - delete m_videoWidget; -} - -QWidget *QT7MovieVideoWidget::videoWidget() -{ - return m_videoWidget; -} - -void QT7MovieVideoWidget::setupVideoOutput() -{ - AutoReleasePool pool; - -// qDebug() << "QT7MovieVideoWidget::setupVideoOutput" << m_movie; - - if (m_movie == 0) { - m_displayLink->stop(); - return; - } - - NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; - m_nativeSize = QSize(size.width, size.height); - m_videoWidget->setNativeSize(m_nativeSize); - -#ifdef QUICKTIME_C_API_AVAILABLE - // targets a Movie to render into a visual context - SetMovieVisualContext([(QTMovie*)m_movie quickTimeMovie], m_visualContext); -#endif - - m_displayLink->start(); -} - -void QT7MovieVideoWidget::setMovie(void *movie) -{ - if (m_movie == movie) - return; - - if (m_movie) { -#ifdef QUICKTIME_C_API_AVAILABLE - SetMovieVisualContext([(QTMovie*)m_movie quickTimeMovie], nil); -#endif - [(QTMovie*)m_movie release]; - } - - m_movie = movie; - [(QTMovie*)m_movie retain]; - - setupVideoOutput(); -} - -void QT7MovieVideoWidget::updateNaturalSize(const QSize &newSize) -{ - if (m_nativeSize != newSize) { - m_nativeSize = newSize; - setupVideoOutput(); - } -} - -bool QT7MovieVideoWidget::isFullScreen() const -{ - return m_fullscreen; -} - -void QT7MovieVideoWidget::setFullScreen(bool fullScreen) -{ - m_fullscreen = fullScreen; -} - -QSize QT7MovieVideoWidget::nativeSize() const -{ - return m_nativeSize; -} - -Qt::AspectRatioMode QT7MovieVideoWidget::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void QT7MovieVideoWidget::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_aspectRatioMode = mode; - m_videoWidget->setAspectRatioMode(mode); -} - -int QT7MovieVideoWidget::brightness() const -{ - return m_brightness; -} - -void QT7MovieVideoWidget::setBrightness(int brightness) -{ - m_brightness = brightness; - updateColors(); -} - -int QT7MovieVideoWidget::contrast() const -{ - return m_contrast; -} - -void QT7MovieVideoWidget::setContrast(int contrast) -{ - m_contrast = contrast; - updateColors(); -} - -int QT7MovieVideoWidget::hue() const -{ - return m_hue; -} - -void QT7MovieVideoWidget::setHue(int hue) -{ - m_hue = hue; - updateColors(); -} - -int QT7MovieVideoWidget::saturation() const -{ - return m_saturation; -} - -void QT7MovieVideoWidget::setSaturation(int saturation) -{ - m_saturation = saturation; - updateColors(); -} - -void QT7MovieVideoWidget::updateColors() -{ -#ifdef QUICKTIME_C_API_AVAILABLE - if (m_movie) { - QTMovie *movie = (QTMovie*)m_movie; - - Float32 value; - value = m_brightness/100.0; - SetMovieVisualBrightness([movie quickTimeMovie], value, 0); - value = pow(2, m_contrast/50.0); - SetMovieVisualContrast([movie quickTimeMovie], value, 0); - value = m_hue/100.0; - SetMovieVisualHue([movie quickTimeMovie], value, 0); - value = 1.0+m_saturation/100.0; - SetMovieVisualSaturation([movie quickTimeMovie], value, 0); - } -#endif -} - -void QT7MovieVideoWidget::updateVideoFrame(const CVTimeStamp &ts) -{ -#ifdef QUICKTIME_C_API_AVAILABLE - AutoReleasePool pool; - // check for new frame - if (m_visualContext && QTVisualContextIsNewImageAvailable(m_visualContext, &ts)) { - CVOpenGLTextureRef currentFrame = NULL; - - // get a "frame" (image buffer) from the Visual Context, indexed by the provided time - OSStatus status = QTVisualContextCopyImageForTime(m_visualContext, NULL, &ts, ¤tFrame); - - // the above call may produce a null frame so check for this first - // if we have a frame, then draw it - if (status == noErr && currentFrame) { - //qDebug() << "render video frame"; - m_videoWidget->setCVTexture(currentFrame); - CVOpenGLTextureRelease(currentFrame); - } - QTVisualContextTask(m_visualContext); - } -#else - Q_UNUSED(ts); -#endif -} - -#include "moc_qt7movievideowidget.cpp" - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h b/src/plugins/mediaservices/qt7/qt7movieviewoutput.h deleted file mode 100644 index d6bfd14..0000000 --- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7MOVIEVIEWOUTPUT_H -#define QT7MOVIEVIEWOUTPUT_H - -#include - -#include -#include - -#include -#include "qt7videooutputcontrol.h" - - -QT_BEGIN_HEADER -QT_BEGIN_NAMESPACE - -class QT7PlayerSession; -class QT7PlayerService; - -class QT7MovieViewOutput : public QT7VideoWindowControl -{ -public: - QT7MovieViewOutput(QObject *parent = 0); - ~QT7MovieViewOutput(); - - void setMovie(void *movie); - void updateNaturalSize(const QSize &newSize); - - WId winId() const; - void setWinId(WId id); - - QRect displayRect() const; - void setDisplayRect(const QRect &rect); - - bool isFullScreen() const; - void setFullScreen(bool fullScreen); - - void repaint(); - - QSize nativeSize() const; - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); - -private: - void setupVideoOutput(); - - void *m_movie; - void *m_movieView; - bool m_layouted; - - WId m_winId; - QRect m_displayRect; - bool m_fullscreen; - QSize m_nativeSize; - Qt::AspectRatioMode m_aspectRatioMode; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm deleted file mode 100644 index 06299a3..0000000 --- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm +++ /dev/null @@ -1,335 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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$ -** -****************************************************************************/ - -#import - -#include "qt7backend.h" - -#include "qt7playercontrol.h" -#include "qt7movieviewoutput.h" -#include "qt7playersession.h" -#include - -#include -#include - - -#define VIDEO_TRANSPARENT(m) -(void)m:(NSEvent *)e{[[self superview] m:e];} - -@interface TransparentQTMovieView : QTMovieView -{ -@private - QRect *m_drawRect; - qreal m_brightness, m_contrast, m_saturation, m_hue; -} - -- (TransparentQTMovieView *) init; -- (void) setDrawRect:(QRect &)rect; -- (CIImage *) view:(QTMovieView *)view willDisplayImage:(CIImage *)img; -- (void) setContrast:(qreal) contrast; -@end - -@implementation TransparentQTMovieView - -- (TransparentQTMovieView *) init -{ - self = [super initWithFrame:NSZeroRect]; - if (self) { - [self setControllerVisible:NO]; - [self setContrast:1.0]; - [self setDelegate:self]; - } - return self; -} - -- (void) dealloc -{ - [super dealloc]; -} - -- (void) setContrast:(qreal) contrast -{ - m_hue = 0.0; - m_brightness = 0.0; - m_contrast = contrast; - m_saturation = 1.0; -} - - -- (void) setDrawRect:(QRect &)rect -{ - *m_drawRect = rect; - - NSRect nsrect; - nsrect.origin.x = m_drawRect->x(); - nsrect.origin.y = m_drawRect->y(); - nsrect.size.width = m_drawRect->width(); - nsrect.size.height = m_drawRect->height(); - [self setFrame:nsrect]; -} - -- (CIImage *) view:(QTMovieView *)view willDisplayImage:(CIImage *)img -{ - // This method is called from QTMovieView just - // before the image will be drawn. - Q_UNUSED(view); - - if ( !qFuzzyCompare(m_brightness, 0.0) || - !qFuzzyCompare(m_contrast, 1.0) || - !qFuzzyCompare(m_saturation, 1.0)){ - CIFilter *colorFilter = [CIFilter filterWithName:@"CIColorControls"]; - [colorFilter setValue:[NSNumber numberWithFloat:m_brightness] forKey:@"inputBrightness"]; - [colorFilter setValue:[NSNumber numberWithFloat:(m_contrast < 1) ? m_contrast : 1 + ((m_contrast-1)*3)] forKey:@"inputContrast"]; - [colorFilter setValue:[NSNumber numberWithFloat:m_saturation] forKey:@"inputSaturation"]; - [colorFilter setValue:img forKey:@"inputImage"]; - img = [colorFilter valueForKey:@"outputImage"]; - } - - /*if (m_hue){ - CIFilter *colorFilter = [CIFilter filterWithName:@"CIHueAdjust"]; - [colorFilter setValue:[NSNumber numberWithFloat:(m_hue * 3.14)] forKey:@"inputAngle"]; - [colorFilter setValue:img forKey:@"inputImage"]; - img = [colorFilter valueForKey:@"outputImage"]; - }*/ - - return img; -} - - -VIDEO_TRANSPARENT(mouseDown); -VIDEO_TRANSPARENT(mouseDragged); -VIDEO_TRANSPARENT(mouseUp); -VIDEO_TRANSPARENT(mouseMoved); -VIDEO_TRANSPARENT(mouseEntered); -VIDEO_TRANSPARENT(mouseExited); -VIDEO_TRANSPARENT(rightMouseDown); -VIDEO_TRANSPARENT(rightMouseDragged); -VIDEO_TRANSPARENT(rightMouseUp); -VIDEO_TRANSPARENT(otherMouseDown); -VIDEO_TRANSPARENT(otherMouseDragged); -VIDEO_TRANSPARENT(otherMouseUp); -VIDEO_TRANSPARENT(keyDown); -VIDEO_TRANSPARENT(keyUp); -VIDEO_TRANSPARENT(scrollWheel) - -@end - - -QT7MovieViewOutput::QT7MovieViewOutput(QObject *parent) - :QT7VideoWindowControl(parent), - m_movie(0), - m_movieView(0), - m_layouted(false), - m_winId(0), - m_fullscreen(false), - m_aspectRatioMode(Qt::KeepAspectRatio), - m_brightness(0), - m_contrast(0), - m_hue(0), - m_saturation(0) -{ -} - -QT7MovieViewOutput::~QT7MovieViewOutput() -{ - [(QTMovieView*)m_movieView release]; - [(QTMovie*)m_movie release]; -} - -void QT7MovieViewOutput::setupVideoOutput() -{ - AutoReleasePool pool; - - //qDebug() << "QT7MovieViewOutput::setupVideoOutput" << m_movie << m_winId; - if (m_movie == 0 || m_winId <= 0) - return; - - NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; - m_nativeSize = QSize(size.width, size.height); - - if (!m_movieView) - m_movieView = [[TransparentQTMovieView alloc] init]; - - [(QTMovieView*)m_movieView setControllerVisible:NO]; - [(QTMovieView*)m_movieView setMovie:(QTMovie*)m_movie]; - - [(NSView *)m_winId addSubview:(QTMovieView*)m_movieView]; - m_layouted = true; - - setDisplayRect(m_displayRect); -} - -void QT7MovieViewOutput::setMovie(void *movie) -{ - if (m_movie != movie) { - if (m_movie) { - if (m_movieView) - [(QTMovieView*)m_movieView setMovie:nil]; - - [(QTMovie*)m_movie release]; - } - - m_movie = movie; - - if (m_movie) - [(QTMovie*)m_movie retain]; - - setupVideoOutput(); - } -} - -void QT7MovieViewOutput::updateNaturalSize(const QSize &newSize) -{ - if (m_nativeSize != newSize) { - m_nativeSize = newSize; - emit nativeSizeChanged(); - } -} - -WId QT7MovieViewOutput::winId() const -{ - return m_winId; -} - -void QT7MovieViewOutput::setWinId(WId id) -{ - if (m_winId != id) { - if (m_movieView && m_layouted) { - [(QTMovieView*)m_movieView removeFromSuperview]; - m_layouted = false; - } - - m_winId = id; - setupVideoOutput(); - } -} - -QRect QT7MovieViewOutput::displayRect() const -{ - return m_displayRect; -} - -void QT7MovieViewOutput::setDisplayRect(const QRect &rect) -{ - m_displayRect = rect; - - if (m_movieView) { - AutoReleasePool pool; - [(QTMovieView*)m_movieView setPreservesAspectRatio:(m_aspectRatioMode == Qt::KeepAspectRatio ? YES : NO)]; - [(QTMovieView*)m_movieView setFrame:NSMakeRect(m_displayRect.x(), - m_displayRect.y(), - m_displayRect.width(), - m_displayRect.height())]; - } - -} - -bool QT7MovieViewOutput::isFullScreen() const -{ - return m_fullscreen; -} - -void QT7MovieViewOutput::setFullScreen(bool fullScreen) -{ - m_fullscreen = fullScreen; - setDisplayRect(m_displayRect); -} - -void QT7MovieViewOutput::repaint() -{ -} - -QSize QT7MovieViewOutput::nativeSize() const -{ - return m_nativeSize; -} - -Qt::AspectRatioMode QT7MovieViewOutput::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void QT7MovieViewOutput::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_aspectRatioMode = mode; - setDisplayRect(m_displayRect); -} - -int QT7MovieViewOutput::brightness() const -{ - return m_brightness; -} - -void QT7MovieViewOutput::setBrightness(int brightness) -{ - m_brightness = brightness; -} - -int QT7MovieViewOutput::contrast() const -{ - return m_contrast; -} - -void QT7MovieViewOutput::setContrast(int contrast) -{ - m_contrast = contrast; - [(TransparentQTMovieView*)m_movieView setContrast:(contrast/100.0+1.0)]; -} - -int QT7MovieViewOutput::hue() const -{ - return m_hue; -} - -void QT7MovieViewOutput::setHue(int hue) -{ - m_hue = hue; -} - -int QT7MovieViewOutput::saturation() const -{ - return m_saturation; -} - -void QT7MovieViewOutput::setSaturation(int saturation) -{ - m_saturation = saturation; -} diff --git a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h deleted file mode 100644 index fa4db4d..0000000 --- a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7MOVIEVIEWRENDERER_H -#define QT7MOVIEVIEWRENDERER_H - -#include -#include - -#include -#include - -#include -#include "qt7videooutputcontrol.h" -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QVideoFrame; -class QT7PlayerSession; -class QT7PlayerService; - -class QT7MovieViewRenderer : public QT7VideoRendererControl -{ -public: - QT7MovieViewRenderer(QObject *parent = 0); - ~QT7MovieViewRenderer(); - - void setMovie(void *movie); - void updateNaturalSize(const QSize &newSize); - - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); - - void renderFrame(const QVideoFrame &); - -protected: - bool event(QEvent *event); - -private: - void setupVideoOutput(); - - void *m_movie; - void *m_movieView; - QSize m_nativeSize; - QAbstractVideoSurface *m_surface; - QVideoFrame m_currentFrame; - bool m_pendingRenderEvent; - QMutex m_mutex; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm deleted file mode 100644 index 5af9809..0000000 --- a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm +++ /dev/null @@ -1,366 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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$ -** -****************************************************************************/ - -#import - -#include "qt7backend.h" - -#include "qt7playercontrol.h" -#include "qt7movieviewrenderer.h" -#include "qt7playersession.h" -#include "qt7ciimagevideobuffer.h" -#include -#include -#include - -#include -#include -#include - -#include -#include - - -QT_BEGIN_NAMESPACE - -class NSBitmapVideoBuffer : public QAbstractVideoBuffer -{ -public: - NSBitmapVideoBuffer(NSBitmapImageRep *buffer) - : QAbstractVideoBuffer(NoHandle) - , m_buffer(buffer) - , m_mode(NotMapped) - { - [m_buffer retain]; - } - - virtual ~NSBitmapVideoBuffer() - { - [m_buffer release]; - } - - MapMode mapMode() const { return m_mode; } - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) - { - if (mode != NotMapped && m_mode == NotMapped) { - if (numBytes) - *numBytes = [m_buffer bytesPerPlane]; - - if (bytesPerLine) - *bytesPerLine = [m_buffer bytesPerRow]; - - m_mode = mode; - - return [m_buffer bitmapData]; - } else { - return 0; - } - } - - void unmap() { m_mode = NotMapped; } - -private: - NSBitmapImageRep *m_buffer; - MapMode m_mode; -}; - -QT_END_NAMESPACE - -#define VIDEO_TRANSPARENT(m) -(void)m:(NSEvent *)e{[[self superview] m:e];} - -@interface HiddenQTMovieView : QTMovieView -{ -@private - QWidget *m_window; - QT7MovieViewRenderer *m_renderer; -} - -- (HiddenQTMovieView *) initWithRenderer:(QT7MovieViewRenderer *)renderer; -- (void) setRenderer:(QT7MovieViewRenderer *)renderer; -- (void) setDrawRect:(const QRect &)rect; -- (CIImage *) view:(QTMovieView *)view willDisplayImage:(CIImage *)img; -@end - -@implementation HiddenQTMovieView - -- (HiddenQTMovieView *) initWithRenderer:(QT7MovieViewRenderer *)renderer -{ - self = [super initWithFrame:NSZeroRect]; - if (self) { - [self setControllerVisible:NO]; - [self setDelegate:self]; - - self->m_renderer = renderer; - - self->m_window = new QWidget; - self->m_window->setWindowOpacity(0.0); - self->m_window->show(); - self->m_window->hide(); - - [(NSView *)(self->m_window->winId()) addSubview:self]; - [self setDrawRect:QRect(0,0,1,1)]; - } - return self; -} - -- (void) dealloc -{ - [super dealloc]; -} - -- (void) setRenderer:(QT7MovieViewRenderer *)renderer -{ - m_renderer = renderer; -} - -- (void) setDrawRect:(const QRect &)rect -{ - NSRect nsrect; - nsrect.origin.x = rect.x(); - nsrect.origin.y = rect.y(); - nsrect.size.width = rect.width(); - nsrect.size.height = rect.height(); - [self setFrame:nsrect]; -} - -- (CIImage *) view:(QTMovieView *)view willDisplayImage:(CIImage *)img -{ - // This method is called from QTMovieView just - // before the image will be drawn. - Q_UNUSED(view); - if (m_renderer) { - CGRect bounds = [img extent]; - int w = bounds.size.width; - int h = bounds.size.height; - - QVideoFrame frame; - - QAbstractVideoSurface *surface = m_renderer->surface(); - if (!surface || !surface->isActive()) - return img; - - if (surface->surfaceFormat().handleType() == QAbstractVideoBuffer::CoreImageHandle) { - //surface supports rendering of opengl based CIImage - frame = QVideoFrame(new QT7CIImageVideoBuffer(img), QSize(w,h), QVideoFrame::Format_RGB32 ); - } else { - //Swap R and B colors - CIFilter *colorSwapFilter = [CIFilter filterWithName: @"CIColorMatrix" keysAndValues: - @"inputImage", img, - @"inputRVector", [CIVector vectorWithX: 0 Y: 0 Z: 1 W: 0], - @"inputGVector", [CIVector vectorWithX: 0 Y: 1 Z: 0 W: 0], - @"inputBVector", [CIVector vectorWithX: 1 Y: 0 Z: 0 W: 0], - @"inputAVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 1], - @"inputBiasVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 0], - nil]; - CIImage *img = [colorSwapFilter valueForKey: @"outputImage"]; - NSBitmapImageRep *bitmap =[[NSBitmapImageRep alloc] initWithCIImage:img]; - //requesting the bitmap data is slow, - //but it's better to do it here to avoid blocking the main thread for a long. - [bitmap bitmapData]; - frame = QVideoFrame(new NSBitmapVideoBuffer(bitmap), QSize(w,h), QVideoFrame::Format_RGB32 ); - [bitmap release]; - } - - if (m_renderer) - m_renderer->renderFrame(frame); - } - - return img; -} - -// Override this method so that the movie doesn't stop if -// the window becomes invisible -- (void)viewWillMoveToWindow:(NSWindow *)newWindow -{ - Q_UNUSED(newWindow); -} - - -VIDEO_TRANSPARENT(mouseDown); -VIDEO_TRANSPARENT(mouseDragged); -VIDEO_TRANSPARENT(mouseUp); -VIDEO_TRANSPARENT(mouseMoved); -VIDEO_TRANSPARENT(mouseEntered); -VIDEO_TRANSPARENT(mouseExited); -VIDEO_TRANSPARENT(rightMouseDown); -VIDEO_TRANSPARENT(rightMouseDragged); -VIDEO_TRANSPARENT(rightMouseUp); -VIDEO_TRANSPARENT(otherMouseDown); -VIDEO_TRANSPARENT(otherMouseDragged); -VIDEO_TRANSPARENT(otherMouseUp); -VIDEO_TRANSPARENT(keyDown); -VIDEO_TRANSPARENT(keyUp); -VIDEO_TRANSPARENT(scrollWheel) - -@end - -QT_BEGIN_NAMESPACE - -QT7MovieViewRenderer::QT7MovieViewRenderer(QObject *parent) - :QT7VideoRendererControl(parent), - m_movie(0), - m_movieView(0), - m_surface(0), - m_pendingRenderEvent(false) -{ -} - -QT7MovieViewRenderer::~QT7MovieViewRenderer() -{ - [(HiddenQTMovieView*)m_movieView setRenderer:0]; - - QMutexLocker locker(&m_mutex); - m_currentFrame = QVideoFrame(); - [(HiddenQTMovieView*)m_movieView release]; -} - -void QT7MovieViewRenderer::setupVideoOutput() -{ - AutoReleasePool pool; - -// qDebug() << "QT7MovieViewRenderer::setupVideoOutput" << m_movie << m_surface; - - HiddenQTMovieView *movieView = (HiddenQTMovieView*)m_movieView; - - if (movieView && !m_movie) { - [movieView setMovie:nil]; - } - - if (m_movie) { - NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; - - m_nativeSize = QSize(size.width, size.height); - - if (!movieView) { - movieView = [[HiddenQTMovieView alloc] initWithRenderer:this]; - m_movieView = movieView; - [movieView setControllerVisible:NO]; - } - - [movieView setMovie:(QTMovie*)m_movie]; - [movieView setDrawRect:QRect(QPoint(0,0), m_nativeSize)]; - } - - if (m_surface && !m_nativeSize.isEmpty()) { - bool coreImageFrameSupported = !m_surface->supportedPixelFormats(QAbstractVideoBuffer::CoreImageHandle).isEmpty() && - !m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle).isEmpty(); - - QVideoSurfaceFormat format(m_nativeSize, QVideoFrame::Format_RGB32, - coreImageFrameSupported ? QAbstractVideoBuffer::CoreImageHandle : QAbstractVideoBuffer::NoHandle); - - if (m_surface->isActive() && m_surface->surfaceFormat() != format) { -// qDebug() << "Surface format was changed, stop the surface."; - m_surface->stop(); - } - - if (!m_surface->isActive()) { - //qDebug() << "Starting the surface with format" << format; - if (!m_surface->start(format)) { - qWarning() << "Failed to start video surface" << m_surface->error(); - qWarning() << "Surface format:" << format; - } - } - } -} - -void QT7MovieViewRenderer::setMovie(void *movie) -{ - if (movie == m_movie) - return; - - QMutexLocker locker(&m_mutex); - m_movie = movie; - setupVideoOutput(); -} - -void QT7MovieViewRenderer::updateNaturalSize(const QSize &newSize) -{ - if (m_nativeSize != newSize) { - m_nativeSize = newSize; - setupVideoOutput(); - } -} - -QAbstractVideoSurface *QT7MovieViewRenderer::surface() const -{ - return m_surface; -} - -void QT7MovieViewRenderer::setSurface(QAbstractVideoSurface *surface) -{ - if (surface == m_surface) - return; - - QMutexLocker locker(&m_mutex); - - if (m_surface && m_surface->isActive()) - m_surface->stop(); - - m_surface = surface; - setupVideoOutput(); -} - -void QT7MovieViewRenderer::renderFrame(const QVideoFrame &frame) -{ - - QMutexLocker locker(&m_mutex); - m_currentFrame = frame; - - if (!m_pendingRenderEvent) - qApp->postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority); - - m_pendingRenderEvent = true; -} - -bool QT7MovieViewRenderer::event(QEvent *event) -{ - if (event->type() == QEvent::User) { - QMutexLocker locker(&m_mutex); - m_pendingRenderEvent = false; - if (m_surface->isActive()) - m_surface->present(m_currentFrame); - } - - return QT7VideoRendererControl::event(event); -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/qt7serviceplugin.h b/src/plugins/mediaservices/qt7/qt7serviceplugin.h deleted file mode 100644 index 3871e10..0000000 --- a/src/plugins/mediaservices/qt7/qt7serviceplugin.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7SERVICEPLUGIN_H -#define QT7SERVICEPLUGIN_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QT7ServicePlugin : public QMediaServiceProviderPlugin -{ -public: - QStringList keys() const; - QMediaService* create(QString const& key); - void release(QMediaService *service); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGSTREAMERSERVICEPLUGIN_H diff --git a/src/plugins/mediaservices/qt7/qt7serviceplugin.mm b/src/plugins/mediaservices/qt7/qt7serviceplugin.mm deleted file mode 100644 index 92b472f..0000000 --- a/src/plugins/mediaservices/qt7/qt7serviceplugin.mm +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qt7serviceplugin.h" -#include "qt7playerservice.h" - -#include - -QT_BEGIN_NAMESPACE - -QStringList QT7ServicePlugin::keys() const -{ - return QStringList() -#ifdef QMEDIA_QT7_PLAYER - << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); -#endif -} - -QMediaService* QT7ServicePlugin::create(QString const& key) -{ -#ifdef QMEDIA_QT7_PLAYER - if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) - return new QT7PlayerService; -#endif - - qWarning() << "Attempt to create unknown service with key" << key; - return 0; -} - -void QT7ServicePlugin::release(QMediaService *service) -{ - delete service; -} - -Q_EXPORT_PLUGIN2(qt7_serviceplugin, QT7ServicePlugin); - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h b/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h deleted file mode 100644 index 76066ba..0000000 --- a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 QT7VIDEOOUTPUTCONTROL_H -#define QT7VIDEOOUTPUTCONTROL_H - -#include -#include - -#include -#include -#include -#include -#include - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlaylist; -class QMediaPlaylistNavigator; -class QT7PlayerSession; -class QT7PlayerService; - - -class QT7VideoOutput { -public: - virtual ~QT7VideoOutput() {} - virtual void setMovie(void *movie) = 0; - virtual void updateNaturalSize(const QSize &newSize) = 0; -}; - -class QT7VideoWindowControl : public QVideoWindowControl, public QT7VideoOutput -{ -public: - virtual ~QT7VideoWindowControl() {} - -protected: - QT7VideoWindowControl(QObject *parent) - :QVideoWindowControl(parent) - {} -}; - -class QT7VideoRendererControl : public QVideoRendererControl, public QT7VideoOutput -{ -public: - virtual ~QT7VideoRendererControl() {} - -protected: - QT7VideoRendererControl(QObject *parent) - :QVideoRendererControl(parent) - {} -}; - -class QT7VideoWidgetControl : public QVideoWidgetControl, public QT7VideoOutput -{ -public: - virtual ~QT7VideoWidgetControl() {} - -protected: - QT7VideoWidgetControl(QObject *parent) - :QVideoWidgetControl(parent) - {} -}; - -class QT7VideoOutputControl : public QVideoOutputControl -{ -Q_OBJECT -public: - QT7VideoOutputControl(QObject *parent = 0); - ~QT7VideoOutputControl(); - - void setSession(QT7PlayerSession *session); - - QList availableOutputs() const; - void enableOutput(Output); - - Output output() const; - void setOutput(Output output); - -signals: - void videoOutputChanged(QVideoOutputControl::Output); - -private: - QT7PlayerSession *m_session; - Output m_output; - QList m_outputs; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.mm b/src/plugins/mediaservices/qt7/qt7videooutputcontrol.mm deleted file mode 100644 index a468431..0000000 --- a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.mm +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "qt7playercontrol.h" -#include "qt7videooutputcontrol.h" -#include "qt7playersession.h" -#include - -QT_BEGIN_NAMESPACE - -QT7VideoOutputControl::QT7VideoOutputControl(QObject *parent) - :QVideoOutputControl(parent), - m_session(0), - m_output(QVideoOutputControl::NoOutput) -{ -} - -QT7VideoOutputControl::~QT7VideoOutputControl() -{ -} - -void QT7VideoOutputControl::setSession(QT7PlayerSession *session) -{ - m_session = session; -} - -QList QT7VideoOutputControl::availableOutputs() const -{ - return m_outputs; -} - -void QT7VideoOutputControl::enableOutput(QVideoOutputControl::Output output) -{ - if (!m_outputs.contains(output)) - m_outputs.append(output); -} - -QVideoOutputControl::Output QT7VideoOutputControl::output() const -{ - return m_output; -} - -void QT7VideoOutputControl::setOutput(Output output) -{ - if (m_output != output) { - m_output = output; - emit videoOutputChanged(m_output); - } - -} - -QT_END_NAMESPACE - -#include "moc_qt7videooutputcontrol.cpp" - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/mediaplayer.pri b/src/plugins/mediaservices/symbian/mediaplayer/mediaplayer.pri deleted file mode 100644 index 205e014..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/mediaplayer.pri +++ /dev/null @@ -1,63 +0,0 @@ -INCLUDEPATH += $$PWD -LIBS += -lmediaclientvideo \ - -lmediaclientaudio \ - -lws32 \ - -lfbscli \ - -lcone \ - -lmmfcontrollerframework \ - -lefsrv \ - -lbitgdi \ - -lapgrfx \ - -lapmime - - -# We are building Symbian backend with media player support -DEFINES += QMEDIA_MMF_PLAYER - - -HEADERS += \ - $$PWD/s60mediaplayercontrol.h \ - $$PWD/s60mediaplayerservice.h \ - $$PWD/s60mediaplayersession.h \ - $$PWD/s60videoplayersession.h \ - $$PWD/s60mediametadataprovider.h \ - $$PWD/s60videosurface.h \ - $$PWD/s60videooverlay.h \ - $$PWD/s60videorenderer.h \ - $$PWD/s60mediarecognizer.h \ - $$PWD/s60audioplayersession.h \ - $$PWD/ms60mediaplayerresolver.h \ - $$PWD/s60videowidget.h \ - $$PWD/s60mediaplayeraudioendpointselector.h - -SOURCES += \ - $$PWD/s60mediaplayercontrol.cpp \ - $$PWD/s60mediaplayerservice.cpp \ - $$PWD/s60mediaplayersession.cpp \ - $$PWD/s60videoplayersession.cpp \ - $$PWD/s60mediametadataprovider.cpp \ - $$PWD/s60videosurface.cpp \ - $$PWD/s60videooverlay.cpp \ - $$PWD/s60videorenderer.cpp \ - $$PWD/s60mediarecognizer.cpp \ - $$PWD/s60audioplayersession.cpp \ - $$PWD/s60videowidget.cpp \ - $$PWD/s60mediaplayeraudioendpointselector.cpp - -contains(S60_VERSION, 3.1) { - - #3.1 doesn't provide audio routing in videoplayer - DEFINES += HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER - - !exists($${EPOCROOT}epoc32\release\winscw\udeb\audiooutputrouting.lib) { - MMP_RULES += "$${LITERAL_HASH}ifdef WINSCW" \ - "MACRO HAS_NO_AUDIOROUTING" \ - "$${LITERAL_HASH}else" \ - "LIBRARY audiooutputrouting.lib" \ - "$${LITERAL_HASH}endif" - } - -} else { - LIBS += -laudiooutputrouting -} - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/ms60mediaplayerresolver.h b/src/plugins/mediaservices/symbian/mediaplayer/ms60mediaplayerresolver.h deleted file mode 100644 index b655a83..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/ms60mediaplayerresolver.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 MS60MEDIAPLAYERRESOLVER_H -#define MS60MEDIAPLAYERRESOLVER_H - -QT_BEGIN_NAMESPACE - -class S60MediaPlayerSession; - -class MS60MediaPlayerResolver -{ - public: - virtual S60MediaPlayerSession* PlayerSession() = 0; - virtual S60MediaPlayerSession* VideoPlayerSession() = 0; - virtual S60MediaPlayerSession* AudioPlayerSession() = 0; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.cpp deleted file mode 100644 index 1bebe0a..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60audioplayersession.h" -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -S60AudioPlayerSession::S60AudioPlayerSession(QObject *parent) - : S60MediaPlayerSession(parent) - , m_player(0) - , m_audioEndpoint("Default") -{ -#ifndef HAS_NO_AUDIOROUTING - m_audioOutput = 0; -#endif - QT_TRAP_THROWING(m_player = CAudioPlayer::NewL(*this, 0, EMdaPriorityPreferenceNone)); - m_player->RegisterForAudioLoadingNotification(*this); -} - -S60AudioPlayerSession::~S60AudioPlayerSession() -{ -#if !defined(HAS_NO_AUDIOROUTING) - if (m_audioOutput) - m_audioOutput->UnregisterObserver(*this); - delete m_audioOutput; -#endif - m_player->Close(); - delete m_player; -} - -void S60AudioPlayerSession::doLoadL(const TDesC &path) -{ -#ifndef HAS_NO_AUDIOROUTING - // m_audioOutput needs to be reinitialized after MapcInitComplete - if (m_audioOutput) - m_audioOutput->UnregisterObserver(*this); - delete m_audioOutput; - m_audioOutput = NULL; -#endif - - m_player->OpenFileL(path); -} - -qint64 S60AudioPlayerSession::doGetDurationL() const -{ - return m_player->Duration().Int64() / qint64(1000); -} - -qint64 S60AudioPlayerSession::doGetPositionL() const -{ - TTimeIntervalMicroSeconds ms = 0; - m_player->GetPosition(ms); - return ms.Int64() / qint64(1000); -} - -bool S60AudioPlayerSession::isVideoAvailable() const -{ - return false; -} -bool S60AudioPlayerSession::isAudioAvailable() const -{ - return true; // this is a bit happy scenario, but we do emit error that we can't play -} - -void S60AudioPlayerSession::MaloLoadingStarted() -{ - buffering(); -} - -void S60AudioPlayerSession::MaloLoadingComplete() -{ - buffered(); -} - -void S60AudioPlayerSession::doPlay() -{ -// For some reason loading progress callbalck are not called on emulator -#ifdef __WINSCW__ - buffering(); -#endif - m_player->Play(); -#ifdef __WINSCW__ - buffered(); -#endif - -} - -void S60AudioPlayerSession::doPauseL() -{ - m_player->Pause(); -} - -void S60AudioPlayerSession::doStop() -{ - m_player->Stop(); -} - -void S60AudioPlayerSession::doSetVolumeL(int volume) -{ - m_player->SetVolume((volume / 100.0) * m_player->MaxVolume()); -} - -void S60AudioPlayerSession::doSetPositionL(qint64 microSeconds) -{ - m_player->SetPosition(TTimeIntervalMicroSeconds(microSeconds)); -} - -void S60AudioPlayerSession::updateMetaDataEntriesL() -{ - metaDataEntries().clear(); - int numberOfMetaDataEntries = 0; - - m_player->GetNumberOfMetaDataEntries(numberOfMetaDataEntries); - - for (int i = 0; i < numberOfMetaDataEntries; i++) { - CMMFMetaDataEntry *entry = NULL; - entry = m_player->GetMetaDataEntryL(i); - metaDataEntries().insert(QString::fromUtf16(entry->Name().Ptr(), entry->Name().Length()), QString::fromUtf16(entry->Value().Ptr(), entry->Value().Length())); - delete entry; - } - emit metaDataChanged(); -} - -int S60AudioPlayerSession::doGetBufferStatusL() const -{ - int progress = 0; - m_player->GetAudioLoadingProgressL(progress); - return progress; -} - -void S60AudioPlayerSession::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration) -{ - Q_UNUSED(aDuration); - setError(aError); -#ifndef HAS_NO_AUDIOROUTING - TRAPD(err, - m_audioOutput = CAudioOutput::NewL(*m_player); - m_audioOutput->RegisterObserverL(*this); - ); - setActiveEndpoint(m_audioEndpoint); - setError(err); -#endif - loaded(); -} - -void S60AudioPlayerSession::MapcPlayComplete(TInt aError) -{ - setError(aError); - endOfMedia(); -} - -void S60AudioPlayerSession::doSetAudioEndpoint(const QString& audioEndpoint) -{ - m_audioEndpoint = audioEndpoint; -} - -QString S60AudioPlayerSession::activeEndpoint() const -{ - QString outputName = QString("Default"); -#if !defined(HAS_NO_AUDIOROUTING) - if (m_audioOutput) { - CAudioOutput::TAudioOutputPreference output = m_audioOutput->AudioOutput(); - outputName = qStringFromTAudioOutputPreference(output); - } -#endif - return outputName; -} - -QString S60AudioPlayerSession::defaultEndpoint() const -{ - QString outputName = QString("Default"); -#if !defined(HAS_NO_AUDIOROUTING) - if (m_audioOutput) { - CAudioOutput::TAudioOutputPreference output = m_audioOutput->DefaultAudioOutput(); - outputName = qStringFromTAudioOutputPreference(output); - } -#endif - return outputName; -} - -void S60AudioPlayerSession::setActiveEndpoint(const QString& name) -{ -#if !defined(HAS_NO_AUDIOROUTING) - CAudioOutput::TAudioOutputPreference output = CAudioOutput::ENoPreference; - - if (name == QString("Default")) - output = CAudioOutput::ENoPreference; - else if (name == QString("All")) - output = CAudioOutput::EAll; - else if (name == QString("None")) - output = CAudioOutput::ENoOutput; - else if (name == QString("Earphone")) - output = CAudioOutput::EPrivate; - else if (name == QString("Speaker")) - output = CAudioOutput::EPublic; - if (m_audioOutput) { - TRAPD(err, m_audioOutput->SetAudioOutputL(output)); - setError(err); - - if (m_audioEndpoint != name) { - m_audioEndpoint = name; - emit activeEndpointChanged(name); - } - } -#endif -} - -#if !defined(HAS_NO_AUDIOROUTING) -void S60AudioPlayerSession::DefaultAudioOutputChanged(CAudioOutput& aAudioOutput, - CAudioOutput::TAudioOutputPreference aNewDefault) -{ - // Emit already implemented in setActiveEndpoint function - Q_UNUSED(aAudioOutput) - Q_UNUSED(aNewDefault) -} - -QString S60AudioPlayerSession::qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const -{ - if (output == CAudioOutput::ENoPreference) - return QString("Default"); - else if (output == CAudioOutput::EAll) - return QString("All"); - else if (output == CAudioOutput::ENoOutput) - return QString("None"); - else if (output == CAudioOutput::EPrivate) - return QString("Earphone"); - else if (output == CAudioOutput::EPublic) - return QString("Speaker"); - return QString("Default"); -} -#endif -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h b/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h deleted file mode 100644 index d7259b9..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60AUDIOPLAYERSESSION_H -#define S60AUDIOPLAYERSESSION_H - -#include "s60mediaplayersession.h" - -#include -typedef CMdaAudioPlayerUtility CAudioPlayer; -typedef MMdaAudioPlayerCallback MAudioPlayerObserver; - -#ifndef HAS_NO_AUDIOROUTING -#include -#include -#endif - -QT_BEGIN_NAMESPACE - -class S60AudioPlayerSession : public S60MediaPlayerSession - , public MAudioPlayerObserver - , public MAudioLoadingObserver -#ifndef HAS_NO_AUDIOROUTING - , public MAudioOutputObserver -#endif -{ - Q_OBJECT - -public: - S60AudioPlayerSession(QObject *parent); - ~S60AudioPlayerSession(); - - //From S60MediaPlayerSession - bool isVideoAvailable() const; - bool isAudioAvailable() const; - - // From MAudioLoadingObserver - void MaloLoadingStarted(); - void MaloLoadingComplete(); - -#ifndef HAS_NO_AUDIOROUTING - // From MAudioOutputObserver - void DefaultAudioOutputChanged( CAudioOutput& aAudioOutput, - CAudioOutput::TAudioOutputPreference aNewDefault ); -#endif -public: - // From S60MediaPlayerAudioEndpointSelector - QString activeEndpoint() const; - QString defaultEndpoint() const; -public Q_SLOTS: - void setActiveEndpoint(const QString& name); -Q_SIGNALS: - void activeEndpointChanged(const QString & name); - -protected: - //From S60MediaPlayerSession - void doLoadL(const TDesC &path); - void doLoadUrlL(const TDesC &path){Q_UNUSED(path)/*empty implementation*/} - void doPlay(); - void doStop(); - void doPauseL(); - void doSetVolumeL(int volume); - qint64 doGetPositionL() const; - void doSetPositionL(qint64 microSeconds); - void updateMetaDataEntriesL(); - int doGetBufferStatusL() const; - qint64 doGetDurationL() const; - void doSetAudioEndpoint(const QString& audioEndpoint); - -private: - void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration); - void MapcPlayComplete(TInt aError); -#ifndef HAS_NO_AUDIOROUTING - QString qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const; -#endif -private: - CAudioPlayer *m_player; -#ifndef HAS_NO_AUDIOROUTING - CAudioOutput *m_audioOutput; -#endif - QString m_audioEndpoint; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.cpp deleted file mode 100644 index e80c487..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60mediametadataprovider.h" -#include "s60mediaplayersession.h" -#include - -QT_BEGIN_NAMESPACE - -S60MediaMetaDataProvider::S60MediaMetaDataProvider(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent) - : QMetaDataControl(parent) - , m_mediaPlayerResolver(mediaPlayerResolver) - , m_session(NULL) -{ -} - -S60MediaMetaDataProvider::~S60MediaMetaDataProvider() -{ -} - -bool S60MediaMetaDataProvider::isMetaDataAvailable() const -{ - m_session = m_mediaPlayerResolver.PlayerSession(); - if (m_session) - return m_session->isMetadataAvailable(); - return false; -} - -bool S60MediaMetaDataProvider::isWritable() const -{ - return false; -} - -QVariant S60MediaMetaDataProvider::metaData(QtMediaServices::MetaData key) const -{ - m_session = m_mediaPlayerResolver.PlayerSession(); - if (m_session && m_session->isMetadataAvailable()) - return m_session->metaData(metaDataKeyAsString(key)); - return QVariant(); -} - -void S60MediaMetaDataProvider::setMetaData(QtMediaServices::MetaData key, QVariant const &value) -{ - Q_UNUSED(key); - Q_UNUSED(value); -} -QList S60MediaMetaDataProvider::availableMetaData() const -{ - m_session = m_mediaPlayerResolver.PlayerSession(); - QList metaDataTags; - if (m_session && m_session->isMetadataAvailable()) { - for (int i = QtMediaServices::Title; i <= QtMediaServices::DeviceSettingDescription; i++) { - QString metaData = metaDataKeyAsString((QtMediaServices::MetaData)i); - if (!metaData.isEmpty()) { - if (!m_session->metaData(metaData).toString().isEmpty()) { - metaDataTags.append((QtMediaServices::MetaData)i); - } - } - } - } - return metaDataTags; -} - -QVariant S60MediaMetaDataProvider::extendedMetaData(const QString &key) const -{ - m_session = m_mediaPlayerResolver.PlayerSession(); - if (m_session && m_session->isMetadataAvailable()) - return m_session->metaData(key); - return QVariant(); -} - -void S60MediaMetaDataProvider::setExtendedMetaData(const QString &key, QVariant const &value) -{ - Q_UNUSED(key); - Q_UNUSED(value); -} - -QStringList S60MediaMetaDataProvider::availableExtendedMetaData() const -{ - m_session = m_mediaPlayerResolver.PlayerSession(); - if (m_session && m_session->isMetadataAvailable()) - return m_session->availableMetaData().keys(); - return QStringList(); -} - -QString S60MediaMetaDataProvider::metaDataKeyAsString(QtMediaServices::MetaData key) const -{ - switch(key) { - case QtMediaServices::Title: return "title"; - case QtMediaServices::AlbumArtist: return "artist"; - case QtMediaServices::Comment: return "comment"; - case QtMediaServices::Genre: return "genre"; - case QtMediaServices::Year: return "year"; - case QtMediaServices::Copyright: return "copyright"; - case QtMediaServices::AlbumTitle: return "album"; - case QtMediaServices::Composer: return "composer"; - case QtMediaServices::TrackNumber: return "albumtrack"; - case QtMediaServices::AudioBitRate: return "audiobitrate"; - case QtMediaServices::VideoBitRate: return "videobitrate"; - case QtMediaServices::Duration: return "duration"; - case QtMediaServices::MediaType: return "contenttype"; - case QtMediaServices::SubTitle: // TODO: Find the matching metadata keys - case QtMediaServices::Description: - case QtMediaServices::Category: - case QtMediaServices::Date: - case QtMediaServices::UserRating: - case QtMediaServices::Keywords: - case QtMediaServices::Language: - case QtMediaServices::Publisher: - case QtMediaServices::ParentalRating: - case QtMediaServices::RatingOrganisation: - case QtMediaServices::Size: - case QtMediaServices::AudioCodec: - case QtMediaServices::AverageLevel: - case QtMediaServices::ChannelCount: - case QtMediaServices::PeakValue: - case QtMediaServices::SampleRate: - case QtMediaServices::Author: - case QtMediaServices::ContributingArtist: - case QtMediaServices::Conductor: - case QtMediaServices::Lyrics: - case QtMediaServices::Mood: - case QtMediaServices::TrackCount: - case QtMediaServices::CoverArtUrlSmall: - case QtMediaServices::CoverArtUrlLarge: - case QtMediaServices::Resolution: - case QtMediaServices::PixelAspectRatio: - case QtMediaServices::VideoFrameRate: - case QtMediaServices::VideoCodec: - case QtMediaServices::PosterUrl: - case QtMediaServices::ChapterNumber: - case QtMediaServices::Director: - case QtMediaServices::LeadPerformer: - case QtMediaServices::Writer: - case QtMediaServices::CameraManufacturer: - case QtMediaServices::CameraModel: - case QtMediaServices::Event: - case QtMediaServices::Subject: - default: - break; - } - - return QString(); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.h deleted file mode 100644 index 07ae494..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60MEDIAMETADATAPROVIDER_H -#define S60MEDIAMETADATAPROVIDER_H - -#include -#include "ms60mediaplayerresolver.h" - -QT_BEGIN_NAMESPACE - -class S60MediaPlayerSession; - -class S60MediaMetaDataProvider : public QMetaDataControl -{ - Q_OBJECT - -public: - S60MediaMetaDataProvider(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent = 0); - ~S60MediaMetaDataProvider(); - - bool isMetaDataAvailable() const; - bool isWritable() const; - - QVariant metaData(QtMediaServices::MetaData key) const; - void setMetaData(QtMediaServices::MetaData key, const QVariant &value); - QList availableMetaData() const; - - QVariant extendedMetaData(const QString &key) const ; - void setExtendedMetaData(const QString &key, const QVariant &value); - QStringList availableExtendedMetaData() const; - -private: - QString metaDataKeyAsString(QtMediaServices::MetaData key) const; - -private: - MS60MediaPlayerResolver& m_mediaPlayerResolver; - mutable S60MediaPlayerSession *m_session; -}; - -QT_END_NAMESPACE - -#endif // S60VIDEOMETADATAPROVIDER_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.cpp deleted file mode 100644 index dbeed90..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60mediaplayercontrol.h" -#include "s60mediaplayersession.h" -#include "s60mediaplayeraudioendpointselector.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -S60MediaPlayerAudioEndpointSelector::S60MediaPlayerAudioEndpointSelector(QObject *control, QObject *parent) - :QMediaControl(parent) - , m_control(0) - , m_audioEndpointNames(0) -{ - m_control = qobject_cast(control); -} - -S60MediaPlayerAudioEndpointSelector::~S60MediaPlayerAudioEndpointSelector() -{ - delete m_audioEndpointNames; -} - -QList S60MediaPlayerAudioEndpointSelector::availableEndpoints() const -{ - if(m_audioEndpointNames->count() == 0) { - m_audioEndpointNames->append("Default"); - m_audioEndpointNames->append("All"); - m_audioEndpointNames->append("None"); - m_audioEndpointNames->append("Earphone"); - m_audioEndpointNames->append("Speaker"); - } - return *m_audioEndpointNames; -} - -QString S60MediaPlayerAudioEndpointSelector::endpointDescription(const QString& name) const -{ - if (name == QString("Default")) //ENoPreference - return QString("Used to indicate that the playing audio can be routed to" - "any speaker. This is the default value for audio."); - else if (name == QString("All")) //EAll - return QString("Used to indicate that the playing audio should be routed to all speakers."); - else if (name == QString("None")) //ENoOutput - return QString("Used to indicate that the playing audio should not be routed to any output."); - else if (name == QString("Earphone")) //EPrivate - return QString("Used to indicate that the playing audio should be routed to" - "the default private speaker. A private speaker is one that can only" - "be heard by one person."); - else if (name == QString("Speaker")) //EPublic - return QString("Used to indicate that the playing audio should be routed to" - "the default public speaker. A public speaker is one that can " - "be heard by multiple people."); - - return QString(); -} - -QString S60MediaPlayerAudioEndpointSelector::activeEndpoint() const -{ - if (m_control->session()) - return m_control->session()->activeEndpoint(); - else - return m_control->mediaControlSettings().audioEndpoint(); -} - -QString S60MediaPlayerAudioEndpointSelector::defaultEndpoint() const -{ - if (m_control->session()) - return m_control->session()->defaultEndpoint(); - else - return m_control->mediaControlSettings().audioEndpoint(); -} - -void S60MediaPlayerAudioEndpointSelector::setActiveEndpoint(const QString& name) -{ - QString oldEndpoint = m_control->mediaControlSettings().audioEndpoint(); - - if (name != oldEndpoint && (name == QString("Default") || name == QString("All") || - name == QString("None") || name == QString("Earphone") || name == QString("Speaker"))) { - - if (m_control->session()) { - m_control->session()->setActiveEndpoint(name); - } - m_control->setAudioEndpoint(name); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.h deleted file mode 100644 index a110ae8..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H -#define S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H - -#include - -#include - -QT_BEGIN_NAMESPACE - -class S60MediaPlayerControl; -class S60MediaPlayerSession; - -class S60MediaPlayerAudioEndpointSelector : public QMediaControl -{ - -Q_OBJECT - -public: - S60MediaPlayerAudioEndpointSelector(QObject *control, QObject *parent = 0); - ~S60MediaPlayerAudioEndpointSelector(); - - QList availableEndpoints() const ; - QString endpointDescription(const QString& name) const; - QString defaultEndpoint() const; - QString activeEndpoint() const; - -public Q_SLOTS: - void setActiveEndpoint(const QString& name); - -private: - S60MediaPlayerControl* m_control; - QString m_audioInput; - QList *m_audioEndpointNames; -}; - -#define QAudioEndpointSelector_iid "com.nokia.Qt.QAudioEndpointSelector/1.0" - -QT_END_NAMESPACE - -#endif // S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.cpp deleted file mode 100644 index 8e03afd..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.cpp +++ /dev/null @@ -1,274 +0,0 @@ - -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60mediaplayercontrol.h" -#include "s60mediaplayersession.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -S60MediaPlayerControl::S60MediaPlayerControl(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent) - : QMediaPlayerControl(parent), - m_mediaPlayerResolver(mediaPlayerResolver), - m_session(NULL), - m_stream(NULL) -{ -} - -S60MediaPlayerControl::~S60MediaPlayerControl() -{ -} - -qint64 S60MediaPlayerControl::position() const -{ - if (m_session) - return m_session->position(); - return 0; -} - -qint64 S60MediaPlayerControl::duration() const -{ - if (m_session) - return m_session->duration(); - return -1; -} - -QMediaPlayer::State S60MediaPlayerControl::state() const -{ - if (m_session) - return m_session->state(); - return QMediaPlayer::StoppedState; -} - -QMediaPlayer::MediaStatus S60MediaPlayerControl::mediaStatus() const -{ - if (m_session) - return m_session->mediaStatus(); - return m_mediaSettings.mediaStatus(); -} - -int S60MediaPlayerControl::bufferStatus() const -{ - if (m_session) - return m_session->bufferStatus(); - return 0; -} - -int S60MediaPlayerControl::volume() const -{ - if (m_session) - return m_session->volume(); - return m_mediaSettings.volume(); -} - -bool S60MediaPlayerControl::isMuted() const -{ - if (m_session) - return m_session->isMuted(); - return m_mediaSettings.isMuted(); -} - -bool S60MediaPlayerControl::isSeekable() const -{ - if (m_session) - return m_session->isSeekable(); - return false; -} - -QMediaTimeRange S60MediaPlayerControl::availablePlaybackRanges() const -{ - QMediaTimeRange ranges; - - if(m_session && m_session->isSeekable()) - ranges.addInterval(0, m_session->duration()); - - return ranges; -} - -qreal S60MediaPlayerControl::playbackRate() const -{ - //None of symbian players supports this. - return m_mediaSettings.playbackRate(); -} - -void S60MediaPlayerControl::setPlaybackRate(qreal rate) -{ - //None of symbian players supports this. - m_mediaSettings.setPlaybackRate(rate); - emit playbackRateChanged(playbackRate()); - -} - -void S60MediaPlayerControl::setPosition(qint64 pos) -{ - if (m_session) - m_session->setPosition(pos); -} - -void S60MediaPlayerControl::play() -{ - if (m_session) - m_session->play(); -} - -void S60MediaPlayerControl::pause() -{ - if (m_session) - m_session->pause(); -} - -void S60MediaPlayerControl::stop() -{ - if (m_session) - m_session->stop(); -} - -void S60MediaPlayerControl::setVolume(int volume) -{ - int boundVolume = qBound(0, volume, 100); - if (boundVolume == m_mediaSettings.volume()) - return; - - m_mediaSettings.setVolume(boundVolume); - if (m_session) - m_session->setVolume(boundVolume); - - emit volumeChanged(boundVolume); -} - -void S60MediaPlayerControl::setMuted(bool muted) -{ - if (m_mediaSettings.isMuted() == muted) - return; - - m_mediaSettings.setMuted(muted); - if (m_session) - m_session->setMuted(muted); - - emit mutedChanged(muted); -} - -QMediaContent S60MediaPlayerControl::media() const -{ - return m_currentResource; -} - -const QIODevice *S60MediaPlayerControl::mediaStream() const -{ - return m_stream; -} - -void S60MediaPlayerControl::setMedia(const QMediaContent &source, QIODevice *stream) -{ - Q_UNUSED(stream) - // we don't want to set & load media again when it is already loaded - if (m_session && m_currentResource == source) - return; - - // store to variable as session is created based on the content type. - m_currentResource = source; - S60MediaPlayerSession *newSession = m_mediaPlayerResolver.PlayerSession(); - m_mediaSettings.setMediaStatus(QMediaPlayer::UnknownMediaStatus); - - if (m_session) - m_session->reset(); - else { - emit mediaStatusChanged(QMediaPlayer::UnknownMediaStatus); - emit error(QMediaPlayer::NoError, QString()); - } - - m_session = newSession; - - if (m_session) - m_session->load(source.canonicalUrl()); - else { - QMediaPlayer::MediaStatus status = (source.isNull()) ? QMediaPlayer::NoMedia : QMediaPlayer::InvalidMedia; - m_mediaSettings.setMediaStatus(status); - emit stateChanged(QMediaPlayer::StoppedState); - emit error((source.isNull()) ? QMediaPlayer::NoError : QMediaPlayer::ResourceError, - (source.isNull()) ? "" : tr("Media couldn't be resolved")); - emit mediaStatusChanged(status); - } - emit mediaChanged(m_currentResource); - } - -S60MediaPlayerSession* S60MediaPlayerControl::session() -{ - return m_session; -} - -void S60MediaPlayerControl::setVideoOutput(QObject *output) -{ - S60MediaPlayerSession *session = NULL; - session = m_mediaPlayerResolver.VideoPlayerSession(); - session->setVideoRenderer(output); -} - -bool S60MediaPlayerControl::isAudioAvailable() const -{ - if (m_session) - return m_session->isAudioAvailable(); - return false; -} - -bool S60MediaPlayerControl::isVideoAvailable() const -{ - if (m_session) - return m_session->isVideoAvailable(); - return false; -} - -const S60MediaSettings& S60MediaPlayerControl::mediaControlSettings() const -{ - return m_mediaSettings; -} - -void S60MediaPlayerControl::setAudioEndpoint(const QString& name) -{ - m_mediaSettings.setAudioEndpoint(name); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.h deleted file mode 100644 index 3d26a5e..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.h +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60MEDIAPLAYERCONTROL_H -#define S60MEDIAPLAYERCONTROL_H - -#include - -#include - -#include "ms60mediaplayerresolver.h" -#include - -QT_BEGIN_NAMESPACE - -class QMediaPlayer; -class QMediaTimeRange; -class QMediaContent; - - -class S60MediaPlayerSession; -class S60MediaPlayerService; - -class S60MediaSettings -{ - -public: - S60MediaSettings() - : m_volume(0) - , m_muted(false) - , m_playbackRate(0) - , m_mediaStatus(QMediaPlayer::UnknownMediaStatus) - , m_audioEndpoint(QString("Default")) - { - } - - void setVolume(int volume) { m_volume = volume; } - void setMuted(bool muted) { m_muted = muted; } - void setPlaybackRate(int rate) { m_playbackRate = rate; } - void setMediaStatus(QMediaPlayer::MediaStatus status) {m_mediaStatus=status;} - void setAudioEndpoint(const QString& audioEndpoint) { m_audioEndpoint = audioEndpoint; } - - int volume() const { return m_volume; } - bool isMuted() const { return m_muted; } - qreal playbackRate() const { return m_playbackRate; } - QMediaPlayer::MediaStatus mediaStatus() const {return m_mediaStatus;} - QString audioEndpoint() const { return m_audioEndpoint; } - -private: - int m_volume; - bool m_muted; - qreal m_playbackRate; - QMediaPlayer::MediaStatus m_mediaStatus; - QString m_audioEndpoint; -}; - -class S60MediaPlayerControl : public QMediaPlayerControl -{ - Q_OBJECT - -public: - S60MediaPlayerControl(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent = 0); - ~S60MediaPlayerControl(); - - // from QMediaPlayerControl - virtual QMediaPlayer::State state() const; - virtual QMediaPlayer::MediaStatus mediaStatus() const; - virtual qint64 duration() const; - virtual qint64 position() const; - virtual void setPosition(qint64 pos); - virtual int volume() const; - virtual void setVolume(int volume); - virtual bool isMuted() const; - virtual void setMuted(bool muted); - virtual int bufferStatus() const; - virtual bool isAudioAvailable() const; - virtual bool isVideoAvailable() const; - virtual bool isSeekable() const; - virtual QMediaTimeRange availablePlaybackRanges() const; - virtual qreal playbackRate() const; - virtual void setPlaybackRate(qreal rate); - virtual QMediaContent media() const; - virtual const QIODevice *mediaStream() const; - virtual void setMedia(const QMediaContent&, QIODevice *); - virtual void play(); - virtual void pause(); - virtual void stop(); - S60MediaPlayerSession* session(); - void setAudioEndpoint(const QString& name); - - // Own methods - void setVideoOutput(QObject *output); - const S60MediaSettings& mediaControlSettings() const; - -private: - MS60MediaPlayerResolver &m_mediaPlayerResolver; - S60MediaPlayerSession *m_session; - QMediaContent m_currentResource; - QIODevice *m_stream; - S60MediaSettings m_mediaSettings; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.cpp deleted file mode 100644 index 0b1c7d5..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60mediaplayerservice.h" -#include "s60mediaplayercontrol.h" -#include "s60videoplayersession.h" -#include "s60audioplayersession.h" -#include "s60mediametadataprovider.h" -#include "s60videowidget.h" -#include "s60mediarecognizer.h" -//#include -#include "s60videooverlay.h" -#include "s60videorenderer.h" -#include "s60mediaplayeraudioendpointselector.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -S60MediaPlayerService::S60MediaPlayerService(QObject *parent) - : QMediaService(parent) - , m_control(NULL) - , m_videoOutput(NULL) - , m_videoPlayerSession(NULL) - , m_audioPlayerSession(NULL) - , m_metaData(NULL) - , m_videoWidget(NULL) - , m_videoWindow(NULL) - , m_videoRenderer(NULL) - , m_audioEndpointSelector(NULL) -{ - m_control = new S60MediaPlayerControl(*this, this); - m_metaData = new S60MediaMetaDataProvider(*this); - m_audioEndpointSelector = new S60MediaPlayerAudioEndpointSelector(m_control, this); -} - -S60MediaPlayerService::~S60MediaPlayerService() -{ - delete m_videoWidget; - delete m_videoRenderer; - delete m_videoWindow; - delete m_videoOutput; -} - -QMediaControl *S60MediaPlayerService::control(const char *name) const -{ - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return m_control; - - if (qstrcmp(name, QMetaDataControl_iid) == 0) { - return m_metaData; - } - - if (qstrcmp(name, QVideoOutputControl_iid) == 0) { - if (!m_videoOutput) { - m_videoOutput = new S60VideoOutputControl; - connect(m_videoOutput, SIGNAL(outputChanged(QVideoOutputControl::Output)), - this, SLOT(videoOutputChanged(QVideoOutputControl::Output))); - m_videoOutput->setAvailableOutputs(QList() -// << QVideoOutputControl::RendererOutput -// << QVideoOutputControl::WindowOutput - << QVideoOutputControl::WidgetOutput); - - } - return m_videoOutput; - } - - if (qstrcmp(name, QVideoWidgetControl_iid) == 0) { - if (!m_videoWidget) - m_videoWidget = new S60VideoWidgetControl; - return m_videoWidget; - } - - if (qstrcmp(name, QVideoRendererControl_iid) == 0) { - if (m_videoRenderer) - m_videoRenderer = new S60VideoRenderer; - return m_videoRenderer; - } - - if (qstrcmp(name, QVideoWindowControl_iid) == 0) { - if (!m_videoWindow) - m_videoWindow = new S60VideoOverlay; - return m_videoWindow; - } - - if (qstrcmp(name, QAudioEndpointSelector_iid) == 0) { - return m_audioEndpointSelector; - } - - return 0; - -} - -void S60MediaPlayerService::videoOutputChanged(QVideoOutputControl::Output output) -{ - switch (output) { - case QVideoOutputControl::NoOutput: - m_control->setVideoOutput(0); - break; - - case QVideoOutputControl::RendererOutput: - m_control->setVideoOutput(m_videoRenderer); - break; - case QVideoOutputControl::WindowOutput: - m_control->setVideoOutput(m_videoWindow); - break; - - case QVideoOutputControl::WidgetOutput: - m_control->setVideoOutput(m_videoWidget); - break; - default: - qWarning("Invalid video output selection"); - break; - } -} - -S60MediaPlayerSession* S60MediaPlayerService::PlayerSession() -{ - QUrl url = m_control->media().canonicalUrl(); - - if (url.isEmpty() == true) { - return NULL; - } - - S60MediaRecognizer *m_mediaRecognizer = new S60MediaRecognizer(this); - S60MediaRecognizer::MediaType mediaType = m_mediaRecognizer->mediaType(url); - - switch (mediaType) { - case S60MediaRecognizer::Video: - case S60MediaRecognizer::Url: - return VideoPlayerSession(); - case S60MediaRecognizer::Audio: - return AudioPlayerSession(); - default: - break; - } - - return NULL; -} - -S60MediaPlayerSession* S60MediaPlayerService::VideoPlayerSession() -{ - if (!m_videoPlayerSession) { - m_videoPlayerSession = new S60VideoPlayerSession(this); - - connect(m_videoPlayerSession, SIGNAL(positionChanged(qint64)), - m_control, SIGNAL(positionChanged(qint64))); - connect(m_videoPlayerSession, SIGNAL(durationChanged(qint64)), - m_control, SIGNAL(durationChanged(qint64))); - connect(m_videoPlayerSession, SIGNAL(stateChanged(QMediaPlayer::State)), - m_control, SIGNAL(stateChanged(QMediaPlayer::State))); - connect(m_videoPlayerSession, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - m_control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - connect(m_videoPlayerSession,SIGNAL(bufferStatusChanged(int)), - m_control, SIGNAL(bufferStatusChanged(int))); - connect(m_videoPlayerSession, SIGNAL(videoAvailableChanged(bool)), - m_control, SIGNAL(videoAvailableChanged(bool))); - connect(m_videoPlayerSession, SIGNAL(audioAvailableChanged(bool)), - m_control, SIGNAL(audioAvailableChanged(bool))); - connect(m_videoPlayerSession, SIGNAL(seekableChanged(bool)), - m_control, SIGNAL(seekableChanged(bool))); - connect(m_videoPlayerSession, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)), - m_control, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&))); - connect(m_videoPlayerSession, SIGNAL(error(int, const QString &)), - m_control, SIGNAL(error(int, const QString &))); - connect(m_videoPlayerSession, SIGNAL(metaDataChanged()), - m_metaData, SIGNAL(metaDataChanged())); - connect(m_videoPlayerSession, SIGNAL(activeEndpointChanged(const QString&)), - m_audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&))); - } - - m_videoPlayerSession->setVolume(m_control->mediaControlSettings().volume()); - m_videoPlayerSession->setMuted(m_control->mediaControlSettings().isMuted()); - m_videoPlayerSession->setAudioEndpoint(m_control->mediaControlSettings().audioEndpoint()); - return m_videoPlayerSession; -} - -S60MediaPlayerSession* S60MediaPlayerService::AudioPlayerSession() -{ - if (!m_audioPlayerSession) { - m_audioPlayerSession = new S60AudioPlayerSession(this); - - connect(m_audioPlayerSession, SIGNAL(positionChanged(qint64)), - m_control, SIGNAL(positionChanged(qint64))); - connect(m_audioPlayerSession, SIGNAL(durationChanged(qint64)), - m_control, SIGNAL(durationChanged(qint64))); - connect(m_audioPlayerSession, SIGNAL(stateChanged(QMediaPlayer::State)), - m_control, SIGNAL(stateChanged(QMediaPlayer::State))); - connect(m_audioPlayerSession, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - m_control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - connect(m_audioPlayerSession,SIGNAL(bufferStatusChanged(int)), - m_control, SIGNAL(bufferStatusChanged(int))); - connect(m_audioPlayerSession, SIGNAL(videoAvailableChanged(bool)), - m_control, SIGNAL(videoAvailableChanged(bool))); - connect(m_audioPlayerSession, SIGNAL(audioAvailableChanged(bool)), - m_control, SIGNAL(audioAvailableChanged(bool))); - connect(m_audioPlayerSession, SIGNAL(seekableChanged(bool)), - m_control, SIGNAL(seekableChanged(bool))); - connect(m_audioPlayerSession, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)), - m_control, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&))); - connect(m_audioPlayerSession, SIGNAL(error(int, const QString &)), - m_control, SIGNAL(error(int, const QString &))); - connect(m_audioPlayerSession, SIGNAL(metaDataChanged()), - m_metaData, SIGNAL(metaDataChanged())); - connect(m_audioPlayerSession, SIGNAL(activeEndpointChanged(const QString&)), - m_audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&))); - } - - m_audioPlayerSession->setVolume(m_control->mediaControlSettings().volume()); - m_audioPlayerSession->setMuted(m_control->mediaControlSettings().isMuted()); - m_audioPlayerSession->setAudioEndpoint(m_control->mediaControlSettings().audioEndpoint()); - return m_audioPlayerSession; -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.h deleted file mode 100644 index 6c8155d..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60VIDEOPLAYERSERVICE_H -#define S60VIDEOPLAYERSERVICE_H - -#include - -#include -#include - -#include "s60videooutputcontrol.h" -#include "ms60mediaplayerresolver.h" - -#include "s60mediaplayeraudioendpointselector.h" - -QT_BEGIN_NAMESPACE - -class QMediaMetaData; -class QMediaPlayerControl; -class QMediaPlaylist; - - -class S60VideoPlayerSession; -class S60AudioPlayerSession; -class S60MediaPlayerControl; -class S60MediaMetaDataProvider; -class S60VideoWidgetControl; -class S60MediaRecognizer; -class S60VideoRenderer; -class S60VideoOverlay; - -class QMediaPlaylistNavigator; - -class S60MediaPlayerService : public QMediaService, public MS60MediaPlayerResolver -{ - Q_OBJECT - -public: - S60MediaPlayerService(QObject *parent = 0); - ~S60MediaPlayerService(); - - QMediaControl *control(const char *name) const; - -private slots: - void videoOutputChanged(QVideoOutputControl::Output output); - -protected: // From MS60MediaPlayerResolver - S60MediaPlayerSession* PlayerSession(); - S60MediaPlayerSession* VideoPlayerSession(); - S60MediaPlayerSession* AudioPlayerSession(); - -private: - S60MediaPlayerControl *m_control; - mutable S60VideoOutputControl *m_videoOutput; - S60VideoPlayerSession *m_videoPlayerSession; - S60AudioPlayerSession *m_audioPlayerSession; - mutable S60MediaMetaDataProvider *m_metaData; - mutable S60VideoWidgetControl *m_videoWidget; - mutable S60VideoOverlay *m_videoWindow; - mutable S60VideoRenderer *m_videoRenderer; - S60MediaPlayerAudioEndpointSelector *m_audioEndpointSelector; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.cpp deleted file mode 100644 index 693c103..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.cpp +++ /dev/null @@ -1,496 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60mediaplayersession.h" - -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -S60MediaPlayerSession::S60MediaPlayerSession(QObject *parent) - : QObject(parent) - , m_playbackRate(0) - , m_muted(false) - , m_volume(0) - , m_state(QMediaPlayer::StoppedState) - , m_mediaStatus(QMediaPlayer::UnknownMediaStatus) - , m_progressTimer(new QTimer(this)) - , m_stalledTimer(new QTimer(this)) - , m_error(KErrNone) - , m_play_requested(false) - , m_stream(false) -{ - connect(m_progressTimer, SIGNAL(timeout()), this, SLOT(tick())); - connect(m_stalledTimer, SIGNAL(timeout()), this, SLOT(stalled())); -} - -S60MediaPlayerSession::~S60MediaPlayerSession() -{ -} - -int S60MediaPlayerSession::volume() const -{ - return m_volume; -} - -void S60MediaPlayerSession::setVolume(int volume) -{ - if (m_volume == volume) - return; - - m_volume = volume; - // Dont set symbian players volume until media loaded. - // Leaves with KerrNotReady although documentation says otherwise. - if (!m_muted && - ( mediaStatus() == QMediaPlayer::LoadedMedia - || mediaStatus() == QMediaPlayer::StalledMedia - || mediaStatus() == QMediaPlayer::BufferingMedia - || mediaStatus() == QMediaPlayer::BufferedMedia - || mediaStatus() == QMediaPlayer::EndOfMedia)) { - TRAPD(err, doSetVolumeL(m_volume)); - setError(err); - } -} - -bool S60MediaPlayerSession::isMuted() const -{ - return m_muted; -} - -bool S60MediaPlayerSession::isSeekable() const -{ - return (m_stream)?false:true; -} - -void S60MediaPlayerSession::setMediaStatus(QMediaPlayer::MediaStatus status) -{ - if (m_mediaStatus == status) - return; - - m_mediaStatus = status; - - emit mediaStatusChanged(m_mediaStatus); - - if (m_play_requested) - play(); -} - -void S60MediaPlayerSession::setState(QMediaPlayer::State state) -{ - if (m_state == state) - return; - - m_state = state; - emit stateChanged(m_state); -} - -QMediaPlayer::State S60MediaPlayerSession::state() const -{ - return m_state; -} - -QMediaPlayer::MediaStatus S60MediaPlayerSession::mediaStatus() const -{ - return m_mediaStatus; -} - -void S60MediaPlayerSession::load(QUrl url) -{ - setMediaStatus(QMediaPlayer::LoadingMedia); - startStalledTimer(); - m_stream = (url.scheme() == "file")?false:true; - TRAPD(err, - if(m_stream) - doLoadUrlL(QString2TPtrC(url.toString())); - else - doLoadL(QString2TPtrC(QDir::toNativeSeparators(url.toLocalFile())))); - setError(err); -} - -void S60MediaPlayerSession::play() -{ - if (state() == QMediaPlayer::PlayingState - || mediaStatus() == QMediaPlayer::UnknownMediaStatus - || mediaStatus() == QMediaPlayer::NoMedia - || mediaStatus() == QMediaPlayer::InvalidMedia) - return; - - if (mediaStatus() == QMediaPlayer::LoadingMedia) { - m_play_requested = true; - return; - } - - m_play_requested = false; - setState(QMediaPlayer::PlayingState); - startProgressTimer(); - doPlay(); -} - -void S60MediaPlayerSession::pause() -{ - if (mediaStatus() == QMediaPlayer::NoMedia || - mediaStatus() == QMediaPlayer::InvalidMedia) - return; - - setState(QMediaPlayer::PausedState); - stopProgressTimer(); - TRAP_IGNORE(doPauseL()); -} - -void S60MediaPlayerSession::stop() -{ - m_play_requested = false; - setState(QMediaPlayer::StoppedState); - if (mediaStatus() == QMediaPlayer::BufferingMedia || - mediaStatus() == QMediaPlayer::BufferedMedia) - setMediaStatus(QMediaPlayer::LoadedMedia); - if (mediaStatus() == QMediaPlayer::LoadingMedia) - setMediaStatus(QMediaPlayer::UnknownMediaStatus); - stopProgressTimer(); - stopStalledTimer(); - doStop(); - emit positionChanged(0); -} -void S60MediaPlayerSession::reset() -{ - m_play_requested = false; - setError(KErrNone, QString(), true); - stopProgressTimer(); - stopStalledTimer(); - doStop(); - setState(QMediaPlayer::StoppedState); - setMediaStatus(QMediaPlayer::UnknownMediaStatus); -} - -void S60MediaPlayerSession::setVideoRenderer(QObject *renderer) -{ - Q_UNUSED(renderer); -} - -int S60MediaPlayerSession::bufferStatus() -{ - if( mediaStatus() == QMediaPlayer::LoadingMedia - || mediaStatus() == QMediaPlayer::UnknownMediaStatus - || mediaStatus() == QMediaPlayer::NoMedia - || mediaStatus() == QMediaPlayer::InvalidMedia) - return 0; - - int progress = 0; - TRAPD(err, progress = doGetBufferStatusL()); - - // If buffer status query not supported by codec return 100 - // do not set error - if(err == KErrNotSupported) - return 100; - - setError(err); - return progress; -} - -bool S60MediaPlayerSession::isMetadataAvailable() const -{ - return !m_metaDataMap.isEmpty(); -} - -QVariant S60MediaPlayerSession::metaData(const QString &key) const -{ - return m_metaDataMap.value(key); -} - -QMap S60MediaPlayerSession::availableMetaData() const -{ - return m_metaDataMap; -} - -void S60MediaPlayerSession::setMuted(bool muted) -{ - m_muted = muted; - - if( m_mediaStatus == QMediaPlayer::LoadedMedia - || m_mediaStatus == QMediaPlayer::StalledMedia - || m_mediaStatus == QMediaPlayer::BufferingMedia - || m_mediaStatus == QMediaPlayer::BufferedMedia - || m_mediaStatus == QMediaPlayer::EndOfMedia) { - TRAPD(err, doSetVolumeL((m_muted)?0:m_volume)); - setError(err); - } -} - -qint64 S60MediaPlayerSession::duration() const -{ - if( mediaStatus() == QMediaPlayer::LoadingMedia - || mediaStatus() == QMediaPlayer::UnknownMediaStatus - || mediaStatus() == QMediaPlayer::NoMedia - || mediaStatus() == QMediaPlayer::InvalidMedia) - return -1; - - qint64 pos = 0; - TRAP_IGNORE(pos = doGetDurationL()); - return pos; -} - -qint64 S60MediaPlayerSession::position() const -{ - if( mediaStatus() == QMediaPlayer::LoadingMedia - || mediaStatus() == QMediaPlayer::UnknownMediaStatus - || mediaStatus() == QMediaPlayer::NoMedia - || mediaStatus() == QMediaPlayer::InvalidMedia) - return 0; - - qint64 pos = 0; - TRAP_IGNORE(pos = doGetPositionL()); - return pos; -} - -void S60MediaPlayerSession::setPosition(qint64 pos) -{ - if (position() == pos) - return; - - if (state() == QMediaPlayer::PlayingState) - pause(); - - TRAPD(err, doSetPositionL(pos * 1000)); - setError(err); - - if (state() == QMediaPlayer::PausedState) - play(); - - emit positionChanged(position()); -} - -void S60MediaPlayerSession::setAudioEndpoint(const QString& audioEndpoint) -{ - doSetAudioEndpoint(audioEndpoint); -} - -void S60MediaPlayerSession::loaded() -{ - stopStalledTimer(); - if (m_error == KErrNone || m_error == KErrMMPartialPlayback) { - setMediaStatus(QMediaPlayer::LoadedMedia); - TRAPD(err, updateMetaDataEntriesL()); - setError(err); - setVolume(m_volume); - setMuted(m_muted); - emit durationChanged(duration()); - emit videoAvailableChanged(isVideoAvailable()); - emit audioAvailableChanged(isAudioAvailable()); - } -} - -void S60MediaPlayerSession::endOfMedia() -{ - setMediaStatus(QMediaPlayer::EndOfMedia); - setState(QMediaPlayer::StoppedState); - emit positionChanged(0); -} - -void S60MediaPlayerSession::buffering() -{ - startStalledTimer(); - setMediaStatus(QMediaPlayer::BufferingMedia); -} - -void S60MediaPlayerSession::buffered() -{ - stopStalledTimer(); - setMediaStatus(QMediaPlayer::BufferedMedia); -} -void S60MediaPlayerSession::stalled() -{ - setMediaStatus(QMediaPlayer::StalledMedia); -} - -QMap& S60MediaPlayerSession::metaDataEntries() -{ - return m_metaDataMap; -} - -QMediaPlayer::Error S60MediaPlayerSession::fromSymbianErrorToMultimediaError(int error) -{ - switch(error) { - case KErrNoMemory: - case KErrNotFound: - case KErrBadHandle: - case KErrAbort: - case KErrNotSupported: - case KErrCorrupt: - case KErrGeneral: - case KErrArgument: - case KErrPathNotFound: - case KErrDied: - case KErrServerTerminated: - case KErrServerBusy: - case KErrCompletion: - case KErrBadPower: - return QMediaPlayer::ResourceError; - - case KErrMMPartialPlayback: - return QMediaPlayer::FormatError; - - case KErrMMAudioDevice: - case KErrMMVideoDevice: - case KErrMMDecoder: - case KErrUnknown: - return QMediaPlayer::ServiceMissingError; - - case KErrMMNotEnoughBandwidth: - case KErrMMSocketServiceNotFound: - case KErrMMNetworkRead: - case KErrMMNetworkWrite: - case KErrMMServerSocket: - case KErrMMServerNotSupported: - case KErrMMUDPReceive: - case KErrMMInvalidProtocol: - case KErrMMInvalidURL: - case KErrMMMulticast: - case KErrMMProxyServer: - case KErrMMProxyServerNotSupported: - case KErrMMProxyServerConnect: - return QMediaPlayer::NetworkError; - - case KErrNotReady: - case KErrInUse: - case KErrAccessDenied: - case KErrLocked: - case KErrMMDRMNotAuthorized: - case KErrPermissionDenied: - case KErrCancel: - case KErrAlreadyExists: - return QMediaPlayer::AccessDeniedError; - - case KErrNone: - default: - return QMediaPlayer::NoError; - } -} - -void S60MediaPlayerSession::setError(int error, const QString &errorString, bool forceReset) -{ - if( forceReset ) { - m_error = KErrNone; - emit this->error(QMediaPlayer::NoError, QString()); - return; - } - - // If error does not change and m_error is reseted without forceReset flag - if (error == m_error || - (m_error != KErrNone && error == KErrNone)) - return; - - m_error = error; - QMediaPlayer::Error mediaError = fromSymbianErrorToMultimediaError(m_error); - QString symbianError = QString(errorString); - - if (mediaError != QMediaPlayer::NoError) { - // TODO: fix to user friendly string at some point - // These error string are only dev usable - symbianError.append("Symbian:"); - symbianError.append(QString::number(m_error)); - } - - emit this->error(mediaError, symbianError); - - switch(mediaError){ - case QMediaPlayer::ResourceError: - case QMediaPlayer::NetworkError: - case QMediaPlayer::AccessDeniedError: - case QMediaPlayer::ServiceMissingError: - m_play_requested = false; - setMediaStatus(QMediaPlayer::InvalidMedia); - stop(); - break; - } -} - -void S60MediaPlayerSession::tick() -{ - emit positionChanged(position()); - - if (bufferStatus() < 100) - emit bufferStatusChanged(bufferStatus()); -} - -void S60MediaPlayerSession::startProgressTimer() -{ - m_progressTimer->start(500); -} - -void S60MediaPlayerSession::stopProgressTimer() -{ - m_progressTimer->stop(); -} - -void S60MediaPlayerSession::startStalledTimer() -{ - m_stalledTimer->start(30000); -} - -void S60MediaPlayerSession::stopStalledTimer() -{ - m_stalledTimer->stop(); -} -QString S60MediaPlayerSession::TDesC2QString(const TDesC& aDescriptor) -{ - return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length()); -} -TPtrC S60MediaPlayerSession::QString2TPtrC( const QString& string ) -{ - // Returned TPtrC is valid as long as the given parameter is valid and unmodified - return TPtrC16(static_cast(string.utf16()), string.length()); -} -QRect S60MediaPlayerSession::TRect2QRect(const TRect& tr) -{ - return QRect(tr.iTl.iX, tr.iTl.iY, tr.Width(), tr.Height()); -} -TRect S60MediaPlayerSession::QRect2TRect(const QRect& qr) -{ - return TRect(TPoint(qr.left(), qr.top()), TSize(qr.width(), qr.height())); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.h deleted file mode 100644 index bb9eddd..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60MEDIAPLAYERSESSION_H -#define S60MEDIAPLAYERSESSION_H - -#include -#include -#include -#include -#include // for TDesC -#include -#include "s60mediaplayerservice.h" - -QT_BEGIN_NAMESPACE - -class QMediaTimeRange; - -class QTimer; - -class S60MediaPlayerSession : public QObject -{ - Q_OBJECT - -public: - S60MediaPlayerSession(QObject *parent); - virtual ~S60MediaPlayerSession(); - - // for player control interface to use - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; - qint64 duration() const; - qint64 position() const; - void setPosition(qint64 pos); - int volume() const; - void setVolume(int volume); - bool isMuted() const; - void setMuted(bool muted); - virtual bool isVideoAvailable() const = 0; - virtual bool isAudioAvailable() const = 0; - bool isSeekable() const; - void play(); - void pause(); - void stop(); - void reset(); - bool isMetadataAvailable() const; - QVariant metaData(const QString &key) const; - QMap availableMetaData() const; - void load(QUrl url); - int bufferStatus(); - virtual void setVideoRenderer(QObject *renderer); - void setMediaStatus(QMediaPlayer::MediaStatus); - void setState(QMediaPlayer::State state); - void setAudioEndpoint(const QString& audioEndpoint); - -protected: - virtual void doLoadL(const TDesC &path) = 0; - virtual void doLoadUrlL(const TDesC &path) = 0; - virtual void doPlay() = 0; - virtual void doStop() = 0; - virtual void doPauseL() = 0; - virtual void doSetVolumeL(int volume) = 0; - virtual void doSetPositionL(qint64 microSeconds) = 0; - virtual qint64 doGetPositionL() const = 0; - virtual void updateMetaDataEntriesL() = 0; - virtual int doGetBufferStatusL() const = 0; - virtual qint64 doGetDurationL() const = 0; - virtual void doSetAudioEndpoint(const QString& audioEndpoint) = 0; - -public: - // From S60MediaPlayerAudioEndpointSelector - virtual QString activeEndpoint() const = 0; - virtual QString defaultEndpoint() const = 0; -public Q_SLOTS: - virtual void setActiveEndpoint(const QString& name) = 0; - -protected: - void setError(int error, const QString &errorString = QString(), bool forceReset = false); - void loaded(); - void buffering(); - void buffered(); - void endOfMedia(); - QMap& metaDataEntries(); - QMediaPlayer::Error fromSymbianErrorToMultimediaError(int error); - void startProgressTimer(); - void stopProgressTimer(); - void startStalledTimer(); - void stopStalledTimer(); - QString TDesC2QString(const TDesC& aDescriptor); - TPtrC QString2TPtrC( const QString& string ); - QRect TRect2QRect(const TRect& tr); - TRect QRect2TRect(const QRect& qr); - - -protected slots: - void tick(); - void stalled(); - -signals: - void durationChanged(qint64 duration); - void positionChanged(qint64 position); - void stateChanged(QMediaPlayer::State state); - void mediaStatusChanged(QMediaPlayer::MediaStatus mediaStatus); - void videoAvailableChanged(bool videoAvailable); - void audioAvailableChanged(bool audioAvailable); - void bufferStatusChanged(int percentFilled); - void seekableChanged(bool); - void availablePlaybackRangesChanged(const QMediaTimeRange&); - void metaDataChanged(); - void error(int error, const QString &errorString); - void activeEndpointChanged(const QString &name); - -private: - qreal m_playbackRate; - QMap m_metaDataMap; - bool m_muted; - int m_volume; - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_mediaStatus; - QTimer *m_progressTimer; - QTimer *m_stalledTimer; - int m_error; - bool m_play_requested; - bool m_stream; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.cpp deleted file mode 100644 index b563dd9..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "S60mediarecognizer.h" -#include -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -static const TInt KMimeTypePrefixLength = 6; // "audio/" or "video/" -_LIT(KMimeTypePrefixAudio, "audio/"); -_LIT(KMimeTypePrefixVideo, "video/"); - -S60MediaRecognizer::S60MediaRecognizer(QObject *parent) : QObject(parent) -{ -} - -S60MediaRecognizer::~S60MediaRecognizer() -{ - m_file.Close(); - m_fileServer.Close(); - m_recognizer.Close(); -} - -S60MediaRecognizer::MediaType S60MediaRecognizer::mediaType(const QUrl &url) -{ - bool isStream = (url.scheme() == "file")?false:true; - - if (isStream) - return Url; - else - return identifyMediaType(url.toLocalFile()); -} - -S60MediaRecognizer::MediaType S60MediaRecognizer::identifyMediaType(const QString& fileName) -{ - S60MediaRecognizer::MediaType result = NotSupported; - bool recognizerOpened = false; - - TInt err = m_recognizer.Connect(); - if (err == KErrNone) { - recognizerOpened = true; - } - - err = m_fileServer.Connect(); - if (err == KErrNone) { - recognizerOpened = true; - } - - // This is needed for sharing file handles for the recognizer - err = m_fileServer.ShareProtected(); - if (err == KErrNone) { - recognizerOpened = true; - } - - if (recognizerOpened) { - m_file.Close(); - err = m_file.Open(m_fileServer, QString2TPtrC(QDir::toNativeSeparators(fileName)), EFileRead | - EFileShareReadersOnly); - - if (err == KErrNone) { - TDataRecognitionResult recognizerResult; - err = m_recognizer.RecognizeData(m_file, recognizerResult); - if (err == KErrNone) { - const TPtrC mimeType = recognizerResult.iDataType.Des(); - - if (mimeType.Left(KMimeTypePrefixLength).Compare(KMimeTypePrefixAudio) == 0) { - result = Audio; - } else if (mimeType.Left(KMimeTypePrefixLength).Compare(KMimeTypePrefixVideo) == 0) { - result = Video; - } - } - } - } - return result; -} - -TPtrC S60MediaRecognizer::QString2TPtrC( const QString& string ) -{ - // Returned TPtrC is valid as long as the given parameter is valid and unmodified - return TPtrC16(static_cast(string.utf16()), string.length()); -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.h deleted file mode 100644 index 320c34c..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60MEDIARECOGNIZER_H_ -#define S60MEDIARECOGNIZER_H_ - -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QUrl; - -class S60MediaRecognizer : public QObject -{ - Q_OBJECT - -public: - enum MediaType { - Audio, - Video, - Url, - NotSupported = -1 - }; - - S60MediaRecognizer(QObject *parent = 0); - ~S60MediaRecognizer(); - - S60MediaRecognizer::MediaType mediaType(const QUrl &url); - S60MediaRecognizer::MediaType identifyMediaType(const QString& fileName); - -protected: - TPtrC QString2TPtrC( const QString& string ); - -private: - RApaLsSession m_recognizer; - RFile m_file; - RFs m_fileServer; -}; - -QT_END_NAMESPACE - -#endif /* S60MEDIARECOGNIZER_H_ */ diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.cpp deleted file mode 100644 index 489b2e3..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60videooverlay.h" -#include "s60videosurface.h" - -QT_BEGIN_NAMESPACE - -S60VideoOverlay::S60VideoOverlay(QObject *parent) - : QVideoWindowControl(parent) - , m_surface(new S60VideoSurface) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_fullScreen(false) -{ - connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SLOT(surfaceFormatChanged())); -} - -S60VideoOverlay::~S60VideoOverlay() -{ - delete m_surface; -} - -WId S60VideoOverlay::winId() const -{ - return m_surface->winId(); -} - -void S60VideoOverlay::setWinId(WId id) -{ - m_surface->setWinId(id); -} - -QRect S60VideoOverlay::displayRect() const -{ - return m_displayRect; -} - -void S60VideoOverlay::setDisplayRect(const QRect &rect) -{ - m_displayRect = rect; - - setScaledDisplayRect(); -} - -Qt::AspectRatioMode S60VideoOverlay::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void S60VideoOverlay::setAspectRatioMode(Qt::AspectRatioMode ratio) -{ - m_aspectRatioMode = ratio; - - setScaledDisplayRect(); -} - -QSize S60VideoOverlay::customAspectRatio() const -{ - return m_aspectRatio; -} - -void S60VideoOverlay::setCustomAspectRatio(const QSize &customRatio) -{ - m_aspectRatio = customRatio; - - setScaledDisplayRect(); -} - -void S60VideoOverlay::repaint() -{ -} - -int S60VideoOverlay::brightness() const -{ - return m_surface->brightness(); -} - -void S60VideoOverlay::setBrightness(int brightness) -{ - m_surface->setBrightness(brightness); - - emit brightnessChanged(m_surface->brightness()); -} - -int S60VideoOverlay::contrast() const -{ - return m_surface->contrast(); -} - -void S60VideoOverlay::setContrast(int contrast) -{ - m_surface->setContrast(contrast); - - emit contrastChanged(m_surface->contrast()); -} - -int S60VideoOverlay::hue() const -{ - return m_surface->hue(); -} - -void S60VideoOverlay::setHue(int hue) -{ - m_surface->setHue(hue); - - emit hueChanged(m_surface->hue()); -} - -int S60VideoOverlay::saturation() const -{ - return m_surface->saturation(); -} - -void S60VideoOverlay::setSaturation(int saturation) -{ - m_surface->setSaturation(saturation); - - emit saturationChanged(m_surface->saturation()); -} - -bool S60VideoOverlay::isFullScreen() const -{ - return m_fullScreen; -} - -void S60VideoOverlay::setFullScreen(bool fullScreen) -{ - emit fullScreenChanged(m_fullScreen = fullScreen); -} - -QSize S60VideoOverlay::nativeSize() const -{ - return m_surface->surfaceFormat().sizeHint(); -} - -QAbstractVideoSurface *S60VideoOverlay::surface() const -{ - return m_surface; -} - -void S60VideoOverlay::surfaceFormatChanged() -{ - setScaledDisplayRect(); - - emit nativeSizeChanged(); -} - -void S60VideoOverlay::setScaledDisplayRect() -{ - switch (m_aspectRatioMode) { - case Qt::KeepAspectRatio: - { - QSize size = m_surface->surfaceFormat().viewport().size(); - - size.scale(m_displayRect.size(), Qt::KeepAspectRatio); - - QRect rect(QPoint(0, 0), size); - rect.moveCenter(m_displayRect.center()); - - m_surface->setDisplayRect(rect); - } - break; - case Qt::IgnoreAspectRatio: - m_surface->setDisplayRect(m_displayRect); - break; - }; -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.h deleted file mode 100644 index d846f32..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60VIDEOOVERLAY_H -#define S60VIDEOOVERLAY_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QAbstractVideoSurface; -class S60VideoSurface; - -class S60VideoOverlay : public QVideoWindowControl -{ - Q_OBJECT - -public: - S60VideoOverlay(QObject *parent = 0); - ~S60VideoOverlay(); - - WId winId() const; - void setWinId(WId id); - - QRect displayRect() const; - void setDisplayRect(const QRect &rect); - - bool isFullScreen() const; - void setFullScreen(bool fullScreen); - - QSize nativeSize() const; - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - QSize customAspectRatio() const; - void setCustomAspectRatio(const QSize &customRatio); - - void repaint(); - - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); - - QAbstractVideoSurface *surface() const; - -private slots: - void surfaceFormatChanged(); - -private: - void setScaledDisplayRect(); - - S60VideoSurface *m_surface; - Qt::AspectRatioMode m_aspectRatioMode; - QRect m_displayRect; - QSize m_aspectRatio; - bool m_fullScreen; -}; - -QT_END_NAMESPACE - -#endif // S60VIDEOOVERLAY_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.cpp deleted file mode 100644 index 134d5a0..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.cpp +++ /dev/null @@ -1,486 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60videoplayersession.h" -#include "s60videowidget.h" -#include "s60mediaplayerservice.h" -#include "s60videooverlay.h" - -#include -#include -#include -#include - -#include -#include // For CCoeEnv -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -S60VideoPlayerSession::S60VideoPlayerSession(QMediaService *service) - : S60MediaPlayerSession(service) - , m_player(0) - , m_rect(0, 0, 0, 0) - , m_output(QVideoOutputControl::NoOutput) - , m_windowId(0) - , m_dsaActive(false) - , m_dsaStopped(false) - , m_wsSession(CCoeEnv::Static()->WsSession()) - , m_screenDevice(*CCoeEnv::Static()->ScreenDevice()) - , m_window(0) - , m_service(*service) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_originalSize(1, 1) - , m_audioOutput(0) - , m_audioEndpoint("Default") -{ - resetNativeHandles(); - QT_TRAP_THROWING(m_player = CVideoPlayerUtility::NewL( - *this, - 0, - EMdaPriorityPreferenceNone, - m_wsSession, - m_screenDevice, - *m_window, - m_rect, - m_rect)); - m_dsaActive = true; - m_player->RegisterForVideoLoadingNotification(*this); -} - -S60VideoPlayerSession::~S60VideoPlayerSession() -{ -#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) - if (m_audioOutput) - m_audioOutput->UnregisterObserver(*this); - delete m_audioOutput; -#endif - m_player->Close(); - delete m_player; -} - -void S60VideoPlayerSession::doLoadL(const TDesC &path) -{ - // m_audioOutput needs to be reinitialized after MapcInitComplete - if (m_audioOutput) - m_audioOutput->UnregisterObserver(*this); - delete m_audioOutput; - m_audioOutput = NULL; - - m_player->OpenFileL(path); -} - -void S60VideoPlayerSession::doLoadUrlL(const TDesC &path) -{ - // m_audioOutput needs to be reinitialized after MapcInitComplete - if (m_audioOutput) - m_audioOutput->UnregisterObserver(*this); - delete m_audioOutput; - m_audioOutput = NULL; - - m_player->OpenUrlL(path); -} - -int S60VideoPlayerSession::doGetBufferStatusL() const -{ - int progress = 0; - m_player->GetVideoLoadingProgressL(progress); - return progress; -} - -qint64 S60VideoPlayerSession::doGetDurationL() const -{ - return m_player->DurationL().Int64() / qint64(1000); -} - -void S60VideoPlayerSession::setVideoRenderer(QObject *videoOutput) -{ - Q_UNUSED(videoOutput) - QVideoOutputControl *videoControl = qobject_cast(m_service.control(QVideoOutputControl_iid)); - - //Render changes - if (m_output != videoControl->output()) { - - if (m_output == QVideoOutputControl::WidgetOutput) { - S60VideoWidgetControl *widgetControl = qobject_cast(m_service.control(QVideoWidgetControl_iid)); - disconnect(widgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay())); - disconnect(widgetControl, SIGNAL(beginVideoWindowNativePaint()), this, SLOT(suspendDirectScreenAccess())); - disconnect(widgetControl, SIGNAL(endVideoWindowNativePaint()), this, SLOT(resumeDirectScreenAccess())); - disconnect(this, SIGNAL(stateChanged(QMediaPlayer::State)), widgetControl, SLOT(videoStateChanged(QMediaPlayer::State))); - } - - if (videoControl->output() == QVideoOutputControl::WidgetOutput) { - S60VideoWidgetControl *widgetControl = qobject_cast(m_service.control(QVideoWidgetControl_iid)); - connect(widgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay())); - connect(widgetControl, SIGNAL(beginVideoWindowNativePaint()), this, SLOT(suspendDirectScreenAccess())); - connect(widgetControl, SIGNAL(endVideoWindowNativePaint()), this, SLOT(resumeDirectScreenAccess())); - connect(this, SIGNAL(stateChanged(QMediaPlayer::State)), widgetControl, SLOT(videoStateChanged(QMediaPlayer::State))); - } - - m_output = videoControl->output(); - resetVideoDisplay(); - } -} - -bool S60VideoPlayerSession::resetNativeHandles() -{ - QVideoOutputControl* videoControl = qobject_cast(m_service.control(QVideoOutputControl_iid)); - WId newId = 0; - TRect newRect = TRect(0,0,0,0); - Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio; - - if (videoControl->output() == QVideoOutputControl::WidgetOutput) { - S60VideoWidgetControl* widgetControl = qobject_cast(m_service.control(QVideoWidgetControl_iid)); - QWidget *videoWidget = widgetControl->videoWidget(); - newId = widgetControl->videoWidgetWId(); - newRect = QRect2TRect(QRect(videoWidget->mapToGlobal(videoWidget->pos()), videoWidget->size())); - aspectRatioMode = widgetControl->aspectRatioMode(); - } else if (videoControl->output() == QVideoOutputControl::WindowOutput) { - S60VideoOverlay* windowControl = qobject_cast(m_service.control(QVideoWindowControl_iid)); - newId = windowControl->winId(); - newRect = TRect( newId->DrawableWindow()->AbsPosition(), newId->DrawableWindow()->Size()); - } else { - if (QApplication::activeWindow()) - newId = QApplication::activeWindow()->effectiveWinId(); - - if (!newId && QApplication::allWidgets().count()) - newId = QApplication::allWidgets().at(0)->effectiveWinId(); - - Q_ASSERT(newId != 0); - } - - if (newRect == m_rect && newId == m_windowId && aspectRatioMode == m_aspectRatioMode) - return false; - - if (newId) { - m_rect = newRect; - m_windowId = newId; - m_window = m_windowId->DrawableWindow(); - m_aspectRatioMode = aspectRatioMode; - return true; - } - return false; -} - -bool S60VideoPlayerSession::isVideoAvailable() const -{ -#ifdef PRE_S60_50_PLATFORM - return true; // this is not support in pre 5th platforms -#else - if (m_player) - return m_player->VideoEnabledL(); - else - return false; -#endif -} - -bool S60VideoPlayerSession::isAudioAvailable() const -{ - if (m_player) - return m_player->AudioEnabledL(); - else - return false; -} - -void S60VideoPlayerSession::doPlay() -{ - m_player->Play(); -} - -void S60VideoPlayerSession::doPauseL() -{ - m_player->PauseL(); -} - -void S60VideoPlayerSession::doStop() -{ - m_player->Stop(); -} - -qint64 S60VideoPlayerSession::doGetPositionL() const -{ - return m_player->PositionL().Int64() / qint64(1000); -} - -void S60VideoPlayerSession::doSetPositionL(qint64 microSeconds) -{ - m_player->SetPositionL(TTimeIntervalMicroSeconds(microSeconds)); -} - -void S60VideoPlayerSession::doSetVolumeL(int volume) -{ - m_player->SetVolumeL((volume / 100.0)* m_player->MaxVolume()); -} - -QPair S60VideoPlayerSession::scaleFactor() -{ - QSize scaled = m_originalSize; - if (m_aspectRatioMode == Qt::IgnoreAspectRatio) - scaled.scale(TRect2QRect(m_rect).size(), Qt::IgnoreAspectRatio); - else if(m_aspectRatioMode == Qt::KeepAspectRatio) - scaled.scale(TRect2QRect(m_rect).size(), Qt::KeepAspectRatio); - - qreal width = qreal(scaled.width()) / qreal(m_originalSize.width()) * qreal(100); - qreal height = qreal(scaled.height()) / qreal(m_originalSize.height()) * qreal(100); - - return QPair(width, height); -} - -void S60VideoPlayerSession::startDirectScreenAccess() -{ - if(m_dsaActive) - return; - - TRAPD(err, m_player->StartDirectScreenAccessL()); - if(err == KErrNone) - m_dsaActive = true; - setError(err); -} - -bool S60VideoPlayerSession::stopDirectScreenAccess() -{ - if(!m_dsaActive) - return false; - - TRAPD(err, m_player->StopDirectScreenAccessL()); - if(err == KErrNone) - m_dsaActive = false; - - setError(err); - return true; -} - -void S60VideoPlayerSession::MvpuoOpenComplete(TInt aError) -{ - setError(aError); - m_player->Prepare(); -} - -void S60VideoPlayerSession::MvpuoPrepareComplete(TInt aError) -{ - setError(aError); - TRAPD(err, - m_player->SetDisplayWindowL(m_wsSession, - m_screenDevice, - *m_window, - m_rect, - m_rect); - TSize originalSize; - m_player->VideoFrameSizeL(originalSize); - m_originalSize = QSize(originalSize.iWidth, originalSize.iHeight); - m_player->SetScaleFactorL(scaleFactor().first, scaleFactor().second, true)); - - setError(err); - m_dsaActive = true; -#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) - TRAP(err, - m_audioOutput = CAudioOutput::NewL(*m_player); - m_audioOutput->RegisterObserverL(*this); - ); - setActiveEndpoint(m_audioEndpoint); - setError(err); -#endif - loaded(); -} - -void S60VideoPlayerSession::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) -{ - Q_UNUSED(aFrame); - Q_UNUSED(aError); -} - -void S60VideoPlayerSession::MvpuoPlayComplete(TInt aError) -{ - setError(aError); - endOfMedia(); -} - -void S60VideoPlayerSession::MvpuoEvent(const TMMFEvent &aEvent) -{ - Q_UNUSED(aEvent); -} - -void S60VideoPlayerSession::updateMetaDataEntriesL() -{ - metaDataEntries().clear(); - int numberOfMetaDataEntries = 0; - - numberOfMetaDataEntries = m_player->NumberOfMetaDataEntriesL(); - - for (int i = 0; i < numberOfMetaDataEntries; i++) { - CMMFMetaDataEntry *entry = NULL; - entry = m_player->MetaDataEntryL(i); - metaDataEntries().insert(TDesC2QString(entry->Name()), TDesC2QString(entry->Value())); - delete entry; - } - emit metaDataChanged(); -} - -void S60VideoPlayerSession::resetVideoDisplay() -{ - if (resetNativeHandles()) { - TRAPD(err, - m_player->SetDisplayWindowL(m_wsSession, - m_screenDevice, - *m_window, - m_rect, - m_rect)); - setError(err); - if( mediaStatus() == QMediaPlayer::LoadedMedia - || mediaStatus() == QMediaPlayer::StalledMedia - || mediaStatus() == QMediaPlayer::BufferingMedia - || mediaStatus() == QMediaPlayer::BufferedMedia - || mediaStatus() == QMediaPlayer::EndOfMedia) { - TRAPD(err, m_player->SetScaleFactorL(scaleFactor().first, scaleFactor().second, true)); - setError(err); - } - } -} - -void S60VideoPlayerSession::suspendDirectScreenAccess() -{ - m_dsaStopped = stopDirectScreenAccess(); -} - -void S60VideoPlayerSession::resumeDirectScreenAccess() -{ - if(!m_dsaStopped) - return; - - startDirectScreenAccess(); - m_dsaStopped = false; -} - -void S60VideoPlayerSession::MvloLoadingStarted() -{ - buffering(); -} - -void S60VideoPlayerSession::MvloLoadingComplete() -{ - buffered(); -} - -void S60VideoPlayerSession::doSetAudioEndpoint(const QString& audioEndpoint) -{ - m_audioEndpoint = audioEndpoint; -} - -QString S60VideoPlayerSession::activeEndpoint() const -{ - QString outputName = QString("Default"); -#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) - if (m_audioOutput) { - CAudioOutput::TAudioOutputPreference output = m_audioOutput->AudioOutput(); - outputName = qStringFromTAudioOutputPreference(output); - } -#endif - return outputName; -} - -QString S60VideoPlayerSession::defaultEndpoint() const -{ - QString outputName = QString("Default"); -#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) - if (m_audioOutput) { - CAudioOutput::TAudioOutputPreference output = m_audioOutput->DefaultAudioOutput(); - outputName = qStringFromTAudioOutputPreference(output); - } -#endif - return outputName; -} - -void S60VideoPlayerSession::setActiveEndpoint(const QString& name) -{ - CAudioOutput::TAudioOutputPreference output = CAudioOutput::ENoPreference; - - if (name == QString("Default")) - output = CAudioOutput::ENoPreference; - else if (name == QString("All")) - output = CAudioOutput::EAll; - else if (name == QString("None")) - output = CAudioOutput::ENoOutput; - else if (name == QString("Earphone")) - output = CAudioOutput::EPrivate; - else if (name == QString("Speaker")) - output = CAudioOutput::EPublic; -#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) - if (m_audioOutput) { - TRAPD(err, m_audioOutput->SetAudioOutputL(output)); - setError(err); - - if (m_audioEndpoint != name) { - m_audioEndpoint = name; - emit activeEndpointChanged(name); - } - } -#endif -} - -void S60VideoPlayerSession::DefaultAudioOutputChanged( CAudioOutput& aAudioOutput, - CAudioOutput::TAudioOutputPreference aNewDefault ) -{ - // Emit already implemented in setActiveEndpoint function - Q_UNUSED(aAudioOutput) - Q_UNUSED(aNewDefault) -} - -QString S60VideoPlayerSession::qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const -{ - if (output == CAudioOutput::ENoPreference) - return QString("Default"); - else if (output == CAudioOutput::EAll) - return QString("All"); - else if (output == CAudioOutput::ENoOutput) - return QString("None"); - else if (output == CAudioOutput::EPrivate) - return QString("Earphone"); - else if (output == CAudioOutput::EPublic) - return QString("Speaker"); - return QString("Default"); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h deleted file mode 100644 index 52e311a..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60VIDEOPLAYERSESSION_H -#define S60VIDEOPLAYERSESSION_H - -#include "s60mediaplayersession.h" -#include "s60mediaplayeraudioendpointselector.h" -#include -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QTimer; - -class S60VideoPlayerSession : public S60MediaPlayerSession, - public MVideoPlayerUtilityObserver, - public MVideoLoadingObserver, - public MAudioOutputObserver -{ - Q_OBJECT - -public: - S60VideoPlayerSession(QMediaService *service); - ~S60VideoPlayerSession(); - - //From S60MediaPlayerSession - bool isVideoAvailable() const; - bool isAudioAvailable() const; - void setVideoRenderer(QObject *renderer); - - //From MVideoLoadingObserver - void MvloLoadingStarted(); - void MvloLoadingComplete(); - - // From MAudioOutputObserver - void DefaultAudioOutputChanged(CAudioOutput& aAudioOutput, - CAudioOutput::TAudioOutputPreference aNewDefault); - -public: - // From S60MediaPlayerAudioEndpointSelector - QString activeEndpoint() const; - QString defaultEndpoint() const; -public Q_SLOTS: - void setActiveEndpoint(const QString& name); -Q_SIGNALS: - void activeEndpointChanged(const QString &name); - -protected: - //From S60MediaPlayerSession - void doLoadL(const TDesC &path); - void doLoadUrlL(const TDesC &path); - void doPlay(); - void doStop(); - void doPauseL(); - void doSetVolumeL(int volume); - qint64 doGetPositionL() const; - void doSetPositionL(qint64 microSeconds); - void updateMetaDataEntriesL(); - int doGetBufferStatusL() const; - qint64 doGetDurationL() const; - void doSetAudioEndpoint(const QString& audioEndpoint); - -private slots: - void resetVideoDisplay(); - void suspendDirectScreenAccess(); - void resumeDirectScreenAccess(); - -private: - bool resetNativeHandles(); - QPair scaleFactor(); - void startDirectScreenAccess(); - bool stopDirectScreenAccess(); - QString qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const; - - - // From MVideoPlayerUtilityObserver - void MvpuoOpenComplete(TInt aError); - void MvpuoPrepareComplete(TInt aError); - void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); - void MvpuoPlayComplete(TInt aError); - void MvpuoEvent(const TMMFEvent &aEvent); - -private: - // Qwn - CVideoPlayerUtility *m_player; - TRect m_rect; - QVideoOutputControl::Output m_output; - WId m_windowId; - bool m_dsaActive; - bool m_dsaStopped; - - //Reference - RWsSession &m_wsSession; - CWsScreenDevice &m_screenDevice; - RWindowBase *m_window; - QMediaService &m_service; - Qt::AspectRatioMode m_aspectRatioMode; - QSize m_originalSize; - CAudioOutput *m_audioOutput; - QString m_audioEndpoint; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.cpp deleted file mode 100644 index 269dd43..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60videorenderer.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -S60VideoRenderer::S60VideoRenderer(QObject *parent) - : QVideoRendererControl(parent) -{ -} - -S60VideoRenderer::~S60VideoRenderer() -{ -} - - -QAbstractVideoSurface *S60VideoRenderer::surface() const -{ - return m_surface; -} - -void S60VideoRenderer::setSurface(QAbstractVideoSurface *surface) -{ - m_surface = surface; -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.h deleted file mode 100644 index 260dc8b..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60VIDEORENDERER_H -#define S60VIDEORENDERER_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class S60VideoRenderer : public QVideoRendererControl -{ - Q_OBJECT - -public: - S60VideoRenderer(QObject *parent = 0); - virtual ~S60VideoRenderer(); - - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); - -private: - - QAbstractVideoSurface *m_surface; -}; - -QT_END_NAMESPACE - -#endif // S60VIDEORENDERER_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.cpp deleted file mode 100644 index bfa7a13..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.cpp +++ /dev/null @@ -1,478 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60videosurface.h" - -QT_BEGIN_NAMESPACE - -/*struct XvFormatRgb -{ - QVideoFrame::PixelFormat pixelFormat; - int bits_per_pixel; - int format; - int num_planes; - - int depth; - unsigned int red_mask; - unsigned int green_mask; - unsigned int blue_mask; - -};*/ -/* -bool operator ==(const XvImageFormatValues &format, const XvFormatRgb &rgb) -{ - return format.type == XvRGB - && format.bits_per_pixel == rgb.bits_per_pixel - && format.format == rgb.format - && format.num_planes == rgb.num_planes - && format.depth == rgb.depth - && format.red_mask == rgb.red_mask - && format.blue_mask == rgb.blue_mask; -} - -static const XvFormatRgb qt_xvRgbLookup[] = -{ - { QVideoFrame::Format_ARGB32, 32, XvPacked, 1, 32, 0x00FF0000, 0x0000FF00, 0x000000FF }, - { QVideoFrame::Format_RGB32 , 32, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, - { QVideoFrame::Format_RGB24 , 24, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, - { QVideoFrame::Format_RGB565, 16, XvPacked, 1, 16, 0x0000F800, 0x000007E0, 0x0000001F }, - { QVideoFrame::Format_BGRA32, 32, XvPacked, 1, 32, 0xFF000000, 0x00FF0000, 0x0000FF00 }, - { QVideoFrame::Format_BGR32 , 32, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, - { QVideoFrame::Format_BGR24 , 24, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, - { QVideoFrame::Format_BGR565, 16, XvPacked, 1, 16, 0x0000F800, 0x000007E0, 0x0000001F } -}; - -struct XvFormatYuv -{ - QVideoFrame::PixelFormat pixelFormat; - int bits_per_pixel; - int format; - int num_planes; - - unsigned int y_sample_bits; - unsigned int u_sample_bits; - unsigned int v_sample_bits; - unsigned int horz_y_period; - unsigned int horz_u_period; - unsigned int horz_v_period; - unsigned int vert_y_period; - unsigned int vert_u_period; - unsigned int vert_v_period; - char component_order[32]; -}; - -bool operator ==(const XvImageFormatValues &format, const XvFormatYuv &yuv) -{ - return format.type == XvYUV - && format.bits_per_pixel == yuv.bits_per_pixel - && format.format == yuv.format - && format.num_planes == yuv.num_planes - && format.y_sample_bits == yuv.y_sample_bits - && format.u_sample_bits == yuv.u_sample_bits - && format.v_sample_bits == yuv.v_sample_bits - && format.horz_y_period == yuv.horz_y_period - && format.horz_u_period == yuv.horz_u_period - && format.horz_v_period == yuv.horz_v_period - && format.horz_y_period == yuv.vert_y_period - && format.vert_u_period == yuv.vert_u_period - && format.vert_v_period == yuv.vert_v_period - && qstrncmp(format.component_order, yuv.component_order, 32) == 0; -} - -static const XvFormatYuv qt_xvYuvLookup[] = -{ - { QVideoFrame::Format_YUV444 , 24, XvPacked, 1, 8, 8, 8, 1, 1, 1, 1, 1, 1, "YUV" }, - { QVideoFrame::Format_YUV420P, 12, XvPlanar, 3, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YUV" }, - { QVideoFrame::Format_YV12 , 12, XvPlanar, 3, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YVU" }, - { QVideoFrame::Format_UYVY , 16, XvPacked, 1, 8, 8, 8, 1, 2, 2, 1, 1, 1, "UYVY" }, - { QVideoFrame::Format_YUYV , 16, XvPacked, 1, 8, 8, 8, 1, 2, 2, 1, 1, 1, "YUYV" }, - { QVideoFrame::Format_NV12 , 12, XvPlanar, 2, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YUV" }, - { QVideoFrame::Format_NV12 , 12, XvPlanar, 2, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YVU" }, - { QVideoFrame::Format_Y8 , 8 , XvPlanar, 1, 8, 0, 0, 1, 0, 0, 1, 0, 0, "Y" } -}; -*/ - -S60VideoSurface::S60VideoSurface(QObject *parent) - : QAbstractVideoSurface(parent) - , m_winId(0) - //, m_portId(0) - //, m_gc(0) - //, m_image(0) -{ -} - -S60VideoSurface::~S60VideoSurface() -{ - /*if (m_gc) - XFreeGC(QX11Info::display(), m_gc); - - if (m_portId != 0) - XvUngrabPort(QX11Info::display(), m_portId, 0); - */ -} - -WId S60VideoSurface::winId() const -{ - return m_winId; -} - -void S60VideoSurface::setWinId(WId id) -{ - /*if (id == m_winId) - return; - - if (m_image) - XFree(m_image); - - if (m_gc) { - XFreeGC(QX11Info::display(), m_gc); - m_gc = 0; - } - - if (m_portId != 0) - XvUngrabPort(QX11Info::display(), m_portId, 0); - - m_supportedPixelFormats.clear(); - m_formatIds.clear(); - - m_winId = id; - - if (m_winId && findPort()) { - querySupportedFormats(); - - m_gc = XCreateGC(QX11Info::display(), m_winId, 0, 0); - - if (m_image) { - m_image = 0; - - if (!start(surfaceFormat())) - QAbstractVideoSurface::stop(); - } - } else if (m_image) { - m_image = 0; - - QAbstractVideoSurface::stop(); - }*/ -} - -QRect S60VideoSurface::displayRect() const -{ - return m_displayRect; -} - -void S60VideoSurface::setDisplayRect(const QRect &rect) -{ - m_displayRect = rect; -} - -int S60VideoSurface::brightness() const -{ - //return getAttribute("XV_BRIGHTNESS", m_brightnessRange.first, m_brightnessRange.second); -} - -void S60VideoSurface::setBrightness(int brightness) -{ - //setAttribute("XV_BRIGHTNESS", brightness, m_brightnessRange.first, m_brightnessRange.second); -} - -int S60VideoSurface::contrast() const -{ - //return getAttribute("XV_CONTRAST", m_contrastRange.first, m_contrastRange.second); -} - -void S60VideoSurface::setContrast(int contrast) -{ - //setAttribute("XV_CONTRAST", contrast, m_contrastRange.first, m_contrastRange.second); -} - -int S60VideoSurface::hue() const -{ - //return getAttribute("XV_HUE", m_hueRange.first, m_hueRange.second); -} - -void S60VideoSurface::setHue(int hue) -{ - // setAttribute("XV_HUE", hue, m_hueRange.first, m_hueRange.second); -} - -int S60VideoSurface::saturation() const -{ - //return getAttribute("XV_SATURATION", m_saturationRange.first, m_saturationRange.second); -} - -void S60VideoSurface::setSaturation(int saturation) -{ - //setAttribute("XV_SATURATION", saturation, m_saturationRange.first, m_saturationRange.second); -} - -int S60VideoSurface::getAttribute(const char *attribute, int minimum, int maximum) const -{ - /*if (m_portId != 0) { - Display *display = QX11Info::display(); - - Atom atom = XInternAtom(display, attribute, True); - - int value = 0; - - XvGetPortAttribute(display, m_portId, atom, &value); - - return redistribute(value, minimum, maximum, -100, 100); - } else { - return 0; - }*/ -} - -void S60VideoSurface::setAttribute(const char *attribute, int value, int minimum, int maximum) -{ - /* if (m_portId != 0) { - Display *display = QX11Info::display(); - - Atom atom = XInternAtom(display, attribute, True); - - XvSetPortAttribute( - display, m_portId, atom, redistribute(value, -100, 100, minimum, maximum)); - }*/ -} - -int S60VideoSurface::redistribute( - int value, int fromLower, int fromUpper, int toLower, int toUpper) -{ - /*return fromUpper != fromLower - ? ((value - fromLower) * (toUpper - toLower) / (fromUpper - fromLower)) + toLower - : 0;*/ -} - -QList S60VideoSurface::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - /*return handleType == QAbstractVideoBuffer::NoHandle - ? m_supportedPixelFormats - : QList();*/ -} - -bool S60VideoSurface::start(const QVideoSurfaceFormat &format) -{ - /*if (m_image) - XFree(m_image); - - int xvFormatId = 0; - for (int i = 0; i < m_supportedPixelFormats.count(); ++i) { - if (m_supportedPixelFormats.at(i) == format.pixelFormat()) { - xvFormatId = m_formatIds.at(i); - break; - } - } - - if (xvFormatId == 0) { - setError(UnsupportedFormatError); - } else { - XvImage *image = XvCreateImage( - QX11Info::display(), - m_portId, - xvFormatId, - 0, - format.frameWidth(), - format.frameHeight()); - - if (!image) { - setError(ResourceError); - } else { - m_viewport = format.viewport(); - m_image = image; - - return QAbstractVideoSurface::start(format); - } - } - - if (m_image) { - m_image = 0; - - QAbstractVideoSurface::stop(); - } -*/ - return false; -} - -void S60VideoSurface::stop() -{/* - if (m_image) { - XFree(m_image); - m_image = 0; - - QAbstractVideoSurface::stop(); - }*/ -} - -bool S60VideoSurface::present(const QVideoFrame &frame) -{/* - if (!m_image) { - setError(StoppedError); - return false; - } else if (m_image->width != frame.width() || m_image->height != frame.height()) { - setError(IncorrectFormatError); - return false; - } else { - QVideoFrame frameCopy(frame); - - if (!frameCopy.map(QAbstractVideoBuffer::ReadOnly)) { - setError(IncorrectFormatError); - return false; - } else { - bool presented = false; - - if (m_image->data_size > frame.numBytes()) { - qWarning("Insufficient frame buffer size"); - setError(IncorrectFormatError); - } else if (m_image->num_planes > 0 && m_image->pitches[0] != frame.bytesPerLine()) { - qWarning("Incompatible frame pitches"); - setError(IncorrectFormatError); - } else { - m_image->data = reinterpret_cast(frameCopy.bits()); - - XvPutImage( - QX11Info::display(), - m_portId, - m_winId, - m_gc, - m_image, - m_viewport.x(), - m_viewport.y(), - m_viewport.width(), - m_viewport.height(), - m_displayRect.x(), - m_displayRect.y(), - m_displayRect.width(), - m_displayRect.height()); - - m_image->data = 0; - - presented = true; - } - - frameCopy.unmap(); - - return presented; - } - }*/ -} - -bool S60VideoSurface::findPort() -{/* - unsigned int count = 0; - XvAdaptorInfo *adaptors = 0; - bool portFound = false; - - if (XvQueryAdaptors(QX11Info::display(), m_winId, &count, &adaptors) == Success) { - for (unsigned int i = 0; i < count && !portFound; ++i) { - if (adaptors[i].type & XvImageMask) { - m_portId = adaptors[i].base_id; - - for (unsigned int j = 0; j < adaptors[i].num_ports && !portFound; ++j, ++m_portId) - portFound = XvGrabPort(QX11Info::display(), m_portId, 0) == Success; - } - } - XvFreeAdaptorInfo(adaptors); - } - - return portFound;*/ -} - -void S60VideoSurface::querySupportedFormats() -{/* - int count = 0; - if (XvImageFormatValues *imageFormats = XvListImageFormats( - QX11Info::display(), m_portId, &count)) { - const int rgbCount = sizeof(qt_xvRgbLookup) / sizeof(XvFormatRgb); - const int yuvCount = sizeof(qt_xvYuvLookup) / sizeof(XvFormatYuv); - - for (int i = 0; i < count; ++i) { - switch (imageFormats[i].type) { - case XvRGB: - for (int j = 0; j < rgbCount; ++j) { - if (imageFormats[i] == qt_xvRgbLookup[j]) { - m_supportedPixelFormats.append(qt_xvRgbLookup[j].pixelFormat); - m_formatIds.append(imageFormats[i].id); - break; - } - } - break; - case XvYUV: - for (int j = 0; j < yuvCount; ++j) { - if (imageFormats[i] == qt_xvYuvLookup[j]) { - m_supportedPixelFormats.append(qt_xvYuvLookup[j].pixelFormat); - m_formatIds.append(imageFormats[i].id); - break; - } - } - break; - } - } - XFree(imageFormats); - } - - m_brightnessRange = qMakePair(0, 0); - m_contrastRange = qMakePair(0, 0); - m_hueRange = qMakePair(0, 0); - m_saturationRange = qMakePair(0, 0); - - if (XvAttribute *attributes = XvQueryPortAttributes(QX11Info::display(), m_portId, &count)) { - for (int i = 0; i < count; ++i) { - if (qstrcmp(attributes[i].name, "XV_BRIGHTNESS") == 0) - m_brightnessRange = qMakePair(attributes[i].min_value, attributes[i].max_value); - else if (qstrcmp(attributes[i].name, "XV_CONTRAST") == 0) - m_contrastRange = qMakePair(attributes[i].min_value, attributes[i].max_value); - else if (qstrcmp(attributes[i].name, "XV_HUE") == 0) - m_hueRange = qMakePair(attributes[i].min_value, attributes[i].max_value); - else if (qstrcmp(attributes[i].name, "XV_SATURATION") == 0) - m_saturationRange = qMakePair(attributes[i].min_value, attributes[i].max_value); - } - - XFree(attributes); - }*/ -} - -bool S60VideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const -{ -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.h deleted file mode 100644 index 836e52f..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60VIDEOSURFACE_H -#define S60VIDEOSURFACE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QVideoSurfaceFormat; - -class S60VideoSurface : public QAbstractVideoSurface -{ - Q_OBJECT -public: - S60VideoSurface(QObject *parent = 0); - ~S60VideoSurface(); - - WId winId() const; - void setWinId(WId id); - - QRect displayRect() const; - void setDisplayRect(const QRect &rect); - - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); - - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; - - bool isFormatSupported(const QVideoSurfaceFormat &format) const; - - bool start(const QVideoSurfaceFormat &format); - void stop(); - - bool present(const QVideoFrame &frame); - -private: - WId m_winId; - //XvPortID m_portId; - //GC m_gc; - //XvImage *m_image; - QList m_supportedPixelFormats; - QVector m_formatIds; - QRect m_viewport; - QRect m_displayRect; - QPair m_brightnessRange; - QPair m_contrastRange; - QPair m_hueRange; - QPair m_saturationRange; - - bool findPort(); - void querySupportedFormats(); - - int getAttribute(const char *attribute, int minimum, int maximum) const; - void setAttribute(const char *attribute, int value, int minimum, int maximum); - - static int redistribute(int value, int fromLower, int fromUpper, int toLower, int toUpper); -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.cpp deleted file mode 100644 index 84000d5..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60videowidget.h" -#include -#include -#include // For CCoeEnv - -QT_BEGIN_NAMESPACE - -QBlackWidget::QBlackWidget(QWidget *parent) - : QWidget(parent) -{ - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - setAttribute(Qt::WA_OpaquePaintEvent, true); - setAttribute(Qt::WA_NoSystemBackground, true); - setAutoFillBackground(false); - setPalette(QPalette(Qt::black)); -#if QT_VERSION >= 0x040601 && !defined(__WINSCW__) - qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill; - qt_widget_private(this)->extraData()->receiveNativePaintEvents = true; -#endif -} - -QBlackWidget::~QBlackWidget() -{ -} - -void QBlackWidget::beginNativePaintEvent(const QRect& /*controlRect*/) -{ - emit beginVideoWindowNativePaint(); -} - -void QBlackWidget::endNativePaintEvent(const QRect& /*controlRect*/) -{ - CCoeEnv::Static()->WsSession().Flush(); - emit endVideoWindowNativePaint(); -} - -void QBlackWidget::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - // Do nothing -} - -S60VideoWidgetControl::S60VideoWidgetControl(QObject *parent) - : QVideoWidgetControl(parent) - , m_widget(0) - , m_aspectRatioMode(Qt::KeepAspectRatio) -{ - m_widget = new QBlackWidget(); - connect(m_widget, SIGNAL(beginVideoWindowNativePaint()), this, SIGNAL(beginVideoWindowNativePaint())); - connect(m_widget, SIGNAL(endVideoWindowNativePaint()), this, SIGNAL(endVideoWindowNativePaint())); - m_widget->installEventFilter(this); - m_widget->winId(); -} - -S60VideoWidgetControl::~S60VideoWidgetControl() -{ - delete m_widget; -} - -QWidget *S60VideoWidgetControl::videoWidget() -{ - return m_widget; -} - -Qt::AspectRatioMode S60VideoWidgetControl::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void S60VideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode ratio) -{ - if (m_aspectRatioMode == ratio) - return; - - m_aspectRatioMode = ratio; - emit widgetUpdated(); -} - -bool S60VideoWidgetControl::isFullScreen() const -{ - return m_widget->isFullScreen(); -} - -void S60VideoWidgetControl::setFullScreen(bool fullScreen) -{ - emit fullScreenChanged(fullScreen); -} - -int S60VideoWidgetControl::brightness() const -{ - return 0; -} - -void S60VideoWidgetControl::setBrightness(int brightness) -{ - Q_UNUSED(brightness); -} - -int S60VideoWidgetControl::contrast() const -{ - return 0; -} - -void S60VideoWidgetControl::setContrast(int contrast) -{ - Q_UNUSED(contrast); -} - -int S60VideoWidgetControl::hue() const -{ - return 0; -} - -void S60VideoWidgetControl::setHue(int hue) -{ - Q_UNUSED(hue); -} - -int S60VideoWidgetControl::saturation() const -{ - return 0; -} - -void S60VideoWidgetControl::setSaturation(int saturation) -{ - Q_UNUSED(saturation); -} - -bool S60VideoWidgetControl::eventFilter(QObject *object, QEvent *e) -{ - if (object == m_widget) { - if ( e->type() == QEvent::Resize - || e->type() == QEvent::Move - || e->type() == QEvent::WinIdChange - || e->type() == QEvent::ParentChange - || e->type() == QEvent::Show) - emit widgetUpdated(); - } - return false; -} - -WId S60VideoWidgetControl::videoWidgetWId() -{ - if (m_widget->internalWinId()) - return m_widget->internalWinId(); - - if (m_widget->effectiveWinId()) - return m_widget->effectiveWinId(); - - return NULL; -} - -void S60VideoWidgetControl::videoStateChanged(QMediaPlayer::State state) -{ - if (state == QMediaPlayer::StoppedState) { -#if QT_VERSION <= 0x040600 && !defined(FF_QT) - qt_widget_private(m_widget)->extraData()->disableBlit = false; -#endif - m_widget->repaint(); - } else if (state == QMediaPlayer::PlayingState) { -#if QT_VERSION <= 0x040600 && !defined(FF_QT) - qt_widget_private(m_widget)->extraData()->disableBlit = true; -#endif - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.h deleted file mode 100644 index 28a1455..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60VIDEOWIDGET_H -#define S60VIDEOWIDGET_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QBlackWidget : public QWidget -{ - Q_OBJECT - -public: - QBlackWidget(QWidget *parent = 0); - virtual ~QBlackWidget(); - -signals: - void beginVideoWindowNativePaint(); - void endVideoWindowNativePaint(); - -public slots: - void beginNativePaintEvent(const QRect&); - void endNativePaintEvent(const QRect&); - -protected: - void paintEvent(QPaintEvent *event); -}; - -class S60VideoWidgetControl : public QVideoWidgetControl -{ - Q_OBJECT - -public: - S60VideoWidgetControl(QObject *parent = 0); - virtual ~S60VideoWidgetControl(); - - // from QVideoWidgetControl - QWidget *videoWidget(); - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode ratio); - bool isFullScreen() const; - void setFullScreen(bool fullScreen); - int brightness() const; - void setBrightness(int brightness); - int contrast() const; - void setContrast(int contrast); - int hue() const; - void setHue(int hue); - int saturation() const; - void setSaturation(int saturation); - - // from QObject - bool eventFilter(QObject *object, QEvent *event); - - //new methods - WId videoWidgetWId(); - -signals: - void widgetUpdated(); - void beginVideoWindowNativePaint(); - void endVideoWindowNativePaint(); - -private slots: - void videoStateChanged(QMediaPlayer::State state); - -private: - QBlackWidget *m_widget; - Qt::AspectRatioMode m_aspectRatioMode; -}; - -QT_END_NAMESPACE - - -#endif // S60VIDEOWIDGET_H diff --git a/src/plugins/mediaservices/symbian/s60mediaserviceplugin.cpp b/src/plugins/mediaservices/symbian/s60mediaserviceplugin.cpp deleted file mode 100644 index 1185583..0000000 --- a/src/plugins/mediaservices/symbian/s60mediaserviceplugin.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60mediaserviceplugin.h" -#ifdef QMEDIA_MMF_RADIO -#include "s60radiotunerservice.h" -#endif -#ifdef QMEDIA_MMF_PLAYER -#include "s60mediaplayerservice.h" -#endif -#ifdef QMEDIA_MMF_CAPTURE -#include "s60audiocaptureservice.h" -#endif - -QT_BEGIN_NAMESPACE - -QStringList S60MediaServicePlugin::keys() const -{ - QStringList list; -#ifdef QMEDIA_MMF_RADIO - list << QLatin1String(Q_MEDIASERVICE_RADIO); -#endif - -#ifdef QMEDIA_MMF_PLAYER - list << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); -#endif -#ifdef QMEDIA_MMF_CAPTURE - list << QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE); -#endif - return list; -} - -QMediaService* S60MediaServicePlugin::create(QString const& key) -{ -#ifdef QMEDIA_MMF_PLAYER - if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) - return new S60MediaPlayerService; -#endif -#ifdef QMEDIA_MMF_CAPTURE - if (key == QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE)) - return new S60AudioCaptureService; -#endif -#ifdef QMEDIA_MMF_RADIO - if (key == QLatin1String(Q_MEDIASERVICE_RADIO)) - return new S60RadioTunerService; -#endif - - return 0; -} - -void S60MediaServicePlugin::release(QMediaService *service) -{ - delete service; -} - -QT_END_NAMESPACE - -Q_EXPORT_PLUGIN2(qmmfengine, S60MediaServicePlugin); - diff --git a/src/plugins/mediaservices/symbian/s60mediaserviceplugin.h b/src/plugins/mediaservices/symbian/s60mediaserviceplugin.h deleted file mode 100644 index be2e05d..0000000 --- a/src/plugins/mediaservices/symbian/s60mediaserviceplugin.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60SERVICEPLUGIN_H -#define S60SERVICEPLUGIN_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class S60MediaServicePlugin : public QMediaServiceProviderPlugin -{ - Q_OBJECT -public: - - QStringList keys() const; - QMediaService* create(QString const& key); - void release(QMediaService *service); -}; - -QT_END_NAMESPACE - -#endif // S60SERVICEPLUGIN_H diff --git a/src/plugins/mediaservices/symbian/s60videooutputcontrol.cpp b/src/plugins/mediaservices/symbian/s60videooutputcontrol.cpp deleted file mode 100644 index da07a7d..0000000 --- a/src/plugins/mediaservices/symbian/s60videooutputcontrol.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 "s60videooutputcontrol.h" - -QT_BEGIN_NAMESPACE - -S60VideoOutputControl::S60VideoOutputControl(QObject *parent) - : QVideoOutputControl(parent) - , m_output(NoOutput) -{ -} - -QList S60VideoOutputControl::availableOutputs() const -{ - return m_outputs; -} - -void S60VideoOutputControl::setAvailableOutputs(const QList &outputs) -{ - emit availableOutputsChanged(m_outputs = outputs); -} - -QVideoOutputControl::Output S60VideoOutputControl::output() const -{ - return m_output; -} - -void S60VideoOutputControl::setOutput(Output output) -{ - if (!m_outputs.contains(output)) - output = NoOutput; - - if (m_output != output) - emit outputChanged(m_output = output); -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/s60videooutputcontrol.h b/src/plugins/mediaservices/symbian/s60videooutputcontrol.h deleted file mode 100644 index dbad889..0000000 --- a/src/plugins/mediaservices/symbian/s60videooutputcontrol.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins 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 S60VIDEOOUTPUTCONTROL_H -#define S60VIDEOOUTPUTCONTROL_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class S60VideoOutputControl : public QVideoOutputControl -{ - Q_OBJECT -public: - S60VideoOutputControl(QObject *parent = 0); - - QList availableOutputs() const; - void setAvailableOutputs(const QList &outputs); - - Output output() const; - void setOutput(Output output); - -Q_SIGNALS: - void outputChanged(QVideoOutputControl::Output output); - -private: - QList m_outputs; - Output m_output; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/symbian.pro b/src/plugins/mediaservices/symbian/symbian.pro deleted file mode 100644 index f76858f..0000000 --- a/src/plugins/mediaservices/symbian/symbian.pro +++ /dev/null @@ -1,27 +0,0 @@ -TARGET = qmmfengine -QT += multimedia mediaservices - -load(data_caging_paths) - -include (../../qpluginbase.pri) -include(mediaplayer/mediaplayer.pri) - -HEADERS += s60mediaserviceplugin.h \ - s60videooutputcontrol.h - -SOURCES += s60mediaserviceplugin.cpp \ - s60videooutputcontrol.cpp - -contains(S60_VERSION, 3.2)|contains(S60_VERSION, 3.1) { - DEFINES += PRE_S60_50_PLATFORM -} - -INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE -symbian-abld:INCLUDEPATH += $$QT_BUILD_TREE/include/QtWidget/private - -# This is needed for having the .qtplugin file properly created on Symbian. -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mediaservices -target.path += $$[QT_INSTALL_PLUGINS]/mediaservices -INSTALLS += target - -TARGET.UID3=0x20021318 diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 507654f..722979d 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -13,6 +13,6 @@ embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers !symbian:!contains(QT_CONFIG, no-gui):SUBDIRS += accessible symbian:SUBDIRS += s60 contains(QT_CONFIG, phonon): SUBDIRS *= phonon -contains(QT_CONFIG, multimedia): SUBDIRS *= audio mediaservices +contains(QT_CONFIG, multimedia): SUBDIRS *= audio diff --git a/src/s60installs/bwins/QtMediaServicesu.def b/src/s60installs/bwins/QtMediaServicesu.def deleted file mode 100644 index d674d12..0000000 --- a/src/s60installs/bwins/QtMediaServicesu.def +++ /dev/null @@ -1,673 +0,0 @@ -EXPORTS - ??0QGraphicsVideoItem@@QAE@PAVQGraphicsItem@@@Z @ 1 NONAME ; QGraphicsVideoItem::QGraphicsVideoItem(class QGraphicsItem *) - ??0QLocalMediaPlaylistProvider@@QAE@PAVQObject@@@Z @ 2 NONAME ; QLocalMediaPlaylistProvider::QLocalMediaPlaylistProvider(class QObject *) - ??0QMediaContent@@QAE@ABV0@@Z @ 3 NONAME ; QMediaContent::QMediaContent(class QMediaContent const &) - ??0QMediaContent@@QAE@ABV?$QList@VQMediaResource@@@@@Z @ 4 NONAME ; QMediaContent::QMediaContent(class QList const &) - ??0QMediaContent@@QAE@ABVQMediaResource@@@Z @ 5 NONAME ; QMediaContent::QMediaContent(class QMediaResource const &) - ??0QMediaContent@@QAE@ABVQNetworkRequest@@@Z @ 6 NONAME ; QMediaContent::QMediaContent(class QNetworkRequest const &) - ??0QMediaContent@@QAE@ABVQUrl@@@Z @ 7 NONAME ; QMediaContent::QMediaContent(class QUrl const &) - ??0QMediaContent@@QAE@XZ @ 8 NONAME ; QMediaContent::QMediaContent(void) - ??0QMediaControl@@IAE@AAVQMediaControlPrivate@@PAVQObject@@@Z @ 9 NONAME ; QMediaControl::QMediaControl(class QMediaControlPrivate &, class QObject *) - ??0QMediaControl@@IAE@PAVQObject@@@Z @ 10 NONAME ; QMediaControl::QMediaControl(class QObject *) - ??0QMediaObject@@IAE@AAVQMediaObjectPrivate@@PAVQObject@@PAVQMediaService@@@Z @ 11 NONAME ; QMediaObject::QMediaObject(class QMediaObjectPrivate &, class QObject *, class QMediaService *) - ??0QMediaObject@@IAE@PAVQObject@@PAVQMediaService@@@Z @ 12 NONAME ; QMediaObject::QMediaObject(class QObject *, class QMediaService *) - ??0QMediaPlayer@@QAE@PAVQObject@@V?$QFlags@W4Flag@QMediaPlayer@@@@PAVQMediaServiceProvider@@@Z @ 13 NONAME ; QMediaPlayer::QMediaPlayer(class QObject *, class QFlags, class QMediaServiceProvider *) - ??0QMediaPlayerControl@@IAE@PAVQObject@@@Z @ 14 NONAME ; QMediaPlayerControl::QMediaPlayerControl(class QObject *) - ??0QMediaPlaylist@@QAE@PAVQObject@@@Z @ 15 NONAME ; QMediaPlaylist::QMediaPlaylist(class QObject *) - ??0QMediaPlaylistControl@@IAE@PAVQObject@@@Z @ 16 NONAME ; QMediaPlaylistControl::QMediaPlaylistControl(class QObject *) - ??0QMediaPlaylistIOPlugin@@QAE@PAVQObject@@@Z @ 17 NONAME ; QMediaPlaylistIOPlugin::QMediaPlaylistIOPlugin(class QObject *) - ??0QMediaPlaylistNavigator@@QAE@PAVQMediaPlaylistProvider@@PAVQObject@@@Z @ 18 NONAME ; QMediaPlaylistNavigator::QMediaPlaylistNavigator(class QMediaPlaylistProvider *, class QObject *) - ??0QMediaPlaylistProvider@@IAE@AAVQMediaPlaylistProviderPrivate@@PAVQObject@@@Z @ 19 NONAME ; QMediaPlaylistProvider::QMediaPlaylistProvider(class QMediaPlaylistProviderPrivate &, class QObject *) - ??0QMediaPlaylistProvider@@QAE@PAVQObject@@@Z @ 20 NONAME ; QMediaPlaylistProvider::QMediaPlaylistProvider(class QObject *) - ??0QMediaResource@@QAE@ABV0@@Z @ 21 NONAME ; QMediaResource::QMediaResource(class QMediaResource const &) - ??0QMediaResource@@QAE@ABVQNetworkRequest@@ABVQString@@@Z @ 22 NONAME ; QMediaResource::QMediaResource(class QNetworkRequest const &, class QString const &) - ??0QMediaResource@@QAE@ABVQUrl@@ABVQString@@@Z @ 23 NONAME ; QMediaResource::QMediaResource(class QUrl const &, class QString const &) - ??0QMediaResource@@QAE@XZ @ 24 NONAME ; QMediaResource::QMediaResource(void) - ??0QMediaService@@IAE@AAVQMediaServicePrivate@@PAVQObject@@@Z @ 25 NONAME ; QMediaService::QMediaService(class QMediaServicePrivate &, class QObject *) - ??0QMediaService@@IAE@PAVQObject@@@Z @ 26 NONAME ; QMediaService::QMediaService(class QObject *) - ??0QMediaServiceProviderHint@@QAE@ABV0@@Z @ 27 NONAME ; QMediaServiceProviderHint::QMediaServiceProviderHint(class QMediaServiceProviderHint const &) - ??0QMediaServiceProviderHint@@QAE@ABVQByteArray@@@Z @ 28 NONAME ; QMediaServiceProviderHint::QMediaServiceProviderHint(class QByteArray const &) - ??0QMediaServiceProviderHint@@QAE@ABVQString@@ABVQStringList@@@Z @ 29 NONAME ; QMediaServiceProviderHint::QMediaServiceProviderHint(class QString const &, class QStringList const &) - ??0QMediaServiceProviderHint@@QAE@V?$QFlags@W4Feature@QMediaServiceProviderHint@@@@@Z @ 30 NONAME ; QMediaServiceProviderHint::QMediaServiceProviderHint(class QFlags) - ??0QMediaServiceProviderHint@@QAE@XZ @ 31 NONAME ; QMediaServiceProviderHint::QMediaServiceProviderHint(void) - ??0QMediaTimeInterval@@QAE@ABV0@@Z @ 32 NONAME ; QMediaTimeInterval::QMediaTimeInterval(class QMediaTimeInterval const &) - ??0QMediaTimeInterval@@QAE@XZ @ 33 NONAME ; QMediaTimeInterval::QMediaTimeInterval(void) - ??0QMediaTimeInterval@@QAE@_J0@Z @ 34 NONAME ; QMediaTimeInterval::QMediaTimeInterval(long long, long long) - ??0QMediaTimeRange@@QAE@ABV0@@Z @ 35 NONAME ; QMediaTimeRange::QMediaTimeRange(class QMediaTimeRange const &) - ??0QMediaTimeRange@@QAE@ABVQMediaTimeInterval@@@Z @ 36 NONAME ; QMediaTimeRange::QMediaTimeRange(class QMediaTimeInterval const &) - ??0QMediaTimeRange@@QAE@XZ @ 37 NONAME ; QMediaTimeRange::QMediaTimeRange(void) - ??0QMediaTimeRange@@QAE@_J0@Z @ 38 NONAME ; QMediaTimeRange::QMediaTimeRange(long long, long long) - ??0QMetaDataControl@@IAE@PAVQObject@@@Z @ 39 NONAME ; QMetaDataControl::QMetaDataControl(class QObject *) - ??0QPainterVideoSurface@@QAE@PAVQObject@@@Z @ 40 NONAME ; QPainterVideoSurface::QPainterVideoSurface(class QObject *) - ??0QSoundEffect@@QAE@PAVQObject@@@Z @ 41 NONAME ; QSoundEffect::QSoundEffect(class QObject *) - ??0QVideoDeviceControl@@IAE@PAVQObject@@@Z @ 42 NONAME ; QVideoDeviceControl::QVideoDeviceControl(class QObject *) - ??0QVideoOutputControl@@IAE@PAVQObject@@@Z @ 43 NONAME ; QVideoOutputControl::QVideoOutputControl(class QObject *) - ??0QVideoRendererControl@@IAE@PAVQObject@@@Z @ 44 NONAME ; QVideoRendererControl::QVideoRendererControl(class QObject *) - ??0QVideoWidget@@QAE@PAVQWidget@@@Z @ 45 NONAME ; QVideoWidget::QVideoWidget(class QWidget *) - ??0QVideoWidgetControl@@IAE@PAVQObject@@@Z @ 46 NONAME ; QVideoWidgetControl::QVideoWidgetControl(class QObject *) - ??0QVideoWindowControl@@IAE@PAVQObject@@@Z @ 47 NONAME ; QVideoWindowControl::QVideoWindowControl(class QObject *) - ??1QGraphicsVideoItem@@UAE@XZ @ 48 NONAME ; QGraphicsVideoItem::~QGraphicsVideoItem(void) - ??1QLocalMediaPlaylistProvider@@UAE@XZ @ 49 NONAME ; QLocalMediaPlaylistProvider::~QLocalMediaPlaylistProvider(void) - ??1QMediaContent@@QAE@XZ @ 50 NONAME ; QMediaContent::~QMediaContent(void) - ??1QMediaControl@@UAE@XZ @ 51 NONAME ; QMediaControl::~QMediaControl(void) - ??1QMediaObject@@UAE@XZ @ 52 NONAME ; QMediaObject::~QMediaObject(void) - ??1QMediaPlayer@@UAE@XZ @ 53 NONAME ; QMediaPlayer::~QMediaPlayer(void) - ??1QMediaPlayerControl@@UAE@XZ @ 54 NONAME ; QMediaPlayerControl::~QMediaPlayerControl(void) - ??1QMediaPlaylist@@UAE@XZ @ 55 NONAME ; QMediaPlaylist::~QMediaPlaylist(void) - ??1QMediaPlaylistControl@@UAE@XZ @ 56 NONAME ; QMediaPlaylistControl::~QMediaPlaylistControl(void) - ??1QMediaPlaylistIOInterface@@UAE@XZ @ 57 NONAME ; QMediaPlaylistIOInterface::~QMediaPlaylistIOInterface(void) - ??1QMediaPlaylistIOPlugin@@UAE@XZ @ 58 NONAME ; QMediaPlaylistIOPlugin::~QMediaPlaylistIOPlugin(void) - ??1QMediaPlaylistNavigator@@UAE@XZ @ 59 NONAME ; QMediaPlaylistNavigator::~QMediaPlaylistNavigator(void) - ??1QMediaPlaylistProvider@@UAE@XZ @ 60 NONAME ; QMediaPlaylistProvider::~QMediaPlaylistProvider(void) - ??1QMediaPlaylistReader@@UAE@XZ @ 61 NONAME ; QMediaPlaylistReader::~QMediaPlaylistReader(void) - ??1QMediaPlaylistWriter@@UAE@XZ @ 62 NONAME ; QMediaPlaylistWriter::~QMediaPlaylistWriter(void) - ??1QMediaResource@@QAE@XZ @ 63 NONAME ; QMediaResource::~QMediaResource(void) - ??1QMediaService@@UAE@XZ @ 64 NONAME ; QMediaService::~QMediaService(void) - ??1QMediaServiceFeaturesInterface@@UAE@XZ @ 65 NONAME ; QMediaServiceFeaturesInterface::~QMediaServiceFeaturesInterface(void) - ??1QMediaServiceProvider@@UAE@XZ @ 66 NONAME ; QMediaServiceProvider::~QMediaServiceProvider(void) - ??1QMediaServiceProviderHint@@QAE@XZ @ 67 NONAME ; QMediaServiceProviderHint::~QMediaServiceProviderHint(void) - ??1QMediaServiceSupportedDevicesInterface@@UAE@XZ @ 68 NONAME ; QMediaServiceSupportedDevicesInterface::~QMediaServiceSupportedDevicesInterface(void) - ??1QMediaServiceSupportedFormatsInterface@@UAE@XZ @ 69 NONAME ; QMediaServiceSupportedFormatsInterface::~QMediaServiceSupportedFormatsInterface(void) - ??1QMediaTimeRange@@QAE@XZ @ 70 NONAME ; QMediaTimeRange::~QMediaTimeRange(void) - ??1QMetaDataControl@@UAE@XZ @ 71 NONAME ; QMetaDataControl::~QMetaDataControl(void) - ??1QPainterVideoSurface@@UAE@XZ @ 72 NONAME ; QPainterVideoSurface::~QPainterVideoSurface(void) - ??1QSoundEffect@@UAE@XZ @ 73 NONAME ; QSoundEffect::~QSoundEffect(void) - ??1QVideoDeviceControl@@UAE@XZ @ 74 NONAME ; QVideoDeviceControl::~QVideoDeviceControl(void) - ??1QVideoOutputControl@@UAE@XZ @ 75 NONAME ; QVideoOutputControl::~QVideoOutputControl(void) - ??1QVideoRendererControl@@UAE@XZ @ 76 NONAME ; QVideoRendererControl::~QVideoRendererControl(void) - ??1QVideoWidget@@UAE@XZ @ 77 NONAME ; QVideoWidget::~QVideoWidget(void) - ??1QVideoWidgetControl@@UAE@XZ @ 78 NONAME ; QVideoWidgetControl::~QVideoWidgetControl(void) - ??1QVideoWindowControl@@UAE@XZ @ 79 NONAME ; QVideoWindowControl::~QVideoWindowControl(void) - ??4QMediaContent@@QAEAAV0@ABV0@@Z @ 80 NONAME ; class QMediaContent & QMediaContent::operator=(class QMediaContent const &) - ??4QMediaResource@@QAEAAV0@ABV0@@Z @ 81 NONAME ; class QMediaResource & QMediaResource::operator=(class QMediaResource const &) - ??4QMediaServiceProviderHint@@QAEAAV0@ABV0@@Z @ 82 NONAME ; class QMediaServiceProviderHint & QMediaServiceProviderHint::operator=(class QMediaServiceProviderHint const &) - ??4QMediaTimeRange@@QAEAAV0@ABV0@@Z @ 83 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator=(class QMediaTimeRange const &) - ??4QMediaTimeRange@@QAEAAV0@ABVQMediaTimeInterval@@@Z @ 84 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator=(class QMediaTimeInterval const &) - ??8@YA_NABVQMediaTimeInterval@@0@Z @ 85 NONAME ; bool operator==(class QMediaTimeInterval const &, class QMediaTimeInterval const &) - ??8@YA_NABVQMediaTimeRange@@0@Z @ 86 NONAME ; bool operator==(class QMediaTimeRange const &, class QMediaTimeRange const &) - ??8QMediaContent@@QBE_NABV0@@Z @ 87 NONAME ; bool QMediaContent::operator==(class QMediaContent const &) const - ??8QMediaResource@@QBE_NABV0@@Z @ 88 NONAME ; bool QMediaResource::operator==(class QMediaResource const &) const - ??8QMediaServiceProviderHint@@QBE_NABV0@@Z @ 89 NONAME ; bool QMediaServiceProviderHint::operator==(class QMediaServiceProviderHint const &) const - ??9@YA_NABVQMediaTimeInterval@@0@Z @ 90 NONAME ; bool operator!=(class QMediaTimeInterval const &, class QMediaTimeInterval const &) - ??9@YA_NABVQMediaTimeRange@@0@Z @ 91 NONAME ; bool operator!=(class QMediaTimeRange const &, class QMediaTimeRange const &) - ??9QMediaContent@@QBE_NABV0@@Z @ 92 NONAME ; bool QMediaContent::operator!=(class QMediaContent const &) const - ??9QMediaResource@@QBE_NABV0@@Z @ 93 NONAME ; bool QMediaResource::operator!=(class QMediaResource const &) const - ??9QMediaServiceProviderHint@@QBE_NABV0@@Z @ 94 NONAME ; bool QMediaServiceProviderHint::operator!=(class QMediaServiceProviderHint const &) const - ??G@YA?AVQMediaTimeRange@@ABV0@0@Z @ 95 NONAME ; class QMediaTimeRange operator-(class QMediaTimeRange const &, class QMediaTimeRange const &) - ??H@YA?AVQMediaTimeRange@@ABV0@0@Z @ 96 NONAME ; class QMediaTimeRange operator+(class QMediaTimeRange const &, class QMediaTimeRange const &) - ??YQMediaTimeRange@@QAEAAV0@ABV0@@Z @ 97 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator+=(class QMediaTimeRange const &) - ??YQMediaTimeRange@@QAEAAV0@ABVQMediaTimeInterval@@@Z @ 98 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator+=(class QMediaTimeInterval const &) - ??ZQMediaTimeRange@@QAEAAV0@ABV0@@Z @ 99 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator-=(class QMediaTimeRange const &) - ??ZQMediaTimeRange@@QAEAAV0@ABVQMediaTimeInterval@@@Z @ 100 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator-=(class QMediaTimeInterval const &) - ??_EQGraphicsVideoItem@@UAE@I@Z @ 101 NONAME ; QGraphicsVideoItem::~QGraphicsVideoItem(unsigned int) - ??_EQLocalMediaPlaylistProvider@@UAE@I@Z @ 102 NONAME ; QLocalMediaPlaylistProvider::~QLocalMediaPlaylistProvider(unsigned int) - ??_EQMediaControl@@UAE@I@Z @ 103 NONAME ; QMediaControl::~QMediaControl(unsigned int) - ??_EQMediaObject@@UAE@I@Z @ 104 NONAME ; QMediaObject::~QMediaObject(unsigned int) - ??_EQMediaPlayer@@UAE@I@Z @ 105 NONAME ; QMediaPlayer::~QMediaPlayer(unsigned int) - ??_EQMediaPlayerControl@@UAE@I@Z @ 106 NONAME ; QMediaPlayerControl::~QMediaPlayerControl(unsigned int) - ??_EQMediaPlaylist@@UAE@I@Z @ 107 NONAME ; QMediaPlaylist::~QMediaPlaylist(unsigned int) - ??_EQMediaPlaylistControl@@UAE@I@Z @ 108 NONAME ; QMediaPlaylistControl::~QMediaPlaylistControl(unsigned int) - ??_EQMediaPlaylistIOInterface@@UAE@I@Z @ 109 NONAME ; QMediaPlaylistIOInterface::~QMediaPlaylistIOInterface(unsigned int) - ??_EQMediaPlaylistIOPlugin@@UAE@I@Z @ 110 NONAME ; QMediaPlaylistIOPlugin::~QMediaPlaylistIOPlugin(unsigned int) - ??_EQMediaPlaylistNavigator@@UAE@I@Z @ 111 NONAME ; QMediaPlaylistNavigator::~QMediaPlaylistNavigator(unsigned int) - ??_EQMediaPlaylistProvider@@UAE@I@Z @ 112 NONAME ; QMediaPlaylistProvider::~QMediaPlaylistProvider(unsigned int) - ??_EQMediaPlaylistReader@@UAE@I@Z @ 113 NONAME ; QMediaPlaylistReader::~QMediaPlaylistReader(unsigned int) - ??_EQMediaPlaylistWriter@@UAE@I@Z @ 114 NONAME ; QMediaPlaylistWriter::~QMediaPlaylistWriter(unsigned int) - ??_EQMediaService@@UAE@I@Z @ 115 NONAME ; QMediaService::~QMediaService(unsigned int) - ??_EQMediaServiceFeaturesInterface@@UAE@I@Z @ 116 NONAME ; QMediaServiceFeaturesInterface::~QMediaServiceFeaturesInterface(unsigned int) - ??_EQMediaServiceProvider@@UAE@I@Z @ 117 NONAME ; QMediaServiceProvider::~QMediaServiceProvider(unsigned int) - ??_EQMediaServiceSupportedDevicesInterface@@UAE@I@Z @ 118 NONAME ; QMediaServiceSupportedDevicesInterface::~QMediaServiceSupportedDevicesInterface(unsigned int) - ??_EQMediaServiceSupportedFormatsInterface@@UAE@I@Z @ 119 NONAME ; QMediaServiceSupportedFormatsInterface::~QMediaServiceSupportedFormatsInterface(unsigned int) - ??_EQMetaDataControl@@UAE@I@Z @ 120 NONAME ; QMetaDataControl::~QMetaDataControl(unsigned int) - ??_EQPainterVideoSurface@@UAE@I@Z @ 121 NONAME ; QPainterVideoSurface::~QPainterVideoSurface(unsigned int) - ??_EQSoundEffect@@UAE@I@Z @ 122 NONAME ; QSoundEffect::~QSoundEffect(unsigned int) - ??_EQVideoDeviceControl@@UAE@I@Z @ 123 NONAME ; QVideoDeviceControl::~QVideoDeviceControl(unsigned int) - ??_EQVideoOutputControl@@UAE@I@Z @ 124 NONAME ; QVideoOutputControl::~QVideoOutputControl(unsigned int) - ??_EQVideoRendererControl@@UAE@I@Z @ 125 NONAME ; QVideoRendererControl::~QVideoRendererControl(unsigned int) - ??_EQVideoWidget@@UAE@I@Z @ 126 NONAME ; QVideoWidget::~QVideoWidget(unsigned int) - ??_EQVideoWidgetControl@@UAE@I@Z @ 127 NONAME ; QVideoWidgetControl::~QVideoWidgetControl(unsigned int) - ??_EQVideoWindowControl@@UAE@I@Z @ 128 NONAME ; QVideoWindowControl::~QVideoWindowControl(unsigned int) - ?activated@QMediaPlaylistNavigator@@IAEXABVQMediaContent@@@Z @ 129 NONAME ; void QMediaPlaylistNavigator::activated(class QMediaContent const &) - ?addInterval@QMediaTimeRange@@QAEXABVQMediaTimeInterval@@@Z @ 130 NONAME ; void QMediaTimeRange::addInterval(class QMediaTimeInterval const &) - ?addInterval@QMediaTimeRange@@QAEX_J0@Z @ 131 NONAME ; void QMediaTimeRange::addInterval(long long, long long) - ?addMedia@QLocalMediaPlaylistProvider@@UAE_NABV?$QList@VQMediaContent@@@@@Z @ 132 NONAME ; bool QLocalMediaPlaylistProvider::addMedia(class QList const &) - ?addMedia@QLocalMediaPlaylistProvider@@UAE_NABVQMediaContent@@@Z @ 133 NONAME ; bool QLocalMediaPlaylistProvider::addMedia(class QMediaContent const &) - ?addMedia@QMediaPlaylist@@QAE_NABV?$QList@VQMediaContent@@@@@Z @ 134 NONAME ; bool QMediaPlaylist::addMedia(class QList const &) - ?addMedia@QMediaPlaylist@@QAE_NABVQMediaContent@@@Z @ 135 NONAME ; bool QMediaPlaylist::addMedia(class QMediaContent const &) - ?addMedia@QMediaPlaylistProvider@@UAE_NABV?$QList@VQMediaContent@@@@@Z @ 136 NONAME ; bool QMediaPlaylistProvider::addMedia(class QList const &) - ?addMedia@QMediaPlaylistProvider@@UAE_NABVQMediaContent@@@Z @ 137 NONAME ; bool QMediaPlaylistProvider::addMedia(class QMediaContent const &) - ?addPropertyWatch@QMediaObject@@IAEXABVQByteArray@@@Z @ 138 NONAME ; void QMediaObject::addPropertyWatch(class QByteArray const &) - ?addTimeRange@QMediaTimeRange@@QAEXABV1@@Z @ 139 NONAME ; void QMediaTimeRange::addTimeRange(class QMediaTimeRange const &) - ?aspectRatioMode@QGraphicsVideoItem@@QBE?AW4AspectRatioMode@Qt@@XZ @ 140 NONAME ; enum Qt::AspectRatioMode QGraphicsVideoItem::aspectRatioMode(void) const - ?aspectRatioMode@QVideoWidget@@QBE?AW4AspectRatioMode@Qt@@XZ @ 141 NONAME ; enum Qt::AspectRatioMode QVideoWidget::aspectRatioMode(void) const - ?audioAvailableChanged@QMediaPlayer@@IAEX_N@Z @ 142 NONAME ; void QMediaPlayer::audioAvailableChanged(bool) - ?audioAvailableChanged@QMediaPlayerControl@@IAEX_N@Z @ 143 NONAME ; void QMediaPlayerControl::audioAvailableChanged(bool) - ?audioBitRate@QMediaResource@@QBEHXZ @ 144 NONAME ; int QMediaResource::audioBitRate(void) const - ?audioCodec@QMediaResource@@QBE?AVQString@@XZ @ 145 NONAME ; class QString QMediaResource::audioCodec(void) const - ?availabilityChanged@QMediaObject@@IAEX_N@Z @ 146 NONAME ; void QMediaObject::availabilityChanged(bool) - ?availabilityError@QMediaObject@@UBE?AW4AvailabilityError@QtMediaServices@@XZ @ 147 NONAME ; enum QtMediaServices::AvailabilityError QMediaObject::availabilityError(void) const - ?availableExtendedMetaData@QMediaObject@@QBE?AVQStringList@@XZ @ 148 NONAME ; class QStringList QMediaObject::availableExtendedMetaData(void) const - ?availableMetaData@QMediaObject@@QBE?AV?$QList@W4MetaData@QtMediaServices@@@@XZ @ 149 NONAME ; class QList QMediaObject::availableMetaData(void) const - ?availableOutputsChanged@QVideoOutputControl@@IAEXABV?$QList@W4Output@QVideoOutputControl@@@@@Z @ 150 NONAME ; void QVideoOutputControl::availableOutputsChanged(class QList const &) - ?availablePlaybackRangesChanged@QMediaPlayerControl@@IAEXABVQMediaTimeRange@@@Z @ 151 NONAME ; void QMediaPlayerControl::availablePlaybackRangesChanged(class QMediaTimeRange const &) - ?bind@QMediaObject@@UAEXPAVQObject@@@Z @ 152 NONAME ; void QMediaObject::bind(class QObject *) - ?bind@QMediaPlayer@@UAEXPAVQObject@@@Z @ 153 NONAME ; void QMediaPlayer::bind(class QObject *) - ?boundingRect@QGraphicsVideoItem@@UBE?AVQRectF@@XZ @ 154 NONAME ; class QRectF QGraphicsVideoItem::boundingRect(void) const - ?brightness@QPainterVideoSurface@@QBEHXZ @ 155 NONAME ; int QPainterVideoSurface::brightness(void) const - ?brightness@QVideoWidget@@QBEHXZ @ 156 NONAME ; int QVideoWidget::brightness(void) const - ?brightnessChanged@QVideoWidget@@IAEXH@Z @ 157 NONAME ; void QVideoWidget::brightnessChanged(int) - ?brightnessChanged@QVideoWidgetControl@@IAEXH@Z @ 158 NONAME ; void QVideoWidgetControl::brightnessChanged(int) - ?brightnessChanged@QVideoWindowControl@@IAEXH@Z @ 159 NONAME ; void QVideoWindowControl::brightnessChanged(int) - ?bufferStatus@QMediaPlayer@@QBEHXZ @ 160 NONAME ; int QMediaPlayer::bufferStatus(void) const - ?bufferStatusChanged@QMediaPlayer@@IAEXH@Z @ 161 NONAME ; void QMediaPlayer::bufferStatusChanged(int) - ?bufferStatusChanged@QMediaPlayerControl@@IAEXH@Z @ 162 NONAME ; void QMediaPlayerControl::bufferStatusChanged(int) - ?canonicalRequest@QMediaContent@@QBE?AVQNetworkRequest@@XZ @ 163 NONAME ; class QNetworkRequest QMediaContent::canonicalRequest(void) const - ?canonicalResource@QMediaContent@@QBE?AVQMediaResource@@XZ @ 164 NONAME ; class QMediaResource QMediaContent::canonicalResource(void) const - ?canonicalUrl@QMediaContent@@QBE?AVQUrl@@XZ @ 165 NONAME ; class QUrl QMediaContent::canonicalUrl(void) const - ?channelCount@QMediaResource@@QBEHXZ @ 166 NONAME ; int QMediaResource::channelCount(void) const - ?clear@QLocalMediaPlaylistProvider@@UAE_NXZ @ 167 NONAME ; bool QLocalMediaPlaylistProvider::clear(void) - ?clear@QMediaPlaylist@@QAE_NXZ @ 168 NONAME ; bool QMediaPlaylist::clear(void) - ?clear@QMediaPlaylistProvider@@UAE_NXZ @ 169 NONAME ; bool QMediaPlaylistProvider::clear(void) - ?clear@QMediaTimeRange@@QAEXXZ @ 170 NONAME ; void QMediaTimeRange::clear(void) - ?codecs@QMediaServiceProviderHint@@QBE?AVQStringList@@XZ @ 171 NONAME ; class QStringList QMediaServiceProviderHint::codecs(void) const - ?contains@QMediaTimeInterval@@QBE_N_J@Z @ 172 NONAME ; bool QMediaTimeInterval::contains(long long) const - ?contains@QMediaTimeRange@@QBE_N_J@Z @ 173 NONAME ; bool QMediaTimeRange::contains(long long) const - ?contrast@QPainterVideoSurface@@QBEHXZ @ 174 NONAME ; int QPainterVideoSurface::contrast(void) const - ?contrast@QVideoWidget@@QBEHXZ @ 175 NONAME ; int QVideoWidget::contrast(void) const - ?contrastChanged@QVideoWidget@@IAEXH@Z @ 176 NONAME ; void QVideoWidget::contrastChanged(int) - ?contrastChanged@QVideoWidgetControl@@IAEXH@Z @ 177 NONAME ; void QVideoWidgetControl::contrastChanged(int) - ?contrastChanged@QVideoWindowControl@@IAEXH@Z @ 178 NONAME ; void QVideoWindowControl::contrastChanged(int) - ?createPainter@QPainterVideoSurface@@AAEXXZ @ 179 NONAME ; void QPainterVideoSurface::createPainter(void) - ?currentIndex@QMediaPlaylist@@QBEHXZ @ 180 NONAME ; int QMediaPlaylist::currentIndex(void) const - ?currentIndex@QMediaPlaylistNavigator@@QBEHXZ @ 181 NONAME ; int QMediaPlaylistNavigator::currentIndex(void) const - ?currentIndexChanged@QMediaPlaylist@@IAEXH@Z @ 182 NONAME ; void QMediaPlaylist::currentIndexChanged(int) - ?currentIndexChanged@QMediaPlaylistControl@@IAEXH@Z @ 183 NONAME ; void QMediaPlaylistControl::currentIndexChanged(int) - ?currentIndexChanged@QMediaPlaylistNavigator@@IAEXH@Z @ 184 NONAME ; void QMediaPlaylistNavigator::currentIndexChanged(int) - ?currentItem@QMediaPlaylistNavigator@@QBE?AVQMediaContent@@XZ @ 185 NONAME ; class QMediaContent QMediaPlaylistNavigator::currentItem(void) const - ?currentMedia@QMediaPlaylist@@QBE?AVQMediaContent@@XZ @ 186 NONAME ; class QMediaContent QMediaPlaylist::currentMedia(void) const - ?currentMediaChanged@QMediaPlaylist@@IAEXABVQMediaContent@@@Z @ 187 NONAME ; void QMediaPlaylist::currentMediaChanged(class QMediaContent const &) - ?currentMediaChanged@QMediaPlaylistControl@@IAEXABVQMediaContent@@@Z @ 188 NONAME ; void QMediaPlaylistControl::currentMediaChanged(class QMediaContent const &) - ?d_func@QGraphicsVideoItem@@AAEPAVQGraphicsVideoItemPrivate@@XZ @ 189 NONAME ; class QGraphicsVideoItemPrivate * QGraphicsVideoItem::d_func(void) - ?d_func@QGraphicsVideoItem@@ABEPBVQGraphicsVideoItemPrivate@@XZ @ 190 NONAME ; class QGraphicsVideoItemPrivate const * QGraphicsVideoItem::d_func(void) const - ?d_func@QLocalMediaPlaylistProvider@@AAEPAVQLocalMediaPlaylistProviderPrivate@@XZ @ 191 NONAME ; class QLocalMediaPlaylistProviderPrivate * QLocalMediaPlaylistProvider::d_func(void) - ?d_func@QLocalMediaPlaylistProvider@@ABEPBVQLocalMediaPlaylistProviderPrivate@@XZ @ 192 NONAME ; class QLocalMediaPlaylistProviderPrivate const * QLocalMediaPlaylistProvider::d_func(void) const - ?d_func@QMediaControl@@AAEPAVQMediaControlPrivate@@XZ @ 193 NONAME ; class QMediaControlPrivate * QMediaControl::d_func(void) - ?d_func@QMediaControl@@ABEPBVQMediaControlPrivate@@XZ @ 194 NONAME ; class QMediaControlPrivate const * QMediaControl::d_func(void) const - ?d_func@QMediaObject@@AAEPAVQMediaObjectPrivate@@XZ @ 195 NONAME ; class QMediaObjectPrivate * QMediaObject::d_func(void) - ?d_func@QMediaObject@@ABEPBVQMediaObjectPrivate@@XZ @ 196 NONAME ; class QMediaObjectPrivate const * QMediaObject::d_func(void) const - ?d_func@QMediaPlayer@@AAEPAVQMediaPlayerPrivate@@XZ @ 197 NONAME ; class QMediaPlayerPrivate * QMediaPlayer::d_func(void) - ?d_func@QMediaPlayer@@ABEPBVQMediaPlayerPrivate@@XZ @ 198 NONAME ; class QMediaPlayerPrivate const * QMediaPlayer::d_func(void) const - ?d_func@QMediaPlaylist@@AAEPAVQMediaPlaylistPrivate@@XZ @ 199 NONAME ; class QMediaPlaylistPrivate * QMediaPlaylist::d_func(void) - ?d_func@QMediaPlaylist@@ABEPBVQMediaPlaylistPrivate@@XZ @ 200 NONAME ; class QMediaPlaylistPrivate const * QMediaPlaylist::d_func(void) const - ?d_func@QMediaPlaylistNavigator@@AAEPAVQMediaPlaylistNavigatorPrivate@@XZ @ 201 NONAME ; class QMediaPlaylistNavigatorPrivate * QMediaPlaylistNavigator::d_func(void) - ?d_func@QMediaPlaylistNavigator@@ABEPBVQMediaPlaylistNavigatorPrivate@@XZ @ 202 NONAME ; class QMediaPlaylistNavigatorPrivate const * QMediaPlaylistNavigator::d_func(void) const - ?d_func@QMediaPlaylistProvider@@AAEPAVQMediaPlaylistProviderPrivate@@XZ @ 203 NONAME ; class QMediaPlaylistProviderPrivate * QMediaPlaylistProvider::d_func(void) - ?d_func@QMediaPlaylistProvider@@ABEPBVQMediaPlaylistProviderPrivate@@XZ @ 204 NONAME ; class QMediaPlaylistProviderPrivate const * QMediaPlaylistProvider::d_func(void) const - ?d_func@QMediaService@@AAEPAVQMediaServicePrivate@@XZ @ 205 NONAME ; class QMediaServicePrivate * QMediaService::d_func(void) - ?d_func@QMediaService@@ABEPBVQMediaServicePrivate@@XZ @ 206 NONAME ; class QMediaServicePrivate const * QMediaService::d_func(void) const - ?d_func@QVideoWidget@@AAEPAVQVideoWidgetPrivate@@XZ @ 207 NONAME ; class QVideoWidgetPrivate * QVideoWidget::d_func(void) - ?d_func@QVideoWidget@@ABEPBVQVideoWidgetPrivate@@XZ @ 208 NONAME ; class QVideoWidgetPrivate const * QVideoWidget::d_func(void) const - ?dataSize@QMediaResource@@QBE_JXZ @ 209 NONAME ; long long QMediaResource::dataSize(void) const - ?defaultServiceProvider@QMediaServiceProvider@@SAPAV1@XZ @ 210 NONAME ; class QMediaServiceProvider * QMediaServiceProvider::defaultServiceProvider(void) - ?device@QMediaServiceProviderHint@@QBE?AVQByteArray@@XZ @ 211 NONAME ; class QByteArray QMediaServiceProviderHint::device(void) const - ?deviceDescription@QMediaServiceProvider@@UAE?AVQString@@ABVQByteArray@@0@Z @ 212 NONAME ; class QString QMediaServiceProvider::deviceDescription(class QByteArray const &, class QByteArray const &) - ?devices@QMediaServiceProvider@@UBE?AV?$QList@VQByteArray@@@@ABVQByteArray@@@Z @ 213 NONAME ; class QList QMediaServiceProvider::devices(class QByteArray const &) const - ?devicesChanged@QVideoDeviceControl@@IAEXXZ @ 214 NONAME ; void QVideoDeviceControl::devicesChanged(void) - ?duration@QMediaPlayer@@QBE_JXZ @ 215 NONAME ; long long QMediaPlayer::duration(void) const - ?durationChanged@QMediaPlayer@@IAEX_J@Z @ 216 NONAME ; void QMediaPlayer::durationChanged(long long) - ?durationChanged@QMediaPlayerControl@@IAEX_J@Z @ 217 NONAME ; void QMediaPlayerControl::durationChanged(long long) - ?earliestTime@QMediaTimeRange@@QBE_JXZ @ 218 NONAME ; long long QMediaTimeRange::earliestTime(void) const - ?end@QMediaTimeInterval@@QBE_JXZ @ 219 NONAME ; long long QMediaTimeInterval::end(void) const - ?error@QMediaPlayer@@IAEXW4Error@1@@Z @ 220 NONAME ; void QMediaPlayer::error(enum QMediaPlayer::Error) - ?error@QMediaPlayer@@QBE?AW4Error@1@XZ @ 221 NONAME ; enum QMediaPlayer::Error QMediaPlayer::error(void) const - ?error@QMediaPlayerControl@@IAEXHABVQString@@@Z @ 222 NONAME ; void QMediaPlayerControl::error(int, class QString const &) - ?error@QMediaPlaylist@@QBE?AW4Error@1@XZ @ 223 NONAME ; enum QMediaPlaylist::Error QMediaPlaylist::error(void) const - ?errorString@QMediaPlayer@@QBE?AVQString@@XZ @ 224 NONAME ; class QString QMediaPlayer::errorString(void) const - ?errorString@QMediaPlaylist@@QBE?AVQString@@XZ @ 225 NONAME ; class QString QMediaPlaylist::errorString(void) const - ?event@QGraphicsVideoItem@@MAE_NPAVQEvent@@@Z @ 226 NONAME ; bool QGraphicsVideoItem::event(class QEvent *) - ?event@QVideoWidget@@MAE_NPAVQEvent@@@Z @ 227 NONAME ; bool QVideoWidget::event(class QEvent *) - ?extendedMetaData@QMediaObject@@QBE?AVQVariant@@ABVQString@@@Z @ 228 NONAME ; class QVariant QMediaObject::extendedMetaData(class QString const &) const - ?features@QMediaServiceProviderHint@@QBE?AV?$QFlags@W4Feature@QMediaServiceProviderHint@@@@XZ @ 229 NONAME ; class QFlags QMediaServiceProviderHint::features(void) const - ?frameChanged@QPainterVideoSurface@@IAEXXZ @ 230 NONAME ; void QPainterVideoSurface::frameChanged(void) - ?fullScreenChanged@QVideoWidget@@IAEX_N@Z @ 231 NONAME ; void QVideoWidget::fullScreenChanged(bool) - ?fullScreenChanged@QVideoWidgetControl@@IAEX_N@Z @ 232 NONAME ; void QVideoWidgetControl::fullScreenChanged(bool) - ?fullScreenChanged@QVideoWindowControl@@IAEX_N@Z @ 233 NONAME ; void QVideoWindowControl::fullScreenChanged(bool) - ?getStaticMetaObject@QGraphicsVideoItem@@SAABUQMetaObject@@XZ @ 234 NONAME ; struct QMetaObject const & QGraphicsVideoItem::getStaticMetaObject(void) - ?getStaticMetaObject@QLocalMediaPlaylistProvider@@SAABUQMetaObject@@XZ @ 235 NONAME ; struct QMetaObject const & QLocalMediaPlaylistProvider::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaControl@@SAABUQMetaObject@@XZ @ 236 NONAME ; struct QMetaObject const & QMediaControl::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaObject@@SAABUQMetaObject@@XZ @ 237 NONAME ; struct QMetaObject const & QMediaObject::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlayer@@SAABUQMetaObject@@XZ @ 238 NONAME ; struct QMetaObject const & QMediaPlayer::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlayerControl@@SAABUQMetaObject@@XZ @ 239 NONAME ; struct QMetaObject const & QMediaPlayerControl::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlaylist@@SAABUQMetaObject@@XZ @ 240 NONAME ; struct QMetaObject const & QMediaPlaylist::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlaylistControl@@SAABUQMetaObject@@XZ @ 241 NONAME ; struct QMetaObject const & QMediaPlaylistControl::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlaylistIOPlugin@@SAABUQMetaObject@@XZ @ 242 NONAME ; struct QMetaObject const & QMediaPlaylistIOPlugin::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlaylistNavigator@@SAABUQMetaObject@@XZ @ 243 NONAME ; struct QMetaObject const & QMediaPlaylistNavigator::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlaylistProvider@@SAABUQMetaObject@@XZ @ 244 NONAME ; struct QMetaObject const & QMediaPlaylistProvider::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaService@@SAABUQMetaObject@@XZ @ 245 NONAME ; struct QMetaObject const & QMediaService::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaServiceProvider@@SAABUQMetaObject@@XZ @ 246 NONAME ; struct QMetaObject const & QMediaServiceProvider::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaServiceProviderPlugin@@SAABUQMetaObject@@XZ @ 247 NONAME ; struct QMetaObject const & QMediaServiceProviderPlugin::getStaticMetaObject(void) - ?getStaticMetaObject@QMetaDataControl@@SAABUQMetaObject@@XZ @ 248 NONAME ; struct QMetaObject const & QMetaDataControl::getStaticMetaObject(void) - ?getStaticMetaObject@QPainterVideoSurface@@SAABUQMetaObject@@XZ @ 249 NONAME ; struct QMetaObject const & QPainterVideoSurface::getStaticMetaObject(void) - ?getStaticMetaObject@QSoundEffect@@SAABUQMetaObject@@XZ @ 250 NONAME ; struct QMetaObject const & QSoundEffect::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoDeviceControl@@SAABUQMetaObject@@XZ @ 251 NONAME ; struct QMetaObject const & QVideoDeviceControl::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoOutputControl@@SAABUQMetaObject@@XZ @ 252 NONAME ; struct QMetaObject const & QVideoOutputControl::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoRendererControl@@SAABUQMetaObject@@XZ @ 253 NONAME ; struct QMetaObject const & QVideoRendererControl::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoWidget@@SAABUQMetaObject@@XZ @ 254 NONAME ; struct QMetaObject const & QVideoWidget::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoWidgetControl@@SAABUQMetaObject@@XZ @ 255 NONAME ; struct QMetaObject const & QVideoWidgetControl::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoWindowControl@@SAABUQMetaObject@@XZ @ 256 NONAME ; struct QMetaObject const & QVideoWindowControl::getStaticMetaObject(void) - ?hasSupport@QMediaPlayer@@SA?AW4SupportEstimate@QtMediaServices@@ABVQString@@ABVQStringList@@V?$QFlags@W4Flag@QMediaPlayer@@@@@Z @ 257 NONAME ; enum QtMediaServices::SupportEstimate QMediaPlayer::hasSupport(class QString const &, class QStringList const &, class QFlags) - ?hasSupport@QMediaServiceProvider@@UBE?AW4SupportEstimate@QtMediaServices@@ABVQByteArray@@ABVQString@@ABVQStringList@@H@Z @ 258 NONAME ; enum QtMediaServices::SupportEstimate QMediaServiceProvider::hasSupport(class QByteArray const &, class QString const &, class QStringList const &, int) const - ?hideEvent@QVideoWidget@@MAEXPAVQHideEvent@@@Z @ 259 NONAME ; void QVideoWidget::hideEvent(class QHideEvent *) - ?hue@QPainterVideoSurface@@QBEHXZ @ 260 NONAME ; int QPainterVideoSurface::hue(void) const - ?hue@QVideoWidget@@QBEHXZ @ 261 NONAME ; int QVideoWidget::hue(void) const - ?hueChanged@QVideoWidget@@IAEXH@Z @ 262 NONAME ; void QVideoWidget::hueChanged(int) - ?hueChanged@QVideoWidgetControl@@IAEXH@Z @ 263 NONAME ; void QVideoWidgetControl::hueChanged(int) - ?hueChanged@QVideoWindowControl@@IAEXH@Z @ 264 NONAME ; void QVideoWindowControl::hueChanged(int) - ?insertMedia@QLocalMediaPlaylistProvider@@UAE_NHABV?$QList@VQMediaContent@@@@@Z @ 265 NONAME ; bool QLocalMediaPlaylistProvider::insertMedia(int, class QList const &) - ?insertMedia@QLocalMediaPlaylistProvider@@UAE_NHABVQMediaContent@@@Z @ 266 NONAME ; bool QLocalMediaPlaylistProvider::insertMedia(int, class QMediaContent const &) - ?insertMedia@QMediaPlaylist@@QAE_NHABV?$QList@VQMediaContent@@@@@Z @ 267 NONAME ; bool QMediaPlaylist::insertMedia(int, class QList const &) - ?insertMedia@QMediaPlaylist@@QAE_NHABVQMediaContent@@@Z @ 268 NONAME ; bool QMediaPlaylist::insertMedia(int, class QMediaContent const &) - ?insertMedia@QMediaPlaylistProvider@@UAE_NHABV?$QList@VQMediaContent@@@@@Z @ 269 NONAME ; bool QMediaPlaylistProvider::insertMedia(int, class QList const &) - ?insertMedia@QMediaPlaylistProvider@@UAE_NHABVQMediaContent@@@Z @ 270 NONAME ; bool QMediaPlaylistProvider::insertMedia(int, class QMediaContent const &) - ?intervals@QMediaTimeRange@@QBE?AV?$QList@VQMediaTimeInterval@@@@XZ @ 271 NONAME ; class QList QMediaTimeRange::intervals(void) const - ?isAudioAvailable@QMediaPlayer@@QBE_NXZ @ 272 NONAME ; bool QMediaPlayer::isAudioAvailable(void) const - ?isAvailable@QMediaObject@@UBE_NXZ @ 273 NONAME ; bool QMediaObject::isAvailable(void) const - ?isContinuous@QMediaTimeRange@@QBE_NXZ @ 274 NONAME ; bool QMediaTimeRange::isContinuous(void) const - ?isEmpty@QMediaPlaylist@@QBE_NXZ @ 275 NONAME ; bool QMediaPlaylist::isEmpty(void) const - ?isEmpty@QMediaTimeRange@@QBE_NXZ @ 276 NONAME ; bool QMediaTimeRange::isEmpty(void) const - ?isFormatSupported@QPainterVideoSurface@@QBE_NABVQVideoSurfaceFormat@@PAV2@@Z @ 277 NONAME ; bool QPainterVideoSurface::isFormatSupported(class QVideoSurfaceFormat const &, class QVideoSurfaceFormat *) const - ?isMetaDataAvailable@QMediaObject@@QBE_NXZ @ 278 NONAME ; bool QMediaObject::isMetaDataAvailable(void) const - ?isMetaDataWritable@QMediaObject@@QBE_NXZ @ 279 NONAME ; bool QMediaObject::isMetaDataWritable(void) const - ?isMuted@QMediaPlayer@@QBE_NXZ @ 280 NONAME ; bool QMediaPlayer::isMuted(void) const - ?isMuted@QSoundEffect@@QBE_NXZ @ 281 NONAME ; bool QSoundEffect::isMuted(void) const - ?isNormal@QMediaTimeInterval@@QBE_NXZ @ 282 NONAME ; bool QMediaTimeInterval::isNormal(void) const - ?isNull@QMediaContent@@QBE_NXZ @ 283 NONAME ; bool QMediaContent::isNull(void) const - ?isNull@QMediaResource@@QBE_NXZ @ 284 NONAME ; bool QMediaResource::isNull(void) const - ?isNull@QMediaServiceProviderHint@@QBE_NXZ @ 285 NONAME ; bool QMediaServiceProviderHint::isNull(void) const - ?isReadOnly@QLocalMediaPlaylistProvider@@UBE_NXZ @ 286 NONAME ; bool QLocalMediaPlaylistProvider::isReadOnly(void) const - ?isReadOnly@QMediaPlaylist@@QBE_NXZ @ 287 NONAME ; bool QMediaPlaylist::isReadOnly(void) const - ?isReadOnly@QMediaPlaylistProvider@@UBE_NXZ @ 288 NONAME ; bool QMediaPlaylistProvider::isReadOnly(void) const - ?isReady@QPainterVideoSurface@@QBE_NXZ @ 289 NONAME ; bool QPainterVideoSurface::isReady(void) const - ?isSeekable@QMediaPlayer@@QBE_NXZ @ 290 NONAME ; bool QMediaPlayer::isSeekable(void) const - ?isVideoAvailable@QMediaPlayer@@QBE_NXZ @ 291 NONAME ; bool QMediaPlayer::isVideoAvailable(void) const - ?itemAt@QMediaPlaylistNavigator@@QBE?AVQMediaContent@@H@Z @ 292 NONAME ; class QMediaContent QMediaPlaylistNavigator::itemAt(int) const - ?itemChange@QGraphicsVideoItem@@MAE?AVQVariant@@W4GraphicsItemChange@QGraphicsItem@@ABV2@@Z @ 293 NONAME ; class QVariant QGraphicsVideoItem::itemChange(enum QGraphicsItem::GraphicsItemChange, class QVariant const &) - ?jump@QMediaPlaylistNavigator@@QAEXH@Z @ 294 NONAME ; void QMediaPlaylistNavigator::jump(int) - ?language@QMediaResource@@QBE?AVQString@@XZ @ 295 NONAME ; class QString QMediaResource::language(void) const - ?latestTime@QMediaTimeRange@@QBE_JXZ @ 296 NONAME ; long long QMediaTimeRange::latestTime(void) const - ?load@QMediaPlaylist@@QAEXABVQUrl@@PBD@Z @ 297 NONAME ; void QMediaPlaylist::load(class QUrl const &, char const *) - ?load@QMediaPlaylist@@QAEXPAVQIODevice@@PBD@Z @ 298 NONAME ; void QMediaPlaylist::load(class QIODevice *, char const *) - ?load@QMediaPlaylistProvider@@UAE_NABVQUrl@@PBD@Z @ 299 NONAME ; bool QMediaPlaylistProvider::load(class QUrl const &, char const *) - ?load@QMediaPlaylistProvider@@UAE_NPAVQIODevice@@PBD@Z @ 300 NONAME ; bool QMediaPlaylistProvider::load(class QIODevice *, char const *) - ?loadFailed@QMediaPlaylist@@IAEXXZ @ 301 NONAME ; void QMediaPlaylist::loadFailed(void) - ?loadFailed@QMediaPlaylistProvider@@IAEXW4Error@QMediaPlaylist@@ABVQString@@@Z @ 302 NONAME ; void QMediaPlaylistProvider::loadFailed(enum QMediaPlaylist::Error, class QString const &) - ?loaded@QMediaPlaylist@@IAEXXZ @ 303 NONAME ; void QMediaPlaylist::loaded(void) - ?loaded@QMediaPlaylistProvider@@IAEXXZ @ 304 NONAME ; void QMediaPlaylistProvider::loaded(void) - ?loops@QSoundEffect@@QBEHXZ @ 305 NONAME ; int QSoundEffect::loops(void) const - ?loopsChanged@QSoundEffect@@IAEXXZ @ 306 NONAME ; void QSoundEffect::loopsChanged(void) - ?media@QLocalMediaPlaylistProvider@@UBE?AVQMediaContent@@H@Z @ 307 NONAME ; class QMediaContent QLocalMediaPlaylistProvider::media(int) const - ?media@QMediaPlayer@@QBE?AVQMediaContent@@XZ @ 308 NONAME ; class QMediaContent QMediaPlayer::media(void) const - ?media@QMediaPlaylist@@QBE?AVQMediaContent@@H@Z @ 309 NONAME ; class QMediaContent QMediaPlaylist::media(int) const - ?mediaAboutToBeInserted@QMediaPlaylist@@IAEXHH@Z @ 310 NONAME ; void QMediaPlaylist::mediaAboutToBeInserted(int, int) - ?mediaAboutToBeInserted@QMediaPlaylistProvider@@IAEXHH@Z @ 311 NONAME ; void QMediaPlaylistProvider::mediaAboutToBeInserted(int, int) - ?mediaAboutToBeRemoved@QMediaPlaylist@@IAEXHH@Z @ 312 NONAME ; void QMediaPlaylist::mediaAboutToBeRemoved(int, int) - ?mediaAboutToBeRemoved@QMediaPlaylistProvider@@IAEXHH@Z @ 313 NONAME ; void QMediaPlaylistProvider::mediaAboutToBeRemoved(int, int) - ?mediaChanged@QMediaPlayer@@IAEXABVQMediaContent@@@Z @ 314 NONAME ; void QMediaPlayer::mediaChanged(class QMediaContent const &) - ?mediaChanged@QMediaPlayerControl@@IAEXABVQMediaContent@@@Z @ 315 NONAME ; void QMediaPlayerControl::mediaChanged(class QMediaContent const &) - ?mediaChanged@QMediaPlaylist@@IAEXHH@Z @ 316 NONAME ; void QMediaPlaylist::mediaChanged(int, int) - ?mediaChanged@QMediaPlaylistProvider@@IAEXHH@Z @ 317 NONAME ; void QMediaPlaylistProvider::mediaChanged(int, int) - ?mediaCount@QLocalMediaPlaylistProvider@@UBEHXZ @ 318 NONAME ; int QLocalMediaPlaylistProvider::mediaCount(void) const - ?mediaCount@QMediaPlaylist@@QBEHXZ @ 319 NONAME ; int QMediaPlaylist::mediaCount(void) const - ?mediaInserted@QMediaPlaylist@@IAEXHH@Z @ 320 NONAME ; void QMediaPlaylist::mediaInserted(int, int) - ?mediaInserted@QMediaPlaylistProvider@@IAEXHH@Z @ 321 NONAME ; void QMediaPlaylistProvider::mediaInserted(int, int) - ?mediaObject@QGraphicsVideoItem@@QBEPAVQMediaObject@@XZ @ 322 NONAME ; class QMediaObject * QGraphicsVideoItem::mediaObject(void) const - ?mediaObject@QMediaPlaylist@@QBEPAVQMediaObject@@XZ @ 323 NONAME ; class QMediaObject * QMediaPlaylist::mediaObject(void) const - ?mediaObject@QVideoWidget@@QBEPAVQMediaObject@@XZ @ 324 NONAME ; class QMediaObject * QVideoWidget::mediaObject(void) const - ?mediaRemoved@QMediaPlaylist@@IAEXHH@Z @ 325 NONAME ; void QMediaPlaylist::mediaRemoved(int, int) - ?mediaRemoved@QMediaPlaylistProvider@@IAEXHH@Z @ 326 NONAME ; void QMediaPlaylistProvider::mediaRemoved(int, int) - ?mediaStatus@QMediaPlayer@@QBE?AW4MediaStatus@1@XZ @ 327 NONAME ; enum QMediaPlayer::MediaStatus QMediaPlayer::mediaStatus(void) const - ?mediaStatusChanged@QMediaPlayer@@IAEXW4MediaStatus@1@@Z @ 328 NONAME ; void QMediaPlayer::mediaStatusChanged(enum QMediaPlayer::MediaStatus) - ?mediaStatusChanged@QMediaPlayerControl@@IAEXW4MediaStatus@QMediaPlayer@@@Z @ 329 NONAME ; void QMediaPlayerControl::mediaStatusChanged(enum QMediaPlayer::MediaStatus) - ?mediaStream@QMediaPlayer@@QBEPBVQIODevice@@XZ @ 330 NONAME ; class QIODevice const * QMediaPlayer::mediaStream(void) const - ?metaData@QMediaObject@@QBE?AVQVariant@@W4MetaData@QtMediaServices@@@Z @ 331 NONAME ; class QVariant QMediaObject::metaData(enum QtMediaServices::MetaData) const - ?metaDataAvailableChanged@QMediaObject@@IAEX_N@Z @ 332 NONAME ; void QMediaObject::metaDataAvailableChanged(bool) - ?metaDataAvailableChanged@QMetaDataControl@@IAEX_N@Z @ 333 NONAME ; void QMetaDataControl::metaDataAvailableChanged(bool) - ?metaDataChanged@QMediaObject@@IAEXXZ @ 334 NONAME ; void QMediaObject::metaDataChanged(void) - ?metaDataChanged@QMetaDataControl@@IAEXXZ @ 335 NONAME ; void QMetaDataControl::metaDataChanged(void) - ?metaDataWritableChanged@QMediaObject@@IAEX_N@Z @ 336 NONAME ; void QMediaObject::metaDataWritableChanged(bool) - ?metaObject@QGraphicsVideoItem@@UBEPBUQMetaObject@@XZ @ 337 NONAME ; struct QMetaObject const * QGraphicsVideoItem::metaObject(void) const - ?metaObject@QLocalMediaPlaylistProvider@@UBEPBUQMetaObject@@XZ @ 338 NONAME ; struct QMetaObject const * QLocalMediaPlaylistProvider::metaObject(void) const - ?metaObject@QMediaControl@@UBEPBUQMetaObject@@XZ @ 339 NONAME ; struct QMetaObject const * QMediaControl::metaObject(void) const - ?metaObject@QMediaObject@@UBEPBUQMetaObject@@XZ @ 340 NONAME ; struct QMetaObject const * QMediaObject::metaObject(void) const - ?metaObject@QMediaPlayer@@UBEPBUQMetaObject@@XZ @ 341 NONAME ; struct QMetaObject const * QMediaPlayer::metaObject(void) const - ?metaObject@QMediaPlayerControl@@UBEPBUQMetaObject@@XZ @ 342 NONAME ; struct QMetaObject const * QMediaPlayerControl::metaObject(void) const - ?metaObject@QMediaPlaylist@@UBEPBUQMetaObject@@XZ @ 343 NONAME ; struct QMetaObject const * QMediaPlaylist::metaObject(void) const - ?metaObject@QMediaPlaylistControl@@UBEPBUQMetaObject@@XZ @ 344 NONAME ; struct QMetaObject const * QMediaPlaylistControl::metaObject(void) const - ?metaObject@QMediaPlaylistIOPlugin@@UBEPBUQMetaObject@@XZ @ 345 NONAME ; struct QMetaObject const * QMediaPlaylistIOPlugin::metaObject(void) const - ?metaObject@QMediaPlaylistNavigator@@UBEPBUQMetaObject@@XZ @ 346 NONAME ; struct QMetaObject const * QMediaPlaylistNavigator::metaObject(void) const - ?metaObject@QMediaPlaylistProvider@@UBEPBUQMetaObject@@XZ @ 347 NONAME ; struct QMetaObject const * QMediaPlaylistProvider::metaObject(void) const - ?metaObject@QMediaService@@UBEPBUQMetaObject@@XZ @ 348 NONAME ; struct QMetaObject const * QMediaService::metaObject(void) const - ?metaObject@QMediaServiceProvider@@UBEPBUQMetaObject@@XZ @ 349 NONAME ; struct QMetaObject const * QMediaServiceProvider::metaObject(void) const - ?metaObject@QMediaServiceProviderPlugin@@UBEPBUQMetaObject@@XZ @ 350 NONAME ; struct QMetaObject const * QMediaServiceProviderPlugin::metaObject(void) const - ?metaObject@QMetaDataControl@@UBEPBUQMetaObject@@XZ @ 351 NONAME ; struct QMetaObject const * QMetaDataControl::metaObject(void) const - ?metaObject@QPainterVideoSurface@@UBEPBUQMetaObject@@XZ @ 352 NONAME ; struct QMetaObject const * QPainterVideoSurface::metaObject(void) const - ?metaObject@QSoundEffect@@UBEPBUQMetaObject@@XZ @ 353 NONAME ; struct QMetaObject const * QSoundEffect::metaObject(void) const - ?metaObject@QVideoDeviceControl@@UBEPBUQMetaObject@@XZ @ 354 NONAME ; struct QMetaObject const * QVideoDeviceControl::metaObject(void) const - ?metaObject@QVideoOutputControl@@UBEPBUQMetaObject@@XZ @ 355 NONAME ; struct QMetaObject const * QVideoOutputControl::metaObject(void) const - ?metaObject@QVideoRendererControl@@UBEPBUQMetaObject@@XZ @ 356 NONAME ; struct QMetaObject const * QVideoRendererControl::metaObject(void) const - ?metaObject@QVideoWidget@@UBEPBUQMetaObject@@XZ @ 357 NONAME ; struct QMetaObject const * QVideoWidget::metaObject(void) const - ?metaObject@QVideoWidgetControl@@UBEPBUQMetaObject@@XZ @ 358 NONAME ; struct QMetaObject const * QVideoWidgetControl::metaObject(void) const - ?metaObject@QVideoWindowControl@@UBEPBUQMetaObject@@XZ @ 359 NONAME ; struct QMetaObject const * QVideoWindowControl::metaObject(void) const - ?mimeType@QMediaResource@@QBE?AVQString@@XZ @ 360 NONAME ; class QString QMediaResource::mimeType(void) const - ?mimeType@QMediaServiceProviderHint@@QBE?AVQString@@XZ @ 361 NONAME ; class QString QMediaServiceProviderHint::mimeType(void) const - ?moveEvent@QVideoWidget@@MAEXPAVQMoveEvent@@@Z @ 362 NONAME ; void QVideoWidget::moveEvent(class QMoveEvent *) - ?mutedChanged@QMediaPlayer@@IAEX_N@Z @ 363 NONAME ; void QMediaPlayer::mutedChanged(bool) - ?mutedChanged@QMediaPlayerControl@@IAEX_N@Z @ 364 NONAME ; void QMediaPlayerControl::mutedChanged(bool) - ?mutedChanged@QSoundEffect@@IAEXXZ @ 365 NONAME ; void QSoundEffect::mutedChanged(void) - ?nativeSize@QGraphicsVideoItem@@QBE?AVQSizeF@@XZ @ 366 NONAME ; class QSizeF QGraphicsVideoItem::nativeSize(void) const - ?nativeSizeChanged@QGraphicsVideoItem@@IAEXABVQSizeF@@@Z @ 367 NONAME ; void QGraphicsVideoItem::nativeSizeChanged(class QSizeF const &) - ?nativeSizeChanged@QVideoWindowControl@@IAEXXZ @ 368 NONAME ; void QVideoWindowControl::nativeSizeChanged(void) - ?next@QMediaPlaylist@@QAEXXZ @ 369 NONAME ; void QMediaPlaylist::next(void) - ?next@QMediaPlaylistNavigator@@QAEXXZ @ 370 NONAME ; void QMediaPlaylistNavigator::next(void) - ?nextIndex@QMediaPlaylist@@QBEHH@Z @ 371 NONAME ; int QMediaPlaylist::nextIndex(int) const - ?nextIndex@QMediaPlaylistNavigator@@QBEHH@Z @ 372 NONAME ; int QMediaPlaylistNavigator::nextIndex(int) const - ?nextItem@QMediaPlaylistNavigator@@QBE?AVQMediaContent@@H@Z @ 373 NONAME ; class QMediaContent QMediaPlaylistNavigator::nextItem(int) const - ?normalized@QMediaTimeInterval@@QBE?AV1@XZ @ 374 NONAME ; class QMediaTimeInterval QMediaTimeInterval::normalized(void) const - ?notifyInterval@QMediaObject@@QBEHXZ @ 375 NONAME ; int QMediaObject::notifyInterval(void) const - ?notifyIntervalChanged@QMediaObject@@IAEXH@Z @ 376 NONAME ; void QMediaObject::notifyIntervalChanged(int) - ?offset@QGraphicsVideoItem@@QBE?AVQPointF@@XZ @ 377 NONAME ; class QPointF QGraphicsVideoItem::offset(void) const - ?paint@QGraphicsVideoItem@@UAEXPAVQPainter@@PBVQStyleOptionGraphicsItem@@PAVQWidget@@@Z @ 378 NONAME ; void QGraphicsVideoItem::paint(class QPainter *, class QStyleOptionGraphicsItem const *, class QWidget *) - ?paint@QPainterVideoSurface@@QAEXPAVQPainter@@ABVQRectF@@1@Z @ 379 NONAME ; void QPainterVideoSurface::paint(class QPainter *, class QRectF const &, class QRectF const &) - ?paintEvent@QVideoWidget@@MAEXPAVQPaintEvent@@@Z @ 380 NONAME ; void QVideoWidget::paintEvent(class QPaintEvent *) - ?pause@QMediaPlayer@@QAEXXZ @ 381 NONAME ; void QMediaPlayer::pause(void) - ?play@QMediaPlayer@@QAEXXZ @ 382 NONAME ; void QMediaPlayer::play(void) - ?play@QSoundEffect@@QAEXXZ @ 383 NONAME ; void QSoundEffect::play(void) - ?playbackMode@QMediaPlaylist@@QBE?AW4PlaybackMode@1@XZ @ 384 NONAME ; enum QMediaPlaylist::PlaybackMode QMediaPlaylist::playbackMode(void) const - ?playbackMode@QMediaPlaylistNavigator@@QBE?AW4PlaybackMode@QMediaPlaylist@@XZ @ 385 NONAME ; enum QMediaPlaylist::PlaybackMode QMediaPlaylistNavigator::playbackMode(void) const - ?playbackModeChanged@QMediaPlaylist@@IAEXW4PlaybackMode@1@@Z @ 386 NONAME ; void QMediaPlaylist::playbackModeChanged(enum QMediaPlaylist::PlaybackMode) - ?playbackModeChanged@QMediaPlaylistControl@@IAEXW4PlaybackMode@QMediaPlaylist@@@Z @ 387 NONAME ; void QMediaPlaylistControl::playbackModeChanged(enum QMediaPlaylist::PlaybackMode) - ?playbackModeChanged@QMediaPlaylistNavigator@@IAEXW4PlaybackMode@QMediaPlaylist@@@Z @ 388 NONAME ; void QMediaPlaylistNavigator::playbackModeChanged(enum QMediaPlaylist::PlaybackMode) - ?playbackRate@QMediaPlayer@@QBEMXZ @ 389 NONAME ; float QMediaPlayer::playbackRate(void) const - ?playbackRateChanged@QMediaPlayer@@IAEXM@Z @ 390 NONAME ; void QMediaPlayer::playbackRateChanged(float) - ?playbackRateChanged@QMediaPlayerControl@@IAEXM@Z @ 391 NONAME ; void QMediaPlayerControl::playbackRateChanged(float) - ?playlist@QMediaPlaylistNavigator@@QBEPAVQMediaPlaylistProvider@@XZ @ 392 NONAME ; class QMediaPlaylistProvider * QMediaPlaylistNavigator::playlist(void) const - ?playlistProviderChanged@QMediaPlaylistControl@@IAEXXZ @ 393 NONAME ; void QMediaPlaylistControl::playlistProviderChanged(void) - ?position@QMediaPlayer@@QBE_JXZ @ 394 NONAME ; long long QMediaPlayer::position(void) const - ?positionChanged@QMediaPlayer@@IAEX_J@Z @ 395 NONAME ; void QMediaPlayer::positionChanged(long long) - ?positionChanged@QMediaPlayerControl@@IAEX_J@Z @ 396 NONAME ; void QMediaPlayerControl::positionChanged(long long) - ?present@QPainterVideoSurface@@UAE_NABVQVideoFrame@@@Z @ 397 NONAME ; bool QPainterVideoSurface::present(class QVideoFrame const &) - ?previous@QMediaPlaylist@@QAEXXZ @ 398 NONAME ; void QMediaPlaylist::previous(void) - ?previous@QMediaPlaylistNavigator@@QAEXXZ @ 399 NONAME ; void QMediaPlaylistNavigator::previous(void) - ?previousIndex@QMediaPlaylist@@QBEHH@Z @ 400 NONAME ; int QMediaPlaylist::previousIndex(int) const - ?previousIndex@QMediaPlaylistNavigator@@QBEHH@Z @ 401 NONAME ; int QMediaPlaylistNavigator::previousIndex(int) const - ?previousItem@QMediaPlaylistNavigator@@QBE?AVQMediaContent@@H@Z @ 402 NONAME ; class QMediaContent QMediaPlaylistNavigator::previousItem(int) const - ?qt_metacall@QGraphicsVideoItem@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 403 NONAME ; int QGraphicsVideoItem::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QLocalMediaPlaylistProvider@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 404 NONAME ; int QLocalMediaPlaylistProvider::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 405 NONAME ; int QMediaControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaObject@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 406 NONAME ; int QMediaObject::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlayer@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 407 NONAME ; int QMediaPlayer::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlayerControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 408 NONAME ; int QMediaPlayerControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlaylist@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 409 NONAME ; int QMediaPlaylist::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlaylistControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 410 NONAME ; int QMediaPlaylistControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlaylistIOPlugin@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 411 NONAME ; int QMediaPlaylistIOPlugin::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlaylistNavigator@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 412 NONAME ; int QMediaPlaylistNavigator::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlaylistProvider@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 413 NONAME ; int QMediaPlaylistProvider::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaService@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 414 NONAME ; int QMediaService::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaServiceProvider@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 415 NONAME ; int QMediaServiceProvider::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaServiceProviderPlugin@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 416 NONAME ; int QMediaServiceProviderPlugin::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMetaDataControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 417 NONAME ; int QMetaDataControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QPainterVideoSurface@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 418 NONAME ; int QPainterVideoSurface::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QSoundEffect@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 419 NONAME ; int QSoundEffect::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoDeviceControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 420 NONAME ; int QVideoDeviceControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoOutputControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 421 NONAME ; int QVideoOutputControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoRendererControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 422 NONAME ; int QVideoRendererControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoWidget@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 423 NONAME ; int QVideoWidget::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoWidgetControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 424 NONAME ; int QVideoWidgetControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoWindowControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 425 NONAME ; int QVideoWindowControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacast@QGraphicsVideoItem@@UAEPAXPBD@Z @ 426 NONAME ; void * QGraphicsVideoItem::qt_metacast(char const *) - ?qt_metacast@QLocalMediaPlaylistProvider@@UAEPAXPBD@Z @ 427 NONAME ; void * QLocalMediaPlaylistProvider::qt_metacast(char const *) - ?qt_metacast@QMediaControl@@UAEPAXPBD@Z @ 428 NONAME ; void * QMediaControl::qt_metacast(char const *) - ?qt_metacast@QMediaObject@@UAEPAXPBD@Z @ 429 NONAME ; void * QMediaObject::qt_metacast(char const *) - ?qt_metacast@QMediaPlayer@@UAEPAXPBD@Z @ 430 NONAME ; void * QMediaPlayer::qt_metacast(char const *) - ?qt_metacast@QMediaPlayerControl@@UAEPAXPBD@Z @ 431 NONAME ; void * QMediaPlayerControl::qt_metacast(char const *) - ?qt_metacast@QMediaPlaylist@@UAEPAXPBD@Z @ 432 NONAME ; void * QMediaPlaylist::qt_metacast(char const *) - ?qt_metacast@QMediaPlaylistControl@@UAEPAXPBD@Z @ 433 NONAME ; void * QMediaPlaylistControl::qt_metacast(char const *) - ?qt_metacast@QMediaPlaylistIOPlugin@@UAEPAXPBD@Z @ 434 NONAME ; void * QMediaPlaylistIOPlugin::qt_metacast(char const *) - ?qt_metacast@QMediaPlaylistNavigator@@UAEPAXPBD@Z @ 435 NONAME ; void * QMediaPlaylistNavigator::qt_metacast(char const *) - ?qt_metacast@QMediaPlaylistProvider@@UAEPAXPBD@Z @ 436 NONAME ; void * QMediaPlaylistProvider::qt_metacast(char const *) - ?qt_metacast@QMediaService@@UAEPAXPBD@Z @ 437 NONAME ; void * QMediaService::qt_metacast(char const *) - ?qt_metacast@QMediaServiceProvider@@UAEPAXPBD@Z @ 438 NONAME ; void * QMediaServiceProvider::qt_metacast(char const *) - ?qt_metacast@QMediaServiceProviderPlugin@@UAEPAXPBD@Z @ 439 NONAME ; void * QMediaServiceProviderPlugin::qt_metacast(char const *) - ?qt_metacast@QMetaDataControl@@UAEPAXPBD@Z @ 440 NONAME ; void * QMetaDataControl::qt_metacast(char const *) - ?qt_metacast@QPainterVideoSurface@@UAEPAXPBD@Z @ 441 NONAME ; void * QPainterVideoSurface::qt_metacast(char const *) - ?qt_metacast@QSoundEffect@@UAEPAXPBD@Z @ 442 NONAME ; void * QSoundEffect::qt_metacast(char const *) - ?qt_metacast@QVideoDeviceControl@@UAEPAXPBD@Z @ 443 NONAME ; void * QVideoDeviceControl::qt_metacast(char const *) - ?qt_metacast@QVideoOutputControl@@UAEPAXPBD@Z @ 444 NONAME ; void * QVideoOutputControl::qt_metacast(char const *) - ?qt_metacast@QVideoRendererControl@@UAEPAXPBD@Z @ 445 NONAME ; void * QVideoRendererControl::qt_metacast(char const *) - ?qt_metacast@QVideoWidget@@UAEPAXPBD@Z @ 446 NONAME ; void * QVideoWidget::qt_metacast(char const *) - ?qt_metacast@QVideoWidgetControl@@UAEPAXPBD@Z @ 447 NONAME ; void * QVideoWidgetControl::qt_metacast(char const *) - ?qt_metacast@QVideoWindowControl@@UAEPAXPBD@Z @ 448 NONAME ; void * QVideoWindowControl::qt_metacast(char const *) - ?removeInterval@QMediaTimeRange@@QAEXABVQMediaTimeInterval@@@Z @ 449 NONAME ; void QMediaTimeRange::removeInterval(class QMediaTimeInterval const &) - ?removeInterval@QMediaTimeRange@@QAEX_J0@Z @ 450 NONAME ; void QMediaTimeRange::removeInterval(long long, long long) - ?removeMedia@QLocalMediaPlaylistProvider@@UAE_NH@Z @ 451 NONAME ; bool QLocalMediaPlaylistProvider::removeMedia(int) - ?removeMedia@QLocalMediaPlaylistProvider@@UAE_NHH@Z @ 452 NONAME ; bool QLocalMediaPlaylistProvider::removeMedia(int, int) - ?removeMedia@QMediaPlaylist@@QAE_NH@Z @ 453 NONAME ; bool QMediaPlaylist::removeMedia(int) - ?removeMedia@QMediaPlaylist@@QAE_NHH@Z @ 454 NONAME ; bool QMediaPlaylist::removeMedia(int, int) - ?removeMedia@QMediaPlaylistProvider@@UAE_NH@Z @ 455 NONAME ; bool QMediaPlaylistProvider::removeMedia(int) - ?removeMedia@QMediaPlaylistProvider@@UAE_NHH@Z @ 456 NONAME ; bool QMediaPlaylistProvider::removeMedia(int, int) - ?removePropertyWatch@QMediaObject@@IAEXABVQByteArray@@@Z @ 457 NONAME ; void QMediaObject::removePropertyWatch(class QByteArray const &) - ?removeTimeRange@QMediaTimeRange@@QAEXABV1@@Z @ 458 NONAME ; void QMediaTimeRange::removeTimeRange(class QMediaTimeRange const &) - ?request@QMediaResource@@QBE?AVQNetworkRequest@@XZ @ 459 NONAME ; class QNetworkRequest QMediaResource::request(void) const - ?resizeEvent@QVideoWidget@@MAEXPAVQResizeEvent@@@Z @ 460 NONAME ; void QVideoWidget::resizeEvent(class QResizeEvent *) - ?resolution@QMediaResource@@QBE?AVQSize@@XZ @ 461 NONAME ; class QSize QMediaResource::resolution(void) const - ?resources@QMediaContent@@QBE?AV?$QList@VQMediaResource@@@@XZ @ 462 NONAME ; class QList QMediaContent::resources(void) const - ?sampleRate@QMediaResource@@QBEHXZ @ 463 NONAME ; int QMediaResource::sampleRate(void) const - ?saturation@QPainterVideoSurface@@QBEHXZ @ 464 NONAME ; int QPainterVideoSurface::saturation(void) const - ?saturation@QVideoWidget@@QBEHXZ @ 465 NONAME ; int QVideoWidget::saturation(void) const - ?saturationChanged@QVideoWidget@@IAEXH@Z @ 466 NONAME ; void QVideoWidget::saturationChanged(int) - ?saturationChanged@QVideoWidgetControl@@IAEXH@Z @ 467 NONAME ; void QVideoWidgetControl::saturationChanged(int) - ?saturationChanged@QVideoWindowControl@@IAEXH@Z @ 468 NONAME ; void QVideoWindowControl::saturationChanged(int) - ?save@QMediaPlaylist@@QAE_NABVQUrl@@PBD@Z @ 469 NONAME ; bool QMediaPlaylist::save(class QUrl const &, char const *) - ?save@QMediaPlaylist@@QAE_NPAVQIODevice@@PBD@Z @ 470 NONAME ; bool QMediaPlaylist::save(class QIODevice *, char const *) - ?save@QMediaPlaylistProvider@@UAE_NABVQUrl@@PBD@Z @ 471 NONAME ; bool QMediaPlaylistProvider::save(class QUrl const &, char const *) - ?save@QMediaPlaylistProvider@@UAE_NPAVQIODevice@@PBD@Z @ 472 NONAME ; bool QMediaPlaylistProvider::save(class QIODevice *, char const *) - ?sceneEvent@QGraphicsVideoItem@@MAE_NPAVQEvent@@@Z @ 473 NONAME ; bool QGraphicsVideoItem::sceneEvent(class QEvent *) - ?seekableChanged@QMediaPlayer@@IAEX_N@Z @ 474 NONAME ; void QMediaPlayer::seekableChanged(bool) - ?seekableChanged@QMediaPlayerControl@@IAEX_N@Z @ 475 NONAME ; void QMediaPlayerControl::seekableChanged(bool) - ?selectedDeviceChanged@QVideoDeviceControl@@IAEXABVQString@@@Z @ 476 NONAME ; void QVideoDeviceControl::selectedDeviceChanged(class QString const &) - ?selectedDeviceChanged@QVideoDeviceControl@@IAEXH@Z @ 477 NONAME ; void QVideoDeviceControl::selectedDeviceChanged(int) - ?service@QMediaObject@@UBEPAVQMediaService@@XZ @ 478 NONAME ; class QMediaService * QMediaObject::service(void) const - ?setAspectRatioMode@QGraphicsVideoItem@@QAEXW4AspectRatioMode@Qt@@@Z @ 479 NONAME ; void QGraphicsVideoItem::setAspectRatioMode(enum Qt::AspectRatioMode) - ?setAspectRatioMode@QVideoWidget@@QAEXW4AspectRatioMode@Qt@@@Z @ 480 NONAME ; void QVideoWidget::setAspectRatioMode(enum Qt::AspectRatioMode) - ?setAudioBitRate@QMediaResource@@QAEXH@Z @ 481 NONAME ; void QMediaResource::setAudioBitRate(int) - ?setAudioCodec@QMediaResource@@QAEXABVQString@@@Z @ 482 NONAME ; void QMediaResource::setAudioCodec(class QString const &) - ?setBrightness@QPainterVideoSurface@@QAEXH@Z @ 483 NONAME ; void QPainterVideoSurface::setBrightness(int) - ?setBrightness@QVideoWidget@@QAEXH@Z @ 484 NONAME ; void QVideoWidget::setBrightness(int) - ?setChannelCount@QMediaResource@@QAEXH@Z @ 485 NONAME ; void QMediaResource::setChannelCount(int) - ?setContrast@QPainterVideoSurface@@QAEXH@Z @ 486 NONAME ; void QPainterVideoSurface::setContrast(int) - ?setContrast@QVideoWidget@@QAEXH@Z @ 487 NONAME ; void QVideoWidget::setContrast(int) - ?setCurrentIndex@QMediaPlaylist@@QAEXH@Z @ 488 NONAME ; void QMediaPlaylist::setCurrentIndex(int) - ?setDataSize@QMediaResource@@QAEX_J@Z @ 489 NONAME ; void QMediaResource::setDataSize(long long) - ?setExtendedMetaData@QMediaObject@@QAEXABVQString@@ABVQVariant@@@Z @ 490 NONAME ; void QMediaObject::setExtendedMetaData(class QString const &, class QVariant const &) - ?setFullScreen@QVideoWidget@@QAEX_N@Z @ 491 NONAME ; void QVideoWidget::setFullScreen(bool) - ?setHue@QPainterVideoSurface@@QAEXH@Z @ 492 NONAME ; void QPainterVideoSurface::setHue(int) - ?setHue@QVideoWidget@@QAEXH@Z @ 493 NONAME ; void QVideoWidget::setHue(int) - ?setLanguage@QMediaResource@@QAEXABVQString@@@Z @ 494 NONAME ; void QMediaResource::setLanguage(class QString const &) - ?setLoops@QSoundEffect@@QAEXH@Z @ 495 NONAME ; void QSoundEffect::setLoops(int) - ?setMedia@QMediaPlayer@@QAEXABVQMediaContent@@PAVQIODevice@@@Z @ 496 NONAME ; void QMediaPlayer::setMedia(class QMediaContent const &, class QIODevice *) - ?setMediaObject@QGraphicsVideoItem@@QAEXPAVQMediaObject@@@Z @ 497 NONAME ; void QGraphicsVideoItem::setMediaObject(class QMediaObject *) - ?setMediaObject@QMediaPlaylist@@QAEXPAVQMediaObject@@@Z @ 498 NONAME ; void QMediaPlaylist::setMediaObject(class QMediaObject *) - ?setMediaObject@QVideoWidget@@QAEXPAVQMediaObject@@@Z @ 499 NONAME ; void QVideoWidget::setMediaObject(class QMediaObject *) - ?setMetaData@QMediaObject@@QAEXW4MetaData@QtMediaServices@@ABVQVariant@@@Z @ 500 NONAME ; void QMediaObject::setMetaData(enum QtMediaServices::MetaData, class QVariant const &) - ?setMuted@QMediaPlayer@@QAEX_N@Z @ 501 NONAME ; void QMediaPlayer::setMuted(bool) - ?setMuted@QSoundEffect@@QAEX_N@Z @ 502 NONAME ; void QSoundEffect::setMuted(bool) - ?setNotifyInterval@QMediaObject@@QAEXH@Z @ 503 NONAME ; void QMediaObject::setNotifyInterval(int) - ?setOffset@QGraphicsVideoItem@@QAEXABVQPointF@@@Z @ 504 NONAME ; void QGraphicsVideoItem::setOffset(class QPointF const &) - ?setPlaybackMode@QMediaPlaylist@@QAEXW4PlaybackMode@1@@Z @ 505 NONAME ; void QMediaPlaylist::setPlaybackMode(enum QMediaPlaylist::PlaybackMode) - ?setPlaybackMode@QMediaPlaylistNavigator@@QAEXW4PlaybackMode@QMediaPlaylist@@@Z @ 506 NONAME ; void QMediaPlaylistNavigator::setPlaybackMode(enum QMediaPlaylist::PlaybackMode) - ?setPlaybackRate@QMediaPlayer@@QAEXM@Z @ 507 NONAME ; void QMediaPlayer::setPlaybackRate(float) - ?setPlaylist@QMediaPlaylistNavigator@@QAEXPAVQMediaPlaylistProvider@@@Z @ 508 NONAME ; void QMediaPlaylistNavigator::setPlaylist(class QMediaPlaylistProvider *) - ?setPosition@QMediaPlayer@@QAEX_J@Z @ 509 NONAME ; void QMediaPlayer::setPosition(long long) - ?setReady@QPainterVideoSurface@@QAEX_N@Z @ 510 NONAME ; void QPainterVideoSurface::setReady(bool) - ?setResolution@QMediaResource@@QAEXABVQSize@@@Z @ 511 NONAME ; void QMediaResource::setResolution(class QSize const &) - ?setResolution@QMediaResource@@QAEXHH@Z @ 512 NONAME ; void QMediaResource::setResolution(int, int) - ?setSampleRate@QMediaResource@@QAEXH@Z @ 513 NONAME ; void QMediaResource::setSampleRate(int) - ?setSaturation@QPainterVideoSurface@@QAEXH@Z @ 514 NONAME ; void QPainterVideoSurface::setSaturation(int) - ?setSaturation@QVideoWidget@@QAEXH@Z @ 515 NONAME ; void QVideoWidget::setSaturation(int) - ?setSize@QGraphicsVideoItem@@QAEXABVQSizeF@@@Z @ 516 NONAME ; void QGraphicsVideoItem::setSize(class QSizeF const &) - ?setSource@QSoundEffect@@QAEXABVQUrl@@@Z @ 517 NONAME ; void QSoundEffect::setSource(class QUrl const &) - ?setVideoBitRate@QMediaResource@@QAEXH@Z @ 518 NONAME ; void QMediaResource::setVideoBitRate(int) - ?setVideoCodec@QMediaResource@@QAEXABVQString@@@Z @ 519 NONAME ; void QMediaResource::setVideoCodec(class QString const &) - ?setVolume@QMediaPlayer@@QAEXH@Z @ 520 NONAME ; void QMediaPlayer::setVolume(int) - ?setVolume@QSoundEffect@@QAEXH@Z @ 521 NONAME ; void QSoundEffect::setVolume(int) - ?setupMetaData@QMediaObject@@AAEXXZ @ 522 NONAME ; void QMediaObject::setupMetaData(void) - ?showEvent@QVideoWidget@@MAEXPAVQShowEvent@@@Z @ 523 NONAME ; void QVideoWidget::showEvent(class QShowEvent *) - ?shuffle@QLocalMediaPlaylistProvider@@UAEXXZ @ 524 NONAME ; void QLocalMediaPlaylistProvider::shuffle(void) - ?shuffle@QMediaPlaylist@@QAEXXZ @ 525 NONAME ; void QMediaPlaylist::shuffle(void) - ?shuffle@QMediaPlaylistProvider@@UAEXXZ @ 526 NONAME ; void QMediaPlaylistProvider::shuffle(void) - ?size@QGraphicsVideoItem@@QBE?AVQSizeF@@XZ @ 527 NONAME ; class QSizeF QGraphicsVideoItem::size(void) const - ?sizeHint@QVideoWidget@@UBE?AVQSize@@XZ @ 528 NONAME ; class QSize QVideoWidget::sizeHint(void) const - ?source@QSoundEffect@@QBE?AVQUrl@@XZ @ 529 NONAME ; class QUrl QSoundEffect::source(void) const - ?sourceChanged@QSoundEffect@@IAEXXZ @ 530 NONAME ; void QSoundEffect::sourceChanged(void) - ?start@QMediaTimeInterval@@QBE_JXZ @ 531 NONAME ; long long QMediaTimeInterval::start(void) const - ?start@QPainterVideoSurface@@UAE_NABVQVideoSurfaceFormat@@@Z @ 532 NONAME ; bool QPainterVideoSurface::start(class QVideoSurfaceFormat const &) - ?state@QMediaPlayer@@QBE?AW4State@1@XZ @ 533 NONAME ; enum QMediaPlayer::State QMediaPlayer::state(void) const - ?stateChanged@QMediaPlayer@@IAEXW4State@1@@Z @ 534 NONAME ; void QMediaPlayer::stateChanged(enum QMediaPlayer::State) - ?stateChanged@QMediaPlayerControl@@IAEXW4State@QMediaPlayer@@@Z @ 535 NONAME ; void QMediaPlayerControl::stateChanged(enum QMediaPlayer::State) - ?stop@QMediaPlayer@@QAEXXZ @ 536 NONAME ; void QMediaPlayer::stop(void) - ?stop@QPainterVideoSurface@@UAEXXZ @ 537 NONAME ; void QPainterVideoSurface::stop(void) - ?supportedMimeTypes@QMediaPlayer@@SA?AVQStringList@@V?$QFlags@W4Flag@QMediaPlayer@@@@@Z @ 538 NONAME ; class QStringList QMediaPlayer::supportedMimeTypes(class QFlags) - ?supportedMimeTypes@QMediaServiceProvider@@UBE?AVQStringList@@ABVQByteArray@@H@Z @ 539 NONAME ; class QStringList QMediaServiceProvider::supportedMimeTypes(class QByteArray const &, int) const - ?supportedPixelFormats@QPainterVideoSurface@@UBE?AV?$QList@W4PixelFormat@QVideoFrame@@@@W4HandleType@QAbstractVideoBuffer@@@Z @ 540 NONAME ; class QList QPainterVideoSurface::supportedPixelFormats(enum QAbstractVideoBuffer::HandleType) const - ?surroundingItemsChanged@QMediaPlaylistNavigator@@IAEXXZ @ 541 NONAME ; void QMediaPlaylistNavigator::surroundingItemsChanged(void) - ?tr@QGraphicsVideoItem@@SA?AVQString@@PBD0@Z @ 542 NONAME ; class QString QGraphicsVideoItem::tr(char const *, char const *) - ?tr@QGraphicsVideoItem@@SA?AVQString@@PBD0H@Z @ 543 NONAME ; class QString QGraphicsVideoItem::tr(char const *, char const *, int) - ?tr@QLocalMediaPlaylistProvider@@SA?AVQString@@PBD0@Z @ 544 NONAME ; class QString QLocalMediaPlaylistProvider::tr(char const *, char const *) - ?tr@QLocalMediaPlaylistProvider@@SA?AVQString@@PBD0H@Z @ 545 NONAME ; class QString QLocalMediaPlaylistProvider::tr(char const *, char const *, int) - ?tr@QMediaControl@@SA?AVQString@@PBD0@Z @ 546 NONAME ; class QString QMediaControl::tr(char const *, char const *) - ?tr@QMediaControl@@SA?AVQString@@PBD0H@Z @ 547 NONAME ; class QString QMediaControl::tr(char const *, char const *, int) - ?tr@QMediaObject@@SA?AVQString@@PBD0@Z @ 548 NONAME ; class QString QMediaObject::tr(char const *, char const *) - ?tr@QMediaObject@@SA?AVQString@@PBD0H@Z @ 549 NONAME ; class QString QMediaObject::tr(char const *, char const *, int) - ?tr@QMediaPlayer@@SA?AVQString@@PBD0@Z @ 550 NONAME ; class QString QMediaPlayer::tr(char const *, char const *) - ?tr@QMediaPlayer@@SA?AVQString@@PBD0H@Z @ 551 NONAME ; class QString QMediaPlayer::tr(char const *, char const *, int) - ?tr@QMediaPlayerControl@@SA?AVQString@@PBD0@Z @ 552 NONAME ; class QString QMediaPlayerControl::tr(char const *, char const *) - ?tr@QMediaPlayerControl@@SA?AVQString@@PBD0H@Z @ 553 NONAME ; class QString QMediaPlayerControl::tr(char const *, char const *, int) - ?tr@QMediaPlaylist@@SA?AVQString@@PBD0@Z @ 554 NONAME ; class QString QMediaPlaylist::tr(char const *, char const *) - ?tr@QMediaPlaylist@@SA?AVQString@@PBD0H@Z @ 555 NONAME ; class QString QMediaPlaylist::tr(char const *, char const *, int) - ?tr@QMediaPlaylistControl@@SA?AVQString@@PBD0@Z @ 556 NONAME ; class QString QMediaPlaylistControl::tr(char const *, char const *) - ?tr@QMediaPlaylistControl@@SA?AVQString@@PBD0H@Z @ 557 NONAME ; class QString QMediaPlaylistControl::tr(char const *, char const *, int) - ?tr@QMediaPlaylistIOPlugin@@SA?AVQString@@PBD0@Z @ 558 NONAME ; class QString QMediaPlaylistIOPlugin::tr(char const *, char const *) - ?tr@QMediaPlaylistIOPlugin@@SA?AVQString@@PBD0H@Z @ 559 NONAME ; class QString QMediaPlaylistIOPlugin::tr(char const *, char const *, int) - ?tr@QMediaPlaylistNavigator@@SA?AVQString@@PBD0@Z @ 560 NONAME ; class QString QMediaPlaylistNavigator::tr(char const *, char const *) - ?tr@QMediaPlaylistNavigator@@SA?AVQString@@PBD0H@Z @ 561 NONAME ; class QString QMediaPlaylistNavigator::tr(char const *, char const *, int) - ?tr@QMediaPlaylistProvider@@SA?AVQString@@PBD0@Z @ 562 NONAME ; class QString QMediaPlaylistProvider::tr(char const *, char const *) - ?tr@QMediaPlaylistProvider@@SA?AVQString@@PBD0H@Z @ 563 NONAME ; class QString QMediaPlaylistProvider::tr(char const *, char const *, int) - ?tr@QMediaService@@SA?AVQString@@PBD0@Z @ 564 NONAME ; class QString QMediaService::tr(char const *, char const *) - ?tr@QMediaService@@SA?AVQString@@PBD0H@Z @ 565 NONAME ; class QString QMediaService::tr(char const *, char const *, int) - ?tr@QMediaServiceProvider@@SA?AVQString@@PBD0@Z @ 566 NONAME ; class QString QMediaServiceProvider::tr(char const *, char const *) - ?tr@QMediaServiceProvider@@SA?AVQString@@PBD0H@Z @ 567 NONAME ; class QString QMediaServiceProvider::tr(char const *, char const *, int) - ?tr@QMediaServiceProviderPlugin@@SA?AVQString@@PBD0@Z @ 568 NONAME ; class QString QMediaServiceProviderPlugin::tr(char const *, char const *) - ?tr@QMediaServiceProviderPlugin@@SA?AVQString@@PBD0H@Z @ 569 NONAME ; class QString QMediaServiceProviderPlugin::tr(char const *, char const *, int) - ?tr@QMetaDataControl@@SA?AVQString@@PBD0@Z @ 570 NONAME ; class QString QMetaDataControl::tr(char const *, char const *) - ?tr@QMetaDataControl@@SA?AVQString@@PBD0H@Z @ 571 NONAME ; class QString QMetaDataControl::tr(char const *, char const *, int) - ?tr@QPainterVideoSurface@@SA?AVQString@@PBD0@Z @ 572 NONAME ; class QString QPainterVideoSurface::tr(char const *, char const *) - ?tr@QPainterVideoSurface@@SA?AVQString@@PBD0H@Z @ 573 NONAME ; class QString QPainterVideoSurface::tr(char const *, char const *, int) - ?tr@QSoundEffect@@SA?AVQString@@PBD0@Z @ 574 NONAME ; class QString QSoundEffect::tr(char const *, char const *) - ?tr@QSoundEffect@@SA?AVQString@@PBD0H@Z @ 575 NONAME ; class QString QSoundEffect::tr(char const *, char const *, int) - ?tr@QVideoDeviceControl@@SA?AVQString@@PBD0@Z @ 576 NONAME ; class QString QVideoDeviceControl::tr(char const *, char const *) - ?tr@QVideoDeviceControl@@SA?AVQString@@PBD0H@Z @ 577 NONAME ; class QString QVideoDeviceControl::tr(char const *, char const *, int) - ?tr@QVideoOutputControl@@SA?AVQString@@PBD0@Z @ 578 NONAME ; class QString QVideoOutputControl::tr(char const *, char const *) - ?tr@QVideoOutputControl@@SA?AVQString@@PBD0H@Z @ 579 NONAME ; class QString QVideoOutputControl::tr(char const *, char const *, int) - ?tr@QVideoRendererControl@@SA?AVQString@@PBD0@Z @ 580 NONAME ; class QString QVideoRendererControl::tr(char const *, char const *) - ?tr@QVideoRendererControl@@SA?AVQString@@PBD0H@Z @ 581 NONAME ; class QString QVideoRendererControl::tr(char const *, char const *, int) - ?tr@QVideoWidget@@SA?AVQString@@PBD0@Z @ 582 NONAME ; class QString QVideoWidget::tr(char const *, char const *) - ?tr@QVideoWidget@@SA?AVQString@@PBD0H@Z @ 583 NONAME ; class QString QVideoWidget::tr(char const *, char const *, int) - ?tr@QVideoWidgetControl@@SA?AVQString@@PBD0@Z @ 584 NONAME ; class QString QVideoWidgetControl::tr(char const *, char const *) - ?tr@QVideoWidgetControl@@SA?AVQString@@PBD0H@Z @ 585 NONAME ; class QString QVideoWidgetControl::tr(char const *, char const *, int) - ?tr@QVideoWindowControl@@SA?AVQString@@PBD0@Z @ 586 NONAME ; class QString QVideoWindowControl::tr(char const *, char const *) - ?tr@QVideoWindowControl@@SA?AVQString@@PBD0H@Z @ 587 NONAME ; class QString QVideoWindowControl::tr(char const *, char const *, int) - ?trUtf8@QGraphicsVideoItem@@SA?AVQString@@PBD0@Z @ 588 NONAME ; class QString QGraphicsVideoItem::trUtf8(char const *, char const *) - ?trUtf8@QGraphicsVideoItem@@SA?AVQString@@PBD0H@Z @ 589 NONAME ; class QString QGraphicsVideoItem::trUtf8(char const *, char const *, int) - ?trUtf8@QLocalMediaPlaylistProvider@@SA?AVQString@@PBD0@Z @ 590 NONAME ; class QString QLocalMediaPlaylistProvider::trUtf8(char const *, char const *) - ?trUtf8@QLocalMediaPlaylistProvider@@SA?AVQString@@PBD0H@Z @ 591 NONAME ; class QString QLocalMediaPlaylistProvider::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaControl@@SA?AVQString@@PBD0@Z @ 592 NONAME ; class QString QMediaControl::trUtf8(char const *, char const *) - ?trUtf8@QMediaControl@@SA?AVQString@@PBD0H@Z @ 593 NONAME ; class QString QMediaControl::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaObject@@SA?AVQString@@PBD0@Z @ 594 NONAME ; class QString QMediaObject::trUtf8(char const *, char const *) - ?trUtf8@QMediaObject@@SA?AVQString@@PBD0H@Z @ 595 NONAME ; class QString QMediaObject::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlayer@@SA?AVQString@@PBD0@Z @ 596 NONAME ; class QString QMediaPlayer::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlayer@@SA?AVQString@@PBD0H@Z @ 597 NONAME ; class QString QMediaPlayer::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlayerControl@@SA?AVQString@@PBD0@Z @ 598 NONAME ; class QString QMediaPlayerControl::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlayerControl@@SA?AVQString@@PBD0H@Z @ 599 NONAME ; class QString QMediaPlayerControl::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlaylist@@SA?AVQString@@PBD0@Z @ 600 NONAME ; class QString QMediaPlaylist::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlaylist@@SA?AVQString@@PBD0H@Z @ 601 NONAME ; class QString QMediaPlaylist::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlaylistControl@@SA?AVQString@@PBD0@Z @ 602 NONAME ; class QString QMediaPlaylistControl::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlaylistControl@@SA?AVQString@@PBD0H@Z @ 603 NONAME ; class QString QMediaPlaylistControl::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlaylistIOPlugin@@SA?AVQString@@PBD0@Z @ 604 NONAME ; class QString QMediaPlaylistIOPlugin::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlaylistIOPlugin@@SA?AVQString@@PBD0H@Z @ 605 NONAME ; class QString QMediaPlaylistIOPlugin::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlaylistNavigator@@SA?AVQString@@PBD0@Z @ 606 NONAME ; class QString QMediaPlaylistNavigator::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlaylistNavigator@@SA?AVQString@@PBD0H@Z @ 607 NONAME ; class QString QMediaPlaylistNavigator::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlaylistProvider@@SA?AVQString@@PBD0@Z @ 608 NONAME ; class QString QMediaPlaylistProvider::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlaylistProvider@@SA?AVQString@@PBD0H@Z @ 609 NONAME ; class QString QMediaPlaylistProvider::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaService@@SA?AVQString@@PBD0@Z @ 610 NONAME ; class QString QMediaService::trUtf8(char const *, char const *) - ?trUtf8@QMediaService@@SA?AVQString@@PBD0H@Z @ 611 NONAME ; class QString QMediaService::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaServiceProvider@@SA?AVQString@@PBD0@Z @ 612 NONAME ; class QString QMediaServiceProvider::trUtf8(char const *, char const *) - ?trUtf8@QMediaServiceProvider@@SA?AVQString@@PBD0H@Z @ 613 NONAME ; class QString QMediaServiceProvider::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaServiceProviderPlugin@@SA?AVQString@@PBD0@Z @ 614 NONAME ; class QString QMediaServiceProviderPlugin::trUtf8(char const *, char const *) - ?trUtf8@QMediaServiceProviderPlugin@@SA?AVQString@@PBD0H@Z @ 615 NONAME ; class QString QMediaServiceProviderPlugin::trUtf8(char const *, char const *, int) - ?trUtf8@QMetaDataControl@@SA?AVQString@@PBD0@Z @ 616 NONAME ; class QString QMetaDataControl::trUtf8(char const *, char const *) - ?trUtf8@QMetaDataControl@@SA?AVQString@@PBD0H@Z @ 617 NONAME ; class QString QMetaDataControl::trUtf8(char const *, char const *, int) - ?trUtf8@QPainterVideoSurface@@SA?AVQString@@PBD0@Z @ 618 NONAME ; class QString QPainterVideoSurface::trUtf8(char const *, char const *) - ?trUtf8@QPainterVideoSurface@@SA?AVQString@@PBD0H@Z @ 619 NONAME ; class QString QPainterVideoSurface::trUtf8(char const *, char const *, int) - ?trUtf8@QSoundEffect@@SA?AVQString@@PBD0@Z @ 620 NONAME ; class QString QSoundEffect::trUtf8(char const *, char const *) - ?trUtf8@QSoundEffect@@SA?AVQString@@PBD0H@Z @ 621 NONAME ; class QString QSoundEffect::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoDeviceControl@@SA?AVQString@@PBD0@Z @ 622 NONAME ; class QString QVideoDeviceControl::trUtf8(char const *, char const *) - ?trUtf8@QVideoDeviceControl@@SA?AVQString@@PBD0H@Z @ 623 NONAME ; class QString QVideoDeviceControl::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoOutputControl@@SA?AVQString@@PBD0@Z @ 624 NONAME ; class QString QVideoOutputControl::trUtf8(char const *, char const *) - ?trUtf8@QVideoOutputControl@@SA?AVQString@@PBD0H@Z @ 625 NONAME ; class QString QVideoOutputControl::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoRendererControl@@SA?AVQString@@PBD0@Z @ 626 NONAME ; class QString QVideoRendererControl::trUtf8(char const *, char const *) - ?trUtf8@QVideoRendererControl@@SA?AVQString@@PBD0H@Z @ 627 NONAME ; class QString QVideoRendererControl::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoWidget@@SA?AVQString@@PBD0@Z @ 628 NONAME ; class QString QVideoWidget::trUtf8(char const *, char const *) - ?trUtf8@QVideoWidget@@SA?AVQString@@PBD0H@Z @ 629 NONAME ; class QString QVideoWidget::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoWidgetControl@@SA?AVQString@@PBD0@Z @ 630 NONAME ; class QString QVideoWidgetControl::trUtf8(char const *, char const *) - ?trUtf8@QVideoWidgetControl@@SA?AVQString@@PBD0H@Z @ 631 NONAME ; class QString QVideoWidgetControl::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoWindowControl@@SA?AVQString@@PBD0@Z @ 632 NONAME ; class QString QVideoWindowControl::trUtf8(char const *, char const *) - ?trUtf8@QVideoWindowControl@@SA?AVQString@@PBD0H@Z @ 633 NONAME ; class QString QVideoWindowControl::trUtf8(char const *, char const *, int) - ?translated@QMediaTimeInterval@@QBE?AV1@_J@Z @ 634 NONAME ; class QMediaTimeInterval QMediaTimeInterval::translated(long long) const - ?type@QMediaServiceProviderHint@@QBE?AW4Type@1@XZ @ 635 NONAME ; enum QMediaServiceProviderHint::Type QMediaServiceProviderHint::type(void) const - ?unbind@QMediaObject@@UAEXPAVQObject@@@Z @ 636 NONAME ; void QMediaObject::unbind(class QObject *) - ?unbind@QMediaPlayer@@UAEXPAVQObject@@@Z @ 637 NONAME ; void QMediaPlayer::unbind(class QObject *) - ?url@QMediaResource@@QBE?AVQUrl@@XZ @ 638 NONAME ; class QUrl QMediaResource::url(void) const - ?videoAvailableChanged@QMediaPlayer@@IAEX_N@Z @ 639 NONAME ; void QMediaPlayer::videoAvailableChanged(bool) - ?videoAvailableChanged@QMediaPlayerControl@@IAEX_N@Z @ 640 NONAME ; void QMediaPlayerControl::videoAvailableChanged(bool) - ?videoBitRate@QMediaResource@@QBEHXZ @ 641 NONAME ; int QMediaResource::videoBitRate(void) const - ?videoCodec@QMediaResource@@QBE?AVQString@@XZ @ 642 NONAME ; class QString QMediaResource::videoCodec(void) const - ?volume@QMediaPlayer@@QBEHXZ @ 643 NONAME ; int QMediaPlayer::volume(void) const - ?volume@QSoundEffect@@QBEHXZ @ 644 NONAME ; int QSoundEffect::volume(void) const - ?volumeChanged@QMediaPlayer@@IAEXH@Z @ 645 NONAME ; void QMediaPlayer::volumeChanged(int) - ?volumeChanged@QMediaPlayerControl@@IAEXH@Z @ 646 NONAME ; void QMediaPlayerControl::volumeChanged(int) - ?volumeChanged@QSoundEffect@@IAEXXZ @ 647 NONAME ; void QSoundEffect::volumeChanged(void) - ?writableChanged@QMetaDataControl@@IAEX_N@Z @ 648 NONAME ; void QMetaDataControl::writableChanged(bool) - ?staticMetaObject@QMediaPlaylistProvider@@2UQMetaObject@@B @ 649 NONAME ; struct QMetaObject const QMediaPlaylistProvider::staticMetaObject - ?staticMetaObject@QSoundEffect@@2UQMetaObject@@B @ 650 NONAME ; struct QMetaObject const QSoundEffect::staticMetaObject - ?staticMetaObject@QVideoWidget@@2UQMetaObject@@B @ 651 NONAME ; struct QMetaObject const QVideoWidget::staticMetaObject - ?staticMetaObject@QMediaPlaylistControl@@2UQMetaObject@@B @ 652 NONAME ; struct QMetaObject const QMediaPlaylistControl::staticMetaObject - ?staticMetaObject@QMediaControl@@2UQMetaObject@@B @ 653 NONAME ; struct QMetaObject const QMediaControl::staticMetaObject - ?staticMetaObject@QLocalMediaPlaylistProvider@@2UQMetaObject@@B @ 654 NONAME ; struct QMetaObject const QLocalMediaPlaylistProvider::staticMetaObject - ?staticMetaObject@QMediaServiceProviderPlugin@@2UQMetaObject@@B @ 655 NONAME ; struct QMetaObject const QMediaServiceProviderPlugin::staticMetaObject - ?staticMetaObject@QVideoOutputControl@@2UQMetaObject@@B @ 656 NONAME ; struct QMetaObject const QVideoOutputControl::staticMetaObject - ?staticMetaObject@QMetaDataControl@@2UQMetaObject@@B @ 657 NONAME ; struct QMetaObject const QMetaDataControl::staticMetaObject - ?staticMetaObject@QMediaPlayer@@2UQMetaObject@@B @ 658 NONAME ; struct QMetaObject const QMediaPlayer::staticMetaObject - ?staticMetaObject@QMediaService@@2UQMetaObject@@B @ 659 NONAME ; struct QMetaObject const QMediaService::staticMetaObject - ?staticMetaObject@QMediaObject@@2UQMetaObject@@B @ 660 NONAME ; struct QMetaObject const QMediaObject::staticMetaObject - ?staticMetaObject@QMediaPlaylist@@2UQMetaObject@@B @ 661 NONAME ; struct QMetaObject const QMediaPlaylist::staticMetaObject - ?staticMetaObject@QMediaServiceProvider@@2UQMetaObject@@B @ 662 NONAME ; struct QMetaObject const QMediaServiceProvider::staticMetaObject - ?staticMetaObject@QMediaPlayerControl@@2UQMetaObject@@B @ 663 NONAME ; struct QMetaObject const QMediaPlayerControl::staticMetaObject - ?staticMetaObject@QMediaPlaylistNavigator@@2UQMetaObject@@B @ 664 NONAME ; struct QMetaObject const QMediaPlaylistNavigator::staticMetaObject - ?staticMetaObject@QVideoWidgetControl@@2UQMetaObject@@B @ 665 NONAME ; struct QMetaObject const QVideoWidgetControl::staticMetaObject - ?staticMetaObject@QVideoWindowControl@@2UQMetaObject@@B @ 666 NONAME ; struct QMetaObject const QVideoWindowControl::staticMetaObject - ?staticMetaObject@QVideoDeviceControl@@2UQMetaObject@@B @ 667 NONAME ; struct QMetaObject const QVideoDeviceControl::staticMetaObject - ?staticMetaObject@QVideoRendererControl@@2UQMetaObject@@B @ 668 NONAME ; struct QMetaObject const QVideoRendererControl::staticMetaObject - ?staticMetaObject@QPainterVideoSurface@@2UQMetaObject@@B @ 669 NONAME ; struct QMetaObject const QPainterVideoSurface::staticMetaObject - ?staticMetaObject@QMediaPlaylistIOPlugin@@2UQMetaObject@@B @ 670 NONAME ; struct QMetaObject const QMediaPlaylistIOPlugin::staticMetaObject - ?staticMetaObject@QGraphicsVideoItem@@2UQMetaObject@@B @ 671 NONAME ; struct QMetaObject const QGraphicsVideoItem::staticMetaObject - diff --git a/src/s60installs/eabi/QtMediaServicesu.def b/src/s60installs/eabi/QtMediaServicesu.def deleted file mode 100644 index 0b4083d..0000000 --- a/src/s60installs/eabi/QtMediaServicesu.def +++ /dev/null @@ -1,674 +0,0 @@ -EXPORTS - _ZN12QMediaObject11qt_metacallEN11QMetaObject4CallEiPPv @ 1 NONAME - _ZN12QMediaObject11qt_metacastEPKc @ 2 NONAME - _ZN12QMediaObject11setMetaDataEN15QtMediaServices8MetaDataERK8QVariant @ 3 NONAME - _ZN12QMediaObject13setupMetaDataEv @ 4 NONAME - _ZN12QMediaObject15metaDataChangedEv @ 5 NONAME - _ZN12QMediaObject16addPropertyWatchERK10QByteArray @ 6 NONAME - _ZN12QMediaObject16staticMetaObjectE @ 7 NONAME DATA 16 - _ZN12QMediaObject17setNotifyIntervalEi @ 8 NONAME - _ZN12QMediaObject19availabilityChangedEb @ 9 NONAME - _ZN12QMediaObject19getStaticMetaObjectEv @ 10 NONAME - _ZN12QMediaObject19removePropertyWatchERK10QByteArray @ 11 NONAME - _ZN12QMediaObject19setExtendedMetaDataERK7QStringRK8QVariant @ 12 NONAME - _ZN12QMediaObject21notifyIntervalChangedEi @ 13 NONAME - _ZN12QMediaObject23metaDataWritableChangedEb @ 14 NONAME - _ZN12QMediaObject24metaDataAvailableChangedEb @ 15 NONAME - _ZN12QMediaObject4bindEP7QObject @ 16 NONAME - _ZN12QMediaObject6unbindEP7QObject @ 17 NONAME - _ZN12QMediaObjectC1EP7QObjectP13QMediaService @ 18 NONAME - _ZN12QMediaObjectC1ER19QMediaObjectPrivateP7QObjectP13QMediaService @ 19 NONAME - _ZN12QMediaObjectC2EP7QObjectP13QMediaService @ 20 NONAME - _ZN12QMediaObjectC2ER19QMediaObjectPrivateP7QObjectP13QMediaService @ 21 NONAME - _ZN12QMediaObjectD0Ev @ 22 NONAME - _ZN12QMediaObjectD1Ev @ 23 NONAME - _ZN12QMediaObjectD2Ev @ 24 NONAME - _ZN12QMediaPlayer10hasSupportERK7QStringRK11QStringList6QFlagsINS_4FlagEE @ 25 NONAME - _ZN12QMediaPlayer11qt_metacallEN11QMetaObject4CallEiPPv @ 26 NONAME - _ZN12QMediaPlayer11qt_metacastEPKc @ 27 NONAME - _ZN12QMediaPlayer11setPositionEx @ 28 NONAME - _ZN12QMediaPlayer12mediaChangedERK13QMediaContent @ 29 NONAME - _ZN12QMediaPlayer12mutedChangedEb @ 30 NONAME - _ZN12QMediaPlayer12stateChangedENS_5StateE @ 31 NONAME - _ZN12QMediaPlayer13volumeChangedEi @ 32 NONAME - _ZN12QMediaPlayer15durationChangedEx @ 33 NONAME - _ZN12QMediaPlayer15positionChangedEx @ 34 NONAME - _ZN12QMediaPlayer15seekableChangedEb @ 35 NONAME - _ZN12QMediaPlayer15setPlaybackRateEf @ 36 NONAME - _ZN12QMediaPlayer16staticMetaObjectE @ 37 NONAME DATA 16 - _ZN12QMediaPlayer18mediaStatusChangedENS_11MediaStatusE @ 38 NONAME - _ZN12QMediaPlayer18supportedMimeTypesE6QFlagsINS_4FlagEE @ 39 NONAME - _ZN12QMediaPlayer19bufferStatusChangedEi @ 40 NONAME - _ZN12QMediaPlayer19getStaticMetaObjectEv @ 41 NONAME - _ZN12QMediaPlayer19playbackRateChangedEf @ 42 NONAME - _ZN12QMediaPlayer21audioAvailableChangedEb @ 43 NONAME - _ZN12QMediaPlayer21videoAvailableChangedEb @ 44 NONAME - _ZN12QMediaPlayer4bindEP7QObject @ 45 NONAME - _ZN12QMediaPlayer4playEv @ 46 NONAME - _ZN12QMediaPlayer4stopEv @ 47 NONAME - _ZN12QMediaPlayer5errorENS_5ErrorE @ 48 NONAME - _ZN12QMediaPlayer5pauseEv @ 49 NONAME - _ZN12QMediaPlayer6unbindEP7QObject @ 50 NONAME - _ZN12QMediaPlayer8setMediaERK13QMediaContentP9QIODevice @ 51 NONAME - _ZN12QMediaPlayer8setMutedEb @ 52 NONAME - _ZN12QMediaPlayer9setVolumeEi @ 53 NONAME - _ZN12QMediaPlayerC1EP7QObject6QFlagsINS_4FlagEEP21QMediaServiceProvider @ 54 NONAME - _ZN12QMediaPlayerC2EP7QObject6QFlagsINS_4FlagEEP21QMediaServiceProvider @ 55 NONAME - _ZN12QMediaPlayerD0Ev @ 56 NONAME - _ZN12QMediaPlayerD1Ev @ 57 NONAME - _ZN12QMediaPlayerD2Ev @ 58 NONAME - _ZN12QSoundEffect11qt_metacallEN11QMetaObject4CallEiPPv @ 59 NONAME - _ZN12QSoundEffect11qt_metacastEPKc @ 60 NONAME - _ZN12QSoundEffect12loopsChangedEv @ 61 NONAME - _ZN12QSoundEffect12mutedChangedEv @ 62 NONAME - _ZN12QSoundEffect13sourceChangedEv @ 63 NONAME - _ZN12QSoundEffect13volumeChangedEv @ 64 NONAME - _ZN12QSoundEffect16staticMetaObjectE @ 65 NONAME DATA 16 - _ZN12QSoundEffect19getStaticMetaObjectEv @ 66 NONAME - _ZN12QSoundEffect4playEv @ 67 NONAME - _ZN12QSoundEffect8setLoopsEi @ 68 NONAME - _ZN12QSoundEffect8setMutedEb @ 69 NONAME - _ZN12QSoundEffect9setSourceERK4QUrl @ 70 NONAME - _ZN12QSoundEffect9setVolumeEi @ 71 NONAME - _ZN12QSoundEffectC1EP7QObject @ 72 NONAME - _ZN12QSoundEffectC2EP7QObject @ 73 NONAME - _ZN12QSoundEffectD0Ev @ 74 NONAME - _ZN12QSoundEffectD1Ev @ 75 NONAME - _ZN12QSoundEffectD2Ev @ 76 NONAME - _ZN12QVideoWidget10hueChangedEi @ 77 NONAME - _ZN12QVideoWidget10paintEventEP11QPaintEvent @ 78 NONAME - _ZN12QVideoWidget11qt_metacallEN11QMetaObject4CallEiPPv @ 79 NONAME - _ZN12QVideoWidget11qt_metacastEPKc @ 80 NONAME - _ZN12QVideoWidget11resizeEventEP12QResizeEvent @ 81 NONAME - _ZN12QVideoWidget11setContrastEi @ 82 NONAME - _ZN12QVideoWidget13setBrightnessEi @ 83 NONAME - _ZN12QVideoWidget13setFullScreenEb @ 84 NONAME - _ZN12QVideoWidget13setSaturationEi @ 85 NONAME - _ZN12QVideoWidget14setMediaObjectEP12QMediaObject @ 86 NONAME - _ZN12QVideoWidget15contrastChangedEi @ 87 NONAME - _ZN12QVideoWidget16staticMetaObjectE @ 88 NONAME DATA 16 - _ZN12QVideoWidget17brightnessChangedEi @ 89 NONAME - _ZN12QVideoWidget17fullScreenChangedEb @ 90 NONAME - _ZN12QVideoWidget17saturationChangedEi @ 91 NONAME - _ZN12QVideoWidget18setAspectRatioModeEN2Qt15AspectRatioModeE @ 92 NONAME - _ZN12QVideoWidget19getStaticMetaObjectEv @ 93 NONAME - _ZN12QVideoWidget5eventEP6QEvent @ 94 NONAME - _ZN12QVideoWidget6setHueEi @ 95 NONAME - _ZN12QVideoWidget9hideEventEP10QHideEvent @ 96 NONAME - _ZN12QVideoWidget9moveEventEP10QMoveEvent @ 97 NONAME - _ZN12QVideoWidget9showEventEP10QShowEvent @ 98 NONAME - _ZN12QVideoWidgetC1EP7QWidget @ 99 NONAME - _ZN12QVideoWidgetC2EP7QWidget @ 100 NONAME - _ZN12QVideoWidgetD0Ev @ 101 NONAME - _ZN12QVideoWidgetD1Ev @ 102 NONAME - _ZN12QVideoWidgetD2Ev @ 103 NONAME - _ZN13QMediaContentC1ERK14QMediaResource @ 104 NONAME - _ZN13QMediaContentC1ERK15QNetworkRequest @ 105 NONAME - _ZN13QMediaContentC1ERK4QUrl @ 106 NONAME - _ZN13QMediaContentC1ERK5QListI14QMediaResourceE @ 107 NONAME - _ZN13QMediaContentC1ERKS_ @ 108 NONAME - _ZN13QMediaContentC1Ev @ 109 NONAME - _ZN13QMediaContentC2ERK14QMediaResource @ 110 NONAME - _ZN13QMediaContentC2ERK15QNetworkRequest @ 111 NONAME - _ZN13QMediaContentC2ERK4QUrl @ 112 NONAME - _ZN13QMediaContentC2ERK5QListI14QMediaResourceE @ 113 NONAME - _ZN13QMediaContentC2ERKS_ @ 114 NONAME - _ZN13QMediaContentC2Ev @ 115 NONAME - _ZN13QMediaContentD1Ev @ 116 NONAME - _ZN13QMediaContentD2Ev @ 117 NONAME - _ZN13QMediaContentaSERKS_ @ 118 NONAME - _ZN13QMediaControl11qt_metacallEN11QMetaObject4CallEiPPv @ 119 NONAME - _ZN13QMediaControl11qt_metacastEPKc @ 120 NONAME - _ZN13QMediaControl16staticMetaObjectE @ 121 NONAME DATA 16 - _ZN13QMediaControl19getStaticMetaObjectEv @ 122 NONAME - _ZN13QMediaControlC1EP7QObject @ 123 NONAME - _ZN13QMediaControlC1ER20QMediaControlPrivateP7QObject @ 124 NONAME - _ZN13QMediaControlC2EP7QObject @ 125 NONAME - _ZN13QMediaControlC2ER20QMediaControlPrivateP7QObject @ 126 NONAME - _ZN13QMediaControlD0Ev @ 127 NONAME - _ZN13QMediaControlD1Ev @ 128 NONAME - _ZN13QMediaControlD2Ev @ 129 NONAME - _ZN13QMediaService11qt_metacallEN11QMetaObject4CallEiPPv @ 130 NONAME - _ZN13QMediaService11qt_metacastEPKc @ 131 NONAME - _ZN13QMediaService16staticMetaObjectE @ 132 NONAME DATA 16 - _ZN13QMediaService19getStaticMetaObjectEv @ 133 NONAME - _ZN13QMediaServiceC2EP7QObject @ 134 NONAME - _ZN13QMediaServiceC2ER20QMediaServicePrivateP7QObject @ 135 NONAME - _ZN13QMediaServiceD0Ev @ 136 NONAME - _ZN13QMediaServiceD1Ev @ 137 NONAME - _ZN13QMediaServiceD2Ev @ 138 NONAME - _ZN14QMediaPlaylist10loadFailedEv @ 139 NONAME - _ZN14QMediaPlaylist11insertMediaEiRK13QMediaContent @ 140 NONAME - _ZN14QMediaPlaylist11insertMediaEiRK5QListI13QMediaContentE @ 141 NONAME - _ZN14QMediaPlaylist11qt_metacallEN11QMetaObject4CallEiPPv @ 142 NONAME - _ZN14QMediaPlaylist11qt_metacastEPKc @ 143 NONAME - _ZN14QMediaPlaylist11removeMediaEi @ 144 NONAME - _ZN14QMediaPlaylist11removeMediaEii @ 145 NONAME - _ZN14QMediaPlaylist12mediaChangedEii @ 146 NONAME - _ZN14QMediaPlaylist12mediaRemovedEii @ 147 NONAME - _ZN14QMediaPlaylist13mediaInsertedEii @ 148 NONAME - _ZN14QMediaPlaylist14setMediaObjectEP12QMediaObject @ 149 NONAME - _ZN14QMediaPlaylist15setCurrentIndexEi @ 150 NONAME - _ZN14QMediaPlaylist15setPlaybackModeENS_12PlaybackModeE @ 151 NONAME - _ZN14QMediaPlaylist16staticMetaObjectE @ 152 NONAME DATA 16 - _ZN14QMediaPlaylist19currentIndexChangedEi @ 153 NONAME - _ZN14QMediaPlaylist19currentMediaChangedERK13QMediaContent @ 154 NONAME - _ZN14QMediaPlaylist19getStaticMetaObjectEv @ 155 NONAME - _ZN14QMediaPlaylist19playbackModeChangedENS_12PlaybackModeE @ 156 NONAME - _ZN14QMediaPlaylist21mediaAboutToBeRemovedEii @ 157 NONAME - _ZN14QMediaPlaylist22mediaAboutToBeInsertedEii @ 158 NONAME - _ZN14QMediaPlaylist4loadEP9QIODevicePKc @ 159 NONAME - _ZN14QMediaPlaylist4loadERK4QUrlPKc @ 160 NONAME - _ZN14QMediaPlaylist4nextEv @ 161 NONAME - _ZN14QMediaPlaylist4saveEP9QIODevicePKc @ 162 NONAME - _ZN14QMediaPlaylist4saveERK4QUrlPKc @ 163 NONAME - _ZN14QMediaPlaylist5clearEv @ 164 NONAME - _ZN14QMediaPlaylist6loadedEv @ 165 NONAME - _ZN14QMediaPlaylist7shuffleEv @ 166 NONAME - _ZN14QMediaPlaylist8addMediaERK13QMediaContent @ 167 NONAME - _ZN14QMediaPlaylist8addMediaERK5QListI13QMediaContentE @ 168 NONAME - _ZN14QMediaPlaylist8previousEv @ 169 NONAME - _ZN14QMediaPlaylistC1EP7QObject @ 170 NONAME - _ZN14QMediaPlaylistC2EP7QObject @ 171 NONAME - _ZN14QMediaPlaylistD0Ev @ 172 NONAME - _ZN14QMediaPlaylistD1Ev @ 173 NONAME - _ZN14QMediaPlaylistD2Ev @ 174 NONAME - _ZN14QMediaResource11setDataSizeEx @ 175 NONAME - _ZN14QMediaResource11setLanguageERK7QString @ 176 NONAME - _ZN14QMediaResource13setAudioCodecERK7QString @ 177 NONAME - _ZN14QMediaResource13setResolutionERK5QSize @ 178 NONAME - _ZN14QMediaResource13setResolutionEii @ 179 NONAME - _ZN14QMediaResource13setSampleRateEi @ 180 NONAME - _ZN14QMediaResource13setVideoCodecERK7QString @ 181 NONAME - _ZN14QMediaResource15setAudioBitRateEi @ 182 NONAME - _ZN14QMediaResource15setChannelCountEi @ 183 NONAME - _ZN14QMediaResource15setVideoBitRateEi @ 184 NONAME - _ZN14QMediaResourceC1ERK15QNetworkRequestRK7QString @ 185 NONAME - _ZN14QMediaResourceC1ERK4QUrlRK7QString @ 186 NONAME - _ZN14QMediaResourceC1ERKS_ @ 187 NONAME - _ZN14QMediaResourceC1Ev @ 188 NONAME - _ZN14QMediaResourceC2ERK15QNetworkRequestRK7QString @ 189 NONAME - _ZN14QMediaResourceC2ERK4QUrlRK7QString @ 190 NONAME - _ZN14QMediaResourceC2ERKS_ @ 191 NONAME - _ZN14QMediaResourceC2Ev @ 192 NONAME - _ZN14QMediaResourceD1Ev @ 193 NONAME - _ZN14QMediaResourceD2Ev @ 194 NONAME - _ZN14QMediaResourceaSERKS_ @ 195 NONAME - _ZN15QMediaTimeRange11addIntervalERK18QMediaTimeInterval @ 196 NONAME - _ZN15QMediaTimeRange11addIntervalExx @ 197 NONAME - _ZN15QMediaTimeRange12addTimeRangeERKS_ @ 198 NONAME - _ZN15QMediaTimeRange14removeIntervalERK18QMediaTimeInterval @ 199 NONAME - _ZN15QMediaTimeRange14removeIntervalExx @ 200 NONAME - _ZN15QMediaTimeRange15removeTimeRangeERKS_ @ 201 NONAME - _ZN15QMediaTimeRange5clearEv @ 202 NONAME - _ZN15QMediaTimeRangeC1ERK18QMediaTimeInterval @ 203 NONAME - _ZN15QMediaTimeRangeC1ERKS_ @ 204 NONAME - _ZN15QMediaTimeRangeC1Ev @ 205 NONAME - _ZN15QMediaTimeRangeC1Exx @ 206 NONAME - _ZN15QMediaTimeRangeC2ERK18QMediaTimeInterval @ 207 NONAME - _ZN15QMediaTimeRangeC2ERKS_ @ 208 NONAME - _ZN15QMediaTimeRangeC2Ev @ 209 NONAME - _ZN15QMediaTimeRangeC2Exx @ 210 NONAME - _ZN15QMediaTimeRangeD1Ev @ 211 NONAME - _ZN15QMediaTimeRangeD2Ev @ 212 NONAME - _ZN15QMediaTimeRangeaSERK18QMediaTimeInterval @ 213 NONAME - _ZN15QMediaTimeRangeaSERKS_ @ 214 NONAME - _ZN15QMediaTimeRangemIERK18QMediaTimeInterval @ 215 NONAME - _ZN15QMediaTimeRangemIERKS_ @ 216 NONAME - _ZN15QMediaTimeRangepLERK18QMediaTimeInterval @ 217 NONAME - _ZN15QMediaTimeRangepLERKS_ @ 218 NONAME - _ZN16QMetaDataControl11qt_metacallEN11QMetaObject4CallEiPPv @ 219 NONAME - _ZN16QMetaDataControl11qt_metacastEPKc @ 220 NONAME - _ZN16QMetaDataControl15metaDataChangedEv @ 221 NONAME - _ZN16QMetaDataControl15writableChangedEb @ 222 NONAME - _ZN16QMetaDataControl16staticMetaObjectE @ 223 NONAME DATA 16 - _ZN16QMetaDataControl19getStaticMetaObjectEv @ 224 NONAME - _ZN16QMetaDataControl24metaDataAvailableChangedEb @ 225 NONAME - _ZN16QMetaDataControlC2EP7QObject @ 226 NONAME - _ZN16QMetaDataControlD0Ev @ 227 NONAME - _ZN16QMetaDataControlD1Ev @ 228 NONAME - _ZN16QMetaDataControlD2Ev @ 229 NONAME - _ZN18QGraphicsVideoItem10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 230 NONAME - _ZN18QGraphicsVideoItem10sceneEventEP6QEvent @ 231 NONAME - _ZN18QGraphicsVideoItem11qt_metacallEN11QMetaObject4CallEiPPv @ 232 NONAME - _ZN18QGraphicsVideoItem11qt_metacastEPKc @ 233 NONAME - _ZN18QGraphicsVideoItem14setMediaObjectEP12QMediaObject @ 234 NONAME - _ZN18QGraphicsVideoItem16staticMetaObjectE @ 235 NONAME DATA 16 - _ZN18QGraphicsVideoItem17nativeSizeChangedERK6QSizeF @ 236 NONAME - _ZN18QGraphicsVideoItem18setAspectRatioModeEN2Qt15AspectRatioModeE @ 237 NONAME - _ZN18QGraphicsVideoItem19getStaticMetaObjectEv @ 238 NONAME - _ZN18QGraphicsVideoItem5eventEP6QEvent @ 239 NONAME - _ZN18QGraphicsVideoItem5paintEP8QPainterPK24QStyleOptionGraphicsItemP7QWidget @ 240 NONAME - _ZN18QGraphicsVideoItem7setSizeERK6QSizeF @ 241 NONAME - _ZN18QGraphicsVideoItem9setOffsetERK7QPointF @ 242 NONAME - _ZN18QGraphicsVideoItemC1EP13QGraphicsItem @ 243 NONAME - _ZN18QGraphicsVideoItemC2EP13QGraphicsItem @ 244 NONAME - _ZN18QGraphicsVideoItemD0Ev @ 245 NONAME - _ZN18QGraphicsVideoItemD1Ev @ 246 NONAME - _ZN18QGraphicsVideoItemD2Ev @ 247 NONAME - _ZN18QMediaTimeIntervalC1ERKS_ @ 248 NONAME - _ZN18QMediaTimeIntervalC1Ev @ 249 NONAME - _ZN18QMediaTimeIntervalC1Exx @ 250 NONAME - _ZN18QMediaTimeIntervalC2ERKS_ @ 251 NONAME - _ZN18QMediaTimeIntervalC2Ev @ 252 NONAME - _ZN18QMediaTimeIntervalC2Exx @ 253 NONAME - _ZN19QMediaPlayerControl11qt_metacallEN11QMetaObject4CallEiPPv @ 254 NONAME - _ZN19QMediaPlayerControl11qt_metacastEPKc @ 255 NONAME - _ZN19QMediaPlayerControl12mediaChangedERK13QMediaContent @ 256 NONAME - _ZN19QMediaPlayerControl12mutedChangedEb @ 257 NONAME - _ZN19QMediaPlayerControl12stateChangedEN12QMediaPlayer5StateE @ 258 NONAME - _ZN19QMediaPlayerControl13volumeChangedEi @ 259 NONAME - _ZN19QMediaPlayerControl15durationChangedEx @ 260 NONAME - _ZN19QMediaPlayerControl15positionChangedEx @ 261 NONAME - _ZN19QMediaPlayerControl15seekableChangedEb @ 262 NONAME - _ZN19QMediaPlayerControl16staticMetaObjectE @ 263 NONAME DATA 16 - _ZN19QMediaPlayerControl18mediaStatusChangedEN12QMediaPlayer11MediaStatusE @ 264 NONAME - _ZN19QMediaPlayerControl19bufferStatusChangedEi @ 265 NONAME - _ZN19QMediaPlayerControl19getStaticMetaObjectEv @ 266 NONAME - _ZN19QMediaPlayerControl19playbackRateChangedEf @ 267 NONAME - _ZN19QMediaPlayerControl21audioAvailableChangedEb @ 268 NONAME - _ZN19QMediaPlayerControl21videoAvailableChangedEb @ 269 NONAME - _ZN19QMediaPlayerControl30availablePlaybackRangesChangedERK15QMediaTimeRange @ 270 NONAME - _ZN19QMediaPlayerControl5errorEiRK7QString @ 271 NONAME - _ZN19QMediaPlayerControlC2EP7QObject @ 272 NONAME - _ZN19QMediaPlayerControlD0Ev @ 273 NONAME - _ZN19QMediaPlayerControlD1Ev @ 274 NONAME - _ZN19QMediaPlayerControlD2Ev @ 275 NONAME - _ZN19QVideoDeviceControl11qt_metacallEN11QMetaObject4CallEiPPv @ 276 NONAME - _ZN19QVideoDeviceControl11qt_metacastEPKc @ 277 NONAME - _ZN19QVideoDeviceControl14devicesChangedEv @ 278 NONAME - _ZN19QVideoDeviceControl16staticMetaObjectE @ 279 NONAME DATA 16 - _ZN19QVideoDeviceControl19getStaticMetaObjectEv @ 280 NONAME - _ZN19QVideoDeviceControl21selectedDeviceChangedERK7QString @ 281 NONAME - _ZN19QVideoDeviceControl21selectedDeviceChangedEi @ 282 NONAME - _ZN19QVideoDeviceControlC2EP7QObject @ 283 NONAME - _ZN19QVideoDeviceControlD0Ev @ 284 NONAME - _ZN19QVideoDeviceControlD1Ev @ 285 NONAME - _ZN19QVideoDeviceControlD2Ev @ 286 NONAME - _ZN19QVideoOutputControl11qt_metacallEN11QMetaObject4CallEiPPv @ 287 NONAME - _ZN19QVideoOutputControl11qt_metacastEPKc @ 288 NONAME - _ZN19QVideoOutputControl16staticMetaObjectE @ 289 NONAME DATA 16 - _ZN19QVideoOutputControl19getStaticMetaObjectEv @ 290 NONAME - _ZN19QVideoOutputControl23availableOutputsChangedERK5QListINS_6OutputEE @ 291 NONAME - _ZN19QVideoOutputControlC2EP7QObject @ 292 NONAME - _ZN19QVideoOutputControlD0Ev @ 293 NONAME - _ZN19QVideoOutputControlD1Ev @ 294 NONAME - _ZN19QVideoOutputControlD2Ev @ 295 NONAME - _ZN19QVideoWidgetControl10hueChangedEi @ 296 NONAME - _ZN19QVideoWidgetControl11qt_metacallEN11QMetaObject4CallEiPPv @ 297 NONAME - _ZN19QVideoWidgetControl11qt_metacastEPKc @ 298 NONAME - _ZN19QVideoWidgetControl15contrastChangedEi @ 299 NONAME - _ZN19QVideoWidgetControl16staticMetaObjectE @ 300 NONAME DATA 16 - _ZN19QVideoWidgetControl17brightnessChangedEi @ 301 NONAME - _ZN19QVideoWidgetControl17fullScreenChangedEb @ 302 NONAME - _ZN19QVideoWidgetControl17saturationChangedEi @ 303 NONAME - _ZN19QVideoWidgetControl19getStaticMetaObjectEv @ 304 NONAME - _ZN19QVideoWidgetControlC2EP7QObject @ 305 NONAME - _ZN19QVideoWidgetControlD0Ev @ 306 NONAME - _ZN19QVideoWidgetControlD1Ev @ 307 NONAME - _ZN19QVideoWidgetControlD2Ev @ 308 NONAME - _ZN19QVideoWindowControl10hueChangedEi @ 309 NONAME - _ZN19QVideoWindowControl11qt_metacallEN11QMetaObject4CallEiPPv @ 310 NONAME - _ZN19QVideoWindowControl11qt_metacastEPKc @ 311 NONAME - _ZN19QVideoWindowControl15contrastChangedEi @ 312 NONAME - _ZN19QVideoWindowControl16staticMetaObjectE @ 313 NONAME DATA 16 - _ZN19QVideoWindowControl17brightnessChangedEi @ 314 NONAME - _ZN19QVideoWindowControl17fullScreenChangedEb @ 315 NONAME - _ZN19QVideoWindowControl17nativeSizeChangedEv @ 316 NONAME - _ZN19QVideoWindowControl17saturationChangedEi @ 317 NONAME - _ZN19QVideoWindowControl19getStaticMetaObjectEv @ 318 NONAME - _ZN19QVideoWindowControlC2EP7QObject @ 319 NONAME - _ZN19QVideoWindowControlD0Ev @ 320 NONAME - _ZN19QVideoWindowControlD1Ev @ 321 NONAME - _ZN19QVideoWindowControlD2Ev @ 322 NONAME - _ZN20QMediaPlaylistReaderD0Ev @ 323 NONAME - _ZN20QMediaPlaylistReaderD1Ev @ 324 NONAME - _ZN20QMediaPlaylistReaderD2Ev @ 325 NONAME - _ZN20QMediaPlaylistWriterD0Ev @ 326 NONAME - _ZN20QMediaPlaylistWriterD1Ev @ 327 NONAME - _ZN20QMediaPlaylistWriterD2Ev @ 328 NONAME - _ZN20QPainterVideoSurface11qt_metacallEN11QMetaObject4CallEiPPv @ 329 NONAME - _ZN20QPainterVideoSurface11qt_metacastEPKc @ 330 NONAME - _ZN20QPainterVideoSurface11setContrastEi @ 331 NONAME - _ZN20QPainterVideoSurface12frameChangedEv @ 332 NONAME - _ZN20QPainterVideoSurface13createPainterEv @ 333 NONAME - _ZN20QPainterVideoSurface13setBrightnessEi @ 334 NONAME - _ZN20QPainterVideoSurface13setSaturationEi @ 335 NONAME - _ZN20QPainterVideoSurface16staticMetaObjectE @ 336 NONAME DATA 16 - _ZN20QPainterVideoSurface19getStaticMetaObjectEv @ 337 NONAME - _ZN20QPainterVideoSurface4stopEv @ 338 NONAME - _ZN20QPainterVideoSurface5paintEP8QPainterRK6QRectFS4_ @ 339 NONAME - _ZN20QPainterVideoSurface5startERK19QVideoSurfaceFormat @ 340 NONAME - _ZN20QPainterVideoSurface6setHueEi @ 341 NONAME - _ZN20QPainterVideoSurface7presentERK11QVideoFrame @ 342 NONAME - _ZN20QPainterVideoSurface8setReadyEb @ 343 NONAME - _ZN20QPainterVideoSurfaceC1EP7QObject @ 344 NONAME - _ZN20QPainterVideoSurfaceC2EP7QObject @ 345 NONAME - _ZN20QPainterVideoSurfaceD0Ev @ 346 NONAME - _ZN20QPainterVideoSurfaceD1Ev @ 347 NONAME - _ZN20QPainterVideoSurfaceD2Ev @ 348 NONAME - _ZN21QMediaPlaylistControl11qt_metacallEN11QMetaObject4CallEiPPv @ 349 NONAME - _ZN21QMediaPlaylistControl11qt_metacastEPKc @ 350 NONAME - _ZN21QMediaPlaylistControl16staticMetaObjectE @ 351 NONAME DATA 16 - _ZN21QMediaPlaylistControl19currentIndexChangedEi @ 352 NONAME - _ZN21QMediaPlaylistControl19currentMediaChangedERK13QMediaContent @ 353 NONAME - _ZN21QMediaPlaylistControl19getStaticMetaObjectEv @ 354 NONAME - _ZN21QMediaPlaylistControl19playbackModeChangedEN14QMediaPlaylist12PlaybackModeE @ 355 NONAME - _ZN21QMediaPlaylistControl23playlistProviderChangedEv @ 356 NONAME - _ZN21QMediaPlaylistControlC2EP7QObject @ 357 NONAME - _ZN21QMediaPlaylistControlD0Ev @ 358 NONAME - _ZN21QMediaPlaylistControlD1Ev @ 359 NONAME - _ZN21QMediaPlaylistControlD2Ev @ 360 NONAME - _ZN21QMediaServiceProvider11qt_metacallEN11QMetaObject4CallEiPPv @ 361 NONAME - _ZN21QMediaServiceProvider11qt_metacastEPKc @ 362 NONAME - _ZN21QMediaServiceProvider16staticMetaObjectE @ 363 NONAME DATA 16 - _ZN21QMediaServiceProvider17deviceDescriptionERK10QByteArrayS2_ @ 364 NONAME - _ZN21QMediaServiceProvider19getStaticMetaObjectEv @ 365 NONAME - _ZN21QMediaServiceProvider22defaultServiceProviderEv @ 366 NONAME - _ZN21QVideoRendererControl11qt_metacallEN11QMetaObject4CallEiPPv @ 367 NONAME - _ZN21QVideoRendererControl11qt_metacastEPKc @ 368 NONAME - _ZN21QVideoRendererControl16staticMetaObjectE @ 369 NONAME DATA 16 - _ZN21QVideoRendererControl19getStaticMetaObjectEv @ 370 NONAME - _ZN21QVideoRendererControlC2EP7QObject @ 371 NONAME - _ZN21QVideoRendererControlD0Ev @ 372 NONAME - _ZN21QVideoRendererControlD1Ev @ 373 NONAME - _ZN21QVideoRendererControlD2Ev @ 374 NONAME - _ZN22QMediaPlaylistIOPlugin11qt_metacallEN11QMetaObject4CallEiPPv @ 375 NONAME - _ZN22QMediaPlaylistIOPlugin11qt_metacastEPKc @ 376 NONAME - _ZN22QMediaPlaylistIOPlugin16staticMetaObjectE @ 377 NONAME DATA 16 - _ZN22QMediaPlaylistIOPlugin19getStaticMetaObjectEv @ 378 NONAME - _ZN22QMediaPlaylistIOPluginC2EP7QObject @ 379 NONAME - _ZN22QMediaPlaylistIOPluginD0Ev @ 380 NONAME - _ZN22QMediaPlaylistIOPluginD1Ev @ 381 NONAME - _ZN22QMediaPlaylistIOPluginD2Ev @ 382 NONAME - _ZN22QMediaPlaylistProvider10loadFailedEN14QMediaPlaylist5ErrorERK7QString @ 383 NONAME - _ZN22QMediaPlaylistProvider11insertMediaEiRK13QMediaContent @ 384 NONAME - _ZN22QMediaPlaylistProvider11insertMediaEiRK5QListI13QMediaContentE @ 385 NONAME - _ZN22QMediaPlaylistProvider11qt_metacallEN11QMetaObject4CallEiPPv @ 386 NONAME - _ZN22QMediaPlaylistProvider11qt_metacastEPKc @ 387 NONAME - _ZN22QMediaPlaylistProvider11removeMediaEi @ 388 NONAME - _ZN22QMediaPlaylistProvider11removeMediaEii @ 389 NONAME - _ZN22QMediaPlaylistProvider12mediaChangedEii @ 390 NONAME - _ZN22QMediaPlaylistProvider12mediaRemovedEii @ 391 NONAME - _ZN22QMediaPlaylistProvider13mediaInsertedEii @ 392 NONAME - _ZN22QMediaPlaylistProvider16staticMetaObjectE @ 393 NONAME DATA 16 - _ZN22QMediaPlaylistProvider19getStaticMetaObjectEv @ 394 NONAME - _ZN22QMediaPlaylistProvider21mediaAboutToBeRemovedEii @ 395 NONAME - _ZN22QMediaPlaylistProvider22mediaAboutToBeInsertedEii @ 396 NONAME - _ZN22QMediaPlaylistProvider4loadEP9QIODevicePKc @ 397 NONAME - _ZN22QMediaPlaylistProvider4loadERK4QUrlPKc @ 398 NONAME - _ZN22QMediaPlaylistProvider4saveEP9QIODevicePKc @ 399 NONAME - _ZN22QMediaPlaylistProvider4saveERK4QUrlPKc @ 400 NONAME - _ZN22QMediaPlaylistProvider5clearEv @ 401 NONAME - _ZN22QMediaPlaylistProvider6loadedEv @ 402 NONAME - _ZN22QMediaPlaylistProvider7shuffleEv @ 403 NONAME - _ZN22QMediaPlaylistProvider8addMediaERK13QMediaContent @ 404 NONAME - _ZN22QMediaPlaylistProvider8addMediaERK5QListI13QMediaContentE @ 405 NONAME - _ZN22QMediaPlaylistProviderC2EP7QObject @ 406 NONAME - _ZN22QMediaPlaylistProviderC2ER29QMediaPlaylistProviderPrivateP7QObject @ 407 NONAME - _ZN22QMediaPlaylistProviderD0Ev @ 408 NONAME - _ZN22QMediaPlaylistProviderD1Ev @ 409 NONAME - _ZN22QMediaPlaylistProviderD2Ev @ 410 NONAME - _ZN23QMediaPlaylistNavigator11qt_metacallEN11QMetaObject4CallEiPPv @ 411 NONAME - _ZN23QMediaPlaylistNavigator11qt_metacastEPKc @ 412 NONAME - _ZN23QMediaPlaylistNavigator11setPlaylistEP22QMediaPlaylistProvider @ 413 NONAME - _ZN23QMediaPlaylistNavigator15setPlaybackModeEN14QMediaPlaylist12PlaybackModeE @ 414 NONAME - _ZN23QMediaPlaylistNavigator16staticMetaObjectE @ 415 NONAME DATA 16 - _ZN23QMediaPlaylistNavigator19currentIndexChangedEi @ 416 NONAME - _ZN23QMediaPlaylistNavigator19getStaticMetaObjectEv @ 417 NONAME - _ZN23QMediaPlaylistNavigator19playbackModeChangedEN14QMediaPlaylist12PlaybackModeE @ 418 NONAME - _ZN23QMediaPlaylistNavigator23surroundingItemsChangedEv @ 419 NONAME - _ZN23QMediaPlaylistNavigator4jumpEi @ 420 NONAME - _ZN23QMediaPlaylistNavigator4nextEv @ 421 NONAME - _ZN23QMediaPlaylistNavigator8previousEv @ 422 NONAME - _ZN23QMediaPlaylistNavigator9activatedERK13QMediaContent @ 423 NONAME - _ZN23QMediaPlaylistNavigatorC1EP22QMediaPlaylistProviderP7QObject @ 424 NONAME - _ZN23QMediaPlaylistNavigatorC2EP22QMediaPlaylistProviderP7QObject @ 425 NONAME - _ZN23QMediaPlaylistNavigatorD0Ev @ 426 NONAME - _ZN23QMediaPlaylistNavigatorD1Ev @ 427 NONAME - _ZN23QMediaPlaylistNavigatorD2Ev @ 428 NONAME - _ZN25QMediaServiceProviderHintC1E6QFlagsINS_7FeatureEE @ 429 NONAME - _ZN25QMediaServiceProviderHintC1ERK10QByteArray @ 430 NONAME - _ZN25QMediaServiceProviderHintC1ERK7QStringRK11QStringList @ 431 NONAME - _ZN25QMediaServiceProviderHintC1ERKS_ @ 432 NONAME - _ZN25QMediaServiceProviderHintC1Ev @ 433 NONAME - _ZN25QMediaServiceProviderHintC2E6QFlagsINS_7FeatureEE @ 434 NONAME - _ZN25QMediaServiceProviderHintC2ERK10QByteArray @ 435 NONAME - _ZN25QMediaServiceProviderHintC2ERK7QStringRK11QStringList @ 436 NONAME - _ZN25QMediaServiceProviderHintC2ERKS_ @ 437 NONAME - _ZN25QMediaServiceProviderHintC2Ev @ 438 NONAME - _ZN25QMediaServiceProviderHintD1Ev @ 439 NONAME - _ZN25QMediaServiceProviderHintD2Ev @ 440 NONAME - _ZN25QMediaServiceProviderHintaSERKS_ @ 441 NONAME - _ZN27QLocalMediaPlaylistProvider11insertMediaEiRK13QMediaContent @ 442 NONAME - _ZN27QLocalMediaPlaylistProvider11insertMediaEiRK5QListI13QMediaContentE @ 443 NONAME - _ZN27QLocalMediaPlaylistProvider11qt_metacallEN11QMetaObject4CallEiPPv @ 444 NONAME - _ZN27QLocalMediaPlaylistProvider11qt_metacastEPKc @ 445 NONAME - _ZN27QLocalMediaPlaylistProvider11removeMediaEi @ 446 NONAME - _ZN27QLocalMediaPlaylistProvider11removeMediaEii @ 447 NONAME - _ZN27QLocalMediaPlaylistProvider16staticMetaObjectE @ 448 NONAME DATA 16 - _ZN27QLocalMediaPlaylistProvider19getStaticMetaObjectEv @ 449 NONAME - _ZN27QLocalMediaPlaylistProvider5clearEv @ 450 NONAME - _ZN27QLocalMediaPlaylistProvider7shuffleEv @ 451 NONAME - _ZN27QLocalMediaPlaylistProvider8addMediaERK13QMediaContent @ 452 NONAME - _ZN27QLocalMediaPlaylistProvider8addMediaERK5QListI13QMediaContentE @ 453 NONAME - _ZN27QLocalMediaPlaylistProviderC1EP7QObject @ 454 NONAME - _ZN27QLocalMediaPlaylistProviderC2EP7QObject @ 455 NONAME - _ZN27QLocalMediaPlaylistProviderD0Ev @ 456 NONAME - _ZN27QLocalMediaPlaylistProviderD1Ev @ 457 NONAME - _ZN27QLocalMediaPlaylistProviderD2Ev @ 458 NONAME - _ZN27QMediaServiceProviderPlugin11qt_metacallEN11QMetaObject4CallEiPPv @ 459 NONAME - _ZN27QMediaServiceProviderPlugin11qt_metacastEPKc @ 460 NONAME - _ZN27QMediaServiceProviderPlugin16staticMetaObjectE @ 461 NONAME DATA 16 - _ZN27QMediaServiceProviderPlugin19getStaticMetaObjectEv @ 462 NONAME - _ZNK12QMediaObject10metaObjectEv @ 463 NONAME - _ZNK12QMediaObject11isAvailableEv @ 464 NONAME - _ZNK12QMediaObject14notifyIntervalEv @ 465 NONAME - _ZNK12QMediaObject16extendedMetaDataERK7QString @ 466 NONAME - _ZNK12QMediaObject17availabilityErrorEv @ 467 NONAME - _ZNK12QMediaObject17availableMetaDataEv @ 468 NONAME - _ZNK12QMediaObject18isMetaDataWritableEv @ 469 NONAME - _ZNK12QMediaObject19isMetaDataAvailableEv @ 470 NONAME - _ZNK12QMediaObject25availableExtendedMetaDataEv @ 471 NONAME - _ZNK12QMediaObject7serviceEv @ 472 NONAME - _ZNK12QMediaObject8metaDataEN15QtMediaServices8MetaDataE @ 473 NONAME - _ZNK12QMediaPlayer10isSeekableEv @ 474 NONAME - _ZNK12QMediaPlayer10metaObjectEv @ 475 NONAME - _ZNK12QMediaPlayer11errorStringEv @ 476 NONAME - _ZNK12QMediaPlayer11mediaStatusEv @ 477 NONAME - _ZNK12QMediaPlayer11mediaStreamEv @ 478 NONAME - _ZNK12QMediaPlayer12bufferStatusEv @ 479 NONAME - _ZNK12QMediaPlayer12playbackRateEv @ 480 NONAME - _ZNK12QMediaPlayer16isAudioAvailableEv @ 481 NONAME - _ZNK12QMediaPlayer16isVideoAvailableEv @ 482 NONAME - _ZNK12QMediaPlayer5errorEv @ 483 NONAME - _ZNK12QMediaPlayer5mediaEv @ 484 NONAME - _ZNK12QMediaPlayer5stateEv @ 485 NONAME - _ZNK12QMediaPlayer6volumeEv @ 486 NONAME - _ZNK12QMediaPlayer7isMutedEv @ 487 NONAME - _ZNK12QMediaPlayer8durationEv @ 488 NONAME - _ZNK12QMediaPlayer8positionEv @ 489 NONAME - _ZNK12QSoundEffect10metaObjectEv @ 490 NONAME - _ZNK12QSoundEffect5loopsEv @ 491 NONAME - _ZNK12QSoundEffect6sourceEv @ 492 NONAME - _ZNK12QSoundEffect6volumeEv @ 493 NONAME - _ZNK12QSoundEffect7isMutedEv @ 494 NONAME - _ZNK12QVideoWidget10brightnessEv @ 495 NONAME - _ZNK12QVideoWidget10metaObjectEv @ 496 NONAME - _ZNK12QVideoWidget10saturationEv @ 497 NONAME - _ZNK12QVideoWidget11mediaObjectEv @ 498 NONAME - _ZNK12QVideoWidget15aspectRatioModeEv @ 499 NONAME - _ZNK12QVideoWidget3hueEv @ 500 NONAME - _ZNK12QVideoWidget8contrastEv @ 501 NONAME - _ZNK12QVideoWidget8sizeHintEv @ 502 NONAME - _ZNK13QMediaContent12canonicalUrlEv @ 503 NONAME - _ZNK13QMediaContent16canonicalRequestEv @ 504 NONAME - _ZNK13QMediaContent17canonicalResourceEv @ 505 NONAME - _ZNK13QMediaContent6isNullEv @ 506 NONAME - _ZNK13QMediaContent9resourcesEv @ 507 NONAME - _ZNK13QMediaContenteqERKS_ @ 508 NONAME - _ZNK13QMediaContentneERKS_ @ 509 NONAME - _ZNK13QMediaControl10metaObjectEv @ 510 NONAME - _ZNK13QMediaService10metaObjectEv @ 511 NONAME - _ZNK14QMediaPlaylist10isReadOnlyEv @ 512 NONAME - _ZNK14QMediaPlaylist10mediaCountEv @ 513 NONAME - _ZNK14QMediaPlaylist10metaObjectEv @ 514 NONAME - _ZNK14QMediaPlaylist11errorStringEv @ 515 NONAME - _ZNK14QMediaPlaylist11mediaObjectEv @ 516 NONAME - _ZNK14QMediaPlaylist12currentIndexEv @ 517 NONAME - _ZNK14QMediaPlaylist12currentMediaEv @ 518 NONAME - _ZNK14QMediaPlaylist12playbackModeEv @ 519 NONAME - _ZNK14QMediaPlaylist13previousIndexEi @ 520 NONAME - _ZNK14QMediaPlaylist5errorEv @ 521 NONAME - _ZNK14QMediaPlaylist5mediaEi @ 522 NONAME - _ZNK14QMediaPlaylist7isEmptyEv @ 523 NONAME - _ZNK14QMediaPlaylist9nextIndexEi @ 524 NONAME - _ZNK14QMediaResource10audioCodecEv @ 525 NONAME - _ZNK14QMediaResource10resolutionEv @ 526 NONAME - _ZNK14QMediaResource10sampleRateEv @ 527 NONAME - _ZNK14QMediaResource10videoCodecEv @ 528 NONAME - _ZNK14QMediaResource12audioBitRateEv @ 529 NONAME - _ZNK14QMediaResource12channelCountEv @ 530 NONAME - _ZNK14QMediaResource12videoBitRateEv @ 531 NONAME - _ZNK14QMediaResource3urlEv @ 532 NONAME - _ZNK14QMediaResource6isNullEv @ 533 NONAME - _ZNK14QMediaResource7requestEv @ 534 NONAME - _ZNK14QMediaResource8dataSizeEv @ 535 NONAME - _ZNK14QMediaResource8languageEv @ 536 NONAME - _ZNK14QMediaResource8mimeTypeEv @ 537 NONAME - _ZNK14QMediaResourceeqERKS_ @ 538 NONAME - _ZNK14QMediaResourceneERKS_ @ 539 NONAME - _ZNK15QMediaTimeRange10latestTimeEv @ 540 NONAME - _ZNK15QMediaTimeRange12earliestTimeEv @ 541 NONAME - _ZNK15QMediaTimeRange12isContinuousEv @ 542 NONAME - _ZNK15QMediaTimeRange7isEmptyEv @ 543 NONAME - _ZNK15QMediaTimeRange8containsEx @ 544 NONAME - _ZNK15QMediaTimeRange9intervalsEv @ 545 NONAME - _ZNK16QMetaDataControl10metaObjectEv @ 546 NONAME - _ZNK18QGraphicsVideoItem10metaObjectEv @ 547 NONAME - _ZNK18QGraphicsVideoItem10nativeSizeEv @ 548 NONAME - _ZNK18QGraphicsVideoItem11mediaObjectEv @ 549 NONAME - _ZNK18QGraphicsVideoItem12boundingRectEv @ 550 NONAME - _ZNK18QGraphicsVideoItem15aspectRatioModeEv @ 551 NONAME - _ZNK18QGraphicsVideoItem4sizeEv @ 552 NONAME - _ZNK18QGraphicsVideoItem6offsetEv @ 553 NONAME - _ZNK18QMediaTimeInterval10normalizedEv @ 554 NONAME - _ZNK18QMediaTimeInterval10translatedEx @ 555 NONAME - _ZNK18QMediaTimeInterval3endEv @ 556 NONAME - _ZNK18QMediaTimeInterval5startEv @ 557 NONAME - _ZNK18QMediaTimeInterval8containsEx @ 558 NONAME - _ZNK18QMediaTimeInterval8isNormalEv @ 559 NONAME - _ZNK19QMediaPlayerControl10metaObjectEv @ 560 NONAME - _ZNK19QVideoDeviceControl10metaObjectEv @ 561 NONAME - _ZNK19QVideoOutputControl10metaObjectEv @ 562 NONAME - _ZNK19QVideoWidgetControl10metaObjectEv @ 563 NONAME - _ZNK19QVideoWindowControl10metaObjectEv @ 564 NONAME - _ZNK20QPainterVideoSurface10brightnessEv @ 565 NONAME - _ZNK20QPainterVideoSurface10metaObjectEv @ 566 NONAME - _ZNK20QPainterVideoSurface10saturationEv @ 567 NONAME - _ZNK20QPainterVideoSurface17isFormatSupportedERK19QVideoSurfaceFormatPS0_ @ 568 NONAME - _ZNK20QPainterVideoSurface21supportedPixelFormatsEN20QAbstractVideoBuffer10HandleTypeE @ 569 NONAME - _ZNK20QPainterVideoSurface3hueEv @ 570 NONAME - _ZNK20QPainterVideoSurface7isReadyEv @ 571 NONAME - _ZNK20QPainterVideoSurface8contrastEv @ 572 NONAME - _ZNK21QMediaPlaylistControl10metaObjectEv @ 573 NONAME - _ZNK21QMediaServiceProvider10hasSupportERK10QByteArrayRK7QStringRK11QStringListi @ 574 NONAME - _ZNK21QMediaServiceProvider10metaObjectEv @ 575 NONAME - _ZNK21QMediaServiceProvider18supportedMimeTypesERK10QByteArrayi @ 576 NONAME - _ZNK21QMediaServiceProvider7devicesERK10QByteArray @ 577 NONAME - _ZNK21QVideoRendererControl10metaObjectEv @ 578 NONAME - _ZNK22QMediaPlaylistIOPlugin10metaObjectEv @ 579 NONAME - _ZNK22QMediaPlaylistProvider10isReadOnlyEv @ 580 NONAME - _ZNK22QMediaPlaylistProvider10metaObjectEv @ 581 NONAME - _ZNK23QMediaPlaylistNavigator10metaObjectEv @ 582 NONAME - _ZNK23QMediaPlaylistNavigator11currentItemEv @ 583 NONAME - _ZNK23QMediaPlaylistNavigator12currentIndexEv @ 584 NONAME - _ZNK23QMediaPlaylistNavigator12playbackModeEv @ 585 NONAME - _ZNK23QMediaPlaylistNavigator12previousItemEi @ 586 NONAME - _ZNK23QMediaPlaylistNavigator13previousIndexEi @ 587 NONAME - _ZNK23QMediaPlaylistNavigator6itemAtEi @ 588 NONAME - _ZNK23QMediaPlaylistNavigator8nextItemEi @ 589 NONAME - _ZNK23QMediaPlaylistNavigator8playlistEv @ 590 NONAME - _ZNK23QMediaPlaylistNavigator9nextIndexEi @ 591 NONAME - _ZNK25QMediaServiceProviderHint4typeEv @ 592 NONAME - _ZNK25QMediaServiceProviderHint6codecsEv @ 593 NONAME - _ZNK25QMediaServiceProviderHint6deviceEv @ 594 NONAME - _ZNK25QMediaServiceProviderHint6isNullEv @ 595 NONAME - _ZNK25QMediaServiceProviderHint8featuresEv @ 596 NONAME - _ZNK25QMediaServiceProviderHint8mimeTypeEv @ 597 NONAME - _ZNK25QMediaServiceProviderHinteqERKS_ @ 598 NONAME - _ZNK25QMediaServiceProviderHintneERKS_ @ 599 NONAME - _ZNK27QLocalMediaPlaylistProvider10isReadOnlyEv @ 600 NONAME - _ZNK27QLocalMediaPlaylistProvider10mediaCountEv @ 601 NONAME - _ZNK27QLocalMediaPlaylistProvider10metaObjectEv @ 602 NONAME - _ZNK27QLocalMediaPlaylistProvider5mediaEi @ 603 NONAME - _ZNK27QMediaServiceProviderPlugin10metaObjectEv @ 604 NONAME - _ZTI12QMediaObject @ 605 NONAME - _ZTI12QMediaPlayer @ 606 NONAME - _ZTI12QSoundEffect @ 607 NONAME - _ZTI12QVideoWidget @ 608 NONAME - _ZTI13QMediaControl @ 609 NONAME - _ZTI13QMediaService @ 610 NONAME - _ZTI14QMediaPlaylist @ 611 NONAME - _ZTI16QMetaDataControl @ 612 NONAME - _ZTI18QGraphicsVideoItem @ 613 NONAME - _ZTI19QMediaPlayerControl @ 614 NONAME - _ZTI19QVideoDeviceControl @ 615 NONAME - _ZTI19QVideoOutputControl @ 616 NONAME - _ZTI19QVideoWidgetControl @ 617 NONAME - _ZTI19QVideoWindowControl @ 618 NONAME - _ZTI20QMediaPlaylistReader @ 619 NONAME - _ZTI20QMediaPlaylistWriter @ 620 NONAME - _ZTI20QPainterVideoSurface @ 621 NONAME - _ZTI21QMediaPlaylistControl @ 622 NONAME - _ZTI21QMediaServiceProvider @ 623 NONAME - _ZTI21QVideoRendererControl @ 624 NONAME - _ZTI22QMediaPlaylistIOPlugin @ 625 NONAME - _ZTI22QMediaPlaylistProvider @ 626 NONAME - _ZTI23QMediaPlaylistNavigator @ 627 NONAME - _ZTI25QMediaPlaylistIOInterface @ 628 NONAME - _ZTI27QLocalMediaPlaylistProvider @ 629 NONAME - _ZTI27QMediaServiceProviderPlugin @ 630 NONAME - _ZTI37QMediaServiceProviderFactoryInterface @ 631 NONAME - _ZTV12QMediaObject @ 632 NONAME - _ZTV12QMediaPlayer @ 633 NONAME - _ZTV12QSoundEffect @ 634 NONAME - _ZTV12QVideoWidget @ 635 NONAME - _ZTV13QMediaControl @ 636 NONAME - _ZTV13QMediaService @ 637 NONAME - _ZTV14QMediaPlaylist @ 638 NONAME - _ZTV16QMetaDataControl @ 639 NONAME - _ZTV18QGraphicsVideoItem @ 640 NONAME - _ZTV19QMediaPlayerControl @ 641 NONAME - _ZTV19QVideoDeviceControl @ 642 NONAME - _ZTV19QVideoOutputControl @ 643 NONAME - _ZTV19QVideoWidgetControl @ 644 NONAME - _ZTV19QVideoWindowControl @ 645 NONAME - _ZTV20QMediaPlaylistReader @ 646 NONAME - _ZTV20QMediaPlaylistWriter @ 647 NONAME - _ZTV20QPainterVideoSurface @ 648 NONAME - _ZTV21QMediaPlaylistControl @ 649 NONAME - _ZTV21QMediaServiceProvider @ 650 NONAME - _ZTV21QVideoRendererControl @ 651 NONAME - _ZTV22QMediaPlaylistIOPlugin @ 652 NONAME - _ZTV22QMediaPlaylistProvider @ 653 NONAME - _ZTV23QMediaPlaylistNavigator @ 654 NONAME - _ZTV27QLocalMediaPlaylistProvider @ 655 NONAME - _ZTV27QMediaServiceProviderPlugin @ 656 NONAME - _ZThn8_N12QVideoWidgetD0Ev @ 657 NONAME - _ZThn8_N12QVideoWidgetD1Ev @ 658 NONAME - _ZThn8_N18QGraphicsVideoItem10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 659 NONAME - _ZThn8_N18QGraphicsVideoItem10sceneEventEP6QEvent @ 660 NONAME - _ZThn8_N18QGraphicsVideoItem5paintEP8QPainterPK24QStyleOptionGraphicsItemP7QWidget @ 661 NONAME - _ZThn8_N18QGraphicsVideoItemD0Ev @ 662 NONAME - _ZThn8_N18QGraphicsVideoItemD1Ev @ 663 NONAME - _ZThn8_N22QMediaPlaylistIOPluginD0Ev @ 664 NONAME - _ZThn8_N22QMediaPlaylistIOPluginD1Ev @ 665 NONAME - _ZThn8_NK18QGraphicsVideoItem12boundingRectEv @ 666 NONAME - _ZeqRK15QMediaTimeRangeS1_ @ 667 NONAME - _ZeqRK18QMediaTimeIntervalS1_ @ 668 NONAME - _ZmiRK15QMediaTimeRangeS1_ @ 669 NONAME - _ZneRK15QMediaTimeRangeS1_ @ 670 NONAME - _ZneRK18QMediaTimeIntervalS1_ @ 671 NONAME - _ZplRK15QMediaTimeRangeS1_ @ 672 NONAME - diff --git a/src/src.pro b/src/src.pro index 9c4831c..796f990 100644 --- a/src/src.pro +++ b/src/src.pro @@ -17,7 +17,6 @@ contains(QT_CONFIG, openvg): SRC_SUBDIRS += src_openvg contains(QT_CONFIG, xmlpatterns): SRC_SUBDIRS += src_xmlpatterns contains(QT_CONFIG, phonon): SRC_SUBDIRS += src_phonon contains(QT_CONFIG, multimedia): SRC_SUBDIRS += src_multimedia -contains(QT_CONFIG, mediaservices): SRC_SUBDIRS += src_mediaservices contains(QT_CONFIG, svg): SRC_SUBDIRS += src_svg contains(QT_CONFIG, webkit) { exists($$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro): SRC_SUBDIRS += src_javascriptcore @@ -67,10 +66,8 @@ src_qt3support.subdir = $$QT_SOURCE_TREE/src/qt3support src_qt3support.target = sub-qt3support src_phonon.subdir = $$QT_SOURCE_TREE/src/phonon src_phonon.target = sub-phonon -src_multimedia.subdir = $$QT_SOURCE_TREE/src/multimedia/multimedia +src_multimedia.subdir = $$QT_SOURCE_TREE/src/multimedia src_multimedia.target = sub-multimedia -src_mediaservices.subdir = $$QT_SOURCE_TREE/src/multimedia/mediaservices -src_mediaservices.target = sub-mediaservices src_activeqt.subdir = $$QT_SOURCE_TREE/src/activeqt src_activeqt.target = sub-activeqt src_plugins.subdir = $$QT_SOURCE_TREE/src/plugins @@ -108,7 +105,6 @@ src_declarative.target = sub-declarative src_phonon.depends = src_gui src_multimedia.depends = src_gui contains(QT_CONFIG, opengl):src_multimedia.depends += src_opengl - src_mediaservices.depends = src_multimedia src_tools_activeqt.depends = src_tools_idc src_gui src_declarative.depends = src_xml src_gui src_script src_network src_svg src_plugins.depends = src_gui src_sql src_svg src_multimedia @@ -116,7 +112,6 @@ src_declarative.target = sub-declarative src_imports.depends = src_gui src_declarative contains(QT_CONFIG, webkit) { src_webkit.depends = src_gui src_sql src_network src_xml - contains(QT_CONFIG, mediaservices):src_webkit.depends += src_mediaservices contains(QT_CONFIG, xmlpatterns): src_webkit.depends += src_xmlpatterns contains(QT_CONFIG, declarative):src_declarative.depends += src_webkit src_imports.depends += src_webkit diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 12ebc75..c0004f7 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -16,7 +16,6 @@ unix:!embedded:contains(QT_CONFIG, dbus): SUBDIRS += dbus.pro contains(QT_CONFIG, script): SUBDIRS += script.pro contains(QT_CONFIG, webkit): SUBDIRS += webkit.pro contains(QT_CONFIG, multimedia): SUBDIRS += multimedia.pro -contains(QT_CONFIG, mediaservices): SUBDIRS += mediaservices.pro contains(QT_CONFIG, phonon): SUBDIRS += phonon.pro contains(QT_CONFIG, svg): SUBDIRS += svg.pro contains(QT_CONFIG, declarative): SUBDIRS += declarative.pro diff --git a/tests/auto/mediaservices.pro b/tests/auto/mediaservices.pro deleted file mode 100644 index 1b50cd7..0000000 --- a/tests/auto/mediaservices.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE=subdirs -SUBDIRS=\ - qsoundeffect \ - qdeclarativeaudio \ - qdeclarativevideo \ - qgraphicsvideoitem \ - qmediacontent \ - qmediaobject \ - qmediaplayer \ - qmediaplaylist \ - qmediaplaylistnavigator \ - qmediapluginloader \ - qmediaresource \ - qmediaservice \ - qmediaserviceprovider \ - qmediatimerange \ - qvideowidget - - diff --git a/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro b/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro deleted file mode 100644 index ecfe299..0000000 --- a/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro +++ /dev/null @@ -1,14 +0,0 @@ -load(qttest_p4) - -HEADERS += \ - $$PWD/../../../src/imports/multimedia/qdeclarativeaudio_p.h \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase_p.h \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject_p.h - -SOURCES += \ - tst_qdeclarativeaudio.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativeaudio.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase.cpp \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject.cpp - -QT += mediaservices declarative diff --git a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp deleted file mode 100644 index e393599..0000000 --- a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp +++ /dev/null @@ -1,1252 +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 "../../../src/imports/multimedia/qdeclarativeaudio_p.h" - -#include -#include -#include -#include - - -class tst_QDeclarativeAudio : public QObject -{ - Q_OBJECT -public slots: - void initTestCase(); - -private slots: - void nullPlayerControl(); - void nullMetaDataControl(); - void nullService(); - - void source(); - void autoLoad(); - void playing(); - void paused(); - void duration(); - void position(); - void volume(); - void muted(); - void bufferProgress(); - void seekable(); - void playbackRate(); - void status(); - void metaData_data(); - void metaData(); - void error(); -}; - -Q_DECLARE_METATYPE(QtMediaServices::MetaData); -Q_DECLARE_METATYPE(QDeclarativeAudio::Error); - -class QtTestMediaPlayerControl : public QMediaPlayerControl -{ - Q_OBJECT -public: - QtTestMediaPlayerControl(QObject *parent = 0) - : QMediaPlayerControl(parent) - , m_state(QMediaPlayer::StoppedState) - , m_mediaStatus(QMediaPlayer::NoMedia) - , m_duration(0) - , m_position(0) - , m_playbackRate(1.0) - , m_volume(50) - , m_bufferStatus(0) - , m_muted(false) - , m_audioAvailable(false) - , m_videoAvailable(false) - , m_seekable(false) - { - } - - QMediaPlayer::State state() const { return m_state; } - void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); } - - QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; } - void updateMediaStatus(QMediaPlayer::MediaStatus status) { - emit mediaStatusChanged(m_mediaStatus = status); } - void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state) - { - m_mediaStatus = status; - m_state = state; - - emit mediaStatusChanged(m_mediaStatus); - emit stateChanged(m_state); - } - - qint64 duration() const { return m_duration; } - void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); } - - qint64 position() const { return m_position; } - void setPosition(qint64 position) { emit positionChanged(m_position = position); } - - int volume() const { return m_volume; } - void setVolume(int volume) { emit volumeChanged(m_volume = volume); } - - bool isMuted() const { return m_muted; } - void setMuted(bool muted) { emit mutedChanged(m_muted = muted); } - - int bufferStatus() const { return m_bufferStatus; } - void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); } - - bool isAudioAvailable() const { return m_audioAvailable; } - void setAudioAvailable(bool available) { - emit audioAvailableChanged(m_audioAvailable = available); } - bool isVideoAvailable() const { return m_videoAvailable; } - void setVideoAvailable(bool available) { - emit videoAvailableChanged(m_videoAvailable = available); } - - bool isSeekable() const { return m_seekable; } - void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); } - - QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); } - - qreal playbackRate() const { return m_playbackRate; } - void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); } - - QMediaContent media() const { return m_media; } - const QIODevice *mediaStream() const { return 0; } - void setMedia(const QMediaContent &media, QIODevice *) - { - m_media = media; - - m_mediaStatus = m_media.isNull() - ? QMediaPlayer::NoMedia - : QMediaPlayer::LoadingMedia; - - emit mediaChanged(m_media); - emit mediaStatusChanged(m_mediaStatus); - } - - void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); } - void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); } - void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); } - - void emitError(QMediaPlayer::Error err, const QString &errorString) { - emit error(err, errorString); } - -private: - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_mediaStatus; - qint64 m_duration; - qint64 m_position; - qreal m_playbackRate; - int m_volume; - int m_bufferStatus; - bool m_muted; - bool m_audioAvailable; - bool m_videoAvailable; - bool m_seekable; - QMediaContent m_media; -}; - -class QtTestMetaDataControl : public QMetaDataControl -{ - Q_OBJECT -public: - QtTestMetaDataControl(QObject *parent = 0) - : QMetaDataControl(parent) - { - } - - bool isWritable() const { return true; } - bool isMetaDataAvailable() const { return true; } - - QVariant metaData(QtMediaServices::MetaData key) const { return m_metaData.value(key); } - void setMetaData(QtMediaServices::MetaData key, const QVariant &value) { - m_metaData.insert(key, value); emit metaDataChanged(); } - void setMetaData(const QMap &metaData) { - m_metaData = metaData; emit metaDataChanged(); } - - QList availableMetaData() const { return m_metaData.keys(); } - - QVariant extendedMetaData(const QString &) const { return QVariant(); } - void setExtendedMetaData(const QString &, const QVariant &) {} - QStringList availableExtendedMetaData() const { return QStringList(); } - -private: - QMap m_metaData; -}; - -class QtTestMediaService : public QMediaService -{ - Q_OBJECT -public: - QtTestMediaService( - QtTestMediaPlayerControl *playerControl, - QtTestMetaDataControl *metaDataControl, - QObject *parent) - : QMediaService(parent) - , playerControl(playerControl) - , metaDataControl(metaDataControl) - { - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return playerControl; - else if (qstrcmp(name, QMetaDataControl_iid) == 0) - return metaDataControl; - else - return 0; - } - - QtTestMediaPlayerControl *playerControl; - QtTestMetaDataControl *metaDataControl; -}; - -class QtTestMediaServiceProvider : public QMediaServiceProvider -{ - Q_OBJECT -public: - QtTestMediaServiceProvider() - : service(new QtTestMediaService( - new QtTestMediaPlayerControl(this), new QtTestMetaDataControl(this), this)) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider(QtTestMediaService *service) - : service(service) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider( - QtTestMediaPlayerControl *playerControl, QtTestMetaDataControl *metaDataControl) - : service(new QtTestMediaService(playerControl, metaDataControl, this)) - { - setDefaultServiceProvider(this); - } - - ~QtTestMediaServiceProvider() - { - setDefaultServiceProvider(0); - } - - QMediaService *requestService( - const QByteArray &type, - const QMediaServiceProviderHint & = QMediaServiceProviderHint()) - { - requestedService = type; - - return service; - } - - void releaseService(QMediaService *) {} - - inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; } - inline QtTestMetaDataControl *metaDataControl() { return service->metaDataControl; } - - QtTestMediaService *service; - QByteArray requestedService; -}; - - -void tst_QDeclarativeAudio::initTestCase() -{ - qRegisterMetaType(); -} - -void tst_QDeclarativeAudio::nullPlayerControl() -{ - QtTestMetaDataControl metaDataControl; - QtTestMediaServiceProvider provider(0, &metaDataControl); - - QDeclarativeAudio audio; - - QCOMPARE(audio.source(), QUrl()); - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.source(), QUrl("http://example.com")); - - QCOMPARE(audio.isPlaying(), false); - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - audio.setPlaying(false); - audio.play(); - QCOMPARE(audio.isPlaying(), false); - - QCOMPARE(audio.isPaused(), false); - audio.pause(); - QCOMPARE(audio.isPaused(), false); - audio.setPaused(true); - QCOMPARE(audio.isPaused(), true); - - QCOMPARE(audio.duration(), 0); - - QCOMPARE(audio.position(), 0); - audio.setPosition(10000); - QCOMPARE(audio.position(), 10000); - - QCOMPARE(audio.volume(), qreal(1.0)); - audio.setVolume(0.5); - QCOMPARE(audio.volume(), qreal(0.5)); - - QCOMPARE(audio.isMuted(), false); - audio.setMuted(true); - QCOMPARE(audio.isMuted(), true); - - QCOMPARE(audio.bufferProgress(), qreal(0)); - - QCOMPARE(audio.isSeekable(), false); - - QCOMPARE(audio.playbackRate(), qreal(1.0)); - - QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia); - - QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing); -} - -void tst_QDeclarativeAudio::nullMetaDataControl() -{ - QtTestMediaPlayerControl playerControl; - QtTestMediaServiceProvider provider(&playerControl, 0); - - QDeclarativeAudio audio; - - QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1); -} - -void tst_QDeclarativeAudio::nullService() -{ - QtTestMediaServiceProvider provider(0); - - QDeclarativeAudio audio; - - QCOMPARE(audio.source(), QUrl()); - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.source(), QUrl("http://example.com")); - - QCOMPARE(audio.isPlaying(), false); - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - audio.setPlaying(false); - audio.play(); - QCOMPARE(audio.isPlaying(), false); - - QCOMPARE(audio.isPaused(), false); - audio.pause(); - QCOMPARE(audio.isPaused(), false); - audio.setPaused(true); - QCOMPARE(audio.isPaused(), true); - - QCOMPARE(audio.duration(), 0); - - QCOMPARE(audio.position(), 0); - audio.setPosition(10000); - QCOMPARE(audio.position(), 10000); - - QCOMPARE(audio.volume(), qreal(1.0)); - audio.setVolume(0.5); - QCOMPARE(audio.volume(), qreal(0.5)); - - QCOMPARE(audio.isMuted(), false); - audio.setMuted(true); - QCOMPARE(audio.isMuted(), true); - - QCOMPARE(audio.bufferProgress(), qreal(0)); - - QCOMPARE(audio.isSeekable(), false); - - QCOMPARE(audio.playbackRate(), qreal(1.0)); - - QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia); - - QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing); - - QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1); -} - -void tst_QDeclarativeAudio::source() -{ - const QUrl url1("http://example.com"); - const QUrl url2("file:///local/path"); - const QUrl url3; - - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(sourceChanged())); - - audio.setSource(url1); - QCOMPARE(audio.source(), url1); - QCOMPARE(provider.playerControl()->media().canonicalUrl(), url1); - QCOMPARE(spy.count(), 1); - - audio.setSource(url2); - QCOMPARE(audio.source(), url2); - QCOMPARE(provider.playerControl()->media().canonicalUrl(), url2); - QCOMPARE(spy.count(), 2); - - audio.setSource(url3); - QCOMPARE(audio.source(), url3); - QCOMPARE(provider.playerControl()->media().canonicalUrl(), url3); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::autoLoad() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(autoLoadChanged())); - - QCOMPARE(audio.isAutoLoad(), true); - - audio.setAutoLoad(false); - QCOMPARE(audio.isAutoLoad(), false); - QCOMPARE(spy.count(), 1); - - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.source(), QUrl("http://example.com")); - audio.play(); - QCOMPARE(audio.isPlaying(), true); - audio.stop(); - - audio.setAutoLoad(true); - audio.setSource(QUrl("http://example.com")); - audio.setPaused(true); - QCOMPARE(spy.count(), 2); - QCOMPARE(audio.isPaused(), true); -} - -void tst_QDeclarativeAudio::playing() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged())); - QSignalSpy startedSpy(&audio, SIGNAL(started())); - QSignalSpy stoppedSpy(&audio, SIGNAL(stopped())); - - int playingChanged = 0; - int started = 0; - int stopped = 0; - - audio.componentComplete(); - - QCOMPARE(audio.isPlaying(), false); - - // setPlaying(true) when stopped. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when playing. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when playing. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // stop() when stopped. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when stopped. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when playing. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when playing. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeAudio::paused() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged())); - QSignalSpy pausedChangedSpy(&audio, SIGNAL(pausedChanged())); - QSignalSpy startedSpy(&audio, SIGNAL(started())); - QSignalSpy pausedSpy(&audio, SIGNAL(paused())); - QSignalSpy resumedSpy(&audio, SIGNAL(resumed())); - QSignalSpy stoppedSpy(&audio, SIGNAL(stopped())); - - int playingChanged = 0; - int pausedChanged = 0; - int started = 0; - int paused = 0; - int resumed = 0; - int stopped = 0; - - audio.componentComplete(); - - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - - // setPlaying(true) when stopped. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when paused. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when paused. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when paused. - audio.setPaused(false); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when playing. - audio.setPaused(false); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when playing. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped and paused. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when stopped and paused. - audio.setPaused(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when stopped. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when stopped and paused. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when paused. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when paused. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when stopped and paused. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when stopped. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // pause() when stopped and paused. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped and paused. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeAudio::duration() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(durationChanged())); - - QCOMPARE(audio.duration(), 0); - - provider.playerControl()->setDuration(4040); - QCOMPARE(audio.duration(), 4040); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setDuration(-129); - QCOMPARE(audio.duration(), -129); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setDuration(0); - QCOMPARE(audio.duration(), 0); - QCOMPARE(spy.count(), 3); - - // Unnecessary duration changed signals aren't filtered. - provider.playerControl()->setDuration(0); - QCOMPARE(audio.duration(), 0); - QCOMPARE(spy.count(), 4); -} - -void tst_QDeclarativeAudio::position() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(positionChanged())); - - QCOMPARE(audio.position(), 0); - - // QDeclarativeAudio won't bound set positions to the duration. A media service may though. - QCOMPARE(audio.duration(), 0); - - audio.setPosition(450); - QCOMPARE(audio.position(), 450); - QCOMPARE(provider.playerControl()->position(), qint64(450)); - QCOMPARE(spy.count(), 1); - - audio.setPosition(-5403); - QCOMPARE(audio.position(), -5403); - QCOMPARE(provider.playerControl()->position(), qint64(-5403)); - QCOMPARE(spy.count(), 2); - - audio.setPosition(-5403); - QCOMPARE(audio.position(), -5403); - QCOMPARE(provider.playerControl()->position(), qint64(-5403)); - QCOMPARE(spy.count(), 2); - - // Check the signal change signal is emitted if the change originates from the media service. - provider.playerControl()->setPosition(0); - QCOMPARE(audio.position(), 0); - QCOMPARE(spy.count(), 3); - - connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - provider.playerControl()->updateState(QMediaPlayer::PlayingState); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5 - - provider.playerControl()->updateState(QMediaPlayer::PausedState); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() < 6); -} - -void tst_QDeclarativeAudio::volume() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(volumeChanged())); - - QCOMPARE(audio.volume(), qreal(1.0)); - - audio.setVolume(0.7); - QCOMPARE(audio.volume(), qreal(0.7)); - QCOMPARE(provider.playerControl()->volume(), 70); - QCOMPARE(spy.count(), 1); - - audio.setVolume(0.7); - QCOMPARE(audio.volume(), qreal(0.7)); - QCOMPARE(provider.playerControl()->volume(), 70); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setVolume(30); - QCOMPARE(audio.volume(), qreal(0.3)); - QCOMPARE(spy.count(), 2); -} - -void tst_QDeclarativeAudio::muted() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(mutedChanged())); - - QCOMPARE(audio.isMuted(), false); - - audio.setMuted(true); - QCOMPARE(audio.isMuted(), true); - QCOMPARE(provider.playerControl()->isMuted(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setMuted(false); - QCOMPARE(audio.isMuted(), false); - QCOMPARE(spy.count(), 2); - - audio.setMuted(false); - QCOMPARE(audio.isMuted(), false); - QCOMPARE(provider.playerControl()->isMuted(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::bufferProgress() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(bufferProgressChanged())); - - QCOMPARE(audio.bufferProgress(), qreal(0.0)); - - provider.playerControl()->setBufferStatus(20); - QCOMPARE(audio.bufferProgress(), qreal(0.2)); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setBufferStatus(20); - QCOMPARE(audio.bufferProgress(), qreal(0.2)); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setBufferStatus(40); - QCOMPARE(audio.bufferProgress(), qreal(0.4)); - QCOMPARE(spy.count(), 3); - - connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - provider.playerControl()->updateMediaStatus( - QMediaPlayer::BufferingMedia, QMediaPlayer::PlayingState); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5 - - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() < 6); -} - -void tst_QDeclarativeAudio::seekable() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(seekableChanged())); - - QCOMPARE(audio.isSeekable(), false); - - provider.playerControl()->setSeekable(true); - QCOMPARE(audio.isSeekable(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setSeekable(true); - QCOMPARE(audio.isSeekable(), true); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setSeekable(false); - QCOMPARE(audio.isSeekable(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::playbackRate() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(playbackRateChanged())); - - QCOMPARE(audio.playbackRate(), qreal(1.0)); - - audio.setPlaybackRate(0.5); - QCOMPARE(audio.playbackRate(), qreal(0.5)); - QCOMPARE(provider.playerControl()->playbackRate(), qreal(0.5)); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setPlaybackRate(2.0); - QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0)); - QCOMPARE(spy.count(), 2); - - audio.setPlaybackRate(2.0); - QCOMPARE(audio.playbackRate(), qreal(2.0)); - QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0)); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::status() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy statusChangedSpy(&audio, SIGNAL(statusChanged())); - QSignalSpy loadedSpy(&audio, SIGNAL(loaded())); - QSignalSpy bufferingSpy(&audio, SIGNAL(buffering())); - QSignalSpy stalledSpy(&audio, SIGNAL(stalled())); - QSignalSpy bufferedSpy(&audio, SIGNAL(buffered())); - QSignalSpy endOfMediaSpy(&audio, SIGNAL(endOfMedia())); - - QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia); - - // Set media, start loading. - provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Loading); - QCOMPARE(statusChangedSpy.count(), 1); - QCOMPARE(loadedSpy.count(), 0); - QCOMPARE(bufferingSpy.count(), 0); - QCOMPARE(stalledSpy.count(), 0); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Finish loading. - provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadedMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Loaded); - QCOMPARE(statusChangedSpy.count(), 2); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 0); - QCOMPARE(stalledSpy.count(), 0); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Play, start buffering. - provider.playerControl()->updateMediaStatus( - QMediaPlayer::StalledMedia, QMediaPlayer::PlayingState); - QCOMPARE(audio.status(), QDeclarativeAudio::Stalled); - QCOMPARE(statusChangedSpy.count(), 3); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 0); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Enough data buffered to proceed. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); - QCOMPARE(statusChangedSpy.count(), 4); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 1); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Errant second buffering status changed. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); - QCOMPARE(statusChangedSpy.count(), 4); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 1); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Buffer full. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffered); - QCOMPARE(statusChangedSpy.count(), 5); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 1); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 1); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Buffer getting low. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); - QCOMPARE(statusChangedSpy.count(), 6); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 2); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 1); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Buffer full. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffered); - QCOMPARE(statusChangedSpy.count(), 7); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 2); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 2); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Finished. - provider.playerControl()->updateMediaStatus( - QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); - QCOMPARE(audio.status(), QDeclarativeAudio::EndOfMedia); - QCOMPARE(statusChangedSpy.count(), 8); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 2); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 2); - QCOMPARE(endOfMediaSpy.count(), 1); -} - -void tst_QDeclarativeAudio::metaData_data() -{ - QTest::addColumn("propertyName"); - QTest::addColumn("propertyKey"); - QTest::addColumn("value1"); - QTest::addColumn("value2"); - - QTest::newRow("title") - << QByteArray("title") - << QtMediaServices::Title - << QVariant(QString::fromLatin1("This is a title")) - << QVariant(QString::fromLatin1("This is another title")); - - QTest::newRow("genre") - << QByteArray("genre") - << QtMediaServices::Genre - << QVariant(QString::fromLatin1("rock")) - << QVariant(QString::fromLatin1("pop")); - - QTest::newRow("trackNumber") - << QByteArray("trackNumber") - << QtMediaServices::TrackNumber - << QVariant(8) - << QVariant(12); -} - -void tst_QDeclarativeAudio::metaData() -{ - QFETCH(QByteArray, propertyName); - QFETCH(QtMediaServices::MetaData, propertyKey); - QFETCH(QVariant, value1); - QFETCH(QVariant, value2); - - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(__metaDataChanged())); - - const int index = audio.metaObject()->indexOfProperty(propertyName.constData()); - QVERIFY(index != -1); - - QMetaProperty property = audio.metaObject()->property(index); - QCOMPARE(property.read(&audio), QVariant()); - - property.write(&audio, value1); - QCOMPARE(property.read(&audio), value1); - QCOMPARE(provider.metaDataControl()->metaData(propertyKey), value1); - QCOMPARE(spy.count(), 1); - - provider.metaDataControl()->setMetaData(propertyKey, value2); - QCOMPARE(property.read(&audio), value2); - QCOMPARE(spy.count(), 2); -} - -void tst_QDeclarativeAudio::error() -{ - const QString errorString = QLatin1String("Failed to open device."); - - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy errorSpy(&audio, SIGNAL(error(QDeclarativeAudio::Error,QString))); - QSignalSpy errorChangedSpy(&audio, SIGNAL(errorChanged())); - - QCOMPARE(audio.error(), QDeclarativeAudio::NoError); - QCOMPARE(audio.errorString(), QString()); - - provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString); - - QCOMPARE(audio.error(), QDeclarativeAudio::ResourceError); - QCOMPARE(audio.errorString(), errorString); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 1); - - // Changing the source resets the error properties. - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.error(), QDeclarativeAudio::NoError); - QCOMPARE(audio.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); - - // But isn't noisy. - audio.setSource(QUrl("file:///file/path")); - QCOMPARE(audio.error(), QDeclarativeAudio::NoError); - QCOMPARE(audio.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); -} - - -QTEST_MAIN(tst_QDeclarativeAudio) - -#include "tst_qdeclarativeaudio.moc" diff --git a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro b/tests/auto/qdeclarativevideo/qdeclarativevideo.pro deleted file mode 100644 index 64a20da..0000000 --- a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro +++ /dev/null @@ -1,14 +0,0 @@ -load(qttest_p4) - -HEADERS += \ - $$PWD/../../../src/imports/multimedia/qdeclarativevideo_p.h \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase_p.h \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject_p.h - -SOURCES += \ - tst_qdeclarativevideo.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativevideo.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase.cpp \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject.cpp - -QT += multimedia mediaservices declarative diff --git a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp deleted file mode 100644 index 99b447a..0000000 --- a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp +++ /dev/null @@ -1,921 +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 "../../../src/imports/multimedia/qdeclarativevideo_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include - - -class tst_QDeclarativeVideo : public QObject -{ - Q_OBJECT -public slots: - void initTestCase(); - -private slots: - void nullPlayerControl(); - void nullService(); - - void playing(); - void paused(); - void error(); - - void hasAudio(); - void hasVideo(); - void fillMode(); - void geometry(); -}; - -Q_DECLARE_METATYPE(QtMediaServices::MetaData); -Q_DECLARE_METATYPE(QDeclarativeVideo::Error); - -class QtTestMediaPlayerControl : public QMediaPlayerControl -{ - Q_OBJECT -public: - QtTestMediaPlayerControl(QObject *parent = 0) - : QMediaPlayerControl(parent) - , m_state(QMediaPlayer::StoppedState) - , m_mediaStatus(QMediaPlayer::NoMedia) - , m_duration(0) - , m_position(0) - , m_playbackRate(1.0) - , m_volume(50) - , m_bufferStatus(0) - , m_muted(false) - , m_audioAvailable(false) - , m_videoAvailable(false) - , m_seekable(false) - { - } - - QMediaPlayer::State state() const { return m_state; } - void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); } - - QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; } - void updateMediaStatus(QMediaPlayer::MediaStatus status) { - emit mediaStatusChanged(m_mediaStatus = status); } - void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state) - { - m_mediaStatus = status; - m_state = state; - - emit mediaStatusChanged(m_mediaStatus); - emit stateChanged(m_state); - } - - qint64 duration() const { return m_duration; } - void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); } - - qint64 position() const { return m_position; } - void setPosition(qint64 position) { emit positionChanged(m_position = position); } - - int volume() const { return m_volume; } - void setVolume(int volume) { emit volumeChanged(m_volume = volume); } - - bool isMuted() const { return m_muted; } - void setMuted(bool muted) { emit mutedChanged(m_muted = muted); } - - int bufferStatus() const { return m_bufferStatus; } - void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); } - - bool isAudioAvailable() const { return m_audioAvailable; } - void setAudioAvailable(bool available) { - emit audioAvailableChanged(m_audioAvailable = available); } - bool isVideoAvailable() const { return m_videoAvailable; } - void setVideoAvailable(bool available) { - emit videoAvailableChanged(m_videoAvailable = available); } - - bool isSeekable() const { return m_seekable; } - void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); } - - QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); } - - qreal playbackRate() const { return m_playbackRate; } - void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); } - - QMediaContent media() const { return m_media; } - const QIODevice *mediaStream() const { return 0; } - void setMedia(const QMediaContent &media, QIODevice *) - { - m_media = media; - - m_mediaStatus = m_media.isNull() - ? QMediaPlayer::NoMedia - : QMediaPlayer::LoadingMedia; - - emit mediaChanged(m_media); - emit mediaStatusChanged(m_mediaStatus); - } - - void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); } - void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); } - void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); } - - void emitError(QMediaPlayer::Error err, const QString &errorString) { - emit error(err, errorString); } - -private: - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_mediaStatus; - qint64 m_duration; - qint64 m_position; - qreal m_playbackRate; - int m_volume; - int m_bufferStatus; - bool m_muted; - bool m_audioAvailable; - bool m_videoAvailable; - bool m_seekable; - QMediaContent m_media; -}; - -class QtTestOutputControl : public QVideoOutputControl -{ -public: - QtTestOutputControl(QObject *parent) : QVideoOutputControl(parent), m_output(NoOutput) {} - - QList availableOutputs() const { return m_outputs; } - void setAvailableOutputs(const QList outputs) { m_outputs = outputs; } - - Output output() const { return m_output; } - virtual void setOutput(Output output) { m_output = output; } - -private: - Output m_output; - QList m_outputs; -}; - -class QtTestRendererControl : public QVideoRendererControl -{ -public: - QtTestRendererControl(QObject *parent ) : QVideoRendererControl(parent), m_surface(0) {} - - QAbstractVideoSurface *surface() const { return m_surface; } - void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; } - -private: - QAbstractVideoSurface *m_surface; -}; - -class QtTestMediaService : public QMediaService -{ - Q_OBJECT -public: - QtTestMediaService( - QtTestMediaPlayerControl *playerControl, - QtTestOutputControl *outputControl, - QtTestRendererControl *rendererControl, - QObject *parent) - : QMediaService(parent) - , playerControl(playerControl) - , outputControl(outputControl) - , rendererControl(rendererControl) - { - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return playerControl; - else if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return outputControl; - else if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return rendererControl; - else - return 0; - } - - QtTestMediaPlayerControl *playerControl; - QtTestOutputControl *outputControl; - QtTestRendererControl *rendererControl; -}; - -class QtTestMediaServiceProvider : public QMediaServiceProvider -{ - Q_OBJECT -public: - QtTestMediaServiceProvider() - : service(new QtTestMediaService( - new QtTestMediaPlayerControl(this), - new QtTestOutputControl(this), - new QtTestRendererControl(this), - this)) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider(QtTestMediaService *service) - : service(service) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider( - QtTestMediaPlayerControl *playerControl, - QtTestOutputControl *outputControl, - QtTestRendererControl *rendererControl) - : service(new QtTestMediaService(playerControl, outputControl, rendererControl, this)) - { - setDefaultServiceProvider(this); - } - - ~QtTestMediaServiceProvider() - { - setDefaultServiceProvider(0); - } - - QMediaService *requestService( - const QByteArray &type, - const QMediaServiceProviderHint & = QMediaServiceProviderHint()) - { - requestedService = type; - - return service; - } - - void releaseService(QMediaService *) {} - - inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; } - inline QtTestRendererControl *rendererControl() { return service->rendererControl; } - - QtTestMediaService *service; - QByteArray requestedService; -}; - - -void tst_QDeclarativeVideo::initTestCase() -{ - qRegisterMetaType(); -} - -void tst_QDeclarativeVideo::nullPlayerControl() -{ - QtTestMediaServiceProvider provider(0, 0, 0); - - QDeclarativeVideo video; - - QCOMPARE(video.source(), QUrl()); - video.setSource(QUrl("http://example.com")); - QCOMPARE(video.source(), QUrl("http://example.com")); - - QCOMPARE(video.isPlaying(), false); - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - video.setPlaying(false); - video.play(); - QCOMPARE(video.isPlaying(), false); - - QCOMPARE(video.isPaused(), false); - video.pause(); - QCOMPARE(video.isPaused(), false); - video.setPaused(true); - QCOMPARE(video.isPaused(), true); - - QCOMPARE(video.duration(), 0); - - QCOMPARE(video.position(), 0); - video.setPosition(10000); - QCOMPARE(video.position(), 10000); - - QCOMPARE(video.volume(), qreal(1.0)); - video.setVolume(0.5); - QCOMPARE(video.volume(), qreal(0.5)); - - QCOMPARE(video.isMuted(), false); - video.setMuted(true); - QCOMPARE(video.isMuted(), true); - - QCOMPARE(video.bufferProgress(), qreal(0)); - - QCOMPARE(video.isSeekable(), false); - - QCOMPARE(video.playbackRate(), qreal(1.0)); - - QCOMPARE(video.hasAudio(), false); - QCOMPARE(video.hasVideo(), false); - - QCOMPARE(video.status(), QDeclarativeVideo::NoMedia); - - QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing); -} - -void tst_QDeclarativeVideo::nullService() -{ - QtTestMediaServiceProvider provider(0); - - QDeclarativeVideo video; - - QCOMPARE(video.source(), QUrl()); - video.setSource(QUrl("http://example.com")); - QCOMPARE(video.source(), QUrl("http://example.com")); - - QCOMPARE(video.isPlaying(), false); - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - video.setPlaying(false); - video.play(); - QCOMPARE(video.isPlaying(), false); - - QCOMPARE(video.isPaused(), false); - video.pause(); - QCOMPARE(video.isPaused(), false); - video.setPaused(true); - QCOMPARE(video.isPaused(), true); - - QCOMPARE(video.duration(), 0); - - QCOMPARE(video.position(), 0); - video.setPosition(10000); - QCOMPARE(video.position(), 10000); - - QCOMPARE(video.volume(), qreal(1.0)); - video.setVolume(0.5); - QCOMPARE(video.volume(), qreal(0.5)); - - QCOMPARE(video.isMuted(), false); - video.setMuted(true); - QCOMPARE(video.isMuted(), true); - - QCOMPARE(video.bufferProgress(), qreal(0)); - - QCOMPARE(video.isSeekable(), false); - - QCOMPARE(video.playbackRate(), qreal(1.0)); - - QCOMPARE(video.hasAudio(), false); - QCOMPARE(video.hasVideo(), false); - - QCOMPARE(video.status(), QDeclarativeVideo::NoMedia); - - QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing); - - QCOMPARE(video.metaObject()->indexOfProperty("title"), -1); - QCOMPARE(video.metaObject()->indexOfProperty("genre"), -1); - QCOMPARE(video.metaObject()->indexOfProperty("description"), -1); -} - -void tst_QDeclarativeVideo::playing() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged())); - QSignalSpy startedSpy(&video, SIGNAL(started())); - QSignalSpy stoppedSpy(&video, SIGNAL(stopped())); - - int playingChanged = 0; - int started = 0; - int stopped = 0; - - QCOMPARE(video.isPlaying(), false); - - // setPlaying(true) when stopped. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when playing. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when playing. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // stop() when stopped. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when stopped. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when playing. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when playing. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeVideo::paused() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged())); - QSignalSpy pausedChangedSpy(&video, SIGNAL(pausedChanged())); - QSignalSpy startedSpy(&video, SIGNAL(started())); - QSignalSpy pausedSpy(&video, SIGNAL(paused())); - QSignalSpy resumedSpy(&video, SIGNAL(resumed())); - QSignalSpy stoppedSpy(&video, SIGNAL(stopped())); - - int playingChanged = 0; - int pausedChanged = 0; - int started = 0; - int paused = 0; - int resumed = 0; - int stopped = 0; - - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - - // setPlaying(true) when stopped. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - video.setPaused(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when paused. - video.setPaused(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when paused. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when paused. - video.setPaused(false); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when playing. - video.setPaused(false); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when playing. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped and paused. - video.setPaused(true); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when stopped and paused. - video.setPaused(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when stopped. - video.setPaused(true); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when stopped and paused. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when paused. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - video.setPaused(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when paused. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped. - video.setPaused(true); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when stopped and paused. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when stopped. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // pause() when stopped and paused. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped and paused. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeVideo::error() -{ - const QString errorString = QLatin1String("Failed to open device."); - - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy errorSpy(&video, SIGNAL(error(QDeclarativeVideo::Error,QString))); - QSignalSpy errorChangedSpy(&video, SIGNAL(errorChanged())); - - QCOMPARE(video.error(), QDeclarativeVideo::NoError); - QCOMPARE(video.errorString(), QString()); - - provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString); - - QCOMPARE(video.error(), QDeclarativeVideo::ResourceError); - QCOMPARE(video.errorString(), errorString); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 1); - - // Changing the source resets the error properties. - video.setSource(QUrl("http://example.com")); - QCOMPARE(video.error(), QDeclarativeVideo::NoError); - QCOMPARE(video.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); - - // But isn't noisy. - video.setSource(QUrl("file:///file/path")); - QCOMPARE(video.error(), QDeclarativeVideo::NoError); - QCOMPARE(video.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); -} - - -void tst_QDeclarativeVideo::hasAudio() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy spy(&video, SIGNAL(hasAudioChanged())); - - QCOMPARE(video.hasAudio(), false); - - provider.playerControl()->setAudioAvailable(true); - QCOMPARE(video.hasAudio(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setAudioAvailable(true); - QCOMPARE(video.hasAudio(), true); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setAudioAvailable(false); - QCOMPARE(video.hasAudio(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeVideo::hasVideo() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - - video.componentComplete(); - - QSignalSpy spy(&video, SIGNAL(hasVideoChanged())); - - QCOMPARE(video.hasVideo(), false); - - provider.playerControl()->setVideoAvailable(true); - QCOMPARE(video.hasVideo(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setVideoAvailable(true); - QCOMPARE(video.hasVideo(), true); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setVideoAvailable(false); - QCOMPARE(video.hasVideo(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeVideo::fillMode() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QList children = video.childItems(); - QCOMPARE(children.count(), 1); - QGraphicsVideoItem *videoItem = qgraphicsitem_cast(children.first()); - QVERIFY(videoItem != 0); - - QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit); - - video.setFillMode(QDeclarativeVideo::PreserveAspectCrop); - QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectCrop); - QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatioByExpanding); - - video.setFillMode(QDeclarativeVideo::Stretch); - QCOMPARE(video.fillMode(), QDeclarativeVideo::Stretch); - QCOMPARE(videoItem->aspectRatioMode(), Qt::IgnoreAspectRatio); - - video.setFillMode(QDeclarativeVideo::PreserveAspectFit); - QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit); - QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QDeclarativeVideo::geometry() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QAbstractVideoSurface *surface = provider.rendererControl()->surface(); - QVERIFY(surface != 0); - - QList children = video.childItems(); - QCOMPARE(children.count(), 1); - QGraphicsVideoItem *videoItem = qgraphicsitem_cast(children.first()); - QVERIFY(videoItem != 0); - - QVideoSurfaceFormat format(QSize(640, 480), QVideoFrame::Format_RGB32); - - QVERIFY(surface->start(format)); - - QCOMPARE(video.implicitWidth(), qreal(640)); - QCOMPARE(video.implicitHeight(), qreal(480)); - - video.setWidth(560); - video.setHeight(328); - - QCOMPARE(videoItem->size().width(), qreal(560)); - QCOMPARE(videoItem->size().height(), qreal(328)); -} - -QTEST_MAIN(tst_QDeclarativeVideo) - -#include "tst_qdeclarativevideo.moc" diff --git a/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro b/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro deleted file mode 100644 index b57e8e3..0000000 --- a/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -SOURCES += tst_qgraphicsvideoitem.cpp - -QT += multimedia mediaservices -requires(contains(QT_CONFIG, mediaservices)) diff --git a/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp deleted file mode 100644 index 1815779..0000000 --- a/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp +++ /dev/null @@ -1,670 +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 -#include -#include -#include - -#include - -class tst_QGraphicsVideoItem : public QObject -{ - Q_OBJECT -public slots: - void initTestCase(); - -private slots: - void nullObject(); - void nullService(); - void nullOutputControl(); - void noOutputs(); - void serviceDestroyed(); - void mediaObjectDestroyed(); - void setMediaObject(); - - void show(); - - void aspectRatioMode(); - void offset(); - void size(); - void nativeSize_data(); - void nativeSize(); - - void boundingRect_data(); - void boundingRect(); - - void paint(); -}; - -Q_DECLARE_METATYPE(const uchar *) -Q_DECLARE_METATYPE(Qt::AspectRatioMode) - -class QtTestOutputControl : public QVideoOutputControl -{ -public: - QtTestOutputControl() : m_output(NoOutput) {} - - QList availableOutputs() const { return m_outputs; } - void setAvailableOutputs(const QList outputs) { m_outputs = outputs; } - - Output output() const { return m_output; } - virtual void setOutput(Output output) { m_output = output; } - -private: - Output m_output; - QList m_outputs; -}; - -class QtTestRendererControl : public QVideoRendererControl -{ -public: - QtTestRendererControl() - : m_surface(0) - { - } - - QAbstractVideoSurface *surface() const { return m_surface; } - void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; } - -private: - QAbstractVideoSurface *m_surface; -}; - -class QtTestVideoService : public QMediaService -{ - Q_OBJECT -public: - QtTestVideoService( - QtTestOutputControl *output, - QtTestRendererControl *renderer) - : QMediaService(0) - , outputControl(output) - , rendererControl(renderer) - { - } - - ~QtTestVideoService() - { - delete outputControl; - delete rendererControl; - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return outputControl; - else if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return rendererControl; - else - return 0; - } - - QtTestOutputControl *outputControl; - QtTestRendererControl *rendererControl; -}; - -class QtTestVideoObject : public QMediaObject -{ - Q_OBJECT -public: - QtTestVideoObject(QtTestRendererControl *renderer): - QMediaObject(0, new QtTestVideoService(new QtTestOutputControl, renderer)) - { - testService = qobject_cast(service()); - QList outputs; - - if (renderer) - outputs.append(QVideoOutputControl::RendererOutput); - - testService->outputControl->setAvailableOutputs(outputs); - } - - QtTestVideoObject(QtTestVideoService *service): - QMediaObject(0, service), - testService(service) - { - } - - ~QtTestVideoObject() - { - delete testService; - } - - QtTestVideoService *testService; -}; - -class QtTestGraphicsVideoItem : public QGraphicsVideoItem -{ -public: - QtTestGraphicsVideoItem(QGraphicsItem *parent = 0) - : QGraphicsVideoItem(parent) - , m_paintCount(0) - { - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) - { - ++m_paintCount; - - QTestEventLoop::instance().exitLoop(); - - QGraphicsVideoItem::paint(painter, option, widget); - } - - bool waitForPaint(int secs) - { - const int paintCount = m_paintCount; - - QTestEventLoop::instance().enterLoop(secs); - - return m_paintCount != paintCount; - } - - int paintCount() const - { - return m_paintCount; - } - -private: - int m_paintCount; -}; - -void tst_QGraphicsVideoItem::initTestCase() -{ - qRegisterMetaType(); -} - -void tst_QGraphicsVideoItem::nullObject() -{ - QGraphicsVideoItem item(0); - - QVERIFY(item.boundingRect().isEmpty()); -} - -void tst_QGraphicsVideoItem::nullService() -{ - QtTestVideoService *service = 0; - - QtTestVideoObject object(service); - - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QVERIFY(item->boundingRect().isEmpty()); - - item->hide(); - item->show(); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); -} - -void tst_QGraphicsVideoItem::nullOutputControl() -{ - QtTestVideoObject object(new QtTestVideoService(0, 0)); - - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QVERIFY(item->boundingRect().isEmpty()); - - item->hide(); - item->show(); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); -} - -void tst_QGraphicsVideoItem::noOutputs() -{ - QtTestRendererControl *control = 0; - QtTestVideoObject object(control); - - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QVERIFY(item->boundingRect().isEmpty()); - - item->hide(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - item->show(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); -} - -void tst_QGraphicsVideoItem::serviceDestroyed() -{ - QtTestVideoObject object(new QtTestRendererControl); - - QGraphicsVideoItem item; - item.setMediaObject(&object); - - QtTestVideoService *service = object.testService; - object.testService = 0; - - delete service; - - QCOMPARE(item.mediaObject(), static_cast(&object)); - QVERIFY(item.boundingRect().isEmpty()); -} - -void tst_QGraphicsVideoItem::mediaObjectDestroyed() -{ - QtTestVideoObject *object = new QtTestVideoObject(new QtTestRendererControl); - - QGraphicsVideoItem item; - item.setMediaObject(object); - - delete object; - object = 0; - - QCOMPARE(item.mediaObject(), static_cast(object)); - QVERIFY(item.boundingRect().isEmpty()); -} - -void tst_QGraphicsVideoItem::setMediaObject() -{ - QMediaObject *nullObject = 0; - QtTestVideoObject object(new QtTestRendererControl); - - QGraphicsVideoItem item; - - QCOMPARE(item.mediaObject(), nullObject); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - item.setMediaObject(&object); - QCOMPARE(item.mediaObject(), static_cast(&object)); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - item.setMediaObject(0); - QCOMPARE(item.mediaObject(), nullObject); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - item.setVisible(false); - - item.setMediaObject(&object); - QCOMPARE(item.mediaObject(), static_cast(&object)); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); -} - -void tst_QGraphicsVideoItem::show() -{ - QtTestVideoObject object(new QtTestRendererControl); - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - // Graphics items are visible by default - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - item->hide(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - - item->show(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - QVERIFY(item->boundingRect().isEmpty()); - - QVideoSurfaceFormat format(QSize(320,240),QVideoFrame::Format_RGB32); - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QVERIFY(!item->boundingRect().isEmpty()); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); - - QVERIFY(item->paintCount() || item->waitForPaint(1)); -} - -void tst_QGraphicsVideoItem::aspectRatioMode() -{ - QGraphicsVideoItem item; - - QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio); - - item.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(item.aspectRatioMode(), Qt::IgnoreAspectRatio); - - item.setAspectRatioMode(Qt::KeepAspectRatioByExpanding); - QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatioByExpanding); - - item.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QGraphicsVideoItem::offset() -{ - QGraphicsVideoItem item; - - QCOMPARE(item.offset(), QPointF(0, 0)); - - item.setOffset(QPointF(-32.4, 43.0)); - QCOMPARE(item.offset(), QPointF(-32.4, 43.0)); - - item.setOffset(QPointF(1, 1)); - QCOMPARE(item.offset(), QPointF(1, 1)); - - item.setOffset(QPointF(12, -30.4)); - QCOMPARE(item.offset(), QPointF(12, -30.4)); - - item.setOffset(QPointF(-90.4, -75)); - QCOMPARE(item.offset(), QPointF(-90.4, -75)); -} - -void tst_QGraphicsVideoItem::size() -{ - QGraphicsVideoItem item; - - QCOMPARE(item.size(), QSizeF(320, 240)); - - item.setSize(QSizeF(542.5, 436.3)); - QCOMPARE(item.size(), QSizeF(542.5, 436.3)); - - item.setSize(QSizeF(-43, 12)); - QCOMPARE(item.size(), QSizeF(0, 0)); - - item.setSize(QSizeF(54, -9)); - QCOMPARE(item.size(), QSizeF(0, 0)); - - item.setSize(QSizeF(-90, -65)); - QCOMPARE(item.size(), QSizeF(0, 0)); - - item.setSize(QSizeF(1000, 1000)); - QCOMPARE(item.size(), QSizeF(1000, 1000)); -} - -void tst_QGraphicsVideoItem::nativeSize_data() -{ - QTest::addColumn("frameSize"); - QTest::addColumn("viewport"); - QTest::addColumn("pixelAspectRatio"); - QTest::addColumn("nativeSize"); - - QTest::newRow("640x480") - << QSize(640, 480) - << QRect(0, 0, 640, 480) - << QSize(1, 1) - << QSizeF(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(1, 1) - << QSizeF(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport, 4:3") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(4, 3) - << QSizeF(853, 480); -} - -void tst_QGraphicsVideoItem::nativeSize() -{ - QFETCH(QSize, frameSize); - QFETCH(QRect, viewport); - QFETCH(QSize, pixelAspectRatio); - QFETCH(QSizeF, nativeSize); - - QtTestVideoObject object(new QtTestRendererControl); - QGraphicsVideoItem item; - item.setMediaObject(&object); - - QCOMPARE(item.nativeSize(), QSizeF()); - - QSignalSpy spy(&item, SIGNAL(nativeSizeChanged(QSizeF))); - - QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); - format.setViewport(viewport); - format.setPixelAspectRatio(pixelAspectRatio); - - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QCOMPARE(item.nativeSize(), nativeSize); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.last().first().toSizeF(), nativeSize); - - object.testService->rendererControl->surface()->stop(); - - QCOMPARE(item.nativeSize(), QSizeF(0, 0)); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.last().first().toSizeF(), QSizeF(0, 0)); -} - -void tst_QGraphicsVideoItem::boundingRect_data() -{ - QTest::addColumn("frameSize"); - QTest::addColumn("offset"); - QTest::addColumn("size"); - QTest::addColumn("aspectRatioMode"); - QTest::addColumn("expectedRect"); - - - QTest::newRow("640x480: (0,0 640x480), Keep") - << QSize(640, 480) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::KeepAspectRatio - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (0,0, 640x480), Keep") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::KeepAspectRatio - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (0,0, 640x480), KeepByExpanding") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::KeepAspectRatioByExpanding - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (0,0, 640x480), Ignore") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::IgnoreAspectRatio - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (100,100, 640x480), Keep") - << QSize(800, 600) - << QPointF(100, 100) - << QSizeF(640, 480) - << Qt::KeepAspectRatio - << QRectF(100, 100, 640, 480); - - QTest::newRow("800x600, (100,-100, 640x480), KeepByExpanding") - << QSize(800, 600) - << QPointF(100, -100) - << QSizeF(640, 480) - << Qt::KeepAspectRatioByExpanding - << QRectF(100, -100, 640, 480); - - QTest::newRow("800x600, (-100,-100, 640x480), Ignore") - << QSize(800, 600) - << QPointF(-100, -100) - << QSizeF(640, 480) - << Qt::IgnoreAspectRatio - << QRectF(-100, -100, 640, 480); - - QTest::newRow("800x600, (0,0, 1920x1024), Keep") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatio - << QRectF(832.0 / 3, 0, 4096.0 / 3, 1024); - - QTest::newRow("800x600, (0,0, 1920x1024), KeepByExpanding") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatioByExpanding - << QRectF(0, 0, 1920, 1024); - - QTest::newRow("800x600, (0,0, 1920x1024), Ignore") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(1920, 1024) - << Qt::IgnoreAspectRatio - << QRectF(0, 0, 1920, 1024); - - QTest::newRow("800x600, (100,100, 1920x1024), Keep") - << QSize(800, 600) - << QPointF(100, 100) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatio - << QRectF(100 + 832.0 / 3, 100, 4096.0 / 3, 1024); - - QTest::newRow("800x600, (100,-100, 1920x1024), KeepByExpanding") - << QSize(800, 600) - << QPointF(100, -100) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatioByExpanding - << QRectF(100, -100, 1920, 1024); - - QTest::newRow("800x600, (-100,-100, 1920x1024), Ignore") - << QSize(800, 600) - << QPointF(-100, -100) - << QSizeF(1920, 1024) - << Qt::IgnoreAspectRatio - << QRectF(-100, -100, 1920, 1024); -} - -void tst_QGraphicsVideoItem::boundingRect() -{ - QFETCH(QSize, frameSize); - QFETCH(QPointF, offset); - QFETCH(QSizeF, size); - QFETCH(Qt::AspectRatioMode, aspectRatioMode); - QFETCH(QRectF, expectedRect); - - QtTestVideoObject object(new QtTestRendererControl); - QGraphicsVideoItem item; - item.setMediaObject(&object); - - item.setOffset(offset); - item.setSize(size); - item.setAspectRatioMode(aspectRatioMode); - - QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); - - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QCOMPARE(item.boundingRect(), expectedRect); -} - -static const uchar rgb32ImageData[] = -{ - 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, - 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00 -}; - -void tst_QGraphicsVideoItem::paint() -{ - QtTestVideoObject object(new QtTestRendererControl); - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); - - QPainterVideoSurface *surface = qobject_cast( - object.testService->rendererControl->surface()); - - QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32); - - QVERIFY(surface->start(format)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QVERIFY(item->waitForPaint(1)); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32); - - frame.map(QAbstractVideoBuffer::WriteOnly); - memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes()); - frame.unmap(); - - QVERIFY(surface->present(frame)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), false); - - QVERIFY(item->waitForPaint(1)); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); -} - - -QTEST_MAIN(tst_QGraphicsVideoItem) - -#include "tst_qgraphicsvideoitem.moc" diff --git a/tests/auto/qmediacontent/qmediacontent.pro b/tests/auto/qmediacontent/qmediacontent.pro deleted file mode 100644 index e20b4db..0000000 --- a/tests/auto/qmediacontent/qmediacontent.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qmediacontent.cpp - -QT = core network mediaservices - diff --git a/tests/auto/qmediacontent/tst_qmediacontent.cpp b/tests/auto/qmediacontent/tst_qmediacontent.cpp deleted file mode 100644 index e33149a..0000000 --- a/tests/auto/qmediacontent/tst_qmediacontent.cpp +++ /dev/null @@ -1,174 +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 - - -class tst_QMediaContent : public QObject -{ - Q_OBJECT - -private slots: - void testNull(); - void testUrlCtor(); - void testRequestCtor(); - void testResourceCtor(); - void testResourceListCtor(); - void testCopy(); - void testAssignment(); - void testEquality(); - void testResources(); -}; - -void tst_QMediaContent::testNull() -{ - QMediaContent media; - - QCOMPARE(media.isNull(), true); - QCOMPARE(media.canonicalUrl(), QUrl()); - QCOMPARE(media.canonicalResource(), QMediaResource()); - QCOMPARE(media.resources(), QMediaResourceList()); -} - -void tst_QMediaContent::testUrlCtor() -{ - QMediaContent media(QUrl("http://example.com/movie.mov")); - - QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov")); - QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov")); -} - -void tst_QMediaContent::testRequestCtor() -{ - QNetworkRequest request(QUrl("http://example.com/movie.mov")); - request.setAttribute(QNetworkRequest::User, QVariant(1234)); - - QMediaContent media(request); - - QCOMPARE(media.canonicalRequest(), request); - QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov")); - QCOMPARE(media.canonicalResource().request(), request); - QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov")); -} - -void tst_QMediaContent::testResourceCtor() -{ - QMediaContent media(QMediaResource(QUrl("http://example.com/movie.mov"))); - - QCOMPARE(media.canonicalResource(), QMediaResource(QUrl("http://example.com/movie.mov"))); -} - -void tst_QMediaContent::testResourceListCtor() -{ - QMediaResourceList resourceList; - resourceList << QMediaResource(QUrl("http://example.com/movie.mov")); - - QMediaContent media(resourceList); - - QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov")); - QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov")); -} - -void tst_QMediaContent::testCopy() -{ - QMediaContent media1(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media2(media1); - - QVERIFY(media1 == media2); -} - -void tst_QMediaContent::testAssignment() -{ - QMediaContent media1(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media2; - QMediaContent media3; - - media2 = media1; - QVERIFY(media2 == media1); - - media2 = media3; - QVERIFY(media2 == media3); -} - -void tst_QMediaContent::testEquality() -{ - QMediaContent media1; - QMediaContent media2; - QMediaContent media3(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media4(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media5(QMediaResource(QUrl("file:///some/where/over/the/rainbow.mp3"))); - - // null == null - QCOMPARE(media1 == media2, true); - QCOMPARE(media1 != media2, false); - - // null != something - QCOMPARE(media1 == media3, false); - QCOMPARE(media1 != media3, true); - - // equiv - QCOMPARE(media3 == media4, true); - QCOMPARE(media3 != media4, false); - - // not equiv - QCOMPARE(media4 == media5, false); - QCOMPARE(media4 != media5, true); -} - -void tst_QMediaContent::testResources() -{ - QMediaResourceList resourceList; - - resourceList << QMediaResource(QUrl("http://example.com/movie-main.mov")); - resourceList << QMediaResource(QUrl("http://example.com/movie-big.mov")); - QMediaContent media(resourceList); - - QMediaResourceList res = media.resources(); - QCOMPARE(res.size(), 2); - QCOMPARE(res[0], QMediaResource(QUrl("http://example.com/movie-main.mov"))); - QCOMPARE(res[1], QMediaResource(QUrl("http://example.com/movie-big.mov"))); -} - -QTEST_MAIN(tst_QMediaContent) - -#include "tst_qmediacontent.moc" diff --git a/tests/auto/qmediaobject/qmediaobject.pro b/tests/auto/qmediaobject/qmediaobject.pro deleted file mode 100644 index d6a0f7b..0000000 --- a/tests/auto/qmediaobject/qmediaobject.pro +++ /dev/null @@ -1,4 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qmediaobject.cpp -QT = core mediaservices diff --git a/tests/auto/qmediaobject/tst_qmediaobject.cpp b/tests/auto/qmediaobject/tst_qmediaobject.cpp deleted file mode 100644 index 5a2fdeb..0000000 --- a/tests/auto/qmediaobject/tst_qmediaobject.cpp +++ /dev/null @@ -1,549 +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 - - -class tst_QMediaObject : public QObject -{ - Q_OBJECT - -private slots: - void propertyWatch(); - void notifySignals_data(); - void notifySignals(); - void notifyInterval_data(); - void notifyInterval(); - - void nullMetaDataControl(); - void isMetaDataAvailable(); - void isWritable(); - void metaDataChanged(); - void metaData_data(); - void metaData(); - void setMetaData_data(); - void setMetaData(); - void extendedMetaData_data() { metaData_data(); } - void extendedMetaData(); - void setExtendedMetaData_data() { extendedMetaData_data(); } - void setExtendedMetaData(); - - -private: - void setupNotifyTests(); -}; - -class QtTestMetaDataProvider : public QMetaDataControl -{ - Q_OBJECT -public: - QtTestMetaDataProvider(QObject *parent = 0) - : QMetaDataControl(parent) - , m_available(false) - , m_writable(false) - { - } - - bool isMetaDataAvailable() const { return m_available; } - void setMetaDataAvailable(bool available) { - if (m_available != available) - emit metaDataAvailableChanged(m_available = available); - } - QList availableMetaData() const { return m_data.keys(); } - - bool isWritable() const { return m_writable; } - void setWritable(bool writable) { emit writableChanged(m_writable = writable); } - - QVariant metaData(QtMediaServices::MetaData key) const { return m_data.value(key); } - void setMetaData(QtMediaServices::MetaData key, const QVariant &value) { - m_data.insert(key, value); } - - QVariant extendedMetaData(const QString &key) const { return m_extendedData.value(key); } - void setExtendedMetaData(const QString &key, const QVariant &value) { - m_extendedData.insert(key, value); } - - QStringList availableExtendedMetaData() const { return m_extendedData.keys(); } - - using QMetaDataControl::metaDataChanged; - - void populateMetaData() - { - m_available = true; - } - - bool m_available; - bool m_writable; - QMap m_data; - QMap m_extendedData; -}; - -class QtTestMetaDataService : public QMediaService -{ - Q_OBJECT -public: - QtTestMetaDataService(QObject *parent = 0):QMediaService(parent), hasMetaData(true) - { - } - - QMediaControl *control(const char *iid) const - { - if (hasMetaData && qstrcmp(iid, QMetaDataControl_iid) == 0) - return const_cast(&metaData); - else - return 0; - } - - QtTestMetaDataProvider metaData; - bool hasMetaData; -}; - - -class QtTestMediaObject : public QMediaObject -{ - Q_OBJECT - Q_PROPERTY(int a READ a WRITE setA NOTIFY aChanged) - Q_PROPERTY(int b READ b WRITE setB NOTIFY bChanged) - Q_PROPERTY(int c READ c WRITE setC NOTIFY cChanged) - Q_PROPERTY(int d READ d WRITE setD) -public: - QtTestMediaObject(QMediaService *service = 0): QMediaObject(0, service), m_a(0), m_b(0), m_c(0), m_d(0) {} - - using QMediaObject::addPropertyWatch; - using QMediaObject::removePropertyWatch; - - int a() const { return m_a; } - void setA(int a) { m_a = a; } - - int b() const { return m_b; } - void setB(int b) { m_b = b; } - - int c() const { return m_c; } - void setC(int c) { m_c = c; } - - int d() const { return m_d; } - void setD(int d) { m_d = d; } - -Q_SIGNALS: - void aChanged(int a); - void bChanged(int b); - void cChanged(int c); - -private: - int m_a; - int m_b; - int m_c; - int m_d; -}; - -void tst_QMediaObject::propertyWatch() -{ - QtTestMediaObject object; - object.setNotifyInterval(0); - - QEventLoop loop; - connect(&object, SIGNAL(aChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - connect(&object, SIGNAL(bChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - connect(&object, SIGNAL(cChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - - QSignalSpy aSpy(&object, SIGNAL(aChanged(int))); - QSignalSpy bSpy(&object, SIGNAL(bChanged(int))); - QSignalSpy cSpy(&object, SIGNAL(cChanged(int))); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), 0); - QCOMPARE(bSpy.count(), 0); - QCOMPARE(cSpy.count(), 0); - - int aCount = 0; - int bCount = 0; - int cCount = 0; - - object.addPropertyWatch("a"); - - QTestEventLoop::instance().enterLoop(1); - - QVERIFY(aSpy.count() > aCount); - QCOMPARE(bSpy.count(), 0); - QCOMPARE(cSpy.count(), 0); - QCOMPARE(aSpy.last().value(0).toInt(), 0); - - aCount = aSpy.count(); - - object.setA(54); - object.setB(342); - object.setC(233); - - QTestEventLoop::instance().enterLoop(1); - - QVERIFY(aSpy.count() > aCount); - QCOMPARE(bSpy.count(), 0); - QCOMPARE(cSpy.count(), 0); - QCOMPARE(aSpy.last().value(0).toInt(), 54); - - aCount = aSpy.count(); - - object.addPropertyWatch("b"); - object.addPropertyWatch("d"); - object.removePropertyWatch("e"); - object.setA(43); - object.setB(235); - object.setC(90); - - QTestEventLoop::instance().enterLoop(1); - - QVERIFY(aSpy.count() > aCount); - QVERIFY(bSpy.count() > bCount); - QCOMPARE(cSpy.count(), 0); - QCOMPARE(aSpy.last().value(0).toInt(), 43); - QCOMPARE(bSpy.last().value(0).toInt(), 235); - - aCount = aSpy.count(); - bCount = bSpy.count(); - - object.removePropertyWatch("a"); - object.addPropertyWatch("c"); - object.addPropertyWatch("e"); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QVERIFY(bSpy.count() > bCount); - QVERIFY(cSpy.count() > cCount); - QCOMPARE(bSpy.last().value(0).toInt(), 235); - QCOMPARE(cSpy.last().value(0).toInt(), 90); - - bCount = bSpy.count(); - cCount = cSpy.count(); - - object.setA(435); - object.setC(9845); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QVERIFY(bSpy.count() > bCount); - QVERIFY(cSpy.count() > cCount); - QCOMPARE(bSpy.last().value(0).toInt(), 235); - QCOMPARE(cSpy.last().value(0).toInt(), 9845); - - bCount = bSpy.count(); - cCount = cSpy.count(); - - object.setA(8432); - object.setB(324); - object.setC(443); - object.removePropertyWatch("c"); - object.removePropertyWatch("d"); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QVERIFY(bSpy.count() > bCount); - QCOMPARE(cSpy.count(), cCount); - QCOMPARE(bSpy.last().value(0).toInt(), 324); - QCOMPARE(cSpy.last().value(0).toInt(), 9845); - - bCount = bSpy.count(); - - object.removePropertyWatch("b"); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QCOMPARE(bSpy.count(), bCount); - QCOMPARE(cSpy.count(), cCount); -} - -void tst_QMediaObject::setupNotifyTests() -{ - QTest::addColumn("interval"); - QTest::addColumn("count"); - - QTest::newRow("single 750ms") - << 750 - << 1; - QTest::newRow("single 600ms") - << 600 - << 1; - QTest::newRow("x3 300ms") - << 300 - << 3; - QTest::newRow("x5 180ms") - << 180 - << 5; -} - -void tst_QMediaObject::notifySignals_data() -{ - setupNotifyTests(); -} - -void tst_QMediaObject::notifySignals() -{ - QFETCH(int, interval); - QFETCH(int, count); - - QtTestMediaObject object; - object.setNotifyInterval(interval); - object.addPropertyWatch("a"); - - QSignalSpy spy(&object, SIGNAL(aChanged(int))); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(spy.count(), count); -} - -void tst_QMediaObject::notifyInterval_data() -{ - setupNotifyTests(); -} - -void tst_QMediaObject::notifyInterval() -{ - QFETCH(int, interval); - - QtTestMediaObject object; - QSignalSpy spy(&object, SIGNAL(notifyIntervalChanged(int))); - - object.setNotifyInterval(interval); - QCOMPARE(object.notifyInterval(), interval); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.last().value(0).toInt(), interval); - - object.setNotifyInterval(interval); - QCOMPARE(object.notifyInterval(), interval); - QCOMPARE(spy.count(), 1); -} - -void tst_QMediaObject::nullMetaDataControl() -{ - const QString titleKey(QLatin1String("Title")); - const QString title(QLatin1String("Host of Seraphim")); - - QtTestMetaDataService service; - service.hasMetaData = false; - - QtTestMediaObject object(&service); - - QSignalSpy spy(&object, SIGNAL(metaDataChanged())); - - QCOMPARE(object.isMetaDataAvailable(), false); - QCOMPARE(object.isMetaDataWritable(), false); - - object.setMetaData(QtMediaServices::Title, title); - object.setExtendedMetaData(titleKey, title); - - QCOMPARE(object.metaData(QtMediaServices::Title).toString(), QString()); - QCOMPARE(object.extendedMetaData(titleKey).toString(), QString()); - QCOMPARE(object.availableMetaData(), QList()); - QCOMPARE(object.availableExtendedMetaData(), QStringList()); - QCOMPARE(spy.count(), 0); -} - -void tst_QMediaObject::isMetaDataAvailable() -{ - QtTestMetaDataService service; - service.metaData.setMetaDataAvailable(false); - - QtTestMediaObject object(&service); - QCOMPARE(object.isMetaDataAvailable(), false); - - QSignalSpy spy(&object, SIGNAL(metaDataAvailableChanged(bool))); - service.metaData.setMetaDataAvailable(true); - - QCOMPARE(object.isMetaDataAvailable(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).at(0).toBool(), true); - - service.metaData.setMetaDataAvailable(false); - - QCOMPARE(object.isMetaDataAvailable(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.at(1).at(0).toBool(), false); -} - -void tst_QMediaObject::isWritable() -{ - QtTestMetaDataService service; - service.metaData.setWritable(false); - - QtTestMediaObject object(&service); - - QSignalSpy spy(&object, SIGNAL(metaDataWritableChanged(bool))); - - QCOMPARE(object.isMetaDataWritable(), false); - - service.metaData.setWritable(true); - - QCOMPARE(object.isMetaDataWritable(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).at(0).toBool(), true); - - service.metaData.setWritable(false); - - QCOMPARE(object.isMetaDataWritable(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.at(1).at(0).toBool(), false); -} - -void tst_QMediaObject::metaDataChanged() -{ - QtTestMetaDataService service; - QtTestMediaObject object(&service); - - QSignalSpy spy(&object, SIGNAL(metaDataChanged())); - - service.metaData.metaDataChanged(); - QCOMPARE(spy.count(), 1); - - service.metaData.metaDataChanged(); - QCOMPARE(spy.count(), 2); -} - -void tst_QMediaObject::metaData_data() -{ - QTest::addColumn("artist"); - QTest::addColumn("title"); - QTest::addColumn("genre"); - - QTest::newRow("") - << QString::fromLatin1("Dead Can Dance") - << QString::fromLatin1("Host of Seraphim") - << QString::fromLatin1("Awesome"); -} - -void tst_QMediaObject::metaData() -{ - QFETCH(QString, artist); - QFETCH(QString, title); - QFETCH(QString, genre); - - QtTestMetaDataService service; - service.metaData.populateMetaData(); - - QtTestMediaObject object(&service); - QVERIFY(object.availableMetaData().isEmpty()); - - service.metaData.m_data.insert(QtMediaServices::AlbumArtist, artist); - service.metaData.m_data.insert(QtMediaServices::Title, title); - service.metaData.m_data.insert(QtMediaServices::Genre, genre); - - QCOMPARE(object.metaData(QtMediaServices::AlbumArtist).toString(), artist); - QCOMPARE(object.metaData(QtMediaServices::Title).toString(), title); - - QList metaDataKeys = object.availableMetaData(); - QCOMPARE(metaDataKeys.size(), 3); - QVERIFY(metaDataKeys.contains(QtMediaServices::AlbumArtist)); - QVERIFY(metaDataKeys.contains(QtMediaServices::Title)); - QVERIFY(metaDataKeys.contains(QtMediaServices::Genre)); -} - -void tst_QMediaObject::setMetaData_data() -{ - QTest::addColumn("title"); - - QTest::newRow("") - << QString::fromLatin1("In the Kingdom of the Blind the One eyed are Kings"); -} - -void tst_QMediaObject::setMetaData() -{ - QFETCH(QString, title); - - QtTestMetaDataService service; - service.metaData.populateMetaData(); - - QtTestMediaObject object(&service); - - object.setMetaData(QtMediaServices::Title, title); - QCOMPARE(object.metaData(QtMediaServices::Title).toString(), title); - QCOMPARE(service.metaData.m_data.value(QtMediaServices::Title).toString(), title); -} - -void tst_QMediaObject::extendedMetaData() -{ - QFETCH(QString, artist); - QFETCH(QString, title); - QFETCH(QString, genre); - - QtTestMetaDataService service; - QtTestMediaObject object(&service); - QVERIFY(object.availableExtendedMetaData().isEmpty()); - - service.metaData.m_extendedData.insert(QLatin1String("Artist"), artist); - service.metaData.m_extendedData.insert(QLatin1String("Title"), title); - service.metaData.m_extendedData.insert(QLatin1String("Genre"), genre); - - QCOMPARE(object.extendedMetaData(QLatin1String("Artist")).toString(), artist); - QCOMPARE(object.extendedMetaData(QLatin1String("Title")).toString(), title); - - QStringList extendedKeys = object.availableExtendedMetaData(); - QCOMPARE(extendedKeys.size(), 3); - QVERIFY(extendedKeys.contains(QLatin1String("Artist"))); - QVERIFY(extendedKeys.contains(QLatin1String("Title"))); - QVERIFY(extendedKeys.contains(QLatin1String("Genre"))); -} - -void tst_QMediaObject::setExtendedMetaData() -{ - QtTestMetaDataService service; - service.metaData.populateMetaData(); - - QtTestMediaObject object(&service); - - QString title(QLatin1String("In the Kingdom of the Blind the One eyed are Kings")); - - object.setExtendedMetaData(QLatin1String("Title"), title); - QCOMPARE(object.extendedMetaData(QLatin1String("Title")).toString(), title); - QCOMPARE(service.metaData.m_extendedData.value(QLatin1String("Title")).toString(), title); -} - -QTEST_MAIN(tst_QMediaObject) - -#include "tst_qmediaobject.moc" diff --git a/tests/auto/qmediaplayer/qmediaplayer.pro b/tests/auto/qmediaplayer/qmediaplayer.pro deleted file mode 100644 index f355078..0000000 --- a/tests/auto/qmediaplayer/qmediaplayer.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qmediaplayer.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediaplayer/tst_qmediaplayer.cpp b/tests/auto/qmediaplayer/tst_qmediaplayer.cpp deleted file mode 100644 index 9a597e2..0000000 --- a/tests/auto/qmediaplayer/tst_qmediaplayer.cpp +++ /dev/null @@ -1,986 +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 - - - -class AutoConnection -{ -public: - AutoConnection(QObject *sender, const char *signal, QObject *receiver, const char *method) - : sender(sender), signal(signal), receiver(receiver), method(method) - { - QObject::connect(sender, signal, receiver, method); - } - - ~AutoConnection() - { - QObject::disconnect(sender, signal, receiver, method); - } - -private: - QObject *sender; - const char *signal; - QObject *receiver; - const char *method; -}; - - -class MockPlayerControl : public QMediaPlayerControl -{ - friend class MockPlayerService; - -public: - MockPlayerControl():QMediaPlayerControl(0) {} - - QMediaPlayer::State state() const { return _state; } - QMediaPlayer::MediaStatus mediaStatus() const { return _mediaStatus; } - - qint64 duration() const { return _duration; } - - qint64 position() const { return _position; } - - void setPosition(qint64 position) { if (position != _position) emit positionChanged(_position = position); } - - int volume() const { return _volume; } - void setVolume(int volume) { emit volumeChanged(_volume = volume); } - - bool isMuted() const { return _muted; } - void setMuted(bool muted) { if (muted != _muted) emit mutedChanged(_muted = muted); } - - int bufferStatus() const { return _bufferStatus; } - - bool isAudioAvailable() const { return _audioAvailable; } - bool isVideoAvailable() const { return _videoAvailable; } - - bool isSeekable() const { return _isSeekable; } - QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(_seekRange.first, _seekRange.second); } - void setSeekRange(qint64 minimum, qint64 maximum) { _seekRange = qMakePair(minimum, maximum); } - - qreal playbackRate() const { return _playbackRate; } - void setPlaybackRate(qreal rate) { if (rate != _playbackRate) emit playbackRateChanged(_playbackRate = rate); } - - QMediaContent media() const { return _media; } - void setMedia(const QMediaContent &content, QIODevice *stream) - { - _stream = stream; - _media = content; - if (_state != QMediaPlayer::StoppedState) { - _mediaStatus = _media.isNull() ? QMediaPlayer::NoMedia : QMediaPlayer::LoadingMedia; - emit stateChanged(_state = QMediaPlayer::StoppedState); - emit mediaStatusChanged(_mediaStatus); - } - emit mediaChanged(_media = content); - } - QIODevice *mediaStream() const { return _stream; } - - void play() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PlayingState) emit stateChanged(_state = QMediaPlayer::PlayingState); } - void pause() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PausedState) emit stateChanged(_state = QMediaPlayer::PausedState); } - void stop() { if (_state != QMediaPlayer::StoppedState) emit stateChanged(_state = QMediaPlayer::StoppedState); } - - QMediaPlayer::State _state; - QMediaPlayer::MediaStatus _mediaStatus; - QMediaPlayer::Error _error; - qint64 _duration; - qint64 _position; - int _volume; - bool _muted; - int _bufferStatus; - bool _audioAvailable; - bool _videoAvailable; - bool _isSeekable; - QPair _seekRange; - qreal _playbackRate; - QMediaContent _media; - QIODevice *_stream; - bool _isValid; - QString _errorString; -}; - - -class MockPlayerService : public QMediaService -{ - Q_OBJECT - -public: - MockPlayerService():QMediaService(0) - { - mockControl = new MockPlayerControl; - } - - ~MockPlayerService() - { - delete mockControl; - } - - QMediaControl* control(const char *iid) const - { - if (qstrcmp(iid, QMediaPlayerControl_iid) == 0) - return mockControl; - - return 0; - } - - void setState(QMediaPlayer::State state) { emit mockControl->stateChanged(mockControl->_state = state); } - void setState(QMediaPlayer::State state, QMediaPlayer::MediaStatus status) { - mockControl->_state = state; - mockControl->_mediaStatus = status; - emit mockControl->mediaStatusChanged(status); - emit mockControl->stateChanged(state); - } - void setMediaStatus(QMediaPlayer::MediaStatus status) { emit mockControl->mediaStatusChanged(mockControl->_mediaStatus = status); } - void setIsValid(bool isValid) { mockControl->_isValid = isValid; } - void setMedia(QMediaContent media) { mockControl->_media = media; } - void setDuration(qint64 duration) { mockControl->_duration = duration; } - void setPosition(qint64 position) { mockControl->_position = position; } - void setSeekable(bool seekable) { mockControl->_isSeekable = seekable; } - void setVolume(int volume) { mockControl->_volume = volume; } - void setMuted(bool muted) { mockControl->_muted = muted; } - void setVideoAvailable(bool videoAvailable) { mockControl->_videoAvailable = videoAvailable; } - void setBufferStatus(int bufferStatus) { mockControl->_bufferStatus = bufferStatus; } - void setPlaybackRate(qreal playbackRate) { mockControl->_playbackRate = playbackRate; } - void setError(QMediaPlayer::Error error) { mockControl->_error = error; emit mockControl->error(mockControl->_error, mockControl->_errorString); } - void setErrorString(QString errorString) { mockControl->_errorString = errorString; emit mockControl->error(mockControl->_error, mockControl->_errorString); } - - void reset() - { - mockControl->_state = QMediaPlayer::StoppedState; - mockControl->_mediaStatus = QMediaPlayer::UnknownMediaStatus; - mockControl->_error = QMediaPlayer::NoError; - mockControl->_duration = 0; - mockControl->_position = 0; - mockControl->_volume = 0; - mockControl->_muted = false; - mockControl->_bufferStatus = 0; - mockControl->_videoAvailable = false; - mockControl->_isSeekable = false; - mockControl->_playbackRate = 0.0; - mockControl->_media = QMediaContent(); - mockControl->_stream = 0; - mockControl->_isValid = false; - mockControl->_errorString = QString(); - } - - MockPlayerControl *mockControl; -}; - -class MockProvider : public QMediaServiceProvider -{ -public: - MockProvider(MockPlayerService *service):mockService(service) {} - QMediaService *requestService(const QByteArray &, const QMediaServiceProviderHint &) - { - return mockService; - } - - void releaseService(QMediaService *service) { delete service; } - - MockPlayerService *mockService; -}; - -class tst_QMediaPlayer: public QObject -{ - Q_OBJECT - -public slots: - void initTestCase_data(); - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void testNullService(); - void testValid(); - void testMedia(); - void testDuration(); - void testPosition(); - void testVolume(); - void testMuted(); - void testVideoAvailable(); - void testBufferStatus(); - void testSeekable(); - void testPlaybackRate(); - void testError(); - void testErrorString(); - void testService(); - void testPlay(); - void testPause(); - void testStop(); - void testMediaStatus(); - void testPlaylist(); - -private: - MockProvider *mockProvider; - MockPlayerService *mockService; - QMediaPlayer *player; -}; - -void tst_QMediaPlayer::initTestCase_data() -{ - QTest::addColumn("valid"); - QTest::addColumn("state"); - QTest::addColumn("status"); - QTest::addColumn("mediaContent"); - QTest::addColumn("duration"); - QTest::addColumn("position"); - QTest::addColumn("seekable"); - QTest::addColumn("volume"); - QTest::addColumn("muted"); - QTest::addColumn("videoAvailable"); - QTest::addColumn("bufferStatus"); - QTest::addColumn("playbackRate"); - QTest::addColumn("error"); - QTest::addColumn("errorString"); - - QTest::newRow("invalid") << false << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent() << qint64(0) << qint64(0) << false << 0 << false << false << 0 << - qreal(0) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+null") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent() << qint64(0) << qint64(0) << false << 0 << false << false << 50 << - qreal(0) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+content+stopped") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent(QUrl("file:///some.mp3")) << qint64(0) << qint64(0) << false << 50 << false << false << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+content+playing") << true << QMediaPlayer::PlayingState << QMediaPlayer::LoadedMedia << - QMediaContent(QUrl("file:///some.mp3")) << qint64(10000) << qint64(10) << true << 50 << true << false << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+content+paused") << true << QMediaPlayer::PausedState << QMediaPlayer::LoadedMedia << - QMediaContent(QUrl("file:///some.mp3")) << qint64(10000) << qint64(10) << true << 50 << true << false << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valud+streaming") << true << QMediaPlayer::PlayingState << QMediaPlayer::LoadedMedia << - QMediaContent(QUrl("http://example.com/stream")) << qint64(10000) << qint64(10000) << false << 50 << false << true << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+error") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent(QUrl("http://example.com/stream")) << qint64(0) << qint64(0) << false << 50 << false << false << 0 << - qreal(0) << QMediaPlayer::ResourceError << QString("Resource unavailable"); -} - -void tst_QMediaPlayer::initTestCase() -{ - qRegisterMetaType(); - - mockService = new MockPlayerService; - mockProvider = new MockProvider(mockService); - player = new QMediaPlayer(0, 0, mockProvider); -} - -void tst_QMediaPlayer::cleanupTestCase() -{ - delete player; -} - -void tst_QMediaPlayer::init() -{ - mockService->reset(); -} - -void tst_QMediaPlayer::cleanup() -{ -} - -void tst_QMediaPlayer::testNullService() -{ - MockProvider provider(0); - QMediaPlayer player(0, 0, &provider); - - const QIODevice *nullDevice = 0; - - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(player.mediaStream(), nullDevice); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(player.duration(), qint64(-1)); - QCOMPARE(player.position(), qint64(0)); - QCOMPARE(player.volume(), 0); - QCOMPARE(player.isMuted(), false); - QCOMPARE(player.isVideoAvailable(), false); - QCOMPARE(player.bufferStatus(), 0); - QCOMPARE(player.isSeekable(), false); - QCOMPARE(player.playbackRate(), qreal(0)); - QCOMPARE(player.error(), QMediaPlayer::ServiceMissingError); - - { - QFETCH_GLOBAL(QMediaContent, mediaContent); - - QSignalSpy spy(&player, SIGNAL(mediaChanged(QMediaContent))); - QFile file; - - player.setMedia(mediaContent, &file); - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(player.mediaStream(), nullDevice); - QCOMPARE(spy.count(), 0); - } { - QSignalSpy stateSpy(&player, SIGNAL(stateChanged(QMediaPlayer::State))); - QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - - player.play(); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - - player.pause(); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - - player.stop(); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - } { - QFETCH_GLOBAL(int, volume); - QFETCH_GLOBAL(bool, muted); - - QSignalSpy volumeSpy(&player, SIGNAL(volumeChanged(int))); - QSignalSpy mutingSpy(&player, SIGNAL(mutedChanged(bool))); - - player.setVolume(volume); - QCOMPARE(player.volume(), 0); - QCOMPARE(volumeSpy.count(), 0); - - player.setMuted(muted); - QCOMPARE(player.isMuted(), false); - QCOMPARE(mutingSpy.count(), 0); - } { - QFETCH_GLOBAL(qint64, position); - - QSignalSpy spy(&player, SIGNAL(positionChanged(qint64))); - - player.setPosition(position); - QCOMPARE(player.position(), qint64(0)); - QCOMPARE(spy.count(), 0); - } { - QFETCH_GLOBAL(qreal, playbackRate); - - QSignalSpy spy(&player, SIGNAL(playbackRateChanged(qreal))); - - player.setPlaybackRate(playbackRate); - QCOMPARE(player.playbackRate(), qreal(0)); - QCOMPARE(spy.count(), 0); - } { - QMediaPlaylist playlist; - playlist.setMediaObject(&player); - - QSignalSpy mediaSpy(&player, SIGNAL(mediaChanged(QMediaContent))); - QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - - playlist.addMedia(QUrl("http://example.com/stream")); - playlist.addMedia(QUrl("file:///some.mp3")); - - playlist.setCurrentIndex(0); - QCOMPARE(playlist.currentIndex(), 0); - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(mediaSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - - playlist.next(); - QCOMPARE(playlist.currentIndex(), 1); - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(mediaSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - } -} - -void tst_QMediaPlayer::testValid() -{ - /* - QFETCH_GLOBAL(bool, valid); - - mockService->setIsValid(valid); - QCOMPARE(player->isValid(), valid); - */ -} - -void tst_QMediaPlayer::testMedia() -{ - QFETCH_GLOBAL(QMediaContent, mediaContent); - - mockService->setMedia(mediaContent); - QCOMPARE(player->media(), mediaContent); - - QBuffer stream; - player->setMedia(mediaContent, &stream); - QCOMPARE(player->media(), mediaContent); - QCOMPARE((QBuffer*)player->mediaStream(), &stream); -} - -void tst_QMediaPlayer::testDuration() -{ - QFETCH_GLOBAL(qint64, duration); - - mockService->setDuration(duration); - QVERIFY(player->duration() == duration); -} - -void tst_QMediaPlayer::testPosition() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(bool, seekable); - QFETCH_GLOBAL(qint64, position); - QFETCH_GLOBAL(qint64, duration); - - mockService->setIsValid(valid); - mockService->setSeekable(seekable); - mockService->setPosition(position); - mockService->setDuration(duration); - QVERIFY(player->isSeekable() == seekable); - QVERIFY(player->position() == position); - QVERIFY(player->duration() == duration); - - if (seekable) { - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(position); - QCOMPARE(player->position(), position); - QCOMPARE(spy.count(), 0); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(0); - QCOMPARE(player->position(), qint64(0)); - QCOMPARE(spy.count(), position == 0 ? 0 : 1); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(duration); - QCOMPARE(player->position(), duration); - QCOMPARE(spy.count(), position == duration ? 0 : 1); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(-1); - QCOMPARE(player->position(), qint64(0)); - QCOMPARE(spy.count(), position == 0 ? 0 : 1); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(duration + 1); - QCOMPARE(player->position(), duration); - QCOMPARE(spy.count(), position == duration ? 0 : 1); } - } - else { - QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(position); - - QCOMPARE(player->position(), position); - QCOMPARE(spy.count(), 0); - } -} - -void tst_QMediaPlayer::testVolume() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(int, volume); - - mockService->setVolume(volume); - QVERIFY(player->volume() == volume); - - if (valid) { - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(10); - QCOMPARE(player->volume(), 10); - QCOMPARE(spy.count(), 1); } - - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(-1000); - QCOMPARE(player->volume(), 0); - QCOMPARE(spy.count(), 1); } - - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(100); - QCOMPARE(player->volume(), 100); - QCOMPARE(spy.count(), 1); } - - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(1000); - QCOMPARE(player->volume(), 100); - QCOMPARE(spy.count(), 0); } - } -} - -void tst_QMediaPlayer::testMuted() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(bool, muted); - QFETCH_GLOBAL(int, volume); - - if (valid) { - mockService->setMuted(muted); - mockService->setVolume(volume); - QVERIFY(player->isMuted() == muted); - - QSignalSpy spy(player, SIGNAL(mutedChanged(bool))); - player->setMuted(!muted); - QCOMPARE(player->isMuted(), !muted); - QCOMPARE(player->volume(), volume); - QCOMPARE(spy.count(), 1); - } -} - -void tst_QMediaPlayer::testVideoAvailable() -{ - QFETCH_GLOBAL(bool, videoAvailable); - - mockService->setVideoAvailable(videoAvailable); - QVERIFY(player->isVideoAvailable() == videoAvailable); -} - -void tst_QMediaPlayer::testBufferStatus() -{ - QFETCH_GLOBAL(int, bufferStatus); - - mockService->setBufferStatus(bufferStatus); - QVERIFY(player->bufferStatus() == bufferStatus); -} - -void tst_QMediaPlayer::testSeekable() -{ - QFETCH_GLOBAL(bool, seekable); - - mockService->setSeekable(seekable); - QVERIFY(player->isSeekable() == seekable); -} - -void tst_QMediaPlayer::testPlaybackRate() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(qreal, playbackRate); - - if (valid) { - mockService->setPlaybackRate(playbackRate); - QVERIFY(player->playbackRate() == playbackRate); - - QSignalSpy spy(player, SIGNAL(playbackRateChanged(qreal))); - player->setPlaybackRate(playbackRate + 0.5f); - QCOMPARE(player->playbackRate(), playbackRate + 0.5f); - QCOMPARE(spy.count(), 1); - } -} - -void tst_QMediaPlayer::testError() -{ - QFETCH_GLOBAL(QMediaPlayer::Error, error); - - mockService->setError(error); - QVERIFY(player->error() == error); -} - -void tst_QMediaPlayer::testErrorString() -{ - QFETCH_GLOBAL(QString, errorString); - - mockService->setErrorString(errorString); - QVERIFY(player->errorString() == errorString); -} - -void tst_QMediaPlayer::testService() -{ - /* - QFETCH_GLOBAL(bool, valid); - - mockService->setIsValid(valid); - - if (valid) - QVERIFY(player->service() != 0); - else - QVERIFY(player->service() == 0); - */ -} - -void tst_QMediaPlayer::testPlay() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(QMediaContent, mediaContent); - QFETCH_GLOBAL(QMediaPlayer::State, state); - - mockService->setIsValid(valid); - mockService->setState(state); - mockService->setMedia(mediaContent); - QVERIFY(player->state() == state); - QVERIFY(player->media() == mediaContent); - - QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - - player->play(); - - if (!valid || mediaContent.isNull()) { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 0); - } - else { - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(spy.count(), state == QMediaPlayer::PlayingState ? 0 : 1); - } -} - -void tst_QMediaPlayer::testPause() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(QMediaContent, mediaContent); - QFETCH_GLOBAL(QMediaPlayer::State, state); - - mockService->setIsValid(valid); - mockService->setState(state); - mockService->setMedia(mediaContent); - QVERIFY(player->state() == state); - QVERIFY(player->media() == mediaContent); - - QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - - player->pause(); - - if (!valid || mediaContent.isNull()) { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 0); - } - else { - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(spy.count(), state == QMediaPlayer::PausedState ? 0 : 1); - } -} - -void tst_QMediaPlayer::testStop() -{ - QFETCH_GLOBAL(QMediaContent, mediaContent); - QFETCH_GLOBAL(QMediaPlayer::State, state); - - mockService->setState(state); - mockService->setMedia(mediaContent); - QVERIFY(player->state() == state); - QVERIFY(player->media() == mediaContent); - - QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - - player->stop(); - - if (mediaContent.isNull() || state == QMediaPlayer::StoppedState) { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 0); - } - else { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 1); - } -} - -void tst_QMediaPlayer::testMediaStatus() -{ - QFETCH_GLOBAL(int, bufferStatus); - int bufferSignals = 0; - - player->setNotifyInterval(10); - - mockService->setMediaStatus(QMediaPlayer::NoMedia); - mockService->setBufferStatus(bufferStatus); - - AutoConnection connection( - player, SIGNAL(bufferStatusChanged(int)), - &QTestEventLoop::instance(), SLOT(exitLoop())); - - QSignalSpy statusSpy(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - QSignalSpy bufferSpy(player, SIGNAL(bufferStatusChanged(int))); - - QCOMPARE(player->mediaStatus(), QMediaPlayer::NoMedia); - - mockService->setMediaStatus(QMediaPlayer::LoadingMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadingMedia); - QCOMPARE(statusSpy.count(), 1); - - QCOMPARE(qvariant_cast(statusSpy.last().value(0)), - QMediaPlayer::LoadingMedia); - - mockService->setMediaStatus(QMediaPlayer::LoadedMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadedMedia); - QCOMPARE(statusSpy.count(), 2); - - QCOMPARE(qvariant_cast(statusSpy.last().value(0)), - QMediaPlayer::LoadedMedia); - - // Verify the bufferStatusChanged() signal isn't being emitted. - QTestEventLoop::instance().enterLoop(1); - QCOMPARE(bufferSpy.count(), 0); - - mockService->setMediaStatus(QMediaPlayer::StalledMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::StalledMedia); - QCOMPARE(statusSpy.count(), 3); - - QCOMPARE(qvariant_cast(statusSpy.last().value(0)), - QMediaPlayer::StalledMedia); - - // Verify the bufferStatusChanged() signal is being emitted. - QTestEventLoop::instance().enterLoop(1); - QVERIFY(bufferSpy.count() > bufferSignals); - QCOMPARE(bufferSpy.last().value(0).toInt(), bufferStatus); - bufferSignals = bufferSpy.count(); - - mockService->setMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferingMedia); - QCOMPARE(statusSpy.count(), 4); - - QCOMPARE(qvariant_cast(statusSpy.last().value(0)), - QMediaPlayer::BufferingMedia); - - // Verify the bufferStatusChanged() signal is being emitted. - QTestEventLoop::instance().enterLoop(1); - QVERIFY(bufferSpy.count() > bufferSignals); - QCOMPARE(bufferSpy.last().value(0).toInt(), bufferStatus); - bufferSignals = bufferSpy.count(); - - mockService->setMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferedMedia); - QCOMPARE(statusSpy.count(), 5); - - QCOMPARE(qvariant_cast(statusSpy.last().value(0)), - QMediaPlayer::BufferedMedia); - - // Verify the bufferStatusChanged() signal isn't being emitted. - QTestEventLoop::instance().enterLoop(1); - QCOMPARE(bufferSpy.count(), bufferSignals); - - mockService->setMediaStatus(QMediaPlayer::EndOfMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::EndOfMedia); - QCOMPARE(statusSpy.count(), 6); - - QCOMPARE(qvariant_cast(statusSpy.last().value(0)), - QMediaPlayer::EndOfMedia); -} - -void tst_QMediaPlayer::testPlaylist() -{ - QMediaContent content0(QUrl(QLatin1String("test://audio/song1.mp3"))); - QMediaContent content1(QUrl(QLatin1String("test://audio/song2.mp3"))); - QMediaContent content2(QUrl(QLatin1String("test://video/movie1.mp4"))); - QMediaContent content3(QUrl(QLatin1String("test://video/movie2.mp4"))); - QMediaContent content4(QUrl(QLatin1String("test://image/photo.jpg"))); - - mockService->setIsValid(true); - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::NoMedia); - - QMediaPlaylist *playlist = new QMediaPlaylist; - playlist->setMediaObject(player); - - QSignalSpy stateSpy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - QSignalSpy mediaSpy(player, SIGNAL(mediaChanged(QMediaContent))); - - // Test the player does nothing with an empty playlist attached. - player->play(); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(mediaSpy.count(), 0); - - playlist->addMedia(content0); - playlist->addMedia(content1); - playlist->addMedia(content2); - playlist->addMedia(content3); - - // Test changing the playlist position, changes the current media, but not the playing state. - playlist->setCurrentIndex(1); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(mediaSpy.count(), 1); - - // Test playing starts with the current media. - player->play(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 1); - QCOMPARE(mediaSpy.count(), 1); - - // Test pausing doesn't change the current media. - player->pause(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(stateSpy.count(), 2); - QCOMPARE(mediaSpy.count(), 1); - - // Test stopping doesn't change the current media. - player->stop(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 3); - QCOMPARE(mediaSpy.count(), 1); - - // Test when the player service reaches the end of the current media, the player moves onto - // the next item without stopping. - player->play(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 4); - QCOMPARE(mediaSpy.count(), 1); - - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia); - QCOMPARE(player->media(), content2); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 4); - QCOMPARE(mediaSpy.count(), 2); - - // Test skipping the current media doesn't change the state. - playlist->next(); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 4); - QCOMPARE(mediaSpy.count(), 3); - - // Test changing the current media while paused doesn't change the state. - player->pause(); - mockService->setMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(stateSpy.count(), 5); - QCOMPARE(mediaSpy.count(), 3); - - playlist->previous(); - QCOMPARE(player->media(), content2); - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(stateSpy.count(), 5); - QCOMPARE(mediaSpy.count(), 4); - - // Test changing the current media while stopped doesn't change the state. - player->stop(); - mockService->setMediaStatus(QMediaPlayer::LoadedMedia); - QCOMPARE(player->media(), content2); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 6); - QCOMPARE(mediaSpy.count(), 4); - - playlist->next(); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 6); - QCOMPARE(mediaSpy.count(), 5); - - // Test the player is stopped and the current media cleared when it reaches the end of the last - // item in the playlist. - player->play(); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 7); - QCOMPARE(mediaSpy.count(), 5); - - // Double up the signals to ensure some noise doesn't destabalize things. - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia); - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia); - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 8); - QCOMPARE(mediaSpy.count(), 6); - - // Test starts playing from the start of the playlist if there is no current media selected. - player->play(); - QCOMPARE(player->media(), content0); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 9); - QCOMPARE(mediaSpy.count(), 7); - - // Test deleting the playlist stops the player and clears the media it set. - delete playlist; - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 10); - QCOMPARE(mediaSpy.count(), 8); - - // Test the player works as normal with the playlist removed. - player->play(); - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 10); - QCOMPARE(mediaSpy.count(), 8); - - player->setMedia(content1); - player->play(); - - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 11); - QCOMPARE(mediaSpy.count(), 9); - - // Test the player can bind to playlist again - playlist = new QMediaPlaylist; - playlist->setMediaObject(player); - QCOMPARE(playlist->mediaObject(), qobject_cast(player)); - - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - - playlist->addMedia(content0); - playlist->addMedia(content1); - playlist->addMedia(content2); - playlist->addMedia(content3); - - playlist->setCurrentIndex(1); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - - // Test attaching the new playlist, - // player should detach the current one - QMediaPlaylist *playlist2 = new QMediaPlaylist; - playlist2->addMedia(content1); - playlist2->addMedia(content2); - playlist2->addMedia(content3); - playlist2->setCurrentIndex(2); - - player->play(); - playlist2->setMediaObject(player); - QCOMPARE(playlist2->mediaObject(), qobject_cast(player)); - QVERIFY(playlist->mediaObject() == 0); - QCOMPARE(player->media(), playlist2->currentMedia()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - - playlist2->setCurrentIndex(1); - QCOMPARE(player->media(), playlist2->currentMedia()); -} - -QTEST_MAIN(tst_QMediaPlayer) - -#include "tst_qmediaplayer.moc" diff --git a/tests/auto/qmediaplaylist/qmediaplaylist.pro b/tests/auto/qmediaplaylist/qmediaplaylist.pro deleted file mode 100644 index 809473b..0000000 --- a/tests/auto/qmediaplaylist/qmediaplaylist.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaplaylist.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediaplaylist/tmp.unsupported_format b/tests/auto/qmediaplaylist/tmp.unsupported_format deleted file mode 100644 index e69de29..0000000 diff --git a/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp b/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp deleted file mode 100644 index 1037f37..0000000 --- a/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp +++ /dev/null @@ -1,593 +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 - - -class MockReadOnlyPlaylistProvider : public QMediaPlaylistProvider -{ - Q_OBJECT -public: - MockReadOnlyPlaylistProvider(QObject *parent) - :QMediaPlaylistProvider(parent) - { - m_items.append(QMediaContent(QUrl(QLatin1String("file:///1")))); - m_items.append(QMediaContent(QUrl(QLatin1String("file:///2")))); - m_items.append(QMediaContent(QUrl(QLatin1String("file:///3")))); - } - - int mediaCount() const { return m_items.size(); } - QMediaContent media(int index) const - { - return index >=0 && index < mediaCount() ? m_items.at(index) : QMediaContent(); - } - -private: - QList m_items; -}; - -class MockPlaylistControl : public QMediaPlaylistControl -{ - Q_OBJECT -public: - MockPlaylistControl(QObject *parent) : QMediaPlaylistControl(parent) - { - m_navigator = new QMediaPlaylistNavigator(new MockReadOnlyPlaylistProvider(this), this); - } - - ~MockPlaylistControl() - { - } - - QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); } - bool setPlaylistProvider(QMediaPlaylistProvider *playlist) { m_navigator->setPlaylist(playlist); return true; } - - int currentIndex() const { return m_navigator->currentIndex(); } - void setCurrentIndex(int position) { m_navigator->jump(position); } - int nextIndex(int steps) const { return m_navigator->nextIndex(steps); } - int previousIndex(int steps) const { return m_navigator->previousIndex(steps); } - - void next() { m_navigator->next(); } - void previous() { m_navigator->previous(); } - - QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); } - void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) { m_navigator->setPlaybackMode(mode); } - -private: - QMediaPlaylistNavigator *m_navigator; -}; - -class MockPlaylistService : public QMediaService -{ - Q_OBJECT - -public: - MockPlaylistService():QMediaService(0) - { - mockControl = new MockPlaylistControl(this); - } - - ~MockPlaylistService() - { - } - - QMediaControl* control(const char *iid) const - { - if (qstrcmp(iid, QMediaPlaylistControl_iid) == 0) - return mockControl; - return 0; - } - - MockPlaylistControl *mockControl; -}; - -class MockReadOnlyPlaylistObject : public QMediaObject -{ - Q_OBJECT -public: - MockReadOnlyPlaylistObject(QObject *parent = 0) - :QMediaObject(parent, new MockPlaylistService) - { - } -}; - - -class tst_QMediaPlaylist : public QObject -{ - Q_OBJECT -public slots: - void init(); - void cleanup(); - void initTestCase(); - -private slots: - void construction(); - void append(); - void insert(); - void clear(); - void removeMedia(); - void currentItem(); - void saveAndLoad(); - void playbackMode(); - void playbackMode_data(); - void shuffle(); - void readOnlyPlaylist(); - void setMediaObject(); - -private: - QMediaContent content1; - QMediaContent content2; - QMediaContent content3; -}; - -void tst_QMediaPlaylist::init() -{ -} - -void tst_QMediaPlaylist::initTestCase() -{ - content1 = QMediaContent(QUrl(QLatin1String("file:///1"))); - content2 = QMediaContent(QUrl(QLatin1String("file:///2"))); - content3 = QMediaContent(QUrl(QLatin1String("file:///3"))); -} - -void tst_QMediaPlaylist::cleanup() -{ -} - -void tst_QMediaPlaylist::construction() -{ - QMediaPlaylist playlist; - QCOMPARE(playlist.mediaCount(), 0); - QVERIFY(playlist.isEmpty()); -} - -void tst_QMediaPlaylist::append() -{ - QMediaPlaylist playlist; - QVERIFY(!playlist.isReadOnly()); - - playlist.addMedia(content1); - QCOMPARE(playlist.mediaCount(), 1); - QCOMPARE(playlist.media(0), content1); - - QSignalSpy aboutToBeInsertedSignalSpy(&playlist, SIGNAL(mediaAboutToBeInserted(int,int))); - QSignalSpy insertedSignalSpy(&playlist, SIGNAL(mediaInserted(int,int))); - playlist.addMedia(content2); - QCOMPARE(playlist.mediaCount(), 2); - QCOMPARE(playlist.media(1), content2); - - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(insertedSignalSpy.first()[1].toInt(), 1); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - QMediaContent content4(QUrl(QLatin1String("file:///4"))); - QMediaContent content5(QUrl(QLatin1String("file:///5"))); - playlist.addMedia(QList() << content3 << content4 << content5); - QCOMPARE(playlist.mediaCount(), 5); - QCOMPARE(playlist.media(2), content3); - QCOMPARE(playlist.media(3), content4); - QCOMPARE(playlist.media(4), content5); - - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy[0][0].toInt(), 2); - QCOMPARE(aboutToBeInsertedSignalSpy[0][1].toInt(), 4); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy[0][0].toInt(), 2); - QCOMPARE(insertedSignalSpy[0][1].toInt(), 4); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - playlist.addMedia(QList()); - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 0); - QCOMPARE(insertedSignalSpy.count(), 0); -} - -void tst_QMediaPlaylist::insert() -{ - QMediaPlaylist playlist; - QVERIFY(!playlist.isReadOnly()); - - playlist.addMedia(content1); - QCOMPARE(playlist.mediaCount(), 1); - QCOMPARE(playlist.media(0), content1); - - playlist.addMedia(content2); - QCOMPARE(playlist.mediaCount(), 2); - QCOMPARE(playlist.media(1), content2); - - QSignalSpy aboutToBeInsertedSignalSpy(&playlist, SIGNAL(mediaAboutToBeInserted(int,int))); - QSignalSpy insertedSignalSpy(&playlist, SIGNAL(mediaInserted(int,int))); - - playlist.insertMedia(1, content3); - QCOMPARE(playlist.mediaCount(), 3); - QCOMPARE(playlist.media(0), content1); - QCOMPARE(playlist.media(1), content3); - QCOMPARE(playlist.media(2), content2); - - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(insertedSignalSpy.first()[1].toInt(), 1); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - QMediaContent content4(QUrl(QLatin1String("file:///4"))); - QMediaContent content5(QUrl(QLatin1String("file:///5"))); - playlist.insertMedia(1, QList() << content4 << content5); - - QCOMPARE(playlist.media(0), content1); - QCOMPARE(playlist.media(1), content4); - QCOMPARE(playlist.media(2), content5); - QCOMPARE(playlist.media(3), content3); - QCOMPARE(playlist.media(4), content2); - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy[0][0].toInt(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy[0][1].toInt(), 2); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy[0][0].toInt(), 1); - QCOMPARE(insertedSignalSpy[0][1].toInt(), 2); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - playlist.insertMedia(1, QList()); - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 0); - QCOMPARE(insertedSignalSpy.count(), 0); -} - - -void tst_QMediaPlaylist::currentItem() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - - QCOMPARE(playlist.currentIndex(), -1); - QCOMPARE(playlist.currentMedia(), QMediaContent()); - - QCOMPARE(playlist.nextIndex(), 0); - QCOMPARE(playlist.nextIndex(2), 1); - QCOMPARE(playlist.previousIndex(), 1); - QCOMPARE(playlist.previousIndex(2), 0); - - playlist.setCurrentIndex(0); - QCOMPARE(playlist.currentIndex(), 0); - QCOMPARE(playlist.currentMedia(), content1); - - QCOMPARE(playlist.nextIndex(), 1); - QCOMPARE(playlist.nextIndex(2), -1); - QCOMPARE(playlist.previousIndex(), -1); - QCOMPARE(playlist.previousIndex(2), -1); - - playlist.setCurrentIndex(1); - QCOMPARE(playlist.currentIndex(), 1); - QCOMPARE(playlist.currentMedia(), content2); - - QCOMPARE(playlist.nextIndex(), -1); - QCOMPARE(playlist.nextIndex(2), -1); - QCOMPARE(playlist.previousIndex(), 0); - QCOMPARE(playlist.previousIndex(2), -1); - - QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range "); - playlist.setCurrentIndex(2); - - QCOMPARE(playlist.currentIndex(), -1); - QCOMPARE(playlist.currentMedia(), QMediaContent()); -} - -void tst_QMediaPlaylist::clear() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - - playlist.clear(); - QVERIFY(playlist.isEmpty()); - QCOMPARE(playlist.mediaCount(), 0); -} - -void tst_QMediaPlaylist::removeMedia() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - QSignalSpy aboutToBeRemovedSignalSpy(&playlist, SIGNAL(mediaAboutToBeRemoved(int,int))); - QSignalSpy removedSignalSpy(&playlist, SIGNAL(mediaRemoved(int,int))); - playlist.removeMedia(1); - QCOMPARE(playlist.mediaCount(), 2); - QCOMPARE(playlist.media(1), content3); - - QCOMPARE(aboutToBeRemovedSignalSpy.count(), 1); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(removedSignalSpy.count(), 1); - QCOMPARE(removedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(removedSignalSpy.first()[1].toInt(), 1); - - aboutToBeRemovedSignalSpy.clear(); - removedSignalSpy.clear(); - - playlist.removeMedia(0,1); - QVERIFY(playlist.isEmpty()); - - QCOMPARE(aboutToBeRemovedSignalSpy.count(), 1); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[0].toInt(), 0); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(removedSignalSpy.count(), 1); - QCOMPARE(removedSignalSpy.first()[0].toInt(), 0); - QCOMPARE(removedSignalSpy.first()[1].toInt(), 1); - - - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - playlist.removeMedia(0,1); - QCOMPARE(playlist.mediaCount(), 1); - QCOMPARE(playlist.media(0), content3); -} - -void tst_QMediaPlaylist::saveAndLoad() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - QCOMPARE(playlist.error(), QMediaPlaylist::NoError); - QVERIFY(playlist.errorString().isEmpty()); - - QBuffer buffer; - buffer.open(QBuffer::ReadWrite); - - bool res = playlist.save(&buffer, "unsupported_format"); - QVERIFY(!res); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); - - QSignalSpy errorSignal(&playlist, SIGNAL(loadFailed())); - playlist.load(&buffer, "unsupported_format"); - QCOMPARE(errorSignal.size(), 1); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); - - res = playlist.save(QUrl(QLatin1String("tmp.unsupported_format")), "unsupported_format"); - QVERIFY(!res); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); - - errorSignal.clear(); - playlist.load(QUrl(QLatin1String("tmp.unsupported_format")), "unsupported_format"); - QCOMPARE(errorSignal.size(), 1); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); -} - -void tst_QMediaPlaylist::playbackMode_data() -{ - QTest::addColumn("playbackMode"); - QTest::addColumn("expectedPrevious"); - QTest::addColumn("pos"); - QTest::addColumn("expectedNext"); - - QTest::newRow("Linear, 0") << QMediaPlaylist::Linear << -1 << 0 << 1; - QTest::newRow("Linear, 1") << QMediaPlaylist::Linear << 0 << 1 << 2; - QTest::newRow("Linear, 2") << QMediaPlaylist::Linear << 1 << 2 << -1; - - QTest::newRow("Loop, 0") << QMediaPlaylist::Loop << 2 << 0 << 1; - QTest::newRow("Loop, 1") << QMediaPlaylist::Loop << 0 << 1 << 2; - QTest::newRow("Lopp, 2") << QMediaPlaylist::Loop << 1 << 2 << 0; - - QTest::newRow("ItemOnce, 1") << QMediaPlaylist::CurrentItemOnce << -1 << 1 << -1; - QTest::newRow("ItemInLoop, 1") << QMediaPlaylist::CurrentItemInLoop << 1 << 1 << 1; - -} - -void tst_QMediaPlaylist::playbackMode() -{ - QFETCH(QMediaPlaylist::PlaybackMode, playbackMode); - QFETCH(int, expectedPrevious); - QFETCH(int, pos); - QFETCH(int, expectedNext); - - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - QCOMPARE(playlist.playbackMode(), QMediaPlaylist::Linear); - QCOMPARE(playlist.currentIndex(), -1); - - playlist.setPlaybackMode(playbackMode); - QCOMPARE(playlist.playbackMode(), playbackMode); - - playlist.setCurrentIndex(pos); - QCOMPARE(playlist.currentIndex(), pos); - QCOMPARE(playlist.nextIndex(), expectedNext); - QCOMPARE(playlist.previousIndex(), expectedPrevious); - - playlist.next(); - QCOMPARE(playlist.currentIndex(), expectedNext); - - playlist.setCurrentIndex(pos); - playlist.previous(); - QCOMPARE(playlist.currentIndex(), expectedPrevious); -} - -void tst_QMediaPlaylist::shuffle() -{ - QMediaPlaylist playlist; - QList contentList; - - for (int i=0; i<100; i++) { - QMediaContent content(QUrl(QString::number(i))); - contentList.append(content); - playlist.addMedia(content); - } - - playlist.shuffle(); - - QList shuffledContentList; - for (int i=0; i() << content1 << content2)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.insertMedia(1, content1)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.insertMedia(1, QList() << content1 << content2)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.removeMedia(1)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.removeMedia(0,2)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.clear()); - QCOMPARE(playlist.mediaCount(), 3); - - //but it is still allowed to append/insert an empty list - QVERIFY(playlist.addMedia(QList())); - QVERIFY(playlist.insertMedia(1, QList())); - - playlist.shuffle(); - //it's still the same - QCOMPARE(playlist.media(0), content1); - QCOMPARE(playlist.media(1), content2); - QCOMPARE(playlist.media(2), content3); - QCOMPARE(playlist.media(3), QMediaContent()); - - - //load to read only playlist should fail, - //unless underlaying provider supports it - QBuffer buffer; - buffer.open(QBuffer::ReadWrite); - buffer.write(QByteArray("file:///1\nfile:///2")); - buffer.seek(0); - - QSignalSpy errorSignal(&playlist, SIGNAL(loadFailed())); - playlist.load(&buffer, "m3u"); - QCOMPARE(errorSignal.size(), 1); - QCOMPARE(playlist.error(), QMediaPlaylist::AccessDeniedError); - QVERIFY(!playlist.errorString().isEmpty()); - QCOMPARE(playlist.mediaCount(), 3); - - errorSignal.clear(); - playlist.load(QUrl(QLatin1String("tmp.m3u")), "m3u"); - - QCOMPARE(errorSignal.size(), 1); - QCOMPARE(playlist.error(), QMediaPlaylist::AccessDeniedError); - QVERIFY(!playlist.errorString().isEmpty()); - QCOMPARE(playlist.mediaCount(), 3); -} - -void tst_QMediaPlaylist::setMediaObject() -{ - MockReadOnlyPlaylistObject mediaObject; - - QMediaPlaylist playlist; - QVERIFY(playlist.mediaObject() == 0); - QVERIFY(!playlist.isReadOnly()); - - playlist.setMediaObject(&mediaObject); - QCOMPARE(playlist.mediaObject(), qobject_cast(&mediaObject)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(playlist.isReadOnly()); - - playlist.setMediaObject(0); - QVERIFY(playlist.mediaObject() == 0); - QCOMPARE(playlist.mediaCount(), 0); - QVERIFY(!playlist.isReadOnly()); - - playlist.setMediaObject(&mediaObject); - QCOMPARE(playlist.mediaObject(), qobject_cast(&mediaObject)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(playlist.isReadOnly()); -} - -QTEST_MAIN(tst_QMediaPlaylist) -#include "tst_qmediaplaylist.moc" - diff --git a/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro b/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro deleted file mode 100644 index 3265762..0000000 --- a/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaplaylistnavigator.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp b/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp deleted file mode 100644 index 04f736c..0000000 --- a/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp +++ /dev/null @@ -1,316 +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 - - -class tst_QMediaPlaylistNavigator : public QObject -{ - Q_OBJECT -public slots: - void init(); - void cleanup(); - -private slots: - void construction(); - void setPlaylist(); - void linearPlayback(); - void loopPlayback(); - void currentItemOnce(); - void currentItemInLoop(); - void randomPlayback(); -}; - -void tst_QMediaPlaylistNavigator::init() -{ -} - -void tst_QMediaPlaylistNavigator::cleanup() -{ -} - -void tst_QMediaPlaylistNavigator::construction() -{ - QLocalMediaPlaylistProvider playlist; - QCOMPARE(playlist.mediaCount(), 0); - - QMediaPlaylistNavigator navigator(&playlist); - QVERIFY(navigator.currentItem().isNull()); - QCOMPARE(navigator.currentIndex(), -1); -} - -void tst_QMediaPlaylistNavigator::setPlaylist() -{ - QMediaPlaylistNavigator navigator(0); - QVERIFY(navigator.playlist() != 0); - QCOMPARE(navigator.playlist()->mediaCount(), 0); - QCOMPARE(navigator.playlist()->media(0), QMediaContent()); - QVERIFY(navigator.playlist()->isReadOnly() ); - - QLocalMediaPlaylistProvider playlist; - QCOMPARE(playlist.mediaCount(), 0); - - navigator.setPlaylist(&playlist); - QCOMPARE(navigator.playlist(), (QMediaPlaylistProvider*)&playlist); - QCOMPARE(navigator.playlist()->mediaCount(), 0); - QVERIFY(!navigator.playlist()->isReadOnly() ); -} - -void tst_QMediaPlaylistNavigator::linearPlayback() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::Linear); - QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range "); - navigator.jump(0);//it's ok to have warning here - QVERIFY(navigator.currentItem().isNull()); - QCOMPARE(navigator.currentIndex(), -1); - - QMediaContent content1(QUrl(QLatin1String("file:///1"))); - playlist.addMedia(content1); - navigator.jump(0); - QVERIFY(!navigator.currentItem().isNull()); - - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), QMediaContent()); - QCOMPARE(navigator.nextItem(2), QMediaContent()); - QCOMPARE(navigator.previousItem(), QMediaContent()); - QCOMPARE(navigator.previousItem(2), QMediaContent()); - - QMediaContent content2(QUrl(QLatin1String("file:///2"))); - playlist.addMedia(content2); - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), content2); - QCOMPARE(navigator.nextItem(2), QMediaContent()); - QCOMPARE(navigator.previousItem(), QMediaContent()); - QCOMPARE(navigator.previousItem(2), QMediaContent()); - - navigator.jump(1); - QCOMPARE(navigator.currentIndex(), 1); - QCOMPARE(navigator.currentItem(), content2); - QCOMPARE(navigator.nextItem(), QMediaContent()); - QCOMPARE(navigator.nextItem(2), QMediaContent()); - QCOMPARE(navigator.previousItem(), content1); - QCOMPARE(navigator.previousItem(2), QMediaContent()); - - navigator.jump(0); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.next();//jump to the first item - QCOMPARE(navigator.currentIndex(), 0); - - navigator.previous(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.previous();//jump to the last item - QCOMPARE(navigator.currentIndex(), 1); -} - -void tst_QMediaPlaylistNavigator::loopPlayback() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::Loop); - QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range "); - navigator.jump(0); - QVERIFY(navigator.currentItem().isNull()); - QCOMPARE(navigator.currentIndex(), -1); - - QMediaContent content1(QUrl(QLatin1String("file:///1"))); - playlist.addMedia(content1); - navigator.jump(0); - QVERIFY(!navigator.currentItem().isNull()); - - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), content1); - QCOMPARE(navigator.nextItem(2), content1); - QCOMPARE(navigator.previousItem(), content1); - QCOMPARE(navigator.previousItem(2), content1); - - QMediaContent content2(QUrl(QLatin1String("file:///2"))); - playlist.addMedia(content2); - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), content2); - QCOMPARE(navigator.nextItem(2), content1); //loop over end of the list - QCOMPARE(navigator.previousItem(), content2); - QCOMPARE(navigator.previousItem(2), content1); - - navigator.jump(1); - QCOMPARE(navigator.currentIndex(), 1); - QCOMPARE(navigator.currentItem(), content2); - QCOMPARE(navigator.nextItem(), content1); - QCOMPARE(navigator.nextItem(2), content2); - QCOMPARE(navigator.previousItem(), content1); - QCOMPARE(navigator.previousItem(2), content2); - - navigator.jump(0); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 0); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 0); -} - -void tst_QMediaPlaylistNavigator::currentItemOnce() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::CurrentItemOnce); - - QCOMPARE(navigator.playbackMode(), QMediaPlaylist::CurrentItemOnce); - QCOMPARE(navigator.currentIndex(), -1); - - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3")))); - - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - - navigator.jump(1); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.jump(1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), -1); -} - -void tst_QMediaPlaylistNavigator::currentItemInLoop() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::CurrentItemInLoop); - - QCOMPARE(navigator.playbackMode(), QMediaPlaylist::CurrentItemInLoop); - QCOMPARE(navigator.currentIndex(), -1); - - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3")))); - - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.jump(1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 1); -} - -void tst_QMediaPlaylistNavigator::randomPlayback() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::Random); - - QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random); - QCOMPARE(navigator.currentIndex(), -1); - - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3")))); - - playlist.shuffle(); - - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - int pos1 = navigator.currentIndex(); - navigator.next(); - int pos2 = navigator.currentIndex(); - navigator.next(); - int pos3 = navigator.currentIndex(); - - QVERIFY(pos1 != -1); - QVERIFY(pos2 != -1); - QVERIFY(pos3 != -1); - - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos2); - navigator.next(); - QCOMPARE(navigator.currentIndex(), pos3); - navigator.next(); - int pos4 = navigator.currentIndex(); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos3); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos2); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos1); - navigator.previous(); - int pos0 = navigator.currentIndex(); - QVERIFY(pos0 != -1); - navigator.next(); - navigator.next(); - navigator.next(); - navigator.next(); - QCOMPARE(navigator.currentIndex(), pos4); - -} - -QTEST_MAIN(tst_QMediaPlaylistNavigator) -#include "tst_qmediaplaylistnavigator.moc" diff --git a/tests/auto/qmediapluginloader/qmediapluginloader.pro b/tests/auto/qmediapluginloader/qmediapluginloader.pro deleted file mode 100644 index a47cc57..0000000 --- a/tests/auto/qmediapluginloader/qmediapluginloader.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediapluginloader.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp b/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp deleted file mode 100644 index 001e68a..0000000 --- a/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp +++ /dev/null @@ -1,121 +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 - - - -class tst_QMediaPluginLoader : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - -private slots: - void testInstance(); - void testInstances(); - void testInvalidKey(); - -private: - QMediaPluginLoader *loader; -}; - -void tst_QMediaPluginLoader::initTestCase() -{ - loader = new QMediaPluginLoader(QMediaServiceProviderFactoryInterface_iid, - QLatin1String("/mediaservice"), - Qt::CaseInsensitive); -} - -void tst_QMediaPluginLoader::cleanupTestCase() -{ - delete loader; -} - -void tst_QMediaPluginLoader::testInstance() -{ - const QStringList keys = loader->keys(); - - if (keys.isEmpty()) // Test is invalidated, skip. - QSKIP("No plug-ins available", SkipAll); - - foreach (const QString &key, keys) - QVERIFY(loader->instance(key) != 0); -} - -void tst_QMediaPluginLoader::testInstances() -{ - const QStringList keys = loader->keys(); - - if (keys.isEmpty()) // Test is invalidated, skip. - QSKIP("No plug-ins available", SkipAll); - - foreach (const QString &key, keys) - QVERIFY(loader->instances(key).size() > 0); -} - -// Last so as to not interfere with the other tests if there is a failure. -void tst_QMediaPluginLoader::testInvalidKey() -{ - const QString key(QLatin1String("invalid-key")); - - // This test assumes there is no 'invalid-key' in the key list, verify that. - if (loader->keys().contains(key)) - QSKIP("a plug-in includes the invalid key", SkipAll); - - QVERIFY(loader->instance(key) == 0); - - // Test looking up the key hasn't inserted it into the list. See QMap::operator[]. - QVERIFY(!loader->keys().contains(key)); - - QVERIFY(loader->instances(key).isEmpty()); - QVERIFY(!loader->keys().contains(key)); -} - -QTEST_MAIN(tst_QMediaPluginLoader) - -#include "tst_qmediapluginloader.moc" diff --git a/tests/auto/qmediaresource/qmediaresource.pro b/tests/auto/qmediaresource/qmediaresource.pro deleted file mode 100644 index 64669a2..0000000 --- a/tests/auto/qmediaresource/qmediaresource.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaresource.cpp - -QT = core mediaservices network - diff --git a/tests/auto/qmediaresource/tst_qmediaresource.cpp b/tests/auto/qmediaresource/tst_qmediaresource.cpp deleted file mode 100644 index 984cfef..0000000 --- a/tests/auto/qmediaresource/tst_qmediaresource.cpp +++ /dev/null @@ -1,516 +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 - - -class tst_QMediaResource : public QObject -{ - Q_OBJECT -private slots: - void constructNull(); - void construct_data(); - void construct(); - void setResolution(); - void equality(); - void copy(); - void assign(); -}; - -void tst_QMediaResource::constructNull() -{ - QMediaResource resource; - - QCOMPARE(resource.isNull(), true); - QCOMPARE(resource.url(), QUrl()); - QCOMPARE(resource.request(), QNetworkRequest()); - QCOMPARE(resource.mimeType(), QString()); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); -} - -void tst_QMediaResource::construct_data() -{ - QTest::addColumn("url"); - QTest::addColumn("request"); - QTest::addColumn("mimeType"); - QTest::addColumn("language"); - QTest::addColumn("audioCodec"); - QTest::addColumn("videoCodec"); - QTest::addColumn("dataSize"); - QTest::addColumn("audioBitRate"); - QTest::addColumn("sampleRate"); - QTest::addColumn("channelCount"); - QTest::addColumn("videoBitRate"); - QTest::addColumn("resolution"); - - QTest::newRow("audio content") - << QUrl(QString::fromLatin1("http:://test.com/test.mp3")) - << QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.mp3"))) - << QString::fromLatin1("audio/mpeg") - << QString::fromLatin1("eng") - << QString::fromLatin1("mp3") - << QString() - << qint64(5465433) - << 128000 - << 44100 - << 2 - << 0 - << QSize(); - QTest::newRow("image content") - << QUrl(QString::fromLatin1("http:://test.com/test.jpg")) - << QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.jpg"))) - << QString::fromLatin1("image/jpeg") - << QString() - << QString() - << QString() - << qint64(23600) - << 0 - << 0 - << 0 - << 0 - << QSize(640, 480); - QTest::newRow("video content") - << QUrl(QString::fromLatin1("http:://test.com/test.mp4")) - << QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.mp4"))) - << QString::fromLatin1("video/mp4") - << QString() - << QString::fromLatin1("aac") - << QString::fromLatin1("h264") - << qint64(36245851) - << 96000 - << 44000 - << 5 - << 750000 - << QSize(720, 576); - QTest::newRow("thumbnail") - << QUrl(QString::fromLatin1("file::///thumbs/test.png")) - << QNetworkRequest(QUrl(QString::fromLatin1("file::///thumbs/test.png"))) - << QString::fromLatin1("image/png") - << QString() - << QString() - << QString() - << qint64(2360) - << 0 - << 0 - << 0 - << 0 - << QSize(128, 128); -} - -void tst_QMediaResource::construct() -{ - QFETCH(QUrl, url); - QFETCH(QNetworkRequest, request); - QFETCH(QString, mimeType); - QFETCH(QString, language); - QFETCH(QString, audioCodec); - QFETCH(QString, videoCodec); - QFETCH(qint64, dataSize); - QFETCH(int, audioBitRate); - QFETCH(int, sampleRate); - QFETCH(int, channelCount); - QFETCH(int, videoBitRate); - QFETCH(QSize, resolution); - - { - QMediaResource resource(url); - - QCOMPARE(resource.isNull(), false); - QCOMPARE(resource.url(), url); - QCOMPARE(resource.mimeType(), QString()); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); - } - { - QMediaResource resource(url, mimeType); - - QCOMPARE(resource.isNull(), false); - QCOMPARE(resource.url(), url); - QCOMPARE(resource.request(), request); - QCOMPARE(resource.mimeType(), mimeType); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); - - resource.setLanguage(language); - resource.setAudioCodec(audioCodec); - resource.setVideoCodec(videoCodec); - resource.setDataSize(dataSize); - resource.setAudioBitRate(audioBitRate); - resource.setSampleRate(sampleRate); - resource.setChannelCount(channelCount); - resource.setVideoBitRate(videoBitRate); - resource.setResolution(resolution); - - QCOMPARE(resource.language(), language); - QCOMPARE(resource.audioCodec(), audioCodec); - QCOMPARE(resource.videoCodec(), videoCodec); - QCOMPARE(resource.dataSize(), dataSize); - QCOMPARE(resource.audioBitRate(), audioBitRate); - QCOMPARE(resource.sampleRate(), sampleRate); - QCOMPARE(resource.channelCount(), channelCount); - QCOMPARE(resource.videoBitRate(), videoBitRate); - QCOMPARE(resource.resolution(), resolution); - } - { - QMediaResource resource(request, mimeType); - - QCOMPARE(resource.isNull(), false); - QCOMPARE(resource.url(), url); - QCOMPARE(resource.request(), request); - QCOMPARE(resource.mimeType(), mimeType); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); - - resource.setLanguage(language); - resource.setAudioCodec(audioCodec); - resource.setVideoCodec(videoCodec); - resource.setDataSize(dataSize); - resource.setAudioBitRate(audioBitRate); - resource.setSampleRate(sampleRate); - resource.setChannelCount(channelCount); - resource.setVideoBitRate(videoBitRate); - resource.setResolution(resolution); - - QCOMPARE(resource.language(), language); - QCOMPARE(resource.audioCodec(), audioCodec); - QCOMPARE(resource.videoCodec(), videoCodec); - QCOMPARE(resource.dataSize(), dataSize); - QCOMPARE(resource.audioBitRate(), audioBitRate); - QCOMPARE(resource.sampleRate(), sampleRate); - QCOMPARE(resource.channelCount(), channelCount); - QCOMPARE(resource.videoBitRate(), videoBitRate); - QCOMPARE(resource.resolution(), resolution); - } -} - -void tst_QMediaResource::setResolution() -{ - QMediaResource resource( - QUrl(QString::fromLatin1("file::///thumbs/test.png")), - QString::fromLatin1("image/png")); - - QCOMPARE(resource.resolution(), QSize()); - - resource.setResolution(QSize(120, 80)); - QCOMPARE(resource.resolution(), QSize(120, 80)); - - resource.setResolution(QSize(-1, 23)); - QCOMPARE(resource.resolution(), QSize(-1, 23)); - - resource.setResolution(QSize(-43, 34)); - QCOMPARE(resource.resolution(), QSize(-43, 34)); - - resource.setResolution(QSize(64, -1)); - QCOMPARE(resource.resolution(), QSize(64, -1)); - - resource.setResolution(QSize(64, -83)); - QCOMPARE(resource.resolution(), QSize(64, -83)); - - resource.setResolution(QSize(-12, -83)); - QCOMPARE(resource.resolution(), QSize(-12, -83)); - - resource.setResolution(QSize()); - QCOMPARE(resource.resolution(), QSize(-1, -1)); - - resource.setResolution(120, 80); - QCOMPARE(resource.resolution(), QSize(120, 80)); - - resource.setResolution(-1, 23); - QCOMPARE(resource.resolution(), QSize(-1, 23)); - - resource.setResolution(-43, 34); - QCOMPARE(resource.resolution(), QSize(-43, 34)); - - resource.setResolution(64, -1); - QCOMPARE(resource.resolution(), QSize(64, -1)); - - resource.setResolution(64, -83); - QCOMPARE(resource.resolution(), QSize(64, -83)); - - resource.setResolution(-12, -83); - QCOMPARE(resource.resolution(), QSize(-12, -83)); - - resource.setResolution(-1, -1); - QCOMPARE(resource.resolution(), QSize()); -} - -void tst_QMediaResource::equality() -{ - QMediaResource resource1( - QUrl(QString::fromLatin1("http://test.com/test.mp4")), - QString::fromLatin1("video/mp4")); - QMediaResource resource2( - QUrl(QString::fromLatin1("http://test.com/test.mp4")), - QString::fromLatin1("video/mp4")); - QMediaResource resource3( - QUrl(QString::fromLatin1("file:///thumbs/test.jpg"))); - QMediaResource resource4( - QUrl(QString::fromLatin1("file:///thumbs/test.jpg"))); - QMediaResource resource5( - QUrl(QString::fromLatin1("http://test.com/test.mp3")), - QString::fromLatin1("audio/mpeg")); - - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - QCOMPARE(resource3 == resource4, true); - QCOMPARE(resource3 != resource4, false); - - QCOMPARE(resource1 == resource3, false); - QCOMPARE(resource1 != resource3, true); - - QCOMPARE(resource1 == resource5, false); - QCOMPARE(resource1 != resource5, true); - - resource1.setAudioCodec(QString::fromLatin1("mp3")); - resource2.setAudioCodec(QString::fromLatin1("aac")); - - // Not equal differing audio codecs. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource1.setAudioCodec(QString::fromLatin1("aac")); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setVideoCodec(QString()); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setVideoCodec(QString::fromLatin1("h264")); - - // Not equal differing video codecs. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setVideoCodec(QString::fromLatin1("h264")); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource2.setDataSize(0); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setDataSize(546423); - - // Not equal differing video codecs. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setDataSize(546423); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setAudioBitRate(96000); - resource1.setSampleRate(48000); - resource2.setSampleRate(44100); - resource1.setChannelCount(0); - resource1.setVideoBitRate(900000); - resource2.setLanguage(QString::fromLatin1("eng")); - - // Not equal, audio bit rate, sample rate, video bit rate, and - // language. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setAudioBitRate(96000); - resource1.setSampleRate(44100); - - // Not equal, differing video bit rate, and language. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setVideoBitRate(900000); - resource1.setLanguage(QString::fromLatin1("eng")); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setResolution(QSize()); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource2.setResolution(-1, -1); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setResolution(QSize(-640, -480)); - - // Not equal, differing resolution. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - resource1.setResolution(QSize(640, 480)); - resource2.setResolution(QSize(800, 600)); - - // Not equal, differing resolution. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource1.setResolution(800, 600); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); -} - -void tst_QMediaResource::copy() -{ - const QUrl url(QString::fromLatin1("http://test.com/test.mp4")); - const QString mimeType(QLatin1String("video/mp4")); - const QString amrCodec(QLatin1String("amr")); - const QString mp3Codec(QLatin1String("mp3")); - const QString aacCodec(QLatin1String("aac")); - const QString h264Codec(QLatin1String("h264")); - - QMediaResource original(url, mimeType); - original.setAudioCodec(amrCodec); - - QMediaResource copy(original); - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - QCOMPARE(copy.audioCodec(), amrCodec); - - QCOMPARE(original == copy, true); - QCOMPARE(original != copy, false); - - original.setAudioCodec(mp3Codec); - - QCOMPARE(copy.audioCodec(), amrCodec); - QCOMPARE(original == copy, false); - QCOMPARE(original != copy, true); - - copy.setAudioCodec(aacCodec); - copy.setVideoCodec(h264Codec); - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - - QCOMPARE(original.audioCodec(), mp3Codec); -} - -void tst_QMediaResource::assign() -{ - const QUrl url(QString::fromLatin1("http://test.com/test.mp4")); - const QString mimeType(QLatin1String("video/mp4")); - const QString amrCodec(QLatin1String("amr")); - const QString mp3Codec(QLatin1String("mp3")); - const QString aacCodec(QLatin1String("aac")); - const QString h264Codec(QLatin1String("h264")); - - QMediaResource copy(QUrl(QString::fromLatin1("file:///thumbs/test.jpg"))); - - QMediaResource original(url, mimeType); - original.setAudioCodec(amrCodec); - - copy = original; - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - QCOMPARE(copy.audioCodec(), amrCodec); - - QCOMPARE(original == copy, true); - QCOMPARE(original != copy, false); - - original.setAudioCodec(mp3Codec); - - QCOMPARE(copy.audioCodec(), amrCodec); - QCOMPARE(original == copy, false); - QCOMPARE(original != copy, true); - - copy.setAudioCodec(aacCodec); - copy.setVideoCodec(h264Codec); - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - - QCOMPARE(original.audioCodec(), mp3Codec); -} - -QTEST_MAIN(tst_QMediaResource) - -#include "tst_qmediaresource.moc" diff --git a/tests/auto/qmediaservice/qmediaservice.pro b/tests/auto/qmediaservice/qmediaservice.pro deleted file mode 100644 index 8acd03a..0000000 --- a/tests/auto/qmediaservice/qmediaservice.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaservice.cpp - -QT = core gui mediaservices - diff --git a/tests/auto/qmediaservice/tst_qmediaservice.cpp b/tests/auto/qmediaservice/tst_qmediaservice.cpp deleted file mode 100644 index a544e77..0000000 --- a/tests/auto/qmediaservice/tst_qmediaservice.cpp +++ /dev/null @@ -1,219 +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 - -class QtTestMediaService; - - -class tst_QMediaService : public QObject -{ - Q_OBJECT -private slots: - void initTestCase(); - - void control_iid(); - void control(); -}; - - -class QtTestMediaControlA : public QMediaControl -{ - Q_OBJECT -}; - - -#define QtTestMediaControlA_iid "com.nokia.QtTestMediaControlA" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlA, QtTestMediaControlA_iid) -QT_END_NAMESPACE - - -class QtTestMediaControlB : public QMediaControl -{ - Q_OBJECT -}; - -#define QtTestMediaControlB_iid "com.nokia.QtTestMediaControlB" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlB, QtTestMediaControlB_iid) -QT_END_NAMESPACE - - -class QtTestMediaControlC : public QMediaControl -{ - Q_OBJECT -}; - -#define QtTestMediaControlC_iid "com.nokia.QtTestMediaControlC" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlC, QtTestMediaControlA_iid) // Yes A. -QT_END_NAMESPACE - -class QtTestMediaControlD : public QMediaControl -{ - Q_OBJECT -}; - -#define QtTestMediaControlD_iid "com.nokia.QtTestMediaControlD" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlD, QtTestMediaControlD_iid) -QT_END_NAMESPACE - -class QtTestMediaControlE : public QMediaControl -{ - Q_OBJECT -}; - -struct QtTestDevice -{ - QtTestDevice() {} - QtTestDevice(const QString &name, const QString &description, const QIcon &icon) - : name(name), description(description), icon(icon) - { - } - - QString name; - QString description; - QIcon icon; -}; - -class QtTestVideoDeviceControl : public QVideoDeviceControl -{ -public: - QtTestVideoDeviceControl(QObject *parent = 0) - : QVideoDeviceControl(parent) - , m_selectedDevice(-1) - , m_defaultDevice(-1) - { - } - - int deviceCount() const { return devices.count(); } - - QString deviceName(int index) const { return devices.value(index).name; } - QString deviceDescription(int index) const { return devices.value(index).description; } - QIcon deviceIcon(int index) const { return devices.value(index).icon; } - - int defaultDevice() const { return m_defaultDevice; } - void setDefaultDevice(int index) { m_defaultDevice = index; } - - int selectedDevice() const { return m_selectedDevice; } - void setSelectedDevice(int index) - { - emit selectedDeviceChanged(m_selectedDevice = index); - emit selectedDeviceChanged(devices.value(index).name); - } - - QList devices; - -private: - int m_selectedDevice; - int m_defaultDevice; -}; - -class QtTestMediaService : public QMediaService -{ - Q_OBJECT -public: - QtTestMediaService() - : QMediaService(0) - , hasDeviceControls(false) - { - } - - QMediaControl* control(const char *name) const - { - if (strcmp(name, QtTestMediaControlA_iid) == 0) - return const_cast(&controlA); - else if (strcmp(name, QtTestMediaControlB_iid) == 0) - return const_cast(&controlB); - else if (strcmp(name, QtTestMediaControlC_iid) == 0) - return const_cast(&controlC); - else if (hasDeviceControls && strcmp(name, QVideoDeviceControl_iid) == 0) - return const_cast(&videoDeviceControl); - else - return 0; - } - - using QMediaService::control; - - QtTestMediaControlA controlA; - QtTestMediaControlB controlB; - QtTestMediaControlC controlC; - QtTestVideoDeviceControl videoDeviceControl; - bool hasDeviceControls; -}; - -void tst_QMediaService::initTestCase() -{ -} - -void tst_QMediaService::control_iid() -{ - const char *nullString = 0; - - // Default implementation. - QCOMPARE(qmediacontrol_iid(), nullString); - - // Partial template. - QVERIFY(qstrcmp(qmediacontrol_iid(), QtTestMediaControlA_iid) == 0); -} - -void tst_QMediaService::control() -{ - QtTestMediaService service; - - QCOMPARE(service.control(), &service.controlA); - QCOMPARE(service.control(), &service.controlB); - QVERIFY(!service.control()); // Faulty implementation returns A. - QVERIFY(!service.control()); // No control of that type. -} - -QTEST_MAIN(tst_QMediaService) - -#include "tst_qmediaservice.moc" diff --git a/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro b/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro deleted file mode 100644 index 69b3864..0000000 --- a/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaserviceprovider.cpp - -QT = core gui mediaservices - diff --git a/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp b/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp deleted file mode 100644 index 64abedb..0000000 --- a/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp +++ /dev/null @@ -1,481 +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 -#include - -class MockMediaService : public QMediaService -{ - Q_OBJECT -public: - MockMediaService(const QString& name, QObject *parent = 0) : QMediaService(parent) - { setObjectName(name); } - ~MockMediaService() {} - - QMediaControl* control(const char *) const {return 0;} -}; - -class MockServicePlugin1 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedFormatsInterface, - public QMediaServiceSupportedDevicesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedFormatsInterface) - Q_INTERFACES(QMediaServiceSupportedDevicesInterface) -public: - QStringList keys() const - { - return QStringList() << - QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin1"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const - { - if (codecs.contains(QLatin1String("mpeg4"))) - return QtMediaServices::NotSupported; - - if (mimeType == "audio/ogg") { - return QtMediaServices::ProbablySupported; - } - - return QtMediaServices::MaybeSupported; - } - - QStringList supportedMimeTypes() const - { - return QStringList("audio/ogg"); - } - - QList devices(const QByteArray &service) const - { - Q_UNUSED(service); - QList res; - return res; - } - - QString deviceDescription(const QByteArray &service, const QByteArray &device) - { - if (devices(service).contains(device)) - return QString(device)+" description"; - else - return QString(); - } -}; - -class MockServicePlugin2 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedFormatsInterface, - public QMediaServiceFeaturesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedFormatsInterface) - Q_INTERFACES(QMediaServiceFeaturesInterface) -public: - QStringList keys() const - { - return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin2"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const - { - Q_UNUSED(codecs); - - if (mimeType == "audio/wav") - return QtMediaServices::PreferredService; - - return QtMediaServices::NotSupported; - } - - QStringList supportedMimeTypes() const - { - return QStringList("audio/wav"); - } - - QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const - { - if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)) - return QMediaServiceProviderHint::LowLatencyPlayback; - else - return 0; - } -}; - - -class MockServicePlugin3 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedDevicesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedDevicesInterface) -public: - QStringList keys() const - { - return QStringList() << - QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin3"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QList devices(const QByteArray &service) const - { - Q_UNUSED(service); - QList res; - return res; - } - - QString deviceDescription(const QByteArray &service, const QByteArray &device) - { - if (devices(service).contains(device)) - return QString(device)+" description"; - else - return QString(); - } -}; - -class MockServicePlugin4 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedFormatsInterface, - public QMediaServiceFeaturesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedFormatsInterface) - Q_INTERFACES(QMediaServiceFeaturesInterface) -public: - QStringList keys() const - { - return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin4"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const - { - if (codecs.contains(QLatin1String("jpeg2000"))) - return QtMediaServices::NotSupported; - - if (supportedMimeTypes().contains(mimeType)) - return QtMediaServices::ProbablySupported; - - return QtMediaServices::MaybeSupported; - } - - QStringList supportedMimeTypes() const - { - return QStringList() << "video/mp4" << "video/quicktime"; - } - - QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const - { - if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)) - return QMediaServiceProviderHint::StreamPlayback; - else - return 0; - } -}; - - - -class MockMediaServiceProvider : public QMediaServiceProvider -{ - QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &) - { - Q_UNUSED(type); - return 0; - } - - void releaseService(QMediaService *service) - { - Q_UNUSED(service); - } -}; - - -class tst_QMediaServiceProvider : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - -private slots: - void testDefaultProviderAvailable(); - void testObtainService(); - void testHasSupport(); - void testSupportedMimeTypes(); - void testProviderHints(); - -private: - QObjectList plugins; -}; - -void tst_QMediaServiceProvider::initTestCase() -{ - plugins << new MockServicePlugin1; - plugins << new MockServicePlugin2; - plugins << new MockServicePlugin3; - plugins << new MockServicePlugin4; - - QMediaPluginLoader::setStaticPlugins(QLatin1String("/mediaservices"), plugins); -} - -void tst_QMediaServiceProvider::testDefaultProviderAvailable() -{ - // Must always be a default provider available - QVERIFY(QMediaServiceProvider::defaultServiceProvider() != 0); -} - -void tst_QMediaServiceProvider::testObtainService() -{ - QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); - - if (provider == 0) - QSKIP("No default provider", SkipSingle); - - QMediaService *service = 0; - - // Player - service = provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER); - QVERIFY(service != 0); - provider->releaseService(service); -} - -void tst_QMediaServiceProvider::testHasSupport() -{ - MockMediaServiceProvider mockProvider; - QCOMPARE(mockProvider.hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), - QtMediaServices::MaybeSupported); - - QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); - - if (provider == 0) - QSKIP("No default provider", SkipSingle); - - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), - QtMediaServices::MaybeSupported); - - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/ogg", QStringList()), - QtMediaServices::ProbablySupported); - - //while the service returns PreferredService, provider should return ProbablySupported - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/wav", QStringList()), - QtMediaServices::ProbablySupported); - - //even while all the plugins with "hasSupport" returned NotSupported, - //MockServicePlugin3 has no "hasSupport" interface, so MaybeSupported - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/avi", - QStringList() << "mpeg4"), - QtMediaServices::MaybeSupported); - - QCOMPARE(provider->hasSupport(QByteArray("non existing service"), "video/ogv", QStringList()), - QtMediaServices::NotSupported); - - QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QtMediaServices::MaybeSupported); - QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QtMediaServices::ProbablySupported); - QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QtMediaServices::ProbablySupported); - - //test low latency flag support - QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::LowLatency), - QtMediaServices::ProbablySupported); - //plugin1 probably supports audio/ogg, it checked because it doesn't provide features iface - QCOMPARE(QMediaPlayer::hasSupport("audio/ogg", QStringList(), QMediaPlayer::LowLatency), - QtMediaServices::ProbablySupported); - //Plugin4 is not checked here, sine it's known not support low latency - QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::LowLatency), - QtMediaServices::MaybeSupported); - - //test streaming flag support - QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::StreamPlayback), - QtMediaServices::ProbablySupported); - //Plugin2 is not checked here, sine it's known not support streaming - QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::StreamPlayback), - QtMediaServices::MaybeSupported); - - //ensure the correct media player plugin is choosen for mime type - QMediaPlayer simplePlayer(0, QMediaPlayer::LowLatency); - QCOMPARE(simplePlayer.service()->objectName(), QLatin1String("MockServicePlugin2")); - - QMediaPlayer mediaPlayer; - QVERIFY(mediaPlayer.service()->objectName() != QLatin1String("MockServicePlugin2")); - - QMediaPlayer streamPlayer(0, QMediaPlayer::StreamPlayback); - QCOMPARE(streamPlayer.service()->objectName(), QLatin1String("MockServicePlugin4")); -} - -void tst_QMediaServiceProvider::testSupportedMimeTypes() -{ - QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); - - if (provider == 0) - QSKIP("No default provider", SkipSingle); - - QVERIFY(provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/ogg")); - QVERIFY(!provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/mp3")); -} - -void tst_QMediaServiceProvider::testProviderHints() -{ - { - QMediaServiceProviderHint hint; - QVERIFY(hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::Null); - QVERIFY(hint.device().isEmpty()); - QVERIFY(hint.mimeType().isEmpty()); - QVERIFY(hint.codecs().isEmpty()); - QCOMPARE(hint.features(), 0); - } - - { - QByteArray deviceName(QByteArray("testDevice")); - QMediaServiceProviderHint hint(deviceName); - QVERIFY(!hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::Device); - QCOMPARE(hint.device(), deviceName); - QVERIFY(hint.mimeType().isEmpty()); - QVERIFY(hint.codecs().isEmpty()); - QCOMPARE(hint.features(), 0); - } - - { - QMediaServiceProviderHint hint(QMediaServiceProviderHint::LowLatencyPlayback); - QVERIFY(!hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures); - QVERIFY(hint.device().isEmpty()); - QVERIFY(hint.mimeType().isEmpty()); - QVERIFY(hint.codecs().isEmpty()); - QCOMPARE(hint.features(), QMediaServiceProviderHint::LowLatencyPlayback); - } - - { - QString mimeType(QLatin1String("video/ogg")); - QStringList codecs; - codecs << "theora" << "vorbis"; - - QMediaServiceProviderHint hint(mimeType,codecs); - QVERIFY(!hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::ContentType); - QVERIFY(hint.device().isEmpty()); - QCOMPARE(hint.mimeType(), mimeType); - QCOMPARE(hint.codecs(), codecs); - - QMediaServiceProviderHint hint2(hint); - - QVERIFY(!hint2.isNull()); - QCOMPARE(hint2.type(), QMediaServiceProviderHint::ContentType); - QVERIFY(hint2.device().isEmpty()); - QCOMPARE(hint2.mimeType(), mimeType); - QCOMPARE(hint2.codecs(), codecs); - - QMediaServiceProviderHint hint3; - QVERIFY(hint3.isNull()); - hint3 = hint; - QVERIFY(!hint3.isNull()); - QCOMPARE(hint3.type(), QMediaServiceProviderHint::ContentType); - QVERIFY(hint3.device().isEmpty()); - QCOMPARE(hint3.mimeType(), mimeType); - QCOMPARE(hint3.codecs(), codecs); - - QCOMPARE(hint, hint2); - QCOMPARE(hint3, hint2); - - QMediaServiceProviderHint hint4(mimeType,codecs); - QCOMPARE(hint, hint4); - - QMediaServiceProviderHint hint5(mimeType,QStringList()); - QVERIFY(hint != hint5); - } -} - -QTEST_MAIN(tst_QMediaServiceProvider) - -#include "tst_qmediaserviceprovider.moc" diff --git a/tests/auto/qmediatimerange/qmediatimerange.pro b/tests/auto/qmediatimerange/qmediatimerange.pro deleted file mode 100644 index c5e74ce..0000000 --- a/tests/auto/qmediatimerange/qmediatimerange.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediatimerange.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediatimerange/tst_qmediatimerange.cpp b/tests/auto/qmediatimerange/tst_qmediatimerange.cpp deleted file mode 100644 index a21abe2..0000000 --- a/tests/auto/qmediatimerange/tst_qmediatimerange.cpp +++ /dev/null @@ -1,735 +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 - -class tst_QMediaTimeRange: public QObject -{ - Q_OBJECT - -public slots: - -private slots: - void testCtor(); - void testGetters(); - void testAssignment(); - void testNormalize(); - void testTranslated(); - void testEarliestLatest(); - void testContains(); - void testAddInterval(); - void testAddTimeRange(); - void testRemoveInterval(); - void testRemoveTimeRange(); - void testClear(); - void testComparisons(); - void testArithmetic(); -}; - -void tst_QMediaTimeRange::testCtor() -{ - // Default Ctor - QMediaTimeRange a; - QVERIFY(a.isEmpty()); - - // (qint, qint) Ctor - QMediaTimeRange b(10, 20); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Interval Ctor - QMediaTimeRange c(QMediaTimeInterval(30, 40)); - - QVERIFY(!c.isEmpty()); - QVERIFY(c.isContinuous()); - QVERIFY(c.earliestTime() == 30); - QVERIFY(c.latestTime() == 40); - - // Abnormal Interval Ctor - QMediaTimeRange d(QMediaTimeInterval(20, 10)); - - QVERIFY(d.isEmpty()); - - // Copy Ctor - QMediaTimeRange e(b); - - QVERIFY(!e.isEmpty()); - QVERIFY(e.isContinuous()); - QVERIFY(e.earliestTime() == 10); - QVERIFY(e.latestTime() == 20); -} - -void tst_QMediaTimeRange::testGetters() -{ - QMediaTimeRange x; - - // isEmpty - QVERIFY(x.isEmpty()); - - x.addInterval(10, 20); - - // isEmpty + isContinuous - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - - x.addInterval(30, 40); - - // isEmpty + isContinuous + intervals + start + end - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 20); - QVERIFY(x.intervals()[1].start() == 30); - QVERIFY(x.intervals()[1].end() == 40); -} - -void tst_QMediaTimeRange::testAssignment() -{ - QMediaTimeRange x; - - // Range Assignment - x = QMediaTimeRange(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 20); - - // Interval Assignment - x = QMediaTimeInterval(30, 40); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 40); - - // Shared Data Check - QMediaTimeRange y; - - y = x; - y.addInterval(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 40); -} - -void tst_QMediaTimeRange::testNormalize() -{ - QMediaTimeInterval x(20, 10); - - QVERIFY(!x.isNormal()); - - x = x.normalized(); - - QVERIFY(x.isNormal()); - QVERIFY(x.start() == 10); - QVERIFY(x.end() == 20); -} - -void tst_QMediaTimeRange::testTranslated() -{ - QMediaTimeInterval x(10, 20); - x = x.translated(10); - - QVERIFY(x.start() == 20); - QVERIFY(x.end() == 30); -} - -void tst_QMediaTimeRange::testEarliestLatest() -{ - // Test over a single interval - QMediaTimeRange x(30, 40); - - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 40); - - // Test over multiple intervals - x.addInterval(50, 60); - - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 60); -} - -void tst_QMediaTimeRange::testContains() -{ - // Test over a single interval - QMediaTimeRange x(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.contains(15)); - QVERIFY(x.contains(10)); - QVERIFY(x.contains(20)); - QVERIFY(!x.contains(25)); - - // Test over multiple intervals - x.addInterval(40, 50); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.contains(15)); - QVERIFY(x.contains(45)); - QVERIFY(!x.contains(30)); - - // Test over a concrete interval - QMediaTimeInterval y(10, 20); - QVERIFY(y.contains(15)); - QVERIFY(y.contains(10)); - QVERIFY(y.contains(20)); - QVERIFY(!y.contains(25)); -} - -void tst_QMediaTimeRange::testAddInterval() -{ - // All intervals Overlap - QMediaTimeRange x; - x.addInterval(10, 40); - x.addInterval(30, 50); - x.addInterval(20, 60); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 60); - - // 1 adjacent interval, 1 encompassed interval - x = QMediaTimeRange(); - x.addInterval(10, 40); - x.addInterval(20, 30); - x.addInterval(41, 50); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 50); - - // 1 overlapping interval, 1 disjoint interval - x = QMediaTimeRange(); - x.addInterval(10, 30); - x.addInterval(20, 40); - x.addInterval(50, 60); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 40); - QVERIFY(x.intervals()[1].start() == 50); - QVERIFY(x.intervals()[1].end() == 60); - - // Identical Add - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 20); - - // Multi-Merge - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.addInterval(50, 60); - x.addInterval(15, 55); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 60); - - // Interval Parameter - All intervals Overlap - x = QMediaTimeRange(); - x.addInterval(QMediaTimeInterval(10, 40)); - x.addInterval(QMediaTimeInterval(30, 50)); - x.addInterval(QMediaTimeInterval(20, 60)); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 60); - - // Interval Parameter - Abnormal Interval - x = QMediaTimeRange(); - x.addInterval(QMediaTimeInterval(20, 10)); - - QVERIFY(x.isEmpty()); -} - -void tst_QMediaTimeRange::testAddTimeRange() -{ - // Add Time Range uses Add Interval internally, - // so in this test the focus is on combinations of number - // of intervals added, rather than the different types of - // merges which can occur. - QMediaTimeRange a, b; - - // Add Single into Single - a = QMediaTimeRange(10, 30); - b = QMediaTimeRange(20, 40); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 40); - - // Add Multiple into Single - a = QMediaTimeRange(); - a.addInterval(10, 30); - a.addInterval(40, 60); - - b = QMediaTimeRange(20, 50); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 60); - - // Add Single into Multiple - a = QMediaTimeRange(20, 50); - - b = QMediaTimeRange(); - b.addInterval(10, 30); - b.addInterval(40, 60); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 60); - - // Add Multiple into Multiple - a = QMediaTimeRange(); - a.addInterval(10, 30); - a.addInterval(40, 70); - a.addInterval(80, 100); - - b = QMediaTimeRange(); - b.addInterval(20, 50); - b.addInterval(60, 90); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 100); - - // Add Nothing to Single - a = QMediaTimeRange(); - b = QMediaTimeRange(10, 20); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Add Single to Nothing - a = QMediaTimeRange(10, 20); - b = QMediaTimeRange(); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Add Nothing to Nothing - a = QMediaTimeRange(); - b = QMediaTimeRange(); - - b.addTimeRange(a); - - QVERIFY(b.isEmpty()); -} - -void tst_QMediaTimeRange::testRemoveInterval() -{ - // Removing an interval, causing a split - QMediaTimeRange x; - x.addInterval(10, 50); - x.removeInterval(20, 40); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 19); - QVERIFY(x.intervals()[1].start() == 41); - QVERIFY(x.intervals()[1].end() == 50); - - // Removing an interval, causing a deletion - x = QMediaTimeRange(); - x.addInterval(20, 30); - x.removeInterval(10, 40); - - QVERIFY(x.isEmpty()); - - // Removing an interval, causing a tail trim - x = QMediaTimeRange(); - x.addInterval(20, 40); - x.removeInterval(30, 50); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 20); - QVERIFY(x.latestTime() == 29); - - // Removing an interval, causing a head trim - x = QMediaTimeRange(); - x.addInterval(20, 40); - x.removeInterval(10, 30); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 31); - QVERIFY(x.latestTime() == 40); - - // Identical Remove - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.removeInterval(10, 20); - - QVERIFY(x.isEmpty()); - - // Multi-Trim - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.removeInterval(15, 35); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 14); - QVERIFY(x.intervals()[1].start() == 36); - QVERIFY(x.intervals()[1].end() == 40); - - // Multi-Delete - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.addInterval(50, 60); - x.removeInterval(10, 60); - - QVERIFY(x.isEmpty()); - - // Interval Parameter - Removing an interval, causing a split - x = QMediaTimeRange(); - x.addInterval(10, 50); - x.removeInterval(QMediaTimeInterval(20, 40)); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 19); - QVERIFY(x.intervals()[1].start() == 41); - QVERIFY(x.intervals()[1].end() == 50); - - // Interval Parameter - Abnormal Interval - x = QMediaTimeRange(); - x.addInterval(10, 40); - x.removeInterval(QMediaTimeInterval(30, 20)); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 40); -} - -void tst_QMediaTimeRange::testRemoveTimeRange() -{ - // Remove Time Range uses Remove Interval internally, - // so in this test the focus is on combinations of number - // of intervals removed, rather than the different types of - // deletions which can occur. - QMediaTimeRange a, b; - - // Remove Single from Single - a = QMediaTimeRange(10, 30); - b = QMediaTimeRange(20, 40); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 31); - QVERIFY(b.latestTime() == 40); - - // Remove Multiple from Single - a = QMediaTimeRange(); - a.addInterval(10, 30); - a.addInterval(40, 60); - - b = QMediaTimeRange(20, 50); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 31); - QVERIFY(b.latestTime() == 39); - - // Remove Single from Multiple - a = QMediaTimeRange(20, 50); - - b = QMediaTimeRange(); - b.addInterval(10, 30); - b.addInterval(40, 60); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(!b.isContinuous()); - QVERIFY(b.intervals().count() == 2); - QVERIFY(b.intervals()[0].start() == 10); - QVERIFY(b.intervals()[0].end() == 19); - QVERIFY(b.intervals()[1].start() == 51); - QVERIFY(b.intervals()[1].end() == 60); - - // Remove Multiple from Multiple - a = QMediaTimeRange(); - a.addInterval(20, 50); - a.addInterval(50, 90); - - - b = QMediaTimeRange(); - b.addInterval(10, 30); - b.addInterval(40, 70); - b.addInterval(80, 100); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(!b.isContinuous()); - QVERIFY(b.intervals().count() == 2); - QVERIFY(b.intervals()[0].start() == 10); - QVERIFY(b.intervals()[0].end() == 19); - QVERIFY(b.intervals()[1].start() == 91); - QVERIFY(b.intervals()[1].end() == 100); - - // Remove Nothing from Single - a = QMediaTimeRange(); - b = QMediaTimeRange(10, 20); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Remove Single from Nothing - a = QMediaTimeRange(10, 20); - b = QMediaTimeRange(); - - b.removeTimeRange(a); - - QVERIFY(b.isEmpty()); - - // Remove Nothing from Nothing - a = QMediaTimeRange(); - b = QMediaTimeRange(); - - b.removeTimeRange(a); - - QVERIFY(b.isEmpty()); -} - -void tst_QMediaTimeRange::testClear() -{ - QMediaTimeRange x; - - // Clear Nothing - x.clear(); - - QVERIFY(x.isEmpty()); - - // Clear Single - x = QMediaTimeRange(10, 20); - x.clear(); - - QVERIFY(x.isEmpty()); - - // Clear Multiple - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.clear(); - - QVERIFY(x.isEmpty()); -} - -void tst_QMediaTimeRange::testComparisons() -{ - // Interval equality - QVERIFY(QMediaTimeInterval(10, 20) == QMediaTimeInterval(10, 20)); - QVERIFY(QMediaTimeInterval(10, 20) != QMediaTimeInterval(10, 30)); - QVERIFY(!(QMediaTimeInterval(10, 20) != QMediaTimeInterval(10, 20))); - QVERIFY(!(QMediaTimeInterval(10, 20) == QMediaTimeInterval(10, 30))); - - // Time range equality - Single Interval - QMediaTimeRange a(10, 20), b(20, 30), c(10, 20); - - QVERIFY(a == c); - QVERIFY(!(a == b)); - QVERIFY(a != b); - QVERIFY(!(a != c)); - - // Time Range Equality - Multiple Intervals - QMediaTimeRange x, y, z; - - x.addInterval(10, 20); - x.addInterval(30, 40); - x.addInterval(50, 60); - - y.addInterval(10, 20); - y.addInterval(35, 45); - y.addInterval(50, 60); - - z.addInterval(10, 20); - z.addInterval(30, 40); - z.addInterval(50, 60); - - QVERIFY(x == z); - QVERIFY(!(x == y)); - QVERIFY(x != y); - QVERIFY(!(x != z)); -} - -void tst_QMediaTimeRange::testArithmetic() -{ - QMediaTimeRange a(10, 20), b(20, 30); - - // Test += - a += b; - - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 30); - - // Test -= - a -= b; - - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 19); - - // Test += and -= on intervals - a -= QMediaTimeInterval(10, 20); - a += QMediaTimeInterval(40, 50); - - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 40); - QVERIFY(a.latestTime() == 50); - - // Test Interval + Interval - a = QMediaTimeInterval(10, 20) + QMediaTimeInterval(20, 30); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 30); - - // Test Range + Interval - a = a + QMediaTimeInterval(30, 40); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 40); - - // Test Interval + Range - a = QMediaTimeInterval(40, 50) + a; - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 50); - - // Test Range + Range - a = a + QMediaTimeRange(50, 60); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 60); - - // Test Range - Interval - a = a - QMediaTimeInterval(50, 60); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 49); - - // Test Range - Range - a = a - QMediaTimeRange(40, 50); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 39); - - // Test Interval - Range - b = QMediaTimeInterval(0, 20) - a; - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 0); - QVERIFY(b.latestTime() == 9); - - // Test Interval - Interval - a = QMediaTimeInterval(10, 20) - QMediaTimeInterval(15, 30); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 14); -} - -QTEST_MAIN(tst_QMediaTimeRange) - -#include "tst_qmediatimerange.moc" diff --git a/tests/auto/qsoundeffect/qsoundeffect.pro b/tests/auto/qsoundeffect/qsoundeffect.pro deleted file mode 100644 index 5344a16..0000000 --- a/tests/auto/qsoundeffect/qsoundeffect.pro +++ /dev/null @@ -1,20 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qsoundeffect.cpp - -QT = core multimedia mediaservices - -wince* { - deploy.sources += 4.wav - DEPLOYMENT = deploy - DEFINES += SRCDIR=\\\"\\\" - QT += gui -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} - -unix:!mac { - !contains(QT_CONFIG, pulseaudio) { - DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER - } -} diff --git a/tests/auto/qsoundeffect/tst_qsoundeffect.cpp b/tests/auto/qsoundeffect/tst_qsoundeffect.cpp deleted file mode 100644 index e76a4c5..0000000 --- a/tests/auto/qsoundeffect/tst_qsoundeffect.cpp +++ /dev/null @@ -1,144 +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 - - -class tst_QSoundEffect : public QObject -{ - Q_OBJECT -public: - tst_QSoundEffect(QObject* parent=0) : QObject(parent) {} - -private slots: - void initTestCase(); - void testSource(); - void testLooping(); - void testVolume(); - void testMuting(); - -private: - QSoundEffect* sound; -}; - -void tst_QSoundEffect::initTestCase() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - sound = new QSoundEffect; - - QVERIFY(sound->source().isEmpty()); - QVERIFY(sound->loops() == 1); - QVERIFY(sound->volume() == 100); - QVERIFY(sound->isMuted() == false); -#endif -} - -void tst_QSoundEffect::testSource() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(sourceChanged())); - - QUrl url = QUrl::fromLocalFile(QString("%1%2").arg(SRCDIR).arg("test.wav")); - sound->setSource(url); - - QCOMPARE(sound->source(),url); - QCOMPARE(readSignal.count(),1); - - QTestEventLoop::instance().enterLoop(1); - sound->play(); - - QTest::qWait(3000); -#endif -} - -void tst_QSoundEffect::testLooping() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(loopsChanged())); - - sound->setLoops(5); - QCOMPARE(sound->loops(),5); - - sound->play(); - - // test.wav is about 200ms, wait until it has finished playing 5 times - QTest::qWait(3000); -#endif -} - -void tst_QSoundEffect::testVolume() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(volumeChanged())); - - sound->setVolume(50); - QCOMPARE(sound->volume(),50); - - QTest::qWait(20); - QCOMPARE(readSignal.count(),1); -#endif -} - -void tst_QSoundEffect::testMuting() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(mutedChanged())); - - sound->setMuted(true); - QCOMPARE(sound->isMuted(),true); - - QTest::qWait(20); - QCOMPARE(readSignal.count(),1); - - delete sound; -#endif -} - -QTEST_MAIN(tst_QSoundEffect) - -#include "tst_qsoundeffect.moc" diff --git a/tests/auto/qvideowidget/qvideowidget.pro b/tests/auto/qvideowidget/qvideowidget.pro deleted file mode 100644 index 12686f3..0000000 --- a/tests/auto/qvideowidget/qvideowidget.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qvideowidget.cpp - -QT = core gui multimedia mediaservices - diff --git a/tests/auto/qvideowidget/tst_qvideowidget.cpp b/tests/auto/qvideowidget/tst_qvideowidget.cpp deleted file mode 100644 index 8a54789..0000000 --- a/tests/auto/qvideowidget/tst_qvideowidget.cpp +++ /dev/null @@ -1,1602 +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 -#include -#include -#include - -#include - - -class tst_QVideoWidget : public QObject -{ - Q_OBJECT -private slots: - void nullObject(); - void nullService(); - void nullOutputControl(); - void noOutputs(); - void serviceDestroyed(); - void objectDestroyed(); - void setMediaObject(); - - void showWindowControl(); - void aspectRatioWindowControl(); - void sizeHintWindowControl_data() { sizeHint_data(); } - void sizeHintWindowControl(); - void brightnessWindowControl_data() { color_data(); } - void brightnessWindowControl(); - void contrastWindowControl_data() { color_data(); } - void contrastWindowControl(); - void hueWindowControl_data() { color_data(); } - void hueWindowControl(); - void saturationWindowControl_data() { color_data(); } - void saturationWindowControl(); - - void showWidgetControl(); - void aspectRatioWidgetControl(); - void sizeHintWidgetControl_data() { sizeHint_data(); } - void sizeHintWidgetControl(); - void brightnessWidgetControl_data() { color_data(); } - void brightnessWidgetControl(); - void contrastWidgetControl_data() { color_data(); } - void contrastWidgetControl(); - void hueWidgetControl_data() { color_data(); } - void hueWidgetControl(); - void saturationWidgetControl_data() { color_data(); } - void saturationWidgetControl(); - - void showRendererControl(); - void aspectRatioRendererControl(); - void sizeHintRendererControl_data(); - void sizeHintRendererControl(); - void brightnessRendererControl_data() { color_data(); } - void brightnessRendererControl(); - void contrastRendererControl_data() { color_data(); } - void contrastRendererControl(); - void hueRendererControl_data() { color_data(); } - void hueRendererControl(); - void saturationRendererControl_data() { color_data(); } - void saturationRendererControl(); - - void paintRendererControl(); - -#ifndef Q_WS_X11 - void fullScreenWindowControl(); - void fullScreenWidgetControl(); - void fullScreenRendererControl(); -#endif - -private: - void sizeHint_data(); - void color_data(); -}; - -Q_DECLARE_METATYPE(Qt::AspectRatioMode) -Q_DECLARE_METATYPE(const uchar *) - -class QtTestOutputControl : public QVideoOutputControl -{ -public: - QtTestOutputControl() : m_output(NoOutput) {} - - QList availableOutputs() const { return m_outputs; } - void setAvailableOutputs(const QList outputs) { m_outputs = outputs; } - - Output output() const { return m_output; } - virtual void setOutput(Output output) { m_output = output; } - -private: - Output m_output; - QList m_outputs; -}; - -class QtTestWindowControl : public QVideoWindowControl -{ -public: - QtTestWindowControl() - : m_winId(0) - , m_repaintCount(0) - , m_brightness(0) - , m_contrast(0) - , m_saturation(0) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_fullScreen(0) - { - } - - WId winId() const { return m_winId; } - void setWinId(WId id) { m_winId = id; } - - QRect displayRect() const { return m_displayRect; } - void setDisplayRect(const QRect &rect) { m_displayRect = rect; } - - bool isFullScreen() const { return m_fullScreen; } - void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); } - - int repaintCount() const { return m_repaintCount; } - void setRepaintCount(int count) { m_repaintCount = count; } - void repaint() { ++m_repaintCount; } - - QSize nativeSize() const { return m_nativeSize; } - void setNativeSize(const QSize &size) { m_nativeSize = size; emit nativeSizeChanged(); } - - Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; } - void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; } - - int brightness() const { return m_brightness; } - void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); } - - int contrast() const { return m_contrast; } - void setContrast(int contrast) { emit contrastChanged(m_contrast = contrast); } - - int hue() const { return m_hue; } - void setHue(int hue) { emit hueChanged(m_hue = hue); } - - int saturation() const { return m_saturation; } - void setSaturation(int saturation) { emit saturationChanged(m_saturation = saturation); } - -private: - WId m_winId; - int m_repaintCount; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; - Qt::AspectRatioMode m_aspectRatioMode; - QRect m_displayRect; - QSize m_nativeSize; - bool m_fullScreen; -}; - -class QtTestWidgetControl : public QVideoWidgetControl -{ -public: - QtTestWidgetControl() - : m_brightness(1.0) - , m_contrast(1.0) - , m_hue(1.0) - , m_saturation(1.0) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_fullScreen(false) - { - } - - bool isFullScreen() const { return m_fullScreen; } - void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); } - - Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; } - void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; } - - int brightness() const { return m_brightness; } - void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); } - - int contrast() const { return m_contrast; } - void setContrast(int contrast) { emit contrastChanged(m_contrast = contrast); } - - int hue() const { return m_hue; } - void setHue(int hue) { emit hueChanged(m_hue = hue); } - - int saturation() const { return m_saturation; } - void setSaturation(int saturation) { emit saturationChanged(m_saturation = saturation); } - - void setSizeHint(const QSize &size) { m_widget.setSizeHint(size); } - - QWidget *videoWidget() { return &m_widget; } - -private: - class Widget : public QWidget - { - public: - QSize sizeHint() const { return m_sizeHint; } - void setSizeHint(const QSize &size) { m_sizeHint = size; updateGeometry(); } - private: - QSize m_sizeHint; - } m_widget; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; - Qt::AspectRatioMode m_aspectRatioMode; - QSize m_sizeHint; - bool m_fullScreen; -}; - -class QtTestRendererControl : public QVideoRendererControl -{ -public: - QtTestRendererControl() - : m_surface(0) - { - } - - QAbstractVideoSurface *surface() const { return m_surface; } - void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; } - -private: - QAbstractVideoSurface *m_surface; -}; - -class QtTestVideoService : public QMediaService -{ - Q_OBJECT -public: - QtTestVideoService( - QtTestOutputControl *output, - QtTestWindowControl *window, - QtTestWidgetControl *widget, - QtTestRendererControl *renderer) - : QMediaService(0) - , outputControl(output) - , windowControl(window) - , widgetControl(widget) - , rendererControl(renderer) - { - } - - ~QtTestVideoService() - { - delete outputControl; - delete windowControl; - delete widgetControl; - delete rendererControl; - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return outputControl; - else if (qstrcmp(name, QVideoWindowControl_iid) == 0) - return windowControl; - else if (qstrcmp(name, QVideoWidgetControl_iid) == 0) - return widgetControl; - else if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return rendererControl; - else - return 0; - } - - QtTestOutputControl *outputControl; - QtTestWindowControl *windowControl; - QtTestWidgetControl *widgetControl; - QtTestRendererControl *rendererControl; -}; - -class QtTestVideoObject : public QMediaObject -{ - Q_OBJECT -public: - QtTestVideoObject( - QtTestWindowControl *window, - QtTestWidgetControl *widget, - QtTestRendererControl *renderer): - QMediaObject(0, new QtTestVideoService(new QtTestOutputControl, window, widget, renderer)) - { - testService = qobject_cast(service()); - QList outputs; - - if (window) - outputs.append(QVideoOutputControl::WindowOutput); - if (widget) - outputs.append(QVideoOutputControl::WidgetOutput); - if (renderer) - outputs.append(QVideoOutputControl::RendererOutput); - - testService->outputControl->setAvailableOutputs(outputs); - } - - QtTestVideoObject(QtTestVideoService *service): - QMediaObject(0, service), - testService(service) - { - } - - ~QtTestVideoObject() - { - delete testService; - } - - QtTestVideoService *testService; -}; - -void tst_QVideoWidget::nullObject() -{ - QVideoWidget widget; - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - - { - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - QCOMPARE(spy.count(), 1); - - widget.setBrightness(-120); - QCOMPARE(widget.brightness(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } { - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(spy.count(), 1); - - widget.setContrast(-120); - QCOMPARE(widget.contrast(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } { - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(spy.count(), 1); - - widget.setHue(-120); - QCOMPARE(widget.hue(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } { - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); - QCOMPARE(spy.count(), 1); - - widget.setSaturation(-120); - QCOMPARE(widget.saturation(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } -} - -void tst_QVideoWidget::nullService() -{ - QtTestVideoObject object(0); - - QVideoWidget widget; - widget.setMediaObject(&object); - - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); -} - -void tst_QVideoWidget::nullOutputControl() -{ - QtTestVideoObject object(new QtTestVideoService(0, 0, 0, 0)); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); -} - -void tst_QVideoWidget::noOutputs() -{ - QtTestVideoObject object(0, 0, 0); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); -} - -void tst_QVideoWidget::serviceDestroyed() -{ - QtTestVideoObject object(new QtTestWindowControl, new QtTestWidgetControl, 0); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - widget.setBrightness(100); - widget.setContrast(100); - widget.setHue(100); - widget.setSaturation(100); - - delete object.testService; - object.testService = 0; - - QCOMPARE(widget.mediaObject(), static_cast(&object)); - - QCOMPARE(widget.brightness(), 100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(widget.saturation(), 100); - - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); -} - -void tst_QVideoWidget::objectDestroyed() -{ - QtTestVideoObject *object = new QtTestVideoObject( - new QtTestWindowControl, - new QtTestWidgetControl, - 0); - - QVideoWidget widget; - widget.setMediaObject(object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - widget.setBrightness(100); - widget.setContrast(100); - widget.setHue(100); - widget.setSaturation(100); - - // Delete the media object without deleting the service. - QtTestVideoService *service = object->testService; - object->testService = 0; - - delete object; - object = 0; - - QCOMPARE(widget.mediaObject(), static_cast(object)); - - QCOMPARE(service->outputControl->output(), QVideoOutputControl::NoOutput); - - QCOMPARE(widget.brightness(), 100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(widget.saturation(), 100); - - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); - - delete service; -} - -void tst_QVideoWidget::setMediaObject() -{ - QMediaObject *nullObject = 0; - QtTestVideoObject windowObject(new QtTestWindowControl, 0, 0); - QtTestVideoObject widgetObject(0, new QtTestWidgetControl, 0); - QtTestVideoObject rendererObject(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(widget.mediaObject(), nullObject); - QCOMPARE(windowObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - QCOMPARE(widgetObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - QCOMPARE(rendererObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.setMediaObject(&windowObject); - QCOMPARE(widget.mediaObject(), static_cast(&windowObject)); - QCOMPARE(windowObject.testService->outputControl->output(), QVideoOutputControl::WindowOutput); - QVERIFY(windowObject.testService->windowControl->winId() != 0); - - - widget.setMediaObject(&widgetObject); - QCOMPARE(widget.mediaObject(), static_cast(&widgetObject)); - QCOMPARE(widgetObject.testService->outputControl->output(), QVideoOutputControl::WidgetOutput); - - QCoreApplication::processEvents(QEventLoop::AllEvents); - QCOMPARE(widgetObject.testService->widgetControl->videoWidget()->isVisible(), true); - - QCOMPARE(windowObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.setMediaObject(&rendererObject); - QCOMPARE(widget.mediaObject(), static_cast(&rendererObject)); - QCOMPARE(rendererObject.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(rendererObject.testService->rendererControl->surface() != 0); - - QCOMPARE(widgetObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.setMediaObject(0); - QCOMPARE(widget.mediaObject(), nullObject); - - QCOMPARE(rendererObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); -} - -void tst_QVideoWidget::showWindowControl() -{ - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setNativeSize(QSize(240, 180)); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WindowOutput); - QVERIFY(object.testService->windowControl->winId() != 0); - - QVERIFY(object.testService->windowControl->repaintCount() > 0); - - widget.resize(640, 480); - QCOMPARE(object.testService->windowControl->displayRect(), QRect(0, 0, 640, 480)); - - widget.move(10, 10); - QCOMPARE(object.testService->windowControl->displayRect(), QRect(0, 0, 640, 480)); - - widget.hide(); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WindowOutput); -} - -void tst_QVideoWidget::showWidgetControl() -{ - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WidgetOutput); - QCOMPARE(object.testService->widgetControl->videoWidget()->isVisible(), true); - - widget.resize(640, 480); - - widget.move(10, 10); - - widget.hide(); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WidgetOutput); - QCOMPARE(object.testService->widgetControl->videoWidget()->isVisible(), false); -} - -void tst_QVideoWidget::showRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - widget.resize(640, 480); - - widget.move(10, 10); - - widget.hide(); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); -} - -void tst_QVideoWidget::aspectRatioWindowControl() -{ - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setAspectRatioMode(Qt::IgnoreAspectRatio); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test the control has been informed of the aspect ratio change, post show. - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio); - - // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::IgnoreAspectRatio); - - // Test an aspect ratio set while not visible is respected. - widget.hide(); - widget.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - widget.show(); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QVideoWidget::aspectRatioWidgetControl() -{ - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setAspectRatioMode(Qt::IgnoreAspectRatio); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test the control has been informed of the aspect ratio change, post show. - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio); - - // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::IgnoreAspectRatio); - - // Test an aspect ratio set while not visible is respected. - widget.hide(); - widget.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - widget.show(); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QVideoWidget::aspectRatioRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test the control has been informed of the aspect ratio change, post show. - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - - // Test an aspect ratio set while not visible is respected. - widget.hide(); - widget.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - widget.show(); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QVideoWidget::sizeHint_data() -{ - QTest::addColumn("size"); - - QTest::newRow("720x576") - << QSize(720, 576); -} - -void tst_QVideoWidget::sizeHintWindowControl() -{ - QFETCH(QSize, size); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QVERIFY(widget.sizeHint().isEmpty()); - - object.testService->windowControl->setNativeSize(size); - QCOMPARE(widget.sizeHint(), size); -} - -void tst_QVideoWidget::sizeHintWidgetControl() -{ - QFETCH(QSize, size); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QVERIFY(widget.sizeHint().isEmpty()); - - object.testService->widgetControl->setSizeHint(size); - QCOMPARE(widget.sizeHint(), size); -} - -void tst_QVideoWidget::sizeHintRendererControl_data() -{ - QTest::addColumn("frameSize"); - QTest::addColumn("viewport"); - QTest::addColumn("pixelAspectRatio"); - QTest::addColumn("expectedSize"); - - QTest::newRow("640x480") - << QSize(640, 480) - << QRect(0, 0, 640, 480) - << QSize(1, 1) - << QSize(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(1, 1) - << QSize(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport, 4:3") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(4, 3) - << QSize(853, 480); - -} - -void tst_QVideoWidget::sizeHintRendererControl() -{ - QFETCH(QSize, frameSize); - QFETCH(QRect, viewport); - QFETCH(QSize, pixelAspectRatio); - QFETCH(QSize, expectedSize); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); - format.setViewport(viewport); - format.setPixelAspectRatio(pixelAspectRatio); - - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QCOMPARE(widget.sizeHint(), expectedSize); -} - -#ifndef Q_WS_X11 - -void tst_QVideoWidget::fullScreenWindowControl() -{ - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - Qt::WindowFlags windowFlags = widget.windowFlags(); - - QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool))); - - // Test showing full screen with setFullScreen(true). - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toBool(), true); - - // Test returning to normal with setFullScreen(false). - widget.setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test showing full screen with showFullScreen(). - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 3); - QCOMPARE(spy.value(2).value(0).toBool(), true); - - // Test returning to normal with showNormal(). - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - QCOMPARE(spy.value(3).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false. - widget.setFullScreen(false); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - - // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true. - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - widget.setFullScreen(true); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - widget.showFullScreen(); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - - // Test if the window control exits full screen mode, the widget follows suit. - object.testService->windowControl->setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); - QCOMPARE(spy.value(5).value(0).toBool(), false); - - // Test if the window control enters full screen mode, the widget does nothing. - object.testService->windowControl->setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); -} - -void tst_QVideoWidget::fullScreenWidgetControl() -{ - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - Qt::WindowFlags windowFlags = widget.windowFlags(); - - QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool))); - - // Test showing full screen with setFullScreen(true). - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toBool(), true); - - // Test returning to normal with setFullScreen(false). - widget.setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test showing full screen with showFullScreen(). - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 3); - QCOMPARE(spy.value(2).value(0).toBool(), true); - - // Test returning to normal with showNormal(). - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - QCOMPARE(spy.value(3).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false. - widget.setFullScreen(false); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - widget.showNormal(); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - - // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true. - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - widget.setFullScreen(true); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - widget.showFullScreen(); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - - // Test if the window control exits full screen mode, the widget follows suit. - object.testService->widgetControl->setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); - QCOMPARE(spy.value(5).value(0).toBool(), false); - - // Test if the window control enters full screen mode, the widget does nothing. - object.testService->widgetControl->setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); -} - - -void tst_QVideoWidget::fullScreenRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - Qt::WindowFlags windowFlags = widget.windowFlags(); - - QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool))); - - // Test showing full screen with setFullScreen(true). - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toBool(), true); - - // Test returning to normal with setFullScreen(false). - widget.setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test showing full screen with showFullScreen(). - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 3); - QCOMPARE(spy.value(2).value(0).toBool(), true); - - // Test returning to normal with showNormal(). - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - QCOMPARE(spy.value(3).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false. - widget.setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - widget.showNormal(); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - - // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true. - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - widget.showFullScreen(); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); -} - -#endif - -void tst_QVideoWidget::color_data() -{ - QTest::addColumn("controlValue"); - QTest::addColumn("value"); - QTest::addColumn("expectedValue"); - - QTest::newRow("12") - << 0 - << 12 - << 12; - QTest::newRow("-56") - << 87 - << -56 - << -56; - QTest::newRow("100") - << 32 - << 100 - << 100; - QTest::newRow("1294") - << 0 - << 1294 - << 100; - QTest::newRow("-102") - << 34 - << -102 - << -100; -} - -void tst_QVideoWidget::brightnessWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setBrightness(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - // Test the video widget resets the controls starting brightness to the default. - QCOMPARE(widget.brightness(), 0); - - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - // Test the video widget sets the brightness value, bounded if necessary and emits a changed - // signal. - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->windowControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - // Test the changed signal isn't emitted if the value is unchanged. - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->windowControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - - // Test the changed signal is emitted if the brightness is changed internally. - object.testService->windowControl->setBrightness(controlValue); - QCOMPARE(widget.brightness(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::brightnessWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setBrightness(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(widget.brightness(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->widgetControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->widgetControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setBrightness(controlValue); - QCOMPARE(widget.brightness(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::brightnessRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -void tst_QVideoWidget::contrastWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setContrast(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(widget.contrast(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.contrast(), 0); - - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->windowControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->windowControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->windowControl->setContrast(controlValue); - QCOMPARE(widget.contrast(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::contrastWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setContrast(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.contrast(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.contrast(), 0); - - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->widgetControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->widgetControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setContrast(controlValue); - QCOMPARE(widget.contrast(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::contrastRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -void tst_QVideoWidget::hueWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setHue(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.hue(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.hue(), 0); - - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->windowControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->windowControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->windowControl->setHue(controlValue); - QCOMPARE(widget.hue(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::hueWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setHue(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.hue(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.hue(), 0); - - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->widgetControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->widgetControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setHue(controlValue); - QCOMPARE(widget.hue(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::hueRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -void tst_QVideoWidget::saturationWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setSaturation(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.saturation(), 0); - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.saturation(), 0); - - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->windowControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->windowControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->windowControl->setSaturation(controlValue); - QCOMPARE(widget.saturation(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::saturationWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setSaturation(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(widget.saturation(), 0); - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.saturation(), 0); - - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->widgetControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->widgetControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setSaturation(controlValue); - QCOMPARE(widget.saturation(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); - -} - -void tst_QVideoWidget::saturationRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -static const uchar rgb32ImageData[] = -{ - 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, - 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00 -}; - -void tst_QVideoWidget::paintRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QPainterVideoSurface *surface = qobject_cast( - object.testService->rendererControl->surface()); - - QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32); - - QVERIFY(surface->start(format)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QCoreApplication::processEvents(QEventLoop::AllEvents); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32); - - frame.map(QAbstractVideoBuffer::WriteOnly); - memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes()); - frame.unmap(); - - QVERIFY(surface->present(frame)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), false); - - //wait up to 2 seconds for the frame to be presented - for (int i=0; i<200 && !surface->isReady(); i++) - QTest::qWait(10); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); -} - -QTEST_MAIN(tst_QVideoWidget) - -#include "tst_qvideowidget.moc" diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index bfa7445..b66fc6a 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -247,9 +247,7 @@ Configure::Configure( int& argc, char** argv ) dictionary[ "PHONON" ] = "auto"; dictionary[ "PHONON_BACKEND" ] = "yes"; dictionary[ "MULTIMEDIA" ] = "yes"; - dictionary[ "MEDIASERVICES" ] = "yes"; dictionary[ "AUDIO_BACKEND" ] = "auto"; - dictionary[ "MEDIA_BACKEND"] = "auto"; dictionary[ "WMSDK" ] = "auto"; dictionary[ "DIRECTSHOW" ] = "no"; dictionary[ "WEBKIT" ] = "auto"; @@ -906,18 +904,10 @@ void Configure::parseCmdLine() dictionary[ "MULTIMEDIA" ] = "no"; } else if( configCmdLine.at(i) == "-multimedia" ) { dictionary[ "MULTIMEDIA" ] = "yes"; - } else if( configCmdLine.at(i) == "-no-mediaservices" ) { - dictionary[ "MEDIASERVICES" ] = "no"; - } else if( configCmdLine.at(i) == "-mediaservices" ) { - dictionary[ "MEDIASERVICES" ] = "yes"; } else if( configCmdLine.at(i) == "-audio-backend" ) { dictionary[ "AUDIO_BACKEND" ] = "yes"; } else if( configCmdLine.at(i) == "-no-audio-backend" ) { dictionary[ "AUDIO_BACKEND" ] = "no"; - } else if( configCmdLine.at(i) == "-media-backend") { - dictionary[ "MEDIA_BACKEND" ] = "yes"; - } else if (configCmdLine.at(i) == "-no-media-backend") { - dictionary[ "MEDIA_BACKEND" ] = "no"; } else if( configCmdLine.at(i) == "-no-phonon" ) { dictionary[ "PHONON" ] = "no"; } else if( configCmdLine.at(i) == "-phonon" ) { @@ -1603,7 +1593,6 @@ bool Configure::displayHelp() "[-qtnamespace ] [-qtlibinfix ] [-no-phonon]\n" "[-phonon] [-no-phonon-backend] [-phonon-backend]\n" "[-no-multimedia] [-multimedia] [-no-audio-backend] [-audio-backend]\n" - "[-no-mediaservices] [-mediaservices] [-no-media-backend] [-media-backend]\n" "[-no-script] [-script] [-no-scripttools] [-scripttools]\n" "[-no-webkit] [-webkit] [-graphicssystem raster|opengl|openvg]\n\n", 0, 7); @@ -1788,10 +1777,6 @@ bool Configure::displayHelp() desc("MULTIMEDIA", "yes","-multimedia", "Compile in multimedia module"); desc("AUDIO_BACKEND", "no","-no-audio-backend", "Do not compile in the platform audio backend into QtMultimedia"); desc("AUDIO_BACKEND", "yes","-audio-backend", "Compile in the platform audio backend into QtMultimedia"); - desc("MEDIASERVICES", "no", "-no-mediaservices","Do not compile the QtMediaServices module"); - desc("MEDIASERVICES", "yes","-mediaservices", "Compile in QtMediaServices module"); - desc("MEDIA_BACKEND", "no","-no-media-backend", "Do not compile in the platform-specific QtMediaServices media service."); - desc("MEDIA_BACKEND", "yes","-media-backend", "Compile in the platform-specific QtMediaServices media service."); desc("WEBKIT", "no", "-no-webkit", "Do not compile in the WebKit module"); desc("WEBKIT", "yes", "-webkit", "Compile in the WebKit module (WebKit is built if a decent C++ compiler is used.)"); desc("SCRIPT", "no", "-no-script", "Do not build the QtScript module."); @@ -2073,7 +2058,7 @@ bool Configure::checkAvailability(const QString &part) && dictionary.value("QMAKESPEC") != "win32-msvc.net" // Leave for now, since we can't be sure if they are using 2002 or 2003 with this spec && dictionary.value("QMAKESPEC") != "win32-msvc2002" && dictionary.value("EXCEPTIONS") == "yes"; - } else if (part == "PHONON" || part == "MEDIA_BACKEND") { + } else if (part == "PHONON") { if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) { available = true; } else { @@ -2237,8 +2222,6 @@ void Configure::autoDetection() dictionary["DECLARATIVE"] = dictionary["SCRIPT"] == "yes" ? "yes" : "no"; if (dictionary["AUDIO_BACKEND"] == "auto") dictionary["AUDIO_BACKEND"] = checkAvailability("AUDIO_BACKEND") ? "yes" : "no"; - if (dictionary["MEDIA_BACKEND"] == "auto") - dictionary["MEDIA_BACKEND"] = checkAvailability("MEDIA_BACKEND") ? "yes" : "no"; if (dictionary["WMSDK"] == "auto") dictionary["WMSDK"] = checkAvailability("WMSDK") ? "yes" : "no"; @@ -2639,14 +2622,6 @@ void Configure::generateOutputVars() qtConfig += "multimedia"; if (dictionary["AUDIO_BACKEND"] == "yes") qtConfig += "audio-backend"; - if (dictionary["MEDIASERVICES"] == "yes") { - qtConfig += "mediaservices"; - if (dictionary["MEDIA_BACKEND"] == "yes") { - qtConfig += "media-backend"; - if (dictionary["WMSDK"] == "yes") - qtConfig += "wmsdk"; - } - } } if (dictionary["WEBKIT"] == "yes") @@ -3048,7 +3023,6 @@ void Configure::generateConfigfiles() if(dictionary["DECLARATIVE"] == "no") qconfigList += "QT_NO_DECLARATIVE"; if(dictionary["PHONON"] == "no") qconfigList += "QT_NO_PHONON"; if(dictionary["MULTIMEDIA"] == "no") qconfigList += "QT_NO_MULTIMEDIA"; - if(dictionary["MEDIASERVICES"] == "no") qconfigList += "QT_NO_MEDIASERVICES"; if(dictionary["XMLPATTERNS"] == "no") qconfigList += "QT_NO_XMLPATTERNS"; if(dictionary["SCRIPT"] == "no") qconfigList += "QT_NO_SCRIPT"; if(dictionary["SCRIPTTOOLS"] == "no") qconfigList += "QT_NO_SCRIPTTOOLS"; @@ -3351,7 +3325,6 @@ void Configure::displayConfig() cout << "QtXmlPatterns support......." << dictionary[ "XMLPATTERNS" ] << endl; cout << "Phonon support.............." << dictionary[ "PHONON" ] << endl; cout << "QtMultimedia support........" << dictionary[ "MULTIMEDIA" ] << endl; - cout << "QtMediaServices support....." << dictionary[ "MEDIASERVICES" ] << endl; cout << "WebKit support.............." << dictionary[ "WEBKIT" ] << endl; cout << "Declarative support........." << dictionary[ "DECLARATIVE" ] << endl; cout << "QtScript support............" << dictionary[ "SCRIPT" ] << endl; diff --git a/translations/qt_de.ts b/translations/qt_de.ts index 86d5edb..226b7da 100644 --- a/translations/qt_de.ts +++ b/translations/qt_de.ts @@ -3683,15 +3683,6 @@ Möchten Sie die Datei trotzdem löschen? - QGstreamerPlayerSession - - - - Unable to play %1 - %1 kann nicht abgespielt werden - - - QHostInfo diff --git a/translations/qt_pl.ts b/translations/qt_pl.ts index a089cb6..1f5ceb0 100644 --- a/translations/qt_pl.ts +++ b/translations/qt_pl.ts @@ -3757,15 +3757,6 @@ ProszÄ™ o sprawdzenie podanej nazwy pliku. - QGstreamerPlayerSession - - - - Unable to play %1 - Nie można odtworzyć %1 - - - QHostInfo @@ -4592,39 +4583,6 @@ ProszÄ™ o sprawdzenie podanej nazwy pliku. - QMediaPlayer - - - The QMediaPlayer object does not have a valid service - - - - - QMediaPlaylist - - - - Could not add items to read only playlist. - Nie można dodać elementów do listy odtwarzania (tylko do odczytu). - - - - - Playlist format is not supported - Format listy odtwarzania nie jest obsÅ‚ugiwany - - - - The file could not be accessed. - Brak dostÄ™pu do pliku. - - - - Playlist format is not supported. - Format listy odtwarzania nie jest obsÅ‚ugiwany. - - - QMenu -- cgit v0.12 From dec910df27f2b6cf64a430b771fcab603fd687d6 Mon Sep 17 00:00:00 2001 From: Derick Hawcroft Date: Tue, 18 May 2010 11:29:57 +1000 Subject: More mediaservices removal work. --- src/s60installs/s60installs.pro | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index dfd2694..90c362b 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -151,20 +151,10 @@ symbian: { graphicssystems_plugins.sources += $$QT_BUILD_TREE/plugins/graphicssystems/qvggraphicssystem$${QT_LIBINFIX}.dll } - contains(QT_CONFIG, multimedia):contains(QT_CONFIG, mediaservices):contains(QT_CONFIG, media-backend) { + contains(QT_CONFIG, multimedia){ qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtMultimedia$${QT_LIBINFIX}.dll } - contains(QT_CONFIG, media-backend) { - qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtMediaServices$${QT_LIBINFIX}.dll - - mediaservices_plugins.path = c:$$QT_PLUGINS_BASE_DIR/mediaservices - mediaservices_plugins.sources += $$QT_BUILD_TREE/plugins/mediaservices/qmmfengine$${QT_LIBINFIX}.dll - - DEPLOYMENT += mediaservices_plugins - - } - BLD_INF_RULES.prj_exports += "qt.iby $$CORE_MW_LAYER_IBY_EXPORT_PATH(qt.iby)" BLD_INF_RULES.prj_exports += "qtdemoapps.iby $$CUSTOMER_VARIANT_APP_LAYER_IBY_EXPORT_PATH(qtdemoapps.iby)" } -- cgit v0.12 From cb03c8cad2a40272c9cc8d0998246fb74a49e671 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 18 May 2010 13:36:39 +1000 Subject: Rebuild configure following the removal of media services. --- configure.exe | Bin 1319424 -> 1317376 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index 35116ff..0344f2c 100755 Binary files a/configure.exe and b/configure.exe differ -- cgit v0.12 From 04e81b425e3b03da28926f7784e040ee48c3eaa0 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 18 May 2010 14:52:50 +1000 Subject: Rebuild configure.exe --- configure.exe | Bin 1319424 -> 1316864 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index 35116ff..a19f515 100755 Binary files a/configure.exe and b/configure.exe differ -- cgit v0.12 From 00b2882349d42736f1e3f753838af27a3774eb64 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 18 May 2010 09:38:54 +0200 Subject: Updated WebKit to cacbdf18fc917122834042d77a9164a490aafde4 Cherry pick http://trac.webkit.org/changeset/59606 to fix auto-test regression of r59563 --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 12 ++++++++++++ src/3rdparty/webkit/WebCore/bridge/qt/qt_class.cpp | 8 ++++---- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index b1b56f6..1973377 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -cacbdf18fc917122834042d77a9164a490aafde4 +807157e42add842605ec67d9363dd3f1861748ca diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 629883a..79581d1 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 4696beb87359fe9236d23e0791526eb38dab341d + cacbdf18fc917122834042d77a9164a490aafde4 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index ac5c388..481b416 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,15 @@ +2010-05-17 Kenneth Rohde Christiansen + + Reviewed by Laszlo Gombos. + + REGRESSION(59563): [Qt] JSValue QtClass::fallbackObject can be optimized + + Patch declared a variable index, which shadowed an earlier declared + variable. + + * bridge/qt/qt_class.cpp: + (JSC::Bindings::QtClass::fallbackObject): + 2010-05-14 Noam Rosenthal Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebCore/bridge/qt/qt_class.cpp b/src/3rdparty/webkit/WebCore/bridge/qt/qt_class.cpp index 5bbc99f..2e1f6e6 100644 --- a/src/3rdparty/webkit/WebCore/bridge/qt/qt_class.cpp +++ b/src/3rdparty/webkit/WebCore/bridge/qt/qt_class.cpp @@ -98,12 +98,12 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, const Identifie if (m.access() == QMetaMethod::Private) continue; - int index = 0; + int iter = 0; const char* signature = m.signature(); - while (signature[index] && signature[index] != '(') - ++index; + while (signature[iter] && signature[iter] != '(') + ++iter; - if (normal == QByteArray::fromRawData(signature, index)) { + if (normal == QByteArray::fromRawData(signature, iter)) { QtRuntimeMetaMethod* val = new (exec) QtRuntimeMetaMethod(exec, identifier, static_cast(inst), index, normal, false); qtinst->m_methods.insert(name, val); return val; -- cgit v0.12 From 8665f4ba8cbf63740cfb379c8f98d8d68d089bf5 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 18 May 2010 10:31:42 +0300 Subject: Fix weatherinfo and flightinfo to only request WLAN connection once New bearer implementation will only keep connection alive as long as the QNetworkAccessManager instance is alive, so changed the demos to have single manager instance instead of recreating it for each request. Task-number: QTBUG-10151 Reviewed-by: Janne Anttila --- demos/embedded/flightinfo/flightinfo.cpp | 56 ++++++++++-------------------- demos/embedded/weatherinfo/weatherinfo.cpp | 17 +++------ 2 files changed, 23 insertions(+), 50 deletions(-) diff --git a/demos/embedded/flightinfo/flightinfo.cpp b/demos/embedded/flightinfo/flightinfo.cpp index 10d3f02..6cc1876 100644 --- a/demos/embedded/flightinfo/flightinfo.cpp +++ b/demos/embedded/flightinfo/flightinfo.cpp @@ -43,10 +43,6 @@ #include #include -#if defined (Q_OS_SYMBIAN) -#include "sym_iap_util.h" -#endif - #include "ui_form.h" #define FLIGHTVIEW_URL "http://mobile.flightview.com/TrackByFlight.aspx" @@ -100,6 +96,8 @@ private: QUrl m_url; QDate m_searchDate; QPixmap m_map; + QNetworkAccessManager m_manager; + QList mapReplies; public: @@ -115,7 +113,6 @@ public: connect(ui.flightEdit, SIGNAL(returnPressed()), SLOT(startSearch())); setWindowTitle("Flight Info"); - QTimer::singleShot(0, this, SLOT(delayedInit())); // Rendered from the public-domain vectorized aircraft // http://openclipart.org/media/people/Jarno @@ -127,6 +124,8 @@ public: connect(searchTodayAction, SIGNAL(triggered()), SLOT(today())); connect(searchYesterdayAction, SIGNAL(triggered()), SLOT(yesterday())); connect(randomAction, SIGNAL(triggered()), SLOT(randomFlight())); + connect(&m_manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(handleNetworkData(QNetworkReply*))); #if defined(Q_OS_SYMBIAN) menuBar()->addAction(searchTodayAction); menuBar()->addAction(searchYesterdayAction); @@ -140,31 +139,21 @@ public: } private slots: - void delayedInit() { -#if defined(Q_OS_SYMBIAN) - qt_SetDefaultIap(); -#endif - } - void handleNetworkData(QNetworkReply *networkReply) { if (!networkReply->error()) { - // Assume UTF-8 encoded - QByteArray data = networkReply->readAll(); - QString xml = QString::fromUtf8(data); - digest(xml); - } - networkReply->deleteLater(); - networkReply->manager()->deleteLater(); - } - - void handleMapData(QNetworkReply *networkReply) { - if (!networkReply->error()) { - m_map.loadFromData(networkReply->readAll()); - update(); + if (!mapReplies.contains(networkReply)) { + // Assume UTF-8 encoded + QByteArray data = networkReply->readAll(); + QString xml = QString::fromUtf8(data); + digest(xml); + } else { + mapReplies.removeOne(networkReply); + m_map.loadFromData(networkReply->readAll()); + update(); + } } networkReply->deleteLater(); - networkReply->manager()->deleteLater(); } void today() { @@ -224,10 +213,7 @@ public slots: ui.flightName->setText("Getting a random flight..."); } - QNetworkAccessManager *manager = new QNetworkAccessManager(this); - connect(manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(handleNetworkData(QNetworkReply*))); - manager->get(QNetworkRequest(m_url)); + m_manager.get(QNetworkRequest(m_url)); } @@ -248,10 +234,7 @@ private: regex.indexIn(href); QString airport = regex.cap(1); m_url.addEncodedQueryItem("dpap", QUrl::toPercentEncoding(airport)); - QNetworkAccessManager *manager = new QNetworkAccessManager(this); - connect(manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(handleNetworkData(QNetworkReply*))); - manager->get(QNetworkRequest(m_url)); + m_manager.get(QNetworkRequest(m_url)); return; } @@ -287,12 +270,9 @@ private: } if (xml.name() == "img" && inFlightMap) { QString src = xml.attributes().value("src").toString(); - src.prepend("http://mobile.flightview.com"); + src.prepend("http://mobile.flightview.com/"); QUrl url = QUrl::fromPercentEncoding(src.toAscii()); - QNetworkAccessManager *manager = new QNetworkAccessManager(this); - connect(manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(handleMapData(QNetworkReply*))); - manager->get(QNetworkRequest(url)); + mapReplies.append(m_manager.get(QNetworkRequest(url))); } } diff --git a/demos/embedded/weatherinfo/weatherinfo.cpp b/demos/embedded/weatherinfo/weatherinfo.cpp index 42b685e..3e0226a 100644 --- a/demos/embedded/weatherinfo/weatherinfo.cpp +++ b/demos/embedded/weatherinfo/weatherinfo.cpp @@ -44,10 +44,6 @@ #include #include -#if defined (Q_OS_SYMBIAN) -#include "sym_iap_util.h" -#endif - class WeatherInfo: public QMainWindow { Q_OBJECT @@ -67,6 +63,7 @@ private: QList m_rangeItems; QTimeLine m_timeLine; QHash m_icons; + QNetworkAccessManager m_manager; public: WeatherInfo(QWidget *parent = 0): QMainWindow(parent) { @@ -98,14 +95,14 @@ public: } setContextMenuPolicy(Qt::ActionsContextMenu); + connect(&m_manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(handleNetworkData(QNetworkReply*))); + QTimer::singleShot(0, this, SLOT(delayedInit())); } private slots: void delayedInit() { -#if defined(Q_OS_SYMBIAN) - qt_SetDefaultIap(); -#endif request("Oslo"); } @@ -122,7 +119,6 @@ private slots: if (!networkReply->error()) digest(QString::fromUtf8(networkReply->readAll())); networkReply->deleteLater(); - networkReply->manager()->deleteLater(); } void animate(int frame) { @@ -185,10 +181,7 @@ private: url.addEncodedQueryItem("hl", "en"); url.addEncodedQueryItem("weather", QUrl::toPercentEncoding(location)); - QNetworkAccessManager *manager = new QNetworkAccessManager(this); - connect(manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(handleNetworkData(QNetworkReply*))); - manager->get(QNetworkRequest(url)); + m_manager.get(QNetworkRequest(url)); city = QString(); setWindowTitle("Loading..."); -- cgit v0.12 From a61d857587b4adbabbeec179117767de99d36be3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 18 May 2010 10:02:32 +0200 Subject: qmake/MinGw: Link statically. Reviewed-by: Thierry Bastian --- qmake/Makefile.win32-g++ | 3 ++- qmake/Makefile.win32-g++-sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++ index 477203d..e52b8c6 100644 --- a/qmake/Makefile.win32-g++ +++ b/qmake/Makefile.win32-g++ @@ -27,7 +27,7 @@ CFLAGS = -c -o$@ -O \ -DQT_BUILD_QMAKE -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \ -DQT_BOOTSTRAPPED CXXFLAGS = $(CFLAGS) -LFLAGS = -static-libgcc -s +LFLAGS = -static-libgcc -static-libstdc++ -s LIBS = -lole32 -luuid LINKQMAKE = g++ $(LFLAGS) -o qmake.exe $(OBJS) $(QTOBJS) $(LIBS) ADDCLEAN = @@ -326,3 +326,4 @@ qxmlstream.o: $(SOURCE_PATH)/src/corelib/xml/qxmlstream.cpp qxmlutils.o: $(SOURCE_PATH)/src/corelib/xml/qxmlutils.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/xml/qxmlutils.cpp + diff --git a/qmake/Makefile.win32-g++-sh b/qmake/Makefile.win32-g++-sh index 6aac39f..e4e2e6a 100644 --- a/qmake/Makefile.win32-g++-sh +++ b/qmake/Makefile.win32-g++-sh @@ -27,7 +27,7 @@ CFLAGS = -c -o$@ -O \ -DQT_BUILD_QMAKE -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \ -DQT_BOOTSTRAPPED CXXFLAGS = $(CFLAGS) -LFLAGS = -static-libgcc -s +LFLAGS = -static-libgcc -static-libstdc++ -s LIBS = -lole32 -luuid LINKQMAKE = g++ $(LFLAGS) -o qmake.exe $(OBJS) $(QTOBJS) $(LIBS) ADDCLEAN = -- cgit v0.12 From acee77966603ed968e68ed36337b90fa32c5062b Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 18 May 2010 11:37:04 +0300 Subject: Fix pkg_prerules handling for installer packages The removed check was causing dropping of vendor info from installer package files. No need to check for header in rawPkgPreRules as it would never get there in the first place; it gets placed into headerRules instead. Reviewed-by: Shane Kearns --- qmake/generators/symbian/symbiancommon.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/qmake/generators/symbian/symbiancommon.cpp b/qmake/generators/symbian/symbiancommon.cpp index ce796c3..aa44afc 100644 --- a/qmake/generators/symbian/symbiancommon.cpp +++ b/qmake/generators/symbian/symbiancommon.cpp @@ -305,11 +305,6 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB t << item << endl; tw << item << endl; } - // Only regular and stub should have pkg header if that is defined using prerules. - else if (!item.startsWith("#")) { - t << item << endl; - ts << item << endl; - } else { t << item << endl; ts << item << endl; -- cgit v0.12 From 7df8d538cdde7bf103950b2bdcb20781c0f07e69 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 18 May 2010 10:56:29 +0200 Subject: QNAM HTTP: Remove dead code --- src/network/access/qnetworkaccesshttpbackend_p.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend_p.h b/src/network/access/qnetworkaccesshttpbackend_p.h index 0eaf003..b0f0ed0 100644 --- a/src/network/access/qnetworkaccesshttpbackend_p.h +++ b/src/network/access/qnetworkaccesshttpbackend_p.h @@ -94,8 +94,6 @@ public: #endif QNetworkCacheMetaData fetchCacheMetaData(const QNetworkCacheMetaData &metaData) const; - qint64 deviceReadData(char *buffer, qint64 maxlen); - // we return true since HTTP needs to send PUT/POST data again after having authenticated bool needsResetableUploadData() { return true; } -- cgit v0.12 From 2313126fc721c9e42f429848bce54a11b5de6659 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 18 May 2010 13:16:01 +0300 Subject: Do not autopatch _installer.pkg when self-signing _installer.pkg produces self-signable packages by default, so no need to patch it. Task-number: QTBUG-10746 Reviewed-by: Janne Koskinen --- bin/createpackage.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/createpackage.pl b/bin/createpackage.pl index 0cc1a9c..939c38e 100755 --- a/bin/createpackage.pl +++ b/bin/createpackage.pl @@ -292,7 +292,7 @@ if($stub) { # Create stub SIS. system ("makesis -s $pkgoutput $stub_sis_name"); } else { - if ($certtext eq "Self Signed" && !@certificates) { + if ($certtext eq "Self Signed" && !@certificates && $templatepkg !~ m/_installer\.pkg$/i) { print("Auto-patching capabilities for self signed package.\n"); system ("patch_capabilities $pkgoutput"); } -- cgit v0.12 From 3335882eaa8ef3531a87d42a3400d06baa60380b Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 18 May 2010 13:46:54 +0200 Subject: Update symbian def files for 4.7 --- src/s60installs/bwins/QtCoreu.def | 14 ++++++++++++++ src/s60installs/bwins/QtDeclarativeu.def | 10 +++++++++- src/s60installs/bwins/QtGuiu.def | 23 +++++++++++++++++++---- src/s60installs/bwins/QtNetworku.def | 1 + src/s60installs/eabi/QtCoreu.def | 7 +++++++ src/s60installs/eabi/QtDeclarativeu.def | 28 ++++++++++++++++++++++++++-- src/s60installs/eabi/QtGuiu.def | 14 ++++++++++++-- src/s60installs/eabi/QtNetworku.def | 1 + 8 files changed, 89 insertions(+), 9 deletions(-) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index 13b8157..c6d7a2c 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -4465,4 +4465,18 @@ EXPORTS ?selectThread@QEventDispatcherSymbian@@AAEAAVQSelectThread@@XZ @ 4464 NONAME ; class QSelectThread & QEventDispatcherSymbian::selectThread(void) ?setRawData@QByteArray@@QAEAAV1@PBDI@Z @ 4465 NONAME ; class QByteArray & QByteArray::setRawData(char const *, unsigned int) ?setRawData@QString@@QAEAAV1@PBVQChar@@H@Z @ 4466 NONAME ; class QString & QString::setRawData(class QChar const *, int) + ?getStaticMetaObject@QEventDispatcherSymbian@@SAABUQMetaObject@@XZ @ 4467 NONAME ; struct QMetaObject const & QEventDispatcherSymbian::getStaticMetaObject(void) + ?isHighSurrogate@QChar@@SA_NI@Z @ 4468 NONAME ; bool QChar::isHighSurrogate(unsigned int) + ?isLowSurrogate@QChar@@SA_NI@Z @ 4469 NONAME ; bool QChar::isLowSurrogate(unsigned int) + ?metaObject@QEventDispatcherSymbian@@UBEPBUQMetaObject@@XZ @ 4470 NONAME ; struct QMetaObject const * QEventDispatcherSymbian::metaObject(void) const + ?msecsTo@QDateTime@@QBE_JABV1@@Z @ 4471 NONAME ; long long QDateTime::msecsTo(class QDateTime const &) const + ?qt_metacall@QEventDispatcherSymbian@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 4472 NONAME ; int QEventDispatcherSymbian::qt_metacall(enum QMetaObject::Call, int, void * *) + ?qt_metacast@QEventDispatcherSymbian@@UAEPAXPBD@Z @ 4473 NONAME ; void * QEventDispatcherSymbian::qt_metacast(char const *) + ?requiresSurrogates@QChar@@SA_NI@Z @ 4474 NONAME ; bool QChar::requiresSurrogates(unsigned int) + ?symbianInit@QCoreApplicationPrivate@@QAEXXZ @ 4475 NONAME ; void QCoreApplicationPrivate::symbianInit(void) + ?tr@QEventDispatcherSymbian@@SA?AVQString@@PBD0@Z @ 4476 NONAME ; class QString QEventDispatcherSymbian::tr(char const *, char const *) + ?tr@QEventDispatcherSymbian@@SA?AVQString@@PBD0H@Z @ 4477 NONAME ; class QString QEventDispatcherSymbian::tr(char const *, char const *, int) + ?trUtf8@QEventDispatcherSymbian@@SA?AVQString@@PBD0@Z @ 4478 NONAME ; class QString QEventDispatcherSymbian::trUtf8(char const *, char const *) + ?trUtf8@QEventDispatcherSymbian@@SA?AVQString@@PBD0H@Z @ 4479 NONAME ; class QString QEventDispatcherSymbian::trUtf8(char const *, char const *, int) + ?staticMetaObject@QEventDispatcherSymbian@@2UQMetaObject@@B @ 4480 NONAME ; struct QMetaObject const QEventDispatcherSymbian::staticMetaObject diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def index f43eadf..3f2f7a0 100644 --- a/src/s60installs/bwins/QtDeclarativeu.def +++ b/src/s60installs/bwins/QtDeclarativeu.def @@ -3563,7 +3563,7 @@ EXPORTS ?computeTransformOrigin@QDeclarativeItemPrivate@@QBE?AVQPointF@@XZ @ 3562 NONAME ; class QPointF QDeclarativeItemPrivate::computeTransformOrigin(void) const ?contextObject@QDeclarativeContext@@QBEPAVQObject@@XZ @ 3563 NONAME ; class QObject * QDeclarativeContext::contextObject(void) const ?copyOriginals@QDeclarativeAnchorChanges@@UAEXPAVQDeclarativeActionEvent@@@Z @ 3564 NONAME ; void QDeclarativeAnchorChanges::copyOriginals(class QDeclarativeActionEvent *) - ?copyOriginals@QDeclarativeParentChange@@UAEXPAVQDeclarativeActionEvent@@@Z @ 3565 NONAME ; void QDeclarativeParentChange::copyOriginals(class QDeclarativeActionEvent *) + ?copyOriginals@QDeclarativeParentChange@@UAEXPAVQDeclarativeActionEvent@@@Z @ 3565 NONAME ABSENT ; void QDeclarativeParentChange::copyOriginals(class QDeclarativeActionEvent *) ?countChanged@QDeclarativeListModel@@IAEXXZ @ 3566 NONAME ; void QDeclarativeListModel::countChanged(void) ?countChanged@QDeclarativePathView@@IAEXXZ @ 3567 NONAME ; void QDeclarativePathView::countChanged(void) ?create@QDeclarativeType@@QBEXPAPAVQObject@@PAPAXI@Z @ 3568 NONAME ; void QDeclarativeType::create(class QObject * *, void * *, unsigned int) const @@ -4012,4 +4012,12 @@ EXPORTS ?setFlickDirection@QDeclarativeFlickable@@QAEXW4FlickableDirection@1@@Z @ 4011 NONAME ; void QDeclarativeFlickable::setFlickDirection(enum QDeclarativeFlickable::FlickableDirection) ?flickableDirectionChanged@QDeclarativeFlickable@@IAEXXZ @ 4012 NONAME ; void QDeclarativeFlickable::flickableDirectionChanged(void) ?isFlickingVertically@QDeclarativeFlickable@@QBE_NXZ @ 4013 NONAME ; bool QDeclarativeFlickable::isFlickingVertically(void) const + ?componentComplete@QDeclarativeLoader@@MAEXXZ @ 4014 NONAME ; void QDeclarativeLoader::componentComplete(void) + ?decrementCurrentIndex@QDeclarativePathView@@QAEXXZ @ 4015 NONAME ; void QDeclarativePathView::decrementCurrentIndex(void) + ?incrementCurrentIndex@QDeclarativePathView@@QAEXXZ @ 4016 NONAME ; void QDeclarativePathView::incrementCurrentIndex(void) + ?inputMethodPreHandler@QDeclarativeItem@@IAEXPAVQInputMethodEvent@@@Z @ 4017 NONAME ; void QDeclarativeItem::inputMethodPreHandler(class QInputMethodEvent *) + ?keyPressPreHandler@QDeclarativeItem@@IAEXPAVQKeyEvent@@@Z @ 4018 NONAME ; void QDeclarativeItem::keyPressPreHandler(class QKeyEvent *) + ?keyReleasePreHandler@QDeclarativeItem@@IAEXPAVQKeyEvent@@@Z @ 4019 NONAME ; void QDeclarativeItem::keyReleasePreHandler(class QKeyEvent *) + ?loaded@QDeclarativeLoader@@IAEXXZ @ 4020 NONAME ; void QDeclarativeLoader::loaded(void) + ?needsCopy@QDeclarativeAnchorChanges@@UAE_NXZ @ 4021 NONAME ; bool QDeclarativeAnchorChanges::needsCopy(void) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index a67f9b8..15addf6 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -2125,7 +2125,7 @@ EXPORTS ?addText@QPainterPath@@QAEXMMABVQFont@@ABVQString@@@Z @ 2124 NONAME ; void QPainterPath::addText(float, float, class QFont const &, class QString const &) ?addToGroup@QGraphicsItemGroup@@QAEXPAVQGraphicsItem@@@Z @ 2125 NONAME ; void QGraphicsItemGroup::addToGroup(class QGraphicsItem *) ?addToIndex@QGraphicsItem@@IAEXXZ @ 2126 NONAME ; void QGraphicsItem::addToIndex(void) - ?addToPolygon@QBezier@@QBEXPAVQPolygonF@@@Z @ 2127 NONAME ; void QBezier::addToPolygon(class QPolygonF *) const + ?addToPolygon@QBezier@@QBEXPAVQPolygonF@@@Z @ 2127 NONAME ABSENT ; void QBezier::addToPolygon(class QPolygonF *) const ?addToPolygonIterative@QBezier@@QBEXPAVQPolygonF@@@Z @ 2128 NONAME ABSENT ; void QBezier::addToPolygonIterative(class QPolygonF *) const ?addToPolygonMixed@QBezier@@QBEXPAVQPolygonF@@@Z @ 2129 NONAME ABSENT ; void QBezier::addToPolygonMixed(class QPolygonF *) const ?addToolBar@QMainWindow@@QAEPAVQToolBar@@ABVQString@@@Z @ 2130 NONAME ; class QToolBar * QMainWindow::addToolBar(class QString const &) @@ -3207,7 +3207,7 @@ EXPORTS ?cursorWordForward@QLineControl@@QAEX_N@Z @ 3206 NONAME ; void QLineControl::cursorWordForward(bool) ?cursorWordForward@QLineEdit@@QAEX_N@Z @ 3207 NONAME ; void QLineEdit::cursorWordForward(bool) ?curveThreshold@QPainterPathStroker@@QBEMXZ @ 3208 NONAME ; float QPainterPathStroker::curveThreshold(void) const - ?curveThreshold@QStroker@@QBEMXZ @ 3209 NONAME ; float QStroker::curveThreshold(void) const + ?curveThreshold@QStroker@@QBEMXZ @ 3209 NONAME ABSENT ; float QStroker::curveThreshold(void) const ?customButtonClicked@QWizard@@IAEXH@Z @ 3210 NONAME ; void QWizard::customButtonClicked(int) ?customColor@QColorDialog@@SAIH@Z @ 3211 NONAME ; unsigned int QColorDialog::customColor(int) ?customContextMenuRequested@QWidget@@IAEXABVQPoint@@@Z @ 3212 NONAME ; void QWidget::customContextMenuRequested(class QPoint const &) @@ -8769,7 +8769,7 @@ EXPORTS ?setCursorWidth@QTextEdit@@QAEXH@Z @ 8768 NONAME ; void QTextEdit::setCursorWidth(int) ?setCursor_sys@QWidgetPrivate@@QAEXABVQCursor@@@Z @ 8769 NONAME ; void QWidgetPrivate::setCursor_sys(class QCursor const &) ?setCurveThreshold@QPainterPathStroker@@QAEXM@Z @ 8770 NONAME ; void QPainterPathStroker::setCurveThreshold(float) - ?setCurveThreshold@QStroker@@QAEXM@Z @ 8771 NONAME ; void QStroker::setCurveThreshold(float) + ?setCurveThreshold@QStroker@@QAEXM@Z @ 8771 NONAME ABSENT ; void QStroker::setCurveThreshold(float) ?setCustomColor@QColorDialog@@SAXHI@Z @ 8772 NONAME ; void QColorDialog::setCustomColor(int, unsigned int) ?setDashOffset@QDashStroker@@QAEXM@Z @ 8773 NONAME ; void QDashStroker::setDashOffset(float) ?setDashOffset@QPainterPathStroker@@QAEXM@Z @ 8774 NONAME ; void QPainterPathStroker::setDashOffset(float) @@ -10990,7 +10990,7 @@ EXPORTS ?toPointF@QVector2D@@QBE?AVQPointF@@XZ @ 10989 NONAME ; class QPointF QVector2D::toPointF(void) const ?toPointF@QVector3D@@QBE?AVQPointF@@XZ @ 10990 NONAME ; class QPointF QVector3D::toPointF(void) const ?toPointF@QVector4D@@QBE?AVQPointF@@XZ @ 10991 NONAME ; class QPointF QVector4D::toPointF(void) const - ?toPolygon@QBezier@@QBE?AVQPolygonF@@XZ @ 10992 NONAME ; class QPolygonF QBezier::toPolygon(void) const + ?toPolygon@QBezier@@QBE?AVQPolygonF@@XZ @ 10992 NONAME ABSENT ; class QPolygonF QBezier::toPolygon(void) const ?toPolygon@QPolygonF@@QBE?AVQPolygon@@XZ @ 10993 NONAME ; class QPolygon QPolygonF::toPolygon(void) const ?toPrevious@QDataWidgetMapper@@QAEXXZ @ 10994 NONAME ; void QDataWidgetMapper::toPrevious(void) ?toReversed@QPainterPath@@QBE?AV1@XZ @ 10995 NONAME ; class QPainterPath QPainterPath::toReversed(void) const @@ -12803,4 +12803,19 @@ EXPORTS ?totalUsed@QPixmapCache@@SAHXZ @ 12802 NONAME ; int QPixmapCache::totalUsed(void) ?allPixmaps@QPixmapCache@@SA?AV?$QList@U?$QPair@VQString@@VQPixmap@@@@@@XZ @ 12803 NONAME ; class QList > QPixmapCache::allPixmaps(void) ?flushDetachedPixmaps@QPixmapCache@@SAXXZ @ 12804 NONAME ; void QPixmapCache::flushDetachedPixmaps(void) + ??0QImageTextureGlyphCache@@QAE@W4Type@QFontEngineGlyphCache@@ABVQTransform@@@Z @ 12805 NONAME ; QImageTextureGlyphCache::QImageTextureGlyphCache(enum QFontEngineGlyphCache::Type, class QTransform const &) + ??1QImageTextureGlyphCache@@UAE@XZ @ 12806 NONAME ; QImageTextureGlyphCache::~QImageTextureGlyphCache(void) + ??_EQImageTextureGlyphCache@@UAE@I@Z @ 12807 NONAME ; QImageTextureGlyphCache::~QImageTextureGlyphCache(unsigned int) + ?addToPolygon@QBezier@@QBEXPAVQPolygonF@@M@Z @ 12808 NONAME ; void QBezier::addToPolygon(class QPolygonF *, float) const + ?createTextureData@QImageTextureGlyphCache@@UAEXHH@Z @ 12809 NONAME ; void QImageTextureGlyphCache::createTextureData(int, int) + ?curveThreshold@QStrokerOps@@QBEMXZ @ 12810 NONAME ; float QStrokerOps::curveThreshold(void) const + ?fillTexture@QImageTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@I@Z @ 12811 NONAME ; void QImageTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int) + ?glyphMargin@QImageTextureGlyphCache@@UBEHXZ @ 12812 NONAME ; int QImageTextureGlyphCache::glyphMargin(void) const + ?image@QImageTextureGlyphCache@@QBEABVQImage@@XZ @ 12813 NONAME ; class QImage const & QImageTextureGlyphCache::image(void) const + ?resizeTextureData@QImageTextureGlyphCache@@UAEXHH@Z @ 12814 NONAME ; void QImageTextureGlyphCache::resizeTextureData(int, int) + ?setCurveThreshold@QStrokerOps@@QAEXM@Z @ 12815 NONAME ; void QStrokerOps::setCurveThreshold(float) + ?setCurveThresholdFromTransform@QStrokerOps@@QAEXABVQTransform@@@Z @ 12816 NONAME ; void QStrokerOps::setCurveThresholdFromTransform(class QTransform const &) + ?setUpdateClip@QGraphicsViewPrivate@@QAEXPAVQGraphicsItem@@@Z @ 12817 NONAME ; void QGraphicsViewPrivate::setUpdateClip(class QGraphicsItem *) + ?toPolygon@QBezier@@QBE?AVQPolygonF@@M@Z @ 12818 NONAME ; class QPolygonF QBezier::toPolygon(float) const + ?updatePaintedViewBoundingRects@QGraphicsItemPrivate@@QAEX_N@Z @ 12819 NONAME ; void QGraphicsItemPrivate::updatePaintedViewBoundingRects(bool) diff --git a/src/s60installs/bwins/QtNetworku.def b/src/s60installs/bwins/QtNetworku.def index 9391ad5..9d4507b 100644 --- a/src/s60installs/bwins/QtNetworku.def +++ b/src/s60installs/bwins/QtNetworku.def @@ -1143,4 +1143,5 @@ EXPORTS ?setNetworkAccessible@QNetworkAccessManager@@QAEXW4NetworkAccessibility@1@@Z @ 1142 NONAME ; void QNetworkAccessManager::setNetworkAccessible(enum QNetworkAccessManager::NetworkAccessibility) ?startPolling@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1143 NONAME ; void QNetworkConfigurationManagerPrivate::startPolling(void) ?capabilities@QNetworkConfigurationManagerPrivate@@QAE?AV?$QFlags@W4Capability@QNetworkConfigurationManager@@@@XZ @ 1144 NONAME ; class QFlags QNetworkConfigurationManagerPrivate::capabilities(void) + ?addPendingConnection@QTcpServer@@IAEXPAVQTcpSocket@@@Z @ 1145 NONAME ; void QTcpServer::addPendingConnection(class QTcpSocket *) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index dc9431b..48ba8d2 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3700,4 +3700,11 @@ EXPORTS _ZN23QEventDispatcherSymbian12selectThreadEv @ 3699 NONAME _ZN10QByteArray10setRawDataEPKcj @ 3700 NONAME _ZN7QString10setRawDataEPK5QChari @ 3701 NONAME + _ZN23QCoreApplicationPrivate11symbianInitEv @ 3702 NONAME + _ZN23QEventDispatcherSymbian11qt_metacallEN11QMetaObject4CallEiPPv @ 3703 NONAME + _ZN23QEventDispatcherSymbian11qt_metacastEPKc @ 3704 NONAME + _ZN23QEventDispatcherSymbian16staticMetaObjectE @ 3705 NONAME DATA 16 + _ZN23QEventDispatcherSymbian19getStaticMetaObjectEv @ 3706 NONAME + _ZNK23QEventDispatcherSymbian10metaObjectEv @ 3707 NONAME + _ZNK9QDateTime7msecsToERKS_ @ 3708 NONAME diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index 34f8b9e..086e1b2 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -1602,7 +1602,7 @@ EXPORTS _ZN24QDeclarativeParentChange11qt_metacastEPKc @ 1601 NONAME _ZN24QDeclarativeParentChange11setRotationEf @ 1602 NONAME _ZN24QDeclarativeParentChange12isReversableEv @ 1603 NONAME - _ZN24QDeclarativeParentChange13copyOriginalsEP23QDeclarativeActionEvent @ 1604 NONAME + _ZN24QDeclarativeParentChange13copyOriginalsEP23QDeclarativeActionEvent @ 1604 NONAME ABSENT _ZN24QDeclarativeParentChange13saveOriginalsEv @ 1605 NONAME _ZN24QDeclarativeParentChange16staticMetaObjectE @ 1606 NONAME DATA 16 _ZN24QDeclarativeParentChange17saveCurrentValuesEv @ 1607 NONAME @@ -3306,7 +3306,7 @@ EXPORTS _ZThn8_N23QDeclarativePaintedItemD0Ev @ 3305 NONAME _ZThn8_N23QDeclarativePaintedItemD1Ev @ 3306 NONAME _ZThn8_N24QDeclarativeParentChange12isReversableEv @ 3307 NONAME - _ZThn8_N24QDeclarativeParentChange13copyOriginalsEP23QDeclarativeActionEvent @ 3308 NONAME + _ZThn8_N24QDeclarativeParentChange13copyOriginalsEP23QDeclarativeActionEvent @ 3308 NONAME ABSENT _ZThn8_N24QDeclarativeParentChange13saveOriginalsEv @ 3309 NONAME _ZThn8_N24QDeclarativeParentChange17saveCurrentValuesEv @ 3310 NONAME _ZThn8_N24QDeclarativeParentChange6rewindEv @ 3311 NONAME @@ -3578,4 +3578,28 @@ EXPORTS _ZThn8_N23QDeclarativeConnections10classBeginEv @ 3577 NONAME _ZThn8_N23QDeclarativePaintedItem10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 3578 NONAME _ZThn8_N24QDeclarativeWorkerScript10classBeginEv @ 3579 NONAME + _ZN16QDeclarativeItem18keyPressPreHandlerEP9QKeyEvent @ 3580 NONAME + _ZN16QDeclarativeItem20keyReleasePreHandlerEP9QKeyEvent @ 3581 NONAME + _ZN16QDeclarativeItem21inputMethodPreHandlerEP17QInputMethodEvent @ 3582 NONAME + _ZN18QDeclarativeLoader17componentCompleteEv @ 3583 NONAME + _ZN18QDeclarativeLoader6loadedEv @ 3584 NONAME + _ZN20QDeclarativePathView21decrementCurrentIndexEv @ 3585 NONAME + _ZN20QDeclarativePathView21incrementCurrentIndexEv @ 3586 NONAME + _ZN21QDeclarativeFlickable17setFlickDirectionENS_18FlickableDirectionE @ 3587 NONAME + _ZN21QDeclarativeFlickable21setFlickableDirectionENS_18FlickableDirectionE @ 3588 NONAME + _ZN21QDeclarativeFlickable23movingVerticallyChangedEv @ 3589 NONAME + _ZN21QDeclarativeFlickable25flickableDirectionChangedEv @ 3590 NONAME + _ZN21QDeclarativeFlickable25flickingVerticallyChangedEv @ 3591 NONAME + _ZN21QDeclarativeFlickable25movingHorizontallyChangedEv @ 3592 NONAME + _ZN21QDeclarativeFlickable27flickingHorizontallyChangedEv @ 3593 NONAME + _ZN27QDeclarativeVisualDataModelC1EP19QDeclarativeContextP7QObject @ 3594 NONAME + _ZN27QDeclarativeVisualDataModelC2EP19QDeclarativeContextP7QObject @ 3595 NONAME + _ZN27QDeclarativeVisualItemModelC1EP7QObject @ 3596 NONAME + _ZN27QDeclarativeVisualItemModelC2EP7QObject @ 3597 NONAME + _ZNK21QDeclarativeFlickable18flickableDirectionEv @ 3598 NONAME + _ZNK21QDeclarativeFlickable18isMovingVerticallyEv @ 3599 NONAME + _ZNK21QDeclarativeFlickable20isFlickingVerticallyEv @ 3600 NONAME + _ZNK21QDeclarativeFlickable20isMovingHorizontallyEv @ 3601 NONAME + _ZNK21QDeclarativeFlickable22isFlickingHorizontallyEv @ 3602 NONAME + _ZThn16_N18QDeclarativeLoader17componentCompleteEv @ 3603 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 3eaa8c3..6b05e9b 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -9899,7 +9899,7 @@ EXPORTS _ZNK7QAction9statusTipEv @ 9898 NONAME _ZNK7QAction9whatsThisEv @ 9899 NONAME _ZNK7QBezier10addIfCloseEPff @ 9900 NONAME - _ZNK7QBezier12addToPolygonEP9QPolygonF @ 9901 NONAME + _ZNK7QBezier12addToPolygonEP9QPolygonF @ 9901 NONAME ABSENT _ZNK7QBezier16bezierOnIntervalEff @ 9902 NONAME _ZNK7QBezier17addToPolygonMixedEP9QPolygonF @ 9903 NONAME ABSENT _ZNK7QBezier17stationaryYPointsERfS0_ @ 9904 NONAME @@ -9909,7 +9909,7 @@ EXPORTS _ZNK7QBezier6lengthEf @ 9908 NONAME _ZNK7QBezier7shiftedEPS_iff @ 9909 NONAME _ZNK7QBezier9tAtLengthEf @ 9910 NONAME - _ZNK7QBezier9toPolygonEv @ 9911 NONAME + _ZNK7QBezier9toPolygonEv @ 9911 NONAME ABSENT _ZNK7QBitmap11transformedERK10QTransform @ 9912 NONAME _ZNK7QBitmap11transformedERK7QMatrix @ 9913 NONAME _ZNK7QBitmapcv8QVariantEv @ 9914 NONAME @@ -12002,4 +12002,14 @@ EXPORTS _ZN12QPixmapCache10allPixmapsEv @ 12001 NONAME _ZN12QPixmapCache20flushDetachedPixmapsEv @ 12002 NONAME _ZN12QPixmapCache9totalUsedEv @ 12003 NONAME + _ZN20QGraphicsItemPrivate30updatePaintedViewBoundingRectsEb @ 12004 NONAME + _ZN20QGraphicsViewPrivate13setUpdateClipEP13QGraphicsItem @ 12005 NONAME + _ZN23QImageTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj @ 12006 NONAME + _ZN23QImageTextureGlyphCache17createTextureDataEii @ 12007 NONAME + _ZN23QImageTextureGlyphCache17resizeTextureDataEii @ 12008 NONAME + _ZNK23QImageTextureGlyphCache11glyphMarginEv @ 12009 NONAME + _ZNK7QBezier12addToPolygonEP9QPolygonFf @ 12010 NONAME + _ZNK7QBezier9toPolygonEf @ 12011 NONAME + _ZTI23QImageTextureGlyphCache @ 12012 NONAME + _ZTV23QImageTextureGlyphCache @ 12013 NONAME diff --git a/src/s60installs/eabi/QtNetworku.def b/src/s60installs/eabi/QtNetworku.def index 2566415..87e0805 100644 --- a/src/s60installs/eabi/QtNetworku.def +++ b/src/s60installs/eabi/QtNetworku.def @@ -1167,4 +1167,5 @@ EXPORTS _ZNK13QBearerEngine19configurationsInUseEv @ 1166 NONAME _ZNK21QNetworkAccessManager17networkAccessibleEv @ 1167 NONAME _ZN35QNetworkConfigurationManagerPrivate12capabilitiesEv @ 1168 NONAME + _ZN10QTcpServer20addPendingConnectionEP10QTcpSocket @ 1169 NONAME -- cgit v0.12 From 61a211e45dd01751acb0adcbb3ae5496aa4bf3b9 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 18 May 2010 16:06:18 +0300 Subject: Set edit focus to proper control in flightinfo demo Set edit focus to line edit control when user needs to input flight number. Task-number: QTBUG-10124 Reviewed-by: Shane Kearns --- demos/embedded/flightinfo/flightinfo.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/demos/embedded/flightinfo/flightinfo.cpp b/demos/embedded/flightinfo/flightinfo.cpp index 6cc1876..425d6aa 100644 --- a/demos/embedded/flightinfo/flightinfo.cpp +++ b/demos/embedded/flightinfo/flightinfo.cpp @@ -174,6 +174,10 @@ private slots: ui.infoBox->hide(); ui.flightStatus->hide(); ui.flightName->setText("Enter flight number"); + ui.flightEdit->setFocus(); +#ifdef QT_KEYPAD_NAVIGATION + ui.flightEdit->setEditFocus(true); +#endif m_map = QPixmap(); update(); } -- cgit v0.12 From 650fefd7e25b10d88048d2a465a27c479d80636d Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 19 May 2010 10:41:46 +1000 Subject: removed test file, part of mediaservice removal. Reviewed-by:Justin McPherson --- tests/auto/qsoundeffect/test.wav | Bin 38316 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/auto/qsoundeffect/test.wav diff --git a/tests/auto/qsoundeffect/test.wav b/tests/auto/qsoundeffect/test.wav deleted file mode 100644 index e4088a9..0000000 Binary files a/tests/auto/qsoundeffect/test.wav and /dev/null differ -- cgit v0.12 From f29f46107204ea542ec899915508a69f520f6159 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 19 May 2010 11:35:48 +1000 Subject: Fixed tst_compilerwarnings test failure due to icecc node failures. When an icecc node has some system error, icecc on the client side outputs a warning. Since it's able to recover and the warning has nothing to do with the code, we should ignore it. Other distributed compile tools will have similar issues, but no attempt has been made to cover them. --- .../auto/compilerwarnings/tst_compilerwarnings.cpp | 30 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp index f910a18..82c327a 100644 --- a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp +++ b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp @@ -62,6 +62,9 @@ class tst_CompilerWarnings: public QObject private slots: void warnings_data(); void warnings(); + +private: + bool shouldIgnoreWarning(QString const&); }; #if 0 @@ -242,16 +245,37 @@ void tst_CompilerWarnings::warnings() if (!errs.isEmpty()) { errList = errs.split("\n"); qDebug() << "Arguments:" << args; - foreach (QString err, errList) { - qDebug() << err; + QStringList validErrors; + foreach (QString const& err, errList) { + bool ignore = shouldIgnoreWarning(err); + qDebug() << err << (ignore ? " [ignored]" : ""); + if (!ignore) { + validErrors << err; + } } + errList = validErrors; } QCOMPARE(errList.count(), 0); // verbose info how many lines of errors in output - QVERIFY(errs.isEmpty()); tmpQSourceFile.remove(); } +bool tst_CompilerWarnings::shouldIgnoreWarning(QString const& warning) +{ + if (warning.isEmpty()) { + return true; + } + + // icecc outputs warnings if some icecc node breaks + if (warning.startsWith("ICECC[")) { + return true; + } + + // Add more bogus warnings here + + return false; +} + QTEST_APPLESS_MAIN(tst_CompilerWarnings) #include "tst_compilerwarnings.moc" -- cgit v0.12 From 68177eeeecaabb46ab01326c268690fcde2ef367 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 19 May 2010 10:57:47 +0300 Subject: Fix build break in Symbian Fix this makefile syntax error when building Qt from root: "makefile:60: *** target pattern contains no `%'. Stop." Break was caused by having absolute path in $(MAKEFILE) variable, which broke subdir targets. Reviewed-by: Janne Koskinen --- qmake/generators/symbian/symmake_abld.cpp | 2 +- qmake/generators/symbian/symmake_sbsv2.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp index 0ba1a3c..7e3fb45 100644 --- a/qmake/generators/symbian/symmake_abld.cpp +++ b/qmake/generators/symbian/symmake_abld.cpp @@ -199,7 +199,7 @@ void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool t << "# ==============================================================================" << "\n" << endl; t << endl; - t << "MAKEFILE = " << wrapperFile.fileName() << endl; + t << "MAKEFILE = " << fileInfo(wrapperFile.fileName()).fileName() << endl; t << "QMAKE = " << var("QMAKE_QMAKE") << endl; t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp index 3a6706a..feacbef 100644 --- a/qmake/generators/symbian/symmake_sbsv2.cpp +++ b/qmake/generators/symbian/symmake_sbsv2.cpp @@ -143,7 +143,7 @@ void SymbianSbsv2MakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, boo t << "#" << endl; t << "# ==============================================================================" << "\n" << endl; t << endl; - t << "MAKEFILE = " << wrapperFile.fileName() << endl; + t << "MAKEFILE = " << fileInfo(wrapperFile.fileName()).fileName() << endl; t << "QMAKE = " << var("QMAKE_QMAKE") << endl; t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; -- cgit v0.12 From fa608f9094591c146f9170ba485ea2e4d7827dca Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 19 May 2010 10:20:08 +0200 Subject: Small hack to allow forcing off font smoothing on Mac OS X In declarative all text is cached in a transparent buffer. Using subpixel antialiasing for this gives subpar results, and for better results, we want to turn off the font smoothing in the OS for this case. Since we cannot efficiently detect non-opaque destination pixels, we have to have a way where a user can override the default. We'll introduce a style strategy for this later, but for now we only want to enable the use of CGContextSetShouldSmoothFonts() to explicitly turn smoothing off in the declarative context. We still override if font smoothing has been explicitly turned off by us for the context by the TextAntialiasing flag. Task-number: QT-2776 Reviewed-by: MortenS --- src/gui/painting/qpaintengine_mac.cpp | 6 +++++- src/gui/painting/qpaintengine_mac_p.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp index 14ba94e..e5323d8 100644 --- a/src/gui/painting/qpaintengine_mac.cpp +++ b/src/gui/painting/qpaintengine_mac.cpp @@ -1390,7 +1390,11 @@ QCoreGraphicsPaintEngine::updateRenderHints(QPainter::RenderHints hints) CGContextSetInterpolationQuality(d->hd, (hints & QPainter::SmoothPixmapTransform) ? kCGInterpolationHigh : kCGInterpolationNone); } - CGContextSetShouldSmoothFonts(d->hd, hints & QPainter::TextAntialiasing); + bool textAntialiasing = (hints & QPainter::TextAntialiasing) == QPainter::TextAntialiasing; + if (!textAntialiasing || d->disabledSmoothFonts) { + d->disabledSmoothFonts = !textAntialiasing; + CGContextSetShouldSmoothFonts(d->hd, textAntialiasing); + } } /* diff --git a/src/gui/painting/qpaintengine_mac_p.h b/src/gui/painting/qpaintengine_mac_p.h index c9ab419..940b2bc 100644 --- a/src/gui/painting/qpaintengine_mac_p.h +++ b/src/gui/painting/qpaintengine_mac_p.h @@ -148,7 +148,7 @@ class QCoreGraphicsPaintEnginePrivate : public QPaintEnginePrivate Q_DECLARE_PUBLIC(QCoreGraphicsPaintEngine) public: QCoreGraphicsPaintEnginePrivate() - : hd(0), shading(0), stackCount(0), complexXForm(false) + : hd(0), shading(0), stackCount(0), complexXForm(false), disabledSmoothFonts(false) { } @@ -168,6 +168,7 @@ public: CGShadingRef shading; int stackCount; bool complexXForm; + bool disabledSmoothFonts; enum { CosmeticNone, CosmeticTransformPath, CosmeticSetPenWidth } cosmeticPen; // pixel and cosmetic pen size in user coordinates. -- cgit v0.12 From 28b894f65c5aba01d5ee80c20f617478faaee7e7 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 19 May 2010 10:58:11 +0200 Subject: Fix a memory leak from QItemSelectionModel when changing the model Reviewed-By: ogoffart Task-Number: QTBUG-10806 --- src/gui/itemviews/qabstractitemview.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 97fd6e1..064f499 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -679,7 +679,11 @@ void QAbstractItemView::setModel(QAbstractItemModel *model) connect(d->model, SIGNAL(modelReset()), this, SLOT(reset())); connect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); } - setSelectionModel(new QItemSelectionModel(d->model, this)); + + QItemSelectionModel *selection_model = new QItemSelectionModel(d->model, this); + connect(d->model, SIGNAL(destroyed()), selection_model, SLOT(deleteLater())); + setSelectionModel(selection_model); + reset(); // kill editors, set new root and do layout } -- cgit v0.12 From 8cbf269e14b372ee3174c2706dd0cc4df37eef1a Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 19 May 2010 11:38:58 +0200 Subject: Fix platform regression: Support QFont::setStretch() on Cocoa QFont::setStretch() would previously have no effect on Mac OS X/Cocoa. Task-number: QTBUG-10585 Reviewed-by: Eskil Done-by: Andy --- src/gui/text/qfontengine_mac.mm | 18 +++++++++++++----- src/gui/text/qfontengine_p.h | 3 ++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index a6510cb..3be6d28 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -162,9 +162,14 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, con QCFString name; ATSFontGetName(atsFontRef, kATSOptionFlagsDefault, &name); + transform = CGAffineTransformIdentity; + if (fontDef.stretch != 100) { + transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1); + } + QCFType descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize); - QCFType baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, 0); - ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, 0, symbolicTraits, symbolicTraits); + QCFType baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, &transform); + ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, &transform, symbolicTraits, symbolicTraits); // CTFontCreateCopyWithSymbolicTraits returns NULL if we ask for a trait that does // not exist for the given font. (for example italic) @@ -378,7 +383,10 @@ QCoreTextFontEngine::QCoreTextFontEngine(CTFontRef font, const QFontDef &def, if (fontDef.style != QFont::StyleNormal && !(traits & kCTFontItalicTrait)) { synthesisFlags |= SynthesizedItalic; } - + transform = CGAffineTransformIdentity; + if (fontDef.stretch != 100) { + transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1); + } QByteArray os2Table = getSfntTable(MAKE_TAG('O', 'S', '/', '2')); if (os2Table.size() >= 10) fsType = qFromBigEndian(reinterpret_cast(os2Table.constData() + 8)); @@ -503,7 +511,7 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt if (synthesisFlags & QFontEngine::SynthesizedItalic) cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -tanf(14 * acosf(0) / 90), 1, 0, 0)); -// ### cgMatrix = CGAffineTransformConcat(cgMatrix, transform); + cgMatrix = CGAffineTransformConcat(cgMatrix, transform); CGContextSetTextMatrix(ctx, cgMatrix); @@ -626,7 +634,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, int margin, bool aa) if (synthesisFlags & QFontEngine::SynthesizedItalic) cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, tanf(14 * acosf(0) / 90), 1, 0, 0)); -// ### cgMatrix = CGAffineTransformConcat(cgMatrix, transform); + cgMatrix = CGAffineTransformConcat(cgMatrix, transform); CGContextSetTextMatrix(ctx, cgMatrix); CGContextSetRGBFillColor(ctx, 1, 1, 1, 1); diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index e645caf..922acfb 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -462,6 +462,7 @@ private: CGFontRef cgFont; QCoreTextFontEngineMulti *parentEngine; int synthesisFlags; + CGAffineTransform transform; friend class QCoreTextFontEngineMulti; }; @@ -493,7 +494,7 @@ private: uint fontIndexForFont(CTFontRef id) const; CTFontRef ctfont; mutable QCFType attributeDict; - + CGAffineTransform transform; friend class QFontDialogPrivate; }; # endif //MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 -- cgit v0.12 From 5ba7b062c3c124f4f9669ec70295a21c84c9fd82 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 19 May 2010 10:57:40 +0200 Subject: Improve virtual mouse on E72 optical joystick Uses scancodes instead of keycodes, to get access to the 8-way cursor keys introduced in S60 3.2. (EStdKeyDevice10-13) Doubled the rate of acceleration and top speed of the cursor (this applies to all phones, but feedback was that the cursor was too slow) Multiple key presses within 500ms of each other are treated the same as key repeat events. This is because the E72 optical joystick sends pulsed key presses. Task-number: QTBUG-5711 Reviewed-by: Sami Merila --- src/gui/kernel/qapplication_s60.cpp | 203 +++++++++++++++++++++++------------- src/gui/kernel/qt_s60_p.h | 13 ++- 2 files changed, 138 insertions(+), 78 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index ea5c14c..fa07b1a 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -590,57 +590,12 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod case EEventKeyUp: case EEventKey: { - // S60 has a confusing way of delivering key events. There are three types of - // events: EKeyEvent, EKeyEventDown and EKeyEventUp. When a key is pressed, the - // two first events are generated. When releasing the key, the last one is - // generated. - // Because S60 does not generate keysyms for EKeyEventDown and EKeyEventUp events, - // we need to do some special tricks to map it to the Qt way. First, we completely - // discard EKeyEventDown events, since they are redundant. Second, since - // EKeyEventUp does not give us a keysym, we need to cache the keysyms from - // the EKeyEvent events. This is what resolveS60ScanCode does. - - - // ### hackish way to send Qt application to background when pressing right softkey - /* - if( keyEvent.iScanCode == EStdKeyDevice1 ) { - S60->window_group->SetOrdinalPosition(-1); - qApp->setActiveWindow(0); - return EKeyWasNotConsumed; - } - */ - - TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode, - keyEvent.iCode); - int keyCode; - if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used - keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode); - } else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) { - // Normal characters keys. - keyCode = s60Keysym; - } else { - // Special S60 keys. - keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym); - } - #ifndef QT_NO_CURSOR if (S60->mouseInteractionEnabled && S60->virtualMouseRequired) { //translate keys to pointer - if (keyCode >= Qt::Key_Left && keyCode <= Qt::Key_Down || keyCode == Qt::Key_Select) { - /*Explanation about virtualMouseAccel: - Tapping an arrow key allows precise pixel positioning - Holding an arrow key down, acceleration is applied to allow cursor - to be quickly moved to another part of the screen by key repeats. - */ - if (S60->virtualMouseLastKey == keyCode) { - S60->virtualMouseAccel *= 2; - if (S60->virtualMouseAccel > S60->virtualMouseMaxAccel) - S60->virtualMouseAccel = S60->virtualMouseMaxAccel; - } - else - S60->virtualMouseAccel = 1; - S60->virtualMouseLastKey = keyCode; - + if ((keyEvent.iScanCode >= EStdKeyLeftArrow && keyEvent.iScanCode <= EStdKeyDownArrow) || + (keyEvent.iScanCode >= EStdKeyDevice10 && keyEvent.iScanCode <= EStdKeyDevice13) || + keyEvent.iScanCode == EStdKeyDevice3) { QPoint pos = QCursor::pos(); TPointerEvent fakeEvent; fakeEvent.iType = (TPointerEvent::TType)(-1); @@ -648,54 +603,100 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod TInt x = pos.x(); TInt y = pos.y(); if (type == EEventKeyUp) { - if (keyCode == Qt::Key_Select && - (S60->virtualMousePressedKeys & QS60Data::Select)) - fakeEvent.iType = TPointerEvent::EButton1Up; - S60->virtualMouseAccel = 1; - S60->virtualMouseLastKey = 0; - switch (keyCode) { - case Qt::Key_Left: + S60->virtualMouseAccelTimeout.start(); + switch (keyEvent.iScanCode) { + case EStdKeyLeftArrow: S60->virtualMousePressedKeys &= ~QS60Data::Left; break; - case Qt::Key_Right: + case EStdKeyRightArrow: S60->virtualMousePressedKeys &= ~QS60Data::Right; break; - case Qt::Key_Up: + case EStdKeyUpArrow: S60->virtualMousePressedKeys &= ~QS60Data::Up; break; - case Qt::Key_Down: + case EStdKeyDownArrow: S60->virtualMousePressedKeys &= ~QS60Data::Down; break; - case Qt::Key_Select: + // diagonal keys (named aliases don't exist in 3.1 SDK) + case EStdKeyDevice10: + S60->virtualMousePressedKeys &= ~QS60Data::LeftUp; + break; + case EStdKeyDevice11: + S60->virtualMousePressedKeys &= ~QS60Data::RightUp; + break; + case EStdKeyDevice12: + S60->virtualMousePressedKeys &= ~QS60Data::RightDown; + break; + case EStdKeyDevice13: + S60->virtualMousePressedKeys &= ~QS60Data::LeftDown; + break; + case EStdKeyDevice3: //select + if (S60->virtualMousePressedKeys & QS60Data::Select) + fakeEvent.iType = TPointerEvent::EButton1Up; S60->virtualMousePressedKeys &= ~QS60Data::Select; break; } } else if (type == EEventKey) { - if (keyCode != Qt::Key_Select) + int dx = 0; + int dy = 0; + if (keyEvent.iScanCode != EStdKeyDevice3) { m_doubleClickTimer.invalidate(); - switch (keyCode) { - case Qt::Key_Left: + //reset mouse accelleration after a short time with no moves + const int maxTimeBetweenKeyEventsMs = 500; + if (S60->virtualMouseAccelTimeout.isValid() && + S60->virtualMouseAccelTimeout.hasExpired(maxTimeBetweenKeyEventsMs)) { + S60->virtualMouseAccelDX = 0; + S60->virtualMouseAccelDY = 0; + } + S60->virtualMouseAccelTimeout.invalidate(); + } + switch (keyEvent.iScanCode) { + case EStdKeyLeftArrow: S60->virtualMousePressedKeys |= QS60Data::Left; - x -= S60->virtualMouseAccel; + dx = -1; fakeEvent.iType = TPointerEvent::EMove; break; - case Qt::Key_Right: + case EStdKeyRightArrow: S60->virtualMousePressedKeys |= QS60Data::Right; - x += S60->virtualMouseAccel; + dx = 1; fakeEvent.iType = TPointerEvent::EMove; break; - case Qt::Key_Up: + case EStdKeyUpArrow: S60->virtualMousePressedKeys |= QS60Data::Up; - y -= S60->virtualMouseAccel; + dy = -1; fakeEvent.iType = TPointerEvent::EMove; break; - case Qt::Key_Down: + case EStdKeyDownArrow: S60->virtualMousePressedKeys |= QS60Data::Down; - y += S60->virtualMouseAccel; + dy = 1; + fakeEvent.iType = TPointerEvent::EMove; + break; + case EStdKeyDevice10: + S60->virtualMousePressedKeys |= QS60Data::LeftUp; + dx = -1; + dy = -1; fakeEvent.iType = TPointerEvent::EMove; break; - case Qt::Key_Select: + case EStdKeyDevice11: + S60->virtualMousePressedKeys |= QS60Data::RightUp; + dx = 1; + dy = -1; + fakeEvent.iType = TPointerEvent::EMove; + break; + case EStdKeyDevice12: + S60->virtualMousePressedKeys |= QS60Data::RightDown; + dx = 1; + dy = 1; + fakeEvent.iType = TPointerEvent::EMove; + break; + case EStdKeyDevice13: + S60->virtualMousePressedKeys |= QS60Data::LeftDown; + dx = -1; + dy = 1; + fakeEvent.iType = TPointerEvent::EMove; + break; + case EStdKeyDevice3: // Platform bug. If you start pressing several keys simultaneously (for // example for drag'n'drop), Symbian starts producing spurious up and // down messages for some keys. Therefore, make sure we have a clean slate @@ -715,6 +716,32 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod } break; } + if (dx) { + int cdx = S60->virtualMouseAccelDX; + //reset accel on change of sign, else double accel + if (dx * cdx <= 0) + cdx = dx; + else + cdx *= 4; + //cap accelleration + if (dx * cdx > S60->virtualMouseMaxAccel) + cdx = dx * S60->virtualMouseMaxAccel; + //move mouse position + x += cdx; + S60->virtualMouseAccelDX = cdx; + } + + if (dy) { + int cdy = S60->virtualMouseAccelDY; + if (dy * cdy <= 0) + cdy = dy; + else + cdy *= 4; + if (dy * cdy > S60->virtualMouseMaxAccel) + cdy = dy * S60->virtualMouseMaxAccel; + y += cdy; + S60->virtualMouseAccelDY = cdy; + } } //clip to screen size (window server allows a sprite hotspot to be outside the screen) if (x < 0) @@ -733,12 +760,40 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod HandlePointerEvent(fakeEvent); return EKeyWasConsumed; } - else { - S60->virtualMouseLastKey = keyCode; - S60->virtualMouseAccel = 1; - } } #endif + // S60 has a confusing way of delivering key events. There are three types of + // events: EKeyEvent, EKeyEventDown and EKeyEventUp. When a key is pressed, the + // two first events are generated. When releasing the key, the last one is + // generated. + // Because S60 does not generate keysyms for EKeyEventDown and EKeyEventUp events, + // we need to do some special tricks to map it to the Qt way. First, we completely + // discard EKeyEventDown events, since they are redundant. Second, since + // EKeyEventUp does not give us a keysym, we need to cache the keysyms from + // the EKeyEvent events. This is what resolveS60ScanCode does. + + + // ### hackish way to send Qt application to background when pressing right softkey + /* + if( keyEvent.iScanCode == EStdKeyDevice1 ) { + S60->window_group->SetOrdinalPosition(-1); + qApp->setActiveWindow(0); + return EKeyWasNotConsumed; + } + */ + + TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode, + keyEvent.iCode); + int keyCode; + if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used + keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode); + } else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) { + // Normal characters keys. + keyCode = s60Keysym; + } else { + // Special S60 keys. + keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym); + } Qt::KeyboardModifiers mods = mapToQtModifiers(keyEvent.iModifiers); QKeyEventEx qKeyEvent(type == EEventKeyUp ? QEvent::KeyRelease : QEvent::KeyPress, keyCode, diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 1af8eeb..f560458 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -103,16 +103,21 @@ public: int defaultDpiX; int defaultDpiY; WId curWin; - int virtualMouseLastKey; enum PressedKeys { Select = 0x1, Right = 0x2, Down = 0x4, Left = 0x8, - Up = 0x10 + Up = 0x10, + LeftUp = 0x20, + RightUp = 0x40, + RightDown = 0x80, + LeftDown = 0x100 }; int virtualMousePressedKeys; // of the above type, but avoids casting problems - int virtualMouseAccel; + int virtualMouseAccelDX; + int virtualMouseAccelDY; + QElapsedTimer virtualMouseAccelTimeout; int virtualMouseMaxAccel; #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS int brokenPointerCursors : 1; @@ -248,7 +253,7 @@ inline void QS60Data::updateScreenSize() S60->screenWidthInTwips = params.iTwipsSize.iWidth; S60->screenHeightInTwips = params.iTwipsSize.iHeight; - S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 20; + S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 10; TReal inches = S60->screenHeightInTwips / (TReal)KTwipsPerInch; S60->defaultDpiY = S60->screenHeightInPixels / inches; -- cgit v0.12 From 78ff4ffadd7160b4e354dedafbaccfdbdef21995 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 19 May 2010 12:03:38 +0200 Subject: Update QtDeclarative .def files for 4.7 Reviewed-by: Trust Me --- src/s60installs/bwins/QtDeclarativeu.def | 8 ++++---- src/s60installs/eabi/QtDeclarativeu.def | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def index 3f2f7a0..c960614 100644 --- a/src/s60installs/bwins/QtDeclarativeu.def +++ b/src/s60installs/bwins/QtDeclarativeu.def @@ -1129,8 +1129,8 @@ EXPORTS ?flickDecelerationChanged@QDeclarativeFlickable@@IAEXXZ @ 1128 NONAME ; void QDeclarativeFlickable::flickDecelerationChanged(void) ?flickDirection@QDeclarativeFlickable@@QBE?AW4FlickDirection@1@XZ @ 1129 NONAME ABSENT ; enum QDeclarativeFlickable::FlickDirection QDeclarativeFlickable::flickDirection(void) const ?flickDirectionChanged@QDeclarativeFlickable@@IAEXXZ @ 1130 NONAME ABSENT ; void QDeclarativeFlickable::flickDirectionChanged(void) - ?flickEnded@QDeclarativeFlickable@@IAEXXZ @ 1131 NONAME ABSENT ; void QDeclarativeFlickable::flickEnded(void) - ?flickStarted@QDeclarativeFlickable@@IAEXXZ @ 1132 NONAME ABSENT ; void QDeclarativeFlickable::flickStarted(void) + ?flickEnded@QDeclarativeFlickable@@IAEXXZ @ 1131 NONAME ; void QDeclarativeFlickable::flickEnded(void) + ?flickStarted@QDeclarativeFlickable@@IAEXXZ @ 1132 NONAME ; void QDeclarativeFlickable::flickStarted(void) ?flickableChildren@QDeclarativeFlickable@@QAE?AU?$QDeclarativeListProperty@VQDeclarativeItem@@@@XZ @ 1133 NONAME ABSENT ; struct QDeclarativeListProperty QDeclarativeFlickable::flickableChildren(void) ?flickableData@QDeclarativeFlickable@@QAE?AU?$QDeclarativeListProperty@VQObject@@@@XZ @ 1134 NONAME ABSENT ; struct QDeclarativeListProperty QDeclarativeFlickable::flickableData(void) ?flickingChanged@QDeclarativeFlickable@@IAEXXZ @ 1135 NONAME ; void QDeclarativeFlickable::flickingChanged(void) @@ -1746,9 +1746,9 @@ EXPORTS ?moveCurrentIndexUp@QDeclarativeGridView@@QAEXXZ @ 1745 NONAME ; void QDeclarativeGridView::moveCurrentIndexUp(void) ?moveCursor@QDeclarativeTextInput@@AAEXXZ @ 1746 NONAME ; void QDeclarativeTextInput::moveCursor(void) ?moveCursorDelegate@QDeclarativeTextEdit@@AAEXXZ @ 1747 NONAME ; void QDeclarativeTextEdit::moveCursorDelegate(void) - ?movementEnded@QDeclarativeFlickable@@IAEXXZ @ 1748 NONAME ABSENT ; void QDeclarativeFlickable::movementEnded(void) + ?movementEnded@QDeclarativeFlickable@@IAEXXZ @ 1748 NONAME ; void QDeclarativeFlickable::movementEnded(void) ?movementEnding@QDeclarativeFlickable@@IAEXXZ @ 1749 NONAME ; void QDeclarativeFlickable::movementEnding(void) - ?movementStarted@QDeclarativeFlickable@@IAEXXZ @ 1750 NONAME ABSENT ; void QDeclarativeFlickable::movementStarted(void) + ?movementStarted@QDeclarativeFlickable@@IAEXXZ @ 1750 NONAME ; void QDeclarativeFlickable::movementStarted(void) ?movementStarting@QDeclarativeFlickable@@IAEXXZ @ 1751 NONAME ; void QDeclarativeFlickable::movementStarting(void) ?movieRequestFinished@QDeclarativeAnimatedImage@@AAEXXZ @ 1752 NONAME ; void QDeclarativeAnimatedImage::movieRequestFinished(void) ?movieUpdate@QDeclarativeAnimatedImage@@AAEXXZ @ 1753 NONAME ; void QDeclarativeAnimatedImage::movieUpdate(void) diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index 086e1b2..a26e193 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -1008,7 +1008,7 @@ EXPORTS _ZN21QDeclarativeDomObjectD1Ev @ 1007 NONAME _ZN21QDeclarativeDomObjectD2Ev @ 1008 NONAME _ZN21QDeclarativeDomObjectaSERKS_ @ 1009 NONAME - _ZN21QDeclarativeFlickable10flickEndedEv @ 1010 NONAME ABSENT + _ZN21QDeclarativeFlickable10flickEndedEv @ 1010 NONAME _ZN21QDeclarativeFlickable10timerEventEP11QTimerEvent @ 1011 NONAME _ZN21QDeclarativeFlickable10wheelEventEP24QGraphicsSceneWheelEvent @ 1012 NONAME _ZN21QDeclarativeFlickable11cancelFlickEv @ 1013 NONAME @@ -1018,10 +1018,10 @@ EXPORTS _ZN21QDeclarativeFlickable11setContentXEf @ 1017 NONAME _ZN21QDeclarativeFlickable11setContentYEf @ 1018 NONAME _ZN21QDeclarativeFlickable11visibleAreaEv @ 1019 NONAME - _ZN21QDeclarativeFlickable12flickStartedEv @ 1020 NONAME ABSENT + _ZN21QDeclarativeFlickable12flickStartedEv @ 1020 NONAME _ZN21QDeclarativeFlickable12setOverShootEb @ 1021 NONAME _ZN21QDeclarativeFlickable13flickableDataEv @ 1022 NONAME - _ZN21QDeclarativeFlickable13movementEndedEv @ 1023 NONAME ABSENT + _ZN21QDeclarativeFlickable13movementEndedEv @ 1023 NONAME _ZN21QDeclarativeFlickable13movingChangedEv @ 1024 NONAME _ZN21QDeclarativeFlickable13setPressDelayEi @ 1025 NONAME _ZN21QDeclarativeFlickable13viewportMovedEv @ 1026 NONAME @@ -1034,7 +1034,7 @@ EXPORTS _ZN21QDeclarativeFlickable15flickingChangedEv @ 1033 NONAME _ZN21QDeclarativeFlickable15geometryChangedERK6QRectFS2_ @ 1034 NONAME _ZN21QDeclarativeFlickable15mousePressEventEP24QGraphicsSceneMouseEvent @ 1035 NONAME - _ZN21QDeclarativeFlickable15movementStartedEv @ 1036 NONAME ABSENT + _ZN21QDeclarativeFlickable15movementStartedEv @ 1036 NONAME _ZN21QDeclarativeFlickable15setContentWidthEf @ 1037 NONAME _ZN21QDeclarativeFlickable16movementStartingEv @ 1038 NONAME _ZN21QDeclarativeFlickable16overShootChangedEv @ 1039 NONAME -- cgit v0.12 From e8bf969172647406cc400a5368a5eb624b2e1ec1 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 19 May 2010 15:12:19 +0200 Subject: Make the 'freeze' target work for linux/symbian. Users can type 'make freeze' to get the def files updated right in the git source tree --- mkspecs/features/symbian/def_files.prf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/symbian/def_files.prf b/mkspecs/features/symbian/def_files.prf index a1f0c8d..8bcd096 100644 --- a/mkspecs/features/symbian/def_files.prf +++ b/mkspecs/features/symbian/def_files.prf @@ -64,14 +64,14 @@ symbian-abld|symbian-sbsv2 { freeze_target.depends = first # The perl part is to convert to unix line endings and remove comments, which the s60 tools refuse to do. freeze_target.commands = perl -n -e \'next if (/; NEW/); s/\r//g; if (/MISSING:(.*)/x) { print(\"\$\$1 ABSENT\\n\"); } else { print; }\' < $$symbianObjdir/$${TARGET}.def > $$elf2e32FileToAdd - #QMAKE_EXTRA_TARGETS += freeze_target + QMAKE_EXTRA_TARGETS += freeze_target } else:contains(TEMPLATE, subdirs) { freeze_target.target = freeze freeze_target.CONFIG = recursive freeze_target.recurse = $$SUBDIRS - #QMAKE_EXTRA_TARGETS += freeze_target + QMAKE_EXTRA_TARGETS += freeze_target } else { freeze_target.target = freeze freeze_target.commands = - #QMAKE_EXTRA_TARGETS += freeze_target + QMAKE_EXTRA_TARGETS += freeze_target } -- cgit v0.12 From 6bdba9c7909d8f53e28823b16e82f89650eea16d Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 19 May 2010 15:43:38 +0200 Subject: Disable compiling unsupported classes for Symbian The accessibility classes are currently unsupported on Symbian, so don't compile them in. The various styles will not be pretty on symbian either, so don't compile them in. --- configure | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/configure b/configure index d357fde..dc0434f 100755 --- a/configure +++ b/configure @@ -607,7 +607,7 @@ mkdir -p "$outpath/config.tests" rm -f "$outpath/config.tests/.qmake.cache" cp "$QMAKE_VARS_FILE" "$outpath/config.tests/.qmake.cache" -QMakeVar add styles "cde mac motif plastique cleanlooks windows s60" +QMakeVar add styles "cde mac motif plastique cleanlooks windows" QMakeVar add decorations "default windows styled" QMakeVar add mouse-drivers "pc" if [ "$UNAME_SYSTEM" = "Linux" ] ; then @@ -4699,6 +4699,8 @@ if [ "$CFG_ZLIB" = "auto" ]; then fi case "$XPLATFORM" in *symbian*) + QMakeVar set styles "windows s60" #overwrite previous default + if test -z "$EPOCROOT"; then echo "Please export EPOCROOT. It should point to the sdk install dir" exit 1 @@ -4828,7 +4830,14 @@ fi # detect accessibility if [ "$CFG_ACCESSIBILITY" = "auto" ]; then - CFG_ACCESSIBILITY=yes + case "$XPLATFORM" in + symbian*) + # accessibility is currently unsupported + CFG_ACCESSIBILITY=no + ;; + *) + CFG_ACCESSIBILITY=yes + esac fi # auto-detect SQL-modules support -- cgit v0.12 From 219a7248733a8f9dce8674aab405e5223693f0a2 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 19 May 2010 16:37:02 +0200 Subject: Freetype is not used on symbian, don't use it. --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 79eb75a..e461fa1 100755 --- a/configure +++ b/configure @@ -4677,6 +4677,7 @@ fi case "$XPLATFORM" in *symbian*) QMakeVar set styles "windows s60" #overwrite previous default + CFG_LIBFREETYPE=no if test -z "$EPOCROOT"; then echo "Please export EPOCROOT. It should point to the sdk install dir" -- cgit v0.12 From e6557220bccbdbbc218dc9eab0eb426ba774435e Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 20 May 2010 11:20:21 +0300 Subject: Fix replacement functions in platform_paths.prf Clearing epocroot_prefix at the end of the file caused it to be empty at the time replacement functions were resolved. Reviewed-by: Janne Koskinen --- mkspecs/features/symbian/platform_paths.prf | 2 -- 1 file changed, 2 deletions(-) diff --git a/mkspecs/features/symbian/platform_paths.prf b/mkspecs/features/symbian/platform_paths.prf index f05a885..0e8770d 100644 --- a/mkspecs/features/symbian/platform_paths.prf +++ b/mkspecs/features/symbian/platform_paths.prf @@ -473,5 +473,3 @@ exists($${EPOCROOT}epoc32/include/platform_paths.prf) { STLLIB_USAGE_DEFINES = _WCHAR_T_DECLARED } - -epocroot_prefix = -- cgit v0.12