From f90aba898074dbd1edc07112b63b8816bbc5855c Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 24 Jul 2009 10:42:15 +0200 Subject: QNAM: Clarify docs about when a QNetworkReply can be deleted Task-number: 258644 Reviewed-by: Thiago --- src/network/access/qnetworkaccessmanager.cpp | 9 +++++++-- src/network/access/qnetworkreply.cpp | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 748d893..8eb2c1b 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -121,7 +121,9 @@ static void ensureInitialized() as well as meta-data (headers, etc.). \note After the request has finished, it is the responsibility of the user - to delete the QNetworkReply object at an appropriate time. + to delete the QNetworkReply object at an appropriate time. Do not directly + delete it inside the slot connected to finished(). You can use the + deleteLater() function. A more involved example, assuming the manager is already existent, can be: @@ -199,6 +201,9 @@ static void ensureInitialized() See QNetworkReply::finished() for information on the status that the object will be in. + \note Do not delete the \a reply object in the slot connected to this + signal. Use deleteLater(). + \sa QNetworkReply::finished(), QNetworkReply::error() */ @@ -573,7 +578,7 @@ QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request) The returned QNetworkReply object will be open for reading and will contain the reply sent by the server to the POST request. - Note: sending a POST request on protocols other than HTTP and + \note sending a POST request on protocols other than HTTP and HTTPS is undefined and will probably fail. \sa get(), put() diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp index c655918..a7a77cb 100644 --- a/src/network/access/qnetworkreply.cpp +++ b/src/network/access/qnetworkreply.cpp @@ -87,6 +87,9 @@ QNetworkReplyPrivate::QNetworkReplyPrivate() indicates the progress of the upload for operations that have such content. + \note Do not delete the object in the slot connected to the + error() or finished() signal. Use deleteLater(). + \sa QNetworkRequest, QNetworkAccessManager */ @@ -228,6 +231,9 @@ QNetworkReplyPrivate::QNetworkReplyPrivate() QNetworkAccessManager::finished() where that signal's reply parameter is this object. + \note Do not delete the object in the slot connected to this + signal. Use deleteLater(). + \sa QNetworkAccessManager::finished() */ @@ -242,6 +248,9 @@ QNetworkReplyPrivate::QNetworkReplyPrivate() detected. Call errorString() to obtain a textual representation of the error condition. + \note Do not delete the object in the slot connected to this + signal. Use deleteLater(). + \sa error(), errorString() */ -- cgit v0.12 From 42c8c59a7be5e1906de09b6a007b868c897ab9e1 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 24 Jul 2009 12:10:21 +0200 Subject: Prematurely creating a dialog as a sheet causes problems Prematurely creating a dialog as a sheet and then calling exec() on it will show a window w/o decorations. The problem is that first telling a window to be a sheet, and then tell it to exec, is unambigious. Because doing the latter implies application modality (when modality is not set), which again implies not using a sheet. Calling exec (and setting modality) will win over window flags, so in this case, we now recreate the window as a normal app-modal dialog. Task: 254524 Reviewed-by: Trenton Schulz --- doc/src/qnamespace.qdoc | 5 ++++- src/gui/kernel/qwidget.cpp | 4 ++++ src/gui/kernel/qwidget_mac.mm | 51 +++++++++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/doc/src/qnamespace.qdoc b/doc/src/qnamespace.qdoc index ca5c981..5858b4b 100644 --- a/doc/src/qnamespace.qdoc +++ b/doc/src/qnamespace.qdoc @@ -1861,7 +1861,10 @@ We refer to a top-level window that has a parent as a \e secondary window. - \value Sheet Indicates that the widget is a Macintosh sheet. + \value Sheet Indicates that the window is a Macintosh sheet. Since + using a sheet implies window modality, the recommended + way is to use QWidget::setWindowModality(), or + QDialog::open(), instead. \value Drawer Indicates that the widget is a Macintosh drawer. diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index fb9084e..1e0f09c 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -9801,6 +9801,10 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) data->window_modality = (w && w->testAttribute(Qt::WA_GroupLeader)) ? Qt::WindowModal : Qt::ApplicationModal; + // Some window managers does not allow us to enter modal after the + // window is showing. Therefore, to be consistent, we cannot call + // QApplicationPrivate::enterModal(this) here. The window must be + // hidden before changing modality. } if (testAttribute(Qt::WA_WState_Created)) { // don't call setModal_sys() before create_sys() diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index f96d061..0a31a28 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4750,31 +4750,40 @@ void QWidgetPrivate::setModal_sys() || (primaryWindow && primaryWindow->windowModality() == Qt::WindowModal)){ // Window should be window-modal (which implies a sheet). if (old_wclass != kSheetWindowClass){ - // We cannot convert a created window to a sheet. So we recreate the window: + // We cannot convert a created window to a sheet. + // So we recreate the window: recreateMacWindow(); return; } - } else if (!(q->data->window_flags & Qt::CustomizeWindowHint)) { - if (old_wclass == kDocumentWindowClass || old_wclass == kFloatingWindowClass || old_wclass == kUtilityWindowClass){ - // Only change the class to kMovableModalWindowClass if the no explicit jewels - // are set (kMovableModalWindowClass can't contain them), and the current window class - // can be converted to modal (according to carbon doc). Mind the order of - // HIWindowChangeClass and ChangeWindowAttributes. - WindowGroupRef group = GetWindowGroup(windowRef); - HIWindowChangeClass(windowRef, kMovableModalWindowClass); - quint32 tmpWattr = kWindowCloseBoxAttribute | kWindowHorizontalZoomAttribute; - ChangeWindowAttributes(windowRef, tmpWattr, kWindowNoAttributes); - ChangeWindowAttributes(windowRef, kWindowNoAttributes, tmpWattr); - // If the window belongs to a qt-created group, set that group once more: - if (data.window_flags & Qt::WindowStaysOnTopHint - || q->windowType() == Qt::Popup - || q->windowType() == Qt::ToolTip) - SetWindowGroup(windowRef, group); + } else { + // Window should be application-modal (which implies NOT using a sheet). + if (old_wclass == kSheetWindowClass){ + // We cannot convert a sheet to a window. + // So we recreate the window: + recreateMacWindow(); + return; + } else if (!(q->data->window_flags & Qt::CustomizeWindowHint)) { + if (old_wclass == kDocumentWindowClass || old_wclass == kFloatingWindowClass || old_wclass == kUtilityWindowClass){ + // Only change the class to kMovableModalWindowClass if the no explicit jewels + // are set (kMovableModalWindowClass can't contain them), and the current window class + // can be converted to modal (according to carbon doc). Mind the order of + // HIWindowChangeClass and ChangeWindowAttributes. + WindowGroupRef group = GetWindowGroup(windowRef); + HIWindowChangeClass(windowRef, kMovableModalWindowClass); + quint32 tmpWattr = kWindowCloseBoxAttribute | kWindowHorizontalZoomAttribute; + ChangeWindowAttributes(windowRef, tmpWattr, kWindowNoAttributes); + ChangeWindowAttributes(windowRef, kWindowNoAttributes, tmpWattr); + // If the window belongs to a qt-created group, set that group once more: + if (data.window_flags & Qt::WindowStaysOnTopHint + || q->windowType() == Qt::Popup + || q->windowType() == Qt::ToolTip) + SetWindowGroup(windowRef, group); + } + // Popups are usually handled "special" and are never modal. + Qt::WindowType winType = q->windowType(); + if (winType != Qt::Popup && winType != Qt::ToolTip) + SetWindowModality(windowRef, kWindowModalityAppModal, 0); } - // Popups are usually handled "special" and are never modal. - Qt::WindowType winType = q->windowType(); - if (winType != Qt::Popup && winType != Qt::ToolTip) - SetWindowModality(windowRef, kWindowModalityAppModal, 0); } } else if (windowRef) { if (old_wclass == kSheetWindowClass){ -- cgit v0.12 From e4c3734d31dd4f76c96b0b8f7607347aeea328c3 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 24 Jul 2009 15:07:51 +0200 Subject: Musicplayer example crashes when trying to open unvalid file Reason: Example tries to get media from QList with an index out of bounds. Nothing to do with Phonon. Task-number: 253307 --- examples/phonon/musicplayer/mainwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/phonon/musicplayer/mainwindow.cpp b/examples/phonon/musicplayer/mainwindow.cpp index a9bb379..ccea606 100644 --- a/examples/phonon/musicplayer/mainwindow.cpp +++ b/examples/phonon/musicplayer/mainwindow.cpp @@ -157,9 +157,12 @@ void MainWindow::tableClicked(int row, int /* column */) mediaObject->stop(); mediaObject->clearQueue(); + if (row >= sources.size()) + return; + mediaObject->setCurrentSource(sources[row]); - if (wasPlaying) + if (wasPlaying) mediaObject->play(); else mediaObject->stop(); -- cgit v0.12 From 295f0fd9b98a7e4846c7a8c8c92116fb05f7cbd7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 25 Jul 2009 12:05:28 +0200 Subject: Fix a running external tests: user program headers must come first. No wonder QT_SHAREDPOINTER_TRACK_POINTERS was having no effect: there was an #include before it. (cherry picked from commit 4c12010fac555bce0a6c8d69a267a56f4c15087f) --- tests/auto/qsharedpointer/externaltests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qsharedpointer/externaltests.cpp b/tests/auto/qsharedpointer/externaltests.cpp index 75ac5f1..d1618d1 100644 --- a/tests/auto/qsharedpointer/externaltests.cpp +++ b/tests/auto/qsharedpointer/externaltests.cpp @@ -323,6 +323,8 @@ namespace QTest { sourceCode.clear(); sourceCode.reserve(8192); + sourceCode += programHeader; + // Add Qt header includes if (qtModules & QExternalTest::QtCore) sourceCode += "#include \n"; @@ -356,8 +358,6 @@ namespace QTest { "#include \n" "#include \n"; - sourceCode += programHeader; - sourceCode += "\n" "void q_external_test_user_code()\n" -- cgit v0.12 From ba5b630fd58127a4bcfe2baf92603a7bc8899824 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Sun, 26 Jul 2009 20:18:02 +0200 Subject: Doc - Mention Google trademarks with the two examples using Google services. Reviewed-by: Simon Hausmann --- doc/src/examples/googlechat.qdoc | 1 + doc/src/examples/googlesuggest.qdoc | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/src/examples/googlechat.qdoc b/doc/src/examples/googlechat.qdoc index 42a0198..7c9d7db 100644 --- a/doc/src/examples/googlechat.qdoc +++ b/doc/src/examples/googlechat.qdoc @@ -48,4 +48,5 @@ \image googlechat-example.png + \note The Google Talk instant messaging service is a registered trademark of Google Inc. */ diff --git a/doc/src/examples/googlesuggest.qdoc b/doc/src/examples/googlesuggest.qdoc index 1752420..e3d2b1f 100644 --- a/doc/src/examples/googlesuggest.qdoc +++ b/doc/src/examples/googlesuggest.qdoc @@ -48,4 +48,5 @@ \image googlesuggest-example.png + \note The Google Suggest suggestion service is a registered trademark of Google Inc. */ -- cgit v0.12 From 5a7d29039917d9f0faf373045e8dbb274837c11d Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Mon, 27 Jul 2009 14:50:10 +1000 Subject: Fixed failure of tst_qlocale if run when LC_ALL is set. This test tried to be unaffected by the locale environment variables set by the user by explicitly overwriting them and spawning a new process. However this was only done for LANG and not the other variables which can affect the locale. Do it for all the locale variables. Also, the previous approach (store the current value with qgetenv, then put it back with qputenv later) doesn't really work because that effectively takes variables which weren't set and sets them to an empty string, which is not the same thing. Use QProcess::setEnvironment instead. Reviewed-by: Andy Shaw --- tests/auto/qlocale/tst_qlocale.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp index 8ac6ef0..82bd864 100644 --- a/tests/auto/qlocale/tst_qlocale.cpp +++ b/tests/auto/qlocale/tst_qlocale.cpp @@ -327,9 +327,8 @@ void tst_QLocale::emptyCtor() { \ /* Test constructor without arguments. Needs separate process */ \ /* because of caching of the system locale. */ \ - QString oldEnv = QString::fromLocal8Bit(qgetenv("LANG")); \ - qputenv("LANG", QString(req_lc).toLocal8Bit()); \ QProcess process; \ + process.setEnvironment(QStringList(env) << QString("LANG=%1").arg(req_lc)); \ process.start("syslocaleapp/syslocaleapp"); \ process.waitForReadyRead(); \ QString ret = QString(process.readAll()); \ @@ -337,18 +336,23 @@ void tst_QLocale::emptyCtor() QVERIFY2(!ret.isEmpty(), "Cannot launch external process"); \ QVERIFY2(QString(exp_str) == ret, QString("Expected: " + QString(exp_str) + ", got: " \ + ret + ". Requested: " + QString(req_lc)).toLatin1().constData()); \ - qputenv("LANG", oldEnv.toLocal8Bit()); \ + } + + // Get an environment free of any locale-related variables + QStringList env; + foreach (QString const& entry, QProcess::systemEnvironment()) { + if (entry.startsWith("LANG=") || entry.startsWith("LC_")) + continue; + env << entry; } // Get default locale. - QString old = QString::fromLocal8Bit(qgetenv("LANG")); - qputenv("LANG", ""); QProcess p; + p.setEnvironment(env); p.start("syslocaleapp/syslocaleapp"); p.waitForReadyRead(); QString defaultLoc = QString(p.readAll()); p.waitForFinished(); - qputenv("LANG", old.toLocal8Bit()); TEST_CTOR("C", "C") TEST_CTOR("bla", "C") -- cgit v0.12 From ebaae9e6a8694d6be4ec5c353a98d532e133245a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Mon, 27 Jul 2009 12:27:09 +0200 Subject: Fix crash when printing to PDF on Qt/Mac Priting to PDF would crash for applications built on Leopard when running on Tiger. Add the standard runtime version check to QFontEngineMac::faceId(). Task-number: 251791 Reviewed-by: Richard Moe Gustavsen --- src/gui/text/qfontengine_mac.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 327df45..72e5175 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -1560,6 +1560,7 @@ QFontEngine::FaceId QFontEngineMac::faceId() const { FaceId ret; #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) +if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { // CTFontGetPlatformFont FSRef ref; if (ATSFontGetFileReference(FMGetATSFontRefFromFont(fontID), &ref) != noErr) @@ -1567,7 +1568,9 @@ QFontEngine::FaceId QFontEngineMac::faceId() const ret.filename = QByteArray(128, 0); ret.index = fontID; FSRefMakePath(&ref, (UInt8 *)ret.filename.data(), ret.filename.size()); -#else +}else +#endif +{ FSSpec spec; if (ATSFontGetFileSpecification(FMGetATSFontRefFromFont(fontID), &spec) != noErr) return ret; @@ -1577,7 +1580,7 @@ QFontEngine::FaceId QFontEngineMac::faceId() const ret.filename = QByteArray(128, 0); ret.index = fontID; FSRefMakePath(&ref, (UInt8 *)ret.filename.data(), ret.filename.size()); -#endif +} return ret; } -- cgit v0.12 From 14c96b7079a0fb32d1c32d00f95a87e0e3ada8b6 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 27 Jul 2009 13:45:20 +0200 Subject: Add docs for Windows Server 2008 R2 to QSysInfo::WinVersion Windows Server 2008 R2 is based on kernel 6.1, the same as Windows 7. Reviewed-by: TrustMe --- src/corelib/global/qglobal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 48116b8..d15c102 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1079,7 +1079,7 @@ bool qSharedBuild() \value WV_XP Windows XP (operating system version 5.1) \value WV_2003 Windows Server 2003, Windows Server 2003 R2, Windows Home Server, Windows XP Professional x64 Edition (operating system version 5.2) \value WV_VISTA Windows Vista, Windows Server 2008 (operating system version 6.0) - \value WV_WINDOWS7 Windows 7 (operating system version 6.1) + \value WV_WINDOWS7 Windows 7, Windows Server 2008 R2 (operating system version 6.1) Alternatively, you may use the following macros which correspond directly to the Windows operating system version number: @@ -1088,7 +1088,7 @@ bool qSharedBuild() \value WV_5_1 Operating system version 5.1, corresponds to Windows XP \value WV_5_2 Operating system version 5.2, corresponds to Windows Server 2003, Windows Server 2003 R2, Windows Home Server, and Windows XP Professional x64 Edition \value WV_6_0 Operating system version 6.0, corresponds to Windows Vista and Windows Server 2008 - \value WV_6_1 Operating system version 6.1, corresponds to Windows 7 + \value WV_6_1 Operating system version 6.1, corresponds to Windows 7 and Windows Server 2008 R2 CE-based versions: -- cgit v0.12 From fab51e1d9ce57be4d786ad7c9df8bc695252a0de Mon Sep 17 00:00:00 2001 From: kh Date: Mon, 27 Jul 2009 15:08:00 +0200 Subject: Fix missing title quoting. Reviewed-by: kh --- tools/assistant/tools/assistant/centralwidget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index a384544..00a8893 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -739,8 +739,10 @@ void CentralWidget::setTabTitle(const QUrl &url) QTabBar *tabBar = qFindChild(tabWidget); for (int tab = 0; tab < tabBar->count(); ++tab) { HelpViewer *viewer = qobject_cast(tabWidget->widget(tab)); - if (viewer) - tabWidget->setTabText(tab, viewer->documentTitle().trimmed()); + if (viewer) { + tabWidget->setTabText(tab, + quoteTabTitle(viewer->documentTitle().trimmed())); + } } #else HelpViewer *viewer = currentHelpViewer(); -- cgit v0.12 From ef105812bd65d7536f2d403dd3b65a0b77ea843c Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 27 Jul 2009 16:00:47 +0200 Subject: Roll back the fancy updating of translucent windows. The problem with the fix, though it produces less flicker when resizing, is that it delays telling windows that the window has moved until after the window has been completely repainted. Problem with this is that functions that rely on windows to be up to date will fail until the backbuffer is flushed. This was the case for mapTo/FromGlobal, and potentially other functions too. Reviewed-By: Eskil --- src/gui/kernel/qwidget_win.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 3ab1ccb..f7ff2d0 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -1468,10 +1468,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) qt_wince_maximize(q); } else { #endif - if (!isTranslucentWindow) - MoveWindow(q->internalWinId(), fs.x(), fs.y(), fs.width(), fs.height(), true); - else if (isMove && !isResize) - SetWindowPos(q->internalWinId(), 0, fs.x(), fs.y(), 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); + MoveWindow(q->internalWinId(), fs.x(), fs.y(), fs.width(), fs.height(), true); } if (!q->isVisible()) InvalidateRect(q->internalWinId(), 0, FALSE); -- cgit v0.12 From 96fbc28c9b4e8e97eec43b99fc18ad29c269bd25 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 27 Jul 2009 21:16:34 +0200 Subject: Disable the pointer tracking feature in Qt 4.5. The functionality is broken, since pointers can be released by a QSharedPointer tracking a pointer of different type, which would leave behind pointers in the hash. The fix requires Qt 4.6 because of a new symbol being added. --- src/corelib/tools/qsharedpointer.cpp | 28 +++++----------------------- src/corelib/tools/qsharedpointer_impl.h | 6 ------ 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index ba62ce1..c9dccd3 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -833,42 +833,24 @@ namespace { }; } -Q_GLOBAL_STATIC(KnownPointers, knownPointers) +//Q_GLOBAL_STATIC(KnownPointers, knownPointers) QT_BEGIN_NAMESPACE /*! \internal */ -void QtSharedPointer::internalSafetyCheckAdd(const volatile void *ptr) +void QtSharedPointer::internalSafetyCheckAdd(const volatile void *) { - KnownPointers *const kp = knownPointers(); - if (!kp) - return; // end-game: the application is being destroyed already - - QMutexLocker lock(&kp->mutex); - void *actual = const_cast(ptr); - if (kp->values.contains(actual)) { - printBacktrace(knownPointers()->values.value(actual)); - qFatal("QSharedPointerData: internal self-check failed: pointer %p was already tracked " - "by another QSharedPointerData object", actual); - } - - kp->values.insert(actual, saveBacktrace()); + // functionality is broken + // fix requires Qt 4.6 } /*! \internal */ -void QtSharedPointer::internalSafetyCheckRemove(const volatile void *ptr) +void QtSharedPointer::internalSafetyCheckRemove(const volatile void *) { - KnownPointers *const kp = knownPointers(); - if (!kp) - return; // end-game: the application is being destroyed already - - QMutexLocker lock(&kp->mutex); - void *actual = const_cast(ptr); - kp->values.remove(actual); } QT_END_NAMESPACE diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 0471a1b..7aaed22 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -140,16 +140,10 @@ namespace QtSharedPointer { inline void internalConstruct(T *ptr) { -#ifdef QT_SHAREDPOINTER_TRACK_POINTERS - if (ptr) internalSafetyCheckAdd(ptr); -#endif value = ptr; } inline void internalDestroy() { -#ifdef QT_SHAREDPOINTER_TRACK_POINTERS - if (value) internalSafetyCheckRemove(value); -#endif } #if defined(Q_NO_TEMPLATE_FRIENDS) -- cgit v0.12 From 54cff1f39d04730ecbb6f2500711c27f3e99465c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 27 Jul 2009 15:36:26 -0700 Subject: Make porterduff operations work in DirectFB This patch makes us not fall back to the raster engine for most of the composition mode operations when doing blits. Primitives are still handled by Qt when composition != SourceOver Reviewed-by: Noam Rosenthal --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 130 +++++++++++++++------ 1 file changed, 97 insertions(+), 33 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index b264ac0..67aa516 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -59,10 +59,17 @@ class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate { public: enum TransformationTypeFlags { - NegativeScale = 0x100, - RectsUnsupported = (QTransform::TxRotate|QTransform::TxShear|QTransform::TxProject), - BlitUnsupported = (NegativeScale|RectsUnsupported) + Matrix_NegativeScale = 0x100, + Matrix_RectsUnsupported = (QTransform::TxRotate|QTransform::TxShear|QTransform::TxProject), + Matrix_BlitsUnsupported = (Matrix_NegativeScale|Matrix_RectsUnsupported) }; + + enum CompositionModeStatus { + PorterDuff_None = 0x0, + PorterDuff_SupportedBlits = 0x1, + PorterDuff_SupportedPrimitives = 0x2 + }; + QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p); ~QDirectFBPaintEnginePrivate(); @@ -100,7 +107,7 @@ private: bool antialiased; bool simplePen; - uint transformationType; // this is QTransform::type() + NegativeScale if qMin(transform.m11(), transform.m22()) < 0 + uint transformationType; // this is QTransform::type() + Matrix_NegativeScale if qMin(transform.m11(), transform.m22()) < 0 SurfaceCache *surfaceCache; @@ -112,7 +119,7 @@ private: bool dfbHandledClip; bool ignoreSystemClip; QDirectFBPaintDevice *dfbDevice; - bool unsupportedCompositionMode; + uint compositionModeStatus; QDirectFBPaintEngine *q; QRect currentClip; @@ -161,8 +168,12 @@ enum PaintOperation { #ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS template -static void rasterFallbackWarn(const char *msg, const char *, const device *, uint, bool, bool, bool, - const char *, const T1 &, const char *, const T2 &, const char *, const T3 &); +static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, + uint transformationType, bool simplePen, + bool dfbHandledClip, uint compositionModeStatus, + const char *nameOne, const T1 &one, + const char *nameTwo, const T2 &two, + const char *nameThree, const T3 &three); #endif #if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS @@ -173,7 +184,7 @@ static void rasterFallbackWarn(const char *msg, const char *, const device *, ui d_func()->transformationType, \ d_func()->simplePen, \ d_func()->dfbCanHandleClip(), \ - d_func()->unsupportedCompositionMode, \ + d_func()->compositionModeStatus, \ #one, one, #two, two, #three, three); \ if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ return; @@ -189,7 +200,7 @@ static void rasterFallbackWarn(const char *msg, const char *, const device *, ui d_func()->transformationType, \ d_func()->simplePen, \ d_func()->dfbCanHandleClip(), \ - d_func()->unsupportedCompositionMode, \ + d_func()->compositionModeStatus, \ #one, one, #two, two, #three, three); #else #define RASTERFALLBACK(op, one, two, three) @@ -233,6 +244,7 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) } d->prepare(d->dfbDevice); + d->setCompositionMode(state()->composition_mode); return QRasterPaintEngine::begin(device); } @@ -325,8 +337,8 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) Q_D(QDirectFBPaintEngine); d->updateClip(); const QBrush &brush = state()->brush; - if (d->unsupportedCompositionMode - || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported) + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || !d->simplePen || !d->dfbCanHandleClip() || !d->isSimpleBrush(brush)) { @@ -354,8 +366,8 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) Q_D(QDirectFBPaintEngine); d->updateClip(); const QBrush &brush = state()->brush; - if (d->unsupportedCompositionMode - || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported) + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || !d->simplePen || !d->dfbCanHandleClip() || !d->isSimpleBrush(brush)) { @@ -382,7 +394,9 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) { Q_D(QDirectFBPaintEngine); d->updateClip(); - if (d->unsupportedCompositionMode || !d->simplePen || !d->dfbCanHandleClip()) { + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) + || !d->simplePen + || !d->dfbCanHandleClip()) { RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); @@ -401,7 +415,9 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) { Q_D(QDirectFBPaintEngine); d->updateClip(); - if (d->unsupportedCompositionMode || !d->simplePen || !d->dfbCanHandleClip()) { + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) + || !d->simplePen + || !d->dfbCanHandleClip()) { RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); @@ -442,8 +458,8 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, d->updateClip(); #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE - if (d->unsupportedCompositionMode - || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported) + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) || !d->dfbCanHandleClip(r) #ifndef QT_DIRECTFB_IMAGECACHE || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN @@ -488,8 +504,8 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); d->lock(); QRasterPaintEngine::drawPixmap(r, pixmap, sr); - } else if (d->unsupportedCompositionMode - || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported) + } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) || !d->dfbCanHandleClip(r)) { RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); @@ -522,8 +538,8 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); d->lock(); QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset); - } else if (d->unsupportedCompositionMode - || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported) + } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) || !d->dfbCanHandleClip(r)) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); @@ -623,11 +639,13 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) if (brush.style() == Qt::NoBrush) return; d->updateClip(); - if (!d->unsupportedCompositionMode - && !(d->transformationType & (QDirectFBPaintEnginePrivate::RectsUnsupported)) - && d->dfbCanHandleClip(rect)) { + if (d->dfbCanHandleClip(rect)) { switch (brush.style()) { case Qt::SolidPattern: { + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)) { + break; + } const QColor color = brush.color(); if (!color.isValid()) return; @@ -638,8 +656,10 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) r.width(), r.height()); return; } case Qt::TexturePattern: { - if (d->transformationType & QDirectFBPaintEnginePrivate::NegativeScale) + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)) { break; + } const QPixmap texture = brush.texture(); if (texture.pixmapData()->classId() != QPixmapData::DirectFBClass) @@ -663,8 +683,8 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) return; Q_D(QDirectFBPaintEngine); d->updateClip(); - if (d->unsupportedCompositionMode - || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported) + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || !d->dfbCanHandleClip()) { RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); d->lock(); @@ -713,7 +733,7 @@ QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p : surface(0), antialiased(false), simplePen(false), transformationType(0), opacity(255), dirtyClip(true), dfbHandledClip(false), dfbDevice(0), - unsupportedCompositionMode(false), q(p) + compositionModeStatus(0), q(p) { fb = QDirectFBScreen::instance()->dfb(); ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip; @@ -769,7 +789,7 @@ void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform) { transformationType = transform.type(); if (qMin(transform.m11(), transform.m22()) < 0) { - transformationType |= QDirectFBPaintEnginePrivate::NegativeScale; + transformationType |= QDirectFBPaintEnginePrivate::Matrix_NegativeScale; } setPen(q->state()->pen); } @@ -791,7 +811,51 @@ void QDirectFBPaintEnginePrivate::setPen(const QPen &pen) void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode) { - unsupportedCompositionMode = (mode != QPainter::CompositionMode_SourceOver); + if (!surface) + return; + compositionModeStatus = PorterDuff_SupportedBlits; + switch (mode) { + case QPainter::CompositionMode_Clear: + surface->SetPorterDuff(surface, DSPD_CLEAR); + break; + case QPainter::CompositionMode_Source: + surface->SetPorterDuff(surface, DSPD_SRC); + break; + case QPainter::CompositionMode_SourceOver: + compositionModeStatus |= PorterDuff_SupportedPrimitives; + surface->SetPorterDuff(surface, DSPD_SRC_OVER); + break; + case QPainter::CompositionMode_DestinationOver: + surface->SetPorterDuff(surface, DSPD_DST_OVER); + break; + case QPainter::CompositionMode_SourceIn: + surface->SetPorterDuff(surface, DSPD_SRC_IN); + break; + case QPainter::CompositionMode_DestinationIn: + surface->SetPorterDuff(surface, DSPD_DST_IN); + break; + case QPainter::CompositionMode_SourceOut: + surface->SetPorterDuff(surface, DSPD_SRC_OUT); + break; + case QPainter::CompositionMode_DestinationOut: + surface->SetPorterDuff(surface, DSPD_DST_OUT); + break; + case QPainter::CompositionMode_SourceAtop: + surface->SetPorterDuff(surface, DSPD_SRC_ATOP); + break; + case QPainter::CompositionMode_DestinationAtop: + surface->SetPorterDuff(surface, DSPD_DST_ATOP); + break; + case QPainter::CompositionMode_Plus: + surface->SetPorterDuff(surface, DSPD_ADD); + break; + case QPainter::CompositionMode_Xor: + surface->SetPorterDuff(surface, DSPD_XOR); + break; + default: + compositionModeStatus = 0; + break; + } } void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints) @@ -897,7 +961,7 @@ static inline qreal fixCoord(qreal rect_pos, qreal pixmapSize, qreal offset) void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &off) { Q_ASSERT(!dirtyClip); - Q_ASSERT(!(transformationType & BlitUnsupported)); + Q_ASSERT(!(transformationType & Matrix_BlitsUnsupported)); const QTransform &transform = q->state()->matrix; const QRect destinationRect = transform.mapRect(dest).toRect().normalized(); QRect newClip = destinationRect; @@ -1108,7 +1172,7 @@ template <> inline const bool* ptr(const bool &) { return 0; } template static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, uint transformationType, bool simplePen, - bool dfbHandledClip, bool unsupportedCompositionMode, + bool dfbHandledClip, uint compositionModeStatus, const char *nameOne, const T1 &one, const char *nameTwo, const T2 &two, const char *nameThree, const T3 &three) @@ -1125,7 +1189,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * dbg << QString("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0')) << "simplePen" << simplePen << "dfbHandledClip" << dfbHandledClip - << "unsupportedCompositionMode" << unsupportedCompositionMode; + << "compositionModeStatus" << compositionModeStatus; const T1 *t1 = ptr(one); const T2 *t2 = ptr(two); -- cgit v0.12 From 3f6adc4a8071257c3a7211343b7591a1c32d73bd Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 27 Jul 2009 16:51:51 -0700 Subject: Major clipping patch in QDirectFBPaintEngine Handle region clips by iterating over the rectangles and updating clips accordingly. Reviewed-by: Noam Rosenthal --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 166 +++++++++++---------- 1 file changed, 91 insertions(+), 75 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 67aa516..68d4b04 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -70,6 +70,14 @@ public: PorterDuff_SupportedPrimitives = 0x2 }; + enum ClipType { + ClipUnset, + NoClip, + RectClip, + RegionClip, + ComplexClip + }; + QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p); ~QDirectFBPaintEnginePrivate(); @@ -83,9 +91,6 @@ public: inline void lock(); inline void unlock(); - inline bool dfbCanHandleClip(const QRect &rect) const; - inline bool dfbCanHandleClip(const QRectF &rect) const; - inline bool dfbCanHandleClip() const; inline bool isSimpleBrush(const QBrush &brush) const; void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &pos); @@ -110,14 +115,11 @@ private: uint transformationType; // this is QTransform::type() + Matrix_NegativeScale if qMin(transform.m11(), transform.m22()) < 0 SurfaceCache *surfaceCache; - IDirectFB *fb; - quint8 opacity; bool dirtyClip; - bool dfbHandledClip; - bool ignoreSystemClip; + ClipType clipType; QDirectFBPaintDevice *dfbDevice; uint compositionModeStatus; @@ -170,7 +172,7 @@ enum PaintOperation { template static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, uint transformationType, bool simplePen, - bool dfbHandledClip, uint compositionModeStatus, + uint clipType, uint compositionModeStatus, const char *nameOne, const T1 &one, const char *nameTwo, const T2 &two, const char *nameThree, const T3 &three); @@ -183,7 +185,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * __FUNCTION__, state()->painter->device(), \ d_func()->transformationType, \ d_func()->simplePen, \ - d_func()->dfbCanHandleClip(), \ + d_func()->clipType, \ d_func()->compositionModeStatus, \ #one, one, #two, two, #three, three); \ if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ @@ -199,14 +201,13 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * __FUNCTION__, state()->painter->device(), \ d_func()->transformationType, \ d_func()->simplePen, \ - d_func()->dfbCanHandleClip(), \ + d_func()->clipType, \ d_func()->compositionModeStatus, \ #one, one, #two, two, #three, three); #else #define RASTERFALLBACK(op, one, two, three) #endif - template static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface); template @@ -214,6 +215,36 @@ static inline void fillRects(const T *rects, int n, const QTransform &transform, template static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface); +#define CLIPPED_PAINT(operation) { \ + DFBRegion clipRegion; \ + switch (d->clipType) { \ + case QDirectFBPaintEnginePrivate::NoClip: \ + case QDirectFBPaintEnginePrivate::RectClip: \ + operation; \ + break; \ + case QDirectFBPaintEnginePrivate::RegionClip: { \ + Q_ASSERT(d->clip()); \ + const QVector cr = d->clip()->clipRegion.rects(); \ + const int size = cr.size(); \ + for (int i=0; icurrentClip = cr.at(i); \ + clipRegion.x1 = d->currentClip.x(); \ + clipRegion.y1 = d->currentClip.y(); \ + clipRegion.x2 = d->currentClip.right(); \ + clipRegion.y2 = d->currentClip.bottom(); \ + d->surface->SetClip(d->surface, &clipRegion); \ + operation; \ + } \ + d->dirtyClip = true; \ + break; } \ + case QDirectFBPaintEnginePrivate::ComplexClip: \ + case QDirectFBPaintEnginePrivate::ClipUnset: \ + qFatal("CLIPPED_PAINT internal error %d", d->clipType); \ + break; \ + } \ + } + + QDirectFBPaintEngine::QDirectFBPaintEngine(QPaintDevice *device) : QRasterPaintEngine(*(new QDirectFBPaintEnginePrivate(this)), device) { @@ -245,7 +276,6 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) d->prepare(d->dfbDevice); d->setCompositionMode(state()->composition_mode); - return QRasterPaintEngine::begin(device); } @@ -335,58 +365,60 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) { Q_D(QDirectFBPaintEngine); - d->updateClip(); + const QPen &pen = state()->pen; const QBrush &brush = state()->brush; + if (brush == Qt::NoBrush && pen == Qt::NoPen) + return; + + d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || !d->simplePen - || !d->dfbCanHandleClip() + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip || !d->isSimpleBrush(brush)) { RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); return; } - d->unlock(); - if (brush != Qt::NoBrush) { d->setDFBColor(brush.color()); - ::fillRects(rects, rectCount, state()->matrix, d->surface); + CLIPPED_PAINT(::fillRects(rects, rectCount, state()->matrix, d->surface)); } - const QPen &pen = state()->pen; if (pen != Qt::NoPen) { d->setDFBColor(pen.color()); - ::drawRects(rects, rectCount, state()->matrix, d->surface); + CLIPPED_PAINT(::drawRects(rects, rectCount, state()->matrix, d->surface)); } } void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) { Q_D(QDirectFBPaintEngine); - d->updateClip(); + const QPen &pen = state()->pen; const QBrush &brush = state()->brush; + if (brush == Qt::NoBrush && pen == Qt::NoPen) + return; + + d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || !d->simplePen - || !d->dfbCanHandleClip() + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip || !d->isSimpleBrush(brush)) { RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); return; } - d->unlock(); - if (brush != Qt::NoBrush) { d->setDFBColor(brush.color()); - ::fillRects(rects, rectCount, state()->matrix, d->surface); + CLIPPED_PAINT(::fillRects(rects, rectCount, state()->matrix, d->surface)); } - const QPen &pen = state()->pen; if (pen != Qt::NoPen) { d->setDFBColor(pen.color()); - ::drawRects(rects, rectCount, state()->matrix, d->surface); + CLIPPED_PAINT(::drawRects(rects, rectCount, state()->matrix, d->surface)); } } @@ -394,9 +426,10 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) { Q_D(QDirectFBPaintEngine); d->updateClip(); + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || !d->simplePen - || !d->dfbCanHandleClip()) { + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) { RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); @@ -407,7 +440,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) if (pen != Qt::NoPen) { d->unlock(); d->setDFBColor(pen.color()); - ::drawLines(lines, lineCount, state()->matrix, d->surface); + CLIPPED_PAINT(::drawLines(lines, lineCount, state()->matrix, d->surface)); } } @@ -415,9 +448,10 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) { Q_D(QDirectFBPaintEngine); d->updateClip(); + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || !d->simplePen - || !d->dfbCanHandleClip()) { + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) { RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); @@ -428,7 +462,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) if (pen != Qt::NoPen) { d->unlock(); d->setDFBColor(pen.color()); - ::drawLines(lines, lineCount, state()->matrix, d->surface); + CLIPPED_PAINT(::drawLines(lines, lineCount, state()->matrix, d->surface)); } } @@ -460,7 +494,7 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) - || !d->dfbCanHandleClip(r) + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip #ifndef QT_DIRECTFB_IMAGECACHE || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN #elif defined QT_NO_DIRECTFB_PREALLOCATED @@ -479,7 +513,7 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, bool release; IDirectFBSurface *imgSurface = d->getSurface(image, &release); d->prepareForBlit(QDirectFBScreen::hasAlpha(imgSurface)); - d->blit(r, imgSurface, sr); + CLIPPED_PAINT(d->blit(r, imgSurface, sr)); if (release) { #if (Q_DIRECTFB_VERSION >= 0x010000) d->surface->ReleaseSource(d->surface); @@ -498,15 +532,15 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, const QRectF &sr) { Q_D(QDirectFBPaintEngine); - d->updateClip(); + d->updateClip(); if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); d->lock(); QRasterPaintEngine::drawPixmap(r, pixmap, sr); } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) - || !d->dfbCanHandleClip(r)) { + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) { RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); d->lock(); @@ -519,7 +553,8 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, QDirectFBPixmapData *dfbData = static_cast(data); dfbData->unlockDirectFB(); IDirectFBSurface *s = dfbData->directFBSurface(); - d->blit(r, s, sr); + + CLIPPED_PAINT(d->blit(r, s, sr)); } } @@ -540,7 +575,7 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset); } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) - || !d->dfbCanHandleClip(r)) { + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); d->lock(); @@ -639,7 +674,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) if (brush.style() == Qt::NoBrush) return; d->updateClip(); - if (d->dfbCanHandleClip(rect)) { + if (d->clipType != QDirectFBPaintEnginePrivate::ComplexClip) { switch (brush.style()) { case Qt::SolidPattern: { if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) @@ -652,9 +687,9 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) d->unlock(); d->setDFBColor(color); const QRect r = state()->matrix.mapRect(rect).toRect(); - d->surface->FillRectangle(d->surface, r.x(), r.y(), - r.width(), r.height()); + CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height())); return; } + case Qt::TexturePattern: { if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)) { @@ -666,7 +701,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) break; d->unlock(); - d->drawTiledPixmap(rect, texture, rect.topLeft() - state()->brushOrigin); + CLIPPED_PAINT(d->drawTiledPixmap(rect, texture, rect.topLeft() - state()->brushOrigin)); return; } default: break; @@ -685,7 +720,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) - || !d->dfbCanHandleClip()) { + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) { RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); d->lock(); QRasterPaintEngine::fillRect(rect, color); @@ -732,11 +767,10 @@ void QDirectFBPaintEngine::initImageCache(int size) QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) : surface(0), antialiased(false), simplePen(false), transformationType(0), opacity(255), dirtyClip(true), - dfbHandledClip(false), dfbDevice(0), + clipType(ClipUnset), dfbDevice(0), compositionModeStatus(0), q(p) { fb = QDirectFBScreen::instance()->dfb(); - ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip; surfaceCache = new SurfaceCache; } @@ -745,23 +779,6 @@ QDirectFBPaintEnginePrivate::~QDirectFBPaintEnginePrivate() delete surfaceCache; } -bool QDirectFBPaintEnginePrivate::dfbCanHandleClip(const QRect &) const -{ - // TODO: Check to see if DirectFB can handle the clip for the given rect - return dfbHandledClip; -} - -bool QDirectFBPaintEnginePrivate::dfbCanHandleClip(const QRectF &) const -{ - // TODO: Check to see if DirectFB can handle the clip for the given rect - return dfbHandledClip; -} - -bool QDirectFBPaintEnginePrivate::dfbCanHandleClip() const -{ - return dfbHandledClip; -} - bool QDirectFBPaintEnginePrivate::isSimpleBrush(const QBrush &brush) const { return (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased); @@ -974,8 +991,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix const DFBRegion clip = { newClip.x(), newClip.y(), - newClip.x() + newClip.width() - 1, - newClip.y() + newClip.height() - 1 + newClip.right(), + newClip.bottom() }; surface->SetClip(surface, &clip); @@ -1044,8 +1061,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix const DFBRegion clip = { currentClip.x(), currentClip.y(), - currentClip.x() + currentClip.width(), - currentClip.y() + currentClip.height() + currentClip.right(), + currentClip.bottom() }; surface->SetClip(surface, &clip); } @@ -1060,22 +1077,22 @@ void QDirectFBPaintEnginePrivate::updateClip() const QClipData *clipData = clip(); if (!clipData || !clipData->enabled) { surface->SetClip(surface, NULL); - dfbHandledClip = true; + clipType = NoClip; } else if (clipData->hasRectClip) { const DFBRegion r = { clipData->clipRect.x(), clipData->clipRect.y(), - clipData->clipRect.x() + clipData->clipRect.width(), - clipData->clipRect.y() + clipData->clipRect.height() + clipData->clipRect.right(), + clipData->clipRect.bottom() }; surface->SetClip(surface, &r); currentClip = clipData->clipRect.normalized(); // ### is this guaranteed to always be normalized? - dfbHandledClip = true; - } else if (clipData->hasRegionClip && ignoreSystemClip && clipData->clipRegion == systemClip) { - dfbHandledClip = true; + clipType = RectClip; + } else if (clipData->hasRegionClip) { + clipType = RegionClip; } else { - dfbHandledClip = false; + clipType = ComplexClip; } dirtyClip = false; @@ -1172,7 +1189,7 @@ template <> inline const bool* ptr(const bool &) { return 0; } template static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, uint transformationType, bool simplePen, - bool dfbHandledClip, uint compositionModeStatus, + uint clipType, uint compositionModeStatus, const char *nameOne, const T1 &one, const char *nameTwo, const T2 &two, const char *nameThree, const T3 &three) @@ -1188,7 +1205,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * dbg << QString("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0')) << "simplePen" << simplePen - << "dfbHandledClip" << dfbHandledClip + << "clipType" << clipType << "compositionModeStatus" << compositionModeStatus; const T1 *t1 = ptr(one); @@ -1206,7 +1223,6 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * } qWarning("%s", qPrintable(out)); } -#endif - +#endif // QT_DIRECTFB_WARN_ON_RASTERFALLBACKS #endif // QT_NO_DIRECTFB -- cgit v0.12 From cb52327b12aa6c25696101a63d44bc688c165f47 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 27 Jul 2009 18:41:39 -0700 Subject: Fix off-by-one bug in QDirectFBScreen::flipSurface DFBRegions are exactly like QRects it turns out. x2/y2 == QRect::right()/QRect::bottom() This means I actually can reinterpret_cast QRect to DFBRegions but it's not really worth it. Reviewed-by: Noam Rosenthal --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 4b76ef6..642a386 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1330,15 +1330,15 @@ void QDirectFBScreen::flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags for (int i=0; iFlip(surface, &dfbReg, i + 1 < rects.size() ? nonWaitFlags : flipFlags); } } else { const QRect r = region.boundingRect(); const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(), - r.x() + r.width() + offset.x(), - r.y() + r.height() + offset.y() }; + r.right() + offset.x(), + r.bottom() + offset.y() }; surface->Flip(surface, &dfbReg, flipFlags); } } -- cgit v0.12 From 444bbfe4f9e82a4d70c707a6c35da54065c6958e Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 27 Jul 2009 12:53:44 -0700 Subject: Remove ignore system clip stuff in dfbpaintengine Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 3 --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 642a386..04759a4 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -916,9 +916,6 @@ bool QDirectFBScreen::connect(const QString &displaySpec) QDirectFBPaintEngine::initImageCache(imageCacheSize); #endif - if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive)) - d_ptr->directFBFlags |= IgnoreSystemClip; - #ifndef QT_NO_DIRECTFB_WM if (displayArgs.contains(QLatin1String("fullscreen"))) #endif diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index c128932..92ea072 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -79,8 +79,7 @@ public: NoFlags = 0x00, VideoOnly = 0x01, SystemOnly = 0x02, - IgnoreSystemClip = 0x04, - BoundingRectFlip = 0x08 + BoundingRectFlip = 0x04 }; Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag); -- cgit v0.12 From 8cfdb13015a58905539c25334e05492f9afe103b Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 28 Jul 2009 09:41:00 +0200 Subject: Don't use layered windows for non-translucent windows Reviewed-by: Samuel --- src/gui/painting/qwindowsurface_raster.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index 409d297..7fe5478 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -128,7 +128,7 @@ QPaintDevice *QRasterWindowSurface::paintDevice() void QRasterWindowSurface::beginPaint(const QRegion &rgn) { #if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_OS_WINCE)) - if (!qt_widget_private(window())->isOpaque) { + if (!qt_widget_private(window())->isOpaque && window()->testAttribute(Qt::WA_TranslucentBackground)) { #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE) if (d_ptr->image->image.format() != QImage::Format_ARGB32_Premultiplied && d_ptr->canUseLayeredWindow) @@ -160,7 +160,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi QRect br = rgn.boundingRect(); #ifndef Q_OS_WINCE - if (!qt_widget_private(window())->isOpaque && d->canUseLayeredWindow) { + if (!qt_widget_private(window())->isOpaque && d->canUseLayeredWindow && window()->testAttribute(Qt::WA_TranslucentBackground)) { QRect r = window()->frameGeometry(); QPoint frameOffset = qt_widget_private(window())->frameStrut().topLeft(); QRect dirtyRect = br.translated(offset + frameOffset); -- cgit v0.12 From ac92e906114ed7216cfd99e0deecfb7be0fd91ec Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 28 Jul 2009 09:55:20 +0200 Subject: Fixed drawImage() so that it doesn't sample outside the source image. In qt_scale_image_16bit() and qt_scale_image_32bit(), when a sample point was located on the border between two pixels in the source image, the sample point was rounded up instead of down. If a sample point was exactly on the bottom or right edge of the source image, the function would therefore sample a pixel outside the image. Because of how the target rectangle is rounded, a sample point will never be exactly on the top or left edge of the source image, so we will not get a similar problem there. I extended the lance test pixmap_scaling.qps. Task-number: 258533 Reviewed-by: Samuel --- src/gui/painting/qblendfunctions.cpp | 8 +- tests/arthur/data/qps/pixmap_scaling.qps | 346 +++++++++++++++++++++++++++++-- 2 files changed, 331 insertions(+), 23 deletions(-) diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp index baea140..82abec3 100644 --- a/src/gui/painting/qblendfunctions.cpp +++ b/src/gui/painting/qblendfunctions.cpp @@ -192,8 +192,8 @@ void qt_scale_image_16bit(uchar *destPixels, int dbpl, int h = ty2 - ty1; int w = tx2 - tx1; - const int dstx = int((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix); - const int dsty = int((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy); + const int dstx = qCeil((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix) - 1; + const int dsty = qCeil((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1; quint32 basex = quint32((sx < 0 ? srcRect.right() : srcRect.left()) * 65536) + dstx; quint32 srcy = quint32((sy < 0 ? srcRect.bottom() : srcRect.top()) * 65536) + dsty; @@ -667,8 +667,8 @@ template void qt_scale_image_32bit(uchar *destPixels, int dbpl, int h = ty2 - ty1; int w = tx2 - tx1; - const int dstx = int((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix); - const int dsty = int((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy); + const int dstx = qCeil((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix) - 1; + const int dsty = qCeil((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1; quint32 basex = quint32((sx < 0 ? srcRect.right() : srcRect.left()) * 65536) + dstx; quint32 srcy = quint32((sy < 0 ? srcRect.bottom() : srcRect.top()) * 65536) + dsty; diff --git a/tests/arthur/data/qps/pixmap_scaling.qps b/tests/arthur/data/qps/pixmap_scaling.qps index 81b8fae..c5053ad 100644 --- a/tests/arthur/data/qps/pixmap_scaling.qps +++ b/tests/arthur/data/qps/pixmap_scaling.qps @@ -3,8 +3,8 @@ translate 5 25 setFont "arial" 8 -save - drawText 15 0 "opaque image" +save + drawText 15 0 "opaque image" translate 50 50 save translate 1 1 @@ -16,23 +16,23 @@ save scale -20 20 drawImage solid2x2.png 0 0 restore - save + save translate 1 -1 scale 20 -20 drawImage solid2x2.png 0 0 restore - save + save translate -1 -1 scale -20 -20 drawImage solid2x2.png 0 0 restore - -restore + +restore save translate 150 0 - drawText 15 0 "alpha image" + drawText 15 0 "alpha image" translate 50 50 save translate 1 1 @@ -44,12 +44,12 @@ save scale -20 20 drawImage alpha2x2.png 0 0 restore - save + save translate 1 -1 scale 20 -20 drawImage alpha2x2.png 0 0 restore - save + save translate -1 -1 scale -20 -20 drawImage alpha2x2.png 0 0 @@ -59,7 +59,7 @@ restore save translate 0 150 - drawText 15 0 "solid pixmap" + drawText 15 0 "solid pixmap" translate 50 50 save translate 1 1 @@ -71,12 +71,12 @@ save scale -20 20 drawPixmap solid2x2.png 0 0 restore - save + save translate 1 -1 scale 20 -20 drawPixmap solid2x2.png 0 0 restore - save + save translate -1 -1 scale -20 -20 drawPixmap solid2x2.png 0 0 @@ -85,9 +85,9 @@ restore save - translate 150 150 + translate 150 150 drawText 15 0 "alpha pixmap" - translate 50 50 + translate 50 50 save translate 1 1 scale 20 20 @@ -98,12 +98,12 @@ save scale -20 20 drawPixmap alpha2x2.png 0 0 restore - save + save translate 1 -1 scale 20 -20 drawPixmap alpha2x2.png 0 0 restore - save + save translate -1 -1 scale -20 -20 drawPixmap alpha2x2.png 0 0 @@ -111,7 +111,7 @@ save restore -save +save translate 300 10 save drawText 0 -10 "subrect solid image" @@ -138,7 +138,7 @@ save drawImage solid2x2.png 45 0 5 50 1.8 0 0.2 2 restore - save + save translate 150 0 drawText 0 -10 "subrect solid image" drawImage alpha2x2.png 0 0 50 5 0 0.0 2 0.2 @@ -151,7 +151,7 @@ save drawImage alpha2x2.png 0 35 50 5 0 1.4 2 0.2 drawImage alpha2x2.png 0 40 50 5 0 1.6 2 0.2 drawImage alpha2x2.png 0 45 50 5 0 1.8 2 0.2 - translate 60 0 + translate 60 0 drawImage alpha2x2.png 0 0 5 50 0.0 0 0.2 2 drawImage alpha2x2.png 5 0 5 50 0.2 0 0.2 2 drawImage alpha2x2.png 10 0 5 50 0.4 0 0.2 2 @@ -217,3 +217,311 @@ save restore restore + + + +image_load alpha2x2.png alpha2x2 +image_convertToFormat alpha2x2 alpha2x2_argb32 ARGB32 +image_convertToFormat alpha2x2 alpha2x2_argb32pre ARGB32_Premultiplied +image_convertToFormat alpha2x2 alpha2x2_rgb888 Format_RGB888 +image_convertToFormat alpha2x2 alpha2x2_rgb32 RGB32 +image_convertToFormat alpha2x2 alpha2x2_rgb16 Format_RGB16 + +save + translate 0 300 + drawText 15 0 "drawImage - argb32" + translate 50 50 + save + translate 0.5 0.5 + scale 20 20 + drawImage alpha2x2_argb32 0 0 + restore + save + translate -0.5 0.5 + scale -20 20 + drawImage alpha2x2_argb32 0 0 + restore + save + translate 0.5 -0.5 + scale 20 -20 + drawImage alpha2x2_argb32 0 0 + restore + save + translate -0.5 -0.5 + scale -20 -20 + drawImage alpha2x2_argb32 0 0 + restore +restore + +save + translate 150 300 + drawText 15 0 "drawImage - argb32premul" + translate 50 50 + save + translate 0.5 0.5 + scale 20 20 + drawImage alpha2x2_argb32pre 0 0 + restore + save + translate -0.5 0.5 + scale -20 20 + drawImage alpha2x2_argb32pre 0 0 + restore + save + translate 0.5 -0.5 + scale 20 -20 + drawImage alpha2x2_argb32pre 0 0 + restore + save + translate -0.5 -0.5 + scale -20 -20 + drawImage alpha2x2_argb32pre 0 0 + restore +restore + + + +save + translate 0 450 + drawText 15 0 "drawImage - rgb888" + translate 50 50 + save + translate 0.5 0.5 + scale 20 20 + drawImage alpha2x2_rgb888 0 0 + restore + save + translate -0.5 0.5 + scale -20 20 + drawImage alpha2x2_rgb888 0 0 + restore + save + translate 0.5 -0.5 + scale 20 -20 + drawImage alpha2x2_rgb888 0 0 + restore + save + translate -0.5 -0.5 + scale -20 -20 + drawImage alpha2x2_rgb888 0 0 + restore +restore + +save + translate 150 450 + drawText 15 0 "drawImage - rgb32" + translate 50 50 + save + translate 0.5 0.5 + scale 20 20 + drawImage alpha2x2_rgb32 0 0 + restore + save + translate -0.5 0.5 + scale -20 20 + drawImage alpha2x2_rgb32 0 0 + restore + save + translate 0.5 -0.5 + scale 20 -20 + drawImage alpha2x2_rgb32 0 0 + restore + save + translate -0.5 -0.5 + scale -20 -20 + drawImage alpha2x2_rgb32 0 0 + restore +restore + +save + translate 300 450 + drawText 15 0 "drawImage - rgb16" + translate 50 50 + save + translate 0.5 0.5 + scale 20 20 + drawImage alpha2x2_rgb16 0 0 + restore + save + translate -0.5 0.5 + scale -20 20 + drawImage alpha2x2_rgb16 0 0 + restore + save + translate 0.5 -0.5 + scale 20 -20 + drawImage alpha2x2_rgb16 0 0 + restore + save + translate -0.5 -0.5 + scale -20 -20 + drawImage alpha2x2_rgb16 0 0 + restore +restore + + + +save + translate 0 600 + drawText 15 0 "clipping - argb32" + translate 50 50 + setClipRect -30 -30 60 60 ReplaceClip + save + translate 0.5 0.5 + scale 20 20 + drawImage alpha2x2_argb32 0 0 + restore + save + translate -0.5 0.5 + scale -20 20 + drawImage alpha2x2_argb32 0 0 + restore + save + translate 0.5 -0.5 + scale 20 -20 + drawImage alpha2x2_argb32 0 0 + restore + save + translate -0.5 -0.5 + scale -20 -20 + drawImage alpha2x2_argb32 0 0 + restore +restore + +save + translate 150 600 + drawText 15 0 "clipping - argb32premul" + translate 50 50 + setClipRect -30 -30 60 60 ReplaceClip + save + translate 0.5 0.5 + scale 20 20 + drawImage alpha2x2_argb32pre 0 0 + restore + save + translate -0.5 0.5 + scale -20 20 + drawImage alpha2x2_argb32pre 0 0 + restore + save + translate 0.5 -0.5 + scale 20 -20 + drawImage alpha2x2_argb32pre 0 0 + restore + save + translate -0.5 -0.5 + scale -20 -20 + drawImage alpha2x2_argb32pre 0 0 + restore +restore + +save + translate 300 600 + drawText 15 0 "clipping - rgb16" + translate 50 50 + setClipRect -30 -30 60 60 ReplaceClip + save + translate 0.5 0.5 + scale 20 20 + drawImage alpha2x2_rgb16 0 0 + restore + save + translate -0.5 0.5 + scale -20 20 + drawImage alpha2x2_rgb16 0 0 + restore + save + translate 0.5 -0.5 + scale 20 -20 + drawImage alpha2x2_rgb16 0 0 + restore + save + translate -0.5 -0.5 + scale -20 -20 + drawImage alpha2x2_rgb16 0 0 + restore +restore + + +path_addEllipse ellipse -30 -30 60 60 + +save + translate 0 750 + drawText 15 0 "clipping - argb32" + translate 50 50 + setClipPath ellipse ReplaceClip + save + translate 0.5 0.5 + scale 20 20 + drawImage alpha2x2_argb32 0 0 + restore + save + translate -0.5 0.5 + scale -20 20 + drawImage alpha2x2_argb32 0 0 + restore + save + translate 0.5 -0.5 + scale 20 -20 + drawImage alpha2x2_argb32 0 0 + restore + save + translate -0.5 -0.5 + scale -20 -20 + drawImage alpha2x2_argb32 0 0 + restore +restore + +save + translate 150 750 + drawText 15 0 "clipping - argb32premul" + translate 50 50 + setClipPath ellipse ReplaceClip + save + translate 0.5 0.5 + scale 20 20 + drawImage alpha2x2_argb32pre 0 0 + restore + save + translate -0.5 0.5 + scale -20 20 + drawImage alpha2x2_argb32pre 0 0 + restore + save + translate 0.5 -0.5 + scale 20 -20 + drawImage alpha2x2_argb32pre 0 0 + restore + save + translate -0.5 -0.5 + scale -20 -20 + drawImage alpha2x2_argb32pre 0 0 + restore +restore + +save + translate 300 750 + drawText 15 0 "clipping - rgb16" + translate 50 50 + setClipPath ellipse ReplaceClip + save + translate 0.5 0.5 + scale 20 20 + drawImage alpha2x2_rgb16 0 0 + restore + save + translate -0.5 0.5 + scale -20 20 + drawImage alpha2x2_rgb16 0 0 + restore + save + translate 0.5 -0.5 + scale 20 -20 + drawImage alpha2x2_rgb16 0 0 + restore + save + translate -0.5 -0.5 + scale -20 -20 + drawImage alpha2x2_rgb16 0 0 + restore +restore -- cgit v0.12 From b0482e0b13ea3c20674515ffdafb66c14231cc56 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 28 Jul 2009 15:54:20 +0200 Subject: Regression: QColorDialog crash on Mac when accepting with keyboard Basically, the crash happends because we release the dialog when the ok button is clicked. But when the button is clicked with the keyboard (actually cocoa emulates a click when pressing enter), it also tries to do some focus handling on the button afterwards. But at that point, the button is already freed up. With a crash as the result. This patch goes through a lot of the code, and rewrites it so we doesnt free up the cocoa objects before the destructor of the QColorDialog is called. Task-number: 258445 Reviewed-by: msorvig --- src/gui/dialogs/qcolordialog.cpp | 22 ++-- src/gui/dialogs/qcolordialog_mac.mm | 218 +++++++++++++++++++----------------- src/gui/dialogs/qcolordialog_p.h | 13 +-- 3 files changed, 134 insertions(+), 119 deletions(-) diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp index 510c0c4..e56faa2 100644 --- a/src/gui/dialogs/qcolordialog.cpp +++ b/src/gui/dialogs/qcolordialog.cpp @@ -1582,8 +1582,7 @@ void QColorDialog::setCurrentColor(const QColor &color) d->setCurrentAlpha(color.alpha()); #ifdef Q_WS_MAC - if (d->delegate) - QColorDialogPrivate::setColor(d->delegate, color); + d->setCocoaPanelColor(color); #endif } @@ -1724,19 +1723,16 @@ void QColorDialog::setVisible(bool visible) #if defined(Q_WS_MAC) if (visible) { - if (!d->delegate && QColorDialogPrivate::sharedColorPanelAvailable && - !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog))){ - d->delegate = QColorDialogPrivate::openCocoaColorPanel( - currentColor(), parentWidget(), windowTitle(), options(), d); + if (d->delegate || (QColorDialogPrivate::sharedColorPanelAvailable && + !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog)))){ + d->openCocoaColorPanel(currentColor(), parentWidget(), windowTitle(), options()); QColorDialogPrivate::sharedColorPanelAvailable = false; setAttribute(Qt::WA_DontShowOnScreen); } setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags); } else { if (d->delegate) { - QColorDialogPrivate::closeCocoaColorPanel(d->delegate); - d->delegate = 0; - QColorDialogPrivate::sharedColorPanelAvailable = true; + d->closeCocoaColorPanel(); setAttribute(Qt::WA_DontShowOnScreen, false); } } @@ -1839,6 +1835,14 @@ QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent) QColorDialog::~QColorDialog() { + Q_D(QColorDialog); +#if defined(Q_WS_MAC) + if (d->delegate) { + d->releaseCocoaColorPanelDelegate(); + QColorDialogPrivate::sharedColorPanelAvailable = true; + } +#endif + #ifndef QT_NO_SETTINGS if (!customSet) { QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); diff --git a/src/gui/dialogs/qcolordialog_mac.mm b/src/gui/dialogs/qcolordialog_mac.mm index 06120da..3770012 100644 --- a/src/gui/dialogs/qcolordialog_mac.mm +++ b/src/gui/dialogs/qcolordialog_mac.mm @@ -76,6 +76,8 @@ QT_USE_NAMESPACE CGFloat mMinWidth; // currently unused CGFloat mExtraHeight; // currently unused BOOL mHackedPanel; + NSInteger mResultCode; + BOOL mDialogIsExecuting; } - (id)initWithColorPanel:(NSColorPanel *)panel stolenContentView:(NSView *)stolenContentView @@ -90,7 +92,8 @@ QT_USE_NAMESPACE - (NSColorPanel *)colorPanel; - (QColor)qtColor; - (void)finishOffWithCode:(NSInteger)result; -- (void)cleanUpAfterMyself; +- (void)showColorPanel; +- (void)exec; @end @implementation QCocoaColorPanelDelegate @@ -110,6 +113,8 @@ QT_USE_NAMESPACE mMinWidth = 0.0; mExtraHeight = 0.0; mHackedPanel = (okButton != 0); + mResultCode = NSCancelButton; + mDialogIsExecuting = false; if (mHackedPanel) { [self relayout]; @@ -121,19 +126,31 @@ QT_USE_NAMESPACE [cancelButton setTarget:self]; } - if (mPriv) - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(colorChanged:) - name:NSColorPanelColorDidChangeNotification - object:mColorPanel]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(colorChanged:) + name:NSColorPanelColorDidChangeNotification + object:mColorPanel]; + mQtColor = new QColor(); return self; } - (void)dealloc { - if (mPriv) - [[NSNotificationCenter defaultCenter] removeObserver:self]; + QMacCocoaAutoReleasePool pool; + if (mHackedPanel) { + NSView *ourContentView = [mColorPanel contentView]; + + // return stolen stuff to its rightful owner + [mStolenContentView removeFromSuperview]; + [mColorPanel setContentView:mStolenContentView]; + + [mOkButton release]; + [mCancelButton release]; + [ourContentView release]; + } + [mColorPanel setDelegate:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; delete mQtColor; [super dealloc]; } @@ -160,8 +177,7 @@ QT_USE_NAMESPACE - (void)colorChanged:(NSNotification *)notification; { Q_UNUSED(notification); - if (mPriv) - [self updateQtColor]; + [self updateQtColor]; } - (void)relayout @@ -252,8 +268,7 @@ QT_USE_NAMESPACE mQtColor->setRgbF(red, green, blue, alpha); } - if (mPriv) - mPriv->setCurrentQColor(*mQtColor); + mPriv->setCurrentQColor(*mQtColor); } - (NSColorPanel *)colorPanel @@ -268,36 +283,39 @@ QT_USE_NAMESPACE - (void)finishOffWithCode:(NSInteger)code { - if (mPriv) { - // Finish the QColorDialog as well. But since a call to accept or reject will - // close down the QEventLoop found in QDialog, we need to make sure that the - // current thread has exited the native dialogs modal session/run loop first. - // We ensure this by posting the call: + // Finish the QColorDialog as well. But since a call to accept or reject will + // close down the QEventLoop found in QDialog, we need to make sure that the + // current thread has exited the native dialogs modal session/run loop first. + // We ensure this by posting the call: + mResultCode = code; + if (mDialogIsExecuting) { [NSApp stopModalWithCode:code]; - if (code == NSOKButton) - QMetaObject::invokeMethod(mPriv->colorDialog(), "accept", Qt::QueuedConnection); - else - QMetaObject::invokeMethod(mPriv->colorDialog(), "reject", Qt::QueuedConnection); } else { - [NSApp stopModalWithCode:code]; + if (mResultCode == NSCancelButton) + mPriv->colorDialog()->reject(); + else + mPriv->colorDialog()->accept(); } } -- (void)cleanUpAfterMyself +- (void)showColorPanel { - if (mHackedPanel) { - NSView *ourContentView = [mColorPanel contentView]; - - // return stolen stuff to its rightful owner - [mStolenContentView removeFromSuperview]; - [mColorPanel setContentView:mStolenContentView]; + mDialogIsExecuting = false; + [mColorPanel makeKeyAndOrderFront:mColorPanel]; +} - [mOkButton release]; - [mCancelButton release]; - [ourContentView release]; - } - [mColorPanel setDelegate:nil]; +- (void)exec +{ + QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active); + QMacCocoaAutoReleasePool pool; + mDialogIsExecuting = true; + [NSApp runModalForWindow:mColorPanel]; + if (mResultCode == NSCancelButton) + mPriv->colorDialog()->reject(); + else + mPriv->colorDialog()->accept(); } + @end QT_BEGIN_NAMESPACE @@ -306,91 +324,90 @@ extern void macStartInterceptNSPanelCtor(); extern void macStopInterceptNSPanelCtor(); extern NSButton *macCreateButton(const char *text, NSView *superview); -void *QColorDialogPrivate::openCocoaColorPanel(const QColor &initial, - QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options, - QColorDialogPrivate *priv) +void QColorDialogPrivate::openCocoaColorPanel(const QColor &initial, + QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options) { Q_UNUSED(parent); // we would use the parent if only NSColorPanel could be a sheet QMacCocoaAutoReleasePool pool; - /* - The standard Cocoa color panel has no OK or Cancel button and - is created as a utility window, whereas we want something like - the Carbon color panel. We need to take the following steps: + if (!delegate) { + /* + The standard Cocoa color panel has no OK or Cancel button and + is created as a utility window, whereas we want something like + the Carbon color panel. We need to take the following steps: + + 1. Intercept the color panel constructor to turn off the + NSUtilityWindowMask flag. This is done by temporarily + replacing initWithContentRect:styleMask:backing:defer: + in NSPanel by our own method. - 1. Intercept the color panel constructor to turn off the - NSUtilityWindowMask flag. This is done by temporarily - replacing initWithContentRect:styleMask:backing:defer: - in NSPanel by our own method. + 2. Modify the color panel so that its content view is part + of a new content view that contains it as well as two + buttons (OK and Cancel). - 2. Modify the color panel so that its content view is part - of a new content view that contains it as well as two - buttons (OK and Cancel). + 3. Lay out the original content view and the buttons when + the color panel is shown and whenever it is resized. - 3. Lay out the original content view and the buttons when - the color panel is shown and whenever it is resized. + 4. Clean up after ourselves. + */ - 4. Clean up after ourselves. - */ + bool hackColorPanel = !(options & QColorDialog::NoButtons); - bool hackColorPanel = !(options & QColorDialog::NoButtons); + if (hackColorPanel) + macStartInterceptNSPanelCtor(); + NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel]; + if (hackColorPanel) + macStopInterceptNSPanelCtor(); - if (hackColorPanel) - macStartInterceptNSPanelCtor(); - NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel]; - if (hackColorPanel) - macStopInterceptNSPanelCtor(); + [colorPanel setHidesOnDeactivate:false]; - [colorPanel setHidesOnDeactivate:false]; + // set up the Cocoa color panel + [colorPanel setShowsAlpha:options & QColorDialog::ShowAlphaChannel]; + [colorPanel setTitle:(NSString*)(CFStringRef)QCFString(title)]; - // set up the Cocoa color panel - [colorPanel setShowsAlpha:options & QColorDialog::ShowAlphaChannel]; - [colorPanel setTitle:(NSString*)(CFStringRef)QCFString(title)]; + NSView *stolenContentView = 0; + NSButton *okButton = 0; + NSButton *cancelButton = 0; - NSView *stolenContentView = 0; - NSButton *okButton = 0; - NSButton *cancelButton = 0; + if (hackColorPanel) { + // steal the color panel's contents view + stolenContentView = [colorPanel contentView]; + [stolenContentView retain]; + [colorPanel setContentView:0]; - if (hackColorPanel) { - // steal the color panel's contents view - stolenContentView = [colorPanel contentView]; - [stolenContentView retain]; - [colorPanel setContentView:0]; + // create a new content view and add the stolen one as a subview + NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } }; + NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect]; + [ourContentView addSubview:stolenContentView]; - // create a new content view and add the stolen one as a subview - NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } }; - NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect]; - [ourContentView addSubview:stolenContentView]; + // create OK and Cancel buttons and add these as subviews + okButton = macCreateButton("&OK", ourContentView); + cancelButton = macCreateButton("Cancel", ourContentView); - // create OK and Cancel buttons and add these as subviews - okButton = macCreateButton("&OK", ourContentView); - cancelButton = macCreateButton("Cancel", ourContentView); + [colorPanel setContentView:ourContentView]; + [colorPanel setDefaultButtonCell:[okButton cell]]; + } - [colorPanel setContentView:ourContentView]; - [colorPanel setDefaultButtonCell:[okButton cell]]; + delegate = [[QCocoaColorPanelDelegate alloc] initWithColorPanel:colorPanel + stolenContentView:stolenContentView + okButton:okButton + cancelButton:cancelButton + priv:this]; + [colorPanel setDelegate:static_cast(delegate)]; } - // create a delegate and set it - QCocoaColorPanelDelegate *delegate = - [[QCocoaColorPanelDelegate alloc] initWithColorPanel:colorPanel - stolenContentView:stolenContentView - okButton:okButton - cancelButton:cancelButton - priv:priv]; - [colorPanel setDelegate:delegate]; - setColor(delegate, initial); - [colorPanel makeKeyAndOrderFront:colorPanel]; - - return delegate; + setCocoaPanelColor(initial); + [static_cast(delegate) showColorPanel]; } -void QColorDialogPrivate::closeCocoaColorPanel(void *delegate) +void QColorDialogPrivate::closeCocoaColorPanel() { - QMacCocoaAutoReleasePool pool; - QCocoaColorPanelDelegate *theDelegate = static_cast(delegate); - [[theDelegate colorPanel] close]; - [theDelegate cleanUpAfterMyself]; - [theDelegate autorelease]; + [[static_cast(delegate) colorPanel] close]; +} + +void QColorDialogPrivate::releaseCocoaColorPanelDelegate() +{ + [static_cast(delegate) release]; } void QColorDialogPrivate::mac_nativeDialogModalHelp() @@ -410,13 +427,10 @@ void QColorDialogPrivate::mac_nativeDialogModalHelp() void QColorDialogPrivate::_q_macRunNativeAppModalPanel() { - QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active); - QMacCocoaAutoReleasePool pool; - QCocoaColorPanelDelegate *delegateCasted = static_cast(delegate); - [NSApp runModalForWindow:[delegateCasted colorPanel]]; + [static_cast(delegate) exec]; } -void QColorDialogPrivate::setColor(void *delegate, const QColor &color) +void QColorDialogPrivate::setCocoaPanelColor(const QColor &color) { QMacCocoaAutoReleasePool pool; QCocoaColorPanelDelegate *theDelegate = static_cast(delegate); diff --git a/src/gui/dialogs/qcolordialog_p.h b/src/gui/dialogs/qcolordialog_p.h index ea66d4a..00d40b6 100644 --- a/src/gui/dialogs/qcolordialog_p.h +++ b/src/gui/dialogs/qcolordialog_p.h @@ -116,14 +116,11 @@ public: QByteArray memberToDisconnectOnClose; #ifdef Q_WS_MAC - static void *openCocoaColorPanel(const QColor &initial, - QWidget *parent, const QString &title, - QColorDialog::ColorDialogOptions options, - QColorDialogPrivate *priv = 0); - static void closeCocoaColorPanel(void *delegate); - static QColor execCocoaColorPanel(const QColor &initial, QWidget *parent, - const QString &title, QColorDialog::ColorDialogOptions options); - static void setColor(void *delegate, const QColor &color); + void openCocoaColorPanel(const QColor &initial, + QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options); + void closeCocoaColorPanel(); + void releaseCocoaColorPanelDelegate(); + void setCocoaPanelColor(const QColor &color); inline void done(int result) { q_func()->done(result); } inline QColorDialog *colorDialog() { return q_func(); } -- cgit v0.12 From f4978a5894212dd655a91dbb0db02a89070bb165 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Mon, 27 Jul 2009 16:44:27 +0200 Subject: Refactor QImage/QPixmap cleanup hooks into a seperate class The new class alows more than one hook to be installed at a time and, for QPixmaps, the hook is told which pixmap is getting deleted. Reviewed-By: Samuel --- src/gui/image/image.pri | 6 +- src/gui/image/qimage.cpp | 17 +--- src/gui/image/qimagepixmapcleanuphooks.cpp | 110 +++++++++++++++++++++ src/gui/image/qimagepixmapcleanuphooks_p.h | 89 +++++++++++++++++ src/gui/image/qpixmap.cpp | 20 +--- src/opengl/qgl.cpp | 25 ++++- src/opengl/qgl_p.h | 3 +- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 5 +- 8 files changed, 238 insertions(+), 37 deletions(-) create mode 100644 src/gui/image/qimagepixmapcleanuphooks.cpp create mode 100644 src/gui/image/qimagepixmapcleanuphooks_p.h diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index bf348af..b9c36dc 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -25,7 +25,9 @@ HEADERS += \ image/qpixmapcache_p.h \ image/qpixmapdata_p.h \ image/qpixmapdatafactory_p.h \ - image/qpixmapfilter_p.h + image/qpixmapfilter_p.h \ + image/qimagepixmapcleanuphooks_p.h \ + SOURCES += \ image/qbitmap.cpp \ @@ -47,6 +49,8 @@ SOURCES += \ image/qmovie.cpp \ image/qpixmap_raster.cpp \ image/qnativeimage.cpp \ + image/qimagepixmapcleanuphooks.cpp \ + win32 { SOURCES += image/qpixmap_win.cpp diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index dd56765..f40bc7b 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -49,6 +49,7 @@ #include "qimagewriter.h" #include "qstringlist.h" #include "qvariant.h" +#include "qimagepixmapcleanuphooks_p.h" #include #include #include @@ -106,14 +107,6 @@ static inline bool checkPixelSize(const QImage::Format format) } -// ### Qt 5: remove -typedef void (*_qt_image_cleanup_hook)(int); -Q_GUI_EXPORT _qt_image_cleanup_hook qt_image_cleanup_hook = 0; - -// ### Qt 5: rename -typedef void (*_qt_image_cleanup_hook_64)(qint64); -Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64 = 0; - static QImage rotated90(const QImage &src); static QImage rotated180(const QImage &src); static QImage rotated270(const QImage &src); @@ -257,8 +250,8 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu QImageData::~QImageData() { - if (is_cached && qt_image_cleanup_hook_64) - qt_image_cleanup_hook_64((((qint64) ser_no) << 32) | ((qint64) detach_no)); + if (is_cached) + QImagePixmapCleanupHooks::executeImageHooks((((qint64) ser_no) << 32) | ((qint64) detach_no)); delete paintEngine; if (data && own_data) free(data); @@ -1342,8 +1335,8 @@ QImage::operator QVariant() const void QImage::detach() { if (d) { - if (d->is_cached && qt_image_cleanup_hook_64 && d->ref == 1) - qt_image_cleanup_hook_64(cacheKey()); + if (d->is_cached && d->ref == 1) + QImagePixmapCleanupHooks::executeImageHooks(cacheKey()); if (d->ref != 1 || d->ro_data) *this = copy(); diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp new file mode 100644 index 0000000..7d1c5fb --- /dev/null +++ b/src/gui/image/qimagepixmapcleanuphooks.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qimagepixmapcleanuphooks_p.h" +#include "qpixmapdata_p.h" + + +// Legacy, single instance hooks: ### Qt 5: remove +typedef void (*_qt_pixmap_cleanup_hook)(int); +typedef void (*_qt_pixmap_cleanup_hook_64)(qint64); +typedef void (*_qt_image_cleanup_hook)(int); +Q_GUI_EXPORT _qt_pixmap_cleanup_hook qt_pixmap_cleanup_hook = 0; +Q_GUI_EXPORT _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64 = 0; +Q_GUI_EXPORT _qt_image_cleanup_hook qt_image_cleanup_hook = 0; +Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64 = 0; + + +QImagePixmapCleanupHooks* qt_image_and_pixmap_cleanup_hooks = 0; + + +QImagePixmapCleanupHooks::QImagePixmapCleanupHooks() +{ + qt_image_and_pixmap_cleanup_hooks = this; +} + +QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance() +{ + if (!qt_image_and_pixmap_cleanup_hooks) + qt_image_and_pixmap_cleanup_hooks = new QImagePixmapCleanupHooks; + return qt_image_and_pixmap_cleanup_hooks; +} + +void QImagePixmapCleanupHooks::addPixmapHook(_qt_pixmap_cleanup_hook_pm hook) +{ + pixmapHooks.append(hook); +} + +void QImagePixmapCleanupHooks::addImageHook(_qt_image_cleanup_hook_64 hook) +{ + imageHooks.append(hook); +} + +void QImagePixmapCleanupHooks::removePixmapHook(_qt_pixmap_cleanup_hook_pm hook) +{ + pixmapHooks.removeAll(hook); +} + +void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook) +{ + imageHooks.removeAll(hook); +} + + +void QImagePixmapCleanupHooks::executePixmapHooks(QPixmap* pm) +{ + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks->pixmapHooks[i](pm); + + if (qt_pixmap_cleanup_hook_64) + qt_pixmap_cleanup_hook_64(pm->cacheKey()); +} + + +void QImagePixmapCleanupHooks::executeImageHooks(qint64 key) +{ + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->imageHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks->imageHooks[i](key); + + if (qt_image_cleanup_hook_64) + qt_image_cleanup_hook_64(key); +} + diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h new file mode 100644 index 0000000..e765e69 --- /dev/null +++ b/src/gui/image/qimagepixmapcleanuphooks_p.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QIMAGEPIXMAP_CLEANUPHOOKS_P_H +#define QIMAGEPIXMAP_CLEANUPHOOKS_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 + +typedef void (*_qt_image_cleanup_hook_64)(qint64); +typedef void (*_qt_pixmap_cleanup_hook_pm)(QPixmap*); + +class QImagePixmapCleanupHooks; +extern QImagePixmapCleanupHooks* qt_image_and_pixmap_cleanup_hooks; + +class Q_GUI_EXPORT QImagePixmapCleanupHooks +{ +public: + QImagePixmapCleanupHooks(); + + static QImagePixmapCleanupHooks *instance(); + + void addPixmapHook(_qt_pixmap_cleanup_hook_pm); + void addImageHook(_qt_image_cleanup_hook_64); + + void removePixmapHook(_qt_pixmap_cleanup_hook_pm); + void removeImageHook(_qt_image_cleanup_hook_64); + + static void executePixmapHooks(QPixmap*); + static void executeImageHooks(qint64 key); + +private: + QList<_qt_image_cleanup_hook_64> imageHooks; + QList<_qt_pixmap_cleanup_hook_pm> pixmapHooks; +}; + +QT_END_NAMESPACE + +#endif // QIMAGEPIXMAP_CLEANUPHOOKS_P_H diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 18829f4..2674cac 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -43,6 +43,7 @@ #include "qpixmap.h" #include "qpixmapdata_p.h" +#include "qimagepixmapcleanuphooks_p.h" #include "qbitmap.h" #include "qcolormap.h" @@ -81,14 +82,6 @@ QT_BEGIN_NAMESPACE // ### Qt 5: remove -typedef void (*_qt_pixmap_cleanup_hook)(int); -Q_GUI_EXPORT _qt_pixmap_cleanup_hook qt_pixmap_cleanup_hook = 0; - -// ### Qt 5: rename -typedef void (*_qt_pixmap_cleanup_hook_64)(qint64); -Q_GUI_EXPORT _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64 = 0; - -// ### Qt 5: remove Q_GUI_EXPORT qint64 qt_pixmap_id(const QPixmap &pixmap) { return pixmap.cacheKey(); @@ -1357,8 +1350,8 @@ bool QPixmap::isDetached() const void QPixmap::deref() { if (data && !data->ref.deref()) { // Destroy image if last ref - if (data->is_cached && qt_pixmap_cleanup_hook_64) - qt_pixmap_cleanup_hook_64(cacheKey()); + if (data->is_cached) + QImagePixmapCleanupHooks::executePixmapHooks(this); delete data; data = 0; } @@ -1897,9 +1890,6 @@ int QPixmap::defaultDepth() #endif } -typedef void (*_qt_pixmap_cleanup_hook_64)(qint64); -extern _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64; - /*! Detaches the pixmap from shared pixmap data. @@ -1925,8 +1915,8 @@ void QPixmap::detach() rasterData->image.detach(); } - if (data->is_cached && qt_pixmap_cleanup_hook_64 && data->ref == 1) - qt_pixmap_cleanup_hook_64(cacheKey()); + if (data->is_cached && data->ref == 1) + QImagePixmapCleanupHooks::executePixmapHooks(this); #if defined(Q_WS_MAC) QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast(data) : 0; diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index edda6b6..8bb72d5 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -86,6 +86,7 @@ #include #include #include +#include #include "qcolormap.h" #include "qfile.h" #include "qlibrary.h" @@ -1407,15 +1408,17 @@ QGLTextureCache::QGLTextureCache() { Q_ASSERT(qt_gl_texture_cache == 0); qt_gl_texture_cache = this; - qt_pixmap_cleanup_hook_64 = cleanupHook; - qt_image_cleanup_hook_64 = cleanupHook; + + QImagePixmapCleanupHooks::instance()->addPixmapHook(pixmapCleanupHook); + QImagePixmapCleanupHooks::instance()->addImageHook(imageCleanupHook); } QGLTextureCache::~QGLTextureCache() { qt_gl_texture_cache = 0; - qt_pixmap_cleanup_hook_64 = 0; - qt_image_cleanup_hook_64 = 0; + + QImagePixmapCleanupHooks::instance()->removePixmapHook(pixmapCleanupHook); + QImagePixmapCleanupHooks::instance()->removeImageHook(imageCleanupHook); } void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, int cost) @@ -1471,11 +1474,23 @@ QGLTextureCache* QGLTextureCache::instance() a hook that removes textures from the cache when a pixmap/image is deref'ed */ -void QGLTextureCache::cleanupHook(qint64 cacheKey) +void QGLTextureCache::imageCleanupHook(qint64 cacheKey) +{ + // ### remove when the GL texture cache becomes thread-safe + if (qApp->thread() != QThread::currentThread()) + return; + QGLTexture *texture = instance()->getTexture(cacheKey); + if (texture && texture->clean) + instance()->remove(cacheKey); +} + + +void QGLTextureCache::pixmapCleanupHook(QPixmap* pixmap) { // ### remove when the GL texture cache becomes thread-safe if (qApp->thread() != QThread::currentThread()) return; + const qint64 cacheKey = pixmap->cacheKey(); QGLTexture *texture = instance()->getTexture(cacheKey); if (texture && texture->clean) instance()->remove(cacheKey); diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 85dae0d..a83cc63 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -458,7 +458,8 @@ public: static QGLTextureCache *instance(); static void deleteIfEmpty(); - static void cleanupHook(qint64 cacheKey); + static void imageCleanupHook(qint64 cacheKey); + static void pixmapCleanupHook(QPixmap* pixmap); private: QCache m_cache; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index b264ac0..2ed890b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -53,6 +53,7 @@ #include #include #include +#include class SurfaceCache; class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate @@ -699,9 +700,7 @@ void QDirectFBPaintEngine::initImageCache(int size) { Q_ASSERT(size >= 0); imageCache.setMaxCost(size); - typedef void (*_qt_image_cleanup_hook_64)(qint64); - extern Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64; - qt_image_cleanup_hook_64 = ::cachedImageCleanupHook; + QImagePixmapCleanupHooks::instance()->addImageHook(cachedImageCleanupHook); } #endif // QT_DIRECTFB_IMAGECACHE -- cgit v0.12 From a1c4e70ddb04e364d89bfd39a409c4bcbe0019e4 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Jul 2009 12:43:12 -0700 Subject: Compile with DirectFB < 1.0 These porter duff operations were added for 1.0. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 68d4b04..8e06e6a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -857,6 +857,7 @@ void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode m case QPainter::CompositionMode_DestinationOut: surface->SetPorterDuff(surface, DSPD_DST_OUT); break; +#if (Q_DIRECTFB_VERSION >= 0x010000) case QPainter::CompositionMode_SourceAtop: surface->SetPorterDuff(surface, DSPD_SRC_ATOP); break; @@ -866,6 +867,7 @@ void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode m case QPainter::CompositionMode_Plus: surface->SetPorterDuff(surface, DSPD_ADD); break; +#endif case QPainter::CompositionMode_Xor: surface->SetPorterDuff(surface, DSPD_XOR); break; -- cgit v0.12 From 4caf5c1568163aa8efbfabb69ef0d83c3c6efd0a Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Jul 2009 13:13:26 -0700 Subject: Fix crash in when resizing directfb windows Since QRasterPaintEngine::baseClip was initialized when the QDirectFBPaintEngine was created and the paintengine persists for the window surface we run the risk that the baseClip is of the wrong size. This could lead to crashes and erroneous clipping. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 15 ++++++++++----- src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index a1009ac..15a46d7 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -56,6 +56,7 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect , dfbWindow(0) #endif , engine(0) + , engineHeight(-1) , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) { @@ -77,6 +78,7 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect , dfbWindow(0) #endif , engine(0) + , engineHeight(-1) , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) { @@ -295,11 +297,8 @@ bool QDirectFBWindowSurface::move(const QPoint &moveBy) QPaintEngine *QDirectFBWindowSurface::paintEngine() const { - if (!engine) { - QDirectFBWindowSurface *that = const_cast(this); - that->engine = new QDirectFBPaintEngine(that); - return that->engine; - } + Q_ASSERT(engine); + Q_ASSERT(height() <= engineHeight); return engine; } @@ -427,6 +426,12 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, void QDirectFBWindowSurface::beginPaint(const QRegion &) { + const int h = height(); + if (h > engineHeight) { + engineHeight = h; + delete engine; + engine = new QDirectFBPaintEngine(this); + } } void QDirectFBWindowSurface::endPaint(const QRegion &) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index c46d93b..cd88aca 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -93,6 +93,7 @@ private: IDirectFBWindow *dfbWindow; #endif QDirectFBPaintEngine *engine; + int engineHeight; enum Mode { Primary, -- cgit v0.12 From c0f85469a76a25fff6951b634b67cfbcd0507b93 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Jul 2009 13:49:03 -0700 Subject: Make autorepeat work for DirectFB When holding down a key DirectFB gives us only keypresses. Qt wants these kind of events: press not autorepeat release autorepeat press autorepeat release autorepeat press autorepeat release not autorepeat Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbkeyboard.cpp | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp index b5376b1..13c4053 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp @@ -77,13 +77,15 @@ private: QSocketNotifier *keyboardNotifier; DFBEvent event; int bytesRead; - + int lastUnicode, lastKeycode; + Qt::KeyboardModifiers lastModifiers; private Q_SLOTS: void readKeyboardData(); }; QDirectFBKeyboardHandlerPrivate::QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboardHandler *h) - : handler(h), eventBuffer(0) + : handler(h), eventBuffer(0), keyboardNotifier(0), bytesRead(0), + lastUnicode(0), lastKeycode(0), lastModifiers(0) { Q_ASSERT(qt_screen); @@ -114,8 +116,6 @@ QDirectFBKeyboardHandlerPrivate::QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboa ::fcntl(fd, F_SETFL, flags | O_NONBLOCK); memset(&event, 0, sizeof(event)); - bytesRead = 0; - keyboardNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); connect(keyboardNotifier, SIGNAL(activated(int)), @@ -213,8 +213,27 @@ void QDirectFBKeyboardHandlerPrivate::readKeyboardData() unicode = symbol; if (unicode != -1 || keycode != 0) { + bool autoRepeat = false; + if (press) { + if (unicode == lastUnicode && keycode == lastKeycode && modifiers == lastModifiers) { + autoRepeat = true; + } else { + lastUnicode = unicode; + lastKeycode = keycode; + lastModifiers = modifiers; + } + } else { + lastUnicode = lastKeycode = -1; + lastModifiers = 0; + } + if (autoRepeat) { + handler->processKeyEvent(unicode, keycode, + modifiers, false, autoRepeat); + + } + handler->processKeyEvent(unicode, keycode, - modifiers, press, false); + modifiers, press, autoRepeat); } } } -- cgit v0.12 From 77fc1ccec09e23de6fc6fedd368cef8111745711 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Jul 2009 14:30:27 -0700 Subject: Refactor QDirectFBPaintDevice Make the engine a member in QDirectFBPaintDevice instead of one in QDirectFBPixmapData and one in QDirectFBWindowSurface. Don't use the default screen for the dfbpaintdevices. Pass one explicitly. Reviewed-by: Noam Rosenthal --- .../gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 13 +++++++++++++ src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h | 17 ++++++++--------- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 13 +++++++------ src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h | 3 +-- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 10 ++++++---- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 9 --------- .../gfxdrivers/directfb/qdirectfbwindowsurface.h | 6 ++---- 7 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 8ad5264..7e61ed4 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -43,10 +43,17 @@ #include "qdirectfbscreen.h" #include "qdirectfbpaintdevice.h" +#include "qdirectfbpaintengine.h" + +QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr) + : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr), + lock(DFBSurfaceLockFlags(0)), mem(0), engine(0) +{} QDirectFBPaintDevice::~QDirectFBPaintDevice() { delete lockedImage; + delete engine; } @@ -168,4 +175,10 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const } } +QPaintEngine *QDirectFBPaintDevice::paintEngine() const +{ + return engine; +} + #endif + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index 248a15b..a6f9265 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -51,7 +51,8 @@ QT_BEGIN_HEADER QT_MODULE(Gui) // Inherited by both window surface and pixmap - class QDirectFBPaintDevice : public QCustomRasterPaintDevice +class QDirectFBPaintEngine; +class QDirectFBPaintDevice : public QCustomRasterPaintDevice { public: ~QDirectFBPaintDevice(); @@ -68,13 +69,10 @@ public: QSize size() const; int metric(QPaintDevice::PaintDeviceMetric metric) const; DFBSurfaceLockFlags lockFlags() const { return lock; } -protected: - // Shouldn't create QDirectFBPaintDevice by itself but only sub-class it: - QDirectFBPaintDevice(QDirectFBScreen *scr = QDirectFBScreen::instance()) - : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr), - lock(DFBSurfaceLockFlags(0)), mem(0) - {} + QPaintEngine *paintEngine() const; +protected: + QDirectFBPaintDevice(QDirectFBScreen *scr); inline int dotsPerMeterX() const { return (screen->deviceWidth() * 1000) / screen->physicalWidth(); @@ -90,9 +88,10 @@ protected: int bpl; DFBSurfaceLockFlags lock; uchar *mem; + QDirectFBPaintEngine *engine; private: - Q_DISABLE_COPY(QDirectFBPaintDevice) - }; + Q_DISABLE_COPY(QDirectFBPaintDevice); +}; QT_END_HEADER diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index dd7faf3..26a77a5 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -49,9 +49,9 @@ static int global_ser_no = 0; -QDirectFBPixmapData::QDirectFBPixmapData(PixelType pixelType) - : QPixmapData(pixelType, DirectFBClass), - engine(0), format(QImage::Format_Invalid), alpha(false) +QDirectFBPixmapData::QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType) + : QPixmapData(pixelType, DirectFBClass), QDirectFBPaintDevice(screen), + format(QImage::Format_Invalid), alpha(false) { setSerialNumber(0); } @@ -61,7 +61,6 @@ QDirectFBPixmapData::~QDirectFBPixmapData() unlockDirectFB(); if (dfbSurface && QDirectFBScreen::instance()) screen->releaseDFBSurface(dfbSurface); - delete engine; } void QDirectFBPixmapData::resize(int width, int height) @@ -289,7 +288,7 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, Q_ASSERT(image); const QImage transformed = image->transformed(transform, mode); that->unlockDirectFB(); - QDirectFBPixmapData *data = new QDirectFBPixmapData(QPixmapData::PixmapType); + QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType); data->fromImage(transformed, Qt::AutoColor); return QPixmap(data); } @@ -302,7 +301,7 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, if (size.isEmpty()) return QPixmap(); - QDirectFBPixmapData *data = new QDirectFBPixmapData(QPixmapData::PixmapType); + QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType); DFBSurfaceBlittingFlags flags = DSBLIT_NOFX; data->alpha = alpha; if (alpha) { @@ -357,6 +356,8 @@ QImage QDirectFBPixmapData::toImage() const return img->copy(); } +/* This is QPixmapData::paintEngine(), not QPaintDevice::paintEngine() */ + QPaintEngine *QDirectFBPixmapData::paintEngine() const { if (!engine) { diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index 8f3ce41..5567102 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -56,7 +56,7 @@ class QDirectFBPaintEngine; class QDirectFBPixmapData : public QPixmapData, public QDirectFBPaintDevice { public: - QDirectFBPixmapData(PixelType pixelType); + QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType); ~QDirectFBPixmapData(); // Re-implemented from QPixmapData: @@ -78,7 +78,6 @@ public: static bool hasAlphaChannel(const QImage &img); private: void invalidate(); - QDirectFBPaintEngine *engine; QImage::Format format; bool alpha; }; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 04759a4..a28e940 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -57,7 +57,7 @@ class QDirectFBScreenPrivate : public QObject, public QWSGraphicsSystem { public: - QDirectFBScreenPrivate(QDirectFBScreen*); + QDirectFBScreenPrivate(QDirectFBScreen *qptr); ~QDirectFBScreenPrivate(); void setFlipFlags(const QStringList &args); @@ -82,10 +82,11 @@ public: QDirectFBScreen::DirectFBFlags directFBFlags; QImage::Format alphaPixmapFormat; QColor backgroundColor; + QDirectFBScreen *q; }; -QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *screen) - : QWSGraphicsSystem(screen), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE) +QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr) + : QWSGraphicsSystem(qptr), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE) #ifndef QT_NO_DIRECTFB_LAYER , dfbLayer(0) #endif @@ -98,6 +99,7 @@ QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *screen) #endif , directFBFlags(QDirectFBScreen::NoFlags) , alphaPixmapFormat(QImage::Format_Invalid) + , q(qptr) { #ifndef QT_NO_QWS_SIGNALHANDLER QWSSignalHandler::instance()->addObject(this); @@ -742,7 +744,7 @@ QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType typ if (type == QPixmapData::BitmapType) return QWSGraphicsSystem::createPixmapData(type); - return new QDirectFBPixmapData(type); + return new QDirectFBPixmapData(q, type); } #ifdef QT_NO_DEBUG diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 15a46d7..562e0c6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -55,7 +55,6 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) #endif - , engine(0) , engineHeight(-1) , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) @@ -77,7 +76,6 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) #endif - , engine(0) , engineHeight(-1) , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) @@ -295,13 +293,6 @@ bool QDirectFBWindowSurface::move(const QPoint &moveBy) return true; } -QPaintEngine *QDirectFBWindowSurface::paintEngine() const -{ - Q_ASSERT(engine); - Q_ASSERT(height() <= engineHeight); - return engine; -} - // hw: XXX: copied from QWidgetPrivate::isOpaque() inline bool isWidgetOpaque(const QWidget *w) { diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index cd88aca..fefe9f3 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -61,8 +61,8 @@ QT_MODULE(Gui) class QDirectFBWindowSurface : public QWSWindowSurface, public QDirectFBPaintDevice { public: - QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr); - QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr, QWidget *widget); + QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr); + QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr, QWidget *widget); ~QDirectFBWindowSurface(); bool isValid() const; @@ -79,7 +79,6 @@ public: QImage image() const { return QImage(); } QPaintDevice *paintDevice() { return this; } - QPaintEngine *paintEngine() const; void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); @@ -92,7 +91,6 @@ private: void createWindow(); IDirectFBWindow *dfbWindow; #endif - QDirectFBPaintEngine *engine; int engineHeight; enum Mode { -- cgit v0.12 From a57403b176c8fe5adcd4a444184832426807d0e9 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Jul 2009 14:45:55 -0700 Subject: Qtify void* func => void *func Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index a6f9265..c4aeb70 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -63,7 +63,7 @@ public: void unlockDirectFB(); // Reimplemented from QCustomRasterPaintDevice: - void* memory() const; + void *memory() const; QImage::Format format() const; int bytesPerLine() const; QSize size() const; @@ -81,7 +81,7 @@ protected: { return (screen->deviceHeight() * 1000) / screen->physicalHeight(); } - +protected: IDirectFBSurface *dfbSurface; QImage *lockedImage; QDirectFBScreen *screen; -- cgit v0.12 From 4c948161f80ddefb568c50f2a2a17612f25f646e Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 29 Jul 2009 09:35:03 +1000 Subject: Fixed failure of tst_q3socket. Make the test use network-settings.h correctly. --- tests/auto/q3socket/tst_qsocket.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/auto/q3socket/tst_qsocket.cpp b/tests/auto/q3socket/tst_qsocket.cpp index b07fa2f..854cc75 100644 --- a/tests/auto/q3socket/tst_qsocket.cpp +++ b/tests/auto/q3socket/tst_qsocket.cpp @@ -124,8 +124,10 @@ void tst_Q3Socket::peerAddress_data() QTest::addColumn("peerClosesConnection"); QTest::addColumn("peerAddr"); - QTest::newRow( "echo" ) << QString("qt-test-server.troll.no") << (uint)7 << false << QString("10.3.3.69"); - QTest::newRow( "daytime" ) << QString("qt-test-server.troll.no") << (uint)13 << true << QString("10.3.3.69"); + QTest::newRow( "echo" ) << QtNetworkSettings::serverLocalName() << (uint)7 << false + << QtNetworkSettings::serverIP().toString(); + QTest::newRow( "daytime" ) << QtNetworkSettings::serverLocalName() << (uint)13 << true + << QtNetworkSettings::serverIP().toString(); } void tst_Q3Socket::peerAddress() @@ -191,7 +193,7 @@ void tst_Q3Socket::emitConnectionRefused() { Q3Socket sock; connect( &sock, SIGNAL(error(int)), SLOT(emitConnectionRefused_error(int)) ); - sock.connectToHost( "ares.troll.no", 12331 ); + sock.connectToHost( QtNetworkSettings::serverLocalName(), 12331 ); emitConnectionRefused_errorReceived = false; QTestEventLoop::instance().enterLoop( 30 ); @@ -225,8 +227,8 @@ void tst_Q3Socket::connectionAttempts_data() QTest::addColumn("port"); QTest::addColumn("expectedResult"); - QTest::newRow("fluke port 80") << QString("qt-test-server.troll.no") << 80 << true; - QTest::newRow("fluke port 79") << QString("qt-test-server.troll.no") << 79 << false; + QTest::newRow("fluke port 80") << QtNetworkSettings::serverLocalName() << 80 << true; + QTest::newRow("fluke port 79") << QtNetworkSettings::serverLocalName() << 79 << false; } void tst_Q3Socket::connectionAttempts() @@ -266,7 +268,7 @@ void tst_Q3Socket::canReadLine() connect(&socket, SIGNAL(connected()), &loop, SLOT(quit())); // timeout error will fail in #238 connect(&socket, SIGNAL(error(int)), &loop, SLOT(quit())); - socket.connectToHost("qt-test-server.troll.no", 143); + socket.connectToHost(QtNetworkSettings::serverLocalName(), 143); loop.exec(); -- cgit v0.12 From 46a78065b4f971d58f91b7eddb7487529ce153c5 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 29 Jul 2009 09:44:27 +1000 Subject: Fixed failure of tst_q3urloperator. Make test use network-settings.h correctly. --- tests/auto/q3urloperator/tst_q3urloperator.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/auto/q3urloperator/tst_q3urloperator.cpp b/tests/auto/q3urloperator/tst_q3urloperator.cpp index f1e1059..a9e5096 100644 --- a/tests/auto/q3urloperator/tst_q3urloperator.cpp +++ b/tests/auto/q3urloperator/tst_q3urloperator.cpp @@ -55,6 +55,8 @@ #include #include +#include "../network-settings.h" + //TESTED_CLASS= //TESTED_FILES= @@ -150,7 +152,7 @@ void tst_Q3UrlOperator::initTestCase() // prepare: make sure that there is a unique directory for FTP upload // testing (to avoid parallel executed tests interfere with each other) - ftpQtestUpload = "ftp://qt-test-server.troll.no/"; + ftpQtestUpload = QString("ftp://%1/").arg(QtNetworkSettings::serverLocalName()); QString dir = QString( "qtest/upload/%1" ).arg( (ulong)this ); Q3UrlOperator opMkdir( ftpQtestUpload ); @@ -218,8 +220,8 @@ void tst_Q3UrlOperator::cleanup() void tst_Q3UrlOperator::copy_data() { - const QString ftpQtest( "ftp://qt-test-server.troll.no/qtest" ); - const QString httpQtest( "http://qt-test-server.troll.no/qtest" ); + const QString ftpQtest( QString("ftp://%1/qtest").arg(QtNetworkSettings::serverLocalName()) ); + const QString httpQtest( QString("http://%1/qtest").arg(QtNetworkSettings::serverLocalName()) ); // argument for the constructor QTest::addColumn("url"); @@ -339,8 +341,8 @@ void tst_Q3UrlOperator::slotFinished_copy( Q3NetworkOperation *op ) void tst_Q3UrlOperator::put_data() { - const QString httpQtest( "http://qt-test-server.troll.no/qtest/cgi-bin" ); - const QString httpQtestGet( "http://qt-test-server.troll.no/qtest/cgi-bin/retrieve_testfile.cgi" ); + const QString httpQtest( QString("http://%1/qtest/cgi-bin").arg(QtNetworkSettings::serverLocalName()) ); + const QString httpQtestGet( QString("http://%1/qtest/cgi-bin/retrieve_testfile.cgi").arg(QtNetworkSettings::serverLocalName()) ); QByteArray putData_1( 5 ); putData_1[0] = 'a'; -- cgit v0.12 From e0238a6d8a6a567dbdf598983dedbe4a58a9ef2d Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 29 Jul 2009 09:49:26 +1000 Subject: Fixed compile of tst_qitemeditorfactory. --- tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp b/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp index d9a7d56..e235ff5 100644 --- a/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp +++ b/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp @@ -59,13 +59,13 @@ void tst_QItemEditorFactory::createEditor() QCOMPARE(w->metaObject()->className(), "QExpandingLineEdit"); } -void tst_QItemEditorFactory::createCustomEditor() +//we make it inherit from QObject so that we can use QPointer +class MyEditor : public QObject, public QStandardItemEditorCreator { - //we make it inherit from QObject so that we can use QPointer - class MyEditor : public QObject, public QStandardItemEditorCreator - { - }; +}; +void tst_QItemEditorFactory::createCustomEditor() +{ QPointer creator = new MyEditor; QPointer creator2 = new MyEditor; -- cgit v0.12 From af489fb5551265da1f5e34deaba627a36e5c560e Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 29 Jul 2009 11:23:37 +1000 Subject: Skip uic3 test when qt3support is disabled. --- tests/auto/uic3/uic3.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/uic3/uic3.pro b/tests/auto/uic3/uic3.pro index 520f95a..72a1304 100644 --- a/tests/auto/uic3/uic3.pro +++ b/tests/auto/uic3/uic3.pro @@ -6,3 +6,6 @@ TARGET = tst_uic3 # This test is not run on wince (I think) DEFINES += SRCDIR=\\\"$$PWD\\\" + +requires(contains(QT_CONFIG,qt3support)) + -- cgit v0.12 From 069be9309b721541b4087614b6ce7b029cf3dcb8 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 29 Jul 2009 12:00:53 +1000 Subject: Fixed failure of tst_moc. os9-newlines.h's lack of newline at end of file is significant. --- tests/auto/moc/os9-newlines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/moc/os9-newlines.h b/tests/auto/moc/os9-newlines.h index fb9bbe4..85fa671 100644 --- a/tests/auto/moc/os9-newlines.h +++ b/tests/auto/moc/os9-newlines.h @@ -1 +1 @@ -/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** 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 either Technology Preview License Agreement or the ** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ #include class Os9Newlines : public QObject { Q_OBJECT public Q_SLOTS: inline void testSlot() {} }; +/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** 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 either Technology Preview License Agreement or the ** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ #include class Os9Newlines : public QObject { Q_OBJECT public Q_SLOTS: inline void testSlot() {} }; \ No newline at end of file -- cgit v0.12 From 5f0374c5754e872aaaabef44bd18f0c3bee8d586 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 29 Jul 2009 13:52:12 +1000 Subject: Fixed failure of tst_qmake::simple_app_shadowbuild. Test needs a placeholder file to make sure its build directory exists. --- tests/auto/qmake/testdata/simple_app_build/README | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/auto/qmake/testdata/simple_app_build/README diff --git a/tests/auto/qmake/testdata/simple_app_build/README b/tests/auto/qmake/testdata/simple_app_build/README new file mode 100644 index 0000000..81dc596 --- /dev/null +++ b/tests/auto/qmake/testdata/simple_app_build/README @@ -0,0 +1 @@ +Placeholder file to ensure this directory exists -- cgit v0.12 From 461518b2429bb1ab4b356f3326b63db98d19e11b Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 29 Jul 2009 13:59:41 +1000 Subject: Disable benchlibtickcounter test by default. This test depends on some low-level features of the CPU and the OS scheduler which seem impractical to automatically verify independently of the test. So turn it off to stop its intermittent failures in our test farm. --- tests/auto/selftests/tst_selftests.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 30fe853..be8fcf6 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -180,9 +180,10 @@ void tst_Selftests::runSubTest_data() QTest::newRow("benchliboptions") << "benchliboptions" << QStringList("-eventcounter"); QTest::newRow("benchlibwalltime") << "benchlibwalltime" << QStringList(); - //### QWS tests are currently run on a virtual machine, where ticks are not - //### monotonously increasing -#if defined(HAVE_TICK_COUNTER) && !defined(Q_WS_QWS) + //### This test is affected by the speed of the CPU and whether the tick counter is + //### monotonically increasing. It won't work on some machines so leave it off by default. + //### Feel free to uncomment for your own testing. +#if 0 QTest::newRow("benchlibtickcounter") << "benchlibtickcounter" << QStringList("-tickcounter"); #endif -- cgit v0.12 From 7ac907ca7cfaac6698bc044e60ffd4d5d4a65d42 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 29 Jul 2009 08:18:35 +0200 Subject: Comment one of my changes from yesterday Task-number: 258445 --- src/gui/dialogs/qcolordialog_mac.mm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qcolordialog_mac.mm b/src/gui/dialogs/qcolordialog_mac.mm index 3770012..1ac225d 100644 --- a/src/gui/dialogs/qcolordialog_mac.mm +++ b/src/gui/dialogs/qcolordialog_mac.mm @@ -283,14 +283,17 @@ QT_USE_NAMESPACE - (void)finishOffWithCode:(NSInteger)code { - // Finish the QColorDialog as well. But since a call to accept or reject will - // close down the QEventLoop found in QDialog, we need to make sure that the - // current thread has exited the native dialogs modal session/run loop first. - // We ensure this by posting the call: mResultCode = code; if (mDialogIsExecuting) { + // We stop the current modal event loop. The control + // will then return inside -(void)exec below. + // It's important that the modal event loop is stopped before + // we accept/reject QColorDialog, since QColorDialog has its + // own event loop that needs to be stopped last. [NSApp stopModalWithCode:code]; } else { + // Since we are not in a modal event loop, we can safely close + // down QColorDialog if (mResultCode == NSCancelButton) mPriv->colorDialog()->reject(); else -- cgit v0.12 From 0eaa3466077839b0cef2ad6c326d80f398eccae7 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 29 Jul 2009 17:09:54 +1000 Subject: Merge QML specific qdoc changes Reviewed-by: Martin Smith --- tools/qdoc3/codemarker.cpp | 81 ++++-- tools/qdoc3/codemarker.h | 12 +- tools/qdoc3/command.cpp | 44 ++-- tools/qdoc3/cppcodemarker.cpp | 141 +++++++++- tools/qdoc3/cppcodemarker.h | 5 + tools/qdoc3/cppcodeparser.cpp | 282 ++++++++++++++++---- tools/qdoc3/cppcodeparser.h | 15 ++ tools/qdoc3/generator.cpp | 143 ++++++---- tools/qdoc3/generator.h | 5 +- tools/qdoc3/helpprojectwriter.cpp | 35 +-- tools/qdoc3/htmlgenerator.cpp | 533 ++++++++++++++++++++++++++++++++------ tools/qdoc3/htmlgenerator.h | 23 +- tools/qdoc3/jambiapiparser.cpp | 5 +- tools/qdoc3/node.cpp | 106 +++++++- tools/qdoc3/node.h | 131 ++++++++-- tools/qdoc3/pagegenerator.cpp | 59 +++-- tools/qdoc3/test/classic.css | 49 ++++ tools/qdoc3/tree.cpp | 52 ++-- tools/qdoc3/webxmlgenerator.cpp | 4 +- 19 files changed, 1413 insertions(+), 312 deletions(-) diff --git a/tools/qdoc3/codemarker.cpp b/tools/qdoc3/codemarker.cpp index e95153d..4c018d1 100644 --- a/tools/qdoc3/codemarker.cpp +++ b/tools/qdoc3/codemarker.cpp @@ -168,7 +168,8 @@ const Node *CodeMarker::nodeForString(const QString& string) { if (sizeof(const Node *) == sizeof(uint)) { return reinterpret_cast(string.toUInt()); - } else { + } + else { return reinterpret_cast(string.toULongLong()); } } @@ -177,7 +178,8 @@ QString CodeMarker::stringForNode(const Node *node) { if (sizeof(const Node *) == sizeof(ulong)) { return QString::number(reinterpret_cast(node)); - } else { + } + else { return QString::number(reinterpret_cast(node)); } } @@ -220,7 +222,8 @@ QString CodeMarker::typified(const QString &string) || ch.digitValue() >= 0 || ch == QLatin1Char('_') || ch == QLatin1Char(':')) { pendingWord += ch; - } else { + } + else { if (!pendingWord.isEmpty()) { bool isProbablyType = (pendingWord != QLatin1String("const")); if (isProbablyType) @@ -251,7 +254,7 @@ QString CodeMarker::typified(const QString &string) return result; } -QString CodeMarker::taggedNode(const Node *node) +QString CodeMarker::taggedNode(const Node* node) { QString tag; @@ -276,10 +279,34 @@ QString CodeMarker::taggedNode(const Node *node) break; default: tag = QLatin1String("@unknown"); + break; + } + return QLatin1Char('<') + tag + QLatin1Char('>') + protect(node->name()) + + QLatin1String("'); +} + +#ifdef QDOC_QML +QString CodeMarker::taggedQmlNode(const Node* node) +{ + QString tag; + switch (node->type()) { + case Node::QmlProperty: + tag = QLatin1String("@property"); + break; + case Node::QmlSignal: + tag = QLatin1String("@signal"); + break; + case Node::QmlMethod: + tag = QLatin1String("@method"); + break; + default: + tag = QLatin1String("@unknown"); + break; } return QLatin1Char('<') + tag + QLatin1Char('>') + protect(node->name()) + QLatin1String("'); } +#endif QString CodeMarker::linkTag(const Node *node, const QString& body) { @@ -308,9 +335,11 @@ QString CodeMarker::sortName(const Node *node) QString sortNo; if (func->metaness() == FunctionNode::Ctor) { sortNo = QLatin1String("C"); - } else if (func->metaness() == FunctionNode::Dtor) { + } + else if (func->metaness() == FunctionNode::Dtor) { sortNo = QLatin1String("D"); - } else { + } + else { if (nodeName.startsWith(QLatin1String("operator")) && nodeName.length() > 8 && !nodeName[8].isLetterOrNumber()) @@ -336,9 +365,14 @@ void CodeMarker::insert(FastSection &fastSection, SynopsisStyle style, Status status) { - bool inheritedMember = (!node->relates() && - (node->parent() != (const InnerNode *)fastSection.innerNode)); bool irrelevant = false; + bool inheritedMember = false; + if (!node->relates()) { + if (node->parent() != (const InnerNode*)fastSection.innerNode) { + if (node->type() != Node::QmlProperty) + inheritedMember = true; + } + } if (node->access() == Node::Private) { irrelevant = true; @@ -462,7 +496,8 @@ QStringList CodeMarker::macRefsForNode(const Node *node) #if 0 if (!classe->templateStuff().isEmpty()) { result += QLatin1String("tmplt/"); - } else + } + else #endif { result += QLatin1String("cl/"); @@ -499,14 +534,18 @@ QStringList CodeMarker::macRefsForNode(const Node *node) result += QLatin1String("macro/"); isMacro = true; #if 0 - } else if (!func->templateStuff().isEmpty()) { + } + else if (!func->templateStuff().isEmpty()) { result += QLatin1String("ftmplt/"); #endif - } else if (func->isStatic()) { + } + else if (func->isStatic()) { result += QLatin1String("clm/"); - } else if (!func->parent()->name().isEmpty()) { + } + else if (!func->parent()->name().isEmpty()) { result += QLatin1String("instm/"); - } else { + } + else { result += QLatin1String("func/"); } @@ -520,7 +559,8 @@ QStringList CodeMarker::macRefsForNode(const Node *node) result += "/" + QLatin1String(QMetaObject::normalizedSignature(func->returnType().toLatin1().constData())) + "/("; const QList ¶ms = func->parameters(); for (int i = 0; i < params.count(); ++i) { - QString type = params.at(i).leftType() + params.at(i).rightType(); + QString type = params.at(i).leftType() + + params.at(i).rightType(); type = QLatin1String(QMetaObject::normalizedSignature(type.toLatin1().constData())); if (i != 0) result += ","; @@ -563,10 +603,21 @@ QString CodeMarker::macName(const Node *node, const QString &name) if (node->name().isEmpty()) { return QLatin1Char('/') + myName; - } else { + } + else { return plainFullName(node) + QLatin1Char('/') + myName; } } +#ifdef QDOC_QML +/*! + Get the list of documentation sections for the children of + the specified QmlClassNode. + */ +QList
CodeMarker::qmlSections(const QmlClassNode* , SynopsisStyle ) +{ + return QList
(); +} +#endif QT_END_NAMESPACE diff --git a/tools/qdoc3/codemarker.h b/tools/qdoc3/codemarker.h index 67b1064..91dc8b0 100644 --- a/tools/qdoc3/codemarker.h +++ b/tools/qdoc3/codemarker.h @@ -121,6 +121,9 @@ class CodeMarker virtual QString markedUpSynopsis(const Node *node, const Node *relative, SynopsisStyle style) = 0; +#ifdef QDOC_QML + virtual QString markedUpQmlItem(const Node* , bool) { return QString(); } +#endif virtual QString markedUpName(const Node *node) = 0; virtual QString markedUpFullName(const Node *node, const Node *relative = 0) = 0; @@ -132,6 +135,10 @@ class CodeMarker virtual QList
sections(const InnerNode *inner, SynopsisStyle style, Status status) = 0; +#ifdef QDOC_QML + virtual QList
qmlSections(const QmlClassNode* qmlClassNode, + SynopsisStyle style); +#endif virtual const Node *resolveTarget(const QString& target, const Tree *tree, const Node *relative) = 0; @@ -151,7 +158,10 @@ class CodeMarker virtual QString sortName(const Node *node); QString protect(const QString &string); QString typified(const QString &string); - QString taggedNode(const Node *node); + QString taggedNode(const Node* node); +#ifdef QDOC_QML + QString taggedQmlNode(const Node* node); +#endif QString linkTag(const Node *node, const QString& body); void insert(FastSection &fastSection, Node *node, diff --git a/tools/qdoc3/command.cpp b/tools/qdoc3/command.cpp index e51e235..bce262b 100644 --- a/tools/qdoc3/command.cpp +++ b/tools/qdoc3/command.cpp @@ -49,44 +49,46 @@ QT_BEGIN_NAMESPACE -void executeCommand( const Location& location, const QString& format, - const QStringList& args ) +void executeCommand(const Location& location, + const QString& format, + const QStringList& args) { QString actualCommand; - for ( int i = 0; i < (int) format.length(); i++ ) { + for (int i = 0; i < (int) format.length(); i++) { int ch = format[i].unicode(); - if ( ch > 0 && ch < 8 ) { + if (ch > 0 && ch < 8) { actualCommand += args[ch - 1]; - } else { + } + else { actualCommand += format[i]; } } QString toolName = actualCommand; - int space = toolName.indexOf( QLatin1Char(' ') ); - if ( space != -1 ) - toolName.truncate( space ); + int space = toolName.indexOf(QLatin1Char(' ')); + if (space != -1) + toolName.truncate(space); QProcess process; process.start(QLatin1String("sh"), - QStringList() << QLatin1String("-c") << actualCommand ); + QStringList() << QLatin1String("-c") << actualCommand); process.waitForFinished(); if (process.exitCode() == 127) - location.fatal( tr("Couldn't launch the '%1' tool") - .arg(toolName), - tr("Make sure the tool is installed and in the" - " path.") ); + location.fatal(tr("Couldn't launch the '%1' tool") + .arg(toolName), + tr("Make sure the tool is installed and in the" + " path.")); QString errors = QString::fromLocal8Bit(process.readAllStandardError()); - while ( errors.endsWith(QLatin1Char('\n')) ) - errors.truncate( errors.length() - 1 ); - if ( !errors.isEmpty() ) - location.fatal( tr("The '%1' tool encountered some problems") - .arg(toolName), - tr("The tool was invoked like this:\n%1\n" - "It emitted these errors:\n%2") - .arg(actualCommand).arg(errors) ); + while (errors.endsWith(QLatin1Char('\n'))) + errors.truncate(errors.length() - 1); + if (!errors.isEmpty()) + location.fatal(tr("The '%1' tool encountered some problems") + .arg(toolName), + tr("The tool was invoked like this:\n%1\n" + "It emitted these errors:\n%2") + .arg(actualCommand).arg(errors)); } QT_END_NAMESPACE diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp index f807609..0f8d1b7 100644 --- a/tools/qdoc3/cppcodemarker.cpp +++ b/tools/qdoc3/cppcodemarker.cpp @@ -284,7 +284,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, } else { for (int i = 0; i < documentedItems.size(); ++i) { - if (i < MaxEnumValues - 2 || i == documentedItems.size() - 1) { + if (i < MaxEnumValues-2 || i == documentedItems.size()-1) { if (i != 0) synopsis += ", "; synopsis += documentedItems.at(i); @@ -345,6 +345,43 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, return synopsis + extra; } +#ifdef QDOC_QML +/*! + */ +QString CppCodeMarker::markedUpQmlItem(const Node* node, bool summary) +{ + QString name = taggedQmlNode(node); + if (summary) { + name = linkTag(node,name); + } + name = "<@name>" + name + ""; + QString synopsis = name; + if (node->type() == Node::QmlProperty) { + const QmlPropertyNode* pn = static_cast(node); + synopsis += " : " + typified(pn->dataType()); + } + + QString extra; + if (summary) { + if (node->status() == Node::Preliminary) { + extra += " (preliminary)"; + } + else if (node->status() == Node::Deprecated) { + extra += " (deprecated)"; + } + else if (node->status() == Node::Obsolete) { + extra += " (obsolete)"; + } + } + + if (!extra.isEmpty()) { + extra.prepend("<@extra>"); + extra.append(""); + } + return synopsis + extra; +} +#endif + QString CppCodeMarker::markedUpName(const Node *node) { QString name = linkTag(node, taggedNode(node)); @@ -537,7 +574,7 @@ QList
CppCodeMarker::sections(const InnerNode *inner, else if (isStatic) { if ((*c)->type() != Node::Variable || !(*c)->doc().isEmpty()) - insert(staticPublicMembers, *c, style, status); + insert(staticPublicMembers,*c,style,status); } else if ((*c)->type() == Node::Property) { insert(properties, *c, style, status); @@ -561,11 +598,11 @@ QList
CppCodeMarker::sections(const InnerNode *inner, else if (isStatic) { if ((*c)->type() != Node::Variable || !(*c)->doc().isEmpty()) - insert(staticProtectedMembers, *c, style, status); + insert(staticProtectedMembers,*c,style,status); } else if ((*c)->type() == Node::Variable) { if (!(*c)->doc().isEmpty()) - insert(protectedVariables, *c, style, status); + insert(protectedVariables,*c,style,status); } else if ((*c)->type() == Node::Function) { if (!insertReimpFunc(protectedFunctions,*c,status)) @@ -582,14 +619,14 @@ QList
CppCodeMarker::sections(const InnerNode *inner, else if (isStatic) { if ((*c)->type() != Node::Variable || !(*c)->doc().isEmpty()) - insert(staticPrivateMembers, *c, style, status); + insert(staticPrivateMembers,*c,style,status); } else if ((*c)->type() == Node::Function) { if (!insertReimpFunc(privateFunctions,*c,status)) insert(privateFunctions, *c, style, status); } else { - insert(privateTypes, *c, style, status); + insert(privateTypes,*c,style,status); } } ++c; @@ -706,17 +743,23 @@ QList
CppCodeMarker::sections(const InnerNode *inner, "Namespaces", "namespace", "namespaces"); - FastSection classes(inner, "Classes", "class", "classes"); + FastSection classes(inner, + "Classes", + "class", + "classes"); FastSection types(inner, - style == Summary ? "Types" : "Type Documentation", + style == Summary ? + "Types" : "Type Documentation", "type", "types"); FastSection functions(inner, - style == Summary ? "Functions" : "Function Documentation", + style == Summary ? + "Functions" : "Function Documentation", "function", "functions"); FastSection macros(inner, - style == Summary ? "Macros" : "Macro Documentation", + style == Summary ? + "Macros" : "Macro Documentation", "macro", "macros"); @@ -1051,4 +1094,82 @@ QString CppCodeMarker::addMarkUp(const QString& protectedCode, return result; } +#ifdef QDOC_QML +/*! + This function is for documenting QML properties. It returns + the list of documentation sections for the children of the + \a qmlClassNode. + + Currently, it only handles QML property groups. + */ +QList
CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, + SynopsisStyle style) +{ + QList
sections; + if (qmlClassNode) { + if (style == Summary) { + FastSection qmlproperties(qmlClassNode, + "QML Properties", + "property", + "properties"); + FastSection qmlsignals(qmlClassNode, + "QML Signals", + "signal", + "signals"); + FastSection qmlmethods(qmlClassNode, + "QML Methods", + "method", + "methods"); + + NodeList::ConstIterator c = qmlClassNode->childNodes().begin(); + while (c != qmlClassNode->childNodes().end()) { + if ((*c)->subType() == Node::QmlPropertyGroup) { + const QmlPropGroupNode* qpgn = static_cast(*c); + NodeList::ConstIterator p = qpgn->childNodes().begin(); + while (p != qpgn->childNodes().end()) { + if ((*p)->type() == Node::QmlProperty) { + insert(qmlproperties,*p,style,Okay); + } + ++p; + } + } + else if ((*c)->type() == Node::QmlSignal) { + insert(qmlsignals,*c,style,Okay); + } + else if ((*c)->type() == Node::QmlMethod) { + insert(qmlmethods,*c,style,Okay); + } + ++c; + } + append(sections,qmlproperties); + append(sections,qmlsignals); + append(sections,qmlmethods); + } + else if (style == Detailed) { + FastSection qmlproperties(qmlClassNode,"QML Property Documentation"); + FastSection qmlsignals(qmlClassNode,"QML Signal Documentation"); + FastSection qmlmethods(qmlClassNode,"QML Method Documentation"); + NodeList::ConstIterator c = qmlClassNode->childNodes().begin(); + while (c != qmlClassNode->childNodes().end()) { + if ((*c)->subType() == Node::QmlPropertyGroup) { + insert(qmlproperties,*c,style,Okay); + } + else if ((*c)->type() == Node::QmlSignal) { + insert(qmlsignals,*c,style,Okay); + } + else if ((*c)->type() == Node::QmlMethod) { + insert(qmlmethods,*c,style,Okay); + } + ++c; + } + append(sections,qmlproperties); + append(sections,qmlsignals); + append(sections,qmlmethods); + } + } + + return sections; +} +#endif + QT_END_NAMESPACE diff --git a/tools/qdoc3/cppcodemarker.h b/tools/qdoc3/cppcodemarker.h index 2967dfe..fa3cb78 100644 --- a/tools/qdoc3/cppcodemarker.h +++ b/tools/qdoc3/cppcodemarker.h @@ -67,6 +67,9 @@ class CppCodeMarker : public CodeMarker QString markedUpSynopsis(const Node *node, const Node *relative, SynopsisStyle style); +#ifdef QDOC_QML + QString markedUpQmlItem(const Node *node, bool summary); +#endif QString markedUpName(const Node *node); QString markedUpFullName(const Node *node, const Node *relative); QString markedUpEnumValue(const QString &enumValue, const Node *relative); @@ -76,6 +79,8 @@ class CppCodeMarker : public CodeMarker QList
sections(const InnerNode *innerNode, SynopsisStyle style, Status status); + QList
qmlSections(const QmlClassNode* qmlClassNode, + SynopsisStyle style); const Node *resolveTarget(const QString& target, const Tree *tree, const Node *relative); diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index dd10c1c..4563f65 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -87,6 +87,10 @@ QT_BEGIN_NAMESPACE #ifdef QDOC_QML #define COMMAND_QMLCLASS Doc::alias("qmlclass") #define COMMAND_QMLPROPERTY Doc::alias("qmlproperty") +#define COMMAND_QMLINHERITS Doc::alias("inherits") +#define COMMAND_QMLSIGNAL Doc::alias("qmlsignal") +#define COMMAND_QMLMETHOD Doc::alias("qmlmethod") +#define COMMAND_QMLDEFAULT Doc::alias("default") #endif QStringList CppCodeParser::exampleFiles; @@ -109,7 +113,8 @@ static void extractPageLinkAndDesc(const QString &arg, if (arg.contains(".html") && spaceAt != -1) { *link = arg.left(spaceAt).trimmed(); *desc = arg.mid(spaceAt).trimmed(); - } else { + } + else { *link = arg; *desc = arg; } @@ -202,11 +207,6 @@ void CppCodeParser::initializeParser(const Config &config) nodeTypeMap.insert(COMMAND_PROPERTY, Node::Property); nodeTypeMap.insert(COMMAND_VARIABLE, Node::Variable); -#ifdef QDOC_QML - // nodeTypeMap.insert(COMMAND_QMLCLASS, Node::Class); - nodeTypeMap.insert(COMMAND_QMLPROPERTY, Node::Property); -#endif - exampleFiles = config.getStringList(CONFIG_EXAMPLES); exampleDirs = config.getStringList(CONFIG_EXAMPLEDIRS); QStringList exampleFilePatterns = config.getStringList( @@ -477,13 +477,15 @@ QSet CppCodeParser::topicCommands() << COMMAND_PROPERTY << COMMAND_SERVICE << COMMAND_TYPEDEF -#ifdef QDOC_QML +#ifdef QDOC_QML << COMMAND_VARIABLE << COMMAND_QMLCLASS - << COMMAND_QMLPROPERTY; -#else + << COMMAND_QMLPROPERTY + << COMMAND_QMLSIGNAL + << COMMAND_QMLMETHOD; +#else << COMMAND_VARIABLE; -#endif +#endif } /*! @@ -587,7 +589,7 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc, The command was neither "fn" nor "macro" . */ // ### split(" ") hack is there to support header file syntax - QStringList paths = arg.split(" "); + QStringList paths = arg.split(" "); QStringList path = paths[0].split("::"); Node *node = 0; if (!usedNamespaces.isEmpty()) { @@ -627,49 +629,169 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc, } } + if (command == COMMAND_CLASS) { + if (paths.size() > 1) { + if (!paths[1].endsWith(".h")) { + ClassNode*cnode = static_cast(node); + cnode->setQmlElement(paths[1]); + } + } + } return node; } else if (command == COMMAND_EXAMPLE) { - FakeNode *fake = new FakeNode(tre->root(), arg, FakeNode::Example); + FakeNode *fake = new FakeNode(tre->root(), arg, Node::Example); createExampleFileNodes(fake); return fake; } else if (command == COMMAND_EXTERNALPAGE) { - return new FakeNode(tre->root(), arg, FakeNode::ExternalPage); + return new FakeNode(tre->root(), arg, Node::ExternalPage); } else if (command == COMMAND_FILE) { - return new FakeNode(tre->root(), arg, FakeNode::File); + return new FakeNode(tre->root(), arg, Node::File); } else if (command == COMMAND_GROUP) { - return new FakeNode(tre->root(), arg, FakeNode::Group); + return new FakeNode(tre->root(), arg, Node::Group); } else if (command == COMMAND_HEADERFILE) { - return new FakeNode(tre->root(), arg, FakeNode::HeaderFile); + return new FakeNode(tre->root(), arg, Node::HeaderFile); } else if (command == COMMAND_MODULE) { - return new FakeNode(tre->root(), arg, FakeNode::Module); + return new FakeNode(tre->root(), arg, Node::Module); } else if (command == COMMAND_PAGE) { - return new FakeNode(tre->root(), arg, FakeNode::Page); + return new FakeNode(tre->root(), arg, Node::Page); } -#ifdef QDOC_QML +#ifdef QDOC_QML else if (command == COMMAND_QMLCLASS) { const ClassNode* classNode = 0; - QStringList names = arg.split(" "); - //qDebug() << "QMLCLASS" << names; + QStringList names = arg.split(" "); if (names.size() > 1) { Node* n = tre->findNode(names[1].split("::"),Node::Class); - if (n) { + if (n) classNode = static_cast(n); - //qDebug() << "FOUND IT!" << classNode->name(); + } + return new QmlClassNode(tre->root(), names[0], classNode); + } + else if ((command == COMMAND_QMLSIGNAL) || + (command == COMMAND_QMLMETHOD)) { + QString element; + QString name; + QmlClassNode* qmlClass = 0; + if (splitQmlArg(doc,arg,element,name)) { + Node* n = tre->findNode(QStringList(element),Node::Fake); + if (n && n->subType() == Node::QmlClass) { + qmlClass = static_cast(n); + if (command == COMMAND_QMLSIGNAL) + return new QmlSignalNode(qmlClass,name); + else + return new QmlMethodNode(qmlClass,name); } } - return new QmlNode(tre->root(), names[0], classNode); } -#endif +#endif return 0; } +#ifdef QDOC_QML + +/*! + A QML property argument has the form... + + :: + + This function splits the argument into those three + parts, sets \a type, \a element, and \a property, + and returns true. If any of the parts isn't found, + a debug message is output and false is returned. + */ +bool CppCodeParser::splitQmlPropertyArg(const Doc& doc, + const QString& arg, + QString& type, + QString& element, + QString& property) +{ + QStringList blankSplit = arg.split(" "); + if (blankSplit.size() > 1) { + type = blankSplit[0]; + QStringList colonSplit(blankSplit[1].split("::")); + if (colonSplit.size() > 1) { + element = colonSplit[0]; + property = colonSplit[1]; + return true; + } + else + doc.location().warning(tr("Missing QML element name or property name")); + } + else + doc.location().warning(tr("Missing QML property type or property path")); + return false; +} + +/*! + A QML signal or method argument has the form... + + :: + + This function splits the argument into those two + parts, sets \a element, and \a name, and returns + true. If either of the parts isn't found, a debug + message is output and false is returned. + */ +bool CppCodeParser::splitQmlArg(const Doc& doc, + const QString& arg, + QString& element, + QString& name) +{ + QStringList colonSplit(arg.split("::")); + if (colonSplit.size() > 1) { + element = colonSplit[0]; + name = colonSplit[1]; + return true; + } + else + doc.location().warning(tr("Missing QML element name or signal/method name")); + return false; +} + +/*! + Process the topic \a command group with arguments \a args. + + Currently, this function is called only for \e{qmlproperty}. + */ +Node *CppCodeParser::processTopicCommandGroup(const Doc& doc, + const QString& command, + const QStringList& args) +{ + QmlPropGroupNode* qmlPropGroup = 0; + if (command == COMMAND_QMLPROPERTY) { + QString type; + QString element; + QString property; + QStringList::ConstIterator arg = args.begin(); + if (splitQmlPropertyArg(doc,(*arg),type,element,property)) { + Node* n = tre->findNode(QStringList(element),Node::Fake); + if (n && n->subType() == Node::QmlClass) { + QmlClassNode* qmlClass = static_cast(n); + if (qmlClass) + qmlPropGroup = new QmlPropGroupNode(qmlClass,property); + } + } + if (qmlPropGroup) { + new QmlPropertyNode(qmlPropGroup,property,type); + ++arg; + while (arg != args.end()) { + if (splitQmlPropertyArg(doc,(*arg),type,element,property)) { + new QmlPropertyNode(qmlPropGroup,property,type); + } + ++arg; + } + } + } + return qmlPropGroup; +} +#endif + /*! Returns the set of strings representing the common metacommands plus some other metacommands. @@ -684,7 +806,13 @@ QSet CppCodeParser::otherMetaCommands() << COMMAND_NEXTPAGE << COMMAND_PREVIOUSPAGE << COMMAND_INDEXPAGE +#ifdef QDOC_QML + << COMMAND_STARTPAGE + << COMMAND_QMLINHERITS + << COMMAND_QMLDEFAULT; +#else << COMMAND_STARTPAGE; +#endif } /*! @@ -759,14 +887,19 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc, else if (command == COMMAND_RELATES) { InnerNode *pseudoParent; if (arg.startsWith("<") || arg.startsWith("\"")) { - pseudoParent = static_cast(tre->findNode(QStringList(arg), Node::Fake)); + pseudoParent = + static_cast(tre->findNode(QStringList(arg), + Node::Fake)); } else { QStringList newPath = arg.split("::"); - pseudoParent = static_cast(tre->findNode(QStringList(newPath), Node::Class)); + pseudoParent = + static_cast(tre->findNode(QStringList(newPath), + Node::Class)); if (!pseudoParent) - pseudoParent = static_cast(tre->findNode(QStringList(newPath), - Node::Namespace)); + pseudoParent = + static_cast(tre->findNode(QStringList(newPath), + Node::Namespace)); } if (!pseudoParent) { doc.location().warning(tr("Cannot find '%1' in '\\%2'") @@ -791,6 +924,15 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc, else if (command == COMMAND_STARTPAGE) { setLink(node, Node::StartLink, arg); } +#ifdef QDOC_QML + else if (command == COMMAND_QMLINHERITS) { + setLink(node, Node::InheritsLink, arg); + } + else if (command == COMMAND_QMLDEFAULT) { + QmlPropGroupNode* qpgn = static_cast(node); + qpgn->setDefault(); + } +#endif else { processCommonMetaCommand(doc.location(),command,arg,node,tre); } @@ -870,9 +1012,8 @@ bool CppCodeParser::match(int target) readToken(); return true; } - else { + else return false; - } } /*! @@ -907,11 +1048,14 @@ bool CppCodeParser::matchTemplateAngles(CodeChunk *dataType) do { if (tok == Tok_LeftAngle) { leftAngleDepth++; - } else if (tok == Tok_RightAngle) { + } + else if (tok == Tok_RightAngle) { leftAngleDepth--; - } else if (tok == Tok_LeftParen || tok == Tok_LeftBrace) { + } + else if (tok == Tok_LeftParen || tok == Tok_LeftBrace) { ++parenAndBraceDepth; - } else if (tok == Tok_RightParen || tok == Tok_RightBrace) { + } + else if (tok == Tok_RightParen || tok == Tok_RightBrace) { if (--parenAndBraceDepth < 0) return false; } @@ -974,7 +1118,8 @@ bool CppCodeParser::matchDataType(CodeChunk *dataType, QString *var) dataType->append(previousLexeme()); else return false; - } else if (match(Tok_int) || match(Tok_char) || match(Tok_double)) { + } + else if (match(Tok_int) || match(Tok_char) || match(Tok_double)) { dataType->append(previousLexeme()); } @@ -1074,8 +1219,10 @@ bool CppCodeParser::matchParameter(FunctionNode *func) readToken(); } } - func->addParameter(Parameter(dataType.toString(), "", name, - defaultValue.toString())); // ### + func->addParameter(Parameter(dataType.toString(), + "", + name, + defaultValue.toString())); // ### return true; } @@ -1123,7 +1270,8 @@ bool CppCodeParser::matchFunctionDecl(InnerNode *parent, compat = true; if (tok == Tok_operator && - (returnType.toString().isEmpty() || returnType.toString().endsWith("::"))) { + (returnType.toString().isEmpty() || + returnType.toString().endsWith("::"))) { // 'QString::operator const char *()' parentPath = returnType.toString().split(sep); parentPath.removeAll(QString()); @@ -1159,11 +1307,10 @@ bool CppCodeParser::matchFunctionDecl(InnerNode *parent, name = previousLexeme(); matchTemplateAngles(); - if (match(Tok_Gulbrandsen)) { + if (match(Tok_Gulbrandsen)) parentPath.append(name); - } else { + else break; - } } if (tok == Tok_operator) { @@ -1176,7 +1323,9 @@ bool CppCodeParser::matchFunctionDecl(InnerNode *parent, break; } } - if (parent && (tok == Tok_Semicolon || tok == Tok_LeftBracket || tok == Tok_Colon) + if (parent && (tok == Tok_Semicolon || + tok == Tok_LeftBracket || + tok == Tok_Colon) && access != Node::Private) { if (tok == Tok_LeftBracket) { returnType.appendHotspot(); @@ -1190,7 +1339,8 @@ bool CppCodeParser::matchFunctionDecl(InnerNode *parent, } if (tok != Tok_Semicolon) return false; - } else if (tok == Tok_Colon) { + } + else if (tok == Tok_Colon) { returnType.appendHotspot(); while (tok != Tok_Semicolon && tok != Tok_Eoi) { @@ -1382,7 +1532,7 @@ bool CppCodeParser::matchNamespaceDecl(InnerNode *parent) QString namespaceName = previousLexeme(); NamespaceNode *namespasse = 0; if (parent) - namespasse = static_cast(parent->findNode(namespaceName, Node::Namespace)); + namespasse = static_cast(parent->findNode(namespaceName, Node::Namespace)); if (!namespasse) { namespasse = new NamespaceNode(parent, namespaceName); namespasse->setAccess(access); @@ -1448,7 +1598,8 @@ bool CppCodeParser::matchEnumItem(InnerNode *parent, EnumNode *enume) if (strVal.isEmpty()) { if (enume->items().isEmpty()) { strVal = "0"; - } else { + } + else { QString last = enume->items().last().value(); bool ok; int n = last.toInt(&ok); @@ -1458,15 +1609,16 @@ bool CppCodeParser::matchEnumItem(InnerNode *parent, EnumNode *enume) strVal = last.left(2) + QString::number(n + 1, 16); else strVal = "0" + QString::number(n + 1, 8); - } else { - strVal = QString::number(n + 1); } + else + strVal = QString::number(n + 1); } } } enume->addItem(EnumItem(name, strVal)); - } else { + } + else { VariableNode *var = new VariableNode(parent, name); var->setAccess(access); var->setLocation(location()); @@ -1554,7 +1706,8 @@ bool CppCodeParser::matchProperty(InnerNode *parent) if (match(Tok_Ident)) { value = previousLexeme(); - } else if (match(Tok_LeftParen)) { + } + else if (match(Tok_LeftParen)) { int depth = 1; while (tok != Tok_Eoi) { if (tok == Tok_LeftParen) { @@ -1807,6 +1960,28 @@ bool CppCodeParser::matchDocsAndStuff() /* There is a topic command. Process it. */ +#ifdef QDOC_QML + if (topic == COMMAND_QMLPROPERTY) { + Doc nodeDoc = doc; + Node *node = processTopicCommandGroup(nodeDoc,topic,args); + if (node != 0) { + nodes.append(node); + docs.append(nodeDoc); + } + } + else { + QStringList::ConstIterator a = args.begin(); + while (a != args.end()) { + Doc nodeDoc = doc; + Node *node = processTopicCommand(nodeDoc,topic,*a); + if (node != 0) { + nodes.append(node); + docs.append(nodeDoc); + } + ++a; + } + } +#else QStringList::ConstIterator a = args.begin(); while (a != args.end()) { Doc nodeDoc = doc; @@ -1817,6 +1992,7 @@ bool CppCodeParser::matchDocsAndStuff() } ++a; } +#endif } NodeList::Iterator n = nodes.begin(); @@ -1824,7 +2000,8 @@ bool CppCodeParser::matchDocsAndStuff() while (n != nodes.end()) { processOtherMetaCommands(*d, *n); (*n)->setDoc(*d); - if ((*n)->isInnerNode() && ((InnerNode *)*n)->includes().isEmpty()) { + if ((*n)->isInnerNode() && + ((InnerNode *)*n)->includes().isEmpty()) { InnerNode *m = static_cast(*n); while (m->parent() != tre->root()) m = m->parent(); @@ -1912,7 +2089,8 @@ void CppCodeParser::parseQiteratorDotH(const Location &location, mutableSequentialIteratorDefinition = lines[1]; associativeIteratorDefinition = lines[2]; mutableAssociativeIteratorDefinition = lines[3]; - } else { + } + else { location.warning(tr("The qiterator.h hack failed")); } } @@ -1994,7 +2172,7 @@ void CppCodeParser::createExampleFileNodes(FakeNode *fake) foreach (const QString &exampleFile, exampleFiles) (void) new FakeNode(fake, exampleFile.mid(sizeOfBoringPartOfName), - FakeNode::File); + Node::File); } QT_END_NAMESPACE diff --git a/tools/qdoc3/cppcodeparser.h b/tools/qdoc3/cppcodeparser.h index 1f41318..cbb0149 100644 --- a/tools/qdoc3/cppcodeparser.h +++ b/tools/qdoc3/cppcodeparser.h @@ -90,6 +90,21 @@ class CppCodeParser : public CodeParser virtual Node *processTopicCommand(const Doc& doc, const QString& command, const QString& arg); +#ifdef QDOC_QML + // might need to implement this in QsCodeParser as well. + virtual Node *processTopicCommandGroup(const Doc& doc, + const QString& command, + const QStringList& args); + bool splitQmlPropertyArg(const Doc& doc, + const QString& arg, + QString& type, + QString& element, + QString& property); + bool splitQmlArg(const Doc& doc, + const QString& arg, + QString& element, + QString& name); +#endif virtual QSet otherMetaCommands(); virtual void processOtherMetaCommand(const Doc& doc, const QString& command, diff --git a/tools/qdoc3/generator.cpp b/tools/qdoc3/generator.cpp index e97b7f2..e92f53b 100644 --- a/tools/qdoc3/generator.cpp +++ b/tools/qdoc3/generator.cpp @@ -42,7 +42,7 @@ /* generator.cpp */ - +#include #include #include #include "codemarker.h" @@ -77,7 +77,11 @@ static void singularPlural(Text& text, const NodeList& nodes) } Generator::Generator() - : amp("&"), lt("<"), gt(">"), quot("""), tag("]*>") + : amp("&"), + lt("<"), + gt(">"), + quot("""), + tag("]*>") { generators.prepend(this); } @@ -125,7 +129,8 @@ void Generator::initialize(const Config &config) QSet formats = config.subVars(imagesDotFileExtensions); QSet::ConstIterator f = formats.begin(); while (f != formats.end()) { - imgFileExts[*f] = config.getStringList(imagesDotFileExtensions + Config::dot + *f); + imgFileExts[*f] = config.getStringList(imagesDotFileExtensions + + Config::dot + *f); ++f; } @@ -133,16 +138,22 @@ void Generator::initialize(const Config &config) while (g != generators.end()) { if (outputFormats.contains((*g)->format())) { (*g)->initializeGenerator(config); - QStringList extraImages = config.getStringList(CONFIG_EXTRAIMAGES + Config::dot - + (*g)->format()); + QStringList extraImages = config.getStringList(CONFIG_EXTRAIMAGES + + Config::dot + + (*g)->format()); QStringList::ConstIterator e = extraImages.begin(); while (e != extraImages.end()) { QString userFriendlyFilePath; - QString filePath = Config::findFile(config.lastLocation(), imageFiles, imageDirs, *e, - imgFileExts[(*g)->format()], userFriendlyFilePath); + QString filePath = Config::findFile(config.lastLocation(), + imageFiles, imageDirs, *e, + imgFileExts[(*g)->format()], + userFriendlyFilePath); if (!filePath.isEmpty()) - Config::copyFile(config.lastLocation(), filePath, userFriendlyFilePath, - (*g)->outputDir() + "/images"); + Config::copyFile(config.lastLocation(), + filePath, + userFriendlyFilePath, + (*g)->outputDir() + + "/images"); ++e; } } @@ -158,20 +169,23 @@ void Generator::initialize(const Config &config) QSet formats = config.subVars(formattingDotName); QSet::ConstIterator f = formats.begin(); while (f != formats.end()) { - QString def = config.getString(formattingDotName + Config::dot + - *f); + QString def = config.getString(formattingDotName + + Config::dot + *f); if (!def.isEmpty()) { int numParams = Config::numParams(def); int numOccs = def.count("\1"); if (numParams != 1) { - config.lastLocation().warning(tr("Formatting '%1' must have exactly one" - " parameter (found %2)") - .arg(*n).arg(numParams)); + config.lastLocation().warning(tr("Formatting '%1' must " + "have exactly one " + "parameter (found %2)") + .arg(*n).arg(numParams)); } else if (numOccs > 1) { - config.lastLocation().fatal(tr("Formatting '%1' must contain exactly one" - " occurrence of '\\1' (found %2)") + config.lastLocation().fatal(tr("Formatting '%1' must " + "contain exactly one " + "occurrence of '\\1' " + "(found %2)") .arg(*n).arg(numOccs)); } else { @@ -262,9 +276,14 @@ bool Generator::generateText(const Text& text, } #ifdef QDOC_QML +/*! + Extract sections of markup text surrounded by \e qmltext + and \e endqmltext and output them. + */ bool Generator::generateQmlText(const Text& text, const Node *relative, - CodeMarker *marker) + CodeMarker *marker, + const QString& qmlName) { const Atom* atom = text.firstAtom(); if (atom == 0) @@ -301,9 +320,9 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) } else if (node->type() == Node::Fake) { const FakeNode *fake = static_cast(node); - if (fake->subType() == FakeNode::Example) + if (fake->subType() == Node::Example) generateExampleFiles(fake, marker); - else if (fake->subType() == FakeNode::File) + else if (fake->subType() == Node::File) quiet = true; } @@ -395,7 +414,8 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) FunctionNode *primaryFunc = func->parent()->findFunctionNode(func->name()); if (primaryFunc) { - foreach (const Parameter ¶m, primaryFunc->parameters()) { + foreach (const Parameter ¶m, + primaryFunc->parameters()) { if (param.name() == *a) { needWarning = false; break; @@ -405,7 +425,8 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) } if (needWarning && !func->isReimp()) node->doc().location().warning( - tr("Undocumented parameter '%1' in %2").arg(*a).arg(marker->plainFullName(node))); + tr("Undocumented parameter '%1' in %2") + .arg(*a).arg(marker->plainFullName(node))); } ++a; } @@ -427,7 +448,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) if (node->type() == Node::Fake) { const FakeNode *fake = static_cast(node); - if (fake->subType() == FakeNode::File) { + if (fake->subType() == Node::File) { Text text; Quoter quoter; Doc::quoteFromFile(fake->doc().location(), quoter, fake->name()); @@ -474,7 +495,8 @@ void Generator::generateInherits(const ClassNode *classe, CodeMarker *marker) if ((*r).access == Node::Protected) { text << " (protected)"; - } else if ((*r).access == Node::Private) { + } + else if ((*r).access == Node::Private) { text << " (private)"; } text << separator(index++, classe->baseClasses().count()); @@ -485,6 +507,15 @@ void Generator::generateInherits(const ClassNode *classe, CodeMarker *marker) } } +#ifdef QDOC_QML +/*! + */ +void Generator::generateQmlInherits(const QmlClassNode* , CodeMarker* ) +{ + // stub. +} +#endif + void Generator::generateInheritedBy(const ClassNode *classe, CodeMarker *marker) { @@ -512,18 +543,21 @@ void Generator::generateExampleFiles(const FakeNode *fake, CodeMarker *marker) QString exampleFile = child->name(); openedList.next(); text << Atom(Atom::ListItemNumber, openedList.numberString()) - << Atom(Atom::ListItemLeft, openedList.styleString()) << Atom::ParaLeft + << Atom(Atom::ListItemLeft, openedList.styleString()) + << Atom::ParaLeft << Atom(Atom::Link, exampleFile) << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK) << exampleFile << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK) - << Atom::ParaRight << Atom(Atom::ListItemRight, openedList.styleString()); + << Atom::ParaRight + << Atom(Atom::ListItemRight, openedList.styleString()); } text << Atom(Atom::ListRight, openedList.styleString()); generateText(text, fake, marker); } -void Generator::generateModuleWarning(const ClassNode *classe, CodeMarker *marker) +void Generator::generateModuleWarning(const ClassNode *classe, + CodeMarker *marker) { QString module = classe->moduleName(); if (!module.isEmpty()) { @@ -544,8 +578,10 @@ void Generator::generateModuleWarning(const ClassNode *classe, CodeMarker *marke << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD) << Atom::ParaRight; } - else if (module == "Qt3Support" && Tokenizer::isTrue("defined(opensourceedition)")) { - text << Atom::ParaLeft << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD) + else if (module == "Qt3Support" && + Tokenizer::isTrue("defined(opensourceedition)")) { + text << Atom::ParaLeft + << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD) << "Note to Qt Desktop Light Edition users:" << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD) << " This class is only available in the " @@ -573,10 +609,12 @@ QString Generator::indent(int level, const QString& markedCode) if (markedCode.at(i - 1) == QLatin1Char('>')) break; } - } else { + } + else { if (markedCode.at(i) == QLatin1Char('\n')) { column = 0; - } else { + } + else { if (column == 0) { for (int j = 0; j < level; j++) t += QLatin1Char(' '); @@ -645,7 +683,7 @@ void Generator::setImageFileExtensions(const QStringList& extensions) void Generator::unknownAtom(const Atom *atom) { Location::internalError(tr("unknown atom type '%1' in %2 generator") - .arg(atom->typeString()).arg(format())); + .arg(atom->typeString()).arg(format())); } bool Generator::matchAhead(const Atom *atom, Atom::Type expectedAtomType) @@ -674,7 +712,8 @@ void Generator::supplementAlsoList(const Node *node, QList &alsoList) alternateFunc = func->parent()->findFunctionNode(alternateName); } } - } else if (!func->name().isEmpty()) { + } + else if (!func->name().isEmpty()) { alternateName = "set"; alternateName += func->name()[0].toUpper(); alternateName += func->name().mid(1); @@ -730,9 +769,13 @@ void Generator::generateStatus(const Node *node, CodeMarker *marker) case Node::Main: break; case Node::Preliminary: - text << Atom::ParaLeft << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD) << "This " - << typeString(node) << " is under development and is subject to change." - << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD) << Atom::ParaRight; + text << Atom::ParaLeft + << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD) + << "This " + << typeString(node) + << " is under development and is subject to change." + << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD) + << Atom::ParaRight; break; case Node::Deprecated: text << Atom::ParaLeft; @@ -750,16 +793,21 @@ void Generator::generateStatus(const Node *node, CodeMarker *marker) text << "This " << typeString(node) << " is obsolete."; if (node->isInnerNode()) text << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD); - text << " It is provided to keep old source code working. We strongly advise against " + text << " It is provided to keep old source code working. " + << "We strongly advise against " << "using it in new code." << Atom::ParaRight; break; case Node::Compat: // reimplemented in HtmlGenerator subclass if (node->isInnerNode()) { - text << Atom::ParaLeft << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD) << "This " - << typeString(node) << " is part of the Qt 3 compatibility layer." + text << Atom::ParaLeft + << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD) + << "This " + << typeString(node) + << " is part of the Qt 3 compatibility layer." << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD) - << " It is provided to keep old source code working. We strongly advise against " + << " It is provided to keep old source code working. " + << "We strongly advise against " << "using it in new code. See " << Atom(Atom::AutoLink, "Porting to Qt 4") << " for more information." @@ -915,7 +963,9 @@ void Generator::generateSince(const Node *node, CodeMarker *marker) { if (!node->since().isEmpty()) { Text text; - text << Atom::ParaLeft << "This " << typeString(node) + text << Atom::ParaLeft + << "This " + << typeString(node) << " was introduced in "; if (project.isEmpty()) text << "version"; @@ -945,7 +995,8 @@ void Generator::generateReimplementedFrom(const FunctionNode *func, { if (func->reimplementedFrom() != 0) { const FunctionNode *from = func->reimplementedFrom(); - if (from->access() != Node::Private && from->parent()->access() != Node::Private) { + if (from->access() != Node::Private && + from->parent()->access() != Node::Private) { Text text; text << Atom::ParaLeft << "Reimplemented from "; QString fullName = from->parent()->name() + "::" + from->name() + "()"; @@ -987,8 +1038,8 @@ const Atom *Generator::generateAtomList(const Atom *atom, if (atom->type() == Atom::FormatEndif) { if (generate && numAtoms0 == numAtoms) { - relative->location().warning(tr("Output format %1 not handled"). - arg(format())); + relative->location().warning(tr("Output format %1 not handled") + .arg(format())); Atom unhandledFormatAtom(Atom::UnhandledFormat, format()); generateAtomList(&unhandledFormatAtom, relative, @@ -999,7 +1050,8 @@ const Atom *Generator::generateAtomList(const Atom *atom, atom = atom->next(); } } - else if (atom->type() == Atom::FormatElse || atom->type() == Atom::FormatEndif) { + else if (atom->type() == Atom::FormatElse || + atom->type() == Atom::FormatEndif) { return atom; } else { @@ -1067,7 +1119,8 @@ void Generator::appendSortedNames(Text& text, r = classes.begin(); while (r != classes.end()) { - if ((*r).node->access() == Node::Public && (*r).node->status() != Node::Internal + if ((*r).node->access() == Node::Public && + (*r).node->status() != Node::Internal && !(*r).node->doc().isEmpty()) { Text className; appendFullName(className, (*r).node, classe, marker); diff --git a/tools/qdoc3/generator.h b/tools/qdoc3/generator.h index cdc4c29..8e3c57e 100644 --- a/tools/qdoc3/generator.h +++ b/tools/qdoc3/generator.h @@ -99,7 +99,10 @@ class Generator #ifdef QDOC_QML virtual bool generateQmlText(const Text& text, const Node *relative, - CodeMarker *marker); + CodeMarker *marker, + const QString& qmlName); + virtual void generateQmlInherits(const QmlClassNode* cn, + CodeMarker* marker); #endif virtual void generateBody(const Node *node, CodeMarker *marker); virtual void generateAlsoList(const Node *node, CodeMarker *marker); diff --git a/tools/qdoc3/helpprojectwriter.cpp b/tools/qdoc3/helpprojectwriter.cpp index cf7c618..f862e55 100644 --- a/tools/qdoc3/helpprojectwriter.cpp +++ b/tools/qdoc3/helpprojectwriter.cpp @@ -118,16 +118,19 @@ void HelpProjectWriter::readSelectors(SubProject &subproject, const QStringList typeHash["variable"] = Node::Variable; typeHash["target"] = Node::Target; - QHash subTypeHash; - subTypeHash["example"] = FakeNode::Example; - subTypeHash["headerfile"] = FakeNode::HeaderFile; - subTypeHash["file"] = FakeNode::File; - subTypeHash["group"] = FakeNode::Group; - subTypeHash["module"] = FakeNode::Module; - subTypeHash["page"] = FakeNode::Page; - subTypeHash["externalpage"] = FakeNode::ExternalPage; - - QSet allSubTypes = QSet::fromList(subTypeHash.values()); + QHash subTypeHash; + subTypeHash["example"] = Node::Example; + subTypeHash["headerfile"] = Node::HeaderFile; + subTypeHash["file"] = Node::File; + subTypeHash["group"] = Node::Group; + subTypeHash["module"] = Node::Module; + subTypeHash["page"] = Node::Page; + subTypeHash["externalpage"] = Node::ExternalPage; +#ifdef QDOC_QML + subTypeHash["qmlclass"] = Node::QmlClass; +#endif + + QSet allSubTypes = QSet::fromList(subTypeHash.values()); foreach (const QString &selector, selectors) { QStringList pieces = selector.split(":"); @@ -139,7 +142,7 @@ void HelpProjectWriter::readSelectors(SubProject &subproject, const QStringList QString lower = pieces[0].toLower(); pieces = pieces[1].split(","); if (typeHash.contains(lower)) { - QSet subTypes; + QSet subTypes; for (int i = 0; i < pieces.size(); ++i) { QString lower = pieces[i].toLower(); if (subTypeHash.contains(lower)) @@ -235,7 +238,7 @@ bool HelpProjectWriter::generateSection(HelpProject &project, // mask. const FakeNode *fakeNode = static_cast(node); if (subproject.selectors[node->type()].contains(fakeNode->subType()) && - fakeNode->subType() != FakeNode::ExternalPage && + fakeNode->subType() != Node::ExternalPage && !fakeNode->fullTitle().isEmpty()) project.subprojects[name].nodes[objName] = node; @@ -324,10 +327,10 @@ bool HelpProjectWriter::generateSection(HelpProject &project, // attributes. case Node::Fake: { const FakeNode *fakeNode = static_cast(node); - if (fakeNode->subType() != FakeNode::ExternalPage && + if (fakeNode->subType() != Node::ExternalPage && !fakeNode->fullTitle().isEmpty()) { - if (fakeNode->subType() != FakeNode::File) { + if (fakeNode->subType() != Node::File) { if (fakeNode->doc().hasKeywords()) { foreach (const Atom *keyword, fakeNode->doc().keywords()) { if (!keyword->string().isEmpty()) { @@ -485,7 +488,7 @@ void HelpProjectWriter::writeNode(HelpProject &project, QXmlStreamWriter &writer writer.writeAttribute("title", fakeNode->fullTitle()); // qDebug() << "Title:" << fakeNode->fullTitle(); - if (fakeNode->subType() == FakeNode::HeaderFile) { + if (fakeNode->subType() == Node::HeaderFile) { // Write subsections for all members, obsolete members and Qt 3 // members. @@ -609,7 +612,7 @@ void HelpProjectWriter::generateProject(HelpProject &project) while (nextPage) { writeNode(project, writer, nextPage); nextTitle = nextPage->links().value(Node::NextLink).first; - if (nextTitle.isEmpty()) + if(nextTitle.isEmpty()) break; nextPage = const_cast(tree->findFakeNodeByTitle(nextTitle)); } diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index f92391e..b1f8167 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -223,11 +223,21 @@ void HtmlGenerator::initializeGenerator(const Config &config) i++; } - style = config.getString(HtmlGenerator::format() + Config::dot + HTMLGENERATOR_STYLE); - postHeader = config.getString(HtmlGenerator::format() + Config::dot + HTMLGENERATOR_POSTHEADER); - footer = config.getString(HtmlGenerator::format() + Config::dot + HTMLGENERATOR_FOOTER); - address = config.getString(HtmlGenerator::format() + Config::dot + HTMLGENERATOR_ADDRESS); - pleaseGenerateMacRef = config.getBool(HtmlGenerator::format() + Config::dot + HTMLGENERATOR_GENERATEMACREFS); + style = config.getString(HtmlGenerator::format() + + Config::dot + + HTMLGENERATOR_STYLE); + postHeader = config.getString(HtmlGenerator::format() + + Config::dot + + HTMLGENERATOR_POSTHEADER); + footer = config.getString(HtmlGenerator::format() + + Config::dot + + HTMLGENERATOR_FOOTER); + address = config.getString(HtmlGenerator::format() + + Config::dot + + HTMLGENERATOR_ADDRESS); + pleaseGenerateMacRef = config.getBool(HtmlGenerator::format() + + Config::dot + + HTMLGENERATOR_GENERATEMACREFS); project = config.getString(CONFIG_PROJECT); @@ -241,10 +251,16 @@ void HtmlGenerator::initializeGenerator(const Config &config) QSet::ConstIterator edition = editionNames.begin(); while (edition != editionNames.end()) { QString editionName = *edition; - QStringList editionModules = config.getStringList( - CONFIG_EDITION + Config::dot + editionName + Config::dot + "modules"); - QStringList editionGroups = config.getStringList( - CONFIG_EDITION + Config::dot + editionName + Config::dot + "groups"); + QStringList editionModules = config.getStringList(CONFIG_EDITION + + Config::dot + + editionName + + Config::dot + + "modules"); + QStringList editionGroups = config.getStringList(CONFIG_EDITION + + Config::dot + + editionName + + Config::dot + + "groups"); if (!editionModules.isEmpty()) editionModuleMap[editionName] = editionModules; @@ -256,11 +272,17 @@ void HtmlGenerator::initializeGenerator(const Config &config) slow = config.getBool(CONFIG_SLOW); - stylesheets = config.getStringList(HtmlGenerator::format() + Config::dot + HTMLGENERATOR_STYLESHEETS); - customHeadElements = config.getStringList(HtmlGenerator::format() + Config::dot + HTMLGENERATOR_CUSTOMHEADELEMENTS); + stylesheets = config.getStringList(HtmlGenerator::format() + + Config::dot + + HTMLGENERATOR_STYLESHEETS); + customHeadElements = config.getStringList(HtmlGenerator::format() + + Config::dot + + HTMLGENERATOR_CUSTOMHEADELEMENTS); codeIndent = config.getInt(CONFIG_CODEINDENT); - helpProjectWriter = new HelpProjectWriter(config, project.toLower() + ".qhp"); + helpProjectWriter = new HelpProjectWriter(config, + project.toLower() + + ".qhp"); } void HtmlGenerator::terminateGenerator() @@ -304,9 +326,9 @@ void HtmlGenerator::generateTree(const Tree *tree, CodeMarker *marker) findAllFunctions(tree->root()); findAllLegaleseTexts(tree->root()); findAllNamespaces(tree->root()); -#ifdef ZZZ_QDOC_QML +#ifdef ZZZ_QDOC_QML findAllQmlClasses(tree->root()); -#endif +#endif PageGenerator::generateTree(tree, marker); @@ -410,7 +432,8 @@ int HtmlGenerator::generateAtom(const Atom *atom, QString str; atom = atom->next(); while (atom != 0 && atom->type() != Atom::BriefRight) { - if (atom->type() == Atom::String || atom->type() == Atom::AutoLink) + if (atom->type() == Atom::String || + atom->type() == Atom::AutoLink) str += atom->string(); skipAhead++; atom = atom->next(); @@ -453,14 +476,14 @@ int HtmlGenerator::generateAtom(const Atom *atom, marker,relative)) << "\n"; break; -#ifdef QDOC_QML +#ifdef QDOC_QML case Atom::Qml: out() << "
"
               << trimmedTrailing(highlightedCode(indent(codeIndent,atom->string()),
                                                  marker,relative))
               << "
\n"; break; -#endif +#endif case Atom::CodeNew: out() << "

you can rewrite it as

\n" << "
"
@@ -976,7 +999,7 @@ int HtmlGenerator::generateAtom(const Atom *atom,
     case Atom::EndQmlText:
         // don't do anything with these. They are just tags.
         break;
-#endif        
+#endif
     default:
         unknownAtom(atom);
     }
@@ -1042,6 +1065,12 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner,
     generateHeader(title, inner, marker, true);
     generateTitle(title, subtitleText, SmallSubTitle, inner, marker);
 
+#ifdef QDOC_QML    
+    if (classe && !classe->qmlElement().isEmpty()) {
+        generateInstantiatedBy(classe,marker);
+    }
+#endif
+    
     generateBrief(inner, marker);
     generateIncludes(inner, marker);
     generateStatus(inner, marker);
@@ -1225,16 +1254,19 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker)
     QList
::const_iterator s; QString htmlTitle = fake->fullTitle(); - if (fake->subType() == FakeNode::File && !fake->subTitle().isEmpty()) { + if (fake->subType() == Node::File && !fake->subTitle().isEmpty()) { subTitleSize = SmallSubTitle; htmlTitle += " (" + fake->subTitle() + ")"; } generateHeader(htmlTitle, fake, marker, true); - generateTitle(fake->fullTitle(), Text() << fake->subTitle(), subTitleSize, - fake, marker); + generateTitle(fake->fullTitle(), + Text() << fake->subTitle(), + subTitleSize, + fake, + marker); - if (fake->subType() == FakeNode::Module) { + if (fake->subType() == Node::Module) { // Generate brief text and status for modules. generateBrief(fake, marker); generateStatus(fake, marker); @@ -1248,7 +1280,7 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) generateAnnotatedList(fake, marker, moduleClassMap[fake->name()]); } } - else if (fake->subType() == FakeNode::HeaderFile) { + else if (fake->subType() == Node::HeaderFile) { // Generate brief text and status for modules. generateBrief(fake, marker); generateStatus(fake, marker); @@ -1295,7 +1327,49 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) appendDcfSubSection(&fakeSection, compatSection); } } +#ifdef QDOC_QML + else if (fake->subType() == Node::QmlClass) { + const QmlClassNode* qml_cn = static_cast(fake); + const ClassNode* cn = qml_cn->classNode(); + generateQmlInherits(qml_cn, marker); + generateQmlInstantiates(qml_cn, marker); + generateBrief(qml_cn, marker); + sections = marker->qmlSections(qml_cn,CodeMarker::Summary); + s = sections.begin(); + while (s != sections.end()) { + out() << "\n"; + out() << "

" << protect((*s).name) << "

\n"; + generateQmlSummary(*s,fake,marker); + ++s; + } + out() << "\n"; + out() << "

" << "Detailed Description" << "

\n"; + generateBody(fake, marker); + if (cn) + generateQmlText(cn->doc().body(), cn, marker, fake->name()); + generateAlsoList(fake, marker); + out() << "
\n"; + + sections = marker->qmlSections(qml_cn,CodeMarker::Detailed); + s = sections.begin(); + while (s != sections.end()) { + out() << "

" << protect((*s).name) << "

\n"; + NodeList::ConstIterator m = (*s).members.begin(); + while (m != (*s).members.end()) { + generateDetailedQmlMember(*m, fake, marker); + out() << "
\n"; + fakeSection.keywords += qMakePair((*m)->name(), + linkForNode(*m,0)); + ++m; + } + ++s; + } + generateFooter(fake); + return; + } +#endif + sections = marker->sections(fake, CodeMarker::Summary, CodeMarker::Okay); s = sections.begin(); while (s != sections.end()) { @@ -1306,24 +1380,12 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) } Text brief = fake->doc().briefText(); - if (fake->subType() == FakeNode::Module && !brief.isEmpty()) { + if (fake->subType() == Node::Module && !brief.isEmpty()) { out() << "\n"; out() << "

" << "Detailed Description" << "

\n"; } generateBody(fake, marker); -#ifdef QDOC_QML - if (fake->subType() == FakeNode::QmlClass) { - //qDebug() << "generateFakeNode(): QML CLASS" << fake->name(); - const QmlNode* qmlNode = static_cast(fake); - const ClassNode* cn = qmlNode->classNode(); - if (cn) { - //qDebug() << " CPP CLASS" << cn->name(); - generateQmlText(cn->doc().body(), cn, marker); - } - } -#endif - generateAlsoList(fake, marker); if (!fake->groupMembers().isEmpty()) { @@ -1353,10 +1415,10 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) } generateFooter(fake); - if (fake->subType() == FakeNode::Example) { + if (fake->subType() == Node::Example) { appendDcfSubSection(&dcfExamplesRoot, fakeSection); } - else if (fake->subType() != FakeNode::File) { + else if (fake->subType() != Node::File) { QString contentsPage = fake->links().value(Node::ContentsLink).first; if (contentsPage == "Qt Designer Manual") { @@ -1643,7 +1705,10 @@ void HtmlGenerator::generateTableOfContents(const Node *node, columnSize = 0; } out() << "
  • "; - out() << ""; generateAtomList(headingText.firstAtom(), node, marker, true, numAtoms); out() << "
  • \n"; @@ -1693,7 +1758,8 @@ void HtmlGenerator::generateNavigationBar(const NavigationBar& bar, } #endif -QString HtmlGenerator::generateListOfAllMemberFile(const InnerNode *inner, CodeMarker *marker) +QString HtmlGenerator::generateListOfAllMemberFile(const InnerNode *inner, + CodeMarker *marker) { QList
    sections; QList
    ::ConstIterator s; @@ -1744,7 +1810,8 @@ QString HtmlGenerator::generateLowStatusMemberFile(const InnerNode *inner, if (status == CodeMarker::Compat) { title = "Qt 3 Support Members for " + inner->name(); fileName = fileBase(inner) + "-qt3." + fileExtension(inner); - } else { + } + else { title = "Obsolete Members for " + inner->name(); fileName = fileBase(inner) + "-obsolete." + fileExtension(inner); } @@ -1758,10 +1825,11 @@ QString HtmlGenerator::generateLowStatusMemberFile(const InnerNode *inner, "Qt 3 support layer. " "They are provided to help you port old code to Qt 4. We advise against " "using them in new code.

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

    The following class members are obsolete. They are provided to keep " - "old source code working. We strongly advise against using them in new " - "code.

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

    The following class members are obsolete. " + << "They are provided to keep old source code working. " + << "We strongly advise against using them in new code.

    \n"; } out() << "

    • \n"; - } else { - const ClassNode *child = static_cast(*stack.top().begin()); + } + else { + const ClassNode *child = + static_cast(*stack.top().begin()); out() << "
    • "; generateFullName(child, relative, marker); out() << "
    • \n"; @@ -1836,10 +1906,9 @@ void HtmlGenerator::generateClassHierarchy(const Node *relative, } } -void -HtmlGenerator::generateAnnotatedList(const Node *relative, - CodeMarker *marker, - const QMap&nodeMap) +void HtmlGenerator::generateAnnotatedList(const Node *relative, + CodeMarker *marker, + const QMap &nodeMap) { out() << "

      \n"; @@ -1866,7 +1935,8 @@ HtmlGenerator::generateAnnotatedList(const Node *relative, generateText(brief, node, marker); out() << ""; } - } else { + } + else { out() << ""; @@ -1876,10 +1946,9 @@ HtmlGenerator::generateAnnotatedList(const Node *relative, out() << "
      "; out() << protect(node->doc().briefText().toString()); out() << "

      \n"; } -void -HtmlGenerator::generateCompactList(const Node *relative, - CodeMarker *marker, - const QMap &classMap) +void HtmlGenerator::generateCompactList(const Node *relative, + CodeMarker *marker, + const QMap &classMap) { const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_' const int NumColumns = 4; // number of columns in the result @@ -1922,8 +1991,9 @@ HtmlGenerator::generateCompactList(const Node *relative, last = classMap.begin().key(); if (classMap.size() > 1) { - while (commonPrefixLen < first.length() + 1 && commonPrefixLen < last.length() + 1 - && first[commonPrefixLen] == last[commonPrefixLen]) + while (commonPrefixLen < first.length() + 1 && + commonPrefixLen < last.length() + 1 && + first[commonPrefixLen] == last[commonPrefixLen]) ++commonPrefixLen; } @@ -1952,7 +2022,8 @@ HtmlGenerator::generateCompactList(const Node *relative, if (key[0].digitValue() != -1) { paragraphNo = key[0].digitValue(); - } else if (key[0] >= QLatin1Char('a') && key[0] <= QLatin1Char('z')) { + } + else if (key[0] >= QLatin1Char('a') && key[0] <= QLatin1Char('z')) { paragraphNo = 10 + key[0].unicode() - 'a'; } @@ -2105,7 +2176,8 @@ void HtmlGenerator::generateFunctionIndex(const Node *relative, #endif } -void HtmlGenerator::generateLegaleseList(const Node *relative, CodeMarker *marker) +void HtmlGenerator::generateLegaleseList(const Node *relative, + CodeMarker *marker) { QMap::ConstIterator it = legaleseTexts.begin(); while (it != legaleseTexts.end()) { @@ -2123,6 +2195,77 @@ void HtmlGenerator::generateLegaleseList(const Node *relative, CodeMarker *marke } } +/*void HtmlGenerator::generateSynopsis(const Node *node, + const Node *relative, + CodeMarker *marker, + CodeMarker::SynopsisStyle style) +{ + QString marked = marker->markedUpSynopsis(node, relative, style); + QRegExp templateTag("(<[^@>]*>)"); + if (marked.indexOf(templateTag) != -1) { + QString contents = protect(marked.mid(templateTag.pos(1), + templateTag.cap(1).length())); + marked.replace(templateTag.pos(1), templateTag.cap(1).length(), + contents); + } + marked.replace(QRegExp("<@param>([a-z]+)_([1-9n])"), + "\\1\\2"); + marked.replace("<@param>", ""); + marked.replace("", ""); + + if (style == CodeMarker::Summary) + marked.replace("@name>", "b>"); + + if (style == CodeMarker::SeparateList) { + QRegExp extraRegExp("<@extra>.*"); + extraRegExp.setMinimal(true); + marked.replace(extraRegExp, ""); + } + else { + marked.replace("<@extra>", "  "); + marked.replace("", ""); + } + + if (style != CodeMarker::Detailed) { + marked.replace("<@type>", ""); + marked.replace("", ""); + } + out() << highlightedCode(marked, marker, relative); +}*/ + +#ifdef QDOC_QML +void HtmlGenerator::generateQmlItem(const Node *node, + const Node *relative, + CodeMarker *marker, + bool summary) +{ + QString marked = marker->markedUpQmlItem(node,summary); + QRegExp templateTag("(<[^@>]*>)"); + if (marked.indexOf(templateTag) != -1) { + QString contents = protect(marked.mid(templateTag.pos(1), + templateTag.cap(1).length())); + marked.replace(templateTag.pos(1), templateTag.cap(1).length(), + contents); + } + marked.replace(QRegExp("<@param>([a-z]+)_([1-9n])"), + "\\1\\2"); + marked.replace("<@param>", ""); + marked.replace("", ""); + + if (summary) + marked.replace("@name>", "b>"); + + marked.replace("<@extra>", "  "); + marked.replace("", ""); + + if (summary) { + marked.replace("<@type>", ""); + marked.replace("", ""); + } + out() << highlightedCode(marked, marker, relative); +} +#endif + void HtmlGenerator::generateOverviewList(const Node *relative, CodeMarker * /* marker */) { QMap > fakeNodeMap; @@ -2145,7 +2288,7 @@ void HtmlGenerator::generateOverviewList(const Node *relative, CodeMarker * /* m } // there are too many examples; they would clutter the list - if (fakeNode->subType() == FakeNode::Example) + if (fakeNode->subType() == Node::Example) continue; // not interested either in individual (Qt Designer etc.) manual chapters @@ -2153,7 +2296,7 @@ void HtmlGenerator::generateOverviewList(const Node *relative, CodeMarker * /* m continue; // Discard external nodes. - if (fakeNode->subType() == FakeNode::ExternalPage) + if (fakeNode->subType() == Node::ExternalPage) continue; QString sortKey = fakeNode->fullTitle().toLower(); @@ -2178,7 +2321,8 @@ void HtmlGenerator::generateOverviewList(const Node *relative, CodeMarker * /* m groupTitlesMap[fakeNode->fullTitle()] = const_cast(fakeNode); } } - } else if (!isGroupPage) { + } + else if (!isGroupPage) { // If we encounter a page that belongs to a group then // we add that page to the list for that group. const FakeNode *groupNode = static_cast(tre->root()->findNode(group, Node::Fake)); @@ -2737,8 +2881,8 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, if (src.at(i) == charLangle && src.at(i + 1) == charAt) { i += 2; if (parseArg(src, linkTag, &i, n, &arg, &par1)) { - QString link = linkForNode( - CodeMarker::nodeForString(par1.toString()), relative); + const Node* node = CodeMarker::nodeForString(par1.toString()); + QString link = linkForNode(node, relative); addLink(link, arg, &html); } else { @@ -2751,7 +2895,6 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, } } - if (slow) { // is this block ever used at all? // replace all <@func> tags: "(<@func target=\"([^\"]*)\">)(.*)()" @@ -3076,10 +3219,9 @@ QString HtmlGenerator::fileBase(const Node *node, QString HtmlGenerator::fileName(const Node *node) { if (node->type() == Node::Fake) { - if (static_cast(node)->subType() == FakeNode::ExternalPage) + if (static_cast(node)->subType() == Node::ExternalPage) return node->name(); } - return PageGenerator::fileName(node); } @@ -3101,7 +3243,8 @@ QString HtmlGenerator::refForNode(const Node *node) typedeffe = static_cast(node); if (typedeffe->associatedEnum()) { return refForNode(typedeffe->associatedEnum()); - } else { + } + else { ref = node->name() + "-typedef"; } break; @@ -3109,15 +3252,27 @@ QString HtmlGenerator::refForNode(const Node *node) func = static_cast(node); if (func->associatedProperty()) { return refForNode(func->associatedProperty()); - } else { + } + else { ref = func->name(); if (func->overloadNumber() != 1) ref += "-" + QString::number(func->overloadNumber()); } break; case Node::Property: +#ifdef QDOC_QML + case Node::QmlProperty: +#endif ref = node->name() + "-prop"; break; +#ifdef QDOC_QML + case Node::QmlSignal: + ref = node->name() + "-signal"; + break; + case Node::QmlMethod: + ref = node->name() + "-method"; + break; +#endif case Node::Variable: ref = node->name() + "-var"; break; @@ -3166,9 +3321,11 @@ QString HtmlGenerator::refForAtom(Atom *atom, const Node * /* node */) { if (atom->type() == Atom::SectionLeft) { return Doc::canonicalTitle(Text::sectionHeading(atom).toString()); - } else if (atom->type() == Atom::Target) { + } + else if (atom->type() == Atom::Target) { return Doc::canonicalTitle(atom->string()); - } else { + } + else { return QString(); } } @@ -3212,7 +3369,10 @@ void HtmlGenerator::generateDetailedMember(const Node *node, out() << "
      "; generateSynopsis(enume, relative, marker, CodeMarker::Detailed); out() << "
      "; - generateSynopsis(enume->flagsType(), relative, marker, CodeMarker::Detailed); + generateSynopsis(enume->flagsType(), + relative, + marker, + CodeMarker::Detailed); out() << "\n"; } else { @@ -3364,7 +3524,7 @@ void HtmlGenerator::findAllNamespaces(const InnerNode *node) } } -#ifdef ZZZ_QDOC_QML +#ifdef ZZZ_QDOC_QML /*! This function finds all the qml element nodes and stores them in a map for later use. @@ -3375,24 +3535,16 @@ void HtmlGenerator::findAllQmlClasses(const InnerNode *node) while (c != node->childNodes().constEnd()) { if ((*c)->type() == Node::Fake) { const FakeNode* fakeNode = static_cast(*c); - if (fakeNode->subType() == FakeNode::QmlClass) { - const QmlNode* qmlNode = static_cast(fakeNode); - //qDebug() << "HtmlGenerator: QML CLASS" << qmlNode->name(); + if (fakeNode->subType() == Node::QmlClass) { + const QmlClassNode* qmlNode = + static_cast(fakeNode); const Node* n = qmlNode->classNode(); - if (n) - //qDebug() << " FOUND IT!" << n->name(); } qmlClasses.insert(fakeNode->name(),*c); } ++c; } } -#endif - -#if 0 - else if ((*c)->isInnerNode()) { - findAllClasses(static_cast(*c)); - } #endif int HtmlGenerator::hOffset(const Node *node) @@ -3705,3 +3857,214 @@ void HtmlGenerator::endLink() } QT_END_NAMESPACE + +#ifdef QDOC_QML + +/*! + Generates the summary for for the \a section. Only used for + sections of QML element documentation. + + Currently handles only the QML property group. + */ +void HtmlGenerator::generateQmlSummary(const Section& section, + const Node *relative, + CodeMarker *marker) +{ + if (!section.members.isEmpty()) { + NodeList::ConstIterator m; + int count = section.members.size(); + bool twoColumn = false; + if (section.members.first()->type() == Node::QmlProperty) { + twoColumn = (count >= 5); + } + if (twoColumn) + 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() << "
      • "; + generateQmlItem(*m,relative,marker,true); + out() << "
      • \n"; + row++; + ++m; + } + out() << "
      \n"; + if (twoColumn) + out() << "

      \n"; + } +} + +/*! + Outputs the html detailed documentation for a section + on a QML element reference page. + */ +void HtmlGenerator::generateDetailedQmlMember(const Node *node, + const InnerNode *relative, + CodeMarker *marker) +{ + const QmlPropertyNode* qpn = 0; + generateMacRef(node, marker); + out() << "
      "; + if (node->subType() == Node::QmlPropertyGroup) { + const QmlPropGroupNode* qpgn = static_cast(node); + NodeList::ConstIterator p = qpgn->childNodes().begin(); + out() << "
      "; + out() << ""; + + while (p != qpgn->childNodes().end()) { + if ((*p)->type() == Node::QmlProperty) { + qpn = static_cast(*p); + out() << ""; + if (qpgn->isDefault()) { + out() << "
      "; + out() << ""; + generateQmlItem(qpn, relative, marker, false); + out() << "
      " + << "
      " + << "
      " + << "
      " + << "" + << ""; + } + } + ++p; + } + out() << "
      " + << "default
      "; + out() << "
      "; + } + else if (node->type() == Node::QmlSignal) { + const QmlSignalNode* qsn = static_cast(node); + out() << "
      "; + out() << ""; + out() << ""; + out() << "
      "; + out() << ""; + generateQmlItem(qsn,relative,marker,false); + out() << "
      "; + out() << "
      "; + } + else if (node->type() == Node::QmlMethod) { + const QmlMethodNode* qmn = static_cast(node); + out() << "
      "; + out() << ""; + out() << ""; + out() << "
      "; + out() << ""; + generateQmlItem(qmn,relative,marker,false); + out() << "
      "; + out() << "
      "; + } + out() << "
      "; + generateStatus(node, marker); + generateBody(node, marker); + generateThreadSafeness(node, marker); + generateSince(node, marker); + generateAlsoList(node, marker); + out() << "
      "; + out() << "
      "; +} + +/*! + Output the "Inherits" line for the QML element, + if there should be one. + */ +void HtmlGenerator::generateQmlInherits(const QmlClassNode* cn, + CodeMarker* marker) +{ + if (cn && !cn->links().empty()) { + if (cn->links().contains(Node::InheritsLink)) { + QPair linkPair; + linkPair = cn->links()[Node::InheritsLink]; + QStringList strList(linkPair.first); + const Node* n = tre->findNode(strList,Node::Fake); + if (n && n->subType() == Node::QmlClass) { + const QmlClassNode* qcn = static_cast(n); + out() << "

      "; + Text text; + text << "[Inherits "; + text << Atom(Atom::LinkNode,CodeMarker::stringForNode(qcn)); + text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK); + text << Atom(Atom::String, linkPair.second); + text << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); + text << "]"; + generateText(text, cn, marker); + out() << "

      "; + } +// else +// qDebug() << "generateQmlInherits(): " +// << "Inherited element not documented -->" +// << linkPair.first; + } + } +} + +/*! + Output the "[Xxx instantiates the C++ class QFxXxx]" + line for the QML element, if there should be one. + + If there is no class node, or if the class node status + is set to Node::Internal, do nothing. + */ +void HtmlGenerator::generateQmlInstantiates(const QmlClassNode* qcn, + CodeMarker* marker) +{ + const ClassNode* cn = qcn->classNode(); + if (cn && (cn->status() != Node::Internal)) { + out() << "

      "; + Text text; + text << "["; + text << Atom(Atom::LinkNode,CodeMarker::stringForNode(qcn)); + text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK); + text << Atom(Atom::String, qcn->name()); + text << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); + text << " instantiates the C++ class "; + text << Atom(Atom::LinkNode,CodeMarker::stringForNode(cn)); + text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK); + text << Atom(Atom::String, cn->name()); + text << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); + text << "]"; + generateText(text, qcn, marker); + out() << "

      "; + } +} + +/*! + Output the "[QFxXxx is instantiated by QML element Xxx]" + line for the class, if there should be one. + + If there is no QML element, or if the class node status + is set to Node::Internal, do nothing. + */ +void HtmlGenerator::generateInstantiatedBy(const ClassNode* cn, + CodeMarker* marker) +{ + if (cn && cn->status() != Node::Internal && !cn->qmlElement().isEmpty()) { + const Node* n = tre->root()->findNode(cn->qmlElement(),Node::Fake); + if (n && n->subType() == Node::QmlClass) { + out() << "

      "; + Text text; + text << "["; + text << Atom(Atom::LinkNode,CodeMarker::stringForNode(cn)); + text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK); + text << Atom(Atom::String, cn->name()); + text << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); + text << " is instantiated by QML element "; + text << Atom(Atom::LinkNode,CodeMarker::stringForNode(n)); + text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK); + text << Atom(Atom::String, n->name()); + text << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); + text << "]"; + generateText(text, cn, marker); + out() << "

      "; + } + } +} + +#endif diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index a7632cd..180c307 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -145,6 +145,21 @@ class HtmlGenerator : public PageGenerator const Node *relative, CodeMarker *marker, CodeMarker::SynopsisStyle style); +#ifdef QDOC_QML + void generateQmlSummary(const Section& section, + const Node *relative, + CodeMarker *marker); + void generateQmlItem(const Node *node, + const Node *relative, + CodeMarker *marker, + bool summary); + void generateDetailedQmlMember(const Node *node, + const InnerNode *relative, + CodeMarker *marker); + void generateQmlInherits(const QmlClassNode* cn, CodeMarker* marker); + void generateQmlInstantiates(const QmlClassNode* qcn, CodeMarker* marker); + void generateInstantiatedBy(const ClassNode* cn, CodeMarker* marker); +#endif #ifdef QDOC_NAME_ALIGNMENT void generateSection(const NodeList& nl, const Node *relative, @@ -180,8 +195,12 @@ class HtmlGenerator : public PageGenerator const Node *relative, CodeMarker *marker, const Node *actualNode = 0); - void generateDetailedMember(const Node *node, const InnerNode *relative, CodeMarker *marker); - void generateLink(const Atom *atom, const Node *relative, CodeMarker *marker); + void generateDetailedMember(const Node *node, + const InnerNode *relative, + CodeMarker *marker); + void generateLink(const Atom *atom, + const Node *relative, + CodeMarker *marker); void generateStatus(const Node *node, CodeMarker *marker); QString registerRef(const QString& ref); diff --git a/tools/qdoc3/jambiapiparser.cpp b/tools/qdoc3/jambiapiparser.cpp index f981e6d..70e9260 100644 --- a/tools/qdoc3/jambiapiparser.cpp +++ b/tools/qdoc3/jambiapiparser.cpp @@ -234,8 +234,9 @@ void JambiApiParser::doneParsingSourceFiles(Tree * /* tree */) foreach (Node *cppNode, cppTre->root()->childNodes()) { if (cppNode->type() == Node::Fake) { FakeNode *cppFake = static_cast(cppNode); - if (cppFake->subType() == FakeNode::Page) { - FakeNode *javaFake = new FakeNode(javaTre->root(), cppFake->name(), + if (cppFake->subType() == Node::Page) { + FakeNode *javaFake = new FakeNode(javaTre->root(), + cppFake->name(), cppFake->subType()); javaFake->setModuleName("com.trolltech.qt"); // ### hard-coded javaFake->setTitle(cppFake->title()); diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index b2e53ab..610249d 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -43,6 +43,7 @@ node.cpp */ +#include #include "node.h" QT_BEGIN_NAMESPACE @@ -113,6 +114,9 @@ void Node::setRelates(InnerNode *pseudoParent) } /*! + This function creates a pair that describes a link. + The pair is composed from \a link and \a desc. The + \a linkType is the map index the pair is filed under. */ void Node::setLink(LinkType linkType, const QString &link, const QString &desc) { @@ -623,7 +627,7 @@ void InnerNode::removeRelated(Node *pseudoChild) */ /*! - Returns false because this is an InnerNode. + Returns false because this is a LeafNode. */ bool LeafNode::isInnerNode() const { @@ -713,9 +717,11 @@ void ClassNode::fixBaseClasses() */ /*! + The type of a FakeNode is Fake, and it has a \a subtype, + which specifies the type of FakeNode. */ -FakeNode::FakeNode(InnerNode *parent, const QString& name, SubType subType) - : InnerNode(Fake, parent, name), sub(subType) +FakeNode::FakeNode(InnerNode *parent, const QString& name, SubType subtype) + : InnerNode(Fake, parent, name), sub(subtype) { } @@ -1033,4 +1039,98 @@ bool TargetNode::isInnerNode() const return false; } +#ifdef QDOC_QML +/*! + Constructor for the Qml class node. + */ +QmlClassNode::QmlClassNode(InnerNode *parent, + const QString& name, + const ClassNode* cn) + : FakeNode(parent, name, QmlClass), cnode(cn) +{ + setTitle("QML " + name + " Element Reference"); +} + +/*! + The base file name for this kind of node has "qml_" + prepended to it. + + But not yet. Still testing. + */ +QString QmlClassNode::fileBase() const +{ +#if 0 + if (Node::fileBase() == "item") + qDebug() << "FILEBASE: qmlitem" << name(); + return "qml_" + Node::fileBase(); +#endif + return Node::fileBase(); +} + +/*! + Constructor for the Qml property group node. \a parent is + always a QmlClassNode. + */ +QmlPropGroupNode::QmlPropGroupNode(QmlClassNode* parent, const QString& name) + : FakeNode(parent, name, QmlPropertyGroup), isdefault(false) +{ + // nothing. +} + +/*! + Constructor for the QML property node. + */ +QmlPropertyNode::QmlPropertyNode(QmlPropGroupNode *parent, + const QString& name, + const QString& type) + : LeafNode(QmlProperty, parent, name), + dt(type), + sto(Trool_Default), + des(Trool_Default) +{ + // nothing. +} + +/*! + I don't know what this is. + */ +QmlPropertyNode::Trool QmlPropertyNode::toTrool(bool boolean) +{ + return boolean ? Trool_True : Trool_False; +} + +/*! + I don't know what this is either. + */ +bool QmlPropertyNode::fromTrool(Trool troolean, bool defaultValue) +{ + switch (troolean) { + case Trool_True: + return true; + case Trool_False: + return false; + default: + return defaultValue; + } +} + +/*! + Constructor for the QML signal node. + */ +QmlSignalNode::QmlSignalNode(QmlClassNode *parent, const QString& name) + : LeafNode(QmlSignal, parent, name) +{ + // nothing. +} + +/*! + Constructor for the QML method node. + */ +QmlMethodNode::QmlMethodNode(QmlClassNode *parent, const QString& name) + : LeafNode(QmlMethod, parent, name) +{ + // nothing. +} +#endif + QT_END_NAMESPACE diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h index a35bc17..17ec447 100644 --- a/tools/qdoc3/node.h +++ b/tools/qdoc3/node.h @@ -72,7 +72,31 @@ class Node Function, Property, Variable, +#ifdef QDOC_QML + Target, + QmlProperty, + QmlSignal, + QmlMethod +#else Target +#endif + }; + + enum SubType { + NoSubType, + Example, + HeaderFile, + File, + Group, + Module, + Page, +#ifdef QDOC_QML + ExternalPage, + QmlClass, + QmlPropertyGroup +#else + ExternalPage +#endif }; enum Access { Public, Protected, Private }; @@ -99,7 +123,8 @@ class Node NextLink, PreviousLink, ContentsLink, - IndexLink /*, + IndexLink, + InheritsLink /*, GlossaryLink, CopyrightLink, ChapterLink, @@ -125,6 +150,7 @@ class Node virtual bool isInnerNode() const = 0; virtual bool isReimp() const { return false; } Type type() const { return typ; } + virtual SubType subType() const { return NoSubType; } InnerNode *parent() const { return par; } InnerNode *relates() const { return rel; } const QString& name() const { return nam; } @@ -144,7 +170,7 @@ class Node void clearRelated() { rel = 0; } - QString fileBase() const; + virtual QString fileBase() const; protected: Node(Type type, InnerNode *parent, const QString& name); @@ -181,7 +207,7 @@ typedef QList NodeList; class InnerNode : public Node { public: - ~InnerNode(); + virtual ~InnerNode(); Node *findNode(const QString& name); Node *findNode(const QString& name, Type type); @@ -203,6 +229,7 @@ class InnerNode : public Node const EnumNode *findEnumNodeForValue(const QString &enumValue) const; const NodeList & childNodes() const { return children; } const NodeList & relatedNodes() const { return related; } + int count() const { return children.size(); } int overloadNumber(const FunctionNode *func) const; int numOverloads(const QString& funcName) const; NodeList overloads(const QString &funcName) const; @@ -232,17 +259,19 @@ class LeafNode : public Node { public: LeafNode(); + virtual ~LeafNode() { } virtual bool isInnerNode() const; protected: - LeafNode(Type type, InnerNode *parent, const QString& name); + LeafNode(Type type, InnerNode* parent, const QString& name); }; class NamespaceNode : public InnerNode { public: NamespaceNode(InnerNode *parent, const QString& name); + virtual ~NamespaceNode() { } }; class ClassNode; @@ -266,6 +295,7 @@ class ClassNode : public InnerNode { public: ClassNode(InnerNode *parent, const QString& name); + virtual ~ClassNode() { } void addBaseClass(Access access, ClassNode *node, @@ -280,29 +310,23 @@ class ClassNode : public InnerNode QString serviceName() const { return sname; } void setServiceName(const QString& value) { sname = value; } + QString qmlElement() const { return qmlelement; } + void setQmlElement(const QString& value) { qmlelement = value; } private: QList bas; QList der; bool hidden; QString sname; + QString qmlelement; }; class FakeNode : public InnerNode { public: - enum SubType { - Example, - HeaderFile, - File, - Group, - Module, - Page, - ExternalPage, - QmlClass - }; FakeNode(InnerNode *parent, const QString& name, SubType subType); + virtual ~FakeNode() { } void setTitle(const QString &title) { tle = title; } void setSubTitle(const QString &subTitle) { stle = subTitle; } @@ -321,18 +345,85 @@ class FakeNode : public InnerNode NodeList gr; }; -class QmlNode : public FakeNode +#ifdef QDOC_QML +class QmlClassNode : public FakeNode { public: - QmlNode(InnerNode *parent, const QString& name, const ClassNode* cn) - : FakeNode(parent, name, QmlClass), cnode(cn) { } + QmlClassNode(InnerNode *parent, + const QString& name, + const ClassNode* cn); + virtual ~QmlClassNode() { } const ClassNode* classNode() const { return cnode; } + virtual QString fileBase() const; private: const ClassNode* cnode; }; +class QmlPropGroupNode : public FakeNode +{ + public: + QmlPropGroupNode(QmlClassNode* parent, const QString& name); + virtual ~QmlPropGroupNode() { } + + const QString& element() const { return name(); } + void setDefault() { isdefault = true; } + bool isDefault() const { return isdefault; } + + private: + bool isdefault; +}; + +class QmlPropertyNode : public LeafNode +{ + public: + QmlPropertyNode(QmlPropGroupNode* parent, + const QString& name, + const QString& type); + virtual ~QmlPropertyNode() { } + + void setDataType(const QString& dataType) { dt = dataType; } + void setStored(bool stored) { sto = toTrool(stored); } + void setDesignable(bool designable) { des = toTrool(designable); } + + const QString &dataType() const { return dt; } + QString qualifiedDataType() const { return dt; } + bool isStored() const { return fromTrool(sto,true); } + bool isDesignable() const { return fromTrool(des,false); } + + const QString& element() const { return parent()->name(); } + + private: + enum Trool { Trool_True, Trool_False, Trool_Default }; + + static Trool toTrool(bool boolean); + static bool fromTrool(Trool troolean, bool defaultValue); + + QString dt; + Trool sto; + Trool des; +}; + +class QmlSignalNode : public LeafNode +{ + public: + QmlSignalNode(QmlClassNode* parent, const QString& name); + virtual ~QmlSignalNode() { } + + const QString& element() const { return parent()->name(); } +}; + +class QmlMethodNode : public LeafNode +{ + public: + QmlMethodNode(QmlClassNode* parent, const QString& name); + virtual ~QmlMethodNode() { } + + const QString& element() const { return parent()->name(); } +}; +#endif + class EnumItem { public: @@ -358,6 +449,7 @@ class EnumNode : public LeafNode { public: EnumNode(InnerNode *parent, const QString& name); + virtual ~EnumNode() { } void addItem(const EnumItem& item); void setFlagsType(TypedefNode *typedeff); @@ -378,6 +470,7 @@ class TypedefNode : public LeafNode { public: TypedefNode(InnerNode *parent, const QString& name); + virtual ~TypedefNode() { } const EnumNode *associatedEnum() const { return ae; } @@ -438,6 +531,7 @@ class FunctionNode : public LeafNode enum Virtualness { NonVirtual, ImpureVirtual, PureVirtual }; FunctionNode(InnerNode *parent, const QString &name); + virtual ~FunctionNode() { } void setReturnType(const QString& returnType) { rt = returnType; } void setMetaness(Metaness metaness) { met = metaness; } @@ -500,6 +594,7 @@ class PropertyNode : public LeafNode enum { NumFunctionRoles = Resetter + 1 }; PropertyNode(InnerNode *parent, const QString& name); + virtual ~PropertyNode() { } void setDataType(const QString& dataType) { dt = dataType; } void addFunction(FunctionNode *function, FunctionRole role); @@ -557,6 +652,7 @@ class VariableNode : public LeafNode { public: VariableNode(InnerNode *parent, const QString &name); + virtual ~VariableNode() { } void setLeftType(const QString &leftType) { lt = leftType; } void setRightType(const QString &rightType) { rt = rightType; } @@ -582,6 +678,7 @@ class TargetNode : public LeafNode { public: TargetNode(InnerNode *parent, const QString& name); + virtual ~TargetNode() { } virtual bool isInnerNode() const; }; diff --git a/tools/qdoc3/pagegenerator.cpp b/tools/qdoc3/pagegenerator.cpp index 06ff398..8715f4a 100644 --- a/tools/qdoc3/pagegenerator.cpp +++ b/tools/qdoc3/pagegenerator.cpp @@ -81,30 +81,50 @@ QString PageGenerator::fileBase(const Node *node) { if (node->relates()) node = node->relates(); - else if (!node->isInnerNode()) + else if (!node->isInnerNode()) { node = node->parent(); +#ifdef QDOC_QML + if (node->subType() == Node::QmlPropertyGroup) { + node = node->parent(); + } +#endif + } QString base = node->doc().baseName(); if (!base.isEmpty()) return base; - const Node *p = node; - - forever { - base.prepend(p->name()); + const Node *p = node; + + forever { + base.prepend(p->name()); +#ifdef QDOC_QML + /* + To avoid file name conflicts in the html directory, + we prepend "qml-" to the file name of QML element doc + files. + */ + if ((p->subType() == Node::QmlClass) || + (p->subType() == Node::QmlPropertyGroup)) + base.prepend("qml-"); + else if ((p->type() == Node::QmlProperty) || + (p->type() == Node::QmlSignal) || + (p->type() == Node::QmlMethod)) + base.prepend("qml-"); +#endif const Node *pp = p->parent(); if (!pp || pp->name().isEmpty() || pp->type() == Node::Fake) - break; + break; base.prepend(QLatin1Char('-')); p = pp; - } - - if (node->type() == Node::Fake) { + } + + if (node->type() == Node::Fake) { #ifdef QDOC2_COMPAT - if (base.endsWith(".html")) - base.truncate(base.length() - 5); + if (base.endsWith(".html")) + base.truncate(base.length() - 5); #endif - } + } // the code below is effectively equivalent to: // base.replace(QRegExp("[^A-Za-z0-9]+"), " "); @@ -126,7 +146,8 @@ QString PageGenerator::fileBase(const Node *node) if ((u >= 'a' && u <= 'z') || (u >= '0' && u <= '9')) { res += QLatin1Char(u); begun = true; - } else if (begun) { + } + else if (begun) { res += QLatin1Char('-'); begun = false; } @@ -187,8 +208,12 @@ void PageGenerator::generateInnerNode(const InnerNode *node, if (node->type() == Node::Fake) { const FakeNode *fakeNode = static_cast(node); - if (fakeNode->subType() == FakeNode::ExternalPage) + if (fakeNode->subType() == Node::ExternalPage) + return; +#ifdef QDOC_QML + if (fakeNode->subType() == Node::QmlPropertyGroup) return; +#endif } if (node->parent() != 0) { @@ -197,12 +222,6 @@ void PageGenerator::generateInnerNode(const InnerNode *node, generateClassLikeNode(node, marker); } else if (node->type() == Node::Fake) { - const FakeNode* fakeNode = static_cast(node); -#ifdef QDOC_QML - if (fakeNode->subType() == FakeNode::QmlClass) { - //qDebug() << "FILENAME:" << fileName(node); - } -#endif generateFakeNode(static_cast(node), marker); } endSubPage(); diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css index 3816164..4225a1b 100644 --- a/tools/qdoc3/test/classic.css +++ b/tools/qdoc3/test/classic.css @@ -225,3 +225,52 @@ span.string,span.char { font-size: 0.65em } + +.qmlitem { + padding: 0; +} + +.qmlname { + white-space: nowrap; + font-weight: bold; + font-size: 125%; +} + +.qmltype { + font-weight: bold; + font-size: 125%; +} + +.qmlproto, .qmldoc { + // border-top: 1px solid #84b0c7; +} + +.qmlproto { + padding: 0; + //background-color: #e4e4e4;//#d5e1e8; + //font-weight: bold; + //-webkit-border-top-left-radius: 8px; + //-webkit-border-top-right-radius: 8px; + //-moz-border-radius-topleft: 8px; + //-moz-border-radius-topright: 8px; +} + +.qmldoc { + border-top: 1px solid #e4e4e4; + //padding: 2px 5px; + //background-color: #eef3f5; + //border-top-width: 0; + //-webkit-border-bottom-left-radius: 8px; + //-webkit-border-bottom-right-radius: 8px; + //-moz-border-radius-bottomleft: 8px; + //-moz-border-radius-bottomright: 8px; +} + +.qmldoc p, .qmldoc dl, .qmldoc ul { + //margin: 6px 0; +} + +*.qmlitem p { + //margin-top: 0px; + //margin-bottom: 0px; +} diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp index 308ba0e..e6dd084 100644 --- a/tools/qdoc3/tree.cpp +++ b/tools/qdoc3/tree.cpp @@ -176,6 +176,8 @@ const Node *Tree::findNode(const QStringList &path, } /*! + Find the node with the specified \a path name of the + specified \a type. */ Node *Tree::findNode(const QStringList &path, Node::Type type, @@ -189,6 +191,8 @@ Node *Tree::findNode(const QStringList &path, } /*! + Find the node with the specified \a path name of the + specified \a type. */ const Node *Tree::findNode(const QStringList &path, Node::Type type, @@ -208,7 +212,9 @@ FunctionNode *Tree::findFunctionNode(const QStringList& path, int findFlags) { return const_cast( - const_cast(this)->findFunctionNode(path, relative, findFlags)); + const_cast(this)->findFunctionNode(path, + relative, + findFlags)); } /*! @@ -233,7 +239,8 @@ const FunctionNode *Tree::findFunctionNode(const QStringList &path, else next = ((InnerNode *) node)->findNode(path.at(i)); - if (!next && node->type() == Node::Class && (findFlags & SearchBaseClasses)) { + if (!next && node->type() == Node::Class && + (findFlags & SearchBaseClasses)) { NodeList baseClasses = allBaseClasses(static_cast(node)); foreach (const Node *baseClass, baseClasses) { if (i == path.size() - 1) @@ -563,7 +570,7 @@ void Tree::resolveGroups() FakeNode *fake = static_cast(findNode(QStringList(i.key()),Node::Fake)); - if (fake && fake->subType() == FakeNode::Group) { + if (fake && fake->subType() == Node::Group) { fake->addGroupMember(i.value()); } else { @@ -770,21 +777,21 @@ void Tree::readIndexSection(const QDomElement &element, } else if (element.nodeName() == "page") { - FakeNode::SubType subtype; + Node::SubType subtype; if (element.attribute("subtype") == "example") - subtype = FakeNode::Example; + subtype = Node::Example; else if (element.attribute("subtype") == "header") - subtype = FakeNode::HeaderFile; + subtype = Node::HeaderFile; else if (element.attribute("subtype") == "file") - subtype = FakeNode::File; + subtype = Node::File; else if (element.attribute("subtype") == "group") - subtype = FakeNode::Group; + subtype = Node::Group; else if (element.attribute("subtype") == "module") - subtype = FakeNode::Module; + subtype = Node::Module; else if (element.attribute("subtype") == "page") - subtype = FakeNode::Page; + subtype = Node::Page; else if (element.attribute("subtype") == "externalpage") - subtype = FakeNode::ExternalPage; + subtype = Node::ExternalPage; else return; @@ -1226,25 +1233,25 @@ bool Tree::generateIndexSection(QXmlStreamWriter &writer, const FakeNode *fakeNode = static_cast(node); switch (fakeNode->subType()) { - case FakeNode::Example: + case Node::Example: writer.writeAttribute("subtype", "example"); break; - case FakeNode::HeaderFile: + case Node::HeaderFile: writer.writeAttribute("subtype", "header"); break; - case FakeNode::File: + case Node::File: writer.writeAttribute("subtype", "file"); break; - case FakeNode::Group: + case Node::Group: writer.writeAttribute("subtype", "group"); break; - case FakeNode::Module: + case Node::Module: writer.writeAttribute("subtype", "module"); break; - case FakeNode::Page: + case Node::Page: writer.writeAttribute("subtype", "page"); break; - case FakeNode::ExternalPage: + case Node::ExternalPage: writer.writeAttribute("subtype", "externalpage"); break; default: @@ -1383,7 +1390,7 @@ bool Tree::generateIndexSection(QXmlStreamWriter &writer, bool external = false; if (inner->type() == Node::Fake) { const FakeNode *fakeNode = static_cast(inner); - if (fakeNode->subType() == FakeNode::ExternalPage) + if (fakeNode->subType() == Node::ExternalPage) external = true; } @@ -1863,7 +1870,7 @@ void Tree::generateTagFile(const QString &fileName) const */ void Tree::addExternalLink(const QString &url, const Node *relative) { - FakeNode *fakeNode = new FakeNode(root(), url, FakeNode::ExternalPage); + FakeNode *fakeNode = new FakeNode(root(), url, Node::ExternalPage); fakeNode->setAccess(Node::Public); // Create some content for the node. @@ -1898,6 +1905,11 @@ QString Tree::fullDocumentLocation(const Node *node) const return ""; } else if (node->type() == Node::Fake) { +#ifdef QDOC_QML + if (node->subType() == Node::QmlClass) + return "qml-" + node->fileBase() + ".html"; + else +#endif parentName = node->fileBase() + ".html"; } else if (node->fileBase().isEmpty()) diff --git a/tools/qdoc3/webxmlgenerator.cpp b/tools/qdoc3/webxmlgenerator.cpp index c5209b8..e87e812 100644 --- a/tools/qdoc3/webxmlgenerator.cpp +++ b/tools/qdoc3/webxmlgenerator.cpp @@ -191,7 +191,7 @@ void WebXMLGenerator::generateIndexSections(QXmlStreamWriter &writer, generateRelations(writer, node, marker); - if (fake->subType() == FakeNode::Module) { + if (fake->subType() == Node::Module) { writer.writeStartElement("generatedlist"); writer.writeAttribute("contents", "classesbymodule"); @@ -264,7 +264,7 @@ void WebXMLGenerator::generateInnerNode(const InnerNode *node, CodeMarker *marke if (node->type() == Node::Fake) { const FakeNode *fakeNode = static_cast(node); - if (fakeNode->subType() == FakeNode::ExternalPage) + if (fakeNode->subType() == Node::ExternalPage) return; } -- cgit v0.12 From 78f079016e0dd9b455d74c6a84cfbdb859fd1094 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 28 Jul 2009 11:35:59 +0200 Subject: Move uninit & readonly into a flags member of QX11PixmapData Also add 2 new flags and a new member to store any GL bound pixmap surface (GLXPixmap or EGLPixmapSurface). Reviewed-By: Samuel --- src/gui/image/qpixmap.cpp | 4 ++-- src/gui/image/qpixmap_x11.cpp | 23 +++++++++++------------ src/gui/image/qpixmap_x11_p.h | 12 ++++++++++-- src/gui/painting/qwindowsurface_x11.cpp | 4 ++-- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 2674cac..82835d5 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -649,7 +649,7 @@ void QPixmap::resize_helper(const QSize &s) QX11PixmapData *x11Data = data->classId() == QPixmapData::X11Class ? static_cast(data) : 0; if (x11Data) { pm.x11SetScreen(x11Data->xinfo.screen()); - uninit = x11Data->uninit; + uninit = x11Data->flags & QX11PixmapData::Uninitialized; } #elif defined(Q_WS_MAC) QMacPixmapData *macData = data->classId() == QPixmapData::MacClass ? static_cast(data) : 0; @@ -1936,7 +1936,7 @@ void QPixmap::detach() #if defined(Q_WS_X11) if (data->classId() == QPixmapData::X11Class) { QX11PixmapData *d = static_cast(data); - d->uninit = false; + d->flags &= ~QX11PixmapData::Uninitialized; // reset the cache data if (d->hd2) { diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index 86cf515..be3d070 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -313,7 +313,7 @@ int Q_GUI_EXPORT qt_x11_preferred_pixmap_depth = 0; QX11PixmapData::QX11PixmapData(PixelType type) : QPixmapData(type, X11Class), hd(0), - uninit(true), read_only(false), x11_mask(0), picture(0), mask_picture(0), hd2(0), + flags(Uninitialized), x11_mask(0), picture(0), mask_picture(0), hd2(0), gl_surface(0), share_mode(QPixmap::ImplicitlyShared), pengine(0) { } @@ -1217,7 +1217,7 @@ void QX11PixmapData::release() XFreePixmap(xinfo.display(), hd2); hd2 = 0; } - if (!read_only) + if (!(flags & Readonly)) XFreePixmap(xinfo.display(), hd); hd = 0; } @@ -1876,7 +1876,7 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform, } else { // color pixmap QPixmap pm; QX11PixmapData *x11Data = static_cast(pm.data); - x11Data->uninit = false; + x11Data->flags &= ~QX11PixmapData::Uninitialized; x11Data->xinfo = xinfo; x11Data->d = d; x11Data->w = w; @@ -2018,7 +2018,7 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) QPixmap pm(data); - data->uninit = false; + data->flags &= ~QX11PixmapData::Uninitialized; pm.x11SetScreen(scr); GC gc = XCreateGC(dpy, pm.handle(), 0, 0); @@ -2060,7 +2060,7 @@ QPaintEngine* QX11PixmapData::paintEngine() const { QX11PixmapData *that = const_cast(this); - if (read_only && share_mode == QPixmap::ImplicitlyShared) { + if ((flags & Readonly) && share_mode == QPixmap::ImplicitlyShared) { // if someone wants to draw onto us, copy the shared contents // and turn it into a fully fledged QPixmap ::Pixmap hd_copy = XCreatePixmap(X11->display, RootWindow(X11->display, xinfo.screen()), @@ -2082,7 +2082,7 @@ QPaintEngine* QX11PixmapData::paintEngine() const XFreeGC(X11->display, gc); } that->hd = hd_copy; - that->read_only = false; + that->flags &= ~QX11PixmapData::Readonly; } if (!that->pengine) @@ -2133,7 +2133,7 @@ void QX11PixmapData::copy(const QPixmapData *data, const QRect &rect) setSerialNumber(++qt_pixmap_serial); - uninit = false; + flags &= ~Uninitialized; xinfo = x11Data->xinfo; d = x11Data->d; w = rect.width(); @@ -2201,7 +2201,7 @@ void QX11PixmapData::convertToARGB32(bool preserveContents) return; // Q_ASSERT(count == 1); - if (read_only && share_mode == QPixmap::ExplicitlyShared) + if ((flags & Readonly) && share_mode == QPixmap::ExplicitlyShared) return; Pixmap pm = XCreatePixmap(X11->display, RootWindow(X11->display, xinfo.screen()), @@ -2211,10 +2211,10 @@ void QX11PixmapData::convertToARGB32(bool preserveContents) if (picture) { if (preserveContents) XRenderComposite(X11->display, PictOpSrc, picture, 0, p, 0, 0, 0, 0, 0, 0, w, h); - if (!read_only) + if (!(flags & Readonly)) XRenderFreePicture(X11->display, picture); } - if (hd && !read_only) + if (hd && !(flags & Readonly)) XFreePixmap(X11->display, hd); if (x11_mask) { XFreePixmap(X11->display, x11_mask); @@ -2252,9 +2252,8 @@ QPixmap QPixmap::fromX11Pixmap(Qt::HANDLE pixmap, QPixmap::ShareMode mode) QX11PixmapData *data = new QX11PixmapData(depth == 1 ? QPixmapData::BitmapType : QPixmapData::PixmapType); data->setSerialNumber(++qt_pixmap_serial); - data->read_only = true; + data->flags = QX11PixmapData::Readonly; data->share_mode = mode; - data->uninit = false; data->w = width; data->h = height; data->is_null = (width <= 0 || height <= 0); diff --git a/src/gui/image/qpixmap_x11_p.h b/src/gui/image/qpixmap_x11_p.h index 3de9a0f..835fea4 100644 --- a/src/gui/image/qpixmap_x11_p.h +++ b/src/gui/image/qpixmap_x11_p.h @@ -99,6 +99,7 @@ private: friend class QX11PaintEngine; friend class QX11WindowSurface; friend class QRasterWindowSurface; + friend class QGLContextPrivate; // Needs to access xinfo, gl_surface & flags void release(); @@ -108,14 +109,21 @@ private: Qt::HANDLE hd; - uint uninit : 1; - uint read_only : 1; + enum Flag { + NoFlags = 0x0, + Uninitialized = 0x1, + Readonly = 0x2, + InvertedWhenBoundToTexture = 0x4, + GlSurfaceCreatedWithAlpha = 0x8 + }; + uint flags; QX11Info xinfo; Qt::HANDLE x11_mask; Qt::HANDLE picture; Qt::HANDLE mask_picture; Qt::HANDLE hd2; // sorted in the default display depth + Qt::HANDLE gl_surface; #ifndef QT_NO_XRENDER void convertToARGB32(bool preserveContents = true); #endif diff --git a/src/gui/painting/qwindowsurface_x11.cpp b/src/gui/painting/qwindowsurface_x11.cpp index d8b0d9e..95f6ce3 100644 --- a/src/gui/painting/qwindowsurface_x11.cpp +++ b/src/gui/painting/qwindowsurface_x11.cpp @@ -154,7 +154,7 @@ void QX11WindowSurface::setGeometry(const QRect &rect) QX11PixmapData *oldData = static_cast(d_ptr->device.pixmapData()); Q_ASSERT(oldData); - if (!oldData->uninit && hasStaticContents()) { + if (!(oldData->flags & QX11PixmapData::Uninitialized) && hasStaticContents()) { // Copy the content of the old pixmap into the new one. QX11PixmapData *newData = new QX11PixmapData(QPixmapData::PixmapType); newData->resize(size.width(), size.height()); @@ -175,7 +175,7 @@ void QX11WindowSurface::setGeometry(const QRect &rect) dx, dy, qMin(boundingRect.width(), size.width()), qMin(boundingRect.height(), size.height()), dx, dy); XFreeGC(X11->display, tmpGc); - newData->uninit = false; + newData->flags &= ~QX11PixmapData::Uninitialized; d_ptr->device = QPixmap(newData); } else { -- cgit v0.12 From 65702aa6b44568946b8c3924a45b9362401d893c Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 28 Jul 2009 15:57:36 +0200 Subject: Refactor texture_from_pixmap to not re-create the gl surface each bind Make a clear seperation between the GL texture and the GLX pixmap. A GLXPixmap is valid in any GL context and thus does not need to be re-created every time the pixmap has changed. Reviewed-By: Samuel --- src/gui/image/qpixmapdata_p.h | 1 + src/opengl/qgl.cpp | 24 ++++-- src/opengl/qgl_p.h | 11 ++- src/opengl/qgl_x11.cpp | 194 ++++++++++++++++++++++++++---------------- src/opengl/qgl_x11egl.cpp | 10 ++- 5 files changed, 152 insertions(+), 88 deletions(-) diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index 29dafaf..32b419e 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -116,6 +116,7 @@ private: friend class QPixmap; friend class QGLContextPrivate; friend class QX11PixmapData; + friend class QGLTextureCache; //Needs to check the reference count QAtomicInt ref; int detach_no; diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 8bb72d5..a8d1797 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1488,12 +1488,18 @@ void QGLTextureCache::imageCleanupHook(qint64 cacheKey) void QGLTextureCache::pixmapCleanupHook(QPixmap* pixmap) { // ### remove when the GL texture cache becomes thread-safe - if (qApp->thread() != QThread::currentThread()) - return; - const qint64 cacheKey = pixmap->cacheKey(); - QGLTexture *texture = instance()->getTexture(cacheKey); - if (texture && texture->clean) - instance()->remove(cacheKey); + if (qApp->thread() == QThread::currentThread()) { + const qint64 cacheKey = pixmap->cacheKey(); + QGLTexture *texture = instance()->getTexture(cacheKey); + if (texture && texture->clean) + instance()->remove(cacheKey); + } +#if defined(Q_WS_X11) + QPixmapData *pd = pixmap->data_ptr(); + // Only need to delete the gl surface if the pixmap is about to be deleted + if (pd->ref == 0) + QGLContextPrivate::destroyGlSurfaceForPixmap(pd); +#endif } void QGLTextureCache::deleteIfEmpty() @@ -2036,11 +2042,11 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, #if defined(Q_WS_X11) // Try to use texture_from_pixmap if (pd->classId() == QPixmapData::X11Class) { - QPixmap *thatPixmap = const_cast(&pixmap); - texture = bindTextureFromNativePixmap(thatPixmap, key, canInvert); + texture = bindTextureFromNativePixmap(pd, key, canInvert); if (texture) { texture->clean = clean; - boundPixmaps.insert(thatPixmap->data_ptr(), QPixmap(pixmap)); + texture->boundPixmap = pd; + boundPixmaps.insert(pd, QPixmap(pixmap)); } } #endif diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index a83cc63..f21ab93 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -241,7 +241,9 @@ public: quint32 gpm; int screen; QHash boundPixmaps; - QGLTexture *bindTextureFromNativePixmap(QPixmap *pm, const qint64 key, bool internal); + QGLTexture *bindTextureFromNativePixmap(QPixmapData*, const qint64 key, bool canInvert); + static void destroyGlSurfaceForPixmap(QPixmapData*); + static void unbindPixmapFromTexture(QPixmapData*); #endif #if defined(Q_WS_MAC) bool update; @@ -423,7 +425,8 @@ public: // is a current context - the context the pixmap was bound to a texture in. // Otherwise the release doesn't do anything and you get BadDrawable errors // when you come to delete the context. - deleteBoundPixmap(); + if (boundPixmap) + QGLContextPrivate::unbindPixmapFromTexture(boundPixmap); #endif glDeleteTextures(1, &id); if (switch_context && current) @@ -437,9 +440,9 @@ public: bool clean; bool yInverted; // NOTE: Y-Inverted textures are for internal use only! #if defined(Q_WS_X11) - Qt::HANDLE boundPixmap; - void deleteBoundPixmap(); // in qgl_x11.cpp/qgl_x11egl.cpp + QPixmapData* boundPixmap; #endif + }; class QGLTextureCache { diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 6381bc2..34e9d38 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -1536,38 +1536,26 @@ void QGLExtensions::init() } } -#if !defined(glXBindTexImageEXT) +// Solaris defines glXBindTexImageEXT as part of the GL library +#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) && !defined(glXBindTexImageEXT) typedef void (*qt_glXBindTexImageEXT)(Display*, GLXDrawable, int, const int*); -static qt_glXBindTexImageEXT glXBindTexImageEXT = 0; -#endif -#if !defined(glXReleaseTexImageEXT) typedef void (*qt_glXReleaseTexImageEXT)(Display*, GLXDrawable, int); +static qt_glXBindTexImageEXT glXBindTexImageEXT = 0; static qt_glXReleaseTexImageEXT glXReleaseTexImageEXT = 0; -#endif -static bool qt_resolved_texture_from_pixmap = false; -QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pm, const qint64 key, bool canInvert) +bool qt_resolveTextureFromPixmap() { -#if !defined(Q_OS_LINUX) - return 0; -#else - Q_Q(QGLContext); - - if (pm->data_ptr()->classId() != QPixmapData::X11Class) - return 0; - QX11PixmapData *pixmapData = static_cast(pm->data_ptr()); - const QX11Info *x11Info = qt_x11Info(pm); - - - // Check to see if we have NPOT texture support - // TODO: Use GLX_TEXTURE_RECTANGLE_EXT texture target on systems without npot textures - if ( !(QGLExtensions::glExtensions & QGLExtensions::NPOTTextures) && - !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)) - return 0; + static bool resolvedTextureFromPixmap = false; + if (!resolvedTextureFromPixmap) { + resolvedTextureFromPixmap = true; - if (!qt_resolved_texture_from_pixmap) { - qt_resolved_texture_from_pixmap = true; + // Check to see if we have NPOT texture support + if ( !(QGLExtensions::glExtensions & QGLExtensions::NPOTTextures) && + !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)) + { + return false; // Can't use TFP without NPOT + } QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); if (glxExt.contains(QLatin1String("GLX_EXT_texture_from_pixmap"))) { @@ -1589,81 +1577,141 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pm, const qi } } - if (!glXBindTexImageEXT) - return 0; + return glXBindTexImageEXT && glXReleaseTexImageEXT; +} +#endif //defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) && !defined(glXBindTexImageEXT) + +QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData *pmd, const qint64 key, bool canInvert) +{ #if !defined(GLX_VERSION_1_3) || defined(Q_OS_HPUX) return 0; #else - GLXFBConfig *configList = 0; - GLXFBConfig glxPixmapConfig; - int configCount = 0; - bool hasAlpha = pixmapData->hasAlphaChannel(); - - int configAttribs[] = { - hasAlpha ? GLX_BIND_TO_TEXTURE_RGBA_EXT : GLX_BIND_TO_TEXTURE_RGB_EXT, True, - GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, - GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT, - // QGLContext::bindTexture() can't return an inverted texture, but QPainter::drawPixmap() can: - GLX_Y_INVERTED_EXT, canInvert ? GLX_DONT_CARE : False, - XNone -// GLX_BIND_TO_MIPMAP_TEXTURE_EXT, False, -// GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_1D_BIT_EXT or GLX_TEXTURE_2D_BIT_EXT or GLX_TEXTURE_RECTANGLE_BIT_EXT - }; - configList = glXChooseFBConfig(x11Info->display(), x11Info->screen(), configAttribs, &configCount); - if (!configList) - return 0; - glxPixmapConfig = configList[0]; - XFree(configList); - - GLXPixmap glxPixmap; - int pixmapAttribs[] = { - GLX_TEXTURE_FORMAT_EXT, hasAlpha ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT, - GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, - GLX_MIPMAP_TEXTURE_EXT, False, - XNone -// GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT or GLX_TEXTURE_FORMAT_RGB_EXT or GLX_TEXTURE_FORMAT_NONE_EXT, -// GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT or GLX_TEXTURE_RECTANGLE_EXT, -// GLX_MIPMAP_TEXTURE_EXT, True or False, - }; + Q_Q(QGLContext); - // Wrap the X Pixmap into a GLXPixmap: - glxPixmap = glXCreatePixmap(x11Info->display(), glxPixmapConfig, pixmapData->handle(), pixmapAttribs); + Q_ASSERT(pmd->classId() == QPixmapData::X11Class); - if (!glxPixmap) +#if !defined(glXBindTexImageEXT) + if (!qt_resolveTextureFromPixmap()) return 0; +#endif - int yInverted; - glXGetFBConfigAttrib(x11Info->display(), glxPixmapConfig, GLX_Y_INVERTED_EXT, &yInverted); + QX11PixmapData *pixmapData = static_cast(pmd); + const QX11Info &x11Info = pixmapData->xinfo; + + // Store the configs (Can be static because configs aren't dependent on current context) + static GLXFBConfig glxRGBPixmapConfig = 0; + static bool RGBConfigInverted = false; + static GLXFBConfig glxRGBAPixmapConfig = 0; + static bool RGBAConfigInverted = false; + + bool hasAlpha = pixmapData->hasAlphaChannel(); + + // Check to see if we need a config + if ( (hasAlpha && !glxRGBAPixmapConfig) || (!hasAlpha && !glxRGBPixmapConfig) ) { + GLXFBConfig *configList = 0; + int configCount = 0; + + int configAttribs[] = { + hasAlpha ? GLX_BIND_TO_TEXTURE_RGBA_EXT : GLX_BIND_TO_TEXTURE_RGB_EXT, True, + GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, + GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT, + // QGLContext::bindTexture() can't return an inverted texture, but QPainter::drawPixmap() can: + GLX_Y_INVERTED_EXT, canInvert ? GLX_DONT_CARE : False, + XNone + }; + configList = glXChooseFBConfig(x11Info.display(), x11Info.screen(), configAttribs, &configCount); + if (!configList) + return 0; + + int yInv; + glXGetFBConfigAttrib(x11Info.display(), configList[0], GLX_Y_INVERTED_EXT, &yInv); + + if (hasAlpha) { + glxRGBAPixmapConfig = configList[0]; + RGBAConfigInverted = yInv; + } + else { + glxRGBPixmapConfig = configList[0]; + RGBConfigInverted = yInv; + } + + XFree(configList); + } + + // Check to see if the surface is still valid + if (pixmapData->gl_surface && + hasAlpha != (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha)) + { + // Surface is invalid! + destroyGlSurfaceForPixmap(pixmapData); + } + + // Check to see if we need a surface + if (!pixmapData->gl_surface) { + GLXPixmap glxPixmap; + int pixmapAttribs[] = { + GLX_TEXTURE_FORMAT_EXT, hasAlpha ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT, + GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, + GLX_MIPMAP_TEXTURE_EXT, False, // Maybe needs to be don't care + XNone + }; + + // Wrap the X Pixmap into a GLXPixmap: + glxPixmap = glXCreatePixmap(x11Info.display(), + hasAlpha ? glxRGBAPixmapConfig : glxRGBPixmapConfig, + pixmapData->handle(), pixmapAttribs); + + if (!glxPixmap) + return 0; + + pixmapData->gl_surface = (Qt::HANDLE)glxPixmap; + + // Make sure the cleanup hook gets called so we can delete the glx pixmap + pixmapData->is_cached = true; + } GLuint textureId; glGenTextures(1, &textureId); glBindTexture(GL_TEXTURE_2D, textureId); - glXBindTexImageEXT(x11Info->display(), glxPixmap, GLX_FRONT_LEFT_EXT, 0); + glXBindTexImageEXT(x11Info.display(), (GLXPixmap)pixmapData->gl_surface, GLX_FRONT_LEFT_EXT, 0); glBindTexture(GL_TEXTURE_2D, textureId); - QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, canInvert, yInverted); - texture->boundPixmap = glxPixmap; + QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, canInvert, false); + texture->yInverted = (hasAlpha && RGBAConfigInverted) || (!hasAlpha && RGBConfigInverted); + if (texture->yInverted) + pixmapData->flags |= QX11PixmapData::InvertedWhenBoundToTexture; // We assume the cost of bound pixmaps is zero QGLTextureCache::instance()->insert(q, key, texture, 0); return texture; #endif //!defined(GLX_VERSION_1_3) || defined(Q_OS_HPUX) -#endif //!defined(Q_OS_LINUX } -void QGLTexture::deleteBoundPixmap() + +void QGLContextPrivate::destroyGlSurfaceForPixmap(QPixmapData* pmd) { -#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) && defined(Q_OS_LINUX) - if (boundPixmap) { - glXReleaseTexImageEXT(QX11Info::display(), boundPixmap, GLX_FRONT_LEFT_EXT); - glXDestroyPixmap(QX11Info::display(), boundPixmap); - boundPixmap = 0; +#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) + Q_ASSERT(pmd->classId() == QPixmapData::X11Class); + QX11PixmapData *pixmapData = static_cast(pmd); + if (pixmapData->gl_surface) { + glXDestroyPixmap(QX11Info::display(), (GLXPixmap)pixmapData->gl_surface); + pixmapData->gl_surface = 0; } #endif } +void QGLContextPrivate::unbindPixmapFromTexture(QPixmapData* pmd) +{ +#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) + Q_ASSERT(pmd->classId() == QPixmapData::X11Class); + Q_ASSERT(QGLContext::currentContext()); + QX11PixmapData *pixmapData = static_cast(pmd); + if (pixmapData->gl_surface) + glXReleaseTexImageEXT(QX11Info::display(), (GLXPixmap)pixmapData->gl_surface, GLX_FRONT_LEFT_EXT); +#endif +} QT_END_NAMESPACE diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index c6904fe..6b90a4f 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -486,13 +486,19 @@ void QGLWidgetPrivate::recreateEglSurface(bool force) } } -QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pm, const qint64 key, bool canInvert) + +QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData*, const qint64 key, bool canInvert) { // TODO return 0; } -void QGLTexture::deleteBoundPixmap() +void QGLContextPrivate::destroyGlSurfaceForPixmap(QPixmapData*) +{ + //TODO +} + +void QGLContextPrivate::unbindPixmapFromTexture(QPixmapData*) { //TODO } -- cgit v0.12 From fd0cd53a24459e0314360d70d8499b491c06a8e4 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 24 Jul 2009 18:44:45 +0200 Subject: Add a getter to QEglContext for the EGL extension string Reviewed-By: Rhys Weatherley --- src/gui/egl/qegl.cpp | 11 +++++++++++ src/gui/egl/qegl_p.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 89d9d1b..ebdac9a 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -400,4 +400,15 @@ void QEglContext::dumpAllConfigs() delete [] configs; } +QString QEglContext::extensions() +{ + const char* exts = eglQueryString(dpy, EGL_EXTENSIONS); + return QString(QLatin1String(exts)); +} + +bool QEglContext::hasExtension(const char* extensionName) +{ + return extensions().contains(QLatin1String(extensionName)); +} + QT_END_NAMESPACE diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index ddf7d27..3ae1489 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -122,6 +122,9 @@ public: void dumpAllConfigs(); + QString extensions(); + bool hasExtension(const char* extensionName); + private: QEgl::API apiType; EGLDisplay dpy; -- cgit v0.12 From e71c1a89f4747c8f94e19113d1fcbc3c51450f3e Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 24 Jul 2009 18:46:29 +0200 Subject: Support EGL_NOKIA_texture_from_pixmap on Harmattan Added QGLContextPrivate::bindTextureFromNativePixmap() implementation for X11/EGL. --- src/opengl/qgl_x11egl.cpp | 171 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 163 insertions(+), 8 deletions(-) diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 6b90a4f..5ab3647 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -41,15 +41,16 @@ #include "qgl.h" #include +#include #include #include #include "qgl_egl_p.h" #include "qcolormap.h" +#include QT_BEGIN_NAMESPACE - bool QGLFormat::hasOpenGL() { return true; @@ -487,20 +488,174 @@ void QGLWidgetPrivate::recreateEglSurface(bool force) } -QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData*, const qint64 key, bool canInvert) +QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData* pd, const qint64 key, bool canInvert) { - // TODO - return 0; + Q_Q(QGLContext); + + Q_ASSERT(pd->classId() == QPixmapData::X11Class); + + static bool checkedForTFP = false; + static bool haveTFP = false; + + if (!checkedForTFP) { + // Check for texture_from_pixmap egl extension + checkedForTFP = true; + if (eglContext->hasExtension("EGL_NOKIA_texture_from_pixmap") || + eglContext->hasExtension("EGL_EXT_texture_from_pixmap")) + { + qDebug("Found texture_from_pixmap EGL extension!"); + haveTFP = true; + } + } + + if (!haveTFP) + return 0; + + QX11PixmapData *pixmapData = static_cast(pd); + + bool hasAlpha = pixmapData->hasAlphaChannel(); + + // Check to see if the surface is still valid + if (pixmapData->gl_surface && + hasAlpha != (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha)) + { + // Surface is invalid! + destroyGlSurfaceForPixmap(pixmapData); + } + + EGLint pixmapAttribs[] = { + EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, + EGL_TEXTURE_FORMAT, hasAlpha ? EGL_TEXTURE_RGBA : EGL_TEXTURE_RGB, + EGL_NONE + }; + Q_ASSERT(sizeof(Qt::HANDLE) >= sizeof(EGLSurface)); // Just to make totally sure! + if (pixmapData->gl_surface == 0) + pixmapData->gl_surface = (Qt::HANDLE)EGL_NO_SURFACE; + EGLSurface pixmapSurface = (EGLSurface)pixmapData->gl_surface; + static EGLConfig pixmapRGBConfig = 0; + static EGLConfig pixmapRGBAConfig = 0; + + // Check to see if we need to find a config + if ((hasAlpha && !pixmapRGBAConfig) || (!hasAlpha && !pixmapRGBConfig) ) { + const EGLint configAttribs[] = { + EGL_SURFACE_TYPE, EGL_PIXMAP_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_DEPTH_SIZE, 0, + hasAlpha ? EGL_BIND_TO_TEXTURE_RGBA : EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE, + EGL_NONE + }; + + EGLint configCount = 0; + eglChooseConfig(eglContext->display(), configAttribs, 0, 256, &configCount); + if (configCount == 0) { + haveTFP = false; + qWarning("bindTextureFromNativePixmap() - Couldn't find a suitable config"); + return 0; + } + + EGLConfig *configList = new EGLConfig[configCount]; + eglChooseConfig(eglContext->display(), configAttribs, configList, configCount, &configCount); + Q_ASSERT(configCount); + + // Try to create a pixmap surface for each config until one works + for (int i = 0; i < configCount; ++i) { + pixmapSurface = eglCreatePixmapSurface(eglContext->display(), configList[i], + (EGLNativePixmapType) pixmapData->handle(), + pixmapAttribs); + if (pixmapSurface != EGL_NO_SURFACE) { + // Got one! + qDebug() << "Found an" << (hasAlpha ? "ARGB" : "RGB") + << "config (" << int(configList[i]) << ") to create a pixmap surface"; + if (hasAlpha) + pixmapRGBAConfig = configList[i]; + else + pixmapRGBConfig = configList[i]; + pixmapData->gl_surface = (Qt::HANDLE)pixmapSurface; + break; + } + } + delete configList; + + if ((hasAlpha && !pixmapRGBAConfig) || (!hasAlpha && !pixmapRGBConfig) ) { + qDebug("Couldn't create a pixmap surface with any of the provided configs"); + haveTFP = false; + return 0; + } + } + + if (pixmapSurface == EGL_NO_SURFACE) { + pixmapSurface = eglCreatePixmapSurface(eglContext->display(), + hasAlpha? pixmapRGBAConfig : pixmapRGBConfig, + (EGLNativePixmapType) pixmapData->handle(), + pixmapAttribs); + if (pixmapSurface == EGL_NO_SURFACE) { + qWarning("Failed to create a pixmap surface using config %d", + (int)(hasAlpha? pixmapRGBAConfig : pixmapRGBConfig)); + haveTFP = false; + return 0; + } + pixmapData->gl_surface = (Qt::HANDLE)pixmapSurface; + } + + // Make sure the cleanup hook gets called so we can delete the glx pixmap + pixmapData->is_cached = true; + Q_ASSERT(pixmapData->gl_surface); + + GLuint textureId; + glGenTextures(1, &textureId); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, textureId); + + // bind the egl pixmap surface to a texture + EGLBoolean success; + success = eglBindTexImage(eglContext->display(), pixmapSurface, EGL_BACK_BUFFER); + if (success == EGL_FALSE) { + qWarning() << "eglBindTexImage() failed:" << eglContext->errorString(eglGetError()); + eglDestroySurface(eglContext->display(), pixmapSurface); + pixmapData->gl_surface = (Qt::HANDLE)EGL_NO_SURFACE; + haveTFP = false; + return 0; + } + + QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, canInvert, true); + pixmapData->flags |= QX11PixmapData::InvertedWhenBoundToTexture; + + // We assume the cost of bound pixmaps is zero + QGLTextureCache::instance()->insert(q, key, texture, 0); + + glBindTexture(GL_TEXTURE_2D, textureId); + return texture; } -void QGLContextPrivate::destroyGlSurfaceForPixmap(QPixmapData*) +void QGLContextPrivate::destroyGlSurfaceForPixmap(QPixmapData* pmd) { - //TODO + Q_ASSERT(pmd->classId() == QPixmapData::X11Class); + QX11PixmapData *pixmapData = static_cast(pmd); + if (pixmapData->gl_surface) { + EGLBoolean success; + success = eglDestroySurface(QEglContext::defaultDisplay(0), (EGLSurface)pixmapData->gl_surface); + if (success == EGL_FALSE) { + qWarning() << "destroyGlSurfaceForPixmap() - Error deleting surface: " + << QEglContext::errorString(eglGetError()); + } + pixmapData->gl_surface = 0; + } } -void QGLContextPrivate::unbindPixmapFromTexture(QPixmapData*) +void QGLContextPrivate::unbindPixmapFromTexture(QPixmapData* pmd) { - //TODO + Q_ASSERT(pmd->classId() == QPixmapData::X11Class); + QX11PixmapData *pixmapData = static_cast(pmd); + if (pixmapData->gl_surface) { + EGLBoolean success; + success = eglReleaseTexImage(QEglContext::defaultDisplay(0), + (EGLSurface)pixmapData->gl_surface, + EGL_BACK_BUFFER); + if (success == EGL_FALSE) { + qWarning() << "unbindPixmapFromTexture() - Unable to release bound texture: " + << QEglContext::errorString(eglGetError()); + } + } } QT_END_NAMESPACE -- cgit v0.12 From 0ff4c453bf3d549e8344ab18f643f61a8b6174ef Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 29 Jul 2009 14:50:06 +0200 Subject: Fix build on Solaris x86 with old Mesa glx headers --- src/opengl/qgl_x11.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 34e9d38..642c7c1 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -58,11 +58,16 @@ #include #endif +// We always define GLX_EXT_texture_from_pixmap ourselves because +// we can't trust system headers to do it properly +#define GLX_EXT_texture_from_pixmap 1 + #define INT8 dummy_INT8 #define INT32 dummy_INT32 #include #undef INT8 #undef INT32 + #include #include #include @@ -82,7 +87,7 @@ extern const QX11Info *qt_x11Info(const QPaintDevice *pd); #define GLX_SAMPLES_ARB 100001 #endif -#ifndef GLX_EXT_texture_from_pixmap +#ifndef GLX_TEXTURE_2D_BIT_EXT #define GLX_TEXTURE_2D_BIT_EXT 0x00000002 #define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 #define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 @@ -1537,7 +1542,7 @@ void QGLExtensions::init() } // Solaris defines glXBindTexImageEXT as part of the GL library -#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) && !defined(glXBindTexImageEXT) +#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) typedef void (*qt_glXBindTexImageEXT)(Display*, GLXDrawable, int, const int*); typedef void (*qt_glXReleaseTexImageEXT)(Display*, GLXDrawable, int); static qt_glXBindTexImageEXT glXBindTexImageEXT = 0; @@ -1579,7 +1584,7 @@ bool qt_resolveTextureFromPixmap() return glXBindTexImageEXT && glXReleaseTexImageEXT; } -#endif //defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) && !defined(glXBindTexImageEXT) +#endif //defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData *pmd, const qint64 key, bool canInvert) @@ -1591,10 +1596,8 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData *pmd, con Q_ASSERT(pmd->classId() == QPixmapData::X11Class); -#if !defined(glXBindTexImageEXT) if (!qt_resolveTextureFromPixmap()) return 0; -#endif QX11PixmapData *pixmapData = static_cast(pmd); const QX11Info &x11Info = pixmapData->xinfo; -- cgit v0.12 From 13a76f28e11d85353f799f31d2e0b75ffe2f7956 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 29 Jul 2009 15:22:44 +0200 Subject: test that vars are stored in custom global object --- tests/auto/qscriptengine/tst_qscriptengine.cpp | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index ab398e9..830cfc7 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -893,6 +893,35 @@ void tst_QScriptEngine::getSetGlobalObject() QVERIFY(eng.globalObject().strictlyEquals(obj)); QVERIFY(eng.currentContext()->thisObject().strictlyEquals(obj)); QVERIFY(eng.currentContext()->activationObject().strictlyEquals(obj)); + + QVERIFY(!obj.property("foo").isValid()); + eng.evaluate("var foo = 123"); + { + QScriptValue ret = obj.property("foo"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 123); + } + + QVERIFY(!obj.property("bar").isValid()); + eng.evaluate("bar = 456"); + { + QScriptValue ret = obj.property("bar"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 456); + } + + QVERIFY(!obj.property("baz").isValid()); + eng.evaluate("this['baz'] = 789"); + { + QScriptValue ret = obj.property("baz"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 789); + } + + { + QScriptValue ret = eng.evaluate("(function() { return this; })()"); + QVERIFY(ret.strictlyEquals(obj)); + } } void tst_QScriptEngine::checkSyntax_data() -- cgit v0.12 From d63f08018b0952eb917e090f214a1dbe24e2a767 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Wed, 29 Jul 2009 17:17:12 +0200 Subject: Doc - Renamed the cursor's images to illustrate splitV and splitH properly Task: 258895 Reviewed-By: Jens Bache-Wiig --- doc/src/images/cursor-hsplit.png | Bin 161 -> 155 bytes doc/src/images/cursor-vsplit.png | Bin 155 -> 161 bytes src/gui/kernel/qcursor.cpp | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/images/cursor-hsplit.png b/doc/src/images/cursor-hsplit.png index 1beda25..a5667e3 100644 Binary files a/doc/src/images/cursor-hsplit.png and b/doc/src/images/cursor-hsplit.png differ diff --git a/doc/src/images/cursor-vsplit.png b/doc/src/images/cursor-vsplit.png index a5667e3..1beda25 100644 Binary files a/doc/src/images/cursor-vsplit.png and b/doc/src/images/cursor-vsplit.png differ diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 6fb5f5a..c48a781 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -127,11 +127,11 @@ QT_BEGIN_NAMESPACE \o Qt::SizeAllCursor \o \c size_all \row \o \inlineimage cursor-busy.png \o Qt::BusyCursor \o \c left_ptr_watch - \o \inlineimage cursor-hsplit.png + \o \inlineimage cursor-vsplit.png \o Qt::SplitVCursor \o \c split_v \row \o \inlineimage cursor-forbidden.png \o Qt::ForbiddenCursor \o \c forbidden - \o \inlineimage cursor-vsplit.png + \o \inlineimage cursor-hsplit.png \o Qt::SplitHCursor \o \c split_h \row \o \inlineimage cursor-hand.png \o Qt::PointingHandCursor \o \c pointing_hand -- cgit v0.12 From b2b626a936d778b89f8fbf33ac914d99876ec4b3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 29 Jul 2009 17:59:03 +0200 Subject: Autotest: fix the regressions in the DOM test caused by one whitespace being removed. Reviewed-by: Volker Hilsheimer --- tests/auto/qdom/tst_qdom.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp index ea3b64e..5b4787f 100644 --- a/tests/auto/qdom/tst_qdom.cpp +++ b/tests/auto/qdom/tst_qdom.cpp @@ -1386,7 +1386,7 @@ void tst_QDom::roundTripAttributes() const doc.save(stream, 0); stream.flush(); - const QByteArray expected("\n"); + const QByteArray expected("\n"); QCOMPARE(QString::fromLatin1(serialized.constData()), QString::fromLatin1(expected.constData())); } @@ -1671,7 +1671,7 @@ void tst_QDom::appendDocumentNode() const doc.appendChild(elem); Q_ASSERT(!xml.isNull()); - const QString expected(QLatin1String("\n\n\n")); + const QString expected(QLatin1String("\n\n\n")); elem.appendChild(xml); QCOMPARE(doc.childNodes().count(), 1); @@ -1788,8 +1788,8 @@ void tst_QDom::doubleNamespaceDeclarations() const QXmlInputSource source(&file); QVERIFY(doc.setContent(&source, &reader)); - QVERIFY(doc.toString(0) == QString::fromLatin1("\n\n\n") || - doc.toString(0) == QString::fromLatin1("\n\n\n")); + QVERIFY(doc.toString(0) == QString::fromLatin1("\n\n\n") || + doc.toString(0) == QString::fromLatin1("\n\n\n")); } void tst_QDom::setContentQXmlReaderOverload() const -- cgit v0.12 From f21a36efaab400e086a8c1e87f91da595e4a4443 Mon Sep 17 00:00:00 2001 From: kh Date: Wed, 29 Jul 2009 18:31:36 +0200 Subject: Disable for the time being until we have fixed collection files. --- tests/auto/auto.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index b4a6600..6f10922 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -159,9 +159,9 @@ SUBDIRS += _networkselftest \ qhash \ qheaderview \ qhelpcontentmodel \ - qhelpenginecore \ +# qhelpenginecore \ qhelpgenerator \ - qhelpindexmodel \ +# qhelpindexmodel \ qhelpprojectdata \ qhostaddress \ qhostinfo \ -- cgit v0.12 From 1d3dabe27730a33da35239c39c69b18d4ce9d725 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 29 Jul 2009 19:47:00 +0200 Subject: Fix compilation: #include was missing. Reviewed-by: Trust Me --- src/network/access/qnetworkcookiejar.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/access/qnetworkcookiejar.h b/src/network/access/qnetworkcookiejar.h index b2cdf12..6ff201e 100644 --- a/src/network/access/qnetworkcookiejar.h +++ b/src/network/access/qnetworkcookiejar.h @@ -43,6 +43,7 @@ #define QNETWORKCOOKIEJAR_H #include +#include QT_BEGIN_HEADER -- cgit v0.12 From 529b30b96435491fc6994515862f44d24efc754f Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 29 Jul 2009 20:58:11 +0200 Subject: Doc: The layout documentation is not a list of classes. --- doc/src/designer-manual.qdoc | 2 +- doc/src/groups.qdoc | 2 +- doc/src/layout.qdoc | 3 +-- doc/src/tutorials/addressbook-fr.qdoc | 2 +- doc/src/tutorials/addressbook.qdoc | 4 ++-- src/gui/kernel/qboxlayout.cpp | 6 +++--- src/gui/kernel/qgridlayout.cpp | 2 +- src/gui/kernel/qlayout.cpp | 4 ++-- src/gui/kernel/qwidget.cpp | 6 +++--- 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/doc/src/designer-manual.qdoc b/doc/src/designer-manual.qdoc index c67865d..ab33185 100644 --- a/doc/src/designer-manual.qdoc +++ b/doc/src/designer-manual.qdoc @@ -402,7 +402,7 @@ while setting as few widget size constraints as possible. For a more technical perspective on Qt's layout classes, refer to the - \l{Layout Classes} document. + \l{Layout Management} documentation. */ diff --git a/doc/src/groups.qdoc b/doc/src/groups.qdoc index 2733853..1ec106e 100644 --- a/doc/src/groups.qdoc +++ b/doc/src/groups.qdoc @@ -241,7 +241,7 @@ /*! \group geomanagement - \title Layout Management + \title Layout Classes \ingroup groups \brief Classes handling automatic resizing and moving of widgets, for diff --git a/doc/src/layout.qdoc b/doc/src/layout.qdoc index ec88089..9350aa8 100644 --- a/doc/src/layout.qdoc +++ b/doc/src/layout.qdoc @@ -42,9 +42,8 @@ /*! \page layout.html - \title Layout Classes + \title Layout Management \ingroup architecture - \ingroup classlists \brief A tour of the standard layout managers and an introduction to custom layouts. diff --git a/doc/src/tutorials/addressbook-fr.qdoc b/doc/src/tutorials/addressbook-fr.qdoc index 78f6821..739f047 100644 --- a/doc/src/tutorials/addressbook-fr.qdoc +++ b/doc/src/tutorials/addressbook-fr.qdoc @@ -220,7 +220,7 @@ On remarque que le label \c AddressLabel est positionné en utilisant Qt::AlignTop comme argument optionnel. Ceci est destiné à assurer qu'il ne sera pas centré verticalement dans la cellule (1,0). Pour un aperçu rapide des layouts de Qt, - consultez la section \l{Layout Classes}. + consultez la section \l{Layout Management}. Afin d'installer l'objet layout dans un widget, il faut appeler la méthode \l{QWidget::setLayout()}{setLayout()} du widget en question: diff --git a/doc/src/tutorials/addressbook.qdoc b/doc/src/tutorials/addressbook.qdoc index 95394eb..fd08bfe 100644 --- a/doc/src/tutorials/addressbook.qdoc +++ b/doc/src/tutorials/addressbook.qdoc @@ -222,8 +222,8 @@ Notice that \c addressLabel is positioned using Qt::AlignTop as an additional argument. This is to make sure it is not vertically centered in - cell (1,0). For a basic overview on Qt Layouts, refer to the \l{Layout Classes} - document. + cell (1,0). For a basic overview on Qt Layouts, refer to the + \l{Layout Management} documentation. In order to install the layout object onto the widget, we have to invoke the widget's \l{QWidget::setLayout()}{setLayout()} function: diff --git a/src/gui/kernel/qboxlayout.cpp b/src/gui/kernel/qboxlayout.cpp index 770f5bb..23d20ff 100644 --- a/src/gui/kernel/qboxlayout.cpp +++ b/src/gui/kernel/qboxlayout.cpp @@ -527,7 +527,7 @@ void QBoxLayoutPrivate::calcHfw(int w) You will almost always want to use QVBoxLayout and QHBoxLayout rather than QBoxLayout because of their convenient constructors. - \sa QGridLayout, QStackedLayout, {Layout Classes} + \sa QGridLayout, QStackedLayout, {Layout Management} */ /*! @@ -1295,7 +1295,7 @@ QBoxLayout::Direction QBoxLayout::direction() const \image qhboxlayout-with-5-children.png Horizontal box layout with five child widgets - \sa QVBoxLayout, QGridLayout, QStackedLayout, {Layout Classes}, {Basic Layouts Example} + \sa QVBoxLayout, QGridLayout, QStackedLayout, {Layout Management}, {Basic Layouts Example} */ @@ -1413,7 +1413,7 @@ QHBoxLayout::~QHBoxLayout() \image qvboxlayout-with-5-children.png Horizontal box layout with five child widgets - \sa QHBoxLayout, QGridLayout, QStackedLayout, {Layout Classes}, {Basic Layouts Example} + \sa QHBoxLayout, QGridLayout, QStackedLayout, {Layout Management}, {Basic Layouts Example} */ /*! diff --git a/src/gui/kernel/qgridlayout.cpp b/src/gui/kernel/qgridlayout.cpp index 7ac874e..558f570 100644 --- a/src/gui/kernel/qgridlayout.cpp +++ b/src/gui/kernel/qgridlayout.cpp @@ -1046,7 +1046,7 @@ QRect QGridLayoutPrivate::cellRect(int row, int col) const the margin width for a top-level layout, or to the same as the parent layout. - \sa QBoxLayout, QStackedLayout, {Layout Classes}, {Basic Layouts Example} + \sa QBoxLayout, QStackedLayout, {Layout Management}, {Basic Layouts Example} */ diff --git a/src/gui/kernel/qlayout.cpp b/src/gui/kernel/qlayout.cpp index e750088..941db8f 100644 --- a/src/gui/kernel/qlayout.cpp +++ b/src/gui/kernel/qlayout.cpp @@ -83,7 +83,7 @@ static int menuBarHeightForWidth(QWidget *menubar, int w) For users of QLayout subclasses or of QMainWindow there is seldom any need to use the basic functions provided by QLayout, such as - setSizeConstraint() or setMenuBar(). See \l{Layout Classes} + setSizeConstraint() or setMenuBar(). See \l{Layout Management} for more information. To make your own layout manager, implement the functions @@ -98,7 +98,7 @@ static int menuBarHeightForWidth(QWidget *menubar, int w) Geometry management stops when the layout manager is deleted. - \sa QLayoutItem, {Layout Classes}, {Basic Layouts Example}, + \sa QLayoutItem, {Layout Management}, {Basic Layouts Example}, {Border Layout Example}, {Flow Layout Example} */ diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 7026525..bca607c 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -505,7 +505,7 @@ void QWidget::setAutoFillBackground(bool enabled) been outlined to indicate their full sizes. If you want to use a QWidget to hold child widgets you will usually want to - add a layout to the parent QWidget. See \l{Layout Classes} for more + add a layout to the parent QWidget. See \l{Layout Management} for more information. @@ -8854,7 +8854,7 @@ QRegion QWidget::mask() const The layout manager sets the geometry of the widget's children that have been added to the layout. - \sa setLayout(), sizePolicy(), {Layout Classes} + \sa setLayout(), sizePolicy(), {Layout Management} */ QLayout *QWidget::layout() const { @@ -8884,7 +8884,7 @@ QLayout *QWidget::layout() const The QWidget will take ownership of \a layout. - \sa layout(), {Layout Classes} + \sa layout(), {Layout Management} */ void QWidget::setLayout(QLayout *l) -- cgit v0.12 From b5363896f44a70f04129be359e101e66d03f8609 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 29 Jul 2009 20:58:27 +0200 Subject: Doc: Fix incorrect merge. --- doc/src/platform-notes.qdoc | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/src/platform-notes.qdoc b/doc/src/platform-notes.qdoc index 7c97f65..4738928 100644 --- a/doc/src/platform-notes.qdoc +++ b/doc/src/platform-notes.qdoc @@ -378,9 +378,6 @@ improve support for this feature. */ - \row \o \l{QNX} \o Intel 32-bit, PowerPC \o unsupported/qnx--g++ \o QNX 6.4 GCC - \row \o VxWorks \o Intel 32-bit, PowerPC \o unsupported/vxworks--g++ \o VxWorks 6.7 GCC - /*! \page platform-notes-windows-ce.html \title Platform Notes - Windows CE -- cgit v0.12 From 474675505b24535f8b2779557c9079942b0fa406 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 29 Jul 2009 20:31:07 +0200 Subject: Remove old and obsolete files. --- .../images/mainwindow-docks-example.png | Bin 14427 -> 0 bytes doc/src/tech-preview/images/mainwindow-docks.png | Bin 10168 -> 0 bytes doc/src/tech-preview/images/plaintext-layout.png | Bin 40981 -> 0 bytes doc/src/tech-preview/known-issues.html | 110 --------------------- 4 files changed, 110 deletions(-) delete mode 100644 doc/src/tech-preview/images/mainwindow-docks-example.png delete mode 100644 doc/src/tech-preview/images/mainwindow-docks.png delete mode 100644 doc/src/tech-preview/images/plaintext-layout.png delete mode 100644 doc/src/tech-preview/known-issues.html diff --git a/doc/src/tech-preview/images/mainwindow-docks-example.png b/doc/src/tech-preview/images/mainwindow-docks-example.png deleted file mode 100644 index a5641fd..0000000 Binary files a/doc/src/tech-preview/images/mainwindow-docks-example.png and /dev/null differ diff --git a/doc/src/tech-preview/images/mainwindow-docks.png b/doc/src/tech-preview/images/mainwindow-docks.png deleted file mode 100644 index 96dafc3..0000000 Binary files a/doc/src/tech-preview/images/mainwindow-docks.png and /dev/null differ diff --git a/doc/src/tech-preview/images/plaintext-layout.png b/doc/src/tech-preview/images/plaintext-layout.png deleted file mode 100644 index 9a0f9c1..0000000 Binary files a/doc/src/tech-preview/images/plaintext-layout.png and /dev/null differ diff --git a/doc/src/tech-preview/known-issues.html b/doc/src/tech-preview/known-issues.html deleted file mode 100644 index 885104e..0000000 --- a/doc/src/tech-preview/known-issues.html +++ /dev/null @@ -1,110 +0,0 @@ - - -Known issues - - - - - - - -
      -

      Known Issues: Qt 4.0.0 Technology Preview 1

      -

      - This is the list of known and reported issues for the Qt 4.0.0 - Technology Preview 1. This list is updated daily. -

      -

      - - - - - - - -
      Build Issues
      General
      Demos
      Windows specific
      X11 specific
      Mac specific
      -

      - - -

      Build Issues

      -

      Static libraries on Mac OS X

      -

      Building a static build on mac will fail the first time.

      -

      Run qmake a second time.

      - -

      QTDIR

      -

      Some applications(e.g. uic3) need QTDIR set and QTDIR/bin in the path to work.

      -

      Set QTDIR and PATH as described in INSTALL.

      - -

      ODBC driver on Windows

      -

      Problems compiling the ODBC driver.

      -

      Change the include from qapplication.h to qcoreapplication.h

      - -

      QtGui does not link because of accessibility errors

      -

      undefined reference to QAccessible::setRootObject(QObject*)

      -

      Rerun configure and rebuild, if that does not help, add the contents of $QTDIR/.qt.config to $QTDIR/.qmake.cache

      - - - - -

      General

      - -

      No connection to Oracle

      -

      I cannot connect to my Oracle server

      -

      Use the Oracle >= 9 client libraries, currently there is no workaround for OCI 8

      - -

      QSqlModel

      -

      Only the first 16 rows from a database result are displayed

      -

      You are using a database driver which does not report back the size of a result set and incremental fetching is not yet implemented in the itemviews. You can either use another database like MySQL or increase the QSQL_PREFETCH in qsqlmodel.cpp

      - - - - -

      Demos

      - -

      -

      - - - - -

      Windows specific

      - -

      Qt Assistant

      -

      Problems with zooming and laying out text. Sometimes the text overlaps.

      - -

      GDI handle leak

      -

      Setting fonts through QPainter::setFont() leaks GDI - handles on windows. This is for instance visible in the OpenGL - part of the Arthur demo. The issue will be fixed before the next - preview.

      - - - -

      X11 specific

      - -

      -

      - - - - -

      Mac specific

      - -

      QComboBox

      -

      Does not have the native Mac look and feel yet. It is rendered in a Windows-like style.

      - -

      Clicking on widgets

      -

      Jaguar 10.2 only: Clicking on widgets that has a focusrect may fail.

      -

      Use 10.3 for now.

      - - - - - - -

      qtsoftware.com
      - - -- cgit v0.12 From 067ffcb46ebcf2b9350bfd0f466736c2c44277a9 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 29 Jul 2009 22:46:40 +0200 Subject: Doc: remove obsolete content. --- doc/src/groups.qdoc | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/doc/src/groups.qdoc b/doc/src/groups.qdoc index 1ec106e..2aba09c 100644 --- a/doc/src/groups.qdoc +++ b/doc/src/groups.qdoc @@ -49,12 +49,6 @@ \generatelist{related} - \omit - \row - \o \l{Component Model} - \o Interfaces and helper classes for the Qt Component Model. - \endomit - */ /*! @@ -147,12 +141,6 @@ */ -/* \group componentmodel - \title Component Model - - These classes and interfaces form the basis of the \l{Qt Component Model}. - -*/ /*! \group database -- cgit v0.12 From a5f0c51b3c9156011e8f051729b386e61fdf7851 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 29 Jul 2009 22:42:46 +0200 Subject: Fix compilation and source compatibility. Source code that includes implicitly includes QNetworkCookie in Qt 4.5. Restore this and keep Qt compiling after the split up by including qnetworkcookie.h from qnetworkcookiejar.h Reviewed-by: Trust me --- src/network/access/qnetworkcookiejar.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkcookiejar.h b/src/network/access/qnetworkcookiejar.h index 6ff201e..fae0857 100644 --- a/src/network/access/qnetworkcookiejar.h +++ b/src/network/access/qnetworkcookiejar.h @@ -45,14 +45,15 @@ #include #include +// ### Qt5 remove this include +#include "qnetworkcookie.h" + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Network) -class QNetworkCookie; - class QNetworkCookieJarPrivate; class Q_NETWORK_EXPORT QNetworkCookieJar: public QObject { -- cgit v0.12 From 96eab09cbb7b97ab04dea9fe5515454ef35b3119 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 29 Jul 2009 22:24:50 +0200 Subject: Doc cleanup: Move list-generating pages together into classes.qdoc --- doc/src/annotated.qdoc | 62 -------------------------------------- doc/src/classes.qdoc | 72 ++++++++++++++++++++++++++++++++++++++++++++ doc/src/functions.qdoc | 63 -------------------------------------- doc/src/groups.qdoc | 12 -------- doc/src/hierarchy.qdoc | 52 -------------------------------- doc/src/mainclasses.qdoc | 51 ------------------------------- doc/src/obsoleteclasses.qdoc | 59 ------------------------------------ 7 files changed, 72 insertions(+), 299 deletions(-) delete mode 100644 doc/src/annotated.qdoc delete mode 100644 doc/src/functions.qdoc delete mode 100644 doc/src/hierarchy.qdoc delete mode 100644 doc/src/mainclasses.qdoc delete mode 100644 doc/src/obsoleteclasses.qdoc diff --git a/doc/src/annotated.qdoc b/doc/src/annotated.qdoc deleted file mode 100644 index a817df6..0000000 --- a/doc/src/annotated.qdoc +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/**************************************************************************** -** -** Documentation for class overview. -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt GUI Toolkit. -** EDITIONS: FREE, PROFESSIONAL, ENTERPRISE -** -****************************************************************************/ - -/*! - \page annotated.html - \title Annotated Class Index - \ingroup classlists - - Qt's classes with brief descriptions: - - \generatelist annotatedclasses -*/ diff --git a/doc/src/classes.qdoc b/doc/src/classes.qdoc index 9a5d3ec..4845f84 100644 --- a/doc/src/classes.qdoc +++ b/doc/src/classes.qdoc @@ -40,6 +40,18 @@ ****************************************************************************/ /*! + \group groups + \title Grouped Classes + \ingroup classlists + + This page provides a way of navigating Qt's classes by grouping + related classes together. Some classes may appear in more than one group. + + \generatelist{related} + +*/ + +/*! \page classes.html \title Qt's Classes \ingroup classlists @@ -65,3 +77,63 @@ \generatelist{namespaces} */ + +/*! + \page obsoleteclasses.html + \title Obsolete Classes + \ingroup classlists + + + This is a list of Qt classes that are obsolete (deprecated). These + classes are provided to keep old source code working but they are + no longer maintained. We strongly advise against using these + classes in new code. + + \generatelist obsoleteclasses + + \sa {Qt's Classes}, {Qt's Modules} +*/ + +/*! + \page annotated.html + \title Annotated Class Index + \ingroup classlists + + Qt's classes with brief descriptions: + + \generatelist annotatedclasses +*/ + +/*! + \page functions.html + \title Member Function Index + \ingroup classlists + + Here is the list of all the documented member functions in the Qt + API with links to the class documentation for each function. + + \generatelist functionindex +*/ + +/*! + \page hierarchy.html + + \title Class Inheritance Hierarchy + \ingroup classlists + + This list shows the C++ class inheritance relations between the + classes in the Qt API. + + \generatelist classhierarchy +*/ + +/*! + \page mainclasses.html + \title Qt's Main Classes + \ingroup classlists + + These are the most frequently used Qt classes. For the complete + list see \link classes.html Qt's Classes \endlink. + + \generatelist mainclasses +*/ diff --git a/doc/src/functions.qdoc b/doc/src/functions.qdoc deleted file mode 100644 index e4c8c57..0000000 --- a/doc/src/functions.qdoc +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/**************************************************************************** -** -** Documentation for class overview. -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt GUI Toolkit. -** EDITIONS: FREE, PROFESSIONAL, ENTERPRISE -** -****************************************************************************/ - -/*! - \page functions.html - \title Member Function Index - \ingroup classlists - - Here is the list of all the documented member functions in the Qt - API with links to the class documentation for each function. - - \generatelist functionindex -*/ diff --git a/doc/src/groups.qdoc b/doc/src/groups.qdoc index 2aba09c..731ac58 100644 --- a/doc/src/groups.qdoc +++ b/doc/src/groups.qdoc @@ -40,18 +40,6 @@ ****************************************************************************/ /*! - \group groups - \title Grouped Classes - \ingroup classlists - - This page provides a way of navigating Qt's classes by grouping - related classes together. Some classes may appear in more than one group. - - \generatelist{related} - -*/ - -/*! \group advanced \title Advanced Widgets \ingroup groups diff --git a/doc/src/hierarchy.qdoc b/doc/src/hierarchy.qdoc deleted file mode 100644 index 4a278dc..0000000 --- a/doc/src/hierarchy.qdoc +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page hierarchy.html - - \title Class Inheritance Hierarchy - \ingroup classlists - - This list shows the C++ class inheritance relations between the - classes in the Qt API. - - \generatelist classhierarchy -*/ diff --git a/doc/src/mainclasses.qdoc b/doc/src/mainclasses.qdoc deleted file mode 100644 index 33bb91a..0000000 --- a/doc/src/mainclasses.qdoc +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page mainclasses.html - \title Qt's Main Classes - \ingroup classlists - - These are the most frequently used Qt classes. For the complete - list see \link classes.html Qt's Classes \endlink. - - \generatelist mainclasses -*/ diff --git a/doc/src/obsoleteclasses.qdoc b/doc/src/obsoleteclasses.qdoc deleted file mode 100644 index 3658dfc..0000000 --- a/doc/src/obsoleteclasses.qdoc +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page obsoleteclasses.html - \group obsolete - \title Obsolete Classes - \ingroup classlists - \ingroup groups - - \brief Qt classes that are obsolete (deprecated). - - This is a list of Qt classes that are obsolete (deprecated). These - classes are provided to keep old source code working but they are - no longer maintained. We strongly advise against using these - classes in new code. - - \generatelist obsoleteclasses - - \sa {Qt's Classes}, {Qt's Modules} -*/ -- cgit v0.12 From d18c722a081c6fa2a8bedba563ecaf9763b60faa Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 29 Jul 2009 22:38:38 +0200 Subject: Doc: Move legalese files into a separate directory. --- doc/src/3rdparty.qdoc | 300 -------------------- doc/src/commercialeditions.qdoc | 135 --------- doc/src/editions.qdoc | 76 ------ doc/src/gpl.qdoc | 84 ------ doc/src/legal/3rdparty.qdoc | 300 ++++++++++++++++++++ doc/src/legal/commercialeditions.qdoc | 135 +++++++++ doc/src/legal/editions.qdoc | 76 ++++++ doc/src/legal/gpl.qdoc | 84 ++++++ doc/src/legal/licenses.qdoc | 496 ++++++++++++++++++++++++++++++++++ doc/src/legal/opensourceedition.qdoc | 91 +++++++ doc/src/legal/trademarks.qdoc | 75 +++++ doc/src/licenses.qdoc | 483 --------------------------------- doc/src/opensourceedition.qdoc | 91 ------- doc/src/topics.qdoc | 12 - doc/src/trademarks.qdoc | 75 ----- 15 files changed, 1257 insertions(+), 1256 deletions(-) delete mode 100644 doc/src/3rdparty.qdoc delete mode 100644 doc/src/commercialeditions.qdoc delete mode 100644 doc/src/editions.qdoc delete mode 100644 doc/src/gpl.qdoc create mode 100644 doc/src/legal/3rdparty.qdoc create mode 100644 doc/src/legal/commercialeditions.qdoc create mode 100644 doc/src/legal/editions.qdoc create mode 100644 doc/src/legal/gpl.qdoc create mode 100644 doc/src/legal/licenses.qdoc create mode 100644 doc/src/legal/opensourceedition.qdoc create mode 100644 doc/src/legal/trademarks.qdoc delete mode 100644 doc/src/licenses.qdoc delete mode 100644 doc/src/opensourceedition.qdoc delete mode 100644 doc/src/trademarks.qdoc diff --git a/doc/src/3rdparty.qdoc b/doc/src/3rdparty.qdoc deleted file mode 100644 index 0d86ab3..0000000 --- a/doc/src/3rdparty.qdoc +++ /dev/null @@ -1,300 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page 3rdparty.html - - \title Third-Party Licenses Used in Qt - \ingroup licensing - \brief License information for third-party libraries supplied with Qt. - - Qt includes a number of third-party libraries that are used to provide - certain features. Unlike the code described in the - \l{Other Licenses Used in Qt}{code used in Qt} document, these - libraries are supplied alongside the Qt modules. - - Third Party Software may impose additional restrictions and it is the - user's responsibility to ensure that they have met the licensing - requirements of the GPL, LGPL, or Qt Commercial license and the relevant - license of the Third Party Software they are using. - - Run \c{configure -help} to see any options that may be available for - controlling the use of these libraries. - - \tableofcontents - - \section1 DES (\c des.cpp) - - \e{Implementation of DES encryption for NTLM\br - Copyright 1997-2005 Simon Tatham.\br - This software is released under the MIT license.} - - See \c src/3rdparty/des/des.cpp for more information about the terms and - conditions under which the code is supplied. - - \section1 FreeType 2 (\c freetype) version 2.3.6 - - \e{The FreeType project is a team of volunteers who develop free, portable - and high-quality software solutions for digital typography. We specifically - target embedded systems and focus on bringing small, efficient and - ubiquitous products.} -- quoted from \c 3rdparty/freetype/docs/freetype2.html. - - See \c src/3rdparty/freetype/docs/FTL.txt and \c - src/3rdparty/freetype/docs/GPL.txt for license details. - - See also the files in \c src/3rdparty/harfbuzz, which are used by - FreeType. - - Parts of the FreeType projects have been modified and put into Qt - for use in the painting subsystem. These files are ftraster.h, - ftraster.c, ftgrays.h and ftgrays.c. The following modifications - has been made to these files: - - \list - \i Renamed FT_ and ft_ symbols to QT_FT_ and qt_ft_ to avoid name - conflicts. - \i Removed parts of code not relevant when compiled with - _STANDALONE_ defined. - \i Changed behavior in ftraster.c to follow X polygon filling - rules. - \i Implemented support in ftraster.c for winding / odd even - polygon fill rules. - \i Replaced bitmap generation with span generation in ftraster.c - \i Renamed: ftraster.h to qblackraster_p.h - \i Renamed: ftraster.c to qblackraster.c - \i Renamed: ftgrays.h to qgrayraster_p.h - \i Renamed: ftgrays.c to qgrayraster.c - \endlist - - \section1 HarfBuzz (\c harfbuzz) - - \e{This is HarfBuzz, an OpenType Layout engine.} - - \e{It was derived originally from the OpenType code in FreeType-1.x, ported to - FreeType2. (This code has been abandoned for FreeType2, but until something - better comes along, should serve our purposes.) In addition to porting to - FreeType-2, it has been modified in various other ways.} -- quoted from - \c src/3rdparty/harfbuzz/README. - - See \c src/3rdparty/harfbuzz/COPYING.FTL and src/3rdparty/harfbuzz/COPYING.GPL - for license details. - - \section1 The Independent JPEG Group's JPEG Software (\c libjpeg) version 6b - - \e{This package contains C software to implement JPEG image compression and - decompression. JPEG (pronounced "jay-peg") is a standardized compression - method for full-color and gray-scale images. JPEG is intended for compressing - "real-world" scenes; line drawings, cartoons and other non-realistic images - are not its strong suit. JPEG is lossy, meaning that the output image is not - exactly identical to the input image.} -- quoted from \c - src/3rdparty/libjpeg/README. - - See \c src/3rdparty/libjpeg/README for license details. - - \section1 MD4 (\c md4.cpp and \c md4.h) - - \e{MD4 (RFC-1320) message digest.\br - Modified from MD5 code by Andrey Panin \br\br - Written by Solar Designer in 2001, and placed in\br - the public domain. There's absolutely no warranty.} - - See \c src/3rdparty/md4/md4.cpp and \c src/3rdparty/md4/md4.h for more - information about the terms and conditions under which the code is - supplied. - - \section1 MD5 (\c md5.cpp and \c md5.h) - - \e{This code implements the MD5 message-digest algorithm. - The algorithm is due to Ron Rivest. This code was - written by Colin Plumb in 1993, no copyright is claimed. - This code is in the public domain; do with it what you wish.} -- quoted from - \c src/3rdparty/md5/md5.h - - See \c src/3rdparty/md5/md5.cpp and \c src/3rdparty/md5/md5.h for more - information about the terms and conditions under which the code is - supplied. - - \section1 MNG Library (\c libmng) version 1.0.10 - - \e{The libmng library supports decoding, displaying, encoding, and various - other manipulations of the Multiple-image Network Graphics (MNG) format - image files. It uses the zlib compression library, and optionally the - JPEG library by the Independant JPEG Group (IJG) and/or - lcms (little cms), a color-management library by Marti Maria Saguer.} - -- quoted from \c src/3rdparty/libmng/doc/libmng.txt - - See \c src/3rdparty/libmng/LICENSE for license details. - - \section1 PNG Reference Library (\c libpng) version 1.2.29 - - \e{Libpng was written as a companion to the PNG specification, as a way - of reducing the amount of time and effort it takes to support the PNG - file format in application programs.} -- quoted from \c - src/3rdparty/libpng/libpng.txt. - - See \c src/3rdparty/libpng/LICENSE for license details. - - \section1 The ptmalloc memory allocator (\c ptmalloc3) version 1.8 - - \e ptmcalloc3 is a scalable concurrent memory allocator suitable - for use in multi-threaded programs. - - \hr - - Copyright (c) 2001-2006 Wolfram Gloger - - Permission to use, copy, modify, distribute, and sell this software - and its documentation for any purpose is hereby granted without fee, - provided that (i) the above copyright notices and this permission - notice appear in all copies of the software and related documentation, - and (ii) the name of Wolfram Gloger may not be used in any advertising - or publicity relating to the software. - - THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - - IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, - INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY - DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY - OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - - \hr - - See \c src/3rdparty/ptmalloc/COPYRIGHT for license details. - - \section1 SHA-1 (\c sha1.cpp) - - \e{Based on the public domain implementation of the SHA-1 algorithm\br - Copyright (C) Dominik Reichl } - - See \c src/3rdparty/sha1/sha1.cpp for more information about the terms and - conditions under which the code is supplied. - - \section1 SQLite (\c sqlite) version 3.5.9 - - \e{SQLite is a small C library that implements a - self-contained, embeddable, zero-configuration SQL database engine.} - -- quoted from \l{http://www.sqlite.org/}{www.sqlite.org}. - - According to the comments in the source files, the code is in the public - domain. See the - \l{http://www.sqlite.org/copyright.html}{SQLite Copyright} page on the - SQLite web site for further information. - - \section1 TIFF Software Distribution (\c libtiff) version 3.8.2 - - \e {libtiff is a set of C functions (a library) that support the - manipulation of TIFF image files.} -- quoted from \c - src/libtiff/html/libtiff.html - - \hr - - Copyright (c) 1988-1997 Sam Leffler\br - Copyright (c) 1991-1997 Silicon Graphics, Inc.\br - Copyright (C) 2004, Andrey Kiselev \br - Copyright (c) 1997 Greg Ward Larson - - Permission to use, copy, modify, distribute, and sell this software and - its documentation for any purpose is hereby granted without fee, provided - that (i) the above copyright notices and this permission notice appear in - all copies of the software and related documentation, and (ii) the names of - Sam Leffler and Silicon Graphics may not be used in any advertising or - publicity relating to the software without the specific, prior written - permission of Sam Leffler and Silicon Graphics. - - THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - - IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - OF THIS SOFTWARE. - - \hr - - Copyright (c) 1996-1997 Sam Leffler\br - Copyright (c) 1996 Pixar - - Permission to use, copy, modify, distribute, and sell this software and - its documentation for any purpose is hereby granted without fee, provided - that (i) the above copyright notices and this permission notice appear in - all copies of the software and related documentation, and (ii) the names of - Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or - publicity relating to the software without the specific, prior written - permission of Pixar, Sam Leffler and Silicon Graphics. - - THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - - IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - OF THIS SOFTWARE. - - \hr - - See \c src/3rdparty/libtiff/COPYRIGHT for license details. - - \section1 Wintab API (\c wintab) - - Wintab is a de facto API for pointing devices on Windows. The - wintab code is from \l{http://www.pointing.com/WINTAB.HTM}. - - See \c src/3rdparty/wintab/wintab.h for license details. - - \section1 Data Compression Library (\c zlib) version 1.2.3 - - \e{zlib is a general purpose data compression library. All the code - is thread safe. The data format used by the zlib library is described - by RFCs (Request for Comments) 1950 to 1952} -- quoted from \c - src/3rdparty/zlib/README. - - See \c src/3rdparty/zlib/README for license details. -*/ diff --git a/doc/src/commercialeditions.qdoc b/doc/src/commercialeditions.qdoc deleted file mode 100644 index b6d80c2..0000000 --- a/doc/src/commercialeditions.qdoc +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page commercialeditions.html - \title Qt Commercial Editions - \ingroup licensing - \brief Information about the license and features of the Commercial Edition. - - \keyword Qt Full Framework Edition - \keyword Qt GUI Framework Edition - - Two editions of Qt are available under a commercial license: - Qt GUI Framework Edition, and Qt Full Framework Edition. - - If you want to develop Free or Open Source software for release using a recognized - Open Source license, you can use the \l{Open Source Versions of Qt}. - - The table below summarizes the differences between the three - commercial editions: - - \table 75% - \header \o{1,2} Features \o{2,1} Editions - \header \o Qt GUI Framework \o Qt Full Framework - \row \o \l{QtCore}{Qt Core classes (QtCore)} \o \bold{X} \o \bold{X} - \row \o \l{QtGui}{Qt GUI classes (QtGui)} \o \bold{(X)} \o \bold{X} - \row \o \l{Graphics View Classes} (part of QtGui) \o \o \bold{X} - \row \o \l{QtNetwork}{Networking (QtNetwork)} \o \o \bold{X} - \row \o \l{QtOpenGL}{OpenGL (QtOpenGL)} \o \o \bold{X} - \row \o \l{QtScript}{Scripting (QtScript)} \o \o \bold{X} - \row \o \l{QtScriptTools}{Script Debugging (QtScriptTools)}\o \o \bold{X} - \row \o \l{QtSql}{Database/SQL (QtSql)} \o \o \bold{X} - \row \o \l{QtSvg}{SVG (QtSvg)} \o \o \bold{X} - \row \o \l{QtWebKit}{WebKit integration (QtWebKit)} \o \o \bold{X} - \row \o \l{QtXml}{XML (QtXml)} \o \o \bold{X} - \row \o \l{QtXmlPatterns}{XQuery and XPath (QtXmlPatterns)}\o \o \bold{X} - \row \o \l{Qt3Support}{Qt 3 Support (Qt3Support)} \o \bold{(X)} \o \bold{X} - \row \o \l{QtHelp}{Help system (QtHelp)} \o \o \bold{X} - \row \o \l{QtDBus}{D-Bus IPC support (QtDBus)} \o \bold{X} \o \bold{X} - \row \o \l{QtDesigner}{\QD extension classes (QtDesigner)} \o \o \bold{X} - \row \o \l{QtTest}{Unit testing framework (QtTest)} \o \bold{X} \o \bold{X} - \row \o \l{QtUiTools}{Run-time form handling (QtUiTools)} \o \o \bold{X} - \row \o \l{Phonon Module}{Phonon Multimedia Framework} \o \o \bold{X} - \row \o \l{ActiveQt} \o \o \bold{} - \endtable - - \bold{(X)} The Qt GUI Framework Edition contains selected classes from the QtGui and - Qt3Support modules corresponding to the functionality available in the Qt 3 Professional - Edition. - - \bold{} The ActiveQt module is only available on Windows. - - Lists of the classes available in each edition are available on the - following pages: - - \list - \o \l{Qt GUI Framework Edition Classes} - \o \l{Qt Full Framework Edition Classes} - \endlist - - Please see the \l{Supported Platforms}{list of supported - platforms} for up-to-date information about the various platforms - and compilers that Qt supports. - - On the Qt web site, you can find a - \l{Qt Licensing Overview} and information on \l{Qt License Pricing} - for commercial editions of Qt and other Qt-related products. - - To purchase, please visit the \l{How to Order}{online order - form}. - - For further information and assistance, please contact Qt - sales. - - Web: http://www.qtsoftware.com/contact. - - Phone, U.S. office (for North America): \bold{1-650-813-1676}. - - Phone, Norway office (for the rest of the world): \bold{+47 21 60 - 48 00}. -*/ - -/*! - \page full-framework-edition-classes.html - \title Qt Full Framework Edition Classes - \ingroup classlists - - \generatelist{classesbyedition Desktop} -*/ - -/*! - \page gui-framework-edition-classes.html - \title Qt GUI Framework Edition Classes - \ingroup classlists - - \generatelist{classesbyedition DesktopLight} -*/ diff --git a/doc/src/editions.qdoc b/doc/src/editions.qdoc deleted file mode 100644 index 9ed4c9c..0000000 --- a/doc/src/editions.qdoc +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/**************************************************************************** -** -** Documentation of Qt editions. -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt GUI Toolkit. -** EDITIONS: FREE, PROFESSIONAL, ENTERPRISE -** -****************************************************************************/ - -/*! - \page editions.html - \title Qt Editions - \ingroup licensing - \brief Information about the different editions of Qt. - - Qt can be used to create both commercial and non-commercial - software for a wide range of different deployment environments, - and is supplied in a number of different forms to suit the needs - of different kinds of developers. - - In terms of license conditions, there are two main forms of Qt: - - \list - \o The \l{Qt Commercial Editions} are the commercial - versions of \l{About Qt}{Qt}. - \o The \l{Open Source Versions of Qt} are freely available for download. - \endlist - - On the Qt web site, you can find a - \l{Qt Licensing Overview} and information on \l{Qt License Pricing} - for commercial editions of Qt and other Qt-related products. -*/ diff --git a/doc/src/gpl.qdoc b/doc/src/gpl.qdoc deleted file mode 100644 index 97959e8..0000000 --- a/doc/src/gpl.qdoc +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! \page gpl.html -\title GNU General Public License (GPL) -\ingroup licensing -\brief About the GPL license used for Qt. - -The Qt GUI Toolkit is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\br -Contact: Nokia Corporation (qt-info@nokia.com) - -Qt is available under the GPL. - -\section1 The GNU General Public License (Version 3) - -Reference: \l{GNU General Public License} - -\snippet doc/src/snippets/code/doc_src_gpl.qdoc GPL v3 -*/ - -/*! \page lgpl.html -\title GNU Lesser General Public License (LGPL) -\ingroup licensing -\brief About the LGPL license used for Qt. - -The Qt GUI Toolkit is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\br -Contact: Nokia Corporation (qt-info@nokia.com) - -Qt is available under the LGPL. - -\section1 The GNU Lesser General Public License (Version 2.1) - -Reference: \l{GNU Lesser General Public License, version 2.1} - -\snippet doc/src/snippets/code/doc_src_lgpl.qdoc LGPL v2.1 - -\section1 Nokia Qt LGPL Exception version 1.0 - -As a special exception to the GNU Lesser General Public License version 2.1, -the object code form of a "work that uses the Library" may incorporate material -from a header file that is part of the Library. You may distribute such object -code under terms of your choice, provided that the incorporated material -(i) does not exceed more than 5% of the total size of the Library; and -(ii) is limited to numerical parameters, data structure layouts, accessors, -macros, inline functions and templates. -*/ diff --git a/doc/src/legal/3rdparty.qdoc b/doc/src/legal/3rdparty.qdoc new file mode 100644 index 0000000..0d86ab3 --- /dev/null +++ b/doc/src/legal/3rdparty.qdoc @@ -0,0 +1,300 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page 3rdparty.html + + \title Third-Party Licenses Used in Qt + \ingroup licensing + \brief License information for third-party libraries supplied with Qt. + + Qt includes a number of third-party libraries that are used to provide + certain features. Unlike the code described in the + \l{Other Licenses Used in Qt}{code used in Qt} document, these + libraries are supplied alongside the Qt modules. + + Third Party Software may impose additional restrictions and it is the + user's responsibility to ensure that they have met the licensing + requirements of the GPL, LGPL, or Qt Commercial license and the relevant + license of the Third Party Software they are using. + + Run \c{configure -help} to see any options that may be available for + controlling the use of these libraries. + + \tableofcontents + + \section1 DES (\c des.cpp) + + \e{Implementation of DES encryption for NTLM\br + Copyright 1997-2005 Simon Tatham.\br + This software is released under the MIT license.} + + See \c src/3rdparty/des/des.cpp for more information about the terms and + conditions under which the code is supplied. + + \section1 FreeType 2 (\c freetype) version 2.3.6 + + \e{The FreeType project is a team of volunteers who develop free, portable + and high-quality software solutions for digital typography. We specifically + target embedded systems and focus on bringing small, efficient and + ubiquitous products.} -- quoted from \c 3rdparty/freetype/docs/freetype2.html. + + See \c src/3rdparty/freetype/docs/FTL.txt and \c + src/3rdparty/freetype/docs/GPL.txt for license details. + + See also the files in \c src/3rdparty/harfbuzz, which are used by + FreeType. + + Parts of the FreeType projects have been modified and put into Qt + for use in the painting subsystem. These files are ftraster.h, + ftraster.c, ftgrays.h and ftgrays.c. The following modifications + has been made to these files: + + \list + \i Renamed FT_ and ft_ symbols to QT_FT_ and qt_ft_ to avoid name + conflicts. + \i Removed parts of code not relevant when compiled with + _STANDALONE_ defined. + \i Changed behavior in ftraster.c to follow X polygon filling + rules. + \i Implemented support in ftraster.c for winding / odd even + polygon fill rules. + \i Replaced bitmap generation with span generation in ftraster.c + \i Renamed: ftraster.h to qblackraster_p.h + \i Renamed: ftraster.c to qblackraster.c + \i Renamed: ftgrays.h to qgrayraster_p.h + \i Renamed: ftgrays.c to qgrayraster.c + \endlist + + \section1 HarfBuzz (\c harfbuzz) + + \e{This is HarfBuzz, an OpenType Layout engine.} + + \e{It was derived originally from the OpenType code in FreeType-1.x, ported to + FreeType2. (This code has been abandoned for FreeType2, but until something + better comes along, should serve our purposes.) In addition to porting to + FreeType-2, it has been modified in various other ways.} -- quoted from + \c src/3rdparty/harfbuzz/README. + + See \c src/3rdparty/harfbuzz/COPYING.FTL and src/3rdparty/harfbuzz/COPYING.GPL + for license details. + + \section1 The Independent JPEG Group's JPEG Software (\c libjpeg) version 6b + + \e{This package contains C software to implement JPEG image compression and + decompression. JPEG (pronounced "jay-peg") is a standardized compression + method for full-color and gray-scale images. JPEG is intended for compressing + "real-world" scenes; line drawings, cartoons and other non-realistic images + are not its strong suit. JPEG is lossy, meaning that the output image is not + exactly identical to the input image.} -- quoted from \c + src/3rdparty/libjpeg/README. + + See \c src/3rdparty/libjpeg/README for license details. + + \section1 MD4 (\c md4.cpp and \c md4.h) + + \e{MD4 (RFC-1320) message digest.\br + Modified from MD5 code by Andrey Panin \br\br + Written by Solar Designer in 2001, and placed in\br + the public domain. There's absolutely no warranty.} + + See \c src/3rdparty/md4/md4.cpp and \c src/3rdparty/md4/md4.h for more + information about the terms and conditions under which the code is + supplied. + + \section1 MD5 (\c md5.cpp and \c md5.h) + + \e{This code implements the MD5 message-digest algorithm. + The algorithm is due to Ron Rivest. This code was + written by Colin Plumb in 1993, no copyright is claimed. + This code is in the public domain; do with it what you wish.} -- quoted from + \c src/3rdparty/md5/md5.h + + See \c src/3rdparty/md5/md5.cpp and \c src/3rdparty/md5/md5.h for more + information about the terms and conditions under which the code is + supplied. + + \section1 MNG Library (\c libmng) version 1.0.10 + + \e{The libmng library supports decoding, displaying, encoding, and various + other manipulations of the Multiple-image Network Graphics (MNG) format + image files. It uses the zlib compression library, and optionally the + JPEG library by the Independant JPEG Group (IJG) and/or + lcms (little cms), a color-management library by Marti Maria Saguer.} + -- quoted from \c src/3rdparty/libmng/doc/libmng.txt + + See \c src/3rdparty/libmng/LICENSE for license details. + + \section1 PNG Reference Library (\c libpng) version 1.2.29 + + \e{Libpng was written as a companion to the PNG specification, as a way + of reducing the amount of time and effort it takes to support the PNG + file format in application programs.} -- quoted from \c + src/3rdparty/libpng/libpng.txt. + + See \c src/3rdparty/libpng/LICENSE for license details. + + \section1 The ptmalloc memory allocator (\c ptmalloc3) version 1.8 + + \e ptmcalloc3 is a scalable concurrent memory allocator suitable + for use in multi-threaded programs. + + \hr + + Copyright (c) 2001-2006 Wolfram Gloger + + Permission to use, copy, modify, distribute, and sell this software + and its documentation for any purpose is hereby granted without fee, + provided that (i) the above copyright notices and this permission + notice appear in all copies of the software and related documentation, + and (ii) the name of Wolfram Gloger may not be used in any advertising + or publicity relating to the software. + + THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + + IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, + INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY + DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY + OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + + \hr + + See \c src/3rdparty/ptmalloc/COPYRIGHT for license details. + + \section1 SHA-1 (\c sha1.cpp) + + \e{Based on the public domain implementation of the SHA-1 algorithm\br + Copyright (C) Dominik Reichl } + + See \c src/3rdparty/sha1/sha1.cpp for more information about the terms and + conditions under which the code is supplied. + + \section1 SQLite (\c sqlite) version 3.5.9 + + \e{SQLite is a small C library that implements a + self-contained, embeddable, zero-configuration SQL database engine.} + -- quoted from \l{http://www.sqlite.org/}{www.sqlite.org}. + + According to the comments in the source files, the code is in the public + domain. See the + \l{http://www.sqlite.org/copyright.html}{SQLite Copyright} page on the + SQLite web site for further information. + + \section1 TIFF Software Distribution (\c libtiff) version 3.8.2 + + \e {libtiff is a set of C functions (a library) that support the + manipulation of TIFF image files.} -- quoted from \c + src/libtiff/html/libtiff.html + + \hr + + Copyright (c) 1988-1997 Sam Leffler\br + Copyright (c) 1991-1997 Silicon Graphics, Inc.\br + Copyright (C) 2004, Andrey Kiselev \br + Copyright (c) 1997 Greg Ward Larson + + Permission to use, copy, modify, distribute, and sell this software and + its documentation for any purpose is hereby granted without fee, provided + that (i) the above copyright notices and this permission notice appear in + all copies of the software and related documentation, and (ii) the names of + Sam Leffler and Silicon Graphics may not be used in any advertising or + publicity relating to the software without the specific, prior written + permission of Sam Leffler and Silicon Graphics. + + THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + + IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + OF THIS SOFTWARE. + + \hr + + Copyright (c) 1996-1997 Sam Leffler\br + Copyright (c) 1996 Pixar + + Permission to use, copy, modify, distribute, and sell this software and + its documentation for any purpose is hereby granted without fee, provided + that (i) the above copyright notices and this permission notice appear in + all copies of the software and related documentation, and (ii) the names of + Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or + publicity relating to the software without the specific, prior written + permission of Pixar, Sam Leffler and Silicon Graphics. + + THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + + IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + OF THIS SOFTWARE. + + \hr + + See \c src/3rdparty/libtiff/COPYRIGHT for license details. + + \section1 Wintab API (\c wintab) + + Wintab is a de facto API for pointing devices on Windows. The + wintab code is from \l{http://www.pointing.com/WINTAB.HTM}. + + See \c src/3rdparty/wintab/wintab.h for license details. + + \section1 Data Compression Library (\c zlib) version 1.2.3 + + \e{zlib is a general purpose data compression library. All the code + is thread safe. The data format used by the zlib library is described + by RFCs (Request for Comments) 1950 to 1952} -- quoted from \c + src/3rdparty/zlib/README. + + See \c src/3rdparty/zlib/README for license details. +*/ diff --git a/doc/src/legal/commercialeditions.qdoc b/doc/src/legal/commercialeditions.qdoc new file mode 100644 index 0000000..b6d80c2 --- /dev/null +++ b/doc/src/legal/commercialeditions.qdoc @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page commercialeditions.html + \title Qt Commercial Editions + \ingroup licensing + \brief Information about the license and features of the Commercial Edition. + + \keyword Qt Full Framework Edition + \keyword Qt GUI Framework Edition + + Two editions of Qt are available under a commercial license: + Qt GUI Framework Edition, and Qt Full Framework Edition. + + If you want to develop Free or Open Source software for release using a recognized + Open Source license, you can use the \l{Open Source Versions of Qt}. + + The table below summarizes the differences between the three + commercial editions: + + \table 75% + \header \o{1,2} Features \o{2,1} Editions + \header \o Qt GUI Framework \o Qt Full Framework + \row \o \l{QtCore}{Qt Core classes (QtCore)} \o \bold{X} \o \bold{X} + \row \o \l{QtGui}{Qt GUI classes (QtGui)} \o \bold{(X)} \o \bold{X} + \row \o \l{Graphics View Classes} (part of QtGui) \o \o \bold{X} + \row \o \l{QtNetwork}{Networking (QtNetwork)} \o \o \bold{X} + \row \o \l{QtOpenGL}{OpenGL (QtOpenGL)} \o \o \bold{X} + \row \o \l{QtScript}{Scripting (QtScript)} \o \o \bold{X} + \row \o \l{QtScriptTools}{Script Debugging (QtScriptTools)}\o \o \bold{X} + \row \o \l{QtSql}{Database/SQL (QtSql)} \o \o \bold{X} + \row \o \l{QtSvg}{SVG (QtSvg)} \o \o \bold{X} + \row \o \l{QtWebKit}{WebKit integration (QtWebKit)} \o \o \bold{X} + \row \o \l{QtXml}{XML (QtXml)} \o \o \bold{X} + \row \o \l{QtXmlPatterns}{XQuery and XPath (QtXmlPatterns)}\o \o \bold{X} + \row \o \l{Qt3Support}{Qt 3 Support (Qt3Support)} \o \bold{(X)} \o \bold{X} + \row \o \l{QtHelp}{Help system (QtHelp)} \o \o \bold{X} + \row \o \l{QtDBus}{D-Bus IPC support (QtDBus)} \o \bold{X} \o \bold{X} + \row \o \l{QtDesigner}{\QD extension classes (QtDesigner)} \o \o \bold{X} + \row \o \l{QtTest}{Unit testing framework (QtTest)} \o \bold{X} \o \bold{X} + \row \o \l{QtUiTools}{Run-time form handling (QtUiTools)} \o \o \bold{X} + \row \o \l{Phonon Module}{Phonon Multimedia Framework} \o \o \bold{X} + \row \o \l{ActiveQt} \o \o \bold{} + \endtable + + \bold{(X)} The Qt GUI Framework Edition contains selected classes from the QtGui and + Qt3Support modules corresponding to the functionality available in the Qt 3 Professional + Edition. + + \bold{} The ActiveQt module is only available on Windows. + + Lists of the classes available in each edition are available on the + following pages: + + \list + \o \l{Qt GUI Framework Edition Classes} + \o \l{Qt Full Framework Edition Classes} + \endlist + + Please see the \l{Supported Platforms}{list of supported + platforms} for up-to-date information about the various platforms + and compilers that Qt supports. + + On the Qt web site, you can find a + \l{Qt Licensing Overview} and information on \l{Qt License Pricing} + for commercial editions of Qt and other Qt-related products. + + To purchase, please visit the \l{How to Order}{online order + form}. + + For further information and assistance, please contact Qt + sales. + + Web: http://www.qtsoftware.com/contact. + + Phone, U.S. office (for North America): \bold{1-650-813-1676}. + + Phone, Norway office (for the rest of the world): \bold{+47 21 60 + 48 00}. +*/ + +/*! + \page full-framework-edition-classes.html + \title Qt Full Framework Edition Classes + \ingroup classlists + + \generatelist{classesbyedition Desktop} +*/ + +/*! + \page gui-framework-edition-classes.html + \title Qt GUI Framework Edition Classes + \ingroup classlists + + \generatelist{classesbyedition DesktopLight} +*/ diff --git a/doc/src/legal/editions.qdoc b/doc/src/legal/editions.qdoc new file mode 100644 index 0000000..9ed4c9c --- /dev/null +++ b/doc/src/legal/editions.qdoc @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/**************************************************************************** +** +** Documentation of Qt editions. +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt GUI Toolkit. +** EDITIONS: FREE, PROFESSIONAL, ENTERPRISE +** +****************************************************************************/ + +/*! + \page editions.html + \title Qt Editions + \ingroup licensing + \brief Information about the different editions of Qt. + + Qt can be used to create both commercial and non-commercial + software for a wide range of different deployment environments, + and is supplied in a number of different forms to suit the needs + of different kinds of developers. + + In terms of license conditions, there are two main forms of Qt: + + \list + \o The \l{Qt Commercial Editions} are the commercial + versions of \l{About Qt}{Qt}. + \o The \l{Open Source Versions of Qt} are freely available for download. + \endlist + + On the Qt web site, you can find a + \l{Qt Licensing Overview} and information on \l{Qt License Pricing} + for commercial editions of Qt and other Qt-related products. +*/ diff --git a/doc/src/legal/gpl.qdoc b/doc/src/legal/gpl.qdoc new file mode 100644 index 0000000..97959e8 --- /dev/null +++ b/doc/src/legal/gpl.qdoc @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! \page gpl.html +\title GNU General Public License (GPL) +\ingroup licensing +\brief About the GPL license used for Qt. + +The Qt GUI Toolkit is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\br +Contact: Nokia Corporation (qt-info@nokia.com) + +Qt is available under the GPL. + +\section1 The GNU General Public License (Version 3) + +Reference: \l{GNU General Public License} + +\snippet doc/src/snippets/code/doc_src_gpl.qdoc GPL v3 +*/ + +/*! \page lgpl.html +\title GNU Lesser General Public License (LGPL) +\ingroup licensing +\brief About the LGPL license used for Qt. + +The Qt GUI Toolkit is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\br +Contact: Nokia Corporation (qt-info@nokia.com) + +Qt is available under the LGPL. + +\section1 The GNU Lesser General Public License (Version 2.1) + +Reference: \l{GNU Lesser General Public License, version 2.1} + +\snippet doc/src/snippets/code/doc_src_lgpl.qdoc LGPL v2.1 + +\section1 Nokia Qt LGPL Exception version 1.0 + +As a special exception to the GNU Lesser General Public License version 2.1, +the object code form of a "work that uses the Library" may incorporate material +from a header file that is part of the Library. You may distribute such object +code under terms of your choice, provided that the incorporated material +(i) does not exceed more than 5% of the total size of the Library; and +(ii) is limited to numerical parameters, data structure layouts, accessors, +macros, inline functions and templates. +*/ diff --git a/doc/src/legal/licenses.qdoc b/doc/src/legal/licenses.qdoc new file mode 100644 index 0000000..4689114 --- /dev/null +++ b/doc/src/legal/licenses.qdoc @@ -0,0 +1,496 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \group licensing + \title Licensing Information + \ingroup topics + \brief Information about licenses and licensing issues. + + These documents include information about Qt's licenses and the licenses + of third party components used in Qt. + + \generatelist{related} +*/ + + +/*! + \page licenses.html + \title Other Licenses Used in Qt + \ingroup licensing + \brief Information about other licenses used for Qt components and third-party code. + + Qt contains some code that is not provided under the + \l{GNU General Public License (GPL)}, + \l{GNU Lesser General Public License (LGPL)} or the + \l{Qt Commercial Editions}{Qt Commercial License Agreement}, but rather under + specific licenses from the original authors. Some pieces of code were developed + by Nokia and others originated from third parties. + This page lists the licenses used, names the authors, and links + to the places where it is used. + + Nokia gratefully acknowledges these and other contributions + to Qt. We recommend that programs that use Qt also acknowledge + these contributions, and quote these license statements in an + appendix to the documentation. + + See also: \l{Licenses for Fonts Used in Qt for Embedded Linux} + + \generatelist legalese + + \hr + + Copyright (C) 2000-2004, International Business Machines\br + Corporation and others. All Rights Reserved.\br + Copyright (C) 2007 Apple Inc. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, and/or sell copies of the Software, and to permit persons + to whom the Software is furnished to do so, provided that the above copyright notice(s) + and this permission notice appear in all copies of the Software and that both the above + copyright notice(s) and this permission notice appear in supporting documentation. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER + OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + Except as contained in this notice, the name of a copyright holder shall not be used in + advertising or otherwise to promote the sale, use or other dealings in this Software + without prior written authorization of the copyright holder. + + \list + \o Parts of WebKit used by the QtWebKit module + \endlist + + \hr + + Copyright (c) 1998 by Bjorn Reese + + Permission to use, copy, modify, and distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND + CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. + + \list + \o Parts of the QCrashHandler class + \endlist + + \hr + + Parts of the FreeType projects have been modified and put into Qt + for use in the painting subsystem. These files are ftraster.h, + ftraster.c, ftgrays.h and ftgrays.c. The following modifications + has been made to these files: + + \list + \i Renamed FT_ and ft_ symbols to QT_FT_ and qt_ft_ to avoid name + conflicts in \c{qrasterdefs_p.h}. + \i Removed parts of code not relevant when compiled with + _STANDALONE_ defined. + \i Changed behavior in \c{ftraster.c} to follow X polygon filling + rules. + \i Implemented support in \c{ftraster.c} for winding / odd even + polygon fill rules. + \i Replaced bitmap generation with span generation in \c{ftraster.c}. + \i Renamed \c{ftraster.h} as \c{qblackraster_p.h}. + \i Renamed \c{ftraster.c} as \c{qblackraster.c}. + \i Renamed \c{ftgrays.h} as \c{qgrayraster_p.h}. + \i Renamed \c{ftgrays.c} as \c{qgrayraster.c}. + \endlist + + See \c src/3rdparty/freetype/docs/FTL.txt and \c + src/3rdparty/freetype/docs/GPL.txt for license details. + + \hr + + Copyright (c) 1985, 1986, 1987 X Consortium + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the name of the X Consortium shall + not be used in advertising or otherwise to promote the sale, use or + other dealings in this Software without prior written authorization + from the X Consortium. + + \list + \o Parts of the Q3PolygonScanner class used in Qt for Embedded Linux + \endlist + + \hr + + Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose and without fee is hereby granted, + provided that the above copyright notice appear in all copies and that + both that copyright notice and this permission notice appear in + supporting documentation, and that the name of Digital not be + used in advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + SOFTWARE. + + \list + \o Parts of the Q3PolygonScanner class used in Qt for Embedded Linux + \endlist + + \hr + + Copyright 1985, 1987, 1998 The Open Group + + Permission to use, copy, modify, distribute, and sell this software and its + documentation for any purpose is hereby granted without fee, provided that + the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation. + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the name of The Open Group shall not be + used in advertising or otherwise to promote the sale, use or other dealings + in this Software without prior written authorization from The Open Group. + + \list + \o Parts of the internal QKeyMapper class on X11 platforms + \endlist + + \hr + + pnmscale.c - read a portable anymap and scale it + + Copyright (C) 1989, 1991 by Jef Poskanzer. + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose and without fee is hereby granted, provided + that the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation. This software is provided "as is" without express or + implied warranty. + + \list + \o Parts of the internal QImageSmoothScaler::scale() function use code + based on pnmscale.c by Jef Poskanzer. + \endlist + + \hr + + jQuery JavaScript Library v1.3.2 + http://jquery.com/ + + Copyright (c) 2009 John Resig + Dual licensed under the MIT and GPL licenses. + http://docs.jquery.com/License + + Sizzle CSS Selector Engine - v0.9.3 + Copyright 2009, The Dojo Foundation + Released under the MIT, BSD, and GPL Licenses. + More information: http://sizzlejs.com/ + + \list + \o examples/webkit/fancybrowser/jquery.min.js + \endlist +*/ + +/*! + \page licenses-fonts.html + \title Licenses for Fonts Used in Qt for Embedded Linux + \ingroup qt-embedded-linux + \ingroup licensing + \brief Information about the licenses of fonts supplied with Qt for Embedded Linux. + + The fonts supplied with Qt for Embedded Linux have been obtained under a + variety of different licenses listed below. + + \tableofcontents + + See also: \l{Other Licenses Used in Qt} + + \section1 Adobe Helvetica + + Copyright 1984-1989, 1994 Adobe Systems Incorporated. + Copyright 1988, 1994 Digital Equipment Corporation. + + Adobe is a trademark of Adobe Systems Incorporated which may be + registered in certain jurisdictions. + Permission to use these trademarks is hereby granted only in + association with the images described in this file. + + Permission to use, copy, modify, distribute and sell this software + and its documentation for any purpose and without fee is hereby + granted, provided that the above copyright notices appear in all + copies and that both those copyright notices and this permission + notice appear in supporting documentation, and that the names of + Adobe Systems and Digital Equipment Corporation not be used in + advertising or publicity pertaining to distribution of the software + without specific, written prior permission. Adobe Systems and + Digital Equipment Corporation make no representations about the + suitability of this software for any purpose. It is provided "as + is" without express or implied warranty. + + \section1 Adobe Utopia + + Permission to use, reproduce, display and distribute the listed + typefaces is hereby granted, provided that the Adobe Copyright notice + appears in all whole and partial copies of the software and that the + following trademark symbol and attribution appear in all unmodified + copies of the software: + + Copyright (c) 1989 Adobe Systems Incorporated + Utopia (R) + Utopia is a registered trademark of Adobe Systems Incorporated + + The Utopia font + Copyright (c) 1989, 1991 Adobe Systems Incorporated. All Rights + Reserved.Utopia is a registered trademark of Adobe Systems + Incorporated. + + \section1 Babelfish + + \snippet doc/src/snippets/code/doc_src_licenses.qdoc 1 + + \section1 Bigelow & Holmes Luxi + + Luxi fonts copyright (c) 2001 by Bigelow & Holmes Inc. Luxi font + instruction code copyright (c) 2001 by URW++ GmbH. All Rights + Reserved. Luxi is a registered trademark of Bigelow & Holmes Inc. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of these Fonts and associated documentation files (the "Font + Software"), to deal in the Font Software, including without + limitation the rights to use, copy, merge, publish, distribute, + sublicense, and/or sell copies of the Font Software, and to permit + persons to whom the Font Software is furnished to do so, subject to + the following conditions: + + The above copyright and trademark notices and this permission notice + shall be included in all copies of one or more of the Font Software. + + The Font Software may not be modified, altered, or added to, and in + particular the designs of glyphs or characters in the Fonts may not + be modified nor may additional glyphs or characters be added to the + Fonts. This License becomes null and void when the Fonts or Font + Software have been modified. + + THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL + BIGELOW & HOLMES INC. OR URW++ GMBH. BE LIABLE FOR ANY CLAIM, DAMAGES + OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, + INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR + INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT + SOFTWARE. + + Except as contained in this notice, the names of Bigelow & Holmes + Inc. and URW++ GmbH. shall not be used in advertising or otherwise to + promote the sale, use or other dealings in this Font Software without + prior written authorization from Bigelow & Holmes Inc. and URW++ GmbH. + + For further information, contact: + + info@urwpp.de + or + design@bigelowandholmes.com + + \section1 Bitstream Charter and Courier + + (c) Copyright 1989-1992, Bitstream Inc., Cambridge, MA. + + You are hereby granted permission under all Bitstream propriety rights + to use, copy, modify, sublicense, sell, and redistribute the 4 Bitstream + Charter (r) Type 1 outline fonts and the 4 Courier Type 1 outline fonts + for any purpose and without restriction; provided, that this notice is + left intact on all copies of such fonts and that Bitstream's trademark + is acknowledged as shown below on all unmodified copies of the 4 Charter + Type 1 fonts. + + BITSTREAM CHARTER is a registered trademark of Bitstream Inc. + + \section1 Bitstream Vera + + Copyright (c) 2003 by Bitstream, Inc. + + All Rights Reserved. + + Bitstream Vera is a trademark of Bitstream, Inc. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of the fonts accompanying this license ("Fonts") and associated + documentation files (the "Font Software"), to reproduce and distribute + the Font Software, including without limitation the rights to use, + copy, merge, publish, distribute, and/or sell copies of the Font + Software, and to permit persons to whom the Font Software is furnished + to do so, subject to the following conditions: + + The above copyright and trademark notices and this permission notice + shall be included in all copies of one or more of the Font Software + typefaces. + + The Font Software may be modified, altered, or added to, and in + particular the designs of glyphs or characters in the Fonts may be + modified and additional glyphs or characters may be added to the + Fonts, only if the fonts are renamed to names not containing either + the words "Bitstream" or the word "Vera". + + This License becomes null and void to the extent applicable to Fonts + or Font Software that has been modified and is distributed under the + "Bitstream Vera" names. + + The Font Software may be sold as part of a larger software package but + no copy of one or more of the Font Software typefaces may be sold by + itself. + + THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL + BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, + OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR + OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT + SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. + + Except as contained in this notice, the names of Gnome, the Gnome + Foundation, and Bitstream Inc., shall not be used in advertising or + otherwise to promote the sale, use or other dealings in this Font + Software without prior written authorization from the Gnome Foundation + or Bitstream Inc., respectively. For further information, contact: + fonts at gnome dot org. + + \omit + http://www.gnome.org/fonts/#Final_Bitstream_Vera_Fonts + \endomit + + See also: + \l{http://www.bitstream.com/font_rendering/products/dev_fonts/vera.html}{Vera Open Source Fonts} + + \section1 Cursor + + The Cursor font is distributed with the following declaration: + + \e{Copyright (c) 2000 XFree86, Inc.} + + \section1 DejaVu Fonts + + DejaVu fonts come with the following copyright statement: + + Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. Glyphs imported from Arev fonts are (c) Tavmjung Bah (see below) + + \snippet doc/src/snippets/code/doc_src_licenses.qdoc 2 + + \section1 Fixed Fonts + + The 5x7 and 6x13 fonts each contain the following copyright notice: + + \e{Public domain font. Share and enjoy.} + + \section1 IBM Courier + + IBM Courier - Copyright (c) IBM Corporation 1990, 1991 + + You are hereby granted permission under the terms of the IBM/MIT X Consortium + Courier Typefont agreement to execute, reproduce, distribute, display, market, + sell and otherwise transfer copies of the IBM Courier font to third parties. + + The font is provided "AS IS" without charge. NO WARRANTIES OR INDEMNIFICATION + ARE GIVEN, WHETHER EXPRESS OR IMPLIED INCLUDING, BUT LIMITED TO THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + \section1 Micro + + The Micro font contains the following copyright notice: + + \e{Public domain font. Share and enjoy.} + + \section1 Unifont + + The Unifont font was originally obtained from + \l{http://www.czyborra.com/}{Roman Czyborra} under the following license: + + \e{All of my works you find here are freeware. You may freely copy, use, quote, + modify or redistribute them as long as you properly attribute my contribution + and have given a quick thought about whether Roman might perhaps be interested + to read what you did with his stuff. Horizontal rules don't apply.} +*/ diff --git a/doc/src/legal/opensourceedition.qdoc b/doc/src/legal/opensourceedition.qdoc new file mode 100644 index 0000000..e7bb26a --- /dev/null +++ b/doc/src/legal/opensourceedition.qdoc @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page opensourceedition.html + + \title Open Source Versions of Qt + \ingroup licensing + \brief Information about the license and features of the Open Source Edition. + + Free (or open source) software is software that comes with a license + that gives users certain rights. In particular the right to use the + software, to modify it, to obtain its source, and to pass it on (under + the same terms). Notice that the term "free" is about rights, not + money. The Free Software Foundation (creators of the GNU GPL) speaks + of free in this context as in "free speech", not as in "no cost". + + Nokia supports the free software concept by providing the Qt Open Source + Edition, which is licensed under the \l{GNU General Public License (GPL)} + (version 3) and the \l{GNU Lesser General Public License (LGPL)} (version 2.1). + You can use this edition of Qt to create and distribute software with licenses + that are compatible to these free software licenses. + + The support of open source with the Open Source Versions of Qt has enabled large + successful software projects like KDE to thrive, with thousands of developers + around the world using open source versions of Qt at no cost to themselves. With + the release of Qt 4, open source versions of Qt became available for Unix/X11, + Mac OS X, and Windows platforms. + + The Open Source Edition can be downloaded from the \l{Downloads}{Qt website}. + + Please refer to the online \l{License FAQ} for answers to frequently asked + questions on open source licensing and its implications. + + More information on Free and Open Source software is available online: + + \list + \o GNU GPL: \l http://www.gnu.org/. + \o Open Source licensing: \l http://www.opensource.org/. + \endlist + + See \l{Licensing Information} for a collection of documents about licenses + used in Qt. + + Information about Qt Commercial License Agreements is available + in the \l{Qt Licensing Overview} on the Qt website or by contacting + the sales department at http://www.qtsoftware.com/contact. + + If you are in doubt what edition of Qt is right for your project, + please contact + \l{mailto:qt-info@nokia.com}{qt-info@nokia.com}. + +*/ diff --git a/doc/src/legal/trademarks.qdoc b/doc/src/legal/trademarks.qdoc new file mode 100644 index 0000000..0e659d2 --- /dev/null +++ b/doc/src/legal/trademarks.qdoc @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page trademarks.html + + \title Trademarks + \ingroup licensing + \brief Information about trademarks owned by Nokia and other organisations. + + Nokia, the Nokia logo, Qt, and the Qt logo are trademarks of Nokia +  Corporation and/or its subsidiaries in Finland and other countries. + + \list + \o Intel, Intel Inside (logos), MMX and Pentium are \reg trademarks of + Intel Corporation in the United States, other countries, or both. + \o Java and all Java-based trademarks are trademarks of Sun Microsystems, + Inc. in the United States, other countries, or both. + \o Linux is a \reg trademark of Linus Torvalds in the United States, other + countries or both. + \o Mac, Mac OS and Macintosh are \reg trademarks of Apple Computer, Inc., + registered in the U.S. and other countries. + \o Microsoft, Windows, Windows NT, XP, Visual Studio and the Windows logo + are \reg trademarks of Microsoft Corporation in the United States, other + countries, or both. + \o Motif is a registered trademark of The Open Group in the United States, + other countries, or both. + \o OpenGL is a \reg trademark of Silicon Graphics, Inc. in the United States + and other countries. + \o UNIX is a registered trademark of The Open Group in the United States + and other countries. + \o All other company, product, or service names may be trademarks or + service marks of others and are the property of their respective owners. + The use of the word partner does not imply a partnership relationship + between Nokia and any other company. + \endlist +*/ diff --git a/doc/src/licenses.qdoc b/doc/src/licenses.qdoc deleted file mode 100644 index 7597e7f..0000000 --- a/doc/src/licenses.qdoc +++ /dev/null @@ -1,483 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page licenses.html - \title Other Licenses Used in Qt - \ingroup licensing - \brief Information about other licenses used for Qt components and third-party code. - - Qt contains some code that is not provided under the - \l{GNU General Public License (GPL)}, - \l{GNU Lesser General Public License (LGPL)} or the - \l{Qt Commercial Editions}{Qt Commercial License Agreement}, but rather under - specific licenses from the original authors. Some pieces of code were developed - by Nokia and others originated from third parties. - This page lists the licenses used, names the authors, and links - to the places where it is used. - - Nokia gratefully acknowledges these and other contributions - to Qt. We recommend that programs that use Qt also acknowledge - these contributions, and quote these license statements in an - appendix to the documentation. - - See also: \l{Licenses for Fonts Used in Qt for Embedded Linux} - - \generatelist legalese - - \hr - - Copyright (C) 2000-2004, International Business Machines\br - Corporation and others. All Rights Reserved.\br - Copyright (C) 2007 Apple Inc. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, and/or sell copies of the Software, and to permit persons - to whom the Software is furnished to do so, provided that the above copyright notice(s) - and this permission notice appear in all copies of the Software and that both the above - copyright notice(s) and this permission notice appear in supporting documentation. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER - OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR - CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - Except as contained in this notice, the name of a copyright holder shall not be used in - advertising or otherwise to promote the sale, use or other dealings in this Software - without prior written authorization of the copyright holder. - - \list - \o Parts of WebKit used by the QtWebKit module - \endlist - - \hr - - Copyright (c) 1998 by Bjorn Reese - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - - \list - \o Parts of the QCrashHandler class - \endlist - - \hr - - Parts of the FreeType projects have been modified and put into Qt - for use in the painting subsystem. These files are ftraster.h, - ftraster.c, ftgrays.h and ftgrays.c. The following modifications - has been made to these files: - - \list - \i Renamed FT_ and ft_ symbols to QT_FT_ and qt_ft_ to avoid name - conflicts in \c{qrasterdefs_p.h}. - \i Removed parts of code not relevant when compiled with - _STANDALONE_ defined. - \i Changed behavior in \c{ftraster.c} to follow X polygon filling - rules. - \i Implemented support in \c{ftraster.c} for winding / odd even - polygon fill rules. - \i Replaced bitmap generation with span generation in \c{ftraster.c}. - \i Renamed \c{ftraster.h} as \c{qblackraster_p.h}. - \i Renamed \c{ftraster.c} as \c{qblackraster.c}. - \i Renamed \c{ftgrays.h} as \c{qgrayraster_p.h}. - \i Renamed \c{ftgrays.c} as \c{qgrayraster.c}. - \endlist - - See \c src/3rdparty/freetype/docs/FTL.txt and \c - src/3rdparty/freetype/docs/GPL.txt for license details. - - \hr - - Copyright (c) 1985, 1986, 1987 X Consortium - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name of the X Consortium shall - not be used in advertising or otherwise to promote the sale, use or - other dealings in this Software without prior written authorization - from the X Consortium. - - \list - \o Parts of the Q3PolygonScanner class used in Qt for Embedded Linux - \endlist - - \hr - - Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - - Permission to use, copy, modify, and distribute this software and its - documentation for any purpose and without fee is hereby granted, - provided that the above copyright notice appear in all copies and that - both that copyright notice and this permission notice appear in - supporting documentation, and that the name of Digital not be - used in advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR - ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - SOFTWARE. - - \list - \o Parts of the Q3PolygonScanner class used in Qt for Embedded Linux - \endlist - - \hr - - Copyright 1985, 1987, 1998 The Open Group - - Permission to use, copy, modify, distribute, and sell this software and its - documentation for any purpose is hereby granted without fee, provided that - the above copyright notice appear in all copies and that both that - copyright notice and this permission notice appear in supporting - documentation. - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name of The Open Group shall not be - used in advertising or otherwise to promote the sale, use or other dealings - in this Software without prior written authorization from The Open Group. - - \list - \o Parts of the internal QKeyMapper class on X11 platforms - \endlist - - \hr - - pnmscale.c - read a portable anymap and scale it - - Copyright (C) 1989, 1991 by Jef Poskanzer. - - Permission to use, copy, modify, and distribute this software and its - documentation for any purpose and without fee is hereby granted, provided - that the above copyright notice appear in all copies and that both that - copyright notice and this permission notice appear in supporting - documentation. This software is provided "as is" without express or - implied warranty. - - \list - \o Parts of the internal QImageSmoothScaler::scale() function use code - based on pnmscale.c by Jef Poskanzer. - \endlist - - \hr - - jQuery JavaScript Library v1.3.2 - http://jquery.com/ - - Copyright (c) 2009 John Resig - Dual licensed under the MIT and GPL licenses. - http://docs.jquery.com/License - - Sizzle CSS Selector Engine - v0.9.3 - Copyright 2009, The Dojo Foundation - Released under the MIT, BSD, and GPL Licenses. - More information: http://sizzlejs.com/ - - \list - \o examples/webkit/fancybrowser/jquery.min.js - \endlist -*/ - -/*! - \page licenses-fonts.html - \title Licenses for Fonts Used in Qt for Embedded Linux - \ingroup qt-embedded-linux - \ingroup licensing - \brief Information about the licenses of fonts supplied with Qt for Embedded Linux. - - The fonts supplied with Qt for Embedded Linux have been obtained under a - variety of different licenses listed below. - - \tableofcontents - - See also: \l{Other Licenses Used in Qt} - - \section1 Adobe Helvetica - - Copyright 1984-1989, 1994 Adobe Systems Incorporated. - Copyright 1988, 1994 Digital Equipment Corporation. - - Adobe is a trademark of Adobe Systems Incorporated which may be - registered in certain jurisdictions. - Permission to use these trademarks is hereby granted only in - association with the images described in this file. - - Permission to use, copy, modify, distribute and sell this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notices appear in all - copies and that both those copyright notices and this permission - notice appear in supporting documentation, and that the names of - Adobe Systems and Digital Equipment Corporation not be used in - advertising or publicity pertaining to distribution of the software - without specific, written prior permission. Adobe Systems and - Digital Equipment Corporation make no representations about the - suitability of this software for any purpose. It is provided "as - is" without express or implied warranty. - - \section1 Adobe Utopia - - Permission to use, reproduce, display and distribute the listed - typefaces is hereby granted, provided that the Adobe Copyright notice - appears in all whole and partial copies of the software and that the - following trademark symbol and attribution appear in all unmodified - copies of the software: - - Copyright (c) 1989 Adobe Systems Incorporated - Utopia (R) - Utopia is a registered trademark of Adobe Systems Incorporated - - The Utopia font - Copyright (c) 1989, 1991 Adobe Systems Incorporated. All Rights - Reserved.Utopia is a registered trademark of Adobe Systems - Incorporated. - - \section1 Babelfish - - \snippet doc/src/snippets/code/doc_src_licenses.qdoc 1 - - \section1 Bigelow & Holmes Luxi - - Luxi fonts copyright (c) 2001 by Bigelow & Holmes Inc. Luxi font - instruction code copyright (c) 2001 by URW++ GmbH. All Rights - Reserved. Luxi is a registered trademark of Bigelow & Holmes Inc. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of these Fonts and associated documentation files (the "Font - Software"), to deal in the Font Software, including without - limitation the rights to use, copy, merge, publish, distribute, - sublicense, and/or sell copies of the Font Software, and to permit - persons to whom the Font Software is furnished to do so, subject to - the following conditions: - - The above copyright and trademark notices and this permission notice - shall be included in all copies of one or more of the Font Software. - - The Font Software may not be modified, altered, or added to, and in - particular the designs of glyphs or characters in the Fonts may not - be modified nor may additional glyphs or characters be added to the - Fonts. This License becomes null and void when the Fonts or Font - Software have been modified. - - THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL - BIGELOW & HOLMES INC. OR URW++ GMBH. BE LIABLE FOR ANY CLAIM, DAMAGES - OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, - INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR - INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT - SOFTWARE. - - Except as contained in this notice, the names of Bigelow & Holmes - Inc. and URW++ GmbH. shall not be used in advertising or otherwise to - promote the sale, use or other dealings in this Font Software without - prior written authorization from Bigelow & Holmes Inc. and URW++ GmbH. - - For further information, contact: - - info@urwpp.de - or - design@bigelowandholmes.com - - \section1 Bitstream Charter and Courier - - (c) Copyright 1989-1992, Bitstream Inc., Cambridge, MA. - - You are hereby granted permission under all Bitstream propriety rights - to use, copy, modify, sublicense, sell, and redistribute the 4 Bitstream - Charter (r) Type 1 outline fonts and the 4 Courier Type 1 outline fonts - for any purpose and without restriction; provided, that this notice is - left intact on all copies of such fonts and that Bitstream's trademark - is acknowledged as shown below on all unmodified copies of the 4 Charter - Type 1 fonts. - - BITSTREAM CHARTER is a registered trademark of Bitstream Inc. - - \section1 Bitstream Vera - - Copyright (c) 2003 by Bitstream, Inc. - - All Rights Reserved. - - Bitstream Vera is a trademark of Bitstream, Inc. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of the fonts accompanying this license ("Fonts") and associated - documentation files (the "Font Software"), to reproduce and distribute - the Font Software, including without limitation the rights to use, - copy, merge, publish, distribute, and/or sell copies of the Font - Software, and to permit persons to whom the Font Software is furnished - to do so, subject to the following conditions: - - The above copyright and trademark notices and this permission notice - shall be included in all copies of one or more of the Font Software - typefaces. - - The Font Software may be modified, altered, or added to, and in - particular the designs of glyphs or characters in the Fonts may be - modified and additional glyphs or characters may be added to the - Fonts, only if the fonts are renamed to names not containing either - the words "Bitstream" or the word "Vera". - - This License becomes null and void to the extent applicable to Fonts - or Font Software that has been modified and is distributed under the - "Bitstream Vera" names. - - The Font Software may be sold as part of a larger software package but - no copy of one or more of the Font Software typefaces may be sold by - itself. - - THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL - BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, - OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR - OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT - SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. - - Except as contained in this notice, the names of Gnome, the Gnome - Foundation, and Bitstream Inc., shall not be used in advertising or - otherwise to promote the sale, use or other dealings in this Font - Software without prior written authorization from the Gnome Foundation - or Bitstream Inc., respectively. For further information, contact: - fonts at gnome dot org. - - \omit - http://www.gnome.org/fonts/#Final_Bitstream_Vera_Fonts - \endomit - - See also: - \l{http://www.bitstream.com/font_rendering/products/dev_fonts/vera.html}{Vera Open Source Fonts} - - \section1 Cursor - - The Cursor font is distributed with the following declaration: - - \e{Copyright (c) 2000 XFree86, Inc.} - - \section1 DejaVu Fonts - - DejaVu fonts come with the following copyright statement: - - Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. Glyphs imported from Arev fonts are (c) Tavmjung Bah (see below) - - \snippet doc/src/snippets/code/doc_src_licenses.qdoc 2 - - \section1 Fixed Fonts - - The 5x7 and 6x13 fonts each contain the following copyright notice: - - \e{Public domain font. Share and enjoy.} - - \section1 IBM Courier - - IBM Courier - Copyright (c) IBM Corporation 1990, 1991 - - You are hereby granted permission under the terms of the IBM/MIT X Consortium - Courier Typefont agreement to execute, reproduce, distribute, display, market, - sell and otherwise transfer copies of the IBM Courier font to third parties. - - The font is provided "AS IS" without charge. NO WARRANTIES OR INDEMNIFICATION - ARE GIVEN, WHETHER EXPRESS OR IMPLIED INCLUDING, BUT LIMITED TO THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - - \section1 Micro - - The Micro font contains the following copyright notice: - - \e{Public domain font. Share and enjoy.} - - \section1 Unifont - - The Unifont font was originally obtained from - \l{http://www.czyborra.com/}{Roman Czyborra} under the following license: - - \e{All of my works you find here are freeware. You may freely copy, use, quote, - modify or redistribute them as long as you properly attribute my contribution - and have given a quick thought about whether Roman might perhaps be interested - to read what you did with his stuff. Horizontal rules don't apply.} -*/ diff --git a/doc/src/opensourceedition.qdoc b/doc/src/opensourceedition.qdoc deleted file mode 100644 index e7bb26a..0000000 --- a/doc/src/opensourceedition.qdoc +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page opensourceedition.html - - \title Open Source Versions of Qt - \ingroup licensing - \brief Information about the license and features of the Open Source Edition. - - Free (or open source) software is software that comes with a license - that gives users certain rights. In particular the right to use the - software, to modify it, to obtain its source, and to pass it on (under - the same terms). Notice that the term "free" is about rights, not - money. The Free Software Foundation (creators of the GNU GPL) speaks - of free in this context as in "free speech", not as in "no cost". - - Nokia supports the free software concept by providing the Qt Open Source - Edition, which is licensed under the \l{GNU General Public License (GPL)} - (version 3) and the \l{GNU Lesser General Public License (LGPL)} (version 2.1). - You can use this edition of Qt to create and distribute software with licenses - that are compatible to these free software licenses. - - The support of open source with the Open Source Versions of Qt has enabled large - successful software projects like KDE to thrive, with thousands of developers - around the world using open source versions of Qt at no cost to themselves. With - the release of Qt 4, open source versions of Qt became available for Unix/X11, - Mac OS X, and Windows platforms. - - The Open Source Edition can be downloaded from the \l{Downloads}{Qt website}. - - Please refer to the online \l{License FAQ} for answers to frequently asked - questions on open source licensing and its implications. - - More information on Free and Open Source software is available online: - - \list - \o GNU GPL: \l http://www.gnu.org/. - \o Open Source licensing: \l http://www.opensource.org/. - \endlist - - See \l{Licensing Information} for a collection of documents about licenses - used in Qt. - - Information about Qt Commercial License Agreements is available - in the \l{Qt Licensing Overview} on the Qt website or by contacting - the sales department at http://www.qtsoftware.com/contact. - - If you are in doubt what edition of Qt is right for your project, - please contact - \l{mailto:qt-info@nokia.com}{qt-info@nokia.com}. - -*/ diff --git a/doc/src/topics.qdoc b/doc/src/topics.qdoc index 7f832ab..15be0ade 100644 --- a/doc/src/topics.qdoc +++ b/doc/src/topics.qdoc @@ -150,18 +150,6 @@ These guides provide specific help about specific Qt-related topics. */ /*! -\group licensing -\title Licensing Information -\ingroup topics -\brief Information about licenses and licensing issues. - -These documents include information about Qt's licenses and the licenses -of third party components used in Qt. - -\generatelist{related} -*/ - -/*! \group platform-notes \title Platform-Specific Notes \ingroup topics diff --git a/doc/src/trademarks.qdoc b/doc/src/trademarks.qdoc deleted file mode 100644 index 0e659d2..0000000 --- a/doc/src/trademarks.qdoc +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page trademarks.html - - \title Trademarks - \ingroup licensing - \brief Information about trademarks owned by Nokia and other organisations. - - Nokia, the Nokia logo, Qt, and the Qt logo are trademarks of Nokia -  Corporation and/or its subsidiaries in Finland and other countries. - - \list - \o Intel, Intel Inside (logos), MMX and Pentium are \reg trademarks of - Intel Corporation in the United States, other countries, or both. - \o Java and all Java-based trademarks are trademarks of Sun Microsystems, - Inc. in the United States, other countries, or both. - \o Linux is a \reg trademark of Linus Torvalds in the United States, other - countries or both. - \o Mac, Mac OS and Macintosh are \reg trademarks of Apple Computer, Inc., - registered in the U.S. and other countries. - \o Microsoft, Windows, Windows NT, XP, Visual Studio and the Windows logo - are \reg trademarks of Microsoft Corporation in the United States, other - countries, or both. - \o Motif is a registered trademark of The Open Group in the United States, - other countries, or both. - \o OpenGL is a \reg trademark of Silicon Graphics, Inc. in the United States - and other countries. - \o UNIX is a registered trademark of The Open Group in the United States - and other countries. - \o All other company, product, or service names may be trademarks or - service marks of others and are the property of their respective owners. - The use of the word partner does not imply a partnership relationship - between Nokia and any other company. - \endlist -*/ -- cgit v0.12 From ed436d4e6e1bffa4a9dd6032ef9f745a735fc8fd Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 29 Jul 2009 22:57:57 +0200 Subject: Doc: Another classlist. --- doc/src/classes.qdoc | 14 ++++++++++++ doc/src/compatclasses.qdoc | 54 ---------------------------------------------- 2 files changed, 14 insertions(+), 54 deletions(-) delete mode 100644 doc/src/compatclasses.qdoc diff --git a/doc/src/classes.qdoc b/doc/src/classes.qdoc index 4845f84..e955a5a 100644 --- a/doc/src/classes.qdoc +++ b/doc/src/classes.qdoc @@ -137,3 +137,17 @@ \generatelist mainclasses */ + +/*! + \page compatclasses.html + \title Qt 3 Compatibility Classes + \ingroup classlists + + This is a list of the classes that Qt provides for compatibility + with Qt 3. The vast majority of these are provided by the + Qt3Support module. + + \generatelist compatclasses + + \sa {Qt's Classes}, {Qt's Modules} +*/ diff --git a/doc/src/compatclasses.qdoc b/doc/src/compatclasses.qdoc deleted file mode 100644 index cb6d7dd..0000000 --- a/doc/src/compatclasses.qdoc +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page compatclasses.html - \title Qt 3 Compatibility Classes - \ingroup classlists - - This is a list of the classes that Qt provides for compatibility - with Qt 3. The vast majority of these are provided by the - Qt3Support module. - - \generatelist compatclasses - - \sa {Qt's Classes}, {Qt's Modules} -*/ -- cgit v0.12 From b2c0b95d38b75035c60a20fdc6bfa5f47371f801 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 30 Jul 2009 09:42:25 +1000 Subject: Add math3d unit tests for QObject properties and metatypes Reviewed-by: trustme --- tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp | 47 +++++++++++ tests/auto/math3d/qquaternion/tst_qquaternion.cpp | 52 ++++++++++++ tests/auto/math3d/qvectornd/tst_qvectornd.cpp | 96 +++++++++++++++++++++++ 3 files changed, 195 insertions(+) diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index d799c1b..fe1d0db 100644 --- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -170,6 +170,9 @@ private slots: void mapRect_data(); void mapRect(); + void properties(); + void metaTypes(); + private: static void setMatrix(QMatrix2x2& m, const qreal *values); static void setMatrixDirect(QMatrix2x2& m, const qreal *values); @@ -3331,6 +3334,50 @@ void tst_QMatrix::mapRect() QVERIFY(mri == tri); } +class tst_QMatrix4x4Properties : public QObject +{ + Q_OBJECT + Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix) +public: + tst_QMatrix4x4Properties(QObject *parent = 0) : QObject(parent) {} + + QMatrix4x4 matrix() const { return m; } + void setMatrix(const QMatrix4x4& value) { m = value; } + +private: + QMatrix4x4 m; +}; + +// Test getting and setting matrix properties via the metaobject system. +void tst_QMatrix::properties() +{ + tst_QMatrix4x4Properties obj; + + QMatrix4x4 m1(uniqueValues4); + obj.setMatrix(m1); + + QMatrix4x4 m2 = qVariantValue(obj.property("matrix")); + QVERIFY(isSame(m2, uniqueValues4)); + + QMatrix4x4 m3(transposedValues4); + obj.setProperty("matrix", qVariantFromValue(m3)); + + m2 = qVariantValue(obj.property("matrix")); + QVERIFY(isSame(m2, transposedValues4)); +} + +void tst_QMatrix::metaTypes() +{ + QVERIFY(QMetaType::type("QMatrix4x4") == QMetaType::QMatrix4x4); + + QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QMatrix4x4)), + QByteArray("QMatrix4x4")); + + QVERIFY(QMetaType::isRegistered(QMetaType::QMatrix4x4)); + + QVERIFY(qMetaTypeId() == QMetaType::QMatrix4x4); +} + QTEST_APPLESS_MAIN(tst_QMatrix) #include "tst_qmatrixnxn.moc" diff --git a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/math3d/qquaternion/tst_qquaternion.cpp index 16b87a1..369f5ac 100644 --- a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp +++ b/tests/auto/math3d/qquaternion/tst_qquaternion.cpp @@ -93,6 +93,9 @@ private slots: void nlerp_data(); void nlerp(); + + void properties(); + void metaTypes(); }; // qFuzzyCompare isn't always "fuzzy" enough to handle conversion @@ -825,6 +828,55 @@ void tst_QQuaternion::nlerp() QVERIFY(fuzzyCompare(result.scalar(), q3.scalar())); } +class tst_QQuaternionProperties : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion) +public: + tst_QQuaternionProperties(QObject *parent = 0) : QObject(parent) {} + + QQuaternion quaternion() const { return q; } + void setQuaternion(const QQuaternion& value) { q = value; } + +private: + QQuaternion q; +}; + +// Test getting and setting quaternion properties via the metaobject system. +void tst_QQuaternion::properties() +{ + tst_QQuaternionProperties obj; + + obj.setQuaternion(QQuaternion(6.0f, 7.0f, 8.0f, 9.0f)); + + QQuaternion q = qVariantValue(obj.property("quaternion")); + QCOMPARE(q.scalar(), (qreal)6.0f); + QCOMPARE(q.x(), (qreal)7.0f); + QCOMPARE(q.y(), (qreal)8.0f); + QCOMPARE(q.z(), (qreal)9.0f); + + obj.setProperty("quaternion", + qVariantFromValue(QQuaternion(-6.0f, -7.0f, -8.0f, -9.0f))); + + q = qVariantValue(obj.property("quaternion")); + QCOMPARE(q.scalar(), (qreal)-6.0f); + QCOMPARE(q.x(), (qreal)-7.0f); + QCOMPARE(q.y(), (qreal)-8.0f); + QCOMPARE(q.z(), (qreal)-9.0f); +} + +void tst_QQuaternion::metaTypes() +{ + QVERIFY(QMetaType::type("QQuaternion") == QMetaType::QQuaternion); + + QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QQuaternion)), + QByteArray("QQuaternion")); + + QVERIFY(QMetaType::isRegistered(QMetaType::QQuaternion)); + + QVERIFY(qMetaTypeId() == QMetaType::QQuaternion); +} + QTEST_APPLESS_MAIN(tst_QQuaternion) #include "tst_qquaternion.moc" diff --git a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/math3d/qvectornd/tst_qvectornd.cpp index 9c1ea83..6368874 100644 --- a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/math3d/qvectornd/tst_qvectornd.cpp @@ -137,6 +137,9 @@ private slots: void dotProduct3(); void dotProduct4_data(); void dotProduct4(); + + void properties(); + void metaTypes(); }; // qFuzzyCompare isn't always "fuzzy" enough to handle conversion @@ -2040,6 +2043,99 @@ void tst_QVector::dotProduct4() QCOMPARE(QVector4D::dotProduct(v1, v2), d); } +class tst_QVectorProperties : public QObject +{ + Q_OBJECT + Q_PROPERTY(QVector2D vector2D READ vector2D WRITE setVector2D) + Q_PROPERTY(QVector3D vector3D READ vector3D WRITE setVector3D) + Q_PROPERTY(QVector4D vector4D READ vector4D WRITE setVector4D) +public: + tst_QVectorProperties(QObject *parent = 0) : QObject(parent) {} + + QVector2D vector2D() const { return v2; } + void setVector2D(const QVector2D& value) { v2 = value; } + + QVector3D vector3D() const { return v3; } + void setVector3D(const QVector3D& value) { v3 = value; } + + QVector4D vector4D() const { return v4; } + void setVector4D(const QVector4D& value) { v4 = value; } + +private: + QVector2D v2; + QVector3D v3; + QVector4D v4; +}; + +// Test getting and setting vector properties via the metaobject system. +void tst_QVector::properties() +{ + tst_QVectorProperties obj; + + obj.setVector2D(QVector2D(1.0f, 2.0f)); + obj.setVector3D(QVector3D(3.0f, 4.0f, 5.0f)); + obj.setVector4D(QVector4D(6.0f, 7.0f, 8.0f, 9.0f)); + + QVector2D v2 = qVariantValue(obj.property("vector2D")); + QCOMPARE(v2.x(), (qreal)1.0f); + QCOMPARE(v2.y(), (qreal)2.0f); + + QVector3D v3 = qVariantValue(obj.property("vector3D")); + QCOMPARE(v3.x(), (qreal)3.0f); + QCOMPARE(v3.y(), (qreal)4.0f); + QCOMPARE(v3.z(), (qreal)5.0f); + + QVector4D v4 = qVariantValue(obj.property("vector4D")); + QCOMPARE(v4.x(), (qreal)6.0f); + QCOMPARE(v4.y(), (qreal)7.0f); + QCOMPARE(v4.z(), (qreal)8.0f); + QCOMPARE(v4.w(), (qreal)9.0f); + + obj.setProperty("vector2D", + qVariantFromValue(QVector2D(-1.0f, -2.0f))); + obj.setProperty("vector3D", + qVariantFromValue(QVector3D(-3.0f, -4.0f, -5.0f))); + obj.setProperty("vector4D", + qVariantFromValue(QVector4D(-6.0f, -7.0f, -8.0f, -9.0f))); + + v2 = qVariantValue(obj.property("vector2D")); + QCOMPARE(v2.x(), (qreal)-1.0f); + QCOMPARE(v2.y(), (qreal)-2.0f); + + v3 = qVariantValue(obj.property("vector3D")); + QCOMPARE(v3.x(), (qreal)-3.0f); + QCOMPARE(v3.y(), (qreal)-4.0f); + QCOMPARE(v3.z(), (qreal)-5.0f); + + v4 = qVariantValue(obj.property("vector4D")); + QCOMPARE(v4.x(), (qreal)-6.0f); + QCOMPARE(v4.y(), (qreal)-7.0f); + QCOMPARE(v4.z(), (qreal)-8.0f); + QCOMPARE(v4.w(), (qreal)-9.0f); +} + +void tst_QVector::metaTypes() +{ + QVERIFY(QMetaType::type("QVector2D") == QMetaType::QVector2D); + QVERIFY(QMetaType::type("QVector3D") == QMetaType::QVector3D); + QVERIFY(QMetaType::type("QVector4D") == QMetaType::QVector4D); + + QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector2D)), + QByteArray("QVector2D")); + QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector3D)), + QByteArray("QVector3D")); + QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector4D)), + QByteArray("QVector4D")); + + QVERIFY(QMetaType::isRegistered(QMetaType::QVector2D)); + QVERIFY(QMetaType::isRegistered(QMetaType::QVector3D)); + QVERIFY(QMetaType::isRegistered(QMetaType::QVector4D)); + + QVERIFY(qMetaTypeId() == QMetaType::QVector2D); + QVERIFY(qMetaTypeId() == QMetaType::QVector3D); + QVERIFY(qMetaTypeId() == QMetaType::QVector4D); +} + QTEST_APPLESS_MAIN(tst_QVector) #include "tst_qvectornd.moc" -- cgit v0.12 From a78355d08ca8e0ec6b5aee06438e5baa331ce285 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 30 Jul 2009 10:32:38 +1000 Subject: qdoc fix: stencil buffer is enabled by default, not disabled Stencil buffer has been enabled by default for quite some time (2 years) but the documentation was still saying disabled. Reviewed-by: bnilsen --- src/opengl/qgl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index edda6b6..f6bfcbe 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -526,7 +526,7 @@ void QGLFormat::setAccum(bool enable) \fn bool QGLFormat::stencil() const Returns true if the stencil buffer is enabled; otherwise returns - false. The stencil buffer is disabled by default. + false. The stencil buffer is enabled by default. \sa setStencil(), setStencilBufferSize() */ @@ -535,7 +535,7 @@ void QGLFormat::setAccum(bool enable) If \a enable is true enables the stencil buffer; otherwise disables the stencil buffer. - The stencil buffer is disabled by default. + The stencil buffer is enabled by default. The stencil buffer masks certain parts of the drawing area so that masked parts are not drawn on. -- cgit v0.12 From 15ccaa0995da2061009d269fa875e8601da1a3c8 Mon Sep 17 00:00:00 2001 From: Bill King Date: Thu, 30 Jul 2009 11:18:59 +1000 Subject: Fixes hack around show queries not allowed to be prepared. Mysql queries other than select can't be prepared, otherwise they fail to return the necessary meta-information to enable them to be seen as returning data under certain versions of mysql. This fixes the hack to work correctly until we stop preparing queries automagically. --- src/sql/drivers/mysql/qsql_mysql.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index 8f377bd..3295a41 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -1336,8 +1336,8 @@ QSqlIndex QMYSQLDriver::primaryIndex(const QString& tablename) const if (!isOpen()) return idx; - prepQ = d->preparedQuerys; - d->preparedQuerys = false; + prepQ = d->preparedQuerysEnabled; + d->preparedQuerysEnabled = false; QSqlQuery i(createResult()); QString stmt(QLatin1String("show index from %1;")); @@ -1351,7 +1351,7 @@ QSqlIndex QMYSQLDriver::primaryIndex(const QString& tablename) const } } - d->preparedQuerys = prepQ; + d->preparedQuerysEnabled = prepQ; return idx; } -- cgit v0.12 From ab5619c395be3fdae70042ca6f6bc93a9a6f2c80 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 30 Jul 2009 12:49:15 +1000 Subject: Increase coverage of QGLFormat unit tests. Reviewed-by: trustme --- tests/auto/qgl/tst_qgl.cpp | 209 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 190 insertions(+), 19 deletions(-) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 96f5ddd..6ac1739 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -94,6 +94,11 @@ public: void setAutoBufferSwap(bool on) { QGLWidget::setAutoBufferSwap(on); } }; +// Using INT_MIN and INT_MAX will cause failures on systems +// where "int" is 64-bit, so use the explicit values instead. +#define TEST_INT_MIN (-2147483647 - 1) +#define TEST_INT_MAX 2147483647 + // Testing get/set functions void tst_QGL::getSetCheck() { @@ -103,120 +108,286 @@ void tst_QGL::getSetCheck() QGLFormat obj1; // int QGLFormat::depthBufferSize() // void QGLFormat::setDepthBufferSize(int) + QCOMPARE(-1, obj1.depthBufferSize()); obj1.setDepthBufferSize(0); QCOMPARE(0, obj1.depthBufferSize()); - obj1.setDepthBufferSize(INT_MIN); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size -2147483648"); + obj1.setDepthBufferSize(TEST_INT_MIN); QCOMPARE(0, obj1.depthBufferSize()); // Makes no sense with a negative buffer size - obj1.setDepthBufferSize(INT_MAX); - QCOMPARE(INT_MAX, obj1.depthBufferSize()); + obj1.setDepthBufferSize(3); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size -1"); + obj1.setDepthBufferSize(-1); + QCOMPARE(3, obj1.depthBufferSize()); + obj1.setDepthBufferSize(TEST_INT_MAX); + QCOMPARE(TEST_INT_MAX, obj1.depthBufferSize()); // int QGLFormat::accumBufferSize() // void QGLFormat::setAccumBufferSize(int) + QCOMPARE(-1, obj1.accumBufferSize()); obj1.setAccumBufferSize(0); QCOMPARE(0, obj1.accumBufferSize()); - obj1.setAccumBufferSize(INT_MIN); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size -2147483648"); + obj1.setAccumBufferSize(TEST_INT_MIN); QCOMPARE(0, obj1.accumBufferSize()); // Makes no sense with a negative buffer size - obj1.setAccumBufferSize(INT_MAX); - QCOMPARE(INT_MAX, obj1.accumBufferSize()); + obj1.setAccumBufferSize(3); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size -1"); + obj1.setAccumBufferSize(-1); + QCOMPARE(3, obj1.accumBufferSize()); + obj1.setAccumBufferSize(TEST_INT_MAX); + QCOMPARE(TEST_INT_MAX, obj1.accumBufferSize()); + + // int QGLFormat::redBufferSize() + // void QGLFormat::setRedBufferSize(int) + QCOMPARE(-1, obj1.redBufferSize()); + obj1.setRedBufferSize(0); + QCOMPARE(0, obj1.redBufferSize()); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setRedBufferSize: Cannot set negative red buffer size -2147483648"); + obj1.setRedBufferSize(TEST_INT_MIN); + QCOMPARE(0, obj1.redBufferSize()); // Makes no sense with a negative buffer size + obj1.setRedBufferSize(3); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setRedBufferSize: Cannot set negative red buffer size -1"); + obj1.setRedBufferSize(-1); + QCOMPARE(3, obj1.redBufferSize()); + obj1.setRedBufferSize(TEST_INT_MAX); + QCOMPARE(TEST_INT_MAX, obj1.redBufferSize()); + + // int QGLFormat::greenBufferSize() + // void QGLFormat::setGreenBufferSize(int) + QCOMPARE(-1, obj1.greenBufferSize()); + obj1.setGreenBufferSize(0); + QCOMPARE(0, obj1.greenBufferSize()); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setGreenBufferSize: Cannot set negative green buffer size -2147483648"); + obj1.setGreenBufferSize(TEST_INT_MIN); + QCOMPARE(0, obj1.greenBufferSize()); // Makes no sense with a negative buffer size + obj1.setGreenBufferSize(3); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setGreenBufferSize: Cannot set negative green buffer size -1"); + obj1.setGreenBufferSize(-1); + QCOMPARE(3, obj1.greenBufferSize()); + obj1.setGreenBufferSize(TEST_INT_MAX); + QCOMPARE(TEST_INT_MAX, obj1.greenBufferSize()); + + // int QGLFormat::blueBufferSize() + // void QGLFormat::setBlueBufferSize(int) + QCOMPARE(-1, obj1.blueBufferSize()); + obj1.setBlueBufferSize(0); + QCOMPARE(0, obj1.blueBufferSize()); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size -2147483648"); + obj1.setBlueBufferSize(TEST_INT_MIN); + QCOMPARE(0, obj1.blueBufferSize()); // Makes no sense with a negative buffer size + obj1.setBlueBufferSize(3); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size -1"); + obj1.setBlueBufferSize(-1); + QCOMPARE(3, obj1.blueBufferSize()); + obj1.setBlueBufferSize(TEST_INT_MAX); + QCOMPARE(TEST_INT_MAX, obj1.blueBufferSize()); // int QGLFormat::alphaBufferSize() // void QGLFormat::setAlphaBufferSize(int) + QCOMPARE(-1, obj1.alphaBufferSize()); + QCOMPARE(false, obj1.alpha()); + QVERIFY(!obj1.testOption(QGL::AlphaChannel)); + QVERIFY(obj1.testOption(QGL::NoAlphaChannel)); obj1.setAlphaBufferSize(0); + QCOMPARE(true, obj1.alpha()); // setAlphaBufferSize() enables alpha. QCOMPARE(0, obj1.alphaBufferSize()); - obj1.setAlphaBufferSize(INT_MIN); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size -2147483648"); + obj1.setAlphaBufferSize(TEST_INT_MIN); QCOMPARE(0, obj1.alphaBufferSize()); // Makes no sense with a negative buffer size - obj1.setAlphaBufferSize(INT_MAX); - QCOMPARE(INT_MAX, obj1.alphaBufferSize()); + obj1.setAlphaBufferSize(3); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size -1"); + obj1.setAlphaBufferSize(-1); + QCOMPARE(3, obj1.alphaBufferSize()); + obj1.setAlphaBufferSize(TEST_INT_MAX); + QCOMPARE(TEST_INT_MAX, obj1.alphaBufferSize()); // int QGLFormat::stencilBufferSize() // void QGLFormat::setStencilBufferSize(int) + QCOMPARE(-1, obj1.stencilBufferSize()); obj1.setStencilBufferSize(0); QCOMPARE(0, obj1.stencilBufferSize()); - obj1.setStencilBufferSize(INT_MIN); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size -2147483648"); + obj1.setStencilBufferSize(TEST_INT_MIN); QCOMPARE(0, obj1.stencilBufferSize()); // Makes no sense with a negative buffer size - obj1.setStencilBufferSize(INT_MAX); - QCOMPARE(INT_MAX, obj1.stencilBufferSize()); + obj1.setStencilBufferSize(3); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size -1"); + obj1.setStencilBufferSize(-1); + QCOMPARE(3, obj1.stencilBufferSize()); + obj1.setStencilBufferSize(TEST_INT_MAX); + QCOMPARE(TEST_INT_MAX, obj1.stencilBufferSize()); // bool QGLFormat::sampleBuffers() // void QGLFormat::setSampleBuffers(bool) + QCOMPARE(false, obj1.sampleBuffers()); + QVERIFY(!obj1.testOption(QGL::SampleBuffers)); + QVERIFY(obj1.testOption(QGL::NoSampleBuffers)); obj1.setSampleBuffers(false); QCOMPARE(false, obj1.sampleBuffers()); + QVERIFY(obj1.testOption(QGL::NoSampleBuffers)); obj1.setSampleBuffers(true); QCOMPARE(true, obj1.sampleBuffers()); + QVERIFY(obj1.testOption(QGL::SampleBuffers)); // int QGLFormat::samples() // void QGLFormat::setSamples(int) + QCOMPARE(-1, obj1.samples()); obj1.setSamples(0); QCOMPARE(0, obj1.samples()); - obj1.setSamples(INT_MIN); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setSamples: Cannot have negative number of samples per pixel -2147483648"); + obj1.setSamples(TEST_INT_MIN); QCOMPARE(0, obj1.samples()); // Makes no sense with a negative sample size - obj1.setSamples(INT_MAX); - QCOMPARE(INT_MAX, obj1.samples()); + obj1.setSamples(3); + QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setSamples: Cannot have negative number of samples per pixel -1"); + obj1.setSamples(-1); + QCOMPARE(3, obj1.samples()); + obj1.setSamples(TEST_INT_MAX); + QCOMPARE(TEST_INT_MAX, obj1.samples()); + + // int QGLFormat::swapInterval() + // void QGLFormat::setSwapInterval(int) + QCOMPARE(-1, obj1.swapInterval()); + obj1.setSwapInterval(0); + QCOMPARE(0, obj1.swapInterval()); + obj1.setSwapInterval(TEST_INT_MIN); + QCOMPARE(TEST_INT_MIN, obj1.swapInterval()); + obj1.setSwapInterval(-1); + QCOMPARE(-1, obj1.swapInterval()); + obj1.setSwapInterval(TEST_INT_MAX); + QCOMPARE(TEST_INT_MAX, obj1.swapInterval()); // bool QGLFormat::doubleBuffer() // void QGLFormat::setDoubleBuffer(bool) + QCOMPARE(true, obj1.doubleBuffer()); + QVERIFY(obj1.testOption(QGL::DoubleBuffer)); + QVERIFY(!obj1.testOption(QGL::SingleBuffer)); obj1.setDoubleBuffer(false); QCOMPARE(false, obj1.doubleBuffer()); + QVERIFY(!obj1.testOption(QGL::DoubleBuffer)); + QVERIFY(obj1.testOption(QGL::SingleBuffer)); obj1.setDoubleBuffer(true); QCOMPARE(true, obj1.doubleBuffer()); + QVERIFY(obj1.testOption(QGL::DoubleBuffer)); + QVERIFY(!obj1.testOption(QGL::SingleBuffer)); // bool QGLFormat::depth() // void QGLFormat::setDepth(bool) + QCOMPARE(true, obj1.depth()); + QVERIFY(obj1.testOption(QGL::DepthBuffer)); + QVERIFY(!obj1.testOption(QGL::NoDepthBuffer)); obj1.setDepth(false); QCOMPARE(false, obj1.depth()); + QVERIFY(!obj1.testOption(QGL::DepthBuffer)); + QVERIFY(obj1.testOption(QGL::NoDepthBuffer)); obj1.setDepth(true); QCOMPARE(true, obj1.depth()); + QVERIFY(obj1.testOption(QGL::DepthBuffer)); + QVERIFY(!obj1.testOption(QGL::NoDepthBuffer)); // bool QGLFormat::rgba() // void QGLFormat::setRgba(bool) + QCOMPARE(true, obj1.rgba()); + QVERIFY(obj1.testOption(QGL::Rgba)); + QVERIFY(!obj1.testOption(QGL::ColorIndex)); obj1.setRgba(false); QCOMPARE(false, obj1.rgba()); + QVERIFY(!obj1.testOption(QGL::Rgba)); + QVERIFY(obj1.testOption(QGL::ColorIndex)); obj1.setRgba(true); QCOMPARE(true, obj1.rgba()); + QVERIFY(obj1.testOption(QGL::Rgba)); + QVERIFY(!obj1.testOption(QGL::ColorIndex)); // bool QGLFormat::alpha() // void QGLFormat::setAlpha(bool) + QVERIFY(obj1.testOption(QGL::AlphaChannel)); + QVERIFY(!obj1.testOption(QGL::NoAlphaChannel)); obj1.setAlpha(false); QCOMPARE(false, obj1.alpha()); + QVERIFY(!obj1.testOption(QGL::AlphaChannel)); + QVERIFY(obj1.testOption(QGL::NoAlphaChannel)); obj1.setAlpha(true); QCOMPARE(true, obj1.alpha()); + QVERIFY(obj1.testOption(QGL::AlphaChannel)); + QVERIFY(!obj1.testOption(QGL::NoAlphaChannel)); // bool QGLFormat::accum() // void QGLFormat::setAccum(bool) + QCOMPARE(false, obj1.accum()); + QVERIFY(!obj1.testOption(QGL::AccumBuffer)); + QVERIFY(obj1.testOption(QGL::NoAccumBuffer)); obj1.setAccum(false); QCOMPARE(false, obj1.accum()); + QVERIFY(!obj1.testOption(QGL::AccumBuffer)); + QVERIFY(obj1.testOption(QGL::NoAccumBuffer)); obj1.setAccum(true); QCOMPARE(true, obj1.accum()); + QVERIFY(obj1.testOption(QGL::AccumBuffer)); + QVERIFY(!obj1.testOption(QGL::NoAccumBuffer)); // bool QGLFormat::stencil() // void QGLFormat::setStencil(bool) + QCOMPARE(true, obj1.stencil()); + QVERIFY(obj1.testOption(QGL::StencilBuffer)); + QVERIFY(!obj1.testOption(QGL::NoStencilBuffer)); obj1.setStencil(false); QCOMPARE(false, obj1.stencil()); + QVERIFY(!obj1.testOption(QGL::StencilBuffer)); + QVERIFY(obj1.testOption(QGL::NoStencilBuffer)); obj1.setStencil(true); QCOMPARE(true, obj1.stencil()); + QVERIFY(obj1.testOption(QGL::StencilBuffer)); + QVERIFY(!obj1.testOption(QGL::NoStencilBuffer)); // bool QGLFormat::stereo() // void QGLFormat::setStereo(bool) + QCOMPARE(false, obj1.stereo()); + QVERIFY(!obj1.testOption(QGL::StereoBuffers)); + QVERIFY(obj1.testOption(QGL::NoStereoBuffers)); obj1.setStereo(false); QCOMPARE(false, obj1.stereo()); + QVERIFY(!obj1.testOption(QGL::StereoBuffers)); + QVERIFY(obj1.testOption(QGL::NoStereoBuffers)); obj1.setStereo(true); QCOMPARE(true, obj1.stereo()); + QVERIFY(obj1.testOption(QGL::StereoBuffers)); + QVERIFY(!obj1.testOption(QGL::NoStereoBuffers)); // bool QGLFormat::directRendering() // void QGLFormat::setDirectRendering(bool) + QCOMPARE(true, obj1.directRendering()); + QVERIFY(obj1.testOption(QGL::DirectRendering)); + QVERIFY(!obj1.testOption(QGL::IndirectRendering)); obj1.setDirectRendering(false); QCOMPARE(false, obj1.directRendering()); + QVERIFY(!obj1.testOption(QGL::DirectRendering)); + QVERIFY(obj1.testOption(QGL::IndirectRendering)); obj1.setDirectRendering(true); QCOMPARE(true, obj1.directRendering()); + QVERIFY(obj1.testOption(QGL::DirectRendering)); + QVERIFY(!obj1.testOption(QGL::IndirectRendering)); + + // bool QGLFormat::overlay() + // void QGLFormat::setOverlay(bool) + QCOMPARE(false, obj1.hasOverlay()); + QVERIFY(!obj1.testOption(QGL::HasOverlay)); + QVERIFY(obj1.testOption(QGL::NoOverlay)); + obj1.setOverlay(false); + QCOMPARE(false, obj1.hasOverlay()); + QVERIFY(!obj1.testOption(QGL::HasOverlay)); + QVERIFY(obj1.testOption(QGL::NoOverlay)); + obj1.setOverlay(true); + QCOMPARE(true, obj1.hasOverlay()); + QVERIFY(obj1.testOption(QGL::HasOverlay)); + QVERIFY(!obj1.testOption(QGL::NoOverlay)); // int QGLFormat::plane() // void QGLFormat::setPlane(int) + QCOMPARE(0, obj1.plane()); obj1.setPlane(0); QCOMPARE(0, obj1.plane()); - obj1.setPlane(INT_MIN); - QCOMPARE(INT_MIN, obj1.plane()); - obj1.setPlane(INT_MAX); - QCOMPARE(INT_MAX, obj1.plane()); + obj1.setPlane(TEST_INT_MIN); + QCOMPARE(TEST_INT_MIN, obj1.plane()); + obj1.setPlane(TEST_INT_MAX); + QCOMPARE(TEST_INT_MAX, obj1.plane()); MyGLContext obj2(obj1); // bool QGLContext::windowCreated() -- cgit v0.12 From 5246aeb198ccfd2a3fc94298161c24cb8f57f81f Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 30 Jul 2009 14:50:39 +1000 Subject: Unit tests and bug fixes for QGLColormap QGLColormap::setEntry() was inserting entries instead of replacing them; QGLColormap::setEntries() had an incorrect assert and weird behaviour for the "base". The documentation for QGLColormap::isEmpty() has been updated to reflect that it will also report empty if the colormap has not been set on a QGLWidget even if it has entries in it. This behaviour is required by existing code. Reviewed-by: Rohan McGovern --- src/opengl/qglcolormap.cpp | 24 ++++++--- tests/auto/qgl/tst_qgl.cpp | 121 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 7 deletions(-) diff --git a/src/opengl/qglcolormap.cpp b/src/opengl/qglcolormap.cpp index 426e090..481089a 100644 --- a/src/opengl/qglcolormap.cpp +++ b/src/opengl/qglcolormap.cpp @@ -174,13 +174,14 @@ void QGLColormap::setEntry(int idx, QRgb color) detach(); if (!d->cells) d->cells = new QVector(256); - d->cells->insert(idx, color); + d->cells->replace(idx, color); } /*! Set an array of cells in this colormap. \a count is the number of colors that should be set, \a colors is the array of colors, and - \a base is the starting index. + \a base is the starting index. The first element in \a colors + is set at \a base in the colormap. */ void QGLColormap::setEntries(int count, const QRgb *colors, int base) { @@ -188,10 +189,10 @@ void QGLColormap::setEntries(int count, const QRgb *colors, int base) if (!d->cells) d->cells = new QVector(256); - Q_ASSERT_X(!colors || base >= 0 || base + count < d->cells->size(), "QGLColormap::setEntries", + Q_ASSERT_X(colors && base >= 0 && (base + count) <= d->cells->size(), "QGLColormap::setEntries", "preconditions not met"); - for (int i = base; i < base + count; ++i) - setEntry(i, colors[i]); + for (int i = 0; i < count; ++i) + setEntry(base + i, colors[i]); } /*! @@ -227,8 +228,17 @@ QColor QGLColormap::entryColor(int idx) const } /*! - Returns true if the colormap is empty; otherwise returns false. A - colormap with no color values set is considered to be empty. + Returns true if the colormap is empty or it is not in use + by a QGLWidget; otherwise returns false. + + A colormap with no color values set is considered to be empty. + For historical reasons, a colormap that has color values set + but which is not in use by a QGLWidget is also considered empty. + + Compare size() with zero to determine if the colormap is empty + regardless of whether it is in use by a QGLWidget or not. + + \sa size() */ bool QGLColormap::isEmpty() const { diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 6ac1739..31c4a3c 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,7 @@ private slots: void graphicsViewClipping(); void partialGLWidgetUpdates_data(); void partialGLWidgetUpdates(); + void colormap(); }; tst_QGL::tst_QGL() @@ -623,5 +625,124 @@ void tst_QGL::partialGLWidgetUpdates() QCOMPARE(widget.paintEventRegion, QRegion(widget.rect())); } +class ColormapExtended : public QGLColormap +{ +public: + ColormapExtended() {} + + Qt::HANDLE handle() { return QGLColormap::handle(); } + void setHandle(Qt::HANDLE handle) { QGLColormap::setHandle(handle); } +}; + +void tst_QGL::colormap() +{ + // Check the properties of the default empty colormap. + QGLColormap cmap1; + QVERIFY(cmap1.isEmpty()); + QCOMPARE(cmap1.size(), 0); + QVERIFY(cmap1.entryRgb(0) == 0); + QVERIFY(cmap1.entryRgb(-1) == 0); + QVERIFY(cmap1.entryRgb(100) == 0); + QVERIFY(!cmap1.entryColor(0).isValid()); + QVERIFY(!cmap1.entryColor(-1).isValid()); + QVERIFY(!cmap1.entryColor(100).isValid()); + QCOMPARE(cmap1.find(qRgb(255, 0, 0)), -1); + QCOMPARE(cmap1.findNearest(qRgb(255, 0, 0)), -1); + + // Set an entry and re-test. + cmap1.setEntry(56, qRgb(255, 0, 0)); + // The colormap is still considered "empty" even though it + // has entries in it now. The isEmpty() method is used to + // detect when the colormap is in use by a GL widget, + // not to detect when it is empty! + QVERIFY(cmap1.isEmpty()); + QCOMPARE(cmap1.size(), 256); + QVERIFY(cmap1.entryRgb(0) == 0); + QVERIFY(cmap1.entryColor(0) == QColor(0, 0, 0, 255)); + QVERIFY(cmap1.entryRgb(56) == qRgb(255, 0, 0)); + QVERIFY(cmap1.entryColor(56) == QColor(255, 0, 0, 255)); + QCOMPARE(cmap1.find(qRgb(255, 0, 0)), 56); + QCOMPARE(cmap1.findNearest(qRgb(255, 0, 0)), 56); + + // Set some more entries. + static QRgb const colors[] = { + qRgb(255, 0, 0), + qRgb(0, 255, 0), + qRgb(255, 255, 255), + qRgb(0, 0, 255), + qRgb(0, 0, 0) + }; + cmap1.setEntry(57, QColor(0, 255, 0)); + cmap1.setEntries(3, colors + 2, 58); + cmap1.setEntries(5, colors, 251); + int idx; + for (idx = 0; idx < 5; ++idx) { + QVERIFY(cmap1.entryRgb(56 + idx) == colors[idx]); + QVERIFY(cmap1.entryColor(56 + idx) == QColor(colors[idx])); + QVERIFY(cmap1.entryRgb(251 + idx) == colors[idx]); + QVERIFY(cmap1.entryColor(251 + idx) == QColor(colors[idx])); + } + QCOMPARE(cmap1.size(), 256); + + // Perform color lookups. + QCOMPARE(cmap1.find(qRgb(255, 0, 0)), 56); + QCOMPARE(cmap1.find(qRgb(0, 0, 0)), 60); // Actually finds 0, 0, 0, 255. + QCOMPARE(cmap1.find(qRgba(0, 0, 0, 0)), 0); + QCOMPARE(cmap1.find(qRgb(0, 255, 0)), 57); + QCOMPARE(cmap1.find(qRgb(255, 255, 255)), 58); + QCOMPARE(cmap1.find(qRgb(0, 0, 255)), 59); + QCOMPARE(cmap1.find(qRgb(140, 0, 0)), -1); + QCOMPARE(cmap1.find(qRgb(0, 140, 0)), -1); + QCOMPARE(cmap1.find(qRgb(0, 0, 140)), -1); + QCOMPARE(cmap1.find(qRgb(64, 0, 0)), -1); + QCOMPARE(cmap1.find(qRgb(0, 64, 0)), -1); + QCOMPARE(cmap1.find(qRgb(0, 0, 64)), -1); + QCOMPARE(cmap1.findNearest(qRgb(255, 0, 0)), 56); + QCOMPARE(cmap1.findNearest(qRgb(0, 0, 0)), 60); + QCOMPARE(cmap1.findNearest(qRgba(0, 0, 0, 0)), 0); + QCOMPARE(cmap1.findNearest(qRgb(0, 255, 0)), 57); + QCOMPARE(cmap1.findNearest(qRgb(255, 255, 255)), 58); + QCOMPARE(cmap1.findNearest(qRgb(0, 0, 255)), 59); + QCOMPARE(cmap1.findNearest(qRgb(140, 0, 0)), 56); + QCOMPARE(cmap1.findNearest(qRgb(0, 140, 0)), 57); + QCOMPARE(cmap1.findNearest(qRgb(0, 0, 140)), 59); + QCOMPARE(cmap1.findNearest(qRgb(64, 0, 0)), 0); + QCOMPARE(cmap1.findNearest(qRgb(0, 64, 0)), 0); + QCOMPARE(cmap1.findNearest(qRgb(0, 0, 64)), 0); + + // Make some copies of the colormap and check that they are the same. + QGLColormap cmap2(cmap1); + QGLColormap cmap3; + cmap3 = cmap1; + QVERIFY(cmap2.isEmpty()); + QVERIFY(cmap3.isEmpty()); + QCOMPARE(cmap2.size(), 256); + QCOMPARE(cmap3.size(), 256); + for (idx = 0; idx < 256; ++idx) { + QCOMPARE(cmap1.entryRgb(idx), cmap2.entryRgb(idx)); + QCOMPARE(cmap1.entryRgb(idx), cmap3.entryRgb(idx)); + } + + // Modify an entry in one of the copies and recheck the original. + cmap2.setEntry(45, qRgb(255, 0, 0)); + for (idx = 0; idx < 256; ++idx) { + if (idx != 45) + QCOMPARE(cmap1.entryRgb(idx), cmap2.entryRgb(idx)); + else + QCOMPARE(cmap2.entryRgb(45), qRgb(255, 0, 0)); + QCOMPARE(cmap1.entryRgb(idx), cmap3.entryRgb(idx)); + } + + // Check that setting the handle will cause isEmpty() to work right. + ColormapExtended cmap4; + cmap4.setEntry(56, qRgb(255, 0, 0)); + QVERIFY(cmap4.isEmpty()); + QCOMPARE(cmap4.size(), 256); + cmap4.setHandle(Qt::HANDLE(42)); + QVERIFY(cmap4.handle() == Qt::HANDLE(42)); + QVERIFY(!cmap4.isEmpty()); + QCOMPARE(cmap4.size(), 256); +} + QTEST_MAIN(tst_QGL) #include "tst_qgl.moc" -- cgit v0.12 From a92117be4323e26efe3f13b5c624e5010a7cd26a Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 29 Jul 2009 17:26:37 +1000 Subject: Allow testlib loggers to dynamically allocate storage for strings. This enables very long failure messages (e.g. including an entire build log in a failure message). This change modifies only the plain test logger to use this feature. Task: 253861 Reviewed-by: Michael Goddard --- src/testlib/qabstracttestlogger_p.h | 36 +++++++++++ src/testlib/qplaintestlogger.cpp | 8 ++- src/testlib/qtest_global.h | 1 + src/testlib/qtestcase.cpp | 52 ++++++++++++++-- tests/auto/selftests/expected_longstring.txt | 16 +++++ tests/auto/selftests/longstring/longstring.pro | 10 +++ tests/auto/selftests/longstring/tst_longstring.cpp | 72 ++++++++++++++++++++++ tests/auto/selftests/selftests.pro | 2 +- tests/auto/selftests/selftests.qrc | 1 + tests/auto/selftests/tst_selftests.cpp | 1 + 10 files changed, 189 insertions(+), 10 deletions(-) create mode 100644 tests/auto/selftests/expected_longstring.txt create mode 100644 tests/auto/selftests/longstring/longstring.pro create mode 100644 tests/auto/selftests/longstring/tst_longstring.cpp diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h index a0e8a1e..588184e 100644 --- a/src/testlib/qabstracttestlogger_p.h +++ b/src/testlib/qabstracttestlogger_p.h @@ -99,6 +99,42 @@ public: static bool isTtyOutput(); }; +struct QTestCharBuffer +{ + inline QTestCharBuffer() + : buf(0) + {} + + inline ~QTestCharBuffer() + { + delete[] buf; + buf = 0; + } + + inline operator void*() + { + return buf; + } + + inline operator char*() + { + return buf; + } + + inline operator char**() + { + return &buf; + } + + inline const char* constData() const + { + return buf; + } + +private: + char* buf; +}; + QT_END_NAMESPACE #endif diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 071b55e..7bebaa1 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -168,7 +168,7 @@ namespace QTest { QTEST_ASSERT(type); QTEST_ASSERT(msg); - char buf[1024]; + QTestCharBuffer buf; const char *fn = QTestResult::currentTestFunction() ? QTestResult::currentTestFunction() : "UnknownTestFunc"; @@ -178,7 +178,7 @@ namespace QTest { : ""; const char *filler = (tag[0] && gtag[0]) ? ":" : ""; if (file) { - QTest::qt_snprintf(buf, sizeof(buf), "%s: %s::%s(%s%s%s)%s%s\n" + QTest::qt_asprintf(buf, "%s: %s::%s(%s%s%s)%s%s\n" #ifdef Q_OS_WIN "%s(%d) : failure location\n" #else @@ -187,10 +187,12 @@ namespace QTest { , type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag, msg[0] ? " " : "", msg, file, line); } else { - QTest::qt_snprintf(buf, sizeof(buf), "%s: %s::%s(%s%s%s)%s%s\n", + QTest::qt_asprintf(buf, "%s: %s::%s(%s%s%s)%s%s\n", type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag, msg[0] ? " " : "", msg); } + // In colored mode, printf above stripped our nonprintable control characters. + // Put them back. memcpy(buf, type, strlen(type)); outputMessage(buf); } diff --git a/src/testlib/qtest_global.h b/src/testlib/qtest_global.h index b5b0fc0..c40f0ad 100644 --- a/src/testlib/qtest_global.h +++ b/src/testlib/qtest_global.h @@ -82,6 +82,7 @@ namespace QTest enum TestFailMode { Abort = 1, Continue = 2 }; int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format, ...); + int qt_asprintf(char **str, const char *format, ...); } QT_END_NAMESPACE diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index cb05400..e44be9c 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -808,6 +808,50 @@ namespace QTest static int eventDelay = -1; static int keyVerbose = -1; +void filter_unprintable(char *str) +{ + char *idx = str; + while (*idx) { + if (((*idx < 0x20 && *idx != '\n' && *idx != '\t') || *idx > 0x7e)) + *idx = '?'; + ++idx; + } +} + +int qt_asprintf(char **str, const char *format, ...) +{ + static const int MAXSIZE = 1024*1024*2; + + int size = 32; + delete[] *str; + *str = new char[size]; + + va_list ap; + int res = 0; + + for (;;) { + va_start(ap, format); + res = qvsnprintf(*str, size, format, ap); + va_end(ap); + (*str)[size - 1] = '\0'; + if (res < size) { + // We succeeded or fatally failed + break; + } + // buffer wasn't big enough, try again + size *= 2; + if (size > MAXSIZE) { + break; + } + delete[] *str; + *str = new char[size]; + } + + filter_unprintable(*str); + + return res; +} + /*! \internal */ int qt_snprintf(char *str, int size, const char *format, ...) @@ -820,12 +864,8 @@ int qt_snprintf(char *str, int size, const char *format, ...) va_end(ap); str[size - 1] = '\0'; - char *idx = str; - while (*idx) { - if (((*idx < 0x20 && *idx != '\n' && *idx != '\t') || *idx > 0x7e)) - *idx = '?'; - ++idx; - } + filter_unprintable(str); + return res; } diff --git a/tests/auto/selftests/expected_longstring.txt b/tests/auto/selftests/expected_longstring.txt new file mode 100644 index 0000000..4abdb23 --- /dev/null +++ b/tests/auto/selftests/expected_longstring.txt @@ -0,0 +1,16 @@ +********* Start testing of tst_LongString ********* +Config: Using QTest library 4.6.0, Qt 4.6.0 +PASS : tst_LongString::initTestCase() +FAIL! : tst_LongString::failWithLongString() Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. + +Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. + +Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. + +Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis. + +Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam. Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. + Loc: [/home/rmcgover/depot/qt/master/tests/auto/selftests/longstring/tst_longstring.cpp(67)] +PASS : tst_LongString::cleanupTestCase() +Totals: 2 passed, 1 failed, 0 skipped +********* Finished testing of tst_LongString ********* diff --git a/tests/auto/selftests/longstring/longstring.pro b/tests/auto/selftests/longstring/longstring.pro new file mode 100644 index 0000000..b917481 --- /dev/null +++ b/tests/auto/selftests/longstring/longstring.pro @@ -0,0 +1,10 @@ +load(qttest_p4) +SOURCES += tst_longstring.cpp +QT = core + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + + +TARGET = longstring + diff --git a/tests/auto/selftests/longstring/tst_longstring.cpp b/tests/auto/selftests/longstring/tst_longstring.cpp new file mode 100644 index 0000000..a708fa7 --- /dev/null +++ b/tests/auto/selftests/longstring/tst_longstring.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include + +char const lipsum[] = +"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui.\n\n" +"Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia.\n\n" +"Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi.\n\n" +"Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis.\n\n" +"Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam. Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas." +; + +/*! + \internal + */ +class tst_LongString: public QObject +{ + Q_OBJECT + +private slots: + void failWithLongString() const; +}; + +void tst_LongString::failWithLongString() const +{ + QFAIL(lipsum); +} + +QTEST_MAIN(tst_LongString) + +#include "tst_longstring.moc" diff --git a/tests/auto/selftests/selftests.pro b/tests/auto/selftests/selftests.pro index 45de658..d854b5e 100644 --- a/tests/auto/selftests/selftests.pro +++ b/tests/auto/selftests/selftests.pro @@ -5,7 +5,7 @@ SUBDIRS = subtest test warnings maxwarnings cmptest globaldata skipglobal skip \ skipinit skipinitdata datetime singleskip assert waitwithoutgui differentexec \ exceptionthrow qexecstringlist datatable commandlinedata\ benchlibwalltime benchlibcallgrind benchlibeventcounter benchlibtickcounter \ - benchliboptions xunit badxml + benchliboptions xunit badxml longstring INSTALLS = diff --git a/tests/auto/selftests/selftests.qrc b/tests/auto/selftests/selftests.qrc index 3d78bf5..4b75405 100644 --- a/tests/auto/selftests/selftests.qrc +++ b/tests/auto/selftests/selftests.qrc @@ -36,5 +36,6 @@ expected_benchliboptions.txt expected_benchlibtickcounter.txt expected_xunit.txt + expected_longstring.txt diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 8eb7fe1..69b84e2 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -191,6 +191,7 @@ void tst_Selftests::runSubTest_data() #endif QTest::newRow("xunit") << "xunit" << QStringList("-xunitxml"); + QTest::newRow("longstring") << "longstring" << QStringList(); } -- cgit v0.12 From 79ed97b8298e3c7e3c7d266c905024affeba7258 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 30 Jul 2009 10:53:28 +1000 Subject: Make QTestBasicStreamer use dynamically allocated strings. This commit contains the bare minimum needed for the API to use dynamic allocation; some parts of the code still use static buffers and therefore have constraints on the size of output messages. Task: 253861 Reviewed-by: Michael Goddard --- src/testlib/qtestbasicstreamer.cpp | 24 ++++----- src/testlib/qtestbasicstreamer.h | 10 ++-- src/testlib/qtestlightxmlstreamer.cpp | 42 ++++++++-------- src/testlib/qtestlightxmlstreamer.h | 6 +-- src/testlib/qtestxmlstreamer.cpp | 28 +++++------ src/testlib/qtestxmlstreamer.h | 6 +-- src/testlib/qtestxunitstreamer.cpp | 34 ++++++------- src/testlib/qtestxunitstreamer.h | 8 +-- src/testlib/qxmltestlogger.cpp | 91 +++++++++++++++++++++++++++-------- src/testlib/qxmltestlogger_p.h | 6 ++- 10 files changed, 153 insertions(+), 102 deletions(-) diff --git a/src/testlib/qtestbasicstreamer.cpp b/src/testlib/qtestbasicstreamer.cpp index 5fe9d4d..aac57ba 100644 --- a/src/testlib/qtestbasicstreamer.cpp +++ b/src/testlib/qtestbasicstreamer.cpp @@ -68,39 +68,39 @@ QTestBasicStreamer::QTestBasicStreamer() QTestBasicStreamer::~QTestBasicStreamer() {} -void QTestBasicStreamer::formatStart(const QTestElement *element, char *formatted) const +void QTestBasicStreamer::formatStart(const QTestElement *element, char **formatted) const { if(!element || !formatted ) return; - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } -void QTestBasicStreamer::formatEnd(const QTestElement *element, char *formatted) const +void QTestBasicStreamer::formatEnd(const QTestElement *element, char **formatted) const { if(!element || !formatted ) return; - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } -void QTestBasicStreamer::formatBeforeAttributes(const QTestElement *element, char *formatted) const +void QTestBasicStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const { if(!element || !formatted ) return; - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } -void QTestBasicStreamer::formatAfterAttributes(const QTestElement *element, char *formatted) const +void QTestBasicStreamer::formatAfterAttributes(const QTestElement *element, char **formatted) const { if(!element || !formatted ) return; - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } -void QTestBasicStreamer::formatAttributes(const QTestElement *, const QTestElementAttribute *attribute, char *formatted) const +void QTestBasicStreamer::formatAttributes(const QTestElement *, const QTestElementAttribute *attribute, char **formatted) const { if(!attribute || !formatted ) return; - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } void QTestBasicStreamer::output(QTestElement *element) const @@ -113,7 +113,7 @@ void QTestBasicStreamer::output(QTestElement *element) const void QTestBasicStreamer::outputElements(QTestElement *element, bool) const { - char buf[1024]; + QTestCharBuffer buf; bool hasChildren; /* Elements are in reverse order of occurrence, so start from the end and work @@ -148,7 +148,7 @@ void QTestBasicStreamer::outputElements(QTestElement *element, bool) const void QTestBasicStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const { - char buf[1024]; + QTestCharBuffer buf; while(attribute){ formatAttributes(element, attribute, buf); outputString(buf); diff --git a/src/testlib/qtestbasicstreamer.h b/src/testlib/qtestbasicstreamer.h index 84d1bce..432dd22 100644 --- a/src/testlib/qtestbasicstreamer.h +++ b/src/testlib/qtestbasicstreamer.h @@ -71,11 +71,11 @@ class QTestBasicStreamer const QTestLogger *logger() const; protected: - virtual void formatStart(const QTestElement *element = 0, char *formatted = 0) const; - virtual void formatEnd(const QTestElement *element = 0, char *formatted = 0) const; - virtual void formatBeforeAttributes(const QTestElement *element = 0, char *formatted = 0) const; - virtual void formatAfterAttributes(const QTestElement *element = 0, char *formatted = 0) const; - virtual void formatAttributes(const QTestElement *element = 0, const QTestElementAttribute *attribute = 0, char *formatted = 0) const; + virtual void formatStart(const QTestElement *element, char **formatted) const; + virtual void formatEnd(const QTestElement *element, char **formatted) const; + virtual void formatBeforeAttributes(const QTestElement *element, char **formatted) const; + virtual void formatAfterAttributes(const QTestElement *element, char **formatted) const; + virtual void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, char **formatted) const; virtual void outputElements(QTestElement *element, bool isChildElement = false) const; virtual void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const; diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp index 170938a..a7e205a 100644 --- a/src/testlib/qtestlightxmlstreamer.cpp +++ b/src/testlib/qtestlightxmlstreamer.cpp @@ -59,7 +59,7 @@ QTestLightXmlStreamer::QTestLightXmlStreamer() QTestLightXmlStreamer::~QTestLightXmlStreamer() {} -void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *formatted) const +void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **formatted) const { if(!element || !formatted) return; @@ -70,7 +70,7 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *forma QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name), sizeof(quotedTf)); - QTest::qt_snprintf(formatted, 1024, "\n", quotedTf); + QTest::qt_asprintf(formatted, "\n", quotedTf); break; } case QTest::LET_Failure: { @@ -78,7 +78,7 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *forma QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description), sizeof(cdataDesc)); - QTest::qt_snprintf(formatted, 1024, " \n", + QTest::qt_asprintf(formatted, " \n", cdataDesc); break; } @@ -91,7 +91,7 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *forma QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description), sizeof(cdataDesc)); - QTest::qt_snprintf(formatted, 1024, "\n \n\n", + QTest::qt_asprintf(formatted, "\n \n\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), quotedFile, @@ -109,7 +109,7 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *forma QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag), sizeof(quotedTag)); - QTest::qt_snprintf(formatted, 1024, "\n", + QTest::qt_asprintf(formatted, "\n", element->attributeName(QTest::AI_Metric), quotedMetric, element->attributeName(QTest::AI_Tag), @@ -121,61 +121,61 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *forma break; } default: - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } } -void QTestLightXmlStreamer::formatEnd(const QTestElement *element, char *formatted) const +void QTestLightXmlStreamer::formatEnd(const QTestElement *element, char **formatted) const { if(!element || !formatted) return; if (element->elementType() == QTest::LET_TestCase) { if( element->attribute(QTest::AI_Result) && element->childElements()) - QTest::qt_snprintf(formatted, 1024, "\n\n"); + QTest::qt_asprintf(formatted, "\n\n"); else - QTest::qt_snprintf(formatted, 1024, "\n"); + QTest::qt_asprintf(formatted, "\n"); } else - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } -void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, char *formatted) const +void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const { if(!element || !formatted) return; if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){ - char buf[900]; + QTestCharBuffer buf; char quotedFile[700]; QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File), sizeof(quotedFile)); - QTest::qt_snprintf(buf, sizeof(buf), "%s=\"%s\" %s=\"%s\"", + QTest::qt_asprintf(buf, "%s=\"%s\" %s=\"%s\"", element->attributeName(QTest::AI_File), quotedFile, element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line)); if( !element->childElements() ) - QTest::qt_snprintf(formatted, 1024, "\n", - element->attributeValue(QTest::AI_Result), buf); + QTest::qt_asprintf(formatted, "\n", + element->attributeValue(QTest::AI_Result), buf.constData()); else - QTest::qt_snprintf(formatted, 1024, "\n", - element->attributeValue(QTest::AI_Result), buf); + QTest::qt_asprintf(formatted, "\n", + element->attributeValue(QTest::AI_Result), buf.constData()); }else{ - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } } void QTestLightXmlStreamer::output(QTestElement *element) const { - char buf[1024]; - QTest::qt_snprintf(buf, sizeof(buf), "\n %s\n %s\n", + QTestCharBuffer buf; + QTest::qt_asprintf(buf, "\n %s\n %s\n", qVersion(), QTEST_VERSION_STR ); outputString(buf); - QTest::qt_snprintf(buf, sizeof(buf), "\n"); + QTest::qt_asprintf(buf, "\n"); outputString(buf); QTestBasicStreamer::output(element); diff --git a/src/testlib/qtestlightxmlstreamer.h b/src/testlib/qtestlightxmlstreamer.h index 5a16327..6dafdcc 100644 --- a/src/testlib/qtestlightxmlstreamer.h +++ b/src/testlib/qtestlightxmlstreamer.h @@ -59,9 +59,9 @@ class QTestLightXmlStreamer: public QTestBasicStreamer QTestLightXmlStreamer(); ~QTestLightXmlStreamer(); - void formatStart(const QTestElement *element = 0, char *formatted = 0) const; - void formatEnd(const QTestElement *element = 0, char *formatted = 0) const; - void formatBeforeAttributes(const QTestElement *element = 0, char *formatted = 0) const; + void formatStart(const QTestElement *element, char **formatted) const; + void formatEnd(const QTestElement *element, char **formatted) const; + void formatBeforeAttributes(const QTestElement *element, char **formatted) const; void output(QTestElement *element) const; }; diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp index 5172bcd..b9e0a38 100644 --- a/src/testlib/qtestxmlstreamer.cpp +++ b/src/testlib/qtestxmlstreamer.cpp @@ -60,7 +60,7 @@ QTestXmlStreamer::QTestXmlStreamer() QTestXmlStreamer::~QTestXmlStreamer() {} -void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted) const +void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted) const { if(!element || !formatted) return; @@ -71,7 +71,7 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted) QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name), sizeof(quotedTf)); - QTest::qt_snprintf(formatted, 1024, "\n", quotedTf); + QTest::qt_asprintf(formatted, "\n", quotedTf); break; } case QTest::LET_Failure: { @@ -94,14 +94,14 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted) char cdataTag[100]; QXmlTestLogger::xmlCdata(cdataTag, element->attributeValue(QTest::AI_Tag), sizeof(cdataTag)); - QTest::qt_snprintf(formatted, 1024, "\n" + QTest::qt_asprintf(formatted, "\n" " \n" " \n" "\n", element->attributeValue(QTest::AI_Result), location, cdataTag, cdataDesc); } else { - QTest::qt_snprintf(formatted, 1024, "\n" + QTest::qt_asprintf(formatted, "\n" " \n" "\n", element->attributeValue(QTest::AI_Result), location, cdataDesc); @@ -117,7 +117,7 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted) QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description), sizeof(cdataDesc)); - QTest::qt_snprintf(formatted, 1024, "\n \n\n", + QTest::qt_asprintf(formatted, "\n \n\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), quotedFile, @@ -135,7 +135,7 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted) QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag), sizeof(quotedTag)); - QTest::qt_snprintf(formatted, 1024, "\n", + QTest::qt_asprintf(formatted, "\n", element->attributeName(QTest::AI_Metric), quotedMetric, element->attributeName(QTest::AI_Tag), @@ -147,23 +147,23 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted) break; } default: - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } } -void QTestXmlStreamer::formatEnd(const QTestElement *element, char *formatted) const +void QTestXmlStreamer::formatEnd(const QTestElement *element, char **formatted) const { if(!element || !formatted) return; if (element->elementType() == QTest::LET_TestCase) { - QTest::qt_snprintf(formatted, 1024, "\n"); + QTest::qt_asprintf(formatted, "\n"); } else - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } -void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char *formatted) const +void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const { if(!element || !formatted) return; @@ -181,14 +181,14 @@ void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char element->attributeValue(QTest::AI_Line)); if( !element->childElements() ) { - QTest::qt_snprintf(formatted, 1024, "\n", + QTest::qt_asprintf(formatted, "\n", element->attributeValue(QTest::AI_Result), buf); } else { - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } }else{ - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } } diff --git a/src/testlib/qtestxmlstreamer.h b/src/testlib/qtestxmlstreamer.h index 3cb1c60..a601f60 100644 --- a/src/testlib/qtestxmlstreamer.h +++ b/src/testlib/qtestxmlstreamer.h @@ -59,9 +59,9 @@ class QTestXmlStreamer: public QTestBasicStreamer QTestXmlStreamer(); ~QTestXmlStreamer(); - void formatStart(const QTestElement *element = 0, char *formatted = 0) const; - void formatEnd(const QTestElement *element = 0, char *formatted = 0) const; - void formatBeforeAttributes(const QTestElement *element = 0, char *formatted = 0) const; + void formatStart(const QTestElement *element, char **formatted) const; + void formatEnd(const QTestElement *element, char **formatted) const; + void formatBeforeAttributes(const QTestElement *element, char **formatted) const; void output(QTestElement *element) const; }; diff --git a/src/testlib/qtestxunitstreamer.cpp b/src/testlib/qtestxunitstreamer.cpp index 6690cec..f59c0f5 100644 --- a/src/testlib/qtestxunitstreamer.cpp +++ b/src/testlib/qtestxunitstreamer.cpp @@ -73,7 +73,7 @@ void QTestXunitStreamer::indentForElement(const QTestElement* element, char* buf } } -void QTestXunitStreamer::formatStart(const QTestElement *element, char *formatted) const +void QTestXunitStreamer::formatStart(const QTestElement *element, char **formatted) const { if(!element || !formatted ) return; @@ -84,34 +84,34 @@ void QTestXunitStreamer::formatStart(const QTestElement *element, char *formatte // Errors are written as CDATA within system-err, comments elsewhere if (element->elementType() == QTest::LET_Error) { if (element->parentElement()->elementType() == QTest::LET_SystemError) { - QTest::qt_snprintf(formatted, 1024, "elementName()); + QTest::qt_asprintf(formatted, "%s<%s", indent, element->elementName()); } -void QTestXunitStreamer::formatEnd(const QTestElement *element, char *formatted) const +void QTestXunitStreamer::formatEnd(const QTestElement *element, char **formatted) const { if(!element || !formatted ) return; if(!element->childElements()){ - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); return; } char indent[20]; indentForElement(element, indent, sizeof(indent)); - QTest::qt_snprintf(formatted, 1024, "%s\n", indent, element->elementName()); + QTest::qt_asprintf(formatted, "%s\n", indent, element->elementName()); } -void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, char *formatted) const +void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, char **formatted) const { if(!attribute || !formatted ) return; @@ -124,7 +124,7 @@ void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTe if (attrindex != QTest::AI_Description) return; - QXmlTestLogger::xmlCdata(formatted, attribute->value(), 1024); + QXmlTestLogger::xmlCdata(formatted, attribute->value()); return; } @@ -137,14 +137,14 @@ void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTe if (key) { char quotedValue[900]; QXmlTestLogger::xmlQuote(quotedValue, attribute->value(), sizeof(quotedValue)); - QTest::qt_snprintf(formatted, 1024, " %s=\"%s\"", key, quotedValue); + QTest::qt_asprintf(formatted, " %s=\"%s\"", key, quotedValue); } else { - QTest::qt_snprintf(formatted, 10, ""); + QTest::qt_asprintf(formatted, ""); } } -void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, char *formatted) const +void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, char **formatted) const { if(!element || !formatted ) return; @@ -152,18 +152,18 @@ void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, char // Errors are written as CDATA within system-err, comments elsewhere if (element->elementType() == QTest::LET_Error) { if (element->parentElement()->elementType() == QTest::LET_SystemError) { - QTest::qt_snprintf(formatted, 1024, "]]>\n"); + QTest::qt_asprintf(formatted, "]]>\n"); } else { - QTest::qt_snprintf(formatted, 1024, " -->\n"); + QTest::qt_asprintf(formatted, " -->\n"); } return; } if(!element->childElements()) - QTest::qt_snprintf(formatted, 10, "/>\n"); + QTest::qt_asprintf(formatted, "/>\n"); else - QTest::qt_snprintf(formatted, 10, ">\n"); + QTest::qt_asprintf(formatted, ">\n"); } void QTestXunitStreamer::output(QTestElement *element) const @@ -176,7 +176,7 @@ void QTestXunitStreamer::output(QTestElement *element) const void QTestXunitStreamer::outputElements(QTestElement *element, bool) const { - char buf[1024]; + QTestCharBuffer buf; bool hasChildren; /* Elements are in reverse order of occurrence, so start from the end and work diff --git a/src/testlib/qtestxunitstreamer.h b/src/testlib/qtestxunitstreamer.h index 9817fd3..044307f 100644 --- a/src/testlib/qtestxunitstreamer.h +++ b/src/testlib/qtestxunitstreamer.h @@ -58,10 +58,10 @@ class QTestXunitStreamer: public QTestBasicStreamer QTestXunitStreamer(); ~QTestXunitStreamer(); - void formatStart(const QTestElement *element = 0, char *formatted = 0) const; - void formatEnd(const QTestElement *element = 0, char *formatted = 0) const; - void formatAfterAttributes(const QTestElement *element = 0, char *formatted = 0) const; - void formatAttributes(const QTestElement *element = 0, const QTestElementAttribute *attribute = 0, char *formatted = 0) const; + void formatStart(const QTestElement *element, char **formatted) const; + void formatEnd(const QTestElement *element, char **formatted) const; + void formatAfterAttributes(const QTestElement *element, char **formatted) const; + void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, char **formatted) const; void output(QTestElement *element) const; void outputElements(QTestElement *element, bool isChildElement = false) const; diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index 85eb0dd..8fc8dd9 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -294,29 +294,30 @@ void QXmlTestLogger::addMessage(MessageTypes type, const char *message, XML characters as necessary so that dest is suitable for use in an XML quoted attribute string. */ -void QXmlTestLogger::xmlQuote(char* dest, char const* src, size_t n) +int QXmlTestLogger::xmlQuote(char* dest, char const* src, size_t n) { - if (n == 0) return; + if (n == 0) return 0; *dest = 0; - if (!src) return; + if (!src) return 0; + char* begin = dest; char* end = dest + n; while (dest < end) { switch (*src) { #define MAP_ENTITY(chr, ent) \ - case chr: \ - if (dest + sizeof(ent) < end) { \ - strcpy(dest, ent); \ - dest += sizeof(ent) - 1; \ - } \ - else { \ - *dest = 0; \ - return; \ - } \ - ++src; \ + case chr: \ + if (dest + sizeof(ent) < end) { \ + strcpy(dest, ent); \ + dest += sizeof(ent) - 1; \ + } \ + else { \ + *dest = 0; \ + return (dest+sizeof(ent)-begin); \ + } \ + ++src; \ break; MAP_ENTITY('>', ">"); @@ -333,7 +334,7 @@ void QXmlTestLogger::xmlQuote(char* dest, char const* src, size_t n) case 0: *dest = 0; - return; + return (dest-begin); default: *dest = *src; @@ -345,29 +346,31 @@ void QXmlTestLogger::xmlQuote(char* dest, char const* src, size_t n) // If we get here, dest was completely filled (dest == end) *(dest-1) = 0; + return (dest-begin); } /* Copy up to n characters from the src string into dest, escaping any special strings such that dest is suitable for use in an XML CDATA section. */ -void QXmlTestLogger::xmlCdata(char* dest, char const* src, size_t n) +int QXmlTestLogger::xmlCdata(char* dest, char const* src, size_t n) { - if (!n) return; + if (!n) return 0; if (!src || n == 1) { *dest = 0; - return; + return 0; } - char const CDATA_END[] = "]]>"; - char const CDATA_END_ESCAPED[] = "]]]>"; + static char const CDATA_END[] = "]]>"; + static char const CDATA_END_ESCAPED[] = "]]]>"; + char* begin = dest; char* end = dest + n; while (dest < end) { if (!*src) { *dest = 0; - return; + return (dest-begin); } if (!strncmp(src, CDATA_END, sizeof(CDATA_END)-1)) { @@ -378,7 +381,7 @@ void QXmlTestLogger::xmlCdata(char* dest, char const* src, size_t n) } else { *dest = 0; - return; + return (dest+sizeof(CDATA_END_ESCAPED)-begin); } continue; } @@ -390,6 +393,52 @@ void QXmlTestLogger::xmlCdata(char* dest, char const* src, size_t n) // If we get here, dest was completely filled (dest == end) *(dest-1) = 0; + return (dest-begin); +} + +typedef int (*StringFormatFunction)(char*,char const*,size_t); + +/* + A wrapper for string functions written to work with a fixed size buffer so they can be called + with a dynamically allocated buffer. +*/ +int allocateStringFn(char** str, char const* src, StringFormatFunction func) +{ + static const int MAXSIZE = 1024*1024*2; + + int size = 32; + delete[] *str; + *str = new char[size]; + + int res = 0; + + for (;;) { + res = func(*str, src, size); + (*str)[size - 1] = '\0'; + if (res < size) { + // We succeeded or fatally failed + break; + } + // buffer wasn't big enough, try again + size *= 2; + if (size > MAXSIZE) { + break; + } + delete[] *str; + *str = new char[size]; + } + + return res; +} + +int QXmlTestLogger::xmlQuote(char** str, char const* src) +{ + return allocateStringFn(str, src, QXmlTestLogger::xmlQuote); +} + +int QXmlTestLogger::xmlCdata(char** str, char const* src) +{ + return allocateStringFn(str, src, QXmlTestLogger::xmlCdata); } QT_END_NAMESPACE diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h index 526b471..a7cc00a 100644 --- a/src/testlib/qxmltestlogger_p.h +++ b/src/testlib/qxmltestlogger_p.h @@ -79,8 +79,10 @@ public: void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0); - static void xmlCdata(char* dest, char const* src, size_t n); - static void xmlQuote(char* dest, char const* src, size_t n); + static int xmlCdata(char** dest, char const* src); + static int xmlQuote(char** dest, char const* src); + static int xmlCdata(char* dest, char const* src, size_t n); + static int xmlQuote(char* dest, char const* src, size_t n); private: XmlMode xmlmode; -- cgit v0.12 From c1a90a535206e0a146e13c60d981a855178e69ca Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 30 Jul 2009 11:15:39 +1000 Subject: Convert all testlib loggers to use dynamically allocated strings. Most log elements in all loggers can now be of (more or less) arbitrary length. Selftests pass and are memcheck-clean. The increase in heap usage seems negligible (it's below the default minimum threshold of massif). Task: 253861 Reviewed-by: Michael Goddard --- src/testlib/qtestlightxmlstreamer.cpp | 49 ++++++++---------- src/testlib/qtestxmlstreamer.cpp | 89 +++++++++++++++----------------- src/testlib/qtestxunitstreamer.cpp | 10 ++-- src/testlib/qxmltestlogger.cpp | 96 +++++++++++++++++------------------ 4 files changed, 112 insertions(+), 132 deletions(-) diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp index a7e205a..e176201 100644 --- a/src/testlib/qtestlightxmlstreamer.cpp +++ b/src/testlib/qtestlightxmlstreamer.cpp @@ -66,54 +66,48 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **form switch(element->elementType()){ case QTest::LET_TestCase: { - char quotedTf[950]; - QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name), - sizeof(quotedTf)); + QTestCharBuffer quotedTf; + QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name)); - QTest::qt_asprintf(formatted, "\n", quotedTf); + QTest::qt_asprintf(formatted, "\n", quotedTf.constData()); break; } case QTest::LET_Failure: { - char cdataDesc[900]; - QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description), - sizeof(cdataDesc)); + QTestCharBuffer cdataDesc; + QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description)); QTest::qt_asprintf(formatted, " \n", - cdataDesc); + cdataDesc.constData()); break; } case QTest::LET_Error: { // assuming type and attribute names don't need quoting - char quotedFile[128]; - char cdataDesc[700]; - QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File), - sizeof(quotedFile)); - QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description), - sizeof(cdataDesc)); + QTestCharBuffer quotedFile; + QTestCharBuffer cdataDesc; + QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File)); + QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description)); QTest::qt_asprintf(formatted, "\n \n\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), - quotedFile, + quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line), - cdataDesc); + cdataDesc.constData()); break; } case QTest::LET_Benchmark: { // assuming value and iterations don't need quoting - char quotedMetric[256]; - char quotedTag[256]; - QXmlTestLogger::xmlQuote(quotedMetric, element->attributeValue(QTest::AI_Metric), - sizeof(quotedMetric)); - QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag), - sizeof(quotedTag)); + QTestCharBuffer quotedMetric; + QTestCharBuffer quotedTag; + QXmlTestLogger::xmlQuote(quotedMetric, element->attributeValue(QTest::AI_Metric)); + QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag)); QTest::qt_asprintf(formatted, "\n", element->attributeName(QTest::AI_Metric), - quotedMetric, + quotedMetric.constData(), element->attributeName(QTest::AI_Tag), - quotedTag, + quotedTag.constData(), element->attributeName(QTest::AI_Value), element->attributeValue(QTest::AI_Value), element->attributeName(QTest::AI_Iterations), @@ -147,13 +141,12 @@ void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){ QTestCharBuffer buf; - char quotedFile[700]; - QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File), - sizeof(quotedFile)); + QTestCharBuffer quotedFile; + QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File)); QTest::qt_asprintf(buf, "%s=\"%s\" %s=\"%s\"", element->attributeName(QTest::AI_File), - quotedFile, + quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line)); diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp index b9e0a38..1b6e674 100644 --- a/src/testlib/qtestxmlstreamer.cpp +++ b/src/testlib/qtestxmlstreamer.cpp @@ -67,79 +67,71 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted switch(element->elementType()){ case QTest::LET_TestCase: { - char quotedTf[950]; - QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name), - sizeof(quotedTf)); + QTestCharBuffer quotedTf; + QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name)); - QTest::qt_asprintf(formatted, "\n", quotedTf); + QTest::qt_asprintf(formatted, "\n", quotedTf.constData()); break; } case QTest::LET_Failure: { - char cdataDesc[800]; - QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description), - sizeof(cdataDesc)); + QTestCharBuffer cdataDesc; + QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description)); - char location[100]; - char quotedFile[70]; - QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File), - sizeof(quotedFile)); + QTestCharBuffer location; + QTestCharBuffer quotedFile; + QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File)); - QTest::qt_snprintf(location, sizeof(location), "%s=\"%s\" %s=\"%s\"", + QTest::qt_asprintf(location, "%s=\"%s\" %s=\"%s\"", element->attributeName(QTest::AI_File), - quotedFile, + quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line)); if (element->attribute(QTest::AI_Tag)) { - char cdataTag[100]; - QXmlTestLogger::xmlCdata(cdataTag, element->attributeValue(QTest::AI_Tag), - sizeof(cdataTag)); + QTestCharBuffer cdataTag; + QXmlTestLogger::xmlCdata(cdataTag, element->attributeValue(QTest::AI_Tag)); QTest::qt_asprintf(formatted, "\n" " \n" " \n" "\n", element->attributeValue(QTest::AI_Result), - location, cdataTag, cdataDesc); + location.constData(), cdataTag.constData(), cdataDesc.constData()); } else { QTest::qt_asprintf(formatted, "\n" " \n" "\n", element->attributeValue(QTest::AI_Result), - location, cdataDesc); + location.constData(), cdataDesc.constData()); } break; } case QTest::LET_Error: { // assuming type and attribute names don't need quoting - char quotedFile[128]; - char cdataDesc[700]; - QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File), - sizeof(quotedFile)); - QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description), - sizeof(cdataDesc)); + QTestCharBuffer quotedFile; + QTestCharBuffer cdataDesc; + QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File)); + QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description)); QTest::qt_asprintf(formatted, "\n \n\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), - quotedFile, + quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line), - cdataDesc); + cdataDesc.constData()); break; } case QTest::LET_Benchmark: { // assuming value and iterations don't need quoting - char quotedMetric[256]; - char quotedTag[256]; - QXmlTestLogger::xmlQuote(quotedMetric, element->attributeValue(QTest::AI_Metric), - sizeof(quotedMetric)); - QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag), - sizeof(quotedTag)); + QTestCharBuffer quotedMetric; + QTestCharBuffer quotedTag; + QXmlTestLogger::xmlQuote(quotedMetric, element->attributeValue(QTest::AI_Metric)); + QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag)); QTest::qt_asprintf(formatted, "\n", element->attributeName(QTest::AI_Metric), - quotedMetric, + quotedMetric.constData(), element->attributeName(QTest::AI_Tag), - quotedTag, + quotedTag.constData(), element->attributeName(QTest::AI_Value), element->attributeValue(QTest::AI_Value), element->attributeName(QTest::AI_Iterations), @@ -169,20 +161,19 @@ void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char return; if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){ - char buf[900]; - char quotedFile[700]; - QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File), - sizeof(quotedFile)); + QTestCharBuffer buf; + QTestCharBuffer quotedFile; + QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File)); - QTest::qt_snprintf(buf, sizeof(buf), "%s=\"%s\" %s=\"%s\"", + QTest::qt_asprintf(buf, "%s=\"%s\" %s=\"%s\"", element->attributeName(QTest::AI_File), - quotedFile, + quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line)); if( !element->childElements() ) { QTest::qt_asprintf(formatted, "\n", - element->attributeValue(QTest::AI_Result), buf); + element->attributeValue(QTest::AI_Result), buf.constData()); } else { QTest::qt_asprintf(formatted, ""); @@ -194,24 +185,24 @@ void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char void QTestXmlStreamer::output(QTestElement *element) const { - char buf[1024]; - char quotedTc[800]; - QXmlTestLogger::xmlQuote(quotedTc, QTestResult::currentTestObjectName(), sizeof(quotedTc)); + QTestCharBuffer buf; + QTestCharBuffer quotedTc; + QXmlTestLogger::xmlQuote(quotedTc, QTestResult::currentTestObjectName()); - QTest::qt_snprintf(buf, sizeof(buf), "\n\n", - quotedTc); + QTest::qt_asprintf(buf, "\n\n", + quotedTc.constData()); outputString(buf); - QTest::qt_snprintf(buf, sizeof(buf), "\n %s\n %s\n", + QTest::qt_asprintf(buf, "\n %s\n %s\n", qVersion(), QTEST_VERSION_STR ); outputString(buf); - QTest::qt_snprintf(buf, sizeof(buf), "\n"); + QTest::qt_asprintf(buf, "\n"); outputString(buf); QTestBasicStreamer::output(element); - QTest::qt_snprintf(buf, sizeof(buf), "\n"); + QTest::qt_asprintf(buf, "\n"); outputString(buf); } diff --git a/src/testlib/qtestxunitstreamer.cpp b/src/testlib/qtestxunitstreamer.cpp index f59c0f5..d5d2631 100644 --- a/src/testlib/qtestxunitstreamer.cpp +++ b/src/testlib/qtestxunitstreamer.cpp @@ -135,9 +135,9 @@ void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTe key = attribute->name(); if (key) { - char quotedValue[900]; - QXmlTestLogger::xmlQuote(quotedValue, attribute->value(), sizeof(quotedValue)); - QTest::qt_asprintf(formatted, " %s=\"%s\"", key, quotedValue); + QTestCharBuffer quotedValue; + QXmlTestLogger::xmlQuote(quotedValue, attribute->value()); + QTest::qt_asprintf(formatted, " %s=\"%s\"", key, quotedValue.constData()); } else { QTest::qt_asprintf(formatted, ""); @@ -168,9 +168,7 @@ void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, char void QTestXunitStreamer::output(QTestElement *element) const { - char buf[1024]; - QTest::qt_snprintf(buf, sizeof(buf), "\n"); - outputString(buf); + outputString("\n"); QTestBasicStreamer::output(element); } diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index 8fc8dd9..fca7bfc 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -104,18 +104,18 @@ QXmlTestLogger::~QXmlTestLogger() void QXmlTestLogger::startLogging() { QAbstractTestLogger::startLogging(); - char buf[1024]; + QTestCharBuffer buf; if (xmlmode == QXmlTestLogger::Complete) { - char quotedTc[900]; - xmlQuote(quotedTc, QTestResult::currentTestObjectName(), sizeof(quotedTc)); - QTest::qt_snprintf(buf, sizeof(buf), + QTestCharBuffer quotedTc; + xmlQuote(quotedTc, QTestResult::currentTestObjectName()); + QTest::qt_asprintf(buf, "\n" - "\n", quotedTc); + "\n", quotedTc.constData()); outputString(buf); } - QTest::qt_snprintf(buf, sizeof(buf), + QTest::qt_asprintf(buf, "\n" " %s\n" " "QTEST_VERSION_STR"\n" @@ -134,10 +134,10 @@ void QXmlTestLogger::stopLogging() void QXmlTestLogger::enterTestFunction(const char *function) { - char buf[1024]; - char quotedFunction[950]; - xmlQuote(quotedFunction, function, sizeof(quotedFunction)); - QTest::qt_snprintf(buf, sizeof(buf), "\n", quotedFunction); + QTestCharBuffer buf; + QTestCharBuffer quotedFunction; + xmlQuote(quotedFunction, function); + QTest::qt_asprintf(buf, "\n", quotedFunction.constData()); outputString(buf); } @@ -208,51 +208,49 @@ static const char *messageFormatString(bool noDescription, bool noTag) void QXmlTestLogger::addIncident(IncidentTypes type, const char *description, const char *file, int line) { - // buffer must be large enough to hold all quoted/cdata buffers plus the format string itself - char buf[5000]; + QTestCharBuffer buf; const char *tag = QTestResult::currentDataTag(); const char *gtag = QTestResult::currentGlobalDataTag(); const char *filler = (tag && gtag) ? ":" : ""; const bool notag = QTest::isEmpty(tag) && QTest::isEmpty(gtag); - char quotedFile[1024]; - char cdataGtag[1024]; - char cdataTag[1024]; - char cdataDescription[1024]; + QTestCharBuffer quotedFile; + QTestCharBuffer cdataGtag; + QTestCharBuffer cdataTag; + QTestCharBuffer cdataDescription; - xmlQuote(quotedFile, file, sizeof(quotedFile)); - xmlCdata(cdataGtag, gtag, sizeof(cdataGtag)); - xmlCdata(cdataTag, tag, sizeof(cdataTag)); - xmlCdata(cdataDescription, description, sizeof(cdataDescription)); + xmlQuote(quotedFile, file); + xmlCdata(cdataGtag, gtag); + xmlCdata(cdataTag, tag); + xmlCdata(cdataDescription, description); - QTest::qt_snprintf(buf, sizeof(buf), + QTest::qt_asprintf(buf, QTest::incidentFormatString(QTest::isEmpty(description), notag), QTest::xmlIncidentType2String(type), - quotedFile, line, - cdataGtag, + quotedFile.constData(), line, + cdataGtag.constData(), filler, - cdataTag, - cdataDescription); + cdataTag.constData(), + cdataDescription.constData()); outputString(buf); } void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result) { - char buf[1536]; - char quotedMetric[64]; - char quotedTag[1024]; + QTestCharBuffer buf; + QTestCharBuffer quotedMetric; + QTestCharBuffer quotedTag; xmlQuote(quotedMetric, - QBenchmarkGlobalData::current->measurer->metricText().toAscii().constData(), - sizeof(quotedMetric)); - xmlQuote(quotedTag, result.context.tag.toAscii().constData(), sizeof(quotedTag)); + QBenchmarkGlobalData::current->measurer->metricText().toAscii().constData()); + xmlQuote(quotedTag, result.context.tag.toAscii().constData()); - QTest::qt_snprintf( - buf, sizeof(buf), + QTest::qt_asprintf( + buf, QTest::benchmarkResultFormatString(), - quotedMetric, - quotedTag, + quotedMetric.constData(), + quotedTag.constData(), QByteArray::number(result.value).constData(), //no 64-bit qt_snprintf support result.iterations); outputString(buf); @@ -261,30 +259,30 @@ void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result) void QXmlTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line) { - char buf[5000]; + QTestCharBuffer buf; const char *tag = QTestResult::currentDataTag(); const char *gtag = QTestResult::currentGlobalDataTag(); const char *filler = (tag && gtag) ? ":" : ""; const bool notag = QTest::isEmpty(tag) && QTest::isEmpty(gtag); - char quotedFile[1024]; - char cdataGtag[1024]; - char cdataTag[1024]; - char cdataDescription[1024]; + QTestCharBuffer quotedFile; + QTestCharBuffer cdataGtag; + QTestCharBuffer cdataTag; + QTestCharBuffer cdataDescription; - xmlQuote(quotedFile, file, sizeof(quotedFile)); - xmlCdata(cdataGtag, gtag, sizeof(cdataGtag)); - xmlCdata(cdataTag, tag, sizeof(cdataTag)); - xmlCdata(cdataDescription, message, sizeof(cdataDescription)); + xmlQuote(quotedFile, file); + xmlCdata(cdataGtag, gtag); + xmlCdata(cdataTag, tag); + xmlCdata(cdataDescription, message); - QTest::qt_snprintf(buf, sizeof(buf), + QTest::qt_asprintf(buf, QTest::messageFormatString(QTest::isEmpty(message), notag), QTest::xmlMessageType2String(type), - quotedFile, line, - cdataGtag, + quotedFile.constData(), line, + cdataGtag.constData(), filler, - cdataTag, - cdataDescription); + cdataTag.constData(), + cdataDescription.constData()); outputString(buf); } -- cgit v0.12 From f752633b878840634ca374fb9c1e8755aa1fd886 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 29 Jul 2009 15:48:46 +0200 Subject: Unable to change focus between two line edits on mac This is because we try to decide whether the window cocoa tells us to be active should be active, and if we desagree, we do nothing. The result is that Qt and Cocoa ends up in different states. I decided to remove a lot of the logic that went on in this case, and the resons is: 1. By checking the callplaces to onApplicationWindowChangedActivation, we know that we always have a valid widget pointer, and we know that the widget always is a window (otherwise Cocoa would never tell us that the widget got active). 2. We can never end up doing nothing in this response. The best we can do is to follow what Cocoa tells us. If this turns out to break something, it would probably be better to check why we get an activation call in the first place for a window that should not be activated (e.g. is canBecomeKeyWindow set correctly?) Task: 253610 RevBy: msorvig --- src/gui/kernel/qapplication_mac.mm | 49 ++++++++++---------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 0d86c8e..be23949 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -1481,6 +1481,7 @@ QWidget *QApplicationPrivate::tryModalHelper_sys(QWidget *top) return top; } +#ifndef QT_MAC_USE_COCOA static bool qt_try_modal(QWidget *widget, EventRef event) { QWidget * top = 0; @@ -1514,6 +1515,7 @@ static bool qt_try_modal(QWidget *widget, EventRef event) #endif return !block_event; } +#endif OSStatus QApplicationPrivate::tabletProximityCallback(EventHandlerCallRef, EventRef carbonEvent, void *) @@ -2894,52 +2896,25 @@ bool QApplicationPrivate::canQuit() #endif } -void onApplicationWindowChangedActivation( QWidget*widget, bool activated ) +void onApplicationWindowChangedActivation(QWidget *widget, bool activated) { #if QT_MAC_USE_COCOA - QApplication *app = qApp; + if (!widget) + return; - if ( activated ) - { - if (QApplicationPrivate::app_style) - { + if (activated) { + if (QApplicationPrivate::app_style) { QEvent ev(QEvent::Style); qt_sendSpontaneousEvent(QApplicationPrivate::app_style, &ev); } - - if (widget && app_do_modal && !qt_try_modal(widget, NULL)) - return; - - if (widget && widget->window()->isVisible()) - { - QWidget *tlw = widget->window(); - - if (tlw->isWindow() && !(tlw->windowType() == Qt::Popup) - && !qt_mac_is_macdrawer(tlw) - && (!tlw->parentWidget() || tlw->isModal() || !(tlw->windowType() == Qt::Tool))) { - bool just_send_event = false; -#if 0 - WindowActivationScope scope; - if ( GetWindowActivationScope((OSWindowRef)wid, &scope) == noErr && - scope == kWindowActivationScopeIndependent) - { - if ( GetFrontWindowOfClass(kAllWindowClasses, true) != wid ) - just_send_event = true; - } -#endif - if (just_send_event) { - QEvent e(QEvent::WindowActivate); - qt_sendSpontaneousEvent(widget, &e); - } else { - app->setActiveWindow(tlw); - } - } - } + qApp->setActiveWindow(widget); } else { // deactivated - if (widget && QApplicationPrivate::active_window == widget) - app->setActiveWindow(0); + if (QApplicationPrivate::active_window == widget) + qApp->setActiveWindow(0); } + QMenuBar::macUpdateMenuBar(); + #else Q_UNUSED(widget); Q_UNUSED(activated); -- cgit v0.12 From d09fa4a816c6b9ccf306b7e1a887c4a4b1dc2f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Thu, 30 Jul 2009 09:25:10 +0200 Subject: Start implementing Mac accessibility for cocoa. Rather than having this stuck in a branch somewhere I'm going to implement it incrementally in main. It's going to be a long haul before it's done. This commit implements: - accessibilityIsIgnored() - Accessibility role translation --- src/gui/accessible/accessible.pri | 3 +- src/gui/accessible/qaccessible_mac_cocoa.mm | 234 ++++++++++++++++++++++++++++ 2 files changed, 236 insertions(+), 1 deletion(-) diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri index 76b6687..ad2fb4c 100644 --- a/src/gui/accessible/accessible.pri +++ b/src/gui/accessible/accessible.pri @@ -14,7 +14,8 @@ contains(QT_CONFIG, accessibility) { mac:!embedded { HEADERS += accessible/qaccessible_mac_p.h - OBJECTIVE_SOURCES += accessible/qaccessible_mac.mm + OBJECTIVE_SOURCES += accessible/qaccessible_mac.mm \ + accessible/qaccessible_mac_cocoa.mm } else:win32 { SOURCES += accessible/qaccessible_win.cpp } else { diff --git a/src/gui/accessible/qaccessible_mac_cocoa.mm b/src/gui/accessible/qaccessible_mac_cocoa.mm index e69de29..1cb2ffa 100644 --- a/src/gui/accessible/qaccessible_mac_cocoa.mm +++ b/src/gui/accessible/qaccessible_mac_cocoa.mm @@ -0,0 +1,234 @@ + +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaccessible.h" +#include "qaccessible_mac_p.h" +#include "qdebug.h" +#include "qtabwidget.h" + +#include +#include +#include + + +#ifndef QT_NO_ACCESSIBILITY + +#ifdef QT_MAC_USE_COCOA + +QT_BEGIN_NAMESPACE + +//#define MAC_ACCESSIBILTY_DEVELOPER_MODE + +#ifdef MAC_ACCESSIBILTY_DEVELOPER_MODE +#define MAC_ACCESSIBILTY_DEBUG qDebug +#else +#define MAC_ACCESSIBILTY_DEBUG if (0) qDebug +#endif + +typedef QMap QMacAccessibiltyRoleMap; +Q_GLOBAL_STATIC(QMacAccessibiltyRoleMap, qMacAccessibiltyRoleMap); + +static QAInterface interfaceForView(QT_MANGLE_NAMESPACE(QCocoaView) *view) +{ + return QAInterface(QAccessible::queryAccessibleInterface([view qt_qwidget])); +} + +/* + Set up mappings from Qt accessibilty roles to Mac accessibilty roles. +*/ +static void populateRoleMap() +{ + QMacAccessibiltyRoleMap &roleMap = *qMacAccessibiltyRoleMap(); + roleMap[QAccessible::MenuItem] = NSAccessibilityMenuItemRole; + roleMap[QAccessible::MenuBar] = NSAccessibilityMenuBarRole; + roleMap[QAccessible::ScrollBar] = NSAccessibilityScrollBarRole; + roleMap[QAccessible::Grip] = NSAccessibilityGrowAreaRole; + roleMap[QAccessible::Window] = NSAccessibilityWindowRole; + roleMap[QAccessible::Dialog] = NSAccessibilityWindowRole; + roleMap[QAccessible::AlertMessage] = NSAccessibilityWindowRole; + roleMap[QAccessible::ToolTip] = NSAccessibilityWindowRole; + roleMap[QAccessible::HelpBalloon] = NSAccessibilityWindowRole; + roleMap[QAccessible::PopupMenu] = NSAccessibilityMenuRole; + roleMap[QAccessible::Application] = NSAccessibilityApplicationRole; + roleMap[QAccessible::Pane] = NSAccessibilityGroupRole; + roleMap[QAccessible::Grouping] = NSAccessibilityGroupRole; + roleMap[QAccessible::Separator] = NSAccessibilitySplitterRole; + roleMap[QAccessible::ToolBar] = NSAccessibilityToolbarRole; + roleMap[QAccessible::PageTab] = NSAccessibilityRadioButtonRole; + roleMap[QAccessible::ButtonMenu] = NSAccessibilityMenuButtonRole; + roleMap[QAccessible::ButtonDropDown] = NSAccessibilityPopUpButtonRole; + roleMap[QAccessible::SpinBox] = NSAccessibilityIncrementorRole; + roleMap[QAccessible::Slider] = NSAccessibilitySliderRole; + roleMap[QAccessible::ProgressBar] = NSAccessibilityProgressIndicatorRole; + roleMap[QAccessible::ComboBox] = NSAccessibilityPopUpButtonRole; + roleMap[QAccessible::RadioButton] = NSAccessibilityRadioButtonRole; + roleMap[QAccessible::CheckBox] = NSAccessibilityCheckBoxRole; + roleMap[QAccessible::StaticText] = NSAccessibilityStaticTextRole; + roleMap[QAccessible::Table] = NSAccessibilityTableRole; + roleMap[QAccessible::StatusBar] = NSAccessibilityStaticTextRole; + roleMap[QAccessible::Column] = NSAccessibilityColumnRole; + roleMap[QAccessible::ColumnHeader] = NSAccessibilityColumnRole; + roleMap[QAccessible::Row] = NSAccessibilityRowRole; + roleMap[QAccessible::RowHeader] = NSAccessibilityRowRole; + roleMap[QAccessible::Cell] = NSAccessibilityTextFieldRole; + roleMap[QAccessible::PushButton] = NSAccessibilityButtonRole; + roleMap[QAccessible::EditableText] = NSAccessibilityTextFieldRole; + roleMap[QAccessible::Link] = NSAccessibilityTextFieldRole; + roleMap[QAccessible::Indicator] = NSAccessibilityValueIndicatorRole; + roleMap[QAccessible::Splitter] = NSAccessibilitySplitGroupRole; + roleMap[QAccessible::List] = NSAccessibilityListRole; + roleMap[QAccessible::ListItem] = NSAccessibilityStaticTextRole; + roleMap[QAccessible::Cell] = NSAccessibilityStaticTextRole; +} + +/* + Returns a Mac accessibility role for the given interface, or + NSAccessibilityUnknownRole if no role mapping is found. +*/ +static NSString *macRoleForInterface(QAInterface interface) +{ + const QAccessible::Role qtRole = interface.role(); + QMacAccessibiltyRoleMap &roleMap = *qMacAccessibiltyRoleMap(); + + if (roleMap.isEmpty()) + populateRoleMap(); + + MAC_ACCESSIBILTY_DEBUG() << "role for" << interface.object() << "interface role" << hex << qtRole; + + if (roleMap.contains(qtRole)) { + MAC_ACCESSIBILTY_DEBUG() << "return" << roleMap[qtRole]; + return roleMap[qtRole]; + } + + MAC_ACCESSIBILTY_DEBUG() << "return NSAccessibilityUnknownRole"; + return NSAccessibilityUnknownRole; +} + +/* + Is the interface a QTabBar embedded in a QTabWidget? + (as opposed to a stand-alone tab bar) +*/ +static bool isEmbeddedTabBar(const QAInterface &interface) +{ + QObject *object = interface.object(); + if (interface.role() == QAccessible::PageTabList && object) + return (qobject_cast(object->parent())); + + return false; +} + +static bool isInterfaceIgnored(QAInterface interface) +{ + // Mac accessibility does not have an attribute that corresponds to the + // Invisible/Offscreen state. Use the ignore facility to disable them. + const QAccessible::State state = interface.state(); + if (state & QAccessible::Invisible || + state & QAccessible::Offscreen ) + return false; + + // Hide QTabBars that has a QTabWidget parent (the QTabWidget handles the accessibility) + if (isEmbeddedTabBar(interface)) + return false; + + if (QObject * const object = interface.object()) { + const QString className = QLatin1String(object->metaObject()->className()); + + // Prevent VoiceOver from focusing on tool tips by ignoring those + // interfaces. Shifting VoiceOver focus to the tool tip is confusing + // and the contents of the tool tip is avalible through the description + // attribute anyway. + if (className == QLatin1String("QTipLabel")) + return false; + } + + // Hide interfaces with an unknown role. When developing it's often useful to disable + // this check to see all interfaces in the hierarchy. +#ifndef MAC_ACCESSIBILTY_DEVELOPER_MODE + return [macRoleForInterface(interface) isEqualToString: NSAccessibilityUnknownRole]; +#else + return NO; +#endif +} + +QT_END_NAMESPACE + +@implementation QT_MANGLE_NAMESPACE(QCocoaView) (Accessibility) + +- (BOOL)accessibilityIsIgnored +{ + QAInterface interface = interfaceForView(self); + return isInterfaceIgnored(interface); +} + +- (NSArray *)accessibilityAttributeNames +{ + QAInterface interface = interfaceForView(self); + + static NSArray *attributes = nil; + if (attributes == nil) { + attributes = [super accessibilityAttributeNames]; + + } + return attributes; +} + +- (id)accessibilityAttributeValue:(NSString *)attribute +{ + MAC_ACCESSIBILTY_DEBUG() << "accessibilityAttributeValue" << self << QCFString::toQString(reinterpret_cast(attribute)); + + QAInterface interface = interfaceForView(self); + + // Switch on the attribute name and call the appropriate handler function. + // Pass the call on to the NSView class for attributes we don't handle. + if ([attribute isEqualToString:@"AXRole"]) { + return macRoleForInterface(interface); + } else { + return [super accessibilityAttributeValue:attribute]; + } +} + +@end + +#endif // QT_MAC_USE_COCOA + +#endif // QT_NO_ACCESSIBILITY + -- cgit v0.12 From 9523b27be4fe00870d19c4ff4caa2d78dcf520e6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 30 Jul 2009 10:11:57 +0200 Subject: parse Q_INVOKABLE explicit constructors regression introduced in e43eae35 because the code of maybeParseFunction and parseFunction is not exactly the same. Reviewed-by: Kent Hansen --- src/tools/moc/moc.cpp | 2 +- tests/auto/moc/tst_moc.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 797595f..0ba7d53 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -429,7 +429,7 @@ bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def) { def->isVirtual = false; //skip modifiers and attributes - while (test(INLINE) || test(STATIC) || + while (test(EXPLICIT) || test(INLINE) || test(STATIC) || (test(VIRTUAL) && (def->isVirtual = true)) //mark as virtual || testFunctionAttribute(def)) {} bool tilde = test(TILDE); diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index d66791f..488f068 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -1157,6 +1157,13 @@ void tst_Moc::constructors() QObject *o3 = mo->newInstance(Q_ARG(QString, str)); QVERIFY(o3 != 0); QCOMPARE(qobject_cast(o3)->m_str, str); + + { + //explicit constructor + QObject *o = QObject::staticMetaObject.newInstance(); + QVERIFY(o); + delete o; + } } #include "task234909.h" -- cgit v0.12 From 776c4a5b8035b87d011b8e431c3d9e970ad98cd9 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 30 Jul 2009 10:44:15 +0200 Subject: fix two bugs in the custom script class example 1) fromScriptValue() needs to call qvariant_cast() on the data, in order to be symmetric with toScriptValue(). 2) use the overload of newFunction() that takes a prototype object, so that the prototype.constructor and constructor.prototype relationship is set up correctly; otherwise the instanceof operator won't work. --- examples/script/customclass/bytearrayclass.cpp | 9 ++++++--- examples/script/customclass/main.cpp | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/script/customclass/bytearrayclass.cpp b/examples/script/customclass/bytearrayclass.cpp index 81a0b8a..2044a16 100644 --- a/examples/script/customclass/bytearrayclass.cpp +++ b/examples/script/customclass/bytearrayclass.cpp @@ -100,7 +100,7 @@ ByteArrayClass::ByteArrayClass(QScriptEngine *engine) QScriptValue global = engine->globalObject(); proto.setPrototype(global.property("Object").property("prototype")); - ctor = engine->newFunction(construct); + ctor = engine->newFunction(construct, proto); ctor.setData(qScriptValueFromValue(engine, this)); } //! [0] @@ -224,7 +224,10 @@ QScriptValue ByteArrayClass::construct(QScriptContext *ctx, QScriptEngine *) ByteArrayClass *cls = qscriptvalue_cast(ctx->callee().data()); if (!cls) return QScriptValue(); - int size = ctx->argument(0).toInt32(); + QScriptValue arg = ctx->argument(0); + if (arg.instanceOf(ctx->callee())) + return cls->newInstance(qscriptvalue_cast(arg)); + int size = arg.toInt32(); return cls->newInstance(size); } //! [2] @@ -240,7 +243,7 @@ QScriptValue ByteArrayClass::toScriptValue(QScriptEngine *eng, const QByteArray void ByteArrayClass::fromScriptValue(const QScriptValue &obj, QByteArray &ba) { - ba = qscriptvalue_cast(obj.data()); + ba = qvariant_cast(obj.data().toVariant()); } diff --git a/examples/script/customclass/main.cpp b/examples/script/customclass/main.cpp index 05aefd5..3b98f5c 100644 --- a/examples/script/customclass/main.cpp +++ b/examples/script/customclass/main.cpp @@ -52,6 +52,7 @@ int main(int argc, char **argv) eng.globalObject().setProperty("ByteArray", baClass->constructor()); qDebug() << "ba = new ByteArray(4):" << eng.evaluate("ba = new ByteArray(4)").toString(); + qDebug() << "ba instanceof ByteArray:" << eng.evaluate("ba instanceof ByteArray").toBool(); qDebug() << "ba.length:" << eng.evaluate("ba.length").toNumber(); qDebug() << "ba[1] = 123; ba[1]:" << eng.evaluate("ba[1] = 123; ba[1]").toNumber(); qDebug() << "ba[7] = 224; ba.length:" << eng.evaluate("ba[7] = 224; ba.length").toNumber(); @@ -65,6 +66,9 @@ int main(int argc, char **argv) qDebug() << "ba.toBase64().toLatin1String():" << eng.evaluate("b64.toLatin1String()").toString(); qDebug() << "ba.valueOf():" << eng.evaluate("ba.valueOf()").toString(); qDebug() << "ba.chop(2); ba.length:" << eng.evaluate("ba.chop(2); ba.length").toNumber(); + qDebug() << "ba2 = new ByteArray(ba):" << eng.evaluate("ba2 = new ByteArray(ba)").toString(); + qDebug() << "ba2.equals(ba):" << eng.evaluate("ba2.equals(ba)").toBool(); + qDebug() << "ba2.equals(new ByteArray()):" << eng.evaluate("ba2.equals(new ByteArray())").toBool(); return 0; } -- cgit v0.12 From e181f8754bccb13cb59212f279e05c20cb76db62 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Thu, 30 Jul 2009 12:09:16 +0200 Subject: Avoids comparing a pointer (d->layout) after deleted in qgraphicswidget Reviewed-by: ogoffart --- src/gui/graphicsview/qgraphicswidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 3ea80ce..cb8336d 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -258,7 +258,6 @@ QGraphicsWidget::~QGraphicsWidget() //we check if we have a layout previously if (d->layout) { - delete d->layout; foreach (QGraphicsItem * item, childItems()) { // In case of a custom layout which doesn't remove and delete items, we ensure that // the parent layout item does not point to the deleted layout. This code is here to @@ -269,6 +268,7 @@ QGraphicsWidget::~QGraphicsWidget() widget->setParentLayoutItem(0); } } + delete d->layout; } // Remove this graphics widget from widgetStyles -- cgit v0.12 From fbe103bd39fcef2b873aae31dcfee9604237a95e Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Thu, 30 Jul 2009 12:23:49 +0200 Subject: Revert "Avoids comparing a pointer (d->layout) after deleted in qgraphicswidget" This reverts commit e181f8754bccb13cb59212f279e05c20cb76db62. This code is used for compatibility issues for custom layouts that dont delete their children, so its a false positive from coverity. --- src/gui/graphicsview/qgraphicswidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index cb8336d..3ea80ce 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -258,6 +258,7 @@ QGraphicsWidget::~QGraphicsWidget() //we check if we have a layout previously if (d->layout) { + delete d->layout; foreach (QGraphicsItem * item, childItems()) { // In case of a custom layout which doesn't remove and delete items, we ensure that // the parent layout item does not point to the deleted layout. This code is here to @@ -268,7 +269,6 @@ QGraphicsWidget::~QGraphicsWidget() widget->setParentLayoutItem(0); } } - delete d->layout; } // Remove this graphics widget from widgetStyles -- cgit v0.12 From 04f7834fcd8db4ecb6a4c53de42ac83f571b37c8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 30 Jul 2009 12:58:06 +0200 Subject: Fix compilation on AIX: -I/usr/include cannot be used. The reason is that the C++ compiler needs to add -I/usr/vacpp/include before -I/usr/include, so our adding of -I/usr/include changes the order. This causes a compilation error in the C++ header xlocinfo.h. In any case, these checks done in qmake are unnecessary. If the OpenSSL headers are in one of those include paths, they will be found on their own already. Reviewed-By: Bradley T. Hughes --- config.tests/unix/openssl/openssl.pri | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/config.tests/unix/openssl/openssl.pri b/config.tests/unix/openssl/openssl.pri index bc95479..f069396 100644 --- a/config.tests/unix/openssl/openssl.pri +++ b/config.tests/unix/openssl/openssl.pri @@ -1,9 +1,3 @@ -!cross_compile { - TRY_INCLUDEPATHS = /include /usr/include /usr/local/include $$QMAKE_INCDIR $$INCLUDEPATH - # LSB doesn't allow using headers from /include or /usr/include - linux-lsb-g++:TRY_INCLUDEPATHS = $$QMAKE_INCDIR $$INCLUDEPATH - for(p, TRY_INCLUDEPATHS) { - pp = $$join(p, "", "", "/openssl") - exists($$pp):INCLUDEPATH *= $$p - } -} +# Empty file since Qt 4.6 +# I'm too lazy to find all places where this file is included + -- cgit v0.12 From 1fa620be2794b46a9b5d867ae6b2d7fa844b610c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Thu, 30 Jul 2009 13:41:34 +0200 Subject: Mac: Fix crash in QCoreTextFontEngineMulti when disabling font kerning. CFDictionaryAddValue expects a CFNumberRef, not a pointer-to-CFNumberRef. Reviewed-by: TrustMe --- src/gui/text/qfontengine_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 72e5175..b16fd7e 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -156,7 +156,7 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, con if (!kerning) { float zero = 0.0; QCFType noKern = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero); - CFDictionaryAddValue(attributeDict, kCTKernAttributeName, &noKern); + CFDictionaryAddValue(attributeDict, kCTKernAttributeName, noKern); } QCoreTextFontEngine *fe = new QCoreTextFontEngine(ctfont, fontDef, this); -- cgit v0.12 From 9fb11e5c2e8127e2916e1cf9b51f676effc9d31e Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 30 Jul 2009 13:55:17 +0200 Subject: Reviewed-by: Thomas H. Squashed commit of the following: commit fcf7e8cab339d0cf9f3f2a9756d7754c54c4d934 Author: Gunnar Sletta Date: Thu Jul 30 13:15:13 2009 +0200 note in the changes file... commit 2c9c3880215988e6609c290a8e738b228736e601 Author: Gunnar Sletta Date: Thu Jul 30 12:51:42 2009 +0200 Don't leak native window HRGN handles commit 6bb30d2075dd1d71a8a600d25f413a38af7f2f2c Author: Gunnar Sletta Date: Thu Jul 30 11:09:22 2009 +0200 Moved qregion_wince.cpp -> qregion_win.cpp, platforms are identical now commit 173fcc5baec73a198167985c6f777987e6015a71 Author: Gunnar Sletta Date: Thu Jul 30 09:42:06 2009 +0200 win32 calls on QRegion.handle() is no longer supported, use from HRGN commit d7ddcce4ba29b70ed81f85274208b388a2bb9d4d Author: Gunnar Sletta Date: Thu Jul 30 09:41:37 2009 +0200 Added convenience function to convert from HRGN to QRegion commit 2fc53ac3d59a9c42bb4154fff7557610092b7946 Author: Gunnar Sletta Date: Wed Jul 29 09:28:10 2009 +0200 Kill qregion_win.cpp and use the unix code instead --- dist/changes-4.6.0 | 67 ++--- src/gui/painting/painting.pri | 8 +- src/gui/painting/qregion.cpp | 28 +- src/gui/painting/qregion.h | 4 +- src/gui/painting/qregion_win.cpp | 514 ++++--------------------------------- src/gui/painting/qregion_wince.cpp | 119 --------- src/gui/styles/qwindowsxpstyle.cpp | 18 +- 7 files changed, 109 insertions(+), 649 deletions(-) delete mode 100644 src/gui/painting/qregion_wince.cpp diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 383c6b7..7a6decf 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -34,9 +34,15 @@ information about a particular change. - Significant external contribution from Milan Burda for planned removal of (non-unicode) Windows 9x/ME support. + - QRegion is no longer a GDI object by default. This means it is no + longer subjuect to gui-thread only nor does it potentially impact + the 10.000 GDI object limit per process. By explicitly calling + .handle() a GDI object will be created and memory managed by + QRegion. The native handle is for reading out only. Any GDI calls + made on the HRGN handle will not affect the QRegion. **************************************************************************** -* Important Behavior Changes * +* Important Behavior Changes * **************************************************************************** - The experimental Direct3D paint engine has been removed. The reason for @@ -71,33 +77,32 @@ information about a particular change. QGraphicsItem::ItemSendsGeometryChanges (which is enabled by default by QGraphicsWidget and QGraphicsProxyWidget). -- QDesktopWidget on X11 no longer emits the resized(int) signal when screens - are added or removed. This was not done on other platforms. Use the - screenCountChanged signal instead - -- QUrl's parser is more strict when for hostnames in URLs. QUrl now - enforces STD 3 rules: - - * each individual hostname section (between dots) must be at most - 63 ASCII characters in length; - - * only letters, digits, and the hyphen character are allowed in the - ASCII range; letters outside the ASCII range follow the normal - IDN rules - - That means QUrl no longer accepts some URLs that were invalid - before, but weren't interpreted as such. - -- The Unix configure-time check for STL is stricter now in Qt - 4.6.0. This means some legacy STL implementations may fail to pass - the test and, therefore, Qt will automatically disable STL support. - - This is a binary-compatible change: existing code will continue to - work without being recompiled. However, it affects the source code, - since some STL-compatibility API will not be enabled. - - Platforms affected by this change: - * solaris-cc-* with the default (Cstd) C++ STL library - recommendation: use -library=stlport4 - See Sun Studio's documentation for the effects of this option - + - QDesktopWidget on X11 no longer emits the resized(int) signal when screens + are added or removed. This was not done on other platforms. Use the + screenCountChanged signal instead + + - QUrl's parser is more strict when for hostnames in URLs. QUrl now + enforces STD 3 rules: + + * each individual hostname section (between dots) must be at most + 63 ASCII characters in length; + + * only letters, digits, and the hyphen character are allowed in the + ASCII range; letters outside the ASCII range follow the normal + IDN rules + + That means QUrl no longer accepts some URLs that were invalid + before, but weren't interpreted as such. + + - The Unix configure-time check for STL is stricter now in Qt + 4.6.0. This means some legacy STL implementations may fail to pass + the test and, therefore, Qt will automatically disable STL support. + + This is a binary-compatible change: existing code will continue to + work without being recompiled. However, it affects the source code, + since some STL-compatibility API will not be enabled. + + Platforms affected by this change: + * solaris-cc-* with the default (Cstd) C++ STL library + recommendation: use -library=stlport4 + See Sun Studio's documentation for the effects of this option diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 34d1779..d226be2 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -100,8 +100,8 @@ win32 { painting/qcolormap_win.cpp \ painting/qpaintdevice_win.cpp \ painting/qprintengine_win.cpp \ - painting/qprinterinfo_win.cpp \ - painting/qregion_win.cpp + painting/qprinterinfo_win.cpp + !win32-borland:!wince*:LIBS += -lmsimg32 } @@ -126,10 +126,6 @@ embedded { painting/qwindowsurface_raster.cpp \ } -wince* { - SOURCES -= painting/qregion_win.cpp -} - unix:x11 { HEADERS += \ painting/qpaintengine_x11_p.h diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 762e9e0..d59f3ff 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -49,7 +49,7 @@ #include -#if defined(Q_OS_UNIX) || defined(Q_OS_WINCE) +#if defined(Q_OS_UNIX) || defined(Q_WS_WIN) #include "qimage.h" #include "qbitmap.h" #include @@ -545,7 +545,7 @@ QRegion& QRegion::operator|=(const QRegion &r) \sa intersected() */ -#if !defined (Q_OS_UNIX) && !defined (Q_OS_WINCE) +#if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN) QRegion& QRegion::operator+=(const QRect &r) { return operator+=(QRegion(r)); @@ -561,16 +561,14 @@ QRegion& QRegion::operator+=(const QRect &r) \sa intersected() */ -#if !defined(Q_WS_WIN) || defined(Q_OS_WINCE) QRegion& QRegion::operator&=(const QRegion &r) { return *this = *this & r; } -#endif /*! \overload \since 4.4 */ -#if defined (Q_OS_UNIX) || defined (Q_OS_WINCE) +#if defined (Q_OS_UNIX) || defined (Q_WS_WIN) QRegion& QRegion::operator&=(const QRect &r) { return *this = *this & r; @@ -591,10 +589,8 @@ QRegion& QRegion::operator&=(const QRect &r) \sa subtracted() */ -#if !defined(Q_WS_WIN) || defined(Q_OS_WINCE) QRegion& QRegion::operator-=(const QRegion &r) { return *this = *this - r; } -#endif /*! Applies the xored() function to this region and \a r and @@ -731,7 +727,7 @@ bool QRegion::intersects(const QRect &rect) const return false; } -#if !defined (Q_OS_UNIX) && !defined (Q_OS_WINCE) +#if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN) /*! \overload \since 4.4 @@ -1086,7 +1082,7 @@ Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion) return result; } -#if defined(Q_OS_UNIX) || defined(Q_OS_WINCE) +#if defined(Q_OS_UNIX) || defined(Q_WS_WIN) //#define QT_REGION_DEBUG /* @@ -1627,9 +1623,9 @@ QT_END_INCLUDE_NAMESPACE QT_BEGIN_INCLUDE_NAMESPACE # include "qregion_mac.cpp" QT_END_INCLUDE_NAMESPACE -#elif defined(Q_OS_WINCE) +#elif defined(Q_WS_WIN) QT_BEGIN_INCLUDE_NAMESPACE -# include "qregion_wince.cpp" +# include "qregion_win.cpp" QT_END_INCLUDE_NAMESPACE #elif defined(Q_WS_QWS) static QRegionPrivate qrp; @@ -3829,7 +3825,7 @@ QRegion::QRegion(const QRect &r, RegionType t) #if defined(Q_WS_X11) d->rgn = 0; d->xrectangles = 0; -#elif defined(Q_OS_WINCE) +#elif defined(Q_WS_WIN) d->rgn = 0; #endif if (t == Rectangle) { @@ -3851,7 +3847,7 @@ QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule) #if defined(Q_WS_X11) d->rgn = 0; d->xrectangles = 0; -#elif defined(Q_OS_WINCE) +#elif defined(Q_WS_WIN) d->rgn = 0; #endif d->qt_rgn = PolygonRegion(a.constData(), a.size(), @@ -3881,7 +3877,7 @@ QRegion::QRegion(const QBitmap &bm) #if defined(Q_WS_X11) d->rgn = 0; d->xrectangles = 0; -#elif defined(Q_OS_WINCE) +#elif defined(Q_WS_WIN) d->rgn = 0; #endif d->qt_rgn = qt_bitmapToRegion(bm); @@ -3896,7 +3892,7 @@ void QRegion::cleanUp(QRegion::QRegionData *x) XDestroyRegion(x->rgn); if (x->xrectangles) free(x->xrectangles); -#elif defined(Q_OS_WINCE) +#elif defined(Q_WS_WIN) if (x->rgn) qt_win_dispose_rgn(x->rgn); #endif @@ -3932,7 +3928,7 @@ QRegion QRegion::copy() const #if defined(Q_WS_X11) x->rgn = 0; x->xrectangles = 0; -#elif defined(Q_OS_WINCE) +#elif defined(Q_WS_WIN) x->rgn = 0; #endif if (d->qt_rgn) diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index bfedcb1..1db07a1 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -59,7 +59,7 @@ QT_MODULE(Gui) template class QVector; class QVariant; -#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_WINCE) +#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) struct QRegionPrivate; #endif @@ -199,7 +199,7 @@ private: #elif defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) mutable RgnHandle unused; // Here for binary compatability reasons. ### Qt 5 remove. #endif -#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_WINCE) +#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) QRegionPrivate *qt_rgn; #endif }; diff --git a/src/gui/painting/qregion_win.cpp b/src/gui/painting/qregion_win.cpp index 249b1a6..2d5e76b 100644 --- a/src/gui/painting/qregion_win.cpp +++ b/src/gui/painting/qregion_win.cpp @@ -39,27 +39,25 @@ ** ****************************************************************************/ +#include "qatomic.h" #include "qbitmap.h" #include "qbuffer.h" #include "qimage.h" #include "qpolygon.h" #include "qregion.h" #include "qt_windows.h" +#include "qpainterpath.h" +#include "qguifunctions_wince.h" QT_BEGIN_NAMESPACE +QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0 }; -/* - In Windows versions before Windows Vista CreateRectRgn - when called in a multi-threaded - environment - might return an invalid handle. This function works around this limitation - by verifying the handle with a quick GetRegionData() call and re-creates the region - if necessary. -*/ HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, int bottom) { const int tries = 10; for (int i = 0; i < tries; ++i) { - HRGN region = 0; + HRGN region; switch (type) { case QRegion::Rectangle: region = CreateRectRgn(left, top, right, bottom); @@ -80,497 +78,73 @@ HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, return 0; } -#ifndef Q_OS_WINCE -HRGN qt_tryCreatePolygonRegion(const QPolygon &a, Qt::FillRule fillRule) -{ - const int tries = 10; - for (int i = 0; i < tries; ++i) { - HRGN region = CreatePolygonRgn(reinterpret_cast(a.data()), a.size(), - fillRule == Qt::OddEvenFill ? ALTERNATE : WINDING); - if (region) { - if (GetRegionData(region, 0, 0)) - return region; - else - DeleteObject(region); - } - } - return 0; -} -#endif - -QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), 0 }; - -QRegion::QRegion() - : d(&shared_empty) -{ - d->ref.ref(); -} - -#ifndef Q_OS_WINCE //implementation for WindowsCE in qregion_wce.cpp -QRegion::QRegion(const QRect &r, RegionType t) -{ - if (r.isEmpty()) { - d = &shared_empty; - d->ref.ref(); - } else { - d = new QRegionData; - d->ref = 1; - if (t == Rectangle) - d->rgn = qt_tryCreateRegion(t, r.left(), r.top(), r.x() + r.width(), r.y() + r.height()); - else if (t == Ellipse) { - // need to add 1 to width/height for the ellipse to have correct boundingrect. - d->rgn = qt_tryCreateRegion(t, r.x(), r.y(), r.x() + r.width() + 1, r.y() + r.height() + 1); - } - } -} -#endif - -#ifndef Q_OS_WINCE //implementation for WindowsCE in qregion_wce.cpp -QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule) -{ - if (a.size() < 3) { - d = &shared_empty; - d->ref.ref(); - } else { - d = new QRegionData; - d->ref = 1; - d->rgn = qt_tryCreatePolygonRegion(a, fillRule); - } -} -#endif - -QRegion::QRegion(const QRegion &r) -{ - d = r.d; - d->ref.ref(); -} - -HRGN qt_win_bitmapToRegion(const QBitmap& bitmap) -{ - HRGN region=0; - QImage image = bitmap.toImage(); - const int MAXRECT = 256; - struct RData { - RGNDATAHEADER header; - RECT rect[MAXRECT]; - }; - RData data; - -#define FlushSpans \ - { \ - data.header.dwSize = sizeof(RGNDATAHEADER); \ - data.header.iType = RDH_RECTANGLES; \ - data.header.nCount = n; \ - data.header.nRgnSize = 0; \ - data.header.rcBound.bottom = y; \ - HRGN r = ExtCreateRegion(0, \ - sizeof(RGNDATAHEADER)+n*sizeof(RECT),(RGNDATA*)&data); \ - if (region) { \ - CombineRgn(region, region, r, RGN_OR); \ - DeleteObject(r); \ - } else { \ - region = r; \ - } \ - data.header.rcBound.top = y; \ - } - -#define AddSpan \ - { \ - data.rect[n].left=prev1; \ - data.rect[n].top=y; \ - data.rect[n].right=x-1+1; \ - data.rect[n].bottom=y+1; \ - n++; \ - if (n == MAXRECT) { \ - FlushSpans \ - n=0; \ - } \ - } - - data.header.rcBound.top = 0; - data.header.rcBound.left = 0; - data.header.rcBound.right = image.width()-1; - int n = 0; - - int zero = 0x00; - - int x, y; - for (y = 0; y < image.height(); ++y) { - uchar *line = image.scanLine(y); - int w = image.width(); - uchar all=zero; - int prev1 = -1; - for (x = 0; x < w;) { - uchar byte = line[x/8]; - if (x > w - 8 || byte != all) { - for (int b = 8; b > 0 && x < w; --b) { - if (!(byte & 0x01) == !all) { - // More of the same - } else { - // A change. - if (all != zero) { - AddSpan; - all = zero; - } else { - prev1 = x; - all = ~zero; - } - } - byte >>= 1; - ++x; - } - } else { - x += 8; - } - } - if (all != zero) { - AddSpan; - } - } - if (n) { - FlushSpans; - } - - if (!region) { - // Surely there is some better way. - region = qt_tryCreateRegion(QRegion::Rectangle, 0,0,1,1); - CombineRgn(region, region, region, RGN_XOR); - } - return region; -} - -#ifndef Q_OS_WINCE //implementation for WindowsCE in qregion_wce.cpp -QRegion::QRegion(const QBitmap &bm) -{ - if (bm.isNull()) { - d = &shared_empty; - d->ref.ref(); - } else { - d = new QRegionData; - d->ref = 1; - d->rgn = qt_win_bitmapToRegion(bm); - } -} -#endif - -void QRegion::cleanUp(QRegion::QRegionData *x) -{ - if (x->rgn) - DeleteObject(x->rgn); - delete x; -} - -QRegion::~QRegion() -{ - if (!d->ref.deref()) - cleanUp(d); -} - -QRegion &QRegion::operator=(const QRegion &r) -{ - r.d->ref.ref(); - if (!d->ref.deref()) - cleanUp(d); - d = r.d; - return *this; -} - - -QRegion QRegion::copy() const -{ - QRegion r; - QRegionData *x = new QRegionData; - x->ref = 1; - if (d->rgn) { - x->rgn = qt_tryCreateRegion(QRegion::Rectangle, 0, 0, 2, 2); - CombineRgn(x->rgn, d->rgn, 0, RGN_COPY); - } else { - x->rgn = 0; - } - if (!r.d->ref.deref()) - cleanUp(r.d); - r.d = x; - return r; -} - -bool QRegion::isEmpty() const -{ - return (d == &shared_empty || boundingRect().isEmpty()); -} - - -bool QRegion::contains(const QPoint &p) const -{ - return d->rgn ? PtInRegion(d->rgn, p.x(), p.y()) : false; -} - -bool QRegion::contains(const QRect &r) const -{ - if (!d->rgn) - return false; - RECT rect; - SetRect(&rect, r.left(), r.top(), r.right(), r.bottom()); - return RectInRegion(d->rgn, &rect); -} - - -void QRegion::translate(int dx, int dy) -{ - if (!d->rgn || (dx == 0 && dy == 0)) - return; - detach(); - OffsetRgn(d->rgn, dx, dy); -} - - -#define RGN_NOP -1 - -// Duplicates of those in qregion.cpp -#define QRGN_OR 6 -#define QRGN_AND 7 -#define QRGN_SUB 8 -#define QRGN_XOR 9 - -/* - Performs the actual OR, AND, SUB and XOR operation between regions. - Sets the resulting region handle to 0 to indicate an empty region. -*/ - -QRegion QRegion::winCombine(const QRegion &r, int op) const +QRegion qt_region_from_HRGN(HRGN rgn) { - int both=RGN_NOP, - left=RGN_NOP, - right=RGN_NOP; - switch (op) { - case QRGN_OR: - both = RGN_OR; - left = right = RGN_COPY; - break; - case QRGN_AND: - both = RGN_AND; - break; - case QRGN_SUB: - both = RGN_DIFF; - left = RGN_COPY; - break; - case QRGN_XOR: - both = RGN_XOR; - left = right = RGN_COPY; - break; - default: - qWarning("QRegion: Internal error in winCombine"); - } - - int allCombineRgnResults = NULLREGION; - QRegion result; - result.detach(); - result.d->rgn = qt_tryCreateRegion(QRegion::Rectangle, 0, 0, 0, 0); - if (d->rgn && r.d->rgn) - allCombineRgnResults = CombineRgn(result.d->rgn, d->rgn, r.d->rgn, both); - else if (d->rgn && left != RGN_NOP) - allCombineRgnResults = CombineRgn(result.d->rgn, d->rgn, d->rgn, left); - else if (r.d->rgn && right != RGN_NOP) - allCombineRgnResults = CombineRgn(result.d->rgn, r.d->rgn, r.d->rgn, right); - - if (allCombineRgnResults == NULLREGION || allCombineRgnResults == ERROR) - result = QRegion(); - - //##### do not delete this. A null pointer is different from an empty region in SelectClipRgn in qpainter_win! (M) -// if (allCombineRgnResults == NULLREGION) { -// if (result.data->rgn) -// DeleteObject(result.data->rgn); -// result.data->rgn = 0; // empty region -// } - return result; -} - -QRegion QRegion::unite(const QRegion &r) const -{ - if (!d->rgn) - return r; - if (!r.d->rgn) - return *this; - return winCombine(r, QRGN_OR); -} - -QRegion QRegion::unite(const QRect &r) const -{ - return unite(QRegion(r)); -} - -QRegion QRegion::intersect(const QRegion &r) const -{ - if (!r.d->rgn || !d->rgn) - return QRegion(); - return winCombine(r, QRGN_AND); -} - -QRegion QRegion::subtract(const QRegion &r) const -{ - if (!r.d->rgn || !d->rgn) - return *this; - return winCombine(r, QRGN_SUB); -} - -QRegion QRegion::eor(const QRegion &r) const -{ - if (!d->rgn) - return r; - if (!r.d->rgn) - return *this; - return winCombine(r, QRGN_XOR); -} - - -QRect QRegion::boundingRect() const -{ - if (!d->rgn) - return QRect(); - RECT r; - if (GetRgnBox(d->rgn, &r) == NULLREGION) - return QRect(); - else - return QRect(r.left, r.top, r.right - r.left, r.bottom - r.top); -} - -QVector QRegion::rects() const -{ - if (d->rgn == 0) - return QVector(); - - int numBytes = GetRegionData(d->rgn, 0, 0); + int numBytes = GetRegionData(rgn, 0, 0); if (numBytes == 0) - return QVector(); + return QRegion(); char *buf = new char[numBytes]; if (buf == 0) - return QVector(); + return QRegion(); RGNDATA *rd = reinterpret_cast(buf); - if (GetRegionData(d->rgn, numBytes, rd) == 0) { + if (GetRegionData(rgn, numBytes, rd) == 0) { delete [] buf; - return QVector(); + return QRegion(); } - QVector a(rd->rdh.nCount); + QRegion region; RECT *r = reinterpret_cast(rd->Buffer); - for (int i = 0; i < a.size(); ++i) { - a[i].setCoords(r->left, r->top, r->right - 1, r->bottom - 1); + for (int i = 0; i < rd->rdh.nCount; ++i) { + QRect rect; + rect.setCoords(r->left, r->top, r->right - 1, r->bottom - 1); ++r; + region |= rect; } delete [] buf; - return a; -} - -void QRegion::setRects(const QRect *rects, int num) -{ - *this = QRegion(); - if (!rects || num == 0 || (num == 1 && rects->isEmpty())) - return; - for (int i = 0; i < num; ++i) - *this |= rects[i]; -} - -int QRegion::numRects() const -{ - if (d->rgn == 0) - return 0; - - const int numBytes = GetRegionData(d->rgn, 0, 0); - if (numBytes == 0) - return 0; - - char *buf = new char[numBytes]; - if (buf == 0) - return 0; - - RGNDATA *rd = reinterpret_cast(buf); - if (GetRegionData(d->rgn, numBytes, rd) == 0) { - delete[] buf; - return 0; - } - - const int n = rd->rdh.nCount; - delete[] buf; - return n; + return region; } -bool QRegion::operator==(const QRegion &r) const +void qt_win_dispose_rgn(HRGN r) { - if (d == r.d) - return true; - if ((d->rgn == 0) ^ (r.d->rgn == 0)) // one is empty, not both - return false; - return d->rgn == 0 ? true // both empty - : EqualRgn(d->rgn, r.d->rgn); // both non-empty + if (r) + DeleteObject(r); } -QRegion& QRegion::operator+=(const QRegion &r) +static void qt_add_rect(HRGN &winRegion, QRect r) { - if (!r.d->rgn) - return *this; - - if (!d->rgn) { - *this = r; - return *this; + HRGN rgn = CreateRectRgn(r.left(), r.top(), r.x() + r.width(), r.y() + r.height()); + if (rgn) { + HRGN dest = CreateRectRgn(0,0,0,0); + int result = CombineRgn(dest, winRegion, rgn, RGN_OR); + if (result) { + DeleteObject(winRegion); + winRegion = dest; + } + DeleteObject(rgn); } - - detach(); - - int result; - result = CombineRgn(d->rgn, d->rgn, r.d->rgn, RGN_OR); - if (result == NULLREGION || result == ERROR) - *this = QRegion(); - - return *this; -} - -QRegion& QRegion::operator-=(const QRegion &r) -{ - if (!r.d->rgn || !d->rgn) - return *this; - - detach(); - - int result; - result = CombineRgn(d->rgn, d->rgn, r.d->rgn, RGN_DIFF); - if (result == NULLREGION || result == ERROR) - *this = QRegion(); - - return *this; } -QRegion& QRegion::operator&=(const QRegion &r) +void QRegion::ensureHandle() const { - if (!d->rgn) - return *this; - - if (!r.d->rgn) { - *this = QRegion(); - return *this; + if (d->rgn) + DeleteObject(d->rgn); + d->rgn = CreateRectRgn(0,0,0,0); + if (d->qt_rgn) { + if (d->qt_rgn->numRects == 1) { + QRect r = d->qt_rgn->extents; + qt_add_rect(d->rgn, r); + return; + } + for (int i = 0;i < d->qt_rgn->numRects;i++) { + QRect r = d->qt_rgn->rects.at(i); + qt_add_rect(d->rgn, r); + } } - - detach(); - - int result; - result = CombineRgn(d->rgn, d->rgn, r.d->rgn, RGN_AND); - if (result == NULLREGION || result == ERROR) - *this = QRegion(); - - return *this; -} - -bool qt_region_strictContains(const QRegion ®ion, const QRect &rect) -{ - Q_UNUSED(region); - Q_UNUSED(rect); - return false; } -void QRegion::ensureHandle() const -{ -} QT_END_NAMESPACE diff --git a/src/gui/painting/qregion_wince.cpp b/src/gui/painting/qregion_wince.cpp deleted file mode 100644 index 9c33123..0000000 --- a/src/gui/painting/qregion_wince.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qatomic.h" -#include "qbitmap.h" -#include "qbuffer.h" -#include "qimage.h" -#include "qpolygon.h" -#include "qregion.h" -#include "qt_windows.h" -#include "qpainterpath.h" -#include "qguifunctions_wince.h" - -QT_BEGIN_NAMESPACE - -QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0 }; - -HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, int bottom) -{ - const int tries = 10; - for (int i = 0; i < tries; ++i) { - HRGN region; - switch (type) { - case QRegion::Rectangle: - region = CreateRectRgn(left, top, right, bottom); - break; - case QRegion::Ellipse: -#ifndef Q_OS_WINCE - region = CreateEllipticRgn(left, top, right, bottom); -#endif - break; - } - if (region) { - if (GetRegionData(region, 0, 0)) - return region; - else - DeleteObject(region); - } - } - return 0; -} - -void qt_win_dispose_rgn(HRGN r) -{ - if (r) - DeleteObject(r); -} - -static void qt_add_rect(HRGN &winRegion, QRect r) -{ - HRGN rgn = CreateRectRgn(r.left(), r.top(), r.x() + r.width(), r.y() + r.height()); - if (rgn) { - HRGN dest = CreateRectRgn(0,0,0,0); - int result = CombineRgn(dest, winRegion, rgn, RGN_OR); - if (result) { - DeleteObject(winRegion); - winRegion = dest; - } - } -} - -void QRegion::ensureHandle() const -{ - if (d->rgn) - DeleteObject(d->rgn); - d->rgn = CreateRectRgn(0,0,0,0); - if (d->qt_rgn) { - if (d->qt_rgn->numRects == 1) { - QRect r = d->qt_rgn->extents; - qt_add_rect(d->rgn, r); - return; - } - for (int i = 0;i < d->qt_rgn->numRects;i++) { - QRect r = d->qt_rgn->rects.at(i); - qt_add_rect(d->rgn, r); - } - } -} - - -QT_END_NAMESPACE diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 9560c4b..ad87354 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -134,6 +134,7 @@ static const int windowsRightBorder = 12; // right border on windows // External function calls extern Q_GUI_EXPORT HDC qt_win_display_dc(); +extern QRegion qt_region_from_HRGN(HRGN rgn); @@ -445,6 +446,7 @@ bool QWindowsXPStylePrivate::isTransparent(XPThemeData &themeData) themeData.stateId); } + /*! \internal Returns a QRegion of the region of the part */ @@ -456,12 +458,18 @@ QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData) themeData.stateId, &rect, &hRgn))) return QRegion(); - QRegion rgn = QRegion(0,0,1,1); - const bool success = CombineRgn(rgn.handle(), hRgn, 0, RGN_COPY) != ERROR; - DeleteObject(hRgn); + HRGN dest = CreateRectRgn(0, 0, 0, 0); + const bool success = CombineRgn(dest, hRgn, 0, RGN_COPY) != ERROR; + + QRegion region; + if (success) - return rgn; - return QRegion(); + region = qt_region_from_HRGN(dest); + + DeleteObject(hRgn); + DeleteObject(dest); + + return region; } /*! \internal -- cgit v0.12 From 66a3c503e8e99b8cd28c2fef2b0a869f27c7efe7 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Thu, 30 Jul 2009 13:59:57 +0200 Subject: Doc - some cleanups to beautify the paragraphs Reviewed-By: TrustMe --- src/gui/kernel/qapplication.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 5181689..109ceb1 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -179,11 +179,11 @@ QApplicationPrivate::~QApplicationPrivate() QApplication contains the main event loop, where all events from the window system and other sources are processed and dispatched. It also handles the - application's initialization and finalization, and provides session - management. In addition, it handles most system-wide and application-wide - settings. + application's initialization, finalization, and provides session + management. In addition, QApplication handles most of the system-wide and + application-wide settings. - For any GUI application using Qt, there is precisely one QApplication + For any GUI application using Qt, there is precisely \bold one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time. For non-GUI Qt applications, use QCoreApplication instead, as it does not depend on the \l QtGui library. @@ -239,9 +239,9 @@ QApplicationPrivate::~QApplicationPrivate() saveState() for details. \endlist - The QApplication object does so much initialization. Hence, it \e{must} be + Since the QApplication object does so much initialization, it \e{must} be created before any other objects related to the user interface are created. - Since QApplication also deals with common command line arguments, it is + QApplication also deals with common command line arguments. Hence, it is usually a good idea to create it \e before any interpretation or modification of \c argv is done in the application itself. -- cgit v0.12 From e1851f3246fe307830173573fbbcf013e8a1b1e8 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 30 Jul 2009 14:11:07 +0200 Subject: Remove mem leak / warning in the cocoaport Remove mem leak / warning in the cocoaport Reviewed-by: msorvig --- src/gui/kernel/qwidget_mac.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 0a31a28..8913c89 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4674,6 +4674,7 @@ void QWidgetPrivate::setModal_sys() OSWindowRef windowRef = qt_mac_window_for(q); #ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; bool alreadySheet = [windowRef styleMask] & NSDocModalWindowMask; if (windowParent && q->windowModality() == Qt::WindowModal){ -- cgit v0.12 From 26e9f4e077c49d1191835def595e4fb70ee50be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Thu, 30 Jul 2009 14:19:50 +0200 Subject: Mac/Carbon: Fix issue causing update(QRegion) to fail on large widgets. HIViewSetNeedsDisplayInRegion fails on large regions with large coordinates, fall back on updating the entire region in this case. The task mentions coordinates outside the range of signed short, but the provided example demonstrates failures in the 10-20K range as well. --- src/gui/kernel/qwidget_mac.mm | 7 ++++++- src/gui/painting/qregion.h | 1 + src/gui/painting/qregion_mac.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 70eea3a..3bbf5d4 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3100,7 +3100,12 @@ void QWidgetPrivate::update_sys(const QRegion &rgn) return; dirtyOnWidget += rgn; #ifndef QT_MAC_USE_COCOA - HIViewSetNeedsDisplayInRegion(qt_mac_nativeview_for(q), QMacSmartQuickDrawRegion(rgn.toQDRgn()), true); + RgnHandle rgnHandle = rgn.toQDRgnForUpdate_sys(); + if (rgnHandle) + HIViewSetNeedsDisplayInRegion(qt_mac_nativeview_for(q), QMacSmartQuickDrawRegion(rgnHandle), true); + else { + HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true); // do a complete repaint on overflow. + } #else // Cocoa doesn't do regions, it seems more efficient to just update the bounding rect instead of a potential number of message passes for each rect. const QRect &boundingRect = rgn.boundingRect(); diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index bfedcb1..6dfdc83 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -148,6 +148,7 @@ public: #elif defined(Q_WS_MAC) #if defined Q_WS_MAC32 RgnHandle toQDRgn() const; + RgnHandle toQDRgnForUpdate_sys() const; static QRegion fromQDRgn(RgnHandle shape); #endif #ifdef QT_MAC_USE_COCOA diff --git a/src/gui/painting/qregion_mac.cpp b/src/gui/painting/qregion_mac.cpp index b57f234..9b0e99f 100644 --- a/src/gui/painting/qregion_mac.cpp +++ b/src/gui/painting/qregion_mac.cpp @@ -155,6 +155,44 @@ RgnHandle QRegion::toQDRgn() const } return rgnHandle; } + +/*! + \internal + Create's a RegionHandle, it's the caller's responsibility to release. + Returns 0 if the QRegion overflows. +*/ +RgnHandle QRegion::toQDRgnForUpdate_sys() const +{ + RgnHandle rgnHandle = qt_mac_get_rgn(); + if(d->qt_rgn && d->qt_rgn->numRects) { + RgnHandle tmp_rgn = qt_mac_get_rgn(); + int n = d->qt_rgn->numRects; + const QRect *qt_r = (n == 1) ? &d->qt_rgn->extents : d->qt_rgn->rects.constData(); + while (n--) { + + // detect overflow. Tested for use with HIViewSetNeedsDisplayInRegion + // in QWidgetPrivate::update_sys(). + enum { HIViewSetNeedsDisplayInRegionOverflow = 10000 }; // empirically determined conservative value + qDebug() << qt_r->x() << qt_r->y() << qt_r->right() << qt_r->bottom(); + if (qt_r->right() > HIViewSetNeedsDisplayInRegionOverflow || qt_r->bottom() > HIViewSetNeedsDisplayInRegionOverflow) { + qt_mac_dispose_rgn(tmp_rgn); + qt_mac_dispose_rgn(rgnHandle); + return 0; + } + + SetRectRgn(tmp_rgn, + qMax(SHRT_MIN, qt_r->x()), + qMax(SHRT_MIN, qt_r->y()), + qMin(SHRT_MAX, qt_r->right() + 1), + qMin(SHRT_MAX, qt_r->bottom() + 1)); + UnionRgn(rgnHandle, tmp_rgn, rgnHandle); + ++qt_r; + } + qt_mac_dispose_rgn(tmp_rgn); + } + return rgnHandle; +} + #endif #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) -- cgit v0.12 From 9939ce88427b4d33f50b45a0da85266f9ee37927 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 5 Jun 2009 16:59:17 +0200 Subject: Don't do two hash lookups in loadGlyphs() loadGlyphs() has a big impact on text rendering speed on X11. Removing the uneeded hash lookup makes this function go twice as fast, as it in the common case (where the glyphs are already cached) the hash lookups are 100% of the running time of the function. Reviewed-by: Trond --- src/gui/text/qfontengine_ft.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index a0b6f0c..d210cb4 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1378,8 +1378,8 @@ bool QFontEngineFT::loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, G FT_Face face = 0; for (int i = 0; i < num_glyphs; ++i) { - if (!gs->glyph_data.contains(glyphs[i]) - || gs->glyph_data.value(glyphs[i])->format != format) { + Glyph *glyph = gs->glyph_data.value(glyphs[i]); + if (glyph == 0 || glyph->format != format) { if (!face) { face = lockFace(); FT_Matrix m = matrix; -- cgit v0.12 From aec91cf6fbfa6abd4a3548690fd22ebeb6237cf6 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 29 Jul 2009 12:15:57 +0200 Subject: updates... --- .../data/qps/linear_gradients_perspectives_qps.png | Bin 78017 -> 77944 bytes tests/arthur/data/qps/linear_gradients_qps.png | Bin 82119 -> 162643 bytes tests/arthur/data/qps/lineconsistency_qps.png | Bin 12500 -> 12388 bytes tests/arthur/data/qps/linedashes2_aa_qps.png | Bin 28956 -> 28418 bytes tests/arthur/data/qps/paths_aa_qps.png | Bin 92711 -> 92147 bytes tests/arthur/data/qps/paths_qps.png | Bin 20637 -> 20392 bytes .../data/qps/radial_gradients_perspectives_qps.png | Bin 133150 -> 131744 bytes tests/arthur/data/qps/radial_gradients_qps.png | Bin 156036 -> 161009 bytes tests/arthur/data/qps/rasterops.qps | 167 +++++++++++---------- tests/arthur/data/qps/rasterops_qps.png | Bin 20400 -> 11059 bytes tests/arthur/data/qps/text_perspectives_qps.png | Bin 112750 -> 116847 bytes tests/arthur/data/qps/text_qps.png | Bin 72027 -> 32991 bytes tests/arthur/lance/interactivewidget.cpp | 2 +- tests/arthur/lance/lance.pro | 2 +- tests/arthur/lance/main.cpp | 16 +- tests/arthur/lance/widgets.h | 151 ++++++++++++++++++- 16 files changed, 234 insertions(+), 104 deletions(-) diff --git a/tests/arthur/data/qps/linear_gradients_perspectives_qps.png b/tests/arthur/data/qps/linear_gradients_perspectives_qps.png index 42ba872..3315ebe 100644 Binary files a/tests/arthur/data/qps/linear_gradients_perspectives_qps.png and b/tests/arthur/data/qps/linear_gradients_perspectives_qps.png differ diff --git a/tests/arthur/data/qps/linear_gradients_qps.png b/tests/arthur/data/qps/linear_gradients_qps.png index dc5223b..a4cdc43 100644 Binary files a/tests/arthur/data/qps/linear_gradients_qps.png and b/tests/arthur/data/qps/linear_gradients_qps.png differ diff --git a/tests/arthur/data/qps/lineconsistency_qps.png b/tests/arthur/data/qps/lineconsistency_qps.png index 48768ef..9d19a5d 100644 Binary files a/tests/arthur/data/qps/lineconsistency_qps.png and b/tests/arthur/data/qps/lineconsistency_qps.png differ diff --git a/tests/arthur/data/qps/linedashes2_aa_qps.png b/tests/arthur/data/qps/linedashes2_aa_qps.png index 0cb5b40..54c84b3 100644 Binary files a/tests/arthur/data/qps/linedashes2_aa_qps.png and b/tests/arthur/data/qps/linedashes2_aa_qps.png differ diff --git a/tests/arthur/data/qps/paths_aa_qps.png b/tests/arthur/data/qps/paths_aa_qps.png index 45b4b74..e51a4ac 100644 Binary files a/tests/arthur/data/qps/paths_aa_qps.png and b/tests/arthur/data/qps/paths_aa_qps.png differ diff --git a/tests/arthur/data/qps/paths_qps.png b/tests/arthur/data/qps/paths_qps.png index a9a8743..094a84f 100644 Binary files a/tests/arthur/data/qps/paths_qps.png and b/tests/arthur/data/qps/paths_qps.png differ diff --git a/tests/arthur/data/qps/radial_gradients_perspectives_qps.png b/tests/arthur/data/qps/radial_gradients_perspectives_qps.png index 0e28aae..d833250 100644 Binary files a/tests/arthur/data/qps/radial_gradients_perspectives_qps.png and b/tests/arthur/data/qps/radial_gradients_perspectives_qps.png differ diff --git a/tests/arthur/data/qps/radial_gradients_qps.png b/tests/arthur/data/qps/radial_gradients_qps.png index 66fcfc4..11043e8 100644 Binary files a/tests/arthur/data/qps/radial_gradients_qps.png and b/tests/arthur/data/qps/radial_gradients_qps.png differ diff --git a/tests/arthur/data/qps/rasterops.qps b/tests/arthur/data/qps/rasterops.qps index b79ec0d..ee3deca 100644 --- a/tests/arthur/data/qps/rasterops.qps +++ b/tests/arthur/data/qps/rasterops.qps @@ -1,83 +1,84 @@ -setPen NoPen - -setBrush black -drawRect 10 10 1200 140 - -setCompositionMode SourceOrDestination -translate 20 20 -begin_block drawShape -setBrush 0xffff0000 -drawEllipse 10 10 80 80 -setBrush 0xff00ff00 -drawRect 0 0 50 50 -setBrush 0xff0000ff -drawRect 50 50 50 50 -end_block - -begin_block loop -setCompositionMode SourceAndDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode SourceXorDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode NotSourceAndNotDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode NotSourceOrNotDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode NotSourceXorDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode NotSource -translate 120 0 -repeat_block drawShape - -setCompositionMode NotSourceAndDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode SourceAndNotDestination -translate 120 0 -repeat_block drawShape -end_block - -resetMatrix -setCompositionMode Source -setBrush white -drawRect 10 160 1200 140 -translate 20 170 -repeat_block loop - -resetMatrix -setCompositionMode Source -translate 20 320 -repeat_block loop - -resetMatrix -setPen black -setCompositionMode SourceOver -translate 20 470 -drawText 20 0 "Or ROP" -translate 120 0 -drawText 20 0 "And ROP" -translate 120 0 -drawText 20 0 "Xor ROP" -translate 120 0 -drawText 20 0 "Nor ROP" -translate 120 0 -drawText 20 0 "Nand ROP" -translate 120 0 -drawText 0 0 "NSrcXorDst ROP" -translate 120 0 -drawText 20 0 "NSrc ROP" -translate 120 0 -drawText 0 0 "NSrcAndDst ROP" -translate 120 0 -drawText 0 0 "SrcAndNDst ROP" +setPen NoPen + +setBrush black +drawRect 10 10 60 500 + +setCompositionMode SourceOrDestination +translate 20 20 + +begin_block drawShape + setBrush 0xffff0000 + drawEllipse 5 5 30 30 + setBrush 0xff00ff00 + drawRect 0 0 20 20 + setBrush 0xff0000ff + drawRect 20 20 20 20 +end_block + +begin_block loop + setCompositionMode SourceAndDestination + translate 0 50 +repeat_block drawShape + +setCompositionMode SourceXorDestination +translate 0 50 +repeat_block drawShape + +setCompositionMode NotSourceAndNotDestination +translate 0 50 +repeat_block drawShape + +setCompositionMode NotSourceOrNotDestination +translate 0 50 +repeat_block drawShape + +setCompositionMode NotSourceXorDestination +translate 0 50 +repeat_block drawShape + +setCompositionMode NotSource +translate 0 50 +repeat_block drawShape + +setCompositionMode NotSourceAndDestination +translate 0 50 +repeat_block drawShape + +setCompositionMode SourceAndNotDestination +translate 0 50 +repeat_block drawShape +end_block + +resetMatrix +setCompositionMode Source +setBrush white +drawRect 100 10 60 500 +translate 110 20 +repeat_block loop + +resetMatrix +setCompositionMode Source +translate 190 20 +repeat_block loop + +resetMatrix +setPen black +setCompositionMode SourceOver +translate 250 45 +drawText 20 0 "Or ROP" +translate 0 50 +drawText 20 0 "And ROP" +translate 0 50 +drawText 20 0 "Xor ROP" +translate 0 50 +drawText 20 0 "Nor ROP" +translate 0 50 +drawText 20 0 "Nand ROP" +translate 0 50 +drawText 0 0 "NSrcXorDst ROP" +translate 0 50 +drawText 20 0 "NSrc ROP" +translate 0 50 +drawText 0 0 "NSrcAndDst ROP" +translate 0 50 +drawText 0 0 "SrcAndNDst ROP" diff --git a/tests/arthur/data/qps/rasterops_qps.png b/tests/arthur/data/qps/rasterops_qps.png index 80ca8ae..7b93001 100644 Binary files a/tests/arthur/data/qps/rasterops_qps.png and b/tests/arthur/data/qps/rasterops_qps.png differ diff --git a/tests/arthur/data/qps/text_perspectives_qps.png b/tests/arthur/data/qps/text_perspectives_qps.png index 483ccc0..183ad6f 100644 Binary files a/tests/arthur/data/qps/text_perspectives_qps.png and b/tests/arthur/data/qps/text_perspectives_qps.png differ diff --git a/tests/arthur/data/qps/text_qps.png b/tests/arthur/data/qps/text_qps.png index 2c2ebf2..9a95493 100644 Binary files a/tests/arthur/data/qps/text_qps.png and b/tests/arthur/data/qps/text_qps.png differ diff --git a/tests/arthur/lance/interactivewidget.cpp b/tests/arthur/lance/interactivewidget.cpp index 0febbed..0c2c7a6 100644 --- a/tests/arthur/lance/interactivewidget.cpp +++ b/tests/arthur/lance/interactivewidget.cpp @@ -43,7 +43,7 @@ InteractiveWidget::InteractiveWidget() { - m_onScreenWidget = new OnScreenWidget(); + m_onScreenWidget = new OnScreenWidget(""); m_onScreenWidget->setMinimumSize(320, 240); setCentralWidget(m_onScreenWidget); diff --git a/tests/arthur/lance/lance.pro b/tests/arthur/lance/lance.pro index 193dbd2..ee9e08b 100644 --- a/tests/arthur/lance/lance.pro +++ b/tests/arthur/lance/lance.pro @@ -6,7 +6,7 @@ INCLUDEPATH += . # Input HEADERS += widgets.h interactivewidget.h -SOURCES += interactivewidget.cpp main.cpp +SOURCES += interactivewidget.cpp main.cpp RESOURCES += icons.qrc contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2):QT += opengl diff --git a/tests/arthur/lance/main.cpp b/tests/arthur/lance/main.cpp index 07e5180..f95b426 100644 --- a/tests/arthur/lance/main.cpp +++ b/tests/arthur/lance/main.cpp @@ -66,7 +66,7 @@ extern bool qt_show_painter_debug_output = false; //#define CONSOLE_APPLICATION -static const struct { +static const struct { const char *name; QImage::Format format; } imageFormats[] = { @@ -282,7 +282,7 @@ int main(int argc, char **argv) if (imageFormat == QImage::Format_Invalid) { printf("Invalid image format. Available formats are:\n"); - for (int ff = 0; ff < formatCount; ++ff) + for (int ff = 0; ff < formatCount; ++ff) printf("\t%s\n", imageFormats[ff].name); return -1; } @@ -403,12 +403,10 @@ int main(int argc, char **argv) case WidgetType: { OnScreenWidget *qWidget = - new OnScreenWidget; + new OnScreenWidget(files.at(j)); qWidget->setVerboseMode(verboseMode); qWidget->setType(type); qWidget->setCheckersBackground(checkers_background); - qWidget->m_filename = files.at(j); - qWidget->setWindowTitle(fileinfo.filePath()); qWidget->m_commands = content; qWidget->resize(width, height); qWidget->show(); @@ -418,12 +416,10 @@ int main(int argc, char **argv) case ImageWidgetType: { - OnScreenWidget *qWidget = new OnScreenWidget; + OnScreenWidget *qWidget = new OnScreenWidget(files.at(j)); qWidget->setVerboseMode(verboseMode); qWidget->setType(type); qWidget->setCheckersBackground(checkers_background); - qWidget->m_filename = files.at(j); - qWidget->setWindowTitle(fileinfo.filePath()); qWidget->m_commands = content; qWidget->resize(width, height); qWidget->show(); @@ -452,12 +448,10 @@ int main(int argc, char **argv) } case OpenGLType: { - OnScreenWidget *qGLWidget = new OnScreenWidget; + OnScreenWidget *qGLWidget = new OnScreenWidget(files.at(j)); qGLWidget->setVerboseMode(verboseMode); qGLWidget->setType(type); qGLWidget->setCheckersBackground(checkers_background); - qGLWidget->m_filename = files.at(j); - qGLWidget->setWindowTitle(fileinfo.filePath()); qGLWidget->m_commands = content; qGLWidget->resize(width, height); qGLWidget->show(); diff --git a/tests/arthur/lance/widgets.h b/tests/arthur/lance/widgets.h index 271c18a..7247608 100644 --- a/tests/arthur/lance/widgets.h +++ b/tests/arthur/lance/widgets.h @@ -57,15 +57,47 @@ #include #include +#include + #include const int CP_RADIUS = 10; +class StupidWorkaround : public QObject +{ + Q_OBJECT +public: + StupidWorkaround(QWidget *widget, int *value) + : QObject(widget), w(widget), mode(value) + { + } + +public slots: + void setViewMode(int m) { + *mode = m; + w->update(); + } + +private: + QWidget *w; + int *mode; +}; + template class OnScreenWidget : public T { public: - OnScreenWidget(QWidget *parent = 0) : T(parent) + + enum ViewMode { + RenderView, + BaselineView, + DifferenceView + }; + + OnScreenWidget(const QString &file, QWidget *parent = 0) + : T(parent), + m_view_mode(RenderView), + m_filename(file) { QSettings settings("Trolltech", "lance"); for (int i=0; i<10; ++i) { @@ -78,11 +110,47 @@ public: m_deviceType = WidgetType; m_checkersBackground = true; m_verboseMode = false; - } - void setVerboseMode(bool v) { m_verboseMode = v; } - void setCheckersBackground(bool b) { m_checkersBackground = b; } - void setType(DeviceType t) { m_deviceType = t; } + m_baseline_name = QString(m_filename).replace(".qps", "_qps") + ".png"; + if (QFileInfo(m_baseline_name).exists()) { + m_baseline = QPixmap(m_baseline_name); + } + + if (m_baseline.isNull()) { + setWindowTitle("Rendering: '" + file + "'. No baseline available"); + } else { + setWindowTitle("Rendering: '" + file + "'. Shortcuts: 1=render, 2=baseline, 3=difference"); + + StupidWorkaround *workaround = new StupidWorkaround(this, &m_view_mode); + + QSignalMapper *mapper = new QSignalMapper(this); + connect(mapper, SIGNAL(mapped(int)), workaround, SLOT(setViewMode(int))); + connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setWindowTitle(QString))); + + QAction *renderViewAction = new QAction("Render View", this); + renderViewAction->setShortcut(Qt::Key_1); + connect(renderViewAction, SIGNAL(triggered()), mapper, SLOT(map())); + mapper->setMapping(renderViewAction, RenderView); + mapper->setMapping(renderViewAction, "Render View: " + file); + addAction(renderViewAction); + + QAction *baselineAction = new QAction("Baseline", this); + baselineAction->setShortcut(Qt::Key_2); + connect(baselineAction, SIGNAL(triggered()), mapper, SLOT(map())); + mapper->setMapping(baselineAction, BaselineView); + mapper->setMapping(baselineAction, "Baseline View: " + file); + addAction(baselineAction); + + QAction *differenceAction = new QAction("Differenfe View", this); + differenceAction->setShortcut(Qt::Key_3); + connect(differenceAction, SIGNAL(triggered()), mapper, SLOT(map())); + mapper->setMapping(differenceAction, DifferenceView); + mapper->setMapping(differenceAction, "Difference View" + file); + addAction(differenceAction); + + } + + } ~OnScreenWidget() { @@ -93,12 +161,24 @@ public: settings.sync(); } + void setVerboseMode(bool v) { m_verboseMode = v; } + void setCheckersBackground(bool b) { m_checkersBackground = b; } + void setType(DeviceType t) { m_deviceType = t; } + void resizeEvent(QResizeEvent *e) { m_image = QImage(); T::resizeEvent(e); } - void paintEvent(QPaintEvent *) + void paintEvent(QPaintEvent *) { + switch (m_view_mode) { + case RenderView: paintRenderView(); break; + case BaselineView: paintBaselineView(); break; + case DifferenceView: paintDifferenceView(); break; + } + } + + void OnScreenWidget::paintRenderView() { QPainter pt; QPaintDevice *dev = this; @@ -152,6 +232,57 @@ public: } } + if (m_render_view.isNull()) { + m_render_view = window()->windowSurface()->grabWidget(this); + m_render_view.save("renderView.png"); + } + } + + void paintBaselineView() { + QPainter p(this); + + if (m_baseline.isNull()) { + p.drawText(rect(), Qt::AlignCenter, + "No baseline found\n" + "file '" + m_baseline_name + "' does not exist..."); + return; + } + + p.drawPixmap(0, 0, m_baseline); + + p.setPen(QColor::fromRgb(0, 0, 0, 0.1)); + p.setFont(QFont("Arial", 128)); + p.rotate(45); + p.drawText(100, 0, "BASELINE"); + } + + QPixmap generateDifference() + { + QImage img(size(), QImage::Format_RGB32); + img.fill(0); + + QPainter p(&img); + p.drawPixmap(0, 0, m_render_view); + + p.setCompositionMode(QPainter::RasterOp_SourceXorDestination); + p.drawPixmap(0, 0, m_baseline); + + p.end(); + + return QPixmap::fromImage(img); + } + + void paintDifferenceView() { + QPainter p(this); + if (m_baseline.isNull()) { + p.drawText(rect(), Qt::AlignCenter, + "No baseline found\n" + "file '" + m_baseline_name + "' does not exist..."); + return; + } + + p.fillRect(rect(), Qt::black); + p.drawPixmap(0, 0, generateDifference()); } @@ -190,8 +321,6 @@ public: T::update(); } - - QSize sizeHint() const { return QSize(800, 800); } QVector m_controlPoints; @@ -200,12 +329,18 @@ public: QStringList m_commands; QString m_filename; + QString m_baseline_name; bool m_verboseMode; bool m_checkersBackground; DeviceType m_deviceType; + int m_view_mode; + QImage m_image; + + QPixmap m_baseline; + QPixmap m_render_view; }; #endif -- cgit v0.12 From efc7c605c5f561a75a718f8186e470bd24a18b4e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 30 Jul 2009 14:35:07 +0200 Subject: Autotest: add a newline after the user program headers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the user forgot to end their headers with a newline, the compilation would fail because the next line is #include . Reviewed-by: Jesper Thomschütz --- tests/auto/qsharedpointer/externaltests.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qsharedpointer/externaltests.cpp b/tests/auto/qsharedpointer/externaltests.cpp index d1618d1..6542350 100644 --- a/tests/auto/qsharedpointer/externaltests.cpp +++ b/tests/auto/qsharedpointer/externaltests.cpp @@ -324,6 +324,7 @@ namespace QTest { sourceCode.reserve(8192); sourceCode += programHeader; + sourceCode += '\n'; // Add Qt header includes if (qtModules & QExternalTest::QtCore) -- cgit v0.12 From eb8c2574848da1a418dbcec6f43699b2a2bc7edc Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 30 Jul 2009 14:47:14 +0200 Subject: Doc: Move class and function documentation into a dedicated directory. --- doc/src/classes/phonon-api.qdoc | 5023 +++++++++++++++++++++++++++++++++ doc/src/classes/q3asciicache.qdoc | 465 +++ doc/src/classes/q3asciidict.qdoc | 416 +++ doc/src/classes/q3cache.qdoc | 461 +++ doc/src/classes/q3dict.qdoc | 446 +++ doc/src/classes/q3intcache.qdoc | 446 +++ doc/src/classes/q3intdict.qdoc | 390 +++ doc/src/classes/q3memarray.qdoc | 523 ++++ doc/src/classes/q3popupmenu.qdoc | 76 + doc/src/classes/q3ptrdict.qdoc | 388 +++ doc/src/classes/q3ptrlist.qdoc | 1157 ++++++++ doc/src/classes/q3ptrqueue.qdoc | 230 ++ doc/src/classes/q3ptrstack.qdoc | 217 ++ doc/src/classes/q3ptrvector.qdoc | 427 +++ doc/src/classes/q3sqlfieldinfo.qdoc | 234 ++ doc/src/classes/q3sqlrecordinfo.qdoc | 89 + doc/src/classes/q3valuelist.qdoc | 569 ++++ doc/src/classes/q3valuestack.qdoc | 149 + doc/src/classes/q3valuevector.qdoc | 274 ++ doc/src/classes/qalgorithms.qdoc | 651 +++++ doc/src/classes/qcache.qdoc | 244 ++ doc/src/classes/qcolormap.qdoc | 152 + doc/src/classes/qdesktopwidget.qdoc | 266 ++ doc/src/classes/qiterator.qdoc | 1431 ++++++++++ doc/src/classes/qmacstyle.qdoc | 261 ++ doc/src/classes/qpagesetupdialog.qdoc | 84 + doc/src/classes/qpaintdevice.qdoc | 289 ++ doc/src/classes/qpair.qdoc | 229 ++ doc/src/classes/qpatternistdummy.cpp | 1010 +++++++ doc/src/classes/qplugin.qdoc | 135 + doc/src/classes/qprintdialog.qdoc | 72 + doc/src/classes/qprinterinfo.qdoc | 137 + doc/src/classes/qset.qdoc | 953 +++++++ doc/src/classes/qsignalspy.qdoc | 98 + doc/src/classes/qsizepolicy.qdoc | 522 ++++ doc/src/classes/qtdesigner-api.qdoc | 1413 ++++++++++ doc/src/classes/qtendian.qdoc | 168 ++ doc/src/classes/qtestevent.qdoc | 191 ++ doc/src/classes/qvarlengtharray.qdoc | 274 ++ doc/src/classes/qwaitcondition.qdoc | 188 ++ doc/src/phonon-api.qdoc | 5023 --------------------------------- doc/src/q3asciicache.qdoc | 465 --- doc/src/q3asciidict.qdoc | 416 --- doc/src/q3cache.qdoc | 461 --- doc/src/q3dict.qdoc | 446 --- doc/src/q3intcache.qdoc | 446 --- doc/src/q3intdict.qdoc | 390 --- doc/src/q3memarray.qdoc | 523 ---- doc/src/q3popupmenu.qdoc | 76 - doc/src/q3ptrdict.qdoc | 388 --- doc/src/q3ptrlist.qdoc | 1157 -------- doc/src/q3ptrqueue.qdoc | 230 -- doc/src/q3ptrstack.qdoc | 217 -- doc/src/q3ptrvector.qdoc | 427 --- doc/src/q3sqlfieldinfo.qdoc | 234 -- doc/src/q3sqlrecordinfo.qdoc | 89 - doc/src/q3valuelist.qdoc | 569 ---- doc/src/q3valuestack.qdoc | 149 - doc/src/q3valuevector.qdoc | 274 -- doc/src/qalgorithms.qdoc | 651 ----- doc/src/qcache.qdoc | 244 -- doc/src/qcolormap.qdoc | 152 - doc/src/qdesktopwidget.qdoc | 266 -- doc/src/qiterator.qdoc | 1431 ---------- doc/src/qpagesetupdialog.qdoc | 84 - doc/src/qpaintdevice.qdoc | 289 -- doc/src/qpair.qdoc | 229 -- doc/src/qpatternistdummy.cpp | 1010 ------- doc/src/qplugin.qdoc | 135 - doc/src/qprintdialog.qdoc | 72 - doc/src/qprinterinfo.qdoc | 137 - doc/src/qset.qdoc | 953 ------- doc/src/qsignalspy.qdoc | 98 - doc/src/qsizepolicy.qdoc | 522 ---- doc/src/qstyles.qdoc | 261 -- doc/src/qtdesigner.qdoc | 1373 --------- doc/src/qtendian.qdoc | 168 -- doc/src/qtestevent.qdoc | 191 -- doc/src/qvarlengtharray.qdoc | 274 -- doc/src/qwaitcondition.qdoc | 188 -- 80 files changed, 20748 insertions(+), 20708 deletions(-) create mode 100644 doc/src/classes/phonon-api.qdoc create mode 100644 doc/src/classes/q3asciicache.qdoc create mode 100644 doc/src/classes/q3asciidict.qdoc create mode 100644 doc/src/classes/q3cache.qdoc create mode 100644 doc/src/classes/q3dict.qdoc create mode 100644 doc/src/classes/q3intcache.qdoc create mode 100644 doc/src/classes/q3intdict.qdoc create mode 100644 doc/src/classes/q3memarray.qdoc create mode 100644 doc/src/classes/q3popupmenu.qdoc create mode 100644 doc/src/classes/q3ptrdict.qdoc create mode 100644 doc/src/classes/q3ptrlist.qdoc create mode 100644 doc/src/classes/q3ptrqueue.qdoc create mode 100644 doc/src/classes/q3ptrstack.qdoc create mode 100644 doc/src/classes/q3ptrvector.qdoc create mode 100644 doc/src/classes/q3sqlfieldinfo.qdoc create mode 100644 doc/src/classes/q3sqlrecordinfo.qdoc create mode 100644 doc/src/classes/q3valuelist.qdoc create mode 100644 doc/src/classes/q3valuestack.qdoc create mode 100644 doc/src/classes/q3valuevector.qdoc create mode 100644 doc/src/classes/qalgorithms.qdoc create mode 100644 doc/src/classes/qcache.qdoc create mode 100644 doc/src/classes/qcolormap.qdoc create mode 100644 doc/src/classes/qdesktopwidget.qdoc create mode 100644 doc/src/classes/qiterator.qdoc create mode 100644 doc/src/classes/qmacstyle.qdoc create mode 100644 doc/src/classes/qpagesetupdialog.qdoc create mode 100644 doc/src/classes/qpaintdevice.qdoc create mode 100644 doc/src/classes/qpair.qdoc create mode 100644 doc/src/classes/qpatternistdummy.cpp create mode 100644 doc/src/classes/qplugin.qdoc create mode 100644 doc/src/classes/qprintdialog.qdoc create mode 100644 doc/src/classes/qprinterinfo.qdoc create mode 100644 doc/src/classes/qset.qdoc create mode 100644 doc/src/classes/qsignalspy.qdoc create mode 100644 doc/src/classes/qsizepolicy.qdoc create mode 100644 doc/src/classes/qtdesigner-api.qdoc create mode 100644 doc/src/classes/qtendian.qdoc create mode 100644 doc/src/classes/qtestevent.qdoc create mode 100644 doc/src/classes/qvarlengtharray.qdoc create mode 100644 doc/src/classes/qwaitcondition.qdoc delete mode 100644 doc/src/phonon-api.qdoc delete mode 100644 doc/src/q3asciicache.qdoc delete mode 100644 doc/src/q3asciidict.qdoc delete mode 100644 doc/src/q3cache.qdoc delete mode 100644 doc/src/q3dict.qdoc delete mode 100644 doc/src/q3intcache.qdoc delete mode 100644 doc/src/q3intdict.qdoc delete mode 100644 doc/src/q3memarray.qdoc delete mode 100644 doc/src/q3popupmenu.qdoc delete mode 100644 doc/src/q3ptrdict.qdoc delete mode 100644 doc/src/q3ptrlist.qdoc delete mode 100644 doc/src/q3ptrqueue.qdoc delete mode 100644 doc/src/q3ptrstack.qdoc delete mode 100644 doc/src/q3ptrvector.qdoc delete mode 100644 doc/src/q3sqlfieldinfo.qdoc delete mode 100644 doc/src/q3sqlrecordinfo.qdoc delete mode 100644 doc/src/q3valuelist.qdoc delete mode 100644 doc/src/q3valuestack.qdoc delete mode 100644 doc/src/q3valuevector.qdoc delete mode 100644 doc/src/qalgorithms.qdoc delete mode 100644 doc/src/qcache.qdoc delete mode 100644 doc/src/qcolormap.qdoc delete mode 100644 doc/src/qdesktopwidget.qdoc delete mode 100644 doc/src/qiterator.qdoc delete mode 100644 doc/src/qpagesetupdialog.qdoc delete mode 100644 doc/src/qpaintdevice.qdoc delete mode 100644 doc/src/qpair.qdoc delete mode 100644 doc/src/qpatternistdummy.cpp delete mode 100644 doc/src/qplugin.qdoc delete mode 100644 doc/src/qprintdialog.qdoc delete mode 100644 doc/src/qprinterinfo.qdoc delete mode 100644 doc/src/qset.qdoc delete mode 100644 doc/src/qsignalspy.qdoc delete mode 100644 doc/src/qsizepolicy.qdoc delete mode 100644 doc/src/qstyles.qdoc delete mode 100644 doc/src/qtendian.qdoc delete mode 100644 doc/src/qtestevent.qdoc delete mode 100644 doc/src/qvarlengtharray.qdoc delete mode 100644 doc/src/qwaitcondition.qdoc diff --git a/doc/src/classes/phonon-api.qdoc b/doc/src/classes/phonon-api.qdoc new file mode 100644 index 0000000..09274bf --- /dev/null +++ b/doc/src/classes/phonon-api.qdoc @@ -0,0 +1,5023 @@ +/* + This file is part of the KDE project + Copyright (C) 2005-2007 Matthias Kretz + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + Contact: Nokia Corporation (qt-info@nokia.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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. +*/ + + +/*! + \enum Phonon::DiscType + Enum to identify the media discs supported by MediaObject. + + \value NoDisc + No disc was selected. This is only useful as a return value from + MediaSource::diskType(). + \value Cd Identifies Audio CDs. + \value Dvd Identifies DVDs (not arbitrary data DVDs, only movie DVDs). + \value Vcd Identifies Video CDs. + + \sa MediaSource, MediaObject +*/ + +/*! + \enum Phonon::MetaData + + Provided as keys for Phonon::MediaObject::metaData(). The enum + values matches strings defined in the Ogg Vorbis specification + + \value ArtistMetaData + \value AlbumMetaData + \value TitleMetaData + \value DateMetaData + \value GenreMetaData + \value TracknumberMetaData + \value DescriptionMetaData + \value MusicBrainzDiscIdMetaData +*/ + +/*! + \enum Phonon::State + \since 4.4 + + The state enum describes the different states a media object can + take. Several functions of \l{Phonon::}{MediaObject} are + asynchronous, so even if a you have requested a state change + through a function call, e.g., through + \l{Phonon::MediaObject::}{play()}, you cannot be sure that the + change has taken place before you receive the + \l{Phonon::MediaObject::}{stateChanged()} signal. + + A media object can at any time change into any state, regardless + of the state it previously had. \omit In the + \l{Phonon::}{MediaObject} class description explains the typical + state changes in the life of a media object. \endomit + + \value LoadingState + After construction it might take a while before the media object + is ready to \l{Phonon::MediaObject::}{play()}. This state is + commonly used by backends to initialize the \l{Phonon + Overview}{media graph} and loading the source. When + the object leaves the loading state, it will enter the + StoppedState unless an error occurred or another state is + requested through a function call, e.g., + \l{Phonon::}{MediaObject::play()}. + + \value StoppedState + In the stopped state, the media object is ready to play its + current media source. The current + \l{MediaObject::seek()}{position} in the media stream is then 0. + + \value PlayingState + The media object is playing back its media source. + + \value BufferingState + The Player is waiting for data to be able to start or continue + playing. This state is commonly used to wait for media data over a + network connection. + + \value PausedState + The media player has currently paused its playback, i.e., it + stops playing but keeps the current playback position in the + stream. + + \value ErrorState + When a media object enters the error state a problem with the + playback has occurred. The possible errors are grouped into + two categories by Phonon::ErrorType, and the type can be + queried through \l{Phonon::MediaObject::}{errorType()}. A + \l{Phonon::}{FatalError} implies that the playback + cannot continue, but one can still try with a new media + source. With a \l{Phonon::}{NormalError} it might + be possible to continue playback, and a media object may + therefore change state from the ErrorState. + + \sa MediaObject +*/ + +/*! + \enum Phonon::Category + + Sets the category your program should be listed in in the mixer. + + \value NoCategory + Will make use of the default device. + \value NotificationCategory + If the sounds produced are notifications (ping, beep and such) you + should use this category. + \value MusicCategory + If your application is a music player (like a jukebox or media player + playing an audio file). + \value VideoCategory + If the sound is the audio channel of a video. + \value CommunicationCategory + If your applications produces sounds from communication with somebody + else (VoIP, voice chat). + \value GameCategory + Sound produced by a computer game should go into this category. + \value AccessibilityCategory + Sounds produced for accessibility (e.g., Text-To-Speech) + \omitvalue LastCategory + Holds the largest value of categories. + \omitvalue AccessibilityCategory + + A Jukebox will set this to Music, a VoIP program to Communication, a + DVD player to video, and so on. + + \note These categories can also become useful for an application that + controls the volumes automatically, like turning down the music when a call + comes in, or turning down the notifications when the media player knows + it's playing classical music. +*/ + +/*! + \enum Phonon::ErrorType + + This enum describes the severity when an error has occurred during + playback. + + After a media object has entered the \l{Phonon::}{ErrorState}, one + can query the type of error from + \l{Phonon::}{MediaObject::errorType()}. Note that you should query + the error when receiving the + \l{Phonon::}{MediaObject::stateChanged()} signal, because the + error type will be lost if the media object leaves the error + state. + + \value NoError No error. MediaObject::errorType() returns this if + MediaObject::state() != Phonon::ErrorState. + + \value NormalError An error has occurred with the playback of the current + source. It might be possible to continue playback, for instance, if only the + audio stream in a video cannot be played back. The media object will then + leave the error state again. + + \value FatalError. Something important does not work. Your program cannot continue + the playback of the current source, but it might be possible to try another. + + \sa MediaObject::errorType() +*/ + +/*! + \fn QString Phonon::categoryToString(Category c) + + Returns a (translated) string to show to the user identifying the given + Category (\a c). +*/ + +/*! + \enum Phonon::ObjectDescriptionType + \relates Phonon::ObjectDescription + + This enum defines the type of information that is contained in a + \l{Phonon::}{ObjectDescription} object. + + \value AudioOutputDeviceType An audio output device (\l{Phonon::}{AudioOutputDevice}). + This can be soundcards (with different drivers), + sound servers, or other virtual outputs like playback on a different + computer on the network. + + \value EffectType An audio effect (\l{Phonon::}{EffectDescription}). + \omitvalue SubtitleType + \omitvalue AudioCaptureDeviceType + \omitvalue AudioChannelType +*/ + +/*! + \typedef Phonon::AudioOutputDevice + \relates Phonon::ObjectDescription + + This typedef of \l{Phonon::}{ObjectDescription} describes an audio output + device, such as soundcards (with different drivers), sound servers, or other + virtual outputs like playback on a different computer on the network. + + \omit + For Hardware devices the backend should use libkaudiodevicelist + (AudioDevice and AudioDeviceEnumerator) which will list removable + devices even when they are unplugged and provide a unique identifier + that can make backends use the same identifiers. + \endomit + + A list of available devices is given by the backend with + Backendcapabilities::availableAudioOutputDevices() + + \snippet doc/src/snippets/phononobjectdescription.cpp 1 + +*/ + +/*! + \fn Phonon::phononVersion() + \inmodule Phonon + \since 4.5 + + Returns the Phonon version. +*/ + +/*! + \class Phonon::ObjectDescription + \inmodule Phonon + \inheaderfile Phonon/ObjectDescription + \since 4.4 + \brief The ObjectDescription class provides information about Phonon objects. + + Phonon currently uses this class to describe audio effects and + audio output devices - using the typedefs AudioOutputDevice and + EffectDescription. The type of an ObjectDescription is also + described through the \l{Phonon::}{ObjectDescriptionType} enum. + Objects of the same \l{Phonon::ObjectDescriptionType}{type} are + uniquely identified by an index(). + + The class gives a description() and a name() of the object, both + of which are strings appropriate for end users of a Phonon + application. You can also check whether the device or effect + described is \l{isValid()}{valid}. This does not guarantee that + the device or effect functions as expected, but that the + ObjectDescription describes an existing device or effect. + + Audio output devices and effect descriptions are used to select + the audio output device to be used for playback and to create + effects; we show examples of this in the snippet below. The + available descriptions can be fetched with + \l{Phonon::BackendCapabilities::}{availableAudioOutputDevices()} + and \l{Phonon::BackendCapabilities::}{availableAudioEffects()} + static functions in the Phonon::BackendCapabilities namespace + + \snippet doc/src/snippets/phononobjectdescription.cpp 0 + + Other types of ObjectDescriptions might be possible in the future, + e.g., descriptions of audio capture devices, such as microphones. + + \omit Not implemented yet. + Need a new paragraph on that some descriptions 'belong + together', such as chained audio effects. + + Some parts give the end user choices, e.g. what source to capture + audio from. These choices are described by the name and + description methods of this class and identified with the id + method. Subclasses then define additional information like which + audio and video choices belong together. \endomit + + \sa Phonon::AudioOutputDevice, Phonon::EffectDescription, {Capabilities Example}, {Phonon Module} +*/ + +/*! + \fn Phonon::ObjectDescription::ObjectDescription() + \brief constructs a new object description. + \internal +*/ + +/*! + \fn Phonon::ObjectDescription::ObjectDescription (int index, const QHash & properties) + \internal +*/ + +/*! + \fn Phonon::ObjectDescription::ObjectDescription(const QExplicitlySharedDataPointer &dd) + \internal +*/ + +/*! + \fn static inline ObjectDescription Phonon::ObjectDescription::fromIndex(int index) + \internal + + \omit Currently indices are not unique for all ObjectDescription types, making + the behavior of this function undefined. \endomit + + Returns a new description object that describes the + device/effect/codec/... with the given \a index. +*/ + +/*! + \fn inline bool Phonon::ObjectDescription::operator==(const ObjectDescription &otherDescription) const + + Returns \c true if this ObjectDescription describes the same + object as \a otherDescription; otherwise, returns \c false. +*/ + +/*! + \fn inline bool Phonon::ObjectDescription::operator!=(const ObjectDescription &otherDescription) const + Returns \c false if this ObjectDescription describes the same + as \a otherDescription; otherwise, returns \c true. +*/ + +/*! + \fn inline QString Phonon::ObjectDescription::name() const + + Returns a string appropriate for a user to select between + object descriptions, e.g., from a QComboBox. + + \sa description() +*/ + +/*! + \fn inline QString Phonon::ObjectDescription::description() const + + Returns a more extensive description than the name() function. + + For example, in the case of \l{Phonon::}{AudioOutputDevice}s, this + text should make clear which sound source is described; this is + sometimes hard to describe or understand from just the name. + + The text is appropriate to present to an end user in for example + tool tips of items, with the name()'s as text, in a QComboBox. + +*/ + +/*! + \fn inline QVariant Phonon::ObjectDescription::property(const char *name) const + + Returns the property named \a name. A property can be used for + extended information, such as the manufacturer of a sound card. The + information will usually be given as text. + + If the property is not set an invalid QVariant is returned. + + Qt's backends do not use properties at the time of this writing. + + \sa propertyNames() +*/ + +/*! + \fn inline QList Phonon::ObjectDescription::propertyNames() const + + Properties can be used for extended information about a + ObjectDescription, e.g., a manufacturer of a sound card. The + information will usually be given text. + + This function returns all names that return valid data when + property() is called. + + Currently, Qt backends do not use properties for their object + descriptions. + + \sa property() +*/ + +/*! + \fn inline bool Phonon::ObjectDescription::isValid() const + + Returns true if the device or effect described exists. + + An ObjectDescription that is invalid, will also have an + index() of -1. + + \sa index() +*/ + +/*! + \fn inline int Phonon::ObjectDescription::index() const + + Returns a unique identifier for this ObjectDescription. Used + internally to distinguish between the descriptions. + + Notice that the identifiers are only unique to the type of + description, e.g., \l{Phonon::}{AudioOutputDevice} or + \l{Phonon::}{EffectDescription}. +*/ + +/*! + \class Phonon::ObjectDescriptionPrivate + \inmodule Phonon + \since 4.4 + \internal + +*/ + +/*! + \class Phonon::StreamInterface + \inmodule Phonon + \since 4.4 + \brief Backend interface to handle media streams (AbstractMediaStream). + \internal +*/ + +/*! + \fn virtual Phonon::StreamInterface::~StreamInterface() +*/ + +/*! + \fn virtual void Phonon::StreamInterface::writeData(const QByteArray &data) = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::StreamInterface::endOfData() = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::StreamInterface::setStreamSize(qint64 newSize) = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::StreamInterface::setStreamSeekable(bool s) = 0 + \internal +*/ + +/*! + \fn void Phonon::StreamInterface::connectToSource(const MediaSource &mediaSource) + \internal +*/ + +/*! + \fn void Phonon::StreamInterface::needData() + \internal +*/ + +/*! + \fn void Phonon::StreamInterface::enoughData() + \internal +*/ + +/*! + \fn void Phonon::StreamInterface::seekStream(qint64) + \internal +*/ + +/*! + \fn void Phonon::StreamInterface::reset() + \internal +*/ + +/*! + \fn Phonon::StreamInterface::StreamInterface() + \internal + \omit + For subclasses. + \endomit +*/ + +/*! + \class StreamInterfacePrivate + \inmodule Phonon + \internal +*/ + +/*! + \class Phonon::AbstractVideoOutput + \inmodule Phonon + \internal + \since 4.4 + \brief The AbstractVideoOutput class is the common base class for all video output classes. + + \sa VideoWidget +*/ + +/*! + \namespace Phonon::Experimental + \internal +*/ + +/*! + \fn Phonon::AbstractVideoOutput::AbstractVideoOutput(AbstractVideoOutputPrivate &d) + \internal + + Constructor that is called from derived classes. + + \param parent Standard QObject parent. +*/ + +/*! + \class Phonon::AbstractVideoOutputPrivate + \inmodule Phonon + \internal + \since 4.4 +*/ + +/*! + \class Phonon::VolumeFaderEffect + \inmodule Phonon + \internal + \since 4.4 + + This effect differs from gradually changing the output volume in that + a dedicated effect can change the volume in the smallest possible + steps while every other volume control will make more or less + noticeable steps. + + \sa AudioOutput::volume() +*/ + +/*! + \property Phonon::VolumeFaderEffect::volume + + This is the current volume of the output as voltage factor. + Setting this property changes the volume immediately. + + 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% + + \sa volumeDecibel +*/ + +/*! + \property Phonon::VolumeFaderEffect::volumeDecibel + + This is the current volume of the output in decibel. + Setting this property changes the volume immediately. + + 0 dB means no change in volume, -6dB means an attenuation of the + voltage to 50% and an attenuation of the power to 25%, -inf dB means + silence. + + \sa volume +*/ + +/*! + \property Phonon::VolumeFaderEffect::fadeCurve + + This property holds the fade curve to be used for the fadeIn(), fadeOut() + and fadeTo() slots. + + Defaults to Fade3Decibel. + + \sa FadeCurve +*/ + +/*! + \enum Phonon::VolumeFaderEffect::FadeCurve + Determines the curve of the volume change. + + \value Fade3Decibel Crossfade curve/fast fade out. + This is the default fade curve. + \value Fade6Decibel Linear fade out. + \value Fade9Decibel Slow fade out. + \value Fade12Decibel A more extreme version of the -9dB fade. + + \bold{Notes:} + + \c Fade3Decibel is often the best fade for a crossfade, as after half + of the time the volume reached -3dB. This means that half the + possible power (which is proportional to the square of the + voltage) is reached. Summed, the maximum power of two audio + signals fading with a -3dB curve will always be equal. + + For fading in or out the -3dB curve is too abrupt in the end. + + With a -6dB fade curve, a volume of -6dB is reached after half of + the fading time. -6dB is equal to half of the voltage meaning + that the voltage multiplier changes linearly from the start + of the fade to the end. + + With the \c Fade9Decibel fade, a volume of -9dB is reached after + half of the fade time, so the fade is fast in the beginning and + slow at the end. This is a good fade for ending music. +*/ + +/*! + \fn void Phonon::VolumeFaderEffect::fadeIn(int fadeTime) + + Tells the Fader to change the volume from the current volume to 100% + in \a fadeTime milliseconds. + + Short for \c fadeTo(1.0, fadeTime). + + \param fadeTime the fade duration in milliseconds + + \sa fadeTo(), volume +*/ + +/*! + \fn void Phonon::VolumeFaderEffect::fadeOut(int fadeTime) + + Tells the Fader to change the volume from the current volume to 0% + in \a fadeTime milliseconds. + Short for \c fadeTo(0.0, fadeTime). + + \param fadeTime the fade duration in milliseconds + + \sa fadeTo +*/ + +/*! + \fn void Phonon::VolumeFaderEffect::fadeTo(float volume, int fadeTime) + + Tells the Fader to change the volume from the current value to + \a volume in \a fadeTime milliseconds. + + \sa fadeIn(), fadeOut() +*/ + +/*! + \class Phonon::VolumeFaderEffectPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::VolumeFaderInterface + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \fn virtual Phonon::VolumeFaderInterface::~VolumeFaderInterface() + \internal +*/ + +/*! + \fn virtual float Phonon::VolumeFaderInterface::volume() const + \internal +*/ + +/*! + \fn virtual void Phonon::VolumeFaderInterface::setVolume(float) + \internal +*/ + +/*! + \fn virtual Phonon::VolumeFaderEffect::FadeCurve Phonon::VolumeFaderInterface::fadeCurve() const + \internal +*/ + +/*! + \fn virtual void Phonon::VolumeFaderInterface::setFadeCurve(Phonon::VolumeFaderEffect::FadeCurve) + \internal +*/ + +/*! + \fn virtual void Phonon::VolumeFaderInterface::fadeTo(float, int) + \internal +*/ + +/*! + \class Phonon::AbstractMediaStream + \inmodule Phonon + \internal + \since 4.4 + \brief The AbstractMediaStream class is the base class for custom media data streams. + \inheaderfile Phonon/AbstractMediaStream + + This class is subclassed to provide custom data streams for + \l{Phonon::}{MediaSource}s. + + The \l{Phonon::}{MediaSource} knows how to handle the most common + media sources, such as files and CD. If you need to fetch + multimedia from other sources, you can reimplement this class, + which can be used by a \l{Phonon::}{MediaSource}. + + When a backend needs more data from the stream, needData() will be + called. You must then use writeData() to write the data to the + backend. You can either write one time and wait for a new + needData() call, or continue to write data until you receive an + enoughData() call. When the stream is at its end, call endOfData() + instead of writeData(). + + Before the custom stream is passed to a \l{Phonon::}{MediaSource}, + setStreamSize() needs to be called, and also setStreamSeekable() + (if the stream is seekable). A good place to do this work is in + the constructor. A seekable stream must also reimplement + seekStream(). + + We show two examples. The first writes data repeatedly until it + receives the enoughData() call, while the second only writes once + and waits for a new needData() call. + + Example where data is written repeatedly. + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 0 + + Example where data is written once: + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 1 + + \sa Phonon::MediaSource, Phonon::MediaObject + +*/ + +/*! + \fn Phonon::AbstractMediaStream::AbstractMediaStream(QObject *parent = 0) + \internal + + Constructs an AbstractMediaStream object with the given \a parent. + +*/ + +/*! + \fn qint64 Phonon::AbstractMediaStream::streamSize() const + + Returns the stream size that was set with setStreamSize(). + + A negative value means that the length of the stream cannot be known. + + Defaults to 0. + + \sa setStreamSize() +*/ + +/*! + \fn void Phonon::AbstractMediaStream::setStreamSize(qint64 size) + + Sets the \a size of the stream in number of bytes. + + A negative value means that the length of the stream cannot be known. + + Defaults to 0. + + This function has to be called. A backend will not call needData() + until the stream size is set. + + \sa streamSize() + +*/ + +/*! + \fn bool Phonon::AbstractMediaStream::streamSeekable() const + + Returns whether your data stream is set as seekable. + + Defaults to \c false. + + \sa setStreamSeekable() + +*/ + +/*! + \fn void Phonon::AbstractMediaStream::setStreamSeekable(bool s) + + Sets whether your data stream is seekable. \a s should be true if + the stream is seekable; otherwise false. + + Defaults to \c false. + + If you set this to \c true you have to implement the seekStream() + function. + + \sa streamSeekable() +*/ + +/*! + \fn void Phonon::AbstractMediaStream::writeData(const QByteArray &data) + + Sends the media \a data to the backend for decoding. + + Use this function to send data to the backend after needData() has + been called. + + If your stream is a push stream, data should be written until the + enoughData() function is called. For a pull stream, write data + once before the call to needData() function returns. + + If the data is depleted, call endOfData() instead of writeData(). + + \warning Don't call this function before the first needData() is emitted. + + \sa needData(), endOfData() + +*/ + +/*! + \fn void Phonon::AbstractMediaStream::endOfData() + + Tells the backend that the media data stream is at its end. + + \warning Don't call this function before the first needData() is emitted. + + \sa writeData(), needData() +*/ + +/*! + \fn void Phonon::AbstractMediaStream::error(Phonon::ErrorType errorType, const QString &errorString) + + If an I/O error occurs you should call this function to make + MediaObject go into ErrorState. \c errorType classifies the error, + while \a errorString is a textual description of the error suitable + for users of Phonon applications. + + \sa MediaObject::errorType(), MediaObject::errorString() +*/ + +/*! + \fn virtual void Phonon::AbstractMediaStream::reset() = 0 + + Reimplement this function to reset the stream. Subsequent calls to writeData should start + from the first position of the data unless a seek is requested. + + The function is necessary for the case where a non-seekable MediaStream is + played more than once. For a seekable stream the implementation can simply call + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 2 + + \sa writeData(), needData() +*/ + +/*! + \fn virtual void Phonon::AbstractMediaStream::needData() = 0 + + Reimplement this function to be notified when the backend needs data. + + When this function is called you should write data to the backend + (See writeData()). + + \sa writeData(), endOfData(), enoughData() +*/ + +/*! + \fn virtual void Phonon::AbstractMediaStream::enoughData() + + If your stream is a push stream, reimplement this function to be + notified when the backend has enough data and your stream object + may take a break. + + This method is important for pushing data to the backend in order + to not fill the backend buffer unnecessarily. + + \sa needData() +*/ + +/*! + \fn virtual void Phonon::AbstractMediaStream::seekStream(qint64 offset) + + Reimplement this function if your stream is seekable. + + When this function is called the next call to writeData has to be at the + requested \a offset. + + \warning Do not call the parent implementation. + + \sa setStreamSeekable(), streamSeekable(), needData() +*/ + +/*! + \class Phonon::BackendInterface + \inmodule Phonon + \since 4.4 + \brief Main Backend class interface + \internal + + This interface defines the main factory of the backend. The createObject() function creates all the + objects needed by the frontend. + + The objectDescriptionIndexes and objectDescriptionProperties functions return information about + available devices, effects and codecs. + + An implementation could look like this: + \snippet snippets/phonon/samplebackend/main.cpp snippet + +*/ + +/*! + \fn virtual Phonon::BackendInterface::~BackendInterface() + \internal + + Silence gcc's warning. +*/ + +/*! + \enum Phonon::BackendInterface::Class + \internal + + Classes that the createObject() function has to handle. + + \value MediaObjectClass Request to return a \c MediaObject object. + \value VolumeFaderEffectClass Request to return a \c VolumeFaderEffect + object. + \value AudioOutputClass Request to return an \c AudioOutput object. + \value AudioDataOutputClass Request to return an \c AudioDataOutput object. + \value VisualizationClass Request to return a \c Visualization object. + \value VideoDataOutputClass Request to return a \c VideoDataOutput object. + \value EffectClass Request to return a \c Effect object. + Takes an additional int that specifies the effect ID. + \value VideoWidgetClass Request to return a \c VideoWidget object. +*/ + +/*! + \fn virtual QObject *Phonon::BackendInterface::createObject(Class c, QObject *parent, const QList &args = QList()) = 0 + \internal + + Returns a new instance of the requested class. + + \param c The requested class. + \param parent The parent object. + \param args Additional arguments (documented in Class). +*/ + + +/*! + \fn virtual QList Phonon::BackendInterface::objectDescriptionIndexes(ObjectDescriptionType type) const = 0 + \internal + + Returns the unique identifiers for the devices/effects/codecs of the given \a type. + + \param type see ObjectDescriptionType +*/ + +/*! + \fn virtual QHash Phonon::BackendInterface::objectDescriptionProperties(ObjectDescriptionType type, int index) const = 0 + \internal + + Given a unique identifier that was returned from objectDescriptionIndexes this function + returns a hash mapping property names to values. + + The property "name" must always be present. All other properties are optional. + + \table + \header \o Property \o Description + \row \o name \o The name of the device/effect/codec/... + \row \o description \o A text explaining what this device/effect/codec/... is/can do + \row \o icon \o An icon name (using the freedesktop naming scheme) or a QIcon for this + device/effect/codec/... + \row \o available \o A bool telling whether the device is present or unplugged. + \endtable + + \param type see ObjectDescriptionType + \param index The unique identifier that is returned from objectDescriptionIndexes +*/ + +/*! + \fn virtual bool Phonon::BackendInterface::startConnectionChange(QSet) = 0; + \internal + + When this function is called the nodes given in the parameter list should + not lose any signal data when connections are changed. +*/ + +/*! + \fn virtual bool Phonon::BackendInterface::connectNodes(QObject *, QObject *) = 0 + \internal + + Defines a signal connection between the two given nodes. +*/ + +/*! + \fn virtual bool Phonon::BackendInterface::disconnectNodes(QObject *, QObject *) = 0 + \internal + + Cuts a signal connection between the two given nodes. +*/ + +/*! + \fn virtual bool Phonon::BackendInterface::endConnectionChange(QSet) = 0 + \internal + + When this function is called the nodes given in the parameter list may lose + signal data when a port is not connected. +*/ + +/*! + \fn virtual QStringList Phonon::BackendInterface::availableMimeTypes() const = 0 + \internal + + Returns all available MIME types. +*/ + +/*! + \class Phonon::MediaSource + \inmodule Phonon + \inheaderfile Phonon/MediaSource + \since 4.4 + \brief The MediaSource class provides multimedia data for media objects. + + The MediaSource class manages a source of multimedia content, such + as a music or video file, of which data is given to a + \l{Phonon::}{MediaObject}. + + The media source knows how fetch its data from several sources, + e.g., from files, a QIODevice, or a CD. The possible source types + are described by the \l{MediaSource::}{Type} enum. The type of the + source is set by the media source itself, and is dependent on the + constructor used to create it. Note that it is possible to provide + data from any source by implementing a QIODevice. + + The class has several functions to acquire information about the + source it manages, e.g., fileName() and url(). The return from + these functions are dependent on the type() of the media source. + + Normally, a programmer does not need to be concerned with media + sources. It's constructors are implicit, so one can, for instance, + send an URL or filename directly to the constructors of the + \l{Phonon::}{MediaObject}. + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 3 + + A MediaSource object cannot be reused for another multimedia + source. It is possible to play the same source again, and also + stop and start a non-seekable media source, such as a radio + stream, with the same MediaSource object. + + \section1 Qt Backends + + Currently, Qt's backends support files in local and remote + locations. Support for other sources, such as CD/DVD, are planned + for the future. + + \sa MediaObject, {Phonon Module} +*/ + +/*! + \enum Phonon::MediaSource::Type + + Identifies the type of media described by the MediaSource object. + + \value Invalid The MediaSource object does not describe any valid source. + \value LocalFile The MediaSource object describes a local file. + \value Url The MediaSource object describes an URL, which can be either a + local file or a file on the network. + \value Disc The MediaSource object describes a disc, e.g., a CD. + \value Stream The MediaSource object describes a data stream. + This is the type used for \l{QIODevice}s. Note + that a stream opened with a QUrl, will still be of the Url type. + \value Empty The media source doesn't have a source. + + \sa MediaSource::type() +*/ + +/*! + \fn Phonon::MediaSource::MediaSource() + \internal + + Creates an invalid MediaSource object. + + \sa Invalid +*/ + +/*! + \fn Phonon::MediaSource::MediaSource(const QString &fileName) + + Creates a MediaSource object for the file specified by \a + fileName. You can also use this constructor with \l{The Qt + Resource System}{Qt resources} + + \omit + \param fileName file name of a local media file or a Qt resource that was compiled in. + \endomit +*/ + +/*! + \fn Phonon::MediaSource::MediaSource(const QUrl &url) + + Creates a MediaSource object for a the URL specified by \a url. + + If the multimedia content you would like to play back is on a + remote network location, you should use this constructor; though, + it also possible to specify an URL to a local file. + + \sa QUrl +*/ + + +/*! + \fn Phonon::MediaSource::MediaSource(Phonon::DiscType discType, const QString &deviceName = QString()) + + Creates a MediaSource object for the type of disc specified by \a discType in the named + device referred to by \a deviceName. + + \note \a deviceName is a platform dependent device name. It can be useful to specify this + if the computer has more than one CD drive. On KDE, it is recommended to use the Solid + hardware discovery framework to retrieve the device name in a portable way. +*/ + +/*! + \fn Phonon::MediaSource::MediaSource(AbstractMediaStream *stream) + \internal + Creates a MediaSource object for a data stream. + + Your application can provide the media data by subclassing AbstractMediaStream and + passing a pointer to that object. Phonon will never delete the \a stream. + + \param stream The AbstractMediaStream subclass to provide the media data. + + \sa setAutoDelete +*/ + +/*! + \fn Phonon::MediaSource::MediaSource(QIODevice *ioDevice) + + Creates a MediaSource object for the QIODevice specified by \a ioDevice. + + This constructor can be very handy in the combination of + QByteArray and QBuffer. + + If you need to fetch multimedia data from a source that is not + supported by MediaSource, you should subclass QIODevice and use + this MediaSource constructor. It is important that you reimplement + QIODevice::isSequential(), as it is used by MediaSource to + determine if the media source is seekable. + + \a ioDevice is an arbitrary readable QIODevice subclass. If the device is not opened + MediaSource will open it as QIODevice::ReadOnly. + + \note Sequential devices can also be used, but MediaObject::isSeekable() will + return false as a result. + + \warning On Windows, we only support \l{QIODevice}s containing the + \c avi, \c mp3, or \c mpg formats. Use the constructor that takes + a file name to open files (the Qt backend does not use a QFile + internally). + + \sa setAutoDelete() +*/ + +/*! + \fn Phonon::MediaSource::MediaSource(MediaSourcePrivate &) + \internal +*/ + +/*! + \fn Phonon::MediaSource::~MediaSource() + + Destroys the MediaSource object. You should never delete a + MediaSource yourself, the MediaObject will handle this. + +*/ + +/*! + \fn Phonon::MediaSource::MediaSource(const MediaSource &other) + + Constructs a copy of the \a other media source. + + This constructor is fast thanks to explicit sharing. +*/ + +/*! + \fn MediaSource &Phonon::MediaSource::operator=(const MediaSource &other) + + Assigns the \a other media source to this media source and returns a + reference to it. + + This operation is fast thanks to explicit sharing. +*/ + +/*! + \fn bool Phonon::MediaSource::operator==(const MediaSource &other) const + + Returns true if this media source is equal to the \a other media source; + otherwise returns false. +*/ + +/*! + \fn void Phonon::MediaSource::setAutoDelete(bool enable) + + If \a enable is true, the media source will take ownership of the + object passed in the \l{Phonon::}{MediaSource}'s constructor + object that was passed in the constructor; otherwise, the + programmer is responsible for deletion of this object. + + This setting is false by default. If you enable it, you should + only access the stream or device as long as you keep the media + source object around. As long as you keep the media source + wrapping the stream or device, the object will not get deleted. + + \sa autoDelete() +*/ + +/*! + \fn bool Phonon::MediaSource::autoDelete() const + + Returns the setting of the auto-delete option. The default is + false. + + \sa setAutoDelete() +*/ + +/*! + \fn Type Phonon::MediaSource::type() const + + Returns the type of the MediaSource (depends on the constructor + that was used). + + \sa Type +*/ + +/*! + \fn QString Phonon::MediaSource::fileName() const + + Returns the file name of the MediaSource if type() == + LocalFile; otherwise, returns QString(). + + \sa type() +*/ + +/*! + \fn QUrl Phonon::MediaSource::url() const + Returns the URL of the MediaSource if type() == URL or type() == LocalFile; + otherwise returns QUrl(). + + \sa type() +*/ + +/*! + \fn Phonon::DiscType Phonon::MediaSource::discType() const + Returns the disc type of the MediaSource if type() == Disc; otherwise + returns NoDisc. + + \sa type() +*/ + +/*! + \fn QString Phonon::MediaSource::deviceName() const + + Returns the device name of the MediaSource if type() == Disc; otherwise + returns QString(). + + \sa type() +*/ + +/*! + \fn AbstractMediaStream *Phonon::MediaSource::stream() const + \internal + Returns the media stream of the MediaSource if type() == Stream; otherwise + returns 0. + QIODevices are handled as streams, too. +*/ + +/*! + \class Phonon::MediaSourcePrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::SeekSlider + \inmodule Phonon + \inheaderfile Phonon/SeekSlider + \since 4.4 + \brief The SeekSlider class provides a slider for seeking to positions in media streams. + + The SeekSlider connects to a \l{Phonon::}{MediaObject}, and + controls the seek position in the object's media stream. + + The slider will connect to the necessary signals to keep track of + the sliders maximum, minimum, and current values. It will also + disable itself for non-seekable streams, and update the media + object when the current value of the slider changes. + + Here follows a typical example of SeekSlider usage: + + \snippet doc/src/snippets/seekslider.cpp 0 + + \sa Phonon::VolumeSlider, Phonon::VideoWidget, {Music Player Example}, {Phonon Module} + +*/ + +/*! + \property Phonon::SeekSlider::iconVisible + \brief whether the icon next to the slider is visible + + By default the icon is visible if the platform provides an icon; else + it's hidden. + +*/ + +/*! + \property Phonon::SeekSlider::tracking + \brief whether slider tracking is enabled + + If tracking is enabled (the default), the media seeks + while the slider is being dragged. If tracking is + disabled, the media seeks only when the user + releases the slider. +*/ + +/*! + \property Phonon::SeekSlider::pageStep + \brief the page step interval + + The larger of two natural steps that a slider provides and + typically corresponds to the user pressing PageUp or PageDown. + + Defaults to 5 seconds. +*/ + +/*! + \property Phonon::SeekSlider::singleStep + \brief the single step interval + + The smaller of two natural steps that a slider provides and + typically corresponds to the user pressing an arrow key. + + Defaults to 0.5 seconds. +*/ + +/*! + \property Phonon::SeekSlider::orientation + \brief the orientation of the slider + + The orientation must be Qt::Vertical or Qt::Horizontal (the default). +*/ + +/*! + \property Phonon::SeekSlider::iconSize + \brief the icon size used for the mute button/icon. + + The default size is defined by the GUI style. +*/ + +/*! + \fn explicit Phonon::SeekSlider::SeekSlider(QWidget *parent = 0) + + Constructs a seek slider widget with the given \a parent. +*/ + +/*! + \fn explicit Phonon::SeekSlider::SeekSlider(MediaObject *media, QWidget *parent = 0) + + Constructs a seek slider widget for the specified \a media with the + given \a parent. +*/ + +/*! + \fn Phonon::SeekSlider::~SeekSlider() + Destroys the seek slider. +*/ + +/*! + \fn Phonon::MediaObject *Phonon::SeekSlider::mediaObject() const + + Return the media object this SeekSlider controls. +*/ + +/*! + \class Phonon::SeekSliderPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \fn void Phonon::SeekSlider::setMediaObject(MediaObject *media) + + Sets the media object to be controlled by this slider to the \a media specified. +*/ + +/*! + \class Phonon::VideoPlayer + \inmodule Phonon + \inheaderfile Phonon/VideoPlayer + \since 4.4 + \brief The VideoPlayer widget is used to perform playback of video. + + With VideoPlayer you can get results quickly and easily. You can + do the standard playback tasks like play(), pause(), and stop(), + but also set a playback volume and seek - if the media and backend + supports seeking. + + VideoPlayer is provided for convenience and removes the need to + create a media graph with a \l{Phonon::}{MediaObject}, + \l{Phonon::}{AudioOutput}, and \l{Phonon::}{VideoWidget}. If + you need functionality not supported by the player, you can build + this \l{Building Graphs}{graph} yourself. + + Keep in mind that when the VideoPlayer instance is deleted the + playback will stop. + + Note also that most of the functions in this class are + asynchronous. For instance, a media source may not play + immediately after you call the play() function. + + A play and forget code example: + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 4 + + \sa {Phonon Module}, MediaObject +*/ + +/*! + \fn Phonon::VideoPlayer::VideoPlayer(QWidget *parent = 0) + + Constructs a new video widget with a \a parent using + Phonon::VideoCategory as its category. + + \param parent The QObject parent. +*/ + +/*! + \fn Phonon::VideoPlayer::VideoPlayer(Phonon::Category category, QWidget *parent = 0) + + Constructs a new VideoPlayer instance with the specified \a + parent. + + \a category is the category used for the audio output device. +*/ + +/*! + \fn Phonon::VideoPlayer::~VideoPlayer() + + On destruction the playback is stopped, also the audio output is + removed so that the desktop mixer will not show the application + anymore. If you need a persistent audio output don't use + VideoPlayer but MediaObject, VideoPath and VideoOutput. +*/ + +/*! + \fn qint64 Phonon::VideoPlayer::totalTime() const + + Get the total time (in milliseconds) of the file currently being played. +*/ + +/*! + \fn qint64 Phonon::VideoPlayer::currentTime() const + + Get the current time (in milliseconds) of the file currently being played. +*/ + +/*! + \fn float Phonon::VideoPlayer::volume() const + + This is the current volume of the output as voltage factor. + + 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% +*/ + +/*! + \fn bool Phonon::VideoPlayer::isPlaying() const + + Returns true if it is currently playing; otherwise returns false if it + is currently stopped or paused +*/ + +/*! + \fn bool Phonon::VideoPlayer::isPaused() const + + Returns true if it is currently paused; otherwise returns false if it + is currently playing or stopped. +*/ + +/*! + \fn void Phonon::VideoPlayer::load(const Phonon::MediaSource &source) + + Starts pre-loading the media data from the specified \a source and + filling audio buffers in the backend. + + When there's already a media playing (or paused) it will be stopped + (the finished signal will not be emitted). + + \sa MediaObject::setCurrentSource() +*/ + +/*! + \fn void Phonon::VideoPlayer::play(const Phonon::MediaSource &source) + + Plays the media from the given \a source. Starts playback as fast as + possible. + This can take a considerable time depending on the URL and the + backend. + + If you need low latency between calling play() and the sound actually + starting to play on your output device you need to use MediaObject + and be able to set the URL before calling play(). Note that + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 5 + doesn't make a difference: the application should be idle between the + load and play calls so that the backend can start preloading the + media and fill audio buffers. +*/ + +/*! + \fn void Phonon::VideoPlayer::play() + + Continues playback of paused media. Restarts playback of a stopped + (or newly loaded) media. + + \sa MediaObject::play(), play() +*/ + +/*! + \fn void Phonon::VideoPlayer::pause() + + Pauses the playback. + + \sa MediaObject::pause() +*/ + +/*! + \fn void Phonon::VideoPlayer::stop() + + Stops the playback. + + \sa MediaObject::stop() +*/ + +/*! + \fn void Phonon::VideoPlayer::seek(qint64 ms) + + Seeks to the requested time. Note that the backend is free to + ignore the seek request if the media source isn't seekable; you + can check this by asking the media object of the VideoPlayer. + + \snippet doc/src/snippets/videomedia.cpp 0 + + The \a ms parameter is the time in milliseconds from the start of + the media. + + The call is asynchronous, so currentTime() can still be the old + value right after this method was called. If all you need is a + slider that shows the current position and allows the user to + seek, use the class SeekSlider. + + \sa MediaObject::seek(), MediaObject::isSeekable(), mediaObject() +*/ + +/*! + \fn void Phonon::VideoPlayer::setVolume(float volume) + + Sets the \a volume of the output as voltage factor. + + 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% +*/ + +/*! + \fn MediaObject *Phonon::VideoPlayer::mediaObject() const + + Returns the media object being used by the player. + + The media object can be accessed directly instead of using the + \l{VideoPlayer}s convenience functions, e.g., play() and stop(). + It is also possible to give the object to other Phonon widgets, + e.g., a \l{Phonon::}{SeekSlider} or a \l{Phonon::}{VolumeSlider}. + + \sa Phonon::SeekSlider, Phonon::MediaObject +*/ + +/*! + \fn AudioOutput *Phonon::VideoPlayer::audioOutput() const + + Returns the audio output object being used by the player. + +*/ + +/*! + \fn VideoWidget *Phonon::VideoPlayer::videoWidget() const + + Returns the video widget being used by the player. +*/ + +/*! + \fn void Phonon::VideoPlayer::finished() + + This signal is emitted when the playback finished. + +*/ + +/*! + \class Phonon::VideoWidgetPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::MediaObject + \inmodule Phonon + \inheaderfile Phonon/MediaObject + \since 4.4 + \brief The MediaObject class provides an interface for media playback. + + + The media object manages a \l{Phonon::}{MediaSource}, which + supplies the media object with multimedia content, e.g., from a + file. A playback in Phonon is always started by calling the + \l{Phonon::MediaObject::}{play()} function. + + The state of play (play, pause, stop, seek) is controlled by the + media object, and you can also query the current + \l{Phonon::MediaObject::}{state()}. It keeps track of the playback + position in the media stream, and emits the + \l{Phonon::MediaObject::}{tick()} signal when the current position + in the stream changes. + + Notice that most functions of this class are asynchronous, so you + cannot rely on that a state is entered after a function call + before you receive the \l{Phonon::MediaObject::}{stateChanged()} + signal. The description of the \l{Phonon::}{State} enum gives a + description of the different states. + + Before play() is called, the media object should be connected to + \l{Sinks}{output nodes}, which outputs the media to the + underlying hardware. The output nodes required are dependent on + the contents of the multimedia file that is played back. Phonon + has currently two output nodes: the \l{Phonon::}{AudioOutput} for + audio content and \l{Phonon::}{VideoWidget} for video content. If + a \l{Phonon::}{MediaSource} contains both audio and video, both + nodes need to be connected to the media object. + + \snippet snippets/phonon.cpp 4 + \snippet snippets/phonon.cpp 5 + + The media object can queue sources for playback. When it has + finished to play one source, it will start playing the next in the + queue; the new source is then removed from the queue. The + queue can be altered at any time. + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 7 + + You can also make use of the + \l{Phonon::MediaObject::}{aboutToFinish()} signal, which is + guaranteed to be emitted in time for altering the queue. + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 8 + + When playback is finishing, i.e., when a media source has been + played to the end and the queue is empty, several signals are + emitted. First, the media object will emit aboutToFinish() - + shortly before the playback has finished - and then finished(). + The stateChanged() signal will also be emitted with + \l{Phonon::}{PausedState}, which is the state the media object + takes when the playback is finished. If you wish to enter another + state, you can connect a slot to finished() and set a new state + there. + + The media object resolves the meta information, such as title, + artist, and album. The meta data is not resolved immediately after + a new source is provided, but will be resolved before the object + leaves the \l{Phonon::}{LoadingState}. The data is queried by + string keys - which should follow the Ogg Vorbis specification + \l http://xiph.org/vorbis/doc/v-comment.html - or by using the + \l{Phonon::}{MetaData} enum. The data available will depend on the + type and content of the individual media files. metaDataChanged() + will be emitted when the media object has resolved new meta data. + + Errors encountered during playback and loading of media sources + are reported by emitting a state changed signal with + \l{Phonon::}{ErrorState}. The severity of the error can be queried + by the \l{Phonon::}{ErrorType}. With a \l{Phonon::}{NormalError}, + it might be possible to continue the playback, for instance, if + only audio playback fails for a media source which also has video. + A \l{Phonon::}{FatalError} indicates that Phonon cannot continue + playback of the current source, but it is possible to try with a + different one. A user readable error message is given by + errorString(). + + \sa Phonon::MediaSource, Phonon::AudioOutput, VideoWidget, + {Music Player Example}, {Phonon Overview}, Phonon::VideoPlayer, + Phonon::createPlayer(), {Phonon Module} + +*/ + +/*! + \property Phonon::MediaObject::transitionTime + \brief Defines the time between playback of two media sources + in the media queue. + + A positive transition time defines a gap of silence between queued + media sources. + + A transition time of 0 ms requests gapless playback (i.e., the + next source in the media queue starts immediately after the + playback of the current source finishes). + + A negative transition time defines a crossfade between the queued + media sources. + + Defaults to 0 (gapless playback). + + \warning This feature might not work reliably with every + backend. +*/ + +/*! + \property Phonon::MediaObject::prefinishMark + \brief the time when the prefinishMarkReached signal is emitted before playback ends. + + This property specifies the time in milliseconds the + prefinishMarkReached() signal is emitted before the playback + finishes. A value of \c 0 disables the signal. The signal is only + emitted for the last source in the \l{queue()}{media queue}. + + Defaults to \c 0 (disabled). + + \warning For some media data the total time cannot be determined + accurately, therefore the accuracy of the prefinishMarkReached signal + can be bad sometimes. Still, it is better to use this method than to + look at totalTime() and currentTime() to emulate the behavior + because the backend might have more information available than your + application does through totalTime() and currentTime(). + + \sa prefinishMarkReached() +*/ + +/*! + \property Phonon::MediaObject::tickInterval + \brief The time interval in milliseconds between two ticks. + + The tick() signal is emitted continuously during playback. + The tick interval is the time that elapses between the emission of two tick signals. + If you set the interval to \c 0 the tick signal gets disabled. + + The tick() signal can, for instance, be used to update widgets + that show the current position in the playback of a media source. + + Defaults to \c 0 (disabled). + + \warning The back-end is free to choose a different tick interval close + to what you asked for. This means that the following code \c may fail: + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 9 + On the other hand the following is guaranteed: + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 10 + + \sa tick() +*/ + +/*! + \fn Phonon::MediaObject::~MediaObject() + + Destroys the MediaObject. +*/ + +/*! + \fn State Phonon::MediaObject::state() const + + Returns the current Phonon::State of the object. + + \sa Phonon::State, stateChanged() +*/ + +/*! + \fn bool Phonon::MediaObject::hasVideo() const + + Check whether the current media source includes a video stream. + + \warning This information is not resolved immediately after a + media object gets a new source. Listen to the hasVideoChanged() + signal instead. + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 11 + + Returns \c true if the media contains video data; otherwise, + returns \c false. + + \sa hasVideoChanged() +*/ + +/*! + \fn bool Phonon::MediaObject::isSeekable() const + + Check whether it is possible to seek, i.e., change the + playback position in the media stream. + + \warning This information is not solved immediately after the + media object gets a new media source. The hasVideoChanged() signal + is emitted after this information is available. + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 12 + + Returns \c true if the current media may be seeked; otherwise, + returns \c false. + + \sa seekableChanged() +*/ + +/*! + \fn QStringList Phonon::MediaObject::metaData(const QString &key) const + + Returns the strings associated with the given \a key. + + Backends should use the keys specified in the Ogg Vorbis + documentation: \l http://xiph.org/vorbis/doc/v-comment.html + + Therefore the following should work with every backend: + + Note that meta data is not resolved before the \c + metaDataChanged() signal is emitted. + + A typical usage looks like this: + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 13 +*/ + +/*! + \fn QStringList Phonon::MediaObject::metaData(Phonon::MetaData key) const + + Returns the strings associated with the given \a key. + + Same as above except that the keys are defined in the + Phonon::MetaData enum. + + \sa metaDataChanged() +*/ + +/*! + \fn QMultiMap Phonon::MediaObject::metaData() const + + Returns all meta data in a multi map. + + \sa metaDataChanged() +*/ + +/*! + \fn QString Phonon::MediaObject::errorString() const + + Returns a human-readable description of the last error that occurred. + The strings given may vary between backends. + + The error description can be used to give a message to the user - + and the developer - when the stateChanged() signal is emitted with + \l{Phonon::}{ErrorState}. + + \section1 Qt Backends + + On Windows, Qt fetches its error messages from the DirectShow + backend. This usually includes an error number, which can be + looked up in the DirectShow documentation: + \l{http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dx81_c/directx_cpp/htm/errorandsuccesscodes.asp}. + + On Linux and Mac, the error strings are not fetched directly from + the backend, but are created in the backend. + + \sa Phonon::ErrorState, stateChanged() +*/ + +/*! + \fn ErrorType Phonon::MediaObject::errorType() const + + Tells your program what to do about the last error that occurred. + Use this function after receiving a stateChanged() signal with + \l{Phonon::}{ErrorState}. + + \sa Phonon::ErrorType, Phonon::ErrorState, stateChanged() +*/ + +/*! + \fn MediaSource Phonon::MediaObject::currentSource() const + + Returns the current media source, i.e., the media source that is + being played back. The current source is either set with + setCurrentSource() or taken from the media queue() when a media + source has finished playing. + + \sa setCurrentSource() +*/ + +/*! + \fn void Phonon::MediaObject::setCurrentSource(const MediaSource &source) + + Set the media source the MediaObject should use. + + After the media object receives a new source, it will enter the + \l{Phonon::}{LoadingState}. When it is ready to play, it + enters the \l{Phonon::}{StoppedState} unless another state + has been requested, e.g., by calling play(). + + \a source is the MediaSource object to the media data. You can + just as well use a QUrl or QString (for a local file) here. + + We show an example: + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 14 + + \sa currentSource(), MediaSource +*/ + +/*! + \fn QList Phonon::MediaObject::queue() const + + Returns the queued media sources. + + This does list does not include the current source, + returned by currentSource(). + + \sa enqueue() +*/ + +/*! + \fn void Phonon::MediaObject::setQueue(const QList &sources) + + Set the \a sources to play when the current source has finished. + + This function will overwrite the current queue. + + \sa clearQueue(), enqueue() +*/ + +/*! + \fn void Phonon::MediaObject::setQueue(const QList &urls) + + Set the \a urls to play when the current media has finished. + + This function overwrites the current queue. + + \sa clearQueue(), enqueue() +*/ + +/*! + \fn void Phonon::MediaObject::enqueue(const MediaSource &source) + + Appends \a source to the queue. + + You can use this function to provide the next source after the + aboutToFinish() signal has been emitted. + + \sa aboutToFinish(), setQueue(), clearQueue() +*/ + +/*! + \fn void Phonon::MediaObject::enqueue(const QList &sources) + + Appends multiple \a sources to the queue. + + \sa setQueue(), clearQueue() +*/ + +/*! + \fn void Phonon::MediaObject::enqueue(const QList &urls) + + Appends the URLs in \a urls to the media source queue. + + The function will create \l{MediaSource}s from the \l{QUrl}s, and + append these to the queue. + + \sa setQueue(), clearQueue() +*/ + +/*! + \fn void Phonon::MediaObject::clearQueue() + + Clears the queue of media sources. + + \sa queue(), enqueue() +*/ + +/*! + \fn qint64 Phonon::MediaObject::currentTime() const + + Returns the current time (in milliseconds), i.e., position in the + media stream, of the file currently being played. + + \sa tick(), totalTime(), remainingTime() +*/ + +/*! + \fn qint64 Phonon::MediaObject::totalTime() const + + Get the total time (in milliseconds) of the file currently being played. + + Returns the total time in milliseconds. + + \warning The total time is not defined before the media object + enters the \l{Phonon::}{LoadingState}. + + \sa totalTimeChanged() +*/ + +/*! + \fn qint64 Phonon::MediaObject::remainingTime() const + + Get the remaining time (in milliseconds) of the file currently being played. + + Returns the remaining time in milliseconds. + + \sa totalTime(), currentTime(), totalTimeChanged() +*/ + +/*! + \fn void Phonon::MediaObject::play() + + Requests playback of the media data to start. + + Playback starts when the stateChanged() signal is emitted with + \l{Phonon::}{PlayingState}. + + If the media object is already in a + \l{Phonon::}{PlayingState}, nothing happens. + + \sa stop(), pause(), stateChanged() +*/ + +/*! + \fn void Phonon::MediaObject::pause() + + Requests playback to pause, and the media object to enter the + \l{Phonon::}{PausedState}. If it was paused already, nothing + changes. + + This function is asynchronous and the media might not be paused + immediately. + + \sa play(), stop(), stateChanged() +*/ + +/*! + \fn void Phonon::MediaObject::stop() + + Requests playback to stop, and the media object to enter the + \l{Phonon::}{StoppedState}. If it was stopped before + nothing changes. + + This function is asynchronous and the media might not be + stopped immediately. + + \sa play(), pause(), stateChanged() +*/ + +/*! + \fn void Phonon::MediaObject::seek(qint64 time) + + Requests a seek to the \a time indicated, specified in milliseconds. + + You can only seek if state() is PlayingState, BufferingState or PausedState. + + The call is asynchronous, so currentTime can still be the old + value right after this method was called. If all you need is a + slider that shows the current position and allows the user to + seek, use the class SeekSlider. + + If the current source of the media object is not seekable, calls + to this functions do nothing. + + \sa SeekSlider, tick() +*/ + +/*! + \fn void Phonon::MediaObject::clear() + + Stops and removes all playing and enqueued media sources. + + \sa setCurrentSource() +*/ + + +/*! + \fn void Phonon::MediaObject::stateChanged(Phonon::State newstate, Phonon::State oldstate) + + This signal is emitted when the state of the MediaObject has changed. + The \a oldstate and \a newstate parameters indicate the previous + state and current state of the media object. + + If you are only interested in the new state of the media object, you can + connect this signal to a slot that accepts only one State argument. +*/ + +/*! + \fn void Phonon::MediaObject::tick(qint64 time) + + This signal is emitted in intervals defined by the + \l{tickInterval} property. The current position of the media + object in the stream is given by the \a time parameter. The \a + time is specified in milliseconds. + + \sa tickInterval +*/ + +/*! + \fn void Phonon::MediaObject::metaDataChanged() + + This signal is emitted when the media object has resolved new meta + data. This will happen before the media object leaves the + \l{Phonon::}{LoadingState} after a new source has been set. + + This signal is not emitted when the media object removes the + current data, i.e., when a new source is set or an error has + occurred. If you need to know this, you can listen for the + \l{Phonon::}{ErrorState}, and connect to the + \l{Phonon::MediaObject::}{currentSourceChanged()} signal. + + You can get the new meta data with the metaData methods. + + \sa metaData(), currentSourceChanged(), stateChanged(), Phonon::State +*/ + +/*! + \fn void Phonon::MediaObject::seekableChanged(bool isSeekable) + + This signal is emitted when the media object's ability to seek in + the media stream changes. \a isSeekable is true if it is possible + to seek(); otherwise, it is false. + + Change in the ability to seek in the stream usually happens when + the current source changes or when an error occurs. + + \omit Emitted whenever the return value of isSeekable() + changes. \endomit + + Normally you'll check isSeekable() after setting a new media + source, and then let this signal tell you when seeking is + possible. That way you don't have to poll isSeekable(). +*/ + +/*! + \fn void Phonon::MediaObject::hasVideoChanged(bool hasVideo) + + Emitted whenever the return value of hasVideo() changes, i.e., + the media source being played back contains video. + + Normally you'll check hasVideo() first and then let this signal + tell you whether video is available now or not. That way you + don't have to poll hasVideo(). + + \a hasVideo is true when the stream contains video and adding a + VideoWidget will show a video, and false if there is no video data + in the stream and adding a VideoWidget will show an empty (black) + VideoWidget. +*/ + +/*! + \fn void Phonon::MediaObject::bufferStatus(int percentFilled) + + Provides information about the status of the buffer. + + When a MediaObject is in the \l{Phonon::}{BufferingState}, it will + send this signal regularly. \a percentFilled is a number between 0 + and 100 telling you how much the buffer is filled. + + You can use this signal to show a progress bar to the user when + in BufferingState: + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 15 + + Note that the \l{Phonon::}{BufferingState} is commonly used when + waiting for data over a network connection, but this might not be + true for all backends. +*/ + +/*! + \fn void Phonon::MediaObject::finished() + + Emitted when the object has finished playback. It is not emitted + if you call stop(), pause() or load(). It is emitted only when the + current media source has finished playing and the media queue() is + empty, or when a \l{Phonon::FatalError}{fatal error} occurs. + + \warning This signal is not emitted when the current source has + finished and there's another source in the queue. It is only + emitted when the queue is empty. + + \sa currentSourceChanged(), aboutToFinish(), prefinishMarkReached() +*/ + +/*! + \fn void Phonon::MediaObject::currentSourceChanged(const Phonon::MediaSource &newSource) + + Emitted when the MediaObject fetches a new MediaSource from the + queue() and before it enters the \l{Phonon::}{LoadingState} for + the new source. The media object will take a new source from the + queue() when it has finished the playback of the + \l{currentSource()}{current source}. + + \a newSource is the source that starts to play at the time the + signal is emitted. +*/ + +/*! + \fn void Phonon::MediaObject::aboutToFinish() + + Emitted before the playback of the whole queue ends. When this + signal is emitted you still have time to enqueue() a new + MediaSource, so that playback continues. + + If you need a signal to be emitted at a specific time before + playback is finished, you should use the prefinishMarkReached() + signal instead. + + \sa enqueue(), prefinishMark, prefinishMarkReached() +*/ + +/*! + \fn void Phonon::MediaObject::prefinishMarkReached(qint32 msecToEnd) + + Emitted when there are only \a msecToEnd milliseconds left + of playback. + + \warning This signal is not emitted when there is another source + in the queue. It is only emitted when the queue is empty. + + \sa setPrefinishMark(), prefinishMark(), aboutToFinish(), finished() +*/ + +/*! + \fn void Phonon::MediaObject::totalTimeChanged(qint64 newTotalTime) + + This signal is emitted as soon as the total time of the media file is + known or has changed. For most non-local media data the total + time of the media can only be known after some time. At that time the + totalTime function can not return useful information. You have + to wait for this signal to know the real total time. + + \a newTotalTime is the length of the media file in milliseconds. + + \sa totalTime() +*/ + +/*! + \fn MediaObject *Phonon::createPlayer(Phonon::Category category, const MediaSource &source = MediaSource()) + + Convenience function to create a MediaObject and AudioOutput + connected by a path. The \l{Phonon::}{MediaObject} return will + have \a source set as its current source and the specified \a + category. + +*/ + +/*! + \class Phonon::MediaObjectPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \namespace Phonon::BackendCapabilities + \inmodule Phonon + \since 4.4 + \brief The BackendCapabilities namespace contains functions to describe the capabilities of the multimedia backend. + +*/ + +/*! + \class Phonon::BackendCapabilitiesPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::BackendCapabilities::Notifier + \since 4.4 + \inmodule Phonon + \inheaderfile Phonon/BackendCapabilities + + Notifications about backend capabilities. +*/ + +/*! + \fn void Phonon::BackendCapabilities::Notifier::capabilitiesChanged() + + This signal is emitted if the capabilities have changed. This can + happen if the user has requested a backend change. +*/ + +/*! + \fn void Phonon::BackendCapabilities::Notifier::availableAudioOutputDevicesChanged() + + This signal is emitted when audio output devices were plugged or + unplugged. + + Check BackendCapabilities::availableAudioOutputDevices to get the + current list of available devices. +*/ + +/*! + \fn Notifier *Phonon::BackendCapabilities::notifier() + + Use this function to get a QObject pointer to connect to the capabilitiesChanged signal. + + \return a pointer to a QObject. + + The capabilitiesChanged signal is emitted if the capabilities have changed. This can + happen if the user has requested a backend change. + + To connect to this signal do the following: + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 16 + + \sa Notifier::capabilitiesChanged() +*/ + +/*! + \fn QStringList Phonon::BackendCapabilities::availableMimeTypes() + + Returns a list of mime types that the Backend can decode. + + \sa isMimeTypeAvailable() +*/ + +/*! + \fn bool Phonon::BackendCapabilities::isMimeTypeAvailable(const QString &mimeType) + + Often all you want to know is whether one given MIME type can be + decoded by the backend. Use this method in favor of + availableMimeTypes() as it can give you a negative answer without + having a backend loaded. + + Returns true if the given \a mimeType is supported by the backend; + otherwise, returns false. + + \sa availableMimeTypes() +*/ + +/*! + \fn QList Phonon::BackendCapabilities::availableAudioOutputDevices() + + Returns the audio output devices the backend supports. + + \return A list of AudioOutputDevice objects that give a name and + description for every supported audio output device. +*/ + +/*! + \fn QList Phonon::BackendCapabilities::availableAudioEffects() + + Returns descriptions for the audio effects the backend supports. + + \return A list of AudioEffectDescription objects that give a name and + description for every supported audio effect. +*/ + +/*! + \internal + \class ObjectDescriptionModelData + \internal + \inmodule Phonon + \brief Data class for models for ObjectDescription objects. +*/ + +/*! + \typedef Phonon::EffectDescription + \relates Phonon::ObjectDescription + + EffectDescription gives a description of an \l{Processors}{audio + effect}. It is a typedef of the \l{Phonon::}{ObjectDescription} + class. Please see its class description for details. + + EffectDescription is used to create audio \l{Phonon::}{Effect}s, + which can be inserted into a media graph, altering an audio + stream. + + \sa Phonon::ObjectDescription, {Capabilities Example}, {Media + Player} + +*/ + +/*! + \class Phonon::ObjectDescriptionModel + \inmodule Phonon + \internal + \since 4.4 + \brief The ObjectDescriptionModel class provides a model from + a list of ObjectDescription objects. + + ObjectDescriptionModel is a read only model that supplies a list + using ObjectDescription::name() for the text and + ObjectDescription::description() for the tooltip. If set the properties + "icon" and "available" are used to set the decoration and disable the + item (disabled only visually, you can still select and drag it). + + It also provides the methods moveUp() and moveDown() to order the list. + Additionally drag and drop is possible so that + QAbstractItemView::InternalMove can be used. + The resulting order of the ObjectDescription::index() values can then be + retrieved using tupleIndexOrder(). + + An example use case would be to give the user a QComboBox to select + the output device: + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 17 + + And to retrieve the selected AudioOutputDevice: + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 18 + +*/ + +/*! + \fn inline int Phonon::ObjectDescriptionModel::rowCount(const QModelIndex &parent = QModelIndex()) const + + Returns the number of rows in the model. This value corresponds + to the size of the list passed through setModelData. + + \param parent The optional \a parent argument is used in most models to specify + the parent of the rows to be counted. Because this is a list if a + valid parent is specified the result will always be 0. + + Reimplemented from QAbstractItemModel. + + \sa QAbstractItemModel::rowCount() +*/ + +/*! + \fn inline QVariant Phonon::ObjectDescriptionModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const + + Returns data from the item with the given \a index for the specified + \a role. + If the view requests an invalid index, an invalid variant is + returned. + + Reimplemented from QAbstractItemModel. + + \sa QAbstractItemModel::data(), Qt::ItemDataRole +*/ + +/*! + \fn inline Qt::ItemFlags Phonon::ObjectDescriptionModel::flags(const QModelIndex &index) const + \internal + + Reimplemented to show unavailable devices as disabled (but still + selectable). The \a index of the model index for which to return + flags. + +*/ + +/*! + \fn inline QList Phonon::ObjectDescriptionModel::tupleIndexOrder() const + + Returns a list of indexes in the same order as they are in the + model. The indexes come from the ObjectDescription::index + method. + + This is useful to let the user define a list of preference. +*/ + +/*! + \fn inline int Phonon::ObjectDescriptionModel::tupleIndexAtPositionIndex(int positionIndex) const + + Returns the ObjectDescription::index for the tuple + at the given position \a positionIndex. For example a + QComboBox will give you the currentIndex as the + position in the list. But to select the according + AudioOutputDevice using AudioOutputDevice::fromIndex + you can use this method. + + \param positionIndex The position in the list. +*/ + +/*! + \class Phonon::ObjectDescriptionModelDataPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \fn inline QMimeData *Phonon::ObjectDescriptionModel::mimeData(const QModelIndexList &indexes) const + \internal + + Returns the MIME data that dropMimeData() can use to create new + items. +*/ + +/*! + \fn inline void Phonon::ObjectDescriptionModel::moveUp(const QModelIndex &index) + + Moves the item at the given \a index up. In the resulting list + the items at index.row() and index.row() - 1 are swapped. + + Connected views are updated automatically. +*/ + +/*! + \fn inline void Phonon::ObjectDescriptionModel::moveDown(const QModelIndex &index) + + Moves the item at the given \a index down. In the resulting list + the items at index.row() and index.row() + 1 are swapped. + + Connected views are updated automatically. +*/ + +/*! + \fn explicit inline Phonon::ObjectDescriptionModel::ObjectDescriptionModel(QObject *parent = 0) + + Constructs a ObjectDescription model with the + given \a parent. +*/ + +/*! + \fn explicit inline Phonon::ObjectDescriptionModel::ObjectDescriptionModel(const QList > &data, QObject *parent = 0) + + Constructs a ObjectDescription model with the + given \a parent and the given \a data. +*/ + +/*! + \fn inline void Phonon::ObjectDescriptionModel::setModelData(const QList > &data) + + Sets the model data using the list provided by \a data. + + All previous model data is cleared. +*/ + +/*! + \fn inline QList > Phonon::ObjectDescriptionModel::modelData() const + + Returns the model data. + + As the order of the list might have changed this can be different + to what was set using setModelData(). +*/ + +/*! + \fn inline ObjectDescription Phonon::ObjectDescriptionModel::modelData(const QModelIndex &index) const + + Returns one ObjectDescription of the model data for the given \a index. +*/ + +/*! + \fn inline Qt::DropActions Phonon::ObjectDescriptionModel::supportedDropActions() const + + This model supports drag and drop to copy or move + items. +*/ + +/*! + \fn inline bool Phonon::ObjectDescriptionModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) + + Accept drops from other models of the same ObjectDescriptionType. + + The \a data is dropped at the given \a row and \a column; you + also receive the \a parent model index. + + If a valid \a parent is given the dropped items will be inserted + above that item. +*/ + +/*! + \fn inline bool Phonon::ObjectDescriptionModel::removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) + + Removes count rows starting with the given row. + + If a valid \a parent is given no rows are removed since this is a + list model. + + Returns true if the rows were successfully removed; otherwise returns false. +*/ + +/*! + \fn inline QStringList Phonon::ObjectDescriptionModel::mimeTypes() const + + Returns a list of supported drag and drop MIME types. Currently + it only supports one type used internally. +*/ + +/*! + \class Phonon::EffectInterface + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::Effect + \inmodule Phonon + \inheaderfile Phonon/Effect + \since 4.4 + \brief The Effect class is used to transform audio streams. + + An effect is a media node which is inserted into a path between a + \l{Phonon::}{MediaObject} and an audio output node, for instance, + an \l{Phonon::}{AudioOutput}. The Effect transforms the media + stream on that path. + + Examples may include simple modifiers, such as fading or pitch + shifting, and more complex mathematical transformations. You can + query the backend for available effects with + BackendCapabilities::availableAudioEffects(). Note that the + effects available is dependent on the underlying system + (DirectDraw, GStreamer, or QuickTime). + + In order to use an effect, insert it into the path as follows: + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 19 + + The effect will immediately begin applying it's transformations on + the path. To stop it, remove the Effect from the path. + + To create an effect, you use the \l{Phonon::}{EffectDescription} + class, which you get from + \l{BackendCapabilities::}{availableAudioEffects()}. We give a code + example below. + + \snippet doc/src/snippets/audioeffects.cpp 0 + + An effect can have one or more parameters, which let you alter how + the effect works, for instance, by specifying the depth of a + reverb effect. See the EffectParameter class description for + details. + + Phonon also provides EffectWidget, which lets the user modify the + parameters of an effect an the fly; e.g., with combo boxes. + + \sa {Phonon Module}, EffectWidget +*/ + +/*! + \fn explicit Phonon::Effect::Effect(const EffectDescription &description, QObject *parent = 0) + + Constructs a new effect object with the given \a description and \a parent object. + + The EffectDescription object determines the type of the effect. + + \sa {Phonon::BackendCapabilities::availableAudioEffects()} +*/ + +/*! + \fn Phonon::Effect::Effect(EffectPrivate &dd, QObject *parent) + \internal +*/ + +/*! + \fn Phonon::Effect::~Effect() + \internal +*/ + +/*! + \fn QVariant Phonon::Effect::parameterValue(const EffectParameter ¶meter) const + + Returns the value of the given effect \a parameter. You can fetch + the available parameters for an effect with parameters(). + + \sa setParameterValue(), EffectParameter +*/ + +/*! + \fn void Phonon::Effect::setParameterValue(const EffectParameter ¶meter, const QVariant &value) + + Sets the given effect \a parameter to the specified \a value. + + Parameters for an effect are returned by parameters(). You can + check which QVariant::Type an EffectParameter takes with the + EffectParameter::type() function. + + \sa parameterValue(), EffectParameter +*/ + +/*! + \fn EffectDescription Phonon::Effect::description() const; + + Returns the description of this effect. This is the same + description that was passed to the constructor. +*/ + +/*! + \fn QList Phonon::Effect::parameters() const; + + Returns a list of parameters that this effect provides to control + its behavior. + + \sa EffectParameter, EffectWidget +*/ + +/*! + \class Phonon::EffectPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::AudioOutput + \inmodule Phonon + \inheaderfile Phonon/AudioOutput + \since 4.4 + \brief The AudioOutput class is used to send data to audio output devices. + + The AudioOutput class plays sound over a sound device. The audio + output needs to be connected to a \l{Phonon::}{MediaObject} using + \l{Phonon::}{createPath()}. To start playback, you call + \l{Phonon::MediaObject::}{play()} on the media object. + + \snippet snippets/phonon.cpp 2 + + The class supports changing the volume(). It is also possible to + mute the sound. + + To find out what \l{Phonon::}{AudioOutputDevice}s are available + for AudioOutput, you can call + BackendCapabilities::availableAudioOutputDevices(). A default device is + selected by the backend, but it is possible to set the device to + be used with setOutputDevice(). The outputDeviceChanged() signal + will be emitted if the device changes. + + If an error occurs with the playback, for instance, if no valid + output device is found, the media object will receive a + stateChanged() signal with the \l{Phonon::}{ErrorState}. + + Note that the default values of properties are dependent on the + backend. + + \sa Phonon::VolumeSlider, {Music Player Example}, BackendCapabilities, {Phonon Module} +*/ + +/*! + \property Phonon::AudioOutput::name + + This is the name that appears in Mixer applications that control + the volume of this output. + +*/ + +/*! + \property Phonon::AudioOutput::volume + + This is the current loudness of the output. \omit The volume is a + real value between 0.0 (minimum) and 1.0 (maximum). The volume + follows the sound device used, with 1.0 being the maximum volume + the device can produce. \endomit + + (it is using Stevens' law + to calculate the change in voltage internally). + + \sa volumeDecibel +*/ + +/*! + \property Phonon::AudioOutput::volumeDecibel + + This is the current volume of the output in decibel. + + 0 dB means no change in volume, -6dB means an attenuation of the + voltage to 50% and an attenuation of the power to 25%, -inf dB means + silence. + + \sa volume +*/ + +/*! + \property Phonon::AudioOutput::outputDevice + This property holds the (hardware) destination for the output. + + The default device is determined by the \l{Phonon::}{Category} and the global + configuration for that category. Normally you don't need + to override this setting - letting the user change the global + configuration is the right choice. You can still override the + device though, if you have good reasons to do so. + + \sa outputDeviceChanged() +*/ + +/*! + \property Phonon::AudioOutput::muted + This property tells whether the output is muted. + + Muting the output has the same effect as calling setVolume(0.0). +*/ + +/*! + \fn explicit Phonon::AudioOutput::AudioOutput(Phonon::Category category, QObject *parent = 0) + + Creates a new AudioOutput with the given \a parent that defines + output to a physical device. + + The \a category can be used by mixer applications to group volume + controls of applications into categories. That makes it easier for + the user to identify the programs. + The category is also used for the default output device that is + configured centrally. As an example: often users want to have the + audio signal of a VoIP application go to their USB headset while + all other sounds should go to the internal soundcard. + + \sa Phonon::categoryToString(), outputDevice +*/ + +/*! + \fn explicit Phonon::AudioOutput::AudioOutput(QObject *parent = 0) + + Creates a new AudioOutput that defines output to the system + default device with the \{Phonon::Category::}{NoCategory} category + + \sa Phonon::categoryToString(), outputDevice +*/ + +/*! + \fn Phonon::Category Phonon::AudioOutput::category() const + + Returns the category of this output. + + \sa Phonon::AudioOutput::AudioOutput() +*/ + +/*! + \fn void Phonon::AudioOutput::volumeChanged(qreal newVolume) + + This signal is emitted whenever the volume has changed. As the + volume can change without a call to setVolume (calls over dbus) + this is important to keep a widget showing the current volume up + to date. + + \a newVolume is the new volume level. + + \sa setVolume(), volume() +*/ + +/*! + \fn void Phonon::AudioOutput::mutedChanged(bool muted) + + This signal is emitted when the muted property has changed. The \a muted + value passed by the signal indicates the state of the muted property. + As this property can change by IPC (DBus) calls a UI element showing + the muted property should listen to this signal. +*/ + +/*! + \fn void Phonon::AudioOutput::outputDeviceChanged(const Phonon::AudioOutputDevice &newAudioOutputDevice) + + This signal is emitted when the (hardware) device for the output + has changed. \a newAudioOutputDevice is the new device. + + The change can happen either through setOutputDevice or if the + global configuration for the used category has changed. + + \sa outputDevice +*/ + +/*! + \class Phonon::AudioOutputPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::EffectParameter + \inmodule Phonon + \inheaderfile Phonon/EffectParameter + \since 4.4 + \brief The EffectParameter class describes one parameter of an effect. + + You fetch the parameters of an \l{Phonon::}{Effect} with + \l{Phonon::}{Effect::parameters()}. + + \snippet doc/src/snippets/phononeffectparameter.cpp 0 + + To describe itself, an effect parameter gives a name() and + possibly description() (depending on the backend used). These are + suited to present the effect parameter to the user of a Phonon + application. + + Note that effects are created by the backend, and that + their name and descriptions may vary. + + The value of an effect parameter is stored in a \l{QVariant}, + of which type() is usually \c int or \c double. + + The value is retrieved with \l{Phonon::}{Effect::parameterValue()} + and set with \l{Phonon::Effect::}{setParameterValue()} - both of + which takes the EffectParameter as argument. Note that not all + effect parameters support setting of their value. + + You get the values a parameter can take with possibleValues(); an + empty list is returned if the values are continuous. + + A parameter may also specify default(), minimum(), and maximum() + values. Values are returned as \l{QVariant}s. If the parameter + does not have the requested value, an \l{QVariant::Invalid} + invalid QVariant is returned from these functions. + + The \l{Phonon::}{EffectWidget} provides a widget with which one + can control the parameters of an \l{Phonon::}{Effect}. + + \snippet doc/src/snippets/phononeffectparameter.cpp 1 + + \sa Effect, EffectWidget, {Capabilities Example}, {Phonon Module} +*/ + +/*! + \fn Phonon::EffectParameter::EffectParameter() + \internal + + Creates an invalid effect parameter. +*/ + +/*! + \fn Phonon::EffectParameter::~EffectParameter() + + Destroys the effect parameter. +*/ + +/*! + \fn Phonon::EffectParameter::EffectParameter(const EffectParameter &other) + + Constructs a copy of the \a other effect parameter. +*/ + +/*! + \fn const QString &Phonon::EffectParameter::name() const + + The name of the parameter. Can be used as the label. + + \return A label for the parameter. +*/ + +/*! + \fn const QString &Phonon::EffectParameter::description() const + + The parameter may come with a description (LADSPA doesn't have a + field for this, so don't expect many effects to provide a + description). + + The description can be used for a tooltip or WhatsThis help. + + \return A text describing the parameter. +*/ + +/*! + \fn QVariant::Type Phonon::EffectParameter::type() const + + Returns the parameter type. + + Common types are QVariant::Int, QVariant::Double, QVariant::Bool and QVariant::String. When + QVariant::String is returned you get the possible values from possibleValues. +*/ + +/*! + \fn bool Phonon::EffectParameter::isLogarithmicControl() const + + Returns whether the parameter should be + displayed using a logarithmic scale. This is particularly useful for + frequencies and gains. +*/ + +/*! + \fn QVariant Phonon::EffectParameter::minimumValue() const + + The minimum value to be used for the control to edit the parameter. + + If the returned QVariant is invalid the value is not bounded from + below. +*/ + +/*! + \fn QVariant Phonon::EffectParameter::maximumValue() const + + The maximum value to be used for the control to edit the parameter. + + If the returned QVariant is invalid the value is not bounded from + above. +*/ + +/*! + \fn QVariant Phonon::EffectParameter::defaultValue() const + + The default value. +*/ + +/*! + \fn QVariantList Phonon::EffectParameter::possibleValues() const + + The possible values to be used for the control to edit the parameter. + + if the value of this parameter is to be picked from predefined values + this returns the list (otherwise it returns an empty QVariantList). +*/ + +/*! + \fn bool Phonon::EffectParameter::operator<(const EffectParameter &rhs) const + + \internal + compares the ids of the parameters +*/ + +/*! + \fn bool Phonon::EffectParameter::operator>(const EffectParameter &rhs) const + + \internal + compares the ids of the parameters +*/ + +/*! + \fn bool Phonon::EffectParameter::operator==(const EffectParameter &rhs) const + + \internal + compares the ids of the parameters +*/ + +/*! + \fn Phonon::EffectParameter &Phonon::EffectParameter::operator=(const EffectParameter &other) + + Assigns the \a other effect parameter to this parameter and returns + a reference to this parameter. +*/ + +/*! + \enum Phonon::EffectParameter::Hint + + Only for backend developers: + + Flags to set the return values of isToggleControl(), + isLogarithmicControl(), isIntegerControl(), isBoundedBelow() and + isBoundedAbove(). The values of the flags correspond to the values + used for LADSPA effects. + + \value ToggledHint + If this hint is set it means that + the control has only two states: zero and non-zero + (see isToggleControl()). + + \value LogarithmicHint + LADSPA's SAMPLE_RATE hint needs to be translated by the backend + to normal bounds, as the backend knows the sample rate - and the + frontend doesn't (see isLogarithmicControl()). + + \value IntegerHint See isIntegerControl(). +*/ + +/*! + \fn Phonon::EffectParameter::EffectParameter(int parameterId, + const QString &name, EffectParameter::Hints hints, + const QVariant &defaultValue, const QVariant &min = QVariant(), + const QVariant &max = QVariant(), const QVariantList &values = QVariantList(), + const QString &description = QString()) + + Only to be used by backend implementations: + + Creates a new effect parameter. + + \a parameterId This is a number to uniquely identify the + parameter. The id is used for value() and setValue(). + + \a name is the name/label for this parameter. + + \a hints sets the hints for the type of parameter. + + \a defaultValue The value that should be used as a default. + + \a min is the minimum value allowed for this parameter. You only + need to set this if the BoundedBelowHint is set. + + \a max is the maximum value allowed for this parameter. You only + need to set this if the BoundedAboveHint is set. + + The \a values parameter is the values that the effect parameter + can take (only applies if non-continuous) + + \a description is a descriptive text for the parameter + (explaining what it controls) to be used as a tooltip or + WhatsThis help. +*/ + +/*! + \fn int Phonon::EffectParameter::id() const + + \internal + + Returns the parameter's identifier. +*/ + +/*! + \typedef Phonon::AudioOutputInterface + \inmodule Phonon + \internal +*/ + +/*! + \class Phonon::AudioOutputInterface40 + \inmodule Phonon + \since 4.4 + \internal + \brief Interface for AudioOutput objects + +*/ + +/*! + \fn virtual Phonon::AudioOutputInterface40::~AudioOutputInterface40() + \internal +*/ + +/*! + \fn virtual qreal Phonon::AudioOutputInterface40::volume() const = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::AudioOutputInterface40::setVolume(qreal) = 0 + \internal +*/ + +/*! + \fn virtual int Phonon::AudioOutputInterface40::outputDevice() const = 0 + \internal +*/ + +/*! + \fn virtual bool Phonon::AudioOutputInterface40::setOutputDevice(int) = 0 + \internal +*/ + +/*! + \class Phonon::Path + \inmodule Phonon + \inheaderfile Phonon/Path + \since 4.4 + \brief The Path class describes connections between media nodes. + + In a \l{Building Graphs}{media graph}, \l{Phonon::}{MediaNode}s + are connected by Paths. The multimedia travels in streams over + these paths. + + You create a path between two media nodes using the static + Phonon::createPath() function, which takes two nodes as arguments. + The first argument will send the media stream to the second. + Please refer to the class description of the individual media + nodes and the Phonon \l{Phonon Overview}{overview} to see which + nodes can be connected to each other. + + Paths are also used to insert audio \l{Phonon::}{Effect}s between + two media nodes. The effect will then alter the stream on the + path. Notice that \l{Phonon::}{Effect}s also are media nodes, but + that insertEffect() - instead of Phonon::createPath() - is used to + insert them into the media graph. + + The following code example shows how to create a path between two + media nodes and insert an effect on that path. + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 20 + + \sa Phonon::MediaNode, Phonon::MediaObject, Phonon::AudioOutput, + Phonon::VideoWidget, {Phonon Module} +*/ + +/*! + \fn Phonon::Path::~Path(); + + Destroys this reference to the Path. If the path was valid the connection is not broken + as both the source and the sink MediaNodes still keep a reference to the Path. + + \sa disconnect() +*/ + +/*! + \fn Phonon::Path::Path(); + + Creates an invalid path. + + You can still make it a valid path by calling reconnect. It is + recommended to use the Phonon::createPath() function to create + paths. + + \sa Phonon::createPath(), isValid() +*/ + +/*! + \fn Phonon::Path::Path(const Path &path); + + Constructs a copy of the other \a path specified. + + This constructor is fast thanks to explicit sharing. +*/ + +/*! + \fn bool Phonon::Path::isValid() const; + + A path is considered valid if it is connected to two media nodes, + in which case this function returns true. If it is connected to + one or no media nodes, it is consider invalid, and this function + will then return false. +*/ + +/*! + \fn Effect *Phonon::Path::insertEffect(const EffectDescription &desc, Effect *insertBefore = 0); + + Creates and inserts an effect into the path. + + You may insert effects of the same class as often as you like, + but if you insert the same object, the call will fail. + + \a desc is the EffectDescription object for the effect to be inserted. + + If you already inserted an effect you can + tell with \a insertBefore in which order the data gets + processed. If this is \c 0 the effect is appended at the end of + the processing list. If the effect has not been inserted before + the method will do nothing and return \c false. + + Returns a pointer to the effect object if it could be inserted + at the specified position. If \c 0 is returned, the effect was not + inserted. + + Below is a code example for inserting an effect into a path: + + \snippet doc/src/snippets/audioeffects.cpp 0 + + \sa removeEffect(), effects() +*/ + +/*! + \fn bool Phonon::Path::insertEffect(Effect *effect, Effect *insertBefore = 0); + + Inserts the given \a effect into the path before the effect specified by \a insertBefore + and returns true if successful; otherwise returns false. + + If \a insertBefore is zero, the effect is appended to the processing list. + + You may insert effects of the same class as often as you like, but if you insert + the same object, the call will fail. + + \a effect will be inserted right before \a insertBefore. If + \a insertBefore is \c 0, the effect is appended at the end of the + processing list. If the effect has not been inserted before the + method will do nothing and return \c false. + + Returns whether the effect could be inserted at the specified + position. If \c false is returned the effect was not inserted. + + \sa removeEffect(), effects() +*/ + +/*! + \fn bool Phonon::Path::removeEffect(Effect *effect); + + Removes the given \a effect from the path and returns true; otherwise returns false. + + Removes an \a effect from the path. + + If the effect is deleted while it is still connected, the effect will be removed + automatically. + + \omit + \param effect The effect to be removed. + + \return Returns whether the call was successful. If it returns + \c false the effect could not be found in the path, meaning it + has not been inserted before. + \endomit + + \sa insertEffect(), effects() +*/ + +/*! + \fn QList Phonon::Path::effects() const; + + Returns a list of Effect objects that are currently + used as effects. The order in the list determines the order the + signal is sent through the effects. + + \return A list with all current effects. + + \sa insertEffect(), removeEffect() +*/ + +/*! + \fn bool Phonon::Path::reconnect(MediaNode *source, MediaNode *sink); + + Changes the media nodes the path is connected to by connecting the path + to the \a source and \a sink nodes specified. Returns true if successful; + otherwise returns false. + + If unsuccessful, the path remains connected to the same nodes as before. + + \sa Phonon::createPath(), {Phonon Overview} +*/ + +/*! + \fn bool Phonon::Path::disconnect(); + + Tries to disconnect the path from the MediaNodes it is connected to, returning + true if successful or false if unsuccessful. + + If successful, the path is invalidated: isValid() will returns false. +*/ + +/*! + \fn Path &Phonon::Path::operator=(const Path &p); + + Assigns \a p to this Path and returns a reference to this Path. + + This operation is fast thanks to explicit sharing. +*/ + +/*! + \fn bool Phonon::Path::operator==(const Path &p) const; + + Returns true if this Path is equal to \a p; otherwise returns false; +*/ + +/*! + \fn bool Phonon::Path::operator!=(const Path &p) const; + + Returns true if this Path is not equal to \a p; otherwise returns false. +*/ + +/*! + \fn MediaNode *Phonon::Path::source() const; + + Returns the source MediaNode used by the path. +*/ + +/*! + \fn MediaNode *Phonon::Path::sink() const; + + Returns the sink MediaNode used by the path. +*/ + +/*! + \fn Path Phonon::createPath(MediaNode *source, MediaNode *sink); + + \relates Phonon::Path + Creates a new Path connecting the two MediaNodes \a source and \a sink. + + The implementation will automatically select the right format and media type. E.g. connecting a + MediaObject and AudioOutput will create a Path object connecting the audio. This might be + represented as PCM or perhaps even AC3 depending on the AudioOutput object. + + \param source The MediaNode to connect an output from + \param sink The MediaNode to connect to. +*/ + +/*! + \class Phonon::PathPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::MediaObjectInterface + \inmodule Phonon + \since 4.4 + \internal + \brief Backend interface for media sources. + + The backend implementation has to provide two signals, that are not defined + in this interface: + \list + \o \target phonon_MediaObjectInterface_stateChanged + void stateChanged(Phonon::State newstate, Phonon::State oldstate) + + Emitted when the state of the MediaObject has changed. + In case you're not interested in the old state you can also + connect to a slot that only has one State argument. + + \param newstate The state the Player is in now. + \param oldstate The state the Player was in before. + + \o \target phonon_MediaObjectInterface_tick + void tick(qint64 time) + + This signal gets emitted every tickInterval milliseconds. + + \param time The position of the media file in milliseconds. + + \sa setTickInterval() + \sa tickInterval() + \endlist + + \sa MediaObject +*/ + +/*! + \fn virtual Phonon::MediaObjectInterface::~MediaObjectInterface() + \internal +*/ + +/*! + \fn virtual qint64 Phonon::MediaObjectInterface::remainingTime() const + \internal +*/ + +/*! + \fn virtual qint32 Phonon::MediaObjectInterface::prefinishMark() const = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::MediaObjectInterface::setPrefinishMark(qint32) = 0 + \internal +*/ + +/*! + \fn virtual qint32 Phonon::MediaObjectInterface::transitionTime() const = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::MediaObjectInterface::setTransitionTime(qint32) = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::MediaObjectInterface::play() = 0 + \internal + + Requests the playback to start. + + This method is only called if the state transition to PlayingState is possible. + + The backend should react immediately + by either going into PlayingState or BufferingState if the + former is not possible. +*/ + +/*! + \fn virtual void Phonon::MediaObjectInterface::pause() = 0 + \internal + + Requests the playback to pause. + + This method is only called if the state transition to PausedState is possible. + + The backend should react as fast as possible. Go to PausedState + as soon as playback is paused. +*/ + +/*! + \fn virtual void Phonon::MediaObjectInterface::stop() = 0 + \internal + + Requests the playback to be stopped. + + This method is only called if the state transition to StoppedState is possible. + + The backend should react as fast as possible. Go to StoppedState + as soon as playback is stopped. + + A subsequent call to play() will start playback at the beginning of + the media. +*/ + +/*! + \fn virtual void Phonon::MediaObjectInterface::seek(qint64 milliseconds) = 0 + \internal + + Requests the playback to be seeked to the given time. + + The backend does not have to finish seeking while in this function + (i.e. the backend does not need to block the thread until the seek is + finished; even worse it might lead to deadlocks when using a + ByteStream which gets its data from the thread this function would + block). + + As soon as the seek is done the currentTime() function and + the tick() signal will report it. + + \param milliseconds The time where playback should seek to in + milliseconds. +*/ + +/*! + \fn virtual qint32 Phonon::MediaObjectInterface::tickInterval() const = 0 + \internal + + Return the time interval in milliseconds between two ticks. + + Returns the tick interval that it was set to (might not + be the same as you asked for). +*/ + +/*! + \fn virtual void Phonon::MediaObjectInterface::setTickInterval(qint32 interval) = 0 + \internal + + Change the interval the tick signal is emitted. Set \a interval to 0 to + disable the signal. + + \a interval tick interval in milliseconds + + Returns the tick interval that it was set to (might not be the same as you + asked for). + +*/ + +/*! + \fn virtual bool Phonon::MediaObjectInterface::hasVideo() const = 0 + \internal + + Check whether the media data includes a video stream. + + Returns true if the media contains video data. +*/ + +/*! + \fn virtual bool Phonon::MediaObjectInterface::isSeekable() const = 0 + \internal + + If the current media may be seeked this function returns true; + otherwise, false. + + Returns whether the current media may be seeked. +*/ + +/*! + \fn virtual qint64 Phonon::MediaObjectInterface::currentTime() const = 0 + \internal + + Get the current time (in milliseconds) of the file currently being played. +*/ + +/*! + \fn virtual Phonon::State Phonon::MediaObjectInterface::state() const = 0 + \internal + + Get the current state. +*/ + +/*! + \fn virtual QString Phonon::MediaObjectInterface::errorString() const = 0 + \internal + + A translated string describing the error. +*/ + +/*! + \fn virtual Phonon::ErrorType Phonon::MediaObjectInterface::errorType() const = 0 + \internal + + Tells your program what to do about the error. + + \sa Phonon::ErrorType +*/ + +/*! + \fn virtual qint64 Phonon::MediaObjectInterface::totalTime() const = 0 + \internal + + Returns the total time of the media in milliseconds. + + If the total time is not know return -1. Do not block until it is + known, instead emit the totalTimeChanged signal as soon as the total + time is known or changes. +*/ + +/*! + \fn virtual MediaSource Phonon::MediaObjectInterface::source() const = 0 + \internal + + Returns the current source. +*/ + +/*! + \fn virtual void Phonon::MediaObjectInterface::setSource(const MediaSource &) = 0 + \internal + + Sets the current source. When this function is called the MediaObject is + expected to stop all current activity and start loading the new + source (i.e. go into LoadingState). + + It is expected that the + backend now starts preloading the media data, filling the audio + and video buffers and making all media meta data available. It + will also trigger the totalTimeChanged signal. + + If the backend does not know how to handle the source it needs to + change state to Phonon::ErrorState. Don't bother about handling KIO + URLs. It is enough to handle AbstractMediaStream sources correctly. + + \warning Keep the MediaSource object around as long as the backend + uses the AbstractMediaStream returned by the MediaSource. In case + that no other reference to the MediaSource exists and it is set to + MediaSource::autoDelete, the AbstractMediaStream is deleted when the + last MediaSource ref is deleted. +*/ + +/*! + \fn virtual void Phonon::MediaObjectInterface::setNextSource(const MediaSource &source) = 0 + \internal + + Sets the next source to be used for transitions. When a next source + is set playback should continue with the new source. In that case + finished and prefinishMarkReached are not emitted. + + \param source The source to transition to (crossfade/gapless/gap). If + \a source is an invalid MediaSource object then the queue is empty + and the playback should stop normally. + + \warning Keep the MediaSource object around as long as the backend + uses the AbstractMediaStream returned by the MediaSource. In case + that no other reference to the MediaSource exists and it is set to + MediaSource::autoDelete, the AbstractMediaStream is deleted when the + last MediaSource ref is deleted. +*/ + +/*! + \class Phonon::EffectWidget effectwidget.h Phonon/EffectWidget + \inmodule Phonon + \inheaderfile Phonon/EffectWidget + \since 4.4 + \brief The EffectWidget class provides a widget to control the parameters of an Effect. + + The EffectWidget class provides a widget, with which an effects + parameters can be controlled. The widget does not have an API, + and is constructed with the \l{Phonon::}{Effect}, of which + parameters should be controlled. + + \snippet doc/src/snippets/audioeffects.cpp 1 + + The following image shows an example of an effect widget. + + \image effectwidget.png + + Note that some audio effects do not have parameters, and the + widget will then not \l{QWidget::}{show()} at all. + + \sa Effect, BackendCapabilities, EffectDescription, {Phonon Module} +*/ + +/*! + \class Phonon::AbstractAudioOutput + \inmodule Phonon + \internal + \brief Provides a common base class for all audio outputs. + + \sa AudioOutput +*/ + +/*! + \fn Phonon::AbstractAudioOutput::~AbstractAudioOutput() + \internal +*/ + +/*! + \class Phonon::AbstractAudioOutputPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class AudioOutputAdaptor + \inmodule Phonon + \brief Provides an adaptor class for interface org.kde.Phonon.AudioOutput + \internal +*/ + +/*! + \class Phonon::VolumeSlider + \inmodule Phonon + \inheaderfile Phonon/VolumeSlider + \since 4.4 + \brief The VolumeSlider widget provides a slider that is used to control the volume of an audio output device. + + The slider also displays an icon indicating if the volume of the + \l{Phonon::}{AudioOutput} it is connected to is muted. The icon + can be removed with setMuteVisible(). + + It is possible to set the \l{maximumVolume}{maximum} value of the + slider. By default, the minimum and maximum values of the slider + are 0.0 (no sound) to 1.0 (the maximum volume the audio output can + produce). + + Here follows a code example: + + \snippet doc/src/snippets/volumeslider.cpp 0 + + \omit mention how to change the style of the slider. \endomit + + \sa {Phonon Module} +*/ + +/*! + \property Phonon::VolumeSlider::maximumVolume + + This property holds the maximum volume that can be set with this slider. + + By default the maximum value is 1.0 (100%). +*/ + +/*! + \property Phonon::VolumeSlider::orientation + This property holds the orientation of the slider. + + The orientation must be Qt::Vertical (the default) or Qt::Horizontal. +*/ + +/*! + \property Phonon::VolumeSlider::tracking + This property holds whether slider tracking is enabled. + + If tracking is enabled (the default), the volume changes + while the slider is being dragged. If tracking is + disabled, the volume changes only when the user + releases the slider. +*/ + +/*! + \property Phonon::VolumeSlider::pageStep + This property holds the page step. + + The larger of two natural steps that a slider provides and + typically corresponds to the user pressing PageUp or PageDown. + + Defaults to 5 (5% of the voltage). +*/ + +/*! + \property Phonon::VolumeSlider::singleStep + This property holds the single step. + + The smaller of two natural steps that a slider provides and + typically corresponds to the user pressing an arrow key. + + Defaults to 1 (1% of the voltage). +*/ + +/*! + \property Phonon::VolumeSlider::muteVisible + This property holds whether the mute button/icon next to the slider is visible. + + By default the mute button/icon is visible. +*/ + +/*! + \property Phonon::VolumeSlider::iconSize + \brief the icon size used for the mute button/icon. + + The default size is defined by the GUI style. +*/ + +/*! + \fn explicit Phonon::VolumeSlider::VolumeSlider(QWidget *parent = 0) + Constructs a new volume slider with the given \a parent. +*/ + +/*! + \fn explicit Phonon::VolumeSlider::VolumeSlider(AudioOutput *output, QWidget *parent = 0) + Constructs a new volume slider with the given \a output object and \a parent. +*/ + +/*! + \fn Phonon::VolumeSlider::~VolumeSlider() +*/ + +/*! + \fn AudioOutput *Phonon::VolumeSlider::audioOutput() const +*/ + +/*! + \fn void Phonon::VolumeSlider::setAudioOutput(Phonon::AudioOutput *output) + + Sets the audio output object to be controlled by this slider to the specified + \a output object. +*/ + +/*! + \class Phonon::VolumeSliderPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::MediaController + \inmodule Phonon + \inheaderfile Phonon/MediaController + \since 4.4 + \brief The MediaController class controls optional features of a media file/device. + + Some media sources have content that the \l{Phonon::}{MediaObject} + does not provide control over, for instance, chapters in a DVD + file. The functionality the media controller offers is + dependent on the type of media source that is played back. + Commonly, the media controller allows you to: + + \list + \o Navigate between \bold chapters. + \o Navigate between \bold titles. + \o Select between \bold angles. + \endlist + + The \l{Phonon::MediaController::}{Feature} enum explains these + terms in more detail, and their context in playback of CD and DVD. + + The media controller keeps a \l{Phonon::}{MediaObject}, of which + \l{Phonon::MediaObject::currentSource()}{media source} is played + back. You can still call the media object's functions, e.g., + \l{Phonon::MediaObject::}{stop()}; this is all handled correctly + by the media controller. You have the option of letting the media + controller play all titles of a source in sequence by setting the + \l{autoplayTitles()}{autoplay titles} option. + + To start a playback using a media object, you call + \l{Phonon::MediaObject::}{play()} on the media object. To play a + specific title, use setCurrentTitle() and then call + \l{Phonon::MediaObject::}{play()}. + + \warning The Phonon::MediaController class is not yet supported by + Qt backends. + + \sa {Phonon Module} +*/ + +/*! + \fn int Phonon::MediaController::availableAudioChannels() const + \internal +*/ + +/*! + \fn void Phonon::MediaController::availableAudioChannelsChanged() + \internal +*/ + +/*! + \fn QList Phonon::MediaController::availableSubtitles() const + \internal +*/ + +/*! + \fn void Phonon::MediaController::availableSubtitlesChanged() + \internal +*/ + +/*! + \fn AudioChannelDescription Phonon::MediaController::currentAudioChannel() const + \internal +*/ + +/*! + \fn SubtitleDescription Phonon::MediaController::currentSubtitle() const + \internal +*/ + +/*! + \fn void Phonon::MediaController::setCurrentAudioChannel(const Phonon::AudioChannelDescription &stream) + \internal +*/ + +/*! + \fn void Phonon::MediaController::setCurrentSubtitle(const Phonon::SubtitleDescription &stream) + \internal +*/ + +/*! + \fn Phonon::BackendCapabilities::availableAudioCaptureDevices() + \internal +*/ + +/*! + \fn Phonon::BackendCapabilities::Notifier::availableAudioCaptureDevicesChanged() + \internal +*/ + +/*! + \enum Phonon::MediaController::Feature + + The values of this enum are interpreted differently depending on + the type of media source, e.g., DVD or CD. We give examples for + these sources. + + \value Angles In the VOB (DVD) format, it is possible to to give + several video streams of the same scene, each of which displays + the scene from a different angle. The DVD viewer can then change + between these angles. + + \value Chapters In the VOB format, chapters are points in a + single video stream that can be played and seeked to + separately. + + \value Titles On a CD, a title is a separate sound track. On DVD, + a title is a separate VOB file. + +*/ + +/*! + \fn Phonon::MediaController::MediaController(MediaObject *parent) + + Constructs a new MediaController with the media object (\a parent) + to be used by the media controller. + + \sa MediaObject, Feature +*/ + +/*! + \fn Phonon::MediaController::~MediaController() +*/ + +/*! + \fn Features Phonon::MediaController::supportedFeatures() const +*/ + +/*! + \fn int Phonon::MediaController::availableAngles() const + + Returns the available angles that is available for the current + media source. + + \sa Feature +*/ + +/*! + \fn int Phonon::MediaController::currentAngle() const + + Returns the angle that is currently used. + + \sa Feature +*/ + +/*! + \fn int Phonon::MediaController::availableChapters() const + + Returns the number of chapters the current media source + contains. + + \sa Feature +*/ + +/*! + \fn int Phonon::MediaController::currentChapter() const + + Returns the chapter that is currently being played back. + + \sa Feature +*/ + +/*! + \fn int Phonon::MediaController::availableTitles() const + + Returns the number of titles that the current media source + contains. + + \sa Feature +*/ + +/*! + \fn int Phonon::MediaController::currentTitle() const + + Returns the title that is currently played back. + + The current title is 0 (the first) by default. + + \sa Feature +*/ + +/*! + \fn bool Phonon::MediaController::autoplayTitles() const + + Returns true if titles will automatically be played when the media + is played; otherwise returns false. + + The media controller will play the titles of the media source in + sequence when the media object's \l{Phonon::MediaObject::}{play()} + function is called. If the autoplay option is disabled, the media + object will play the + \l{Phonon::}{MediaController::currentTitle()}{current title} and then + finish the playback. + + \sa setAutoplayTitles(), currentTitle() +*/ + +/*! + \fn void Phonon::MediaController::setAutoplayTitles(bool enable) + + Sets the titles to play automatically when the media is played if + \a enable is true; otherwise disables this option. + + The media controller will play the titles of the media source in + sequence when the media object's \l{Phonon::MediaObject::}{play()} + function is called. If the autoplay option is disabled, the media + object will play the + \l{Phonon::}{MediaController::currentTitle()}{current title} and then + finish the playback. + + \sa autoplayTitles(), currentTitle() +*/ + +/*! + \fn void Phonon::MediaController::setCurrentAngle(int angleNumber) + + Sets the current angle to the given \a angleNumber if the media + file or device supports navigation by angle number. + + \sa Feature +*/ + +/*! + \fn void Phonon::MediaController::setCurrentChapter(int chapterNumber) + + Sets the current chapter to the given \a chapterNumber if the media + file or device supports navigation by chapter number. + + \sa Feature +*/ + +/*! + \fn void Phonon::MediaController::setCurrentTitle(int titleNumber) + + Skips to the given title \a titleNumber. + + If it was playing before the title change it will start playback on the new title if + autoplayTitles is enabled. + + \sa Feature +*/ + +/*! + \fn void Phonon::MediaController::nextTitle() + + Skips to the next title. + + If it was playing before the title change it will start playback on the next title if + autoplayTitles is enabled. + + \sa Feature +*/ + +/*! + \fn void Phonon::MediaController::previousTitle() + + Skips to the previous title. + + If it was playing before the title change it will start playback on the previous title if + autoplayTitles is enabled. + + \sa Feature +*/ + +/*! + \fn void Phonon::MediaController::availableAnglesChanged(int availableAngles) + + This signal is emitted whenever the number of available angles changes. + The new number of available angles is given by \a availableAngles. + + \sa Feature +*/ + +/*! + \fn void Phonon::MediaController::angleChanged(int angleNumber) + + This signal is emitted whenever the current angle changes. + The new angle number is given by \a angleNumber. + + \sa Feature +*/ + +/*! + \fn void Phonon::MediaController::availableChaptersChanged(int availableChapters) + + This signal is emitted whenever the number of available chapters changes. + The new number of available chapters is given by \a availableChapters. + + \sa Feature +*/ + +/*! + \fn void Phonon::MediaController::chapterChanged(int chapterNumber) + + This signal is emitted whenever the current chapter changes. + The new chapter number is given by \a chapterNumber. + + \sa Feature +*/ + +/*! + \fn void Phonon::MediaController::availableTitlesChanged(int availableTitles) + + This signal is emitted whenever the number of available titles changes. + The new number of available titles is given by \a availableTitles. + + \sa Feature +*/ + +/*! + \fn void Phonon::MediaController::titleChanged(int titleNumber) + + This signal is emitted whenever the current title changes. + The new title number is given by \a titleNumber. + + \sa Feature +*/ + +/*! + \class Phonon::VideoWidget + \inmodule Phonon + \inheaderfile Phonon/VideoWidget + \since 4.4 + \ingroup advanced + \ingroup multimedia + \brief The VideoWidget class provides a widget that is used to display video. + + The VideoWidget class renders the video of a media stream on a + QWidget. It is connected to the \l{Phonon::}{MediaObject}, of + which video stream it should render. You connect the two objects + using the Phonon::createPath() function. + + The widget has some possibilities to manipulate the video + stream. You can change the brightness(), hue(), saturation(), + and contrast(). + + Resizing of the video is handled automatically, but you can affect + the way the video is resized with the aspectRatio and scaleMode + properties. By default, the widget will use the aspect ratio of + the video stream itself. + + The video widget takes the size of the video when it receives a new video + stream (i.e., when a new MediaSource is set on the MediaObject to which it is + connected). If you need to know the size of the video, you can call + \l{QWidget::}{sizeHint()} after the video has been loaded (i.e., after the + MediaObject leaves the \l{Phonon::}{LoadingState}). + + It is also possible to go to \l{fullScreen}{full screen} mode. + + A typical example of usage follows below: + + \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 21 + + \sa {Phonon Module} +*/ + +/*! + \fn Phonon::VideoWidget::VideoWidget(QWidget *parent = 0) + + Constructs a new video widget with the specified \a parent. +*/ + +/*! + \fn Phonon::VideoWidget::VideoWidget(VideoWidgetPrivate &d, QWidget *parent) + \internal + + Constructs a new video widget with the specified \a parent. +*/ + +/*! + \fn bool Phonon::VideoWidget::event(QEvent *) + \reimp +*/ + +/*! + \fn void Phonon::VideoWidget::mouseMoveEvent(QMouseEvent *) + \reimp +*/ + +/*! + \enum Phonon::VideoWidget::ScaleMode + + The ScaleMode enum describes how to treat aspect ratio during + resizing of video. + + \value FitInView The video will be fitted to fill the view + keeping aspect ratio. + \value ScaleAndCrop The video is scaled +*/ + +/*! + \property Phonon::VideoWidget::fullScreen + This property holds whether the video is shown using the complete + screen. + + The property differs from QWidget::fullScreen in that it is + writeable. + + By default the widget is not shown in fullScreen. + + \warning When switching to full screen mode using setFullScreen(), + the widget onto which the video is rendered is shown as a + top-level window. Key event forwarding is handled by VideoWidget, + but if you need to handle other events, e.g., mouse events, you + should handle fullscreen mode yourself. +*/ + +/*! + \property Phonon::VideoWidget::aspectRatio + Defaults to AspectRatioAuto. + + \sa AspectRatio +*/ + +/*! + \property Phonon::VideoWidget::scaleMode + + If the size of the widget and the size of the video are not equal. + The video will be zoomed to fit the widget. The smaller zoom + (AddBarsScaleMode) adds black bars at the left/right or top/bottom to + make all of the image visible (default). The bigger zoom (ExpandMode) + fills the widget completely, keeping all information in one direction + and leaving parts of the image outside of the widget in the other + direction. +*/ + +/*! + \property Phonon::VideoWidget::brightness + + This property holds brightness of the video. + + Default is 0. Acceptable values are in range of -1, 1. +*/ + +/*! + \property Phonon::VideoWidget::contrast + + This property holds the contrast of the video. + + Default is 0. Acceptable values are in range of -1, 1. +*/ + +/*! + \property Phonon::VideoWidget::hue + + This property holds the hue of the video. + + Default is 0. Acceptable values are in range of -1, 1. +*/ + +/*! + \property Phonon::VideoWidget::saturation + + This property holds saturation of the video. + + Default is 0. Acceptable values are in range of -1, 1. +*/ + +/*! + \enum Phonon::VideoWidget::AspectRatio + + Defines the width:height to be used for the video. + + \value AspectRatioAuto + Let the decoder find the aspect ratio automatically from the + media file (this is the default). + + \value AspectRatioWidget + Fits the video into the widget making the aspect ratio depend + solely on the size of the widget. This way the aspect ratio + is freely resizeable by the user. + + \value AspectRatio4_3 + Make width/height == 4/3, which is the old TV size and + monitor size (1024/768 == 4/3). (4:3) + + \value AspectRatio16_9 + Make width/height == 16/9, which is the size of most current + media. (16:9) +*/ + +/*! + \fn void Phonon::VideoWidget::exitFullScreen() + + Convenience slot, calling setFullScreen(false) +*/ + + +/*! + \fn void Phonon::VideoWidget::enterFullScreen() + + Convenience slot, calling setFullScreen(true) +*/ + +/*! + \class Phonon::VideoWidgetInterface + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \fn virtual Phonon::VideoWidgetInterface::~VideoWidgetInterface() +*/ + +/*! + \fn virtual Phonon::VideoWidget::AspectRatio Phonon::VideoWidgetInterface::aspectRatio() const = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::VideoWidgetInterface::setAspectRatio(Phonon::VideoWidget::AspectRatio ratio) = 0 + \internal +*/ + +/*! + \fn virtual qreal Phonon::VideoWidgetInterface::brightness() const = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::VideoWidgetInterface::setBrightness(qreal) = 0 + \internal +*/ + +/*! + \fn virtual Phonon::VideoWidget::ScaleMode Phonon::VideoWidgetInterface::scaleMode() const = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::VideoWidgetInterface::setScaleMode(Phonon::VideoWidget::ScaleMode mode) = 0 + \internal +*/ + +/*! + \fn virtual qreal Phonon::VideoWidgetInterface::contrast() const = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::VideoWidgetInterface::setContrast(qreal) = 0 + \internal +*/ + +/*! + \fn virtual qreal Phonon::VideoWidgetInterface::hue() const = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::VideoWidgetInterface::setHue(qreal) = 0 + \internal +*/ + +/*! + \fn virtual qreal Phonon::VideoWidgetInterface::saturation() const = 0 + \internal +*/ + +/*! + \fn virtual void Phonon::VideoWidgetInterface::setSaturation(qreal) = 0 + \internal +*/ + +/*! + \fn virtual QWidget *Phonon::VideoWidgetInterface::widget() = 0 + \internal +*/ + +/*! + \class Phonon::PlatformPlugin + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \fn virtual AbstractMediaStream *Phonon::PlatformPlugin::createMediaStream(const QUrl &url, QObject *parent) = 0 + + Creates a AbstractMediaStream object with the given \a parent that provides the data + for the given URL specified by \a url. + \omit + On KDE this uses KIO. + \endomit +*/ + +/*! + \fn virtual QIcon Phonon::PlatformPlugin::icon(const QString &name) const = 0 + + Returns the icon for the given icon name. +*/ + +/*! + \fn virtual void Phonon::PlatformPlugin::notification(const char *notificationName, const QString &text, + const QStringList &actions, QObject *receiver, const char *actionSlot) const = 0 + + Shows a notification pop-up with the given \a notificationName and \a text. + Each action in the associated list of \a actions is connected to the \a actionSlot + of the specified \a receiver object, which is expected to act on the actions as + they are triggered by the user. +*/ + +/*! + \fn virtual QString Phonon::PlatformPlugin::applicationName() const = 0 + + Returns the name of the application. For most Qt application this is + QCoreApplication::applicationName(), but for KDE this is overridden by KAboutData. +*/ + + +/*! + \fn virtual QObject *Phonon::PlatformPlugin::createBackend() = 0 + + Creates a backend object. This way the platform can decide the backend preference. +*/ + +/*! + \fn virtual QObject *Phonon::PlatformPlugin::createBackend(const QString &library, const QString &version) = 0 + + Using the library loader of the platform, loads a given backend provided the + specified \a library and \a version. +*/ + +/*! + \fn virtual bool Phonon::PlatformPlugin::isMimeTypeAvailable(const QString &mimeType) const = 0 + + Tries to check whether the default backend supports the MIME type specified by \a mimeType + without loading the actual backend library. + \omit + On KDE this reads the MIME type list from the .desktop file of + the backend. + \endomit +*/ + +/*! + \fn virtual void Phonon::PlatformPlugin::saveVolume(const QString &outputName, qreal volume) = 0 + + Saves the volume for the given output. +*/ + +/*! + \fn virtual qreal Phonon::PlatformPlugin::loadVolume(const QString &outputName) const = 0 + + Loads the volume for the given output. +*/ + +/*! + \class Phonon::MediaNode + \inmodule Phonon + \inheaderfile Phonon/MediaNode + \since 4.4 + \brief The MediaNode class is the base class for all nodes in a media graph. + + In all phonon applications, one builds a media graph consisting of + MediaNodes. The graph will take multimedia content, e.g., from a + file, as input. After its nodes have processed the multimedia, the + graph will output the media again, e.g., to a sound card. + + The multimedia content is streamed over \l{Phonon::}{Path}s + between the nodes in the graph. You can query the paths that are + connected to a media node with inputPaths() and outputPaths(). + + You can check whether the node is implemented by the current + backend by calling isValid(). This does not guarantee that an + instance of the class works as expected, but that the backend has + implemented functionality for the class. + + Currently, Phonon has four media nodes: \l{Phonon::}{MediaObject}, + \l{Phonon::}{AudioOutput}, \l{Phonon::}{VideoWidget}, and \l{Phonon::}{Effect}. + Please refer to their class descriptions for details about their usage, and to + find out which nodes can be connected to each other. See also \l{Building + Graphs} in Phonon's \l{Phonon Overview}{overview} document. + + Two nodes are connected to each other using the + Phonon::createPath() or \l{Phonon::}{Path::insertEffect()} + functions (only \l{Phonon::Effect}s use + \l{Phonon::Path::}{insertEffect()}). We show a code example below, + in which we build a media graph for video playback and then query + its media nodes for their \l{Phonon::}{Path}s: + + \snippet doc/src/snippets/medianodesnippet.cpp 0 + + When you create a Phonon application, you will likely build the + graph yourself. This makes isValid() the most useful function of + this class. The other two functions help navigate the graph, which + you do not need to do as you created the nodes yourself. + + \sa {Phonon Overview}, Phonon::MediaObject, + Phonon::AudioOutput, Phonon::VideoWidget, {Phonon Module} +*/ + +/*! + \fn virtual Phonon::MediaNode::~MediaNode() + + Destroys the media node and any paths connecting it to other + nodes. Any \l{Phonon::}{Effect}s connected to these paths will + also be deleted. +*/ + +/*! + \fn bool Phonon::MediaNode::isValid() const + + Returns true if the backend provides an implementation of this + class; otherwise returns false. + + This does not guarantee that instances of the class works as + expected, but that the backend has implemented the functionality + for this class. For instance, Qt's GStreamer backend will return + true for instances of the \l{Phonon::}{AudioOutput} class, even if + there is a problem with GStreamer and it could not play sound. + +*/ + +/*! + \fn QList Phonon::MediaNode::inputPaths() const + + Returns the paths that inputs multimedia to this media node. + + \sa outputPaths() +*/ + +/*! + \fn QList Phonon::MediaNode::outputPaths() const + + Returns the paths to which this media node outputs media. + + \sa inputPaths() +*/ + +/*! + \fn Phonon::MediaNode::MediaNode(MediaNodePrivate &dd) + \internal +*/ + +/*! + \class Phonon::GlobalConfig + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \fn Phonon::GlobalConfig::GlobalConfig() + \internal +*/ + +/*! + \fn Phonon::GlobalConfig::~GlobalConfig() + \internal +*/ + +/*! + \fn QList Phonon::GlobalConfig::audioOutputDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const + \internal +*/ + +/*! + \fn int Phonon::GlobalConfig::audioOutputDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const + \internal +*/ + +/*! + \class Phonon::ObjectDescriptionData + \inmodule Phonon + \since 4.4 + \internal + \brief Data class for objects describing devices or features of the backend. + + \sa Phonon::BackendCapabilities +*/ + +/*! + \fn bool Phonon::ObjectDescriptionData::operator==(const ObjectDescriptionData &otherDescription) const + + Returns \c true if this ObjectDescription describes the same + as \a otherDescription; otherwise returns \c false. +*/ + +/*! + \fn QString Phonon::ObjectDescriptionData::name() const + + Returns the name of the capture source. + + \return A string that should be presented to the user to + choose the capture source. +*/ + +/*! + \fn QString Phonon::ObjectDescriptionData::description() const + + Returns a description of the capture source. This text should + make clear what sound source this is, which is sometimes hard + to describe or understand from just the name. + + \return A string describing the capture source. +*/ + +/*! + \fn QVariant Phonon::ObjectDescriptionData::property(const char *name) const + + Returns a named property. + + If the property is not set an invalid value is returned. + + \sa propertyNames() +*/ + +/*! + \fn QList Phonon::ObjectDescriptionData::propertyNames() const + + Returns all names that return valid data when property() is called. + + \sa property() +*/ + +/*! + \fn bool Phonon::ObjectDescriptionData::isValid() const + + Returns true if the Tuple is valid (index != -1); otherwise returns + false. +*/ + +/*! + \fn int Phonon::ObjectDescriptionData::index() const + + A unique identifier for this device/. Used internally + to distinguish between the devices/. + + \return An integer that uniquely identifies every device. +*/ + +/*! + \fn static ObjectDescriptionData *Phonon::ObjectDescriptionData::fromIndex(ObjectDescriptionType type, int index) + \internal +*/ + +/*! + \fn Phonon::ObjectDescriptionData::~ObjectDescriptionData() + \internal +*/ + +/*! + \fn Phonon::ObjectDescriptionData::ObjectDescriptionData(ObjectDescriptionPrivate * = 0) + \internal +*/ + +/*! + \class Phonon::AddonInterface + \inmodule Phonon + \since 4.4 + \internal + \brief Interface for Menu, Chapter, Angle and Title/Track control. +*/ + +/*! + \fn virtual Phonon::AddonInterface::~AddonInterface() + \internal +*/ + +/*! + \enum Phonon::AddonInterface::Interface + + This enum describes the type of interface represented by an AddonInterface object. + + \value NavigationInterface + \value ChapterInterface + \value AngleInterface + \value TitleInterface +*/ + +/*! + \enum Phonon::AddonInterface::NavigationCommand + \internal + \value Menu1Button +*/ + +/*! + \enum Phonon::AddonInterface::ChapterCommand + \internal + \value availableChapters + \value chapter + \value setChapter +*/ + +/*! + \enum Phonon::AddonInterface::AngleCommand + \internal + \value availableAngles + \value angle + \value setAngle +*/ + +/*! + \enum Phonon::AddonInterface::TitleCommand + \internal + \value availableTitles + \value title + \value setTitle + \value autoplayTitles + \value setAutoplayTitles +*/ + +/*! + \fn virtual bool Phonon::AddonInterface::hasInterface(Interface iface) const = 0 + \internal +*/ + +/*! + \fn virtual QVariant Phonon::AddonInterface::interfaceCall(Interface iface, int command, + const QList &arguments) = 0 + \internal +*/ + +/*! + \class Phonon::MediaNodePrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \namespace Phonon::Factory + \inmodule Phonon + \internal +*/ + +/*! + \fn Sender *Phonon::Factory::sender() + + Returns a pointer to the object emitting the signals. + + \sa Sender::backendChanged() +*/ + +/*! + \fn QObject *Phonon::Factory::createMediaObject(QObject *parent = 0) + + Create a new backend object for a MediaObject. + + \return a pointer to the MediaObject the backend provides. +*/ + +/*! + \fn QObject *Phonon::Factory::createEffect(int effectId, QObject *parent = 0) + + Create a new backend object for a Effect. + + \return a pointer to the Effect the backend provides. +*/ + +/*! + \fn QObject *Phonon::Factory::createVolumeFaderEffect(QObject *parent = 0) + + Create a new backend object for a VolumeFaderEffect. + + \return a pointer to the VolumeFaderEffect the backend provides. +*/ + +/*! + \fn QObject *Phonon::Factory::createAudioOutput(QObject *parent = 0) + + Create a new backend object for a AudioOutput. + + \return a pointer to the AudioOutput the backend provides. +*/ + +/*! + \fn QObject *Phonon::Factory::createVideoWidget(QObject *parent = 0) + + Create a new backend object for a VideoWidget. + + \return a pointer to the VideoWidget the backend provides. +*/ + +/*! + \fn QObject *Phonon::Factory::backend(bool createWhenNull = true) + + \return a pointer to the backend interface. +*/ + +/*! + \fn QString Phonon::Factory::identifier() + + Unique identifier for the Backend. Can be used in configuration files + for example. +*/ + + +/*! + \fn QString Phonon::Factory::backendName() + + Get the name of the Backend. + \omit + It's the name from the .desktop file. + \endomit +*/ + +/*! + \fn QString Phonon::Factory::backendComment() + + Get the comment of the Backend. + \omit + It's the comment from the .desktop file. + \endomit +*/ + +/*! + \fn QString Phonon::Factory::backendVersion() + + Get the version of the Backend. + \omit + It's the version from the .desktop file. + \endomit + + The version is especially interesting if there are several versions + available for binary incompatible versions of the backend's media + framework. +*/ + +/*! + \fn QString Phonon::Factory::backendIcon() + + Get the icon (name) of the Backend. + \omit + It's the icon from the .desktop file. + \endomit +*/ + +/*! + \fn QString Phonon::Factory::backendWebsite() + + Get the website of the Backend. + \omit + It's the website from the .desktop file. + \endomit +*/ + +/*! + \fn QObject *Phonon::Factory::registerQObject(QObject *object) + + Registers the given backend \a object with the factory. +*/ + +/*! + \fn bool Phonon::Factory::isMimeTypeAvailable(const QString &mimeType) +*/ + +/*! + \fn void Phonon::Factory::registerFrontendObject(MediaNodePrivate *) + \internal +*/ + +/*! + \fn void Phonon::Factory::deregisterFrontendObject(MediaNodePrivate *) + \internal +*/ + +/*! + \fn void Phonon::Factory::setBackend(QObject *) +*/ + +/*! + \fn PlatformPlugin *Phonon::Factory::platformPlugin() +*/ + +/*! +/*! + \class Phonon::AbstractMediaStreamPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::FrontendInterfacePrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::EffectWidgetPrivate + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::IODeviceStream + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \fn explicit Phonon::IODeviceStream::IODeviceStream(QIODevice *ioDevice, QObject *parent = 0) + \internal + + Creates a new IODeviceStream with the given \a ioDevice and \a + parent. + +*/ + +/*! + \fn Phonon::IODeviceStream::~IODeviceStream() + \internal +*/ + +/*! + \fn void Phonon::IODeviceStream::reset() + \internal +*/ + +/*! + \fn void Phonon::IODeviceStream::needData() + \internal +*/ + +/*! + \fn void Phonon::IODeviceStream::seekStream(qint64) + \internal +*/ + +/*! + \namespace Phonon::Platform + \inmodule Phonon + \internal +*/ + +/*! + \typedef Phonon::EffectDescriptionModel + \inmodule Phonon + \brief provides a item view model containing available audio effects. + +*/ + +/*! + \typedef Phonon::SubtitleDescription + \inmodule Phonon + \internal +*/ + +/*! + \typedef Phonon::SubtitleDescriptionModel + \inmodule Phonon + \internal +*/ + +/*! + \typedef Phonon::AudioChannelDescription + \inmodule Phonon + \internal +*/ + +/*! + \typedef Phonon::AudioChannelDescriptionModel + \inmodule Phonon + \internal +*/ + +/*! + \typedef Phonon::AudioCaptureDevice + \inmodule Phonon + \internal +*/ + +/*! + \typedef Phonon::AudioCaptureDeviceModel + \inmodule Phonon + \internal +*/ + +/*! + \typedef Phonon::CleanUpFunction + \inmodule Phonon + \internal +*/ + +/*! + \typedef Phonon::QObjectPair + \inmodule Phonon + \since 4.4 + \internal + +*/ + +/*! + \typedef Phonon::AudioOutputDeviceModel + \inmodule Phonon + \brief provides an item view model containing available audio output devices. + +*/ + +/*! + \fn uint Phonon::qHash(const Phonon::EffectParameter ¶m) + \internal + +*/ + +/*! + \fn Phonon::CleanUpGlobalStatic::~CleanUpGlobalStatic() + \internal +*/ + +/*! + \class Phonon::ConstIface + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::CleanUpGlobalStatic + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class Phonon::EffectParameterPrivate + \inmodule Phonon + \since 4.4 + \internal + +*/ + +/*! + \class Phonon::QSettingsGroup + \inmodule Phonon + \since 4.4 + \internal + +*/ + +/*! + \class Phonon::MediaNodeDestructionHandler + \inmodule Phonon + \since 4.4 + \internal + +*/ + +/*! + \fn Phonon::MediaNodeDestructionHandler::~MediaNodeDestructionHandler() + \internal + Called from Base::~Base if this object was registered + using BasePrivate::addDestructionHandler(). +*/ + +/*! + \fn Phonon::MediaNodeDestructionHandler::phononObjectDestroyed(MediaNodePrivate *) + \internal +*/ + +/*! + \fn explicit Phonon::EffectWidget::EffectWidget(Effect *effect, QWidget *parent = 0) + \internal + + Constructs a new EffectWidget for the specified \a effect and with + the specified \a parent. +*/ + +/*! + \fn Phonon::EffectWidget::~EffectWidget() + \internal +*/ + +/*! + \fn QDebug Phonon::operator<<(QDebug s, const ObjectDescription &o) + \internal +*/ + +/*! + \class Phonon::ListModelHelper + \inmodule Phonon + \since 4.4 + \internal +*/ + +/*! + \class AudioOutputInterface42 + \inmodule Phonon + \since 4.4 + \internal +*/ + diff --git a/doc/src/classes/q3asciicache.qdoc b/doc/src/classes/q3asciicache.qdoc new file mode 100644 index 0000000..43537cc --- /dev/null +++ b/doc/src/classes/q3asciicache.qdoc @@ -0,0 +1,465 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3AsciiCache + \brief The Q3AsciiCache class is a template class that provides a cache based on char* keys. + \compat + + Q3AsciiCache is implemented as a template class. Define a template + instance Q3AsciiCache\ to create a cache that operates on + pointers to X (X*). + + A cache is a least recently used (LRU) list of cache items. The + cache items are accessed via \c char* keys. For Unicode keys use + the Q3Cache template instead, which uses QString keys. A Q3Cache + has the same performace as a Q3AsciiCache. + + Each cache item has a cost. The sum of item costs, totalCost(), + will not exceed the maximum cache cost, maxCost(). If inserting a + new item would cause the total cost to exceed the maximum cost, + the least recently used items in the cache are removed. + + Apart from insert(), by far the most important function is find() + (which also exists as operator[]()). This function looks up an + item, returns it, and by default marks it as being the most + recently used item. + + There are also methods to remove() or take() an object from the + cache. Calling \link Q3PtrCollection::setAutoDelete() + setAutoDelete(TRUE)\endlink tells the cache to delete items that + are removed. The default is to not delete items when then are + removed (i.e., remove() and take() are equivalent). + + When inserting an item into the cache, only the pointer is copied, + not the item itself. This is called a shallow copy. It is possible + to make the cache copy all of the item's data (known as a deep + copy) when an item is inserted. insert() calls the virtual + function Q3PtrCollection::newItem() for the item to be inserted. + Inherit a cache and reimplement newItem() if you want deep copies. + + When removing a cache item the virtual function + Q3PtrCollection::deleteItem() is called. Its default implementation + in Q3AsciiCache is to delete the item if \link + Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. + + There is a Q3AsciiCacheIterator which may be used to traverse the + items in the cache in arbitrary order. + + \sa Q3AsciiCacheIterator, Q3Cache, Q3IntCache +*/ + +/*! + \fn Q3AsciiCache::Q3AsciiCache( const Q3AsciiCache &c ) + + \internal + + Do not use. A Q3AsciiCache cannot be copied. Calls qFatal() in debug version. +*/ + + +/*! + \fn Q3AsciiCache::Q3AsciiCache( int maxCost, int size, bool caseSensitive, bool copyKeys ) + + Constructs a cache whose contents will never have a total cost + greater than \a maxCost and which is expected to contain less than + \a size items. + + \a size is actually the size of an internal hash array; it's + usually best to make it prime and at least 50% bigger than the + largest expected number of items in the cache. + + Each inserted item has an associated cost. When inserting a new + item, if the total cost of all items in the cache will exceed \a + maxCost, the cache will start throwing out the older (least + recently used) items until there is enough room for the new item + to be inserted. + + If \a caseSensitive is TRUE (the default), the cache keys are case + sensitive; if it is FALSE, they are case-insensitive. + Case-insensitive comparison only affects the 26 letters in + US-ASCII. If \a copyKeys is TRUE (the default), Q3AsciiCache makes + a copy of the cache keys, otherwise it copies just the const char + * pointer - slightly faster if you can guarantee that the keys + will never change, but very risky. +*/ + +/*! + \fn Q3AsciiCache::~Q3AsciiCache() + + Removes all items from the cache and destroys it. + All iterators that access this cache will be reset. +*/ + +/*! + \fn Q3AsciiCache& Q3AsciiCache::operator=( const Q3AsciiCache &c ) + + \internal + + Do not use. A Q3AsciiCache cannot be copied. Calls qFatal() in debug version. +*/ + +/*! + \fn int Q3AsciiCache::maxCost() const + + Returns the maximum allowed total cost of the cache. + + \sa setMaxCost() totalCost() +*/ + +/*! + \fn int Q3AsciiCache::totalCost() const + + Returns the total cost of the items in the cache. This is an + integer in the range 0 to maxCost(). + + \sa setMaxCost() +*/ + +/*! + \fn void Q3AsciiCache::setMaxCost( int m ) + + Sets the maximum allowed total cost of the cache to \a m. If the + current total cost is greater than \a m, some items are removed + immediately. + + \sa maxCost() totalCost() +*/ + +/*! + \fn uint Q3AsciiCache::count() const + + Returns the number of items in the cache. + + \sa totalCost() size() +*/ + +/*! + \fn uint Q3AsciiCache::size() const + + Returns the size of the hash array used to implement the cache. + This should be a bit bigger than count() is likely to be. +*/ + +/*! + \fn bool Q3AsciiCache::isEmpty() const + + Returns TRUE if the cache is empty; otherwise returns FALSE. +*/ + +/*! + \fn bool Q3AsciiCache::insert( const char *k, const type *d, int c, int p ) + + Inserts the item \a d into the cache using key \a k, and with an + associated cost of \a c. Returns TRUE if the item is successfully + inserted. Returns FALSE if the item is not inserted, for example, + if the cost of the item exceeds maxCost(). + + The cache's size is limited, and if the total cost is too high, + Q3AsciiCache will remove old, least recently used items until there + is room for this new item. + + Items with duplicate keys can be inserted. + + The parameter \a p is internal and should be left at the default + value (0). + + \warning If this function returns FALSE, you must delete \a d + yourself. Additionally, be very careful about using \a d after + calling this function, because any other insertions into the + cache, from anywhere in the application or within Qt itself, could + cause the object to be discarded from the cache and the pointer to + become invalid. +*/ + +/*! + \fn bool Q3AsciiCache::remove( const char *k ) + + Removes the item with key \a k and returns TRUE if the item was + present in the cache; otherwise returns FALSE. + + The item is deleted if auto-deletion has been enabled, i.e., if + you have called \link Q3PtrCollection::setAutoDelete() + setAutoDelete(TRUE)\endlink. + + If there are two or more items with equal keys, the one that was + inserted last is removed. + + All iterators that refer to the removed item are set to point to + the next item in the cache's traversal order. + + \sa take(), clear() +*/ + +/*! + \fn type *Q3AsciiCache::take( const char *k ) + + Takes the item associated with \a k out of the cache without + deleting it and returns a pointer to the item taken out, or 0 + if the key does not exist in the cache. + + If there are two or more items with equal keys, the one that was + inserted last is taken. + + All iterators that refer to the taken item are set to point to the + next item in the cache's traversal order. + + \sa remove(), clear() +*/ + +/*! + \fn void Q3AsciiCache::clear() + + Removes all items from the cache, and deletes them if \link + Q3PtrCollection::setAutoDelete() auto-deletion\endlink has been + enabled. + + All cache iterators that operate on this cache are reset. + + \sa remove() take() +*/ + +/*! + \fn type *Q3AsciiCache::find( const char *k, bool ref ) const + + Returns the item with key \a k, or 0 if the key does not exist + in the cache. If \a ref is TRUE (the default), the item is moved + to the front of the least recently used list. + + If there are two or more items with equal keys, the one that was + inserted last is returned. +*/ + +/*! + \fn type *Q3AsciiCache::operator[]( const char *k ) const + + Returns the item with key \a k, or 0 if \a k does not exist in + the cache, and moves the item to the front of the least recently + used list. + + If there are two or more items with equal keys, the one that was + inserted last is returned. + + This is the same as find( k, TRUE ). + + \sa find() +*/ + +/*! + \fn void Q3AsciiCache::statistics() const + + A debug-only utility function. Prints out cache usage, hit/miss, + and distribution information using qDebug(). This function does + nothing in the release library. +*/ + +/*! + \class Q3AsciiCacheIterator + \brief The Q3AsciiCacheIterator class provides an iterator for Q3AsciiCache collections. + \compat + + Note that the traversal order is arbitrary; you are not guaranteed + any particular order. If new objects are inserted into the cache + while the iterator is active, the iterator may or may not see + them. + + Multiple iterators are completely independent, even when they + operate on the same Q3AsciiCache. Q3AsciiCache updates all iterators + that refer an item when that item is removed. + + Q3AsciiCacheIterator provides an operator++() and an operator+=() + to traverse the cache; current() and currentKey() to access the + current cache item and its key. It also provides atFirst() and + atLast(), which return TRUE if the iterator points to the first or + last item in the cache respectively. The isEmpty() function + returns TRUE if the cache is empty; and count() returns the number + of items in the cache. + + Note that atFirst() and atLast() refer to the iterator's arbitrary + ordering, not to the cache's internal least recently used list. + + \sa Q3AsciiCache +*/ + +/*! + \fn Q3AsciiCacheIterator::Q3AsciiCacheIterator( const Q3AsciiCache &cache ) + + Constructs an iterator for \a cache. The current iterator item is + set to point to the first item in the \a cache. +*/ + +/*! + \fn Q3AsciiCacheIterator::Q3AsciiCacheIterator (const Q3AsciiCacheIterator & ci) + + Constructs an iterator for the same cache as \a ci. The new + iterator starts at the same item as ci.current() but moves + independently from there on. +*/ + +/*! + \fn Q3AsciiCacheIterator& Q3AsciiCacheIterator::operator=( const Q3AsciiCacheIterator &ci ) + + Makes this an iterator for the same cache as \a ci. The new + iterator starts at the same item as ci.current(), but moves + independently thereafter. +*/ + +/*! + \fn uint Q3AsciiCacheIterator::count() const + + Returns the number of items in the cache over which this iterator + operates. + + \sa isEmpty() +*/ + +/*! + \fn bool Q3AsciiCacheIterator::isEmpty() const + + Returns TRUE if the cache is empty, i.e. count() == 0; otherwise + returns FALSE. + + \sa count() +*/ + +/*! + \fn bool Q3AsciiCacheIterator::atFirst() const + + Returns TRUE if the iterator points to the first item in the + cache; otherwise returns FALSE. Note that this refers to the + iterator's arbitrary ordering, not to the cache's internal least + recently used list. + + \sa toFirst(), atLast() +*/ + +/*! + \fn bool Q3AsciiCacheIterator::atLast() const + + Returns TRUE if the iterator points to the last item in the cache; + otherwise returns FALSE. Note that this refers to the iterator's + arbitrary ordering, not to the cache's internal least recently + used list. + + \sa toLast(), atFirst() +*/ + +/*! + \fn type *Q3AsciiCacheIterator::toFirst() + + Sets the iterator to point to the first item in the cache and + returns a pointer to the item. + + Sets the iterator to 0 and returns 0 if the cache is empty. + + \sa toLast() isEmpty() +*/ + +/*! + \fn type *Q3AsciiCacheIterator::toLast() + + Sets the iterator to point to the last item in the cache and + returns a pointer to the item. + + Sets the iterator to 0 and returns 0 if the cache is empty. + + \sa toFirst() isEmpty() +*/ + +/*! + \fn Q3AsciiCacheIterator::operator type *() const + + Cast operator. Returns a pointer to the current iterator item. + Same as current(). +*/ + +/*! + \fn type *Q3AsciiCacheIterator::current() const + + Returns a pointer to the current iterator item. +*/ + +/*! + \fn const char *Q3AsciiCacheIterator::currentKey() const + + Returns the key for the current iterator item. +*/ + +/*! + \fn type *Q3AsciiCacheIterator::operator()() + + Makes the succeeding item current and returns the original current + item. + + If the current iterator item was the last item in the cache or if + it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3AsciiCacheIterator::operator+=( uint jump ) + + Returns the item \a jump positions after the current item, or 0 + if it is beyond the last item. Makes this the current item. +*/ + +/*! + \fn type *Q3AsciiCacheIterator::operator-=( uint jump ) + + Returns the item \a jump positions before the current item, or 0 + if it is before the first item. Makes this the current item. +*/ + +/*! + \fn type *Q3AsciiCacheIterator::operator++() + + Prefix ++ makes the iterator point to the item just after + current(), and makes that the new current item for the iterator. If + current() was the last item, operator++() returns 0. +*/ + +/*! + \fn type *Q3AsciiCacheIterator::operator--() + + Prefix -- makes the iterator point to the item just before + current(), and makes that the new current item for the iterator. If + current() was the first item, operator--() returns 0. +*/ + diff --git a/doc/src/classes/q3asciidict.qdoc b/doc/src/classes/q3asciidict.qdoc new file mode 100644 index 0000000..9a51db1 --- /dev/null +++ b/doc/src/classes/q3asciidict.qdoc @@ -0,0 +1,416 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3AsciiDict + \brief The Q3AsciiDict class is a template class that provides a dictionary based on char* keys. + \compat + + Q3AsciiDict is implemented as a template class. Define a template + instance Q3AsciiDict\ to create a dictionary that operates on + pointers to X (X*). + + A dictionary is a collection of key-value pairs. The key is a + char* used for insertion, removal and lookup. The value is a + pointer. Dictionaries provide very fast insertion and lookup. + + Q3AsciiDict cannot handle Unicode keys; use the Q3Dict template + instead, which uses QString keys. A Q3Dict has the same + performace as a Q3AsciiDict. + + Example: + \snippet doc/src/snippets/code/doc_src_q3asciidict.qdoc 0 + In this example we use a dictionary to keep track of the line + edits we're using. We insert each line edit into the dictionary + with a unique name and then access the line edits via the + dictionary. See Q3PtrDict, Q3IntDict and Q3Dict. + + See Q3Dict for full details, including the choice of dictionary + size, and how deletions are handled. + + \sa Q3AsciiDictIterator, Q3Dict, Q3IntDict, Q3PtrDict +*/ + + +/*! + \fn Q3AsciiDict::Q3AsciiDict( int size, bool caseSensitive, bool copyKeys ) + + Constructs a dictionary optimized for less than \a size entries. + + We recommend setting \a size to a suitably large prime number (a + bit larger than the expected number of entries). This makes the + hash distribution better and will improve lookup performance. + + When \a caseSensitive is TRUE (the default) Q3AsciiDict treats + "abc" and "Abc" as different keys; when it is FALSE "abc" and + "Abc" are the same. Case-insensitive comparison only considers the + 26 letters in US-ASCII. + + If \a copyKeys is TRUE (the default), the dictionary copies keys + using strcpy(); if it is FALSE, the dictionary just copies the + pointers. +*/ + +/*! + \fn Q3AsciiDict::Q3AsciiDict( const Q3AsciiDict &dict ) + + Constructs a copy of \a dict. + + Each item in \a dict is inserted into this dictionary. Only the + pointers are copied (shallow copy). +*/ + +/*! + \fn Q3AsciiDict::~Q3AsciiDict() + + Removes all items from the dictionary and destroys it. + + The items are deleted if auto-delete is enabled. + + All iterators that access this dictionary will be reset. + + \sa setAutoDelete() +*/ + +/*! + \fn Q3AsciiDict &Q3AsciiDict::operator=(const Q3AsciiDict &dict) + + Assigns \a dict to this dictionary and returns a reference to this + dictionary. + + This dictionary is first cleared and then each item in \a dict is + inserted into this dictionary. Only the pointers are copied + (shallow copy) unless newItem() has been reimplemented(). +*/ + +/*! + \fn uint Q3AsciiDict::count() const + + Returns the number of items in the dictionary. + + \sa isEmpty() +*/ + +/*! + \fn uint Q3AsciiDict::size() const + + Returns the size of the internal hash array (as specified in the + constructor). + + \sa count() +*/ + +/*! + \fn void Q3AsciiDict::resize( uint newsize ) + + Changes the size of the hashtable to \a newsize. The contents of + the dictionary are preserved but all iterators on the dictionary + become invalid. +*/ + +/*! + \fn bool Q3AsciiDict::isEmpty() const + + Returns TRUE if the dictionary is empty, i.e. count() == 0; + otherwise it returns FALSE. + + \sa count() +*/ + +/*! + \fn void Q3AsciiDict::insert( const char *key, const type *item ) + + Inserts the \a key with the \a item into the dictionary. + + Multiple items can have the same key, in which case only the last + item will be accessible using \l operator[](). + + \a item may not be 0. + + \sa replace() +*/ + +/*! + \fn void Q3AsciiDict::replace( const char *key, const type *item ) + + Replaces an item that has a key equal to \a key with \a item. + + If the item does not already exist, it will be inserted. + + \a item may not be 0. + + Equivalent to: + \snippet doc/src/snippets/code/doc_src_q3asciidict.qdoc 1 + + If there are two or more items with equal keys, then the most + recently inserted item will be replaced. + + \sa insert() +*/ + +/*! + \fn bool Q3AsciiDict::remove( const char *key ) + + Removes the item associated with \a key from the dictionary. + Returns TRUE if successful, i.e. if the key existed in the + dictionary; otherwise returns FALSE. + + If there are two or more items with equal keys, then the most + recently inserted item will be removed. + + The removed item is deleted if \link + Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. + + All dictionary iterators that refer to the removed item will be + set to point to the next item in the dictionary traversal order. + + \sa take(), clear(), setAutoDelete() +*/ + +/*! + \fn type *Q3AsciiDict::take( const char *key ) + + Takes the item associated with \a key out of the dictionary + without deleting it (even if \link Q3PtrCollection::setAutoDelete() + auto-deletion\endlink is enabled). + + If there are two or more items with equal keys, then the most + recently inserted item will be taken. + + Returns a pointer to the item taken out, or 0 if the key does not + exist in the dictionary. + + All dictionary iterators that refer to the taken item will be set + to point to the next item in the dictionary traversal order. + + \sa remove(), clear(), setAutoDelete() +*/ + +/*! + \fn void Q3AsciiDict::clear() + + Removes all items from the dictionary. + + The removed items are deleted if \link + Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. + + All dictionary iterators that operate on dictionary are reset. + + \sa remove(), take(), setAutoDelete() +*/ + +/*! + \fn type *Q3AsciiDict::find( const char *key ) const + + Returns the item associated with \a key, or 0 if the key does not + exist in the dictionary. + + This function uses an internal hashing algorithm to optimize + lookup. + + If there are two or more items with equal keys, then the item that + was most recently inserted will be found. + + Equivalent to the [] operator. + + \sa operator[]() +*/ + +/*! + \fn type *Q3AsciiDict::operator[]( const char *key ) const + + Returns the item associated with \a key, or 0 if the key does + not exist in the dictionary. + + This function uses an internal hashing algorithm to optimize + lookup. + + If there are two or more items with equal keys, then the item that + was most recently inserted will be found. + + Equivalent to the find() function. + + \sa find() +*/ + +/*! + \fn void Q3AsciiDict::statistics() const + + Debugging-only function that prints out the dictionary + distribution using qDebug(). +*/ + +/*! + \fn QDataStream& Q3AsciiDict::read( QDataStream &s, + Q3PtrCollection::Item &item ) + + Reads a dictionary item from the stream \a s and returns a + reference to the stream. + + The default implementation sets \a item to 0. + + \sa write() +*/ + +/*! + \fn QDataStream& Q3AsciiDict::write(QDataStream &s, Q3PtrCollection::Item item) const + + Writes a dictionary \a item to the stream \a s and returns a + reference to the stream. + + \sa read() +*/ + +/*! + \class Q3AsciiDictIterator + \brief The Q3AsciiDictIterator class provides an iterator for Q3AsciiDict collections. + \compat + + Q3AsciiDictIterator is implemented as a template class. Define a + template instance Q3AsciiDictIterator\ to create a dictionary + iterator that operates on Q3AsciiDict\ (dictionary of X*). + + Example: + \snippet doc/src/snippets/code/doc_src_q3asciidict.qdoc 2 + In the example we insert some line edits into a dictionary, then + iterate over the dictionary printing the strings associated with + those line edits. + + Note that the traversal order is arbitrary; you are not guaranteed + any particular order. + + Multiple iterators may independently traverse the same dictionary. + A Q3AsciiDict knows about all the iterators that are operating on + the dictionary. When an item is removed from the dictionary, + Q3AsciiDict updates all the iterators that are referring to the + removed item to point to the next item in the (arbitrary) + traversal order. + + \sa Q3AsciiDict +*/ + +/*! + \fn Q3AsciiDictIterator::Q3AsciiDictIterator( const Q3AsciiDict &dict ) + + Constructs an iterator for \a dict. The current iterator item is + set to point on the first item in the \a dict. +*/ + +/*! + \fn Q3AsciiDictIterator::~Q3AsciiDictIterator() + + Destroys the iterator. +*/ + +/*! + \fn uint Q3AsciiDictIterator::count() const + + Returns the number of items in the dictionary this iterator + operates over. + + \sa isEmpty() +*/ + +/*! + \fn bool Q3AsciiDictIterator::isEmpty() const + + Returns TRUE if the dictionary is empty, i.e. count() == 0, + otherwise returns FALSE. + + \sa count() +*/ + +/*! + \fn type *Q3AsciiDictIterator::toFirst() + + Sets the current iterator item to point to the first item in the + dictionary and returns a pointer to the item. If the dictionary is + empty it sets the current item to 0 and returns 0. +*/ + +/*! + \fn Q3AsciiDictIterator::operator type *() const + + Cast operator. Returns a pointer to the current iterator item. + Same as current(). +*/ + +/*! + \fn type *Q3AsciiDictIterator::current() const + + Returns a pointer to the current iterator item. +*/ + +/*! + \fn const char *Q3AsciiDictIterator::currentKey() const + + Returns a pointer to the key for the current iterator item. +*/ + +/*! + \fn type *Q3AsciiDictIterator::operator()() + + Makes the succeeding item current and returns the original current + item. + + If the current iterator item was the last item in the dictionary + or if it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3AsciiDictIterator::operator++() + + Prefix ++ makes the succeeding item current and returns the new + current item. + + If the current iterator item was the last item in the dictionary + or if it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3AsciiDictIterator::operator+=( uint jump ) + + Sets the current item to the item \a jump positions after the + current item, and returns a pointer to that item. + + If that item is beyond the last item or if the dictionary is + empty, it sets the current item to 0 and returns 0. +*/ diff --git a/doc/src/classes/q3cache.qdoc b/doc/src/classes/q3cache.qdoc new file mode 100644 index 0000000..d8799b6 --- /dev/null +++ b/doc/src/classes/q3cache.qdoc @@ -0,0 +1,461 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3Cache + \brief The Q3Cache class is a template class that provides a cache based on QString keys. + \compat + + A cache is a least recently used (LRU) list of cache items. Each + cache item has a key and a certain cost. The sum of item costs, + totalCost(), never exceeds the maximum cache cost, maxCost(). If + inserting a new item would cause the total cost to exceed the + maximum cost, the least recently used items in the cache are + removed. + + Q3Cache is a template class. Q3Cache\ defines a cache that + operates on pointers to X, or X*. + + Apart from insert(), by far the most important function is find() + (which also exists as operator[]()). This function looks up an + item, returns it, and by default marks it as being the most + recently used item. + + There are also methods to remove() or take() an object from the + cache. Calling setAutoDelete(TRUE) for a cache tells it to delete + items that are removed. The default is to not delete items when + they are removed (i.e., remove() and take() are equivalent). + + When inserting an item into the cache, only the pointer is copied, + not the item itself. This is called a shallow copy. It is possible + to make the cache copy all of the item's data (known as a deep + copy) when an item is inserted. insert() calls the virtual + function Q3PtrCollection::newItem() for the item to be inserted. + Inherit a cache and reimplement newItem() if you want deep copies. + + When removing a cache item, the virtual function + Q3PtrCollection::deleteItem() is called. The default + implementation deletes the item if auto-deletion is enabled, and + does nothing otherwise. + + There is a Q3CacheIterator that can be used to traverse the items + in the cache in arbitrary order. + + In Q3Cache, the cache items are accessed via QString keys, which + are Unicode strings. If you want to use non-Unicode, plain 8-bit + \c char* keys, use the Q3AsciiCache template. A Q3Cache has the + same performance as a Q3AsciiCache. + + \sa Q3CacheIterator, Q3AsciiCache, Q3IntCache +*/ + +/*! + \fn Q3Cache::Q3Cache( const Q3Cache &c ) + + \internal + + Do not use. A Q3Cache cannot be copied. Calls qFatal() in debug version. +*/ + + +/*! + \fn Q3Cache::Q3Cache( int maxCost, int size, bool caseSensitive ) + + Constructs a cache whose contents will never have a total cost + greater than \a maxCost and which is expected to contain less than + \a size items. + + \a size is actually the size of an internal hash array; it's + usually best to make it a prime number and at least 50% bigger + than the largest expected number of items in the cache. + + Each inserted item has an associated cost. When inserting a new + item, if the total cost of all items in the cache will exceed \a + maxCost, the cache will start throwing out the older (least + recently used) items until there is enough room for the new item + to be inserted. + + If \a caseSensitive is TRUE (the default), the cache keys are case + sensitive; if it is FALSE, they are case-insensitive. + Case-insensitive comparison considers all Unicode letters. +*/ + +/*! + \fn Q3Cache::~Q3Cache() + + Removes all items from the cache and destroys it. All iterators + that access this cache will be reset. +*/ + +/*! + \fn Q3Cache& Q3Cache::operator=( const Q3Cache &c ) + + \internal + + Do not use. A Q3Cache cannot be copied. Calls qFatal() in debug version. +*/ + +/*! + \fn int Q3Cache::maxCost() const + + Returns the maximum allowed total cost of the cache. + + \sa setMaxCost() totalCost() +*/ + +/*! + \fn int Q3Cache::totalCost() const + + Returns the total cost of the items in the cache. This is an + integer in the range 0 to maxCost(). + + \sa setMaxCost() +*/ + +/*! + \fn void Q3Cache::setMaxCost( int m ) + + Sets the maximum allowed total cost of the cache to \a m. If the + current total cost is greater than \a m, some items are deleted + immediately. + + \sa maxCost() totalCost() +*/ + +/*! + \fn uint Q3Cache::count() const + + Returns the number of items in the cache. + + \sa totalCost() +*/ + +/*! + \fn uint Q3Cache::size() const + + Returns the size of the hash array used to implement the cache. + This should be a bit bigger than count() is likely to be. +*/ + +/*! + \fn bool Q3Cache::isEmpty() const + + Returns TRUE if the cache is empty; otherwise returns FALSE. +*/ + +/*! + \fn bool Q3Cache::insert( const QString &k, const type *d, int c, int p ) + + Inserts the item \a d into the cache with key \a k and associated + cost, \a c. Returns TRUE if it is successfully inserted; otherwise + returns FALSE. + + The cache's size is limited, and if the total cost is too high, + Q3Cache will remove old, least recently used items until there is + room for this new item. + + The parameter \a p is internal and should be left at the default + value (0). + + \warning If this function returns FALSE (which could happen, e.g. + if the cost of this item alone exceeds maxCost()) you must delete + \a d yourself. Additionally, be very careful about using \a d + after calling this function because any other insertions into the + cache, from anywhere in the application or within Qt itself, could + cause the object to be discarded from the cache and the pointer to + become invalid. +*/ + +/*! + \fn bool Q3Cache::remove( const QString &k ) + + Removes the item associated with \a k, and returns TRUE if the + item was present in the cache; otherwise returns FALSE. + + The item is deleted if auto-deletion has been enabled, i.e., if + you have called setAutoDelete(TRUE). + + If there are two or more items with equal keys, the one that was + inserted last is removed. + + All iterators that refer to the removed item are set to point to + the next item in the cache's traversal order. + + \sa take(), clear() +*/ + +/*! + \fn type *Q3Cache::take( const QString &k ) + + Takes the item associated with \a k out of the cache without + deleting it, and returns a pointer to the item taken out, or 0 + if the key does not exist in the cache. + + If there are two or more items with equal keys, the one that was + inserted last is taken. + + All iterators that refer to the taken item are set to point to the + next item in the cache's traversal order. + + \sa remove(), clear() +*/ + +/*! + \fn void Q3Cache::clear() + + Removes all items from the cache and deletes them if auto-deletion + has been enabled. + + All cache iterators that operate this on cache are reset. + + \sa remove() take() +*/ + +/*! + \fn type *Q3Cache::find( const QString &k, bool ref ) const + + Returns the item associated with key \a k, or 0 if the key does + not exist in the cache. If \a ref is TRUE (the default), the item + is moved to the front of the least recently used list. + + If there are two or more items with equal keys, the one that was + inserted last is returned. +*/ + +/*! + \fn type *Q3Cache::operator[]( const QString &k ) const + + Returns the item associated with key \a k, or 0 if \a k does not + exist in the cache, and moves the item to the front of the least + recently used list. + + If there are two or more items with equal keys, the one that was + inserted last is returned. + + This is the same as find( k, TRUE ). + + \sa find() +*/ + +/*! + \fn void Q3Cache::statistics() const + + A debug-only utility function. Prints out cache usage, hit/miss, + and distribution information using qDebug(). This function does + nothing in the release library. +*/ + +/***************************************************************************** + Q3CacheIterator documentation + *****************************************************************************/ + +/*! + \class Q3CacheIterator qcache.h + \brief The Q3CacheIterator class provides an iterator for Q3Cache collections. + \compat + + Note that the traversal order is arbitrary; you are not guaranteed + any particular order. If new objects are inserted into the cache + while the iterator is active, the iterator may or may not see + them. + + Multiple iterators are completely independent, even when they + operate on the same Q3Cache. Q3Cache updates all iterators that + refer an item when that item is removed. + + Q3CacheIterator provides an operator++(), and an operator+=() to + traverse the cache. The current() and currentKey() functions are + used to access the current cache item and its key. The atFirst() + and atLast() return TRUE if the iterator points to the first or + last item in the cache respectively. The isEmpty() function + returns TRUE if the cache is empty, and count() returns the number + of items in the cache. + + Note that atFirst() and atLast() refer to the iterator's arbitrary + ordering, not to the cache's internal least recently used list. + + \sa Q3Cache +*/ + +/*! + \fn Q3CacheIterator::Q3CacheIterator( const Q3Cache &cache ) + + Constructs an iterator for \a cache. The current iterator item is + set to point to the first item in the \a cache. +*/ + +/*! + \fn Q3CacheIterator::Q3CacheIterator (const Q3CacheIterator & ci) + + Constructs an iterator for the same cache as \a ci. The new + iterator starts at the same item as ci.current(), but moves + independently from there on. +*/ + +/*! + \fn Q3CacheIterator& Q3CacheIterator::operator=( const Q3CacheIterator &ci ) + + Makes this an iterator for the same cache as \a ci. The new + iterator starts at the same item as ci.current(), but moves + independently thereafter. +*/ + +/*! + \fn uint Q3CacheIterator::count() const + + Returns the number of items in the cache on which this iterator + operates. + + \sa isEmpty() +*/ + +/*! + \fn bool Q3CacheIterator::isEmpty() const + + Returns TRUE if the cache is empty, i.e. count() == 0; otherwise + it returns FALSE. + + \sa count() +*/ + +/*! + \fn bool Q3CacheIterator::atFirst() const + + Returns TRUE if the iterator points to the first item in the + cache; otherwise returns FALSE. Note that this refers to the + iterator's arbitrary ordering, not to the cache's internal least + recently used list. + + \sa toFirst(), atLast() +*/ + +/*! + \fn bool Q3CacheIterator::atLast() const + + Returns TRUE if the iterator points to the last item in the cache; + otherwise returns FALSE. Note that this refers to the iterator's + arbitrary ordering, not to the cache's internal least recently + used list. + + \sa toLast(), atFirst() +*/ + +/*! + \fn type *Q3CacheIterator::toFirst() + + Sets the iterator to point to the first item in the cache and + returns a pointer to the item. + + Sets the iterator to 0 and returns 0 if the cache is empty. + + \sa toLast() isEmpty() +*/ + +/*! + \fn type *Q3CacheIterator::toLast() + + Sets the iterator to point to the last item in the cache and + returns a pointer to the item. + + Sets the iterator to 0 and returns 0 if the cache is empty. + + \sa toFirst() isEmpty() +*/ + +/*! + \fn Q3CacheIterator::operator type *() const + + Cast operator. Returns a pointer to the current iterator item. + Same as current(). +*/ + +/*! + \fn type *Q3CacheIterator::current() const + + Returns a pointer to the current iterator item. +*/ + +/*! + \fn QString Q3CacheIterator::currentKey() const + + Returns the key for the current iterator item. +*/ + +/*! + \fn type *Q3CacheIterator::operator()() + + Makes the succeeding item current and returns the original current + item. + + If the current iterator item was the last item in the cache or if + it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3CacheIterator::operator+=( uint jump ) + + Returns the item \a jump positions after the current item, or 0 if + it is beyond the last item. Makes this the current item. +*/ + +/*! + \fn type *Q3CacheIterator::operator-=( uint jump ) + + Returns the item \a jump positions before the current item, or 0 + if it is before the first item. Makes this the current item. +*/ + +/*! + \fn type *Q3CacheIterator::operator++() + + Prefix++ makes the iterator point to the item just after current() + and makes that the new current item for the iterator. If current() + was the last item, operator++() returns 0. +*/ + +/*! + \fn type *Q3CacheIterator::operator--() + + Prefix-- makes the iterator point to the item just before + current() and makes that the new current item for the iterator. If + current() was the first item, operator--() returns 0. +*/ + diff --git a/doc/src/classes/q3dict.qdoc b/doc/src/classes/q3dict.qdoc new file mode 100644 index 0000000..0e6d51d --- /dev/null +++ b/doc/src/classes/q3dict.qdoc @@ -0,0 +1,446 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3Dict + \brief The Q3Dict class is a template class that provides a + dictionary based on QString keys. + \compat + + Q3Dict is implemented as a template class. Define a template + instance Q3Dict\ to create a dictionary that operates on + pointers to X (X *). + + A dictionary is a collection of key-value pairs. The key is a + QString used for insertion, removal and lookup. The value is a + pointer. Dictionaries provide very fast insertion and lookup. + + If you want to use non-Unicode, plain 8-bit \c char* keys, use the + Q3AsciiDict template. A Q3Dict has the same performance as a + Q3AsciiDict. If you want to have a dictionary that maps QStrings to + QStrings use QMap. + + The size() of the dictionary is very important. In order to get + good performance, you should use a suitably large prime number. + Suitable means equal to or larger than the maximum expected number + of dictionary items. Size is set in the constructor but may be + changed with resize(). + + Items are inserted with insert(); 0 pointers cannot be inserted. + Items are removed with remove(). All the items in a dictionary can + be removed with clear(). The number of items in the dictionary is + returned by count(). If the dictionary contains no items isEmpty() + returns TRUE. You can change an item's value with replace(). Items + are looked up with operator[](), or with find() which return a + pointer to the value or 0 if the given key does not exist. You can + take an item out of the dictionary with take(). + + Calling setAutoDelete(TRUE) for a dictionary tells it to delete + items that are removed. The default behavior is not to delete + items when they are removed. + + When an item is inserted, the key is converted (hashed) to an + integer index into an internal hash array. This makes lookup very + fast. + + Items with equal keys are allowed. When inserting two items with + the same key, only the last inserted item will be accessible (last + in, first out) until it is removed. + + The Q3DictIterator class can traverse the dictionary, but only in + an arbitrary order. Multiple iterators may independently traverse + the same dictionary. + + When inserting an item into a dictionary, only the pointer is + copied, not the item itself, i.e. a shallow copy is made. It is + possible to make the dictionary copy all of the item's data (a + deep copy) when an item is inserted. insert() calls the virtual + function Q3PtrCollection::newItem() for the item to be inserted. + Inherit a dictionary and reimplement newItem() if you want deep + copies. + + When removing a dictionary item, the virtual function + Q3PtrCollection::deleteItem() is called. Q3Dict's default + implementation is to delete the item if auto-deletion is enabled. + + \sa Q3DictIterator, Q3AsciiDict, Q3IntDict, Q3PtrDict +*/ + + +/*! + \fn Q3Dict::Q3Dict( int size, bool caseSensitive ) + + Constructs a dictionary optimized for less than \a size entries. + + We recommend setting \a size to a suitably large prime number + (e.g. a prime that's slightly larger than the expected number of + entries). This makes the hash distribution better which will lead + to faster lookup. + + If \a caseSensitive is TRUE (the default), keys which differ only + by case are considered different. +*/ + +/*! + \fn Q3Dict::Q3Dict( const Q3Dict &dict ) + + Constructs a copy of \a dict. + + Each item in \a dict is inserted into this dictionary. Only the + pointers are copied (shallow copy). +*/ + +/*! + \fn Q3Dict::~Q3Dict() + + Removes all items from the dictionary and destroys it. If + setAutoDelete() is TRUE, each value is deleted. All iterators that + access this dictionary will be reset. + + \sa setAutoDelete() +*/ + +/*! + \fn Q3Dict &Q3Dict::operator=(const Q3Dict &dict) + + Assigns \a dict to this dictionary and returns a reference to this + dictionary. + + This dictionary is first cleared, then each item in \a dict is + inserted into this dictionary. Only the pointers are copied + (shallow copy), unless newItem() has been reimplemented. +*/ + +/*! + \fn uint Q3Dict::count() const + + Returns the number of items in the dictionary. + + \sa isEmpty() +*/ + +/*! + \fn uint Q3Dict::size() const + + Returns the size of the internal hash array (as specified in the + constructor). + + \sa count() +*/ + +/*! + \fn void Q3Dict::resize( uint newsize ) + + Changes the size of the hash table to \a newsize. The contents of + the dictionary are preserved, but all iterators on the dictionary + become invalid. +*/ + +/*! + \fn bool Q3Dict::isEmpty() const + + Returns TRUE if the dictionary is empty, i.e. count() == 0; + otherwise returns FALSE. + + \sa count() +*/ + +/*! + \fn void Q3Dict::insert( const QString &key, const type *item ) + + Inserts the key \a key with value \a item into the dictionary. + + Multiple items can have the same key, in which case only the last + item will be accessible using \l operator[](). + + \a item may not be 0. + + \sa replace() +*/ + +/*! + \fn void Q3Dict::replace( const QString &key, const type *item ) + + Replaces the value of the key, \a key with \a item. + + If the item does not already exist, it will be inserted. + + \a item may not be 0. + + Equivalent to: + \snippet doc/src/snippets/code/doc_src_q3dict.qdoc 0 + + If there are two or more items with equal keys, then the last item + that was inserted will be replaced. + + \sa insert() +*/ + +/*! + \fn bool Q3Dict::remove( const QString &key ) + + Removes the item with \a key from the dictionary. Returns TRUE if + successful, i.e. if the item is in the dictionary; otherwise + returns FALSE. + + If there are two or more items with equal keys, then the last item + that was inserted will be removed. + + The removed item is deleted if \link + Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. + + All dictionary iterators that refer to the removed item will be + set to point to the next item in the dictionary's traversal order. + + \sa take(), clear(), setAutoDelete() +*/ + +/*! + \fn type *Q3Dict::take( const QString &key ) + + Takes the item with \a key out of the dictionary without deleting + it (even if \link Q3PtrCollection::setAutoDelete() + auto-deletion\endlink is enabled). + + If there are two or more items with equal keys, then the last item + that was inserted will be taken. + + Returns a pointer to the item taken out, or 0 if the key does not + exist in the dictionary. + + All dictionary iterators that refer to the taken item will be set + to point to the next item in the dictionary traversal order. + + \sa remove(), clear(), setAutoDelete() +*/ + +/*! + \fn void Q3Dict::clear() + + Removes all items from the dictionary. + + The removed items are deleted if \link + Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. + + All dictionary iterators that operate on the dictionary are reset. + + \sa remove(), take(), setAutoDelete() +*/ + +/*! + \fn type *Q3Dict::find( const QString &key ) const + + Returns the item with key \a key, or 0 if the key does not exist + in the dictionary. + + If there are two or more items with equal keys, then the most + recently inserted item will be found. + + Equivalent to the [] operator. + + \sa operator[]() +*/ + +/*! + \fn type *Q3Dict::operator[]( const QString &key ) const + + Returns the item with key \a key, or 0 if the key does not + exist in the dictionary. + + If there are two or more items with equal keys, then the most + recently inserted item will be found. + + Equivalent to the find() function. + + \sa find() +*/ + +/*! + \fn void Q3Dict::statistics() const + + Debugging-only function that prints out the dictionary + distribution using qDebug(). +*/ + +/*! + \fn QDataStream& Q3Dict::read( QDataStream &s, Q3PtrCollection::Item &item ) + + Reads a dictionary item from the stream \a s and returns a + reference to the stream. + + The default implementation sets \a item to 0. + + \sa write() +*/ + +/*! + \fn QDataStream& Q3Dict::write( QDataStream &s, Q3PtrCollection::Item item ) const + + Writes a dictionary \a item to the stream \a s and returns a + reference to the stream. + + \sa read() +*/ + +/*! + \class Q3DictIterator + \brief The Q3DictIterator class provides an iterator for Q3Dict collections. + \compat + + Q3DictIterator is implemented as a template class. Define a + template instance Q3DictIterator\ to create a dictionary + iterator that operates on Q3Dict\ (dictionary of X*). + + The traversal order is arbitrary; when we speak of the "first", + "last" and "next" item we are talking in terms of this arbitrary + order. + + Multiple iterators may independently traverse the same dictionary. + A Q3Dict knows about all the iterators that are operating on the + dictionary. When an item is removed from the dictionary, Q3Dict + updates all iterators that are referring to the removed item to + point to the next item in the (arbitrary) traversal order. + + Example: + \snippet doc/src/snippets/code/doc_src_q3dict.qdoc 1 + In the example we insert some pointers to line edits into a + dictionary, then iterate over the dictionary printing the strings + associated with the line edits. + + \sa Q3Dict +*/ + +/*! + \fn Q3DictIterator::Q3DictIterator( const Q3Dict &dict ) + + Constructs an iterator for \a dict. The current iterator item is + set to point to the first item in the dictionary, \a dict. First + in this context means first in the arbitrary traversal order. +*/ + +/*! + \fn Q3DictIterator::~Q3DictIterator() + + Destroys the iterator. +*/ + +/*! + \fn uint Q3DictIterator::count() const + + Returns the number of items in the dictionary over which the + iterator is operating. + + \sa isEmpty() +*/ + +/*! + \fn bool Q3DictIterator::isEmpty() const + + Returns TRUE if the dictionary is empty, i.e. count() == 0; + otherwise returns FALSE. + + \sa count() +*/ + +/*! + \fn type *Q3DictIterator::toFirst() + + Resets the iterator, making the first item the first current item. + First in this context means first in the arbitrary traversal + order. Returns a pointer to this item. + + If the dictionary is empty it sets the current item to 0 and + returns 0. +*/ + +/*! + \fn type *Q3DictIterator::operator*() + \internal +*/ + +/*! + \fn Q3DictIterator::operator type*() const + + Cast operator. Returns a pointer to the current iterator item. + Same as current(). +*/ + + +/*! + \fn type *Q3DictIterator::current() const + + Returns a pointer to the current iterator item's value. +*/ + +/*! + \fn QString Q3DictIterator::currentKey() const + + Returns the current iterator item's key. +*/ + +/*! + \fn type *Q3DictIterator::operator()() + + Makes the next item current and returns the original current item. + + If the current iterator item was the last item in the dictionary + or if it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3DictIterator::operator++() + + Prefix ++ makes the next item current and returns the new current + item. + + If the current iterator item was the last item in the dictionary + or if it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3DictIterator::operator+=( uint jump ) + \internal + Sets the current item to the item \a jump positions after the current item, + and returns a pointer to that item. + + If that item is beyond the last item or if the dictionary is empty, + it sets the current item to 0 and returns 0. +*/ diff --git a/doc/src/classes/q3intcache.qdoc b/doc/src/classes/q3intcache.qdoc new file mode 100644 index 0000000..dfff679 --- /dev/null +++ b/doc/src/classes/q3intcache.qdoc @@ -0,0 +1,446 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3IntCache + \brief The Q3IntCache class is a template class that provides a cache based on long keys. + \compat + + Q3IntCache is implemented as a template class. Define a template + instance Q3IntCache\ to create a cache that operates on + pointers to X, or X*. + + A cache is a least recently used (LRU) list of cache items, + accessed via \c long keys. Each cache item has a cost. The sum + of item costs, totalCost(), will not exceed the maximum cache + cost, maxCost(). If inserting a new item would cause the total + cost to exceed the maximum cost, the least recently used items in + the cache are removed. + + Apart from insert(), by far the most important function is find() + (which also exists as operator[]). This function looks up an + item, returns it, and by default marks it as being the most + recently used item. + + There are also methods to remove() or take() an object from the + cache. Calling setAutoDelete(TRUE) for a cache tells it to delete + items that are removed. The default is to not delete items when + they are removed (i.e. remove() and take() are equivalent). + + When inserting an item into the cache, only the pointer is copied, + not the item itself. This is called a shallow copy. It is possible + to make the cache copy all of the item's data (known as a deep + copy) when an item is inserted. insert() calls the virtual + function Q3PtrCollection::newItem() for the item to be inserted. + Inherit a dictionary and reimplement newItem() if you want deep + copies. + + When removing a cache item, the item will be automatically + deleted if auto-deletion is enabled. + + There is a Q3IntCacheIterator which may be used to traverse the + items in the cache in arbitrary order. + + \sa Q3IntCacheIterator, Q3Cache, Q3AsciiCache +*/ + +/*! + \fn Q3IntCache::Q3IntCache( const Q3IntCache &c ) + + \internal + + Do not use. A Q3IntCache cannot be copied. Calls qFatal() in debug version. +*/ + +/*! + \fn Q3IntCache::Q3IntCache( int maxCost, int size ) + + Constructs a cache whose contents will never have a total cost + greater than \a maxCost and which is expected to contain less than + \a size items. + + \a size is actually the size of an internal hash array; it's + usually best to make it prime and at least 50% bigger than the + largest expected number of items in the cache. + + Each inserted item is associated with a cost. When inserting a new + item, if the total cost of all items in the cache will exceed \a + maxCost, the cache will start throwing out the older (least + recently used) items until there is enough room for the new item + to be inserted. +*/ + +/*! + \fn Q3IntCache::~Q3IntCache() + + Removes all items from the cache and then destroys the int cache. + If auto-deletion is enabled the cache's items are deleted. All + iterators that access this cache will be reset. +*/ + +/*! + \fn Q3IntCache& Q3IntCache::operator=( const Q3IntCache &c ) + + \internal + + Do not use. A Q3IntCache cannot be copied. Calls qFatal() in debug version. +*/ + +/*! + \fn int Q3IntCache::maxCost() const + + Returns the maximum allowed total cost of the cache. + + \sa setMaxCost() totalCost() +*/ + +/*! + \fn int Q3IntCache::totalCost() const + + Returns the total cost of the items in the cache. This is an + integer in the range 0 to maxCost(). + + \sa setMaxCost() +*/ + +/*! + \fn void Q3IntCache::setMaxCost( int m ) + + Sets the maximum allowed total cost of the cache to \a m. If the + current total cost is greater than \a m, some items are removed + immediately. + + \sa maxCost() totalCost() +*/ + +/*! + \fn uint Q3IntCache::count() const + + Returns the number of items in the cache. + + \sa totalCost() +*/ + +/*! + \fn uint Q3IntCache::size() const + + Returns the size of the hash array used to implement the cache. + This should be a bit larger than count() is likely to be. +*/ + +/*! + \fn bool Q3IntCache::isEmpty() const + + Returns TRUE if the cache is empty; otherwise returns FALSE. +*/ + +/*! + \fn bool Q3IntCache::insert( long k, const type *d, int c, int p ) + + Inserts the item \a d into the cache with key \a k and assigns it + a cost of \a c (default 1). Returns TRUE if it succeeds; otherwise + returns FALSE. + + The cache's size is limited, and if the total cost is too high, + Q3IntCache will remove old, least-used items until there is room + for this new item. + + The parameter \a p is internal and should be left at the default + value (0). + + \warning If this function returns FALSE (for example, the cost \c, + exceeds maxCost()), you must delete \a d yourself. Additionally, + be very careful about using \a d after calling this function. Any + other insertions into the cache, from anywhere in the application + or within Qt itself, could cause the object to be discarded from + the cache and the pointer to become invalid. +*/ + +/*! + \fn bool Q3IntCache::remove( long k ) + + Removes the item associated with \a k, and returns TRUE if the + item was present in the cache; otherwise returns FALSE. + + The item is deleted if auto-deletion has been enabled, i.e. if you + have called setAutoDelete(TRUE). + + If there are two or more items with equal keys, the one that was + inserted most recently is removed. + + All iterators that refer to the removed item are set to point to + the next item in the cache's traversal order. + + \sa take(), clear() +*/ + +/*! + \fn type * Q3IntCache::take( long k ) + + Takes the item associated with \a k out of the cache without + deleting it, and returns a pointer to the item taken out or 0 if + the key does not exist in the cache. + + If there are two or more items with equal keys, the one that was + inserted most recently is taken. + + All iterators that refer to the taken item are set to point to the + next item in the cache's traversal order. + + \sa remove(), clear() +*/ + +/*! + \fn void Q3IntCache::clear() + + Removes all items from the cache, and deletes them if + auto-deletion has been enabled. + + All cache iterators that operate this on cache are reset. + + \sa remove() take() +*/ + +/*! + \fn type * Q3IntCache::find( long k, bool ref ) const + + Returns the item associated with \a k, or 0 if the key does not + exist in the cache. If \a ref is TRUE (the default), the item is + moved to the front of the least recently used list. + + If there are two or more items with equal keys, the one that was + inserted most recently is returned. +*/ + +/*! + \fn type * Q3IntCache::operator[]( long k ) const + + Returns the item associated with \a k, or 0 if \a k does not exist + in the cache, and moves the item to the front of the least + recently used list. + + If there are two or more items with equal keys, the one that was + inserted most recently is returned. + + This is the same as find( k, TRUE ). + + \sa find() +*/ + +/*! + \fn void Q3IntCache::statistics() const + + A debug-only utility function. Prints out cache usage, hit/miss, + and distribution information using qDebug(). This function does + nothing in the release library. +*/ + +/*! + \class Q3IntCacheIterator + \brief The Q3IntCacheIterator class provides an iterator for Q3IntCache collections. + \compat + + Note that the traversal order is arbitrary; you are not guaranteed + any particular order. If new objects are inserted into the cache + while the iterator is active, the iterator may or may not see + them. + + Multiple iterators are completely independent, even when they + operate on the same Q3IntCache. Q3IntCache updates all iterators + that refer an item when that item is removed. + + Q3IntCacheIterator provides an operator++(), and an operator+=() to + traverse the cache; current() and currentKey() to access the + current cache item and its key; atFirst() atLast(), which return + TRUE if the iterator points to the first/last item in the cache; + isEmpty(), which returns TRUE if the cache is empty; and count(), + which returns the number of items in the cache. + + Note that atFirst() and atLast() refer to the iterator's arbitrary + ordering, not to the cache's internal least recently used list. + + \sa Q3IntCache +*/ + +/*! + \fn Q3IntCacheIterator::Q3IntCacheIterator( const Q3IntCache &cache ) + + Constructs an iterator for \a cache. The current iterator item is + set to point to the first item in the \a cache (or rather, the + first item is defined to be the item at which this constructor + sets the iterator to point). +*/ + +/*! + \fn Q3IntCacheIterator::Q3IntCacheIterator (const Q3IntCacheIterator & ci) + + Constructs an iterator for the same cache as \a ci. The new + iterator starts at the same item as ci.current(), but moves + independently from there on. +*/ + +/*! + \fn Q3IntCacheIterator& Q3IntCacheIterator::operator=( const Q3IntCacheIterator &ci ) + + Makes this an iterator for the same cache as \a ci. The new + iterator starts at the same item as ci.current(), but moves + independently thereafter. +*/ + +/*! + \fn uint Q3IntCacheIterator::count() const + + Returns the number of items in the cache on which this iterator + operates. + + \sa isEmpty() +*/ + +/*! + \fn bool Q3IntCacheIterator::isEmpty() const + + Returns TRUE if the cache is empty; otherwise returns FALSE. + + \sa count() +*/ + +/*! + \fn bool Q3IntCacheIterator::atFirst() const + + Returns TRUE if the iterator points to the first item in the + cache; otherwise returns FALSE. Note that this refers to the + iterator's arbitrary ordering, not to the cache's internal least + recently used list. + + \sa toFirst(), atLast() +*/ + +/*! + \fn bool Q3IntCacheIterator::atLast() const + + Returns TRUE if the iterator points to the last item in the cache; + otherwise returns FALSE. Note that this refers to the iterator's + arbitrary ordering, not to the cache's internal least recently + used list. + + \sa toLast(), atFirst() +*/ + +/*! + \fn type *Q3IntCacheIterator::toFirst() + + Sets the iterator to point to the first item in the cache and + returns a pointer to the item. + + Sets the iterator to 0, and returns 0, if the cache is empty. + + \sa toLast() isEmpty() +*/ + +/*! + \fn type *Q3IntCacheIterator::toLast() + + Sets the iterator to point to the last item in the cache and + returns a pointer to the item. + + Sets the iterator to 0, and returns 0, if the cache is empty. + + \sa toFirst() isEmpty() +*/ + +/*! + \fn Q3IntCacheIterator::operator type *() const + + Cast operator. Returns a pointer to the current iterator item. + Same as current(). +*/ + +/*! + \fn type *Q3IntCacheIterator::current() const + + Returns a pointer to the current iterator item. +*/ + +/*! + \fn long Q3IntCacheIterator::currentKey() const + + Returns the key for the current iterator item. +*/ + +/*! + \fn type *Q3IntCacheIterator::operator()() + + Makes the succeeding item current and returns the original current + item. + + If the current iterator item was the last item in the cache or if + it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3IntCacheIterator::operator+=( uint jump ) + + Returns the item \a jump positions after the current item, or 0 if + it is beyond the last item. Makes this the current item. +*/ + +/*! + \fn type *Q3IntCacheIterator::operator-=( uint jump ) + + Returns the item \a jump positions before the current item, or 0 + if it is beyond the first item. Makes this the current item. +*/ + +/*! + \fn type *Q3IntCacheIterator::operator++() + + Prefix ++ makes the iterator point to the item just after + current(), and makes it the new current item for the iterator. If + current() was the last item, operator--() returns 0. +*/ + +/*! + \fn type *Q3IntCacheIterator::operator--() + + Prefix -- makes the iterator point to the item just before + current(), and makes it the new current item for the iterator. If + current() was the first item, operator--() returns 0. +*/ diff --git a/doc/src/classes/q3intdict.qdoc b/doc/src/classes/q3intdict.qdoc new file mode 100644 index 0000000..cef2e79 --- /dev/null +++ b/doc/src/classes/q3intdict.qdoc @@ -0,0 +1,390 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3IntDict + \brief The Q3IntDict class is a template class that provides a dictionary based on long keys.\ + \compat + + Q3IntDict is implemented as a template class. Define a template + instance Q3IntDict\ to create a dictionary that operates on + pointers to X (X*). + + A dictionary is a collection of key-value pairs. The key is an \c + long used for insertion, removal and lookup. The value is a + pointer. Dictionaries provide very fast insertion and lookup. + + Example: + \snippet doc/src/snippets/code/doc_src_q3intdict.qdoc 0 + + See Q3Dict for full details, including the choice of dictionary + size, and how deletions are handled. + + \sa Q3IntDictIterator, Q3Dict, Q3AsciiDict, Q3PtrDict +*/ + + +/*! + \fn Q3IntDict::Q3IntDict( int size ) + + Constructs a dictionary using an internal hash array of size \a + size. + + Setting \a size to a suitably large prime number (equal to or + greater than the expected number of entries) makes the hash + distribution better which leads to faster lookup. +*/ + +/*! + \fn Q3IntDict::Q3IntDict( const Q3IntDict &dict ) + + Constructs a copy of \a dict. + + Each item in \a dict is inserted into this dictionary. Only the + pointers are copied (shallow copy). +*/ + +/*! + \fn Q3IntDict::~Q3IntDict() + + Removes all items from the dictionary and destroys it. + + All iterators that access this dictionary will be reset. + + \sa setAutoDelete() +*/ + +/*! + \fn Q3IntDict &Q3IntDict::operator=(const Q3IntDict &dict) + + Assigns \a dict to this dictionary and returns a reference to this + dictionary. + + This dictionary is first cleared and then each item in \a dict is + inserted into this dictionary. Only the pointers are copied + (shallow copy), unless newItem() has been reimplemented. +*/ + +/*! + \fn uint Q3IntDict::count() const + + Returns the number of items in the dictionary. + + \sa isEmpty() +*/ + +/*! + \fn uint Q3IntDict::size() const + + Returns the size of the internal hash array (as specified in the + constructor). + + \sa count() +*/ + +/*! + \fn void Q3IntDict::resize( uint newsize ) + + Changes the size of the hashtable to \a newsize. The contents of + the dictionary are preserved, but all iterators on the dictionary + become invalid. +*/ + +/*! + \fn bool Q3IntDict::isEmpty() const + + Returns TRUE if the dictionary is empty; otherwise returns FALSE. + + \sa count() +*/ + +/*! + \fn void Q3IntDict::insert( long key, const type *item ) + + Insert item \a item into the dictionary using key \a key. + + Multiple items can have the same key, in which case only the last + item will be accessible using \l operator[](). + + \a item may not be 0. + + \sa replace() +*/ + +/*! + \fn void Q3IntDict::replace( long key, const type *item ) + + If the dictionary has key \a key, this key's item is replaced with + \a item. If the dictionary doesn't contain key \a key, \a item is + inserted into the dictionary using key \a key. + + \a item may not be 0. + + Equivalent to: + \snippet doc/src/snippets/code/doc_src_q3intdict.qdoc 1 + + If there are two or more items with equal keys, then the most + recently inserted item will be replaced. + + \sa insert() +*/ + +/*! + \fn bool Q3IntDict::remove( long key ) + + Removes the item associated with \a key from the dictionary. + Returns TRUE if successful, i.e. if the \a key is in the + dictionary; otherwise returns FALSE. + + If there are two or more items with equal keys, then the most + recently inserted item will be removed. + + The removed item is deleted if \link + Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. + + All dictionary iterators that refer to the removed item will be + set to point to the next item in the dictionary's traversal + order. + + \sa take(), clear(), setAutoDelete() +*/ + +/*! + \fn type *Q3IntDict::take( long key ) + + Takes the item associated with \a key out of the dictionary + without deleting it (even if \link Q3PtrCollection::setAutoDelete() + auto-deletion\endlink is enabled). + + If there are two or more items with equal keys, then the most + recently inserted item will be taken. + + Returns a pointer to the item taken out, or 0 if the key does not + exist in the dictionary. + + All dictionary iterators that refer to the taken item will be set + to point to the next item in the dictionary's traversing order. + + \sa remove(), clear(), setAutoDelete() +*/ + +/*! + \fn void Q3IntDict::clear() + + Removes all items from the dictionary. + + The removed items are deleted if \link + Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. + + All dictionary iterators that access this dictionary will be reset. + + \sa remove(), take(), setAutoDelete() +*/ + +/*! + \fn type *Q3IntDict::find( long key ) const + + Returns the item associated with \a key, or 0 if the key does not + exist in the dictionary. + + If there are two or more items with equal keys, then the most + recently inserted item will be found. + + Equivalent to operator[]. + + \sa operator[]() +*/ + +/*! + \fn type *Q3IntDict::operator[]( long key ) const + + Returns the item associated with \a key, or 0 if the key does not + exist in the dictionary. + + If there are two or more items with equal keys, then the most + recently inserted item will be found. + + Equivalent to the find() function. + + \sa find() +*/ + +/*! + \fn void Q3IntDict::statistics() const + + Debugging-only function that prints out the dictionary + distribution using qDebug(). +*/ + +/*! + \fn QDataStream& Q3IntDict::read( QDataStream &s, Q3PtrCollection::Item &item ) + + Reads a dictionary item from the stream \a s and returns a + reference to the stream. + + The default implementation sets \a item to 0. + + \sa write() +*/ + +/*! + \fn QDataStream& Q3IntDict::write( QDataStream &s, Q3PtrCollection::Item item ) const + + Writes a dictionary \a item to the stream \a s and returns a + reference to the stream. + + \sa read() +*/ + +/*! + \class Q3IntDictIterator + \brief The Q3IntDictIterator class provides an iterator for Q3IntDict collections. + \compat + + Q3IntDictIterator is implemented as a template class. Define a + template instance Q3IntDictIterator\ to create a dictionary + iterator that operates on Q3IntDict\ (dictionary of X*). + + Example: + \snippet doc/src/snippets/code/doc_src_q3intdict.qdoc 2 + + Note that the traversal order is arbitrary; you are not guaranteed the + order shown above. + + Multiple iterators may independently traverse the same dictionary. + A Q3IntDict knows about all the iterators that are operating on the + dictionary. When an item is removed from the dictionary, Q3IntDict + updates all iterators that refer the removed item to point to the + next item in the traversal order. + + \sa Q3IntDict +*/ + +/*! + \fn Q3IntDictIterator::Q3IntDictIterator( const Q3IntDict &dict ) + + Constructs an iterator for \a dict. The current iterator item is + set to point to the 'first' item in the \a dict. The first item + refers to the first item in the dictionary's arbitrary internal + ordering. +*/ + +/*! + \fn Q3IntDictIterator::~Q3IntDictIterator() + + Destroys the iterator. +*/ + +/*! + \fn uint Q3IntDictIterator::count() const + + Returns the number of items in the dictionary this iterator + operates over. + + \sa isEmpty() +*/ + +/*! + \fn bool Q3IntDictIterator::isEmpty() const + + Returns TRUE if the dictionary is empty; otherwise eturns FALSE. + + \sa count() +*/ + +/*! + \fn type *Q3IntDictIterator::toFirst() + + Sets the current iterator item to point to the first item in the + dictionary and returns a pointer to the item. The first item + refers to the first item in the dictionary's arbitrary internal + ordering. If the dictionary is empty it sets the current item to + 0 and returns 0. +*/ + +/*! + \fn Q3IntDictIterator::operator type *() const + + Cast operator. Returns a pointer to the current iterator item. + Same as current(). +*/ + +/*! + \fn type *Q3IntDictIterator::current() const + + Returns a pointer to the current iterator item. +*/ + +/*! + \fn long Q3IntDictIterator::currentKey() const + + Returns the key for the current iterator item. +*/ + +/*! + \fn type *Q3IntDictIterator::operator()() + + Makes the succeeding item current and returns the original current + item. + + If the current iterator item was the last item in the dictionary + or if it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3IntDictIterator::operator++() + + Prefix ++ makes the succeeding item current and returns the new + current item. + + If the current iterator item was the last item in the dictionary + or if it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3IntDictIterator::operator+=( uint jump ) + + Sets the current item to the item \a jump positions after the + current item, and returns a pointer to that item. + + If that item is beyond the last item or if the dictionary is + empty, it sets the current item to 0 and returns 0. +*/ diff --git a/doc/src/classes/q3memarray.qdoc b/doc/src/classes/q3memarray.qdoc new file mode 100644 index 0000000..b9c1f73 --- /dev/null +++ b/doc/src/classes/q3memarray.qdoc @@ -0,0 +1,523 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3MemArray + \brief The Q3MemArray class is a template class that provides arrays of simple types. + \compat + + Q3MemArray is implemented as a template class. Define a template + instance Q3MemArray\ to create an array that contains X items. + + Q3MemArray stores the array elements directly in the array. It can + only deal with simple types (i.e. C++ types, structs, and classes + that have no constructors, destructors, or virtual functions). + Q3MemArray uses bitwise operations to copy and compare array + elements. + + The Q3PtrVector collection class is also a kind of array. Like most + old Qt collection classes, it uses pointers to the contained items. + + Q3MemArray uses explicit sharing with a + reference count. If more than one array shares common data and one + of the arrays is modified, all the arrays are modified. + + The benefit of sharing is that a program does not need to duplicate + data when it is not required, which results in lower memory use + and less copying of data. + + Example: + \snippet doc/src/snippets/code/doc_src_q3memarray.qdoc 0 + + Program output: + \snippet doc/src/snippets/code/doc_src_q3memarray.qdoc 1 + + Note concerning the use of Q3MemArray for manipulating structs or + classes: Compilers will often pad the size of structs of odd sizes + up to the nearest word boundary. This will then be the size + Q3MemArray will use for its bitwise element comparisons. Because + the remaining bytes will typically be uninitialized, this can + cause find() etc. to fail to find the element. Example: + + \snippet doc/src/snippets/code/doc_src_q3memarray.qdoc 2 + + To work around this, make sure that you use a struct where + sizeof() returns the same as the sum of the sizes of the members + either by changing the types of the struct members or by adding + dummy members. + + Q3MemArray data can be traversed by iterators (see begin() and + end()). The number of items is returned by count(). The array can + be resized with resize() and filled using fill(). + + You can make a shallow copy of the array with assign() (or + operator=()) and a deep copy with duplicate(). + + Search for values in the array with find() and contains(). For + sorted arrays (see sort()) you can search using bsearch(). + + You can set the data directly using setRawData() and + resetRawData(), although this requires care. +*/ + +/*! \fn Q3MemArray::operator QVector() const + + Automatically converts the Q3MemArray into a QVector. +*/ + +/*! \typedef Q3MemArray::Iterator + A Q3MemArray iterator. + \sa begin() end() +*/ +/*! \typedef Q3MemArray::ConstIterator + A const Q3MemArray iterator. + \sa begin() end() +*/ +/*! \typedef Q3MemArray::ValueType + \internal +*/ + +/*! + \fn Q3MemArray::Q3MemArray() + + Constructs a null array. + + \sa isNull() +*/ + +/*! + \fn Q3MemArray::Q3MemArray( int size ) + + Constructs an array with room for \a size elements. Makes a null + array if \a size == 0. + + The elements are left uninitialized. + + \sa resize(), isNull() +*/ + +/*! + \fn Q3MemArray::Q3MemArray( const Q3MemArray &a ) + + Constructs a shallow copy of \a a. + + \sa assign() +*/ + +/*! + \fn Q3MemArray::Q3MemArray(const QVector &vector) + + Constructs a copy of \a vector. +*/ + +/*! + \fn Q3MemArray::Q3MemArray(int arg1, int arg2) + + Constructs an array \e{without allocating} array space. The + arguments \a arg1 and \a arg2 should be zero. Use at your own + risk. +*/ + +/*! + \fn Q3MemArray::~Q3MemArray() + + Dereferences the array data and deletes it if this was the last + reference. +*/ + +/*! + \fn Q3MemArray &Q3MemArray::operator=( const Q3MemArray &a ) + + Assigns a shallow copy of \a a to this array and returns a + reference to this array. + + Equivalent to assign( a ). +*/ + +/*! + \fn type *Q3MemArray::data() const + + Returns a pointer to the actual array data. + + The array is a null array if data() == 0 (null pointer). + + \sa isNull() +*/ + +/*! + \fn uint Q3MemArray::nrefs() const + + Returns the reference count for the shared array data. This + reference count is always greater than zero. +*/ + +/*! + \fn uint Q3MemArray::size() const + + Returns the size of the array (maximum number of elements). + + The array is a null array if size() == 0. + + \sa isNull(), resize() +*/ + +/*! + \fn uint Q3MemArray::count() const + + Returns the same as size(). + + \sa size() +*/ + +/*! + \fn bool Q3MemArray::isEmpty() const + + Returns TRUE if the array is empty; otherwise returns FALSE. + + isEmpty() is equivalent to isNull() for Q3MemArray (unlike + QString). +*/ + +/*! + \fn bool Q3MemArray::isNull() const + + Returns TRUE if the array is null; otherwise returns FALSE. + + A null array has size() == 0 and data() == 0. +*/ + +/*! + \fn bool Q3MemArray::resize( uint size, Optimization optim ) + + Resizes (expands or shrinks) the array to \a size elements. The + array becomes a null array if \a size == 0. + + Returns TRUE if successful, or FALSE if the memory cannot be + allocated. + + New elements are not initialized. + + \a optim is either Q3GArray::MemOptim (the default) or + Q3GArray::SpeedOptim. When optimizing for speed rather than memory + consumption, the array uses a smart grow and shrink algorithm that + might allocate more memory than is actually needed for \a size + elements. This speeds up subsequent resize operations, for example + when appending many elements to an array, since the space has + already been allocated. + + \sa size() +*/ + +/*! + \fn bool Q3MemArray::resize( uint size ) + + \overload + + Resizes (expands or shrinks) the array to \a size elements. The + array becomes a null array if \a size == 0. + + Returns TRUE if successful, i.e. if the memory can be allocated; + otherwise returns FALSE. + + New elements are not initialized. + + \sa size() +*/ + +/*! + \fn bool Q3MemArray::truncate( uint pos ) + + Truncates the array at position \a pos. + + Returns TRUE if successful, i.e. if the memory can be allocated; + otherwise returns FALSE. + + Equivalent to resize(\a pos). + + \sa resize() +*/ + +/*! + \fn bool Q3MemArray::fill( const type &v, int size ) + + Fills the array with the value \a v. If \a size is specified as + different from -1, then the array will be resized before being + filled. + + Returns TRUE if successful, i.e. if \a size is -1, or \a size is + != -1 and the memory can be allocated; otherwise returns FALSE. + + \sa resize() +*/ + +/*! + \fn void Q3MemArray::detach() + + Detaches this array from shared array data; i.e. it makes a + private, deep copy of the data. + + Copying will be performed only if the \link nrefs() reference + count\endlink is greater than one. + + \sa copy() +*/ + +/*! + \fn Q3MemArray Q3MemArray::copy() const + + Returns a deep copy of this array. + + \sa detach(), duplicate() +*/ + +/*! + \fn Q3MemArray &Q3MemArray::assign( const Q3MemArray &a ) + + Shallow copy. Dereferences the current array and references the + data contained in \a a instead. Returns a reference to this array. + + \sa operator=() +*/ + +/*! + \fn Q3MemArray &Q3MemArray::assign( const type *data, uint size ) + + \overload + + Shallow copy. Dereferences the current array and references the + array data \a data, which contains \a size elements. Returns a + reference to this array. + + Do not delete \a data later; Q3MemArray will call free() on it + at the right time. +*/ + +/*! + \fn Q3MemArray &Q3MemArray::duplicate( const Q3MemArray &a ) + + Deep copy. Dereferences the current array and obtains a copy of + the data contained in \a a instead. Returns a reference to this + array. + + \sa copy() +*/ + +/*! + \fn Q3MemArray &Q3MemArray::duplicate( const type *data, uint size ) + + \overload + + Deep copy. Dereferences the current array and obtains a copy of + the array data \a data instead. Returns a reference to this array. + The size of the array is given by \a size. + + \sa copy() +*/ + +/*! + \fn Q3MemArray &Q3MemArray::setRawData( const type *data, uint size ) + + Sets raw data and returns a reference to the array. + + Dereferences the current array and sets the new array data to \a + data and the new array size to \a size. Do not attempt to resize + or re-assign the array data when raw data has been set. Call + resetRawData(\a data, \a size) to reset the array. + + Setting raw data is useful because it sets Q3MemArray data without + allocating memory or copying data. + + Example I (intended use): + \snippet doc/src/snippets/code/doc_src_q3memarray.qdoc 3 + + Example II (you don't want to do this): + \snippet doc/src/snippets/code/doc_src_q3memarray.qdoc 4 + + \warning If you do not call resetRawData(), Q3MemArray will attempt + to deallocate or reallocate the raw data, which might not be too + good. Be careful. + + \sa resetRawData() +*/ + +/*! + \fn void Q3MemArray::resetRawData( const type *data, uint size ) + + Removes internal references to the raw data that was set using + setRawData(). This means that Q3MemArray no longer has access to + the \a data, so you are free to manipulate \a data as you wish. + You can now use the Q3MemArray without affecting the original \a + data, for example by calling setRawData() with a pointer to some + other data. + + The arguments must be the \a data and length, \a size, that were + passed to setRawData(). This is for consistency checking. + + \sa setRawData() +*/ + +/*! + \fn int Q3MemArray::find( const type &v, uint index ) const + + Finds the first occurrence of \a v, starting at position \a index. + + Returns the position of \a v, or -1 if \a v could not be found. + + \sa contains() +*/ + +/*! + \fn int Q3MemArray::contains( const type &v ) const + + Returns the number of times \a v occurs in the array. + + \sa find() +*/ + +/*! + \fn void Q3MemArray::sort() + + Sorts the array elements in ascending order, using bitwise + comparison (memcmp()). + + \sa bsearch() +*/ + +/*! + \fn int Q3MemArray::bsearch( const type &v ) const + + In a sorted array (as sorted by sort()), finds the first + occurrence of \a v by using a binary search. For a sorted + array this is generally much faster than find(), which does + a linear search. + + Returns the position of \a v, or -1 if \a v could not be found. + + \sa sort(), find() +*/ + +/*! + \fn type &Q3MemArray::operator[]( int index ) const + + Returns a reference to the element at position \a index in the + array. + + This can be used to both read and set an element. Equivalent to + at(). + + \sa at() +*/ + +/*! + \fn type &Q3MemArray::at( uint index ) const + + Returns a reference to the element at position \a index in the array. + + This can be used to both read and set an element. + + \sa operator[]() +*/ + +/*! + \fn Q3MemArray::operator const type *() const + + Cast operator. Returns a pointer to the array. + + \sa data() +*/ + +/*! + \fn bool Q3MemArray::operator==( const Q3MemArray &a ) const + + Returns TRUE if this array is equal to \a a; otherwise returns + FALSE. + + The two arrays are compared bitwise. + + \sa operator!=() +*/ + +/*! + \fn bool Q3MemArray::operator!=( const Q3MemArray &a ) const + + Returns TRUE if this array is different from \a a; otherwise + returns FALSE. + + The two arrays are compared bitwise. + + \sa operator==() +*/ + +/*! + \fn Iterator Q3MemArray::begin() + + Returns an iterator pointing at the beginning of this array. This + iterator can be used in the same way as the iterators of + Q3ValueList and QMap, for example. +*/ + +/*! + \fn Iterator Q3MemArray::end() + + Returns an iterator pointing behind the last element of this + array. This iterator can be used in the same way as the iterators + of Q3ValueList and QMap, for example. +*/ + +/*! + \fn ConstIterator Q3MemArray::begin() const + + \overload + + Returns a const iterator pointing at the beginning of this array. + This iterator can be used in the same way as the iterators of + Q3ValueList and QMap, for example. +*/ + +/*! + \fn ConstIterator Q3MemArray::end() const + + \overload + + Returns a const iterator pointing behind the last element of this + array. This iterator can be used in the same way as the iterators + of Q3ValueList and QMap, for example. +*/ diff --git a/doc/src/classes/q3popupmenu.qdoc b/doc/src/classes/q3popupmenu.qdoc new file mode 100644 index 0000000..a2cfe08 --- /dev/null +++ b/doc/src/classes/q3popupmenu.qdoc @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3PopupMenu + \brief The Q3PopupMenu class is a thin compatibility wrapper around QMenu. + \compat + + Use QMenu in new applications. Note that the menu's actions must + be \l {Q3Action}s. +*/ + +/*! + \fn Q3PopupMenu::Q3PopupMenu(QWidget *parent, const char *name) + + Constructs a menu with the given \a parent and \a name. +*/ + +/*! + \fn int Q3PopupMenu::exec() + + Pops up the menu and returns the ID of the action that was + selected. + + \sa QMenu::exec() +*/ + +/*! + \fn int Q3PopupMenu::exec(const QPoint & pos, int indexAtPoint) + + Pops up the menu at coordinate \a pos and returns the ID of the + action that was selected. + + If \a indexAtPoint is specified, the menu will pop up with the + item at index \a indexAtPoint under the mouse cursor. + + \sa QMenu::exec() +*/ diff --git a/doc/src/classes/q3ptrdict.qdoc b/doc/src/classes/q3ptrdict.qdoc new file mode 100644 index 0000000..38ca0bb --- /dev/null +++ b/doc/src/classes/q3ptrdict.qdoc @@ -0,0 +1,388 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3PtrDict + \brief The Q3PtrDict class is a template class that provides a dictionary based on void* keys. + \compat + + Q3PtrDict is implemented as a template class. Define a template + instance Q3PtrDict\ to create a dictionary that operates on + pointers to X (X*). + + A dictionary is a collection of key-value pairs. The key is a + void* used for insertion, removal and lookup. The value is a + pointer. Dictionaries provide very fast insertion and lookup. + + Example: + \snippet doc/src/snippets/code/doc_src_q3ptrdict.qdoc 0 + In this example we use a dictionary to add an extra property (a + char*) to the line edits we're using. + + See Q3Dict for full details, including the choice of dictionary + size, and how deletions are handled. + + \sa Q3PtrDictIterator, Q3Dict, Q3AsciiDict, Q3IntDict +*/ + + +/*! + \fn Q3PtrDict::Q3PtrDict( int size ) + + Constructs a dictionary using an internal hash array with the size + \a size. + + Setting \a size to a suitably large prime number (equal to or + greater than the expected number of entries) makes the hash + distribution better and improves lookup performance. +*/ + +/*! + \fn Q3PtrDict::Q3PtrDict( const Q3PtrDict &dict ) + + Constructs a copy of \a dict. + + Each item in \a dict is inserted into this dictionary. Only the + pointers are copied (shallow copy). +*/ + +/*! + \fn Q3PtrDict::~Q3PtrDict() + + Removes all items from the dictionary and destroys it. + + All iterators that access this dictionary will be reset. + + \sa setAutoDelete() +*/ + +/*! + \fn Q3PtrDict &Q3PtrDict::operator=(const Q3PtrDict &dict) + + Assigns \a dict to this dictionary and returns a reference to this + dictionary. + + This dictionary is first cleared and then each item in \a dict is + inserted into the dictionary. Only the pointers are copied + (shallow copy), unless newItem() has been reimplemented. +*/ + +/*! + \fn uint Q3PtrDict::count() const + + Returns the number of items in the dictionary. + + \sa isEmpty() +*/ + +/*! + \fn uint Q3PtrDict::size() const + + Returns the size of the internal hash table (as specified in the + constructor). + + \sa count() +*/ + +/*! + \fn void Q3PtrDict::resize( uint newsize ) + + Changes the size of the hash table to \a newsize. The contents of + the dictionary are preserved, but all iterators on the dictionary + become invalid. +*/ + +/*! + \fn bool Q3PtrDict::isEmpty() const + + Returns TRUE if the dictionary is empty; otherwise returns FALSE. + + \sa count() +*/ + +/*! + \fn void Q3PtrDict::insert( void *key, const type *item ) + + Inserts the \a key with the \a item into the dictionary. + + Multiple items can have the same key, in which case only the last + item will be accessible using \l operator[](). + + \a item may not be 0. + + \sa replace() +*/ + +/*! + \fn void Q3PtrDict::replace( void *key, const type *item ) + + If the dictionary has key \a key, this key's item is replaced with + \a item. If the dictionary doesn't contain key \a key, \a item is + inserted into the dictionary using key \a key. + + \a item may not be 0. + + Equivalent to + \snippet doc/src/snippets/code/doc_src_q3ptrdict.qdoc 1 + + If there are two or more items with equal keys, then the most + recently inserted item will be replaced. + + \sa insert() +*/ + +/*! + \fn bool Q3PtrDict::remove( void *key ) + + Removes the item associated with \a key from the dictionary. + Returns TRUE if successful, i.e. if \a key is in the dictionary; + otherwise returns FALSE. + + If there are two or more items with equal keys, then the most + recently inserted item will be removed. + + The removed item is deleted if \link + Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. + + All dictionary iterators that refer to the removed item will be + set to point to the next item in the dictionary traversal order. + + \sa take(), clear(), setAutoDelete() +*/ + +/*! + \fn type *Q3PtrDict::take( void *key ) + + Takes the item associated with \a key out of the dictionary + without deleting it (even if \link Q3PtrCollection::setAutoDelete() + auto-deletion\endlink is enabled). + + If there are two or more items with equal keys, then the most + recently inserted item will be removed. + + Returns a pointer to the item taken out, or 0 if the key does not + exist in the dictionary. + + All dictionary iterators that refer to the taken item will be set + to point to the next item in the dictionary traversal order. + + \sa remove(), clear(), setAutoDelete() +*/ + +/*! + \fn void Q3PtrDict::clear() + + Removes all items from the dictionary. + + The removed items are deleted if \link + Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. + + All dictionary iterators that access this dictionary will be + reset. + + \sa remove(), take(), setAutoDelete() +*/ + +/*! + \fn type *Q3PtrDict::find( void *key ) const + + Returns the item associated with \a key, or 0 if the key does not + exist in the dictionary. + + If there are two or more items with equal keys, then the most + recently inserted item will be found. + + Equivalent to operator[]. + + \sa operator[]() +*/ + +/*! + \fn type *Q3PtrDict::operator[]( void *key ) const + + Returns the item associated with \a key, or 0 if the key does not + exist in the dictionary. + + If there are two or more items with equal keys, then the most + recently inserted item will be found. + + Equivalent to the find() function. + + \sa find() +*/ + +/*! + \fn void Q3PtrDict::statistics() const + + Debugging-only function that prints out the dictionary + distribution using qDebug(). +*/ + +/*! + \fn QDataStream& Q3PtrDict::read( QDataStream &s, Q3PtrCollection::Item &item ) + + Reads a dictionary item from the stream \a s and returns a + reference to the stream. + + The default implementation sets \a item to 0. + + \sa write() +*/ + +/*! + \fn QDataStream& Q3PtrDict::write( QDataStream &s, Q3PtrCollection::Item item) const + + Writes a dictionary \a item to the stream \a s and returns a + reference to the stream. + + \sa read() +*/ + +/*! + \class Q3PtrDictIterator + \brief The Q3PtrDictIterator class provides an iterator for Q3PtrDict collections. + \compat + + Q3PtrDictIterator is implemented as a template class. Define a + template instance Q3PtrDictIterator\ to create a dictionary + iterator that operates on Q3PtrDict\ (dictionary of X*). + + Example: + \snippet doc/src/snippets/code/doc_src_q3ptrdict.qdoc 2 + In the example we insert some line edits into a dictionary, + associating a string with each. We then iterate over the + dictionary printing the associated strings. + + Multiple iterators may independently traverse the same dictionary. + A Q3PtrDict knows about all the iterators that are operating on the + dictionary. When an item is removed from the dictionary, Q3PtrDict + updates all iterators that refer the removed item to point to the + next item in the traversing order. + + \sa Q3PtrDict +*/ + +/*! + \fn Q3PtrDictIterator::Q3PtrDictIterator( const Q3PtrDict &dict ) + + Constructs an iterator for \a dict. The current iterator item is + set to point on the first item in the \a dict. +*/ + +/*! + \fn Q3PtrDictIterator::~Q3PtrDictIterator() + + Destroys the iterator. +*/ + +/*! + \fn uint Q3PtrDictIterator::count() const + + Returns the number of items in the dictionary this iterator + operates on. + + \sa isEmpty() +*/ + +/*! + \fn bool Q3PtrDictIterator::isEmpty() const + + Returns TRUE if the dictionary is empty; otherwise returns FALSE. + + \sa count() +*/ + +/*! + \fn type *Q3PtrDictIterator::toFirst() + + Sets the current iterator item to point to the first item in the + dictionary and returns a pointer to the item. If the dictionary is + empty, it sets the current item to 0 and returns 0. +*/ + +/*! + \fn Q3PtrDictIterator::operator type *() const + + Cast operator. Returns a pointer to the current iterator item. + Same as current(). +*/ + +/*! + \fn type *Q3PtrDictIterator::current() const + + Returns a pointer to the current iterator item's value. +*/ + +/*! + \fn void *Q3PtrDictIterator::currentKey() const + + Returns the current iterator item's key. +*/ + +/*! + \fn type *Q3PtrDictIterator::operator()() + + Makes the succeeding item current and returns the original current + item. + + If the current iterator item was the last item in the dictionary + or if it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3PtrDictIterator::operator++() + + Prefix ++ makes the succeeding item current and returns the new + current item. + + If the current iterator item was the last item in the dictionary + or if it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3PtrDictIterator::operator+=( uint jump ) + + Sets the current item to the item \a jump positions after the + current item and returns a pointer to that item. + + If that item is beyond the last item or if the dictionary is + empty, it sets the current item to 0 and returns 0. +*/ diff --git a/doc/src/classes/q3ptrlist.qdoc b/doc/src/classes/q3ptrlist.qdoc new file mode 100644 index 0000000..3000940 --- /dev/null +++ b/doc/src/classes/q3ptrlist.qdoc @@ -0,0 +1,1157 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3PtrList + \brief The Q3PtrList class is a template class that provides a list. + \compat + + Q3ValueList is an STL-compatible alternative to this class. + + Define a template instance Q3PtrList\ to create a list that + operates on pointers to X (X*). + + The list class is indexable and has a \link at() current + index\endlink and a \link current() current item\endlink. The + first item corresponds to index position 0. The current index is + -1 if the current item is 0. + + Items are inserted with prepend(), insert() or append(). Items are + removed with remove(), removeRef(), removeFirst() and + removeLast(). You can search for an item using find(), findNext(), + findRef() or findNextRef(). The list can be sorted with sort(). + You can count the number of occurrences of an item with contains() + or containsRef(). You can get a pointer to the current item with + current(), to an item at a particular index position in the list + with at() or to the first or last item with getFirst() and + getLast(). You can also iterate over the list with first(), + last(), next() and prev() (which all update current()). The list's + deletion property is set with setAutoDelete(). + + \target example + Example: + \snippet doc/src/snippets/code/doc_src_q3ptrlist.qdoc 0 + + The output is + \snippet doc/src/snippets/code/doc_src_q3ptrlist.qdoc 1 + + Q3PtrList has several member functions for traversing the list, but + using a Q3PtrListIterator can be more practical. Multiple list + iterators may traverse the same list, independently of each other + and of the current list item. + + In the example above we make the call setAutoDelete(true). + Enabling auto-deletion tells the list to delete items that are + removed. The default is to not delete items when they are removed + but this would cause a memory leak in the example because there + are no other references to the list items. + + When inserting an item into a list only the pointer is copied, not + the item itself, i.e. a shallow copy. It is possible to make the + list copy all of the item's data (deep copy) when an item is + inserted. insert(), inSort() and append() call the virtual + function Q3PtrCollection::newItem() for the item to be inserted. + Inherit a list and reimplement newItem() to have deep copies. + + When removing an item from a list, the virtual function + Q3PtrCollection::deleteItem() is called. Q3PtrList's default + implementation is to delete the item if auto-deletion is enabled. + + The virtual function compareItems() can be reimplemented to + compare two list items. This function is called from all list + functions that need to compare list items, for instance + remove(const type*). If you only want to deal with pointers, there + are functions that compare pointers instead, for instance + removeRef(const type*). These functions are somewhat faster than + those that call compareItems(). + + List items are stored as \c void* in an internal Q3LNode, which + also holds pointers to the next and previous list items. The + functions currentNode(), removeNode(), and takeNode() operate + directly on the Q3LNode, but they should be used with care. The + data component of the node is available through Q3LNode::getData(). + + The Q3StrList class is a list of \c char*. + It reimplements newItem(), deleteItem() and compareItems(). (But + see QStringList for a list of Unicode QStrings.) + + \sa Q3PtrListIterator +*/ + + +/*! + \fn Q3PtrList::Q3PtrList() + + Constructs an empty list. +*/ + +/*! + \fn Q3PtrList::Q3PtrList( const Q3PtrList &list ) + + Constructs a copy of \a list. + + Each item in \a list is \link append() appended\endlink to this + list. Only the pointers are copied (shallow copy). +*/ + +/*! + \fn Q3PtrList::~Q3PtrList() + + Removes all items from the list and destroys the list. + + All list iterators that access this list will be reset. + + \sa setAutoDelete() +*/ + +/*! + \fn Q3PtrList &Q3PtrList::operator=(const Q3PtrList &list) + + Assigns \a list to this list and returns a reference to this list. + + This list is first cleared and then each item in \a list is \link + append() appended\endlink to this list. Only the pointers are + copied (shallow copy) unless newItem() has been reimplemented. +*/ + +/*! + \fn bool Q3PtrList::operator==(const Q3PtrList &list ) const + + Compares this list with \a list. Returns TRUE if the lists contain + the same data; otherwise returns FALSE. +*/ + +/*! + \fn uint Q3PtrList::count() const + + Returns the number of items in the list. + + \sa isEmpty() +*/ + +/*! + \fn bool Q3PtrList::operator!=(const Q3PtrList &list ) const + + Compares this list with \a list. Returns TRUE if the lists contain + different data; otherwise returns FALSE. +*/ + + +/*! + \fn void Q3PtrList::sort() + + Sorts the list by the result of the virtual compareItems() + function. + + The heap sort algorithm is used for sorting. It sorts n items with + O(n*log n) comparisons. This is the asymptotic optimal solution of + the sorting problem. + + If the items in your list support operator<() and operator==(), + you might be better off with Q3SortedList because it implements the + compareItems() function for you using these two operators. + + \sa inSort() +*/ + +/*! + \fn bool Q3PtrList::isEmpty() const + + Returns TRUE if the list is empty; otherwise returns FALSE. + + \sa count() +*/ + +/*! + \fn bool Q3PtrList::insert( uint index, const type *item ) + + Inserts the \a item at position \a index in the list. + + Returns TRUE if successful, i.e. if \a index is in range; + otherwise returns FALSE. The valid range is 0 to count() + (inclusively). The item is appended if \a index == count(). + + The inserted item becomes the current list item. + + \a item must not be 0. + + \sa append(), current(), replace() +*/ + +/*! + \fn bool Q3PtrList::replace( uint index, const type *item ) + + Replaces the item at position \a index with the new \a item. + + Returns TRUE if successful, i.e. \a index is in the range 0 to + count()-1. + + \sa append(), current(), insert() +*/ + +/*! + \fn void Q3PtrList::inSort( const type *item ) + + Inserts the \a item at its sorted position in the list. + + The sort order depends on the virtual compareItems() function. All + items must be inserted with inSort() to maintain the sorting + order. + + The inserted item becomes the current list item. + + \a item must not be 0. + + \warning Using inSort() is slow. An alternative, especially if you + have lots of items, is to simply append() or insert() them and + then use sort(). inSort() takes up to O(n) compares. That means + inserting n items in your list will need O(n^2) compares whereas + sort() only needs O(n*log n) for the same task. So use inSort() + only if you already have a presorted list and want to insert just + a few additional items. + + \sa insert(), compareItems(), current(), sort() +*/ + +/*! + \fn void Q3PtrList::append( const type *item ) + + Inserts the \a item at the end of the list. + + The inserted item becomes the current list item. This is + equivalent to \c{insert( count(), item )}. + + \a item must not be 0. + + \sa insert(), current(), prepend() +*/ + +/*! + \fn void Q3PtrList::prepend( const type *item ) + + Inserts the \a item at the start of the list. + + The inserted item becomes the current list item. This is + equivalent to \c{insert( 0, item )}. + + \a item must not be 0. + + \sa append(), insert(), current() +*/ + +/*! + \fn bool Q3PtrList::remove( uint index ) + + Removes the item at position \a index in the list. + + Returns TRUE if successful, i.e. if \a index is in range; + otherwise returns FALSE. The valid range is \c{0..(count() - 1)} + inclusive. + + The removed item is deleted if \link setAutoDelete() + auto-deletion\endlink is enabled. + + The item after the removed item becomes the new current list item + if the removed item is not the last item in the list. If the last + item is removed, the new last item becomes the current item. + + All list iterators that refer to the removed item will be set to + point to the new current item. + + \sa take(), clear(), setAutoDelete(), current() removeRef() +*/ + +/*! + \fn bool Q3PtrList::remove() + + \overload + + Removes the current list item. + + Returns TRUE if successful, i.e. if the current item isn't 0; + otherwise returns FALSE. + + The removed item is deleted if \link setAutoDelete() + auto-deletion\endlink is enabled. + + The item after the removed item becomes the new current list item + if the removed item is not the last item in the list. If the last + item is removed, the new last item becomes the current item. The + current item is set to 0 if the list becomes empty. + + All list iterators that refer to the removed item will be set to + point to the new current item. + + \sa take(), clear(), setAutoDelete(), current() removeRef() +*/ + +/*! + \fn bool Q3PtrList::remove( const type *item ) + + \overload + + Removes the first occurrence of \a item from the list. + + Returns TRUE if successful, i.e. if \a item is in the list; + otherwise returns FALSE. + + The removed item is deleted if \link setAutoDelete() + auto-deletion\endlink is enabled. + + The compareItems() function is called when searching for the item + in the list. If compareItems() is not reimplemented, it is more + efficient to call removeRef(). + + If \a item is NULL then the current item is removed from the list. + + The item after the removed item becomes the new current list item + if the removed item is not the last item in the list. If the last + item is removed, the new last item becomes the current item. The + current item is set to 0 if the list becomes empty. + + All list iterators that refer to the removed item will be set to + point to the new current item. + + \sa removeRef(), take(), clear(), setAutoDelete(), compareItems(), + current() +*/ + +/*! + \fn bool Q3PtrList::removeRef( const type *item ) + + Removes the first occurrence of \a item from the list. + + Returns TRUE if successful, i.e. if \a item is in the list; + otherwise returns FALSE. + + The removed item is deleted if \link setAutoDelete() + auto-deletion\endlink is enabled. + + Equivalent to: + \snippet doc/src/snippets/code/doc_src_q3ptrlist.qdoc 2 + + The item after the removed item becomes the new current list item + if the removed item is not the last item in the list. If the last + item is removed, the new last item becomes the current item. The + current item is set to 0 if the list becomes empty. + + All list iterators that refer to the removed item will be set to + point to the new current item. + + \sa remove(), clear(), setAutoDelete(), current() +*/ + +/*! + \fn void Q3PtrList::removeNode( Q3LNode *node ) + + Removes the \a node from the list. + + This node must exist in the list, otherwise the program may crash. + + The removed item is deleted if \link setAutoDelete() + auto-deletion\endlink is enabled. + + The first item in the list will become the new current list item. + The current item is set to 0 if the list becomes empty. + + All list iterators that refer to the removed item will be set to + point to the item succeeding this item or to the preceding item if + the removed item was the last item. + + \warning Do not call this function unless you are an expert. + + \sa takeNode(), currentNode() remove() removeRef() +*/ + +/*! + \fn bool Q3PtrList::removeFirst() + + Removes the first item from the list. Returns TRUE if successful, + i.e. if the list isn't empty; otherwise returns FALSE. + + The removed item is deleted if \link setAutoDelete() + auto-deletion\endlink is enabled. + + The first item in the list becomes the new current list item. The + current item is set to 0 if the list becomes empty. + + All list iterators that refer to the removed item will be set to + point to the new current item. + + \sa removeLast(), setAutoDelete(), current() remove() +*/ + +/*! + \fn bool Q3PtrList::removeLast() + + Removes the last item from the list. Returns TRUE if successful, + i.e. if the list isn't empty; otherwise returns FALSE. + + The removed item is deleted if \link setAutoDelete() + auto-deletion\endlink is enabled. + + The last item in the list becomes the new current list item. The + current item is set to 0 if the list becomes empty. + + All list iterators that refer to the removed item will be set to + point to the new current item. + + \sa removeFirst(), setAutoDelete(), current() +*/ + +/*! + \fn type *Q3PtrList::take( uint index ) + + Takes the item at position \a index out of the list without + deleting it (even if \link setAutoDelete() auto-deletion\endlink + is enabled). + + Returns a pointer to the item taken out of the list, or 0 if the + index is out of range. The valid range is \c{0..(count() - 1)} + inclusive. + + The item after the removed item becomes the new current list item + if the removed item is not the last item in the list. If the last + item is removed, the new last item becomes the current item. The + current item is set to 0 if the list becomes empty. + + All list iterators that refer to the taken item will be set to + point to the new current item. + + \sa remove(), clear(), current() +*/ + +/*! + \fn type *Q3PtrList::take() + + \overload + + Takes the current item out of the list without deleting it (even + if \link setAutoDelete() auto-deletion\endlink is enabled). + + Returns a pointer to the item taken out of the list, or 0 if + the current item is 0. + + The item after the removed item becomes the new current list item + if the removed item is not the last item in the list. If the last + item is removed, the new last item becomes the current item. The + current item is set to 0 if the list becomes empty. + + All list iterators that refer to the taken item will be set to + point to the new current item. + + \sa remove(), clear(), current() +*/ + +/*! + \fn type *Q3PtrList::takeNode( Q3LNode *node ) + + Takes the \a node out of the list without deleting its item (even + if \link setAutoDelete() auto-deletion\endlink is enabled). + Returns a pointer to the item taken out of the list. + + This node must exist in the list, otherwise the program may crash. + + The first item in the list becomes the new current list item. + + All list iterators that refer to the taken item will be set to + point to the item succeeding this item or to the preceding item if + the taken item was the last item. + + \warning Do not call this function unless you are an expert. + + \sa removeNode(), currentNode() +*/ + +/*! + \fn void Q3PtrList::clear() + + Removes all items from the list. + + The removed items are deleted if \link setAutoDelete() + auto-deletion\endlink is enabled. + + All list iterators that access this list will be reset. + + \sa remove(), take(), setAutoDelete() +*/ + +/*! + \fn int Q3PtrList::find( const type *item ) + + Finds the first occurrence of \a item in the list. + + If the item is found, the list sets the current item to point to + the found item and returns the index of this item. If the item is + not found, the list sets the current item to 0, the current + index to -1, and returns -1. + + The compareItems() function is called when searching for the item + in the list. If compareItems() is not reimplemented, it is more + efficient to call findRef(). + + \sa findNext(), findRef(), compareItems(), current() +*/ + +/*! + \fn int Q3PtrList::findNext( const type *item ) + + Finds the next occurrence of \a item in the list, starting from + the current list item. + + If the item is found, the list sets the current item to point to + the found item and returns the index of this item. If the item is + not found, the list sets the current item to 0, the current + index to -1, and returns -1. + + The compareItems() function is called when searching for the item + in the list. If compareItems() is not reimplemented, it is more + efficient to call findNextRef(). + + \sa find(), findNextRef(), compareItems(), current() +*/ + +/*! + \fn int Q3PtrList::findRef( const type *item ) + + Finds the first occurrence of \a item in the list. + + If the item is found, the list sets the current item to point to + the found item and returns the index of this item. If the item is + not found, the list sets the current item to 0, the current + index to -1, and returns -1. + + Calling this function is much faster than find() because find() + compares \a item with each list item using compareItems(), whereas + this function only compares the pointers. + + \sa findNextRef(), find(), current() +*/ + +/*! + \fn int Q3PtrList::findNextRef( const type *item ) + + Finds the next occurrence of \a item in the list, starting from + the current list item. + + If the item is found, the list sets the current item to point to + the found item and returns the index of this item. If the item is + not found, the list sets the current item to 0, the current + index to -1, and returns -1. + + Calling this function is much faster than findNext() because + findNext() compares \a item with each list item using + compareItems(), whereas this function only compares the pointers. + + \sa findRef(), findNext(), current() +*/ + +/*! + \fn uint Q3PtrList::contains( const type *item ) const + + Returns the number of occurrences of \a item in the list. + + The compareItems() function is called when looking for the \a item + in the list. If compareItems() is not reimplemented, it is more + efficient to call containsRef(). + + This function does not affect the current list item. + + \sa containsRef(), compareItems() +*/ + +/*! + \fn uint Q3PtrList::containsRef( const type *item ) const + + Returns the number of occurrences of \a item in the list. + + Calling this function is much faster than contains() because + contains() compares \a item with each list item using + compareItems(), whereas his function only compares the pointers. + + This function does not affect the current list item. + + \sa contains() +*/ + +/*! + \fn type *Q3PtrList::at( uint index ) + + Returns a pointer to the item at position \a index in the list, or + 0 if the index is out of range. + + Sets the current list item to this item if \a index is valid. The + valid range is \c{0..(count() - 1)} inclusive. + + This function is very efficient. It starts scanning from the first + item, last item, or current item, whichever is closest to \a + index. + + \sa current() +*/ + +/*! + \fn int Q3PtrList::at() const + + \overload + + Returns the index of the current list item. The returned value is + -1 if the current item is 0. + + \sa current() +*/ + +/*! + \fn type *Q3PtrList::current() const + + Returns a pointer to the current list item. The current item may + be 0 (implies that the current index is -1). + + \sa at() +*/ + +/*! + \fn Q3LNode *Q3PtrList::currentNode() const + + Returns a pointer to the current list node. + + The node can be kept and removed later using removeNode(). The + advantage is that the item can be removed directly without + searching the list. + + \warning Do not call this function unless you are an expert. + + \sa removeNode(), takeNode(), current() +*/ + +/*! + \fn type *Q3PtrList::getFirst() const + + Returns a pointer to the first item in the list, or 0 if the list + is empty. + + This function does not affect the current list item. + + \sa first(), getLast() +*/ + +/*! + \fn type *Q3PtrList::getLast() const + + Returns a pointer to the last item in the list, or 0 if the list + is empty. + + This function does not affect the current list item. + + \sa last(), getFirst() +*/ + +/*! + \fn type *Q3PtrList::first() + + Returns a pointer to the first item in the list and makes this the + current list item; returns 0 if the list is empty. + + \sa getFirst(), last(), next(), prev(), current() +*/ + +/*! + \fn type *Q3PtrList::last() + + Returns a pointer to the last item in the list and makes this the + current list item; returns 0 if the list is empty. + + \sa getLast(), first(), next(), prev(), current() +*/ + +/*! + \fn type *Q3PtrList::next() + + Returns a pointer to the item succeeding the current item. Returns + 0 if the current item is 0 or equal to the last item. + + Makes the succeeding item current. If the current item before this + function call was the last item, the current item will be set to + 0. If the current item was 0, this function does nothing. + + \sa first(), last(), prev(), current() +*/ + +/*! + \fn type *Q3PtrList::prev() + + Returns a pointer to the item preceding the current item. Returns + 0 if the current item is 0 or equal to the first item. + + Makes the preceding item current. If the current item before this + function call was the first item, the current item will be set to + 0. If the current item was 0, this function does nothing. + + \sa first(), last(), next(), current() +*/ + +/*! + \fn void Q3PtrList::toVector( Q3GVector *vec ) const + + Stores all list items in the vector \a vec. + + The vector must be of the same item type, otherwise the result + will be undefined. +*/ + +/*! + \typedef Q3PtrList::iterator + + \internal +*/ + +/*! + \typedef Q3PtrList::Iterator + + \internal +*/ + +/*! + \typedef Q3PtrList::ConstIterator + + \internal +*/ + +/*! + \typedef Q3PtrList::const_iterator + + \internal +*/ + +/*! + \fn Q3PtrList::constBegin() const + + \internal +*/ + +/*! + \fn Q3PtrList::constEnd() const + + \internal +*/ + +/*! + \fn Q3PtrList::erase(Iterator) + + \internal +*/ + + +/***************************************************************************** + Q3PtrListIterator documentation + *****************************************************************************/ + +/*! + \class Q3PtrListIterator + \brief The Q3PtrListIterator class provides an iterator for + Q3PtrList collections. + \compat + + Define a template instance Q3PtrListIterator\ to create a list + iterator that operates on Q3PtrList\ (list of X*). + + The following example is similar to the + example in the Q3PtrList class documentation, + but it uses Q3PtrListIterator. The class Employee is + defined there. + + \snippet doc/src/snippets/code/doc_src_q3ptrlist.qdoc 3 + + The output is + \snippet doc/src/snippets/code/doc_src_q3ptrlist.qdoc 4 + + Using a list iterator is a more robust way of traversing the list + than using the Q3PtrList member functions \link Q3PtrList::first() + first\endlink(), \link Q3PtrList::next() next\endlink(), \link + Q3PtrList::current() current\endlink(), etc., as many iterators can + traverse the same list independently. + + An iterator has its own current list item and can get the next and + previous list items. It doesn't modify the list in any way. + + When an item is removed from the list, all iterators that point to + that item are updated to point to Q3PtrList::current() instead to + avoid dangling references. + + \sa Q3PtrList +*/ + +/*! + \fn Q3PtrListIterator::Q3PtrListIterator( const Q3PtrList &list ) + + Constructs an iterator for \a list. The current iterator item is + set to point on the first item in the \a list. +*/ + +/*! + \fn Q3PtrListIterator::~Q3PtrListIterator() + + Destroys the iterator. +*/ + +/*! + \fn uint Q3PtrListIterator::count() const + + Returns the number of items in the list this iterator operates on. + + \sa isEmpty() +*/ + +/*! + \fn bool Q3PtrListIterator::isEmpty() const + + Returns TRUE if the list is empty; otherwise returns FALSE. + + \sa count() +*/ + +/*! + \fn bool Q3PtrListIterator::atFirst() const + + Returns TRUE if the current iterator item is the first list item; + otherwise returns FALSE. + + \sa toFirst(), atLast() +*/ + +/*! + \fn bool Q3PtrListIterator::atLast() const + + Returns TRUE if the current iterator item is the last list item; + otherwise returns FALSE. + + \sa toLast(), atFirst() +*/ + +/*! + \fn type *Q3PtrListIterator::toFirst() + + Sets the current iterator item to point to the first list item and + returns a pointer to the item. Sets the current item to 0 and + returns 0 if the list is empty. + + \sa toLast(), atFirst() +*/ + +/*! + \fn type *Q3PtrListIterator::toLast() + + Sets the current iterator item to point to the last list item and + returns a pointer to the item. Sets the current item to 0 and + returns 0 if the list is empty. + + \sa toFirst(), atLast() +*/ + +/*! + \fn Q3PtrListIterator::operator type *() const + + Cast operator. Returns a pointer to the current iterator item. + Same as current(). +*/ + +/*! + \fn type *Q3PtrListIterator::operator*() + + Asterisk operator. Returns a pointer to the current iterator item. + Same as current(). +*/ + +/*! + \fn type *Q3PtrListIterator::current() const + + Returns a pointer to the current iterator item. If the iterator is + positioned before the first item in the list or after the last + item in the list, 0 is returned. +*/ + +/*! + \fn type *Q3PtrListIterator::operator()() + + Makes the succeeding item current and returns the original current + item. + + If the current iterator item was the last item in the list or if + it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3PtrListIterator::operator++() + + Prefix ++ makes the succeeding item current and returns the new + current item. + + If the current iterator item was the last item in the list or if + it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3PtrListIterator::operator+=( uint jump ) + + Sets the current item to the item \a jump positions after the + current item and returns a pointer to that item. + + If that item is beyond the last item or if the list is empty, it + sets the current item to 0 and returns 0 +*/ + +/*! + \fn type *Q3PtrListIterator::operator--() + + Prefix - makes the preceding item current and returns the new + current item. + + If the current iterator item was the first item in the list or if + it was 0, 0 is returned. +*/ + +/*! + \fn type *Q3PtrListIterator::operator-=( uint jump ) + + Returns the item \a jump positions before the current item or 0 + if it is beyond the first item. Makes this the current item. +*/ + +/*! + \fn Q3PtrListIterator& Q3PtrListIterator::operator=( const Q3PtrListIterator &it ) + + Assignment. Makes a copy of the iterator \a it and returns a + reference to this iterator. +*/ + +/*! + \class Q3StrList + \brief The Q3StrList class provides a doubly-linked list of char*. + \compat + + If you want a string list of \l{QString}s use QStringList. + + This class is a Q3PtrList\ instance (a list of char*). + + Q3StrList can make deep or shallow copies of the strings that are + inserted. + + A deep copy means that memory is allocated for the string and then + the string data is copied into that memory. A shallow copy is just + a copy of the pointer value and not of the string data itself. + + The disadvantage of shallow copies is that because a pointer can + be deleted only once, the program must put all strings in a + central place and know when it is safe to delete them (i.e. when + the strings are no longer referenced by other parts of the + program). This can make the program more complex. The advantage of + shallow copies is that they consume far less memory than deep + copies. It is also much faster to copy a pointer (typically 4 or 8 + bytes) than to copy string data. + + A Q3StrList that operates on deep copies will, by default, turn on + auto-deletion (see setAutoDelete()). Thus, by default Q3StrList + will deallocate any string copies it allocates. + + The virtual compareItems() function is reimplemented and does a + case-sensitive string comparison. The inSort() function will + insert strings in sorted order. In general it is fastest to insert + the strings as they come and sort() at the end; inSort() is useful + when you just have to add a few extra strings to an already sorted + list. + + The Q3StrListIterator class is an iterator for Q3StrList. +*/ + +/*! + \fn Q3StrList::operator QList() const + + Automatically converts a Q3StrList into a QList. +*/ + +/*! + \fn Q3StrList::Q3StrList( bool deepCopies ) + + Constructs an empty list of strings. Will make deep copies of all + inserted strings if \a deepCopies is TRUE, or use shallow copies + if \a deepCopies is FALSE. +*/ + +/*! + \fn Q3StrList::Q3StrList(const Q3StrList &list) + \fn Q3StrList::Q3StrList(const QList &list) + + Constructs a copy of \a list. +*/ + +/*! + \fn Q3StrList::~Q3StrList() + + Destroys the list. All strings are removed. +*/ + +/*! + \fn Q3StrList& Q3StrList::operator=(const Q3StrList& list) + \fn Q3StrList &Q3StrList::operator=(const QList &list) + + Assigns \a list to this list and returns a reference to this list. +*/ + +/*! + \class Q3StrIList + \brief The Q3StrIList class provides a doubly-linked list of char* + with case-insensitive comparison. + \compat + + This class is a Q3PtrList\ instance (a list of char*). + + Q3StrIList is identical to Q3StrList except that the virtual + compareItems() function is reimplemented to compare strings + case-insensitively. The inSort() function inserts strings in a + sorted order. In general it is fastest to insert the strings as + they come and sort() at the end; inSort() is useful when you just + have to add a few extra strings to an already sorted list. + + The Q3StrListIterator class works for Q3StrIList. + + \sa QStringList +*/ + +/*! + \fn Q3StrIList::Q3StrIList( bool deepCopies ) + + Constructs a list of strings. Will make deep copies of all + inserted strings if \a deepCopies is TRUE, or use shallow copies + if \a deepCopies is FALSE. +*/ + +/*! + \fn Q3StrIList::~Q3StrIList() + + Destroys the list. All strings are removed. +*/ + +/*! + \fn int Q3PtrList::compareItems( Q3PtrCollection::Item item1, + Q3PtrCollection::Item item2 ) + + This virtual function compares two list items. + + Returns: + \list + \i zero if \a item1 == \a item2 + \i nonzero if \a item1 != \a item2 + \endlist + + This function returns \e int rather than \e bool so that + reimplementations can return three values and use it to sort by: + + \list + \i 0 if \a item1 == \a item2 + \i \> 0 (positive integer) if \a item1 \> \a item2 + \i \< 0 (negative integer) if \a item1 \< \a item2 + \endlist + + inSort() requires that compareItems() is implemented as described + here. + + This function should not modify the list because some const + functions call compareItems(). + + The default implementation compares the pointers. +*/ + +/*! + \fn QDataStream& Q3PtrList::read( QDataStream& s, + Q3PtrCollection::Item& item ) + + Reads a list item from the stream \a s and returns a reference to + the stream. + + The default implementation sets \a item to 0. + + \sa write() +*/ + +/*! + \fn QDataStream& Q3PtrList::write( QDataStream& s, + Q3PtrCollection::Item item ) const + + Writes a list item, \a item to the stream \a s and returns a + reference to the stream. + + The default implementation does nothing. + + \sa read() +*/ + +/*! \fn iterator Q3PtrList::begin() +\internal +*/ +/*! \fn const_iterator Q3PtrList::begin() const +\internal +*/ +/*! \fn iterator Q3PtrList::end() +\internal +*/ +/*! \fn const_iterator Q3PtrList::end() const +\internal +*/ + +/*! + \class Q3StrListIterator + \brief The Q3StrListIterator class is an iterator for the Q3StrList + and Q3StrIList classes. + \compat + + This class is a Q3PtrListIterator\ instance. It can traverse + the strings in the Q3StrList and Q3StrIList classes. +*/ + + +/* + \class Q3PtrListAutoDelete + \brief The Q3PtrListAutoDelete class is a template class that provides a list that auto-deletes its data. + \compat + + A Q3PtrListAutoDelete is identical to a Q3PtrList with + setAutoDelete(TRUE). +*/ diff --git a/doc/src/classes/q3ptrqueue.qdoc b/doc/src/classes/q3ptrqueue.qdoc new file mode 100644 index 0000000..b3af5f6 --- /dev/null +++ b/doc/src/classes/q3ptrqueue.qdoc @@ -0,0 +1,230 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3PtrQueue + \brief The Q3PtrQueue class is a template class that provides a queue. + \compat + + Q3ValueVector can be used as an STL-compatible alternative to this + class. + + A template instance Q3PtrQueue\ is a queue that operates on + pointers to X (X*). + + A queue is a first in, first out structure. Items are added to the + tail of the queue with enqueue() and retrieved from the head with + dequeue(). You can peek at the head item without dequeing it using + head(). + + You can control the queue's deletion policy with setAutoDelete(). + + For compatibility with the Q3PtrCollection classes, current() and + remove() are provided; both operate on the head(). + + \sa Q3PtrList Q3PtrStack +*/ + +/*! + \fn Q3PtrQueue::Q3PtrQueue () + + Creates an empty queue with autoDelete() set to FALSE. +*/ + +/*! + \fn Q3PtrQueue::Q3PtrQueue( const Q3PtrQueue& queue ) + + Creates a queue from \a queue. + + Only the pointers are copied; the items are not. The autoDelete() + flag is set to FALSE. +*/ + +/*! + \fn Q3PtrQueue::~Q3PtrQueue() + + Destroys the queue. Items in the queue are deleted if autoDelete() + is TRUE. +*/ + +/*! + \fn Q3PtrQueue& Q3PtrQueue::operator= (const Q3PtrQueue& queue) + + Assigns \a queue to this queue and returns a reference to this + queue. + + This queue is first cleared and then each item in \a queue is + enqueued to this queue. Only the pointers are copied. + + \warning The autoDelete() flag is not modified. If it is TRUE for + both \a queue and this queue, deleting the two lists will cause \e + double-deletion of the items. +*/ + +/*! + \fn bool Q3PtrQueue::isEmpty() const + + Returns TRUE if the queue is empty; otherwise returns FALSE. + + \sa count() dequeue() head() +*/ + +/*! + \fn void Q3PtrQueue::enqueue (const type* d) + + Adds item \a d to the tail of the queue. + + \sa count() dequeue() +*/ + +/*! + \fn type* Q3PtrQueue::dequeue () + + Takes the head item from the queue and returns a pointer to it. + Returns 0 if the queue is empty. + + \sa enqueue() count() +*/ + +/*! + \fn bool Q3PtrQueue::remove() + + Removes the head item from the queue, and returns TRUE if there + was an item, i.e. the queue wasn't empty; otherwise returns FALSE. + + The item is deleted if autoDelete() is TRUE. + + \sa head() isEmpty() dequeue() +*/ + +/*! + \fn void Q3PtrQueue::clear() + + Removes all items from the queue, and deletes them if autoDelete() + is TRUE. + + \sa remove() +*/ + +/*! + \fn uint Q3PtrQueue::count() const + + Returns the number of items in the queue. + + \sa isEmpty() +*/ + +/*! + \fn type* Q3PtrQueue::head() const + + Returns a pointer to the head item in the queue. The queue is not + changed. Returns 0 if the queue is empty. + + \sa dequeue() isEmpty() +*/ + +/*! + \fn Q3PtrQueue::operator type*() const + + Returns a pointer to the head item in the queue. The queue is not + changed. Returns 0 if the queue is empty. + + \sa dequeue() isEmpty() +*/ + +/*! + \fn type* Q3PtrQueue::current() const + + Returns a pointer to the head item in the queue. The queue is not + changed. Returns 0 if the queue is empty. + + \sa dequeue() isEmpty() +*/ + +/*! + \fn bool Q3PtrQueue::autoDelete() const + + Returns the setting of the auto-delete option. The default is + FALSE. + + \sa setAutoDelete() +*/ + +/*! + \fn void Q3PtrQueue::setAutoDelete( bool enable ) + + Sets the queue to auto-delete its contents if \a enable is TRUE + and not to delete them if \a enable is FALSE. + + If auto-deleting is turned on, all the items in a queue are + deleted when the queue itself is deleted. This can be quite + convenient if the queue has the only pointer to the items. + + The default setting is FALSE, for safety. If you turn it on, be + careful about copying the queue: you might find yourself with two + queues deleting the same items. + + \sa autoDelete() +*/ + +/*! + \fn QDataStream& Q3PtrQueue::read( QDataStream& s, + Q3PtrCollection::Item& item ) + + Reads a queue item, \a item, from the stream \a s and returns a + reference to the stream. + + The default implementation sets \a item to 0. + + \sa write() +*/ + +/*! + \fn QDataStream& Q3PtrQueue::write( QDataStream& s, + Q3PtrCollection::Item item ) const + + Writes a queue item, \a item, to the stream \a s and returns a + reference to the stream. + + The default implementation does nothing. + + \sa read() +*/ diff --git a/doc/src/classes/q3ptrstack.qdoc b/doc/src/classes/q3ptrstack.qdoc new file mode 100644 index 0000000..1650d69 --- /dev/null +++ b/doc/src/classes/q3ptrstack.qdoc @@ -0,0 +1,217 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3PtrStack + \brief The Q3PtrStack class is a template class that provides a stack. + \compat + + Q3ValueStack is an STL-compatible alternative to this class. + + Define a template instance Q3PtrStack\ to create a stack that + operates on pointers to X, (X*). + + A stack is a last in, first out (LIFO) structure. Items are added + to the top of the stack with push() and retrieved from the top + with pop(). Use top() to get a reference to the top element + without changing the stack. + + You can control the stack's deletion policy with setAutoDelete(). + + For compatibility with the Q3PtrCollection classes current() and + remove() are provided; they both operate on the top(). + + \sa Q3PtrList Q3PtrQueue +*/ + +/*! + \fn Q3PtrStack::Q3PtrStack () + + Creates an empty stack. +*/ + +/*! + \fn Q3PtrStack::Q3PtrStack (const Q3PtrStack& s) + + Creates a stack by making a shallow copy of another stack \a s. +*/ + +/*! + \fn Q3PtrStack::~Q3PtrStack () + + Destroys the stack. All items will be deleted if autoDelete() is + true. +*/ + +/*! + \fn Q3PtrStack& Q3PtrStack::operator= (const Q3PtrStack& s) + + Sets the contents of this stack by making a shallow copy of + another stack \a s. Elements currently in this stack will be + deleted if autoDelete() is true. +*/ + +/*! + \fn bool Q3PtrStack::isEmpty () const + + Returns true if the stack contains no elements; otherwise returns + false. +*/ + +/*! + \fn void Q3PtrStack::push (const type* d) + + Adds an element \a d to the top of the stack. Last in, first out. +*/ + +/*! + \fn type* Q3PtrStack::pop () + + Removes the top item from the stack and returns it. The stack must + not be empty. +*/ + +/*! + \fn bool Q3PtrStack::remove () + + Removes the top item from the stack and deletes it if autoDelete() + is true. Returns true if there was an item to pop; otherwise + returns false. + + \sa clear() +*/ + +/*! + \fn void Q3PtrStack::clear() + + Removes all items from the stack, deleting them if autoDelete() is + true. + + \sa remove() +*/ + +/*! + \fn uint Q3PtrStack::count() const + + Returns the number of items in the stack. + + \sa isEmpty() +*/ + +/*! + \fn type* Q3PtrStack::top () const + + Returns a pointer to the top item on the stack (most recently + pushed). The stack is not changed. Returns 0 if the stack is + empty. +*/ + +/*! + \fn Q3PtrStack::operator type* ()const + + Returns a pointer to the top item on the stack (most recently + pushed). The stack is not changed. Returns 0 if the stack is + empty. +*/ + +/*! + \fn type* Q3PtrStack::current () const + + Returns a pointer to the top item on the stack (most recently + pushed). The stack is not changed. Returns 0 if the stack is + empty. +*/ + +/*! + \fn bool Q3PtrStack::autoDelete() const + + The same as Q3PtrCollection::autoDelete(). Returns true if + the auto-delete option is set. If the option is set, the + stack auto-deletes its contents. + + \sa setAutoDelete() +*/ + +/*! + \fn void Q3PtrStack::setAutoDelete(bool enable) + + Defines whether this stack auto-deletes its contents. The same as + Q3PtrCollection::setAutoDelete(). If \a enable is true, auto-delete + is turned on. + + If auto-deleting is turned on, all the items in the stack are + deleted when the stack itself is deleted. This is convenient if + the stack has the only pointers to the items. + + The default setting is false, for safety. If you turn it on, be + careful about copying the stack, or you might find yourself with + two stacks deleting the same items. + + Note that the auto-delete setting may also affect other functions in + subclasses. For example, a subclass that has a remove() function + will remove the item from its data structure, and if auto-delete is + enabled, will also delete the item. + + \sa autoDelete() +*/ + +/*! + \fn QDataStream& Q3PtrStack::read(QDataStream& s, Q3PtrCollection::Item& item) + + Reads a stack item, \a item, from the stream \a s and returns a + reference to the stream. + + The default implementation sets \a item to 0. + + \sa write() +*/ + +/*! + \fn QDataStream& Q3PtrStack::write(QDataStream& s, + Q3PtrCollection::Item item) const + + Writes a stack item, \a item, to the stream \a s and returns a + reference to the stream. + + The default implementation does nothing. + + \sa read() +*/ diff --git a/doc/src/classes/q3ptrvector.qdoc b/doc/src/classes/q3ptrvector.qdoc new file mode 100644 index 0000000..fa78de5 --- /dev/null +++ b/doc/src/classes/q3ptrvector.qdoc @@ -0,0 +1,427 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3PtrVector + \brief The Q3PtrVector class is a template collection class that + provides a vector (array). + \compat + + Q3ValueVector is an STL-compatible alternative to this class. + + Q3PtrVector is implemented as a template class. Defines a template + instance Q3PtrVector\ to create a vector that contains pointers + to X (X*). + + A vector is the same as an array. The main difference between + Q3PtrVector and Q3MemArray is that Q3PtrVector stores pointers to the + elements, whereas Q3MemArray stores the elements themselves (i.e. + Q3MemArray is value-based and Q3PtrVector is pointer-based). + + Items are added to the vector using insert() or fill(). Items are + removed with remove(). You can get a pointer to an item at a + particular index position using at(). + + Unless otherwise stated, all functions that remove items from the + vector will also delete the element pointed to if \link + setAutoDelete() auto-deletion\endlink is enabled. By default, + auto-deletion is disabled; see setAutoDelete(). This behavior can + be changed in a subclass by reimplementing the virtual function + deleteItem(). + + Functions that compare items (find() and sort() for example) will + do so using the virtual function compareItems(). The default + implementation of this function only compares the pointer values. + Reimplement compareItems() in a subclass to get searching and + sorting based on the item contents. You can perform a linear + search for a pointer in the vector using findRef(), or a binary + search (of a sorted vector) using bsearch(). You can count the + number of times an item appears in the vector with contains() or + containsRef(). + + \sa Q3MemArray +*/ + +/*! + \fn Q3PtrVector::Q3PtrVector() + + Constructs a null vector. + + \sa isNull() +*/ + +/*! + \fn Q3PtrVector::Q3PtrVector(uint size) + + Constructs an vector with room for \a size items. Makes a null + vector if \a size == 0. + + All \a size positions in the vector are initialized to 0. + + \sa size(), resize(), isNull() +*/ + +/*! + \fn Q3PtrVector::Q3PtrVector(const Q3PtrVector &v) + + Constructs a copy of \a v. Only the pointers are copied (i.e. + shallow copy). +*/ + +/*! + \fn Q3PtrVector::~Q3PtrVector() + + Removes all items from the vector, and destroys the vector itself. + + \sa clear() +*/ + +/*! + \fn Q3PtrVector &Q3PtrVector::operator=(const Q3PtrVector &v) + + Assigns \a v to this vector and returns a reference to this + vector. + + This vector is first cleared and then all the items from \a v are + copied into the vector. Only the pointers are copied (i.e. shallow + copy). + + \sa clear() +*/ + +/*! + \fn type **Q3PtrVector::data() const + + Returns a pointer to the actual vector data, which is an array of + type*. + + The vector is a null vector if data() == 0 (null pointer). + + \sa isNull() +*/ + +/*! + \fn uint Q3PtrVector::size() const + + Returns the size of the vector, i.e. the number of vector + positions. This is also the maximum number of items the vector can + hold. + + The vector is a null vector if size() == 0. + + \sa isNull(), resize(), count() +*/ + +/*! + \fn uint Q3PtrVector::count() const + + Returns the number of items in the vector. The vector is empty if + count() == 0. + + \sa isEmpty(), size(), isNull() +*/ + +/*! + \fn bool Q3PtrVector::isEmpty() const + + Returns true if the vector is empty; otherwise returns false. + + \sa count() +*/ + +/*! + \fn bool Q3PtrVector::isNull() const + + Returns true if the vector is null; otherwise returns false. + + A null vector has size() == 0 and data() == 0. + + \sa size() +*/ + +/*! + \fn bool Q3PtrVector::resize(uint size) + + Resizes (expands or shrinks) the vector to \a size elements. The + vector becomes a null vector if \a size == 0. + + Any items at position \a size or beyond in the vector are removed. + New positions are initialized to 0. + + Returns true if successful, i.e. if the memory was successfully + allocated; otherwise returns false. + + \sa size(), isNull() +*/ + +/*! + \fn bool Q3PtrVector::insert(uint i, const type *d) + + Sets position \a i in the vector to contain the item \a d. \a i + must be less than size(). Any previous element in position \a i is + removed. + + Returns true if \a i is within range; otherwise returns false. + + \sa at() +*/ + +/*! + \fn bool Q3PtrVector::remove(uint i) + + Removes the item at position \a i in the vector, if there is one. + \a i must be less than size(). + + Returns true if \a i is within range; otherwise returns false. + + \sa take(), at() +*/ + +/*! + \fn type* Q3PtrVector::take(uint i) + + Returns the item at position \a i in the vector, and removes that + item from the vector. \a i must be less than size(). If there is + no item at position \a i, 0 is returned. + + Unlike remove(), this function does \e not call deleteItem() for + the removed item. + + \sa remove(), at() +*/ + +/*! + \fn void Q3PtrVector::clear() + + Removes all items from the vector, and destroys the vector itself. + + The vector becomes a null vector. + + \sa isNull() +*/ + +/*! + \fn bool Q3PtrVector::fill(const type *d, int size) + + Inserts item \a d in all positions in the vector. Any existing + items are removed. If \a d is 0, the vector becomes empty. + + If \a size >= 0, the vector is first resized to \a size. By + default, \a size is -1. + + Returns true if successful, i.e. \a size is the same as the + current size, or \a size is larger and the memory has successfully + been allocated; otherwise returns false. + + \sa resize(), insert(), isEmpty() +*/ + +/*! + \fn void Q3PtrVector::sort() + + Sorts the items in ascending order. Any empty positions will be + put last. + + Compares items using the virtual function compareItems(). + + \sa bsearch() +*/ + +/*! + \fn int Q3PtrVector::bsearch(const type* d) const + + In a sorted array, finds the first occurrence of \a d using a + binary search. For a sorted array, this is generally much faster + than find(), which performs a linear search. + + Returns the position of \a d, or -1 if \a d could not be found. \a + d must not be 0. + + Compares items using the virtual function compareItems(). + + \sa sort(), find() +*/ + + +/*! + \fn int Q3PtrVector::findRef(const type *d, uint i) const + + Finds the first occurrence of the item pointer \a d in the vector + using a linear search. The search starts at position \a i, which + must be less than size(). \a i is by default 0; i.e. the search + starts at the start of the vector. + + Returns the position of \a d, or -1 if \a d could not be found. + + This function does \e not use compareItems() to compare items. + + Use the much faster bsearch() to search a sorted vector. + + \sa find(), bsearch() +*/ + +/*! + \fn int Q3PtrVector::find(const type *d, uint i) const + + Finds the first occurrence of item \a d in the vector using a + linear search. The search starts at position \a i, which must be + less than size(). \a i is by default 0; i.e. the search starts at + the start of the vector. + + Returns the position of \a d, or -1 if \a d could not be found. + + Compares items using the virtual function compareItems(). + + Use the much faster bsearch() to search a sorted vector. + + \sa findRef(), bsearch() +*/ + + +/*! + \fn uint Q3PtrVector::containsRef(const type *d) const + + Returns the number of occurrences of the item pointer \a d in the + vector. + + This function does \e not use compareItems() to compare items. + + \sa findRef() +*/ + +/*! + \fn uint Q3PtrVector::contains(const type *d) const + + Returns the number of occurrences of item \a d in the vector. + + Compares items using the virtual function compareItems(). + + \sa containsRef() +*/ + +/*! + \fn type *Q3PtrVector::operator[](int i) const + + Returns the item at position \a i, or 0 if there is no item at + that position. \a i must be less than size(). + + Equivalent to at(\a i). + + \sa at() +*/ + +/*! + \fn type *Q3PtrVector::at(uint i) const + + Returns the item at position \a i, or 0 if there is no item at + that position. \a i must be less than size(). +*/ + + +/*! + \fn void Q3PtrVector::toList(Q3GList *list) const + + \internal + + Copies all items in this vector to the list \a list. \a list is + first cleared and then all items are appended to \a list. + + \sa Q3PtrList, Q3PtrStack, Q3PtrQueue +*/ + +/*! + \fn int Q3PtrVector::compareItems(Q3PtrCollection::Item d1, + Q3PtrCollection::Item d2) + + This virtual function compares two list items. + + Returns: + \list + \i zero if \a d1 == \a d2 + \i nonzero if \a d1 != \a d2 + \endlist + + This function returns \e int rather than \e bool so that + reimplementations can return one of three values and use it to + sort by: + \list + \i 0 if \a d1 == \a d2 + \i \> 0 (positive integer) if \a d1 \> \a d2 + \i \< 0 (negative integer) if \a d1 \< \a d2 + \endlist + + The sort() and bsearch() functions require compareItems() to be + implemented as described here. + + This function should not modify the vector because some const + functions call compareItems(). +*/ + +/*! + \fn QDataStream& Q3PtrVector::read(QDataStream &s, + Q3PtrCollection::Item &item) + + Reads a vector item, \a item, from the stream \a s and returns a + reference to the stream. + + The default implementation sets \a item to 0. + + \sa write() +*/ + +/*! + \fn QDataStream& Q3PtrVector::write(QDataStream &s, + Q3PtrCollection::Item item) const + + Writes a vector item, \a item, to the stream \a s and returns a + reference to the stream. + + The default implementation does nothing. + + \sa read() +*/ + +/*! + \fn bool Q3PtrVector::operator==(const Q3PtrVector &v) const + + Returns true if this vector and \a v are equal; otherwise returns + false. +*/ diff --git a/doc/src/classes/q3sqlfieldinfo.qdoc b/doc/src/classes/q3sqlfieldinfo.qdoc new file mode 100644 index 0000000..ba064f3 --- /dev/null +++ b/doc/src/classes/q3sqlfieldinfo.qdoc @@ -0,0 +1,234 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3SqlFieldInfo + \brief The Q3SqlFieldInfo class stores meta data associated with a SQL field. + + \compat + + Q3SqlFieldInfo objects only store meta data; field values are + stored in QSqlField objects. + + All values must be set in the constructor, and may be retrieved + using isRequired(), type(), length(), precision(), defaultValue(), + name(), isGenerated() and typeID(). + + \sa Q3SqlRecordInfo +*/ + +/*! + \fn Q3SqlFieldInfo::Q3SqlFieldInfo(const QString& name, + QVariant::Type typ, + int required, + int len, + int prec, + const QVariant& defValue, + int typeID, + bool generated, + bool trim, + bool calculated) + + Constructs a Q3SqlFieldInfo with the following parameters: + \table + \row \i \a name \i the name of the field. + \row \i \a typ \i the field's type in a QVariant. + \row \i \a required \i greater than 0 if the field is required, 0 + if its value can be NULL and less than 0 if it cannot be + determined whether the field is required or not. + \row \i \a len \i the length of the field. Note that for + non-character types some databases return either the length in + bytes or the number of digits. -1 signifies that the length cannot + be determined. + \row \i \a prec \i the precision of the field, or -1 if the field + has no precision or it cannot be determined. + \row \i \a defValue \i the default value that is inserted into + the table if none is specified by the user. QVariant() if there is + no default value or it cannot be determined. + \row \i \a typeID \i the internal typeID of the database system + (only useful for low-level programming). 0 if unknown. + \row \i \a generated \i TRUE indicates that this field should be + included in auto-generated SQL statments, e.g. in Q3SqlCursor. + \row \i \a trim \i TRUE indicates that widgets should remove + trailing whitespace from character fields. This does not affect + the field value but only its representation inside widgets. + \row \i \a calculated \i TRUE indicates that the value of this + field is calculated. The value of calculated fields can by + modified by subclassing Q3SqlCursor and overriding + Q3SqlCursor::calculateField(). + \endtable +*/ + +/*! + \fn Q3SqlFieldInfo::~Q3SqlFieldInfo() + + Destroys the object and frees any allocated resources. +*/ + +/*! + \fn Q3SqlFieldInfo::Q3SqlFieldInfo(const QSqlField & other) + + Creates a Q3SqlFieldInfo object with the type and the name of the + QSqlField \a other. +*/ + +/*! + \fn bool Q3SqlFieldInfo::operator==(const Q3SqlFieldInfo& other) const + + Assigns \a other to this field info and returns a reference to it. +*/ + +/*! + \fn QSqlField Q3SqlFieldInfo::toField() const + + Returns an empty QSqlField based on the information in this + Q3SqlFieldInfo. +*/ + +/*! + \fn int Q3SqlFieldInfo::isRequired() const + + Returns a value greater than 0 if the field is required (NULL + values are not allowed), 0 if it isn't required (NULL values are + allowed) or less than 0 if it cannot be determined whether the + field is required or not. +*/ + +/*! + \fn QVariant::Type Q3SqlFieldInfo::type() const + + Returns the field's type or QVariant::Invalid if the type is + unknown. +*/ + +/*! + \fn int Q3SqlFieldInfo::length() const + + Returns the field's length. For fields storing text the return + value is the maximum number of characters the field can hold. For + non-character fields some database systems return the number of + bytes needed or the number of digits allowed. If the length cannot + be determined -1 is returned. +*/ + +/*! + \fn int Q3SqlFieldInfo::precision() const + + Returns the field's precision or -1 if the field has no precision + or it cannot be determined. +*/ + +/*! + \fn QVariant Q3SqlFieldInfo::defaultValue() const + + Returns the field's default value or an empty QVariant if the + field has no default value or the value couldn't be determined. + The default value is the value inserted in the database when it + is not explicitly specified by the user. +*/ + +/*! + \fn QString Q3SqlFieldInfo::name() const + + Returns the name of the field in the SQL table. +*/ + +/*! + \fn int Q3SqlFieldInfo::typeID() const + + Returns the internal type identifier as returned from the database + system. The return value is 0 if the type is unknown. +*/ + +/*! + \fn bool Q3SqlFieldInfo::isGenerated() const + + Returns TRUE if the field should be included in auto-generated + SQL statments, e.g. in Q3SqlCursor; otherwise returns FALSE. + + \sa setGenerated() +*/ + +/*! + \fn bool Q3SqlFieldInfo::isTrim() const + + Returns TRUE if trailing whitespace should be removed from + character fields; otherwise returns FALSE. + + \sa setTrim() +*/ + +/*! + \fn bool Q3SqlFieldInfo::isCalculated() const + + Returns TRUE if the field is calculated; otherwise returns FALSE. + + \sa setCalculated() +*/ + +/*! + \fn void Q3SqlFieldInfo::setTrim(bool trim) + + If \a trim is TRUE widgets should remove trailing whitespace from + character fields. This does not affect the field value but only + its representation inside widgets. + + \sa isTrim() +*/ + +/*! + \fn void Q3SqlFieldInfo::setGenerated(bool generated) + + \a generated set to FALSE indicates that this field should not appear + in auto-generated SQL statements (for example in Q3SqlCursor). + + \sa isGenerated() +*/ + +/*! + \fn void Q3SqlFieldInfo::setCalculated(bool calculated) + + \a calculated set to TRUE indicates that this field is a calculated + field. The value of calculated fields can by modified by subclassing + Q3SqlCursor and overriding Q3SqlCursor::calculateField(). + + \sa isCalculated() +*/ diff --git a/doc/src/classes/q3sqlrecordinfo.qdoc b/doc/src/classes/q3sqlrecordinfo.qdoc new file mode 100644 index 0000000..64236d2 --- /dev/null +++ b/doc/src/classes/q3sqlrecordinfo.qdoc @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3SqlRecordInfo + \brief The Q3SqlRecordInfo class encapsulates a set of database field meta data. + + \compat + + This class is a list that holds a set of database field meta + data. Use contains() to see if a given field name exists in the + record, and use find() to get a QSqlFieldInfo record for a named + field. + + \sa Q3SqlFieldInfo +*/ + +/*! + \fn Q3SqlRecordInfo::Q3SqlRecordInfo() + + Constructs an empty record info object. +*/ + +/*! + \fn Q3SqlRecordInfo::Q3SqlRecordInfo(const Q3SqlFieldInfoList& other) + \fn Q3SqlRecordInfo::Q3SqlRecordInfo(const QSqlRecord& other) + + Constructs a copy of \a other. +*/ + +/*! + \fn size_type Q3SqlRecordInfo::contains(const QString& fieldName) const + + Returns the number of times a field called \a fieldName occurs in + the record. Returns 0 if no field by that name could be found. +*/ + +/*! + \fn Q3SqlFieldInfo Q3SqlRecordInfo::find(const QString& fieldName) const + + Returns a QSqlFieldInfo object for the first field in the record + which has the field name \a fieldName. If no matching field is + found then an empty QSqlFieldInfo object is returned. +*/ + +/*! + \fn QSqlRecord Q3SqlRecordInfo::toRecord() const + + Returns an empty QSqlRecord based on the field information + in this Q3SqlRecordInfo. +*/ diff --git a/doc/src/classes/q3valuelist.qdoc b/doc/src/classes/q3valuelist.qdoc new file mode 100644 index 0000000..fd73763 --- /dev/null +++ b/doc/src/classes/q3valuelist.qdoc @@ -0,0 +1,569 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3ValueList + \brief The Q3ValueList class is a value-based template class that + provides lists. + \compat + + Q3ValueList is a Qt implementation of an STL-like list container. + It can be used in your application if the standard \c list is not + available for your target platforms. + + Q3ValueList\ defines a template instance to create a list of + values that all have the class T. Note that Q3ValueList does not + store pointers to the members of the list; it holds a copy of + every member. This is why these kinds of classes are called "value + based"; Q3PtrList and Q3Dict are "pointer based". + + Q3ValueList contains and manages a collection of objects of type T + and provides iterators that allow the contained objects to be + addressed. Q3ValueList owns the contained items. For more relaxed + ownership semantics, see Q3PtrCollection and friends which are + pointer-based containers. + + Some classes cannot be used within a Q3ValueList, for example, all + classes derived from QObject and thus all classes that implement + widgets. Only values can be used in a Q3ValueList. To qualify as a + value the class must provide: + \list + \i a copy constructor; + \i an assignment operator; + \i a default constructor, i.e. a constructor that does not take any arguments. + \endlist + + Note that C++ defaults to field-by-field assignment operators and + copy constructors if no explicit version is supplied. In many + cases this is sufficient. + + In addition, some compilers (e.g. Sun CC) might require that the + class provides an equality operator (operator==()). + + Q3ValueList's function naming is consistent with the other Qt + classes (e.g. count(), isEmpty()). Q3ValueList also provides extra + functions for compatibility with STL algorithms, such as size() + and empty(). Programmers already familiar with the STL \c list may + prefer to use the STL-compatible functions. + + Example: + \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 0 + + + Notice that the latest changes to Mary's salary did not affect the + value in the list because the list created a copy of Mary's entry. + + There are several ways to find items in the list. The begin() and + end() functions return iterators to the beginning and end of the + list. The advantage of getting an iterator is that you can move + forward or backward from this position by + incrementing/decrementing the iterator. The iterator returned by + end() points to the item which is one \e past the last item in the + container. The past-the-end iterator is still associated with the + list it belongs to, however it is \e not dereferenceable; + operator*() will not return a well-defined value. If the list is + empty(), the iterator returned by begin() will equal the iterator + returned by end(). + + It is safe to have multiple iterators a the list at the same + time. If some member of the list is removed, only iterators + pointing to the removed member become invalid. Inserting into the + list does not invalidate any iterator. For convenience, the + function last() returns a reference to the last item in the list, + and first() returns a reference to the first item. If the + list is empty(), both last() and first() have undefined behavior + (your application will crash or do unpredictable things). Use + last() and first() with caution, for example: + + \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 1 + + Because Q3ValueList is value-based there is no need to be careful + about deleting items in the list. The list holds its own copies + and will free them if the corresponding member or the list itself + is deleted. You can force the list to free all of its items with + clear(). + + Q3ValueList is shared implicitly, which means it can be copied in + constant time, i.e. O(1). If multiple Q3ValueList instances share + the same data and one needs to modify its contents, this modifying + instance makes a copy and modifies its private copy; therefore it + does not affect the other instances; this takes O(n) time. This is + often called "copy on write". If a Q3ValueList is being used in a + multi-threaded program, you must protect all access to the list. + See \l QMutex. + + There are several ways to insert items into the list. The + prepend() and append() functions insert items at the beginning and + the end of the list respectively. The insert() function comes in + several flavors and can be used to add one or more items at + specific positions within the list. + + Items can also be removed from the list in several ways. There + are several variants of the remove() function, which removes a + specific item from the list. The remove() function will find and + remove items according to a specific item value. + + \sa Q3ValueListIterator +*/ + +/*! \typedef Q3ValueList::iterator + The list's iterator type, Q3ValueListIterator. */ +/*! \typedef Q3ValueList::const_iterator + The list's const iterator type, Q3ValueListConstIterator. */ +/*! \typedef Q3ValueList::value_type + The type of the object stored in the list, T. */ +/*! \typedef Q3ValueList::pointer + The pointer to T type. */ +/*! \typedef Q3ValueList::const_pointer + The const pointer to T type. */ +/*! \typedef Q3ValueList::reference + The reference to T type. */ +/*! \typedef Q3ValueList::const_reference + The const reference to T type. */ +/*! \typedef Q3ValueList::size_type + An unsigned integral type, used to represent various sizes. */ +/*! \typedef Q3ValueList::difference_type + \internal +*/ +/*! + \fn Q3ValueList::Q3ValueList() + + Constructs an empty list. +*/ + +/*! + \fn Q3ValueList::Q3ValueList( const Q3ValueList& l ) + \fn Q3ValueList::Q3ValueList( const QList& l ) + \fn Q3ValueList::Q3ValueList( const QLinkedList& l ) + + Constructs a copy of \a l. +*/ + +/*! + \fn Q3ValueList::Q3ValueList( const std::list& l ) + + Contructs a copy of \a l. + + This constructor is provided for compatibility with STL + containers. +*/ + +/*! + \fn Q3ValueList::~Q3ValueList() + + Destroys the list. References to the values in the list and all + iterators of this list become invalidated. Note that it is + impossible for an iterator to check whether or not it is valid: + Q3ValueList is highly tuned for performance, not for error + checking. +*/ + +/*! + \fn bool Q3ValueList::operator== ( const Q3ValueList& l ) const + + Compares both lists. + + Returns TRUE if this list and \a l are equal; otherwise returns + FALSE. +*/ + +/*! + \fn bool Q3ValueList::operator== ( const std::list& l ) const + + \overload + + Returns TRUE if this list and \a l are equal; otherwise returns + FALSE. + + This operator is provided for compatibility with STL containers. +*/ + +/*! + \fn Q3ValueList& Q3ValueList::operator= ( const Q3ValueList& l ) + + Assigns \a l to this list and returns a reference to this list. + + All iterators of the current list become invalidated by this + operation. The cost of such an assignment is O(1) since Q3ValueList + is implicitly shared. +*/ + +/*! + \fn Q3ValueList& Q3ValueList::operator= ( const QList& l ) + + Assigns \a l to this list and returns a reference to this list. + + All iterators of the current list become invalidated by this + operation. +*/ + +/*! + \fn Q3ValueList& Q3ValueList::operator= ( const std::list& l ) + + \overload + + Assigns the contents of \a l to the list. + + All iterators of the current list become invalidated by this + operation. +*/ + +/*! + \fn bool Q3ValueList::operator!= ( const Q3ValueList& l ) const + + Compares both lists. + + Returns TRUE if this list and \a l are unequal; otherwise returns + FALSE. +*/ + +/*! + \fn iterator Q3ValueList::insert( typename Q3ValueList::Iterator it, const T& x ) + + Inserts the value \a x in front of the item pointed to by the + iterator, \a it. + + Returns an iterator pointing at the inserted item. + + \sa append(), prepend() +*/ + +/*! + \fn uint Q3ValueList::remove( const T& x ) + + \overload + + Removes all items that have value \a x and returns the number of + removed items. +*/ + +/*! + \fn QDataStream& operator>>( QDataStream& s, Q3ValueList& l ) + + \relates Q3ValueList + + Reads a list, \a l, from the stream \a s. The type T stored in the + list must implement the streaming operator. +*/ + +/*! + \fn QDataStream& operator<<( QDataStream& s, const Q3ValueList& l ) + + \overload + \relates Q3ValueList + + Writes a list, \a l, to the stream \a s. The type T stored in the + list must implement the streaming operator. +*/ + +/*! + \fn void Q3ValueList::insert( typename Q3ValueList::Iterator pos, + typename Q3ValueList::size_type n, const T& x ) + + \overload + + Inserts \a n copies of \a x before position \a pos. +*/ + +/*! + \fn Q3ValueList& Q3ValueList::operator<< ( const T& x ) + + Adds the value \a x to the end of the list. + + Returns a reference to the list. +*/ + +/*! + \fn const T& Q3ValueList::operator[] ( typename Q3ValueList::size_type i ) const + + Returns a const reference to the item with index \a i in the list. + It is up to you to check whether this item really exists. You can + do that easily with the count() function. However this operator + does not check whether \a i is in range and will deliver undefined + results if it does not exist. + + \warning This function uses a linear search and can be extremely + slow for large lists. Q3ValueList is not optimized for random item + access. If you need random access use a different container, such + as Q3ValueVector. +*/ + +/*! + \fn T& Q3ValueList::operator[] ( typename Q3ValueList::size_type i ) + + \overload + + Returns a non-const reference to the item with index \a i. +*/ + +/*! + \fn const_iterator Q3ValueList::at( typename Q3ValueList::size_type i ) const + + Returns an iterator pointing to the item at position \a i in the + list, or an undefined value if the index is out of range. + + \warning This function uses a linear search and can be extremely + slow for large lists. Q3ValueList is not optimized for random item + access. If you need random access use a different container, such + as Q3ValueVector. +*/ + +/*! + \fn iterator Q3ValueList::at( typename Q3ValueList::size_type i ) + + \overload + + Returns an iterator pointing to the item at position \a i in the + list, or an undefined value if the index is out of range. + +*/ + +/*! + \fn iterator Q3ValueList::fromLast() + + \overload + + Returns an iterator to the last item in the list, or end() if + there is no last item. + + Use the end() function instead. For example: + + \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 2 + +*/ + +/*! + \fn const_iterator Q3ValueList::fromLast() const + + Returns an iterator to the last item in the list, or end() if + there is no last item. + + Use the end() function instead. For example: + + \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 3 + +*/ + +/*! + \fn Q3ValueList Q3ValueList::operator+( const Q3ValueList& l ) const + + Creates a new list and fills it with the items of this list. Then + the items of \a l are appended. Returns the new list. +*/ + +/*! + \fn Q3ValueList& Q3ValueList::operator+= ( const Q3ValueList& l ) + + Appends the items of \a l to this list. Returns a reference to + this list. +*/ + +/*! + \fn Q3ValueList& Q3ValueList::operator+= ( const T& x ) + + \overload + + Appends the value \a x to the list. Returns a reference to the + list. +*/ + +/*! + \fn iterator Q3ValueList::append( const T& x ) + + Inserts \a x at the end of the list. + + \sa insert(), prepend() +*/ + +/*! + \fn iterator Q3ValueList::prepend( const T& x ) + + Inserts \a x at the beginning of the list. + + \sa insert(), append() +*/ + +/*! + \fn iterator Q3ValueList::remove( typename Q3ValueList::Iterator it ) + + Removes the item pointed to by \a it from the list. No iterators + other than \a it or other iterators pointing at the same item as + \a it are invalidated. Returns an iterator to the next item after + \a it, or end() if there is no such item. + + \sa clear() +*/ + +/*! + \fn uint Q3ValueList::contains( const T& x ) const + + Returns the number of occurrences of the value \a x in the list. +*/ + +/*! + \class Q3ValueListIterator + \brief The Q3ValueListIterator class provides an iterator for Q3ValueList. + \compat + + An iterator is a class for accessing the items of a container + class: a generalization of the index in an array. A pointer + into a "const char *" and an index into an "int[]" are both + iterators, and the general idea is to provide that functionality + for any data structure. + + The Q3ValueListIterator class is an iterator for Q3ValueList + instantiations. You can create the appropriate iterator type by + using the \c iterator typedef provided by Q3ValueList. + + The only way to access the items in a Q3ValueList is to use an + iterator. + + Example (see Q3ValueList for the complete code): + \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 4 + + Q3ValueList is highly optimized for performance and memory usage. + This means that you must be careful: Q3ValueList does not know + about all its iterators and the iterators don't know to which list + they belong. This makes things very fast, but if you're not + careful, you can get spectacular bugs. Always make sure iterators + are valid before dereferencing them or using them as parameters to + generic algorithms in the STL. + + Using an invalid iterator is undefined (your application will + probably crash). Many Qt functions return const value lists; to + iterate over these you should make a copy and iterate over the + copy. + + For every Iterator there is a ConstIterator. When accessing a + Q3ValueList in a const environment or if the reference or pointer + to the list is itself const, then you must use the ConstIterator. + Its semantics are the same as the Iterator, but it only returns + const references. + + \sa Q3ValueList, Q3ValueListConstIterator +*/ + +/*! + \fn Q3ValueListIterator::Q3ValueListIterator() + + Constructs an unitialized iterator. +*/ + +/*! + \fn Q3ValueListIterator::Q3ValueListIterator(const Q3ValueListIterator &o) + \fn Q3ValueListIterator::Q3ValueListIterator(const typename QLinkedList::iterator &o) + + Constucts a copy of iterator \a o. +*/ + +/*! + \class Q3ValueListConstIterator + \brief The Q3ValueListConstIterator class provides a const iterator + for Q3ValueList. + \compat + + In contrast to Q3ValueListIterator, this class is used to iterate + over a const list. It does not allow modification of the values of + the list since that would break const semantics. + + You can create the appropriate const iterator type by using the \c + const_iterator typedef provided by Q3ValueList. + + For more information on Q3ValueList iterators, see + Q3ValueListIterator. + + \sa Q3ValueListIterator, Q3ValueList +*/ + +/*! + \fn Q3ValueListConstIterator::Q3ValueListConstIterator() + + Constructs an unitialized iterator. +*/ + +/*! + \fn Q3ValueListConstIterator::Q3ValueListConstIterator(const Q3ValueListConstIterator &o) + \fn Q3ValueListConstIterator::Q3ValueListConstIterator(const typename QLinkedList::const_iterator &o) + \fn Q3ValueListConstIterator::Q3ValueListConstIterator(const typename QLinkedList::iterator &o) + + Constructs a copy of iterator \a o. +*/ + +/*! + \typedef Q3ValueList::Iterator + + This iterator is an instantiation of Q3ValueListIterator for the + same type as this Q3ValueList. In other words, if you instantiate + Q3ValueList, Iterator is a Q3ValueListIterator. Several + member function use it, such as Q3ValueList::begin(), which returns + an iterator pointing to the first item in the list. + + Functionally, this is almost the same as ConstIterator. The only + difference is that you cannot use ConstIterator for non-const + operations, and that the compiler can often generate better code + if you use ConstIterator. + + \sa Q3ValueListIterator ConstIterator +*/ + +/*! + \typedef Q3ValueList::ConstIterator + + This iterator is an instantiation of Q3ValueListConstIterator for + the same type as this Q3ValueList. In other words, if you + instantiate Q3ValueList, ConstIterator is a + Q3ValueListConstIterator. Several member function use it, such + as Q3ValueList::begin(), which returns an iterator pointing to the + first item in the list. + + Functionally, this is almost the same as Iterator. The only + difference is you cannot use ConstIterator for non-const + operations, and that the compiler can often generate better code + if you use ConstIterator. + + \sa Q3ValueListIterator Iterator +*/ + +/*! + \fn Q3ValueList::operator QList() const + + Automatically converts a Q3ValueList into a QList. +*/ diff --git a/doc/src/classes/q3valuestack.qdoc b/doc/src/classes/q3valuestack.qdoc new file mode 100644 index 0000000..e3ae677 --- /dev/null +++ b/doc/src/classes/q3valuestack.qdoc @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3ValueStack + \brief The Q3ValueStack class is a value-based template class that provides a stack. + \compat + + Define a template instance Q3ValueStack\ to create a stack of + values that all have the class X. + + Note that Q3ValueStack does not store pointers to the members of + the stack; it holds a copy of every member. That is why these + kinds of classes are called "value based"; Q3PtrStack, Q3PtrList, + Q3Dict, etc., are "pointer based". + + A stack is a last in, first out (LIFO) structure. Items are added + to the top of the stack with push() and retrieved from the top + with pop(). The top() function provides access to the topmost item + without removing it. + + Example: + \snippet doc/src/snippets/code/doc_src_q3valuestack.qdoc 0 + + Q3ValueStack is a specialized Q3ValueList provided for convenience. + All of Q3ValueList's functionality also applies to Q3PtrStack, for + example the facility to iterate over all elements using + Q3ValueStack::Iterator. See Q3ValueListIterator for further + details. + + Some classes cannot be used within a Q3ValueStack, for example + everything derived from QObject and thus all classes that + implement widgets. Only values can be used in a Q3ValueStack. To + qualify as a value, the class must provide + \list + \i a copy constructor; + \i an assignment operator; + \i a default constructor, i.e. a constructor that does not take any arguments. + \endlist + + Note that C++ defaults to field-by-field assignment operators and + copy constructors if no explicit version is supplied. In many + cases this is sufficient. +*/ + + +/*! + \fn Q3ValueStack::Q3ValueStack() + + Constructs an empty stack. +*/ + +/*! + \fn Q3ValueStack::~Q3ValueStack() + + Destroys the stack. References to the values in the stack and all + iterators of this stack become invalidated. Because Q3ValueStack is + highly tuned for performance, you won't see warnings if you use + invalid iterators because it is impossible for an iterator to + check whether or not it is valid. +*/ + + +/*! + \fn void Q3ValueStack::push( const T& d ) + + Adds element, \a d, to the top of the stack. Last in, first out. + + This function is equivalent to append(). + + \sa pop(), top() +*/ + +/*! + \fn T& Q3ValueStack::top() + + Returns a reference to the top item of the stack or the item + referenced by end() if no such item exists. Note that you must not + change the value the end() iterator points to. + + This function is equivalent to last(). + + \sa pop(), push(), Q3ValueList::fromLast() +*/ + + +/*! + \fn const T& Q3ValueStack::top() const + + \overload + + Returns a reference to the top item of the stack or the item + referenced by end() if no such item exists. + + This function is equivalent to last(). + + \sa pop(), push(), Q3ValueList::fromLast() +*/ + +/*! + \fn T Q3ValueStack::pop() + + Removes the top item from the stack and returns it. + + \sa top() push() +*/ + + + + + diff --git a/doc/src/classes/q3valuevector.qdoc b/doc/src/classes/q3valuevector.qdoc new file mode 100644 index 0000000..353b7fa --- /dev/null +++ b/doc/src/classes/q3valuevector.qdoc @@ -0,0 +1,274 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class Q3ValueVector + \brief The Q3ValueVector class is a value-based template class that provides a dynamic array. + \compat + + Q3ValueVector is a Qt implementation of an STL-like vector + container. It can be used in your application if the standard \c + vector is not available for your target platforms. + + Q3ValueVector\ defines a template instance to create a vector + of values that all have the class T. Q3ValueVector does not store + pointers to the members of the vector; it holds a copy of every + member. Q3ValueVector is said to be value based; in contrast, + Q3PtrList and Q3Dict are pointer based. + + Q3ValueVector contains and manages a collection of objects of type + T and provides random access iterators that allow the contained + objects to be addressed. Q3ValueVector owns the contained + elements. For more relaxed ownership semantics, see Q3PtrCollection + and friends, which are pointer-based containers. + + Q3ValueVector provides good performance if you append or remove + elements from the end of the vector. If you insert or remove + elements from anywhere but the end, performance is very bad. The + reason for this is that elements must to be copied into new + positions. + + Some classes cannot be used within a Q3ValueVector: for example, + all classes derived from QObject and thus all classes that + implement widgets. Only values can be used in a Q3ValueVector. To + qualify as a value the class must provide: + \list + \i a copy constructor; + \i an assignment operator; + \i a default constructor, i.e., a constructor that does not take any arguments. + \endlist + + Note that C++ defaults to field-by-field assignment operators and + copy constructors if no explicit version is supplied. In many + cases this is sufficient. + + Q3ValueVector uses an STL-like syntax to manipulate and address the + objects it contains. + + Example: + \snippet doc/src/snippets/code/doc_src_q3valuevector.qdoc 0 + + Program output: + \snippet doc/src/snippets/code/doc_src_q3valuevector.qdoc 1 + + As you can see, the most recent change to Joe's salary did not + affect the value in the vector because the vector created a copy + of Joe's entry. + + Many Qt functions return const value vectors; to iterate over + these you should make a copy and iterate over the copy. + + There are several ways to find items in the vector. The begin() + and end() functions return iterators to the beginning and end of + the vector. The advantage of getting an iterator is that you can + move forward or backward from this position by + incrementing/decrementing the iterator. The iterator returned by + end() points to the element which is one past the last element in + the container. The past-the-end iterator is still associated with + the vector it belongs to, however it is \e not dereferenceable; + operator*() will not return a well-defined value. If the vector is + empty(), the iterator returned by begin() will equal the iterator + returned by end(). + + The fastest way to access an element of a vector is by using + operator[]. This function provides random access and will return + a reference to the element located at the specified index. Thus, + you can access every element directly, in constant time, providing + you know the location of the element. It is undefined to access + an element that does not exist (your application will probably + crash). For example: + + \snippet doc/src/snippets/code/doc_src_q3valuevector.qdoc 2 + + Whenever inserting, removing or referencing elements in a vector, + always make sure you are referring to valid positions. For + example: + + \snippet doc/src/snippets/code/doc_src_q3valuevector.qdoc 3 + + The iterators provided by vector are random access iterators, + therefore you can use them with many generic algorithms, for + example, algorithms provided by the STL. + + It is safe to have multiple iterators on the vector at the same + time. Since Q3ValueVector manages memory dynamically, all iterators + can become invalid if a memory reallocation occurs. For example, + if some member of the vector is removed, iterators that point to + the removed element and to all following elements become + invalidated. Inserting into the middle of the vector will + invalidate all iterators. For convenience, the function back() + returns a reference to the last element in the vector, and front() + returns a reference to the first element. If the vector is + empty(), both back() and front() have undefined behavior (your + application will crash or do unpredictable things). Use back() and + front() with caution, for example: + + \snippet doc/src/snippets/code/doc_src_q3valuevector.qdoc 4 + + Because Q3ValueVector manages memory dynamically, it is recommended + that you contruct a vector with an initial size. Inserting and + removing elements happens fastest when: + \list + \i Inserting or removing elements happens at the end() of the + vector; + \i The vector does not need to allocate additional memory. + \endlist + + By creating a Q3ValueVector with a sufficiently large initial size, + there will be less memory allocations. Do not use an initial size + that is too big, since it will still take time to construct all + the empty entries, and the extra space will be wasted if it is + never used. + + Because Q3ValueVector is value-based there is no need to be careful + about deleting elements in the vector. The vector holds its own + copies and will free them if the corresponding member or the + vector itself is deleted. You can force the vector to free all of + its items with clear(). + + Q3ValueVector is shared implicitly, which means it can be copied in + constant time. If multiple Q3ValueVector instances share the same + data and one needs to modify its contents, this modifying instance + makes a copy and modifies its private copy; it thus does not + affect the other instances. This is often called "copy on write". + If a Q3ValueVector is being used in a multi-threaded program, you + must protect all access to the vector. See QMutex. + + There are several ways to insert elements into the vector. The + push_back() function insert elements into the end of the vector, + and is usually fastest. The insert() function can be used to add + elements at specific positions within the vector. + + Items can be also be removed from the vector in several ways. + There are several variants of the erase() function which removes a + specific element, or range of elements, from the vector. + + Q3ValueVector stores its elements in contiguous memory. This means + that you can use a Q3ValueVector in any situation that requires an + array. +*/ + +/*! + \fn Q3ValueVector::Q3ValueVector() + + Constructs an empty vector without any elements. To create a + vector which reserves an initial amount of space for elements, use + \c Q3ValueVector(size_type n). +*/ + +/*! + \fn Q3ValueVector::Q3ValueVector( const Q3ValueVector& v ) + + Constructs a copy of \a v. + + This operation costs O(1) time because Q3ValueVector is implicitly + shared. + + The first modification to the vector does takes O(n) time, because + the elements must be copied. +*/ + +/*! + \fn Q3ValueVector::Q3ValueVector( const std::vector& v ) + + This operation costs O(n) time because \a v is copied. +*/ + +/*! + \fn Q3ValueVector::Q3ValueVector( QVector::size_type n, const T& val ) + + Constructs a vector with an initial size of \a n elements. Each + element is initialized with the value of \a val. +*/ + +/*! + \fn Q3ValueVector& Q3ValueVector::operator=( const Q3ValueVector& v ) + + Assigns \a v to this vector and returns a reference to this vector. + + All iterators of the current vector become invalidated by this + operation. The cost of such an assignment is O(1) since + Q3ValueVector is implicitly shared. +*/ + +/*! + \fn Q3ValueVector& Q3ValueVector::operator=( const std::vector& v ) + + \overload + + Assigns \a v to this vector and returns a reference to this vector. + + All iterators of the current vector become invalidated by this + operation. The cost of this assignment is O(n) since \a v is + copied. +*/ + +/*! + \fn T &Q3ValueVector::at( int i , bool* ok ) + + Returns a reference to the element with index \a i. If \a ok is + non-null, and the index \a i is out of range, *\a ok is set to + FALSE and the returned reference is undefined. If the index \a i + is within the range of the vector, and \a ok is non-null, *\a ok + is set to TRUE and the returned reference is well defined. +*/ + +/*! + \fn const T &Q3ValueVector::at( int i , bool* ok ) const + + \overload + + Returns a const reference to the element with index \a i. If \a ok + is non-null, and the index \a i is out of range, *\a ok is set to + FALSE and the returned reference is undefined. If the index \a i + is within the range of the vector, and \a ok is non-null, *\a ok + is set to TRUE and the returned reference is well defined. +*/ + +/*! + \fn void Q3ValueVector::resize( int n, const T& val = T() ) + + Changes the size of the vector to \a n. If \a n is greater than + the current size(), elements are added to the end and initialized + with the value of \a val. If \a n is less than size(), elements + are removed from the end. If \a n is equal to size() nothing + happens. +*/ diff --git a/doc/src/classes/qalgorithms.qdoc b/doc/src/classes/qalgorithms.qdoc new file mode 100644 index 0000000..7634322 --- /dev/null +++ b/doc/src/classes/qalgorithms.qdoc @@ -0,0 +1,651 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \headerfile + \title Generic Algorithms + \ingroup architecture + + \brief The header provides generic template-based algorithms. + + Qt provides a number of global template functions in \c + that work on containers and perform well-know + algorithms. You can use these algorithms with any \l {container + class} that provides STL-style iterators, including Qt's QList, + QLinkedList, QVector, QMap, and QHash classes. + + These functions have taken their inspiration from similar + functions available in the STL \c header. Most of them + have a direct STL equivalent; for example, qCopyBackward() is the + same as STL's copy_backward() algorithm. + + If STL is available on all your target platforms, you can use the + STL algorithms instead of their Qt counterparts. One reason why + you might want to use the STL algorithms is that STL provides + dozens and dozens of algorithms, whereas Qt only provides the most + important ones, making no attempt to duplicate functionality that + is already provided by the C++ standard. + + Most algorithms take \l {STL-style iterators} as parameters. The + algorithms are generic in the sense that they aren't bound to a + specific iterator class; you can use them with any iterators that + meet a certain set of requirements. + + Let's take the qFill() algorithm as an example. Unlike QVector, + QList has no fill() function that can be used to fill a list with + a particular value. If you need that functionality, you can use + qFill(): + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 0 + + qFill() takes a begin iterator, an end iterator, and a value. + In the example above, we pass \c list.begin() and \c list.end() + as the begin and end iterators, but this doesn't have to be + the case: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 1 + + Different algorithms can have different requirements for the + iterators they accept. For example, qFill() accepts two + \l {forward iterators}. The iterator types required are specified + for each algorithm. If an iterator of the wrong type is passed (for + example, if QList::ConstIterator is passed as an \l {output + iterator}), you will always get a compiler error, although not + necessarily a very informative one. + + Some algorithms have special requirements on the value type + stored in the containers. For example, qEqual() requires that the + value type supports operator==(), which it uses to compare items. + Similarly, qDeleteAll() requires that the value type is a + non-const pointer type (for example, QWidget *). The value type + requirements are specified for each algorithm, and the compiler + will produce an error if a requirement isn't met. + + \target binaryFind example + + The generic algorithms can be used on other container classes + than those provided by Qt and STL. The syntax of STL-style + iterators is modeled after C++ pointers, so it's possible to use + plain arrays as containers and plain pointers as iterators. A + common idiom is to use qBinaryFind() together with two static + arrays: one that contains a list of keys, and another that + contains a list of associated values. For example, the following + code will look up an HTML entity (e.g., \c &) in the \c + name_table array and return the corresponding Unicode value from + the \c value_table if the entity is recognized: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 2 + + This kind of code is for advanced users only; for most + applications, a QMap- or QHash-based approach would work just as + well: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 3 + + \section1 Types of Iterators + + The algorithms have certain requirements on the iterator types + they accept, and these are specified individually for each + function. The compiler will produce an error if a requirement + isn't met. + + \section2 Input Iterators + + An \e{input iterator} is an iterator that can be used for reading + data sequentially from a container. It must provide the following + operators: \c{==} and \c{!=} for comparing two iterators, unary + \c{*} for retrieving the value stored in the item, and prefix + \c{++} for advancing to the next item. + + The Qt containers' iterator types (const and non-const) are all + input iterators. + + \section2 Output Iterators + + An \e{output iterator} is an iterator that can be used for + writing data sequentially to a container or to some output + stream. It must provide the following operators: unary \c{*} for + writing a value (i.e., \c{*it = val}) and prefix \c{++} for + advancing to the next item. + + The Qt containers' non-const iterator types are all output + iterators. + + \section2 Forward Iterators + + A \e{forward iterator} is an iterator that meets the requirements + of both input iterators and output iterators. + + The Qt containers' non-const iterator types are all forward + iterators. + + \section2 Bidirectional Iterators + + A \e{bidirectional iterator} is an iterator that meets the + requirements of forward iterators but that in addition supports + prefix \c{--} for iterating backward. + + The Qt containers' non-const iterator types are all bidirectional + iterators. + + \section2 Random Access Iterators + + The last category, \e{random access iterators}, is the most + powerful type of iterator. It supports all the requirements of a + bidirectional iterator, and supports the following operations: + + \table + \row \i \c{i += n} \i advances iterator \c i by \c n positions + \row \i \c{i -= n} \i moves iterator \c i back by \c n positions + \row \i \c{i + n} or \c{n + i} \i returns the iterator for the item \c + n positions ahead of iterator \c i + \row \i \c{i - n} \i returns the iterator for the item \c n positions behind of iterator \c i + \row \i \c{i - j} \i returns the number of items between iterators \c i and \c j + \row \i \c{i[n]} \i same as \c{*(i + n)} + \row \i \c{i < j} \i returns true if iterator \c j comes after iterator \c i + \endtable + + QList and QVector's non-const iterator types are random access iterators. + + \sa {container classes}, +*/ + +/*! \fn OutputIterator qCopy(InputIterator begin1, InputIterator end1, OutputIterator begin2) + \relates + + Copies the items from range [\a begin1, \a end1) to range [\a + begin2, ...), in the order in which they appear. + + The item at position \a begin1 is assigned to that at position \a + begin2; the item at position \a begin1 + 1 is assigned to that at + position \a begin2 + 1; and so on. + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 4 + + \sa qCopyBackward(), {input iterators}, {output iterators} +*/ + +/*! \fn BiIterator2 qCopyBackward(BiIterator1 begin1, BiIterator1 end1, BiIterator2 end2) + \relates + + Copies the items from range [\a begin1, \a end1) to range [..., + \a end2). + + The item at position \a end1 - 1 is assigned to that at position + \a end2 - 1; the item at position \a end1 - 2 is assigned to that + at position \a end2 - 2; and so on. + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 5 + + \sa qCopy(), {bidirectional iterators} +*/ + +/*! \fn bool qEqual(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2) + \relates + + Compares the items in the range [\a begin1, \a end1) with the + items in the range [\a begin2, ...). Returns true if all the + items compare equal; otherwise returns false. + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 6 + + This function requires the item type (in the example above, + QString) to implement \c operator==(). + + \sa {input iterators} +*/ + +/*! \fn void qFill(ForwardIterator begin, ForwardIterator end, const T &value) + \relates + + Fills the range [\a begin, \a end) with \a value. + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 7 + + \sa qCopy(), {forward iterators} +*/ + +/*! \fn void qFill(Container &container, const T &value) + \relates + + \overload + + This is the same as qFill(\a{container}.begin(), \a{container}.end(), \a value); +*/ + +/*! \fn InputIterator qFind(InputIterator begin, InputIterator end, const T &value) + \relates + + Returns an iterator to the first occurrence of \a value in a + container in the range [\a begin, \a end). Returns \a end if \a + value isn't found. + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 8 + + This function requires the item type (in the example above, + QString) to implement \c operator==(). + + If the items in the range are in ascending order, you can get + faster results by using qLowerBound() or qBinaryFind() instead of + qFind(). + + \sa qBinaryFind(), {input iterators} +*/ + +/*! \fn void qFind(const Container &container, const T &value) + \relates + + \overload + + This is the same as qFind(\a{container}.begin(), \a{container}.end(), value); +*/ + +/*! \fn void qCount(InputIterator begin, InputIterator end, const T &value, Size &n) + \relates + + Returns the number of occurrences of \a value in the range [\a begin, \a end), + which is returned in \a n. \a n is never initialized, the count is added to \a n. + It is the caller's responsibility to initialize \a n. + + Example: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 9 + + This function requires the item type (in the example above, + \c int) to implement \c operator==(). + + \sa {input iterators} +*/ + +/*! \fn void qCount(const Container &container, const T &value, Size &n) +\relates + +\overload + +Instead of operating on iterators, as in the other overload, this function +operates on the specified \a container to obtain the number of instances +of \a value in the variable passed as a reference in argument \a n. +*/ + +/*! \fn void qSwap(T &var1, T &var2) + \relates + + Exchanges the values of variables \a var1 and \a var2. + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 10 +*/ + +/*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end) + \relates + + Sorts the items in range [\a begin, \a end) in ascending order + using the quicksort algorithm. + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 11 + + The sort algorithm is efficient on large data sets. It operates + in \l {linear-logarithmic time}, O(\e{n} log \e{n}). + + This function requires the item type (in the example above, + \c{int}) to implement \c operator<(). + + If neither of the two items is "less than" the other, the items are + taken to be equal. It is then undefined which one of the two + items will appear before the other after the sort. + + \sa qStableSort(), {random access iterators} +*/ + +/*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan) + \relates + + \overload + + Uses the \a lessThan function instead of \c operator<() to + compare the items. + + For example, here's how to sort the strings in a QStringList + in case-insensitive alphabetical order: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 12 + + To sort values in reverse order, pass + \l{qGreater()}{qGreater()} as the \a lessThan parameter. For + example: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 13 + + If neither of the two items is "less than" the other, the items are + taken to be equal. It is then undefined which one of the two + items will appear before the other after the sort. + + An alternative to using qSort() is to put the items to sort in a + QMap, using the sort key as the QMap key. This is often more + convenient than defining a \a lessThan function. For example, the + following code shows how to sort a list of strings case + insensitively using QMap: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 14 + + \sa QMap +*/ + +/*! \fn void qSort(Container &container) + \relates + + \overload + + This is the same as qSort(\a{container}.begin(), \a{container}.end()); +*/ + +/*! + \fn void qStableSort(RandomAccessIterator begin, RandomAccessIterator end) + \relates + + Sorts the items in range [\a begin, \a end) in ascending order + using a stable sorting algorithm. + + If neither of the two items is "less than" the other, the items are + taken to be equal. The item that appeared before the other in the + original container will still appear first after the sort. This + property is often useful when sorting user-visible data. + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 15 + + The sort algorithm is efficient on large data sets. It operates + in \l {linear-logarithmic time}, O(\e{n} log \e{n}). + + This function requires the item type (in the example above, + \c{int}) to implement \c operator<(). + + \sa qSort(), {random access iterators} +*/ + +/*! + \fn void qStableSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan) + \relates + + \overload + + Uses the \a lessThan function instead of \c operator<() to + compare the items. + + For example, here's how to sort the strings in a QStringList + in case-insensitive alphabetical order: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 16 + + Note that earlier versions of Qt allowed using a lessThan function that took its + arguments by non-const reference. From 4.3 and on this is no longer possible, + the arguments has to be passed by const reference or value. + + To sort values in reverse order, pass + \l{qGreater()}{qGreater()} as the \a lessThan parameter. For + example: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 17 + + If neither of the two items is "less than" the other, the items are + taken to be equal. The item that appeared before the other in the + original container will still appear first after the sort. This + property is often useful when sorting user-visible data. +*/ + +/*! + \fn void qStableSort(Container &container) + \relates + + \overload + + This is the same as qStableSort(\a{container}.begin(), \a{container}.end()); +*/ + +/*! \fn RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) + \relates + + Performs a binary search of the range [\a begin, \a end) and + returns the position of the first ocurrence of \a value. If no + such item is found, returns the position where it should be + inserted. + + The items in the range [\a begin, \e end) must be sorted in + ascending order; see qSort(). + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 18 + + This function requires the item type (in the example above, + \c{int}) to implement \c operator<(). + + qLowerBound() can be used in conjunction with qUpperBound() to + iterate over all occurrences of the same value: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 19 + + \sa qUpperBound(), qBinaryFind() +*/ + +/*! + \fn RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) + \relates + + \overload + + Uses the \a lessThan function instead of \c operator<() to + compare the items. + + Note that the items in the range must be sorted according to the order + specified by the \a lessThan object. +*/ + +/*! + \fn void qLowerBound(const Container &container, const T &value) + \relates + + \overload + + For read-only iteration over containers, this function is broadly equivalent to + qLowerBound(\a{container}.begin(), \a{container}.end(), value). However, since it + returns a const iterator, you cannot use it to modify the container; for example, + to insert items. +*/ + +/*! \fn RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) + \relates + + Performs a binary search of the range [\a begin, \a end) and + returns the position of the one-past-the-last occurrence of \a + value. If no such item is found, returns the position where the + item should be inserted. + + The items in the range [\a begin, \e end) must be sorted in + ascending order; see qSort(). + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 20 + + This function requires the item type (in the example above, + \c{int}) to implement \c operator<(). + + qUpperBound() can be used in conjunction with qLowerBound() to + iterate over all occurrences of the same value: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 21 + + \sa qLowerBound(), qBinaryFind() +*/ + +/*! + \fn RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) + \relates + + \overload + + Uses the \a lessThan function instead of \c operator<() to + compare the items. + + Note that the items in the range must be sorted according to the order + specified by the \a lessThan object. +*/ + +/*! + \fn void qUpperBound(const Container &container, const T &value) + \relates + + \overload + + This is the same as qUpperBound(\a{container}.begin(), \a{container}.end(), value); +*/ + + +/*! \fn RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value) + \relates + + Performs a binary search of the range [\a begin, \a end) and + returns the position of an occurrence of \a value. If there are + no occurrences of \a value, returns \a end. + + The items in the range [\a begin, \a end) must be sorted in + ascending order; see qSort(). + + If there are many occurrences of the same value, any one of them + could be returned. Use qLowerBound() or qUpperBound() if you need + finer control. + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 22 + + This function requires the item type (in the example above, + QString) to implement \c operator<(). + + See the \l{#binaryFind example}{detailed + description} for an example usage. + + \sa qLowerBound(), qUpperBound(), {random access iterators} +*/ + +/*! \fn RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) + \relates + + \overload + + Uses the \a lessThan function instead of \c operator<() to + compare the items. + + Note that the items in the range must be sorted according to the order + specified by the \a lessThan object. +*/ + +/*! + \fn void qBinaryFind(const Container &container, const T &value) + \relates + + \overload + + This is the same as qBinaryFind(\a{container}.begin(), \a{container}.end(), value); +*/ + + +/*! + \fn void qDeleteAll(ForwardIterator begin, ForwardIterator end) + \relates + + Deletes all the items in the range [\a begin, \a end) using the + C++ \c delete operator. The item type must be a pointer type (for + example, \c{QWidget *}). + + Example: + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 23 + + Notice that qDeleteAll() doesn't remove the items from the + container; it merely calls \c delete on them. In the example + above, we call clear() on the container to remove the items. + + This function can also be used to delete items stored in + associative containers, such as QMap and QHash. Only the objects + stored in each container will be deleted by this function; objects + used as keys will not be deleted. + + \sa {forward iterators} +*/ + +/*! + \fn void qDeleteAll(const Container &c) + \relates + + \overload + + This is the same as qDeleteAll(\a{c}.begin(), \a{c}.end()). +*/ + +/*! \fn LessThan qLess() + \relates + + Returns a functional object, or functor, that can be passed to qSort() + or qStableSort(). + + Example: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 24 + + \sa {qGreater()}{qGreater()} +*/ + +/*! \fn LessThan qGreater() + \relates + + Returns a functional object, or functor, that can be passed to qSort() + or qStableSort(). + + Example: + + \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 25 + + \sa {qLess()}{qLess()} +*/ diff --git a/doc/src/classes/qcache.qdoc b/doc/src/classes/qcache.qdoc new file mode 100644 index 0000000..6c88ede --- /dev/null +++ b/doc/src/classes/qcache.qdoc @@ -0,0 +1,244 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QCache + \brief The QCache class is a template class that provides a cache. + + \ingroup tools + \ingroup shared + \mainclass + \reentrant + + QCache\ defines a cache that stores objects of type T + associated with keys of type Key. For example, here's the + definition of a cache that stores objects of type Employee + associated with an integer key: + + \snippet doc/src/snippets/code/doc_src_qcache.qdoc 0 + + Here's how to insert an object in the cache: + + \snippet doc/src/snippets/code/doc_src_qcache.qdoc 1 + + The advantage of using QCache over some other key-based data + structure (such as QMap or QHash) is that QCache automatically + takes ownership of the objects that are inserted into the cache and + deletes them to make room for new objects, if necessary. When + inserting an object into the cache, you can specify a \e{cost}, + which should bear some approximate relationship to the amount of + memory taken by the object. When the sum of all objects' costs + (totalCost()) exceeds the cache's limit (maxCost()), QCache starts + deleting objects in the cache to keep under the limit, starting with + less recently accessed objects. + + By default, QCache's maxCost() is 100. You can specify a + different value in the QCache constructor: + + \snippet doc/src/snippets/code/doc_src_qcache.qdoc 2 + + Each time you call insert(), you can specify a cost as third + argument (after the key and a pointer to the object to insert). + After the call, the inserted object is owned by the QCache, which + may delete it at any time to make room for other objects. + + To look up objects in the cache, use object() or + operator[](). This function looks up an object by its key, and + returns either a pointer to the cached object (which is owned by + the cache) or 0. + + If you want to remove an object from the cache for a particular key, + call remove(). This will also delete the object. If you want to + remove an object from the cache without the QCache deleting it, use + take(). + + \sa QPixmapCache, QHash, QMap +*/ + +/*! \fn QCache::QCache(int maxCost = 100) + + Constructs a cache whose contents will never have a total cost + greater than \a maxCost. +*/ + +/*! \fn QCache::~QCache() + + Destroys the cache. Deletes all the objects in the cache. +*/ + +/*! \fn int QCache::maxCost() const + + Returns the maximum allowed total cost of the cache. + + \sa setMaxCost(), totalCost() +*/ + +/*! \fn void QCache::setMaxCost(int cost) + + Sets the maximum allowed total cost of the cache to \a cost. If + the current total cost is greater than \a cost, some objects are + deleted immediately. + + \sa maxCost(), totalCost() +*/ + +/*! \fn int QCache::totalCost() const + + Returns the total cost of the objects in the cache. + + This value is normally below maxCost(), but QCache makes an + exception for Qt's \l{implicitly shared} classes. If a cached + object shares its internal data with another instance, QCache may + keep the object lying around, possibly contributing to making + totalCost() larger than maxCost(). + + \sa setMaxCost() +*/ + +/*! \fn int QCache::size() const + + Returns the number of objects in the cache. + + \sa isEmpty() +*/ + +/*! \fn int QCache::count() const + + Same as size(). +*/ + +/*! \fn bool QCache::isEmpty() const + + Returns true if the cache contains no objects; otherwise + returns false. + + \sa size() +*/ + +/*! \fn QList QCache::keys() const + + Returns a list of the keys in the cache. +*/ + +/*! \fn void QCache::clear(); + + Deletes all the objects in the cache. + + \sa remove(), take() +*/ + + +/*! \fn bool QCache::insert(const Key &key, T *object, int cost = 1) + + Inserts \a object into the cache with key \a key and + associated cost \a cost. Any object with the same key already in + the cache will be removed. + + After this call, \a object is owned by the QCache and may be + deleted at any time. In particular, if \a cost is greater than + maxCost(), the object will be deleted immediately. + + The function returns true if the object was inserted into the + cache; otherwise it returns false. + + \sa take(), remove() +*/ + +/*! \fn T *QCache::object(const Key &key) const + + Returns the object associated with key \a key, or 0 if the key does + not exist in the cache. + + \warning The returned object is owned by QCache and may be + deleted at any time. + + \sa take(), remove() +*/ + +/*! \fn bool QCache::contains(const Key &key) const + + Returns true if the cache contains an object associated with key \a + key; otherwise returns false. + + \sa take(), remove() +*/ + +/*! \fn T *QCache::operator[](const Key &key) const + + Returns the object associated with key \a key, or 0 if the key does + not exist in the cache. + + This is the same as object(). + + \warning The returned object is owned by QCache and may be + deleted at any time. +*/ + +/*! \fn bool QCache::remove(const Key &key) + + Deletes the object associated with key \a key. Returns true if the + object was found in the cache; otherwise returns false. + + \sa take(), clear() +*/ + +/*! \fn T *QCache::take(const Key &key) + + Takes the object associated with key \a key out of the cache + without deleting it. Returns a pointer to the object taken out, or + 0 if the key does not exist in the cache. + + The ownership of the returned object is passed to the caller. + + \sa remove() +*/ + +/*! + \fn QCache::QCache(int maxCost, int dummy) + + Use QCache(int) instead. +*/ + +/*! + \fn T *QCache::find(const Key &key) const + + Use object() instead. +*/ diff --git a/doc/src/classes/qcolormap.qdoc b/doc/src/classes/qcolormap.qdoc new file mode 100644 index 0000000..95f7dc0 --- /dev/null +++ b/doc/src/classes/qcolormap.qdoc @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QColormap + \ingroup multimedia + + \brief The QColormap class maps device independent QColors to device + dependent pixel values. +*/ + +/*! \enum QColormap::Mode + + This enum describes how QColormap maps device independent RGB + values to device dependent pixel values. + + \value Direct Pixel values are derived directly from the RGB + values, also known as "True Color." + + \value Indexed Pixel values represent indexes into a vector of + available colors, i.e. QColormap uses the index of the color that + most closely matches an RGB value. + + \value Gray Similar to \c Indexed, pixel values represent a vector + of available gray tones. QColormap uses the index of the gray + tone that most closely matches the computed gray tone of an RGB + value. +*/ + +/*! + \fn QColormap QColormap::instance(int screen) + + Returns the colormap for the specified \a screen. If \a screen is + -1, this function returns the colormap for the default screen. +*/ + +/*! + \fn QColormap::QColormap(const QColormap &colormap) + + Constructs a copy of another \a colormap. +*/ + +/*! + \fn QColormap::~QColormap() + + Destroys the colormap. +*/ + +/*! + \fn int QColormap::size() const + + Returns the size of the colormap for \c Indexed and \c Gray modes; + Returns -1 for \c Direct mode. + + \sa colormap() +*/ + +/*! + \fn uint QColormap::pixel(const QColor &color) const + + Returns a device dependent pixel value for the \a color. + + \sa colorAt() +*/ + +/*! + \fn int QColormap::depth() const + + Returns the depth of the device. + + \sa size() +*/ + +/*! + \fn QColormap::Mode QColormap::mode() const + + Returns the mode of this colormap. + + \sa QColormap::Mode +*/ + +/*! + \fn const QColor QColormap::colorAt(uint pixel) const + + Returns a QColor for the \a pixel. + + \sa pixel() +*/ + +/*! + \fn const QVector QColormap::colormap() const + + Returns a vector of colors which represents the devices colormap + for \c Indexed and \c Gray modes. This function returns an empty + vector for \c Direct mode. + + \sa size() +*/ + +/*! \fn HPALETTE QColormap::hPal() + + This function is only available on Windows. + + Returns an handle to the HPALETTE used by this colormap. If no + HPALETTE is being used, this function returns zero. +*/ + +/*! \since 4.2 + + \fn QColormap &QColormap::operator=(const QColormap &colormap) + + Assigns the given \a colormap to \e this color map and returns + a reference to \e this color map. +*/ diff --git a/doc/src/classes/qdesktopwidget.qdoc b/doc/src/classes/qdesktopwidget.qdoc new file mode 100644 index 0000000..56a882d --- /dev/null +++ b/doc/src/classes/qdesktopwidget.qdoc @@ -0,0 +1,266 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QDesktopWidget + \brief The QDesktopWidget class provides access to screen information on multi-head systems. + + \ingroup advanced + \ingroup desktop + \ingroup environment + \mainclass + + QApplication::desktop() function should be used to get an instance + of the QDesktopWidget. + + Systems with more than one graphics card and monitor can manage the + physical screen space available either as multiple desktops, or as a + large virtual desktop, which usually has the size of the bounding + rectangle of all the screens (see virtualDesktop). For an + application, one of the available screens is the primary screen, i.e. + the screen where the main widget resides (see primaryScreen). All + windows opened in the context of the application should be + constrained to the boundaries of the primary screen; for example, + it would be inconvenient if a dialog box popped up on a different + screen, or split over two screens. + + The QDesktopWidget provides information about the geometry of the + available screens with screenGeometry(). The number of screens + available is returned by screenCount, and the screenCountChanged + signal is emitted when screens are added or removed during runtime. + The screen number that a particular point or widget is located in + is returned by screenNumber(). + + Widgets provided by Qt use this class, for example, to place + tooltips, menus and dialog boxes according to the parent or + application widget. Applications can use this class to save window + positions, or to place child widgets and dialogs on one particular + screen. + + \img qdesktopwidget.png Managing Multiple Screens + + In the illustration above, Application One's primary screen is + screen 0, and App Two's primary screen is screen 1. + + \target multiple screens note + \note QDesktopWidget inherits the QWidget properties, width() and + height(), which specify the size of the desktop. However, for + desktops with multiple screens, the size of the desktop is the union + of all the screen sizes, so width() and height() should \e not be + used for computing the size of a widget to be placed on one of the + screens. The correct width and height values are obtained using + availableGeometry() or screenGeometry() for a particular screen. + + \sa QApplication, QApplication::desktop(), QX11Info::appRootWindow() +*/ + +/*! + \fn QDesktopWidget::QDesktopWidget() + + \internal + + Creates the desktop widget. + + If the system supports a virtual desktop, this widget will have + the size of the virtual desktop; otherwise this widget will have + the size of the primary screen. + + Instead of using QDesktopWidget directly, use QApplication::desktop(). +*/ + +/*! + \fn QDesktopWidget::~QDesktopWidget() + + \internal + + Destroys the desktop widget and frees any allocated resources. +*/ + +/*! + \fn int QDesktopWidget::numScreens() const + + Returns the number of available screens. + + \obsolete + + This function is deprecated. Use screenCount instead. + + \sa primaryScreen +*/ + +/*! + \fn QWidget *QDesktopWidget::screen(int screen) + + Returns a widget that represents the screen with index \a screen + (a value of -1 means the default screen). + + If the system uses a virtual desktop, the returned widget will + have the geometry of the entire virtual desktop; i.e., bounding + every \a screen. + + \sa primaryScreen, screenCount, virtualDesktop +*/ + +/*! + \fn const QRect QDesktopWidget::availableGeometry(int screen) const + + Returns the available geometry of the screen with index \a screen. What + is available will be subrect of screenGeometry() based on what the + platform decides is available (for example excludes the dock and menu bar + on Mac OS X, or the task bar on Windows). The default screen is used if + \a screen is -1. + + \sa screenNumber(), screenGeometry() +*/ + +/*! + \fn const QRect QDesktopWidget::availableGeometry(const QWidget *widget) const + \overload + + Returns the available geometry of the screen which contains \a widget. + + \sa screenGeometry() +*/ + +/*! + \fn const QRect QDesktopWidget::availableGeometry(const QPoint &p) const + \overload + + Returns the available geometry of the screen which contains \a p. + + \sa screenGeometry() +*/ + + +/*! + \fn const QRect QDesktopWidget::screenGeometry(int screen) const + + Returns the geometry of the screen with index \a screen. The default + screen is used if \a screen is -1. + + \sa screenNumber() +*/ + +/*! + \fn const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const + \overload + + Returns the geometry of the screen which contains \a widget. +*/ + +/*! + \fn const QRect QDesktopWidget::screenGeometry(const QPoint &p) const + \overload + + Returns the geometry of the screen which contains \a p. +*/ + + +/*! + \fn int QDesktopWidget::screenNumber(const QWidget *widget) const + + Returns the index of the screen that contains the largest + part of \a widget, or -1 if the widget not on a screen. + + \sa primaryScreen +*/ + +/*! + \fn int QDesktopWidget::screenNumber(const QPoint &point) const + + \overload + Returns the index of the screen that contains the \a point, or the + screen which is the shortest distance from the \a point. + + \sa primaryScreen +*/ + +/*! + \fn void QDesktopWidget::resizeEvent(QResizeEvent *event) + \reimp +*/ + +/*! + \fn void QDesktopWidget::resized(int screen) + + This signal is emitted when the size of \a screen changes. +*/ + +/*! + \fn void QDesktopWidget::workAreaResized(int screen) + + This signal is emitted when the work area available on \a screen changes. +*/ + +/*! + \property QDesktopWidget::screenCount + \brief the number of screens currently available on the system. + + \since 4.6 + + \sa screenCountChanged() +*/ + +/*! + \property QDesktopWidget::primaryScreen + \brief the index of the screen that is configured to be the primary screen + on the system. +*/ + +/*! + \property QDesktopWidget::virtualDesktop + + \brief if the system manages the available screens in a virtual desktop. + + For virtual desktops, screen() will always return the same widget. + The size of the virtual desktop is the size of this desktop + widget. +*/ + +/*! + \fn void QDesktopWidget::screenCountChanged(int newCount) + + \since 4.6 + + This signal is emitted when the number of screens changes to \a newCount. + + \sa screenCount +*/ diff --git a/doc/src/classes/qiterator.qdoc b/doc/src/classes/qiterator.qdoc new file mode 100644 index 0000000..416b4bc --- /dev/null +++ b/doc/src/classes/qiterator.qdoc @@ -0,0 +1,1431 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QListIterator + \inmodule QtCore + + \brief The QListIterator class provides a Java-style const iterator for QList and QQueue. + + QList has both \l{Java-style iterators} and \l{STL-style + iterators}. The Java-style iterators are more high-level and + easier to use than the STL-style iterators; on the other hand, + they are slightly less efficient. + + An alternative to using iterators is to use index positions. Most + QList member functions take an index as their first parameter, + making it possible to access, modify, and remove items without + using iterators. + + QListIterator\ allows you to iterate over a QList\ (or a + QQueue\). If you want to modify the list as you iterate over + it, use QMutableListIterator\ instead. + + The QListIterator constructor takes a QList as argument. After + construction, the iterator is located at the very beginning of + the list (before the first item). Here's how to iterate over all + the elements sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 0 + + The next() function returns the next item in the list and + advances the iterator. Unlike STL-style iterators, Java-style + iterators point \e between items rather than directly \e at + items. The first call to next() advances the iterator to the + position between the first and second item, and returns the first + item; the second call to next() advances the iterator to the + position between the second and third item, and returns the second + item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 1 + + If you want to find all occurrences of a particular value, use + findNext() or findPrevious() in a loop. + + Multiple iterators can be used on the same list. If the list is + modified while a QListIterator is active, the QListIterator will + continue iterating over the original list, ignoring the modified + copy. + + \sa QMutableListIterator, QList::const_iterator +*/ + +/*! + \class QLinkedListIterator + \inmodule QtCore + + \brief The QLinkedListIterator class provides a Java-style const iterator for QLinkedList. + + QLinkedList has both \l{Java-style iterators} and + \l{STL-style iterators}. The Java-style iterators are more + high-level and easier to use than the STL-style iterators; on the + other hand, they are slightly less efficient. + + QLinkedListIterator\ allows you to iterate over a + QLinkedList\. If you want to modify the list as you iterate + over it, use QMutableLinkedListIterator\ instead. + + The QLinkedListIterator constructor takes a QLinkedList as + argument. After construction, the iterator is located at the very + beginning of the list (before the first item). Here's how to + iterate over all the elements sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 2 + + The next() function returns the next item in the list and + advances the iterator. Unlike STL-style iterators, Java-style + iterators point \e between items rather than directly \e at + items. The first call to next() advances the iterator to the + position between the first and second item, and returns the first + item; the second call to next() advances the iterator to the + position between the second and third item, and returns the second + item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 3 + + If you want to find all occurrences of a particular value, use + findNext() or findPrevious() in a loop. + + Multiple iterators can be used on the same list. If the list is + modified while a QLinkedListIterator is active, the + QLinkedListIterator will continue iterating over the original + list, ignoring the modified copy. + + \sa QMutableLinkedListIterator, QLinkedList::const_iterator +*/ + +/*! + \class QVectorIterator + \inmodule QtCore + \brief The QVectorIterator class provides a Java-style const iterator for QVector and QStack. + + QVector has both \l{Java-style iterators} and \l{STL-style + iterators}. The Java-style iterators are more high-level and + easier to use than the STL-style iterators; on the other hand, + they are slightly less efficient. + + An alternative to using iterators is to use index positions. Most + QVector member functions take an index as their first parameter, + making it possible to access, insert, and remove items without + using iterators. + + QVectorIterator\ allows you to iterate over a QVector\ + (or a QStack\). If you want to modify the vector as you + iterate over it, use QMutableVectorIterator\ instead. + + The QVectorIterator constructor takes a QVector as argument. + After construction, the iterator is located at the very beginning + of the vector (before the first item). Here's how to iterate over + all the elements sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 4 + + The next() function returns the next item in the vector and + advances the iterator. Unlike STL-style iterators, Java-style + iterators point \e between items rather than directly \e at + items. The first call to next() advances the iterator to the + position between the first and second item, and returns the first + item; the second call to next() advances the iterator to the + position between the second and third item, returning the second + item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 5 + + If you want to find all occurrences of a particular value, use + findNext() or findPrevious() in a loop. + + Multiple iterators can be used on the same vector. If the vector + is modified while a QVectorIterator is active, the QVectorIterator + will continue iterating over the original vector, ignoring the + modified copy. + + \sa QMutableVectorIterator, QVector::const_iterator +*/ + +/*! + \class QSetIterator + \inmodule QtCore + \brief The QSetIterator class provides a Java-style const iterator for QSet. + + QSet supports both \l{Java-style iterators} and \l{STL-style + iterators}. The Java-style iterators are more high-level and + easier to use than the STL-style iterators; on the other hand, + they are slightly less efficient. + + QSetIterator\ allows you to iterate over a QSet\. If you + want to modify the set as you iterate over it, use + QMutableSetIterator\ instead. + + The constructor takes a QSet as argument. After construction, the + iterator is located at the very beginning of the set (before + the first item). Here's how to iterate over all the elements + sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 6 + + The next() function returns the next item in the set and + advances the iterator. Unlike STL-style iterators, Java-style + iterators point \e between items rather than directly \e at + items. The first call to next() advances the iterator to the + position between the first and second item, and returns the first + item; the second call to next() advances the iterator to the + position between the second and third item, returning the second + item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 7 + + If you want to find all occurrences of a particular value, use + findNext() or findPrevious() in a loop. + + Multiple iterators can be used on the same set. If the set + is modified while a QSetIterator is active, the QSetIterator + will continue iterating over the original set, ignoring the + modified copy. + + \sa QMutableSetIterator, QSet::const_iterator +*/ + +/*! + \class QMutableListIterator + \inmodule QtCore + + \brief The QMutableListIterator class provides a Java-style non-const iterator for QList and QQueue. + + QList has both \l{Java-style iterators} and \l{STL-style + iterators}. The Java-style iterators are more high-level and + easier to use than the STL-style iterators; on the other hand, + they are slightly less efficient. + + An alternative to using iterators is to use index positions. Most + QList member functions take an index as their first parameter, + making it possible to access, insert, and remove items without + using iterators. + + QMutableListIterator\ allows you to iterate over a QList\ + (or a QQueue\) and modify the list. If you don't want to + modify the list (or have a const QList), use the slightly faster + QListIterator\ instead. + + The QMutableListIterator constructor takes a QList as argument. + After construction, the iterator is located at the very beginning + of the list (before the first item). Here's how to iterate over + all the elements sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 8 + + The next() function returns the next item in the list and + advances the iterator. Unlike STL-style iterators, Java-style + iterators point \e between items rather than directly \e at + items. The first call to next() advances the iterator to the + position between the first and second item, and returns the first + item; the second call to next() advances the iterator to the + position between the second and third item, returning the second + item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 9 + + If you want to find all occurrences of a particular value, use + findNext() or findPrevious() in a loop. + + If you want to remove items as you iterate over the list, use + remove(). If you want to modify the value of an item, use + setValue(). If you want to insert a new item in the list, use + insert(). + + Example: + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 10 + + The example traverses a list, replacing negative numbers with + their absolute values, and eliminating zeroes. + + Only one mutable iterator can be active on a given list at any + time. Furthermore, no changes should be done directly to the list + while the iterator is active (as opposed to through the + iterator), since this could invalidate the iterator and lead to + undefined behavior. + + \sa QListIterator, QList::iterator +*/ + +/*! + \class QMutableLinkedListIterator + \inmodule QtCore + + \brief The QMutableLinkedListIterator class provides a Java-style non-const iterator for QLinkedList. + + QLinkedList has both \l{Java-style iterators} and + \l{STL-style iterators}. The Java-style iterators are more + high-level and easier to use than the STL-style iterators; on the + other hand, they are slightly less efficient. + + QMutableLinkedListIterator\ allows you to iterate over a + QLinkedList\ and modify the list. If you don't want to modify + the list (or have a const QLinkedList), use the slightly faster + QLinkedListIterator\ instead. + + The QMutableLinkedListIterator constructor takes a QLinkedList as + argument. After construction, the iterator is located at the very + beginning of the list (before the first item). Here's how to + iterate over all the elements sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 11 + + The next() function returns the next item in the list and + advances the iterator. Unlike STL-style iterators, Java-style + iterators point \e between items rather than directly \e at + items. The first call to next() advances the iterator to the + position between the first and second item, and returns the first + item; the second call to next() advances the iterator to the + position between the second and third item, returning the second + item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 12 + + If you want to find all occurrences of a particular value, use + findNext() or findPrevious() in a loop. + + If you want to remove items as you iterate over the list, use + remove(). If you want to modify the value of an item, use + setValue(). If you want to insert a new item in the list, use + insert(). + + Example: + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 13 + + The example traverses a list, replacing negative numbers with + their absolute values, and eliminating zeroes. + + Only one mutable iterator can be active on a given list at any + time. Furthermore, no changes should be done directly to the list + while the iterator is active (as opposed to through the + iterator), since this could invalidate the iterator and lead to + undefined behavior. + + \sa QLinkedListIterator, QLinkedList::iterator +*/ + +/*! + \class QMutableVectorIterator + \inmodule QtCore + + \brief The QMutableVectorIterator class provides a Java-style non-const iterator for QVector and QStack. + + QVector has both \l{Java-style iterators} and \l{STL-style + iterators}. The Java-style iterators are more high-level and + easier to use than the STL-style iterators; on the other hand, + they are slightly less efficient. + + An alternative to using iterators is to use index positions. Most + QVector member functions take an index as their first parameter, + making it possible to access, insert, and remove items without + using iterators. + + QMutableVectorIterator\ allows you to iterate over a + QVector\ and modify the vector. If you don't want to modify + the vector (or have a const QVector), use the slightly faster + QVectorIterator\ instead. + + The QMutableVectorIterator constructor takes a QVector as + argument. After construction, the iterator is located at the very + beginning of the list (before the first item). Here's how to + iterate over all the elements sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 14 + + The next() function returns the next item in the vector and + advances the iterator. Unlike STL-style iterators, Java-style + iterators point \e between items rather than directly \e at + items. The first call to next() advances the iterator to the + position between the first and second item, and returns the first + item; the second call to next() advances the iterator to the + position between the second and third item, returning the second + item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 15 + + If you want to find all occurrences of a particular value, use + findNext() or findPrevious() in a loop. + + If you want to remove items as you iterate over the vector, use + remove(). If you want to modify the value of an item, use + setValue(). If you want to insert a new item in the vector, use + insert(). + + Example: + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 16 + + The example traverses a vector, replacing negative numbers with + their absolute values, and eliminating zeroes. + + Only one mutable iterator can be active on a given vector at any + time. Furthermore, no changes should be done directly to the + vector while the iterator is active (as opposed to through the + iterator), since this could invalidate the iterator and lead to + undefined behavior. + + \sa QVectorIterator, QVector::iterator +*/ + +/*! + \class QMutableSetIterator + \inmodule QtCore + \since 4.2 + + \brief The QMutableSetIterator class provides a Java-style non-const iterator for QSet. + + QSet has both \l{Java-style iterators} and \l{STL-style + iterators}. The Java-style iterators are more high-level and + easier to use than the STL-style iterators; on the other hand, + they are slightly less efficient. + + QMutableSetIterator\ allows you to iterate over a QSet\ + and remove items from the set as you iterate. If you don't want + to modify the set (or have a const QSet), use the slightly faster + QSetIterator\ instead. + + The QMutableSetIterator constructor takes a QSet as argument. + After construction, the iterator is located at the very beginning + of the set (before the first item). Here's how to iterate over + all the elements sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 17 + + The next() function returns the next item in the set and + advances the iterator. Unlike STL-style iterators, Java-style + iterators point \e between items rather than directly \e at + items. The first call to next() advances the iterator to the + position between the first and second item, and returns the first + item; the second call to next() advances the iterator to the + position between the second and third item, returning the second + item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 18 + + If you want to remove items as you iterate over the set, use + remove(). + + Only one mutable iterator can be active on a given set at any + time. Furthermore, no changes should be done directly to the set + while the iterator is active (as opposed to through the + iterator), since this could invalidate the iterator and lead to + undefined behavior. + + \sa QSetIterator, QSet::iterator +*/ + +/*! + \fn QListIterator::QListIterator(const QList &list) + \fn QLinkedListIterator::QLinkedListIterator(const QLinkedList &list) + \fn QMutableListIterator::QMutableListIterator(QList &list) + \fn QMutableLinkedListIterator::QMutableLinkedListIterator(QLinkedList &list) + + Constructs an iterator for traversing \a list. The iterator is + set to be at the front of the list (before the first item). + + \sa operator=() +*/ + +/*! + \fn QVectorIterator::QVectorIterator(const QVector &vector) + \fn QMutableVectorIterator::QMutableVectorIterator(QVector &vector) + + Constructs an iterator for traversing \a vector. The iterator is + set to be at the front of the vector (before the first item). + + \sa operator=() +*/ + +/*! + \fn QSetIterator::QSetIterator(const QSet &set) + \fn QMutableSetIterator::QMutableSetIterator(QSet &set) + + Constructs an iterator for traversing \a set. The iterator is + set to be at the front of the set (before the first item). + + \sa operator=() +*/ + +/*! + \fn QMutableListIterator::~QMutableListIterator() + \fn QMutableLinkedListIterator::~QMutableLinkedListIterator() + \fn QMutableVectorIterator::~QMutableVectorIterator() + \fn QMutableSetIterator::~QMutableSetIterator() + + Destroys the iterator. + + \sa operator=() +*/ + +/*! \fn QMutableListIterator &QMutableListIterator::operator=(QList &list) + \fn QMutableLinkedListIterator &QMutableLinkedListIterator::operator=(QLinkedList &list) + \fn QListIterator &QListIterator::operator=(const QList &list) + \fn QLinkedListIterator &QLinkedListIterator::operator=(const QLinkedList &list) + + Makes the iterator operate on \a list. The iterator is set to be + at the front of the list (before the first item). + + \sa toFront(), toBack() +*/ + +/*! \fn QVectorIterator &QVectorIterator::operator=(const QVector &vector) + \fn QMutableVectorIterator &QMutableVectorIterator::operator=(QVector &vector) + + Makes the iterator operate on \a vector. The iterator is set to be + at the front of the vector (before the first item). + + \sa toFront(), toBack() +*/ + +/*! \fn QSetIterator &QSetIterator::operator=(const QSet &set) + \fn QMutableSetIterator &QMutableSetIterator::operator=(QSet &set) + + Makes the iterator operate on \a set. The iterator is set to be + at the front of the set (before the first item). + + \sa toFront(), toBack() +*/ + +/*! \fn void QListIterator::toFront() + \fn void QLinkedListIterator::toFront() + \fn void QVectorIterator::toFront() + \fn void QSetIterator::toFront() + \fn void QMutableListIterator::toFront() + \fn void QMutableLinkedListIterator::toFront() + \fn void QMutableVectorIterator::toFront() + \fn void QMutableSetIterator::toFront() + + Moves the iterator to the front of the container (before the + first item). + + \sa toBack(), next() +*/ + +/*! \fn void QListIterator::toBack() + \fn void QLinkedListIterator::toBack() + \fn void QVectorIterator::toBack() + \fn void QSetIterator::toBack() + \fn void QMutableListIterator::toBack() + \fn void QMutableLinkedListIterator::toBack() + \fn void QMutableVectorIterator::toBack() + \fn void QMutableSetIterator::toBack() + + Moves the iterator to the back of the container (after the last + item). + + \sa toFront(), previous() +*/ + +/*! \fn bool QListIterator::hasNext() const + \fn bool QLinkedListIterator::hasNext() const + \fn bool QVectorIterator::hasNext() const + \fn bool QSetIterator::hasNext() const + \fn bool QMutableListIterator::hasNext() const + \fn bool QMutableLinkedListIterator::hasNext() const + \fn bool QMutableVectorIterator::hasNext() const + \fn bool QMutableSetIterator::hasNext() const + + Returns true if there is at least one item ahead of the iterator, + i.e. the iterator is \e not at the back of the container; + otherwise returns false. + + \sa hasPrevious(), next() +*/ + +/*! \fn const T &QListIterator::next() + \fn const T &QLinkedListIterator::next() + \fn const T &QVectorIterator::next() + \fn const T &QSetIterator::next() + \fn const T &QMutableSetIterator::next() + + Returns the next item and advances the iterator by one position. + + Calling this function on an iterator located at the back of the + container leads to undefined results. + + \sa hasNext(), peekNext(), previous() +*/ + +/*! \fn T &QMutableListIterator::next() + \fn T &QMutableLinkedListIterator::next() + \fn T &QMutableVectorIterator::next() + + Returns a reference to the next item, and advances the iterator + by one position. + + Calling this function on an iterator located at the back of the + container leads to undefined results. + + \sa hasNext(), peekNext(), previous() +*/ + +/*! \fn const T &QListIterator::peekNext() const + \fn const T &QLinkedListIterator::peekNext() const + \fn const T &QVectorIterator::peekNext() const + \fn const T &QSetIterator::peekNext() const + \fn const T &QMutableSetIterator::peekNext() const + + Returns the next item without moving the iterator. + + Calling this function on an iterator located at the back of the + container leads to undefined results. + + \sa hasNext(), next(), peekPrevious() +*/ + +/*! \fn T &QMutableListIterator::peekNext() const + \fn T &QMutableLinkedListIterator::peekNext() const + \fn T &QMutableVectorIterator::peekNext() const + + Returns a reference to the next item, without moving the iterator. + + Calling this function on an iterator located at the back of the + container leads to undefined results. + + \sa hasNext(), next(), peekPrevious() +*/ + +/*! \fn bool QListIterator::hasPrevious() const + \fn bool QLinkedListIterator::hasPrevious() const + \fn bool QVectorIterator::hasPrevious() const + \fn bool QSetIterator::hasPrevious() const + \fn bool QMutableListIterator::hasPrevious() const + \fn bool QMutableLinkedListIterator::hasPrevious() const + \fn bool QMutableVectorIterator::hasPrevious() const + \fn bool QMutableSetIterator::hasPrevious() const + + Returns true if there is at least one item behind the iterator, + i.e. the iterator is \e not at the front of the container; + otherwise returns false. + + \sa hasNext(), previous() +*/ + +/*! \fn const T &QListIterator::previous() + \fn const T &QLinkedListIterator::previous() + \fn const T &QVectorIterator::previous() + \fn const T &QSetIterator::previous() + \fn const T &QMutableSetIterator::previous() + + Returns the previous item and moves the iterator back by one + position. + + Calling this function on an iterator located at the front of the + container leads to undefined results. + + \sa hasPrevious(), peekPrevious(), next() +*/ + +/*! \fn T &QMutableListIterator::previous() + \fn T &QMutableLinkedListIterator::previous() + \fn T &QMutableVectorIterator::previous() + + Returns a reference to the previous item and moves the iterator + back by one position. + + Calling this function on an iterator located at the front of the + container leads to undefined results. + + \sa hasPrevious(), peekPrevious(), next() +*/ + +/*! \fn const T &QListIterator::peekPrevious() const + \fn const T &QLinkedListIterator::peekPrevious() const + \fn const T &QVectorIterator::peekPrevious() const + \fn const T &QSetIterator::peekPrevious() const + \fn const T &QMutableSetIterator::peekPrevious() const + + Returns the previous item without moving the iterator. + + Calling this function on an iterator located at the front of the + container leads to undefined results. + + \sa hasPrevious(), previous(), peekNext() +*/ + +/*! \fn T &QMutableListIterator::peekPrevious() const + \fn T &QMutableLinkedListIterator::peekPrevious() const + \fn T &QMutableVectorIterator::peekPrevious() const + + Returns a reference to the previous item, without moving the iterator. + + Calling this function on an iterator located at the front of the + container leads to undefined results. + + \sa hasPrevious(), previous(), peekNext() +*/ + +/*! \fn bool QListIterator::findNext(const T &value) + \fn bool QLinkedListIterator::findNext(const T &value) + \fn bool QVectorIterator::findNext(const T &value) + \fn bool QSetIterator::findNext(const T &value) + \fn bool QMutableListIterator::findNext(const T &value) + \fn bool QMutableLinkedListIterator::findNext(const T &value) + \fn bool QMutableVectorIterator::findNext(const T &value) + \fn bool QMutableSetIterator::findNext(const T &value) + + Searches for \a value starting from the current iterator position + forward. Returns true if \a value is found; otherwise returns false. + + After the call, if \a value was found, the iterator is positioned + just after the matching item; otherwise, the iterator is + positioned at the back of the container. + + \sa findPrevious() +*/ + +/*! \fn bool QListIterator::findPrevious(const T &value) + \fn bool QLinkedListIterator::findPrevious(const T &value) + \fn bool QVectorIterator::findPrevious(const T &value) + \fn bool QSetIterator::findPrevious(const T &value) + \fn bool QMutableListIterator::findPrevious(const T &value) + \fn bool QMutableLinkedListIterator::findPrevious(const T &value) + \fn bool QMutableVectorIterator::findPrevious(const T &value) + \fn bool QMutableSetIterator::findPrevious(const T &value) + + Searches for \a value starting from the current iterator position + backward. Returns true if \a value is found; otherwise returns + false. + + After the call, if \a value was found, the iterator is positioned + just before the matching item; otherwise, the iterator is + positioned at the front of the container. + + \sa findNext() +*/ + +/*! \fn void QMutableListIterator::remove() + + Removes the last item that was jumped over using one of the + traversal functions (next(), previous(), findNext(), findPrevious()). + + Example: + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 19 + + \sa insert(), setValue() +*/ + +/*! \fn void QMutableLinkedListIterator::remove() + + Removes the last item that was jumped over using one of the + traversal functions (next(), previous(), findNext(), findPrevious()). + + Example: + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 20 + + \sa insert(), setValue() +*/ + +/*! \fn void QMutableVectorIterator::remove() + + Removes the last item that was jumped over using one of the + traversal functions (next(), previous(), findNext(), findPrevious()). + + Example: + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 21 + + \sa insert(), setValue() +*/ + +/*! \fn void QMutableSetIterator::remove() + + Removes the last item that was jumped over using one of the + traversal functions (next(), previous(), findNext(), findPrevious()). + + Example: + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 22 + + \sa value() +*/ + +/*! \fn void QMutableListIterator::setValue(const T &value) const + + Replaces the value of the last item that was jumped over using + one of the traversal functions with \a value. + + The traversal functions are next(), previous(), findNext(), and + findPrevious(). + + Example: + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 23 + + \sa value(), remove(), insert() +*/ + +/*! \fn void QMutableLinkedListIterator::setValue(const T &value) const + + Replaces the value of the last item that was jumped over using + one of the traversal functions with \a value. + + The traversal functions are next(), previous(), findNext(), and + findPrevious(). + + Example: + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 24 + + \sa value(), remove(), insert() +*/ + +/*! \fn void QMutableVectorIterator::setValue(const T &value) const + + Replaces the value of the last item that was jumped over using + one of the traversal functions with \a value. + + The traversal functions are next(), previous(), findNext(), and + findPrevious(). + + Example: + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 25 + + \sa value(), remove(), insert() +*/ + +/*! \fn const T &QMutableListIterator::value() const + \fn const T &QMutableLinkedListIterator::value() const + \fn const T &QMutableVectorIterator::value() const + \fn const T &QMutableSetIterator::value() const + + Returns the value of the last item that was jumped over using one + of the traversal functions (next(), previous(), findNext(), + findPrevious()). + + After a call to next() or findNext(), value() is equivalent to + peekPrevious(). After a call to previous() or findPrevious(), value() is + equivalent to peekNext(). +*/ + +/*! + \fn T &QMutableListIterator::value() + \fn T &QMutableLinkedListIterator::value() + \fn T &QMutableVectorIterator::value() + \overload + + Returns a non-const reference to the value of the last item that + was jumped over using one of the traversal functions. +*/ + +/*! \fn void QMutableListIterator::insert(const T &value) + \fn void QMutableLinkedListIterator::insert(const T &value) + \fn void QMutableVectorIterator::insert(const T &value) + + Inserts \a value at the current iterator position. After the + call, the iterator is located just after the inserted item. + + \sa remove(), setValue() +*/ + +/*! + \class QMapIterator + \inmodule QtCore + + \brief The QMapIterator class provides a Java-style const iterator for QMap and QMultiMap. + + QMap has both \l{Java-style iterators} and \l{STL-style + iterators}. The Java-style iterators are more high-level and + easier to use than the STL-style iterators; on the other hand, + they are slightly less efficient. + + QMapIterator\ allows you to iterate over a QMap (or a + QMultiMap). If you want to modify the map as you iterate over + it, use QMutableMapIterator instead. + + The QMapIterator constructor takes a QMap as argument. After + construction, the iterator is located at the very beginning of + the map (before the first item). Here's how to iterate over all + the elements sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 26 + + The next() function returns the next item in the map and + advances the iterator. The key() and value() functions return the + key and value of the last item that was jumped over. + + Unlike STL-style iterators, Java-style iterators point \e between + items rather than directly \e at items. The first call to next() + advances the iterator to the position between the first and + second item, and returns the first item; the second call to + next() advances the iterator to the position between the second + and third item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 27 + + If you want to find all occurrences of a particular value, use + findNext() or findPrevious() in a loop. For example: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 28 + + Multiple iterators can be used on the same map. If the map is + modified while a QMapIterator is active, the QMapIterator will + continue iterating over the original map, ignoring the modified + copy. + + \sa QMutableMapIterator, QMap::const_iterator +*/ + +/*! + \class QHashIterator + \inmodule QtCore + + \brief The QHashIterator class provides a Java-style const iterator for QHash and QMultiHash. + + QHash has both \l{Java-style iterators} and \l{STL-style + iterators}. The Java-style iterators are more high-level and + easier to use than the STL-style iterators; on the other hand, + they are slightly less efficient. + + QHashIterator\ allows you to iterate over a QHash (or a + QMultiHash). If you want to modify the hash as you iterate over + it, use QMutableHashIterator instead. + + The QHashIterator constructor takes a QHash as argument. After + construction, the iterator is located at the very beginning of + the hash (before the first item). Here's how to iterate over all + the elements sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 29 + + The next() function returns the next item in the hash and + advances the iterator. The key() and value() functions return the + key and value of the last item that was jumped over. + + Unlike STL-style iterators, Java-style iterators point \e between + items rather than directly \e at items. The first call to next() + advances the iterator to the position between the first and + second item, and returns the first item; the second call to + next() advances the iterator to the position between the second + and third item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 30 + + If you want to find all occurrences of a particular value, use + findNext() or findPrevious() in a loop. For example: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 31 + + Multiple iterators can be used on the same hash. If the hash is + modified while a QHashIterator is active, the QHashIterator will + continue iterating over the original hash, ignoring the modified + copy. + + \sa QMutableHashIterator, QHash::const_iterator +*/ + +/*! + \class QMutableMapIterator + \inmodule QtCore + + \brief The QMutableMapIterator class provides a Java-style non-const iterator for QMap and QMultiMap. + + QMap has both \l{Java-style iterators} and \l{STL-style + iterators}. The Java-style iterators are more high-level and + easier to use than the STL-style iterators; on the other hand, + they are slightly less efficient. + + QMutableMapIterator\ allows you to iterate over a QMap + (or a QMultiMap) and modify the map. If you don't want to modify + the map (or have a const QMap), use the slightly faster + QMapIterator instead. + + The QMutableMapIterator constructor takes a QMap as argument. + After construction, the iterator is located at the very beginning + of the map (before the first item). Here's how to iterate over + all the elements sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 32 + + The next() function returns the next item in the map and + advances the iterator. The key() and value() functions return the + key and value of the last item that was jumped over. + + Unlike STL-style iterators, Java-style iterators point \e between + items rather than directly \e at items. The first call to next() + advances the iterator to the position between the first and + second item, and returns the first item; the second call to + next() advances the iterator to the position between the second + and third item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 33 + + If you want to find all occurrences of a particular value, use + findNext() or findPrevious() in a loop. For example: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 34 + + If you want to remove items as you iterate over the map, use + remove(). If you want to modify the value of an item, use + setValue(). + + Example: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 35 + + The example removes all (key, value) pairs where the key and the + value are the same. + + Only one mutable iterator can be active on a given map at any + time. Furthermore, no changes should be done directly to the map + while the iterator is active (as opposed to through the + iterator), since this could invalidate the iterator and lead to + undefined behavior. + + \sa QMapIterator, QMap::iterator +*/ + +/*! + \class QMutableHashIterator + \inmodule QtCore + + \brief The QMutableHashIterator class provides a Java-style non-const iterator for QHash and QMultiHash. + + QHash has both \l{Java-style iterators} and \l{STL-style + iterators}. The Java-style iterators are more high-level and + easier to use than the STL-style iterators; on the other hand, + they are slightly less efficient. + + QMutableHashIterator\ allows you to iterate over a QHash + (or a QMultiHash) and modify the hash. If you don't want to modify + the hash (or have a const QHash), use the slightly faster + QHashIterator instead. + + The QMutableHashIterator constructor takes a QHash as argument. + After construction, the iterator is located at the very beginning + of the hash (before the first item). Here's how to iterate over + all the elements sequentially: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 36 + + The next() function returns the next item in the hash and + advances the iterator. The key() and value() functions return the + key and value of the last item that was jumped over. + + Unlike STL-style iterators, Java-style iterators point \e between + items rather than directly \e at items. The first call to next() + advances the iterator to the position between the first and + second item, and returns the first item; the second call to + next() advances the iterator to the position between the second + and third item; and so on. + + \img javaiterators1.png + + Here's how to iterate over the elements in reverse order: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 37 + + If you want to find all occurrences of a particular value, use + findNext() or findPrevious() in a loop. For example: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 38 + + If you want to remove items as you iterate over the hash, use + remove(). If you want to modify the value of an item, use + setValue(). + + Example: + + \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 39 + + The example removes all (key, value) pairs where the key and the + value are the same. + + Only one mutable iterator can be active on a given hash at any + time. Furthermore, no changes should be done directly to the hash + while the iterator is active (as opposed to through the + iterator), since this could invalidate the iterator and lead to + undefined behavior. + + \sa QHashIterator, QHash::iterator +*/ + +/*! \fn QMapIterator::QMapIterator(const QMap &map) + \fn QMutableMapIterator::QMutableMapIterator(QMap &map) + + Constructs an iterator for traversing \a map. The iterator is set + to be at the front of the map (before the first item). + + \sa operator=() +*/ + +/*! \fn QHashIterator::QHashIterator(const QHash &hash) + \fn QMutableHashIterator::QMutableHashIterator(QHash &hash) + + Constructs an iterator for traversing \a hash. The iterator is + set to be at the front of the hash (before the first item). + + \sa operator=() +*/ + +/*! + \fn QMutableMapIterator::~QMutableMapIterator() + \fn QMutableHashIterator::~QMutableHashIterator() + + Destroys the iterator. + + \sa operator=() +*/ + +/*! \fn QMapIterator &QMapIterator::operator=(const QMap &map) + \fn QMutableMapIterator &QMutableMapIterator::operator=(QMap &map) + + Makes the iterator operate on \a map. The iterator is set to be + at the front of the map (before the first item). + + \sa toFront(), toBack() +*/ + +/*! \fn QHashIterator &QHashIterator::operator=(const QHash &hash) + \fn QMutableHashIterator &QMutableHashIterator::operator=(QHash &hash) + + Makes the iterator operate on \a hash. The iterator is set to be + at the front of the hash (before the first item). + + \sa toFront(), toBack() +*/ + +/*! \fn void QMapIterator::toFront() + \fn void QHashIterator::toFront() + \fn void QMutableMapIterator::toFront() + \fn void QMutableHashIterator::toFront() + + Moves the iterator to the front of the container (before the + first item). + + \sa toBack(), next() +*/ + +/*! \fn void QMapIterator::toBack() + \fn void QHashIterator::toBack() + \fn void QMutableMapIterator::toBack() + \fn void QMutableHashIterator::toBack() + + Moves the iterator to the back of the container (after the last + item). + + \sa toFront(), previous() +*/ + +/*! \fn bool QMapIterator::hasNext() const + \fn bool QHashIterator::hasNext() const + \fn bool QMutableMapIterator::hasNext() const + \fn bool QMutableHashIterator::hasNext() const + + Returns true if there is at least one item ahead of the iterator, + i.e. the iterator is \e not at the back of the container; + otherwise returns false. + + \sa hasPrevious(), next() +*/ + +/*! \fn QMapIterator::Item QMapIterator::next() + \fn QHashIterator::Item QHashIterator::next() + + Returns the next item and advances the iterator by one position. + + Call key() on the return value to obtain the item's key, and + value() to obtain the value. + + Calling this function on an iterator located at the back of the + container leads to undefined results. + + \sa hasNext(), peekNext(), previous() +*/ + +/*! \fn QMutableMapIterator::Item QMutableMapIterator::next() + \fn QMutableHashIterator::Item QMutableHashIterator::next() + + Returns the next item and advances the iterator by one position. + + Call key() on the return value to obtain the item's key, and + value() to obtain the value. + + Calling this function on an iterator located at the back of the + container leads to undefined results. + + \sa hasNext(), peekNext(), previous() +*/ + +/*! \fn QMapIterator::Item QMapIterator::peekNext() const + \fn QHashIterator::Item QHashIterator::peekNext() const + + Returns the next item without moving the iterator. + + Call key() on the return value to obtain the item's key, and + value() to obtain the value. + + Calling this function on an iterator located at the back of the + container leads to undefined results. + + \sa hasNext(), next(), peekPrevious() +*/ + +/*! \fn QMutableMapIterator::Item QMutableMapIterator::peekNext() const + \fn QMutableHashIterator::Item QMutableHashIterator::peekNext() const + + Returns a reference to the next item without moving the iterator. + + Call key() on the return value to obtain the item's key, and + value() to obtain the value. + + Calling this function on an iterator located at the back of the + container leads to undefined results. + + \sa hasNext(), next(), peekPrevious() +*/ + +/*! \fn bool QMapIterator::hasPrevious() const + \fn bool QHashIterator::hasPrevious() const + \fn bool QMutableMapIterator::hasPrevious() const + \fn bool QMutableHashIterator::hasPrevious() const + + Returns true if there is at least one item behind the iterator, + i.e. the iterator is \e not at the front of the container; + otherwise returns false. + + \sa hasNext(), previous() +*/ + +/*! \fn QMapIterator::Item QMapIterator::previous() + \fn QHashIterator::Item QHashIterator::previous() + + Returns the previous item and moves the iterator back by one + position. + + Call key() on the return value to obtain the item's key, and + value() to obtain the value. + + Calling this function on an iterator located at the front of the + container leads to undefined results. + + \sa hasPrevious(), peekPrevious(), next() +*/ + +/*! \fn QMutableMapIterator::Item QMutableMapIterator::previous() + \fn QMutableHashIterator::Item QMutableHashIterator::previous() + + Returns the previous item and moves the iterator back by one + position. + + Call key() on the return value to obtain the item's key, and + value() to obtain the value. + + Calling this function on an iterator located at the front of the + container leads to undefined results. + + \sa hasPrevious(), peekPrevious(), next() +*/ + +/*! \fn QMapIterator::Item QMapIterator::peekPrevious() const + \fn QHashIterator::Item QHashIterator::peekPrevious() const + + Returns the previous item without moving the iterator. + + Call key() on the return value to obtain the item's key, and + value() to obtain the value. + + Calling this function on an iterator located at the front of the + container leads to undefined results. + + \sa hasPrevious(), previous(), peekNext() +*/ + +/*! \fn QMutableMapIterator::Item QMutableMapIterator::peekPrevious() const + \fn QMutableHashIterator::Item QMutableHashIterator::peekPrevious() const + + Returns the previous item without moving the iterator. + + Call key() on the return value to obtain the item's key, and + value() to obtain the value. + + Calling this function on an iterator located at the front of the + container leads to undefined results. + + \sa hasPrevious(), previous(), peekNext() +*/ + +/*! \fn const T &QMapIterator::value() const + \fn const T &QHashIterator::value() const + + Returns the value of the last item that was jumped over using one + of the traversal functions (next(), previous(), findNext(), + findPrevious()). + + After a call to next() or findNext(), value() is + equivalent to peekPrevious().value(). After a call to previous() + or findPrevious(), value() is equivalent to peekNext().value(). + + \sa key() +*/ + +/*! + \fn const T &QMutableMapIterator::value() const + \fn const T &QMutableHashIterator::value() const + + Returns the value of the last item that was jumped over using one + of the traversal functions (next(), previous(), findNext(), + findPrevious()). + + After a call to next() or findNext(), value() is + equivalent to peekPrevious().value(). After a call to previous() + or findPrevious(), value() is equivalent to peekNext().value(). + + \sa key(), setValue() +*/ + +/*! + \fn T &QMutableMapIterator::value() + \fn T &QMutableHashIterator::value() + \overload + + Returns a non-const reference to the value of + the last item that was jumped over using one + of the traversal functions. +*/ + +/*! \fn const Key &QMapIterator::key() const + \fn const Key &QHashIterator::key() const + \fn const Key &QMutableMapIterator::key() const + \fn const Key &QMutableHashIterator::key() const + + Returns the key of the last item that was jumped over using one + of the traversal functions (next(), previous(), findNext(), + findPrevious()). + + After a call to next() or findNext(), key() is + equivalent to peekPrevious().key(). After a call to previous() or + findPrevious(), key() is equivalent to peekNext().key(). + + \sa value() +*/ + +/*! \fn bool QMapIterator::findNext(const T &value) + \fn bool QHashIterator::findNext(const T &value) + \fn bool QMutableMapIterator::findNext(const T &value) + \fn bool QMutableHashIterator::findNext(const T &value) + + Searches for \a value starting from the current iterator position + forward. Returns true if a (key, value) pair with value \a value + is found; otherwise returns false. + + After the call, if \a value was found, the iterator is positioned + just after the matching item; otherwise, the iterator is + positioned at the back of the container. + + \sa findPrevious() +*/ + +/*! \fn bool QMapIterator::findPrevious(const T &value) + \fn bool QHashIterator::findPrevious(const T &value) + \fn bool QMutableMapIterator::findPrevious(const T &value) + \fn bool QMutableHashIterator::findPrevious(const T &value) + + Searches for \a value starting from the current iterator position + backward. Returns true if a (key, value) pair with value \a value + is found; otherwise returns false. + + After the call, if \a value was found, the iterator is positioned + just before the matching item; otherwise, the iterator is + positioned at the front of the container. + + \sa findNext() +*/ + +/*! \fn void QMutableMapIterator::remove() + \fn void QMutableHashIterator::remove() + + Removes the last item that was jumped over using one of the + traversal functions (next(), previous(), findNext(), findPrevious()). + + \sa setValue() +*/ + +/*! \fn void QMutableMapIterator::setValue(const T &value) + \fn void QMutableHashIterator::setValue(const T &value) + + Replaces the value of the last item that was jumped over using + one of the traversal functions with \a value. + + The traversal functions are next(), previous(), findNext(), and + findPrevious(). + + \sa key(), value(), remove() +*/ diff --git a/doc/src/classes/qmacstyle.qdoc b/doc/src/classes/qmacstyle.qdoc new file mode 100644 index 0000000..ae2d95b --- /dev/null +++ b/doc/src/classes/qmacstyle.qdoc @@ -0,0 +1,261 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +/*! + \class QMacStyle + \brief The QMacStyle class provides a Mac OS X style using the Apple Appearance Manager. + + \ingroup appearance + + This class is implemented as a wrapper to the HITheme + APIs, allowing applications to be styled according to the current + theme in use on Mac OS X. This is done by having primitives + in QStyle implemented in terms of what Mac OS X would normally theme. + + \warning This style is only available on Mac OS X because it relies on the + HITheme APIs. + + There are additional issues that should be taken + into consideration to make an application compatible with the + \link http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html + Apple Human Interface Guidelines \endlink. Some of these issues are outlined + below. + + \list + + \i Layout - The restrictions on window layout are such that some + aspects of layout that are style-dependent cannot be achieved + using QLayout. Changes are being considered (and feedback would be + appreciated) to make layouts QStyle-able. Some of the restrictions + involve horizontal and vertical widget alignment and widget size + (covered below). + + \i Widget size - Mac OS X allows widgets to have specific fixed sizes. Qt + does not fully implement this behavior so as to maintain cross-platform + compatibility. As a result some widgets sizes may be inappropriate (and + subsequently not rendered correctly by the HITheme APIs).The + QWidget::sizeHint() will return the appropriate size for many + managed widgets (widgets enumerated in \l QStyle::ContentsType). + + \i Effects - QMacStyle uses HITheme for performing most of the drawing, but + also uses emulation in a few cases where HITheme does not provide the + required functionality (for example, tab bars on Panther, the toolbar + separator, etc). We tried to make the emulation as close to the original as + possible. Please report any issues you see in effects or non-standard + widgets. + + \endlist + + There are other issues that need to be considered in the feel of + your application (including the general color scheme to match the + Aqua colors). The Guidelines mentioned above will remain current + with new advances and design suggestions for Mac OS X. + + Note that the functions provided by QMacStyle are + reimplementations of QStyle functions; see QStyle for their + documentation. + + \img qmacstyle.png + \sa QWindowsXPStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle +*/ + + +/*! + \enum QMacStyle::WidgetSizePolicy + + \value SizeSmall + \value SizeLarge + \value SizeMini + \value SizeDefault + \omitvalue SizeNone +*/ + +/*! \fn QMacStyle::QMacStyle() + Constructs a QMacStyle object. +*/ + +/*! \fn QMacStyle::~QMacStyle() + Destructs a QMacStyle object. +*/ + +/*! \fn void QMacStyle::polish(QPalette &pal) + \reimp +*/ + +/*! \fn void QMacStyle::polish(QApplication *) + \reimp +*/ + +/*! \fn void QMacStyle::unpolish(QApplication *) + \reimp +*/ + +/*! \fn void QMacStyle::polish(QWidget* w) + \reimp +*/ + +/*! \fn void QMacStyle::unpolish(QWidget* w) + \reimp +*/ + +/*! \fn int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *widget) const + \reimp +*/ + +/*! \fn QPalette QMacStyle::standardPalette() const + \reimp +*/ + +/*! \fn int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *hret) const + \reimp +*/ + +/*! \fn QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const + \reimp +*/ + +/*! \fn QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const + \reimp +*/ + +/*! + \enum QMacStyle::FocusRectPolicy + + This type is used to signify a widget's focus rectangle policy. + + \value FocusEnabled show a focus rectangle when the widget has focus. + \value FocusDisabled never show a focus rectangle for the widget. + \value FocusDefault show a focus rectangle when the widget has + focus and the widget is a QSpinWidget, QDateTimeEdit, QLineEdit, + QListBox, QListView, editable QTextEdit, or one of their + subclasses. +*/ + +/*! \fn void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy) + \obsolete + Sets the focus rectangle policy of \a w. The \a policy can be one of + \l{QMacStyle::FocusRectPolicy}. + + This is now simply an interface to the Qt::WA_MacShowFocusRect attribute and the + FocusDefault value does nothing anymore. If you want to set a widget back + to its default value, you must save the old value of the attribute before + you change it. + + \sa focusRectPolicy() QWidget::setAttribute() +*/ + +/*! \fn QMacStyle::FocusRectPolicy QMacStyle::focusRectPolicy(const QWidget *w) + \obsolete + Returns the focus rectangle policy for the widget \a w. + + The focus rectangle policy can be one of \l{QMacStyle::FocusRectPolicy}. + + In 4.3 and up this function will simply test for the + Qt::WA_MacShowFocusRect attribute and will never return + QMacStyle::FocusDefault. + + \sa setFocusRectPolicy(), QWidget::testAttribute() +*/ + +/*! \fn void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy) + + \obsolete + + Call QWidget::setAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, + or Qt::WA_MacNormalSize instead. +*/ + +/*! \fn QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget) + \obsolete + + Call QWidget::testAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, + or Qt::WA_MacNormalSize instead. +*/ + +/*! \fn void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const + + \reimp +*/ + +/*! \fn void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w) const + + \reimp +*/ + +/*! \fn QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const + + \reimp +*/ + +/*! \fn void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const + \reimp +*/ + +/*! \fn QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget) const + \reimp +*/ + +/*! \fn QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const + \reimp +*/ + +/*! \fn QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &csz, const QWidget *widget) const + \reimp +*/ + +/*! \fn void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const + \reimp +*/ + +/*! \fn bool QMacStyle::event(QEvent *e) + \reimp +*/ + +/*! \fn QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt, const QWidget *widget) const + \internal +*/ + +/*! \fn int QMacStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const + + \internal +*/ + diff --git a/doc/src/classes/qpagesetupdialog.qdoc b/doc/src/classes/qpagesetupdialog.qdoc new file mode 100644 index 0000000..7f0b09e --- /dev/null +++ b/doc/src/classes/qpagesetupdialog.qdoc @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QPageSetupDialog + + \brief The QPageSetupDialog class provides a configuration dialog + for the page-related options on a printer. + + On Windows and Mac OS X the page setup dialog is implemented using + the native page setup dialogs. + + Note that on Windows and Mac OS X custom paper sizes won't be + reflected in the native page setup dialogs. Additionally, custom + page margins set on a QPrinter won't show in the native Mac OS X + page setup dialog. + + \sa QPrinter, QPrintDialog +*/ + + +/*! + \fn QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent) + + Constructs a page setup dialog that configures \a printer with \a + parent as the parent widget. +*/ + +/*! + \since 4.5 + + \fn QPageSetupDialog::QPageSetupDialog(QWidget *parent) + + Constructs a page setup dialog that configures a default-constructed + QPrinter with \a parent as the parent widget. + + \sa printer() +*/ + +/*! + \fn QPrinter *QPageSetupDialog::printer() + + Returns the printer that was passed to the QPageSetupDialog + constructor. +*/ + diff --git a/doc/src/classes/qpaintdevice.qdoc b/doc/src/classes/qpaintdevice.qdoc new file mode 100644 index 0000000..0f4e9a0 --- /dev/null +++ b/doc/src/classes/qpaintdevice.qdoc @@ -0,0 +1,289 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QPaintDevice + \brief The QPaintDevice class is the base class of objects that + can be painted. + + \ingroup multimedia + + A paint device is an abstraction of a two-dimensional space that + can be drawn using a QPainter. Its default coordinate system has + its origin located at the top-left position. X increases to the + right and Y increases downwards. The unit is one pixel. + + The drawing capabilities of QPaintDevice are currently implemented + by the QWidget, QImage, QPixmap, QGLPixelBuffer, QPicture, and + QPrinter subclasses. + + To implement support for a new backend, you must derive from + QPaintDevice and reimplement the virtual paintEngine() function to + tell QPainter which paint engine should be used to draw on this + particular device. Note that you also must create a corresponding + paint engine to be able to draw on the device, i.e derive from + QPaintEngine and reimplement its virtual functions. + + \warning Qt requires that a QApplication object exists before + any paint devices can be created. Paint devices access window + system resources, and these resources are not initialized before + an application object is created. + + The QPaintDevice class provides several functions returning the + various device metrics: The depth() function returns its bit depth + (number of bit planes). The height() function returns its height + in default coordinate system units (e.g. pixels for QPixmap and + QWidget) while heightMM() returns the height of the device in + millimeters. Similiarily, the width() and widthMM() functions + return the width of the device in default coordinate system units + and in millimeters, respectively. Alternatively, the protected + metric() function can be used to retrieve the metric information + by specifying the desired PaintDeviceMetric as argument. + + The logicalDpiX() and logicalDpiY() functions return the + horizontal and vertical resolution of the device in dots per + inch. The physicalDpiX() and physicalDpiY() functions also return + the resolution of the device in dots per inch, but note that if + the logical and vertical resolution differ, the corresponding + QPaintEngine must handle the mapping. Finally, the numColors() + function returns the number of different colors available for the + paint device. + + \sa QPaintEngine, QPainter, {The Coordinate System}, {The Paint + System} +*/ + +/*! + \enum QPaintDevice::PaintDeviceMetric + + Describes the various metrics of a paint device. + + \value PdmWidth The width of the paint device in default + coordinate system units (e.g. pixels for QPixmap and QWidget). See + also width(). + + \value PdmHeight The height of the paint device in default + coordinate system units (e.g. pixels for QPixmap and QWidget). See + also height(). + + \value PdmWidthMM The width of the paint device in millimeters. See + also widthMM(). + + \value PdmHeightMM The height of the paint device in millimeters. See + also heightMM(). + + \value PdmNumColors The number of different colors available for + the paint device. See also numColors(). + + \value PdmDepth The bit depth (number of bit planes) of the paint + device. See also depth(). + + \value PdmDpiX The horizontal resolution of the device in dots per + inch. See also logicalDpiX(). + + \value PdmDpiY The vertical resolution of the device in dots per inch. See + also logicalDpiY(). + + \value PdmPhysicalDpiX The horizontal resolution of the device in + dots per inch. See also physicalDpiX(). + + \value PdmPhysicalDpiY The vertical resolution of the device in + dots per inch. See also physicalDpiY(). + + \sa metric() +*/ + +/*! + \fn QPaintDevice::QPaintDevice() + + Constructs a paint device. This constructor can be invoked only from + subclasses of QPaintDevice. +*/ + +/*! + \fn QPaintDevice::~QPaintDevice() + + Destroys the paint device and frees window system resources. +*/ + +/*! + \fn int QPaintDevice::devType() const + + \internal + + Returns the device type identifier, which is QInternal::Widget + if the device is a QWidget, QInternal::Pixmap if it's a + QPixmap, QInternal::Printer if it's a QPrinter, + QInternal::Picture if it's a QPicture, or + QInternal::UnknownDevice in other cases. +*/ + +/*! + \fn bool QPaintDevice::paintingActive() const + + Returns true if the device is currently being painted on, i.e. someone has + called QPainter::begin() but not yet called QPainter::end() for + this device; otherwise returns false. + + \sa QPainter::isActive() +*/ + +/*! + \fn QPaintEngine *QPaintDevice::paintEngine() const + + Returns a pointer to the paint engine used for drawing on the + device. +*/ + +/*! + \fn int QPaintDevice::metric(PaintDeviceMetric metric) const + + Returns the metric information for the given paint device \a metric. + + \sa PaintDeviceMetric +*/ + +/*! + \fn int QPaintDevice::width() const + + Returns the width of the paint device in default coordinate system + units (e.g. pixels for QPixmap and QWidget). + + \sa widthMM() +*/ + +/*! + \fn int QPaintDevice::height() const + + Returns the height of the paint device in default coordinate + system units (e.g. pixels for QPixmap and QWidget). + + \sa heightMM() +*/ + +/*! + \fn int QPaintDevice::widthMM() const + + Returns the width of the paint device in millimeters. Due to platform + limitations it may not be possible to use this function to determine + the actual physical size of a widget on the screen. + + \sa width() +*/ + +/*! + \fn int QPaintDevice::heightMM() const + + Returns the height of the paint device in millimeters. Due to platform + limitations it may not be possible to use this function to determine + the actual physical size of a widget on the screen. + + \sa height() +*/ + +/*! + \fn int QPaintDevice::numColors() const + + Returns the number of different colors available for the paint + device. Since this value is an int, it will not be sufficient to represent + the number of colors on 32 bit displays, in this case INT_MAX is + returned instead. +*/ + +/*! + \fn int QPaintDevice::depth() const + + Returns the bit depth (number of bit planes) of the paint device. +*/ + +/*! + \fn int QPaintDevice::logicalDpiX() const + + Returns the horizontal resolution of the device in dots per inch, + which is used when computing font sizes. For X11, this is usually + the same as could be computed from widthMM(). + + Note that if the logicalDpiX() doesn't equal the physicalDpiX(), + the corresponding QPaintEngine must handle the resolution mapping. + + \sa logicalDpiY(), physicalDpiX() +*/ + +/*! + \fn int QPaintDevice::logicalDpiY() const + + Returns the vertical resolution of the device in dots per inch, + which is used when computing font sizes. For X11, this is usually + the same as could be computed from heightMM(). + + Note that if the logicalDpiY() doesn't equal the physicalDpiY(), + the corresponding QPaintEngine must handle the resolution mapping. + + \sa logicalDpiX(), physicalDpiY() +*/ + +/*! + \fn int QPaintDevice::physicalDpiX() const + + Returns the horizontal resolution of the device in dots per inch. + For example, when printing, this resolution refers to the physical + printer's resolution. The logical DPI on the other hand, refers to + the resolution used by the actual paint engine. + + Note that if the physicalDpiX() doesn't equal the logicalDpiX(), + the corresponding QPaintEngine must handle the resolution mapping. + + \sa physicalDpiY(), logicalDpiX() +*/ + +/*! + \fn int QPaintDevice::physicalDpiY() const + + Returns the horizontal resolution of the device in dots per inch. + For example, when printing, this resolution refers to the physical + printer's resolution. The logical DPI on the other hand, refers to + the resolution used by the actual paint engine. + + Note that if the physicalDpiY() doesn't equal the logicalDpiY(), + the corresponding QPaintEngine must handle the resolution mapping. + + \sa physicalDpiX(), logicalDpiY() +*/ diff --git a/doc/src/classes/qpair.qdoc b/doc/src/classes/qpair.qdoc new file mode 100644 index 0000000..6d8a0f9 --- /dev/null +++ b/doc/src/classes/qpair.qdoc @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QPair + \brief The QPair class is a template class that stores a pair of items. + + \ingroup tools + + QPair\ can be used in your application if the STL \c + pair type is not available. It stores one value of type T1 and + one value of type T2. It can be used as a return value for a + function that needs to return two values, or as the value type of + a \l{generic container}. + + Here's an example of a QPair that stores one QString and one \c + double value: + + \snippet doc/src/snippets/code/doc_src_qpair.qdoc 0 + + The components are accessible as public data members called \l + first and \l second. For example: + + \snippet doc/src/snippets/code/doc_src_qpair.qdoc 1 + + QPair's template data types (T1 and T2) must be \l{assignable + data types}. You cannot, for example, store a QWidget as a value; + instead, store a QWidget *. A few functions have additional + requirements; these requirements are documented on a per-function + basis. + + \sa {Generic Containers} +*/ + +/*! \typedef QPair::first_type + + The type of the first element in the pair (T1). + + \sa first +*/ + +/*! \typedef QPair::second_type + + The type of the second element in the pair (T2). + + \sa second +*/ + +/*! \variable QPair::first + + The first element in the pair. +*/ + +/*! \variable QPair::second + + The second element in the pair. +*/ + +/*! \fn QPair::QPair() + + Constructs an empty pair. The \c first and \c second elements are + initialized with \l{default-constructed values}. +*/ + +/*! + \fn QPair::QPair(const T1 &value1, const T2 &value2) + + Constructs a pair and initializes the \c first element with \a + value1 and the \c second element with \a value2. + + \sa qMakePair() +*/ + +/*! + \fn QPair &QPair::operator=(const QPair &other) + + Assigns \a other to this pair. +*/ + +/*! \fn bool operator==(const QPair &p1, const QPair &p2) + + \relates QPair + + Returns true if \a p1 is equal to \a p2; otherwise returns false. + Two pairs compare equal if their \c first data members compare + equal and if their \c second data members compare equal. + + This function requires the T1 and T2 types to have an + implementation of \c operator==(). +*/ + +/*! \fn bool operator!=(const QPair &p1, const QPair &p2) + + \relates QPair + + Returns true if \a p1 is not equal to \a p2; otherwise returns + false. Two pairs compare as not equal if their \c first data + members are not equal or if their \c second data members are not + equal. + + This function requires the T1 and T2 types to have an + implementation of \c operator==(). +*/ + +/*! \fn bool operator<(const QPair &p1, const QPair &p2) + + \relates QPair + + Returns true if \a p1 is less than \a p2; otherwise returns + false. The comparison is done on the \c first members of \a p1 + and \a p2; if they compare equal, the \c second members are + compared to break the tie. + + This function requires the T1 and T2 types to have an + implementation of \c operator<(). +*/ + +/*! \fn bool operator>(const QPair &p1, const QPair &p2) + + \relates QPair + + Returns true if \a p1 is greater than \a p2; otherwise returns + false. The comparison is done on the \c first members of \a p1 + and \a p2; if they compare equal, the \c second members are + compared to break the tie. + + This function requires the T1 and T2 types to have an + implementation of \c operator<(). +*/ + +/*! \fn bool operator<=(const QPair &p1, const QPair &p2) + + \relates QPair + + Returns true if \a p1 is less than or equal to \a p2; otherwise + returns false. The comparison is done on the \c first members of + \a p1 and \a p2; if they compare equal, the \c second members are + compared to break the tie. + + This function requires the T1 and T2 types to have an + implementation of \c operator<(). +*/ + +/*! \fn bool operator>=(const QPair &p1, const QPair &p2) + + \relates QPair + + Returns true if \a p1 is greater than or equal to \a p2; + otherwise returns false. The comparison is done on the \c first + members of \a p1 and \a p2; if they compare equal, the \c second + members are compared to break the tie. + + This function requires the T1 and T2 types to have an + implementation of \c operator<(). +*/ + +/*! + \fn QPair qMakePair(const T1 &value1, const T2 &value2) + + \relates QPair + + Returns a QPair\ that contains \a value1 and \a value2. + Example: + + \snippet doc/src/snippets/code/doc_src_qpair.qdoc 2 + + This is equivalent to QPair(\a value1, \a value2), but + usually requires less typing. +*/ + +/*! \fn QDataStream &operator>>(QDataStream &in, QPair &pair) + + \relates QPair + + Reads a pair from stream \a in into \a pair. + + This function requires the T1 and T2 types to implement \c operator>>(). + + \sa {Format of the QDataStream operators} +*/ + +/*! \fn QDataStream &operator<<(QDataStream &out, const QPair &pair) + + \relates QPair + + Writes the pair \a pair to stream \a out. + + This function requires the T1 and T2 types to implement \c operator<<(). + + \sa {Format of the QDataStream operators} +*/ diff --git a/doc/src/classes/qpatternistdummy.cpp b/doc/src/classes/qpatternistdummy.cpp new file mode 100644 index 0000000..a690184 --- /dev/null +++ b/doc/src/classes/qpatternistdummy.cpp @@ -0,0 +1,1010 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + + This file exists only to make internal all the classes you see + below. they are all in the QPatternist namespace, but they don't + have qdoc documentation because they are all declared in xxx_p.h files. Without these \internal declarations, the class names + appear on the Inheritance Hierarchy page, which is bad because + clicking on them brings up the "File not found" page. + */ + +#include "qitem_p.h" +#include "qbuiltintypes_p.h" +#include "qitem_p.h" +#include "qschematypefactory_p.h" +#include "qxmlname.h" +#include "qatomictype_p.h" + +QT_BEGIN_NAMESPACE + +using namespace QPatternist; + +/*! + \class AtomicCaster + \internal + */ + +/*! + \class AtomicComparator + \internal + */ + +/*! + \class AtomicMathematician + \internal + */ + +/*! + \class AtomicValue + \internal + */ + +/*! + \class AbstractDateTime + \internal + */ + +/*! + \class AbstractDuration + \internal + */ + +/*! + \class AbstractFloatComparator + \internal + */ + +/*! + \class AtomicString + \internal + */ + +/*! + \class Base64Binary + \internal + */ + +/*! + \class FunctionCall + \internal + */ + +/*! + \class AddingAggregate + \internal + */ + +/*! + \class AdjustTimezone + \internal + */ + +/*! + \class Aggregator + \internal + */ + +/*! + \class ComparesCaseAware + \internal + */ + +/*! + \class EncodeString + \internal + */ + +/*! + \class ExtractFromDateTimeFN + \internal + */ + +/*! + \class ExtractFromDurationFN + \internal + */ + +/*! + \class FunctionFactory + \internal + */ + +/*! + \class Numeric + \internal + */ + +/*! + \class ReportContext + \internal + */ + +/*! + \class AbstractFunctionFactory + \internal + */ + +/*! + \class DynamicContext + \internal + */ + +/*! + \class IdFN + \internal + */ + +/*! + \class IntegerType + \internal + */ + +/*! + \class NamespaceResolver + \internal + */ + +/*! + \class PatternPlatform + \internal + */ + +/*! \class DocumentProjector + \internal */ +/*! \class NodeBuilder + \internal */ +/*! \class AccelTreeBuilder + \internal */ +/*! \class OutputValidator + \internal */ +/*! \class NetworkLoop + \internal */ +/*! \class QIODeviceDelegate + \internal */ +/*! \class URILoader + \internal */ +/*! \class AbsFN + \internal */ +/*! \class AbstractDateTimeComparator + \internal */ +/*! \class AbstractDateTimeMathematician + \internal */ +/*! \class AbstractDateTimeToDateCaster + \internal */ +/*! \class AbstractDateTimeToDateTimeCaster + \internal */ +/*! \class AbstractDateTimeToGDayCaster + \internal */ +/*! \class AbstractDateTimeToGMonthCaster + \internal */ +/*! \class AbstractDateTimeToGMonthDayCaster + \internal */ +/*! \class AbstractDateTimeToGYearCaster + \internal */ +/*! \class AbstractDateTimeToGYearMonthCaster + \internal */ +/*! \class AbstractDateTimeToTimeCaster + \internal */ +/*! \class AbstractDurationComparator + \internal */ +/*! \class AbstractDurationToDayTimeDurationCaster + \internal */ +/*! \class AbstractDurationToDurationCaster + \internal */ +/*! \class AbstractDurationToYearMonthDurationCaster + \internal */ +/*! \class AbstractFloat + \internal */ +/*! \class AbstractFloatMathematician + \internal */ +/*! \class AbstractFloatSortComparator + \internal */ +/*! \class ConstructorFunctionsFactory + \internal */ +/*! \class XPath10CoreFunctions + \internal */ +/*! \class XPath20CoreFunctions + \internal */ +/*! \class AdjustDateTimeToTimezoneFN + \internal */ +/*! \class AdjustDateToTimezoneFN + \internal */ +/*! \class AdjustTimeToTimezoneFN + \internal */ +/*! \class AnyToDerivedStringCaster + \internal */ +/*! \class AnyURI + \internal */ +/*! \class Atomizer + \internal */ +/*! \class AvgFN + \internal */ +/*! \class Base64BinaryComparatorLocator + \internal */ +/*! \class Base64BinaryToHexBinaryCaster + \internal */ +/*! \class Base64BinaryType + \internal */ +/*! \class BaseURIFN + \internal */ +/*! \class BinaryDataComparator + \internal */ +/*! \class Boolean + \internal */ +/*! \class BooleanComparator + \internal */ +/*! \class BooleanComparatorLocator + \internal */ +/*! \class BooleanFN + \internal */ +/*! \class BooleanToAbstractFloatCaster + \internal */ +/*! \class BooleanToDecimalCaster + \internal */ +/*! \class BooleanToDerivedIntegerCaster + \internal */ +/*! \class BooleanToIntegerCaster + \internal */ +/*! \class BooleanType + \internal */ +/*! \class BuiltinNodeType + \internal */ +/*! \class CardinalityVerifier + \internal */ +/*! \class CaseInsensitiveStringComparator + \internal */ +/*! \class CeilingFN + \internal */ +/*! \class CodepointEqualFN + \internal */ +/*! \class CodepointsToStringFN + \internal */ +/*! \class CollectionFN + \internal */ +/*! \class CompareFN + \internal */ +/*! \class ComparingAggregator + \internal */ +/*! \class ConcatFN + \internal */ +/*! \class ContainsFN + \internal */ +/*! \class CountFN + \internal */ +/*! \class CurrentDateFN + \internal */ +/*! \class CurrentDateTimeFN + \internal */ +/*! \class CurrentTimeFN + \internal */ +/*! \class Date + \internal */ +/*! \class DateComparatorLocator + \internal */ +/*! \class DateMathematicianLocator + \internal */ +/*! \class DateTime + \internal */ +/*! \class DateTimeComparatorLocator + \internal */ +/*! \class DateTimeDurationMathematician + \internal */ +/*! \class DateTimeFN + \internal */ +/*! \class DateTimeMathematicianLocator + \internal */ +/*! \class DateTimeType + \internal */ +/*! \class DateType + \internal */ +/*! \class DayFromAbstractDateTimeFN + \internal */ +/*! \class DayTimeDuration + \internal */ +/*! \class DayTimeDurationComparatorLocator + \internal */ +/*! \class DayTimeDurationMathematicianLocator + \internal */ +/*! \class DayTimeDurationType + \internal */ +/*! \class DaysFromDurationFN + \internal */ +/*! \class Decimal + \internal */ +/*! \class DecimalComparator + \internal */ +/*! \class DecimalComparatorLocator + \internal */ +/*! \class DecimalMathematician + \internal */ +/*! \class DecimalMathematicianLocator + \internal */ +/*! \class DecimalType + \internal */ +/*! \class DeduplicateIterator + \internal */ +/*! \class DeepEqualFN + \internal */ +/*! \class DefaultCollationFN + \internal */ +/*! \class DerivedInteger + \internal */ +/*! \class DerivedString + \internal */ +/*! \class DistinctValuesFN + \internal */ +/*! \class DocAvailableFN + \internal */ +/*! \class DocFN + \internal */ +/*! \class DocumentURIFN + \internal */ +/*! \class DoubleComparatorLocator + \internal */ +/*! \class DoubleMathematicianLocator + \internal */ +/*! \class DoubleType + \internal */ +/*! \class Duration + \internal */ +/*! \class DurationComparatorLocator + \internal */ +/*! \class DurationDurationDivisor + \internal */ +/*! \class DurationDurationMathematician + \internal */ +/*! \class DurationNumericMathematician + \internal */ +/*! \class DurationType + \internal */ +/*! \class DelegatingDynamicContext + \internal */ +/*! \class Focus + \internal */ +/*! \class ReceiverDynamicContext + \internal */ +/*! \class EmptyIterator + \internal */ +/*! \class EncodeForURIFN + \internal */ +/*! \class EndsWithFN + \internal */ +/*! \class ErrorFN + \internal */ +/*! \class EscapeHtmlURIFN + \internal */ +/*! \class EvaluationCache + \internal */ +/*! \class Existence + \internal */ +/*! \class ExpressionVisitor + \internal */ +/*! \class ExpressionVisitorResult + \internal */ +/*! \class FalseFN + \internal */ +/*! \class FloatComparatorLocator + \internal */ +/*! \class FloatMathematicianLocator + \internal */ +/*! \class FloatType + \internal */ +/*! \class FloorFN + \internal */ +/*! \class FunctionArgument + \internal */ +/*! \class FunctionAvailableFN + \internal */ +/*! \class FunctionFactoryCollection + \internal */ +/*! \class FunctionSignature + \internal */ +/*! \class GDay + \internal */ +/*! \class GDayComparatorLocator + \internal */ +/*! \class GDayType + \internal */ +/*! \class GMonth + \internal */ +/*! \class GMonthComparatorLocator + \internal */ +/*! \class GMonthDay + \internal */ +/*! \class GMonthDayComparatorLocator + \internal */ +/*! \class GMonthDayType + \internal */ +/*! \class GMonthType + \internal */ +/*! \class GYear + \internal */ +/*! \class GYearComparatorLocator + \internal */ +/*! \class GYearMonth + \internal */ +/*! \class GYearMonthComparatorLocator + \internal */ +/*! \class GYearMonthType + \internal */ +/*! \class GYearType + \internal */ +/*! \class HexBinary + \internal */ +/*! \class HexBinaryComparatorLocator + \internal */ +/*! \class HexBinaryToBase64BinaryCaster + \internal */ +/*! \class HexBinaryType + \internal */ +/*! \class HoursFromAbstractDateTimeFN + \internal */ +/*! \class HoursFromDurationFN + \internal */ +/*! \class IdrefFN + \internal */ +/*! \class ImplicitTimezoneFN + \internal */ +/*! \class InScopePrefixesFN + \internal */ +/*! \class IndexOfFN + \internal */ +/*! \class InsertBeforeFN + \internal */ +/*! \class Integer + \internal */ +/*! \class IntegerComparator + \internal */ +/*! \class IntegerComparatorLocator + \internal */ +/*! \class IntegerMathematician + \internal */ +/*! \class IntegerMathematicianLocator + \internal */ +/*! \class DerivedIntegerType + \internal */ +/*! \class IriToURIFN + \internal */ +/*! \class ItemMappingIterator + \internal */ +/*! \class ItemVerifier + \internal */ +/*! \class LangFN + \internal */ +/*! \class LastFN + \internal */ +/*! \class LocalNameFN + \internal */ +/*! \class LocalNameFromQNameFN + \internal */ +/*! \class LowerCaseFN + \internal */ +/*! \class MinutesFromAbstractDateTimeFN + \internal */ +/*! \class MinutesFromDurationFN + \internal */ +/*! \class MonthFromAbstractDateTimeFN + \internal */ +/*! \class MonthsFromDurationFN + \internal */ +/*! \class NOTATIONType + \internal */ +/*! \class NameFN + \internal */ +/*! \class NamePool + \internal */ +/*! \class DelegatingNamespaceResolver + \internal */ +/*! \class GenericNamespaceResolver + \internal */ +/*! \class NodeNamespaceResolver + \internal */ +/*! \class NamespaceURIFN + \internal */ +/*! \class NamespaceURIForPrefixFN + \internal */ +/*! \class NamespaceURIFromQNameFN + \internal */ +/*! \class NilledFN + \internal */ +/*! \class NodeNameFN + \internal */ +/*! \class NormalizeSpaceFN + \internal */ +/*! \class NormalizeUnicodeFN + \internal */ +/*! \class NotFN + \internal */ +/*! \class NumberFN + \internal */ +/*! \class NumericToAbstractFloatCaster + \internal */ +/*! \class NumericToBooleanCaster + \internal */ +/*! \class NumericToDecimalCaster + \internal */ +/*! \class NumericToDerivedIntegerCaster + \internal */ +/*! \class OperandSwitcherMathematician + \internal */ +/*! \class ParserContext + \internal */ +/*! \class MatchesFN + \internal */ +/*! \class ReplaceFN + \internal */ +/*! \class TokenizeFN + \internal */ +/*! \class PositionFN + \internal */ +/*! \class PrefixFromQNameFN + \internal */ +/*! \class AccelTree + \internal */ +/*! \class QNameComparator + \internal */ +/*! \class QNameComparatorLocator + \internal */ +/*! \class QNameFN + \internal */ +/*! \class QNameType + \internal */ +/*! \class QNameValue + \internal */ +/*! \class RemoveFN + \internal */ +/*! \class ResolveQNameFN + \internal */ +/*! \class ResolveURIFN + \internal */ +/*! \class ResourceLoader + \internal */ +/*! \class AccelTreeResourceLoader + \internal */ +/*! \class ReverseFN + \internal */ +/*! \class RootFN + \internal */ +/*! \class RoundFN + \internal */ +/*! \class RoundHalfToEvenFN + \internal */ +/*! \class SchemaTime + \internal */ +/*! \class SchemaTimeComparatorLocator + \internal */ +/*! \class SchemaTimeMathematicianLocator + \internal */ +/*! \class SchemaTimeType + \internal */ +/*! \class SecondsFromAbstractDateTimeFN + \internal */ +/*! \class SecondsFromDurationFN + \internal */ +/*! \class SelfToSelfCaster + \internal */ +/*! \class SequenceMappingIterator + \internal */ +/*! \class SingletonIterator + \internal */ +/*! \class SortTuple + \internal */ +/*! \class StartsWithFN + \internal */ +/*! \class StaticBaseURIFN + \internal */ +/*! \class StaticContext + \internal */ +/*! \class DelegatingStaticContext + \internal */ +/*! \class StaticFocusContext + \internal */ +/*! \class StaticNamespaceContext + \internal */ +/*! \class GenericStaticContext + \internal */ +/*! \class StringComparator + \internal */ +/*! \class StringComparatorLocator + \internal */ +/*! \class StringFN + \internal */ +/*! \class StringJoinFN + \internal */ +/*! \class StringLengthFN + \internal */ +/*! \class StringToAbstractFloatCaster + \internal */ +/*! \class StringToBase64BinaryCaster + \internal */ +/*! \class StringToBooleanCaster + \internal */ +/*! \class StringToCodepointsFN + \internal */ +/*! \class StringToDateCaster + \internal */ +/*! \class StringToDateTimeCaster + \internal */ +/*! \class StringToDayTimeDurationCaster + \internal */ +/*! \class StringToDecimalCaster + \internal */ +/*! \class StringToDerivedIntegerCaster + \internal */ +/*! \class StringToDurationCaster + \internal */ +/*! \class StringToGDayCaster + \internal */ +/*! \class StringToGMonthCaster + \internal */ +/*! \class StringToGMonthDayCaster + \internal */ +/*! \class StringToGYearCaster + \internal */ +/*! \class StringToGYearMonthCaster + \internal */ +/*! \class StringToHexBinaryCaster + \internal */ +/*! \class StringToIntegerCaster + \internal */ +/*! \class StringToTimeCaster + \internal */ +/*! \class StringToYearMonthDurationCaster + \internal */ +/*! \class StringType + \internal */ +/*! \class DerivedStringType + \internal */ +/*! \class SubsequenceFN + \internal */ +/*! \class SubstringAfterFN + \internal */ +/*! \class SubstringBeforeFN + \internal */ +/*! \class SubstringFN + \internal */ +/*! \class SumFN + \internal */ +/*! \class SystemPropertyFN + \internal */ +/*! \class TimezoneFromAbstractDateTimeFN + \internal */ +/*! \class ToAnyURICaster + \internal */ +/*! \class ToAnyURICasterLocator + \internal */ +/*! \class ToBase64BinaryCasterLocator + \internal */ +/*! \class ToBooleanCasterLocator + \internal */ +/*! \class ToDateCasterLocator + \internal */ +/*! \class ToDateTimeCasterLocator + \internal */ +/*! \class ToDayTimeDurationCasterLocator + \internal */ +/*! \class ToDecimalCasterLocator + \internal */ +/*! \class ToDoubleCasterLocator + \internal */ +/*! \class ToDurationCasterLocator + \internal */ +/*! \class ToFloatCasterLocator + \internal */ +/*! \class ToGDayCasterLocator + \internal */ +/*! \class ToGMonthCasterLocator + \internal */ +/*! \class ToGMonthDayCasterLocator + \internal */ +/*! \class ToGYearCasterLocator + \internal */ +/*! \class ToGYearMonthCasterLocator + \internal */ +/*! \class ToHexBinaryCasterLocator + \internal */ +/*! \class ToIntegerCasterLocator + \internal */ +/*! \class ToDerivedIntegerCasterLocator + \internal */ +/*! \class ToQNameCasterLocator + \internal */ +/*! \class ToSchemaTimeCasterLocator + \internal */ +/*! \class ToStringCaster + \internal */ +/*! \class ToStringCasterLocator + \internal */ +/*! \class ToDerivedStringCasterLocator + \internal */ +/*! \class ToUntypedAtomicCaster + \internal */ +/*! \class ToUntypedAtomicCasterLocator + \internal */ +/*! \class ToYearMonthDurationCasterLocator + \internal */ +/*! \class Tokenizer + \internal */ +/*! \class XQueryTokenizer + \internal */ +/*! \class TraceFN + \internal */ +/*! \class TranslateFN + \internal */ +/*! \class TrueFN + \internal */ +/*! \class UntypedAtomic + \internal */ +/*! \class UntypedAtomicConverter + \internal */ +/*! \class ArgumentConverter + \internal */ +/*! \class UntypedAtomicType + \internal */ +/*! \class UpperCaseFN + \internal */ +/*! \class ValidationError + \internal */ +/*! \class VariableDeclaration + \internal */ +/*! \class VariableLoader + \internal */ +/*! \class YearFromAbstractDateTimeFN + \internal */ +/*! \class YearMonthDuration + \internal */ +/*! \class YearMonthDurationComparatorLocator + \internal */ +/*! \class YearMonthDurationMathematicianLocator + \internal */ +/*! \class YearMonthDurationType + \internal */ +/*! \class YearsFromDurationFN + \internal + */ +/*! \class DocumentContentValidator + \internal */ +/*! \class AtomicTypeVisitor + \internal */ +/*! \class AtomicCasterLocator + \internal */ +/*! \class AtomicTypeVisitorResult + \internal */ +/*! \class Expression + \internal */ +/*! \class EmptyContainer + \internal */ +/*! \class AxisStep + \internal */ +/*! \class ContextItem + \internal */ +/*! \class EmptySequence + \internal */ +/*! \class ExternalVariableReference + \internal */ +/*! \class Literal + \internal */ +/*! \class LiteralSequence + \internal */ +/*! \class NamespaceConstructor + \internal */ +/*! \class ParentNodeAxis + \internal */ +/*! \class VariableReference + \internal */ +/*! \class ArgumentReference + \internal */ +/*! \class ExpressionVariableReference + \internal */ +/*! \class PositionalVariableReference + \internal */ +/*! \class RangeVariableReference + \internal */ +/*! \class PairContainer + \internal */ +/*! \class AndExpression + \internal */ +/*! \class OrExpression + \internal */ +/*! \class ArithmeticExpression + \internal */ +/*! \class UnaryExpression + \internal */ +/*! \class AttributeConstructor + \internal */ +/*! \class CombineNodes + \internal */ +/*! \class ElementConstructor + \internal */ +/*! \class ForClause + \internal */ +/*! \class GeneralComparison + \internal */ +/*! \class GenericPredicate + \internal */ +/*! \class TruthPredicate + \internal */ +/*! \class LetClause + \internal */ +/*! \class NodeComparison + \internal */ +/*! \class Path + \internal */ +/*! \class ProcessingInstructionConstructor + \internal */ +/*! \class QuantifiedExpression + \internal */ +/*! \class RangeExpression + \internal */ +/*! \class ValueComparison + \internal */ +/*! \class SingleContainer + \internal */ +/*! \class AttributeNameValidator + \internal */ +/*! \class CastAs + \internal */ +/*! \class CastableAs + \internal */ +/*! \class CollationChecker + \internal */ +/*! \class CommentConstructor + \internal */ +/*! \class CopyOf + \internal */ +/*! \class DocumentConstructor + \internal */ +/*! \class DynamicContextStore + \internal */ +/*! \class FirstItemPredicate + \internal */ +/*! \class InstanceOf + \internal */ +/*! \class NCNameConstructor + \internal */ +/*! \class NodeSortExpression + \internal */ +/*! \class OrderBy + \internal */ +/*! \class QNameConstructor + \internal */ +/*! \class SimpleContentConstructor + \internal */ +/*! \class TextNodeConstructor + \internal */ +/*! \class TreatAs + \internal */ +/*! \class TripleContainer + \internal */ +/*! \class IfThenClause + \internal */ +/*! \class UnlimitedContainer + \internal */ +/*! \class ExpressionSequence + \internal */ +/*! \class ReturnOrderBy + \internal */ +/*! \class UserFunctionCallsite + \internal */ +/*! \class ExpressionCreator + \internal */ +/*! \class ByIDCreator + \internal */ +/*! \class ExpressionFactory + \internal */ +/*! \class ExpressionIdentifier + \internal */ +/*! \class BooleanIdentifier + \internal */ +/*! \class ByIDIdentifier + \internal */ +/*! \class BySequenceTypeIdentifier + \internal */ +/*! \class ComparisonIdentifier + \internal */ +/*! \class IntegerIdentifier + \internal */ +/*! \class ExternalVariableLoader + \internal */ +/*! \class ItemType + \internal */ +/*! \class AnyItemType + \internal */ +/*! \class AnyNodeType + \internal */ +/*! \class AbstractNodeTest + \internal */ +/*! \class LocalNameTest + \internal */ +/*! \class NamespaceNameTest + \internal */ +/*! \class QNameTest + \internal */ +/*! \class AtomicType + \internal */ +/*! \class BuiltinAtomicType + \internal */ +/*! \class AnyAtomicType + \internal */ +/*! \class AnyURIType + \internal */ +/*! \class NumericType + \internal */ +/*! \class EBVType + \internal */ +/*! \class EmptySequenceType + \internal */ +/*! \class MultiItemType + \internal */ +/*! \class NoneType + \internal */ +/*! \class OptimizationPass + \internal */ +/*! \class ParameterizedAtomicTypeVisitor + \internal */ +/*! \class AtomicComparatorLocator + \internal */ +/*! \class AtomicMathematicianLocator + \internal */ +/*! \class SchemaComponent + \internal */ +/*! \class SchemaType + \internal */ +/*! \class AnyType + \internal */ +/*! \class AnySimpleType + \internal */ +/*! \class Untyped + \internal */ +/*! \class SchemaTypeFactory + \internal */ +/*! \class BasicTypesFactory + \internal */ +/*! \class SequenceType + \internal */ +/*! \class GenericSequenceType + \internal */ +/*! \class UserFunction + \internal +*/ +QT_END_NAMESPACE diff --git a/doc/src/classes/qplugin.qdoc b/doc/src/classes/qplugin.qdoc new file mode 100644 index 0000000..4fbd198 --- /dev/null +++ b/doc/src/classes/qplugin.qdoc @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \headerfile + \title Macros for Defining Plugins + + \brief The header files defines macros for defining plugins. + + \sa {How to Create Qt Plugins} +*/ + +/*! + \macro Q_DECLARE_INTERFACE(ClassName, Identifier) + \relates + + This macro associates the given \a Identifier (a string literal) + to the interface class called \a ClassName. The \a Identifier must + be unique. For example: + + \snippet examples/tools/plugandpaint/interfaces.h 3 + + This macro is normally used right after the class definition for + \a ClassName, in a header file. See the + \l{tools/plugandpaint}{Plug & Paint} example for details. + + If you want to use Q_DECLARE_INTERFACE with interface classes + declared in a namespace then you have to make sure the Q_DECLARE_INTERFACE + is not inside a namespace though. For example: + \snippet doc/src/snippets/code/doc_src_qplugin.qdoc 0 + + \sa Q_INTERFACES(), Q_EXPORT_PLUGIN2(), {How to Create Qt Plugins} +*/ + +/*! + \macro Q_EXPORT_PLUGIN(ClassName) + \relates + \obsolete + + Use Q_EXPORT_PLUGIN2() instead. This macro is equivalent to + Q_EXPORT_PLUGIN2(\a ClassName, \a ClassName). +*/ + +/*! + \macro Q_EXPORT_PLUGIN2(PluginName, ClassName) + \relates + \since 4.1 + \keyword Q_EXPORT_PLUGIN2 + + This macro exports the plugin class \a ClassName for the plugin specified + by \a PluginName. The value of \a PluginName should correspond to the + \l{qmake Variable Reference#TARGET}{TARGET} specified in the plugin's + project file. + + There should be exactly one occurrence of this macro in the source code + for a Qt plugin, and it should be used where the implementation is written + rather than in a header file. + + Example: + + \snippet doc/src/snippets/code/doc_src_qplugin.qdoc 1 + + See the \l{tools/plugandpaint}{Plug & Paint} example for details. + + \sa Q_DECLARE_INTERFACE(), {How to Create Qt Plugins} +*/ + +/*! + \macro Q_IMPORT_PLUGIN(PluginName) + \relates + + This macro imports the plugin named \a PluginName, corresponding + to the \l{qmake Variable Reference#TARGET}{TARGET} specified in the + plugin's project file. + + Inserting this macro into your application's source code will allow + you to make use of a static plugin. + + Example: + + \snippet doc/src/snippets/code/doc_src_qplugin.qdoc 2 + + Static plugins must also be included by the linker when your + application is built. For Qt's predefined plugins, + you can use the \c QTPLUGIN to add + the required plugins to your build. For example: + + \snippet doc/src/snippets/code/doc_src_qplugin.qdoc 3 + + \sa {Static Plugins}, {How to Create Qt Plugins}, {Using qmake} +*/ + +/*! + \macro Q_EXPORT_STATIC_PLUGIN(ClassName) + \relates + \internal +*/ diff --git a/doc/src/classes/qprintdialog.qdoc b/doc/src/classes/qprintdialog.qdoc new file mode 100644 index 0000000..8011f62 --- /dev/null +++ b/doc/src/classes/qprintdialog.qdoc @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifdef QT3_SUPPORT +/*! + \fn QPrinter *QPrintDialog::printer() const + + Returns a pointer to the printer this dialog configures, or 0 if + this dialog does not operate on any printer. + + This function is available for Unix platforms only. +*/ + +/*! + \fn void QPrintDialog::setPrinter(QPrinter *printer, bool pickupSettings) + + Sets this dialog to configure printer \a printer, or no printer if \a printer + is null. If \a pickupSettings is true, the dialog reads most of + its settings from \a printer. If \a pickupSettings is false (the + default) the dialog keeps its old settings. + + This function is available for Unix platforms only. +*/ + +/*! + \fn void QPrintDialog::addButton(QPushButton *button) + + Adds the \a button to the layout of the print dialog. The added + buttons are arranged from the left to the right below the + last groupbox of the printdialog. + + This function is available for Unix platforms only. +*/ +#endif diff --git a/doc/src/classes/qprinterinfo.qdoc b/doc/src/classes/qprinterinfo.qdoc new file mode 100644 index 0000000..a4ffeb2 --- /dev/null +++ b/doc/src/classes/qprinterinfo.qdoc @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QPrinterInfo + + \brief The QPrinterInfo class gives access to information about + existing printers. + + Use the static functions to generate a list of QPrinterInfo + objects. Each QPrinterInfo object in the list represents a single + printer and can be queried for name, supported paper sizes, and + whether or not it is the default printer. + + \since 4.4 +*/ + +/*! + \fn QList QPrinterInfo::availablePrinters() + + Returns a list of available printers on the system. +*/ + +/*! + \fn QPrinterInfo QPrinterInfo::defaultPrinter() + + Returns the default printer on the system. + + The return value should be checked using isNull() before being + used, in case there is no default printer. + + \sa isNull() +*/ + +/*! + \fn QPrinterInfo::QPrinterInfo() + + Constructs an empty QPrinterInfo object. + + \sa isNull() +*/ + +/*! + \fn QPrinterInfo::QPrinterInfo(const QPrinterInfo& src) + + Constructs a copy of \a src. +*/ + +/*! + \fn QPrinterInfo::QPrinterInfo(const QPrinter& printer) + + Constructs a QPrinterInfo object from \a printer. +*/ + +/*! + \fn QPrinterInfo::~QPrinterInfo() + + Destroys the QPrinterInfo object. References to the values in the + object become invalid. +*/ + +/*! + \fn QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src) + + Sets the QPrinterInfo object to be equal to \a src. +*/ + +/*! + \fn QString QPrinterInfo::printerName() const + + Returns the name of the printer. + + \sa QPrinter::setPrinterName() +*/ + +/*! + \fn bool QPrinterInfo::isNull() const + + Returns whether this QPrinterInfo object holds a printer definition. + + An empty QPrinterInfo object could result for example from calling + defaultPrinter() when there are no printers on the system. +*/ + +/*! + \fn bool QPrinterInfo::isDefault() const + + Returns whether this printer is the default printer. +*/ + +/*! + \fn QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const + \since 4.4 + + Returns a list of supported paper sizes by the printer. + + Not all printer drivers support this query, so the list may be empty. + On Mac OS X 10.3, this function always returns an empty list. +*/ diff --git a/doc/src/classes/qset.qdoc b/doc/src/classes/qset.qdoc new file mode 100644 index 0000000..0db3775 --- /dev/null +++ b/doc/src/classes/qset.qdoc @@ -0,0 +1,953 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QSet + \brief The QSet class is a template class that provides a hash-table-based set. + + \ingroup tools + \ingroup shared + \reentrant + \mainclass + + QSet is one of Qt's generic \l{container classes}. It stores + values in an unspecified order and provides very fast lookup of + the values. Internally, QSet is implemented as a QHash. + + Here's an example QSet with QString values: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 0 + + To insert a value into the set, use insert(): + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 1 + + Another way to insert items into the set is to use operator<<(): + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 2 + + To test whether an item belongs to the set or not, use contains(): + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 3 + + If you want to navigate through all the values stored in a QSet, + you can use an iterator. QSet supports both \l{Java-style + iterators} (QSetIterator and QMutableSetIterator) and \l{STL-style + iterators} (QSet::iterator and QSet::const_iterator). Here's how + to iterate over a QSet using a Java-style iterator: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 4 + + Here's the same code, but using an STL-style iterator: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 5 + + QSet is unordered, so an iterator's sequence cannot be assumed to + be predictable. If ordering by key is required, use a QMap. + + To navigate through a QSet, you can also use \l{foreach}: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 6 + + Items can be removed from the set using remove(). There is also a + clear() function that removes all items. + + QSet's value data type must be an \l{assignable data type}. You + cannot, for example, store a QWidget as a value; instead, store a + QWidget *. In addition, the type must provide \c operator==(), and + there must also be a global qHash() function that returns a hash + value for an argument of the key's type. See the QHash + documentation for a list of types supported by qHash(). + + Internally, QSet uses a hash table to perform lookups. The hash + table automatically grows and shrinks to provide fast lookups + without wasting memory. You can still control the size of the hash + table by calling reserve(), if you already know approximately how + many elements the QSet will contain, but this isn't necessary to + obtain good performance. You can also call capacity() to retrieve + the hash table's size. + + \sa QSetIterator, QMutableSetIterator, QHash, QMap +*/ + +/*! + \fn QSet::QSet() + + Constructs an empty set. + + \sa clear() +*/ + +/*! + \fn QSet::QSet(const QSet &other) + + Constructs a copy of \a other. + + This operation occurs in \l{constant time}, because QSet is + \l{implicitly shared}. This makes returning a QSet from a + function very fast. If a shared instance is modified, it will be + copied (copy-on-write), and this takes \l{linear time}. + + \sa operator=() +*/ + +/*! + \fn QSet &QSet::operator=(const QSet &other) + + Assigns the \a other set to this set and returns a reference to + this set. +*/ + +/*! + \fn bool QSet::operator==(const QSet &other) const + + Returns true if the \a other set is equal to this set; otherwise + returns false. + + Two sets are considered equal if they contain the same elements. + + This function requires the value type to implement \c operator==(). + + \sa operator!=() +*/ + +/*! + \fn bool QSet::operator!=(const QSet &other) const + + Returns true if the \a other set is not equal to this set; otherwise + returns false. + + Two sets are considered equal if they contain the same elements. + + This function requires the value type to implement \c operator==(). + + \sa operator==() +*/ + +/*! + \fn int QSet::size() const + + Returns the number of items in the set. + + \sa isEmpty(), count() +*/ + +/*! + \fn bool QSet::isEmpty() const + + Returns true if the set contains no elements; otherwise returns + false. + + \sa size() +*/ + +/*! + \fn int QSet::capacity() const + + Returns the number of buckets in the set's internal hash + table. + + The sole purpose of this function is to provide a means of fine + tuning QSet's memory usage. In general, you will rarely ever need + to call this function. If you want to know how many items are in + the set, call size(). + + \sa reserve(), squeeze() +*/ + +/*! \fn void QSet::reserve(int size) + + Ensures that the set's internal hash table consists of at + least \a size buckets. + + This function is useful for code that needs to build a huge set + and wants to avoid repeated reallocation. For example: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 7 + + Ideally, \a size should be slightly more than the maximum number + of elements expected in the set. \a size doesn't have to be prime, + because QSet will use a prime number internally anyway. If \a size + is an underestimate, the worst that will happen is that the QSet + will be a bit slower. + + In general, you will rarely ever need to call this function. + QSet's internal hash table automatically shrinks or grows to + provide good performance without wasting too much memory. + + \sa squeeze(), capacity() +*/ + +/*! + \fn void QSet::squeeze() + + Reduces the size of the set's internal hash table to save + memory. + + The sole purpose of this function is to provide a means of fine + tuning QSet's memory usage. In general, you will rarely ever + need to call this function. + + \sa reserve(), capacity() +*/ + +/*! + \fn void QSet::detach() + + \internal + + Detaches this set from any other sets with which it may share + data. + + \sa isDetached() +*/ + +/*! \fn bool QSet::isDetached() const + + \internal + + Returns true if the set's internal data isn't shared with any + other set object; otherwise returns false. + + \sa detach() +*/ + +/*! + \fn void QSet::setSharable(bool sharable) + \internal +*/ + +/*! + \fn void QSet::clear() + + Removes all elements from the set. + + \sa remove() +*/ + +/*! + \fn bool QSet::remove(const T &value) + + Removes any occurrence of item \a value from the set. Returns + true if an item was actually removed; otherwise returns false. + + \sa contains(), insert() +*/ + +/*! + \fn QSet::iterator QSet::erase(iterator pos) + \since 4.2 + + Removes the item at the iterator position \a pos from the set, and + returns an iterator positioned at the next item in the set. + + Unlike remove(), this function never causes QSet to rehash its + internal data structure. This means that it can safely be called + while iterating, and won't affect the order of items in the set. + + \sa remove(), find() +*/ + +/*! \fn QSet::const_iterator QSet::find(const T &value) const + \since 4.2 + + Returns a const iterator positioned at the item \a value in the + set. If the set contains no item \a value, the function returns + constEnd(). + + \sa constFind(), contains() +*/ + +/*! \fn QSet::iterator QSet::find(const T &value) + \since 4.2 + \overload + + Returns a non-const iterator positioned at the item \a value in + the set. If the set contains no item \a value, the function + returns end(). +*/ + +/*! \fn QSet::const_iterator QSet::constFind(const T &value) const + \since 4.2 + + Returns a const iterator positioned at the item \a value in the + set. If the set contains no item \a value, the function returns + constEnd(). + + \sa find(), contains() +*/ + +/*! + \fn bool QSet::contains(const T &value) const + + Returns true if the set contains item \a value; otherwise returns + false. + + \sa insert(), remove(), find() +*/ + +/*! + \fn bool QSet::contains(const QSet &other) const + \since 4.6 + + Returns true if the set contains all items from the \a other set; + otherwise returns false. + + \sa insert(), remove(), find() +*/ + +/*! \fn QSet::const_iterator QSet::begin() const + + Returns a const \l{STL-style iterator} positioned at the first + item in the set. + + \sa constBegin(), end() +*/ + +/*! \fn QSet::iterator QSet::begin() + \since 4.2 + \overload + + Returns a non-const \l{STL-style iterator} positioned at the first + item in the set. +*/ + +/*! \fn QSet::const_iterator QSet::constBegin() const + + Returns a const \l{STL-style iterator} positioned at the first + item in the set. + + \sa begin(), constEnd() +*/ + +/*! \fn QSet::const_iterator QSet::end() const + + Returns a const \l{STL-style iterator} positioned at the imaginary + item after the last item in the set. + + \sa constEnd(), begin() +*/ + +/*! \fn QSet::iterator QSet::end() + \since 4.2 + \overload + + Returns a non-const \l{STL-style iterator} pointing to the + imaginary item after the last item in the set. +*/ + +/*! \fn QSet::const_iterator QSet::constEnd() const + + Returns a const \l{STL-style iterator} pointing to the imaginary + item after the last item in the set. + + \sa constBegin(), end() +*/ + +/*! + \typedef QSet::Iterator + \since 4.2 + + Qt-style synonym for QSet::iterator. +*/ + +/*! + \typedef QSet::ConstIterator + + Qt-style synonym for QSet::const_iterator. +*/ + +/*! + \typedef QSet::const_pointer + + Typedef for const T *. Provided for STL compatibility. +*/ + +/*! + \typedef QSet::const_reference + + Typedef for const T &. Provided for STL compatibility. +*/ + +/*! + \typedef QSet::difference_type + + Typedef for const ptrdiff_t. Provided for STL compatibility. +*/ + +/*! + \typedef QSet::key_type + + Typedef for T. Provided for STL compatibility. +*/ + +/*! + \typedef QSet::pointer + + Typedef for T *. Provided for STL compatibility. +*/ + +/*! + \typedef QSet::reference + + Typedef for T &. Provided for STL compatibility. +*/ + +/*! + \typedef QSet::size_type + + Typedef for int. Provided for STL compatibility. +*/ + +/*! + \typedef QSet::value_type + + Typedef for T. Provided for STL compatibility. +*/ + +/*! + \fn QSet::const_iterator QSet::insert(const T &value) + + Inserts item \a value into the set, if \a value isn't already + in the set, and returns an iterator pointing at the inserted + item. + + \sa operator<<(), remove(), contains() +*/ + +/*! + \fn QSet &QSet::unite(const QSet &other) + + Each item in the \a other set that isn't already in this set is + inserted into this set. A reference to this set is returned. + + \sa operator|=(), intersect(), subtract() +*/ + +/*! + \fn QSet &QSet::intersect(const QSet &other) + + Removes all items from this set that are not contained in the + \a other set. A reference to this set is returned. + + \sa operator&=(), unite(), subtract() +*/ + +/*! + \fn QSet &QSet::subtract(const QSet &other) + + Removes all items from this set that are contained in the + \a other set. Returns a reference to this set. + + \sa operator-=(), unite(), intersect() +*/ + +/*! + \fn bool QSet::empty() const + + Returns true if the set is empty. This function is provided + for STL compatibility. It is equivalent to isEmpty(). +*/ + +/*! + \fn bool QSet::count() const + + Same as size(). +*/ + +/*! + \fn QSet &QSet::operator<<(const T &value) + \fn QSet &QSet::operator+=(const T &value) + \fn QSet &QSet::operator|=(const T &value) + + Inserts a new item \a value and returns a reference to the set. + If \a value already exists in the set, the set is left unchanged. + + \sa insert() +*/ + +/*! + \fn QSet &QSet::operator-=(const T &value) + + Removes the occurrence of item \a value from the set, if + it is found, and returns a reference to the set. If the + \a value is not contained the set, nothing is removed. + + \sa remove() +*/ + +/*! + \fn QSet &QSet::operator|=(const QSet &other) + \fn QSet &QSet::operator+=(const QSet &other) + + Same as unite(\a other). + + \sa operator|(), operator&=(), operator-=() +*/ + +/*! + \fn QSet &QSet::operator&=(const QSet &other) + + Same as intersect(\a other). + + \sa operator&(), operator|=(), operator-=() +*/ + +/*! + \fn QSet &QSet::operator&=(const T &value) + + \overload + + Same as intersect(\e{other}), if we consider \e{other} to be a set + that contains the singleton \a value. +*/ + + +/*! + \fn QSet &QSet::operator-=(const QSet &other) + + Same as subtract(\a{other}). + + \sa operator-(), operator|=(), operator&=() +*/ + +/*! + \fn QSet QSet::operator|(const QSet &other) const + \fn QSet QSet::operator+(const QSet &other) const + + Returns a new QSet that is the union of this set and the + \a other set. + + \sa unite(), operator|=(), operator&(), operator-() +*/ + +/*! + \fn QSet QSet::operator&(const QSet &other) const + + Returns a new QSet that is the intersection of this set and the + \a other set. + + \sa intersect(), operator&=(), operator|(), operator-() +*/ + +/*! + \fn QSet QSet::operator-(const QSet &other) const + + Returns a new QSet that is the set difference of this set and + the \a other set, i.e., this set - \a other set. + + \sa subtract(), operator-=(), operator|(), operator&() +*/ + +/*! + \fn QSet QSet::operator-(const QSet &other) + \fn QSet QSet::operator|(const QSet &other) + \fn QSet QSet::operator+(const QSet &other) + \fn QSet QSet::operator&(const QSet &other) + \internal + + These will go away in Qt 5. +*/ + +/*! + \class QSet::iterator + \since 4.2 + \brief The QSet::iterator class provides an STL-style non-const iterator for QSet. + + QSet features both \l{STL-style iterators} and + \l{Java-style iterators}. The STL-style iterators are more + low-level and more cumbersome to use; on the other hand, they are + slightly faster and, for developers who already know STL, have + the advantage of familiarity. + + QSet::iterator allows you to iterate over a QSet and to remove + items (using QSet::erase()) while you iterate. (QSet doesn't let + you \e modify a value through an iterator, because that + would potentially require moving the value in the internal hash + table used by QSet.) If you want to iterate over a const QSet, + you should use QSet::const_iterator. It is generally good + practice to use QSet::const_iterator on a non-const QSet as well, + unless you need to change the QSet through the iterator. Const + iterators are slightly faster, and can improve code readability. + + QSet\::iterator allows you to iterate over a QSet\ and + modify it as you go (using QSet::erase()). However, + + The default QSet::iterator constructor creates an uninitialized + iterator. You must initialize it using a function like + QSet::begin(), QSet::end(), or QSet::insert() before you can + start iterating. Here's a typical loop that prints all the items + stored in a set: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 8 + + Here's a loop that removes certain items (all those that start + with 'J') from a set while iterating: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 9 + + STL-style iterators can be used as arguments to \l{generic + algorithms}. For example, here's how to find an item in the set + using the qFind() algorithm: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 10 + + Multiple iterators can be used on the same set. However, you may + not attempt to modify the container while iterating on it. + + \sa QSet::const_iterator, QMutableSetIterator +*/ + +/*! + \class QSet::const_iterator + \brief The QSet::const_iterator class provides an STL-style const iterator for QSet. + \since 4.2 + + QSet features both \l{STL-style iterators} and + \l{Java-style iterators}. The STL-style iterators are more + low-level and more cumbersome to use; on the other hand, they are + slightly faster and, for developers who already know STL, have + the advantage of familiarity. + + QSet\::const_iterator allows you to iterate over a QSet. + If you want to modify the QSet as you iterate over it, you must + use QSet::iterator instead. It is generally good practice to use + QSet::const_iterator on a non-const QSet as well, unless you need + to change the QSet through the iterator. Const iterators are + slightly faster, and can improve code readability. + + The default QSet::const_iterator constructor creates an + uninitialized iterator. You must initialize it using a function + like QSet::begin(), QSet::end(), or QSet::insert() before you can + start iterating. Here's a typical loop that prints all the items + stored in a set: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 11 + + STL-style iterators can be used as arguments to \l{generic + algorithms}. For example, here's how to find an item in the set + using the qFind() algorithm: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 12 + + Multiple iterators can be used on the same set. However, you may + not attempt to modify the container while iterating on it. + + \sa QSet::iterator, QSetIterator +*/ + +/*! + \fn QSet::iterator::iterator() + \fn QSet::const_iterator::const_iterator() + + Constructs an uninitialized iterator. + + Functions like operator*() and operator++() should not be called + on an uninitialized iterator. Use operator=() to assign a value + to it before using it. + + \sa QSet::begin(), QSet::end() +*/ + +/*! + \fn QSet::iterator::iterator(typename Hash::iterator i) + \fn QSet::const_iterator::const_iterator(typename Hash::const_iterator i) + + \internal +*/ + +/*! + \typedef QSet::iterator::iterator_category + \typedef QSet::const_iterator::iterator_category + + Synonyms for \e {std::bidirectional_iterator_tag} indicating + these iterators are bidirectional iterators. + */ + +/*! + \typedef QSet::iterator::difference_type + \typedef QSet::const_iterator::difference_type + + \internal +*/ + +/*! + \typedef QSet::iterator::value_type + \typedef QSet::const_iterator::value_type + + \internal +*/ + +/*! + \typedef QSet::iterator::pointer + \typedef QSet::const_iterator::pointer + + \internal +*/ + +/*! + \typedef QSet::iterator::reference + \typedef QSet::const_iterator::reference + + \internal +*/ + +/*! + \fn QSet::iterator::iterator(const iterator &other) + \fn QSet::const_iterator::const_iterator(const const_iterator &other) + + Constructs a copy of \a other. +*/ + +/*! + \fn QSet::const_iterator::const_iterator(const iterator &other) + \since 4.2 + \overload + + Constructs a copy of \a other. +*/ + +/*! + \fn QSet::iterator &QSet::iterator::operator=(const iterator &other) + \fn QSet::const_iterator &QSet::const_iterator::operator=(const const_iterator &other) + + Assigns \a other to this iterator. +*/ + +/*! + \fn const T &QSet::iterator::operator*() const + \fn const T &QSet::const_iterator::operator*() const + + Returns a reference to the current item. + + \sa operator->() +*/ + +/*! + \fn const T *QSet::iterator::operator->() const + \fn const T *QSet::const_iterator::operator->() const + + Returns a pointer to the current item. + + \sa operator*() +*/ + +/*! + \fn bool QSet::iterator::operator==(const iterator &other) const + \fn bool QSet::const_iterator::operator==(const const_iterator &other) const + + Returns true if \a other points to the same item as this + iterator; otherwise returns false. + + \sa operator!=() +*/ + +/*! + \fn bool QSet::iterator::operator==(const const_iterator &other) const + \fn bool QSet::iterator::operator!=(const const_iterator &other) const + + \overload +*/ + +/*! + \fn bool QSet::iterator::operator!=(const iterator &other) const + \fn bool QSet::const_iterator::operator!=(const const_iterator &other) const + + Returns true if \a other points to a different item than this + iterator; otherwise returns false. + + \sa operator==() +*/ + +/*! + \fn QSet::iterator &QSet::iterator::operator++() + \fn QSet::const_iterator &QSet::const_iterator::operator++() + + The prefix ++ operator (\c{++it}) advances the iterator to the + next item in the set and returns an iterator to the new current + item. + + Calling this function on QSet::constEnd() leads to + undefined results. + + \sa operator--() +*/ + +/*! + \fn QSet::iterator QSet::iterator::operator++(int) + \fn QSet::const_iterator QSet::const_iterator::operator++(int) + + \overload + + The postfix ++ operator (\c{it++}) advances the iterator to the + next item in the set and returns an iterator to the previously + current item. +*/ + +/*! + \fn QSet::iterator &QSet::iterator::operator--() + \fn QSet::const_iterator &QSet::const_iterator::operator--() + + The prefix -- operator (\c{--it}) makes the preceding item + current and returns an iterator to the new current item. + + Calling this function on QSet::begin() leads to undefined + results. + + \sa operator++() +*/ + +/*! + \fn QSet::iterator QSet::iterator::operator--(int) + \fn QSet::const_iterator QSet::const_iterator::operator--(int) + + \overload + + The postfix -- operator (\c{it--}) makes the preceding item + current and returns an iterator to the previously current item. +*/ + +/*! + \fn QSet::iterator QSet::iterator::operator+(int j) const + \fn QSet::const_iterator QSet::const_iterator::operator+(int j) const + + Returns an iterator to the item at \a j positions forward from + this iterator. (If \a j is negative, the iterator goes backward.) + + This operation can be slow for large \a j values. + + \sa operator-() +*/ + +/*! + \fn QSet::iterator QSet::iterator::operator-(int j) const + \fn QSet::const_iterator QSet::const_iterator::operator-(int j) const + + Returns an iterator to the item at \a j positions backward from + this iterator. (If \a j is negative, the iterator goes forward.) + + This operation can be slow for large \a j values. + + \sa operator+() +*/ + +/*! + \fn QSet::iterator &QSet::iterator::operator+=(int j) + \fn QSet::const_iterator &QSet::const_iterator::operator+=(int j) + + Advances the iterator by \a j items. (If \a j is negative, the + iterator goes backward.) + + This operation can be slow for large \a j values. + + \sa operator-=(), operator+() +*/ + +/*! + \fn QSet::iterator &QSet::iterator::operator-=(int j) + \fn QSet::const_iterator &QSet::const_iterator::operator-=(int j) + + Makes the iterator go back by \a j items. (If \a j is negative, + the iterator goes forward.) + + This operation can be slow for large \a j values. + + \sa operator+=(), operator-() +*/ + +/*! \fn QList QSet::toList() const + + Returns a new QList containing the elements in the set. The + order of the elements in the QList is undefined. + + Example: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 13 + + \sa fromList(), QList::fromSet(), qSort() +*/ + +/*! \fn QList QSet::values() const + + Returns a new QList containing the elements in the set. The + order of the elements in the QList is undefined. + + This is the same as toList(). + + \sa fromList(), QList::fromSet(), qSort() +*/ + + +/*! \fn QSet QSet::fromList(const QList &list) + + Returns a new QSet object containing the data contained in \a + list. Since QSet doesn't allow duplicates, the resulting QSet + might be smaller than the \a list, because QList can contain + duplicates. + + Example: + + \snippet doc/src/snippets/code/doc_src_qset.qdoc 14 + + \sa toList(), QList::toSet() +*/ + +/*! + \fn QDataStream &operator<<(QDataStream &out, const QSet &set) + \relates QSet + + Writes the \a set to stream \a out. + + This function requires the value type to implement \c operator<<(). + + \sa \link datastreamformat.html Format of the QDataStream operators \endlink +*/ + +/*! + \fn QDataStream &operator>>(QDataStream &in, QSet &set) + \relates QSet + + Reads a set from stream \a in into \a set. + + This function requires the value type to implement \c operator>>(). + + \sa \link datastreamformat.html Format of the QDataStream operators \endlink +*/ diff --git a/doc/src/classes/qsignalspy.qdoc b/doc/src/classes/qsignalspy.qdoc new file mode 100644 index 0000000..4ee7590 --- /dev/null +++ b/doc/src/classes/qsignalspy.qdoc @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QSignalSpy + \inmodule QtTest + + \brief The QSignalSpy class enables introspection of signal emission. + + QSignalSpy can connect to any signal of any object and records its emission. + QSignalSpy itself is a list of QVariant lists. Each emission of the signal + will append one item to the list, containing the arguments of the signal. + + The following example records all signal emissions for the \c clicked() signal + of a QCheckBox: + + \snippet doc/src/snippets/code/doc_src_qsignalspy.qdoc 0 + + \c{spy.takeFirst()} returns the arguments for the first emitted signal, as a + list of QVariant objects. The \c clicked() signal has a single bool argument, + which is stored as the first entry in the list of arguments. + + The example below catches a signal from a custom object: + + \snippet doc/src/snippets/code/doc_src_qsignalspy.qdoc 1 + + \bold {Note:} Non-standard data types need to be registered, using + the qRegisterMetaType() function, before you can create a + QSignalSpy. For example: + + \snippet doc/src/snippets/code/doc_src_qsignalspy.qdoc 2 + + To retrieve the \c QModelIndex, you can use qvariant_cast: + + \snippet doc/src/snippets/code/doc_src_qsignalspy.qdoc 3 + */ + +/*! \fn QSignalSpy::QSignalSpy(QObject *object, const char *signal) + + Constructs a new QSignalSpy that listens for emissions of the \a signal + from the QObject \a object. Neither \a signal nor \a object can be null. + + Example: + \snippet doc/src/snippets/code/doc_src_qsignalspy.qdoc 4 +*/ + +/*! \fn QSignalSpy::isValid() const + + Returns true if the signal spy listens to a valid signal, otherwise false. +*/ + +/*! \fn QSignalSpy::signal() const + + Returns the normalized signal the spy is currently listening to. +*/ + +/*! \fn int QSignalSpy::qt_metacall(QMetaObject::Call call, int id, void **a) + \internal +*/ + diff --git a/doc/src/classes/qsizepolicy.qdoc b/doc/src/classes/qsizepolicy.qdoc new file mode 100644 index 0000000..c74beb8 --- /dev/null +++ b/doc/src/classes/qsizepolicy.qdoc @@ -0,0 +1,522 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QSizePolicy + \brief The QSizePolicy class is a layout attribute describing horizontal + and vertical resizing policy. + + \ingroup appearance + \ingroup geomanagement + + The size policy of a widget is an expression of its willingness to + be resized in various ways, and affects how the widget is treated + by the \l{Layout Management}{layout engine}. Each widget returns a + QSizePolicy that describes the horizontal and vertical resizing + policy it prefers when being laid out. You can change this for + a specific widget by changing its QWidget::sizePolicy property. + + QSizePolicy contains two independent QSizePolicy::Policy values + and two stretch factors; one describes the widgets's horizontal + size policy, and the other describes its vertical size policy. It + also contains a flag to indicate whether the height and width of + its preferred size are related. + + The horizontal and vertical policies can be set in the + constructor, and altered using the setHorizontalPolicy() and + setVerticalPolicy() functions. The stretch factors can be set + using the setHorizontalStretch() and setVerticalStretch() + functions. The flag indicating whether the widget's + \l{QWidget::sizeHint()}{sizeHint()} is width-dependent (such as a + menu bar or a word-wrapping label) can be set using the + setHeightForWidth() function. + + The current size policies and stretch factors be retrieved using + the horizontalPolicy(), verticalPolicy(), horizontalStretch() and + verticalStretch() functions. Alternatively, use the transpose() + function to swap the horizontal and vertical policies and + stretches. The hasHeightForWidth() function returns the current + status of the flag indicating the size hint dependencies. + + Use the expandingDirections() function to determine whether the + associated widget can make use of more space than its + \l{QWidget::sizeHint()}{sizeHint()} function indicates, as well as + find out in which directions it can expand. + + Finally, the QSizePolicy class provides operators comparing this + size policy to a given policy, as well as a QVariant operator + storing this QSizePolicy as a QVariant object. + + \sa QSize, QWidget::sizeHint(), QWidget::sizePolicy, + QLayoutItem::sizeHint() +*/ + +/*! + \enum QSizePolicy::PolicyFlag + + These flags are combined together to form the various \l{Policy} + values: + + \value GrowFlag The widget can grow beyond its size hint if necessary. + \value ExpandFlag The widget should get as much space as possible. + \value ShrinkFlag The widget can shrink below its size hint if necessary. + \value IgnoreFlag The widget's size hint is ignored. The widget will get + as much space as possible. + + \sa Policy +*/ + +/*! + \enum QSizePolicy::Policy + + This enum describes the various per-dimension sizing types used + when constructing a QSizePolicy. + + \value Fixed The QWidget::sizeHint() is the only acceptable + alternative, so the widget can never grow or shrink (e.g. the + vertical direction of a push button). + + \value Minimum The sizeHint() is minimal, and sufficient. The + widget can be expanded, but there is no advantage to it being + larger (e.g. the horizontal direction of a push button). + It cannot be smaller than the size provided by sizeHint(). + + \value Maximum The sizeHint() is a maximum. The widget can be + shrunk any amount without detriment if other widgets need the + space (e.g. a separator line). + It cannot be larger than the size provided by sizeHint(). + + \value Preferred The sizeHint() is best, but the widget can be + shrunk and still be useful. The widget can be expanded, but there + is no advantage to it being larger than sizeHint() (the default + QWidget policy). + + \value Expanding The sizeHint() is a sensible size, but the + widget can be shrunk and still be useful. The widget can make use + of extra space, so it should get as much space as possible (e.g. + the horizontal direction of a horizontal slider). + + \value MinimumExpanding The sizeHint() is minimal, and sufficient. + The widget can make use of extra space, so it should get as much + space as possible (e.g. the horizontal direction of a horizontal + slider). + + \value Ignored The sizeHint() is ignored. The widget will get as + much space as possible. + + \sa PolicyFlag, setHorizontalPolicy(), setVerticalPolicy() +*/ + +/*! + \fn QSizePolicy::QSizePolicy() + + Constructs a QSizePolicy object with \l Fixed as its horizontal + and vertical policies. + + The policies can be altered using the setHorizontalPolicy() and + setVerticalPolicy() functions. Use the setHeightForWidth() + function if the preferred height of the widget is dependent on the + width of the widget (for example, a QLabel with line wrapping). + + \sa setHorizontalStretch(), setVerticalStretch() +*/ + +/*! + \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical) + + Constructs a QSizePolicy object with the given \a horizontal and + \a vertical policies, and DefaultType as the control type. + + Use setHeightForWidth() if the preferred height of the widget is + dependent on the width of the widget (for example, a QLabel with + line wrapping). + + \sa setHorizontalStretch(), setVerticalStretch() +*/ + +/*! + \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical, ControlType type) + \since 4.3 + + Constructs a QSizePolicy object with the given \a horizontal and + \a vertical policies, and the specified control \a type. + + Use setHeightForWidth() if the preferred height of the widget is + dependent on the width of the widget (for example, a QLabel with + line wrapping). + + \sa setHorizontalStretch(), setVerticalStretch(), controlType() +*/ + +/*! + \fn QSizePolicy::Policy QSizePolicy::horizontalPolicy() const + + Returns the horizontal component of the size policy. + + \sa setHorizontalPolicy(), verticalPolicy(), horizontalStretch() +*/ + +/*! + \fn QSizePolicy::Policy QSizePolicy::verticalPolicy() const + + Returns the vertical component of the size policy. + + \sa setVerticalPolicy(), horizontalPolicy(), verticalStretch() +*/ + +/*! + \fn void QSizePolicy::setHorizontalPolicy(Policy policy) + + Sets the horizontal component to the given \a policy. + + \sa horizontalPolicy(), setVerticalPolicy(), setHorizontalStretch() +*/ + +/*! + \fn void QSizePolicy::setVerticalPolicy(Policy policy) + + Sets the vertical component to the given \a policy. + + \sa verticalPolicy(), setHorizontalPolicy(), setVerticalStretch() +*/ + +/*! + \fn Qt::Orientations QSizePolicy::expandingDirections() const + + Returns whether a widget can make use of more space than the + QWidget::sizeHint() function indicates. + + A value of Qt::Horizontal or Qt::Vertical means that the widget + can grow horizontally or vertically (i.e., the horizontal or + vertical policy is \l Expanding or \l MinimumExpanding), whereas + Qt::Horizontal | Qt::Vertical means that it can grow in both + dimensions. + + \sa horizontalPolicy(), verticalPolicy() +*/ + +/*! + \fn ControlType QSizePolicy::controlType() const + \since 4.3 + + Returns the control type associated with the widget for which + this size policy applies. +*/ + +/*! + \fn void QSizePolicy::setControlType(ControlType type) + \since 4.3 + + Sets the control type associated with the widget for which this + size policy applies to \a type. + + The control type specifies the type of the widget for which this + size policy applies. It is used by some styles, notably + QMacStyle, to insert proper spacing between widgets. For example, + the Mac OS X Aqua guidelines specify that push buttons should be + separated by 12 pixels, whereas vertically stacked radio buttons + only require 6 pixels. + + \sa QStyle::layoutSpacing() +*/ + +/*! + \fn void QSizePolicy::setHeightForWidth(bool dependent) + + Sets the flag determining whether the widget's preferred height + depends on its width, to \a dependent. + + \sa hasHeightForWidth() +*/ + +/*! + \fn bool QSizePolicy::hasHeightForWidth() const + + Returns true if the widget's preferred height depends on its + width; otherwise returns false. + + \sa setHeightForWidth() +*/ + +/*! + \fn bool QSizePolicy::operator==(const QSizePolicy &other) const + + Returns true if this policy is equal to \a other; otherwise + returns false. + + \sa operator!=() +*/ + +/*! + \fn bool QSizePolicy::operator!=(const QSizePolicy &other) const + + Returns true if this policy is different from \a other; otherwise + returns false. + + \sa operator==() +*/ + +/*! + \fn int QSizePolicy::horizontalStretch() const + + Returns the horizontal stretch factor of the size policy. + + \sa setHorizontalStretch(), verticalStretch(), horizontalPolicy() +*/ + +/*! + \fn int QSizePolicy::verticalStretch() const + + Returns the vertical stretch factor of the size policy. + + \sa setVerticalStretch(), horizontalStretch(), verticalPolicy() +*/ + +/*! + \fn void QSizePolicy::setHorizontalStretch(uchar stretchFactor) + + Sets the horizontal stretch factor of the size policy to the given \a + stretchFactor. + + \sa horizontalStretch(), setVerticalStretch(), setHorizontalPolicy() +*/ + +/*! + \fn void QSizePolicy::setVerticalStretch(uchar stretchFactor) + + Sets the vertical stretch factor of the size policy to the given + \a stretchFactor. + + \sa verticalStretch(), setHorizontalStretch(), setVerticalPolicy() +*/ + +/*! + \fn void QSizePolicy::transpose() + + Swaps the horizontal and vertical policies and stretches. +*/ + +/*! + \enum QSizePolicy::ControlType + \since 4.3 + + This enum specifies the different types of widgets in terms of + layout interaction: + + \value DefaultType The default type, when none is specified. + \value ButtonBox A QDialogButtonBox instance. + \value CheckBox A QCheckBox instance. + \value ComboBox A QComboBox instance. + \value Frame A QFrame instance. + \value GroupBox A QGroupBox instance. + \value Label A QLabel instance. + \value Line A QFrame instance with QFrame::HLine or QFrame::VLine. + \value LineEdit A QLineEdit instance. + \value PushButton A QPushButton instance. + \value RadioButton A QRadioButton instance. + \value Slider A QAbstractSlider instance. + \value SpinBox A QAbstractSpinBox instance. + \value TabWidget A QTabWidget instance. + \value ToolButton A QToolButton instance. + + \sa setControlType(), controlType() +*/ + +#ifdef QT3_SUPPORT +/*! + \typedef QSizePolicy::SizeType + \compat + + Use the QSizePolicy::Policy enum instead. +*/ + +/*! + \enum QSizePolicy::ExpandData + \compat + + Use the Qt::Orientations enum instead. + + \value NoDirection Use 0 instead. + \value Horizontally Use Qt::Horizontal instead. + \value Vertically Use Qt::Vertical instead. + \value BothDirections Use Qt::Horizontal | Qt::Vertical instead. +*/ + +/*! + \fn bool QSizePolicy::mayShrinkHorizontally() const + + Use the horizontalPolicy() function combined with the + QSizePolicy::PolicyFlag enum instead. + + \oldcode + bool policy = mayShrinkHorizontally(); + \newcode + bool policy = horizontalPolicy() & QSizePolicy::ShrinkFlag; + \endcode +*/ + +/*! + \fn bool QSizePolicy::mayShrinkVertically() const + + Use the verticalPolicy() function combined with the + QSizePolicy::PolicyFlag enum instead. + + \oldcode + bool policy = mayShrinkVertically(); + \newcode + bool policy = verticalPolicy() & QSizePolicy::ShrinkFlag; + \endcode +*/ + +/*! + \fn bool QSizePolicy::mayGrowHorizontally() const + + Use the horizontalPolicy() function combined with the + QSizePolicy::PolicyFlag enum instead. + + \oldcode + bool policy = mayGrowHorizontally(); + \newcode + bool policy = horizontalPolicy() & QSizePolicy::GrowFlag; + \endcode +*/ + +/*! + \fn bool QSizePolicy::mayGrowVertically() const + + Use the verticalPolicy() function combined with the + QSizePolicy::PolicyFlag enum instead. + + \oldcode + bool policy = mayGrowVertically(); + \newcode + bool policy = verticalPolicy() & QSizePolicy::GrowFlag; + \endcode +*/ + +/*! + \fn Qt::QSizePolicy::Orientations QSizePolicy::expanding() const + + Use expandingDirections() instead. +*/ + +/*! + \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical, bool dependent) + + Use the QSizePolicy() constructor and the setHeightForWidth() + function instead. + + \oldcode + QSizePolicy *policy = new QSizePolicy(horizontal, vertical, dependent); + \newcode + QSizePolicy *policy = new QSizePolicy(horizontal, vertical); + policy->setHeightForWidth(dependent); + \endcode +*/ + +/*! + \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical, uchar horizontalStretch, + uchar verticalStretch, bool dependent) + + Use the QSizePolicy() constructor and call the + setHorizontalStretch(), setVerticalStretch(), and + setHeightForWidth() functions instead. + + \oldcode + QSizePolicy *policy = new QSizePolicy(horizontal, vertical, + horizontalStretch, verticalStretch, + dependent); + \newcode + QSizePolicy *policy = new QSizePolicy(horizontal, vertical); + policy->setHorizontalStretch(horizontalStretch); + policy->setVerticalStretch(verticalStretch); + policy->setHeightForWidth(dependent); + \endcode +*/ + +/*! + \fn QSizePolicy::Policy QSizePolicy::horData() const + + Use horizontalPolicy() instead. +*/ + +/*! + \fn QSizePolicy::Policy QSizePolicy::verData() const + + Use verticalPolicy() instead. +*/ + +/*! + \fn void QSizePolicy::setHorData(Policy policy) + + Use setHorizontalPolicy() instead. +*/ + +/*! + \fn void QSizePolicy::setVerData(Policy policy) + + Use setVerticalPolicy() instead. +*/ + +/*! + \fn uint QSizePolicy::horStretch() const + + Use horizontalStretch() instead. +*/ + +/*! + \fn uint QSizePolicy::verStretch() const + + Use verticalStretch() instead. +*/ + +/*! + \fn void QSizePolicy::setHorStretch(uchar stretch) + + Use setHorizontalStretch() instead. +*/ + +/*! + \fn void QSizePolicy::setVerStretch(uchar stretch) + + Use setVerticalStretch() instead. +*/ +#endif diff --git a/doc/src/classes/qtdesigner-api.qdoc b/doc/src/classes/qtdesigner-api.qdoc new file mode 100644 index 0000000..d7c47b1 --- /dev/null +++ b/doc/src/classes/qtdesigner-api.qdoc @@ -0,0 +1,1413 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QDesignerMemberSheetExtension + + \brief The QDesignerMemberSheetExtension class allows you to + manipulate a widget's member functions which is displayed when + configuring connections using Qt Designer's mode for editing + signals and slots. + + \inmodule QtDesigner + + QDesignerMemberSheetExtension is a collection of functions that is + typically used to query a widget's member functions, and to + manipulate the member functions' appearance in \QD's signals and + slots editing mode. For example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 2 + + When implementing a custom widget plugin, a pointer to \QD's + current QDesignerFormEditorInterface object (\c formEditor in the + example above) is provided by the + QDesignerCustomWidgetInterface::initialize() function's parameter. + + The member sheet (and any other extension), can be retrieved by + querying \QD's extension manager using the qt_extension() + function. When you want to release the extension, you only need to + delete the pointer. + + All widgets have a default member sheet used in \QD's signals and + slots editing mode with the widget's member functions. But + QDesignerMemberSheetExtension also provides an interface for + creating custom member sheet extensions. + + \warning \QD uses the QDesignerMemberSheetExtension to facilitate + the signal and slot editing mode. Whenever a connection between + two widgets is requested, \QD will query for the widgets' member + sheet extensions. If a widget has an implemented member sheet + extension, this extension will override the default member sheet. + + To create a member sheet extension, your extension class must + inherit from both QObject and QDesignerMemberSheetExtension. Then, + since we are implementing an interface, we must ensure that it's + made known to the meta object system using the Q_INTERFACES() + macro: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 3 + + This enables \QD to use qobject_cast() to query for + supported interfaces using nothing but a QObject pointer. + + In \QD the extensions are not created until they are + required. For that reason, when implementing a member sheet + extension, you must also create a QExtensionFactory, i.e a class + that is able to make an instance of your extension, and register + it using \QD's \l {QExtensionManager}{extension manager}. + + When a widget's member sheet extension is required, \QD's \l + {QExtensionManager}{extension manager} will run through all its + registered factories calling QExtensionFactory::createExtension() + for each until the first one that is able to create a member sheet + extension for that widget, is found. This factory will then make + an instance of the extension. If no such factory is found, \QD + will use the default member sheet. + + There are four available types of extensions in \QD: + QDesignerContainerExtension, QDesignerMemberSheetExtension, + QDesignerPropertySheetExtension and + QDesignerTaskMenuExtension. \QD's behavior is the same whether the + requested extension is associated with a multi page container, a + member sheet, a property sheet or a task menu. + + The QExtensionFactory class provides a standard extension + factory, and can also be used as an interface for custom + extension factories. You can either create a new + QExtensionFactory and reimplement the + QExtensionFactory::createExtension() function. For example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 4 + + Or you can use an existing factory, expanding the + QExtensionFactory::createExtension() function to make the factory + able to create a member sheet extension as well. For example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 5 + + For a complete example using an extension class, see \l + {designer/taskmenuextension}{Task Menu Extension example}. The + example shows how to create a custom widget plugin for Qt + Designer, and how to to use the QDesignerTaskMenuExtension class + to add custom items to \QD's task menu. + + \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget + Extensions} +*/ + +/*! + \fn QDesignerMemberSheetExtension::~QDesignerMemberSheetExtension() + + Destroys the member sheet extension. +*/ + +/*! + \fn int QDesignerMemberSheetExtension::count() const + + Returns the extension's number of member functions. +*/ + +/*! + \fn int QDesignerMemberSheetExtension::indexOf(const QString &name) const + + Returns the index of the member function specified by the given \a + name. + + \sa memberName() +*/ + +/*! + \fn QString QDesignerMemberSheetExtension::memberName(int index) const + + Returns the name of the member function with the given \a index. + + \sa indexOf() +*/ + +/*! + \fn QString QDesignerMemberSheetExtension::memberGroup(int index) const + + Returns the name of the member group specified for the function + with the given \a index. + + \sa indexOf(), setMemberGroup() +*/ + +/*! + \fn void QDesignerMemberSheetExtension::setMemberGroup(int index, const QString &group) + + Sets the member group of the member function with the given \a + index, to \a group. + + \sa indexOf(), memberGroup() +*/ + +/*! + \fn bool QDesignerMemberSheetExtension::isVisible(int index) const + + Returns true if the member function with the given \a index is + visible in \QD's signal and slot editor, otherwise false. + + \sa indexOf(), setVisible() +*/ + +/*! + \fn void QDesignerMemberSheetExtension::setVisible(int index, bool visible) + + If \a visible is true, the member function with the given \a index + is visible in \QD's signals and slots editing mode; otherwise the + member function is hidden. + + \sa indexOf(), isVisible() +*/ + +/*! + \fn virtual bool QDesignerMemberSheetExtension::isSignal(int index) const + + Returns true if the member function with the given \a index is a + signal, otherwise false. + + \sa indexOf() +*/ + +/*! + \fn bool QDesignerMemberSheetExtension::isSlot(int index) const + + Returns true if the member function with the given \a index is a + slot, otherwise false. + + \sa indexOf() +*/ + +/*! + \fn bool QDesignerMemberSheetExtension::inheritedFromWidget(int index) const + + Returns true if the member function with the given \a index is + inherited from QWidget, otherwise false. + + \sa indexOf() +*/ + +/*! + \fn QString QDesignerMemberSheetExtension::declaredInClass(int index) const + + Returns the name of the class in which the member function with + the given \a index is declared. + + \sa indexOf() +*/ + +/*! + \fn QString QDesignerMemberSheetExtension::signature(int index) const + + Returns the signature of the member function with the given \a + index. + + \sa indexOf() +*/ + +/*! + \fn QList QDesignerMemberSheetExtension::parameterTypes(int index) const + + Returns the parameter types of the member function with the given + \a index, as a QByteArray list. + + \sa indexOf(), parameterNames() +*/ + +/*! + \fn QList QDesignerMemberSheetExtension::parameterNames(int index) const + + Returns the parameter names of the member function with the given + \a index, as a QByteArray list. + + \sa indexOf(), parameterTypes() +*/ + + +// Doc: Interface only + +/*! + \class QDesignerLayoutDecorationExtension + \brief The QDesignerLayoutDecorationExtension class provides an extension to a layout in \QD. + \inmodule QtDesigner + \internal +*/ + +/*! + \enum QDesignerLayoutDecorationExtension::InsertMode + + This enum describes the modes that are used to insert items into a layout. + + \value InsertWidgetMode Widgets are inserted into empty cells in a layout. + \value InsertRowMode Whole rows are inserted into a vertical or grid layout. + \value InsertColumnMode Whole columns are inserted into a horizontal or grid layout. +*/ + +/*! + \fn virtual QDesignerLayoutDecorationExtension::~QDesignerLayoutDecorationExtension() + + Destroys the extension. +*/ + +/*! + \fn virtual QList QDesignerLayoutDecorationExtension::widgets(QLayout *layout) const + + Returns the widgets that are managed by the given \a layout. + + \sa insertWidget(), removeWidget() +*/ + +/*! + \fn QRect QDesignerLayoutDecorationExtension::itemInfo(int index) const + + Returns the rectangle covered by the item at the given \a index in the layout. +*/ + +/*! + \fn int QDesignerLayoutDecorationExtension::indexOf(QWidget *widget) const + + Returns the index of the specified \a widget in the layout. +*/ + +/*! + \fn int QDesignerLayoutDecorationExtension::indexOf(QLayoutItem *item) const + + Returns the index of the specified layout \a item. +*/ + +/*! + \fn QDesignerLayoutDecorationExtension::InsertMode QDesignerLayoutDecorationExtension::currentInsertMode() const + + Returns the current insertion mode. +*/ + +/*! + \fn int QDesignerLayoutDecorationExtension::currentIndex() const + + Returns the current index in the layout. +*/ + +/*! + \fn QPair QDesignerLayoutDecorationExtension::currentCell() const + + Returns a pair containing the row and column of the current cell in the layout. +*/ + +/*! + \fn void QDesignerLayoutDecorationExtension::insertWidget(QWidget *widget, const QPair &cell) + + Inserts the given \a widget into the specified \a cell in the layout. + + \sa removeWidget() +*/ + +/*! + \fn void QDesignerLayoutDecorationExtension::removeWidget(QWidget *widget) + + Removes the specified \a widget from the layout. + + \sa insertWidget() +*/ + +/*! + \fn void QDesignerLayoutDecorationExtension::insertRow(int row) + + Inserts a new row into the form at the position specified by \a row. +*/ + +/*! + \fn void QDesignerLayoutDecorationExtension::insertColumn(int column) + + Inserts a new column into the form at the position specified by \a column. +*/ + +/*! + \fn void QDesignerLayoutDecorationExtension::simplify() + + Simplifies the layout by removing unnecessary empty rows and columns, and by changing the + number of rows or columns spanned by widgets. +*/ + +/*! + \fn int QDesignerLayoutDecorationExtension::findItemAt(const QPoint &position) const + + Returns the index of the item in the layout that covers the given \a position. +*/ + +/*! + \fn int QDesignerLayoutDecorationExtension::findItemAt(int row, int column) const + + Returns the item in the layout that occupies the specified \a row and \a column in the layout. + + Currently, this only applies to grid layouts. +*/ + +/*! + \fn void QDesignerLayoutDecorationExtension::adjustIndicator(const QPoint &position, int index) + + Adjusts the indicator for the item specified by \a index so that + it lies at the given \a position on the form. +*/ + + +// Doc: Interface only + +/*! + \class QDesignerContainerExtension + \brief The QDesignerContainerExtension class allows you to add pages to + a custom multi-page container in Qt Designer's workspace. + \inmodule QtDesigner + + QDesignerContainerExtension provide an interface for creating + custom container extensions. A container extension consists of a + collection of functions that \QD needs to manage a multi-page + container plugin, and a list of the container's pages. + + \image containerextension-example.png + + \warning This is \e not an extension for container plugins in + general, only custom \e multi-page containers. + + To create a container extension, your extension class must inherit + from both QObject and QDesignerContainerExtension. For example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 6 + + Since we are implementing an interface, we must ensure that it's + made known to the meta object system using the Q_INTERFACES() + macro. This enables \QD to use the qobject_cast() function to + query for supported interfaces using nothing but a QObject + pointer. + + You must reimplement several functions to enable \QD to manage a + custom multi-page container widget: \QD uses count() to keep track + of the number pages in your container, widget() to return the page + at a given index in the list of the container's pages, and + currentIndex() to return the list index of the selected page. \QD + uses the addWidget() function to add a given page to the + container, expecting it to be appended to the list of pages, while + it expects the insertWidget() function to add a given page to the + container by inserting it at a given index. + + In \QD the extensions are not created until they are + required. For that reason you must also create a + QExtensionFactory, i.e a class that is able to make an instance of + your extension, and register it using \QD's \l + {QExtensionManager}{extension manager}. + + When a container extension is required, \QD's \l + {QExtensionManager}{extension manager} will run through all its + registered factories calling QExtensionFactory::createExtension() + for each until the first one that is able to create a container + extension, is found. This factory will then create the extension + for the plugin. + + There are four available types of extensions in \QD: + QDesignerContainerExtension , QDesignerMemberSheetExtension, + QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. + \QD's behavior is the same whether the requested extension is + associated with a multi page container, a member sheet, a property + sheet or a task menu. + + The QExtensionFactory class provides a standard extension factory, + and can also be used as an interface for custom extension + factories. You can either create a new QExtensionFactory and + reimplement the QExtensionFactory::createExtension() function. For + example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 7 + + Or you can use an existing factory, expanding the + QExtensionFactory::createExtension() function to make the factory + able to create a container extension as well. For example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 8 + + For a complete example using the QDesignerContainerExtension + class, see the \l {designer/containerextension}{Container + Extension example}. The example shows how to create a custom + multi-page plugin for \QD. + + \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget + Extensions} +*/ + +/*! + \fn QDesignerContainerExtension::~QDesignerContainerExtension() + + Destroys the extension. +*/ + +/*! + \fn int QDesignerContainerExtension::count() const + + Returns the number of pages in the container. +*/ + +/*! + \fn QWidget *QDesignerContainerExtension::widget(int index) const + + Returns the page at the given \a index in the extension's list of + pages. + + \sa addWidget(), insertWidget() +*/ + +/*! + \fn int QDesignerContainerExtension::currentIndex() const + + Returns the index of the currently selected page in the + container. + + \sa setCurrentIndex() +*/ + +/*! + \fn void QDesignerContainerExtension::setCurrentIndex(int index) + + Sets the currently selected page in the container to be the + page at the given \a index in the extension's list of pages. + + \sa currentIndex() +*/ + +/*! + \fn void QDesignerContainerExtension::addWidget(QWidget *page) + + Adds the given \a page to the container by appending it to the + extension's list of pages. + + \sa insertWidget(), remove(), widget() +*/ + +/*! + \fn void QDesignerContainerExtension::insertWidget(int index, QWidget *page) + + Adds the given \a page to the container by inserting it at the + given \a index in the extension's list of pages. + + \sa addWidget(), remove(), widget() +*/ + +/*! + \fn void QDesignerContainerExtension::remove(int index) + + Removes the page at the given \a index from the extension's list + of pages. + + \sa addWidget(), insertWidget() +*/ + + +// Doc: Interface only + +/*! + \class QDesignerTaskMenuExtension + \brief The QDesignerTaskMenuExtension class allows you to add custom + menu entries to Qt Designer's task menu. + \inmodule QtDesigner + + QDesignerTaskMenuExtension provides an interface for creating + custom task menu extensions. It is typically used to create task + menu entries that are specific to a plugin in \QD. + + \QD uses the QDesignerTaskMenuExtension to feed its task + menu. Whenever a task menu is requested, \QD will query + for the selected widget's task menu extension. + + \image taskmenuextension-example-faded.png + + A task menu extension is a collection of QActions. The actions + appear as entries in the task menu when the plugin with the + specified extension is selected. The image above shows the custom + \gui {Edit State...} action which appears in addition to \QD's + default task menu entries: \gui Cut, \gui Copy, \gui Paste etc. + + To create a custom task menu extension, your extension class must + inherit from both QObject and QDesignerTaskMenuExtension. For + example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 9 + + Since we are implementing an interface, we must ensure that it + is made known to the meta-object system using the Q_INTERFACES() + macro. This enables \QD to use the qobject_cast() function to + query for supported interfaces using nothing but a QObject + pointer. + + You must reimplement the taskActions() function to return a list + of actions that will be included in \QD task menu. Optionally, you + can reimplement the preferredEditAction() function to set the + action that is invoked when selecting your plugin and pressing + \key F2. The preferred edit action must be one of the actions + returned by taskActions() and, if it's not defined, pressing the + \key F2 key will simply be ignored. + + In \QD, extensions are not created until they are required. A + task menu extension, for example, is created when you click the + right mouse button over a widget in \QD's workspace. For that + reason you must also construct an extension factory, using either + QExtensionFactory or a subclass, and register it using \QD's + \l {QExtensionManager}{extension manager}. + + When a task menu extension is required, \QD's \l + {QExtensionManager}{extension manager} will run through all its + registered factories calling QExtensionFactory::createExtension() + for each until it finds one that is able to create a task menu + extension for the selected widget. This factory will then make an + instance of the extension. + + There are four available types of extensions in \QD: + QDesignerContainerExtension, QDesignerMemberSheetExtension, + QDesignerPropertySheetExtension, and QDesignerTaskMenuExtension. + \QD's behavior is the same whether the requested extension is + associated with a container, a member sheet, a property sheet or a + task menu. + + The QExtensionFactory class provides a standard extension factory, + and can also be used as an interface for custom extension + factories. You can either create a new QExtensionFactory and + reimplement the QExtensionFactory::createExtension() function. For + example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 10 + + Or you can use an existing factory, expanding the + QExtensionFactory::createExtension() function to make the factory + able to create a task menu extension as well. For example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 11 + + For a complete example using the QDesignerTaskMenuExtension class, + see the \l {designer/taskmenuextension}{Task Menu Extension + example}. The example shows how to create a custom widget plugin + for \QD, and how to to use the QDesignerTaskMenuExtension + class to add custom items to \QD's task menu. + + \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget + Extensions} +*/ + +/*! + \fn QDesignerTaskMenuExtension::~QDesignerTaskMenuExtension() + + Destroys the task menu extension. +*/ + +/*! + \fn QAction *QDesignerTaskMenuExtension::preferredEditAction() const + + Returns the action that is invoked when selecting a plugin with + the specified extension and pressing \key F2. + + The action must be one of the actions returned by taskActions(). +*/ + +/*! + \fn QList QDesignerTaskMenuExtension::taskActions() const + + Returns the task menu extension as a list of actions which will be + included in \QD's task menu when a plugin with the specified + extension is selected. + + The function must be reimplemented to add actions to the list. +*/ + + +// Doc: Interface only + +/*! + \class QDesignerCustomWidgetCollectionInterface + + \brief The QDesignerCustomWidgetCollectionInterface class allows + you to include several custom widgets in one single library. + + \inmodule QtDesigner + + When implementing a custom widget plugin, you build it as a + separate library. If you want to include several custom widget + plugins in the same library, you must in addition subclass + QDesignerCustomWidgetCollectionInterface. + + QDesignerCustomWidgetCollectionInterface contains one single + function returning a list of the collection's + QDesignerCustomWidgetInterface objects. For example, if you have + several custom widgets \c CustomWidgetOne, \c CustomWidgetTwo and + \c CustomWidgetThree, the class definition may look like this: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 12 + + In the class constructor you add the interfaces to your custom + widgets to the list which you return in the customWidgets() + function: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 13 + + Note that instead of exporting each custom widget plugin using the + Q_EXPORT_PLUGIN2() macro, you export the entire collection. The + Q_EXPORT_PLUGIN2() macro ensures that \QD can access and construct + the custom widgets. Without this macro, there is no way for \QD to + use them. + + \sa QDesignerCustomWidgetInterface, {Creating Custom Widgets for + Qt Designer} +*/ + +/*! + \fn QDesignerCustomWidgetCollectionInterface::~QDesignerCustomWidgetCollectionInterface() { + + Destroys the custom widget collection interface. +*/ + +/*! + \fn QList QDesignerCustomWidgetCollectionInterface::customWidgets() const + + Returns a list of interfaces to the collection's custom widgets. +*/ + + +// Doc: Interface only + +/*! + \class QDesignerCustomWidgetInterface + + \brief The QDesignerCustomWidgetInterface class enables Qt Designer + to access and construct custom widgets. + + \inmodule QtDesigner + + QDesignerCustomWidgetInterface provides a custom widget with an + interface. The class contains a set of functions that must be subclassed + to return basic information about the widget, such as its class name and + the name of its header file. Other functions must be implemented to + initialize the plugin when it is loaded, and to construct instances of + the custom widget for \QD to use. + + When implementing a custom widget you must subclass + QDesignerCustomWidgetInterface to expose your widget to \QD. For + example, this is the declaration for the plugin used in the + \l{Custom Widget Plugin Example}{Custom Widget Plugin example} that + enables an analog clock custom widget to be used by \QD: + + \snippet examples/designer/customwidgetplugin/customwidgetplugin.h 0 + + Note that the only part of the class definition that is specific + to this particular custom widget is the class name. In addition, + since we are implementing an interface, we must ensure that it's + made known to the meta object system using the Q_INTERFACES() + macro. This enables \QD to use the qobject_cast() function to + query for supported interfaces using nothing but a QObject + pointer. + + After \QD loads a custom widget plugin, it calls the interface's + initialize() function to enable it to set up any resources that it + may need. This function is called with a QDesignerFormEditorInterface + parameter that provides the plugin with a gateway to all of \QD's API. + + \QD constructs instances of the custom widget by calling the plugin's + createWidget() function with a suitable parent widget. Plugins must + construct and return an instance of a custom widget with the specified + parent widget. + + In the implementation of the class you must remember to export + your custom widget plugin to \QD using the Q_EXPORT_PLUGIN2() + macro. For example, if a library called \c libcustomwidgetplugin.so + (on Unix) or \c libcustomwidget.dll (on Windows) contains a widget + class called \c MyCustomWidget, we can export it by adding the + following line to the file containing the plugin implementation: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 14 + + This macro ensures that \QD can access and construct the custom widget. + Without this macro, there is no way for \QD to use it. + + When implementing a custom widget plugin, you build it as a + separate library. If you want to include several custom widget + plugins in the same library, you must in addition subclass + QDesignerCustomWidgetCollectionInterface. + + \warning If your custom widget plugin contains QVariant + properties, be aware that only the following \l + {QVariant::Type}{types} are supported: + + \list + \o QVariant::ByteArray + \o QVariant::Bool + \o QVariant::Color + \o QVariant::Cursor + \o QVariant::Date + \o QVariant::DateTime + \o QVariant::Double + \o QVariant::Int + \o QVariant::Point + \o QVariant::Rect + \o QVariant::Size + \o QVariant::SizePolicy + \o QVariant::String + \o QVariant::Time + \o QVariant::UInt + \endlist + + For a complete example using the QDesignerCustomWidgetInterface + class, see the \l {designer/customwidgetplugin}{Custom Widget + Example}. The example shows how to create a custom widget plugin + for \QD. + + \sa QDesignerCustomWidgetCollectionInterface {Creating Custom + Widgets for Qt Designer} +*/ + +/*! + \fn QDesignerCustomWidgetInterface::~QDesignerCustomWidgetInterface() + + Destroys the custom widget interface. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::name() const + + Returns the class name of the custom widget supplied by the interface. + + The name returned \e must be identical to the class name used for the + custom widget. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::group() const + + Returns the name of the group to which the custom widget belongs. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::toolTip() const + + Returns a short description of the widget that can be used by \QD + in a tool tip. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::whatsThis() const + + Returns a description of the widget that can be used by \QD in + "What's This?" help for the widget. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::includeFile() const + + Returns the path to the include file that \l uic uses when + creating code for the custom widget. +*/ + +/*! + \fn QIcon QDesignerCustomWidgetInterface::icon() const + + Returns the icon used to represent the custom widget in \QD's + widget box. +*/ + +/*! + \fn bool QDesignerCustomWidgetInterface::isContainer() const + + Returns true if the custom widget is intended to be used as a + container; otherwise returns false. + + Most custom widgets are not used to hold other widgets, so their + implementations of this function will return false, but custom + containers will return true to ensure that they behave correctly + in \QD. +*/ + +/*! + \fn QWidget *QDesignerCustomWidgetInterface::createWidget(QWidget *parent) + + Returns a new instance of the custom widget, with the given \a + parent. +*/ + +/*! + \fn bool QDesignerCustomWidgetInterface::isInitialized() const + + Returns true if the widget has been initialized; otherwise returns + false. + + \sa initialize() +*/ + +/*! + \fn void QDesignerCustomWidgetInterface::initialize(QDesignerFormEditorInterface *formEditor) + + Initializes the widget for use with the specified \a formEditor + interface. + + \sa isInitialized() +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::domXml() const + + Returns the XML that is used to describe the custom widget's + properties to \QD. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::codeTemplate() const + + This function is reserved for future use by \QD. + + \omit + Returns the code template that \QD includes in forms that contain + the custom widget when they are saved. + \endomit +*/ + +/*! + \macro QDESIGNER_WIDGET_EXPORT + \relates QDesignerCustomWidgetInterface + \since 4.1 + + This macro is used when defining custom widgets to ensure that they are + correctly exported from plugins for use with \QD. + + On some platforms, the symbols required by \QD to create new widgets + are removed from plugins by the build system, making them unusable. + Using this macro ensures that the symbols are retained on those platforms, + and has no side effects on other platforms. + + For example, the \l{designer/worldtimeclockplugin}{World Time Clock Plugin} + example exports a custom widget class with the following declaration: + + \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 0 + \dots + \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 2 + + \sa {Creating Custom Widgets for Qt Designer} +*/ + + +// Doc: Abstract class + +/*! + \class QDesignerDnDItemInterface + \brief The QDesignerDnDItemInterface class provides an interface that is used to manage items + during a drag and drop operation. + \inmodule QtDesigner + \internal +*/ + +/*! + \enum QDesignerDnDItemInterface::DropType + + This enum describes the result of a drag and drop operation. + + \value MoveDrop The item was moved. + \value CopyDrop The item was copied. +*/ + +/*! + \fn QDesignerDnDItemInterface::QDesignerDnDItemInterface() + + Constructs a new interface to a drag and drop item. +*/ + +/*! + \fn QDesignerDnDItemInterface::~QDesignerDnDItemInterface() + + Destroys the interface to the item. +*/ + +/*! + \fn DomUI *QDesignerDnDItemInterface::domUi() const + + Returns a user interface object for the item. +*/ + +/*! + \fn QWidget *QDesignerDnDItemInterface::widget() const + + Returns the widget being copied or moved in the drag and drop operation. + + \sa source() +*/ + +/*! + \fn QWidget *QDesignerDnDItemInterface::decoration() const + + Returns the widget used to represent the item. +*/ + +/*! + \fn QPoint QDesignerDnDItemInterface::hotSpot() const + + Returns the cursor's hotspot. + + \sa QDrag::hotSpot() +*/ + +/*! + \fn DropType QDesignerDnDItemInterface::type() const + + Returns the type of drag and drop operation in progress. +*/ + +/*! + \fn QWidget *QDesignerDnDItemInterface::source() const + + Returns the widget that is the source of the drag and drop operation; i.e. the original + container of the widget being dragged. + + \sa widget() +*/ + + +// Doc: Abstract class + +/*! + \class QDesignerIconCacheInterface + \brief The QDesignerIconCacheInterface class provides an interface to \QD's icon cache. + \inmodule QtDesigner + \internal +*/ + +/*! + \fn QDesignerIconCacheInterface::QDesignerIconCacheInterface(QObject *parent) + + Constructs a new interface with the given \a parent. +*/ + +/*! + \fn QIcon QDesignerIconCacheInterface::nameToIcon(const QString &filePath, const QString &qrcPath) + + Returns the icon associated with the name specified by \a filePath in the resource + file specified by \a qrcPath. + + If \a qrcPath refers to a valid resource file, the name used for the file path is a path + within those resources; otherwise the file path refers to a local file. + + \sa {The Qt Resource System}, nameToPixmap() +*/ + +/*! + \fn QPixmap QDesignerIconCacheInterface::nameToPixmap(const QString &filePath, const QString &qrcPath) + + Returns the pixmap associated with the name specified by \a filePath in the resource + file specified by \a qrcPath. + + If \a qrcPath refers to a valid resource file, the name used for the file path is a path + within those resources; otherwise the file path refers to a local file. + + \sa {The Qt Resource System}, nameToIcon() +*/ + +/*! + \fn QString QDesignerIconCacheInterface::iconToFilePath(const QIcon &icon) const + + Returns the file path associated with the given \a icon. The file path is a path within + an application resources. +*/ + +/*! + \fn QString QDesignerIconCacheInterface::iconToQrcPath(const QIcon &icon) const + + Returns the path to the resource file that refers to the specified \a icon. The resource + path refers to a local file. +*/ + +/*! + \fn QString QDesignerIconCacheInterface::pixmapToFilePath(const QPixmap &pixmap) const + + Returns the file path associated with the given \a pixmap. The file path is a path within + an application resources. +*/ + +/*! + \fn QString QDesignerIconCacheInterface::pixmapToQrcPath(const QPixmap &pixmap) const + + Returns the path to the resource file that refers to the specified \a pixmap. The resource + path refers to a local file. +*/ + +/*! + \fn QList QDesignerIconCacheInterface::pixmapList() const + + Returns a list of pixmaps for the icons provided by the icon cache. +*/ + +/*! + \fn QList QDesignerIconCacheInterface::iconList() const + + Returns a list of icons provided by the icon cache. +*/ + +/*! + \fn QString QDesignerIconCacheInterface::resolveQrcPath(const QString &filePath, const QString &qrcPath, const QString &workingDirectory) const + + Returns a path to a resource specified by the \a filePath within + the resource file located at \a qrcPath. If \a workingDirectory is + a valid path to a directory, the path returned will be relative to + that directory; otherwise an absolute path is returned. + + \omit + ### Needs checking + \endomit +*/ + + +// Doc: Interface only + +/*! + \class QDesignerPropertySheetExtension + + \brief The QDesignerPropertySheetExtension class allows you to + manipulate a widget's properties which is displayed in Qt + Designer's property editor. + + \sa QDesignerDynamicPropertySheetExtension + + \inmodule QtDesigner + + QDesignerPropertySheetExtension provides a collection of functions that + are typically used to query a widget's properties, and to + manipulate the properties' appearance in the property editor. For + example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 15 + + Note that if you change the value of a property using the + QDesignerPropertySheetExtension::setProperty() function, the undo + stack is not updated. To ensure that a property's value can be + reverted using the undo stack, you must use the + QDesignerFormWindowCursorInterface::setProperty() function, or its + buddy \l + {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()}, + instead. + + When implementing a custom widget plugin, a pointer to \QD's + current QDesignerFormEditorInterface object (\c formEditor in the + example above) is provided by the + QDesignerCustomWidgetInterface::initialize() function's parameter. + + The property sheet, or any other extension, can be retrieved by + querying \QD's extension manager using the qt_extension() + function. When you want to release the extension, you only need to + delete the pointer. + + All widgets have a default property sheet which populates \QD's + property editor with the widget's properties (i.e the ones defined + with the Q_PROPERTY() macro). But QDesignerPropertySheetExtension + also provides an interface for creating custom property sheet + extensions. + + \warning \QD uses the QDesignerPropertySheetExtension to feed its + property editor. Whenever a widget is selected in its workspace, + \QD will query for the widget's property sheet extension. If the + selected widget has an implemented property sheet extension, this + extension will override the default property sheet. + + To create a property sheet extension, your extension class must + inherit from both QObject and + QDesignerPropertySheetExtension. Then, since we are implementing + an interface, we must ensure that it's made known to the meta + object system using the Q_INTERFACES() macro: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 16 + + This enables \QD to use qobject_cast() to query for supported + interfaces using nothing but a QObject pointer. + + In \QD the extensions are not created until they are + required. For that reason, when implementing a property sheet + extension, you must also create a QExtensionFactory, i.e a class + that is able to make an instance of your extension, and register + it using \QD's \l {QExtensionManager}{extension manager}. + + When a property sheet extension is required, \QD's \l + {QExtensionManager}{extension manager} will run through all its + registered factories calling QExtensionFactory::createExtension() + for each until the first one that is able to create a property + sheet extension for the selected widget, is found. This factory + will then make an instance of the extension. If no such factory + can be found, \QD will use the default property sheet. + + There are four available types of extensions in \QD: + QDesignerContainerExtension, QDesignerMemberSheetExtension, + QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. Qt + Designer's behavior is the same whether the requested extension is + associated with a multi page container, a member sheet, a property + sheet or a task menu. + + The QExtensionFactory class provides a standard extension factory, + and can also be used as an interface for custom extension + factories. You can either create a new QExtensionFactory and + reimplement the QExtensionFactory::createExtension() function. For + example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 17 + + Or you can use an existing factory, expanding the + QExtensionFactory::createExtension() function to make the factory + able to create a property sheet extension extension as well. For + example: + + \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 18 + + For a complete example using an extension class, see the \l + {designer/taskmenuextension}{Task Menu Extension example}. The + example shows how to create a custom widget plugin for Qt + Designer, and how to to use the QDesignerTaskMenuExtension class + to add custom items to \QD's task menu. + + \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget + Extensions} +*/ + +/*! + \fn QDesignerPropertySheetExtension::~QDesignerPropertySheetExtension() + + Destroys the property sheet extension. +*/ + +/*! + \fn int QDesignerPropertySheetExtension::count() const + + Returns the selected widget's number of properties. +*/ + +/*! + \fn int QDesignerPropertySheetExtension::indexOf(const QString &name) const + + Returns the index for a given property \a name. + + \sa propertyName() +*/ + +/*! + \fn QString QDesignerPropertySheetExtension::propertyName(int index) const + + Returns the name of the property at the given \a index. + + \sa indexOf() +*/ + +/*! + \fn QString QDesignerPropertySheetExtension::propertyGroup(int index) const + + Returns the property group for the property at the given \a index. + + \QD's property editor supports property groups, i.e. sections of + related properties. A property can be related to a group using the + setPropertyGroup() function. The default group of any property is + the name of the class that defines it. For example, the + QObject::objectName property appears within the QObject property + group. + + \sa indexOf(), setPropertyGroup() +*/ + +/*! + \fn void QDesignerPropertySheetExtension::setPropertyGroup(int index, const QString &group) + + Sets the property group for the property at the given \a index to + \a group. + + Relating a property to a group makes it appear within that group's + section in the property editor. The default property group of any + property is the name of the class that defines it. For example, + the QObject::objectName property appears within the QObject + property group. + + \sa indexOf(), property(), propertyGroup() +*/ + +/*! + \fn bool QDesignerPropertySheetExtension::hasReset(int index) const + + Returns true if the property at the given \a index has a reset + button in \QD's property editor, otherwise false. + + \sa indexOf(), reset() +*/ + +/*! + \fn bool QDesignerPropertySheetExtension::reset(int index) + + Resets the value of the property at the given \a index, to the + default value. Returns true if a default value could be found, otherwise false. + + \sa indexOf(), hasReset(), isChanged() +*/ + +/*! + \fn bool QDesignerPropertySheetExtension::isVisible(int index) const + + Returns true if the property at the given \a index is visible in + \QD's property editor, otherwise false. + + \sa indexOf(), setVisible() +*/ + +/*! + \fn void QDesignerPropertySheetExtension::setVisible(int index, bool visible) + + If \a visible is true, the property at the given \a index is + visible in \QD's property editor; otherwise the property is + hidden. + + \sa indexOf(), isVisible() +*/ + +/*! + \fn bool QDesignerPropertySheetExtension::isAttribute(int index) const + + Returns true if the property at the given \a index is an attribute, + which will be \e excluded from the UI file, otherwise false. + + \sa indexOf(), setAttribute() +*/ + +/*! + \fn void QDesignerPropertySheetExtension::setAttribute(int index, bool attribute) + + If \a attribute is true, the property at the given \a index is + made an attribute which will be \e excluded from the UI file; + otherwise it will be included. + + \sa indexOf(), isAttribute() +*/ + +/*! + \fn QVariant QDesignerPropertySheetExtension::property(int index) const + + Returns the value of the property at the given \a index. + + \sa indexOf(), setProperty(), propertyGroup() +*/ + +/*! + \fn void QDesignerPropertySheetExtension::setProperty(int index, const QVariant &value) + + Sets the \a value of the property at the given \a index. + + \warning If you change the value of a property using this + function, the undo stack is not updated. To ensure that a + property's value can be reverted using the undo stack, you must + use the QDesignerFormWindowCursorInterface::setProperty() + function, or its buddy \l + {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()}, + instead. + + \sa indexOf(), property(), propertyGroup() +*/ + +/*! + \fn bool QDesignerPropertySheetExtension::isChanged(int index) const + + Returns true if the value of the property at the given \a index + differs from the property's default value, otherwise false. + + \sa indexOf(), setChanged(), reset() +*/ + +/*! + \fn void QDesignerPropertySheetExtension::setChanged(int index, bool changed) + + Sets whether the property at the given \a index is different from + its default value, or not, depending on the \a changed parameter. + + \sa indexOf(), isChanged() +*/ + +// Doc: Interface only + +/*! + \class QDesignerDynamicPropertySheetExtension + + \brief The QDesignerDynamicPropertySheetExtension class allows you to + manipulate a widget's dynamic properties in Qt Designer's property editor. + + \sa QDesignerPropertySheetExtension, {QObject#Dynamic Properties}{Dynamic Properties} + + \inmodule QtDesigner + \since 4.3 +*/ + +/*! + \fn QDesignerDynamicPropertySheetExtension::~QDesignerDynamicPropertySheetExtension() + + Destroys the dynamic property sheet extension. +*/ + +/*! + \fn bool QDesignerDynamicPropertySheetExtension::dynamicPropertiesAllowed() const + + Returns true if the widget supports dynamic properties; otherwise returns false. +*/ + +/*! + \fn int QDesignerDynamicPropertySheetExtension::addDynamicProperty(const QString &propertyName, const QVariant &value) + + Adds a dynamic property named \a propertyName and sets its value to \a value. + Returns the index of the property if it was added successfully; otherwise returns -1 to + indicate failure. +*/ + +/*! + \fn bool QDesignerDynamicPropertySheetExtension::removeDynamicProperty(int index) + + Removes the dynamic property at the given \a index. + Returns true if the operation succeeds; otherwise returns false. +*/ + +/*! + \fn bool QDesignerDynamicPropertySheetExtension::isDynamicProperty(int index) const + + Returns true if the property at the given \a index is a dynamic property; otherwise + returns false. +*/ + +/*! + \fn bool QDesignerDynamicPropertySheetExtension::canAddDynamicProperty(const QString &propertyName) const + + Returns true if \a propertyName is a valid, unique name for a dynamic + property; otherwise returns false. + +*/ diff --git a/doc/src/classes/qtendian.qdoc b/doc/src/classes/qtendian.qdoc new file mode 100644 index 0000000..dcffb5d --- /dev/null +++ b/doc/src/classes/qtendian.qdoc @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \headerfile + \title Endian Conversion Functions + \ingroup architecture + \brief The header provides functions to convert between + little and big endian representations of numbers. +*/ + +/*! + \fn T qFromBigEndian(const uchar *src) + \since 4.3 + \relates + + Reads a big-endian number from memory location \a src and returns the number in the + host byte order representation. + On CPU architectures where the host byte order is little-endian (such as x86) this + will swap the byte order; otherwise it will just read from \a src. + + \note Template type \c{T} can either be a qint16, qint32 or qint64. Other types of + integers, e.g., qlong, are not applicable. + + There are no data alignment constraints for \a src. + + \sa qFromLittleEndian() + \sa qToBigEndian() + \sa qToLittleEndian() +*/ +/*! + \fn T qFromBigEndian(T src) + \since 4.3 + \relates + \overload + + Converts \a src from big-endian byte order and returns the number in host byte order + representation of that number. + On CPU architectures where the host byte order is little-endian (such as x86) this + will return \a src with the byte order swapped; otherwise it will return \a src + unmodified. +*/ +/*! + \fn T qFromLittleEndian(const uchar *src) + \since 4.3 + \relates + + Reads a little-endian number from memory location \a src and returns the number in + the host byte order representation. + On CPU architectures where the host byte order is big-endian (such as PowerPC) this + will swap the byte order; otherwise it will just read from \a src. + + \note Template type \c{T} can either be a qint16, qint32 or qint64. Other types of + integers, e.g., qlong, are not applicable. + + There are no data alignment constraints for \a src. + + \sa qFromBigEndian() + \sa qToBigEndian() + \sa qToLittleEndian() +*/ +/*! + \fn T qFromLittleEndian(T src) + \since 4.3 + \relates + \overload + + Converts \a src from little-endian byte order and returns the number in host byte + order representation of that number. + On CPU architectures where the host byte order is big-endian (such as PowerPC) this + will return \a src with the byte order swapped; otherwise it will return \a src + unmodified. +*/ +/*! + \fn void qToBigEndian(T src, uchar *dest) + \since 4.3 + \relates + + Writes the number \a src with template type \c{T} to the memory location at \a dest + in big-endian byte order. + + Note that template type \c{T} can only be an integer data type (signed or unsigned). + + There are no data alignment constraints for \a dest. + + \sa qFromBigEndian() + \sa qFromLittleEndian() + \sa qToLittleEndian() +*/ +/*! + \fn T qToBigEndian(T src) + \since 4.3 + \relates + \overload + + Converts \a src from host byte order and returns the number in big-endian byte order + representation of that number. + On CPU architectures where the host byte order is little-endian (such as x86) this + will return \a src with the byte order swapped; otherwise it will return \a src + unmodified. +*/ +/*! + \fn void qToLittleEndian(T src, uchar *dest) + \since 4.3 + \relates + + Writes the number \a src with template type \c{T} to the memory location at \a dest + in little-endian byte order. + + Note that template type \c{T} can only be an integer data type (signed or unsigned). + + There are no data alignment constraints for \a dest. + + \sa qFromBigEndian() + \sa qFromLittleEndian() + \sa qToBigEndian() +*/ +/*! + \fn T qToLittleEndian(T src) + \since 4.3 + \relates + \overload + + Converts \a src from host byte order and returns the number in little-endian byte + order representation of that number. + On CPU architectures where the host byte order is big-endian (such as PowerPC) this + will return \a src with the byte order swapped; otherwise it will return \a src + unmodified. +*/ + diff --git a/doc/src/classes/qtestevent.qdoc b/doc/src/classes/qtestevent.qdoc new file mode 100644 index 0000000..2e111b3 --- /dev/null +++ b/doc/src/classes/qtestevent.qdoc @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QTestEventList + \inmodule QtTest + + \brief The QTestEventList class provides a list of GUI events. + + QTestEventList inherits from QList, and provides + convenience functions for populating the list. + + A QTestEventList can be populated with GUI events that can be + stored as test data for later usage, or be replayed on any + QWidget. + + Example: + \snippet doc/src/snippets/code/doc_src_qtestevent.qdoc 0 + + The example above simulates the user entering the character \c a + followed by a backspace, waiting for 200 milliseconds and + repeating it. +*/ + +/*! \fn QTestEventList::QTestEventList() + + Constructs an empty QTestEventList. +*/ + +/*! \fn QTestEventList::QTestEventList(const QTestEventList &other) + + Constructs a new QTestEventList as a copy of \a other. +*/ + +/*! \fn QTestEventList::~QTestEventList() + + Empties the list and destroys all stored events. +*/ + +/*! \fn void QTestEventList::clear() + + Removes all events from the list. +*/ + +/*! \fn void QTestEventList::addKeyClick(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + + Adds a new key click to the list. The event will simulate the key \a qtKey with the modifier \a modifiers and then wait for \a msecs milliseconds. + + \sa QTest::keyClick() +*/ + +/*! \fn void QTestEventList::addKeyPress(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + + Adds a new key press to the list. The event will press the key \a qtKey with the modifier \a modifiers and then wait for \a msecs milliseconds. + + \sa QTest::keyPress() +*/ + +/*! \fn void QTestEventList::addKeyRelease(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + + Adds a new key release to the list. The event will release the key \a qtKey with the modifier \a modifiers and then wait for \a msecs milliseconds. + + \sa QTest::keyRelease() + +*/ + +/*! \fn void QTestEventList::addKeyEvent(QTest::KeyAction action, Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + \internal +*/ + +/*! \fn void QTestEventList::addKeyClick(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + + \overload + + Adds a new key click to the list. The event will simulate the key \a ascii with the modifier \a modifiers and then wait for \a msecs milliseconds. + + \sa QTest::keyClick() + +*/ + +/*! \fn void QTestEventList::addKeyPress(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + + \overload + + Adds a new key press to the list. The event will press the key \a ascii with the modifier \a modifiers and then wait for \a msecs milliseconds. + + \sa QTest::keyPress() +*/ + +/*! \fn void QTestEventList::addKeyRelease(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + + \overload + + Adds a new key release to the list. The event will release the key \a ascii with the modifier \a modifiers and then wait for \a msecs milliseconds. + + \sa QTest::keyRelease() +*/ + +/*! \fn void QTestEventList::addKeyClicks(const QString &keys, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + + Adds new keyboard entries to the list. The event will press the \a keys with the \a modifiers and wait \a msecs milliseconds between each key. + + \sa QTest::keyClicks() +*/ + +/*! \fn void QTestEventList::addKeyEvent(QTest::KeyAction action, char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + \internal +*/ + +/*! \fn void QTestEventList::addDelay(int msecs) + + Adds a \a msecs milliseconds delay. + + \sa QTest::qWait() +*/ + +/*! \fn void QTestEventList::simulate(QWidget *w) + + Simulates the events from the list one by one on the widget \a w. + For an example, please read the \l QTestEventList class documentation. +*/ + +/*! \fn void QTestEventList::addMousePress(Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay=-1) + + Add a mouse press to the list. The event will press the \a button with optional \a modifiers at the position \a pos with an optional \a delay. The default position is the center of the widget. + + \sa QTest::mousePress() +*/ +/*! \fn void QTestEventList::addMouseRelease(Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay=-1) + + Add a mouse release to the list. The event will release the \a button with optional \a modifiers at the position \a pos with an optional \a delay. The default position is the center of the widget. + + \sa QTest::mouseRelease() +*/ +/*! \fn void QTestEventList::addMouseClick(Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay=-1) + + Add a mouse click to the list. The event will click the \a button with optional \a modifiers at the position \a pos with an optional \a delay. The default position is the center of the widget. + + \sa QTest::mouseClick() +*/ +/*! \fn void QTestEventList::addMouseDClick(Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay=-1) + + Add a double mouse click to the list. The event will double click the \a button with optional \a modifiers at the position \a pos with an optional \a delay. The default position is the center of the widget. + + \sa QTest::mousePress() +*/ +/*! \fn void QTestEventList::addMouseMove(QPoint pos = QPoint(), int delay=-1) + + Adds a mouse move to the list. The event will move the mouse to the position \a pos. If a \a delay (in milliseconds) is set, the test will wait after moving the mouse. The default position is the center of the widget. + + \sa QTest::mousePress() +*/ + diff --git a/doc/src/classes/qvarlengtharray.qdoc b/doc/src/classes/qvarlengtharray.qdoc new file mode 100644 index 0000000..ac6bb6e --- /dev/null +++ b/doc/src/classes/qvarlengtharray.qdoc @@ -0,0 +1,274 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QVarLengthArray + \brief The QVarLengthArray class provides a low-level variable-length array. + + \ingroup tools + \reentrant + + The C++ language doesn't support variable-length arrays on the stack. + For example, the following code won't compile: + + \snippet doc/src/snippets/code/doc_src_qvarlengtharray.qdoc 0 + + The alternative is to allocate the array on the heap (with + \c{new}): + + \snippet doc/src/snippets/code/doc_src_qvarlengtharray.qdoc 1 + + However, if myfunc() is called very frequently from the + application's inner loop, heap allocation can be a major source + of slowdown. + + QVarLengthArray is an attempt to work around this gap in the C++ + language. It allocates a certain number of elements on the stack, + and if you resize the array to a larger size, it automatically + uses the heap instead. Stack allocation has the advantage that + it is much faster than heap allocation. + + Example: + \snippet doc/src/snippets/code/doc_src_qvarlengtharray.qdoc 2 + + In the example above, QVarLengthArray will preallocate 1024 + elements on the stack and use them unless \c{n + 1} is greater + than 1024. If you omit the second template argument, + QVarLengthArray's default of 256 is used. + + QVarLengthArray's value type must be an \l{assignable data type}. + This covers most data types that are commonly used, but the + compiler won't let you, for example, store a QWidget as a value; + instead, store a QWidget *. + + QVarLengthArray, like QVector, provides a resizable array data + structure. The main differences between the two classes are: + + \list + \o QVarLengthArray's API is much more low-level. It provides no + iterators and lacks much of QVector's functionality. + + \o QVarLengthArray doesn't initialize the memory if the value is + a basic type. (QVector always does.) + + \o QVector uses \l{implicit sharing} as a memory optimization. + QVarLengthArray doesn't provide that feature; however, it + usually produces slightly better performance due to reduced + overhead, especially in tight loops. + \endlist + + In summary, QVarLengthArray is a low-level optimization class + that only makes sense in very specific cases. It is used a few + places inside Qt and was added to Qt's public API for the + convenience of advanced users. + + \sa QVector, QList, QLinkedList +*/ + +/*! \fn QVarLengthArray::QVarLengthArray(int size) + + Constructs an array with an initial size of \a size elements. + + If the value type is a primitive type (e.g., char, int, float) or + a pointer type (e.g., QWidget *), the elements are not + initialized. For other types, the elements are initialized with a + \l{default-constructed value}. +*/ + +/*! \fn QVarLengthArray::~QVarLengthArray() + + Destroys the array. +*/ + +/*! \fn int QVarLengthArray::size() const + + Returns the number of elements in the array. + + \sa isEmpty(), resize() +*/ + +/*! \fn int QVarLengthArray::count() const + + Same as size(). + + \sa isEmpty(), resize() +*/ + +/*! \fn bool QVarLengthArray::isEmpty() const + + Returns true if the array has size 0; otherwise returns false. + + \sa size(), resize() +*/ + +/*! \fn void QVarLengthArray::clear() + + Removes all the elements from the array. + + Same as resize(0). +*/ + +/*! \fn void QVarLengthArray::resize(int size) + + Sets the size of the array to \a size. If \a size is greater than + the current size, elements are added to the end. If \a size is + less than the current size, elements are removed from the end. + + If the value type is a primitive type (e.g., char, int, float) or + a pointer type (e.g., QWidget *), new elements are not + initialized. For other types, the elements are initialized with a + \l{default-constructed value}. + + \sa size() +*/ + +/*! \fn int QVarLengthArray::capacity() const + + Returns the maximum number of elements that can be stored in the + array without forcing a reallocation. + + The sole purpose of this function is to provide a means of fine + tuning QVarLengthArray's memory usage. In general, you will rarely ever + need to call this function. If you want to know how many items are + in the array, call size(). + + \sa reserve() +*/ + +/*! \fn void QVarLengthArray::reserve(int size) + + Attempts to allocate memory for at least \a size elements. If you + know in advance how large the array can get, you can call this + function and if you call resize() often, you are likely to get + better performance. If \a size is an underestimate, the worst + that will happen is that the QVarLengthArray will be a bit + slower. + + The sole purpose of this function is to provide a means of fine + tuning QVarLengthArray's memory usage. In general, you will + rarely ever need to call this function. If you want to change the + size of the array, call resize(). + + \sa capacity() +*/ + +/*! \fn T &QVarLengthArray::operator[](int i) + + Returns a reference to the item at index position \a i. + + \a i must be a valid index position in the array (i.e., 0 <= \a i + < size()). + + \sa data() +*/ + +/*! \fn const T &QVarLengthArray::operator[](int i) const + + \overload +*/ + + +/*! + \fn void QVarLengthArray::append(const T &t) + + Appends item \a t to the array, extending the array if necessary. + + \sa removeLast() +*/ + + +/*! + \fn inline void QVarLengthArray::removeLast() + \since 4.5 + + Decreases the size of the array by one. The allocated size is not changed. + + \sa append() +*/ + +/*! + \fn void QVarLengthArray::append(const T *buf, int size) + + Appends \a size amount of items referenced by \a buf to this array. +*/ + + +/*! \fn T *QVarLengthArray::data() + + Returns a pointer to the data stored in the array. The pointer can + be used to access and modify the items in the array. + + Example: + \snippet doc/src/snippets/code/doc_src_qvarlengtharray.qdoc 3 + + The pointer remains valid as long as the array isn't reallocated. + + This function is mostly useful to pass an array to a function + that accepts a plain C++ array. + + \sa constData(), operator[]() +*/ + +/*! \fn const T *QVarLengthArray::data() const + + \overload +*/ + +/*! \fn const T *QVarLengthArray::constData() const + + Returns a const pointer to the data stored in the array. The + pointer can be used to access the items in the array. The + pointer remains valid as long as the array isn't reallocated. + + This function is mostly useful to pass an array to a function + that accepts a plain C++ array. + + \sa data(), operator[]() +*/ + +/*! \fn QVarLengthArray &QVarLengthArray::operator=(const QVarLengthArray &other) + Assigns \a other to this array and returns a reference to this array. + */ + +/*! \fn QVarLengthArray::QVarLengthArray(const QVarLengthArray &other) + Constructs a copy of \a other. + */ + diff --git a/doc/src/classes/qwaitcondition.qdoc b/doc/src/classes/qwaitcondition.qdoc new file mode 100644 index 0000000..ae94e35 --- /dev/null +++ b/doc/src/classes/qwaitcondition.qdoc @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QWaitCondition + \brief The QWaitCondition class provides a condition variable for + synchronizing threads. + + \threadsafe + + \ingroup thread + \ingroup environment + + QWaitCondition allows a thread to tell other threads that some + sort of condition has been met. One or many threads can block + waiting for a QWaitCondition to set a condition with wakeOne() or + wakeAll(). Use wakeOne() to wake one randomly selected condition or + wakeAll() to wake them all. + + For example, let's suppose that we have three tasks that should + be performed whenever the user presses a key. Each task could be + split into a thread, each of which would have a + \l{QThread::run()}{run()} body like this: + + \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 0 + + Here, the \c keyPressed variable is a global variable of type + QWaitCondition. + + A fourth thread would read key presses and wake the other three + threads up every time it receives one, like this: + + \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 1 + + The order in which the three threads are woken up is undefined. + Also, if some of the threads are still in \c do_something() when + the key is pressed, they won't be woken up (since they're not + waiting on the condition variable) and so the task will not be + performed for that key press. This issue can be solved using a + counter and a QMutex to guard it. For example, here's the new + code for the worker threads: + + \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 2 + + Here's the code for the fourth thread: + + \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 3 + + The mutex is necessary because the results of two threads + attempting to change the value of the same variable + simultaneously are unpredictable. + + Wait conditions are a powerful thread synchronization primitive. + The \l{threads/waitconditions}{Wait Conditions} example shows how + to use QWaitCondition as an alternative to QSemaphore for + controlling access to a circular buffer shared by a producer + thread and a consumer thread. + + \sa QMutex, QSemaphore, QThread, {Wait Conditions Example} +*/ + +/*! + \fn QWaitCondition::QWaitCondition() + + Constructs a new wait condition object. +*/ + +/*! + \fn QWaitCondition::~QWaitCondition() + + Destroys the wait condition object. +*/ + +/*! + \fn void QWaitCondition::wakeOne() + + Wakes one thread waiting on the wait condition. The thread that + is woken up depends on the operating system's scheduling + policies, and cannot be controlled or predicted. + + If you want to wake up a specific thread, the solution is + typically to use different wait conditions and have different + threads wait on different conditions. + + \sa wakeAll() +*/ + +/*! + \fn void QWaitCondition::wakeAll() + + Wakes all threads waiting on the wait condition. The order in + which the threads are woken up depends on the operating system's + scheduling policies and cannot be controlled or predicted. + + \sa wakeOne() +*/ + +/*! + \fn bool QWaitCondition::wait(QMutex *mutex, unsigned long time) + + Releases the locked \a mutex and waits on the wait condition. The + \a mutex must be initially locked by the calling thread. If \a + mutex is not in a locked state, this function returns + immediately. If \a mutex is a recursive mutex, this function + returns immediately. The \a mutex will be unlocked, and the + calling thread will block until either of these conditions is met: + + \list + \o Another thread signals it using wakeOne() or wakeAll(). This + function will return true in this case. + \o \a time milliseconds has elapsed. If \a time is \c ULONG_MAX + (the default), then the wait will never timeout (the event + must be signalled). This function will return false if the + wait timed out. + \endlist + + The mutex will be returned to the same locked state. This + function is provided to allow the atomic transition from the + locked state to the wait state. + + \sa wakeOne(), wakeAll() +*/ + +/*! + \fn bool QWaitCondition::wait(QReadWriteLock *readWriteLock, unsigned long time) + \since 4.4 + + Releases the locked \a readWriteLock and waits on the wait + condition. The \a readWriteLock must be initially locked by the + calling thread. If \a readWriteLock is not in a locked state, this + function returns immediately. The \a readWriteLock must not be + locked recursively, otherwise this function will not release the + lock properly. The \a readWriteLock will be unlocked, and the + calling thread will block until either of these conditions is met: + + \list + \o Another thread signals it using wakeOne() or wakeAll(). This + function will return true in this case. + \o \a time milliseconds has elapsed. If \a time is \c ULONG_MAX + (the default), then the wait will never timeout (the event + must be signalled). This function will return false if the + wait timed out. + \endlist + + The \a readWriteLock will be returned to the same locked + state. This function is provided to allow the atomic transition + from the locked state to the wait state. + + \sa wakeOne(), wakeAll() +*/ diff --git a/doc/src/phonon-api.qdoc b/doc/src/phonon-api.qdoc deleted file mode 100644 index 09274bf..0000000 --- a/doc/src/phonon-api.qdoc +++ /dev/null @@ -1,5023 +0,0 @@ -/* - This file is part of the KDE project - Copyright (C) 2005-2007 Matthias Kretz - Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - Contact: Nokia Corporation (qt-info@nokia.com) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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. -*/ - - -/*! - \enum Phonon::DiscType - Enum to identify the media discs supported by MediaObject. - - \value NoDisc - No disc was selected. This is only useful as a return value from - MediaSource::diskType(). - \value Cd Identifies Audio CDs. - \value Dvd Identifies DVDs (not arbitrary data DVDs, only movie DVDs). - \value Vcd Identifies Video CDs. - - \sa MediaSource, MediaObject -*/ - -/*! - \enum Phonon::MetaData - - Provided as keys for Phonon::MediaObject::metaData(). The enum - values matches strings defined in the Ogg Vorbis specification - - \value ArtistMetaData - \value AlbumMetaData - \value TitleMetaData - \value DateMetaData - \value GenreMetaData - \value TracknumberMetaData - \value DescriptionMetaData - \value MusicBrainzDiscIdMetaData -*/ - -/*! - \enum Phonon::State - \since 4.4 - - The state enum describes the different states a media object can - take. Several functions of \l{Phonon::}{MediaObject} are - asynchronous, so even if a you have requested a state change - through a function call, e.g., through - \l{Phonon::MediaObject::}{play()}, you cannot be sure that the - change has taken place before you receive the - \l{Phonon::MediaObject::}{stateChanged()} signal. - - A media object can at any time change into any state, regardless - of the state it previously had. \omit In the - \l{Phonon::}{MediaObject} class description explains the typical - state changes in the life of a media object. \endomit - - \value LoadingState - After construction it might take a while before the media object - is ready to \l{Phonon::MediaObject::}{play()}. This state is - commonly used by backends to initialize the \l{Phonon - Overview}{media graph} and loading the source. When - the object leaves the loading state, it will enter the - StoppedState unless an error occurred or another state is - requested through a function call, e.g., - \l{Phonon::}{MediaObject::play()}. - - \value StoppedState - In the stopped state, the media object is ready to play its - current media source. The current - \l{MediaObject::seek()}{position} in the media stream is then 0. - - \value PlayingState - The media object is playing back its media source. - - \value BufferingState - The Player is waiting for data to be able to start or continue - playing. This state is commonly used to wait for media data over a - network connection. - - \value PausedState - The media player has currently paused its playback, i.e., it - stops playing but keeps the current playback position in the - stream. - - \value ErrorState - When a media object enters the error state a problem with the - playback has occurred. The possible errors are grouped into - two categories by Phonon::ErrorType, and the type can be - queried through \l{Phonon::MediaObject::}{errorType()}. A - \l{Phonon::}{FatalError} implies that the playback - cannot continue, but one can still try with a new media - source. With a \l{Phonon::}{NormalError} it might - be possible to continue playback, and a media object may - therefore change state from the ErrorState. - - \sa MediaObject -*/ - -/*! - \enum Phonon::Category - - Sets the category your program should be listed in in the mixer. - - \value NoCategory - Will make use of the default device. - \value NotificationCategory - If the sounds produced are notifications (ping, beep and such) you - should use this category. - \value MusicCategory - If your application is a music player (like a jukebox or media player - playing an audio file). - \value VideoCategory - If the sound is the audio channel of a video. - \value CommunicationCategory - If your applications produces sounds from communication with somebody - else (VoIP, voice chat). - \value GameCategory - Sound produced by a computer game should go into this category. - \value AccessibilityCategory - Sounds produced for accessibility (e.g., Text-To-Speech) - \omitvalue LastCategory - Holds the largest value of categories. - \omitvalue AccessibilityCategory - - A Jukebox will set this to Music, a VoIP program to Communication, a - DVD player to video, and so on. - - \note These categories can also become useful for an application that - controls the volumes automatically, like turning down the music when a call - comes in, or turning down the notifications when the media player knows - it's playing classical music. -*/ - -/*! - \enum Phonon::ErrorType - - This enum describes the severity when an error has occurred during - playback. - - After a media object has entered the \l{Phonon::}{ErrorState}, one - can query the type of error from - \l{Phonon::}{MediaObject::errorType()}. Note that you should query - the error when receiving the - \l{Phonon::}{MediaObject::stateChanged()} signal, because the - error type will be lost if the media object leaves the error - state. - - \value NoError No error. MediaObject::errorType() returns this if - MediaObject::state() != Phonon::ErrorState. - - \value NormalError An error has occurred with the playback of the current - source. It might be possible to continue playback, for instance, if only the - audio stream in a video cannot be played back. The media object will then - leave the error state again. - - \value FatalError. Something important does not work. Your program cannot continue - the playback of the current source, but it might be possible to try another. - - \sa MediaObject::errorType() -*/ - -/*! - \fn QString Phonon::categoryToString(Category c) - - Returns a (translated) string to show to the user identifying the given - Category (\a c). -*/ - -/*! - \enum Phonon::ObjectDescriptionType - \relates Phonon::ObjectDescription - - This enum defines the type of information that is contained in a - \l{Phonon::}{ObjectDescription} object. - - \value AudioOutputDeviceType An audio output device (\l{Phonon::}{AudioOutputDevice}). - This can be soundcards (with different drivers), - sound servers, or other virtual outputs like playback on a different - computer on the network. - - \value EffectType An audio effect (\l{Phonon::}{EffectDescription}). - \omitvalue SubtitleType - \omitvalue AudioCaptureDeviceType - \omitvalue AudioChannelType -*/ - -/*! - \typedef Phonon::AudioOutputDevice - \relates Phonon::ObjectDescription - - This typedef of \l{Phonon::}{ObjectDescription} describes an audio output - device, such as soundcards (with different drivers), sound servers, or other - virtual outputs like playback on a different computer on the network. - - \omit - For Hardware devices the backend should use libkaudiodevicelist - (AudioDevice and AudioDeviceEnumerator) which will list removable - devices even when they are unplugged and provide a unique identifier - that can make backends use the same identifiers. - \endomit - - A list of available devices is given by the backend with - Backendcapabilities::availableAudioOutputDevices() - - \snippet doc/src/snippets/phononobjectdescription.cpp 1 - -*/ - -/*! - \fn Phonon::phononVersion() - \inmodule Phonon - \since 4.5 - - Returns the Phonon version. -*/ - -/*! - \class Phonon::ObjectDescription - \inmodule Phonon - \inheaderfile Phonon/ObjectDescription - \since 4.4 - \brief The ObjectDescription class provides information about Phonon objects. - - Phonon currently uses this class to describe audio effects and - audio output devices - using the typedefs AudioOutputDevice and - EffectDescription. The type of an ObjectDescription is also - described through the \l{Phonon::}{ObjectDescriptionType} enum. - Objects of the same \l{Phonon::ObjectDescriptionType}{type} are - uniquely identified by an index(). - - The class gives a description() and a name() of the object, both - of which are strings appropriate for end users of a Phonon - application. You can also check whether the device or effect - described is \l{isValid()}{valid}. This does not guarantee that - the device or effect functions as expected, but that the - ObjectDescription describes an existing device or effect. - - Audio output devices and effect descriptions are used to select - the audio output device to be used for playback and to create - effects; we show examples of this in the snippet below. The - available descriptions can be fetched with - \l{Phonon::BackendCapabilities::}{availableAudioOutputDevices()} - and \l{Phonon::BackendCapabilities::}{availableAudioEffects()} - static functions in the Phonon::BackendCapabilities namespace - - \snippet doc/src/snippets/phononobjectdescription.cpp 0 - - Other types of ObjectDescriptions might be possible in the future, - e.g., descriptions of audio capture devices, such as microphones. - - \omit Not implemented yet. - Need a new paragraph on that some descriptions 'belong - together', such as chained audio effects. - - Some parts give the end user choices, e.g. what source to capture - audio from. These choices are described by the name and - description methods of this class and identified with the id - method. Subclasses then define additional information like which - audio and video choices belong together. \endomit - - \sa Phonon::AudioOutputDevice, Phonon::EffectDescription, {Capabilities Example}, {Phonon Module} -*/ - -/*! - \fn Phonon::ObjectDescription::ObjectDescription() - \brief constructs a new object description. - \internal -*/ - -/*! - \fn Phonon::ObjectDescription::ObjectDescription (int index, const QHash & properties) - \internal -*/ - -/*! - \fn Phonon::ObjectDescription::ObjectDescription(const QExplicitlySharedDataPointer &dd) - \internal -*/ - -/*! - \fn static inline ObjectDescription Phonon::ObjectDescription::fromIndex(int index) - \internal - - \omit Currently indices are not unique for all ObjectDescription types, making - the behavior of this function undefined. \endomit - - Returns a new description object that describes the - device/effect/codec/... with the given \a index. -*/ - -/*! - \fn inline bool Phonon::ObjectDescription::operator==(const ObjectDescription &otherDescription) const - - Returns \c true if this ObjectDescription describes the same - object as \a otherDescription; otherwise, returns \c false. -*/ - -/*! - \fn inline bool Phonon::ObjectDescription::operator!=(const ObjectDescription &otherDescription) const - Returns \c false if this ObjectDescription describes the same - as \a otherDescription; otherwise, returns \c true. -*/ - -/*! - \fn inline QString Phonon::ObjectDescription::name() const - - Returns a string appropriate for a user to select between - object descriptions, e.g., from a QComboBox. - - \sa description() -*/ - -/*! - \fn inline QString Phonon::ObjectDescription::description() const - - Returns a more extensive description than the name() function. - - For example, in the case of \l{Phonon::}{AudioOutputDevice}s, this - text should make clear which sound source is described; this is - sometimes hard to describe or understand from just the name. - - The text is appropriate to present to an end user in for example - tool tips of items, with the name()'s as text, in a QComboBox. - -*/ - -/*! - \fn inline QVariant Phonon::ObjectDescription::property(const char *name) const - - Returns the property named \a name. A property can be used for - extended information, such as the manufacturer of a sound card. The - information will usually be given as text. - - If the property is not set an invalid QVariant is returned. - - Qt's backends do not use properties at the time of this writing. - - \sa propertyNames() -*/ - -/*! - \fn inline QList Phonon::ObjectDescription::propertyNames() const - - Properties can be used for extended information about a - ObjectDescription, e.g., a manufacturer of a sound card. The - information will usually be given text. - - This function returns all names that return valid data when - property() is called. - - Currently, Qt backends do not use properties for their object - descriptions. - - \sa property() -*/ - -/*! - \fn inline bool Phonon::ObjectDescription::isValid() const - - Returns true if the device or effect described exists. - - An ObjectDescription that is invalid, will also have an - index() of -1. - - \sa index() -*/ - -/*! - \fn inline int Phonon::ObjectDescription::index() const - - Returns a unique identifier for this ObjectDescription. Used - internally to distinguish between the descriptions. - - Notice that the identifiers are only unique to the type of - description, e.g., \l{Phonon::}{AudioOutputDevice} or - \l{Phonon::}{EffectDescription}. -*/ - -/*! - \class Phonon::ObjectDescriptionPrivate - \inmodule Phonon - \since 4.4 - \internal - -*/ - -/*! - \class Phonon::StreamInterface - \inmodule Phonon - \since 4.4 - \brief Backend interface to handle media streams (AbstractMediaStream). - \internal -*/ - -/*! - \fn virtual Phonon::StreamInterface::~StreamInterface() -*/ - -/*! - \fn virtual void Phonon::StreamInterface::writeData(const QByteArray &data) = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::StreamInterface::endOfData() = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::StreamInterface::setStreamSize(qint64 newSize) = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::StreamInterface::setStreamSeekable(bool s) = 0 - \internal -*/ - -/*! - \fn void Phonon::StreamInterface::connectToSource(const MediaSource &mediaSource) - \internal -*/ - -/*! - \fn void Phonon::StreamInterface::needData() - \internal -*/ - -/*! - \fn void Phonon::StreamInterface::enoughData() - \internal -*/ - -/*! - \fn void Phonon::StreamInterface::seekStream(qint64) - \internal -*/ - -/*! - \fn void Phonon::StreamInterface::reset() - \internal -*/ - -/*! - \fn Phonon::StreamInterface::StreamInterface() - \internal - \omit - For subclasses. - \endomit -*/ - -/*! - \class StreamInterfacePrivate - \inmodule Phonon - \internal -*/ - -/*! - \class Phonon::AbstractVideoOutput - \inmodule Phonon - \internal - \since 4.4 - \brief The AbstractVideoOutput class is the common base class for all video output classes. - - \sa VideoWidget -*/ - -/*! - \namespace Phonon::Experimental - \internal -*/ - -/*! - \fn Phonon::AbstractVideoOutput::AbstractVideoOutput(AbstractVideoOutputPrivate &d) - \internal - - Constructor that is called from derived classes. - - \param parent Standard QObject parent. -*/ - -/*! - \class Phonon::AbstractVideoOutputPrivate - \inmodule Phonon - \internal - \since 4.4 -*/ - -/*! - \class Phonon::VolumeFaderEffect - \inmodule Phonon - \internal - \since 4.4 - - This effect differs from gradually changing the output volume in that - a dedicated effect can change the volume in the smallest possible - steps while every other volume control will make more or less - noticeable steps. - - \sa AudioOutput::volume() -*/ - -/*! - \property Phonon::VolumeFaderEffect::volume - - This is the current volume of the output as voltage factor. - Setting this property changes the volume immediately. - - 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% - - \sa volumeDecibel -*/ - -/*! - \property Phonon::VolumeFaderEffect::volumeDecibel - - This is the current volume of the output in decibel. - Setting this property changes the volume immediately. - - 0 dB means no change in volume, -6dB means an attenuation of the - voltage to 50% and an attenuation of the power to 25%, -inf dB means - silence. - - \sa volume -*/ - -/*! - \property Phonon::VolumeFaderEffect::fadeCurve - - This property holds the fade curve to be used for the fadeIn(), fadeOut() - and fadeTo() slots. - - Defaults to Fade3Decibel. - - \sa FadeCurve -*/ - -/*! - \enum Phonon::VolumeFaderEffect::FadeCurve - Determines the curve of the volume change. - - \value Fade3Decibel Crossfade curve/fast fade out. - This is the default fade curve. - \value Fade6Decibel Linear fade out. - \value Fade9Decibel Slow fade out. - \value Fade12Decibel A more extreme version of the -9dB fade. - - \bold{Notes:} - - \c Fade3Decibel is often the best fade for a crossfade, as after half - of the time the volume reached -3dB. This means that half the - possible power (which is proportional to the square of the - voltage) is reached. Summed, the maximum power of two audio - signals fading with a -3dB curve will always be equal. - - For fading in or out the -3dB curve is too abrupt in the end. - - With a -6dB fade curve, a volume of -6dB is reached after half of - the fading time. -6dB is equal to half of the voltage meaning - that the voltage multiplier changes linearly from the start - of the fade to the end. - - With the \c Fade9Decibel fade, a volume of -9dB is reached after - half of the fade time, so the fade is fast in the beginning and - slow at the end. This is a good fade for ending music. -*/ - -/*! - \fn void Phonon::VolumeFaderEffect::fadeIn(int fadeTime) - - Tells the Fader to change the volume from the current volume to 100% - in \a fadeTime milliseconds. - - Short for \c fadeTo(1.0, fadeTime). - - \param fadeTime the fade duration in milliseconds - - \sa fadeTo(), volume -*/ - -/*! - \fn void Phonon::VolumeFaderEffect::fadeOut(int fadeTime) - - Tells the Fader to change the volume from the current volume to 0% - in \a fadeTime milliseconds. - Short for \c fadeTo(0.0, fadeTime). - - \param fadeTime the fade duration in milliseconds - - \sa fadeTo -*/ - -/*! - \fn void Phonon::VolumeFaderEffect::fadeTo(float volume, int fadeTime) - - Tells the Fader to change the volume from the current value to - \a volume in \a fadeTime milliseconds. - - \sa fadeIn(), fadeOut() -*/ - -/*! - \class Phonon::VolumeFaderEffectPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::VolumeFaderInterface - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \fn virtual Phonon::VolumeFaderInterface::~VolumeFaderInterface() - \internal -*/ - -/*! - \fn virtual float Phonon::VolumeFaderInterface::volume() const - \internal -*/ - -/*! - \fn virtual void Phonon::VolumeFaderInterface::setVolume(float) - \internal -*/ - -/*! - \fn virtual Phonon::VolumeFaderEffect::FadeCurve Phonon::VolumeFaderInterface::fadeCurve() const - \internal -*/ - -/*! - \fn virtual void Phonon::VolumeFaderInterface::setFadeCurve(Phonon::VolumeFaderEffect::FadeCurve) - \internal -*/ - -/*! - \fn virtual void Phonon::VolumeFaderInterface::fadeTo(float, int) - \internal -*/ - -/*! - \class Phonon::AbstractMediaStream - \inmodule Phonon - \internal - \since 4.4 - \brief The AbstractMediaStream class is the base class for custom media data streams. - \inheaderfile Phonon/AbstractMediaStream - - This class is subclassed to provide custom data streams for - \l{Phonon::}{MediaSource}s. - - The \l{Phonon::}{MediaSource} knows how to handle the most common - media sources, such as files and CD. If you need to fetch - multimedia from other sources, you can reimplement this class, - which can be used by a \l{Phonon::}{MediaSource}. - - When a backend needs more data from the stream, needData() will be - called. You must then use writeData() to write the data to the - backend. You can either write one time and wait for a new - needData() call, or continue to write data until you receive an - enoughData() call. When the stream is at its end, call endOfData() - instead of writeData(). - - Before the custom stream is passed to a \l{Phonon::}{MediaSource}, - setStreamSize() needs to be called, and also setStreamSeekable() - (if the stream is seekable). A good place to do this work is in - the constructor. A seekable stream must also reimplement - seekStream(). - - We show two examples. The first writes data repeatedly until it - receives the enoughData() call, while the second only writes once - and waits for a new needData() call. - - Example where data is written repeatedly. - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 0 - - Example where data is written once: - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 1 - - \sa Phonon::MediaSource, Phonon::MediaObject - -*/ - -/*! - \fn Phonon::AbstractMediaStream::AbstractMediaStream(QObject *parent = 0) - \internal - - Constructs an AbstractMediaStream object with the given \a parent. - -*/ - -/*! - \fn qint64 Phonon::AbstractMediaStream::streamSize() const - - Returns the stream size that was set with setStreamSize(). - - A negative value means that the length of the stream cannot be known. - - Defaults to 0. - - \sa setStreamSize() -*/ - -/*! - \fn void Phonon::AbstractMediaStream::setStreamSize(qint64 size) - - Sets the \a size of the stream in number of bytes. - - A negative value means that the length of the stream cannot be known. - - Defaults to 0. - - This function has to be called. A backend will not call needData() - until the stream size is set. - - \sa streamSize() - -*/ - -/*! - \fn bool Phonon::AbstractMediaStream::streamSeekable() const - - Returns whether your data stream is set as seekable. - - Defaults to \c false. - - \sa setStreamSeekable() - -*/ - -/*! - \fn void Phonon::AbstractMediaStream::setStreamSeekable(bool s) - - Sets whether your data stream is seekable. \a s should be true if - the stream is seekable; otherwise false. - - Defaults to \c false. - - If you set this to \c true you have to implement the seekStream() - function. - - \sa streamSeekable() -*/ - -/*! - \fn void Phonon::AbstractMediaStream::writeData(const QByteArray &data) - - Sends the media \a data to the backend for decoding. - - Use this function to send data to the backend after needData() has - been called. - - If your stream is a push stream, data should be written until the - enoughData() function is called. For a pull stream, write data - once before the call to needData() function returns. - - If the data is depleted, call endOfData() instead of writeData(). - - \warning Don't call this function before the first needData() is emitted. - - \sa needData(), endOfData() - -*/ - -/*! - \fn void Phonon::AbstractMediaStream::endOfData() - - Tells the backend that the media data stream is at its end. - - \warning Don't call this function before the first needData() is emitted. - - \sa writeData(), needData() -*/ - -/*! - \fn void Phonon::AbstractMediaStream::error(Phonon::ErrorType errorType, const QString &errorString) - - If an I/O error occurs you should call this function to make - MediaObject go into ErrorState. \c errorType classifies the error, - while \a errorString is a textual description of the error suitable - for users of Phonon applications. - - \sa MediaObject::errorType(), MediaObject::errorString() -*/ - -/*! - \fn virtual void Phonon::AbstractMediaStream::reset() = 0 - - Reimplement this function to reset the stream. Subsequent calls to writeData should start - from the first position of the data unless a seek is requested. - - The function is necessary for the case where a non-seekable MediaStream is - played more than once. For a seekable stream the implementation can simply call - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 2 - - \sa writeData(), needData() -*/ - -/*! - \fn virtual void Phonon::AbstractMediaStream::needData() = 0 - - Reimplement this function to be notified when the backend needs data. - - When this function is called you should write data to the backend - (See writeData()). - - \sa writeData(), endOfData(), enoughData() -*/ - -/*! - \fn virtual void Phonon::AbstractMediaStream::enoughData() - - If your stream is a push stream, reimplement this function to be - notified when the backend has enough data and your stream object - may take a break. - - This method is important for pushing data to the backend in order - to not fill the backend buffer unnecessarily. - - \sa needData() -*/ - -/*! - \fn virtual void Phonon::AbstractMediaStream::seekStream(qint64 offset) - - Reimplement this function if your stream is seekable. - - When this function is called the next call to writeData has to be at the - requested \a offset. - - \warning Do not call the parent implementation. - - \sa setStreamSeekable(), streamSeekable(), needData() -*/ - -/*! - \class Phonon::BackendInterface - \inmodule Phonon - \since 4.4 - \brief Main Backend class interface - \internal - - This interface defines the main factory of the backend. The createObject() function creates all the - objects needed by the frontend. - - The objectDescriptionIndexes and objectDescriptionProperties functions return information about - available devices, effects and codecs. - - An implementation could look like this: - \snippet snippets/phonon/samplebackend/main.cpp snippet - -*/ - -/*! - \fn virtual Phonon::BackendInterface::~BackendInterface() - \internal - - Silence gcc's warning. -*/ - -/*! - \enum Phonon::BackendInterface::Class - \internal - - Classes that the createObject() function has to handle. - - \value MediaObjectClass Request to return a \c MediaObject object. - \value VolumeFaderEffectClass Request to return a \c VolumeFaderEffect - object. - \value AudioOutputClass Request to return an \c AudioOutput object. - \value AudioDataOutputClass Request to return an \c AudioDataOutput object. - \value VisualizationClass Request to return a \c Visualization object. - \value VideoDataOutputClass Request to return a \c VideoDataOutput object. - \value EffectClass Request to return a \c Effect object. - Takes an additional int that specifies the effect ID. - \value VideoWidgetClass Request to return a \c VideoWidget object. -*/ - -/*! - \fn virtual QObject *Phonon::BackendInterface::createObject(Class c, QObject *parent, const QList &args = QList()) = 0 - \internal - - Returns a new instance of the requested class. - - \param c The requested class. - \param parent The parent object. - \param args Additional arguments (documented in Class). -*/ - - -/*! - \fn virtual QList Phonon::BackendInterface::objectDescriptionIndexes(ObjectDescriptionType type) const = 0 - \internal - - Returns the unique identifiers for the devices/effects/codecs of the given \a type. - - \param type see ObjectDescriptionType -*/ - -/*! - \fn virtual QHash Phonon::BackendInterface::objectDescriptionProperties(ObjectDescriptionType type, int index) const = 0 - \internal - - Given a unique identifier that was returned from objectDescriptionIndexes this function - returns a hash mapping property names to values. - - The property "name" must always be present. All other properties are optional. - - \table - \header \o Property \o Description - \row \o name \o The name of the device/effect/codec/... - \row \o description \o A text explaining what this device/effect/codec/... is/can do - \row \o icon \o An icon name (using the freedesktop naming scheme) or a QIcon for this - device/effect/codec/... - \row \o available \o A bool telling whether the device is present or unplugged. - \endtable - - \param type see ObjectDescriptionType - \param index The unique identifier that is returned from objectDescriptionIndexes -*/ - -/*! - \fn virtual bool Phonon::BackendInterface::startConnectionChange(QSet) = 0; - \internal - - When this function is called the nodes given in the parameter list should - not lose any signal data when connections are changed. -*/ - -/*! - \fn virtual bool Phonon::BackendInterface::connectNodes(QObject *, QObject *) = 0 - \internal - - Defines a signal connection between the two given nodes. -*/ - -/*! - \fn virtual bool Phonon::BackendInterface::disconnectNodes(QObject *, QObject *) = 0 - \internal - - Cuts a signal connection between the two given nodes. -*/ - -/*! - \fn virtual bool Phonon::BackendInterface::endConnectionChange(QSet) = 0 - \internal - - When this function is called the nodes given in the parameter list may lose - signal data when a port is not connected. -*/ - -/*! - \fn virtual QStringList Phonon::BackendInterface::availableMimeTypes() const = 0 - \internal - - Returns all available MIME types. -*/ - -/*! - \class Phonon::MediaSource - \inmodule Phonon - \inheaderfile Phonon/MediaSource - \since 4.4 - \brief The MediaSource class provides multimedia data for media objects. - - The MediaSource class manages a source of multimedia content, such - as a music or video file, of which data is given to a - \l{Phonon::}{MediaObject}. - - The media source knows how fetch its data from several sources, - e.g., from files, a QIODevice, or a CD. The possible source types - are described by the \l{MediaSource::}{Type} enum. The type of the - source is set by the media source itself, and is dependent on the - constructor used to create it. Note that it is possible to provide - data from any source by implementing a QIODevice. - - The class has several functions to acquire information about the - source it manages, e.g., fileName() and url(). The return from - these functions are dependent on the type() of the media source. - - Normally, a programmer does not need to be concerned with media - sources. It's constructors are implicit, so one can, for instance, - send an URL or filename directly to the constructors of the - \l{Phonon::}{MediaObject}. - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 3 - - A MediaSource object cannot be reused for another multimedia - source. It is possible to play the same source again, and also - stop and start a non-seekable media source, such as a radio - stream, with the same MediaSource object. - - \section1 Qt Backends - - Currently, Qt's backends support files in local and remote - locations. Support for other sources, such as CD/DVD, are planned - for the future. - - \sa MediaObject, {Phonon Module} -*/ - -/*! - \enum Phonon::MediaSource::Type - - Identifies the type of media described by the MediaSource object. - - \value Invalid The MediaSource object does not describe any valid source. - \value LocalFile The MediaSource object describes a local file. - \value Url The MediaSource object describes an URL, which can be either a - local file or a file on the network. - \value Disc The MediaSource object describes a disc, e.g., a CD. - \value Stream The MediaSource object describes a data stream. - This is the type used for \l{QIODevice}s. Note - that a stream opened with a QUrl, will still be of the Url type. - \value Empty The media source doesn't have a source. - - \sa MediaSource::type() -*/ - -/*! - \fn Phonon::MediaSource::MediaSource() - \internal - - Creates an invalid MediaSource object. - - \sa Invalid -*/ - -/*! - \fn Phonon::MediaSource::MediaSource(const QString &fileName) - - Creates a MediaSource object for the file specified by \a - fileName. You can also use this constructor with \l{The Qt - Resource System}{Qt resources} - - \omit - \param fileName file name of a local media file or a Qt resource that was compiled in. - \endomit -*/ - -/*! - \fn Phonon::MediaSource::MediaSource(const QUrl &url) - - Creates a MediaSource object for a the URL specified by \a url. - - If the multimedia content you would like to play back is on a - remote network location, you should use this constructor; though, - it also possible to specify an URL to a local file. - - \sa QUrl -*/ - - -/*! - \fn Phonon::MediaSource::MediaSource(Phonon::DiscType discType, const QString &deviceName = QString()) - - Creates a MediaSource object for the type of disc specified by \a discType in the named - device referred to by \a deviceName. - - \note \a deviceName is a platform dependent device name. It can be useful to specify this - if the computer has more than one CD drive. On KDE, it is recommended to use the Solid - hardware discovery framework to retrieve the device name in a portable way. -*/ - -/*! - \fn Phonon::MediaSource::MediaSource(AbstractMediaStream *stream) - \internal - Creates a MediaSource object for a data stream. - - Your application can provide the media data by subclassing AbstractMediaStream and - passing a pointer to that object. Phonon will never delete the \a stream. - - \param stream The AbstractMediaStream subclass to provide the media data. - - \sa setAutoDelete -*/ - -/*! - \fn Phonon::MediaSource::MediaSource(QIODevice *ioDevice) - - Creates a MediaSource object for the QIODevice specified by \a ioDevice. - - This constructor can be very handy in the combination of - QByteArray and QBuffer. - - If you need to fetch multimedia data from a source that is not - supported by MediaSource, you should subclass QIODevice and use - this MediaSource constructor. It is important that you reimplement - QIODevice::isSequential(), as it is used by MediaSource to - determine if the media source is seekable. - - \a ioDevice is an arbitrary readable QIODevice subclass. If the device is not opened - MediaSource will open it as QIODevice::ReadOnly. - - \note Sequential devices can also be used, but MediaObject::isSeekable() will - return false as a result. - - \warning On Windows, we only support \l{QIODevice}s containing the - \c avi, \c mp3, or \c mpg formats. Use the constructor that takes - a file name to open files (the Qt backend does not use a QFile - internally). - - \sa setAutoDelete() -*/ - -/*! - \fn Phonon::MediaSource::MediaSource(MediaSourcePrivate &) - \internal -*/ - -/*! - \fn Phonon::MediaSource::~MediaSource() - - Destroys the MediaSource object. You should never delete a - MediaSource yourself, the MediaObject will handle this. - -*/ - -/*! - \fn Phonon::MediaSource::MediaSource(const MediaSource &other) - - Constructs a copy of the \a other media source. - - This constructor is fast thanks to explicit sharing. -*/ - -/*! - \fn MediaSource &Phonon::MediaSource::operator=(const MediaSource &other) - - Assigns the \a other media source to this media source and returns a - reference to it. - - This operation is fast thanks to explicit sharing. -*/ - -/*! - \fn bool Phonon::MediaSource::operator==(const MediaSource &other) const - - Returns true if this media source is equal to the \a other media source; - otherwise returns false. -*/ - -/*! - \fn void Phonon::MediaSource::setAutoDelete(bool enable) - - If \a enable is true, the media source will take ownership of the - object passed in the \l{Phonon::}{MediaSource}'s constructor - object that was passed in the constructor; otherwise, the - programmer is responsible for deletion of this object. - - This setting is false by default. If you enable it, you should - only access the stream or device as long as you keep the media - source object around. As long as you keep the media source - wrapping the stream or device, the object will not get deleted. - - \sa autoDelete() -*/ - -/*! - \fn bool Phonon::MediaSource::autoDelete() const - - Returns the setting of the auto-delete option. The default is - false. - - \sa setAutoDelete() -*/ - -/*! - \fn Type Phonon::MediaSource::type() const - - Returns the type of the MediaSource (depends on the constructor - that was used). - - \sa Type -*/ - -/*! - \fn QString Phonon::MediaSource::fileName() const - - Returns the file name of the MediaSource if type() == - LocalFile; otherwise, returns QString(). - - \sa type() -*/ - -/*! - \fn QUrl Phonon::MediaSource::url() const - Returns the URL of the MediaSource if type() == URL or type() == LocalFile; - otherwise returns QUrl(). - - \sa type() -*/ - -/*! - \fn Phonon::DiscType Phonon::MediaSource::discType() const - Returns the disc type of the MediaSource if type() == Disc; otherwise - returns NoDisc. - - \sa type() -*/ - -/*! - \fn QString Phonon::MediaSource::deviceName() const - - Returns the device name of the MediaSource if type() == Disc; otherwise - returns QString(). - - \sa type() -*/ - -/*! - \fn AbstractMediaStream *Phonon::MediaSource::stream() const - \internal - Returns the media stream of the MediaSource if type() == Stream; otherwise - returns 0. - QIODevices are handled as streams, too. -*/ - -/*! - \class Phonon::MediaSourcePrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::SeekSlider - \inmodule Phonon - \inheaderfile Phonon/SeekSlider - \since 4.4 - \brief The SeekSlider class provides a slider for seeking to positions in media streams. - - The SeekSlider connects to a \l{Phonon::}{MediaObject}, and - controls the seek position in the object's media stream. - - The slider will connect to the necessary signals to keep track of - the sliders maximum, minimum, and current values. It will also - disable itself for non-seekable streams, and update the media - object when the current value of the slider changes. - - Here follows a typical example of SeekSlider usage: - - \snippet doc/src/snippets/seekslider.cpp 0 - - \sa Phonon::VolumeSlider, Phonon::VideoWidget, {Music Player Example}, {Phonon Module} - -*/ - -/*! - \property Phonon::SeekSlider::iconVisible - \brief whether the icon next to the slider is visible - - By default the icon is visible if the platform provides an icon; else - it's hidden. - -*/ - -/*! - \property Phonon::SeekSlider::tracking - \brief whether slider tracking is enabled - - If tracking is enabled (the default), the media seeks - while the slider is being dragged. If tracking is - disabled, the media seeks only when the user - releases the slider. -*/ - -/*! - \property Phonon::SeekSlider::pageStep - \brief the page step interval - - The larger of two natural steps that a slider provides and - typically corresponds to the user pressing PageUp or PageDown. - - Defaults to 5 seconds. -*/ - -/*! - \property Phonon::SeekSlider::singleStep - \brief the single step interval - - The smaller of two natural steps that a slider provides and - typically corresponds to the user pressing an arrow key. - - Defaults to 0.5 seconds. -*/ - -/*! - \property Phonon::SeekSlider::orientation - \brief the orientation of the slider - - The orientation must be Qt::Vertical or Qt::Horizontal (the default). -*/ - -/*! - \property Phonon::SeekSlider::iconSize - \brief the icon size used for the mute button/icon. - - The default size is defined by the GUI style. -*/ - -/*! - \fn explicit Phonon::SeekSlider::SeekSlider(QWidget *parent = 0) - - Constructs a seek slider widget with the given \a parent. -*/ - -/*! - \fn explicit Phonon::SeekSlider::SeekSlider(MediaObject *media, QWidget *parent = 0) - - Constructs a seek slider widget for the specified \a media with the - given \a parent. -*/ - -/*! - \fn Phonon::SeekSlider::~SeekSlider() - Destroys the seek slider. -*/ - -/*! - \fn Phonon::MediaObject *Phonon::SeekSlider::mediaObject() const - - Return the media object this SeekSlider controls. -*/ - -/*! - \class Phonon::SeekSliderPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \fn void Phonon::SeekSlider::setMediaObject(MediaObject *media) - - Sets the media object to be controlled by this slider to the \a media specified. -*/ - -/*! - \class Phonon::VideoPlayer - \inmodule Phonon - \inheaderfile Phonon/VideoPlayer - \since 4.4 - \brief The VideoPlayer widget is used to perform playback of video. - - With VideoPlayer you can get results quickly and easily. You can - do the standard playback tasks like play(), pause(), and stop(), - but also set a playback volume and seek - if the media and backend - supports seeking. - - VideoPlayer is provided for convenience and removes the need to - create a media graph with a \l{Phonon::}{MediaObject}, - \l{Phonon::}{AudioOutput}, and \l{Phonon::}{VideoWidget}. If - you need functionality not supported by the player, you can build - this \l{Building Graphs}{graph} yourself. - - Keep in mind that when the VideoPlayer instance is deleted the - playback will stop. - - Note also that most of the functions in this class are - asynchronous. For instance, a media source may not play - immediately after you call the play() function. - - A play and forget code example: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 4 - - \sa {Phonon Module}, MediaObject -*/ - -/*! - \fn Phonon::VideoPlayer::VideoPlayer(QWidget *parent = 0) - - Constructs a new video widget with a \a parent using - Phonon::VideoCategory as its category. - - \param parent The QObject parent. -*/ - -/*! - \fn Phonon::VideoPlayer::VideoPlayer(Phonon::Category category, QWidget *parent = 0) - - Constructs a new VideoPlayer instance with the specified \a - parent. - - \a category is the category used for the audio output device. -*/ - -/*! - \fn Phonon::VideoPlayer::~VideoPlayer() - - On destruction the playback is stopped, also the audio output is - removed so that the desktop mixer will not show the application - anymore. If you need a persistent audio output don't use - VideoPlayer but MediaObject, VideoPath and VideoOutput. -*/ - -/*! - \fn qint64 Phonon::VideoPlayer::totalTime() const - - Get the total time (in milliseconds) of the file currently being played. -*/ - -/*! - \fn qint64 Phonon::VideoPlayer::currentTime() const - - Get the current time (in milliseconds) of the file currently being played. -*/ - -/*! - \fn float Phonon::VideoPlayer::volume() const - - This is the current volume of the output as voltage factor. - - 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% -*/ - -/*! - \fn bool Phonon::VideoPlayer::isPlaying() const - - Returns true if it is currently playing; otherwise returns false if it - is currently stopped or paused -*/ - -/*! - \fn bool Phonon::VideoPlayer::isPaused() const - - Returns true if it is currently paused; otherwise returns false if it - is currently playing or stopped. -*/ - -/*! - \fn void Phonon::VideoPlayer::load(const Phonon::MediaSource &source) - - Starts pre-loading the media data from the specified \a source and - filling audio buffers in the backend. - - When there's already a media playing (or paused) it will be stopped - (the finished signal will not be emitted). - - \sa MediaObject::setCurrentSource() -*/ - -/*! - \fn void Phonon::VideoPlayer::play(const Phonon::MediaSource &source) - - Plays the media from the given \a source. Starts playback as fast as - possible. - This can take a considerable time depending on the URL and the - backend. - - If you need low latency between calling play() and the sound actually - starting to play on your output device you need to use MediaObject - and be able to set the URL before calling play(). Note that - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 5 - doesn't make a difference: the application should be idle between the - load and play calls so that the backend can start preloading the - media and fill audio buffers. -*/ - -/*! - \fn void Phonon::VideoPlayer::play() - - Continues playback of paused media. Restarts playback of a stopped - (or newly loaded) media. - - \sa MediaObject::play(), play() -*/ - -/*! - \fn void Phonon::VideoPlayer::pause() - - Pauses the playback. - - \sa MediaObject::pause() -*/ - -/*! - \fn void Phonon::VideoPlayer::stop() - - Stops the playback. - - \sa MediaObject::stop() -*/ - -/*! - \fn void Phonon::VideoPlayer::seek(qint64 ms) - - Seeks to the requested time. Note that the backend is free to - ignore the seek request if the media source isn't seekable; you - can check this by asking the media object of the VideoPlayer. - - \snippet doc/src/snippets/videomedia.cpp 0 - - The \a ms parameter is the time in milliseconds from the start of - the media. - - The call is asynchronous, so currentTime() can still be the old - value right after this method was called. If all you need is a - slider that shows the current position and allows the user to - seek, use the class SeekSlider. - - \sa MediaObject::seek(), MediaObject::isSeekable(), mediaObject() -*/ - -/*! - \fn void Phonon::VideoPlayer::setVolume(float volume) - - Sets the \a volume of the output as voltage factor. - - 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% -*/ - -/*! - \fn MediaObject *Phonon::VideoPlayer::mediaObject() const - - Returns the media object being used by the player. - - The media object can be accessed directly instead of using the - \l{VideoPlayer}s convenience functions, e.g., play() and stop(). - It is also possible to give the object to other Phonon widgets, - e.g., a \l{Phonon::}{SeekSlider} or a \l{Phonon::}{VolumeSlider}. - - \sa Phonon::SeekSlider, Phonon::MediaObject -*/ - -/*! - \fn AudioOutput *Phonon::VideoPlayer::audioOutput() const - - Returns the audio output object being used by the player. - -*/ - -/*! - \fn VideoWidget *Phonon::VideoPlayer::videoWidget() const - - Returns the video widget being used by the player. -*/ - -/*! - \fn void Phonon::VideoPlayer::finished() - - This signal is emitted when the playback finished. - -*/ - -/*! - \class Phonon::VideoWidgetPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::MediaObject - \inmodule Phonon - \inheaderfile Phonon/MediaObject - \since 4.4 - \brief The MediaObject class provides an interface for media playback. - - - The media object manages a \l{Phonon::}{MediaSource}, which - supplies the media object with multimedia content, e.g., from a - file. A playback in Phonon is always started by calling the - \l{Phonon::MediaObject::}{play()} function. - - The state of play (play, pause, stop, seek) is controlled by the - media object, and you can also query the current - \l{Phonon::MediaObject::}{state()}. It keeps track of the playback - position in the media stream, and emits the - \l{Phonon::MediaObject::}{tick()} signal when the current position - in the stream changes. - - Notice that most functions of this class are asynchronous, so you - cannot rely on that a state is entered after a function call - before you receive the \l{Phonon::MediaObject::}{stateChanged()} - signal. The description of the \l{Phonon::}{State} enum gives a - description of the different states. - - Before play() is called, the media object should be connected to - \l{Sinks}{output nodes}, which outputs the media to the - underlying hardware. The output nodes required are dependent on - the contents of the multimedia file that is played back. Phonon - has currently two output nodes: the \l{Phonon::}{AudioOutput} for - audio content and \l{Phonon::}{VideoWidget} for video content. If - a \l{Phonon::}{MediaSource} contains both audio and video, both - nodes need to be connected to the media object. - - \snippet snippets/phonon.cpp 4 - \snippet snippets/phonon.cpp 5 - - The media object can queue sources for playback. When it has - finished to play one source, it will start playing the next in the - queue; the new source is then removed from the queue. The - queue can be altered at any time. - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 7 - - You can also make use of the - \l{Phonon::MediaObject::}{aboutToFinish()} signal, which is - guaranteed to be emitted in time for altering the queue. - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 8 - - When playback is finishing, i.e., when a media source has been - played to the end and the queue is empty, several signals are - emitted. First, the media object will emit aboutToFinish() - - shortly before the playback has finished - and then finished(). - The stateChanged() signal will also be emitted with - \l{Phonon::}{PausedState}, which is the state the media object - takes when the playback is finished. If you wish to enter another - state, you can connect a slot to finished() and set a new state - there. - - The media object resolves the meta information, such as title, - artist, and album. The meta data is not resolved immediately after - a new source is provided, but will be resolved before the object - leaves the \l{Phonon::}{LoadingState}. The data is queried by - string keys - which should follow the Ogg Vorbis specification - \l http://xiph.org/vorbis/doc/v-comment.html - or by using the - \l{Phonon::}{MetaData} enum. The data available will depend on the - type and content of the individual media files. metaDataChanged() - will be emitted when the media object has resolved new meta data. - - Errors encountered during playback and loading of media sources - are reported by emitting a state changed signal with - \l{Phonon::}{ErrorState}. The severity of the error can be queried - by the \l{Phonon::}{ErrorType}. With a \l{Phonon::}{NormalError}, - it might be possible to continue the playback, for instance, if - only audio playback fails for a media source which also has video. - A \l{Phonon::}{FatalError} indicates that Phonon cannot continue - playback of the current source, but it is possible to try with a - different one. A user readable error message is given by - errorString(). - - \sa Phonon::MediaSource, Phonon::AudioOutput, VideoWidget, - {Music Player Example}, {Phonon Overview}, Phonon::VideoPlayer, - Phonon::createPlayer(), {Phonon Module} - -*/ - -/*! - \property Phonon::MediaObject::transitionTime - \brief Defines the time between playback of two media sources - in the media queue. - - A positive transition time defines a gap of silence between queued - media sources. - - A transition time of 0 ms requests gapless playback (i.e., the - next source in the media queue starts immediately after the - playback of the current source finishes). - - A negative transition time defines a crossfade between the queued - media sources. - - Defaults to 0 (gapless playback). - - \warning This feature might not work reliably with every - backend. -*/ - -/*! - \property Phonon::MediaObject::prefinishMark - \brief the time when the prefinishMarkReached signal is emitted before playback ends. - - This property specifies the time in milliseconds the - prefinishMarkReached() signal is emitted before the playback - finishes. A value of \c 0 disables the signal. The signal is only - emitted for the last source in the \l{queue()}{media queue}. - - Defaults to \c 0 (disabled). - - \warning For some media data the total time cannot be determined - accurately, therefore the accuracy of the prefinishMarkReached signal - can be bad sometimes. Still, it is better to use this method than to - look at totalTime() and currentTime() to emulate the behavior - because the backend might have more information available than your - application does through totalTime() and currentTime(). - - \sa prefinishMarkReached() -*/ - -/*! - \property Phonon::MediaObject::tickInterval - \brief The time interval in milliseconds between two ticks. - - The tick() signal is emitted continuously during playback. - The tick interval is the time that elapses between the emission of two tick signals. - If you set the interval to \c 0 the tick signal gets disabled. - - The tick() signal can, for instance, be used to update widgets - that show the current position in the playback of a media source. - - Defaults to \c 0 (disabled). - - \warning The back-end is free to choose a different tick interval close - to what you asked for. This means that the following code \c may fail: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 9 - On the other hand the following is guaranteed: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 10 - - \sa tick() -*/ - -/*! - \fn Phonon::MediaObject::~MediaObject() - - Destroys the MediaObject. -*/ - -/*! - \fn State Phonon::MediaObject::state() const - - Returns the current Phonon::State of the object. - - \sa Phonon::State, stateChanged() -*/ - -/*! - \fn bool Phonon::MediaObject::hasVideo() const - - Check whether the current media source includes a video stream. - - \warning This information is not resolved immediately after a - media object gets a new source. Listen to the hasVideoChanged() - signal instead. - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 11 - - Returns \c true if the media contains video data; otherwise, - returns \c false. - - \sa hasVideoChanged() -*/ - -/*! - \fn bool Phonon::MediaObject::isSeekable() const - - Check whether it is possible to seek, i.e., change the - playback position in the media stream. - - \warning This information is not solved immediately after the - media object gets a new media source. The hasVideoChanged() signal - is emitted after this information is available. - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 12 - - Returns \c true if the current media may be seeked; otherwise, - returns \c false. - - \sa seekableChanged() -*/ - -/*! - \fn QStringList Phonon::MediaObject::metaData(const QString &key) const - - Returns the strings associated with the given \a key. - - Backends should use the keys specified in the Ogg Vorbis - documentation: \l http://xiph.org/vorbis/doc/v-comment.html - - Therefore the following should work with every backend: - - Note that meta data is not resolved before the \c - metaDataChanged() signal is emitted. - - A typical usage looks like this: - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 13 -*/ - -/*! - \fn QStringList Phonon::MediaObject::metaData(Phonon::MetaData key) const - - Returns the strings associated with the given \a key. - - Same as above except that the keys are defined in the - Phonon::MetaData enum. - - \sa metaDataChanged() -*/ - -/*! - \fn QMultiMap Phonon::MediaObject::metaData() const - - Returns all meta data in a multi map. - - \sa metaDataChanged() -*/ - -/*! - \fn QString Phonon::MediaObject::errorString() const - - Returns a human-readable description of the last error that occurred. - The strings given may vary between backends. - - The error description can be used to give a message to the user - - and the developer - when the stateChanged() signal is emitted with - \l{Phonon::}{ErrorState}. - - \section1 Qt Backends - - On Windows, Qt fetches its error messages from the DirectShow - backend. This usually includes an error number, which can be - looked up in the DirectShow documentation: - \l{http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dx81_c/directx_cpp/htm/errorandsuccesscodes.asp}. - - On Linux and Mac, the error strings are not fetched directly from - the backend, but are created in the backend. - - \sa Phonon::ErrorState, stateChanged() -*/ - -/*! - \fn ErrorType Phonon::MediaObject::errorType() const - - Tells your program what to do about the last error that occurred. - Use this function after receiving a stateChanged() signal with - \l{Phonon::}{ErrorState}. - - \sa Phonon::ErrorType, Phonon::ErrorState, stateChanged() -*/ - -/*! - \fn MediaSource Phonon::MediaObject::currentSource() const - - Returns the current media source, i.e., the media source that is - being played back. The current source is either set with - setCurrentSource() or taken from the media queue() when a media - source has finished playing. - - \sa setCurrentSource() -*/ - -/*! - \fn void Phonon::MediaObject::setCurrentSource(const MediaSource &source) - - Set the media source the MediaObject should use. - - After the media object receives a new source, it will enter the - \l{Phonon::}{LoadingState}. When it is ready to play, it - enters the \l{Phonon::}{StoppedState} unless another state - has been requested, e.g., by calling play(). - - \a source is the MediaSource object to the media data. You can - just as well use a QUrl or QString (for a local file) here. - - We show an example: - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 14 - - \sa currentSource(), MediaSource -*/ - -/*! - \fn QList Phonon::MediaObject::queue() const - - Returns the queued media sources. - - This does list does not include the current source, - returned by currentSource(). - - \sa enqueue() -*/ - -/*! - \fn void Phonon::MediaObject::setQueue(const QList &sources) - - Set the \a sources to play when the current source has finished. - - This function will overwrite the current queue. - - \sa clearQueue(), enqueue() -*/ - -/*! - \fn void Phonon::MediaObject::setQueue(const QList &urls) - - Set the \a urls to play when the current media has finished. - - This function overwrites the current queue. - - \sa clearQueue(), enqueue() -*/ - -/*! - \fn void Phonon::MediaObject::enqueue(const MediaSource &source) - - Appends \a source to the queue. - - You can use this function to provide the next source after the - aboutToFinish() signal has been emitted. - - \sa aboutToFinish(), setQueue(), clearQueue() -*/ - -/*! - \fn void Phonon::MediaObject::enqueue(const QList &sources) - - Appends multiple \a sources to the queue. - - \sa setQueue(), clearQueue() -*/ - -/*! - \fn void Phonon::MediaObject::enqueue(const QList &urls) - - Appends the URLs in \a urls to the media source queue. - - The function will create \l{MediaSource}s from the \l{QUrl}s, and - append these to the queue. - - \sa setQueue(), clearQueue() -*/ - -/*! - \fn void Phonon::MediaObject::clearQueue() - - Clears the queue of media sources. - - \sa queue(), enqueue() -*/ - -/*! - \fn qint64 Phonon::MediaObject::currentTime() const - - Returns the current time (in milliseconds), i.e., position in the - media stream, of the file currently being played. - - \sa tick(), totalTime(), remainingTime() -*/ - -/*! - \fn qint64 Phonon::MediaObject::totalTime() const - - Get the total time (in milliseconds) of the file currently being played. - - Returns the total time in milliseconds. - - \warning The total time is not defined before the media object - enters the \l{Phonon::}{LoadingState}. - - \sa totalTimeChanged() -*/ - -/*! - \fn qint64 Phonon::MediaObject::remainingTime() const - - Get the remaining time (in milliseconds) of the file currently being played. - - Returns the remaining time in milliseconds. - - \sa totalTime(), currentTime(), totalTimeChanged() -*/ - -/*! - \fn void Phonon::MediaObject::play() - - Requests playback of the media data to start. - - Playback starts when the stateChanged() signal is emitted with - \l{Phonon::}{PlayingState}. - - If the media object is already in a - \l{Phonon::}{PlayingState}, nothing happens. - - \sa stop(), pause(), stateChanged() -*/ - -/*! - \fn void Phonon::MediaObject::pause() - - Requests playback to pause, and the media object to enter the - \l{Phonon::}{PausedState}. If it was paused already, nothing - changes. - - This function is asynchronous and the media might not be paused - immediately. - - \sa play(), stop(), stateChanged() -*/ - -/*! - \fn void Phonon::MediaObject::stop() - - Requests playback to stop, and the media object to enter the - \l{Phonon::}{StoppedState}. If it was stopped before - nothing changes. - - This function is asynchronous and the media might not be - stopped immediately. - - \sa play(), pause(), stateChanged() -*/ - -/*! - \fn void Phonon::MediaObject::seek(qint64 time) - - Requests a seek to the \a time indicated, specified in milliseconds. - - You can only seek if state() is PlayingState, BufferingState or PausedState. - - The call is asynchronous, so currentTime can still be the old - value right after this method was called. If all you need is a - slider that shows the current position and allows the user to - seek, use the class SeekSlider. - - If the current source of the media object is not seekable, calls - to this functions do nothing. - - \sa SeekSlider, tick() -*/ - -/*! - \fn void Phonon::MediaObject::clear() - - Stops and removes all playing and enqueued media sources. - - \sa setCurrentSource() -*/ - - -/*! - \fn void Phonon::MediaObject::stateChanged(Phonon::State newstate, Phonon::State oldstate) - - This signal is emitted when the state of the MediaObject has changed. - The \a oldstate and \a newstate parameters indicate the previous - state and current state of the media object. - - If you are only interested in the new state of the media object, you can - connect this signal to a slot that accepts only one State argument. -*/ - -/*! - \fn void Phonon::MediaObject::tick(qint64 time) - - This signal is emitted in intervals defined by the - \l{tickInterval} property. The current position of the media - object in the stream is given by the \a time parameter. The \a - time is specified in milliseconds. - - \sa tickInterval -*/ - -/*! - \fn void Phonon::MediaObject::metaDataChanged() - - This signal is emitted when the media object has resolved new meta - data. This will happen before the media object leaves the - \l{Phonon::}{LoadingState} after a new source has been set. - - This signal is not emitted when the media object removes the - current data, i.e., when a new source is set or an error has - occurred. If you need to know this, you can listen for the - \l{Phonon::}{ErrorState}, and connect to the - \l{Phonon::MediaObject::}{currentSourceChanged()} signal. - - You can get the new meta data with the metaData methods. - - \sa metaData(), currentSourceChanged(), stateChanged(), Phonon::State -*/ - -/*! - \fn void Phonon::MediaObject::seekableChanged(bool isSeekable) - - This signal is emitted when the media object's ability to seek in - the media stream changes. \a isSeekable is true if it is possible - to seek(); otherwise, it is false. - - Change in the ability to seek in the stream usually happens when - the current source changes or when an error occurs. - - \omit Emitted whenever the return value of isSeekable() - changes. \endomit - - Normally you'll check isSeekable() after setting a new media - source, and then let this signal tell you when seeking is - possible. That way you don't have to poll isSeekable(). -*/ - -/*! - \fn void Phonon::MediaObject::hasVideoChanged(bool hasVideo) - - Emitted whenever the return value of hasVideo() changes, i.e., - the media source being played back contains video. - - Normally you'll check hasVideo() first and then let this signal - tell you whether video is available now or not. That way you - don't have to poll hasVideo(). - - \a hasVideo is true when the stream contains video and adding a - VideoWidget will show a video, and false if there is no video data - in the stream and adding a VideoWidget will show an empty (black) - VideoWidget. -*/ - -/*! - \fn void Phonon::MediaObject::bufferStatus(int percentFilled) - - Provides information about the status of the buffer. - - When a MediaObject is in the \l{Phonon::}{BufferingState}, it will - send this signal regularly. \a percentFilled is a number between 0 - and 100 telling you how much the buffer is filled. - - You can use this signal to show a progress bar to the user when - in BufferingState: - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 15 - - Note that the \l{Phonon::}{BufferingState} is commonly used when - waiting for data over a network connection, but this might not be - true for all backends. -*/ - -/*! - \fn void Phonon::MediaObject::finished() - - Emitted when the object has finished playback. It is not emitted - if you call stop(), pause() or load(). It is emitted only when the - current media source has finished playing and the media queue() is - empty, or when a \l{Phonon::FatalError}{fatal error} occurs. - - \warning This signal is not emitted when the current source has - finished and there's another source in the queue. It is only - emitted when the queue is empty. - - \sa currentSourceChanged(), aboutToFinish(), prefinishMarkReached() -*/ - -/*! - \fn void Phonon::MediaObject::currentSourceChanged(const Phonon::MediaSource &newSource) - - Emitted when the MediaObject fetches a new MediaSource from the - queue() and before it enters the \l{Phonon::}{LoadingState} for - the new source. The media object will take a new source from the - queue() when it has finished the playback of the - \l{currentSource()}{current source}. - - \a newSource is the source that starts to play at the time the - signal is emitted. -*/ - -/*! - \fn void Phonon::MediaObject::aboutToFinish() - - Emitted before the playback of the whole queue ends. When this - signal is emitted you still have time to enqueue() a new - MediaSource, so that playback continues. - - If you need a signal to be emitted at a specific time before - playback is finished, you should use the prefinishMarkReached() - signal instead. - - \sa enqueue(), prefinishMark, prefinishMarkReached() -*/ - -/*! - \fn void Phonon::MediaObject::prefinishMarkReached(qint32 msecToEnd) - - Emitted when there are only \a msecToEnd milliseconds left - of playback. - - \warning This signal is not emitted when there is another source - in the queue. It is only emitted when the queue is empty. - - \sa setPrefinishMark(), prefinishMark(), aboutToFinish(), finished() -*/ - -/*! - \fn void Phonon::MediaObject::totalTimeChanged(qint64 newTotalTime) - - This signal is emitted as soon as the total time of the media file is - known or has changed. For most non-local media data the total - time of the media can only be known after some time. At that time the - totalTime function can not return useful information. You have - to wait for this signal to know the real total time. - - \a newTotalTime is the length of the media file in milliseconds. - - \sa totalTime() -*/ - -/*! - \fn MediaObject *Phonon::createPlayer(Phonon::Category category, const MediaSource &source = MediaSource()) - - Convenience function to create a MediaObject and AudioOutput - connected by a path. The \l{Phonon::}{MediaObject} return will - have \a source set as its current source and the specified \a - category. - -*/ - -/*! - \class Phonon::MediaObjectPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \namespace Phonon::BackendCapabilities - \inmodule Phonon - \since 4.4 - \brief The BackendCapabilities namespace contains functions to describe the capabilities of the multimedia backend. - -*/ - -/*! - \class Phonon::BackendCapabilitiesPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::BackendCapabilities::Notifier - \since 4.4 - \inmodule Phonon - \inheaderfile Phonon/BackendCapabilities - - Notifications about backend capabilities. -*/ - -/*! - \fn void Phonon::BackendCapabilities::Notifier::capabilitiesChanged() - - This signal is emitted if the capabilities have changed. This can - happen if the user has requested a backend change. -*/ - -/*! - \fn void Phonon::BackendCapabilities::Notifier::availableAudioOutputDevicesChanged() - - This signal is emitted when audio output devices were plugged or - unplugged. - - Check BackendCapabilities::availableAudioOutputDevices to get the - current list of available devices. -*/ - -/*! - \fn Notifier *Phonon::BackendCapabilities::notifier() - - Use this function to get a QObject pointer to connect to the capabilitiesChanged signal. - - \return a pointer to a QObject. - - The capabilitiesChanged signal is emitted if the capabilities have changed. This can - happen if the user has requested a backend change. - - To connect to this signal do the following: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 16 - - \sa Notifier::capabilitiesChanged() -*/ - -/*! - \fn QStringList Phonon::BackendCapabilities::availableMimeTypes() - - Returns a list of mime types that the Backend can decode. - - \sa isMimeTypeAvailable() -*/ - -/*! - \fn bool Phonon::BackendCapabilities::isMimeTypeAvailable(const QString &mimeType) - - Often all you want to know is whether one given MIME type can be - decoded by the backend. Use this method in favor of - availableMimeTypes() as it can give you a negative answer without - having a backend loaded. - - Returns true if the given \a mimeType is supported by the backend; - otherwise, returns false. - - \sa availableMimeTypes() -*/ - -/*! - \fn QList Phonon::BackendCapabilities::availableAudioOutputDevices() - - Returns the audio output devices the backend supports. - - \return A list of AudioOutputDevice objects that give a name and - description for every supported audio output device. -*/ - -/*! - \fn QList Phonon::BackendCapabilities::availableAudioEffects() - - Returns descriptions for the audio effects the backend supports. - - \return A list of AudioEffectDescription objects that give a name and - description for every supported audio effect. -*/ - -/*! - \internal - \class ObjectDescriptionModelData - \internal - \inmodule Phonon - \brief Data class for models for ObjectDescription objects. -*/ - -/*! - \typedef Phonon::EffectDescription - \relates Phonon::ObjectDescription - - EffectDescription gives a description of an \l{Processors}{audio - effect}. It is a typedef of the \l{Phonon::}{ObjectDescription} - class. Please see its class description for details. - - EffectDescription is used to create audio \l{Phonon::}{Effect}s, - which can be inserted into a media graph, altering an audio - stream. - - \sa Phonon::ObjectDescription, {Capabilities Example}, {Media - Player} - -*/ - -/*! - \class Phonon::ObjectDescriptionModel - \inmodule Phonon - \internal - \since 4.4 - \brief The ObjectDescriptionModel class provides a model from - a list of ObjectDescription objects. - - ObjectDescriptionModel is a read only model that supplies a list - using ObjectDescription::name() for the text and - ObjectDescription::description() for the tooltip. If set the properties - "icon" and "available" are used to set the decoration and disable the - item (disabled only visually, you can still select and drag it). - - It also provides the methods moveUp() and moveDown() to order the list. - Additionally drag and drop is possible so that - QAbstractItemView::InternalMove can be used. - The resulting order of the ObjectDescription::index() values can then be - retrieved using tupleIndexOrder(). - - An example use case would be to give the user a QComboBox to select - the output device: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 17 - - And to retrieve the selected AudioOutputDevice: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 18 - -*/ - -/*! - \fn inline int Phonon::ObjectDescriptionModel::rowCount(const QModelIndex &parent = QModelIndex()) const - - Returns the number of rows in the model. This value corresponds - to the size of the list passed through setModelData. - - \param parent The optional \a parent argument is used in most models to specify - the parent of the rows to be counted. Because this is a list if a - valid parent is specified the result will always be 0. - - Reimplemented from QAbstractItemModel. - - \sa QAbstractItemModel::rowCount() -*/ - -/*! - \fn inline QVariant Phonon::ObjectDescriptionModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const - - Returns data from the item with the given \a index for the specified - \a role. - If the view requests an invalid index, an invalid variant is - returned. - - Reimplemented from QAbstractItemModel. - - \sa QAbstractItemModel::data(), Qt::ItemDataRole -*/ - -/*! - \fn inline Qt::ItemFlags Phonon::ObjectDescriptionModel::flags(const QModelIndex &index) const - \internal - - Reimplemented to show unavailable devices as disabled (but still - selectable). The \a index of the model index for which to return - flags. - -*/ - -/*! - \fn inline QList Phonon::ObjectDescriptionModel::tupleIndexOrder() const - - Returns a list of indexes in the same order as they are in the - model. The indexes come from the ObjectDescription::index - method. - - This is useful to let the user define a list of preference. -*/ - -/*! - \fn inline int Phonon::ObjectDescriptionModel::tupleIndexAtPositionIndex(int positionIndex) const - - Returns the ObjectDescription::index for the tuple - at the given position \a positionIndex. For example a - QComboBox will give you the currentIndex as the - position in the list. But to select the according - AudioOutputDevice using AudioOutputDevice::fromIndex - you can use this method. - - \param positionIndex The position in the list. -*/ - -/*! - \class Phonon::ObjectDescriptionModelDataPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \fn inline QMimeData *Phonon::ObjectDescriptionModel::mimeData(const QModelIndexList &indexes) const - \internal - - Returns the MIME data that dropMimeData() can use to create new - items. -*/ - -/*! - \fn inline void Phonon::ObjectDescriptionModel::moveUp(const QModelIndex &index) - - Moves the item at the given \a index up. In the resulting list - the items at index.row() and index.row() - 1 are swapped. - - Connected views are updated automatically. -*/ - -/*! - \fn inline void Phonon::ObjectDescriptionModel::moveDown(const QModelIndex &index) - - Moves the item at the given \a index down. In the resulting list - the items at index.row() and index.row() + 1 are swapped. - - Connected views are updated automatically. -*/ - -/*! - \fn explicit inline Phonon::ObjectDescriptionModel::ObjectDescriptionModel(QObject *parent = 0) - - Constructs a ObjectDescription model with the - given \a parent. -*/ - -/*! - \fn explicit inline Phonon::ObjectDescriptionModel::ObjectDescriptionModel(const QList > &data, QObject *parent = 0) - - Constructs a ObjectDescription model with the - given \a parent and the given \a data. -*/ - -/*! - \fn inline void Phonon::ObjectDescriptionModel::setModelData(const QList > &data) - - Sets the model data using the list provided by \a data. - - All previous model data is cleared. -*/ - -/*! - \fn inline QList > Phonon::ObjectDescriptionModel::modelData() const - - Returns the model data. - - As the order of the list might have changed this can be different - to what was set using setModelData(). -*/ - -/*! - \fn inline ObjectDescription Phonon::ObjectDescriptionModel::modelData(const QModelIndex &index) const - - Returns one ObjectDescription of the model data for the given \a index. -*/ - -/*! - \fn inline Qt::DropActions Phonon::ObjectDescriptionModel::supportedDropActions() const - - This model supports drag and drop to copy or move - items. -*/ - -/*! - \fn inline bool Phonon::ObjectDescriptionModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) - - Accept drops from other models of the same ObjectDescriptionType. - - The \a data is dropped at the given \a row and \a column; you - also receive the \a parent model index. - - If a valid \a parent is given the dropped items will be inserted - above that item. -*/ - -/*! - \fn inline bool Phonon::ObjectDescriptionModel::removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) - - Removes count rows starting with the given row. - - If a valid \a parent is given no rows are removed since this is a - list model. - - Returns true if the rows were successfully removed; otherwise returns false. -*/ - -/*! - \fn inline QStringList Phonon::ObjectDescriptionModel::mimeTypes() const - - Returns a list of supported drag and drop MIME types. Currently - it only supports one type used internally. -*/ - -/*! - \class Phonon::EffectInterface - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::Effect - \inmodule Phonon - \inheaderfile Phonon/Effect - \since 4.4 - \brief The Effect class is used to transform audio streams. - - An effect is a media node which is inserted into a path between a - \l{Phonon::}{MediaObject} and an audio output node, for instance, - an \l{Phonon::}{AudioOutput}. The Effect transforms the media - stream on that path. - - Examples may include simple modifiers, such as fading or pitch - shifting, and more complex mathematical transformations. You can - query the backend for available effects with - BackendCapabilities::availableAudioEffects(). Note that the - effects available is dependent on the underlying system - (DirectDraw, GStreamer, or QuickTime). - - In order to use an effect, insert it into the path as follows: - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 19 - - The effect will immediately begin applying it's transformations on - the path. To stop it, remove the Effect from the path. - - To create an effect, you use the \l{Phonon::}{EffectDescription} - class, which you get from - \l{BackendCapabilities::}{availableAudioEffects()}. We give a code - example below. - - \snippet doc/src/snippets/audioeffects.cpp 0 - - An effect can have one or more parameters, which let you alter how - the effect works, for instance, by specifying the depth of a - reverb effect. See the EffectParameter class description for - details. - - Phonon also provides EffectWidget, which lets the user modify the - parameters of an effect an the fly; e.g., with combo boxes. - - \sa {Phonon Module}, EffectWidget -*/ - -/*! - \fn explicit Phonon::Effect::Effect(const EffectDescription &description, QObject *parent = 0) - - Constructs a new effect object with the given \a description and \a parent object. - - The EffectDescription object determines the type of the effect. - - \sa {Phonon::BackendCapabilities::availableAudioEffects()} -*/ - -/*! - \fn Phonon::Effect::Effect(EffectPrivate &dd, QObject *parent) - \internal -*/ - -/*! - \fn Phonon::Effect::~Effect() - \internal -*/ - -/*! - \fn QVariant Phonon::Effect::parameterValue(const EffectParameter ¶meter) const - - Returns the value of the given effect \a parameter. You can fetch - the available parameters for an effect with parameters(). - - \sa setParameterValue(), EffectParameter -*/ - -/*! - \fn void Phonon::Effect::setParameterValue(const EffectParameter ¶meter, const QVariant &value) - - Sets the given effect \a parameter to the specified \a value. - - Parameters for an effect are returned by parameters(). You can - check which QVariant::Type an EffectParameter takes with the - EffectParameter::type() function. - - \sa parameterValue(), EffectParameter -*/ - -/*! - \fn EffectDescription Phonon::Effect::description() const; - - Returns the description of this effect. This is the same - description that was passed to the constructor. -*/ - -/*! - \fn QList Phonon::Effect::parameters() const; - - Returns a list of parameters that this effect provides to control - its behavior. - - \sa EffectParameter, EffectWidget -*/ - -/*! - \class Phonon::EffectPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::AudioOutput - \inmodule Phonon - \inheaderfile Phonon/AudioOutput - \since 4.4 - \brief The AudioOutput class is used to send data to audio output devices. - - The AudioOutput class plays sound over a sound device. The audio - output needs to be connected to a \l{Phonon::}{MediaObject} using - \l{Phonon::}{createPath()}. To start playback, you call - \l{Phonon::MediaObject::}{play()} on the media object. - - \snippet snippets/phonon.cpp 2 - - The class supports changing the volume(). It is also possible to - mute the sound. - - To find out what \l{Phonon::}{AudioOutputDevice}s are available - for AudioOutput, you can call - BackendCapabilities::availableAudioOutputDevices(). A default device is - selected by the backend, but it is possible to set the device to - be used with setOutputDevice(). The outputDeviceChanged() signal - will be emitted if the device changes. - - If an error occurs with the playback, for instance, if no valid - output device is found, the media object will receive a - stateChanged() signal with the \l{Phonon::}{ErrorState}. - - Note that the default values of properties are dependent on the - backend. - - \sa Phonon::VolumeSlider, {Music Player Example}, BackendCapabilities, {Phonon Module} -*/ - -/*! - \property Phonon::AudioOutput::name - - This is the name that appears in Mixer applications that control - the volume of this output. - -*/ - -/*! - \property Phonon::AudioOutput::volume - - This is the current loudness of the output. \omit The volume is a - real value between 0.0 (minimum) and 1.0 (maximum). The volume - follows the sound device used, with 1.0 being the maximum volume - the device can produce. \endomit - - (it is using Stevens' law - to calculate the change in voltage internally). - - \sa volumeDecibel -*/ - -/*! - \property Phonon::AudioOutput::volumeDecibel - - This is the current volume of the output in decibel. - - 0 dB means no change in volume, -6dB means an attenuation of the - voltage to 50% and an attenuation of the power to 25%, -inf dB means - silence. - - \sa volume -*/ - -/*! - \property Phonon::AudioOutput::outputDevice - This property holds the (hardware) destination for the output. - - The default device is determined by the \l{Phonon::}{Category} and the global - configuration for that category. Normally you don't need - to override this setting - letting the user change the global - configuration is the right choice. You can still override the - device though, if you have good reasons to do so. - - \sa outputDeviceChanged() -*/ - -/*! - \property Phonon::AudioOutput::muted - This property tells whether the output is muted. - - Muting the output has the same effect as calling setVolume(0.0). -*/ - -/*! - \fn explicit Phonon::AudioOutput::AudioOutput(Phonon::Category category, QObject *parent = 0) - - Creates a new AudioOutput with the given \a parent that defines - output to a physical device. - - The \a category can be used by mixer applications to group volume - controls of applications into categories. That makes it easier for - the user to identify the programs. - The category is also used for the default output device that is - configured centrally. As an example: often users want to have the - audio signal of a VoIP application go to their USB headset while - all other sounds should go to the internal soundcard. - - \sa Phonon::categoryToString(), outputDevice -*/ - -/*! - \fn explicit Phonon::AudioOutput::AudioOutput(QObject *parent = 0) - - Creates a new AudioOutput that defines output to the system - default device with the \{Phonon::Category::}{NoCategory} category - - \sa Phonon::categoryToString(), outputDevice -*/ - -/*! - \fn Phonon::Category Phonon::AudioOutput::category() const - - Returns the category of this output. - - \sa Phonon::AudioOutput::AudioOutput() -*/ - -/*! - \fn void Phonon::AudioOutput::volumeChanged(qreal newVolume) - - This signal is emitted whenever the volume has changed. As the - volume can change without a call to setVolume (calls over dbus) - this is important to keep a widget showing the current volume up - to date. - - \a newVolume is the new volume level. - - \sa setVolume(), volume() -*/ - -/*! - \fn void Phonon::AudioOutput::mutedChanged(bool muted) - - This signal is emitted when the muted property has changed. The \a muted - value passed by the signal indicates the state of the muted property. - As this property can change by IPC (DBus) calls a UI element showing - the muted property should listen to this signal. -*/ - -/*! - \fn void Phonon::AudioOutput::outputDeviceChanged(const Phonon::AudioOutputDevice &newAudioOutputDevice) - - This signal is emitted when the (hardware) device for the output - has changed. \a newAudioOutputDevice is the new device. - - The change can happen either through setOutputDevice or if the - global configuration for the used category has changed. - - \sa outputDevice -*/ - -/*! - \class Phonon::AudioOutputPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::EffectParameter - \inmodule Phonon - \inheaderfile Phonon/EffectParameter - \since 4.4 - \brief The EffectParameter class describes one parameter of an effect. - - You fetch the parameters of an \l{Phonon::}{Effect} with - \l{Phonon::}{Effect::parameters()}. - - \snippet doc/src/snippets/phononeffectparameter.cpp 0 - - To describe itself, an effect parameter gives a name() and - possibly description() (depending on the backend used). These are - suited to present the effect parameter to the user of a Phonon - application. - - Note that effects are created by the backend, and that - their name and descriptions may vary. - - The value of an effect parameter is stored in a \l{QVariant}, - of which type() is usually \c int or \c double. - - The value is retrieved with \l{Phonon::}{Effect::parameterValue()} - and set with \l{Phonon::Effect::}{setParameterValue()} - both of - which takes the EffectParameter as argument. Note that not all - effect parameters support setting of their value. - - You get the values a parameter can take with possibleValues(); an - empty list is returned if the values are continuous. - - A parameter may also specify default(), minimum(), and maximum() - values. Values are returned as \l{QVariant}s. If the parameter - does not have the requested value, an \l{QVariant::Invalid} - invalid QVariant is returned from these functions. - - The \l{Phonon::}{EffectWidget} provides a widget with which one - can control the parameters of an \l{Phonon::}{Effect}. - - \snippet doc/src/snippets/phononeffectparameter.cpp 1 - - \sa Effect, EffectWidget, {Capabilities Example}, {Phonon Module} -*/ - -/*! - \fn Phonon::EffectParameter::EffectParameter() - \internal - - Creates an invalid effect parameter. -*/ - -/*! - \fn Phonon::EffectParameter::~EffectParameter() - - Destroys the effect parameter. -*/ - -/*! - \fn Phonon::EffectParameter::EffectParameter(const EffectParameter &other) - - Constructs a copy of the \a other effect parameter. -*/ - -/*! - \fn const QString &Phonon::EffectParameter::name() const - - The name of the parameter. Can be used as the label. - - \return A label for the parameter. -*/ - -/*! - \fn const QString &Phonon::EffectParameter::description() const - - The parameter may come with a description (LADSPA doesn't have a - field for this, so don't expect many effects to provide a - description). - - The description can be used for a tooltip or WhatsThis help. - - \return A text describing the parameter. -*/ - -/*! - \fn QVariant::Type Phonon::EffectParameter::type() const - - Returns the parameter type. - - Common types are QVariant::Int, QVariant::Double, QVariant::Bool and QVariant::String. When - QVariant::String is returned you get the possible values from possibleValues. -*/ - -/*! - \fn bool Phonon::EffectParameter::isLogarithmicControl() const - - Returns whether the parameter should be - displayed using a logarithmic scale. This is particularly useful for - frequencies and gains. -*/ - -/*! - \fn QVariant Phonon::EffectParameter::minimumValue() const - - The minimum value to be used for the control to edit the parameter. - - If the returned QVariant is invalid the value is not bounded from - below. -*/ - -/*! - \fn QVariant Phonon::EffectParameter::maximumValue() const - - The maximum value to be used for the control to edit the parameter. - - If the returned QVariant is invalid the value is not bounded from - above. -*/ - -/*! - \fn QVariant Phonon::EffectParameter::defaultValue() const - - The default value. -*/ - -/*! - \fn QVariantList Phonon::EffectParameter::possibleValues() const - - The possible values to be used for the control to edit the parameter. - - if the value of this parameter is to be picked from predefined values - this returns the list (otherwise it returns an empty QVariantList). -*/ - -/*! - \fn bool Phonon::EffectParameter::operator<(const EffectParameter &rhs) const - - \internal - compares the ids of the parameters -*/ - -/*! - \fn bool Phonon::EffectParameter::operator>(const EffectParameter &rhs) const - - \internal - compares the ids of the parameters -*/ - -/*! - \fn bool Phonon::EffectParameter::operator==(const EffectParameter &rhs) const - - \internal - compares the ids of the parameters -*/ - -/*! - \fn Phonon::EffectParameter &Phonon::EffectParameter::operator=(const EffectParameter &other) - - Assigns the \a other effect parameter to this parameter and returns - a reference to this parameter. -*/ - -/*! - \enum Phonon::EffectParameter::Hint - - Only for backend developers: - - Flags to set the return values of isToggleControl(), - isLogarithmicControl(), isIntegerControl(), isBoundedBelow() and - isBoundedAbove(). The values of the flags correspond to the values - used for LADSPA effects. - - \value ToggledHint - If this hint is set it means that - the control has only two states: zero and non-zero - (see isToggleControl()). - - \value LogarithmicHint - LADSPA's SAMPLE_RATE hint needs to be translated by the backend - to normal bounds, as the backend knows the sample rate - and the - frontend doesn't (see isLogarithmicControl()). - - \value IntegerHint See isIntegerControl(). -*/ - -/*! - \fn Phonon::EffectParameter::EffectParameter(int parameterId, - const QString &name, EffectParameter::Hints hints, - const QVariant &defaultValue, const QVariant &min = QVariant(), - const QVariant &max = QVariant(), const QVariantList &values = QVariantList(), - const QString &description = QString()) - - Only to be used by backend implementations: - - Creates a new effect parameter. - - \a parameterId This is a number to uniquely identify the - parameter. The id is used for value() and setValue(). - - \a name is the name/label for this parameter. - - \a hints sets the hints for the type of parameter. - - \a defaultValue The value that should be used as a default. - - \a min is the minimum value allowed for this parameter. You only - need to set this if the BoundedBelowHint is set. - - \a max is the maximum value allowed for this parameter. You only - need to set this if the BoundedAboveHint is set. - - The \a values parameter is the values that the effect parameter - can take (only applies if non-continuous) - - \a description is a descriptive text for the parameter - (explaining what it controls) to be used as a tooltip or - WhatsThis help. -*/ - -/*! - \fn int Phonon::EffectParameter::id() const - - \internal - - Returns the parameter's identifier. -*/ - -/*! - \typedef Phonon::AudioOutputInterface - \inmodule Phonon - \internal -*/ - -/*! - \class Phonon::AudioOutputInterface40 - \inmodule Phonon - \since 4.4 - \internal - \brief Interface for AudioOutput objects - -*/ - -/*! - \fn virtual Phonon::AudioOutputInterface40::~AudioOutputInterface40() - \internal -*/ - -/*! - \fn virtual qreal Phonon::AudioOutputInterface40::volume() const = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::AudioOutputInterface40::setVolume(qreal) = 0 - \internal -*/ - -/*! - \fn virtual int Phonon::AudioOutputInterface40::outputDevice() const = 0 - \internal -*/ - -/*! - \fn virtual bool Phonon::AudioOutputInterface40::setOutputDevice(int) = 0 - \internal -*/ - -/*! - \class Phonon::Path - \inmodule Phonon - \inheaderfile Phonon/Path - \since 4.4 - \brief The Path class describes connections between media nodes. - - In a \l{Building Graphs}{media graph}, \l{Phonon::}{MediaNode}s - are connected by Paths. The multimedia travels in streams over - these paths. - - You create a path between two media nodes using the static - Phonon::createPath() function, which takes two nodes as arguments. - The first argument will send the media stream to the second. - Please refer to the class description of the individual media - nodes and the Phonon \l{Phonon Overview}{overview} to see which - nodes can be connected to each other. - - Paths are also used to insert audio \l{Phonon::}{Effect}s between - two media nodes. The effect will then alter the stream on the - path. Notice that \l{Phonon::}{Effect}s also are media nodes, but - that insertEffect() - instead of Phonon::createPath() - is used to - insert them into the media graph. - - The following code example shows how to create a path between two - media nodes and insert an effect on that path. - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 20 - - \sa Phonon::MediaNode, Phonon::MediaObject, Phonon::AudioOutput, - Phonon::VideoWidget, {Phonon Module} -*/ - -/*! - \fn Phonon::Path::~Path(); - - Destroys this reference to the Path. If the path was valid the connection is not broken - as both the source and the sink MediaNodes still keep a reference to the Path. - - \sa disconnect() -*/ - -/*! - \fn Phonon::Path::Path(); - - Creates an invalid path. - - You can still make it a valid path by calling reconnect. It is - recommended to use the Phonon::createPath() function to create - paths. - - \sa Phonon::createPath(), isValid() -*/ - -/*! - \fn Phonon::Path::Path(const Path &path); - - Constructs a copy of the other \a path specified. - - This constructor is fast thanks to explicit sharing. -*/ - -/*! - \fn bool Phonon::Path::isValid() const; - - A path is considered valid if it is connected to two media nodes, - in which case this function returns true. If it is connected to - one or no media nodes, it is consider invalid, and this function - will then return false. -*/ - -/*! - \fn Effect *Phonon::Path::insertEffect(const EffectDescription &desc, Effect *insertBefore = 0); - - Creates and inserts an effect into the path. - - You may insert effects of the same class as often as you like, - but if you insert the same object, the call will fail. - - \a desc is the EffectDescription object for the effect to be inserted. - - If you already inserted an effect you can - tell with \a insertBefore in which order the data gets - processed. If this is \c 0 the effect is appended at the end of - the processing list. If the effect has not been inserted before - the method will do nothing and return \c false. - - Returns a pointer to the effect object if it could be inserted - at the specified position. If \c 0 is returned, the effect was not - inserted. - - Below is a code example for inserting an effect into a path: - - \snippet doc/src/snippets/audioeffects.cpp 0 - - \sa removeEffect(), effects() -*/ - -/*! - \fn bool Phonon::Path::insertEffect(Effect *effect, Effect *insertBefore = 0); - - Inserts the given \a effect into the path before the effect specified by \a insertBefore - and returns true if successful; otherwise returns false. - - If \a insertBefore is zero, the effect is appended to the processing list. - - You may insert effects of the same class as often as you like, but if you insert - the same object, the call will fail. - - \a effect will be inserted right before \a insertBefore. If - \a insertBefore is \c 0, the effect is appended at the end of the - processing list. If the effect has not been inserted before the - method will do nothing and return \c false. - - Returns whether the effect could be inserted at the specified - position. If \c false is returned the effect was not inserted. - - \sa removeEffect(), effects() -*/ - -/*! - \fn bool Phonon::Path::removeEffect(Effect *effect); - - Removes the given \a effect from the path and returns true; otherwise returns false. - - Removes an \a effect from the path. - - If the effect is deleted while it is still connected, the effect will be removed - automatically. - - \omit - \param effect The effect to be removed. - - \return Returns whether the call was successful. If it returns - \c false the effect could not be found in the path, meaning it - has not been inserted before. - \endomit - - \sa insertEffect(), effects() -*/ - -/*! - \fn QList Phonon::Path::effects() const; - - Returns a list of Effect objects that are currently - used as effects. The order in the list determines the order the - signal is sent through the effects. - - \return A list with all current effects. - - \sa insertEffect(), removeEffect() -*/ - -/*! - \fn bool Phonon::Path::reconnect(MediaNode *source, MediaNode *sink); - - Changes the media nodes the path is connected to by connecting the path - to the \a source and \a sink nodes specified. Returns true if successful; - otherwise returns false. - - If unsuccessful, the path remains connected to the same nodes as before. - - \sa Phonon::createPath(), {Phonon Overview} -*/ - -/*! - \fn bool Phonon::Path::disconnect(); - - Tries to disconnect the path from the MediaNodes it is connected to, returning - true if successful or false if unsuccessful. - - If successful, the path is invalidated: isValid() will returns false. -*/ - -/*! - \fn Path &Phonon::Path::operator=(const Path &p); - - Assigns \a p to this Path and returns a reference to this Path. - - This operation is fast thanks to explicit sharing. -*/ - -/*! - \fn bool Phonon::Path::operator==(const Path &p) const; - - Returns true if this Path is equal to \a p; otherwise returns false; -*/ - -/*! - \fn bool Phonon::Path::operator!=(const Path &p) const; - - Returns true if this Path is not equal to \a p; otherwise returns false. -*/ - -/*! - \fn MediaNode *Phonon::Path::source() const; - - Returns the source MediaNode used by the path. -*/ - -/*! - \fn MediaNode *Phonon::Path::sink() const; - - Returns the sink MediaNode used by the path. -*/ - -/*! - \fn Path Phonon::createPath(MediaNode *source, MediaNode *sink); - - \relates Phonon::Path - Creates a new Path connecting the two MediaNodes \a source and \a sink. - - The implementation will automatically select the right format and media type. E.g. connecting a - MediaObject and AudioOutput will create a Path object connecting the audio. This might be - represented as PCM or perhaps even AC3 depending on the AudioOutput object. - - \param source The MediaNode to connect an output from - \param sink The MediaNode to connect to. -*/ - -/*! - \class Phonon::PathPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::MediaObjectInterface - \inmodule Phonon - \since 4.4 - \internal - \brief Backend interface for media sources. - - The backend implementation has to provide two signals, that are not defined - in this interface: - \list - \o \target phonon_MediaObjectInterface_stateChanged - void stateChanged(Phonon::State newstate, Phonon::State oldstate) - - Emitted when the state of the MediaObject has changed. - In case you're not interested in the old state you can also - connect to a slot that only has one State argument. - - \param newstate The state the Player is in now. - \param oldstate The state the Player was in before. - - \o \target phonon_MediaObjectInterface_tick - void tick(qint64 time) - - This signal gets emitted every tickInterval milliseconds. - - \param time The position of the media file in milliseconds. - - \sa setTickInterval() - \sa tickInterval() - \endlist - - \sa MediaObject -*/ - -/*! - \fn virtual Phonon::MediaObjectInterface::~MediaObjectInterface() - \internal -*/ - -/*! - \fn virtual qint64 Phonon::MediaObjectInterface::remainingTime() const - \internal -*/ - -/*! - \fn virtual qint32 Phonon::MediaObjectInterface::prefinishMark() const = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::MediaObjectInterface::setPrefinishMark(qint32) = 0 - \internal -*/ - -/*! - \fn virtual qint32 Phonon::MediaObjectInterface::transitionTime() const = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::MediaObjectInterface::setTransitionTime(qint32) = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::MediaObjectInterface::play() = 0 - \internal - - Requests the playback to start. - - This method is only called if the state transition to PlayingState is possible. - - The backend should react immediately - by either going into PlayingState or BufferingState if the - former is not possible. -*/ - -/*! - \fn virtual void Phonon::MediaObjectInterface::pause() = 0 - \internal - - Requests the playback to pause. - - This method is only called if the state transition to PausedState is possible. - - The backend should react as fast as possible. Go to PausedState - as soon as playback is paused. -*/ - -/*! - \fn virtual void Phonon::MediaObjectInterface::stop() = 0 - \internal - - Requests the playback to be stopped. - - This method is only called if the state transition to StoppedState is possible. - - The backend should react as fast as possible. Go to StoppedState - as soon as playback is stopped. - - A subsequent call to play() will start playback at the beginning of - the media. -*/ - -/*! - \fn virtual void Phonon::MediaObjectInterface::seek(qint64 milliseconds) = 0 - \internal - - Requests the playback to be seeked to the given time. - - The backend does not have to finish seeking while in this function - (i.e. the backend does not need to block the thread until the seek is - finished; even worse it might lead to deadlocks when using a - ByteStream which gets its data from the thread this function would - block). - - As soon as the seek is done the currentTime() function and - the tick() signal will report it. - - \param milliseconds The time where playback should seek to in - milliseconds. -*/ - -/*! - \fn virtual qint32 Phonon::MediaObjectInterface::tickInterval() const = 0 - \internal - - Return the time interval in milliseconds between two ticks. - - Returns the tick interval that it was set to (might not - be the same as you asked for). -*/ - -/*! - \fn virtual void Phonon::MediaObjectInterface::setTickInterval(qint32 interval) = 0 - \internal - - Change the interval the tick signal is emitted. Set \a interval to 0 to - disable the signal. - - \a interval tick interval in milliseconds - - Returns the tick interval that it was set to (might not be the same as you - asked for). - -*/ - -/*! - \fn virtual bool Phonon::MediaObjectInterface::hasVideo() const = 0 - \internal - - Check whether the media data includes a video stream. - - Returns true if the media contains video data. -*/ - -/*! - \fn virtual bool Phonon::MediaObjectInterface::isSeekable() const = 0 - \internal - - If the current media may be seeked this function returns true; - otherwise, false. - - Returns whether the current media may be seeked. -*/ - -/*! - \fn virtual qint64 Phonon::MediaObjectInterface::currentTime() const = 0 - \internal - - Get the current time (in milliseconds) of the file currently being played. -*/ - -/*! - \fn virtual Phonon::State Phonon::MediaObjectInterface::state() const = 0 - \internal - - Get the current state. -*/ - -/*! - \fn virtual QString Phonon::MediaObjectInterface::errorString() const = 0 - \internal - - A translated string describing the error. -*/ - -/*! - \fn virtual Phonon::ErrorType Phonon::MediaObjectInterface::errorType() const = 0 - \internal - - Tells your program what to do about the error. - - \sa Phonon::ErrorType -*/ - -/*! - \fn virtual qint64 Phonon::MediaObjectInterface::totalTime() const = 0 - \internal - - Returns the total time of the media in milliseconds. - - If the total time is not know return -1. Do not block until it is - known, instead emit the totalTimeChanged signal as soon as the total - time is known or changes. -*/ - -/*! - \fn virtual MediaSource Phonon::MediaObjectInterface::source() const = 0 - \internal - - Returns the current source. -*/ - -/*! - \fn virtual void Phonon::MediaObjectInterface::setSource(const MediaSource &) = 0 - \internal - - Sets the current source. When this function is called the MediaObject is - expected to stop all current activity and start loading the new - source (i.e. go into LoadingState). - - It is expected that the - backend now starts preloading the media data, filling the audio - and video buffers and making all media meta data available. It - will also trigger the totalTimeChanged signal. - - If the backend does not know how to handle the source it needs to - change state to Phonon::ErrorState. Don't bother about handling KIO - URLs. It is enough to handle AbstractMediaStream sources correctly. - - \warning Keep the MediaSource object around as long as the backend - uses the AbstractMediaStream returned by the MediaSource. In case - that no other reference to the MediaSource exists and it is set to - MediaSource::autoDelete, the AbstractMediaStream is deleted when the - last MediaSource ref is deleted. -*/ - -/*! - \fn virtual void Phonon::MediaObjectInterface::setNextSource(const MediaSource &source) = 0 - \internal - - Sets the next source to be used for transitions. When a next source - is set playback should continue with the new source. In that case - finished and prefinishMarkReached are not emitted. - - \param source The source to transition to (crossfade/gapless/gap). If - \a source is an invalid MediaSource object then the queue is empty - and the playback should stop normally. - - \warning Keep the MediaSource object around as long as the backend - uses the AbstractMediaStream returned by the MediaSource. In case - that no other reference to the MediaSource exists and it is set to - MediaSource::autoDelete, the AbstractMediaStream is deleted when the - last MediaSource ref is deleted. -*/ - -/*! - \class Phonon::EffectWidget effectwidget.h Phonon/EffectWidget - \inmodule Phonon - \inheaderfile Phonon/EffectWidget - \since 4.4 - \brief The EffectWidget class provides a widget to control the parameters of an Effect. - - The EffectWidget class provides a widget, with which an effects - parameters can be controlled. The widget does not have an API, - and is constructed with the \l{Phonon::}{Effect}, of which - parameters should be controlled. - - \snippet doc/src/snippets/audioeffects.cpp 1 - - The following image shows an example of an effect widget. - - \image effectwidget.png - - Note that some audio effects do not have parameters, and the - widget will then not \l{QWidget::}{show()} at all. - - \sa Effect, BackendCapabilities, EffectDescription, {Phonon Module} -*/ - -/*! - \class Phonon::AbstractAudioOutput - \inmodule Phonon - \internal - \brief Provides a common base class for all audio outputs. - - \sa AudioOutput -*/ - -/*! - \fn Phonon::AbstractAudioOutput::~AbstractAudioOutput() - \internal -*/ - -/*! - \class Phonon::AbstractAudioOutputPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class AudioOutputAdaptor - \inmodule Phonon - \brief Provides an adaptor class for interface org.kde.Phonon.AudioOutput - \internal -*/ - -/*! - \class Phonon::VolumeSlider - \inmodule Phonon - \inheaderfile Phonon/VolumeSlider - \since 4.4 - \brief The VolumeSlider widget provides a slider that is used to control the volume of an audio output device. - - The slider also displays an icon indicating if the volume of the - \l{Phonon::}{AudioOutput} it is connected to is muted. The icon - can be removed with setMuteVisible(). - - It is possible to set the \l{maximumVolume}{maximum} value of the - slider. By default, the minimum and maximum values of the slider - are 0.0 (no sound) to 1.0 (the maximum volume the audio output can - produce). - - Here follows a code example: - - \snippet doc/src/snippets/volumeslider.cpp 0 - - \omit mention how to change the style of the slider. \endomit - - \sa {Phonon Module} -*/ - -/*! - \property Phonon::VolumeSlider::maximumVolume - - This property holds the maximum volume that can be set with this slider. - - By default the maximum value is 1.0 (100%). -*/ - -/*! - \property Phonon::VolumeSlider::orientation - This property holds the orientation of the slider. - - The orientation must be Qt::Vertical (the default) or Qt::Horizontal. -*/ - -/*! - \property Phonon::VolumeSlider::tracking - This property holds whether slider tracking is enabled. - - If tracking is enabled (the default), the volume changes - while the slider is being dragged. If tracking is - disabled, the volume changes only when the user - releases the slider. -*/ - -/*! - \property Phonon::VolumeSlider::pageStep - This property holds the page step. - - The larger of two natural steps that a slider provides and - typically corresponds to the user pressing PageUp or PageDown. - - Defaults to 5 (5% of the voltage). -*/ - -/*! - \property Phonon::VolumeSlider::singleStep - This property holds the single step. - - The smaller of two natural steps that a slider provides and - typically corresponds to the user pressing an arrow key. - - Defaults to 1 (1% of the voltage). -*/ - -/*! - \property Phonon::VolumeSlider::muteVisible - This property holds whether the mute button/icon next to the slider is visible. - - By default the mute button/icon is visible. -*/ - -/*! - \property Phonon::VolumeSlider::iconSize - \brief the icon size used for the mute button/icon. - - The default size is defined by the GUI style. -*/ - -/*! - \fn explicit Phonon::VolumeSlider::VolumeSlider(QWidget *parent = 0) - Constructs a new volume slider with the given \a parent. -*/ - -/*! - \fn explicit Phonon::VolumeSlider::VolumeSlider(AudioOutput *output, QWidget *parent = 0) - Constructs a new volume slider with the given \a output object and \a parent. -*/ - -/*! - \fn Phonon::VolumeSlider::~VolumeSlider() -*/ - -/*! - \fn AudioOutput *Phonon::VolumeSlider::audioOutput() const -*/ - -/*! - \fn void Phonon::VolumeSlider::setAudioOutput(Phonon::AudioOutput *output) - - Sets the audio output object to be controlled by this slider to the specified - \a output object. -*/ - -/*! - \class Phonon::VolumeSliderPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::MediaController - \inmodule Phonon - \inheaderfile Phonon/MediaController - \since 4.4 - \brief The MediaController class controls optional features of a media file/device. - - Some media sources have content that the \l{Phonon::}{MediaObject} - does not provide control over, for instance, chapters in a DVD - file. The functionality the media controller offers is - dependent on the type of media source that is played back. - Commonly, the media controller allows you to: - - \list - \o Navigate between \bold chapters. - \o Navigate between \bold titles. - \o Select between \bold angles. - \endlist - - The \l{Phonon::MediaController::}{Feature} enum explains these - terms in more detail, and their context in playback of CD and DVD. - - The media controller keeps a \l{Phonon::}{MediaObject}, of which - \l{Phonon::MediaObject::currentSource()}{media source} is played - back. You can still call the media object's functions, e.g., - \l{Phonon::MediaObject::}{stop()}; this is all handled correctly - by the media controller. You have the option of letting the media - controller play all titles of a source in sequence by setting the - \l{autoplayTitles()}{autoplay titles} option. - - To start a playback using a media object, you call - \l{Phonon::MediaObject::}{play()} on the media object. To play a - specific title, use setCurrentTitle() and then call - \l{Phonon::MediaObject::}{play()}. - - \warning The Phonon::MediaController class is not yet supported by - Qt backends. - - \sa {Phonon Module} -*/ - -/*! - \fn int Phonon::MediaController::availableAudioChannels() const - \internal -*/ - -/*! - \fn void Phonon::MediaController::availableAudioChannelsChanged() - \internal -*/ - -/*! - \fn QList Phonon::MediaController::availableSubtitles() const - \internal -*/ - -/*! - \fn void Phonon::MediaController::availableSubtitlesChanged() - \internal -*/ - -/*! - \fn AudioChannelDescription Phonon::MediaController::currentAudioChannel() const - \internal -*/ - -/*! - \fn SubtitleDescription Phonon::MediaController::currentSubtitle() const - \internal -*/ - -/*! - \fn void Phonon::MediaController::setCurrentAudioChannel(const Phonon::AudioChannelDescription &stream) - \internal -*/ - -/*! - \fn void Phonon::MediaController::setCurrentSubtitle(const Phonon::SubtitleDescription &stream) - \internal -*/ - -/*! - \fn Phonon::BackendCapabilities::availableAudioCaptureDevices() - \internal -*/ - -/*! - \fn Phonon::BackendCapabilities::Notifier::availableAudioCaptureDevicesChanged() - \internal -*/ - -/*! - \enum Phonon::MediaController::Feature - - The values of this enum are interpreted differently depending on - the type of media source, e.g., DVD or CD. We give examples for - these sources. - - \value Angles In the VOB (DVD) format, it is possible to to give - several video streams of the same scene, each of which displays - the scene from a different angle. The DVD viewer can then change - between these angles. - - \value Chapters In the VOB format, chapters are points in a - single video stream that can be played and seeked to - separately. - - \value Titles On a CD, a title is a separate sound track. On DVD, - a title is a separate VOB file. - -*/ - -/*! - \fn Phonon::MediaController::MediaController(MediaObject *parent) - - Constructs a new MediaController with the media object (\a parent) - to be used by the media controller. - - \sa MediaObject, Feature -*/ - -/*! - \fn Phonon::MediaController::~MediaController() -*/ - -/*! - \fn Features Phonon::MediaController::supportedFeatures() const -*/ - -/*! - \fn int Phonon::MediaController::availableAngles() const - - Returns the available angles that is available for the current - media source. - - \sa Feature -*/ - -/*! - \fn int Phonon::MediaController::currentAngle() const - - Returns the angle that is currently used. - - \sa Feature -*/ - -/*! - \fn int Phonon::MediaController::availableChapters() const - - Returns the number of chapters the current media source - contains. - - \sa Feature -*/ - -/*! - \fn int Phonon::MediaController::currentChapter() const - - Returns the chapter that is currently being played back. - - \sa Feature -*/ - -/*! - \fn int Phonon::MediaController::availableTitles() const - - Returns the number of titles that the current media source - contains. - - \sa Feature -*/ - -/*! - \fn int Phonon::MediaController::currentTitle() const - - Returns the title that is currently played back. - - The current title is 0 (the first) by default. - - \sa Feature -*/ - -/*! - \fn bool Phonon::MediaController::autoplayTitles() const - - Returns true if titles will automatically be played when the media - is played; otherwise returns false. - - The media controller will play the titles of the media source in - sequence when the media object's \l{Phonon::MediaObject::}{play()} - function is called. If the autoplay option is disabled, the media - object will play the - \l{Phonon::}{MediaController::currentTitle()}{current title} and then - finish the playback. - - \sa setAutoplayTitles(), currentTitle() -*/ - -/*! - \fn void Phonon::MediaController::setAutoplayTitles(bool enable) - - Sets the titles to play automatically when the media is played if - \a enable is true; otherwise disables this option. - - The media controller will play the titles of the media source in - sequence when the media object's \l{Phonon::MediaObject::}{play()} - function is called. If the autoplay option is disabled, the media - object will play the - \l{Phonon::}{MediaController::currentTitle()}{current title} and then - finish the playback. - - \sa autoplayTitles(), currentTitle() -*/ - -/*! - \fn void Phonon::MediaController::setCurrentAngle(int angleNumber) - - Sets the current angle to the given \a angleNumber if the media - file or device supports navigation by angle number. - - \sa Feature -*/ - -/*! - \fn void Phonon::MediaController::setCurrentChapter(int chapterNumber) - - Sets the current chapter to the given \a chapterNumber if the media - file or device supports navigation by chapter number. - - \sa Feature -*/ - -/*! - \fn void Phonon::MediaController::setCurrentTitle(int titleNumber) - - Skips to the given title \a titleNumber. - - If it was playing before the title change it will start playback on the new title if - autoplayTitles is enabled. - - \sa Feature -*/ - -/*! - \fn void Phonon::MediaController::nextTitle() - - Skips to the next title. - - If it was playing before the title change it will start playback on the next title if - autoplayTitles is enabled. - - \sa Feature -*/ - -/*! - \fn void Phonon::MediaController::previousTitle() - - Skips to the previous title. - - If it was playing before the title change it will start playback on the previous title if - autoplayTitles is enabled. - - \sa Feature -*/ - -/*! - \fn void Phonon::MediaController::availableAnglesChanged(int availableAngles) - - This signal is emitted whenever the number of available angles changes. - The new number of available angles is given by \a availableAngles. - - \sa Feature -*/ - -/*! - \fn void Phonon::MediaController::angleChanged(int angleNumber) - - This signal is emitted whenever the current angle changes. - The new angle number is given by \a angleNumber. - - \sa Feature -*/ - -/*! - \fn void Phonon::MediaController::availableChaptersChanged(int availableChapters) - - This signal is emitted whenever the number of available chapters changes. - The new number of available chapters is given by \a availableChapters. - - \sa Feature -*/ - -/*! - \fn void Phonon::MediaController::chapterChanged(int chapterNumber) - - This signal is emitted whenever the current chapter changes. - The new chapter number is given by \a chapterNumber. - - \sa Feature -*/ - -/*! - \fn void Phonon::MediaController::availableTitlesChanged(int availableTitles) - - This signal is emitted whenever the number of available titles changes. - The new number of available titles is given by \a availableTitles. - - \sa Feature -*/ - -/*! - \fn void Phonon::MediaController::titleChanged(int titleNumber) - - This signal is emitted whenever the current title changes. - The new title number is given by \a titleNumber. - - \sa Feature -*/ - -/*! - \class Phonon::VideoWidget - \inmodule Phonon - \inheaderfile Phonon/VideoWidget - \since 4.4 - \ingroup advanced - \ingroup multimedia - \brief The VideoWidget class provides a widget that is used to display video. - - The VideoWidget class renders the video of a media stream on a - QWidget. It is connected to the \l{Phonon::}{MediaObject}, of - which video stream it should render. You connect the two objects - using the Phonon::createPath() function. - - The widget has some possibilities to manipulate the video - stream. You can change the brightness(), hue(), saturation(), - and contrast(). - - Resizing of the video is handled automatically, but you can affect - the way the video is resized with the aspectRatio and scaleMode - properties. By default, the widget will use the aspect ratio of - the video stream itself. - - The video widget takes the size of the video when it receives a new video - stream (i.e., when a new MediaSource is set on the MediaObject to which it is - connected). If you need to know the size of the video, you can call - \l{QWidget::}{sizeHint()} after the video has been loaded (i.e., after the - MediaObject leaves the \l{Phonon::}{LoadingState}). - - It is also possible to go to \l{fullScreen}{full screen} mode. - - A typical example of usage follows below: - - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 21 - - \sa {Phonon Module} -*/ - -/*! - \fn Phonon::VideoWidget::VideoWidget(QWidget *parent = 0) - - Constructs a new video widget with the specified \a parent. -*/ - -/*! - \fn Phonon::VideoWidget::VideoWidget(VideoWidgetPrivate &d, QWidget *parent) - \internal - - Constructs a new video widget with the specified \a parent. -*/ - -/*! - \fn bool Phonon::VideoWidget::event(QEvent *) - \reimp -*/ - -/*! - \fn void Phonon::VideoWidget::mouseMoveEvent(QMouseEvent *) - \reimp -*/ - -/*! - \enum Phonon::VideoWidget::ScaleMode - - The ScaleMode enum describes how to treat aspect ratio during - resizing of video. - - \value FitInView The video will be fitted to fill the view - keeping aspect ratio. - \value ScaleAndCrop The video is scaled -*/ - -/*! - \property Phonon::VideoWidget::fullScreen - This property holds whether the video is shown using the complete - screen. - - The property differs from QWidget::fullScreen in that it is - writeable. - - By default the widget is not shown in fullScreen. - - \warning When switching to full screen mode using setFullScreen(), - the widget onto which the video is rendered is shown as a - top-level window. Key event forwarding is handled by VideoWidget, - but if you need to handle other events, e.g., mouse events, you - should handle fullscreen mode yourself. -*/ - -/*! - \property Phonon::VideoWidget::aspectRatio - Defaults to AspectRatioAuto. - - \sa AspectRatio -*/ - -/*! - \property Phonon::VideoWidget::scaleMode - - If the size of the widget and the size of the video are not equal. - The video will be zoomed to fit the widget. The smaller zoom - (AddBarsScaleMode) adds black bars at the left/right or top/bottom to - make all of the image visible (default). The bigger zoom (ExpandMode) - fills the widget completely, keeping all information in one direction - and leaving parts of the image outside of the widget in the other - direction. -*/ - -/*! - \property Phonon::VideoWidget::brightness - - This property holds brightness of the video. - - Default is 0. Acceptable values are in range of -1, 1. -*/ - -/*! - \property Phonon::VideoWidget::contrast - - This property holds the contrast of the video. - - Default is 0. Acceptable values are in range of -1, 1. -*/ - -/*! - \property Phonon::VideoWidget::hue - - This property holds the hue of the video. - - Default is 0. Acceptable values are in range of -1, 1. -*/ - -/*! - \property Phonon::VideoWidget::saturation - - This property holds saturation of the video. - - Default is 0. Acceptable values are in range of -1, 1. -*/ - -/*! - \enum Phonon::VideoWidget::AspectRatio - - Defines the width:height to be used for the video. - - \value AspectRatioAuto - Let the decoder find the aspect ratio automatically from the - media file (this is the default). - - \value AspectRatioWidget - Fits the video into the widget making the aspect ratio depend - solely on the size of the widget. This way the aspect ratio - is freely resizeable by the user. - - \value AspectRatio4_3 - Make width/height == 4/3, which is the old TV size and - monitor size (1024/768 == 4/3). (4:3) - - \value AspectRatio16_9 - Make width/height == 16/9, which is the size of most current - media. (16:9) -*/ - -/*! - \fn void Phonon::VideoWidget::exitFullScreen() - - Convenience slot, calling setFullScreen(false) -*/ - - -/*! - \fn void Phonon::VideoWidget::enterFullScreen() - - Convenience slot, calling setFullScreen(true) -*/ - -/*! - \class Phonon::VideoWidgetInterface - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \fn virtual Phonon::VideoWidgetInterface::~VideoWidgetInterface() -*/ - -/*! - \fn virtual Phonon::VideoWidget::AspectRatio Phonon::VideoWidgetInterface::aspectRatio() const = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::VideoWidgetInterface::setAspectRatio(Phonon::VideoWidget::AspectRatio ratio) = 0 - \internal -*/ - -/*! - \fn virtual qreal Phonon::VideoWidgetInterface::brightness() const = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::VideoWidgetInterface::setBrightness(qreal) = 0 - \internal -*/ - -/*! - \fn virtual Phonon::VideoWidget::ScaleMode Phonon::VideoWidgetInterface::scaleMode() const = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::VideoWidgetInterface::setScaleMode(Phonon::VideoWidget::ScaleMode mode) = 0 - \internal -*/ - -/*! - \fn virtual qreal Phonon::VideoWidgetInterface::contrast() const = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::VideoWidgetInterface::setContrast(qreal) = 0 - \internal -*/ - -/*! - \fn virtual qreal Phonon::VideoWidgetInterface::hue() const = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::VideoWidgetInterface::setHue(qreal) = 0 - \internal -*/ - -/*! - \fn virtual qreal Phonon::VideoWidgetInterface::saturation() const = 0 - \internal -*/ - -/*! - \fn virtual void Phonon::VideoWidgetInterface::setSaturation(qreal) = 0 - \internal -*/ - -/*! - \fn virtual QWidget *Phonon::VideoWidgetInterface::widget() = 0 - \internal -*/ - -/*! - \class Phonon::PlatformPlugin - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \fn virtual AbstractMediaStream *Phonon::PlatformPlugin::createMediaStream(const QUrl &url, QObject *parent) = 0 - - Creates a AbstractMediaStream object with the given \a parent that provides the data - for the given URL specified by \a url. - \omit - On KDE this uses KIO. - \endomit -*/ - -/*! - \fn virtual QIcon Phonon::PlatformPlugin::icon(const QString &name) const = 0 - - Returns the icon for the given icon name. -*/ - -/*! - \fn virtual void Phonon::PlatformPlugin::notification(const char *notificationName, const QString &text, - const QStringList &actions, QObject *receiver, const char *actionSlot) const = 0 - - Shows a notification pop-up with the given \a notificationName and \a text. - Each action in the associated list of \a actions is connected to the \a actionSlot - of the specified \a receiver object, which is expected to act on the actions as - they are triggered by the user. -*/ - -/*! - \fn virtual QString Phonon::PlatformPlugin::applicationName() const = 0 - - Returns the name of the application. For most Qt application this is - QCoreApplication::applicationName(), but for KDE this is overridden by KAboutData. -*/ - - -/*! - \fn virtual QObject *Phonon::PlatformPlugin::createBackend() = 0 - - Creates a backend object. This way the platform can decide the backend preference. -*/ - -/*! - \fn virtual QObject *Phonon::PlatformPlugin::createBackend(const QString &library, const QString &version) = 0 - - Using the library loader of the platform, loads a given backend provided the - specified \a library and \a version. -*/ - -/*! - \fn virtual bool Phonon::PlatformPlugin::isMimeTypeAvailable(const QString &mimeType) const = 0 - - Tries to check whether the default backend supports the MIME type specified by \a mimeType - without loading the actual backend library. - \omit - On KDE this reads the MIME type list from the .desktop file of - the backend. - \endomit -*/ - -/*! - \fn virtual void Phonon::PlatformPlugin::saveVolume(const QString &outputName, qreal volume) = 0 - - Saves the volume for the given output. -*/ - -/*! - \fn virtual qreal Phonon::PlatformPlugin::loadVolume(const QString &outputName) const = 0 - - Loads the volume for the given output. -*/ - -/*! - \class Phonon::MediaNode - \inmodule Phonon - \inheaderfile Phonon/MediaNode - \since 4.4 - \brief The MediaNode class is the base class for all nodes in a media graph. - - In all phonon applications, one builds a media graph consisting of - MediaNodes. The graph will take multimedia content, e.g., from a - file, as input. After its nodes have processed the multimedia, the - graph will output the media again, e.g., to a sound card. - - The multimedia content is streamed over \l{Phonon::}{Path}s - between the nodes in the graph. You can query the paths that are - connected to a media node with inputPaths() and outputPaths(). - - You can check whether the node is implemented by the current - backend by calling isValid(). This does not guarantee that an - instance of the class works as expected, but that the backend has - implemented functionality for the class. - - Currently, Phonon has four media nodes: \l{Phonon::}{MediaObject}, - \l{Phonon::}{AudioOutput}, \l{Phonon::}{VideoWidget}, and \l{Phonon::}{Effect}. - Please refer to their class descriptions for details about their usage, and to - find out which nodes can be connected to each other. See also \l{Building - Graphs} in Phonon's \l{Phonon Overview}{overview} document. - - Two nodes are connected to each other using the - Phonon::createPath() or \l{Phonon::}{Path::insertEffect()} - functions (only \l{Phonon::Effect}s use - \l{Phonon::Path::}{insertEffect()}). We show a code example below, - in which we build a media graph for video playback and then query - its media nodes for their \l{Phonon::}{Path}s: - - \snippet doc/src/snippets/medianodesnippet.cpp 0 - - When you create a Phonon application, you will likely build the - graph yourself. This makes isValid() the most useful function of - this class. The other two functions help navigate the graph, which - you do not need to do as you created the nodes yourself. - - \sa {Phonon Overview}, Phonon::MediaObject, - Phonon::AudioOutput, Phonon::VideoWidget, {Phonon Module} -*/ - -/*! - \fn virtual Phonon::MediaNode::~MediaNode() - - Destroys the media node and any paths connecting it to other - nodes. Any \l{Phonon::}{Effect}s connected to these paths will - also be deleted. -*/ - -/*! - \fn bool Phonon::MediaNode::isValid() const - - Returns true if the backend provides an implementation of this - class; otherwise returns false. - - This does not guarantee that instances of the class works as - expected, but that the backend has implemented the functionality - for this class. For instance, Qt's GStreamer backend will return - true for instances of the \l{Phonon::}{AudioOutput} class, even if - there is a problem with GStreamer and it could not play sound. - -*/ - -/*! - \fn QList Phonon::MediaNode::inputPaths() const - - Returns the paths that inputs multimedia to this media node. - - \sa outputPaths() -*/ - -/*! - \fn QList Phonon::MediaNode::outputPaths() const - - Returns the paths to which this media node outputs media. - - \sa inputPaths() -*/ - -/*! - \fn Phonon::MediaNode::MediaNode(MediaNodePrivate &dd) - \internal -*/ - -/*! - \class Phonon::GlobalConfig - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \fn Phonon::GlobalConfig::GlobalConfig() - \internal -*/ - -/*! - \fn Phonon::GlobalConfig::~GlobalConfig() - \internal -*/ - -/*! - \fn QList Phonon::GlobalConfig::audioOutputDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const - \internal -*/ - -/*! - \fn int Phonon::GlobalConfig::audioOutputDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const - \internal -*/ - -/*! - \class Phonon::ObjectDescriptionData - \inmodule Phonon - \since 4.4 - \internal - \brief Data class for objects describing devices or features of the backend. - - \sa Phonon::BackendCapabilities -*/ - -/*! - \fn bool Phonon::ObjectDescriptionData::operator==(const ObjectDescriptionData &otherDescription) const - - Returns \c true if this ObjectDescription describes the same - as \a otherDescription; otherwise returns \c false. -*/ - -/*! - \fn QString Phonon::ObjectDescriptionData::name() const - - Returns the name of the capture source. - - \return A string that should be presented to the user to - choose the capture source. -*/ - -/*! - \fn QString Phonon::ObjectDescriptionData::description() const - - Returns a description of the capture source. This text should - make clear what sound source this is, which is sometimes hard - to describe or understand from just the name. - - \return A string describing the capture source. -*/ - -/*! - \fn QVariant Phonon::ObjectDescriptionData::property(const char *name) const - - Returns a named property. - - If the property is not set an invalid value is returned. - - \sa propertyNames() -*/ - -/*! - \fn QList Phonon::ObjectDescriptionData::propertyNames() const - - Returns all names that return valid data when property() is called. - - \sa property() -*/ - -/*! - \fn bool Phonon::ObjectDescriptionData::isValid() const - - Returns true if the Tuple is valid (index != -1); otherwise returns - false. -*/ - -/*! - \fn int Phonon::ObjectDescriptionData::index() const - - A unique identifier for this device/. Used internally - to distinguish between the devices/. - - \return An integer that uniquely identifies every device. -*/ - -/*! - \fn static ObjectDescriptionData *Phonon::ObjectDescriptionData::fromIndex(ObjectDescriptionType type, int index) - \internal -*/ - -/*! - \fn Phonon::ObjectDescriptionData::~ObjectDescriptionData() - \internal -*/ - -/*! - \fn Phonon::ObjectDescriptionData::ObjectDescriptionData(ObjectDescriptionPrivate * = 0) - \internal -*/ - -/*! - \class Phonon::AddonInterface - \inmodule Phonon - \since 4.4 - \internal - \brief Interface for Menu, Chapter, Angle and Title/Track control. -*/ - -/*! - \fn virtual Phonon::AddonInterface::~AddonInterface() - \internal -*/ - -/*! - \enum Phonon::AddonInterface::Interface - - This enum describes the type of interface represented by an AddonInterface object. - - \value NavigationInterface - \value ChapterInterface - \value AngleInterface - \value TitleInterface -*/ - -/*! - \enum Phonon::AddonInterface::NavigationCommand - \internal - \value Menu1Button -*/ - -/*! - \enum Phonon::AddonInterface::ChapterCommand - \internal - \value availableChapters - \value chapter - \value setChapter -*/ - -/*! - \enum Phonon::AddonInterface::AngleCommand - \internal - \value availableAngles - \value angle - \value setAngle -*/ - -/*! - \enum Phonon::AddonInterface::TitleCommand - \internal - \value availableTitles - \value title - \value setTitle - \value autoplayTitles - \value setAutoplayTitles -*/ - -/*! - \fn virtual bool Phonon::AddonInterface::hasInterface(Interface iface) const = 0 - \internal -*/ - -/*! - \fn virtual QVariant Phonon::AddonInterface::interfaceCall(Interface iface, int command, - const QList &arguments) = 0 - \internal -*/ - -/*! - \class Phonon::MediaNodePrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \namespace Phonon::Factory - \inmodule Phonon - \internal -*/ - -/*! - \fn Sender *Phonon::Factory::sender() - - Returns a pointer to the object emitting the signals. - - \sa Sender::backendChanged() -*/ - -/*! - \fn QObject *Phonon::Factory::createMediaObject(QObject *parent = 0) - - Create a new backend object for a MediaObject. - - \return a pointer to the MediaObject the backend provides. -*/ - -/*! - \fn QObject *Phonon::Factory::createEffect(int effectId, QObject *parent = 0) - - Create a new backend object for a Effect. - - \return a pointer to the Effect the backend provides. -*/ - -/*! - \fn QObject *Phonon::Factory::createVolumeFaderEffect(QObject *parent = 0) - - Create a new backend object for a VolumeFaderEffect. - - \return a pointer to the VolumeFaderEffect the backend provides. -*/ - -/*! - \fn QObject *Phonon::Factory::createAudioOutput(QObject *parent = 0) - - Create a new backend object for a AudioOutput. - - \return a pointer to the AudioOutput the backend provides. -*/ - -/*! - \fn QObject *Phonon::Factory::createVideoWidget(QObject *parent = 0) - - Create a new backend object for a VideoWidget. - - \return a pointer to the VideoWidget the backend provides. -*/ - -/*! - \fn QObject *Phonon::Factory::backend(bool createWhenNull = true) - - \return a pointer to the backend interface. -*/ - -/*! - \fn QString Phonon::Factory::identifier() - - Unique identifier for the Backend. Can be used in configuration files - for example. -*/ - - -/*! - \fn QString Phonon::Factory::backendName() - - Get the name of the Backend. - \omit - It's the name from the .desktop file. - \endomit -*/ - -/*! - \fn QString Phonon::Factory::backendComment() - - Get the comment of the Backend. - \omit - It's the comment from the .desktop file. - \endomit -*/ - -/*! - \fn QString Phonon::Factory::backendVersion() - - Get the version of the Backend. - \omit - It's the version from the .desktop file. - \endomit - - The version is especially interesting if there are several versions - available for binary incompatible versions of the backend's media - framework. -*/ - -/*! - \fn QString Phonon::Factory::backendIcon() - - Get the icon (name) of the Backend. - \omit - It's the icon from the .desktop file. - \endomit -*/ - -/*! - \fn QString Phonon::Factory::backendWebsite() - - Get the website of the Backend. - \omit - It's the website from the .desktop file. - \endomit -*/ - -/*! - \fn QObject *Phonon::Factory::registerQObject(QObject *object) - - Registers the given backend \a object with the factory. -*/ - -/*! - \fn bool Phonon::Factory::isMimeTypeAvailable(const QString &mimeType) -*/ - -/*! - \fn void Phonon::Factory::registerFrontendObject(MediaNodePrivate *) - \internal -*/ - -/*! - \fn void Phonon::Factory::deregisterFrontendObject(MediaNodePrivate *) - \internal -*/ - -/*! - \fn void Phonon::Factory::setBackend(QObject *) -*/ - -/*! - \fn PlatformPlugin *Phonon::Factory::platformPlugin() -*/ - -/*! -/*! - \class Phonon::AbstractMediaStreamPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::FrontendInterfacePrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::EffectWidgetPrivate - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::IODeviceStream - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \fn explicit Phonon::IODeviceStream::IODeviceStream(QIODevice *ioDevice, QObject *parent = 0) - \internal - - Creates a new IODeviceStream with the given \a ioDevice and \a - parent. - -*/ - -/*! - \fn Phonon::IODeviceStream::~IODeviceStream() - \internal -*/ - -/*! - \fn void Phonon::IODeviceStream::reset() - \internal -*/ - -/*! - \fn void Phonon::IODeviceStream::needData() - \internal -*/ - -/*! - \fn void Phonon::IODeviceStream::seekStream(qint64) - \internal -*/ - -/*! - \namespace Phonon::Platform - \inmodule Phonon - \internal -*/ - -/*! - \typedef Phonon::EffectDescriptionModel - \inmodule Phonon - \brief provides a item view model containing available audio effects. - -*/ - -/*! - \typedef Phonon::SubtitleDescription - \inmodule Phonon - \internal -*/ - -/*! - \typedef Phonon::SubtitleDescriptionModel - \inmodule Phonon - \internal -*/ - -/*! - \typedef Phonon::AudioChannelDescription - \inmodule Phonon - \internal -*/ - -/*! - \typedef Phonon::AudioChannelDescriptionModel - \inmodule Phonon - \internal -*/ - -/*! - \typedef Phonon::AudioCaptureDevice - \inmodule Phonon - \internal -*/ - -/*! - \typedef Phonon::AudioCaptureDeviceModel - \inmodule Phonon - \internal -*/ - -/*! - \typedef Phonon::CleanUpFunction - \inmodule Phonon - \internal -*/ - -/*! - \typedef Phonon::QObjectPair - \inmodule Phonon - \since 4.4 - \internal - -*/ - -/*! - \typedef Phonon::AudioOutputDeviceModel - \inmodule Phonon - \brief provides an item view model containing available audio output devices. - -*/ - -/*! - \fn uint Phonon::qHash(const Phonon::EffectParameter ¶m) - \internal - -*/ - -/*! - \fn Phonon::CleanUpGlobalStatic::~CleanUpGlobalStatic() - \internal -*/ - -/*! - \class Phonon::ConstIface - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::CleanUpGlobalStatic - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class Phonon::EffectParameterPrivate - \inmodule Phonon - \since 4.4 - \internal - -*/ - -/*! - \class Phonon::QSettingsGroup - \inmodule Phonon - \since 4.4 - \internal - -*/ - -/*! - \class Phonon::MediaNodeDestructionHandler - \inmodule Phonon - \since 4.4 - \internal - -*/ - -/*! - \fn Phonon::MediaNodeDestructionHandler::~MediaNodeDestructionHandler() - \internal - Called from Base::~Base if this object was registered - using BasePrivate::addDestructionHandler(). -*/ - -/*! - \fn Phonon::MediaNodeDestructionHandler::phononObjectDestroyed(MediaNodePrivate *) - \internal -*/ - -/*! - \fn explicit Phonon::EffectWidget::EffectWidget(Effect *effect, QWidget *parent = 0) - \internal - - Constructs a new EffectWidget for the specified \a effect and with - the specified \a parent. -*/ - -/*! - \fn Phonon::EffectWidget::~EffectWidget() - \internal -*/ - -/*! - \fn QDebug Phonon::operator<<(QDebug s, const ObjectDescription &o) - \internal -*/ - -/*! - \class Phonon::ListModelHelper - \inmodule Phonon - \since 4.4 - \internal -*/ - -/*! - \class AudioOutputInterface42 - \inmodule Phonon - \since 4.4 - \internal -*/ - diff --git a/doc/src/q3asciicache.qdoc b/doc/src/q3asciicache.qdoc deleted file mode 100644 index 43537cc..0000000 --- a/doc/src/q3asciicache.qdoc +++ /dev/null @@ -1,465 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3AsciiCache - \brief The Q3AsciiCache class is a template class that provides a cache based on char* keys. - \compat - - Q3AsciiCache is implemented as a template class. Define a template - instance Q3AsciiCache\ to create a cache that operates on - pointers to X (X*). - - A cache is a least recently used (LRU) list of cache items. The - cache items are accessed via \c char* keys. For Unicode keys use - the Q3Cache template instead, which uses QString keys. A Q3Cache - has the same performace as a Q3AsciiCache. - - Each cache item has a cost. The sum of item costs, totalCost(), - will not exceed the maximum cache cost, maxCost(). If inserting a - new item would cause the total cost to exceed the maximum cost, - the least recently used items in the cache are removed. - - Apart from insert(), by far the most important function is find() - (which also exists as operator[]()). This function looks up an - item, returns it, and by default marks it as being the most - recently used item. - - There are also methods to remove() or take() an object from the - cache. Calling \link Q3PtrCollection::setAutoDelete() - setAutoDelete(TRUE)\endlink tells the cache to delete items that - are removed. The default is to not delete items when then are - removed (i.e., remove() and take() are equivalent). - - When inserting an item into the cache, only the pointer is copied, - not the item itself. This is called a shallow copy. It is possible - to make the cache copy all of the item's data (known as a deep - copy) when an item is inserted. insert() calls the virtual - function Q3PtrCollection::newItem() for the item to be inserted. - Inherit a cache and reimplement newItem() if you want deep copies. - - When removing a cache item the virtual function - Q3PtrCollection::deleteItem() is called. Its default implementation - in Q3AsciiCache is to delete the item if \link - Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. - - There is a Q3AsciiCacheIterator which may be used to traverse the - items in the cache in arbitrary order. - - \sa Q3AsciiCacheIterator, Q3Cache, Q3IntCache -*/ - -/*! - \fn Q3AsciiCache::Q3AsciiCache( const Q3AsciiCache &c ) - - \internal - - Do not use. A Q3AsciiCache cannot be copied. Calls qFatal() in debug version. -*/ - - -/*! - \fn Q3AsciiCache::Q3AsciiCache( int maxCost, int size, bool caseSensitive, bool copyKeys ) - - Constructs a cache whose contents will never have a total cost - greater than \a maxCost and which is expected to contain less than - \a size items. - - \a size is actually the size of an internal hash array; it's - usually best to make it prime and at least 50% bigger than the - largest expected number of items in the cache. - - Each inserted item has an associated cost. When inserting a new - item, if the total cost of all items in the cache will exceed \a - maxCost, the cache will start throwing out the older (least - recently used) items until there is enough room for the new item - to be inserted. - - If \a caseSensitive is TRUE (the default), the cache keys are case - sensitive; if it is FALSE, they are case-insensitive. - Case-insensitive comparison only affects the 26 letters in - US-ASCII. If \a copyKeys is TRUE (the default), Q3AsciiCache makes - a copy of the cache keys, otherwise it copies just the const char - * pointer - slightly faster if you can guarantee that the keys - will never change, but very risky. -*/ - -/*! - \fn Q3AsciiCache::~Q3AsciiCache() - - Removes all items from the cache and destroys it. - All iterators that access this cache will be reset. -*/ - -/*! - \fn Q3AsciiCache& Q3AsciiCache::operator=( const Q3AsciiCache &c ) - - \internal - - Do not use. A Q3AsciiCache cannot be copied. Calls qFatal() in debug version. -*/ - -/*! - \fn int Q3AsciiCache::maxCost() const - - Returns the maximum allowed total cost of the cache. - - \sa setMaxCost() totalCost() -*/ - -/*! - \fn int Q3AsciiCache::totalCost() const - - Returns the total cost of the items in the cache. This is an - integer in the range 0 to maxCost(). - - \sa setMaxCost() -*/ - -/*! - \fn void Q3AsciiCache::setMaxCost( int m ) - - Sets the maximum allowed total cost of the cache to \a m. If the - current total cost is greater than \a m, some items are removed - immediately. - - \sa maxCost() totalCost() -*/ - -/*! - \fn uint Q3AsciiCache::count() const - - Returns the number of items in the cache. - - \sa totalCost() size() -*/ - -/*! - \fn uint Q3AsciiCache::size() const - - Returns the size of the hash array used to implement the cache. - This should be a bit bigger than count() is likely to be. -*/ - -/*! - \fn bool Q3AsciiCache::isEmpty() const - - Returns TRUE if the cache is empty; otherwise returns FALSE. -*/ - -/*! - \fn bool Q3AsciiCache::insert( const char *k, const type *d, int c, int p ) - - Inserts the item \a d into the cache using key \a k, and with an - associated cost of \a c. Returns TRUE if the item is successfully - inserted. Returns FALSE if the item is not inserted, for example, - if the cost of the item exceeds maxCost(). - - The cache's size is limited, and if the total cost is too high, - Q3AsciiCache will remove old, least recently used items until there - is room for this new item. - - Items with duplicate keys can be inserted. - - The parameter \a p is internal and should be left at the default - value (0). - - \warning If this function returns FALSE, you must delete \a d - yourself. Additionally, be very careful about using \a d after - calling this function, because any other insertions into the - cache, from anywhere in the application or within Qt itself, could - cause the object to be discarded from the cache and the pointer to - become invalid. -*/ - -/*! - \fn bool Q3AsciiCache::remove( const char *k ) - - Removes the item with key \a k and returns TRUE if the item was - present in the cache; otherwise returns FALSE. - - The item is deleted if auto-deletion has been enabled, i.e., if - you have called \link Q3PtrCollection::setAutoDelete() - setAutoDelete(TRUE)\endlink. - - If there are two or more items with equal keys, the one that was - inserted last is removed. - - All iterators that refer to the removed item are set to point to - the next item in the cache's traversal order. - - \sa take(), clear() -*/ - -/*! - \fn type *Q3AsciiCache::take( const char *k ) - - Takes the item associated with \a k out of the cache without - deleting it and returns a pointer to the item taken out, or 0 - if the key does not exist in the cache. - - If there are two or more items with equal keys, the one that was - inserted last is taken. - - All iterators that refer to the taken item are set to point to the - next item in the cache's traversal order. - - \sa remove(), clear() -*/ - -/*! - \fn void Q3AsciiCache::clear() - - Removes all items from the cache, and deletes them if \link - Q3PtrCollection::setAutoDelete() auto-deletion\endlink has been - enabled. - - All cache iterators that operate on this cache are reset. - - \sa remove() take() -*/ - -/*! - \fn type *Q3AsciiCache::find( const char *k, bool ref ) const - - Returns the item with key \a k, or 0 if the key does not exist - in the cache. If \a ref is TRUE (the default), the item is moved - to the front of the least recently used list. - - If there are two or more items with equal keys, the one that was - inserted last is returned. -*/ - -/*! - \fn type *Q3AsciiCache::operator[]( const char *k ) const - - Returns the item with key \a k, or 0 if \a k does not exist in - the cache, and moves the item to the front of the least recently - used list. - - If there are two or more items with equal keys, the one that was - inserted last is returned. - - This is the same as find( k, TRUE ). - - \sa find() -*/ - -/*! - \fn void Q3AsciiCache::statistics() const - - A debug-only utility function. Prints out cache usage, hit/miss, - and distribution information using qDebug(). This function does - nothing in the release library. -*/ - -/*! - \class Q3AsciiCacheIterator - \brief The Q3AsciiCacheIterator class provides an iterator for Q3AsciiCache collections. - \compat - - Note that the traversal order is arbitrary; you are not guaranteed - any particular order. If new objects are inserted into the cache - while the iterator is active, the iterator may or may not see - them. - - Multiple iterators are completely independent, even when they - operate on the same Q3AsciiCache. Q3AsciiCache updates all iterators - that refer an item when that item is removed. - - Q3AsciiCacheIterator provides an operator++() and an operator+=() - to traverse the cache; current() and currentKey() to access the - current cache item and its key. It also provides atFirst() and - atLast(), which return TRUE if the iterator points to the first or - last item in the cache respectively. The isEmpty() function - returns TRUE if the cache is empty; and count() returns the number - of items in the cache. - - Note that atFirst() and atLast() refer to the iterator's arbitrary - ordering, not to the cache's internal least recently used list. - - \sa Q3AsciiCache -*/ - -/*! - \fn Q3AsciiCacheIterator::Q3AsciiCacheIterator( const Q3AsciiCache &cache ) - - Constructs an iterator for \a cache. The current iterator item is - set to point to the first item in the \a cache. -*/ - -/*! - \fn Q3AsciiCacheIterator::Q3AsciiCacheIterator (const Q3AsciiCacheIterator & ci) - - Constructs an iterator for the same cache as \a ci. The new - iterator starts at the same item as ci.current() but moves - independently from there on. -*/ - -/*! - \fn Q3AsciiCacheIterator& Q3AsciiCacheIterator::operator=( const Q3AsciiCacheIterator &ci ) - - Makes this an iterator for the same cache as \a ci. The new - iterator starts at the same item as ci.current(), but moves - independently thereafter. -*/ - -/*! - \fn uint Q3AsciiCacheIterator::count() const - - Returns the number of items in the cache over which this iterator - operates. - - \sa isEmpty() -*/ - -/*! - \fn bool Q3AsciiCacheIterator::isEmpty() const - - Returns TRUE if the cache is empty, i.e. count() == 0; otherwise - returns FALSE. - - \sa count() -*/ - -/*! - \fn bool Q3AsciiCacheIterator::atFirst() const - - Returns TRUE if the iterator points to the first item in the - cache; otherwise returns FALSE. Note that this refers to the - iterator's arbitrary ordering, not to the cache's internal least - recently used list. - - \sa toFirst(), atLast() -*/ - -/*! - \fn bool Q3AsciiCacheIterator::atLast() const - - Returns TRUE if the iterator points to the last item in the cache; - otherwise returns FALSE. Note that this refers to the iterator's - arbitrary ordering, not to the cache's internal least recently - used list. - - \sa toLast(), atFirst() -*/ - -/*! - \fn type *Q3AsciiCacheIterator::toFirst() - - Sets the iterator to point to the first item in the cache and - returns a pointer to the item. - - Sets the iterator to 0 and returns 0 if the cache is empty. - - \sa toLast() isEmpty() -*/ - -/*! - \fn type *Q3AsciiCacheIterator::toLast() - - Sets the iterator to point to the last item in the cache and - returns a pointer to the item. - - Sets the iterator to 0 and returns 0 if the cache is empty. - - \sa toFirst() isEmpty() -*/ - -/*! - \fn Q3AsciiCacheIterator::operator type *() const - - Cast operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *Q3AsciiCacheIterator::current() const - - Returns a pointer to the current iterator item. -*/ - -/*! - \fn const char *Q3AsciiCacheIterator::currentKey() const - - Returns the key for the current iterator item. -*/ - -/*! - \fn type *Q3AsciiCacheIterator::operator()() - - Makes the succeeding item current and returns the original current - item. - - If the current iterator item was the last item in the cache or if - it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3AsciiCacheIterator::operator+=( uint jump ) - - Returns the item \a jump positions after the current item, or 0 - if it is beyond the last item. Makes this the current item. -*/ - -/*! - \fn type *Q3AsciiCacheIterator::operator-=( uint jump ) - - Returns the item \a jump positions before the current item, or 0 - if it is before the first item. Makes this the current item. -*/ - -/*! - \fn type *Q3AsciiCacheIterator::operator++() - - Prefix ++ makes the iterator point to the item just after - current(), and makes that the new current item for the iterator. If - current() was the last item, operator++() returns 0. -*/ - -/*! - \fn type *Q3AsciiCacheIterator::operator--() - - Prefix -- makes the iterator point to the item just before - current(), and makes that the new current item for the iterator. If - current() was the first item, operator--() returns 0. -*/ - diff --git a/doc/src/q3asciidict.qdoc b/doc/src/q3asciidict.qdoc deleted file mode 100644 index 9a51db1..0000000 --- a/doc/src/q3asciidict.qdoc +++ /dev/null @@ -1,416 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3AsciiDict - \brief The Q3AsciiDict class is a template class that provides a dictionary based on char* keys. - \compat - - Q3AsciiDict is implemented as a template class. Define a template - instance Q3AsciiDict\ to create a dictionary that operates on - pointers to X (X*). - - A dictionary is a collection of key-value pairs. The key is a - char* used for insertion, removal and lookup. The value is a - pointer. Dictionaries provide very fast insertion and lookup. - - Q3AsciiDict cannot handle Unicode keys; use the Q3Dict template - instead, which uses QString keys. A Q3Dict has the same - performace as a Q3AsciiDict. - - Example: - \snippet doc/src/snippets/code/doc_src_q3asciidict.qdoc 0 - In this example we use a dictionary to keep track of the line - edits we're using. We insert each line edit into the dictionary - with a unique name and then access the line edits via the - dictionary. See Q3PtrDict, Q3IntDict and Q3Dict. - - See Q3Dict for full details, including the choice of dictionary - size, and how deletions are handled. - - \sa Q3AsciiDictIterator, Q3Dict, Q3IntDict, Q3PtrDict -*/ - - -/*! - \fn Q3AsciiDict::Q3AsciiDict( int size, bool caseSensitive, bool copyKeys ) - - Constructs a dictionary optimized for less than \a size entries. - - We recommend setting \a size to a suitably large prime number (a - bit larger than the expected number of entries). This makes the - hash distribution better and will improve lookup performance. - - When \a caseSensitive is TRUE (the default) Q3AsciiDict treats - "abc" and "Abc" as different keys; when it is FALSE "abc" and - "Abc" are the same. Case-insensitive comparison only considers the - 26 letters in US-ASCII. - - If \a copyKeys is TRUE (the default), the dictionary copies keys - using strcpy(); if it is FALSE, the dictionary just copies the - pointers. -*/ - -/*! - \fn Q3AsciiDict::Q3AsciiDict( const Q3AsciiDict &dict ) - - Constructs a copy of \a dict. - - Each item in \a dict is inserted into this dictionary. Only the - pointers are copied (shallow copy). -*/ - -/*! - \fn Q3AsciiDict::~Q3AsciiDict() - - Removes all items from the dictionary and destroys it. - - The items are deleted if auto-delete is enabled. - - All iterators that access this dictionary will be reset. - - \sa setAutoDelete() -*/ - -/*! - \fn Q3AsciiDict &Q3AsciiDict::operator=(const Q3AsciiDict &dict) - - Assigns \a dict to this dictionary and returns a reference to this - dictionary. - - This dictionary is first cleared and then each item in \a dict is - inserted into this dictionary. Only the pointers are copied - (shallow copy) unless newItem() has been reimplemented(). -*/ - -/*! - \fn uint Q3AsciiDict::count() const - - Returns the number of items in the dictionary. - - \sa isEmpty() -*/ - -/*! - \fn uint Q3AsciiDict::size() const - - Returns the size of the internal hash array (as specified in the - constructor). - - \sa count() -*/ - -/*! - \fn void Q3AsciiDict::resize( uint newsize ) - - Changes the size of the hashtable to \a newsize. The contents of - the dictionary are preserved but all iterators on the dictionary - become invalid. -*/ - -/*! - \fn bool Q3AsciiDict::isEmpty() const - - Returns TRUE if the dictionary is empty, i.e. count() == 0; - otherwise it returns FALSE. - - \sa count() -*/ - -/*! - \fn void Q3AsciiDict::insert( const char *key, const type *item ) - - Inserts the \a key with the \a item into the dictionary. - - Multiple items can have the same key, in which case only the last - item will be accessible using \l operator[](). - - \a item may not be 0. - - \sa replace() -*/ - -/*! - \fn void Q3AsciiDict::replace( const char *key, const type *item ) - - Replaces an item that has a key equal to \a key with \a item. - - If the item does not already exist, it will be inserted. - - \a item may not be 0. - - Equivalent to: - \snippet doc/src/snippets/code/doc_src_q3asciidict.qdoc 1 - - If there are two or more items with equal keys, then the most - recently inserted item will be replaced. - - \sa insert() -*/ - -/*! - \fn bool Q3AsciiDict::remove( const char *key ) - - Removes the item associated with \a key from the dictionary. - Returns TRUE if successful, i.e. if the key existed in the - dictionary; otherwise returns FALSE. - - If there are two or more items with equal keys, then the most - recently inserted item will be removed. - - The removed item is deleted if \link - Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. - - All dictionary iterators that refer to the removed item will be - set to point to the next item in the dictionary traversal order. - - \sa take(), clear(), setAutoDelete() -*/ - -/*! - \fn type *Q3AsciiDict::take( const char *key ) - - Takes the item associated with \a key out of the dictionary - without deleting it (even if \link Q3PtrCollection::setAutoDelete() - auto-deletion\endlink is enabled). - - If there are two or more items with equal keys, then the most - recently inserted item will be taken. - - Returns a pointer to the item taken out, or 0 if the key does not - exist in the dictionary. - - All dictionary iterators that refer to the taken item will be set - to point to the next item in the dictionary traversal order. - - \sa remove(), clear(), setAutoDelete() -*/ - -/*! - \fn void Q3AsciiDict::clear() - - Removes all items from the dictionary. - - The removed items are deleted if \link - Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. - - All dictionary iterators that operate on dictionary are reset. - - \sa remove(), take(), setAutoDelete() -*/ - -/*! - \fn type *Q3AsciiDict::find( const char *key ) const - - Returns the item associated with \a key, or 0 if the key does not - exist in the dictionary. - - This function uses an internal hashing algorithm to optimize - lookup. - - If there are two or more items with equal keys, then the item that - was most recently inserted will be found. - - Equivalent to the [] operator. - - \sa operator[]() -*/ - -/*! - \fn type *Q3AsciiDict::operator[]( const char *key ) const - - Returns the item associated with \a key, or 0 if the key does - not exist in the dictionary. - - This function uses an internal hashing algorithm to optimize - lookup. - - If there are two or more items with equal keys, then the item that - was most recently inserted will be found. - - Equivalent to the find() function. - - \sa find() -*/ - -/*! - \fn void Q3AsciiDict::statistics() const - - Debugging-only function that prints out the dictionary - distribution using qDebug(). -*/ - -/*! - \fn QDataStream& Q3AsciiDict::read( QDataStream &s, - Q3PtrCollection::Item &item ) - - Reads a dictionary item from the stream \a s and returns a - reference to the stream. - - The default implementation sets \a item to 0. - - \sa write() -*/ - -/*! - \fn QDataStream& Q3AsciiDict::write(QDataStream &s, Q3PtrCollection::Item item) const - - Writes a dictionary \a item to the stream \a s and returns a - reference to the stream. - - \sa read() -*/ - -/*! - \class Q3AsciiDictIterator - \brief The Q3AsciiDictIterator class provides an iterator for Q3AsciiDict collections. - \compat - - Q3AsciiDictIterator is implemented as a template class. Define a - template instance Q3AsciiDictIterator\ to create a dictionary - iterator that operates on Q3AsciiDict\ (dictionary of X*). - - Example: - \snippet doc/src/snippets/code/doc_src_q3asciidict.qdoc 2 - In the example we insert some line edits into a dictionary, then - iterate over the dictionary printing the strings associated with - those line edits. - - Note that the traversal order is arbitrary; you are not guaranteed - any particular order. - - Multiple iterators may independently traverse the same dictionary. - A Q3AsciiDict knows about all the iterators that are operating on - the dictionary. When an item is removed from the dictionary, - Q3AsciiDict updates all the iterators that are referring to the - removed item to point to the next item in the (arbitrary) - traversal order. - - \sa Q3AsciiDict -*/ - -/*! - \fn Q3AsciiDictIterator::Q3AsciiDictIterator( const Q3AsciiDict &dict ) - - Constructs an iterator for \a dict. The current iterator item is - set to point on the first item in the \a dict. -*/ - -/*! - \fn Q3AsciiDictIterator::~Q3AsciiDictIterator() - - Destroys the iterator. -*/ - -/*! - \fn uint Q3AsciiDictIterator::count() const - - Returns the number of items in the dictionary this iterator - operates over. - - \sa isEmpty() -*/ - -/*! - \fn bool Q3AsciiDictIterator::isEmpty() const - - Returns TRUE if the dictionary is empty, i.e. count() == 0, - otherwise returns FALSE. - - \sa count() -*/ - -/*! - \fn type *Q3AsciiDictIterator::toFirst() - - Sets the current iterator item to point to the first item in the - dictionary and returns a pointer to the item. If the dictionary is - empty it sets the current item to 0 and returns 0. -*/ - -/*! - \fn Q3AsciiDictIterator::operator type *() const - - Cast operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *Q3AsciiDictIterator::current() const - - Returns a pointer to the current iterator item. -*/ - -/*! - \fn const char *Q3AsciiDictIterator::currentKey() const - - Returns a pointer to the key for the current iterator item. -*/ - -/*! - \fn type *Q3AsciiDictIterator::operator()() - - Makes the succeeding item current and returns the original current - item. - - If the current iterator item was the last item in the dictionary - or if it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3AsciiDictIterator::operator++() - - Prefix ++ makes the succeeding item current and returns the new - current item. - - If the current iterator item was the last item in the dictionary - or if it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3AsciiDictIterator::operator+=( uint jump ) - - Sets the current item to the item \a jump positions after the - current item, and returns a pointer to that item. - - If that item is beyond the last item or if the dictionary is - empty, it sets the current item to 0 and returns 0. -*/ diff --git a/doc/src/q3cache.qdoc b/doc/src/q3cache.qdoc deleted file mode 100644 index d8799b6..0000000 --- a/doc/src/q3cache.qdoc +++ /dev/null @@ -1,461 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3Cache - \brief The Q3Cache class is a template class that provides a cache based on QString keys. - \compat - - A cache is a least recently used (LRU) list of cache items. Each - cache item has a key and a certain cost. The sum of item costs, - totalCost(), never exceeds the maximum cache cost, maxCost(). If - inserting a new item would cause the total cost to exceed the - maximum cost, the least recently used items in the cache are - removed. - - Q3Cache is a template class. Q3Cache\ defines a cache that - operates on pointers to X, or X*. - - Apart from insert(), by far the most important function is find() - (which also exists as operator[]()). This function looks up an - item, returns it, and by default marks it as being the most - recently used item. - - There are also methods to remove() or take() an object from the - cache. Calling setAutoDelete(TRUE) for a cache tells it to delete - items that are removed. The default is to not delete items when - they are removed (i.e., remove() and take() are equivalent). - - When inserting an item into the cache, only the pointer is copied, - not the item itself. This is called a shallow copy. It is possible - to make the cache copy all of the item's data (known as a deep - copy) when an item is inserted. insert() calls the virtual - function Q3PtrCollection::newItem() for the item to be inserted. - Inherit a cache and reimplement newItem() if you want deep copies. - - When removing a cache item, the virtual function - Q3PtrCollection::deleteItem() is called. The default - implementation deletes the item if auto-deletion is enabled, and - does nothing otherwise. - - There is a Q3CacheIterator that can be used to traverse the items - in the cache in arbitrary order. - - In Q3Cache, the cache items are accessed via QString keys, which - are Unicode strings. If you want to use non-Unicode, plain 8-bit - \c char* keys, use the Q3AsciiCache template. A Q3Cache has the - same performance as a Q3AsciiCache. - - \sa Q3CacheIterator, Q3AsciiCache, Q3IntCache -*/ - -/*! - \fn Q3Cache::Q3Cache( const Q3Cache &c ) - - \internal - - Do not use. A Q3Cache cannot be copied. Calls qFatal() in debug version. -*/ - - -/*! - \fn Q3Cache::Q3Cache( int maxCost, int size, bool caseSensitive ) - - Constructs a cache whose contents will never have a total cost - greater than \a maxCost and which is expected to contain less than - \a size items. - - \a size is actually the size of an internal hash array; it's - usually best to make it a prime number and at least 50% bigger - than the largest expected number of items in the cache. - - Each inserted item has an associated cost. When inserting a new - item, if the total cost of all items in the cache will exceed \a - maxCost, the cache will start throwing out the older (least - recently used) items until there is enough room for the new item - to be inserted. - - If \a caseSensitive is TRUE (the default), the cache keys are case - sensitive; if it is FALSE, they are case-insensitive. - Case-insensitive comparison considers all Unicode letters. -*/ - -/*! - \fn Q3Cache::~Q3Cache() - - Removes all items from the cache and destroys it. All iterators - that access this cache will be reset. -*/ - -/*! - \fn Q3Cache& Q3Cache::operator=( const Q3Cache &c ) - - \internal - - Do not use. A Q3Cache cannot be copied. Calls qFatal() in debug version. -*/ - -/*! - \fn int Q3Cache::maxCost() const - - Returns the maximum allowed total cost of the cache. - - \sa setMaxCost() totalCost() -*/ - -/*! - \fn int Q3Cache::totalCost() const - - Returns the total cost of the items in the cache. This is an - integer in the range 0 to maxCost(). - - \sa setMaxCost() -*/ - -/*! - \fn void Q3Cache::setMaxCost( int m ) - - Sets the maximum allowed total cost of the cache to \a m. If the - current total cost is greater than \a m, some items are deleted - immediately. - - \sa maxCost() totalCost() -*/ - -/*! - \fn uint Q3Cache::count() const - - Returns the number of items in the cache. - - \sa totalCost() -*/ - -/*! - \fn uint Q3Cache::size() const - - Returns the size of the hash array used to implement the cache. - This should be a bit bigger than count() is likely to be. -*/ - -/*! - \fn bool Q3Cache::isEmpty() const - - Returns TRUE if the cache is empty; otherwise returns FALSE. -*/ - -/*! - \fn bool Q3Cache::insert( const QString &k, const type *d, int c, int p ) - - Inserts the item \a d into the cache with key \a k and associated - cost, \a c. Returns TRUE if it is successfully inserted; otherwise - returns FALSE. - - The cache's size is limited, and if the total cost is too high, - Q3Cache will remove old, least recently used items until there is - room for this new item. - - The parameter \a p is internal and should be left at the default - value (0). - - \warning If this function returns FALSE (which could happen, e.g. - if the cost of this item alone exceeds maxCost()) you must delete - \a d yourself. Additionally, be very careful about using \a d - after calling this function because any other insertions into the - cache, from anywhere in the application or within Qt itself, could - cause the object to be discarded from the cache and the pointer to - become invalid. -*/ - -/*! - \fn bool Q3Cache::remove( const QString &k ) - - Removes the item associated with \a k, and returns TRUE if the - item was present in the cache; otherwise returns FALSE. - - The item is deleted if auto-deletion has been enabled, i.e., if - you have called setAutoDelete(TRUE). - - If there are two or more items with equal keys, the one that was - inserted last is removed. - - All iterators that refer to the removed item are set to point to - the next item in the cache's traversal order. - - \sa take(), clear() -*/ - -/*! - \fn type *Q3Cache::take( const QString &k ) - - Takes the item associated with \a k out of the cache without - deleting it, and returns a pointer to the item taken out, or 0 - if the key does not exist in the cache. - - If there are two or more items with equal keys, the one that was - inserted last is taken. - - All iterators that refer to the taken item are set to point to the - next item in the cache's traversal order. - - \sa remove(), clear() -*/ - -/*! - \fn void Q3Cache::clear() - - Removes all items from the cache and deletes them if auto-deletion - has been enabled. - - All cache iterators that operate this on cache are reset. - - \sa remove() take() -*/ - -/*! - \fn type *Q3Cache::find( const QString &k, bool ref ) const - - Returns the item associated with key \a k, or 0 if the key does - not exist in the cache. If \a ref is TRUE (the default), the item - is moved to the front of the least recently used list. - - If there are two or more items with equal keys, the one that was - inserted last is returned. -*/ - -/*! - \fn type *Q3Cache::operator[]( const QString &k ) const - - Returns the item associated with key \a k, or 0 if \a k does not - exist in the cache, and moves the item to the front of the least - recently used list. - - If there are two or more items with equal keys, the one that was - inserted last is returned. - - This is the same as find( k, TRUE ). - - \sa find() -*/ - -/*! - \fn void Q3Cache::statistics() const - - A debug-only utility function. Prints out cache usage, hit/miss, - and distribution information using qDebug(). This function does - nothing in the release library. -*/ - -/***************************************************************************** - Q3CacheIterator documentation - *****************************************************************************/ - -/*! - \class Q3CacheIterator qcache.h - \brief The Q3CacheIterator class provides an iterator for Q3Cache collections. - \compat - - Note that the traversal order is arbitrary; you are not guaranteed - any particular order. If new objects are inserted into the cache - while the iterator is active, the iterator may or may not see - them. - - Multiple iterators are completely independent, even when they - operate on the same Q3Cache. Q3Cache updates all iterators that - refer an item when that item is removed. - - Q3CacheIterator provides an operator++(), and an operator+=() to - traverse the cache. The current() and currentKey() functions are - used to access the current cache item and its key. The atFirst() - and atLast() return TRUE if the iterator points to the first or - last item in the cache respectively. The isEmpty() function - returns TRUE if the cache is empty, and count() returns the number - of items in the cache. - - Note that atFirst() and atLast() refer to the iterator's arbitrary - ordering, not to the cache's internal least recently used list. - - \sa Q3Cache -*/ - -/*! - \fn Q3CacheIterator::Q3CacheIterator( const Q3Cache &cache ) - - Constructs an iterator for \a cache. The current iterator item is - set to point to the first item in the \a cache. -*/ - -/*! - \fn Q3CacheIterator::Q3CacheIterator (const Q3CacheIterator & ci) - - Constructs an iterator for the same cache as \a ci. The new - iterator starts at the same item as ci.current(), but moves - independently from there on. -*/ - -/*! - \fn Q3CacheIterator& Q3CacheIterator::operator=( const Q3CacheIterator &ci ) - - Makes this an iterator for the same cache as \a ci. The new - iterator starts at the same item as ci.current(), but moves - independently thereafter. -*/ - -/*! - \fn uint Q3CacheIterator::count() const - - Returns the number of items in the cache on which this iterator - operates. - - \sa isEmpty() -*/ - -/*! - \fn bool Q3CacheIterator::isEmpty() const - - Returns TRUE if the cache is empty, i.e. count() == 0; otherwise - it returns FALSE. - - \sa count() -*/ - -/*! - \fn bool Q3CacheIterator::atFirst() const - - Returns TRUE if the iterator points to the first item in the - cache; otherwise returns FALSE. Note that this refers to the - iterator's arbitrary ordering, not to the cache's internal least - recently used list. - - \sa toFirst(), atLast() -*/ - -/*! - \fn bool Q3CacheIterator::atLast() const - - Returns TRUE if the iterator points to the last item in the cache; - otherwise returns FALSE. Note that this refers to the iterator's - arbitrary ordering, not to the cache's internal least recently - used list. - - \sa toLast(), atFirst() -*/ - -/*! - \fn type *Q3CacheIterator::toFirst() - - Sets the iterator to point to the first item in the cache and - returns a pointer to the item. - - Sets the iterator to 0 and returns 0 if the cache is empty. - - \sa toLast() isEmpty() -*/ - -/*! - \fn type *Q3CacheIterator::toLast() - - Sets the iterator to point to the last item in the cache and - returns a pointer to the item. - - Sets the iterator to 0 and returns 0 if the cache is empty. - - \sa toFirst() isEmpty() -*/ - -/*! - \fn Q3CacheIterator::operator type *() const - - Cast operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *Q3CacheIterator::current() const - - Returns a pointer to the current iterator item. -*/ - -/*! - \fn QString Q3CacheIterator::currentKey() const - - Returns the key for the current iterator item. -*/ - -/*! - \fn type *Q3CacheIterator::operator()() - - Makes the succeeding item current and returns the original current - item. - - If the current iterator item was the last item in the cache or if - it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3CacheIterator::operator+=( uint jump ) - - Returns the item \a jump positions after the current item, or 0 if - it is beyond the last item. Makes this the current item. -*/ - -/*! - \fn type *Q3CacheIterator::operator-=( uint jump ) - - Returns the item \a jump positions before the current item, or 0 - if it is before the first item. Makes this the current item. -*/ - -/*! - \fn type *Q3CacheIterator::operator++() - - Prefix++ makes the iterator point to the item just after current() - and makes that the new current item for the iterator. If current() - was the last item, operator++() returns 0. -*/ - -/*! - \fn type *Q3CacheIterator::operator--() - - Prefix-- makes the iterator point to the item just before - current() and makes that the new current item for the iterator. If - current() was the first item, operator--() returns 0. -*/ - diff --git a/doc/src/q3dict.qdoc b/doc/src/q3dict.qdoc deleted file mode 100644 index 0e6d51d..0000000 --- a/doc/src/q3dict.qdoc +++ /dev/null @@ -1,446 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3Dict - \brief The Q3Dict class is a template class that provides a - dictionary based on QString keys. - \compat - - Q3Dict is implemented as a template class. Define a template - instance Q3Dict\ to create a dictionary that operates on - pointers to X (X *). - - A dictionary is a collection of key-value pairs. The key is a - QString used for insertion, removal and lookup. The value is a - pointer. Dictionaries provide very fast insertion and lookup. - - If you want to use non-Unicode, plain 8-bit \c char* keys, use the - Q3AsciiDict template. A Q3Dict has the same performance as a - Q3AsciiDict. If you want to have a dictionary that maps QStrings to - QStrings use QMap. - - The size() of the dictionary is very important. In order to get - good performance, you should use a suitably large prime number. - Suitable means equal to or larger than the maximum expected number - of dictionary items. Size is set in the constructor but may be - changed with resize(). - - Items are inserted with insert(); 0 pointers cannot be inserted. - Items are removed with remove(). All the items in a dictionary can - be removed with clear(). The number of items in the dictionary is - returned by count(). If the dictionary contains no items isEmpty() - returns TRUE. You can change an item's value with replace(). Items - are looked up with operator[](), or with find() which return a - pointer to the value or 0 if the given key does not exist. You can - take an item out of the dictionary with take(). - - Calling setAutoDelete(TRUE) for a dictionary tells it to delete - items that are removed. The default behavior is not to delete - items when they are removed. - - When an item is inserted, the key is converted (hashed) to an - integer index into an internal hash array. This makes lookup very - fast. - - Items with equal keys are allowed. When inserting two items with - the same key, only the last inserted item will be accessible (last - in, first out) until it is removed. - - The Q3DictIterator class can traverse the dictionary, but only in - an arbitrary order. Multiple iterators may independently traverse - the same dictionary. - - When inserting an item into a dictionary, only the pointer is - copied, not the item itself, i.e. a shallow copy is made. It is - possible to make the dictionary copy all of the item's data (a - deep copy) when an item is inserted. insert() calls the virtual - function Q3PtrCollection::newItem() for the item to be inserted. - Inherit a dictionary and reimplement newItem() if you want deep - copies. - - When removing a dictionary item, the virtual function - Q3PtrCollection::deleteItem() is called. Q3Dict's default - implementation is to delete the item if auto-deletion is enabled. - - \sa Q3DictIterator, Q3AsciiDict, Q3IntDict, Q3PtrDict -*/ - - -/*! - \fn Q3Dict::Q3Dict( int size, bool caseSensitive ) - - Constructs a dictionary optimized for less than \a size entries. - - We recommend setting \a size to a suitably large prime number - (e.g. a prime that's slightly larger than the expected number of - entries). This makes the hash distribution better which will lead - to faster lookup. - - If \a caseSensitive is TRUE (the default), keys which differ only - by case are considered different. -*/ - -/*! - \fn Q3Dict::Q3Dict( const Q3Dict &dict ) - - Constructs a copy of \a dict. - - Each item in \a dict is inserted into this dictionary. Only the - pointers are copied (shallow copy). -*/ - -/*! - \fn Q3Dict::~Q3Dict() - - Removes all items from the dictionary and destroys it. If - setAutoDelete() is TRUE, each value is deleted. All iterators that - access this dictionary will be reset. - - \sa setAutoDelete() -*/ - -/*! - \fn Q3Dict &Q3Dict::operator=(const Q3Dict &dict) - - Assigns \a dict to this dictionary and returns a reference to this - dictionary. - - This dictionary is first cleared, then each item in \a dict is - inserted into this dictionary. Only the pointers are copied - (shallow copy), unless newItem() has been reimplemented. -*/ - -/*! - \fn uint Q3Dict::count() const - - Returns the number of items in the dictionary. - - \sa isEmpty() -*/ - -/*! - \fn uint Q3Dict::size() const - - Returns the size of the internal hash array (as specified in the - constructor). - - \sa count() -*/ - -/*! - \fn void Q3Dict::resize( uint newsize ) - - Changes the size of the hash table to \a newsize. The contents of - the dictionary are preserved, but all iterators on the dictionary - become invalid. -*/ - -/*! - \fn bool Q3Dict::isEmpty() const - - Returns TRUE if the dictionary is empty, i.e. count() == 0; - otherwise returns FALSE. - - \sa count() -*/ - -/*! - \fn void Q3Dict::insert( const QString &key, const type *item ) - - Inserts the key \a key with value \a item into the dictionary. - - Multiple items can have the same key, in which case only the last - item will be accessible using \l operator[](). - - \a item may not be 0. - - \sa replace() -*/ - -/*! - \fn void Q3Dict::replace( const QString &key, const type *item ) - - Replaces the value of the key, \a key with \a item. - - If the item does not already exist, it will be inserted. - - \a item may not be 0. - - Equivalent to: - \snippet doc/src/snippets/code/doc_src_q3dict.qdoc 0 - - If there are two or more items with equal keys, then the last item - that was inserted will be replaced. - - \sa insert() -*/ - -/*! - \fn bool Q3Dict::remove( const QString &key ) - - Removes the item with \a key from the dictionary. Returns TRUE if - successful, i.e. if the item is in the dictionary; otherwise - returns FALSE. - - If there are two or more items with equal keys, then the last item - that was inserted will be removed. - - The removed item is deleted if \link - Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. - - All dictionary iterators that refer to the removed item will be - set to point to the next item in the dictionary's traversal order. - - \sa take(), clear(), setAutoDelete() -*/ - -/*! - \fn type *Q3Dict::take( const QString &key ) - - Takes the item with \a key out of the dictionary without deleting - it (even if \link Q3PtrCollection::setAutoDelete() - auto-deletion\endlink is enabled). - - If there are two or more items with equal keys, then the last item - that was inserted will be taken. - - Returns a pointer to the item taken out, or 0 if the key does not - exist in the dictionary. - - All dictionary iterators that refer to the taken item will be set - to point to the next item in the dictionary traversal order. - - \sa remove(), clear(), setAutoDelete() -*/ - -/*! - \fn void Q3Dict::clear() - - Removes all items from the dictionary. - - The removed items are deleted if \link - Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. - - All dictionary iterators that operate on the dictionary are reset. - - \sa remove(), take(), setAutoDelete() -*/ - -/*! - \fn type *Q3Dict::find( const QString &key ) const - - Returns the item with key \a key, or 0 if the key does not exist - in the dictionary. - - If there are two or more items with equal keys, then the most - recently inserted item will be found. - - Equivalent to the [] operator. - - \sa operator[]() -*/ - -/*! - \fn type *Q3Dict::operator[]( const QString &key ) const - - Returns the item with key \a key, or 0 if the key does not - exist in the dictionary. - - If there are two or more items with equal keys, then the most - recently inserted item will be found. - - Equivalent to the find() function. - - \sa find() -*/ - -/*! - \fn void Q3Dict::statistics() const - - Debugging-only function that prints out the dictionary - distribution using qDebug(). -*/ - -/*! - \fn QDataStream& Q3Dict::read( QDataStream &s, Q3PtrCollection::Item &item ) - - Reads a dictionary item from the stream \a s and returns a - reference to the stream. - - The default implementation sets \a item to 0. - - \sa write() -*/ - -/*! - \fn QDataStream& Q3Dict::write( QDataStream &s, Q3PtrCollection::Item item ) const - - Writes a dictionary \a item to the stream \a s and returns a - reference to the stream. - - \sa read() -*/ - -/*! - \class Q3DictIterator - \brief The Q3DictIterator class provides an iterator for Q3Dict collections. - \compat - - Q3DictIterator is implemented as a template class. Define a - template instance Q3DictIterator\ to create a dictionary - iterator that operates on Q3Dict\ (dictionary of X*). - - The traversal order is arbitrary; when we speak of the "first", - "last" and "next" item we are talking in terms of this arbitrary - order. - - Multiple iterators may independently traverse the same dictionary. - A Q3Dict knows about all the iterators that are operating on the - dictionary. When an item is removed from the dictionary, Q3Dict - updates all iterators that are referring to the removed item to - point to the next item in the (arbitrary) traversal order. - - Example: - \snippet doc/src/snippets/code/doc_src_q3dict.qdoc 1 - In the example we insert some pointers to line edits into a - dictionary, then iterate over the dictionary printing the strings - associated with the line edits. - - \sa Q3Dict -*/ - -/*! - \fn Q3DictIterator::Q3DictIterator( const Q3Dict &dict ) - - Constructs an iterator for \a dict. The current iterator item is - set to point to the first item in the dictionary, \a dict. First - in this context means first in the arbitrary traversal order. -*/ - -/*! - \fn Q3DictIterator::~Q3DictIterator() - - Destroys the iterator. -*/ - -/*! - \fn uint Q3DictIterator::count() const - - Returns the number of items in the dictionary over which the - iterator is operating. - - \sa isEmpty() -*/ - -/*! - \fn bool Q3DictIterator::isEmpty() const - - Returns TRUE if the dictionary is empty, i.e. count() == 0; - otherwise returns FALSE. - - \sa count() -*/ - -/*! - \fn type *Q3DictIterator::toFirst() - - Resets the iterator, making the first item the first current item. - First in this context means first in the arbitrary traversal - order. Returns a pointer to this item. - - If the dictionary is empty it sets the current item to 0 and - returns 0. -*/ - -/*! - \fn type *Q3DictIterator::operator*() - \internal -*/ - -/*! - \fn Q3DictIterator::operator type*() const - - Cast operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - - -/*! - \fn type *Q3DictIterator::current() const - - Returns a pointer to the current iterator item's value. -*/ - -/*! - \fn QString Q3DictIterator::currentKey() const - - Returns the current iterator item's key. -*/ - -/*! - \fn type *Q3DictIterator::operator()() - - Makes the next item current and returns the original current item. - - If the current iterator item was the last item in the dictionary - or if it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3DictIterator::operator++() - - Prefix ++ makes the next item current and returns the new current - item. - - If the current iterator item was the last item in the dictionary - or if it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3DictIterator::operator+=( uint jump ) - \internal - Sets the current item to the item \a jump positions after the current item, - and returns a pointer to that item. - - If that item is beyond the last item or if the dictionary is empty, - it sets the current item to 0 and returns 0. -*/ diff --git a/doc/src/q3intcache.qdoc b/doc/src/q3intcache.qdoc deleted file mode 100644 index dfff679..0000000 --- a/doc/src/q3intcache.qdoc +++ /dev/null @@ -1,446 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3IntCache - \brief The Q3IntCache class is a template class that provides a cache based on long keys. - \compat - - Q3IntCache is implemented as a template class. Define a template - instance Q3IntCache\ to create a cache that operates on - pointers to X, or X*. - - A cache is a least recently used (LRU) list of cache items, - accessed via \c long keys. Each cache item has a cost. The sum - of item costs, totalCost(), will not exceed the maximum cache - cost, maxCost(). If inserting a new item would cause the total - cost to exceed the maximum cost, the least recently used items in - the cache are removed. - - Apart from insert(), by far the most important function is find() - (which also exists as operator[]). This function looks up an - item, returns it, and by default marks it as being the most - recently used item. - - There are also methods to remove() or take() an object from the - cache. Calling setAutoDelete(TRUE) for a cache tells it to delete - items that are removed. The default is to not delete items when - they are removed (i.e. remove() and take() are equivalent). - - When inserting an item into the cache, only the pointer is copied, - not the item itself. This is called a shallow copy. It is possible - to make the cache copy all of the item's data (known as a deep - copy) when an item is inserted. insert() calls the virtual - function Q3PtrCollection::newItem() for the item to be inserted. - Inherit a dictionary and reimplement newItem() if you want deep - copies. - - When removing a cache item, the item will be automatically - deleted if auto-deletion is enabled. - - There is a Q3IntCacheIterator which may be used to traverse the - items in the cache in arbitrary order. - - \sa Q3IntCacheIterator, Q3Cache, Q3AsciiCache -*/ - -/*! - \fn Q3IntCache::Q3IntCache( const Q3IntCache &c ) - - \internal - - Do not use. A Q3IntCache cannot be copied. Calls qFatal() in debug version. -*/ - -/*! - \fn Q3IntCache::Q3IntCache( int maxCost, int size ) - - Constructs a cache whose contents will never have a total cost - greater than \a maxCost and which is expected to contain less than - \a size items. - - \a size is actually the size of an internal hash array; it's - usually best to make it prime and at least 50% bigger than the - largest expected number of items in the cache. - - Each inserted item is associated with a cost. When inserting a new - item, if the total cost of all items in the cache will exceed \a - maxCost, the cache will start throwing out the older (least - recently used) items until there is enough room for the new item - to be inserted. -*/ - -/*! - \fn Q3IntCache::~Q3IntCache() - - Removes all items from the cache and then destroys the int cache. - If auto-deletion is enabled the cache's items are deleted. All - iterators that access this cache will be reset. -*/ - -/*! - \fn Q3IntCache& Q3IntCache::operator=( const Q3IntCache &c ) - - \internal - - Do not use. A Q3IntCache cannot be copied. Calls qFatal() in debug version. -*/ - -/*! - \fn int Q3IntCache::maxCost() const - - Returns the maximum allowed total cost of the cache. - - \sa setMaxCost() totalCost() -*/ - -/*! - \fn int Q3IntCache::totalCost() const - - Returns the total cost of the items in the cache. This is an - integer in the range 0 to maxCost(). - - \sa setMaxCost() -*/ - -/*! - \fn void Q3IntCache::setMaxCost( int m ) - - Sets the maximum allowed total cost of the cache to \a m. If the - current total cost is greater than \a m, some items are removed - immediately. - - \sa maxCost() totalCost() -*/ - -/*! - \fn uint Q3IntCache::count() const - - Returns the number of items in the cache. - - \sa totalCost() -*/ - -/*! - \fn uint Q3IntCache::size() const - - Returns the size of the hash array used to implement the cache. - This should be a bit larger than count() is likely to be. -*/ - -/*! - \fn bool Q3IntCache::isEmpty() const - - Returns TRUE if the cache is empty; otherwise returns FALSE. -*/ - -/*! - \fn bool Q3IntCache::insert( long k, const type *d, int c, int p ) - - Inserts the item \a d into the cache with key \a k and assigns it - a cost of \a c (default 1). Returns TRUE if it succeeds; otherwise - returns FALSE. - - The cache's size is limited, and if the total cost is too high, - Q3IntCache will remove old, least-used items until there is room - for this new item. - - The parameter \a p is internal and should be left at the default - value (0). - - \warning If this function returns FALSE (for example, the cost \c, - exceeds maxCost()), you must delete \a d yourself. Additionally, - be very careful about using \a d after calling this function. Any - other insertions into the cache, from anywhere in the application - or within Qt itself, could cause the object to be discarded from - the cache and the pointer to become invalid. -*/ - -/*! - \fn bool Q3IntCache::remove( long k ) - - Removes the item associated with \a k, and returns TRUE if the - item was present in the cache; otherwise returns FALSE. - - The item is deleted if auto-deletion has been enabled, i.e. if you - have called setAutoDelete(TRUE). - - If there are two or more items with equal keys, the one that was - inserted most recently is removed. - - All iterators that refer to the removed item are set to point to - the next item in the cache's traversal order. - - \sa take(), clear() -*/ - -/*! - \fn type * Q3IntCache::take( long k ) - - Takes the item associated with \a k out of the cache without - deleting it, and returns a pointer to the item taken out or 0 if - the key does not exist in the cache. - - If there are two or more items with equal keys, the one that was - inserted most recently is taken. - - All iterators that refer to the taken item are set to point to the - next item in the cache's traversal order. - - \sa remove(), clear() -*/ - -/*! - \fn void Q3IntCache::clear() - - Removes all items from the cache, and deletes them if - auto-deletion has been enabled. - - All cache iterators that operate this on cache are reset. - - \sa remove() take() -*/ - -/*! - \fn type * Q3IntCache::find( long k, bool ref ) const - - Returns the item associated with \a k, or 0 if the key does not - exist in the cache. If \a ref is TRUE (the default), the item is - moved to the front of the least recently used list. - - If there are two or more items with equal keys, the one that was - inserted most recently is returned. -*/ - -/*! - \fn type * Q3IntCache::operator[]( long k ) const - - Returns the item associated with \a k, or 0 if \a k does not exist - in the cache, and moves the item to the front of the least - recently used list. - - If there are two or more items with equal keys, the one that was - inserted most recently is returned. - - This is the same as find( k, TRUE ). - - \sa find() -*/ - -/*! - \fn void Q3IntCache::statistics() const - - A debug-only utility function. Prints out cache usage, hit/miss, - and distribution information using qDebug(). This function does - nothing in the release library. -*/ - -/*! - \class Q3IntCacheIterator - \brief The Q3IntCacheIterator class provides an iterator for Q3IntCache collections. - \compat - - Note that the traversal order is arbitrary; you are not guaranteed - any particular order. If new objects are inserted into the cache - while the iterator is active, the iterator may or may not see - them. - - Multiple iterators are completely independent, even when they - operate on the same Q3IntCache. Q3IntCache updates all iterators - that refer an item when that item is removed. - - Q3IntCacheIterator provides an operator++(), and an operator+=() to - traverse the cache; current() and currentKey() to access the - current cache item and its key; atFirst() atLast(), which return - TRUE if the iterator points to the first/last item in the cache; - isEmpty(), which returns TRUE if the cache is empty; and count(), - which returns the number of items in the cache. - - Note that atFirst() and atLast() refer to the iterator's arbitrary - ordering, not to the cache's internal least recently used list. - - \sa Q3IntCache -*/ - -/*! - \fn Q3IntCacheIterator::Q3IntCacheIterator( const Q3IntCache &cache ) - - Constructs an iterator for \a cache. The current iterator item is - set to point to the first item in the \a cache (or rather, the - first item is defined to be the item at which this constructor - sets the iterator to point). -*/ - -/*! - \fn Q3IntCacheIterator::Q3IntCacheIterator (const Q3IntCacheIterator & ci) - - Constructs an iterator for the same cache as \a ci. The new - iterator starts at the same item as ci.current(), but moves - independently from there on. -*/ - -/*! - \fn Q3IntCacheIterator& Q3IntCacheIterator::operator=( const Q3IntCacheIterator &ci ) - - Makes this an iterator for the same cache as \a ci. The new - iterator starts at the same item as ci.current(), but moves - independently thereafter. -*/ - -/*! - \fn uint Q3IntCacheIterator::count() const - - Returns the number of items in the cache on which this iterator - operates. - - \sa isEmpty() -*/ - -/*! - \fn bool Q3IntCacheIterator::isEmpty() const - - Returns TRUE if the cache is empty; otherwise returns FALSE. - - \sa count() -*/ - -/*! - \fn bool Q3IntCacheIterator::atFirst() const - - Returns TRUE if the iterator points to the first item in the - cache; otherwise returns FALSE. Note that this refers to the - iterator's arbitrary ordering, not to the cache's internal least - recently used list. - - \sa toFirst(), atLast() -*/ - -/*! - \fn bool Q3IntCacheIterator::atLast() const - - Returns TRUE if the iterator points to the last item in the cache; - otherwise returns FALSE. Note that this refers to the iterator's - arbitrary ordering, not to the cache's internal least recently - used list. - - \sa toLast(), atFirst() -*/ - -/*! - \fn type *Q3IntCacheIterator::toFirst() - - Sets the iterator to point to the first item in the cache and - returns a pointer to the item. - - Sets the iterator to 0, and returns 0, if the cache is empty. - - \sa toLast() isEmpty() -*/ - -/*! - \fn type *Q3IntCacheIterator::toLast() - - Sets the iterator to point to the last item in the cache and - returns a pointer to the item. - - Sets the iterator to 0, and returns 0, if the cache is empty. - - \sa toFirst() isEmpty() -*/ - -/*! - \fn Q3IntCacheIterator::operator type *() const - - Cast operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *Q3IntCacheIterator::current() const - - Returns a pointer to the current iterator item. -*/ - -/*! - \fn long Q3IntCacheIterator::currentKey() const - - Returns the key for the current iterator item. -*/ - -/*! - \fn type *Q3IntCacheIterator::operator()() - - Makes the succeeding item current and returns the original current - item. - - If the current iterator item was the last item in the cache or if - it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3IntCacheIterator::operator+=( uint jump ) - - Returns the item \a jump positions after the current item, or 0 if - it is beyond the last item. Makes this the current item. -*/ - -/*! - \fn type *Q3IntCacheIterator::operator-=( uint jump ) - - Returns the item \a jump positions before the current item, or 0 - if it is beyond the first item. Makes this the current item. -*/ - -/*! - \fn type *Q3IntCacheIterator::operator++() - - Prefix ++ makes the iterator point to the item just after - current(), and makes it the new current item for the iterator. If - current() was the last item, operator--() returns 0. -*/ - -/*! - \fn type *Q3IntCacheIterator::operator--() - - Prefix -- makes the iterator point to the item just before - current(), and makes it the new current item for the iterator. If - current() was the first item, operator--() returns 0. -*/ diff --git a/doc/src/q3intdict.qdoc b/doc/src/q3intdict.qdoc deleted file mode 100644 index cef2e79..0000000 --- a/doc/src/q3intdict.qdoc +++ /dev/null @@ -1,390 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3IntDict - \brief The Q3IntDict class is a template class that provides a dictionary based on long keys.\ - \compat - - Q3IntDict is implemented as a template class. Define a template - instance Q3IntDict\ to create a dictionary that operates on - pointers to X (X*). - - A dictionary is a collection of key-value pairs. The key is an \c - long used for insertion, removal and lookup. The value is a - pointer. Dictionaries provide very fast insertion and lookup. - - Example: - \snippet doc/src/snippets/code/doc_src_q3intdict.qdoc 0 - - See Q3Dict for full details, including the choice of dictionary - size, and how deletions are handled. - - \sa Q3IntDictIterator, Q3Dict, Q3AsciiDict, Q3PtrDict -*/ - - -/*! - \fn Q3IntDict::Q3IntDict( int size ) - - Constructs a dictionary using an internal hash array of size \a - size. - - Setting \a size to a suitably large prime number (equal to or - greater than the expected number of entries) makes the hash - distribution better which leads to faster lookup. -*/ - -/*! - \fn Q3IntDict::Q3IntDict( const Q3IntDict &dict ) - - Constructs a copy of \a dict. - - Each item in \a dict is inserted into this dictionary. Only the - pointers are copied (shallow copy). -*/ - -/*! - \fn Q3IntDict::~Q3IntDict() - - Removes all items from the dictionary and destroys it. - - All iterators that access this dictionary will be reset. - - \sa setAutoDelete() -*/ - -/*! - \fn Q3IntDict &Q3IntDict::operator=(const Q3IntDict &dict) - - Assigns \a dict to this dictionary and returns a reference to this - dictionary. - - This dictionary is first cleared and then each item in \a dict is - inserted into this dictionary. Only the pointers are copied - (shallow copy), unless newItem() has been reimplemented. -*/ - -/*! - \fn uint Q3IntDict::count() const - - Returns the number of items in the dictionary. - - \sa isEmpty() -*/ - -/*! - \fn uint Q3IntDict::size() const - - Returns the size of the internal hash array (as specified in the - constructor). - - \sa count() -*/ - -/*! - \fn void Q3IntDict::resize( uint newsize ) - - Changes the size of the hashtable to \a newsize. The contents of - the dictionary are preserved, but all iterators on the dictionary - become invalid. -*/ - -/*! - \fn bool Q3IntDict::isEmpty() const - - Returns TRUE if the dictionary is empty; otherwise returns FALSE. - - \sa count() -*/ - -/*! - \fn void Q3IntDict::insert( long key, const type *item ) - - Insert item \a item into the dictionary using key \a key. - - Multiple items can have the same key, in which case only the last - item will be accessible using \l operator[](). - - \a item may not be 0. - - \sa replace() -*/ - -/*! - \fn void Q3IntDict::replace( long key, const type *item ) - - If the dictionary has key \a key, this key's item is replaced with - \a item. If the dictionary doesn't contain key \a key, \a item is - inserted into the dictionary using key \a key. - - \a item may not be 0. - - Equivalent to: - \snippet doc/src/snippets/code/doc_src_q3intdict.qdoc 1 - - If there are two or more items with equal keys, then the most - recently inserted item will be replaced. - - \sa insert() -*/ - -/*! - \fn bool Q3IntDict::remove( long key ) - - Removes the item associated with \a key from the dictionary. - Returns TRUE if successful, i.e. if the \a key is in the - dictionary; otherwise returns FALSE. - - If there are two or more items with equal keys, then the most - recently inserted item will be removed. - - The removed item is deleted if \link - Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. - - All dictionary iterators that refer to the removed item will be - set to point to the next item in the dictionary's traversal - order. - - \sa take(), clear(), setAutoDelete() -*/ - -/*! - \fn type *Q3IntDict::take( long key ) - - Takes the item associated with \a key out of the dictionary - without deleting it (even if \link Q3PtrCollection::setAutoDelete() - auto-deletion\endlink is enabled). - - If there are two or more items with equal keys, then the most - recently inserted item will be taken. - - Returns a pointer to the item taken out, or 0 if the key does not - exist in the dictionary. - - All dictionary iterators that refer to the taken item will be set - to point to the next item in the dictionary's traversing order. - - \sa remove(), clear(), setAutoDelete() -*/ - -/*! - \fn void Q3IntDict::clear() - - Removes all items from the dictionary. - - The removed items are deleted if \link - Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. - - All dictionary iterators that access this dictionary will be reset. - - \sa remove(), take(), setAutoDelete() -*/ - -/*! - \fn type *Q3IntDict::find( long key ) const - - Returns the item associated with \a key, or 0 if the key does not - exist in the dictionary. - - If there are two or more items with equal keys, then the most - recently inserted item will be found. - - Equivalent to operator[]. - - \sa operator[]() -*/ - -/*! - \fn type *Q3IntDict::operator[]( long key ) const - - Returns the item associated with \a key, or 0 if the key does not - exist in the dictionary. - - If there are two or more items with equal keys, then the most - recently inserted item will be found. - - Equivalent to the find() function. - - \sa find() -*/ - -/*! - \fn void Q3IntDict::statistics() const - - Debugging-only function that prints out the dictionary - distribution using qDebug(). -*/ - -/*! - \fn QDataStream& Q3IntDict::read( QDataStream &s, Q3PtrCollection::Item &item ) - - Reads a dictionary item from the stream \a s and returns a - reference to the stream. - - The default implementation sets \a item to 0. - - \sa write() -*/ - -/*! - \fn QDataStream& Q3IntDict::write( QDataStream &s, Q3PtrCollection::Item item ) const - - Writes a dictionary \a item to the stream \a s and returns a - reference to the stream. - - \sa read() -*/ - -/*! - \class Q3IntDictIterator - \brief The Q3IntDictIterator class provides an iterator for Q3IntDict collections. - \compat - - Q3IntDictIterator is implemented as a template class. Define a - template instance Q3IntDictIterator\ to create a dictionary - iterator that operates on Q3IntDict\ (dictionary of X*). - - Example: - \snippet doc/src/snippets/code/doc_src_q3intdict.qdoc 2 - - Note that the traversal order is arbitrary; you are not guaranteed the - order shown above. - - Multiple iterators may independently traverse the same dictionary. - A Q3IntDict knows about all the iterators that are operating on the - dictionary. When an item is removed from the dictionary, Q3IntDict - updates all iterators that refer the removed item to point to the - next item in the traversal order. - - \sa Q3IntDict -*/ - -/*! - \fn Q3IntDictIterator::Q3IntDictIterator( const Q3IntDict &dict ) - - Constructs an iterator for \a dict. The current iterator item is - set to point to the 'first' item in the \a dict. The first item - refers to the first item in the dictionary's arbitrary internal - ordering. -*/ - -/*! - \fn Q3IntDictIterator::~Q3IntDictIterator() - - Destroys the iterator. -*/ - -/*! - \fn uint Q3IntDictIterator::count() const - - Returns the number of items in the dictionary this iterator - operates over. - - \sa isEmpty() -*/ - -/*! - \fn bool Q3IntDictIterator::isEmpty() const - - Returns TRUE if the dictionary is empty; otherwise eturns FALSE. - - \sa count() -*/ - -/*! - \fn type *Q3IntDictIterator::toFirst() - - Sets the current iterator item to point to the first item in the - dictionary and returns a pointer to the item. The first item - refers to the first item in the dictionary's arbitrary internal - ordering. If the dictionary is empty it sets the current item to - 0 and returns 0. -*/ - -/*! - \fn Q3IntDictIterator::operator type *() const - - Cast operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *Q3IntDictIterator::current() const - - Returns a pointer to the current iterator item. -*/ - -/*! - \fn long Q3IntDictIterator::currentKey() const - - Returns the key for the current iterator item. -*/ - -/*! - \fn type *Q3IntDictIterator::operator()() - - Makes the succeeding item current and returns the original current - item. - - If the current iterator item was the last item in the dictionary - or if it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3IntDictIterator::operator++() - - Prefix ++ makes the succeeding item current and returns the new - current item. - - If the current iterator item was the last item in the dictionary - or if it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3IntDictIterator::operator+=( uint jump ) - - Sets the current item to the item \a jump positions after the - current item, and returns a pointer to that item. - - If that item is beyond the last item or if the dictionary is - empty, it sets the current item to 0 and returns 0. -*/ diff --git a/doc/src/q3memarray.qdoc b/doc/src/q3memarray.qdoc deleted file mode 100644 index b9c1f73..0000000 --- a/doc/src/q3memarray.qdoc +++ /dev/null @@ -1,523 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3MemArray - \brief The Q3MemArray class is a template class that provides arrays of simple types. - \compat - - Q3MemArray is implemented as a template class. Define a template - instance Q3MemArray\ to create an array that contains X items. - - Q3MemArray stores the array elements directly in the array. It can - only deal with simple types (i.e. C++ types, structs, and classes - that have no constructors, destructors, or virtual functions). - Q3MemArray uses bitwise operations to copy and compare array - elements. - - The Q3PtrVector collection class is also a kind of array. Like most - old Qt collection classes, it uses pointers to the contained items. - - Q3MemArray uses explicit sharing with a - reference count. If more than one array shares common data and one - of the arrays is modified, all the arrays are modified. - - The benefit of sharing is that a program does not need to duplicate - data when it is not required, which results in lower memory use - and less copying of data. - - Example: - \snippet doc/src/snippets/code/doc_src_q3memarray.qdoc 0 - - Program output: - \snippet doc/src/snippets/code/doc_src_q3memarray.qdoc 1 - - Note concerning the use of Q3MemArray for manipulating structs or - classes: Compilers will often pad the size of structs of odd sizes - up to the nearest word boundary. This will then be the size - Q3MemArray will use for its bitwise element comparisons. Because - the remaining bytes will typically be uninitialized, this can - cause find() etc. to fail to find the element. Example: - - \snippet doc/src/snippets/code/doc_src_q3memarray.qdoc 2 - - To work around this, make sure that you use a struct where - sizeof() returns the same as the sum of the sizes of the members - either by changing the types of the struct members or by adding - dummy members. - - Q3MemArray data can be traversed by iterators (see begin() and - end()). The number of items is returned by count(). The array can - be resized with resize() and filled using fill(). - - You can make a shallow copy of the array with assign() (or - operator=()) and a deep copy with duplicate(). - - Search for values in the array with find() and contains(). For - sorted arrays (see sort()) you can search using bsearch(). - - You can set the data directly using setRawData() and - resetRawData(), although this requires care. -*/ - -/*! \fn Q3MemArray::operator QVector() const - - Automatically converts the Q3MemArray into a QVector. -*/ - -/*! \typedef Q3MemArray::Iterator - A Q3MemArray iterator. - \sa begin() end() -*/ -/*! \typedef Q3MemArray::ConstIterator - A const Q3MemArray iterator. - \sa begin() end() -*/ -/*! \typedef Q3MemArray::ValueType - \internal -*/ - -/*! - \fn Q3MemArray::Q3MemArray() - - Constructs a null array. - - \sa isNull() -*/ - -/*! - \fn Q3MemArray::Q3MemArray( int size ) - - Constructs an array with room for \a size elements. Makes a null - array if \a size == 0. - - The elements are left uninitialized. - - \sa resize(), isNull() -*/ - -/*! - \fn Q3MemArray::Q3MemArray( const Q3MemArray &a ) - - Constructs a shallow copy of \a a. - - \sa assign() -*/ - -/*! - \fn Q3MemArray::Q3MemArray(const QVector &vector) - - Constructs a copy of \a vector. -*/ - -/*! - \fn Q3MemArray::Q3MemArray(int arg1, int arg2) - - Constructs an array \e{without allocating} array space. The - arguments \a arg1 and \a arg2 should be zero. Use at your own - risk. -*/ - -/*! - \fn Q3MemArray::~Q3MemArray() - - Dereferences the array data and deletes it if this was the last - reference. -*/ - -/*! - \fn Q3MemArray &Q3MemArray::operator=( const Q3MemArray &a ) - - Assigns a shallow copy of \a a to this array and returns a - reference to this array. - - Equivalent to assign( a ). -*/ - -/*! - \fn type *Q3MemArray::data() const - - Returns a pointer to the actual array data. - - The array is a null array if data() == 0 (null pointer). - - \sa isNull() -*/ - -/*! - \fn uint Q3MemArray::nrefs() const - - Returns the reference count for the shared array data. This - reference count is always greater than zero. -*/ - -/*! - \fn uint Q3MemArray::size() const - - Returns the size of the array (maximum number of elements). - - The array is a null array if size() == 0. - - \sa isNull(), resize() -*/ - -/*! - \fn uint Q3MemArray::count() const - - Returns the same as size(). - - \sa size() -*/ - -/*! - \fn bool Q3MemArray::isEmpty() const - - Returns TRUE if the array is empty; otherwise returns FALSE. - - isEmpty() is equivalent to isNull() for Q3MemArray (unlike - QString). -*/ - -/*! - \fn bool Q3MemArray::isNull() const - - Returns TRUE if the array is null; otherwise returns FALSE. - - A null array has size() == 0 and data() == 0. -*/ - -/*! - \fn bool Q3MemArray::resize( uint size, Optimization optim ) - - Resizes (expands or shrinks) the array to \a size elements. The - array becomes a null array if \a size == 0. - - Returns TRUE if successful, or FALSE if the memory cannot be - allocated. - - New elements are not initialized. - - \a optim is either Q3GArray::MemOptim (the default) or - Q3GArray::SpeedOptim. When optimizing for speed rather than memory - consumption, the array uses a smart grow and shrink algorithm that - might allocate more memory than is actually needed for \a size - elements. This speeds up subsequent resize operations, for example - when appending many elements to an array, since the space has - already been allocated. - - \sa size() -*/ - -/*! - \fn bool Q3MemArray::resize( uint size ) - - \overload - - Resizes (expands or shrinks) the array to \a size elements. The - array becomes a null array if \a size == 0. - - Returns TRUE if successful, i.e. if the memory can be allocated; - otherwise returns FALSE. - - New elements are not initialized. - - \sa size() -*/ - -/*! - \fn bool Q3MemArray::truncate( uint pos ) - - Truncates the array at position \a pos. - - Returns TRUE if successful, i.e. if the memory can be allocated; - otherwise returns FALSE. - - Equivalent to resize(\a pos). - - \sa resize() -*/ - -/*! - \fn bool Q3MemArray::fill( const type &v, int size ) - - Fills the array with the value \a v. If \a size is specified as - different from -1, then the array will be resized before being - filled. - - Returns TRUE if successful, i.e. if \a size is -1, or \a size is - != -1 and the memory can be allocated; otherwise returns FALSE. - - \sa resize() -*/ - -/*! - \fn void Q3MemArray::detach() - - Detaches this array from shared array data; i.e. it makes a - private, deep copy of the data. - - Copying will be performed only if the \link nrefs() reference - count\endlink is greater than one. - - \sa copy() -*/ - -/*! - \fn Q3MemArray Q3MemArray::copy() const - - Returns a deep copy of this array. - - \sa detach(), duplicate() -*/ - -/*! - \fn Q3MemArray &Q3MemArray::assign( const Q3MemArray &a ) - - Shallow copy. Dereferences the current array and references the - data contained in \a a instead. Returns a reference to this array. - - \sa operator=() -*/ - -/*! - \fn Q3MemArray &Q3MemArray::assign( const type *data, uint size ) - - \overload - - Shallow copy. Dereferences the current array and references the - array data \a data, which contains \a size elements. Returns a - reference to this array. - - Do not delete \a data later; Q3MemArray will call free() on it - at the right time. -*/ - -/*! - \fn Q3MemArray &Q3MemArray::duplicate( const Q3MemArray &a ) - - Deep copy. Dereferences the current array and obtains a copy of - the data contained in \a a instead. Returns a reference to this - array. - - \sa copy() -*/ - -/*! - \fn Q3MemArray &Q3MemArray::duplicate( const type *data, uint size ) - - \overload - - Deep copy. Dereferences the current array and obtains a copy of - the array data \a data instead. Returns a reference to this array. - The size of the array is given by \a size. - - \sa copy() -*/ - -/*! - \fn Q3MemArray &Q3MemArray::setRawData( const type *data, uint size ) - - Sets raw data and returns a reference to the array. - - Dereferences the current array and sets the new array data to \a - data and the new array size to \a size. Do not attempt to resize - or re-assign the array data when raw data has been set. Call - resetRawData(\a data, \a size) to reset the array. - - Setting raw data is useful because it sets Q3MemArray data without - allocating memory or copying data. - - Example I (intended use): - \snippet doc/src/snippets/code/doc_src_q3memarray.qdoc 3 - - Example II (you don't want to do this): - \snippet doc/src/snippets/code/doc_src_q3memarray.qdoc 4 - - \warning If you do not call resetRawData(), Q3MemArray will attempt - to deallocate or reallocate the raw data, which might not be too - good. Be careful. - - \sa resetRawData() -*/ - -/*! - \fn void Q3MemArray::resetRawData( const type *data, uint size ) - - Removes internal references to the raw data that was set using - setRawData(). This means that Q3MemArray no longer has access to - the \a data, so you are free to manipulate \a data as you wish. - You can now use the Q3MemArray without affecting the original \a - data, for example by calling setRawData() with a pointer to some - other data. - - The arguments must be the \a data and length, \a size, that were - passed to setRawData(). This is for consistency checking. - - \sa setRawData() -*/ - -/*! - \fn int Q3MemArray::find( const type &v, uint index ) const - - Finds the first occurrence of \a v, starting at position \a index. - - Returns the position of \a v, or -1 if \a v could not be found. - - \sa contains() -*/ - -/*! - \fn int Q3MemArray::contains( const type &v ) const - - Returns the number of times \a v occurs in the array. - - \sa find() -*/ - -/*! - \fn void Q3MemArray::sort() - - Sorts the array elements in ascending order, using bitwise - comparison (memcmp()). - - \sa bsearch() -*/ - -/*! - \fn int Q3MemArray::bsearch( const type &v ) const - - In a sorted array (as sorted by sort()), finds the first - occurrence of \a v by using a binary search. For a sorted - array this is generally much faster than find(), which does - a linear search. - - Returns the position of \a v, or -1 if \a v could not be found. - - \sa sort(), find() -*/ - -/*! - \fn type &Q3MemArray::operator[]( int index ) const - - Returns a reference to the element at position \a index in the - array. - - This can be used to both read and set an element. Equivalent to - at(). - - \sa at() -*/ - -/*! - \fn type &Q3MemArray::at( uint index ) const - - Returns a reference to the element at position \a index in the array. - - This can be used to both read and set an element. - - \sa operator[]() -*/ - -/*! - \fn Q3MemArray::operator const type *() const - - Cast operator. Returns a pointer to the array. - - \sa data() -*/ - -/*! - \fn bool Q3MemArray::operator==( const Q3MemArray &a ) const - - Returns TRUE if this array is equal to \a a; otherwise returns - FALSE. - - The two arrays are compared bitwise. - - \sa operator!=() -*/ - -/*! - \fn bool Q3MemArray::operator!=( const Q3MemArray &a ) const - - Returns TRUE if this array is different from \a a; otherwise - returns FALSE. - - The two arrays are compared bitwise. - - \sa operator==() -*/ - -/*! - \fn Iterator Q3MemArray::begin() - - Returns an iterator pointing at the beginning of this array. This - iterator can be used in the same way as the iterators of - Q3ValueList and QMap, for example. -*/ - -/*! - \fn Iterator Q3MemArray::end() - - Returns an iterator pointing behind the last element of this - array. This iterator can be used in the same way as the iterators - of Q3ValueList and QMap, for example. -*/ - -/*! - \fn ConstIterator Q3MemArray::begin() const - - \overload - - Returns a const iterator pointing at the beginning of this array. - This iterator can be used in the same way as the iterators of - Q3ValueList and QMap, for example. -*/ - -/*! - \fn ConstIterator Q3MemArray::end() const - - \overload - - Returns a const iterator pointing behind the last element of this - array. This iterator can be used in the same way as the iterators - of Q3ValueList and QMap, for example. -*/ diff --git a/doc/src/q3popupmenu.qdoc b/doc/src/q3popupmenu.qdoc deleted file mode 100644 index a2cfe08..0000000 --- a/doc/src/q3popupmenu.qdoc +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3PopupMenu - \brief The Q3PopupMenu class is a thin compatibility wrapper around QMenu. - \compat - - Use QMenu in new applications. Note that the menu's actions must - be \l {Q3Action}s. -*/ - -/*! - \fn Q3PopupMenu::Q3PopupMenu(QWidget *parent, const char *name) - - Constructs a menu with the given \a parent and \a name. -*/ - -/*! - \fn int Q3PopupMenu::exec() - - Pops up the menu and returns the ID of the action that was - selected. - - \sa QMenu::exec() -*/ - -/*! - \fn int Q3PopupMenu::exec(const QPoint & pos, int indexAtPoint) - - Pops up the menu at coordinate \a pos and returns the ID of the - action that was selected. - - If \a indexAtPoint is specified, the menu will pop up with the - item at index \a indexAtPoint under the mouse cursor. - - \sa QMenu::exec() -*/ diff --git a/doc/src/q3ptrdict.qdoc b/doc/src/q3ptrdict.qdoc deleted file mode 100644 index 38ca0bb..0000000 --- a/doc/src/q3ptrdict.qdoc +++ /dev/null @@ -1,388 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3PtrDict - \brief The Q3PtrDict class is a template class that provides a dictionary based on void* keys. - \compat - - Q3PtrDict is implemented as a template class. Define a template - instance Q3PtrDict\ to create a dictionary that operates on - pointers to X (X*). - - A dictionary is a collection of key-value pairs. The key is a - void* used for insertion, removal and lookup. The value is a - pointer. Dictionaries provide very fast insertion and lookup. - - Example: - \snippet doc/src/snippets/code/doc_src_q3ptrdict.qdoc 0 - In this example we use a dictionary to add an extra property (a - char*) to the line edits we're using. - - See Q3Dict for full details, including the choice of dictionary - size, and how deletions are handled. - - \sa Q3PtrDictIterator, Q3Dict, Q3AsciiDict, Q3IntDict -*/ - - -/*! - \fn Q3PtrDict::Q3PtrDict( int size ) - - Constructs a dictionary using an internal hash array with the size - \a size. - - Setting \a size to a suitably large prime number (equal to or - greater than the expected number of entries) makes the hash - distribution better and improves lookup performance. -*/ - -/*! - \fn Q3PtrDict::Q3PtrDict( const Q3PtrDict &dict ) - - Constructs a copy of \a dict. - - Each item in \a dict is inserted into this dictionary. Only the - pointers are copied (shallow copy). -*/ - -/*! - \fn Q3PtrDict::~Q3PtrDict() - - Removes all items from the dictionary and destroys it. - - All iterators that access this dictionary will be reset. - - \sa setAutoDelete() -*/ - -/*! - \fn Q3PtrDict &Q3PtrDict::operator=(const Q3PtrDict &dict) - - Assigns \a dict to this dictionary and returns a reference to this - dictionary. - - This dictionary is first cleared and then each item in \a dict is - inserted into the dictionary. Only the pointers are copied - (shallow copy), unless newItem() has been reimplemented. -*/ - -/*! - \fn uint Q3PtrDict::count() const - - Returns the number of items in the dictionary. - - \sa isEmpty() -*/ - -/*! - \fn uint Q3PtrDict::size() const - - Returns the size of the internal hash table (as specified in the - constructor). - - \sa count() -*/ - -/*! - \fn void Q3PtrDict::resize( uint newsize ) - - Changes the size of the hash table to \a newsize. The contents of - the dictionary are preserved, but all iterators on the dictionary - become invalid. -*/ - -/*! - \fn bool Q3PtrDict::isEmpty() const - - Returns TRUE if the dictionary is empty; otherwise returns FALSE. - - \sa count() -*/ - -/*! - \fn void Q3PtrDict::insert( void *key, const type *item ) - - Inserts the \a key with the \a item into the dictionary. - - Multiple items can have the same key, in which case only the last - item will be accessible using \l operator[](). - - \a item may not be 0. - - \sa replace() -*/ - -/*! - \fn void Q3PtrDict::replace( void *key, const type *item ) - - If the dictionary has key \a key, this key's item is replaced with - \a item. If the dictionary doesn't contain key \a key, \a item is - inserted into the dictionary using key \a key. - - \a item may not be 0. - - Equivalent to - \snippet doc/src/snippets/code/doc_src_q3ptrdict.qdoc 1 - - If there are two or more items with equal keys, then the most - recently inserted item will be replaced. - - \sa insert() -*/ - -/*! - \fn bool Q3PtrDict::remove( void *key ) - - Removes the item associated with \a key from the dictionary. - Returns TRUE if successful, i.e. if \a key is in the dictionary; - otherwise returns FALSE. - - If there are two or more items with equal keys, then the most - recently inserted item will be removed. - - The removed item is deleted if \link - Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. - - All dictionary iterators that refer to the removed item will be - set to point to the next item in the dictionary traversal order. - - \sa take(), clear(), setAutoDelete() -*/ - -/*! - \fn type *Q3PtrDict::take( void *key ) - - Takes the item associated with \a key out of the dictionary - without deleting it (even if \link Q3PtrCollection::setAutoDelete() - auto-deletion\endlink is enabled). - - If there are two or more items with equal keys, then the most - recently inserted item will be removed. - - Returns a pointer to the item taken out, or 0 if the key does not - exist in the dictionary. - - All dictionary iterators that refer to the taken item will be set - to point to the next item in the dictionary traversal order. - - \sa remove(), clear(), setAutoDelete() -*/ - -/*! - \fn void Q3PtrDict::clear() - - Removes all items from the dictionary. - - The removed items are deleted if \link - Q3PtrCollection::setAutoDelete() auto-deletion\endlink is enabled. - - All dictionary iterators that access this dictionary will be - reset. - - \sa remove(), take(), setAutoDelete() -*/ - -/*! - \fn type *Q3PtrDict::find( void *key ) const - - Returns the item associated with \a key, or 0 if the key does not - exist in the dictionary. - - If there are two or more items with equal keys, then the most - recently inserted item will be found. - - Equivalent to operator[]. - - \sa operator[]() -*/ - -/*! - \fn type *Q3PtrDict::operator[]( void *key ) const - - Returns the item associated with \a key, or 0 if the key does not - exist in the dictionary. - - If there are two or more items with equal keys, then the most - recently inserted item will be found. - - Equivalent to the find() function. - - \sa find() -*/ - -/*! - \fn void Q3PtrDict::statistics() const - - Debugging-only function that prints out the dictionary - distribution using qDebug(). -*/ - -/*! - \fn QDataStream& Q3PtrDict::read( QDataStream &s, Q3PtrCollection::Item &item ) - - Reads a dictionary item from the stream \a s and returns a - reference to the stream. - - The default implementation sets \a item to 0. - - \sa write() -*/ - -/*! - \fn QDataStream& Q3PtrDict::write( QDataStream &s, Q3PtrCollection::Item item) const - - Writes a dictionary \a item to the stream \a s and returns a - reference to the stream. - - \sa read() -*/ - -/*! - \class Q3PtrDictIterator - \brief The Q3PtrDictIterator class provides an iterator for Q3PtrDict collections. - \compat - - Q3PtrDictIterator is implemented as a template class. Define a - template instance Q3PtrDictIterator\ to create a dictionary - iterator that operates on Q3PtrDict\ (dictionary of X*). - - Example: - \snippet doc/src/snippets/code/doc_src_q3ptrdict.qdoc 2 - In the example we insert some line edits into a dictionary, - associating a string with each. We then iterate over the - dictionary printing the associated strings. - - Multiple iterators may independently traverse the same dictionary. - A Q3PtrDict knows about all the iterators that are operating on the - dictionary. When an item is removed from the dictionary, Q3PtrDict - updates all iterators that refer the removed item to point to the - next item in the traversing order. - - \sa Q3PtrDict -*/ - -/*! - \fn Q3PtrDictIterator::Q3PtrDictIterator( const Q3PtrDict &dict ) - - Constructs an iterator for \a dict. The current iterator item is - set to point on the first item in the \a dict. -*/ - -/*! - \fn Q3PtrDictIterator::~Q3PtrDictIterator() - - Destroys the iterator. -*/ - -/*! - \fn uint Q3PtrDictIterator::count() const - - Returns the number of items in the dictionary this iterator - operates on. - - \sa isEmpty() -*/ - -/*! - \fn bool Q3PtrDictIterator::isEmpty() const - - Returns TRUE if the dictionary is empty; otherwise returns FALSE. - - \sa count() -*/ - -/*! - \fn type *Q3PtrDictIterator::toFirst() - - Sets the current iterator item to point to the first item in the - dictionary and returns a pointer to the item. If the dictionary is - empty, it sets the current item to 0 and returns 0. -*/ - -/*! - \fn Q3PtrDictIterator::operator type *() const - - Cast operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *Q3PtrDictIterator::current() const - - Returns a pointer to the current iterator item's value. -*/ - -/*! - \fn void *Q3PtrDictIterator::currentKey() const - - Returns the current iterator item's key. -*/ - -/*! - \fn type *Q3PtrDictIterator::operator()() - - Makes the succeeding item current and returns the original current - item. - - If the current iterator item was the last item in the dictionary - or if it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3PtrDictIterator::operator++() - - Prefix ++ makes the succeeding item current and returns the new - current item. - - If the current iterator item was the last item in the dictionary - or if it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3PtrDictIterator::operator+=( uint jump ) - - Sets the current item to the item \a jump positions after the - current item and returns a pointer to that item. - - If that item is beyond the last item or if the dictionary is - empty, it sets the current item to 0 and returns 0. -*/ diff --git a/doc/src/q3ptrlist.qdoc b/doc/src/q3ptrlist.qdoc deleted file mode 100644 index 3000940..0000000 --- a/doc/src/q3ptrlist.qdoc +++ /dev/null @@ -1,1157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3PtrList - \brief The Q3PtrList class is a template class that provides a list. - \compat - - Q3ValueList is an STL-compatible alternative to this class. - - Define a template instance Q3PtrList\ to create a list that - operates on pointers to X (X*). - - The list class is indexable and has a \link at() current - index\endlink and a \link current() current item\endlink. The - first item corresponds to index position 0. The current index is - -1 if the current item is 0. - - Items are inserted with prepend(), insert() or append(). Items are - removed with remove(), removeRef(), removeFirst() and - removeLast(). You can search for an item using find(), findNext(), - findRef() or findNextRef(). The list can be sorted with sort(). - You can count the number of occurrences of an item with contains() - or containsRef(). You can get a pointer to the current item with - current(), to an item at a particular index position in the list - with at() or to the first or last item with getFirst() and - getLast(). You can also iterate over the list with first(), - last(), next() and prev() (which all update current()). The list's - deletion property is set with setAutoDelete(). - - \target example - Example: - \snippet doc/src/snippets/code/doc_src_q3ptrlist.qdoc 0 - - The output is - \snippet doc/src/snippets/code/doc_src_q3ptrlist.qdoc 1 - - Q3PtrList has several member functions for traversing the list, but - using a Q3PtrListIterator can be more practical. Multiple list - iterators may traverse the same list, independently of each other - and of the current list item. - - In the example above we make the call setAutoDelete(true). - Enabling auto-deletion tells the list to delete items that are - removed. The default is to not delete items when they are removed - but this would cause a memory leak in the example because there - are no other references to the list items. - - When inserting an item into a list only the pointer is copied, not - the item itself, i.e. a shallow copy. It is possible to make the - list copy all of the item's data (deep copy) when an item is - inserted. insert(), inSort() and append() call the virtual - function Q3PtrCollection::newItem() for the item to be inserted. - Inherit a list and reimplement newItem() to have deep copies. - - When removing an item from a list, the virtual function - Q3PtrCollection::deleteItem() is called. Q3PtrList's default - implementation is to delete the item if auto-deletion is enabled. - - The virtual function compareItems() can be reimplemented to - compare two list items. This function is called from all list - functions that need to compare list items, for instance - remove(const type*). If you only want to deal with pointers, there - are functions that compare pointers instead, for instance - removeRef(const type*). These functions are somewhat faster than - those that call compareItems(). - - List items are stored as \c void* in an internal Q3LNode, which - also holds pointers to the next and previous list items. The - functions currentNode(), removeNode(), and takeNode() operate - directly on the Q3LNode, but they should be used with care. The - data component of the node is available through Q3LNode::getData(). - - The Q3StrList class is a list of \c char*. - It reimplements newItem(), deleteItem() and compareItems(). (But - see QStringList for a list of Unicode QStrings.) - - \sa Q3PtrListIterator -*/ - - -/*! - \fn Q3PtrList::Q3PtrList() - - Constructs an empty list. -*/ - -/*! - \fn Q3PtrList::Q3PtrList( const Q3PtrList &list ) - - Constructs a copy of \a list. - - Each item in \a list is \link append() appended\endlink to this - list. Only the pointers are copied (shallow copy). -*/ - -/*! - \fn Q3PtrList::~Q3PtrList() - - Removes all items from the list and destroys the list. - - All list iterators that access this list will be reset. - - \sa setAutoDelete() -*/ - -/*! - \fn Q3PtrList &Q3PtrList::operator=(const Q3PtrList &list) - - Assigns \a list to this list and returns a reference to this list. - - This list is first cleared and then each item in \a list is \link - append() appended\endlink to this list. Only the pointers are - copied (shallow copy) unless newItem() has been reimplemented. -*/ - -/*! - \fn bool Q3PtrList::operator==(const Q3PtrList &list ) const - - Compares this list with \a list. Returns TRUE if the lists contain - the same data; otherwise returns FALSE. -*/ - -/*! - \fn uint Q3PtrList::count() const - - Returns the number of items in the list. - - \sa isEmpty() -*/ - -/*! - \fn bool Q3PtrList::operator!=(const Q3PtrList &list ) const - - Compares this list with \a list. Returns TRUE if the lists contain - different data; otherwise returns FALSE. -*/ - - -/*! - \fn void Q3PtrList::sort() - - Sorts the list by the result of the virtual compareItems() - function. - - The heap sort algorithm is used for sorting. It sorts n items with - O(n*log n) comparisons. This is the asymptotic optimal solution of - the sorting problem. - - If the items in your list support operator<() and operator==(), - you might be better off with Q3SortedList because it implements the - compareItems() function for you using these two operators. - - \sa inSort() -*/ - -/*! - \fn bool Q3PtrList::isEmpty() const - - Returns TRUE if the list is empty; otherwise returns FALSE. - - \sa count() -*/ - -/*! - \fn bool Q3PtrList::insert( uint index, const type *item ) - - Inserts the \a item at position \a index in the list. - - Returns TRUE if successful, i.e. if \a index is in range; - otherwise returns FALSE. The valid range is 0 to count() - (inclusively). The item is appended if \a index == count(). - - The inserted item becomes the current list item. - - \a item must not be 0. - - \sa append(), current(), replace() -*/ - -/*! - \fn bool Q3PtrList::replace( uint index, const type *item ) - - Replaces the item at position \a index with the new \a item. - - Returns TRUE if successful, i.e. \a index is in the range 0 to - count()-1. - - \sa append(), current(), insert() -*/ - -/*! - \fn void Q3PtrList::inSort( const type *item ) - - Inserts the \a item at its sorted position in the list. - - The sort order depends on the virtual compareItems() function. All - items must be inserted with inSort() to maintain the sorting - order. - - The inserted item becomes the current list item. - - \a item must not be 0. - - \warning Using inSort() is slow. An alternative, especially if you - have lots of items, is to simply append() or insert() them and - then use sort(). inSort() takes up to O(n) compares. That means - inserting n items in your list will need O(n^2) compares whereas - sort() only needs O(n*log n) for the same task. So use inSort() - only if you already have a presorted list and want to insert just - a few additional items. - - \sa insert(), compareItems(), current(), sort() -*/ - -/*! - \fn void Q3PtrList::append( const type *item ) - - Inserts the \a item at the end of the list. - - The inserted item becomes the current list item. This is - equivalent to \c{insert( count(), item )}. - - \a item must not be 0. - - \sa insert(), current(), prepend() -*/ - -/*! - \fn void Q3PtrList::prepend( const type *item ) - - Inserts the \a item at the start of the list. - - The inserted item becomes the current list item. This is - equivalent to \c{insert( 0, item )}. - - \a item must not be 0. - - \sa append(), insert(), current() -*/ - -/*! - \fn bool Q3PtrList::remove( uint index ) - - Removes the item at position \a index in the list. - - Returns TRUE if successful, i.e. if \a index is in range; - otherwise returns FALSE. The valid range is \c{0..(count() - 1)} - inclusive. - - The removed item is deleted if \link setAutoDelete() - auto-deletion\endlink is enabled. - - The item after the removed item becomes the new current list item - if the removed item is not the last item in the list. If the last - item is removed, the new last item becomes the current item. - - All list iterators that refer to the removed item will be set to - point to the new current item. - - \sa take(), clear(), setAutoDelete(), current() removeRef() -*/ - -/*! - \fn bool Q3PtrList::remove() - - \overload - - Removes the current list item. - - Returns TRUE if successful, i.e. if the current item isn't 0; - otherwise returns FALSE. - - The removed item is deleted if \link setAutoDelete() - auto-deletion\endlink is enabled. - - The item after the removed item becomes the new current list item - if the removed item is not the last item in the list. If the last - item is removed, the new last item becomes the current item. The - current item is set to 0 if the list becomes empty. - - All list iterators that refer to the removed item will be set to - point to the new current item. - - \sa take(), clear(), setAutoDelete(), current() removeRef() -*/ - -/*! - \fn bool Q3PtrList::remove( const type *item ) - - \overload - - Removes the first occurrence of \a item from the list. - - Returns TRUE if successful, i.e. if \a item is in the list; - otherwise returns FALSE. - - The removed item is deleted if \link setAutoDelete() - auto-deletion\endlink is enabled. - - The compareItems() function is called when searching for the item - in the list. If compareItems() is not reimplemented, it is more - efficient to call removeRef(). - - If \a item is NULL then the current item is removed from the list. - - The item after the removed item becomes the new current list item - if the removed item is not the last item in the list. If the last - item is removed, the new last item becomes the current item. The - current item is set to 0 if the list becomes empty. - - All list iterators that refer to the removed item will be set to - point to the new current item. - - \sa removeRef(), take(), clear(), setAutoDelete(), compareItems(), - current() -*/ - -/*! - \fn bool Q3PtrList::removeRef( const type *item ) - - Removes the first occurrence of \a item from the list. - - Returns TRUE if successful, i.e. if \a item is in the list; - otherwise returns FALSE. - - The removed item is deleted if \link setAutoDelete() - auto-deletion\endlink is enabled. - - Equivalent to: - \snippet doc/src/snippets/code/doc_src_q3ptrlist.qdoc 2 - - The item after the removed item becomes the new current list item - if the removed item is not the last item in the list. If the last - item is removed, the new last item becomes the current item. The - current item is set to 0 if the list becomes empty. - - All list iterators that refer to the removed item will be set to - point to the new current item. - - \sa remove(), clear(), setAutoDelete(), current() -*/ - -/*! - \fn void Q3PtrList::removeNode( Q3LNode *node ) - - Removes the \a node from the list. - - This node must exist in the list, otherwise the program may crash. - - The removed item is deleted if \link setAutoDelete() - auto-deletion\endlink is enabled. - - The first item in the list will become the new current list item. - The current item is set to 0 if the list becomes empty. - - All list iterators that refer to the removed item will be set to - point to the item succeeding this item or to the preceding item if - the removed item was the last item. - - \warning Do not call this function unless you are an expert. - - \sa takeNode(), currentNode() remove() removeRef() -*/ - -/*! - \fn bool Q3PtrList::removeFirst() - - Removes the first item from the list. Returns TRUE if successful, - i.e. if the list isn't empty; otherwise returns FALSE. - - The removed item is deleted if \link setAutoDelete() - auto-deletion\endlink is enabled. - - The first item in the list becomes the new current list item. The - current item is set to 0 if the list becomes empty. - - All list iterators that refer to the removed item will be set to - point to the new current item. - - \sa removeLast(), setAutoDelete(), current() remove() -*/ - -/*! - \fn bool Q3PtrList::removeLast() - - Removes the last item from the list. Returns TRUE if successful, - i.e. if the list isn't empty; otherwise returns FALSE. - - The removed item is deleted if \link setAutoDelete() - auto-deletion\endlink is enabled. - - The last item in the list becomes the new current list item. The - current item is set to 0 if the list becomes empty. - - All list iterators that refer to the removed item will be set to - point to the new current item. - - \sa removeFirst(), setAutoDelete(), current() -*/ - -/*! - \fn type *Q3PtrList::take( uint index ) - - Takes the item at position \a index out of the list without - deleting it (even if \link setAutoDelete() auto-deletion\endlink - is enabled). - - Returns a pointer to the item taken out of the list, or 0 if the - index is out of range. The valid range is \c{0..(count() - 1)} - inclusive. - - The item after the removed item becomes the new current list item - if the removed item is not the last item in the list. If the last - item is removed, the new last item becomes the current item. The - current item is set to 0 if the list becomes empty. - - All list iterators that refer to the taken item will be set to - point to the new current item. - - \sa remove(), clear(), current() -*/ - -/*! - \fn type *Q3PtrList::take() - - \overload - - Takes the current item out of the list without deleting it (even - if \link setAutoDelete() auto-deletion\endlink is enabled). - - Returns a pointer to the item taken out of the list, or 0 if - the current item is 0. - - The item after the removed item becomes the new current list item - if the removed item is not the last item in the list. If the last - item is removed, the new last item becomes the current item. The - current item is set to 0 if the list becomes empty. - - All list iterators that refer to the taken item will be set to - point to the new current item. - - \sa remove(), clear(), current() -*/ - -/*! - \fn type *Q3PtrList::takeNode( Q3LNode *node ) - - Takes the \a node out of the list without deleting its item (even - if \link setAutoDelete() auto-deletion\endlink is enabled). - Returns a pointer to the item taken out of the list. - - This node must exist in the list, otherwise the program may crash. - - The first item in the list becomes the new current list item. - - All list iterators that refer to the taken item will be set to - point to the item succeeding this item or to the preceding item if - the taken item was the last item. - - \warning Do not call this function unless you are an expert. - - \sa removeNode(), currentNode() -*/ - -/*! - \fn void Q3PtrList::clear() - - Removes all items from the list. - - The removed items are deleted if \link setAutoDelete() - auto-deletion\endlink is enabled. - - All list iterators that access this list will be reset. - - \sa remove(), take(), setAutoDelete() -*/ - -/*! - \fn int Q3PtrList::find( const type *item ) - - Finds the first occurrence of \a item in the list. - - If the item is found, the list sets the current item to point to - the found item and returns the index of this item. If the item is - not found, the list sets the current item to 0, the current - index to -1, and returns -1. - - The compareItems() function is called when searching for the item - in the list. If compareItems() is not reimplemented, it is more - efficient to call findRef(). - - \sa findNext(), findRef(), compareItems(), current() -*/ - -/*! - \fn int Q3PtrList::findNext( const type *item ) - - Finds the next occurrence of \a item in the list, starting from - the current list item. - - If the item is found, the list sets the current item to point to - the found item and returns the index of this item. If the item is - not found, the list sets the current item to 0, the current - index to -1, and returns -1. - - The compareItems() function is called when searching for the item - in the list. If compareItems() is not reimplemented, it is more - efficient to call findNextRef(). - - \sa find(), findNextRef(), compareItems(), current() -*/ - -/*! - \fn int Q3PtrList::findRef( const type *item ) - - Finds the first occurrence of \a item in the list. - - If the item is found, the list sets the current item to point to - the found item and returns the index of this item. If the item is - not found, the list sets the current item to 0, the current - index to -1, and returns -1. - - Calling this function is much faster than find() because find() - compares \a item with each list item using compareItems(), whereas - this function only compares the pointers. - - \sa findNextRef(), find(), current() -*/ - -/*! - \fn int Q3PtrList::findNextRef( const type *item ) - - Finds the next occurrence of \a item in the list, starting from - the current list item. - - If the item is found, the list sets the current item to point to - the found item and returns the index of this item. If the item is - not found, the list sets the current item to 0, the current - index to -1, and returns -1. - - Calling this function is much faster than findNext() because - findNext() compares \a item with each list item using - compareItems(), whereas this function only compares the pointers. - - \sa findRef(), findNext(), current() -*/ - -/*! - \fn uint Q3PtrList::contains( const type *item ) const - - Returns the number of occurrences of \a item in the list. - - The compareItems() function is called when looking for the \a item - in the list. If compareItems() is not reimplemented, it is more - efficient to call containsRef(). - - This function does not affect the current list item. - - \sa containsRef(), compareItems() -*/ - -/*! - \fn uint Q3PtrList::containsRef( const type *item ) const - - Returns the number of occurrences of \a item in the list. - - Calling this function is much faster than contains() because - contains() compares \a item with each list item using - compareItems(), whereas his function only compares the pointers. - - This function does not affect the current list item. - - \sa contains() -*/ - -/*! - \fn type *Q3PtrList::at( uint index ) - - Returns a pointer to the item at position \a index in the list, or - 0 if the index is out of range. - - Sets the current list item to this item if \a index is valid. The - valid range is \c{0..(count() - 1)} inclusive. - - This function is very efficient. It starts scanning from the first - item, last item, or current item, whichever is closest to \a - index. - - \sa current() -*/ - -/*! - \fn int Q3PtrList::at() const - - \overload - - Returns the index of the current list item. The returned value is - -1 if the current item is 0. - - \sa current() -*/ - -/*! - \fn type *Q3PtrList::current() const - - Returns a pointer to the current list item. The current item may - be 0 (implies that the current index is -1). - - \sa at() -*/ - -/*! - \fn Q3LNode *Q3PtrList::currentNode() const - - Returns a pointer to the current list node. - - The node can be kept and removed later using removeNode(). The - advantage is that the item can be removed directly without - searching the list. - - \warning Do not call this function unless you are an expert. - - \sa removeNode(), takeNode(), current() -*/ - -/*! - \fn type *Q3PtrList::getFirst() const - - Returns a pointer to the first item in the list, or 0 if the list - is empty. - - This function does not affect the current list item. - - \sa first(), getLast() -*/ - -/*! - \fn type *Q3PtrList::getLast() const - - Returns a pointer to the last item in the list, or 0 if the list - is empty. - - This function does not affect the current list item. - - \sa last(), getFirst() -*/ - -/*! - \fn type *Q3PtrList::first() - - Returns a pointer to the first item in the list and makes this the - current list item; returns 0 if the list is empty. - - \sa getFirst(), last(), next(), prev(), current() -*/ - -/*! - \fn type *Q3PtrList::last() - - Returns a pointer to the last item in the list and makes this the - current list item; returns 0 if the list is empty. - - \sa getLast(), first(), next(), prev(), current() -*/ - -/*! - \fn type *Q3PtrList::next() - - Returns a pointer to the item succeeding the current item. Returns - 0 if the current item is 0 or equal to the last item. - - Makes the succeeding item current. If the current item before this - function call was the last item, the current item will be set to - 0. If the current item was 0, this function does nothing. - - \sa first(), last(), prev(), current() -*/ - -/*! - \fn type *Q3PtrList::prev() - - Returns a pointer to the item preceding the current item. Returns - 0 if the current item is 0 or equal to the first item. - - Makes the preceding item current. If the current item before this - function call was the first item, the current item will be set to - 0. If the current item was 0, this function does nothing. - - \sa first(), last(), next(), current() -*/ - -/*! - \fn void Q3PtrList::toVector( Q3GVector *vec ) const - - Stores all list items in the vector \a vec. - - The vector must be of the same item type, otherwise the result - will be undefined. -*/ - -/*! - \typedef Q3PtrList::iterator - - \internal -*/ - -/*! - \typedef Q3PtrList::Iterator - - \internal -*/ - -/*! - \typedef Q3PtrList::ConstIterator - - \internal -*/ - -/*! - \typedef Q3PtrList::const_iterator - - \internal -*/ - -/*! - \fn Q3PtrList::constBegin() const - - \internal -*/ - -/*! - \fn Q3PtrList::constEnd() const - - \internal -*/ - -/*! - \fn Q3PtrList::erase(Iterator) - - \internal -*/ - - -/***************************************************************************** - Q3PtrListIterator documentation - *****************************************************************************/ - -/*! - \class Q3PtrListIterator - \brief The Q3PtrListIterator class provides an iterator for - Q3PtrList collections. - \compat - - Define a template instance Q3PtrListIterator\ to create a list - iterator that operates on Q3PtrList\ (list of X*). - - The following example is similar to the - example in the Q3PtrList class documentation, - but it uses Q3PtrListIterator. The class Employee is - defined there. - - \snippet doc/src/snippets/code/doc_src_q3ptrlist.qdoc 3 - - The output is - \snippet doc/src/snippets/code/doc_src_q3ptrlist.qdoc 4 - - Using a list iterator is a more robust way of traversing the list - than using the Q3PtrList member functions \link Q3PtrList::first() - first\endlink(), \link Q3PtrList::next() next\endlink(), \link - Q3PtrList::current() current\endlink(), etc., as many iterators can - traverse the same list independently. - - An iterator has its own current list item and can get the next and - previous list items. It doesn't modify the list in any way. - - When an item is removed from the list, all iterators that point to - that item are updated to point to Q3PtrList::current() instead to - avoid dangling references. - - \sa Q3PtrList -*/ - -/*! - \fn Q3PtrListIterator::Q3PtrListIterator( const Q3PtrList &list ) - - Constructs an iterator for \a list. The current iterator item is - set to point on the first item in the \a list. -*/ - -/*! - \fn Q3PtrListIterator::~Q3PtrListIterator() - - Destroys the iterator. -*/ - -/*! - \fn uint Q3PtrListIterator::count() const - - Returns the number of items in the list this iterator operates on. - - \sa isEmpty() -*/ - -/*! - \fn bool Q3PtrListIterator::isEmpty() const - - Returns TRUE if the list is empty; otherwise returns FALSE. - - \sa count() -*/ - -/*! - \fn bool Q3PtrListIterator::atFirst() const - - Returns TRUE if the current iterator item is the first list item; - otherwise returns FALSE. - - \sa toFirst(), atLast() -*/ - -/*! - \fn bool Q3PtrListIterator::atLast() const - - Returns TRUE if the current iterator item is the last list item; - otherwise returns FALSE. - - \sa toLast(), atFirst() -*/ - -/*! - \fn type *Q3PtrListIterator::toFirst() - - Sets the current iterator item to point to the first list item and - returns a pointer to the item. Sets the current item to 0 and - returns 0 if the list is empty. - - \sa toLast(), atFirst() -*/ - -/*! - \fn type *Q3PtrListIterator::toLast() - - Sets the current iterator item to point to the last list item and - returns a pointer to the item. Sets the current item to 0 and - returns 0 if the list is empty. - - \sa toFirst(), atLast() -*/ - -/*! - \fn Q3PtrListIterator::operator type *() const - - Cast operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *Q3PtrListIterator::operator*() - - Asterisk operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *Q3PtrListIterator::current() const - - Returns a pointer to the current iterator item. If the iterator is - positioned before the first item in the list or after the last - item in the list, 0 is returned. -*/ - -/*! - \fn type *Q3PtrListIterator::operator()() - - Makes the succeeding item current and returns the original current - item. - - If the current iterator item was the last item in the list or if - it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3PtrListIterator::operator++() - - Prefix ++ makes the succeeding item current and returns the new - current item. - - If the current iterator item was the last item in the list or if - it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3PtrListIterator::operator+=( uint jump ) - - Sets the current item to the item \a jump positions after the - current item and returns a pointer to that item. - - If that item is beyond the last item or if the list is empty, it - sets the current item to 0 and returns 0 -*/ - -/*! - \fn type *Q3PtrListIterator::operator--() - - Prefix - makes the preceding item current and returns the new - current item. - - If the current iterator item was the first item in the list or if - it was 0, 0 is returned. -*/ - -/*! - \fn type *Q3PtrListIterator::operator-=( uint jump ) - - Returns the item \a jump positions before the current item or 0 - if it is beyond the first item. Makes this the current item. -*/ - -/*! - \fn Q3PtrListIterator& Q3PtrListIterator::operator=( const Q3PtrListIterator &it ) - - Assignment. Makes a copy of the iterator \a it and returns a - reference to this iterator. -*/ - -/*! - \class Q3StrList - \brief The Q3StrList class provides a doubly-linked list of char*. - \compat - - If you want a string list of \l{QString}s use QStringList. - - This class is a Q3PtrList\ instance (a list of char*). - - Q3StrList can make deep or shallow copies of the strings that are - inserted. - - A deep copy means that memory is allocated for the string and then - the string data is copied into that memory. A shallow copy is just - a copy of the pointer value and not of the string data itself. - - The disadvantage of shallow copies is that because a pointer can - be deleted only once, the program must put all strings in a - central place and know when it is safe to delete them (i.e. when - the strings are no longer referenced by other parts of the - program). This can make the program more complex. The advantage of - shallow copies is that they consume far less memory than deep - copies. It is also much faster to copy a pointer (typically 4 or 8 - bytes) than to copy string data. - - A Q3StrList that operates on deep copies will, by default, turn on - auto-deletion (see setAutoDelete()). Thus, by default Q3StrList - will deallocate any string copies it allocates. - - The virtual compareItems() function is reimplemented and does a - case-sensitive string comparison. The inSort() function will - insert strings in sorted order. In general it is fastest to insert - the strings as they come and sort() at the end; inSort() is useful - when you just have to add a few extra strings to an already sorted - list. - - The Q3StrListIterator class is an iterator for Q3StrList. -*/ - -/*! - \fn Q3StrList::operator QList() const - - Automatically converts a Q3StrList into a QList. -*/ - -/*! - \fn Q3StrList::Q3StrList( bool deepCopies ) - - Constructs an empty list of strings. Will make deep copies of all - inserted strings if \a deepCopies is TRUE, or use shallow copies - if \a deepCopies is FALSE. -*/ - -/*! - \fn Q3StrList::Q3StrList(const Q3StrList &list) - \fn Q3StrList::Q3StrList(const QList &list) - - Constructs a copy of \a list. -*/ - -/*! - \fn Q3StrList::~Q3StrList() - - Destroys the list. All strings are removed. -*/ - -/*! - \fn Q3StrList& Q3StrList::operator=(const Q3StrList& list) - \fn Q3StrList &Q3StrList::operator=(const QList &list) - - Assigns \a list to this list and returns a reference to this list. -*/ - -/*! - \class Q3StrIList - \brief The Q3StrIList class provides a doubly-linked list of char* - with case-insensitive comparison. - \compat - - This class is a Q3PtrList\ instance (a list of char*). - - Q3StrIList is identical to Q3StrList except that the virtual - compareItems() function is reimplemented to compare strings - case-insensitively. The inSort() function inserts strings in a - sorted order. In general it is fastest to insert the strings as - they come and sort() at the end; inSort() is useful when you just - have to add a few extra strings to an already sorted list. - - The Q3StrListIterator class works for Q3StrIList. - - \sa QStringList -*/ - -/*! - \fn Q3StrIList::Q3StrIList( bool deepCopies ) - - Constructs a list of strings. Will make deep copies of all - inserted strings if \a deepCopies is TRUE, or use shallow copies - if \a deepCopies is FALSE. -*/ - -/*! - \fn Q3StrIList::~Q3StrIList() - - Destroys the list. All strings are removed. -*/ - -/*! - \fn int Q3PtrList::compareItems( Q3PtrCollection::Item item1, - Q3PtrCollection::Item item2 ) - - This virtual function compares two list items. - - Returns: - \list - \i zero if \a item1 == \a item2 - \i nonzero if \a item1 != \a item2 - \endlist - - This function returns \e int rather than \e bool so that - reimplementations can return three values and use it to sort by: - - \list - \i 0 if \a item1 == \a item2 - \i \> 0 (positive integer) if \a item1 \> \a item2 - \i \< 0 (negative integer) if \a item1 \< \a item2 - \endlist - - inSort() requires that compareItems() is implemented as described - here. - - This function should not modify the list because some const - functions call compareItems(). - - The default implementation compares the pointers. -*/ - -/*! - \fn QDataStream& Q3PtrList::read( QDataStream& s, - Q3PtrCollection::Item& item ) - - Reads a list item from the stream \a s and returns a reference to - the stream. - - The default implementation sets \a item to 0. - - \sa write() -*/ - -/*! - \fn QDataStream& Q3PtrList::write( QDataStream& s, - Q3PtrCollection::Item item ) const - - Writes a list item, \a item to the stream \a s and returns a - reference to the stream. - - The default implementation does nothing. - - \sa read() -*/ - -/*! \fn iterator Q3PtrList::begin() -\internal -*/ -/*! \fn const_iterator Q3PtrList::begin() const -\internal -*/ -/*! \fn iterator Q3PtrList::end() -\internal -*/ -/*! \fn const_iterator Q3PtrList::end() const -\internal -*/ - -/*! - \class Q3StrListIterator - \brief The Q3StrListIterator class is an iterator for the Q3StrList - and Q3StrIList classes. - \compat - - This class is a Q3PtrListIterator\ instance. It can traverse - the strings in the Q3StrList and Q3StrIList classes. -*/ - - -/* - \class Q3PtrListAutoDelete - \brief The Q3PtrListAutoDelete class is a template class that provides a list that auto-deletes its data. - \compat - - A Q3PtrListAutoDelete is identical to a Q3PtrList with - setAutoDelete(TRUE). -*/ diff --git a/doc/src/q3ptrqueue.qdoc b/doc/src/q3ptrqueue.qdoc deleted file mode 100644 index b3af5f6..0000000 --- a/doc/src/q3ptrqueue.qdoc +++ /dev/null @@ -1,230 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3PtrQueue - \brief The Q3PtrQueue class is a template class that provides a queue. - \compat - - Q3ValueVector can be used as an STL-compatible alternative to this - class. - - A template instance Q3PtrQueue\ is a queue that operates on - pointers to X (X*). - - A queue is a first in, first out structure. Items are added to the - tail of the queue with enqueue() and retrieved from the head with - dequeue(). You can peek at the head item without dequeing it using - head(). - - You can control the queue's deletion policy with setAutoDelete(). - - For compatibility with the Q3PtrCollection classes, current() and - remove() are provided; both operate on the head(). - - \sa Q3PtrList Q3PtrStack -*/ - -/*! - \fn Q3PtrQueue::Q3PtrQueue () - - Creates an empty queue with autoDelete() set to FALSE. -*/ - -/*! - \fn Q3PtrQueue::Q3PtrQueue( const Q3PtrQueue& queue ) - - Creates a queue from \a queue. - - Only the pointers are copied; the items are not. The autoDelete() - flag is set to FALSE. -*/ - -/*! - \fn Q3PtrQueue::~Q3PtrQueue() - - Destroys the queue. Items in the queue are deleted if autoDelete() - is TRUE. -*/ - -/*! - \fn Q3PtrQueue& Q3PtrQueue::operator= (const Q3PtrQueue& queue) - - Assigns \a queue to this queue and returns a reference to this - queue. - - This queue is first cleared and then each item in \a queue is - enqueued to this queue. Only the pointers are copied. - - \warning The autoDelete() flag is not modified. If it is TRUE for - both \a queue and this queue, deleting the two lists will cause \e - double-deletion of the items. -*/ - -/*! - \fn bool Q3PtrQueue::isEmpty() const - - Returns TRUE if the queue is empty; otherwise returns FALSE. - - \sa count() dequeue() head() -*/ - -/*! - \fn void Q3PtrQueue::enqueue (const type* d) - - Adds item \a d to the tail of the queue. - - \sa count() dequeue() -*/ - -/*! - \fn type* Q3PtrQueue::dequeue () - - Takes the head item from the queue and returns a pointer to it. - Returns 0 if the queue is empty. - - \sa enqueue() count() -*/ - -/*! - \fn bool Q3PtrQueue::remove() - - Removes the head item from the queue, and returns TRUE if there - was an item, i.e. the queue wasn't empty; otherwise returns FALSE. - - The item is deleted if autoDelete() is TRUE. - - \sa head() isEmpty() dequeue() -*/ - -/*! - \fn void Q3PtrQueue::clear() - - Removes all items from the queue, and deletes them if autoDelete() - is TRUE. - - \sa remove() -*/ - -/*! - \fn uint Q3PtrQueue::count() const - - Returns the number of items in the queue. - - \sa isEmpty() -*/ - -/*! - \fn type* Q3PtrQueue::head() const - - Returns a pointer to the head item in the queue. The queue is not - changed. Returns 0 if the queue is empty. - - \sa dequeue() isEmpty() -*/ - -/*! - \fn Q3PtrQueue::operator type*() const - - Returns a pointer to the head item in the queue. The queue is not - changed. Returns 0 if the queue is empty. - - \sa dequeue() isEmpty() -*/ - -/*! - \fn type* Q3PtrQueue::current() const - - Returns a pointer to the head item in the queue. The queue is not - changed. Returns 0 if the queue is empty. - - \sa dequeue() isEmpty() -*/ - -/*! - \fn bool Q3PtrQueue::autoDelete() const - - Returns the setting of the auto-delete option. The default is - FALSE. - - \sa setAutoDelete() -*/ - -/*! - \fn void Q3PtrQueue::setAutoDelete( bool enable ) - - Sets the queue to auto-delete its contents if \a enable is TRUE - and not to delete them if \a enable is FALSE. - - If auto-deleting is turned on, all the items in a queue are - deleted when the queue itself is deleted. This can be quite - convenient if the queue has the only pointer to the items. - - The default setting is FALSE, for safety. If you turn it on, be - careful about copying the queue: you might find yourself with two - queues deleting the same items. - - \sa autoDelete() -*/ - -/*! - \fn QDataStream& Q3PtrQueue::read( QDataStream& s, - Q3PtrCollection::Item& item ) - - Reads a queue item, \a item, from the stream \a s and returns a - reference to the stream. - - The default implementation sets \a item to 0. - - \sa write() -*/ - -/*! - \fn QDataStream& Q3PtrQueue::write( QDataStream& s, - Q3PtrCollection::Item item ) const - - Writes a queue item, \a item, to the stream \a s and returns a - reference to the stream. - - The default implementation does nothing. - - \sa read() -*/ diff --git a/doc/src/q3ptrstack.qdoc b/doc/src/q3ptrstack.qdoc deleted file mode 100644 index 1650d69..0000000 --- a/doc/src/q3ptrstack.qdoc +++ /dev/null @@ -1,217 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3PtrStack - \brief The Q3PtrStack class is a template class that provides a stack. - \compat - - Q3ValueStack is an STL-compatible alternative to this class. - - Define a template instance Q3PtrStack\ to create a stack that - operates on pointers to X, (X*). - - A stack is a last in, first out (LIFO) structure. Items are added - to the top of the stack with push() and retrieved from the top - with pop(). Use top() to get a reference to the top element - without changing the stack. - - You can control the stack's deletion policy with setAutoDelete(). - - For compatibility with the Q3PtrCollection classes current() and - remove() are provided; they both operate on the top(). - - \sa Q3PtrList Q3PtrQueue -*/ - -/*! - \fn Q3PtrStack::Q3PtrStack () - - Creates an empty stack. -*/ - -/*! - \fn Q3PtrStack::Q3PtrStack (const Q3PtrStack& s) - - Creates a stack by making a shallow copy of another stack \a s. -*/ - -/*! - \fn Q3PtrStack::~Q3PtrStack () - - Destroys the stack. All items will be deleted if autoDelete() is - true. -*/ - -/*! - \fn Q3PtrStack& Q3PtrStack::operator= (const Q3PtrStack& s) - - Sets the contents of this stack by making a shallow copy of - another stack \a s. Elements currently in this stack will be - deleted if autoDelete() is true. -*/ - -/*! - \fn bool Q3PtrStack::isEmpty () const - - Returns true if the stack contains no elements; otherwise returns - false. -*/ - -/*! - \fn void Q3PtrStack::push (const type* d) - - Adds an element \a d to the top of the stack. Last in, first out. -*/ - -/*! - \fn type* Q3PtrStack::pop () - - Removes the top item from the stack and returns it. The stack must - not be empty. -*/ - -/*! - \fn bool Q3PtrStack::remove () - - Removes the top item from the stack and deletes it if autoDelete() - is true. Returns true if there was an item to pop; otherwise - returns false. - - \sa clear() -*/ - -/*! - \fn void Q3PtrStack::clear() - - Removes all items from the stack, deleting them if autoDelete() is - true. - - \sa remove() -*/ - -/*! - \fn uint Q3PtrStack::count() const - - Returns the number of items in the stack. - - \sa isEmpty() -*/ - -/*! - \fn type* Q3PtrStack::top () const - - Returns a pointer to the top item on the stack (most recently - pushed). The stack is not changed. Returns 0 if the stack is - empty. -*/ - -/*! - \fn Q3PtrStack::operator type* ()const - - Returns a pointer to the top item on the stack (most recently - pushed). The stack is not changed. Returns 0 if the stack is - empty. -*/ - -/*! - \fn type* Q3PtrStack::current () const - - Returns a pointer to the top item on the stack (most recently - pushed). The stack is not changed. Returns 0 if the stack is - empty. -*/ - -/*! - \fn bool Q3PtrStack::autoDelete() const - - The same as Q3PtrCollection::autoDelete(). Returns true if - the auto-delete option is set. If the option is set, the - stack auto-deletes its contents. - - \sa setAutoDelete() -*/ - -/*! - \fn void Q3PtrStack::setAutoDelete(bool enable) - - Defines whether this stack auto-deletes its contents. The same as - Q3PtrCollection::setAutoDelete(). If \a enable is true, auto-delete - is turned on. - - If auto-deleting is turned on, all the items in the stack are - deleted when the stack itself is deleted. This is convenient if - the stack has the only pointers to the items. - - The default setting is false, for safety. If you turn it on, be - careful about copying the stack, or you might find yourself with - two stacks deleting the same items. - - Note that the auto-delete setting may also affect other functions in - subclasses. For example, a subclass that has a remove() function - will remove the item from its data structure, and if auto-delete is - enabled, will also delete the item. - - \sa autoDelete() -*/ - -/*! - \fn QDataStream& Q3PtrStack::read(QDataStream& s, Q3PtrCollection::Item& item) - - Reads a stack item, \a item, from the stream \a s and returns a - reference to the stream. - - The default implementation sets \a item to 0. - - \sa write() -*/ - -/*! - \fn QDataStream& Q3PtrStack::write(QDataStream& s, - Q3PtrCollection::Item item) const - - Writes a stack item, \a item, to the stream \a s and returns a - reference to the stream. - - The default implementation does nothing. - - \sa read() -*/ diff --git a/doc/src/q3ptrvector.qdoc b/doc/src/q3ptrvector.qdoc deleted file mode 100644 index fa78de5..0000000 --- a/doc/src/q3ptrvector.qdoc +++ /dev/null @@ -1,427 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3PtrVector - \brief The Q3PtrVector class is a template collection class that - provides a vector (array). - \compat - - Q3ValueVector is an STL-compatible alternative to this class. - - Q3PtrVector is implemented as a template class. Defines a template - instance Q3PtrVector\ to create a vector that contains pointers - to X (X*). - - A vector is the same as an array. The main difference between - Q3PtrVector and Q3MemArray is that Q3PtrVector stores pointers to the - elements, whereas Q3MemArray stores the elements themselves (i.e. - Q3MemArray is value-based and Q3PtrVector is pointer-based). - - Items are added to the vector using insert() or fill(). Items are - removed with remove(). You can get a pointer to an item at a - particular index position using at(). - - Unless otherwise stated, all functions that remove items from the - vector will also delete the element pointed to if \link - setAutoDelete() auto-deletion\endlink is enabled. By default, - auto-deletion is disabled; see setAutoDelete(). This behavior can - be changed in a subclass by reimplementing the virtual function - deleteItem(). - - Functions that compare items (find() and sort() for example) will - do so using the virtual function compareItems(). The default - implementation of this function only compares the pointer values. - Reimplement compareItems() in a subclass to get searching and - sorting based on the item contents. You can perform a linear - search for a pointer in the vector using findRef(), or a binary - search (of a sorted vector) using bsearch(). You can count the - number of times an item appears in the vector with contains() or - containsRef(). - - \sa Q3MemArray -*/ - -/*! - \fn Q3PtrVector::Q3PtrVector() - - Constructs a null vector. - - \sa isNull() -*/ - -/*! - \fn Q3PtrVector::Q3PtrVector(uint size) - - Constructs an vector with room for \a size items. Makes a null - vector if \a size == 0. - - All \a size positions in the vector are initialized to 0. - - \sa size(), resize(), isNull() -*/ - -/*! - \fn Q3PtrVector::Q3PtrVector(const Q3PtrVector &v) - - Constructs a copy of \a v. Only the pointers are copied (i.e. - shallow copy). -*/ - -/*! - \fn Q3PtrVector::~Q3PtrVector() - - Removes all items from the vector, and destroys the vector itself. - - \sa clear() -*/ - -/*! - \fn Q3PtrVector &Q3PtrVector::operator=(const Q3PtrVector &v) - - Assigns \a v to this vector and returns a reference to this - vector. - - This vector is first cleared and then all the items from \a v are - copied into the vector. Only the pointers are copied (i.e. shallow - copy). - - \sa clear() -*/ - -/*! - \fn type **Q3PtrVector::data() const - - Returns a pointer to the actual vector data, which is an array of - type*. - - The vector is a null vector if data() == 0 (null pointer). - - \sa isNull() -*/ - -/*! - \fn uint Q3PtrVector::size() const - - Returns the size of the vector, i.e. the number of vector - positions. This is also the maximum number of items the vector can - hold. - - The vector is a null vector if size() == 0. - - \sa isNull(), resize(), count() -*/ - -/*! - \fn uint Q3PtrVector::count() const - - Returns the number of items in the vector. The vector is empty if - count() == 0. - - \sa isEmpty(), size(), isNull() -*/ - -/*! - \fn bool Q3PtrVector::isEmpty() const - - Returns true if the vector is empty; otherwise returns false. - - \sa count() -*/ - -/*! - \fn bool Q3PtrVector::isNull() const - - Returns true if the vector is null; otherwise returns false. - - A null vector has size() == 0 and data() == 0. - - \sa size() -*/ - -/*! - \fn bool Q3PtrVector::resize(uint size) - - Resizes (expands or shrinks) the vector to \a size elements. The - vector becomes a null vector if \a size == 0. - - Any items at position \a size or beyond in the vector are removed. - New positions are initialized to 0. - - Returns true if successful, i.e. if the memory was successfully - allocated; otherwise returns false. - - \sa size(), isNull() -*/ - -/*! - \fn bool Q3PtrVector::insert(uint i, const type *d) - - Sets position \a i in the vector to contain the item \a d. \a i - must be less than size(). Any previous element in position \a i is - removed. - - Returns true if \a i is within range; otherwise returns false. - - \sa at() -*/ - -/*! - \fn bool Q3PtrVector::remove(uint i) - - Removes the item at position \a i in the vector, if there is one. - \a i must be less than size(). - - Returns true if \a i is within range; otherwise returns false. - - \sa take(), at() -*/ - -/*! - \fn type* Q3PtrVector::take(uint i) - - Returns the item at position \a i in the vector, and removes that - item from the vector. \a i must be less than size(). If there is - no item at position \a i, 0 is returned. - - Unlike remove(), this function does \e not call deleteItem() for - the removed item. - - \sa remove(), at() -*/ - -/*! - \fn void Q3PtrVector::clear() - - Removes all items from the vector, and destroys the vector itself. - - The vector becomes a null vector. - - \sa isNull() -*/ - -/*! - \fn bool Q3PtrVector::fill(const type *d, int size) - - Inserts item \a d in all positions in the vector. Any existing - items are removed. If \a d is 0, the vector becomes empty. - - If \a size >= 0, the vector is first resized to \a size. By - default, \a size is -1. - - Returns true if successful, i.e. \a size is the same as the - current size, or \a size is larger and the memory has successfully - been allocated; otherwise returns false. - - \sa resize(), insert(), isEmpty() -*/ - -/*! - \fn void Q3PtrVector::sort() - - Sorts the items in ascending order. Any empty positions will be - put last. - - Compares items using the virtual function compareItems(). - - \sa bsearch() -*/ - -/*! - \fn int Q3PtrVector::bsearch(const type* d) const - - In a sorted array, finds the first occurrence of \a d using a - binary search. For a sorted array, this is generally much faster - than find(), which performs a linear search. - - Returns the position of \a d, or -1 if \a d could not be found. \a - d must not be 0. - - Compares items using the virtual function compareItems(). - - \sa sort(), find() -*/ - - -/*! - \fn int Q3PtrVector::findRef(const type *d, uint i) const - - Finds the first occurrence of the item pointer \a d in the vector - using a linear search. The search starts at position \a i, which - must be less than size(). \a i is by default 0; i.e. the search - starts at the start of the vector. - - Returns the position of \a d, or -1 if \a d could not be found. - - This function does \e not use compareItems() to compare items. - - Use the much faster bsearch() to search a sorted vector. - - \sa find(), bsearch() -*/ - -/*! - \fn int Q3PtrVector::find(const type *d, uint i) const - - Finds the first occurrence of item \a d in the vector using a - linear search. The search starts at position \a i, which must be - less than size(). \a i is by default 0; i.e. the search starts at - the start of the vector. - - Returns the position of \a d, or -1 if \a d could not be found. - - Compares items using the virtual function compareItems(). - - Use the much faster bsearch() to search a sorted vector. - - \sa findRef(), bsearch() -*/ - - -/*! - \fn uint Q3PtrVector::containsRef(const type *d) const - - Returns the number of occurrences of the item pointer \a d in the - vector. - - This function does \e not use compareItems() to compare items. - - \sa findRef() -*/ - -/*! - \fn uint Q3PtrVector::contains(const type *d) const - - Returns the number of occurrences of item \a d in the vector. - - Compares items using the virtual function compareItems(). - - \sa containsRef() -*/ - -/*! - \fn type *Q3PtrVector::operator[](int i) const - - Returns the item at position \a i, or 0 if there is no item at - that position. \a i must be less than size(). - - Equivalent to at(\a i). - - \sa at() -*/ - -/*! - \fn type *Q3PtrVector::at(uint i) const - - Returns the item at position \a i, or 0 if there is no item at - that position. \a i must be less than size(). -*/ - - -/*! - \fn void Q3PtrVector::toList(Q3GList *list) const - - \internal - - Copies all items in this vector to the list \a list. \a list is - first cleared and then all items are appended to \a list. - - \sa Q3PtrList, Q3PtrStack, Q3PtrQueue -*/ - -/*! - \fn int Q3PtrVector::compareItems(Q3PtrCollection::Item d1, - Q3PtrCollection::Item d2) - - This virtual function compares two list items. - - Returns: - \list - \i zero if \a d1 == \a d2 - \i nonzero if \a d1 != \a d2 - \endlist - - This function returns \e int rather than \e bool so that - reimplementations can return one of three values and use it to - sort by: - \list - \i 0 if \a d1 == \a d2 - \i \> 0 (positive integer) if \a d1 \> \a d2 - \i \< 0 (negative integer) if \a d1 \< \a d2 - \endlist - - The sort() and bsearch() functions require compareItems() to be - implemented as described here. - - This function should not modify the vector because some const - functions call compareItems(). -*/ - -/*! - \fn QDataStream& Q3PtrVector::read(QDataStream &s, - Q3PtrCollection::Item &item) - - Reads a vector item, \a item, from the stream \a s and returns a - reference to the stream. - - The default implementation sets \a item to 0. - - \sa write() -*/ - -/*! - \fn QDataStream& Q3PtrVector::write(QDataStream &s, - Q3PtrCollection::Item item) const - - Writes a vector item, \a item, to the stream \a s and returns a - reference to the stream. - - The default implementation does nothing. - - \sa read() -*/ - -/*! - \fn bool Q3PtrVector::operator==(const Q3PtrVector &v) const - - Returns true if this vector and \a v are equal; otherwise returns - false. -*/ diff --git a/doc/src/q3sqlfieldinfo.qdoc b/doc/src/q3sqlfieldinfo.qdoc deleted file mode 100644 index ba064f3..0000000 --- a/doc/src/q3sqlfieldinfo.qdoc +++ /dev/null @@ -1,234 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3SqlFieldInfo - \brief The Q3SqlFieldInfo class stores meta data associated with a SQL field. - - \compat - - Q3SqlFieldInfo objects only store meta data; field values are - stored in QSqlField objects. - - All values must be set in the constructor, and may be retrieved - using isRequired(), type(), length(), precision(), defaultValue(), - name(), isGenerated() and typeID(). - - \sa Q3SqlRecordInfo -*/ - -/*! - \fn Q3SqlFieldInfo::Q3SqlFieldInfo(const QString& name, - QVariant::Type typ, - int required, - int len, - int prec, - const QVariant& defValue, - int typeID, - bool generated, - bool trim, - bool calculated) - - Constructs a Q3SqlFieldInfo with the following parameters: - \table - \row \i \a name \i the name of the field. - \row \i \a typ \i the field's type in a QVariant. - \row \i \a required \i greater than 0 if the field is required, 0 - if its value can be NULL and less than 0 if it cannot be - determined whether the field is required or not. - \row \i \a len \i the length of the field. Note that for - non-character types some databases return either the length in - bytes or the number of digits. -1 signifies that the length cannot - be determined. - \row \i \a prec \i the precision of the field, or -1 if the field - has no precision or it cannot be determined. - \row \i \a defValue \i the default value that is inserted into - the table if none is specified by the user. QVariant() if there is - no default value or it cannot be determined. - \row \i \a typeID \i the internal typeID of the database system - (only useful for low-level programming). 0 if unknown. - \row \i \a generated \i TRUE indicates that this field should be - included in auto-generated SQL statments, e.g. in Q3SqlCursor. - \row \i \a trim \i TRUE indicates that widgets should remove - trailing whitespace from character fields. This does not affect - the field value but only its representation inside widgets. - \row \i \a calculated \i TRUE indicates that the value of this - field is calculated. The value of calculated fields can by - modified by subclassing Q3SqlCursor and overriding - Q3SqlCursor::calculateField(). - \endtable -*/ - -/*! - \fn Q3SqlFieldInfo::~Q3SqlFieldInfo() - - Destroys the object and frees any allocated resources. -*/ - -/*! - \fn Q3SqlFieldInfo::Q3SqlFieldInfo(const QSqlField & other) - - Creates a Q3SqlFieldInfo object with the type and the name of the - QSqlField \a other. -*/ - -/*! - \fn bool Q3SqlFieldInfo::operator==(const Q3SqlFieldInfo& other) const - - Assigns \a other to this field info and returns a reference to it. -*/ - -/*! - \fn QSqlField Q3SqlFieldInfo::toField() const - - Returns an empty QSqlField based on the information in this - Q3SqlFieldInfo. -*/ - -/*! - \fn int Q3SqlFieldInfo::isRequired() const - - Returns a value greater than 0 if the field is required (NULL - values are not allowed), 0 if it isn't required (NULL values are - allowed) or less than 0 if it cannot be determined whether the - field is required or not. -*/ - -/*! - \fn QVariant::Type Q3SqlFieldInfo::type() const - - Returns the field's type or QVariant::Invalid if the type is - unknown. -*/ - -/*! - \fn int Q3SqlFieldInfo::length() const - - Returns the field's length. For fields storing text the return - value is the maximum number of characters the field can hold. For - non-character fields some database systems return the number of - bytes needed or the number of digits allowed. If the length cannot - be determined -1 is returned. -*/ - -/*! - \fn int Q3SqlFieldInfo::precision() const - - Returns the field's precision or -1 if the field has no precision - or it cannot be determined. -*/ - -/*! - \fn QVariant Q3SqlFieldInfo::defaultValue() const - - Returns the field's default value or an empty QVariant if the - field has no default value or the value couldn't be determined. - The default value is the value inserted in the database when it - is not explicitly specified by the user. -*/ - -/*! - \fn QString Q3SqlFieldInfo::name() const - - Returns the name of the field in the SQL table. -*/ - -/*! - \fn int Q3SqlFieldInfo::typeID() const - - Returns the internal type identifier as returned from the database - system. The return value is 0 if the type is unknown. -*/ - -/*! - \fn bool Q3SqlFieldInfo::isGenerated() const - - Returns TRUE if the field should be included in auto-generated - SQL statments, e.g. in Q3SqlCursor; otherwise returns FALSE. - - \sa setGenerated() -*/ - -/*! - \fn bool Q3SqlFieldInfo::isTrim() const - - Returns TRUE if trailing whitespace should be removed from - character fields; otherwise returns FALSE. - - \sa setTrim() -*/ - -/*! - \fn bool Q3SqlFieldInfo::isCalculated() const - - Returns TRUE if the field is calculated; otherwise returns FALSE. - - \sa setCalculated() -*/ - -/*! - \fn void Q3SqlFieldInfo::setTrim(bool trim) - - If \a trim is TRUE widgets should remove trailing whitespace from - character fields. This does not affect the field value but only - its representation inside widgets. - - \sa isTrim() -*/ - -/*! - \fn void Q3SqlFieldInfo::setGenerated(bool generated) - - \a generated set to FALSE indicates that this field should not appear - in auto-generated SQL statements (for example in Q3SqlCursor). - - \sa isGenerated() -*/ - -/*! - \fn void Q3SqlFieldInfo::setCalculated(bool calculated) - - \a calculated set to TRUE indicates that this field is a calculated - field. The value of calculated fields can by modified by subclassing - Q3SqlCursor and overriding Q3SqlCursor::calculateField(). - - \sa isCalculated() -*/ diff --git a/doc/src/q3sqlrecordinfo.qdoc b/doc/src/q3sqlrecordinfo.qdoc deleted file mode 100644 index 64236d2..0000000 --- a/doc/src/q3sqlrecordinfo.qdoc +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3SqlRecordInfo - \brief The Q3SqlRecordInfo class encapsulates a set of database field meta data. - - \compat - - This class is a list that holds a set of database field meta - data. Use contains() to see if a given field name exists in the - record, and use find() to get a QSqlFieldInfo record for a named - field. - - \sa Q3SqlFieldInfo -*/ - -/*! - \fn Q3SqlRecordInfo::Q3SqlRecordInfo() - - Constructs an empty record info object. -*/ - -/*! - \fn Q3SqlRecordInfo::Q3SqlRecordInfo(const Q3SqlFieldInfoList& other) - \fn Q3SqlRecordInfo::Q3SqlRecordInfo(const QSqlRecord& other) - - Constructs a copy of \a other. -*/ - -/*! - \fn size_type Q3SqlRecordInfo::contains(const QString& fieldName) const - - Returns the number of times a field called \a fieldName occurs in - the record. Returns 0 if no field by that name could be found. -*/ - -/*! - \fn Q3SqlFieldInfo Q3SqlRecordInfo::find(const QString& fieldName) const - - Returns a QSqlFieldInfo object for the first field in the record - which has the field name \a fieldName. If no matching field is - found then an empty QSqlFieldInfo object is returned. -*/ - -/*! - \fn QSqlRecord Q3SqlRecordInfo::toRecord() const - - Returns an empty QSqlRecord based on the field information - in this Q3SqlRecordInfo. -*/ diff --git a/doc/src/q3valuelist.qdoc b/doc/src/q3valuelist.qdoc deleted file mode 100644 index fd73763..0000000 --- a/doc/src/q3valuelist.qdoc +++ /dev/null @@ -1,569 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3ValueList - \brief The Q3ValueList class is a value-based template class that - provides lists. - \compat - - Q3ValueList is a Qt implementation of an STL-like list container. - It can be used in your application if the standard \c list is not - available for your target platforms. - - Q3ValueList\ defines a template instance to create a list of - values that all have the class T. Note that Q3ValueList does not - store pointers to the members of the list; it holds a copy of - every member. This is why these kinds of classes are called "value - based"; Q3PtrList and Q3Dict are "pointer based". - - Q3ValueList contains and manages a collection of objects of type T - and provides iterators that allow the contained objects to be - addressed. Q3ValueList owns the contained items. For more relaxed - ownership semantics, see Q3PtrCollection and friends which are - pointer-based containers. - - Some classes cannot be used within a Q3ValueList, for example, all - classes derived from QObject and thus all classes that implement - widgets. Only values can be used in a Q3ValueList. To qualify as a - value the class must provide: - \list - \i a copy constructor; - \i an assignment operator; - \i a default constructor, i.e. a constructor that does not take any arguments. - \endlist - - Note that C++ defaults to field-by-field assignment operators and - copy constructors if no explicit version is supplied. In many - cases this is sufficient. - - In addition, some compilers (e.g. Sun CC) might require that the - class provides an equality operator (operator==()). - - Q3ValueList's function naming is consistent with the other Qt - classes (e.g. count(), isEmpty()). Q3ValueList also provides extra - functions for compatibility with STL algorithms, such as size() - and empty(). Programmers already familiar with the STL \c list may - prefer to use the STL-compatible functions. - - Example: - \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 0 - - - Notice that the latest changes to Mary's salary did not affect the - value in the list because the list created a copy of Mary's entry. - - There are several ways to find items in the list. The begin() and - end() functions return iterators to the beginning and end of the - list. The advantage of getting an iterator is that you can move - forward or backward from this position by - incrementing/decrementing the iterator. The iterator returned by - end() points to the item which is one \e past the last item in the - container. The past-the-end iterator is still associated with the - list it belongs to, however it is \e not dereferenceable; - operator*() will not return a well-defined value. If the list is - empty(), the iterator returned by begin() will equal the iterator - returned by end(). - - It is safe to have multiple iterators a the list at the same - time. If some member of the list is removed, only iterators - pointing to the removed member become invalid. Inserting into the - list does not invalidate any iterator. For convenience, the - function last() returns a reference to the last item in the list, - and first() returns a reference to the first item. If the - list is empty(), both last() and first() have undefined behavior - (your application will crash or do unpredictable things). Use - last() and first() with caution, for example: - - \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 1 - - Because Q3ValueList is value-based there is no need to be careful - about deleting items in the list. The list holds its own copies - and will free them if the corresponding member or the list itself - is deleted. You can force the list to free all of its items with - clear(). - - Q3ValueList is shared implicitly, which means it can be copied in - constant time, i.e. O(1). If multiple Q3ValueList instances share - the same data and one needs to modify its contents, this modifying - instance makes a copy and modifies its private copy; therefore it - does not affect the other instances; this takes O(n) time. This is - often called "copy on write". If a Q3ValueList is being used in a - multi-threaded program, you must protect all access to the list. - See \l QMutex. - - There are several ways to insert items into the list. The - prepend() and append() functions insert items at the beginning and - the end of the list respectively. The insert() function comes in - several flavors and can be used to add one or more items at - specific positions within the list. - - Items can also be removed from the list in several ways. There - are several variants of the remove() function, which removes a - specific item from the list. The remove() function will find and - remove items according to a specific item value. - - \sa Q3ValueListIterator -*/ - -/*! \typedef Q3ValueList::iterator - The list's iterator type, Q3ValueListIterator. */ -/*! \typedef Q3ValueList::const_iterator - The list's const iterator type, Q3ValueListConstIterator. */ -/*! \typedef Q3ValueList::value_type - The type of the object stored in the list, T. */ -/*! \typedef Q3ValueList::pointer - The pointer to T type. */ -/*! \typedef Q3ValueList::const_pointer - The const pointer to T type. */ -/*! \typedef Q3ValueList::reference - The reference to T type. */ -/*! \typedef Q3ValueList::const_reference - The const reference to T type. */ -/*! \typedef Q3ValueList::size_type - An unsigned integral type, used to represent various sizes. */ -/*! \typedef Q3ValueList::difference_type - \internal -*/ -/*! - \fn Q3ValueList::Q3ValueList() - - Constructs an empty list. -*/ - -/*! - \fn Q3ValueList::Q3ValueList( const Q3ValueList& l ) - \fn Q3ValueList::Q3ValueList( const QList& l ) - \fn Q3ValueList::Q3ValueList( const QLinkedList& l ) - - Constructs a copy of \a l. -*/ - -/*! - \fn Q3ValueList::Q3ValueList( const std::list& l ) - - Contructs a copy of \a l. - - This constructor is provided for compatibility with STL - containers. -*/ - -/*! - \fn Q3ValueList::~Q3ValueList() - - Destroys the list. References to the values in the list and all - iterators of this list become invalidated. Note that it is - impossible for an iterator to check whether or not it is valid: - Q3ValueList is highly tuned for performance, not for error - checking. -*/ - -/*! - \fn bool Q3ValueList::operator== ( const Q3ValueList& l ) const - - Compares both lists. - - Returns TRUE if this list and \a l are equal; otherwise returns - FALSE. -*/ - -/*! - \fn bool Q3ValueList::operator== ( const std::list& l ) const - - \overload - - Returns TRUE if this list and \a l are equal; otherwise returns - FALSE. - - This operator is provided for compatibility with STL containers. -*/ - -/*! - \fn Q3ValueList& Q3ValueList::operator= ( const Q3ValueList& l ) - - Assigns \a l to this list and returns a reference to this list. - - All iterators of the current list become invalidated by this - operation. The cost of such an assignment is O(1) since Q3ValueList - is implicitly shared. -*/ - -/*! - \fn Q3ValueList& Q3ValueList::operator= ( const QList& l ) - - Assigns \a l to this list and returns a reference to this list. - - All iterators of the current list become invalidated by this - operation. -*/ - -/*! - \fn Q3ValueList& Q3ValueList::operator= ( const std::list& l ) - - \overload - - Assigns the contents of \a l to the list. - - All iterators of the current list become invalidated by this - operation. -*/ - -/*! - \fn bool Q3ValueList::operator!= ( const Q3ValueList& l ) const - - Compares both lists. - - Returns TRUE if this list and \a l are unequal; otherwise returns - FALSE. -*/ - -/*! - \fn iterator Q3ValueList::insert( typename Q3ValueList::Iterator it, const T& x ) - - Inserts the value \a x in front of the item pointed to by the - iterator, \a it. - - Returns an iterator pointing at the inserted item. - - \sa append(), prepend() -*/ - -/*! - \fn uint Q3ValueList::remove( const T& x ) - - \overload - - Removes all items that have value \a x and returns the number of - removed items. -*/ - -/*! - \fn QDataStream& operator>>( QDataStream& s, Q3ValueList& l ) - - \relates Q3ValueList - - Reads a list, \a l, from the stream \a s. The type T stored in the - list must implement the streaming operator. -*/ - -/*! - \fn QDataStream& operator<<( QDataStream& s, const Q3ValueList& l ) - - \overload - \relates Q3ValueList - - Writes a list, \a l, to the stream \a s. The type T stored in the - list must implement the streaming operator. -*/ - -/*! - \fn void Q3ValueList::insert( typename Q3ValueList::Iterator pos, - typename Q3ValueList::size_type n, const T& x ) - - \overload - - Inserts \a n copies of \a x before position \a pos. -*/ - -/*! - \fn Q3ValueList& Q3ValueList::operator<< ( const T& x ) - - Adds the value \a x to the end of the list. - - Returns a reference to the list. -*/ - -/*! - \fn const T& Q3ValueList::operator[] ( typename Q3ValueList::size_type i ) const - - Returns a const reference to the item with index \a i in the list. - It is up to you to check whether this item really exists. You can - do that easily with the count() function. However this operator - does not check whether \a i is in range and will deliver undefined - results if it does not exist. - - \warning This function uses a linear search and can be extremely - slow for large lists. Q3ValueList is not optimized for random item - access. If you need random access use a different container, such - as Q3ValueVector. -*/ - -/*! - \fn T& Q3ValueList::operator[] ( typename Q3ValueList::size_type i ) - - \overload - - Returns a non-const reference to the item with index \a i. -*/ - -/*! - \fn const_iterator Q3ValueList::at( typename Q3ValueList::size_type i ) const - - Returns an iterator pointing to the item at position \a i in the - list, or an undefined value if the index is out of range. - - \warning This function uses a linear search and can be extremely - slow for large lists. Q3ValueList is not optimized for random item - access. If you need random access use a different container, such - as Q3ValueVector. -*/ - -/*! - \fn iterator Q3ValueList::at( typename Q3ValueList::size_type i ) - - \overload - - Returns an iterator pointing to the item at position \a i in the - list, or an undefined value if the index is out of range. - -*/ - -/*! - \fn iterator Q3ValueList::fromLast() - - \overload - - Returns an iterator to the last item in the list, or end() if - there is no last item. - - Use the end() function instead. For example: - - \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 2 - -*/ - -/*! - \fn const_iterator Q3ValueList::fromLast() const - - Returns an iterator to the last item in the list, or end() if - there is no last item. - - Use the end() function instead. For example: - - \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 3 - -*/ - -/*! - \fn Q3ValueList Q3ValueList::operator+( const Q3ValueList& l ) const - - Creates a new list and fills it with the items of this list. Then - the items of \a l are appended. Returns the new list. -*/ - -/*! - \fn Q3ValueList& Q3ValueList::operator+= ( const Q3ValueList& l ) - - Appends the items of \a l to this list. Returns a reference to - this list. -*/ - -/*! - \fn Q3ValueList& Q3ValueList::operator+= ( const T& x ) - - \overload - - Appends the value \a x to the list. Returns a reference to the - list. -*/ - -/*! - \fn iterator Q3ValueList::append( const T& x ) - - Inserts \a x at the end of the list. - - \sa insert(), prepend() -*/ - -/*! - \fn iterator Q3ValueList::prepend( const T& x ) - - Inserts \a x at the beginning of the list. - - \sa insert(), append() -*/ - -/*! - \fn iterator Q3ValueList::remove( typename Q3ValueList::Iterator it ) - - Removes the item pointed to by \a it from the list. No iterators - other than \a it or other iterators pointing at the same item as - \a it are invalidated. Returns an iterator to the next item after - \a it, or end() if there is no such item. - - \sa clear() -*/ - -/*! - \fn uint Q3ValueList::contains( const T& x ) const - - Returns the number of occurrences of the value \a x in the list. -*/ - -/*! - \class Q3ValueListIterator - \brief The Q3ValueListIterator class provides an iterator for Q3ValueList. - \compat - - An iterator is a class for accessing the items of a container - class: a generalization of the index in an array. A pointer - into a "const char *" and an index into an "int[]" are both - iterators, and the general idea is to provide that functionality - for any data structure. - - The Q3ValueListIterator class is an iterator for Q3ValueList - instantiations. You can create the appropriate iterator type by - using the \c iterator typedef provided by Q3ValueList. - - The only way to access the items in a Q3ValueList is to use an - iterator. - - Example (see Q3ValueList for the complete code): - \snippet doc/src/snippets/code/doc_src_q3valuelist.qdoc 4 - - Q3ValueList is highly optimized for performance and memory usage. - This means that you must be careful: Q3ValueList does not know - about all its iterators and the iterators don't know to which list - they belong. This makes things very fast, but if you're not - careful, you can get spectacular bugs. Always make sure iterators - are valid before dereferencing them or using them as parameters to - generic algorithms in the STL. - - Using an invalid iterator is undefined (your application will - probably crash). Many Qt functions return const value lists; to - iterate over these you should make a copy and iterate over the - copy. - - For every Iterator there is a ConstIterator. When accessing a - Q3ValueList in a const environment or if the reference or pointer - to the list is itself const, then you must use the ConstIterator. - Its semantics are the same as the Iterator, but it only returns - const references. - - \sa Q3ValueList, Q3ValueListConstIterator -*/ - -/*! - \fn Q3ValueListIterator::Q3ValueListIterator() - - Constructs an unitialized iterator. -*/ - -/*! - \fn Q3ValueListIterator::Q3ValueListIterator(const Q3ValueListIterator &o) - \fn Q3ValueListIterator::Q3ValueListIterator(const typename QLinkedList::iterator &o) - - Constucts a copy of iterator \a o. -*/ - -/*! - \class Q3ValueListConstIterator - \brief The Q3ValueListConstIterator class provides a const iterator - for Q3ValueList. - \compat - - In contrast to Q3ValueListIterator, this class is used to iterate - over a const list. It does not allow modification of the values of - the list since that would break const semantics. - - You can create the appropriate const iterator type by using the \c - const_iterator typedef provided by Q3ValueList. - - For more information on Q3ValueList iterators, see - Q3ValueListIterator. - - \sa Q3ValueListIterator, Q3ValueList -*/ - -/*! - \fn Q3ValueListConstIterator::Q3ValueListConstIterator() - - Constructs an unitialized iterator. -*/ - -/*! - \fn Q3ValueListConstIterator::Q3ValueListConstIterator(const Q3ValueListConstIterator &o) - \fn Q3ValueListConstIterator::Q3ValueListConstIterator(const typename QLinkedList::const_iterator &o) - \fn Q3ValueListConstIterator::Q3ValueListConstIterator(const typename QLinkedList::iterator &o) - - Constructs a copy of iterator \a o. -*/ - -/*! - \typedef Q3ValueList::Iterator - - This iterator is an instantiation of Q3ValueListIterator for the - same type as this Q3ValueList. In other words, if you instantiate - Q3ValueList, Iterator is a Q3ValueListIterator. Several - member function use it, such as Q3ValueList::begin(), which returns - an iterator pointing to the first item in the list. - - Functionally, this is almost the same as ConstIterator. The only - difference is that you cannot use ConstIterator for non-const - operations, and that the compiler can often generate better code - if you use ConstIterator. - - \sa Q3ValueListIterator ConstIterator -*/ - -/*! - \typedef Q3ValueList::ConstIterator - - This iterator is an instantiation of Q3ValueListConstIterator for - the same type as this Q3ValueList. In other words, if you - instantiate Q3ValueList, ConstIterator is a - Q3ValueListConstIterator. Several member function use it, such - as Q3ValueList::begin(), which returns an iterator pointing to the - first item in the list. - - Functionally, this is almost the same as Iterator. The only - difference is you cannot use ConstIterator for non-const - operations, and that the compiler can often generate better code - if you use ConstIterator. - - \sa Q3ValueListIterator Iterator -*/ - -/*! - \fn Q3ValueList::operator QList() const - - Automatically converts a Q3ValueList into a QList. -*/ diff --git a/doc/src/q3valuestack.qdoc b/doc/src/q3valuestack.qdoc deleted file mode 100644 index e3ae677..0000000 --- a/doc/src/q3valuestack.qdoc +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3ValueStack - \brief The Q3ValueStack class is a value-based template class that provides a stack. - \compat - - Define a template instance Q3ValueStack\ to create a stack of - values that all have the class X. - - Note that Q3ValueStack does not store pointers to the members of - the stack; it holds a copy of every member. That is why these - kinds of classes are called "value based"; Q3PtrStack, Q3PtrList, - Q3Dict, etc., are "pointer based". - - A stack is a last in, first out (LIFO) structure. Items are added - to the top of the stack with push() and retrieved from the top - with pop(). The top() function provides access to the topmost item - without removing it. - - Example: - \snippet doc/src/snippets/code/doc_src_q3valuestack.qdoc 0 - - Q3ValueStack is a specialized Q3ValueList provided for convenience. - All of Q3ValueList's functionality also applies to Q3PtrStack, for - example the facility to iterate over all elements using - Q3ValueStack::Iterator. See Q3ValueListIterator for further - details. - - Some classes cannot be used within a Q3ValueStack, for example - everything derived from QObject and thus all classes that - implement widgets. Only values can be used in a Q3ValueStack. To - qualify as a value, the class must provide - \list - \i a copy constructor; - \i an assignment operator; - \i a default constructor, i.e. a constructor that does not take any arguments. - \endlist - - Note that C++ defaults to field-by-field assignment operators and - copy constructors if no explicit version is supplied. In many - cases this is sufficient. -*/ - - -/*! - \fn Q3ValueStack::Q3ValueStack() - - Constructs an empty stack. -*/ - -/*! - \fn Q3ValueStack::~Q3ValueStack() - - Destroys the stack. References to the values in the stack and all - iterators of this stack become invalidated. Because Q3ValueStack is - highly tuned for performance, you won't see warnings if you use - invalid iterators because it is impossible for an iterator to - check whether or not it is valid. -*/ - - -/*! - \fn void Q3ValueStack::push( const T& d ) - - Adds element, \a d, to the top of the stack. Last in, first out. - - This function is equivalent to append(). - - \sa pop(), top() -*/ - -/*! - \fn T& Q3ValueStack::top() - - Returns a reference to the top item of the stack or the item - referenced by end() if no such item exists. Note that you must not - change the value the end() iterator points to. - - This function is equivalent to last(). - - \sa pop(), push(), Q3ValueList::fromLast() -*/ - - -/*! - \fn const T& Q3ValueStack::top() const - - \overload - - Returns a reference to the top item of the stack or the item - referenced by end() if no such item exists. - - This function is equivalent to last(). - - \sa pop(), push(), Q3ValueList::fromLast() -*/ - -/*! - \fn T Q3ValueStack::pop() - - Removes the top item from the stack and returns it. - - \sa top() push() -*/ - - - - - diff --git a/doc/src/q3valuevector.qdoc b/doc/src/q3valuevector.qdoc deleted file mode 100644 index 353b7fa..0000000 --- a/doc/src/q3valuevector.qdoc +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class Q3ValueVector - \brief The Q3ValueVector class is a value-based template class that provides a dynamic array. - \compat - - Q3ValueVector is a Qt implementation of an STL-like vector - container. It can be used in your application if the standard \c - vector is not available for your target platforms. - - Q3ValueVector\ defines a template instance to create a vector - of values that all have the class T. Q3ValueVector does not store - pointers to the members of the vector; it holds a copy of every - member. Q3ValueVector is said to be value based; in contrast, - Q3PtrList and Q3Dict are pointer based. - - Q3ValueVector contains and manages a collection of objects of type - T and provides random access iterators that allow the contained - objects to be addressed. Q3ValueVector owns the contained - elements. For more relaxed ownership semantics, see Q3PtrCollection - and friends, which are pointer-based containers. - - Q3ValueVector provides good performance if you append or remove - elements from the end of the vector. If you insert or remove - elements from anywhere but the end, performance is very bad. The - reason for this is that elements must to be copied into new - positions. - - Some classes cannot be used within a Q3ValueVector: for example, - all classes derived from QObject and thus all classes that - implement widgets. Only values can be used in a Q3ValueVector. To - qualify as a value the class must provide: - \list - \i a copy constructor; - \i an assignment operator; - \i a default constructor, i.e., a constructor that does not take any arguments. - \endlist - - Note that C++ defaults to field-by-field assignment operators and - copy constructors if no explicit version is supplied. In many - cases this is sufficient. - - Q3ValueVector uses an STL-like syntax to manipulate and address the - objects it contains. - - Example: - \snippet doc/src/snippets/code/doc_src_q3valuevector.qdoc 0 - - Program output: - \snippet doc/src/snippets/code/doc_src_q3valuevector.qdoc 1 - - As you can see, the most recent change to Joe's salary did not - affect the value in the vector because the vector created a copy - of Joe's entry. - - Many Qt functions return const value vectors; to iterate over - these you should make a copy and iterate over the copy. - - There are several ways to find items in the vector. The begin() - and end() functions return iterators to the beginning and end of - the vector. The advantage of getting an iterator is that you can - move forward or backward from this position by - incrementing/decrementing the iterator. The iterator returned by - end() points to the element which is one past the last element in - the container. The past-the-end iterator is still associated with - the vector it belongs to, however it is \e not dereferenceable; - operator*() will not return a well-defined value. If the vector is - empty(), the iterator returned by begin() will equal the iterator - returned by end(). - - The fastest way to access an element of a vector is by using - operator[]. This function provides random access and will return - a reference to the element located at the specified index. Thus, - you can access every element directly, in constant time, providing - you know the location of the element. It is undefined to access - an element that does not exist (your application will probably - crash). For example: - - \snippet doc/src/snippets/code/doc_src_q3valuevector.qdoc 2 - - Whenever inserting, removing or referencing elements in a vector, - always make sure you are referring to valid positions. For - example: - - \snippet doc/src/snippets/code/doc_src_q3valuevector.qdoc 3 - - The iterators provided by vector are random access iterators, - therefore you can use them with many generic algorithms, for - example, algorithms provided by the STL. - - It is safe to have multiple iterators on the vector at the same - time. Since Q3ValueVector manages memory dynamically, all iterators - can become invalid if a memory reallocation occurs. For example, - if some member of the vector is removed, iterators that point to - the removed element and to all following elements become - invalidated. Inserting into the middle of the vector will - invalidate all iterators. For convenience, the function back() - returns a reference to the last element in the vector, and front() - returns a reference to the first element. If the vector is - empty(), both back() and front() have undefined behavior (your - application will crash or do unpredictable things). Use back() and - front() with caution, for example: - - \snippet doc/src/snippets/code/doc_src_q3valuevector.qdoc 4 - - Because Q3ValueVector manages memory dynamically, it is recommended - that you contruct a vector with an initial size. Inserting and - removing elements happens fastest when: - \list - \i Inserting or removing elements happens at the end() of the - vector; - \i The vector does not need to allocate additional memory. - \endlist - - By creating a Q3ValueVector with a sufficiently large initial size, - there will be less memory allocations. Do not use an initial size - that is too big, since it will still take time to construct all - the empty entries, and the extra space will be wasted if it is - never used. - - Because Q3ValueVector is value-based there is no need to be careful - about deleting elements in the vector. The vector holds its own - copies and will free them if the corresponding member or the - vector itself is deleted. You can force the vector to free all of - its items with clear(). - - Q3ValueVector is shared implicitly, which means it can be copied in - constant time. If multiple Q3ValueVector instances share the same - data and one needs to modify its contents, this modifying instance - makes a copy and modifies its private copy; it thus does not - affect the other instances. This is often called "copy on write". - If a Q3ValueVector is being used in a multi-threaded program, you - must protect all access to the vector. See QMutex. - - There are several ways to insert elements into the vector. The - push_back() function insert elements into the end of the vector, - and is usually fastest. The insert() function can be used to add - elements at specific positions within the vector. - - Items can be also be removed from the vector in several ways. - There are several variants of the erase() function which removes a - specific element, or range of elements, from the vector. - - Q3ValueVector stores its elements in contiguous memory. This means - that you can use a Q3ValueVector in any situation that requires an - array. -*/ - -/*! - \fn Q3ValueVector::Q3ValueVector() - - Constructs an empty vector without any elements. To create a - vector which reserves an initial amount of space for elements, use - \c Q3ValueVector(size_type n). -*/ - -/*! - \fn Q3ValueVector::Q3ValueVector( const Q3ValueVector& v ) - - Constructs a copy of \a v. - - This operation costs O(1) time because Q3ValueVector is implicitly - shared. - - The first modification to the vector does takes O(n) time, because - the elements must be copied. -*/ - -/*! - \fn Q3ValueVector::Q3ValueVector( const std::vector& v ) - - This operation costs O(n) time because \a v is copied. -*/ - -/*! - \fn Q3ValueVector::Q3ValueVector( QVector::size_type n, const T& val ) - - Constructs a vector with an initial size of \a n elements. Each - element is initialized with the value of \a val. -*/ - -/*! - \fn Q3ValueVector& Q3ValueVector::operator=( const Q3ValueVector& v ) - - Assigns \a v to this vector and returns a reference to this vector. - - All iterators of the current vector become invalidated by this - operation. The cost of such an assignment is O(1) since - Q3ValueVector is implicitly shared. -*/ - -/*! - \fn Q3ValueVector& Q3ValueVector::operator=( const std::vector& v ) - - \overload - - Assigns \a v to this vector and returns a reference to this vector. - - All iterators of the current vector become invalidated by this - operation. The cost of this assignment is O(n) since \a v is - copied. -*/ - -/*! - \fn T &Q3ValueVector::at( int i , bool* ok ) - - Returns a reference to the element with index \a i. If \a ok is - non-null, and the index \a i is out of range, *\a ok is set to - FALSE and the returned reference is undefined. If the index \a i - is within the range of the vector, and \a ok is non-null, *\a ok - is set to TRUE and the returned reference is well defined. -*/ - -/*! - \fn const T &Q3ValueVector::at( int i , bool* ok ) const - - \overload - - Returns a const reference to the element with index \a i. If \a ok - is non-null, and the index \a i is out of range, *\a ok is set to - FALSE and the returned reference is undefined. If the index \a i - is within the range of the vector, and \a ok is non-null, *\a ok - is set to TRUE and the returned reference is well defined. -*/ - -/*! - \fn void Q3ValueVector::resize( int n, const T& val = T() ) - - Changes the size of the vector to \a n. If \a n is greater than - the current size(), elements are added to the end and initialized - with the value of \a val. If \a n is less than size(), elements - are removed from the end. If \a n is equal to size() nothing - happens. -*/ diff --git a/doc/src/qalgorithms.qdoc b/doc/src/qalgorithms.qdoc deleted file mode 100644 index 7634322..0000000 --- a/doc/src/qalgorithms.qdoc +++ /dev/null @@ -1,651 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \headerfile - \title Generic Algorithms - \ingroup architecture - - \brief The header provides generic template-based algorithms. - - Qt provides a number of global template functions in \c - that work on containers and perform well-know - algorithms. You can use these algorithms with any \l {container - class} that provides STL-style iterators, including Qt's QList, - QLinkedList, QVector, QMap, and QHash classes. - - These functions have taken their inspiration from similar - functions available in the STL \c header. Most of them - have a direct STL equivalent; for example, qCopyBackward() is the - same as STL's copy_backward() algorithm. - - If STL is available on all your target platforms, you can use the - STL algorithms instead of their Qt counterparts. One reason why - you might want to use the STL algorithms is that STL provides - dozens and dozens of algorithms, whereas Qt only provides the most - important ones, making no attempt to duplicate functionality that - is already provided by the C++ standard. - - Most algorithms take \l {STL-style iterators} as parameters. The - algorithms are generic in the sense that they aren't bound to a - specific iterator class; you can use them with any iterators that - meet a certain set of requirements. - - Let's take the qFill() algorithm as an example. Unlike QVector, - QList has no fill() function that can be used to fill a list with - a particular value. If you need that functionality, you can use - qFill(): - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 0 - - qFill() takes a begin iterator, an end iterator, and a value. - In the example above, we pass \c list.begin() and \c list.end() - as the begin and end iterators, but this doesn't have to be - the case: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 1 - - Different algorithms can have different requirements for the - iterators they accept. For example, qFill() accepts two - \l {forward iterators}. The iterator types required are specified - for each algorithm. If an iterator of the wrong type is passed (for - example, if QList::ConstIterator is passed as an \l {output - iterator}), you will always get a compiler error, although not - necessarily a very informative one. - - Some algorithms have special requirements on the value type - stored in the containers. For example, qEqual() requires that the - value type supports operator==(), which it uses to compare items. - Similarly, qDeleteAll() requires that the value type is a - non-const pointer type (for example, QWidget *). The value type - requirements are specified for each algorithm, and the compiler - will produce an error if a requirement isn't met. - - \target binaryFind example - - The generic algorithms can be used on other container classes - than those provided by Qt and STL. The syntax of STL-style - iterators is modeled after C++ pointers, so it's possible to use - plain arrays as containers and plain pointers as iterators. A - common idiom is to use qBinaryFind() together with two static - arrays: one that contains a list of keys, and another that - contains a list of associated values. For example, the following - code will look up an HTML entity (e.g., \c &) in the \c - name_table array and return the corresponding Unicode value from - the \c value_table if the entity is recognized: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 2 - - This kind of code is for advanced users only; for most - applications, a QMap- or QHash-based approach would work just as - well: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 3 - - \section1 Types of Iterators - - The algorithms have certain requirements on the iterator types - they accept, and these are specified individually for each - function. The compiler will produce an error if a requirement - isn't met. - - \section2 Input Iterators - - An \e{input iterator} is an iterator that can be used for reading - data sequentially from a container. It must provide the following - operators: \c{==} and \c{!=} for comparing two iterators, unary - \c{*} for retrieving the value stored in the item, and prefix - \c{++} for advancing to the next item. - - The Qt containers' iterator types (const and non-const) are all - input iterators. - - \section2 Output Iterators - - An \e{output iterator} is an iterator that can be used for - writing data sequentially to a container or to some output - stream. It must provide the following operators: unary \c{*} for - writing a value (i.e., \c{*it = val}) and prefix \c{++} for - advancing to the next item. - - The Qt containers' non-const iterator types are all output - iterators. - - \section2 Forward Iterators - - A \e{forward iterator} is an iterator that meets the requirements - of both input iterators and output iterators. - - The Qt containers' non-const iterator types are all forward - iterators. - - \section2 Bidirectional Iterators - - A \e{bidirectional iterator} is an iterator that meets the - requirements of forward iterators but that in addition supports - prefix \c{--} for iterating backward. - - The Qt containers' non-const iterator types are all bidirectional - iterators. - - \section2 Random Access Iterators - - The last category, \e{random access iterators}, is the most - powerful type of iterator. It supports all the requirements of a - bidirectional iterator, and supports the following operations: - - \table - \row \i \c{i += n} \i advances iterator \c i by \c n positions - \row \i \c{i -= n} \i moves iterator \c i back by \c n positions - \row \i \c{i + n} or \c{n + i} \i returns the iterator for the item \c - n positions ahead of iterator \c i - \row \i \c{i - n} \i returns the iterator for the item \c n positions behind of iterator \c i - \row \i \c{i - j} \i returns the number of items between iterators \c i and \c j - \row \i \c{i[n]} \i same as \c{*(i + n)} - \row \i \c{i < j} \i returns true if iterator \c j comes after iterator \c i - \endtable - - QList and QVector's non-const iterator types are random access iterators. - - \sa {container classes}, -*/ - -/*! \fn OutputIterator qCopy(InputIterator begin1, InputIterator end1, OutputIterator begin2) - \relates - - Copies the items from range [\a begin1, \a end1) to range [\a - begin2, ...), in the order in which they appear. - - The item at position \a begin1 is assigned to that at position \a - begin2; the item at position \a begin1 + 1 is assigned to that at - position \a begin2 + 1; and so on. - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 4 - - \sa qCopyBackward(), {input iterators}, {output iterators} -*/ - -/*! \fn BiIterator2 qCopyBackward(BiIterator1 begin1, BiIterator1 end1, BiIterator2 end2) - \relates - - Copies the items from range [\a begin1, \a end1) to range [..., - \a end2). - - The item at position \a end1 - 1 is assigned to that at position - \a end2 - 1; the item at position \a end1 - 2 is assigned to that - at position \a end2 - 2; and so on. - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 5 - - \sa qCopy(), {bidirectional iterators} -*/ - -/*! \fn bool qEqual(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2) - \relates - - Compares the items in the range [\a begin1, \a end1) with the - items in the range [\a begin2, ...). Returns true if all the - items compare equal; otherwise returns false. - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 6 - - This function requires the item type (in the example above, - QString) to implement \c operator==(). - - \sa {input iterators} -*/ - -/*! \fn void qFill(ForwardIterator begin, ForwardIterator end, const T &value) - \relates - - Fills the range [\a begin, \a end) with \a value. - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 7 - - \sa qCopy(), {forward iterators} -*/ - -/*! \fn void qFill(Container &container, const T &value) - \relates - - \overload - - This is the same as qFill(\a{container}.begin(), \a{container}.end(), \a value); -*/ - -/*! \fn InputIterator qFind(InputIterator begin, InputIterator end, const T &value) - \relates - - Returns an iterator to the first occurrence of \a value in a - container in the range [\a begin, \a end). Returns \a end if \a - value isn't found. - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 8 - - This function requires the item type (in the example above, - QString) to implement \c operator==(). - - If the items in the range are in ascending order, you can get - faster results by using qLowerBound() or qBinaryFind() instead of - qFind(). - - \sa qBinaryFind(), {input iterators} -*/ - -/*! \fn void qFind(const Container &container, const T &value) - \relates - - \overload - - This is the same as qFind(\a{container}.begin(), \a{container}.end(), value); -*/ - -/*! \fn void qCount(InputIterator begin, InputIterator end, const T &value, Size &n) - \relates - - Returns the number of occurrences of \a value in the range [\a begin, \a end), - which is returned in \a n. \a n is never initialized, the count is added to \a n. - It is the caller's responsibility to initialize \a n. - - Example: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 9 - - This function requires the item type (in the example above, - \c int) to implement \c operator==(). - - \sa {input iterators} -*/ - -/*! \fn void qCount(const Container &container, const T &value, Size &n) -\relates - -\overload - -Instead of operating on iterators, as in the other overload, this function -operates on the specified \a container to obtain the number of instances -of \a value in the variable passed as a reference in argument \a n. -*/ - -/*! \fn void qSwap(T &var1, T &var2) - \relates - - Exchanges the values of variables \a var1 and \a var2. - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 10 -*/ - -/*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end) - \relates - - Sorts the items in range [\a begin, \a end) in ascending order - using the quicksort algorithm. - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 11 - - The sort algorithm is efficient on large data sets. It operates - in \l {linear-logarithmic time}, O(\e{n} log \e{n}). - - This function requires the item type (in the example above, - \c{int}) to implement \c operator<(). - - If neither of the two items is "less than" the other, the items are - taken to be equal. It is then undefined which one of the two - items will appear before the other after the sort. - - \sa qStableSort(), {random access iterators} -*/ - -/*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan) - \relates - - \overload - - Uses the \a lessThan function instead of \c operator<() to - compare the items. - - For example, here's how to sort the strings in a QStringList - in case-insensitive alphabetical order: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 12 - - To sort values in reverse order, pass - \l{qGreater()}{qGreater()} as the \a lessThan parameter. For - example: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 13 - - If neither of the two items is "less than" the other, the items are - taken to be equal. It is then undefined which one of the two - items will appear before the other after the sort. - - An alternative to using qSort() is to put the items to sort in a - QMap, using the sort key as the QMap key. This is often more - convenient than defining a \a lessThan function. For example, the - following code shows how to sort a list of strings case - insensitively using QMap: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 14 - - \sa QMap -*/ - -/*! \fn void qSort(Container &container) - \relates - - \overload - - This is the same as qSort(\a{container}.begin(), \a{container}.end()); -*/ - -/*! - \fn void qStableSort(RandomAccessIterator begin, RandomAccessIterator end) - \relates - - Sorts the items in range [\a begin, \a end) in ascending order - using a stable sorting algorithm. - - If neither of the two items is "less than" the other, the items are - taken to be equal. The item that appeared before the other in the - original container will still appear first after the sort. This - property is often useful when sorting user-visible data. - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 15 - - The sort algorithm is efficient on large data sets. It operates - in \l {linear-logarithmic time}, O(\e{n} log \e{n}). - - This function requires the item type (in the example above, - \c{int}) to implement \c operator<(). - - \sa qSort(), {random access iterators} -*/ - -/*! - \fn void qStableSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan) - \relates - - \overload - - Uses the \a lessThan function instead of \c operator<() to - compare the items. - - For example, here's how to sort the strings in a QStringList - in case-insensitive alphabetical order: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 16 - - Note that earlier versions of Qt allowed using a lessThan function that took its - arguments by non-const reference. From 4.3 and on this is no longer possible, - the arguments has to be passed by const reference or value. - - To sort values in reverse order, pass - \l{qGreater()}{qGreater()} as the \a lessThan parameter. For - example: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 17 - - If neither of the two items is "less than" the other, the items are - taken to be equal. The item that appeared before the other in the - original container will still appear first after the sort. This - property is often useful when sorting user-visible data. -*/ - -/*! - \fn void qStableSort(Container &container) - \relates - - \overload - - This is the same as qStableSort(\a{container}.begin(), \a{container}.end()); -*/ - -/*! \fn RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) - \relates - - Performs a binary search of the range [\a begin, \a end) and - returns the position of the first ocurrence of \a value. If no - such item is found, returns the position where it should be - inserted. - - The items in the range [\a begin, \e end) must be sorted in - ascending order; see qSort(). - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 18 - - This function requires the item type (in the example above, - \c{int}) to implement \c operator<(). - - qLowerBound() can be used in conjunction with qUpperBound() to - iterate over all occurrences of the same value: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 19 - - \sa qUpperBound(), qBinaryFind() -*/ - -/*! - \fn RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) - \relates - - \overload - - Uses the \a lessThan function instead of \c operator<() to - compare the items. - - Note that the items in the range must be sorted according to the order - specified by the \a lessThan object. -*/ - -/*! - \fn void qLowerBound(const Container &container, const T &value) - \relates - - \overload - - For read-only iteration over containers, this function is broadly equivalent to - qLowerBound(\a{container}.begin(), \a{container}.end(), value). However, since it - returns a const iterator, you cannot use it to modify the container; for example, - to insert items. -*/ - -/*! \fn RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) - \relates - - Performs a binary search of the range [\a begin, \a end) and - returns the position of the one-past-the-last occurrence of \a - value. If no such item is found, returns the position where the - item should be inserted. - - The items in the range [\a begin, \e end) must be sorted in - ascending order; see qSort(). - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 20 - - This function requires the item type (in the example above, - \c{int}) to implement \c operator<(). - - qUpperBound() can be used in conjunction with qLowerBound() to - iterate over all occurrences of the same value: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 21 - - \sa qLowerBound(), qBinaryFind() -*/ - -/*! - \fn RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) - \relates - - \overload - - Uses the \a lessThan function instead of \c operator<() to - compare the items. - - Note that the items in the range must be sorted according to the order - specified by the \a lessThan object. -*/ - -/*! - \fn void qUpperBound(const Container &container, const T &value) - \relates - - \overload - - This is the same as qUpperBound(\a{container}.begin(), \a{container}.end(), value); -*/ - - -/*! \fn RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value) - \relates - - Performs a binary search of the range [\a begin, \a end) and - returns the position of an occurrence of \a value. If there are - no occurrences of \a value, returns \a end. - - The items in the range [\a begin, \a end) must be sorted in - ascending order; see qSort(). - - If there are many occurrences of the same value, any one of them - could be returned. Use qLowerBound() or qUpperBound() if you need - finer control. - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 22 - - This function requires the item type (in the example above, - QString) to implement \c operator<(). - - See the \l{#binaryFind example}{detailed - description} for an example usage. - - \sa qLowerBound(), qUpperBound(), {random access iterators} -*/ - -/*! \fn RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) - \relates - - \overload - - Uses the \a lessThan function instead of \c operator<() to - compare the items. - - Note that the items in the range must be sorted according to the order - specified by the \a lessThan object. -*/ - -/*! - \fn void qBinaryFind(const Container &container, const T &value) - \relates - - \overload - - This is the same as qBinaryFind(\a{container}.begin(), \a{container}.end(), value); -*/ - - -/*! - \fn void qDeleteAll(ForwardIterator begin, ForwardIterator end) - \relates - - Deletes all the items in the range [\a begin, \a end) using the - C++ \c delete operator. The item type must be a pointer type (for - example, \c{QWidget *}). - - Example: - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 23 - - Notice that qDeleteAll() doesn't remove the items from the - container; it merely calls \c delete on them. In the example - above, we call clear() on the container to remove the items. - - This function can also be used to delete items stored in - associative containers, such as QMap and QHash. Only the objects - stored in each container will be deleted by this function; objects - used as keys will not be deleted. - - \sa {forward iterators} -*/ - -/*! - \fn void qDeleteAll(const Container &c) - \relates - - \overload - - This is the same as qDeleteAll(\a{c}.begin(), \a{c}.end()). -*/ - -/*! \fn LessThan qLess() - \relates - - Returns a functional object, or functor, that can be passed to qSort() - or qStableSort(). - - Example: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 24 - - \sa {qGreater()}{qGreater()} -*/ - -/*! \fn LessThan qGreater() - \relates - - Returns a functional object, or functor, that can be passed to qSort() - or qStableSort(). - - Example: - - \snippet doc/src/snippets/code/doc_src_qalgorithms.qdoc 25 - - \sa {qLess()}{qLess()} -*/ diff --git a/doc/src/qcache.qdoc b/doc/src/qcache.qdoc deleted file mode 100644 index 6c88ede..0000000 --- a/doc/src/qcache.qdoc +++ /dev/null @@ -1,244 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QCache - \brief The QCache class is a template class that provides a cache. - - \ingroup tools - \ingroup shared - \mainclass - \reentrant - - QCache\ defines a cache that stores objects of type T - associated with keys of type Key. For example, here's the - definition of a cache that stores objects of type Employee - associated with an integer key: - - \snippet doc/src/snippets/code/doc_src_qcache.qdoc 0 - - Here's how to insert an object in the cache: - - \snippet doc/src/snippets/code/doc_src_qcache.qdoc 1 - - The advantage of using QCache over some other key-based data - structure (such as QMap or QHash) is that QCache automatically - takes ownership of the objects that are inserted into the cache and - deletes them to make room for new objects, if necessary. When - inserting an object into the cache, you can specify a \e{cost}, - which should bear some approximate relationship to the amount of - memory taken by the object. When the sum of all objects' costs - (totalCost()) exceeds the cache's limit (maxCost()), QCache starts - deleting objects in the cache to keep under the limit, starting with - less recently accessed objects. - - By default, QCache's maxCost() is 100. You can specify a - different value in the QCache constructor: - - \snippet doc/src/snippets/code/doc_src_qcache.qdoc 2 - - Each time you call insert(), you can specify a cost as third - argument (after the key and a pointer to the object to insert). - After the call, the inserted object is owned by the QCache, which - may delete it at any time to make room for other objects. - - To look up objects in the cache, use object() or - operator[](). This function looks up an object by its key, and - returns either a pointer to the cached object (which is owned by - the cache) or 0. - - If you want to remove an object from the cache for a particular key, - call remove(). This will also delete the object. If you want to - remove an object from the cache without the QCache deleting it, use - take(). - - \sa QPixmapCache, QHash, QMap -*/ - -/*! \fn QCache::QCache(int maxCost = 100) - - Constructs a cache whose contents will never have a total cost - greater than \a maxCost. -*/ - -/*! \fn QCache::~QCache() - - Destroys the cache. Deletes all the objects in the cache. -*/ - -/*! \fn int QCache::maxCost() const - - Returns the maximum allowed total cost of the cache. - - \sa setMaxCost(), totalCost() -*/ - -/*! \fn void QCache::setMaxCost(int cost) - - Sets the maximum allowed total cost of the cache to \a cost. If - the current total cost is greater than \a cost, some objects are - deleted immediately. - - \sa maxCost(), totalCost() -*/ - -/*! \fn int QCache::totalCost() const - - Returns the total cost of the objects in the cache. - - This value is normally below maxCost(), but QCache makes an - exception for Qt's \l{implicitly shared} classes. If a cached - object shares its internal data with another instance, QCache may - keep the object lying around, possibly contributing to making - totalCost() larger than maxCost(). - - \sa setMaxCost() -*/ - -/*! \fn int QCache::size() const - - Returns the number of objects in the cache. - - \sa isEmpty() -*/ - -/*! \fn int QCache::count() const - - Same as size(). -*/ - -/*! \fn bool QCache::isEmpty() const - - Returns true if the cache contains no objects; otherwise - returns false. - - \sa size() -*/ - -/*! \fn QList QCache::keys() const - - Returns a list of the keys in the cache. -*/ - -/*! \fn void QCache::clear(); - - Deletes all the objects in the cache. - - \sa remove(), take() -*/ - - -/*! \fn bool QCache::insert(const Key &key, T *object, int cost = 1) - - Inserts \a object into the cache with key \a key and - associated cost \a cost. Any object with the same key already in - the cache will be removed. - - After this call, \a object is owned by the QCache and may be - deleted at any time. In particular, if \a cost is greater than - maxCost(), the object will be deleted immediately. - - The function returns true if the object was inserted into the - cache; otherwise it returns false. - - \sa take(), remove() -*/ - -/*! \fn T *QCache::object(const Key &key) const - - Returns the object associated with key \a key, or 0 if the key does - not exist in the cache. - - \warning The returned object is owned by QCache and may be - deleted at any time. - - \sa take(), remove() -*/ - -/*! \fn bool QCache::contains(const Key &key) const - - Returns true if the cache contains an object associated with key \a - key; otherwise returns false. - - \sa take(), remove() -*/ - -/*! \fn T *QCache::operator[](const Key &key) const - - Returns the object associated with key \a key, or 0 if the key does - not exist in the cache. - - This is the same as object(). - - \warning The returned object is owned by QCache and may be - deleted at any time. -*/ - -/*! \fn bool QCache::remove(const Key &key) - - Deletes the object associated with key \a key. Returns true if the - object was found in the cache; otherwise returns false. - - \sa take(), clear() -*/ - -/*! \fn T *QCache::take(const Key &key) - - Takes the object associated with key \a key out of the cache - without deleting it. Returns a pointer to the object taken out, or - 0 if the key does not exist in the cache. - - The ownership of the returned object is passed to the caller. - - \sa remove() -*/ - -/*! - \fn QCache::QCache(int maxCost, int dummy) - - Use QCache(int) instead. -*/ - -/*! - \fn T *QCache::find(const Key &key) const - - Use object() instead. -*/ diff --git a/doc/src/qcolormap.qdoc b/doc/src/qcolormap.qdoc deleted file mode 100644 index 95f7dc0..0000000 --- a/doc/src/qcolormap.qdoc +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QColormap - \ingroup multimedia - - \brief The QColormap class maps device independent QColors to device - dependent pixel values. -*/ - -/*! \enum QColormap::Mode - - This enum describes how QColormap maps device independent RGB - values to device dependent pixel values. - - \value Direct Pixel values are derived directly from the RGB - values, also known as "True Color." - - \value Indexed Pixel values represent indexes into a vector of - available colors, i.e. QColormap uses the index of the color that - most closely matches an RGB value. - - \value Gray Similar to \c Indexed, pixel values represent a vector - of available gray tones. QColormap uses the index of the gray - tone that most closely matches the computed gray tone of an RGB - value. -*/ - -/*! - \fn QColormap QColormap::instance(int screen) - - Returns the colormap for the specified \a screen. If \a screen is - -1, this function returns the colormap for the default screen. -*/ - -/*! - \fn QColormap::QColormap(const QColormap &colormap) - - Constructs a copy of another \a colormap. -*/ - -/*! - \fn QColormap::~QColormap() - - Destroys the colormap. -*/ - -/*! - \fn int QColormap::size() const - - Returns the size of the colormap for \c Indexed and \c Gray modes; - Returns -1 for \c Direct mode. - - \sa colormap() -*/ - -/*! - \fn uint QColormap::pixel(const QColor &color) const - - Returns a device dependent pixel value for the \a color. - - \sa colorAt() -*/ - -/*! - \fn int QColormap::depth() const - - Returns the depth of the device. - - \sa size() -*/ - -/*! - \fn QColormap::Mode QColormap::mode() const - - Returns the mode of this colormap. - - \sa QColormap::Mode -*/ - -/*! - \fn const QColor QColormap::colorAt(uint pixel) const - - Returns a QColor for the \a pixel. - - \sa pixel() -*/ - -/*! - \fn const QVector QColormap::colormap() const - - Returns a vector of colors which represents the devices colormap - for \c Indexed and \c Gray modes. This function returns an empty - vector for \c Direct mode. - - \sa size() -*/ - -/*! \fn HPALETTE QColormap::hPal() - - This function is only available on Windows. - - Returns an handle to the HPALETTE used by this colormap. If no - HPALETTE is being used, this function returns zero. -*/ - -/*! \since 4.2 - - \fn QColormap &QColormap::operator=(const QColormap &colormap) - - Assigns the given \a colormap to \e this color map and returns - a reference to \e this color map. -*/ diff --git a/doc/src/qdesktopwidget.qdoc b/doc/src/qdesktopwidget.qdoc deleted file mode 100644 index 56a882d..0000000 --- a/doc/src/qdesktopwidget.qdoc +++ /dev/null @@ -1,266 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QDesktopWidget - \brief The QDesktopWidget class provides access to screen information on multi-head systems. - - \ingroup advanced - \ingroup desktop - \ingroup environment - \mainclass - - QApplication::desktop() function should be used to get an instance - of the QDesktopWidget. - - Systems with more than one graphics card and monitor can manage the - physical screen space available either as multiple desktops, or as a - large virtual desktop, which usually has the size of the bounding - rectangle of all the screens (see virtualDesktop). For an - application, one of the available screens is the primary screen, i.e. - the screen where the main widget resides (see primaryScreen). All - windows opened in the context of the application should be - constrained to the boundaries of the primary screen; for example, - it would be inconvenient if a dialog box popped up on a different - screen, or split over two screens. - - The QDesktopWidget provides information about the geometry of the - available screens with screenGeometry(). The number of screens - available is returned by screenCount, and the screenCountChanged - signal is emitted when screens are added or removed during runtime. - The screen number that a particular point or widget is located in - is returned by screenNumber(). - - Widgets provided by Qt use this class, for example, to place - tooltips, menus and dialog boxes according to the parent or - application widget. Applications can use this class to save window - positions, or to place child widgets and dialogs on one particular - screen. - - \img qdesktopwidget.png Managing Multiple Screens - - In the illustration above, Application One's primary screen is - screen 0, and App Two's primary screen is screen 1. - - \target multiple screens note - \note QDesktopWidget inherits the QWidget properties, width() and - height(), which specify the size of the desktop. However, for - desktops with multiple screens, the size of the desktop is the union - of all the screen sizes, so width() and height() should \e not be - used for computing the size of a widget to be placed on one of the - screens. The correct width and height values are obtained using - availableGeometry() or screenGeometry() for a particular screen. - - \sa QApplication, QApplication::desktop(), QX11Info::appRootWindow() -*/ - -/*! - \fn QDesktopWidget::QDesktopWidget() - - \internal - - Creates the desktop widget. - - If the system supports a virtual desktop, this widget will have - the size of the virtual desktop; otherwise this widget will have - the size of the primary screen. - - Instead of using QDesktopWidget directly, use QApplication::desktop(). -*/ - -/*! - \fn QDesktopWidget::~QDesktopWidget() - - \internal - - Destroys the desktop widget and frees any allocated resources. -*/ - -/*! - \fn int QDesktopWidget::numScreens() const - - Returns the number of available screens. - - \obsolete - - This function is deprecated. Use screenCount instead. - - \sa primaryScreen -*/ - -/*! - \fn QWidget *QDesktopWidget::screen(int screen) - - Returns a widget that represents the screen with index \a screen - (a value of -1 means the default screen). - - If the system uses a virtual desktop, the returned widget will - have the geometry of the entire virtual desktop; i.e., bounding - every \a screen. - - \sa primaryScreen, screenCount, virtualDesktop -*/ - -/*! - \fn const QRect QDesktopWidget::availableGeometry(int screen) const - - Returns the available geometry of the screen with index \a screen. What - is available will be subrect of screenGeometry() based on what the - platform decides is available (for example excludes the dock and menu bar - on Mac OS X, or the task bar on Windows). The default screen is used if - \a screen is -1. - - \sa screenNumber(), screenGeometry() -*/ - -/*! - \fn const QRect QDesktopWidget::availableGeometry(const QWidget *widget) const - \overload - - Returns the available geometry of the screen which contains \a widget. - - \sa screenGeometry() -*/ - -/*! - \fn const QRect QDesktopWidget::availableGeometry(const QPoint &p) const - \overload - - Returns the available geometry of the screen which contains \a p. - - \sa screenGeometry() -*/ - - -/*! - \fn const QRect QDesktopWidget::screenGeometry(int screen) const - - Returns the geometry of the screen with index \a screen. The default - screen is used if \a screen is -1. - - \sa screenNumber() -*/ - -/*! - \fn const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const - \overload - - Returns the geometry of the screen which contains \a widget. -*/ - -/*! - \fn const QRect QDesktopWidget::screenGeometry(const QPoint &p) const - \overload - - Returns the geometry of the screen which contains \a p. -*/ - - -/*! - \fn int QDesktopWidget::screenNumber(const QWidget *widget) const - - Returns the index of the screen that contains the largest - part of \a widget, or -1 if the widget not on a screen. - - \sa primaryScreen -*/ - -/*! - \fn int QDesktopWidget::screenNumber(const QPoint &point) const - - \overload - Returns the index of the screen that contains the \a point, or the - screen which is the shortest distance from the \a point. - - \sa primaryScreen -*/ - -/*! - \fn void QDesktopWidget::resizeEvent(QResizeEvent *event) - \reimp -*/ - -/*! - \fn void QDesktopWidget::resized(int screen) - - This signal is emitted when the size of \a screen changes. -*/ - -/*! - \fn void QDesktopWidget::workAreaResized(int screen) - - This signal is emitted when the work area available on \a screen changes. -*/ - -/*! - \property QDesktopWidget::screenCount - \brief the number of screens currently available on the system. - - \since 4.6 - - \sa screenCountChanged() -*/ - -/*! - \property QDesktopWidget::primaryScreen - \brief the index of the screen that is configured to be the primary screen - on the system. -*/ - -/*! - \property QDesktopWidget::virtualDesktop - - \brief if the system manages the available screens in a virtual desktop. - - For virtual desktops, screen() will always return the same widget. - The size of the virtual desktop is the size of this desktop - widget. -*/ - -/*! - \fn void QDesktopWidget::screenCountChanged(int newCount) - - \since 4.6 - - This signal is emitted when the number of screens changes to \a newCount. - - \sa screenCount -*/ diff --git a/doc/src/qiterator.qdoc b/doc/src/qiterator.qdoc deleted file mode 100644 index 416b4bc..0000000 --- a/doc/src/qiterator.qdoc +++ /dev/null @@ -1,1431 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QListIterator - \inmodule QtCore - - \brief The QListIterator class provides a Java-style const iterator for QList and QQueue. - - QList has both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - An alternative to using iterators is to use index positions. Most - QList member functions take an index as their first parameter, - making it possible to access, modify, and remove items without - using iterators. - - QListIterator\ allows you to iterate over a QList\ (or a - QQueue\). If you want to modify the list as you iterate over - it, use QMutableListIterator\ instead. - - The QListIterator constructor takes a QList as argument. After - construction, the iterator is located at the very beginning of - the list (before the first item). Here's how to iterate over all - the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 0 - - The next() function returns the next item in the list and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, and returns the second - item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 1 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. - - Multiple iterators can be used on the same list. If the list is - modified while a QListIterator is active, the QListIterator will - continue iterating over the original list, ignoring the modified - copy. - - \sa QMutableListIterator, QList::const_iterator -*/ - -/*! - \class QLinkedListIterator - \inmodule QtCore - - \brief The QLinkedListIterator class provides a Java-style const iterator for QLinkedList. - - QLinkedList has both \l{Java-style iterators} and - \l{STL-style iterators}. The Java-style iterators are more - high-level and easier to use than the STL-style iterators; on the - other hand, they are slightly less efficient. - - QLinkedListIterator\ allows you to iterate over a - QLinkedList\. If you want to modify the list as you iterate - over it, use QMutableLinkedListIterator\ instead. - - The QLinkedListIterator constructor takes a QLinkedList as - argument. After construction, the iterator is located at the very - beginning of the list (before the first item). Here's how to - iterate over all the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 2 - - The next() function returns the next item in the list and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, and returns the second - item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 3 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. - - Multiple iterators can be used on the same list. If the list is - modified while a QLinkedListIterator is active, the - QLinkedListIterator will continue iterating over the original - list, ignoring the modified copy. - - \sa QMutableLinkedListIterator, QLinkedList::const_iterator -*/ - -/*! - \class QVectorIterator - \inmodule QtCore - \brief The QVectorIterator class provides a Java-style const iterator for QVector and QStack. - - QVector has both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - An alternative to using iterators is to use index positions. Most - QVector member functions take an index as their first parameter, - making it possible to access, insert, and remove items without - using iterators. - - QVectorIterator\ allows you to iterate over a QVector\ - (or a QStack\). If you want to modify the vector as you - iterate over it, use QMutableVectorIterator\ instead. - - The QVectorIterator constructor takes a QVector as argument. - After construction, the iterator is located at the very beginning - of the vector (before the first item). Here's how to iterate over - all the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 4 - - The next() function returns the next item in the vector and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, returning the second - item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 5 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. - - Multiple iterators can be used on the same vector. If the vector - is modified while a QVectorIterator is active, the QVectorIterator - will continue iterating over the original vector, ignoring the - modified copy. - - \sa QMutableVectorIterator, QVector::const_iterator -*/ - -/*! - \class QSetIterator - \inmodule QtCore - \brief The QSetIterator class provides a Java-style const iterator for QSet. - - QSet supports both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - QSetIterator\ allows you to iterate over a QSet\. If you - want to modify the set as you iterate over it, use - QMutableSetIterator\ instead. - - The constructor takes a QSet as argument. After construction, the - iterator is located at the very beginning of the set (before - the first item). Here's how to iterate over all the elements - sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 6 - - The next() function returns the next item in the set and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, returning the second - item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 7 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. - - Multiple iterators can be used on the same set. If the set - is modified while a QSetIterator is active, the QSetIterator - will continue iterating over the original set, ignoring the - modified copy. - - \sa QMutableSetIterator, QSet::const_iterator -*/ - -/*! - \class QMutableListIterator - \inmodule QtCore - - \brief The QMutableListIterator class provides a Java-style non-const iterator for QList and QQueue. - - QList has both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - An alternative to using iterators is to use index positions. Most - QList member functions take an index as their first parameter, - making it possible to access, insert, and remove items without - using iterators. - - QMutableListIterator\ allows you to iterate over a QList\ - (or a QQueue\) and modify the list. If you don't want to - modify the list (or have a const QList), use the slightly faster - QListIterator\ instead. - - The QMutableListIterator constructor takes a QList as argument. - After construction, the iterator is located at the very beginning - of the list (before the first item). Here's how to iterate over - all the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 8 - - The next() function returns the next item in the list and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, returning the second - item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 9 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. - - If you want to remove items as you iterate over the list, use - remove(). If you want to modify the value of an item, use - setValue(). If you want to insert a new item in the list, use - insert(). - - Example: - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 10 - - The example traverses a list, replacing negative numbers with - their absolute values, and eliminating zeroes. - - Only one mutable iterator can be active on a given list at any - time. Furthermore, no changes should be done directly to the list - while the iterator is active (as opposed to through the - iterator), since this could invalidate the iterator and lead to - undefined behavior. - - \sa QListIterator, QList::iterator -*/ - -/*! - \class QMutableLinkedListIterator - \inmodule QtCore - - \brief The QMutableLinkedListIterator class provides a Java-style non-const iterator for QLinkedList. - - QLinkedList has both \l{Java-style iterators} and - \l{STL-style iterators}. The Java-style iterators are more - high-level and easier to use than the STL-style iterators; on the - other hand, they are slightly less efficient. - - QMutableLinkedListIterator\ allows you to iterate over a - QLinkedList\ and modify the list. If you don't want to modify - the list (or have a const QLinkedList), use the slightly faster - QLinkedListIterator\ instead. - - The QMutableLinkedListIterator constructor takes a QLinkedList as - argument. After construction, the iterator is located at the very - beginning of the list (before the first item). Here's how to - iterate over all the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 11 - - The next() function returns the next item in the list and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, returning the second - item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 12 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. - - If you want to remove items as you iterate over the list, use - remove(). If you want to modify the value of an item, use - setValue(). If you want to insert a new item in the list, use - insert(). - - Example: - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 13 - - The example traverses a list, replacing negative numbers with - their absolute values, and eliminating zeroes. - - Only one mutable iterator can be active on a given list at any - time. Furthermore, no changes should be done directly to the list - while the iterator is active (as opposed to through the - iterator), since this could invalidate the iterator and lead to - undefined behavior. - - \sa QLinkedListIterator, QLinkedList::iterator -*/ - -/*! - \class QMutableVectorIterator - \inmodule QtCore - - \brief The QMutableVectorIterator class provides a Java-style non-const iterator for QVector and QStack. - - QVector has both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - An alternative to using iterators is to use index positions. Most - QVector member functions take an index as their first parameter, - making it possible to access, insert, and remove items without - using iterators. - - QMutableVectorIterator\ allows you to iterate over a - QVector\ and modify the vector. If you don't want to modify - the vector (or have a const QVector), use the slightly faster - QVectorIterator\ instead. - - The QMutableVectorIterator constructor takes a QVector as - argument. After construction, the iterator is located at the very - beginning of the list (before the first item). Here's how to - iterate over all the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 14 - - The next() function returns the next item in the vector and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, returning the second - item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 15 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. - - If you want to remove items as you iterate over the vector, use - remove(). If you want to modify the value of an item, use - setValue(). If you want to insert a new item in the vector, use - insert(). - - Example: - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 16 - - The example traverses a vector, replacing negative numbers with - their absolute values, and eliminating zeroes. - - Only one mutable iterator can be active on a given vector at any - time. Furthermore, no changes should be done directly to the - vector while the iterator is active (as opposed to through the - iterator), since this could invalidate the iterator and lead to - undefined behavior. - - \sa QVectorIterator, QVector::iterator -*/ - -/*! - \class QMutableSetIterator - \inmodule QtCore - \since 4.2 - - \brief The QMutableSetIterator class provides a Java-style non-const iterator for QSet. - - QSet has both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - QMutableSetIterator\ allows you to iterate over a QSet\ - and remove items from the set as you iterate. If you don't want - to modify the set (or have a const QSet), use the slightly faster - QSetIterator\ instead. - - The QMutableSetIterator constructor takes a QSet as argument. - After construction, the iterator is located at the very beginning - of the set (before the first item). Here's how to iterate over - all the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 17 - - The next() function returns the next item in the set and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, returning the second - item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 18 - - If you want to remove items as you iterate over the set, use - remove(). - - Only one mutable iterator can be active on a given set at any - time. Furthermore, no changes should be done directly to the set - while the iterator is active (as opposed to through the - iterator), since this could invalidate the iterator and lead to - undefined behavior. - - \sa QSetIterator, QSet::iterator -*/ - -/*! - \fn QListIterator::QListIterator(const QList &list) - \fn QLinkedListIterator::QLinkedListIterator(const QLinkedList &list) - \fn QMutableListIterator::QMutableListIterator(QList &list) - \fn QMutableLinkedListIterator::QMutableLinkedListIterator(QLinkedList &list) - - Constructs an iterator for traversing \a list. The iterator is - set to be at the front of the list (before the first item). - - \sa operator=() -*/ - -/*! - \fn QVectorIterator::QVectorIterator(const QVector &vector) - \fn QMutableVectorIterator::QMutableVectorIterator(QVector &vector) - - Constructs an iterator for traversing \a vector. The iterator is - set to be at the front of the vector (before the first item). - - \sa operator=() -*/ - -/*! - \fn QSetIterator::QSetIterator(const QSet &set) - \fn QMutableSetIterator::QMutableSetIterator(QSet &set) - - Constructs an iterator for traversing \a set. The iterator is - set to be at the front of the set (before the first item). - - \sa operator=() -*/ - -/*! - \fn QMutableListIterator::~QMutableListIterator() - \fn QMutableLinkedListIterator::~QMutableLinkedListIterator() - \fn QMutableVectorIterator::~QMutableVectorIterator() - \fn QMutableSetIterator::~QMutableSetIterator() - - Destroys the iterator. - - \sa operator=() -*/ - -/*! \fn QMutableListIterator &QMutableListIterator::operator=(QList &list) - \fn QMutableLinkedListIterator &QMutableLinkedListIterator::operator=(QLinkedList &list) - \fn QListIterator &QListIterator::operator=(const QList &list) - \fn QLinkedListIterator &QLinkedListIterator::operator=(const QLinkedList &list) - - Makes the iterator operate on \a list. The iterator is set to be - at the front of the list (before the first item). - - \sa toFront(), toBack() -*/ - -/*! \fn QVectorIterator &QVectorIterator::operator=(const QVector &vector) - \fn QMutableVectorIterator &QMutableVectorIterator::operator=(QVector &vector) - - Makes the iterator operate on \a vector. The iterator is set to be - at the front of the vector (before the first item). - - \sa toFront(), toBack() -*/ - -/*! \fn QSetIterator &QSetIterator::operator=(const QSet &set) - \fn QMutableSetIterator &QMutableSetIterator::operator=(QSet &set) - - Makes the iterator operate on \a set. The iterator is set to be - at the front of the set (before the first item). - - \sa toFront(), toBack() -*/ - -/*! \fn void QListIterator::toFront() - \fn void QLinkedListIterator::toFront() - \fn void QVectorIterator::toFront() - \fn void QSetIterator::toFront() - \fn void QMutableListIterator::toFront() - \fn void QMutableLinkedListIterator::toFront() - \fn void QMutableVectorIterator::toFront() - \fn void QMutableSetIterator::toFront() - - Moves the iterator to the front of the container (before the - first item). - - \sa toBack(), next() -*/ - -/*! \fn void QListIterator::toBack() - \fn void QLinkedListIterator::toBack() - \fn void QVectorIterator::toBack() - \fn void QSetIterator::toBack() - \fn void QMutableListIterator::toBack() - \fn void QMutableLinkedListIterator::toBack() - \fn void QMutableVectorIterator::toBack() - \fn void QMutableSetIterator::toBack() - - Moves the iterator to the back of the container (after the last - item). - - \sa toFront(), previous() -*/ - -/*! \fn bool QListIterator::hasNext() const - \fn bool QLinkedListIterator::hasNext() const - \fn bool QVectorIterator::hasNext() const - \fn bool QSetIterator::hasNext() const - \fn bool QMutableListIterator::hasNext() const - \fn bool QMutableLinkedListIterator::hasNext() const - \fn bool QMutableVectorIterator::hasNext() const - \fn bool QMutableSetIterator::hasNext() const - - Returns true if there is at least one item ahead of the iterator, - i.e. the iterator is \e not at the back of the container; - otherwise returns false. - - \sa hasPrevious(), next() -*/ - -/*! \fn const T &QListIterator::next() - \fn const T &QLinkedListIterator::next() - \fn const T &QVectorIterator::next() - \fn const T &QSetIterator::next() - \fn const T &QMutableSetIterator::next() - - Returns the next item and advances the iterator by one position. - - Calling this function on an iterator located at the back of the - container leads to undefined results. - - \sa hasNext(), peekNext(), previous() -*/ - -/*! \fn T &QMutableListIterator::next() - \fn T &QMutableLinkedListIterator::next() - \fn T &QMutableVectorIterator::next() - - Returns a reference to the next item, and advances the iterator - by one position. - - Calling this function on an iterator located at the back of the - container leads to undefined results. - - \sa hasNext(), peekNext(), previous() -*/ - -/*! \fn const T &QListIterator::peekNext() const - \fn const T &QLinkedListIterator::peekNext() const - \fn const T &QVectorIterator::peekNext() const - \fn const T &QSetIterator::peekNext() const - \fn const T &QMutableSetIterator::peekNext() const - - Returns the next item without moving the iterator. - - Calling this function on an iterator located at the back of the - container leads to undefined results. - - \sa hasNext(), next(), peekPrevious() -*/ - -/*! \fn T &QMutableListIterator::peekNext() const - \fn T &QMutableLinkedListIterator::peekNext() const - \fn T &QMutableVectorIterator::peekNext() const - - Returns a reference to the next item, without moving the iterator. - - Calling this function on an iterator located at the back of the - container leads to undefined results. - - \sa hasNext(), next(), peekPrevious() -*/ - -/*! \fn bool QListIterator::hasPrevious() const - \fn bool QLinkedListIterator::hasPrevious() const - \fn bool QVectorIterator::hasPrevious() const - \fn bool QSetIterator::hasPrevious() const - \fn bool QMutableListIterator::hasPrevious() const - \fn bool QMutableLinkedListIterator::hasPrevious() const - \fn bool QMutableVectorIterator::hasPrevious() const - \fn bool QMutableSetIterator::hasPrevious() const - - Returns true if there is at least one item behind the iterator, - i.e. the iterator is \e not at the front of the container; - otherwise returns false. - - \sa hasNext(), previous() -*/ - -/*! \fn const T &QListIterator::previous() - \fn const T &QLinkedListIterator::previous() - \fn const T &QVectorIterator::previous() - \fn const T &QSetIterator::previous() - \fn const T &QMutableSetIterator::previous() - - Returns the previous item and moves the iterator back by one - position. - - Calling this function on an iterator located at the front of the - container leads to undefined results. - - \sa hasPrevious(), peekPrevious(), next() -*/ - -/*! \fn T &QMutableListIterator::previous() - \fn T &QMutableLinkedListIterator::previous() - \fn T &QMutableVectorIterator::previous() - - Returns a reference to the previous item and moves the iterator - back by one position. - - Calling this function on an iterator located at the front of the - container leads to undefined results. - - \sa hasPrevious(), peekPrevious(), next() -*/ - -/*! \fn const T &QListIterator::peekPrevious() const - \fn const T &QLinkedListIterator::peekPrevious() const - \fn const T &QVectorIterator::peekPrevious() const - \fn const T &QSetIterator::peekPrevious() const - \fn const T &QMutableSetIterator::peekPrevious() const - - Returns the previous item without moving the iterator. - - Calling this function on an iterator located at the front of the - container leads to undefined results. - - \sa hasPrevious(), previous(), peekNext() -*/ - -/*! \fn T &QMutableListIterator::peekPrevious() const - \fn T &QMutableLinkedListIterator::peekPrevious() const - \fn T &QMutableVectorIterator::peekPrevious() const - - Returns a reference to the previous item, without moving the iterator. - - Calling this function on an iterator located at the front of the - container leads to undefined results. - - \sa hasPrevious(), previous(), peekNext() -*/ - -/*! \fn bool QListIterator::findNext(const T &value) - \fn bool QLinkedListIterator::findNext(const T &value) - \fn bool QVectorIterator::findNext(const T &value) - \fn bool QSetIterator::findNext(const T &value) - \fn bool QMutableListIterator::findNext(const T &value) - \fn bool QMutableLinkedListIterator::findNext(const T &value) - \fn bool QMutableVectorIterator::findNext(const T &value) - \fn bool QMutableSetIterator::findNext(const T &value) - - Searches for \a value starting from the current iterator position - forward. Returns true if \a value is found; otherwise returns false. - - After the call, if \a value was found, the iterator is positioned - just after the matching item; otherwise, the iterator is - positioned at the back of the container. - - \sa findPrevious() -*/ - -/*! \fn bool QListIterator::findPrevious(const T &value) - \fn bool QLinkedListIterator::findPrevious(const T &value) - \fn bool QVectorIterator::findPrevious(const T &value) - \fn bool QSetIterator::findPrevious(const T &value) - \fn bool QMutableListIterator::findPrevious(const T &value) - \fn bool QMutableLinkedListIterator::findPrevious(const T &value) - \fn bool QMutableVectorIterator::findPrevious(const T &value) - \fn bool QMutableSetIterator::findPrevious(const T &value) - - Searches for \a value starting from the current iterator position - backward. Returns true if \a value is found; otherwise returns - false. - - After the call, if \a value was found, the iterator is positioned - just before the matching item; otherwise, the iterator is - positioned at the front of the container. - - \sa findNext() -*/ - -/*! \fn void QMutableListIterator::remove() - - Removes the last item that was jumped over using one of the - traversal functions (next(), previous(), findNext(), findPrevious()). - - Example: - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 19 - - \sa insert(), setValue() -*/ - -/*! \fn void QMutableLinkedListIterator::remove() - - Removes the last item that was jumped over using one of the - traversal functions (next(), previous(), findNext(), findPrevious()). - - Example: - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 20 - - \sa insert(), setValue() -*/ - -/*! \fn void QMutableVectorIterator::remove() - - Removes the last item that was jumped over using one of the - traversal functions (next(), previous(), findNext(), findPrevious()). - - Example: - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 21 - - \sa insert(), setValue() -*/ - -/*! \fn void QMutableSetIterator::remove() - - Removes the last item that was jumped over using one of the - traversal functions (next(), previous(), findNext(), findPrevious()). - - Example: - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 22 - - \sa value() -*/ - -/*! \fn void QMutableListIterator::setValue(const T &value) const - - Replaces the value of the last item that was jumped over using - one of the traversal functions with \a value. - - The traversal functions are next(), previous(), findNext(), and - findPrevious(). - - Example: - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 23 - - \sa value(), remove(), insert() -*/ - -/*! \fn void QMutableLinkedListIterator::setValue(const T &value) const - - Replaces the value of the last item that was jumped over using - one of the traversal functions with \a value. - - The traversal functions are next(), previous(), findNext(), and - findPrevious(). - - Example: - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 24 - - \sa value(), remove(), insert() -*/ - -/*! \fn void QMutableVectorIterator::setValue(const T &value) const - - Replaces the value of the last item that was jumped over using - one of the traversal functions with \a value. - - The traversal functions are next(), previous(), findNext(), and - findPrevious(). - - Example: - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 25 - - \sa value(), remove(), insert() -*/ - -/*! \fn const T &QMutableListIterator::value() const - \fn const T &QMutableLinkedListIterator::value() const - \fn const T &QMutableVectorIterator::value() const - \fn const T &QMutableSetIterator::value() const - - Returns the value of the last item that was jumped over using one - of the traversal functions (next(), previous(), findNext(), - findPrevious()). - - After a call to next() or findNext(), value() is equivalent to - peekPrevious(). After a call to previous() or findPrevious(), value() is - equivalent to peekNext(). -*/ - -/*! - \fn T &QMutableListIterator::value() - \fn T &QMutableLinkedListIterator::value() - \fn T &QMutableVectorIterator::value() - \overload - - Returns a non-const reference to the value of the last item that - was jumped over using one of the traversal functions. -*/ - -/*! \fn void QMutableListIterator::insert(const T &value) - \fn void QMutableLinkedListIterator::insert(const T &value) - \fn void QMutableVectorIterator::insert(const T &value) - - Inserts \a value at the current iterator position. After the - call, the iterator is located just after the inserted item. - - \sa remove(), setValue() -*/ - -/*! - \class QMapIterator - \inmodule QtCore - - \brief The QMapIterator class provides a Java-style const iterator for QMap and QMultiMap. - - QMap has both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - QMapIterator\ allows you to iterate over a QMap (or a - QMultiMap). If you want to modify the map as you iterate over - it, use QMutableMapIterator instead. - - The QMapIterator constructor takes a QMap as argument. After - construction, the iterator is located at the very beginning of - the map (before the first item). Here's how to iterate over all - the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 26 - - The next() function returns the next item in the map and - advances the iterator. The key() and value() functions return the - key and value of the last item that was jumped over. - - Unlike STL-style iterators, Java-style iterators point \e between - items rather than directly \e at items. The first call to next() - advances the iterator to the position between the first and - second item, and returns the first item; the second call to - next() advances the iterator to the position between the second - and third item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 27 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. For example: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 28 - - Multiple iterators can be used on the same map. If the map is - modified while a QMapIterator is active, the QMapIterator will - continue iterating over the original map, ignoring the modified - copy. - - \sa QMutableMapIterator, QMap::const_iterator -*/ - -/*! - \class QHashIterator - \inmodule QtCore - - \brief The QHashIterator class provides a Java-style const iterator for QHash and QMultiHash. - - QHash has both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - QHashIterator\ allows you to iterate over a QHash (or a - QMultiHash). If you want to modify the hash as you iterate over - it, use QMutableHashIterator instead. - - The QHashIterator constructor takes a QHash as argument. After - construction, the iterator is located at the very beginning of - the hash (before the first item). Here's how to iterate over all - the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 29 - - The next() function returns the next item in the hash and - advances the iterator. The key() and value() functions return the - key and value of the last item that was jumped over. - - Unlike STL-style iterators, Java-style iterators point \e between - items rather than directly \e at items. The first call to next() - advances the iterator to the position between the first and - second item, and returns the first item; the second call to - next() advances the iterator to the position between the second - and third item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 30 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. For example: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 31 - - Multiple iterators can be used on the same hash. If the hash is - modified while a QHashIterator is active, the QHashIterator will - continue iterating over the original hash, ignoring the modified - copy. - - \sa QMutableHashIterator, QHash::const_iterator -*/ - -/*! - \class QMutableMapIterator - \inmodule QtCore - - \brief The QMutableMapIterator class provides a Java-style non-const iterator for QMap and QMultiMap. - - QMap has both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - QMutableMapIterator\ allows you to iterate over a QMap - (or a QMultiMap) and modify the map. If you don't want to modify - the map (or have a const QMap), use the slightly faster - QMapIterator instead. - - The QMutableMapIterator constructor takes a QMap as argument. - After construction, the iterator is located at the very beginning - of the map (before the first item). Here's how to iterate over - all the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 32 - - The next() function returns the next item in the map and - advances the iterator. The key() and value() functions return the - key and value of the last item that was jumped over. - - Unlike STL-style iterators, Java-style iterators point \e between - items rather than directly \e at items. The first call to next() - advances the iterator to the position between the first and - second item, and returns the first item; the second call to - next() advances the iterator to the position between the second - and third item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 33 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. For example: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 34 - - If you want to remove items as you iterate over the map, use - remove(). If you want to modify the value of an item, use - setValue(). - - Example: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 35 - - The example removes all (key, value) pairs where the key and the - value are the same. - - Only one mutable iterator can be active on a given map at any - time. Furthermore, no changes should be done directly to the map - while the iterator is active (as opposed to through the - iterator), since this could invalidate the iterator and lead to - undefined behavior. - - \sa QMapIterator, QMap::iterator -*/ - -/*! - \class QMutableHashIterator - \inmodule QtCore - - \brief The QMutableHashIterator class provides a Java-style non-const iterator for QHash and QMultiHash. - - QHash has both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - QMutableHashIterator\ allows you to iterate over a QHash - (or a QMultiHash) and modify the hash. If you don't want to modify - the hash (or have a const QHash), use the slightly faster - QHashIterator instead. - - The QMutableHashIterator constructor takes a QHash as argument. - After construction, the iterator is located at the very beginning - of the hash (before the first item). Here's how to iterate over - all the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 36 - - The next() function returns the next item in the hash and - advances the iterator. The key() and value() functions return the - key and value of the last item that was jumped over. - - Unlike STL-style iterators, Java-style iterators point \e between - items rather than directly \e at items. The first call to next() - advances the iterator to the position between the first and - second item, and returns the first item; the second call to - next() advances the iterator to the position between the second - and third item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 37 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. For example: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 38 - - If you want to remove items as you iterate over the hash, use - remove(). If you want to modify the value of an item, use - setValue(). - - Example: - - \snippet doc/src/snippets/code/doc_src_qiterator.qdoc 39 - - The example removes all (key, value) pairs where the key and the - value are the same. - - Only one mutable iterator can be active on a given hash at any - time. Furthermore, no changes should be done directly to the hash - while the iterator is active (as opposed to through the - iterator), since this could invalidate the iterator and lead to - undefined behavior. - - \sa QHashIterator, QHash::iterator -*/ - -/*! \fn QMapIterator::QMapIterator(const QMap &map) - \fn QMutableMapIterator::QMutableMapIterator(QMap &map) - - Constructs an iterator for traversing \a map. The iterator is set - to be at the front of the map (before the first item). - - \sa operator=() -*/ - -/*! \fn QHashIterator::QHashIterator(const QHash &hash) - \fn QMutableHashIterator::QMutableHashIterator(QHash &hash) - - Constructs an iterator for traversing \a hash. The iterator is - set to be at the front of the hash (before the first item). - - \sa operator=() -*/ - -/*! - \fn QMutableMapIterator::~QMutableMapIterator() - \fn QMutableHashIterator::~QMutableHashIterator() - - Destroys the iterator. - - \sa operator=() -*/ - -/*! \fn QMapIterator &QMapIterator::operator=(const QMap &map) - \fn QMutableMapIterator &QMutableMapIterator::operator=(QMap &map) - - Makes the iterator operate on \a map. The iterator is set to be - at the front of the map (before the first item). - - \sa toFront(), toBack() -*/ - -/*! \fn QHashIterator &QHashIterator::operator=(const QHash &hash) - \fn QMutableHashIterator &QMutableHashIterator::operator=(QHash &hash) - - Makes the iterator operate on \a hash. The iterator is set to be - at the front of the hash (before the first item). - - \sa toFront(), toBack() -*/ - -/*! \fn void QMapIterator::toFront() - \fn void QHashIterator::toFront() - \fn void QMutableMapIterator::toFront() - \fn void QMutableHashIterator::toFront() - - Moves the iterator to the front of the container (before the - first item). - - \sa toBack(), next() -*/ - -/*! \fn void QMapIterator::toBack() - \fn void QHashIterator::toBack() - \fn void QMutableMapIterator::toBack() - \fn void QMutableHashIterator::toBack() - - Moves the iterator to the back of the container (after the last - item). - - \sa toFront(), previous() -*/ - -/*! \fn bool QMapIterator::hasNext() const - \fn bool QHashIterator::hasNext() const - \fn bool QMutableMapIterator::hasNext() const - \fn bool QMutableHashIterator::hasNext() const - - Returns true if there is at least one item ahead of the iterator, - i.e. the iterator is \e not at the back of the container; - otherwise returns false. - - \sa hasPrevious(), next() -*/ - -/*! \fn QMapIterator::Item QMapIterator::next() - \fn QHashIterator::Item QHashIterator::next() - - Returns the next item and advances the iterator by one position. - - Call key() on the return value to obtain the item's key, and - value() to obtain the value. - - Calling this function on an iterator located at the back of the - container leads to undefined results. - - \sa hasNext(), peekNext(), previous() -*/ - -/*! \fn QMutableMapIterator::Item QMutableMapIterator::next() - \fn QMutableHashIterator::Item QMutableHashIterator::next() - - Returns the next item and advances the iterator by one position. - - Call key() on the return value to obtain the item's key, and - value() to obtain the value. - - Calling this function on an iterator located at the back of the - container leads to undefined results. - - \sa hasNext(), peekNext(), previous() -*/ - -/*! \fn QMapIterator::Item QMapIterator::peekNext() const - \fn QHashIterator::Item QHashIterator::peekNext() const - - Returns the next item without moving the iterator. - - Call key() on the return value to obtain the item's key, and - value() to obtain the value. - - Calling this function on an iterator located at the back of the - container leads to undefined results. - - \sa hasNext(), next(), peekPrevious() -*/ - -/*! \fn QMutableMapIterator::Item QMutableMapIterator::peekNext() const - \fn QMutableHashIterator::Item QMutableHashIterator::peekNext() const - - Returns a reference to the next item without moving the iterator. - - Call key() on the return value to obtain the item's key, and - value() to obtain the value. - - Calling this function on an iterator located at the back of the - container leads to undefined results. - - \sa hasNext(), next(), peekPrevious() -*/ - -/*! \fn bool QMapIterator::hasPrevious() const - \fn bool QHashIterator::hasPrevious() const - \fn bool QMutableMapIterator::hasPrevious() const - \fn bool QMutableHashIterator::hasPrevious() const - - Returns true if there is at least one item behind the iterator, - i.e. the iterator is \e not at the front of the container; - otherwise returns false. - - \sa hasNext(), previous() -*/ - -/*! \fn QMapIterator::Item QMapIterator::previous() - \fn QHashIterator::Item QHashIterator::previous() - - Returns the previous item and moves the iterator back by one - position. - - Call key() on the return value to obtain the item's key, and - value() to obtain the value. - - Calling this function on an iterator located at the front of the - container leads to undefined results. - - \sa hasPrevious(), peekPrevious(), next() -*/ - -/*! \fn QMutableMapIterator::Item QMutableMapIterator::previous() - \fn QMutableHashIterator::Item QMutableHashIterator::previous() - - Returns the previous item and moves the iterator back by one - position. - - Call key() on the return value to obtain the item's key, and - value() to obtain the value. - - Calling this function on an iterator located at the front of the - container leads to undefined results. - - \sa hasPrevious(), peekPrevious(), next() -*/ - -/*! \fn QMapIterator::Item QMapIterator::peekPrevious() const - \fn QHashIterator::Item QHashIterator::peekPrevious() const - - Returns the previous item without moving the iterator. - - Call key() on the return value to obtain the item's key, and - value() to obtain the value. - - Calling this function on an iterator located at the front of the - container leads to undefined results. - - \sa hasPrevious(), previous(), peekNext() -*/ - -/*! \fn QMutableMapIterator::Item QMutableMapIterator::peekPrevious() const - \fn QMutableHashIterator::Item QMutableHashIterator::peekPrevious() const - - Returns the previous item without moving the iterator. - - Call key() on the return value to obtain the item's key, and - value() to obtain the value. - - Calling this function on an iterator located at the front of the - container leads to undefined results. - - \sa hasPrevious(), previous(), peekNext() -*/ - -/*! \fn const T &QMapIterator::value() const - \fn const T &QHashIterator::value() const - - Returns the value of the last item that was jumped over using one - of the traversal functions (next(), previous(), findNext(), - findPrevious()). - - After a call to next() or findNext(), value() is - equivalent to peekPrevious().value(). After a call to previous() - or findPrevious(), value() is equivalent to peekNext().value(). - - \sa key() -*/ - -/*! - \fn const T &QMutableMapIterator::value() const - \fn const T &QMutableHashIterator::value() const - - Returns the value of the last item that was jumped over using one - of the traversal functions (next(), previous(), findNext(), - findPrevious()). - - After a call to next() or findNext(), value() is - equivalent to peekPrevious().value(). After a call to previous() - or findPrevious(), value() is equivalent to peekNext().value(). - - \sa key(), setValue() -*/ - -/*! - \fn T &QMutableMapIterator::value() - \fn T &QMutableHashIterator::value() - \overload - - Returns a non-const reference to the value of - the last item that was jumped over using one - of the traversal functions. -*/ - -/*! \fn const Key &QMapIterator::key() const - \fn const Key &QHashIterator::key() const - \fn const Key &QMutableMapIterator::key() const - \fn const Key &QMutableHashIterator::key() const - - Returns the key of the last item that was jumped over using one - of the traversal functions (next(), previous(), findNext(), - findPrevious()). - - After a call to next() or findNext(), key() is - equivalent to peekPrevious().key(). After a call to previous() or - findPrevious(), key() is equivalent to peekNext().key(). - - \sa value() -*/ - -/*! \fn bool QMapIterator::findNext(const T &value) - \fn bool QHashIterator::findNext(const T &value) - \fn bool QMutableMapIterator::findNext(const T &value) - \fn bool QMutableHashIterator::findNext(const T &value) - - Searches for \a value starting from the current iterator position - forward. Returns true if a (key, value) pair with value \a value - is found; otherwise returns false. - - After the call, if \a value was found, the iterator is positioned - just after the matching item; otherwise, the iterator is - positioned at the back of the container. - - \sa findPrevious() -*/ - -/*! \fn bool QMapIterator::findPrevious(const T &value) - \fn bool QHashIterator::findPrevious(const T &value) - \fn bool QMutableMapIterator::findPrevious(const T &value) - \fn bool QMutableHashIterator::findPrevious(const T &value) - - Searches for \a value starting from the current iterator position - backward. Returns true if a (key, value) pair with value \a value - is found; otherwise returns false. - - After the call, if \a value was found, the iterator is positioned - just before the matching item; otherwise, the iterator is - positioned at the front of the container. - - \sa findNext() -*/ - -/*! \fn void QMutableMapIterator::remove() - \fn void QMutableHashIterator::remove() - - Removes the last item that was jumped over using one of the - traversal functions (next(), previous(), findNext(), findPrevious()). - - \sa setValue() -*/ - -/*! \fn void QMutableMapIterator::setValue(const T &value) - \fn void QMutableHashIterator::setValue(const T &value) - - Replaces the value of the last item that was jumped over using - one of the traversal functions with \a value. - - The traversal functions are next(), previous(), findNext(), and - findPrevious(). - - \sa key(), value(), remove() -*/ diff --git a/doc/src/qpagesetupdialog.qdoc b/doc/src/qpagesetupdialog.qdoc deleted file mode 100644 index 7f0b09e..0000000 --- a/doc/src/qpagesetupdialog.qdoc +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QPageSetupDialog - - \brief The QPageSetupDialog class provides a configuration dialog - for the page-related options on a printer. - - On Windows and Mac OS X the page setup dialog is implemented using - the native page setup dialogs. - - Note that on Windows and Mac OS X custom paper sizes won't be - reflected in the native page setup dialogs. Additionally, custom - page margins set on a QPrinter won't show in the native Mac OS X - page setup dialog. - - \sa QPrinter, QPrintDialog -*/ - - -/*! - \fn QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent) - - Constructs a page setup dialog that configures \a printer with \a - parent as the parent widget. -*/ - -/*! - \since 4.5 - - \fn QPageSetupDialog::QPageSetupDialog(QWidget *parent) - - Constructs a page setup dialog that configures a default-constructed - QPrinter with \a parent as the parent widget. - - \sa printer() -*/ - -/*! - \fn QPrinter *QPageSetupDialog::printer() - - Returns the printer that was passed to the QPageSetupDialog - constructor. -*/ - diff --git a/doc/src/qpaintdevice.qdoc b/doc/src/qpaintdevice.qdoc deleted file mode 100644 index 0f4e9a0..0000000 --- a/doc/src/qpaintdevice.qdoc +++ /dev/null @@ -1,289 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QPaintDevice - \brief The QPaintDevice class is the base class of objects that - can be painted. - - \ingroup multimedia - - A paint device is an abstraction of a two-dimensional space that - can be drawn using a QPainter. Its default coordinate system has - its origin located at the top-left position. X increases to the - right and Y increases downwards. The unit is one pixel. - - The drawing capabilities of QPaintDevice are currently implemented - by the QWidget, QImage, QPixmap, QGLPixelBuffer, QPicture, and - QPrinter subclasses. - - To implement support for a new backend, you must derive from - QPaintDevice and reimplement the virtual paintEngine() function to - tell QPainter which paint engine should be used to draw on this - particular device. Note that you also must create a corresponding - paint engine to be able to draw on the device, i.e derive from - QPaintEngine and reimplement its virtual functions. - - \warning Qt requires that a QApplication object exists before - any paint devices can be created. Paint devices access window - system resources, and these resources are not initialized before - an application object is created. - - The QPaintDevice class provides several functions returning the - various device metrics: The depth() function returns its bit depth - (number of bit planes). The height() function returns its height - in default coordinate system units (e.g. pixels for QPixmap and - QWidget) while heightMM() returns the height of the device in - millimeters. Similiarily, the width() and widthMM() functions - return the width of the device in default coordinate system units - and in millimeters, respectively. Alternatively, the protected - metric() function can be used to retrieve the metric information - by specifying the desired PaintDeviceMetric as argument. - - The logicalDpiX() and logicalDpiY() functions return the - horizontal and vertical resolution of the device in dots per - inch. The physicalDpiX() and physicalDpiY() functions also return - the resolution of the device in dots per inch, but note that if - the logical and vertical resolution differ, the corresponding - QPaintEngine must handle the mapping. Finally, the numColors() - function returns the number of different colors available for the - paint device. - - \sa QPaintEngine, QPainter, {The Coordinate System}, {The Paint - System} -*/ - -/*! - \enum QPaintDevice::PaintDeviceMetric - - Describes the various metrics of a paint device. - - \value PdmWidth The width of the paint device in default - coordinate system units (e.g. pixels for QPixmap and QWidget). See - also width(). - - \value PdmHeight The height of the paint device in default - coordinate system units (e.g. pixels for QPixmap and QWidget). See - also height(). - - \value PdmWidthMM The width of the paint device in millimeters. See - also widthMM(). - - \value PdmHeightMM The height of the paint device in millimeters. See - also heightMM(). - - \value PdmNumColors The number of different colors available for - the paint device. See also numColors(). - - \value PdmDepth The bit depth (number of bit planes) of the paint - device. See also depth(). - - \value PdmDpiX The horizontal resolution of the device in dots per - inch. See also logicalDpiX(). - - \value PdmDpiY The vertical resolution of the device in dots per inch. See - also logicalDpiY(). - - \value PdmPhysicalDpiX The horizontal resolution of the device in - dots per inch. See also physicalDpiX(). - - \value PdmPhysicalDpiY The vertical resolution of the device in - dots per inch. See also physicalDpiY(). - - \sa metric() -*/ - -/*! - \fn QPaintDevice::QPaintDevice() - - Constructs a paint device. This constructor can be invoked only from - subclasses of QPaintDevice. -*/ - -/*! - \fn QPaintDevice::~QPaintDevice() - - Destroys the paint device and frees window system resources. -*/ - -/*! - \fn int QPaintDevice::devType() const - - \internal - - Returns the device type identifier, which is QInternal::Widget - if the device is a QWidget, QInternal::Pixmap if it's a - QPixmap, QInternal::Printer if it's a QPrinter, - QInternal::Picture if it's a QPicture, or - QInternal::UnknownDevice in other cases. -*/ - -/*! - \fn bool QPaintDevice::paintingActive() const - - Returns true if the device is currently being painted on, i.e. someone has - called QPainter::begin() but not yet called QPainter::end() for - this device; otherwise returns false. - - \sa QPainter::isActive() -*/ - -/*! - \fn QPaintEngine *QPaintDevice::paintEngine() const - - Returns a pointer to the paint engine used for drawing on the - device. -*/ - -/*! - \fn int QPaintDevice::metric(PaintDeviceMetric metric) const - - Returns the metric information for the given paint device \a metric. - - \sa PaintDeviceMetric -*/ - -/*! - \fn int QPaintDevice::width() const - - Returns the width of the paint device in default coordinate system - units (e.g. pixels for QPixmap and QWidget). - - \sa widthMM() -*/ - -/*! - \fn int QPaintDevice::height() const - - Returns the height of the paint device in default coordinate - system units (e.g. pixels for QPixmap and QWidget). - - \sa heightMM() -*/ - -/*! - \fn int QPaintDevice::widthMM() const - - Returns the width of the paint device in millimeters. Due to platform - limitations it may not be possible to use this function to determine - the actual physical size of a widget on the screen. - - \sa width() -*/ - -/*! - \fn int QPaintDevice::heightMM() const - - Returns the height of the paint device in millimeters. Due to platform - limitations it may not be possible to use this function to determine - the actual physical size of a widget on the screen. - - \sa height() -*/ - -/*! - \fn int QPaintDevice::numColors() const - - Returns the number of different colors available for the paint - device. Since this value is an int, it will not be sufficient to represent - the number of colors on 32 bit displays, in this case INT_MAX is - returned instead. -*/ - -/*! - \fn int QPaintDevice::depth() const - - Returns the bit depth (number of bit planes) of the paint device. -*/ - -/*! - \fn int QPaintDevice::logicalDpiX() const - - Returns the horizontal resolution of the device in dots per inch, - which is used when computing font sizes. For X11, this is usually - the same as could be computed from widthMM(). - - Note that if the logicalDpiX() doesn't equal the physicalDpiX(), - the corresponding QPaintEngine must handle the resolution mapping. - - \sa logicalDpiY(), physicalDpiX() -*/ - -/*! - \fn int QPaintDevice::logicalDpiY() const - - Returns the vertical resolution of the device in dots per inch, - which is used when computing font sizes. For X11, this is usually - the same as could be computed from heightMM(). - - Note that if the logicalDpiY() doesn't equal the physicalDpiY(), - the corresponding QPaintEngine must handle the resolution mapping. - - \sa logicalDpiX(), physicalDpiY() -*/ - -/*! - \fn int QPaintDevice::physicalDpiX() const - - Returns the horizontal resolution of the device in dots per inch. - For example, when printing, this resolution refers to the physical - printer's resolution. The logical DPI on the other hand, refers to - the resolution used by the actual paint engine. - - Note that if the physicalDpiX() doesn't equal the logicalDpiX(), - the corresponding QPaintEngine must handle the resolution mapping. - - \sa physicalDpiY(), logicalDpiX() -*/ - -/*! - \fn int QPaintDevice::physicalDpiY() const - - Returns the horizontal resolution of the device in dots per inch. - For example, when printing, this resolution refers to the physical - printer's resolution. The logical DPI on the other hand, refers to - the resolution used by the actual paint engine. - - Note that if the physicalDpiY() doesn't equal the logicalDpiY(), - the corresponding QPaintEngine must handle the resolution mapping. - - \sa physicalDpiX(), logicalDpiY() -*/ diff --git a/doc/src/qpair.qdoc b/doc/src/qpair.qdoc deleted file mode 100644 index 6d8a0f9..0000000 --- a/doc/src/qpair.qdoc +++ /dev/null @@ -1,229 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QPair - \brief The QPair class is a template class that stores a pair of items. - - \ingroup tools - - QPair\ can be used in your application if the STL \c - pair type is not available. It stores one value of type T1 and - one value of type T2. It can be used as a return value for a - function that needs to return two values, or as the value type of - a \l{generic container}. - - Here's an example of a QPair that stores one QString and one \c - double value: - - \snippet doc/src/snippets/code/doc_src_qpair.qdoc 0 - - The components are accessible as public data members called \l - first and \l second. For example: - - \snippet doc/src/snippets/code/doc_src_qpair.qdoc 1 - - QPair's template data types (T1 and T2) must be \l{assignable - data types}. You cannot, for example, store a QWidget as a value; - instead, store a QWidget *. A few functions have additional - requirements; these requirements are documented on a per-function - basis. - - \sa {Generic Containers} -*/ - -/*! \typedef QPair::first_type - - The type of the first element in the pair (T1). - - \sa first -*/ - -/*! \typedef QPair::second_type - - The type of the second element in the pair (T2). - - \sa second -*/ - -/*! \variable QPair::first - - The first element in the pair. -*/ - -/*! \variable QPair::second - - The second element in the pair. -*/ - -/*! \fn QPair::QPair() - - Constructs an empty pair. The \c first and \c second elements are - initialized with \l{default-constructed values}. -*/ - -/*! - \fn QPair::QPair(const T1 &value1, const T2 &value2) - - Constructs a pair and initializes the \c first element with \a - value1 and the \c second element with \a value2. - - \sa qMakePair() -*/ - -/*! - \fn QPair &QPair::operator=(const QPair &other) - - Assigns \a other to this pair. -*/ - -/*! \fn bool operator==(const QPair &p1, const QPair &p2) - - \relates QPair - - Returns true if \a p1 is equal to \a p2; otherwise returns false. - Two pairs compare equal if their \c first data members compare - equal and if their \c second data members compare equal. - - This function requires the T1 and T2 types to have an - implementation of \c operator==(). -*/ - -/*! \fn bool operator!=(const QPair &p1, const QPair &p2) - - \relates QPair - - Returns true if \a p1 is not equal to \a p2; otherwise returns - false. Two pairs compare as not equal if their \c first data - members are not equal or if their \c second data members are not - equal. - - This function requires the T1 and T2 types to have an - implementation of \c operator==(). -*/ - -/*! \fn bool operator<(const QPair &p1, const QPair &p2) - - \relates QPair - - Returns true if \a p1 is less than \a p2; otherwise returns - false. The comparison is done on the \c first members of \a p1 - and \a p2; if they compare equal, the \c second members are - compared to break the tie. - - This function requires the T1 and T2 types to have an - implementation of \c operator<(). -*/ - -/*! \fn bool operator>(const QPair &p1, const QPair &p2) - - \relates QPair - - Returns true if \a p1 is greater than \a p2; otherwise returns - false. The comparison is done on the \c first members of \a p1 - and \a p2; if they compare equal, the \c second members are - compared to break the tie. - - This function requires the T1 and T2 types to have an - implementation of \c operator<(). -*/ - -/*! \fn bool operator<=(const QPair &p1, const QPair &p2) - - \relates QPair - - Returns true if \a p1 is less than or equal to \a p2; otherwise - returns false. The comparison is done on the \c first members of - \a p1 and \a p2; if they compare equal, the \c second members are - compared to break the tie. - - This function requires the T1 and T2 types to have an - implementation of \c operator<(). -*/ - -/*! \fn bool operator>=(const QPair &p1, const QPair &p2) - - \relates QPair - - Returns true if \a p1 is greater than or equal to \a p2; - otherwise returns false. The comparison is done on the \c first - members of \a p1 and \a p2; if they compare equal, the \c second - members are compared to break the tie. - - This function requires the T1 and T2 types to have an - implementation of \c operator<(). -*/ - -/*! - \fn QPair qMakePair(const T1 &value1, const T2 &value2) - - \relates QPair - - Returns a QPair\ that contains \a value1 and \a value2. - Example: - - \snippet doc/src/snippets/code/doc_src_qpair.qdoc 2 - - This is equivalent to QPair(\a value1, \a value2), but - usually requires less typing. -*/ - -/*! \fn QDataStream &operator>>(QDataStream &in, QPair &pair) - - \relates QPair - - Reads a pair from stream \a in into \a pair. - - This function requires the T1 and T2 types to implement \c operator>>(). - - \sa {Format of the QDataStream operators} -*/ - -/*! \fn QDataStream &operator<<(QDataStream &out, const QPair &pair) - - \relates QPair - - Writes the pair \a pair to stream \a out. - - This function requires the T1 and T2 types to implement \c operator<<(). - - \sa {Format of the QDataStream operators} -*/ diff --git a/doc/src/qpatternistdummy.cpp b/doc/src/qpatternistdummy.cpp deleted file mode 100644 index a690184..0000000 --- a/doc/src/qpatternistdummy.cpp +++ /dev/null @@ -1,1010 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - - This file exists only to make internal all the classes you see - below. they are all in the QPatternist namespace, but they don't - have qdoc documentation because they are all declared in xxx_p.h files. Without these \internal declarations, the class names - appear on the Inheritance Hierarchy page, which is bad because - clicking on them brings up the "File not found" page. - */ - -#include "qitem_p.h" -#include "qbuiltintypes_p.h" -#include "qitem_p.h" -#include "qschematypefactory_p.h" -#include "qxmlname.h" -#include "qatomictype_p.h" - -QT_BEGIN_NAMESPACE - -using namespace QPatternist; - -/*! - \class AtomicCaster - \internal - */ - -/*! - \class AtomicComparator - \internal - */ - -/*! - \class AtomicMathematician - \internal - */ - -/*! - \class AtomicValue - \internal - */ - -/*! - \class AbstractDateTime - \internal - */ - -/*! - \class AbstractDuration - \internal - */ - -/*! - \class AbstractFloatComparator - \internal - */ - -/*! - \class AtomicString - \internal - */ - -/*! - \class Base64Binary - \internal - */ - -/*! - \class FunctionCall - \internal - */ - -/*! - \class AddingAggregate - \internal - */ - -/*! - \class AdjustTimezone - \internal - */ - -/*! - \class Aggregator - \internal - */ - -/*! - \class ComparesCaseAware - \internal - */ - -/*! - \class EncodeString - \internal - */ - -/*! - \class ExtractFromDateTimeFN - \internal - */ - -/*! - \class ExtractFromDurationFN - \internal - */ - -/*! - \class FunctionFactory - \internal - */ - -/*! - \class Numeric - \internal - */ - -/*! - \class ReportContext - \internal - */ - -/*! - \class AbstractFunctionFactory - \internal - */ - -/*! - \class DynamicContext - \internal - */ - -/*! - \class IdFN - \internal - */ - -/*! - \class IntegerType - \internal - */ - -/*! - \class NamespaceResolver - \internal - */ - -/*! - \class PatternPlatform - \internal - */ - -/*! \class DocumentProjector - \internal */ -/*! \class NodeBuilder - \internal */ -/*! \class AccelTreeBuilder - \internal */ -/*! \class OutputValidator - \internal */ -/*! \class NetworkLoop - \internal */ -/*! \class QIODeviceDelegate - \internal */ -/*! \class URILoader - \internal */ -/*! \class AbsFN - \internal */ -/*! \class AbstractDateTimeComparator - \internal */ -/*! \class AbstractDateTimeMathematician - \internal */ -/*! \class AbstractDateTimeToDateCaster - \internal */ -/*! \class AbstractDateTimeToDateTimeCaster - \internal */ -/*! \class AbstractDateTimeToGDayCaster - \internal */ -/*! \class AbstractDateTimeToGMonthCaster - \internal */ -/*! \class AbstractDateTimeToGMonthDayCaster - \internal */ -/*! \class AbstractDateTimeToGYearCaster - \internal */ -/*! \class AbstractDateTimeToGYearMonthCaster - \internal */ -/*! \class AbstractDateTimeToTimeCaster - \internal */ -/*! \class AbstractDurationComparator - \internal */ -/*! \class AbstractDurationToDayTimeDurationCaster - \internal */ -/*! \class AbstractDurationToDurationCaster - \internal */ -/*! \class AbstractDurationToYearMonthDurationCaster - \internal */ -/*! \class AbstractFloat - \internal */ -/*! \class AbstractFloatMathematician - \internal */ -/*! \class AbstractFloatSortComparator - \internal */ -/*! \class ConstructorFunctionsFactory - \internal */ -/*! \class XPath10CoreFunctions - \internal */ -/*! \class XPath20CoreFunctions - \internal */ -/*! \class AdjustDateTimeToTimezoneFN - \internal */ -/*! \class AdjustDateToTimezoneFN - \internal */ -/*! \class AdjustTimeToTimezoneFN - \internal */ -/*! \class AnyToDerivedStringCaster - \internal */ -/*! \class AnyURI - \internal */ -/*! \class Atomizer - \internal */ -/*! \class AvgFN - \internal */ -/*! \class Base64BinaryComparatorLocator - \internal */ -/*! \class Base64BinaryToHexBinaryCaster - \internal */ -/*! \class Base64BinaryType - \internal */ -/*! \class BaseURIFN - \internal */ -/*! \class BinaryDataComparator - \internal */ -/*! \class Boolean - \internal */ -/*! \class BooleanComparator - \internal */ -/*! \class BooleanComparatorLocator - \internal */ -/*! \class BooleanFN - \internal */ -/*! \class BooleanToAbstractFloatCaster - \internal */ -/*! \class BooleanToDecimalCaster - \internal */ -/*! \class BooleanToDerivedIntegerCaster - \internal */ -/*! \class BooleanToIntegerCaster - \internal */ -/*! \class BooleanType - \internal */ -/*! \class BuiltinNodeType - \internal */ -/*! \class CardinalityVerifier - \internal */ -/*! \class CaseInsensitiveStringComparator - \internal */ -/*! \class CeilingFN - \internal */ -/*! \class CodepointEqualFN - \internal */ -/*! \class CodepointsToStringFN - \internal */ -/*! \class CollectionFN - \internal */ -/*! \class CompareFN - \internal */ -/*! \class ComparingAggregator - \internal */ -/*! \class ConcatFN - \internal */ -/*! \class ContainsFN - \internal */ -/*! \class CountFN - \internal */ -/*! \class CurrentDateFN - \internal */ -/*! \class CurrentDateTimeFN - \internal */ -/*! \class CurrentTimeFN - \internal */ -/*! \class Date - \internal */ -/*! \class DateComparatorLocator - \internal */ -/*! \class DateMathematicianLocator - \internal */ -/*! \class DateTime - \internal */ -/*! \class DateTimeComparatorLocator - \internal */ -/*! \class DateTimeDurationMathematician - \internal */ -/*! \class DateTimeFN - \internal */ -/*! \class DateTimeMathematicianLocator - \internal */ -/*! \class DateTimeType - \internal */ -/*! \class DateType - \internal */ -/*! \class DayFromAbstractDateTimeFN - \internal */ -/*! \class DayTimeDuration - \internal */ -/*! \class DayTimeDurationComparatorLocator - \internal */ -/*! \class DayTimeDurationMathematicianLocator - \internal */ -/*! \class DayTimeDurationType - \internal */ -/*! \class DaysFromDurationFN - \internal */ -/*! \class Decimal - \internal */ -/*! \class DecimalComparator - \internal */ -/*! \class DecimalComparatorLocator - \internal */ -/*! \class DecimalMathematician - \internal */ -/*! \class DecimalMathematicianLocator - \internal */ -/*! \class DecimalType - \internal */ -/*! \class DeduplicateIterator - \internal */ -/*! \class DeepEqualFN - \internal */ -/*! \class DefaultCollationFN - \internal */ -/*! \class DerivedInteger - \internal */ -/*! \class DerivedString - \internal */ -/*! \class DistinctValuesFN - \internal */ -/*! \class DocAvailableFN - \internal */ -/*! \class DocFN - \internal */ -/*! \class DocumentURIFN - \internal */ -/*! \class DoubleComparatorLocator - \internal */ -/*! \class DoubleMathematicianLocator - \internal */ -/*! \class DoubleType - \internal */ -/*! \class Duration - \internal */ -/*! \class DurationComparatorLocator - \internal */ -/*! \class DurationDurationDivisor - \internal */ -/*! \class DurationDurationMathematician - \internal */ -/*! \class DurationNumericMathematician - \internal */ -/*! \class DurationType - \internal */ -/*! \class DelegatingDynamicContext - \internal */ -/*! \class Focus - \internal */ -/*! \class ReceiverDynamicContext - \internal */ -/*! \class EmptyIterator - \internal */ -/*! \class EncodeForURIFN - \internal */ -/*! \class EndsWithFN - \internal */ -/*! \class ErrorFN - \internal */ -/*! \class EscapeHtmlURIFN - \internal */ -/*! \class EvaluationCache - \internal */ -/*! \class Existence - \internal */ -/*! \class ExpressionVisitor - \internal */ -/*! \class ExpressionVisitorResult - \internal */ -/*! \class FalseFN - \internal */ -/*! \class FloatComparatorLocator - \internal */ -/*! \class FloatMathematicianLocator - \internal */ -/*! \class FloatType - \internal */ -/*! \class FloorFN - \internal */ -/*! \class FunctionArgument - \internal */ -/*! \class FunctionAvailableFN - \internal */ -/*! \class FunctionFactoryCollection - \internal */ -/*! \class FunctionSignature - \internal */ -/*! \class GDay - \internal */ -/*! \class GDayComparatorLocator - \internal */ -/*! \class GDayType - \internal */ -/*! \class GMonth - \internal */ -/*! \class GMonthComparatorLocator - \internal */ -/*! \class GMonthDay - \internal */ -/*! \class GMonthDayComparatorLocator - \internal */ -/*! \class GMonthDayType - \internal */ -/*! \class GMonthType - \internal */ -/*! \class GYear - \internal */ -/*! \class GYearComparatorLocator - \internal */ -/*! \class GYearMonth - \internal */ -/*! \class GYearMonthComparatorLocator - \internal */ -/*! \class GYearMonthType - \internal */ -/*! \class GYearType - \internal */ -/*! \class HexBinary - \internal */ -/*! \class HexBinaryComparatorLocator - \internal */ -/*! \class HexBinaryToBase64BinaryCaster - \internal */ -/*! \class HexBinaryType - \internal */ -/*! \class HoursFromAbstractDateTimeFN - \internal */ -/*! \class HoursFromDurationFN - \internal */ -/*! \class IdrefFN - \internal */ -/*! \class ImplicitTimezoneFN - \internal */ -/*! \class InScopePrefixesFN - \internal */ -/*! \class IndexOfFN - \internal */ -/*! \class InsertBeforeFN - \internal */ -/*! \class Integer - \internal */ -/*! \class IntegerComparator - \internal */ -/*! \class IntegerComparatorLocator - \internal */ -/*! \class IntegerMathematician - \internal */ -/*! \class IntegerMathematicianLocator - \internal */ -/*! \class DerivedIntegerType - \internal */ -/*! \class IriToURIFN - \internal */ -/*! \class ItemMappingIterator - \internal */ -/*! \class ItemVerifier - \internal */ -/*! \class LangFN - \internal */ -/*! \class LastFN - \internal */ -/*! \class LocalNameFN - \internal */ -/*! \class LocalNameFromQNameFN - \internal */ -/*! \class LowerCaseFN - \internal */ -/*! \class MinutesFromAbstractDateTimeFN - \internal */ -/*! \class MinutesFromDurationFN - \internal */ -/*! \class MonthFromAbstractDateTimeFN - \internal */ -/*! \class MonthsFromDurationFN - \internal */ -/*! \class NOTATIONType - \internal */ -/*! \class NameFN - \internal */ -/*! \class NamePool - \internal */ -/*! \class DelegatingNamespaceResolver - \internal */ -/*! \class GenericNamespaceResolver - \internal */ -/*! \class NodeNamespaceResolver - \internal */ -/*! \class NamespaceURIFN - \internal */ -/*! \class NamespaceURIForPrefixFN - \internal */ -/*! \class NamespaceURIFromQNameFN - \internal */ -/*! \class NilledFN - \internal */ -/*! \class NodeNameFN - \internal */ -/*! \class NormalizeSpaceFN - \internal */ -/*! \class NormalizeUnicodeFN - \internal */ -/*! \class NotFN - \internal */ -/*! \class NumberFN - \internal */ -/*! \class NumericToAbstractFloatCaster - \internal */ -/*! \class NumericToBooleanCaster - \internal */ -/*! \class NumericToDecimalCaster - \internal */ -/*! \class NumericToDerivedIntegerCaster - \internal */ -/*! \class OperandSwitcherMathematician - \internal */ -/*! \class ParserContext - \internal */ -/*! \class MatchesFN - \internal */ -/*! \class ReplaceFN - \internal */ -/*! \class TokenizeFN - \internal */ -/*! \class PositionFN - \internal */ -/*! \class PrefixFromQNameFN - \internal */ -/*! \class AccelTree - \internal */ -/*! \class QNameComparator - \internal */ -/*! \class QNameComparatorLocator - \internal */ -/*! \class QNameFN - \internal */ -/*! \class QNameType - \internal */ -/*! \class QNameValue - \internal */ -/*! \class RemoveFN - \internal */ -/*! \class ResolveQNameFN - \internal */ -/*! \class ResolveURIFN - \internal */ -/*! \class ResourceLoader - \internal */ -/*! \class AccelTreeResourceLoader - \internal */ -/*! \class ReverseFN - \internal */ -/*! \class RootFN - \internal */ -/*! \class RoundFN - \internal */ -/*! \class RoundHalfToEvenFN - \internal */ -/*! \class SchemaTime - \internal */ -/*! \class SchemaTimeComparatorLocator - \internal */ -/*! \class SchemaTimeMathematicianLocator - \internal */ -/*! \class SchemaTimeType - \internal */ -/*! \class SecondsFromAbstractDateTimeFN - \internal */ -/*! \class SecondsFromDurationFN - \internal */ -/*! \class SelfToSelfCaster - \internal */ -/*! \class SequenceMappingIterator - \internal */ -/*! \class SingletonIterator - \internal */ -/*! \class SortTuple - \internal */ -/*! \class StartsWithFN - \internal */ -/*! \class StaticBaseURIFN - \internal */ -/*! \class StaticContext - \internal */ -/*! \class DelegatingStaticContext - \internal */ -/*! \class StaticFocusContext - \internal */ -/*! \class StaticNamespaceContext - \internal */ -/*! \class GenericStaticContext - \internal */ -/*! \class StringComparator - \internal */ -/*! \class StringComparatorLocator - \internal */ -/*! \class StringFN - \internal */ -/*! \class StringJoinFN - \internal */ -/*! \class StringLengthFN - \internal */ -/*! \class StringToAbstractFloatCaster - \internal */ -/*! \class StringToBase64BinaryCaster - \internal */ -/*! \class StringToBooleanCaster - \internal */ -/*! \class StringToCodepointsFN - \internal */ -/*! \class StringToDateCaster - \internal */ -/*! \class StringToDateTimeCaster - \internal */ -/*! \class StringToDayTimeDurationCaster - \internal */ -/*! \class StringToDecimalCaster - \internal */ -/*! \class StringToDerivedIntegerCaster - \internal */ -/*! \class StringToDurationCaster - \internal */ -/*! \class StringToGDayCaster - \internal */ -/*! \class StringToGMonthCaster - \internal */ -/*! \class StringToGMonthDayCaster - \internal */ -/*! \class StringToGYearCaster - \internal */ -/*! \class StringToGYearMonthCaster - \internal */ -/*! \class StringToHexBinaryCaster - \internal */ -/*! \class StringToIntegerCaster - \internal */ -/*! \class StringToTimeCaster - \internal */ -/*! \class StringToYearMonthDurationCaster - \internal */ -/*! \class StringType - \internal */ -/*! \class DerivedStringType - \internal */ -/*! \class SubsequenceFN - \internal */ -/*! \class SubstringAfterFN - \internal */ -/*! \class SubstringBeforeFN - \internal */ -/*! \class SubstringFN - \internal */ -/*! \class SumFN - \internal */ -/*! \class SystemPropertyFN - \internal */ -/*! \class TimezoneFromAbstractDateTimeFN - \internal */ -/*! \class ToAnyURICaster - \internal */ -/*! \class ToAnyURICasterLocator - \internal */ -/*! \class ToBase64BinaryCasterLocator - \internal */ -/*! \class ToBooleanCasterLocator - \internal */ -/*! \class ToDateCasterLocator - \internal */ -/*! \class ToDateTimeCasterLocator - \internal */ -/*! \class ToDayTimeDurationCasterLocator - \internal */ -/*! \class ToDecimalCasterLocator - \internal */ -/*! \class ToDoubleCasterLocator - \internal */ -/*! \class ToDurationCasterLocator - \internal */ -/*! \class ToFloatCasterLocator - \internal */ -/*! \class ToGDayCasterLocator - \internal */ -/*! \class ToGMonthCasterLocator - \internal */ -/*! \class ToGMonthDayCasterLocator - \internal */ -/*! \class ToGYearCasterLocator - \internal */ -/*! \class ToGYearMonthCasterLocator - \internal */ -/*! \class ToHexBinaryCasterLocator - \internal */ -/*! \class ToIntegerCasterLocator - \internal */ -/*! \class ToDerivedIntegerCasterLocator - \internal */ -/*! \class ToQNameCasterLocator - \internal */ -/*! \class ToSchemaTimeCasterLocator - \internal */ -/*! \class ToStringCaster - \internal */ -/*! \class ToStringCasterLocator - \internal */ -/*! \class ToDerivedStringCasterLocator - \internal */ -/*! \class ToUntypedAtomicCaster - \internal */ -/*! \class ToUntypedAtomicCasterLocator - \internal */ -/*! \class ToYearMonthDurationCasterLocator - \internal */ -/*! \class Tokenizer - \internal */ -/*! \class XQueryTokenizer - \internal */ -/*! \class TraceFN - \internal */ -/*! \class TranslateFN - \internal */ -/*! \class TrueFN - \internal */ -/*! \class UntypedAtomic - \internal */ -/*! \class UntypedAtomicConverter - \internal */ -/*! \class ArgumentConverter - \internal */ -/*! \class UntypedAtomicType - \internal */ -/*! \class UpperCaseFN - \internal */ -/*! \class ValidationError - \internal */ -/*! \class VariableDeclaration - \internal */ -/*! \class VariableLoader - \internal */ -/*! \class YearFromAbstractDateTimeFN - \internal */ -/*! \class YearMonthDuration - \internal */ -/*! \class YearMonthDurationComparatorLocator - \internal */ -/*! \class YearMonthDurationMathematicianLocator - \internal */ -/*! \class YearMonthDurationType - \internal */ -/*! \class YearsFromDurationFN - \internal - */ -/*! \class DocumentContentValidator - \internal */ -/*! \class AtomicTypeVisitor - \internal */ -/*! \class AtomicCasterLocator - \internal */ -/*! \class AtomicTypeVisitorResult - \internal */ -/*! \class Expression - \internal */ -/*! \class EmptyContainer - \internal */ -/*! \class AxisStep - \internal */ -/*! \class ContextItem - \internal */ -/*! \class EmptySequence - \internal */ -/*! \class ExternalVariableReference - \internal */ -/*! \class Literal - \internal */ -/*! \class LiteralSequence - \internal */ -/*! \class NamespaceConstructor - \internal */ -/*! \class ParentNodeAxis - \internal */ -/*! \class VariableReference - \internal */ -/*! \class ArgumentReference - \internal */ -/*! \class ExpressionVariableReference - \internal */ -/*! \class PositionalVariableReference - \internal */ -/*! \class RangeVariableReference - \internal */ -/*! \class PairContainer - \internal */ -/*! \class AndExpression - \internal */ -/*! \class OrExpression - \internal */ -/*! \class ArithmeticExpression - \internal */ -/*! \class UnaryExpression - \internal */ -/*! \class AttributeConstructor - \internal */ -/*! \class CombineNodes - \internal */ -/*! \class ElementConstructor - \internal */ -/*! \class ForClause - \internal */ -/*! \class GeneralComparison - \internal */ -/*! \class GenericPredicate - \internal */ -/*! \class TruthPredicate - \internal */ -/*! \class LetClause - \internal */ -/*! \class NodeComparison - \internal */ -/*! \class Path - \internal */ -/*! \class ProcessingInstructionConstructor - \internal */ -/*! \class QuantifiedExpression - \internal */ -/*! \class RangeExpression - \internal */ -/*! \class ValueComparison - \internal */ -/*! \class SingleContainer - \internal */ -/*! \class AttributeNameValidator - \internal */ -/*! \class CastAs - \internal */ -/*! \class CastableAs - \internal */ -/*! \class CollationChecker - \internal */ -/*! \class CommentConstructor - \internal */ -/*! \class CopyOf - \internal */ -/*! \class DocumentConstructor - \internal */ -/*! \class DynamicContextStore - \internal */ -/*! \class FirstItemPredicate - \internal */ -/*! \class InstanceOf - \internal */ -/*! \class NCNameConstructor - \internal */ -/*! \class NodeSortExpression - \internal */ -/*! \class OrderBy - \internal */ -/*! \class QNameConstructor - \internal */ -/*! \class SimpleContentConstructor - \internal */ -/*! \class TextNodeConstructor - \internal */ -/*! \class TreatAs - \internal */ -/*! \class TripleContainer - \internal */ -/*! \class IfThenClause - \internal */ -/*! \class UnlimitedContainer - \internal */ -/*! \class ExpressionSequence - \internal */ -/*! \class ReturnOrderBy - \internal */ -/*! \class UserFunctionCallsite - \internal */ -/*! \class ExpressionCreator - \internal */ -/*! \class ByIDCreator - \internal */ -/*! \class ExpressionFactory - \internal */ -/*! \class ExpressionIdentifier - \internal */ -/*! \class BooleanIdentifier - \internal */ -/*! \class ByIDIdentifier - \internal */ -/*! \class BySequenceTypeIdentifier - \internal */ -/*! \class ComparisonIdentifier - \internal */ -/*! \class IntegerIdentifier - \internal */ -/*! \class ExternalVariableLoader - \internal */ -/*! \class ItemType - \internal */ -/*! \class AnyItemType - \internal */ -/*! \class AnyNodeType - \internal */ -/*! \class AbstractNodeTest - \internal */ -/*! \class LocalNameTest - \internal */ -/*! \class NamespaceNameTest - \internal */ -/*! \class QNameTest - \internal */ -/*! \class AtomicType - \internal */ -/*! \class BuiltinAtomicType - \internal */ -/*! \class AnyAtomicType - \internal */ -/*! \class AnyURIType - \internal */ -/*! \class NumericType - \internal */ -/*! \class EBVType - \internal */ -/*! \class EmptySequenceType - \internal */ -/*! \class MultiItemType - \internal */ -/*! \class NoneType - \internal */ -/*! \class OptimizationPass - \internal */ -/*! \class ParameterizedAtomicTypeVisitor - \internal */ -/*! \class AtomicComparatorLocator - \internal */ -/*! \class AtomicMathematicianLocator - \internal */ -/*! \class SchemaComponent - \internal */ -/*! \class SchemaType - \internal */ -/*! \class AnyType - \internal */ -/*! \class AnySimpleType - \internal */ -/*! \class Untyped - \internal */ -/*! \class SchemaTypeFactory - \internal */ -/*! \class BasicTypesFactory - \internal */ -/*! \class SequenceType - \internal */ -/*! \class GenericSequenceType - \internal */ -/*! \class UserFunction - \internal -*/ -QT_END_NAMESPACE diff --git a/doc/src/qplugin.qdoc b/doc/src/qplugin.qdoc deleted file mode 100644 index 4fbd198..0000000 --- a/doc/src/qplugin.qdoc +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \headerfile - \title Macros for Defining Plugins - - \brief The header files defines macros for defining plugins. - - \sa {How to Create Qt Plugins} -*/ - -/*! - \macro Q_DECLARE_INTERFACE(ClassName, Identifier) - \relates - - This macro associates the given \a Identifier (a string literal) - to the interface class called \a ClassName. The \a Identifier must - be unique. For example: - - \snippet examples/tools/plugandpaint/interfaces.h 3 - - This macro is normally used right after the class definition for - \a ClassName, in a header file. See the - \l{tools/plugandpaint}{Plug & Paint} example for details. - - If you want to use Q_DECLARE_INTERFACE with interface classes - declared in a namespace then you have to make sure the Q_DECLARE_INTERFACE - is not inside a namespace though. For example: - \snippet doc/src/snippets/code/doc_src_qplugin.qdoc 0 - - \sa Q_INTERFACES(), Q_EXPORT_PLUGIN2(), {How to Create Qt Plugins} -*/ - -/*! - \macro Q_EXPORT_PLUGIN(ClassName) - \relates - \obsolete - - Use Q_EXPORT_PLUGIN2() instead. This macro is equivalent to - Q_EXPORT_PLUGIN2(\a ClassName, \a ClassName). -*/ - -/*! - \macro Q_EXPORT_PLUGIN2(PluginName, ClassName) - \relates - \since 4.1 - \keyword Q_EXPORT_PLUGIN2 - - This macro exports the plugin class \a ClassName for the plugin specified - by \a PluginName. The value of \a PluginName should correspond to the - \l{qmake Variable Reference#TARGET}{TARGET} specified in the plugin's - project file. - - There should be exactly one occurrence of this macro in the source code - for a Qt plugin, and it should be used where the implementation is written - rather than in a header file. - - Example: - - \snippet doc/src/snippets/code/doc_src_qplugin.qdoc 1 - - See the \l{tools/plugandpaint}{Plug & Paint} example for details. - - \sa Q_DECLARE_INTERFACE(), {How to Create Qt Plugins} -*/ - -/*! - \macro Q_IMPORT_PLUGIN(PluginName) - \relates - - This macro imports the plugin named \a PluginName, corresponding - to the \l{qmake Variable Reference#TARGET}{TARGET} specified in the - plugin's project file. - - Inserting this macro into your application's source code will allow - you to make use of a static plugin. - - Example: - - \snippet doc/src/snippets/code/doc_src_qplugin.qdoc 2 - - Static plugins must also be included by the linker when your - application is built. For Qt's predefined plugins, - you can use the \c QTPLUGIN to add - the required plugins to your build. For example: - - \snippet doc/src/snippets/code/doc_src_qplugin.qdoc 3 - - \sa {Static Plugins}, {How to Create Qt Plugins}, {Using qmake} -*/ - -/*! - \macro Q_EXPORT_STATIC_PLUGIN(ClassName) - \relates - \internal -*/ diff --git a/doc/src/qprintdialog.qdoc b/doc/src/qprintdialog.qdoc deleted file mode 100644 index 8011f62..0000000 --- a/doc/src/qprintdialog.qdoc +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifdef QT3_SUPPORT -/*! - \fn QPrinter *QPrintDialog::printer() const - - Returns a pointer to the printer this dialog configures, or 0 if - this dialog does not operate on any printer. - - This function is available for Unix platforms only. -*/ - -/*! - \fn void QPrintDialog::setPrinter(QPrinter *printer, bool pickupSettings) - - Sets this dialog to configure printer \a printer, or no printer if \a printer - is null. If \a pickupSettings is true, the dialog reads most of - its settings from \a printer. If \a pickupSettings is false (the - default) the dialog keeps its old settings. - - This function is available for Unix platforms only. -*/ - -/*! - \fn void QPrintDialog::addButton(QPushButton *button) - - Adds the \a button to the layout of the print dialog. The added - buttons are arranged from the left to the right below the - last groupbox of the printdialog. - - This function is available for Unix platforms only. -*/ -#endif diff --git a/doc/src/qprinterinfo.qdoc b/doc/src/qprinterinfo.qdoc deleted file mode 100644 index a4ffeb2..0000000 --- a/doc/src/qprinterinfo.qdoc +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QPrinterInfo - - \brief The QPrinterInfo class gives access to information about - existing printers. - - Use the static functions to generate a list of QPrinterInfo - objects. Each QPrinterInfo object in the list represents a single - printer and can be queried for name, supported paper sizes, and - whether or not it is the default printer. - - \since 4.4 -*/ - -/*! - \fn QList QPrinterInfo::availablePrinters() - - Returns a list of available printers on the system. -*/ - -/*! - \fn QPrinterInfo QPrinterInfo::defaultPrinter() - - Returns the default printer on the system. - - The return value should be checked using isNull() before being - used, in case there is no default printer. - - \sa isNull() -*/ - -/*! - \fn QPrinterInfo::QPrinterInfo() - - Constructs an empty QPrinterInfo object. - - \sa isNull() -*/ - -/*! - \fn QPrinterInfo::QPrinterInfo(const QPrinterInfo& src) - - Constructs a copy of \a src. -*/ - -/*! - \fn QPrinterInfo::QPrinterInfo(const QPrinter& printer) - - Constructs a QPrinterInfo object from \a printer. -*/ - -/*! - \fn QPrinterInfo::~QPrinterInfo() - - Destroys the QPrinterInfo object. References to the values in the - object become invalid. -*/ - -/*! - \fn QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src) - - Sets the QPrinterInfo object to be equal to \a src. -*/ - -/*! - \fn QString QPrinterInfo::printerName() const - - Returns the name of the printer. - - \sa QPrinter::setPrinterName() -*/ - -/*! - \fn bool QPrinterInfo::isNull() const - - Returns whether this QPrinterInfo object holds a printer definition. - - An empty QPrinterInfo object could result for example from calling - defaultPrinter() when there are no printers on the system. -*/ - -/*! - \fn bool QPrinterInfo::isDefault() const - - Returns whether this printer is the default printer. -*/ - -/*! - \fn QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const - \since 4.4 - - Returns a list of supported paper sizes by the printer. - - Not all printer drivers support this query, so the list may be empty. - On Mac OS X 10.3, this function always returns an empty list. -*/ diff --git a/doc/src/qset.qdoc b/doc/src/qset.qdoc deleted file mode 100644 index 0db3775..0000000 --- a/doc/src/qset.qdoc +++ /dev/null @@ -1,953 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QSet - \brief The QSet class is a template class that provides a hash-table-based set. - - \ingroup tools - \ingroup shared - \reentrant - \mainclass - - QSet is one of Qt's generic \l{container classes}. It stores - values in an unspecified order and provides very fast lookup of - the values. Internally, QSet is implemented as a QHash. - - Here's an example QSet with QString values: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 0 - - To insert a value into the set, use insert(): - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 1 - - Another way to insert items into the set is to use operator<<(): - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 2 - - To test whether an item belongs to the set or not, use contains(): - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 3 - - If you want to navigate through all the values stored in a QSet, - you can use an iterator. QSet supports both \l{Java-style - iterators} (QSetIterator and QMutableSetIterator) and \l{STL-style - iterators} (QSet::iterator and QSet::const_iterator). Here's how - to iterate over a QSet using a Java-style iterator: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 4 - - Here's the same code, but using an STL-style iterator: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 5 - - QSet is unordered, so an iterator's sequence cannot be assumed to - be predictable. If ordering by key is required, use a QMap. - - To navigate through a QSet, you can also use \l{foreach}: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 6 - - Items can be removed from the set using remove(). There is also a - clear() function that removes all items. - - QSet's value data type must be an \l{assignable data type}. You - cannot, for example, store a QWidget as a value; instead, store a - QWidget *. In addition, the type must provide \c operator==(), and - there must also be a global qHash() function that returns a hash - value for an argument of the key's type. See the QHash - documentation for a list of types supported by qHash(). - - Internally, QSet uses a hash table to perform lookups. The hash - table automatically grows and shrinks to provide fast lookups - without wasting memory. You can still control the size of the hash - table by calling reserve(), if you already know approximately how - many elements the QSet will contain, but this isn't necessary to - obtain good performance. You can also call capacity() to retrieve - the hash table's size. - - \sa QSetIterator, QMutableSetIterator, QHash, QMap -*/ - -/*! - \fn QSet::QSet() - - Constructs an empty set. - - \sa clear() -*/ - -/*! - \fn QSet::QSet(const QSet &other) - - Constructs a copy of \a other. - - This operation occurs in \l{constant time}, because QSet is - \l{implicitly shared}. This makes returning a QSet from a - function very fast. If a shared instance is modified, it will be - copied (copy-on-write), and this takes \l{linear time}. - - \sa operator=() -*/ - -/*! - \fn QSet &QSet::operator=(const QSet &other) - - Assigns the \a other set to this set and returns a reference to - this set. -*/ - -/*! - \fn bool QSet::operator==(const QSet &other) const - - Returns true if the \a other set is equal to this set; otherwise - returns false. - - Two sets are considered equal if they contain the same elements. - - This function requires the value type to implement \c operator==(). - - \sa operator!=() -*/ - -/*! - \fn bool QSet::operator!=(const QSet &other) const - - Returns true if the \a other set is not equal to this set; otherwise - returns false. - - Two sets are considered equal if they contain the same elements. - - This function requires the value type to implement \c operator==(). - - \sa operator==() -*/ - -/*! - \fn int QSet::size() const - - Returns the number of items in the set. - - \sa isEmpty(), count() -*/ - -/*! - \fn bool QSet::isEmpty() const - - Returns true if the set contains no elements; otherwise returns - false. - - \sa size() -*/ - -/*! - \fn int QSet::capacity() const - - Returns the number of buckets in the set's internal hash - table. - - The sole purpose of this function is to provide a means of fine - tuning QSet's memory usage. In general, you will rarely ever need - to call this function. If you want to know how many items are in - the set, call size(). - - \sa reserve(), squeeze() -*/ - -/*! \fn void QSet::reserve(int size) - - Ensures that the set's internal hash table consists of at - least \a size buckets. - - This function is useful for code that needs to build a huge set - and wants to avoid repeated reallocation. For example: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 7 - - Ideally, \a size should be slightly more than the maximum number - of elements expected in the set. \a size doesn't have to be prime, - because QSet will use a prime number internally anyway. If \a size - is an underestimate, the worst that will happen is that the QSet - will be a bit slower. - - In general, you will rarely ever need to call this function. - QSet's internal hash table automatically shrinks or grows to - provide good performance without wasting too much memory. - - \sa squeeze(), capacity() -*/ - -/*! - \fn void QSet::squeeze() - - Reduces the size of the set's internal hash table to save - memory. - - The sole purpose of this function is to provide a means of fine - tuning QSet's memory usage. In general, you will rarely ever - need to call this function. - - \sa reserve(), capacity() -*/ - -/*! - \fn void QSet::detach() - - \internal - - Detaches this set from any other sets with which it may share - data. - - \sa isDetached() -*/ - -/*! \fn bool QSet::isDetached() const - - \internal - - Returns true if the set's internal data isn't shared with any - other set object; otherwise returns false. - - \sa detach() -*/ - -/*! - \fn void QSet::setSharable(bool sharable) - \internal -*/ - -/*! - \fn void QSet::clear() - - Removes all elements from the set. - - \sa remove() -*/ - -/*! - \fn bool QSet::remove(const T &value) - - Removes any occurrence of item \a value from the set. Returns - true if an item was actually removed; otherwise returns false. - - \sa contains(), insert() -*/ - -/*! - \fn QSet::iterator QSet::erase(iterator pos) - \since 4.2 - - Removes the item at the iterator position \a pos from the set, and - returns an iterator positioned at the next item in the set. - - Unlike remove(), this function never causes QSet to rehash its - internal data structure. This means that it can safely be called - while iterating, and won't affect the order of items in the set. - - \sa remove(), find() -*/ - -/*! \fn QSet::const_iterator QSet::find(const T &value) const - \since 4.2 - - Returns a const iterator positioned at the item \a value in the - set. If the set contains no item \a value, the function returns - constEnd(). - - \sa constFind(), contains() -*/ - -/*! \fn QSet::iterator QSet::find(const T &value) - \since 4.2 - \overload - - Returns a non-const iterator positioned at the item \a value in - the set. If the set contains no item \a value, the function - returns end(). -*/ - -/*! \fn QSet::const_iterator QSet::constFind(const T &value) const - \since 4.2 - - Returns a const iterator positioned at the item \a value in the - set. If the set contains no item \a value, the function returns - constEnd(). - - \sa find(), contains() -*/ - -/*! - \fn bool QSet::contains(const T &value) const - - Returns true if the set contains item \a value; otherwise returns - false. - - \sa insert(), remove(), find() -*/ - -/*! - \fn bool QSet::contains(const QSet &other) const - \since 4.6 - - Returns true if the set contains all items from the \a other set; - otherwise returns false. - - \sa insert(), remove(), find() -*/ - -/*! \fn QSet::const_iterator QSet::begin() const - - Returns a const \l{STL-style iterator} positioned at the first - item in the set. - - \sa constBegin(), end() -*/ - -/*! \fn QSet::iterator QSet::begin() - \since 4.2 - \overload - - Returns a non-const \l{STL-style iterator} positioned at the first - item in the set. -*/ - -/*! \fn QSet::const_iterator QSet::constBegin() const - - Returns a const \l{STL-style iterator} positioned at the first - item in the set. - - \sa begin(), constEnd() -*/ - -/*! \fn QSet::const_iterator QSet::end() const - - Returns a const \l{STL-style iterator} positioned at the imaginary - item after the last item in the set. - - \sa constEnd(), begin() -*/ - -/*! \fn QSet::iterator QSet::end() - \since 4.2 - \overload - - Returns a non-const \l{STL-style iterator} pointing to the - imaginary item after the last item in the set. -*/ - -/*! \fn QSet::const_iterator QSet::constEnd() const - - Returns a const \l{STL-style iterator} pointing to the imaginary - item after the last item in the set. - - \sa constBegin(), end() -*/ - -/*! - \typedef QSet::Iterator - \since 4.2 - - Qt-style synonym for QSet::iterator. -*/ - -/*! - \typedef QSet::ConstIterator - - Qt-style synonym for QSet::const_iterator. -*/ - -/*! - \typedef QSet::const_pointer - - Typedef for const T *. Provided for STL compatibility. -*/ - -/*! - \typedef QSet::const_reference - - Typedef for const T &. Provided for STL compatibility. -*/ - -/*! - \typedef QSet::difference_type - - Typedef for const ptrdiff_t. Provided for STL compatibility. -*/ - -/*! - \typedef QSet::key_type - - Typedef for T. Provided for STL compatibility. -*/ - -/*! - \typedef QSet::pointer - - Typedef for T *. Provided for STL compatibility. -*/ - -/*! - \typedef QSet::reference - - Typedef for T &. Provided for STL compatibility. -*/ - -/*! - \typedef QSet::size_type - - Typedef for int. Provided for STL compatibility. -*/ - -/*! - \typedef QSet::value_type - - Typedef for T. Provided for STL compatibility. -*/ - -/*! - \fn QSet::const_iterator QSet::insert(const T &value) - - Inserts item \a value into the set, if \a value isn't already - in the set, and returns an iterator pointing at the inserted - item. - - \sa operator<<(), remove(), contains() -*/ - -/*! - \fn QSet &QSet::unite(const QSet &other) - - Each item in the \a other set that isn't already in this set is - inserted into this set. A reference to this set is returned. - - \sa operator|=(), intersect(), subtract() -*/ - -/*! - \fn QSet &QSet::intersect(const QSet &other) - - Removes all items from this set that are not contained in the - \a other set. A reference to this set is returned. - - \sa operator&=(), unite(), subtract() -*/ - -/*! - \fn QSet &QSet::subtract(const QSet &other) - - Removes all items from this set that are contained in the - \a other set. Returns a reference to this set. - - \sa operator-=(), unite(), intersect() -*/ - -/*! - \fn bool QSet::empty() const - - Returns true if the set is empty. This function is provided - for STL compatibility. It is equivalent to isEmpty(). -*/ - -/*! - \fn bool QSet::count() const - - Same as size(). -*/ - -/*! - \fn QSet &QSet::operator<<(const T &value) - \fn QSet &QSet::operator+=(const T &value) - \fn QSet &QSet::operator|=(const T &value) - - Inserts a new item \a value and returns a reference to the set. - If \a value already exists in the set, the set is left unchanged. - - \sa insert() -*/ - -/*! - \fn QSet &QSet::operator-=(const T &value) - - Removes the occurrence of item \a value from the set, if - it is found, and returns a reference to the set. If the - \a value is not contained the set, nothing is removed. - - \sa remove() -*/ - -/*! - \fn QSet &QSet::operator|=(const QSet &other) - \fn QSet &QSet::operator+=(const QSet &other) - - Same as unite(\a other). - - \sa operator|(), operator&=(), operator-=() -*/ - -/*! - \fn QSet &QSet::operator&=(const QSet &other) - - Same as intersect(\a other). - - \sa operator&(), operator|=(), operator-=() -*/ - -/*! - \fn QSet &QSet::operator&=(const T &value) - - \overload - - Same as intersect(\e{other}), if we consider \e{other} to be a set - that contains the singleton \a value. -*/ - - -/*! - \fn QSet &QSet::operator-=(const QSet &other) - - Same as subtract(\a{other}). - - \sa operator-(), operator|=(), operator&=() -*/ - -/*! - \fn QSet QSet::operator|(const QSet &other) const - \fn QSet QSet::operator+(const QSet &other) const - - Returns a new QSet that is the union of this set and the - \a other set. - - \sa unite(), operator|=(), operator&(), operator-() -*/ - -/*! - \fn QSet QSet::operator&(const QSet &other) const - - Returns a new QSet that is the intersection of this set and the - \a other set. - - \sa intersect(), operator&=(), operator|(), operator-() -*/ - -/*! - \fn QSet QSet::operator-(const QSet &other) const - - Returns a new QSet that is the set difference of this set and - the \a other set, i.e., this set - \a other set. - - \sa subtract(), operator-=(), operator|(), operator&() -*/ - -/*! - \fn QSet QSet::operator-(const QSet &other) - \fn QSet QSet::operator|(const QSet &other) - \fn QSet QSet::operator+(const QSet &other) - \fn QSet QSet::operator&(const QSet &other) - \internal - - These will go away in Qt 5. -*/ - -/*! - \class QSet::iterator - \since 4.2 - \brief The QSet::iterator class provides an STL-style non-const iterator for QSet. - - QSet features both \l{STL-style iterators} and - \l{Java-style iterators}. The STL-style iterators are more - low-level and more cumbersome to use; on the other hand, they are - slightly faster and, for developers who already know STL, have - the advantage of familiarity. - - QSet::iterator allows you to iterate over a QSet and to remove - items (using QSet::erase()) while you iterate. (QSet doesn't let - you \e modify a value through an iterator, because that - would potentially require moving the value in the internal hash - table used by QSet.) If you want to iterate over a const QSet, - you should use QSet::const_iterator. It is generally good - practice to use QSet::const_iterator on a non-const QSet as well, - unless you need to change the QSet through the iterator. Const - iterators are slightly faster, and can improve code readability. - - QSet\::iterator allows you to iterate over a QSet\ and - modify it as you go (using QSet::erase()). However, - - The default QSet::iterator constructor creates an uninitialized - iterator. You must initialize it using a function like - QSet::begin(), QSet::end(), or QSet::insert() before you can - start iterating. Here's a typical loop that prints all the items - stored in a set: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 8 - - Here's a loop that removes certain items (all those that start - with 'J') from a set while iterating: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 9 - - STL-style iterators can be used as arguments to \l{generic - algorithms}. For example, here's how to find an item in the set - using the qFind() algorithm: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 10 - - Multiple iterators can be used on the same set. However, you may - not attempt to modify the container while iterating on it. - - \sa QSet::const_iterator, QMutableSetIterator -*/ - -/*! - \class QSet::const_iterator - \brief The QSet::const_iterator class provides an STL-style const iterator for QSet. - \since 4.2 - - QSet features both \l{STL-style iterators} and - \l{Java-style iterators}. The STL-style iterators are more - low-level and more cumbersome to use; on the other hand, they are - slightly faster and, for developers who already know STL, have - the advantage of familiarity. - - QSet\::const_iterator allows you to iterate over a QSet. - If you want to modify the QSet as you iterate over it, you must - use QSet::iterator instead. It is generally good practice to use - QSet::const_iterator on a non-const QSet as well, unless you need - to change the QSet through the iterator. Const iterators are - slightly faster, and can improve code readability. - - The default QSet::const_iterator constructor creates an - uninitialized iterator. You must initialize it using a function - like QSet::begin(), QSet::end(), or QSet::insert() before you can - start iterating. Here's a typical loop that prints all the items - stored in a set: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 11 - - STL-style iterators can be used as arguments to \l{generic - algorithms}. For example, here's how to find an item in the set - using the qFind() algorithm: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 12 - - Multiple iterators can be used on the same set. However, you may - not attempt to modify the container while iterating on it. - - \sa QSet::iterator, QSetIterator -*/ - -/*! - \fn QSet::iterator::iterator() - \fn QSet::const_iterator::const_iterator() - - Constructs an uninitialized iterator. - - Functions like operator*() and operator++() should not be called - on an uninitialized iterator. Use operator=() to assign a value - to it before using it. - - \sa QSet::begin(), QSet::end() -*/ - -/*! - \fn QSet::iterator::iterator(typename Hash::iterator i) - \fn QSet::const_iterator::const_iterator(typename Hash::const_iterator i) - - \internal -*/ - -/*! - \typedef QSet::iterator::iterator_category - \typedef QSet::const_iterator::iterator_category - - Synonyms for \e {std::bidirectional_iterator_tag} indicating - these iterators are bidirectional iterators. - */ - -/*! - \typedef QSet::iterator::difference_type - \typedef QSet::const_iterator::difference_type - - \internal -*/ - -/*! - \typedef QSet::iterator::value_type - \typedef QSet::const_iterator::value_type - - \internal -*/ - -/*! - \typedef QSet::iterator::pointer - \typedef QSet::const_iterator::pointer - - \internal -*/ - -/*! - \typedef QSet::iterator::reference - \typedef QSet::const_iterator::reference - - \internal -*/ - -/*! - \fn QSet::iterator::iterator(const iterator &other) - \fn QSet::const_iterator::const_iterator(const const_iterator &other) - - Constructs a copy of \a other. -*/ - -/*! - \fn QSet::const_iterator::const_iterator(const iterator &other) - \since 4.2 - \overload - - Constructs a copy of \a other. -*/ - -/*! - \fn QSet::iterator &QSet::iterator::operator=(const iterator &other) - \fn QSet::const_iterator &QSet::const_iterator::operator=(const const_iterator &other) - - Assigns \a other to this iterator. -*/ - -/*! - \fn const T &QSet::iterator::operator*() const - \fn const T &QSet::const_iterator::operator*() const - - Returns a reference to the current item. - - \sa operator->() -*/ - -/*! - \fn const T *QSet::iterator::operator->() const - \fn const T *QSet::const_iterator::operator->() const - - Returns a pointer to the current item. - - \sa operator*() -*/ - -/*! - \fn bool QSet::iterator::operator==(const iterator &other) const - \fn bool QSet::const_iterator::operator==(const const_iterator &other) const - - Returns true if \a other points to the same item as this - iterator; otherwise returns false. - - \sa operator!=() -*/ - -/*! - \fn bool QSet::iterator::operator==(const const_iterator &other) const - \fn bool QSet::iterator::operator!=(const const_iterator &other) const - - \overload -*/ - -/*! - \fn bool QSet::iterator::operator!=(const iterator &other) const - \fn bool QSet::const_iterator::operator!=(const const_iterator &other) const - - Returns true if \a other points to a different item than this - iterator; otherwise returns false. - - \sa operator==() -*/ - -/*! - \fn QSet::iterator &QSet::iterator::operator++() - \fn QSet::const_iterator &QSet::const_iterator::operator++() - - The prefix ++ operator (\c{++it}) advances the iterator to the - next item in the set and returns an iterator to the new current - item. - - Calling this function on QSet::constEnd() leads to - undefined results. - - \sa operator--() -*/ - -/*! - \fn QSet::iterator QSet::iterator::operator++(int) - \fn QSet::const_iterator QSet::const_iterator::operator++(int) - - \overload - - The postfix ++ operator (\c{it++}) advances the iterator to the - next item in the set and returns an iterator to the previously - current item. -*/ - -/*! - \fn QSet::iterator &QSet::iterator::operator--() - \fn QSet::const_iterator &QSet::const_iterator::operator--() - - The prefix -- operator (\c{--it}) makes the preceding item - current and returns an iterator to the new current item. - - Calling this function on QSet::begin() leads to undefined - results. - - \sa operator++() -*/ - -/*! - \fn QSet::iterator QSet::iterator::operator--(int) - \fn QSet::const_iterator QSet::const_iterator::operator--(int) - - \overload - - The postfix -- operator (\c{it--}) makes the preceding item - current and returns an iterator to the previously current item. -*/ - -/*! - \fn QSet::iterator QSet::iterator::operator+(int j) const - \fn QSet::const_iterator QSet::const_iterator::operator+(int j) const - - Returns an iterator to the item at \a j positions forward from - this iterator. (If \a j is negative, the iterator goes backward.) - - This operation can be slow for large \a j values. - - \sa operator-() -*/ - -/*! - \fn QSet::iterator QSet::iterator::operator-(int j) const - \fn QSet::const_iterator QSet::const_iterator::operator-(int j) const - - Returns an iterator to the item at \a j positions backward from - this iterator. (If \a j is negative, the iterator goes forward.) - - This operation can be slow for large \a j values. - - \sa operator+() -*/ - -/*! - \fn QSet::iterator &QSet::iterator::operator+=(int j) - \fn QSet::const_iterator &QSet::const_iterator::operator+=(int j) - - Advances the iterator by \a j items. (If \a j is negative, the - iterator goes backward.) - - This operation can be slow for large \a j values. - - \sa operator-=(), operator+() -*/ - -/*! - \fn QSet::iterator &QSet::iterator::operator-=(int j) - \fn QSet::const_iterator &QSet::const_iterator::operator-=(int j) - - Makes the iterator go back by \a j items. (If \a j is negative, - the iterator goes forward.) - - This operation can be slow for large \a j values. - - \sa operator+=(), operator-() -*/ - -/*! \fn QList QSet::toList() const - - Returns a new QList containing the elements in the set. The - order of the elements in the QList is undefined. - - Example: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 13 - - \sa fromList(), QList::fromSet(), qSort() -*/ - -/*! \fn QList QSet::values() const - - Returns a new QList containing the elements in the set. The - order of the elements in the QList is undefined. - - This is the same as toList(). - - \sa fromList(), QList::fromSet(), qSort() -*/ - - -/*! \fn QSet QSet::fromList(const QList &list) - - Returns a new QSet object containing the data contained in \a - list. Since QSet doesn't allow duplicates, the resulting QSet - might be smaller than the \a list, because QList can contain - duplicates. - - Example: - - \snippet doc/src/snippets/code/doc_src_qset.qdoc 14 - - \sa toList(), QList::toSet() -*/ - -/*! - \fn QDataStream &operator<<(QDataStream &out, const QSet &set) - \relates QSet - - Writes the \a set to stream \a out. - - This function requires the value type to implement \c operator<<(). - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -/*! - \fn QDataStream &operator>>(QDataStream &in, QSet &set) - \relates QSet - - Reads a set from stream \a in into \a set. - - This function requires the value type to implement \c operator>>(). - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ diff --git a/doc/src/qsignalspy.qdoc b/doc/src/qsignalspy.qdoc deleted file mode 100644 index 4ee7590..0000000 --- a/doc/src/qsignalspy.qdoc +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QSignalSpy - \inmodule QtTest - - \brief The QSignalSpy class enables introspection of signal emission. - - QSignalSpy can connect to any signal of any object and records its emission. - QSignalSpy itself is a list of QVariant lists. Each emission of the signal - will append one item to the list, containing the arguments of the signal. - - The following example records all signal emissions for the \c clicked() signal - of a QCheckBox: - - \snippet doc/src/snippets/code/doc_src_qsignalspy.qdoc 0 - - \c{spy.takeFirst()} returns the arguments for the first emitted signal, as a - list of QVariant objects. The \c clicked() signal has a single bool argument, - which is stored as the first entry in the list of arguments. - - The example below catches a signal from a custom object: - - \snippet doc/src/snippets/code/doc_src_qsignalspy.qdoc 1 - - \bold {Note:} Non-standard data types need to be registered, using - the qRegisterMetaType() function, before you can create a - QSignalSpy. For example: - - \snippet doc/src/snippets/code/doc_src_qsignalspy.qdoc 2 - - To retrieve the \c QModelIndex, you can use qvariant_cast: - - \snippet doc/src/snippets/code/doc_src_qsignalspy.qdoc 3 - */ - -/*! \fn QSignalSpy::QSignalSpy(QObject *object, const char *signal) - - Constructs a new QSignalSpy that listens for emissions of the \a signal - from the QObject \a object. Neither \a signal nor \a object can be null. - - Example: - \snippet doc/src/snippets/code/doc_src_qsignalspy.qdoc 4 -*/ - -/*! \fn QSignalSpy::isValid() const - - Returns true if the signal spy listens to a valid signal, otherwise false. -*/ - -/*! \fn QSignalSpy::signal() const - - Returns the normalized signal the spy is currently listening to. -*/ - -/*! \fn int QSignalSpy::qt_metacall(QMetaObject::Call call, int id, void **a) - \internal -*/ - diff --git a/doc/src/qsizepolicy.qdoc b/doc/src/qsizepolicy.qdoc deleted file mode 100644 index c74beb8..0000000 --- a/doc/src/qsizepolicy.qdoc +++ /dev/null @@ -1,522 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QSizePolicy - \brief The QSizePolicy class is a layout attribute describing horizontal - and vertical resizing policy. - - \ingroup appearance - \ingroup geomanagement - - The size policy of a widget is an expression of its willingness to - be resized in various ways, and affects how the widget is treated - by the \l{Layout Management}{layout engine}. Each widget returns a - QSizePolicy that describes the horizontal and vertical resizing - policy it prefers when being laid out. You can change this for - a specific widget by changing its QWidget::sizePolicy property. - - QSizePolicy contains two independent QSizePolicy::Policy values - and two stretch factors; one describes the widgets's horizontal - size policy, and the other describes its vertical size policy. It - also contains a flag to indicate whether the height and width of - its preferred size are related. - - The horizontal and vertical policies can be set in the - constructor, and altered using the setHorizontalPolicy() and - setVerticalPolicy() functions. The stretch factors can be set - using the setHorizontalStretch() and setVerticalStretch() - functions. The flag indicating whether the widget's - \l{QWidget::sizeHint()}{sizeHint()} is width-dependent (such as a - menu bar or a word-wrapping label) can be set using the - setHeightForWidth() function. - - The current size policies and stretch factors be retrieved using - the horizontalPolicy(), verticalPolicy(), horizontalStretch() and - verticalStretch() functions. Alternatively, use the transpose() - function to swap the horizontal and vertical policies and - stretches. The hasHeightForWidth() function returns the current - status of the flag indicating the size hint dependencies. - - Use the expandingDirections() function to determine whether the - associated widget can make use of more space than its - \l{QWidget::sizeHint()}{sizeHint()} function indicates, as well as - find out in which directions it can expand. - - Finally, the QSizePolicy class provides operators comparing this - size policy to a given policy, as well as a QVariant operator - storing this QSizePolicy as a QVariant object. - - \sa QSize, QWidget::sizeHint(), QWidget::sizePolicy, - QLayoutItem::sizeHint() -*/ - -/*! - \enum QSizePolicy::PolicyFlag - - These flags are combined together to form the various \l{Policy} - values: - - \value GrowFlag The widget can grow beyond its size hint if necessary. - \value ExpandFlag The widget should get as much space as possible. - \value ShrinkFlag The widget can shrink below its size hint if necessary. - \value IgnoreFlag The widget's size hint is ignored. The widget will get - as much space as possible. - - \sa Policy -*/ - -/*! - \enum QSizePolicy::Policy - - This enum describes the various per-dimension sizing types used - when constructing a QSizePolicy. - - \value Fixed The QWidget::sizeHint() is the only acceptable - alternative, so the widget can never grow or shrink (e.g. the - vertical direction of a push button). - - \value Minimum The sizeHint() is minimal, and sufficient. The - widget can be expanded, but there is no advantage to it being - larger (e.g. the horizontal direction of a push button). - It cannot be smaller than the size provided by sizeHint(). - - \value Maximum The sizeHint() is a maximum. The widget can be - shrunk any amount without detriment if other widgets need the - space (e.g. a separator line). - It cannot be larger than the size provided by sizeHint(). - - \value Preferred The sizeHint() is best, but the widget can be - shrunk and still be useful. The widget can be expanded, but there - is no advantage to it being larger than sizeHint() (the default - QWidget policy). - - \value Expanding The sizeHint() is a sensible size, but the - widget can be shrunk and still be useful. The widget can make use - of extra space, so it should get as much space as possible (e.g. - the horizontal direction of a horizontal slider). - - \value MinimumExpanding The sizeHint() is minimal, and sufficient. - The widget can make use of extra space, so it should get as much - space as possible (e.g. the horizontal direction of a horizontal - slider). - - \value Ignored The sizeHint() is ignored. The widget will get as - much space as possible. - - \sa PolicyFlag, setHorizontalPolicy(), setVerticalPolicy() -*/ - -/*! - \fn QSizePolicy::QSizePolicy() - - Constructs a QSizePolicy object with \l Fixed as its horizontal - and vertical policies. - - The policies can be altered using the setHorizontalPolicy() and - setVerticalPolicy() functions. Use the setHeightForWidth() - function if the preferred height of the widget is dependent on the - width of the widget (for example, a QLabel with line wrapping). - - \sa setHorizontalStretch(), setVerticalStretch() -*/ - -/*! - \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical) - - Constructs a QSizePolicy object with the given \a horizontal and - \a vertical policies, and DefaultType as the control type. - - Use setHeightForWidth() if the preferred height of the widget is - dependent on the width of the widget (for example, a QLabel with - line wrapping). - - \sa setHorizontalStretch(), setVerticalStretch() -*/ - -/*! - \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical, ControlType type) - \since 4.3 - - Constructs a QSizePolicy object with the given \a horizontal and - \a vertical policies, and the specified control \a type. - - Use setHeightForWidth() if the preferred height of the widget is - dependent on the width of the widget (for example, a QLabel with - line wrapping). - - \sa setHorizontalStretch(), setVerticalStretch(), controlType() -*/ - -/*! - \fn QSizePolicy::Policy QSizePolicy::horizontalPolicy() const - - Returns the horizontal component of the size policy. - - \sa setHorizontalPolicy(), verticalPolicy(), horizontalStretch() -*/ - -/*! - \fn QSizePolicy::Policy QSizePolicy::verticalPolicy() const - - Returns the vertical component of the size policy. - - \sa setVerticalPolicy(), horizontalPolicy(), verticalStretch() -*/ - -/*! - \fn void QSizePolicy::setHorizontalPolicy(Policy policy) - - Sets the horizontal component to the given \a policy. - - \sa horizontalPolicy(), setVerticalPolicy(), setHorizontalStretch() -*/ - -/*! - \fn void QSizePolicy::setVerticalPolicy(Policy policy) - - Sets the vertical component to the given \a policy. - - \sa verticalPolicy(), setHorizontalPolicy(), setVerticalStretch() -*/ - -/*! - \fn Qt::Orientations QSizePolicy::expandingDirections() const - - Returns whether a widget can make use of more space than the - QWidget::sizeHint() function indicates. - - A value of Qt::Horizontal or Qt::Vertical means that the widget - can grow horizontally or vertically (i.e., the horizontal or - vertical policy is \l Expanding or \l MinimumExpanding), whereas - Qt::Horizontal | Qt::Vertical means that it can grow in both - dimensions. - - \sa horizontalPolicy(), verticalPolicy() -*/ - -/*! - \fn ControlType QSizePolicy::controlType() const - \since 4.3 - - Returns the control type associated with the widget for which - this size policy applies. -*/ - -/*! - \fn void QSizePolicy::setControlType(ControlType type) - \since 4.3 - - Sets the control type associated with the widget for which this - size policy applies to \a type. - - The control type specifies the type of the widget for which this - size policy applies. It is used by some styles, notably - QMacStyle, to insert proper spacing between widgets. For example, - the Mac OS X Aqua guidelines specify that push buttons should be - separated by 12 pixels, whereas vertically stacked radio buttons - only require 6 pixels. - - \sa QStyle::layoutSpacing() -*/ - -/*! - \fn void QSizePolicy::setHeightForWidth(bool dependent) - - Sets the flag determining whether the widget's preferred height - depends on its width, to \a dependent. - - \sa hasHeightForWidth() -*/ - -/*! - \fn bool QSizePolicy::hasHeightForWidth() const - - Returns true if the widget's preferred height depends on its - width; otherwise returns false. - - \sa setHeightForWidth() -*/ - -/*! - \fn bool QSizePolicy::operator==(const QSizePolicy &other) const - - Returns true if this policy is equal to \a other; otherwise - returns false. - - \sa operator!=() -*/ - -/*! - \fn bool QSizePolicy::operator!=(const QSizePolicy &other) const - - Returns true if this policy is different from \a other; otherwise - returns false. - - \sa operator==() -*/ - -/*! - \fn int QSizePolicy::horizontalStretch() const - - Returns the horizontal stretch factor of the size policy. - - \sa setHorizontalStretch(), verticalStretch(), horizontalPolicy() -*/ - -/*! - \fn int QSizePolicy::verticalStretch() const - - Returns the vertical stretch factor of the size policy. - - \sa setVerticalStretch(), horizontalStretch(), verticalPolicy() -*/ - -/*! - \fn void QSizePolicy::setHorizontalStretch(uchar stretchFactor) - - Sets the horizontal stretch factor of the size policy to the given \a - stretchFactor. - - \sa horizontalStretch(), setVerticalStretch(), setHorizontalPolicy() -*/ - -/*! - \fn void QSizePolicy::setVerticalStretch(uchar stretchFactor) - - Sets the vertical stretch factor of the size policy to the given - \a stretchFactor. - - \sa verticalStretch(), setHorizontalStretch(), setVerticalPolicy() -*/ - -/*! - \fn void QSizePolicy::transpose() - - Swaps the horizontal and vertical policies and stretches. -*/ - -/*! - \enum QSizePolicy::ControlType - \since 4.3 - - This enum specifies the different types of widgets in terms of - layout interaction: - - \value DefaultType The default type, when none is specified. - \value ButtonBox A QDialogButtonBox instance. - \value CheckBox A QCheckBox instance. - \value ComboBox A QComboBox instance. - \value Frame A QFrame instance. - \value GroupBox A QGroupBox instance. - \value Label A QLabel instance. - \value Line A QFrame instance with QFrame::HLine or QFrame::VLine. - \value LineEdit A QLineEdit instance. - \value PushButton A QPushButton instance. - \value RadioButton A QRadioButton instance. - \value Slider A QAbstractSlider instance. - \value SpinBox A QAbstractSpinBox instance. - \value TabWidget A QTabWidget instance. - \value ToolButton A QToolButton instance. - - \sa setControlType(), controlType() -*/ - -#ifdef QT3_SUPPORT -/*! - \typedef QSizePolicy::SizeType - \compat - - Use the QSizePolicy::Policy enum instead. -*/ - -/*! - \enum QSizePolicy::ExpandData - \compat - - Use the Qt::Orientations enum instead. - - \value NoDirection Use 0 instead. - \value Horizontally Use Qt::Horizontal instead. - \value Vertically Use Qt::Vertical instead. - \value BothDirections Use Qt::Horizontal | Qt::Vertical instead. -*/ - -/*! - \fn bool QSizePolicy::mayShrinkHorizontally() const - - Use the horizontalPolicy() function combined with the - QSizePolicy::PolicyFlag enum instead. - - \oldcode - bool policy = mayShrinkHorizontally(); - \newcode - bool policy = horizontalPolicy() & QSizePolicy::ShrinkFlag; - \endcode -*/ - -/*! - \fn bool QSizePolicy::mayShrinkVertically() const - - Use the verticalPolicy() function combined with the - QSizePolicy::PolicyFlag enum instead. - - \oldcode - bool policy = mayShrinkVertically(); - \newcode - bool policy = verticalPolicy() & QSizePolicy::ShrinkFlag; - \endcode -*/ - -/*! - \fn bool QSizePolicy::mayGrowHorizontally() const - - Use the horizontalPolicy() function combined with the - QSizePolicy::PolicyFlag enum instead. - - \oldcode - bool policy = mayGrowHorizontally(); - \newcode - bool policy = horizontalPolicy() & QSizePolicy::GrowFlag; - \endcode -*/ - -/*! - \fn bool QSizePolicy::mayGrowVertically() const - - Use the verticalPolicy() function combined with the - QSizePolicy::PolicyFlag enum instead. - - \oldcode - bool policy = mayGrowVertically(); - \newcode - bool policy = verticalPolicy() & QSizePolicy::GrowFlag; - \endcode -*/ - -/*! - \fn Qt::QSizePolicy::Orientations QSizePolicy::expanding() const - - Use expandingDirections() instead. -*/ - -/*! - \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical, bool dependent) - - Use the QSizePolicy() constructor and the setHeightForWidth() - function instead. - - \oldcode - QSizePolicy *policy = new QSizePolicy(horizontal, vertical, dependent); - \newcode - QSizePolicy *policy = new QSizePolicy(horizontal, vertical); - policy->setHeightForWidth(dependent); - \endcode -*/ - -/*! - \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical, uchar horizontalStretch, - uchar verticalStretch, bool dependent) - - Use the QSizePolicy() constructor and call the - setHorizontalStretch(), setVerticalStretch(), and - setHeightForWidth() functions instead. - - \oldcode - QSizePolicy *policy = new QSizePolicy(horizontal, vertical, - horizontalStretch, verticalStretch, - dependent); - \newcode - QSizePolicy *policy = new QSizePolicy(horizontal, vertical); - policy->setHorizontalStretch(horizontalStretch); - policy->setVerticalStretch(verticalStretch); - policy->setHeightForWidth(dependent); - \endcode -*/ - -/*! - \fn QSizePolicy::Policy QSizePolicy::horData() const - - Use horizontalPolicy() instead. -*/ - -/*! - \fn QSizePolicy::Policy QSizePolicy::verData() const - - Use verticalPolicy() instead. -*/ - -/*! - \fn void QSizePolicy::setHorData(Policy policy) - - Use setHorizontalPolicy() instead. -*/ - -/*! - \fn void QSizePolicy::setVerData(Policy policy) - - Use setVerticalPolicy() instead. -*/ - -/*! - \fn uint QSizePolicy::horStretch() const - - Use horizontalStretch() instead. -*/ - -/*! - \fn uint QSizePolicy::verStretch() const - - Use verticalStretch() instead. -*/ - -/*! - \fn void QSizePolicy::setHorStretch(uchar stretch) - - Use setHorizontalStretch() instead. -*/ - -/*! - \fn void QSizePolicy::setVerStretch(uchar stretch) - - Use setVerticalStretch() instead. -*/ -#endif diff --git a/doc/src/qstyles.qdoc b/doc/src/qstyles.qdoc deleted file mode 100644 index ae2d95b..0000000 --- a/doc/src/qstyles.qdoc +++ /dev/null @@ -1,261 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -/*! - \class QMacStyle - \brief The QMacStyle class provides a Mac OS X style using the Apple Appearance Manager. - - \ingroup appearance - - This class is implemented as a wrapper to the HITheme - APIs, allowing applications to be styled according to the current - theme in use on Mac OS X. This is done by having primitives - in QStyle implemented in terms of what Mac OS X would normally theme. - - \warning This style is only available on Mac OS X because it relies on the - HITheme APIs. - - There are additional issues that should be taken - into consideration to make an application compatible with the - \link http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html - Apple Human Interface Guidelines \endlink. Some of these issues are outlined - below. - - \list - - \i Layout - The restrictions on window layout are such that some - aspects of layout that are style-dependent cannot be achieved - using QLayout. Changes are being considered (and feedback would be - appreciated) to make layouts QStyle-able. Some of the restrictions - involve horizontal and vertical widget alignment and widget size - (covered below). - - \i Widget size - Mac OS X allows widgets to have specific fixed sizes. Qt - does not fully implement this behavior so as to maintain cross-platform - compatibility. As a result some widgets sizes may be inappropriate (and - subsequently not rendered correctly by the HITheme APIs).The - QWidget::sizeHint() will return the appropriate size for many - managed widgets (widgets enumerated in \l QStyle::ContentsType). - - \i Effects - QMacStyle uses HITheme for performing most of the drawing, but - also uses emulation in a few cases where HITheme does not provide the - required functionality (for example, tab bars on Panther, the toolbar - separator, etc). We tried to make the emulation as close to the original as - possible. Please report any issues you see in effects or non-standard - widgets. - - \endlist - - There are other issues that need to be considered in the feel of - your application (including the general color scheme to match the - Aqua colors). The Guidelines mentioned above will remain current - with new advances and design suggestions for Mac OS X. - - Note that the functions provided by QMacStyle are - reimplementations of QStyle functions; see QStyle for their - documentation. - - \img qmacstyle.png - \sa QWindowsXPStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle -*/ - - -/*! - \enum QMacStyle::WidgetSizePolicy - - \value SizeSmall - \value SizeLarge - \value SizeMini - \value SizeDefault - \omitvalue SizeNone -*/ - -/*! \fn QMacStyle::QMacStyle() - Constructs a QMacStyle object. -*/ - -/*! \fn QMacStyle::~QMacStyle() - Destructs a QMacStyle object. -*/ - -/*! \fn void QMacStyle::polish(QPalette &pal) - \reimp -*/ - -/*! \fn void QMacStyle::polish(QApplication *) - \reimp -*/ - -/*! \fn void QMacStyle::unpolish(QApplication *) - \reimp -*/ - -/*! \fn void QMacStyle::polish(QWidget* w) - \reimp -*/ - -/*! \fn void QMacStyle::unpolish(QWidget* w) - \reimp -*/ - -/*! \fn int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *widget) const - \reimp -*/ - -/*! \fn QPalette QMacStyle::standardPalette() const - \reimp -*/ - -/*! \fn int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *hret) const - \reimp -*/ - -/*! \fn QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const - \reimp -*/ - -/*! \fn QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const - \reimp -*/ - -/*! - \enum QMacStyle::FocusRectPolicy - - This type is used to signify a widget's focus rectangle policy. - - \value FocusEnabled show a focus rectangle when the widget has focus. - \value FocusDisabled never show a focus rectangle for the widget. - \value FocusDefault show a focus rectangle when the widget has - focus and the widget is a QSpinWidget, QDateTimeEdit, QLineEdit, - QListBox, QListView, editable QTextEdit, or one of their - subclasses. -*/ - -/*! \fn void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy) - \obsolete - Sets the focus rectangle policy of \a w. The \a policy can be one of - \l{QMacStyle::FocusRectPolicy}. - - This is now simply an interface to the Qt::WA_MacShowFocusRect attribute and the - FocusDefault value does nothing anymore. If you want to set a widget back - to its default value, you must save the old value of the attribute before - you change it. - - \sa focusRectPolicy() QWidget::setAttribute() -*/ - -/*! \fn QMacStyle::FocusRectPolicy QMacStyle::focusRectPolicy(const QWidget *w) - \obsolete - Returns the focus rectangle policy for the widget \a w. - - The focus rectangle policy can be one of \l{QMacStyle::FocusRectPolicy}. - - In 4.3 and up this function will simply test for the - Qt::WA_MacShowFocusRect attribute and will never return - QMacStyle::FocusDefault. - - \sa setFocusRectPolicy(), QWidget::testAttribute() -*/ - -/*! \fn void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy) - - \obsolete - - Call QWidget::setAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, - or Qt::WA_MacNormalSize instead. -*/ - -/*! \fn QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget) - \obsolete - - Call QWidget::testAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, - or Qt::WA_MacNormalSize instead. -*/ - -/*! \fn void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const - - \reimp -*/ - -/*! \fn void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w) const - - \reimp -*/ - -/*! \fn QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const - - \reimp -*/ - -/*! \fn void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const - \reimp -*/ - -/*! \fn QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget) const - \reimp -*/ - -/*! \fn QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const - \reimp -*/ - -/*! \fn QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &csz, const QWidget *widget) const - \reimp -*/ - -/*! \fn void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const - \reimp -*/ - -/*! \fn bool QMacStyle::event(QEvent *e) - \reimp -*/ - -/*! \fn QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt, const QWidget *widget) const - \internal -*/ - -/*! \fn int QMacStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const - - \internal -*/ - diff --git a/doc/src/qtdesigner.qdoc b/doc/src/qtdesigner.qdoc index d913b32..0959bd9 100644 --- a/doc/src/qtdesigner.qdoc +++ b/doc/src/qtdesigner.qdoc @@ -166,1376 +166,3 @@ \sa {Qt Designer Manual}, {QtUiTools Module} */ - -/*! - \class QDesignerMemberSheetExtension - - \brief The QDesignerMemberSheetExtension class allows you to - manipulate a widget's member functions which is displayed when - configuring connections using Qt Designer's mode for editing - signals and slots. - - \inmodule QtDesigner - - QDesignerMemberSheetExtension is a collection of functions that is - typically used to query a widget's member functions, and to - manipulate the member functions' appearance in \QD's signals and - slots editing mode. For example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 2 - - When implementing a custom widget plugin, a pointer to \QD's - current QDesignerFormEditorInterface object (\c formEditor in the - example above) is provided by the - QDesignerCustomWidgetInterface::initialize() function's parameter. - - The member sheet (and any other extension), can be retrieved by - querying \QD's extension manager using the qt_extension() - function. When you want to release the extension, you only need to - delete the pointer. - - All widgets have a default member sheet used in \QD's signals and - slots editing mode with the widget's member functions. But - QDesignerMemberSheetExtension also provides an interface for - creating custom member sheet extensions. - - \warning \QD uses the QDesignerMemberSheetExtension to facilitate - the signal and slot editing mode. Whenever a connection between - two widgets is requested, \QD will query for the widgets' member - sheet extensions. If a widget has an implemented member sheet - extension, this extension will override the default member sheet. - - To create a member sheet extension, your extension class must - inherit from both QObject and QDesignerMemberSheetExtension. Then, - since we are implementing an interface, we must ensure that it's - made known to the meta object system using the Q_INTERFACES() - macro: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 3 - - This enables \QD to use qobject_cast() to query for - supported interfaces using nothing but a QObject pointer. - - In \QD the extensions are not created until they are - required. For that reason, when implementing a member sheet - extension, you must also create a QExtensionFactory, i.e a class - that is able to make an instance of your extension, and register - it using \QD's \l {QExtensionManager}{extension manager}. - - When a widget's member sheet extension is required, \QD's \l - {QExtensionManager}{extension manager} will run through all its - registered factories calling QExtensionFactory::createExtension() - for each until the first one that is able to create a member sheet - extension for that widget, is found. This factory will then make - an instance of the extension. If no such factory is found, \QD - will use the default member sheet. - - There are four available types of extensions in \QD: - QDesignerContainerExtension, QDesignerMemberSheetExtension, - QDesignerPropertySheetExtension and - QDesignerTaskMenuExtension. \QD's behavior is the same whether the - requested extension is associated with a multi page container, a - member sheet, a property sheet or a task menu. - - The QExtensionFactory class provides a standard extension - factory, and can also be used as an interface for custom - extension factories. You can either create a new - QExtensionFactory and reimplement the - QExtensionFactory::createExtension() function. For example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 4 - - Or you can use an existing factory, expanding the - QExtensionFactory::createExtension() function to make the factory - able to create a member sheet extension as well. For example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 5 - - For a complete example using an extension class, see \l - {designer/taskmenuextension}{Task Menu Extension example}. The - example shows how to create a custom widget plugin for Qt - Designer, and how to to use the QDesignerTaskMenuExtension class - to add custom items to \QD's task menu. - - \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget - Extensions} -*/ - -/*! - \fn QDesignerMemberSheetExtension::~QDesignerMemberSheetExtension() - - Destroys the member sheet extension. -*/ - -/*! - \fn int QDesignerMemberSheetExtension::count() const - - Returns the extension's number of member functions. -*/ - -/*! - \fn int QDesignerMemberSheetExtension::indexOf(const QString &name) const - - Returns the index of the member function specified by the given \a - name. - - \sa memberName() -*/ - -/*! - \fn QString QDesignerMemberSheetExtension::memberName(int index) const - - Returns the name of the member function with the given \a index. - - \sa indexOf() -*/ - -/*! - \fn QString QDesignerMemberSheetExtension::memberGroup(int index) const - - Returns the name of the member group specified for the function - with the given \a index. - - \sa indexOf(), setMemberGroup() -*/ - -/*! - \fn void QDesignerMemberSheetExtension::setMemberGroup(int index, const QString &group) - - Sets the member group of the member function with the given \a - index, to \a group. - - \sa indexOf(), memberGroup() -*/ - -/*! - \fn bool QDesignerMemberSheetExtension::isVisible(int index) const - - Returns true if the member function with the given \a index is - visible in \QD's signal and slot editor, otherwise false. - - \sa indexOf(), setVisible() -*/ - -/*! - \fn void QDesignerMemberSheetExtension::setVisible(int index, bool visible) - - If \a visible is true, the member function with the given \a index - is visible in \QD's signals and slots editing mode; otherwise the - member function is hidden. - - \sa indexOf(), isVisible() -*/ - -/*! - \fn virtual bool QDesignerMemberSheetExtension::isSignal(int index) const - - Returns true if the member function with the given \a index is a - signal, otherwise false. - - \sa indexOf() -*/ - -/*! - \fn bool QDesignerMemberSheetExtension::isSlot(int index) const - - Returns true if the member function with the given \a index is a - slot, otherwise false. - - \sa indexOf() -*/ - -/*! - \fn bool QDesignerMemberSheetExtension::inheritedFromWidget(int index) const - - Returns true if the member function with the given \a index is - inherited from QWidget, otherwise false. - - \sa indexOf() -*/ - -/*! - \fn QString QDesignerMemberSheetExtension::declaredInClass(int index) const - - Returns the name of the class in which the member function with - the given \a index is declared. - - \sa indexOf() -*/ - -/*! - \fn QString QDesignerMemberSheetExtension::signature(int index) const - - Returns the signature of the member function with the given \a - index. - - \sa indexOf() -*/ - -/*! - \fn QList QDesignerMemberSheetExtension::parameterTypes(int index) const - - Returns the parameter types of the member function with the given - \a index, as a QByteArray list. - - \sa indexOf(), parameterNames() -*/ - -/*! - \fn QList QDesignerMemberSheetExtension::parameterNames(int index) const - - Returns the parameter names of the member function with the given - \a index, as a QByteArray list. - - \sa indexOf(), parameterTypes() -*/ - - -// Doc: Interface only - -/*! - \class QDesignerLayoutDecorationExtension - \brief The QDesignerLayoutDecorationExtension class provides an extension to a layout in \QD. - \inmodule QtDesigner - \internal -*/ - -/*! - \enum QDesignerLayoutDecorationExtension::InsertMode - - This enum describes the modes that are used to insert items into a layout. - - \value InsertWidgetMode Widgets are inserted into empty cells in a layout. - \value InsertRowMode Whole rows are inserted into a vertical or grid layout. - \value InsertColumnMode Whole columns are inserted into a horizontal or grid layout. -*/ - -/*! - \fn virtual QDesignerLayoutDecorationExtension::~QDesignerLayoutDecorationExtension() - - Destroys the extension. -*/ - -/*! - \fn virtual QList QDesignerLayoutDecorationExtension::widgets(QLayout *layout) const - - Returns the widgets that are managed by the given \a layout. - - \sa insertWidget(), removeWidget() -*/ - -/*! - \fn QRect QDesignerLayoutDecorationExtension::itemInfo(int index) const - - Returns the rectangle covered by the item at the given \a index in the layout. -*/ - -/*! - \fn int QDesignerLayoutDecorationExtension::indexOf(QWidget *widget) const - - Returns the index of the specified \a widget in the layout. -*/ - -/*! - \fn int QDesignerLayoutDecorationExtension::indexOf(QLayoutItem *item) const - - Returns the index of the specified layout \a item. -*/ - -/*! - \fn QDesignerLayoutDecorationExtension::InsertMode QDesignerLayoutDecorationExtension::currentInsertMode() const - - Returns the current insertion mode. -*/ - -/*! - \fn int QDesignerLayoutDecorationExtension::currentIndex() const - - Returns the current index in the layout. -*/ - -/*! - \fn QPair QDesignerLayoutDecorationExtension::currentCell() const - - Returns a pair containing the row and column of the current cell in the layout. -*/ - -/*! - \fn void QDesignerLayoutDecorationExtension::insertWidget(QWidget *widget, const QPair &cell) - - Inserts the given \a widget into the specified \a cell in the layout. - - \sa removeWidget() -*/ - -/*! - \fn void QDesignerLayoutDecorationExtension::removeWidget(QWidget *widget) - - Removes the specified \a widget from the layout. - - \sa insertWidget() -*/ - -/*! - \fn void QDesignerLayoutDecorationExtension::insertRow(int row) - - Inserts a new row into the form at the position specified by \a row. -*/ - -/*! - \fn void QDesignerLayoutDecorationExtension::insertColumn(int column) - - Inserts a new column into the form at the position specified by \a column. -*/ - -/*! - \fn void QDesignerLayoutDecorationExtension::simplify() - - Simplifies the layout by removing unnecessary empty rows and columns, and by changing the - number of rows or columns spanned by widgets. -*/ - -/*! - \fn int QDesignerLayoutDecorationExtension::findItemAt(const QPoint &position) const - - Returns the index of the item in the layout that covers the given \a position. -*/ - -/*! - \fn int QDesignerLayoutDecorationExtension::findItemAt(int row, int column) const - - Returns the item in the layout that occupies the specified \a row and \a column in the layout. - - Currently, this only applies to grid layouts. -*/ - -/*! - \fn void QDesignerLayoutDecorationExtension::adjustIndicator(const QPoint &position, int index) - - Adjusts the indicator for the item specified by \a index so that - it lies at the given \a position on the form. -*/ - - -// Doc: Interface only - -/*! - \class QDesignerContainerExtension - \brief The QDesignerContainerExtension class allows you to add pages to - a custom multi-page container in Qt Designer's workspace. - \inmodule QtDesigner - - QDesignerContainerExtension provide an interface for creating - custom container extensions. A container extension consists of a - collection of functions that \QD needs to manage a multi-page - container plugin, and a list of the container's pages. - - \image containerextension-example.png - - \warning This is \e not an extension for container plugins in - general, only custom \e multi-page containers. - - To create a container extension, your extension class must inherit - from both QObject and QDesignerContainerExtension. For example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 6 - - Since we are implementing an interface, we must ensure that it's - made known to the meta object system using the Q_INTERFACES() - macro. This enables \QD to use the qobject_cast() function to - query for supported interfaces using nothing but a QObject - pointer. - - You must reimplement several functions to enable \QD to manage a - custom multi-page container widget: \QD uses count() to keep track - of the number pages in your container, widget() to return the page - at a given index in the list of the container's pages, and - currentIndex() to return the list index of the selected page. \QD - uses the addWidget() function to add a given page to the - container, expecting it to be appended to the list of pages, while - it expects the insertWidget() function to add a given page to the - container by inserting it at a given index. - - In \QD the extensions are not created until they are - required. For that reason you must also create a - QExtensionFactory, i.e a class that is able to make an instance of - your extension, and register it using \QD's \l - {QExtensionManager}{extension manager}. - - When a container extension is required, \QD's \l - {QExtensionManager}{extension manager} will run through all its - registered factories calling QExtensionFactory::createExtension() - for each until the first one that is able to create a container - extension, is found. This factory will then create the extension - for the plugin. - - There are four available types of extensions in \QD: - QDesignerContainerExtension , QDesignerMemberSheetExtension, - QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. - \QD's behavior is the same whether the requested extension is - associated with a multi page container, a member sheet, a property - sheet or a task menu. - - The QExtensionFactory class provides a standard extension factory, - and can also be used as an interface for custom extension - factories. You can either create a new QExtensionFactory and - reimplement the QExtensionFactory::createExtension() function. For - example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 7 - - Or you can use an existing factory, expanding the - QExtensionFactory::createExtension() function to make the factory - able to create a container extension as well. For example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 8 - - For a complete example using the QDesignerContainerExtension - class, see the \l {designer/containerextension}{Container - Extension example}. The example shows how to create a custom - multi-page plugin for \QD. - - \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget - Extensions} -*/ - -/*! - \fn QDesignerContainerExtension::~QDesignerContainerExtension() - - Destroys the extension. -*/ - -/*! - \fn int QDesignerContainerExtension::count() const - - Returns the number of pages in the container. -*/ - -/*! - \fn QWidget *QDesignerContainerExtension::widget(int index) const - - Returns the page at the given \a index in the extension's list of - pages. - - \sa addWidget(), insertWidget() -*/ - -/*! - \fn int QDesignerContainerExtension::currentIndex() const - - Returns the index of the currently selected page in the - container. - - \sa setCurrentIndex() -*/ - -/*! - \fn void QDesignerContainerExtension::setCurrentIndex(int index) - - Sets the currently selected page in the container to be the - page at the given \a index in the extension's list of pages. - - \sa currentIndex() -*/ - -/*! - \fn void QDesignerContainerExtension::addWidget(QWidget *page) - - Adds the given \a page to the container by appending it to the - extension's list of pages. - - \sa insertWidget(), remove(), widget() -*/ - -/*! - \fn void QDesignerContainerExtension::insertWidget(int index, QWidget *page) - - Adds the given \a page to the container by inserting it at the - given \a index in the extension's list of pages. - - \sa addWidget(), remove(), widget() -*/ - -/*! - \fn void QDesignerContainerExtension::remove(int index) - - Removes the page at the given \a index from the extension's list - of pages. - - \sa addWidget(), insertWidget() -*/ - - -// Doc: Interface only - -/*! - \class QDesignerTaskMenuExtension - \brief The QDesignerTaskMenuExtension class allows you to add custom - menu entries to Qt Designer's task menu. - \inmodule QtDesigner - - QDesignerTaskMenuExtension provides an interface for creating - custom task menu extensions. It is typically used to create task - menu entries that are specific to a plugin in \QD. - - \QD uses the QDesignerTaskMenuExtension to feed its task - menu. Whenever a task menu is requested, \QD will query - for the selected widget's task menu extension. - - \image taskmenuextension-example-faded.png - - A task menu extension is a collection of QActions. The actions - appear as entries in the task menu when the plugin with the - specified extension is selected. The image above shows the custom - \gui {Edit State...} action which appears in addition to \QD's - default task menu entries: \gui Cut, \gui Copy, \gui Paste etc. - - To create a custom task menu extension, your extension class must - inherit from both QObject and QDesignerTaskMenuExtension. For - example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 9 - - Since we are implementing an interface, we must ensure that it - is made known to the meta-object system using the Q_INTERFACES() - macro. This enables \QD to use the qobject_cast() function to - query for supported interfaces using nothing but a QObject - pointer. - - You must reimplement the taskActions() function to return a list - of actions that will be included in \QD task menu. Optionally, you - can reimplement the preferredEditAction() function to set the - action that is invoked when selecting your plugin and pressing - \key F2. The preferred edit action must be one of the actions - returned by taskActions() and, if it's not defined, pressing the - \key F2 key will simply be ignored. - - In \QD, extensions are not created until they are required. A - task menu extension, for example, is created when you click the - right mouse button over a widget in \QD's workspace. For that - reason you must also construct an extension factory, using either - QExtensionFactory or a subclass, and register it using \QD's - \l {QExtensionManager}{extension manager}. - - When a task menu extension is required, \QD's \l - {QExtensionManager}{extension manager} will run through all its - registered factories calling QExtensionFactory::createExtension() - for each until it finds one that is able to create a task menu - extension for the selected widget. This factory will then make an - instance of the extension. - - There are four available types of extensions in \QD: - QDesignerContainerExtension, QDesignerMemberSheetExtension, - QDesignerPropertySheetExtension, and QDesignerTaskMenuExtension. - \QD's behavior is the same whether the requested extension is - associated with a container, a member sheet, a property sheet or a - task menu. - - The QExtensionFactory class provides a standard extension factory, - and can also be used as an interface for custom extension - factories. You can either create a new QExtensionFactory and - reimplement the QExtensionFactory::createExtension() function. For - example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 10 - - Or you can use an existing factory, expanding the - QExtensionFactory::createExtension() function to make the factory - able to create a task menu extension as well. For example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 11 - - For a complete example using the QDesignerTaskMenuExtension class, - see the \l {designer/taskmenuextension}{Task Menu Extension - example}. The example shows how to create a custom widget plugin - for \QD, and how to to use the QDesignerTaskMenuExtension - class to add custom items to \QD's task menu. - - \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget - Extensions} -*/ - -/*! - \fn QDesignerTaskMenuExtension::~QDesignerTaskMenuExtension() - - Destroys the task menu extension. -*/ - -/*! - \fn QAction *QDesignerTaskMenuExtension::preferredEditAction() const - - Returns the action that is invoked when selecting a plugin with - the specified extension and pressing \key F2. - - The action must be one of the actions returned by taskActions(). -*/ - -/*! - \fn QList QDesignerTaskMenuExtension::taskActions() const - - Returns the task menu extension as a list of actions which will be - included in \QD's task menu when a plugin with the specified - extension is selected. - - The function must be reimplemented to add actions to the list. -*/ - - -// Doc: Interface only - -/*! - \class QDesignerCustomWidgetCollectionInterface - - \brief The QDesignerCustomWidgetCollectionInterface class allows - you to include several custom widgets in one single library. - - \inmodule QtDesigner - - When implementing a custom widget plugin, you build it as a - separate library. If you want to include several custom widget - plugins in the same library, you must in addition subclass - QDesignerCustomWidgetCollectionInterface. - - QDesignerCustomWidgetCollectionInterface contains one single - function returning a list of the collection's - QDesignerCustomWidgetInterface objects. For example, if you have - several custom widgets \c CustomWidgetOne, \c CustomWidgetTwo and - \c CustomWidgetThree, the class definition may look like this: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 12 - - In the class constructor you add the interfaces to your custom - widgets to the list which you return in the customWidgets() - function: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 13 - - Note that instead of exporting each custom widget plugin using the - Q_EXPORT_PLUGIN2() macro, you export the entire collection. The - Q_EXPORT_PLUGIN2() macro ensures that \QD can access and construct - the custom widgets. Without this macro, there is no way for \QD to - use them. - - \sa QDesignerCustomWidgetInterface, {Creating Custom Widgets for - Qt Designer} -*/ - -/*! - \fn QDesignerCustomWidgetCollectionInterface::~QDesignerCustomWidgetCollectionInterface() { - - Destroys the custom widget collection interface. -*/ - -/*! - \fn QList QDesignerCustomWidgetCollectionInterface::customWidgets() const - - Returns a list of interfaces to the collection's custom widgets. -*/ - - -// Doc: Interface only - -/*! - \class QDesignerCustomWidgetInterface - - \brief The QDesignerCustomWidgetInterface class enables Qt Designer - to access and construct custom widgets. - - \inmodule QtDesigner - - QDesignerCustomWidgetInterface provides a custom widget with an - interface. The class contains a set of functions that must be subclassed - to return basic information about the widget, such as its class name and - the name of its header file. Other functions must be implemented to - initialize the plugin when it is loaded, and to construct instances of - the custom widget for \QD to use. - - When implementing a custom widget you must subclass - QDesignerCustomWidgetInterface to expose your widget to \QD. For - example, this is the declaration for the plugin used in the - \l{Custom Widget Plugin Example}{Custom Widget Plugin example} that - enables an analog clock custom widget to be used by \QD: - - \snippet examples/designer/customwidgetplugin/customwidgetplugin.h 0 - - Note that the only part of the class definition that is specific - to this particular custom widget is the class name. In addition, - since we are implementing an interface, we must ensure that it's - made known to the meta object system using the Q_INTERFACES() - macro. This enables \QD to use the qobject_cast() function to - query for supported interfaces using nothing but a QObject - pointer. - - After \QD loads a custom widget plugin, it calls the interface's - initialize() function to enable it to set up any resources that it - may need. This function is called with a QDesignerFormEditorInterface - parameter that provides the plugin with a gateway to all of \QD's API. - - \QD constructs instances of the custom widget by calling the plugin's - createWidget() function with a suitable parent widget. Plugins must - construct and return an instance of a custom widget with the specified - parent widget. - - In the implementation of the class you must remember to export - your custom widget plugin to \QD using the Q_EXPORT_PLUGIN2() - macro. For example, if a library called \c libcustomwidgetplugin.so - (on Unix) or \c libcustomwidget.dll (on Windows) contains a widget - class called \c MyCustomWidget, we can export it by adding the - following line to the file containing the plugin implementation: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 14 - - This macro ensures that \QD can access and construct the custom widget. - Without this macro, there is no way for \QD to use it. - - When implementing a custom widget plugin, you build it as a - separate library. If you want to include several custom widget - plugins in the same library, you must in addition subclass - QDesignerCustomWidgetCollectionInterface. - - \warning If your custom widget plugin contains QVariant - properties, be aware that only the following \l - {QVariant::Type}{types} are supported: - - \list - \o QVariant::ByteArray - \o QVariant::Bool - \o QVariant::Color - \o QVariant::Cursor - \o QVariant::Date - \o QVariant::DateTime - \o QVariant::Double - \o QVariant::Int - \o QVariant::Point - \o QVariant::Rect - \o QVariant::Size - \o QVariant::SizePolicy - \o QVariant::String - \o QVariant::Time - \o QVariant::UInt - \endlist - - For a complete example using the QDesignerCustomWidgetInterface - class, see the \l {designer/customwidgetplugin}{Custom Widget - Example}. The example shows how to create a custom widget plugin - for \QD. - - \sa QDesignerCustomWidgetCollectionInterface {Creating Custom - Widgets for Qt Designer} -*/ - -/*! - \fn QDesignerCustomWidgetInterface::~QDesignerCustomWidgetInterface() - - Destroys the custom widget interface. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::name() const - - Returns the class name of the custom widget supplied by the interface. - - The name returned \e must be identical to the class name used for the - custom widget. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::group() const - - Returns the name of the group to which the custom widget belongs. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::toolTip() const - - Returns a short description of the widget that can be used by \QD - in a tool tip. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::whatsThis() const - - Returns a description of the widget that can be used by \QD in - "What's This?" help for the widget. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::includeFile() const - - Returns the path to the include file that \l uic uses when - creating code for the custom widget. -*/ - -/*! - \fn QIcon QDesignerCustomWidgetInterface::icon() const - - Returns the icon used to represent the custom widget in \QD's - widget box. -*/ - -/*! - \fn bool QDesignerCustomWidgetInterface::isContainer() const - - Returns true if the custom widget is intended to be used as a - container; otherwise returns false. - - Most custom widgets are not used to hold other widgets, so their - implementations of this function will return false, but custom - containers will return true to ensure that they behave correctly - in \QD. -*/ - -/*! - \fn QWidget *QDesignerCustomWidgetInterface::createWidget(QWidget *parent) - - Returns a new instance of the custom widget, with the given \a - parent. -*/ - -/*! - \fn bool QDesignerCustomWidgetInterface::isInitialized() const - - Returns true if the widget has been initialized; otherwise returns - false. - - \sa initialize() -*/ - -/*! - \fn void QDesignerCustomWidgetInterface::initialize(QDesignerFormEditorInterface *formEditor) - - Initializes the widget for use with the specified \a formEditor - interface. - - \sa isInitialized() -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::domXml() const - - Returns the XML that is used to describe the custom widget's - properties to \QD. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::codeTemplate() const - - This function is reserved for future use by \QD. - - \omit - Returns the code template that \QD includes in forms that contain - the custom widget when they are saved. - \endomit -*/ - -/*! - \macro QDESIGNER_WIDGET_EXPORT - \relates QDesignerCustomWidgetInterface - \since 4.1 - - This macro is used when defining custom widgets to ensure that they are - correctly exported from plugins for use with \QD. - - On some platforms, the symbols required by \QD to create new widgets - are removed from plugins by the build system, making them unusable. - Using this macro ensures that the symbols are retained on those platforms, - and has no side effects on other platforms. - - For example, the \l{designer/worldtimeclockplugin}{World Time Clock Plugin} - example exports a custom widget class with the following declaration: - - \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 0 - \dots - \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 2 - - \sa {Creating Custom Widgets for Qt Designer} -*/ - - -// Doc: Abstract class - -/*! - \class QDesignerDnDItemInterface - \brief The QDesignerDnDItemInterface class provides an interface that is used to manage items - during a drag and drop operation. - \inmodule QtDesigner - \internal -*/ - -/*! - \enum QDesignerDnDItemInterface::DropType - - This enum describes the result of a drag and drop operation. - - \value MoveDrop The item was moved. - \value CopyDrop The item was copied. -*/ - -/*! - \fn QDesignerDnDItemInterface::QDesignerDnDItemInterface() - - Constructs a new interface to a drag and drop item. -*/ - -/*! - \fn QDesignerDnDItemInterface::~QDesignerDnDItemInterface() - - Destroys the interface to the item. -*/ - -/*! - \fn DomUI *QDesignerDnDItemInterface::domUi() const - - Returns a user interface object for the item. -*/ - -/*! - \fn QWidget *QDesignerDnDItemInterface::widget() const - - Returns the widget being copied or moved in the drag and drop operation. - - \sa source() -*/ - -/*! - \fn QWidget *QDesignerDnDItemInterface::decoration() const - - Returns the widget used to represent the item. -*/ - -/*! - \fn QPoint QDesignerDnDItemInterface::hotSpot() const - - Returns the cursor's hotspot. - - \sa QDrag::hotSpot() -*/ - -/*! - \fn DropType QDesignerDnDItemInterface::type() const - - Returns the type of drag and drop operation in progress. -*/ - -/*! - \fn QWidget *QDesignerDnDItemInterface::source() const - - Returns the widget that is the source of the drag and drop operation; i.e. the original - container of the widget being dragged. - - \sa widget() -*/ - - -// Doc: Abstract class - -/*! - \class QDesignerIconCacheInterface - \brief The QDesignerIconCacheInterface class provides an interface to \QD's icon cache. - \inmodule QtDesigner - \internal -*/ - -/*! - \fn QDesignerIconCacheInterface::QDesignerIconCacheInterface(QObject *parent) - - Constructs a new interface with the given \a parent. -*/ - -/*! - \fn QIcon QDesignerIconCacheInterface::nameToIcon(const QString &filePath, const QString &qrcPath) - - Returns the icon associated with the name specified by \a filePath in the resource - file specified by \a qrcPath. - - If \a qrcPath refers to a valid resource file, the name used for the file path is a path - within those resources; otherwise the file path refers to a local file. - - \sa {The Qt Resource System}, nameToPixmap() -*/ - -/*! - \fn QPixmap QDesignerIconCacheInterface::nameToPixmap(const QString &filePath, const QString &qrcPath) - - Returns the pixmap associated with the name specified by \a filePath in the resource - file specified by \a qrcPath. - - If \a qrcPath refers to a valid resource file, the name used for the file path is a path - within those resources; otherwise the file path refers to a local file. - - \sa {The Qt Resource System}, nameToIcon() -*/ - -/*! - \fn QString QDesignerIconCacheInterface::iconToFilePath(const QIcon &icon) const - - Returns the file path associated with the given \a icon. The file path is a path within - an application resources. -*/ - -/*! - \fn QString QDesignerIconCacheInterface::iconToQrcPath(const QIcon &icon) const - - Returns the path to the resource file that refers to the specified \a icon. The resource - path refers to a local file. -*/ - -/*! - \fn QString QDesignerIconCacheInterface::pixmapToFilePath(const QPixmap &pixmap) const - - Returns the file path associated with the given \a pixmap. The file path is a path within - an application resources. -*/ - -/*! - \fn QString QDesignerIconCacheInterface::pixmapToQrcPath(const QPixmap &pixmap) const - - Returns the path to the resource file that refers to the specified \a pixmap. The resource - path refers to a local file. -*/ - -/*! - \fn QList QDesignerIconCacheInterface::pixmapList() const - - Returns a list of pixmaps for the icons provided by the icon cache. -*/ - -/*! - \fn QList QDesignerIconCacheInterface::iconList() const - - Returns a list of icons provided by the icon cache. -*/ - -/*! - \fn QString QDesignerIconCacheInterface::resolveQrcPath(const QString &filePath, const QString &qrcPath, const QString &workingDirectory) const - - Returns a path to a resource specified by the \a filePath within - the resource file located at \a qrcPath. If \a workingDirectory is - a valid path to a directory, the path returned will be relative to - that directory; otherwise an absolute path is returned. - - \omit - ### Needs checking - \endomit -*/ - - -// Doc: Interface only - -/*! - \class QDesignerPropertySheetExtension - - \brief The QDesignerPropertySheetExtension class allows you to - manipulate a widget's properties which is displayed in Qt - Designer's property editor. - - \sa QDesignerDynamicPropertySheetExtension - - \inmodule QtDesigner - - QDesignerPropertySheetExtension provides a collection of functions that - are typically used to query a widget's properties, and to - manipulate the properties' appearance in the property editor. For - example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 15 - - Note that if you change the value of a property using the - QDesignerPropertySheetExtension::setProperty() function, the undo - stack is not updated. To ensure that a property's value can be - reverted using the undo stack, you must use the - QDesignerFormWindowCursorInterface::setProperty() function, or its - buddy \l - {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()}, - instead. - - When implementing a custom widget plugin, a pointer to \QD's - current QDesignerFormEditorInterface object (\c formEditor in the - example above) is provided by the - QDesignerCustomWidgetInterface::initialize() function's parameter. - - The property sheet, or any other extension, can be retrieved by - querying \QD's extension manager using the qt_extension() - function. When you want to release the extension, you only need to - delete the pointer. - - All widgets have a default property sheet which populates \QD's - property editor with the widget's properties (i.e the ones defined - with the Q_PROPERTY() macro). But QDesignerPropertySheetExtension - also provides an interface for creating custom property sheet - extensions. - - \warning \QD uses the QDesignerPropertySheetExtension to feed its - property editor. Whenever a widget is selected in its workspace, - \QD will query for the widget's property sheet extension. If the - selected widget has an implemented property sheet extension, this - extension will override the default property sheet. - - To create a property sheet extension, your extension class must - inherit from both QObject and - QDesignerPropertySheetExtension. Then, since we are implementing - an interface, we must ensure that it's made known to the meta - object system using the Q_INTERFACES() macro: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 16 - - This enables \QD to use qobject_cast() to query for supported - interfaces using nothing but a QObject pointer. - - In \QD the extensions are not created until they are - required. For that reason, when implementing a property sheet - extension, you must also create a QExtensionFactory, i.e a class - that is able to make an instance of your extension, and register - it using \QD's \l {QExtensionManager}{extension manager}. - - When a property sheet extension is required, \QD's \l - {QExtensionManager}{extension manager} will run through all its - registered factories calling QExtensionFactory::createExtension() - for each until the first one that is able to create a property - sheet extension for the selected widget, is found. This factory - will then make an instance of the extension. If no such factory - can be found, \QD will use the default property sheet. - - There are four available types of extensions in \QD: - QDesignerContainerExtension, QDesignerMemberSheetExtension, - QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. Qt - Designer's behavior is the same whether the requested extension is - associated with a multi page container, a member sheet, a property - sheet or a task menu. - - The QExtensionFactory class provides a standard extension factory, - and can also be used as an interface for custom extension - factories. You can either create a new QExtensionFactory and - reimplement the QExtensionFactory::createExtension() function. For - example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 17 - - Or you can use an existing factory, expanding the - QExtensionFactory::createExtension() function to make the factory - able to create a property sheet extension extension as well. For - example: - - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 18 - - For a complete example using an extension class, see the \l - {designer/taskmenuextension}{Task Menu Extension example}. The - example shows how to create a custom widget plugin for Qt - Designer, and how to to use the QDesignerTaskMenuExtension class - to add custom items to \QD's task menu. - - \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget - Extensions} -*/ - -/*! - \fn QDesignerPropertySheetExtension::~QDesignerPropertySheetExtension() - - Destroys the property sheet extension. -*/ - -/*! - \fn int QDesignerPropertySheetExtension::count() const - - Returns the selected widget's number of properties. -*/ - -/*! - \fn int QDesignerPropertySheetExtension::indexOf(const QString &name) const - - Returns the index for a given property \a name. - - \sa propertyName() -*/ - -/*! - \fn QString QDesignerPropertySheetExtension::propertyName(int index) const - - Returns the name of the property at the given \a index. - - \sa indexOf() -*/ - -/*! - \fn QString QDesignerPropertySheetExtension::propertyGroup(int index) const - - Returns the property group for the property at the given \a index. - - \QD's property editor supports property groups, i.e. sections of - related properties. A property can be related to a group using the - setPropertyGroup() function. The default group of any property is - the name of the class that defines it. For example, the - QObject::objectName property appears within the QObject property - group. - - \sa indexOf(), setPropertyGroup() -*/ - -/*! - \fn void QDesignerPropertySheetExtension::setPropertyGroup(int index, const QString &group) - - Sets the property group for the property at the given \a index to - \a group. - - Relating a property to a group makes it appear within that group's - section in the property editor. The default property group of any - property is the name of the class that defines it. For example, - the QObject::objectName property appears within the QObject - property group. - - \sa indexOf(), property(), propertyGroup() -*/ - -/*! - \fn bool QDesignerPropertySheetExtension::hasReset(int index) const - - Returns true if the property at the given \a index has a reset - button in \QD's property editor, otherwise false. - - \sa indexOf(), reset() -*/ - -/*! - \fn bool QDesignerPropertySheetExtension::reset(int index) - - Resets the value of the property at the given \a index, to the - default value. Returns true if a default value could be found, otherwise false. - - \sa indexOf(), hasReset(), isChanged() -*/ - -/*! - \fn bool QDesignerPropertySheetExtension::isVisible(int index) const - - Returns true if the property at the given \a index is visible in - \QD's property editor, otherwise false. - - \sa indexOf(), setVisible() -*/ - -/*! - \fn void QDesignerPropertySheetExtension::setVisible(int index, bool visible) - - If \a visible is true, the property at the given \a index is - visible in \QD's property editor; otherwise the property is - hidden. - - \sa indexOf(), isVisible() -*/ - -/*! - \fn bool QDesignerPropertySheetExtension::isAttribute(int index) const - - Returns true if the property at the given \a index is an attribute, - which will be \e excluded from the UI file, otherwise false. - - \sa indexOf(), setAttribute() -*/ - -/*! - \fn void QDesignerPropertySheetExtension::setAttribute(int index, bool attribute) - - If \a attribute is true, the property at the given \a index is - made an attribute which will be \e excluded from the UI file; - otherwise it will be included. - - \sa indexOf(), isAttribute() -*/ - -/*! - \fn QVariant QDesignerPropertySheetExtension::property(int index) const - - Returns the value of the property at the given \a index. - - \sa indexOf(), setProperty(), propertyGroup() -*/ - -/*! - \fn void QDesignerPropertySheetExtension::setProperty(int index, const QVariant &value) - - Sets the \a value of the property at the given \a index. - - \warning If you change the value of a property using this - function, the undo stack is not updated. To ensure that a - property's value can be reverted using the undo stack, you must - use the QDesignerFormWindowCursorInterface::setProperty() - function, or its buddy \l - {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()}, - instead. - - \sa indexOf(), property(), propertyGroup() -*/ - -/*! - \fn bool QDesignerPropertySheetExtension::isChanged(int index) const - - Returns true if the value of the property at the given \a index - differs from the property's default value, otherwise false. - - \sa indexOf(), setChanged(), reset() -*/ - -/*! - \fn void QDesignerPropertySheetExtension::setChanged(int index, bool changed) - - Sets whether the property at the given \a index is different from - its default value, or not, depending on the \a changed parameter. - - \sa indexOf(), isChanged() -*/ - -// Doc: Interface only - -/*! - \class QDesignerDynamicPropertySheetExtension - - \brief The QDesignerDynamicPropertySheetExtension class allows you to - manipulate a widget's dynamic properties in Qt Designer's property editor. - - \sa QDesignerPropertySheetExtension, {QObject#Dynamic Properties}{Dynamic Properties} - - \inmodule QtDesigner - \since 4.3 -*/ - -/*! - \fn QDesignerDynamicPropertySheetExtension::~QDesignerDynamicPropertySheetExtension() - - Destroys the dynamic property sheet extension. -*/ - -/*! - \fn bool QDesignerDynamicPropertySheetExtension::dynamicPropertiesAllowed() const - - Returns true if the widget supports dynamic properties; otherwise returns false. -*/ - -/*! - \fn int QDesignerDynamicPropertySheetExtension::addDynamicProperty(const QString &propertyName, const QVariant &value) - - Adds a dynamic property named \a propertyName and sets its value to \a value. - Returns the index of the property if it was added successfully; otherwise returns -1 to - indicate failure. -*/ - -/*! - \fn bool QDesignerDynamicPropertySheetExtension::removeDynamicProperty(int index) - - Removes the dynamic property at the given \a index. - Returns true if the operation succeeds; otherwise returns false. -*/ - -/*! - \fn bool QDesignerDynamicPropertySheetExtension::isDynamicProperty(int index) const - - Returns true if the property at the given \a index is a dynamic property; otherwise - returns false. -*/ - -/*! - \fn bool QDesignerDynamicPropertySheetExtension::canAddDynamicProperty(const QString &propertyName) const - - Returns true if \a propertyName is a valid, unique name for a dynamic - property; otherwise returns false. - -*/ diff --git a/doc/src/qtendian.qdoc b/doc/src/qtendian.qdoc deleted file mode 100644 index dcffb5d..0000000 --- a/doc/src/qtendian.qdoc +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \headerfile - \title Endian Conversion Functions - \ingroup architecture - \brief The header provides functions to convert between - little and big endian representations of numbers. -*/ - -/*! - \fn T qFromBigEndian(const uchar *src) - \since 4.3 - \relates - - Reads a big-endian number from memory location \a src and returns the number in the - host byte order representation. - On CPU architectures where the host byte order is little-endian (such as x86) this - will swap the byte order; otherwise it will just read from \a src. - - \note Template type \c{T} can either be a qint16, qint32 or qint64. Other types of - integers, e.g., qlong, are not applicable. - - There are no data alignment constraints for \a src. - - \sa qFromLittleEndian() - \sa qToBigEndian() - \sa qToLittleEndian() -*/ -/*! - \fn T qFromBigEndian(T src) - \since 4.3 - \relates - \overload - - Converts \a src from big-endian byte order and returns the number in host byte order - representation of that number. - On CPU architectures where the host byte order is little-endian (such as x86) this - will return \a src with the byte order swapped; otherwise it will return \a src - unmodified. -*/ -/*! - \fn T qFromLittleEndian(const uchar *src) - \since 4.3 - \relates - - Reads a little-endian number from memory location \a src and returns the number in - the host byte order representation. - On CPU architectures where the host byte order is big-endian (such as PowerPC) this - will swap the byte order; otherwise it will just read from \a src. - - \note Template type \c{T} can either be a qint16, qint32 or qint64. Other types of - integers, e.g., qlong, are not applicable. - - There are no data alignment constraints for \a src. - - \sa qFromBigEndian() - \sa qToBigEndian() - \sa qToLittleEndian() -*/ -/*! - \fn T qFromLittleEndian(T src) - \since 4.3 - \relates - \overload - - Converts \a src from little-endian byte order and returns the number in host byte - order representation of that number. - On CPU architectures where the host byte order is big-endian (such as PowerPC) this - will return \a src with the byte order swapped; otherwise it will return \a src - unmodified. -*/ -/*! - \fn void qToBigEndian(T src, uchar *dest) - \since 4.3 - \relates - - Writes the number \a src with template type \c{T} to the memory location at \a dest - in big-endian byte order. - - Note that template type \c{T} can only be an integer data type (signed or unsigned). - - There are no data alignment constraints for \a dest. - - \sa qFromBigEndian() - \sa qFromLittleEndian() - \sa qToLittleEndian() -*/ -/*! - \fn T qToBigEndian(T src) - \since 4.3 - \relates - \overload - - Converts \a src from host byte order and returns the number in big-endian byte order - representation of that number. - On CPU architectures where the host byte order is little-endian (such as x86) this - will return \a src with the byte order swapped; otherwise it will return \a src - unmodified. -*/ -/*! - \fn void qToLittleEndian(T src, uchar *dest) - \since 4.3 - \relates - - Writes the number \a src with template type \c{T} to the memory location at \a dest - in little-endian byte order. - - Note that template type \c{T} can only be an integer data type (signed or unsigned). - - There are no data alignment constraints for \a dest. - - \sa qFromBigEndian() - \sa qFromLittleEndian() - \sa qToBigEndian() -*/ -/*! - \fn T qToLittleEndian(T src) - \since 4.3 - \relates - \overload - - Converts \a src from host byte order and returns the number in little-endian byte - order representation of that number. - On CPU architectures where the host byte order is big-endian (such as PowerPC) this - will return \a src with the byte order swapped; otherwise it will return \a src - unmodified. -*/ - diff --git a/doc/src/qtestevent.qdoc b/doc/src/qtestevent.qdoc deleted file mode 100644 index 2e111b3..0000000 --- a/doc/src/qtestevent.qdoc +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QTestEventList - \inmodule QtTest - - \brief The QTestEventList class provides a list of GUI events. - - QTestEventList inherits from QList, and provides - convenience functions for populating the list. - - A QTestEventList can be populated with GUI events that can be - stored as test data for later usage, or be replayed on any - QWidget. - - Example: - \snippet doc/src/snippets/code/doc_src_qtestevent.qdoc 0 - - The example above simulates the user entering the character \c a - followed by a backspace, waiting for 200 milliseconds and - repeating it. -*/ - -/*! \fn QTestEventList::QTestEventList() - - Constructs an empty QTestEventList. -*/ - -/*! \fn QTestEventList::QTestEventList(const QTestEventList &other) - - Constructs a new QTestEventList as a copy of \a other. -*/ - -/*! \fn QTestEventList::~QTestEventList() - - Empties the list and destroys all stored events. -*/ - -/*! \fn void QTestEventList::clear() - - Removes all events from the list. -*/ - -/*! \fn void QTestEventList::addKeyClick(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) - - Adds a new key click to the list. The event will simulate the key \a qtKey with the modifier \a modifiers and then wait for \a msecs milliseconds. - - \sa QTest::keyClick() -*/ - -/*! \fn void QTestEventList::addKeyPress(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) - - Adds a new key press to the list. The event will press the key \a qtKey with the modifier \a modifiers and then wait for \a msecs milliseconds. - - \sa QTest::keyPress() -*/ - -/*! \fn void QTestEventList::addKeyRelease(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) - - Adds a new key release to the list. The event will release the key \a qtKey with the modifier \a modifiers and then wait for \a msecs milliseconds. - - \sa QTest::keyRelease() - -*/ - -/*! \fn void QTestEventList::addKeyEvent(QTest::KeyAction action, Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) - \internal -*/ - -/*! \fn void QTestEventList::addKeyClick(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) - - \overload - - Adds a new key click to the list. The event will simulate the key \a ascii with the modifier \a modifiers and then wait for \a msecs milliseconds. - - \sa QTest::keyClick() - -*/ - -/*! \fn void QTestEventList::addKeyPress(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) - - \overload - - Adds a new key press to the list. The event will press the key \a ascii with the modifier \a modifiers and then wait for \a msecs milliseconds. - - \sa QTest::keyPress() -*/ - -/*! \fn void QTestEventList::addKeyRelease(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) - - \overload - - Adds a new key release to the list. The event will release the key \a ascii with the modifier \a modifiers and then wait for \a msecs milliseconds. - - \sa QTest::keyRelease() -*/ - -/*! \fn void QTestEventList::addKeyClicks(const QString &keys, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) - - Adds new keyboard entries to the list. The event will press the \a keys with the \a modifiers and wait \a msecs milliseconds between each key. - - \sa QTest::keyClicks() -*/ - -/*! \fn void QTestEventList::addKeyEvent(QTest::KeyAction action, char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) - \internal -*/ - -/*! \fn void QTestEventList::addDelay(int msecs) - - Adds a \a msecs milliseconds delay. - - \sa QTest::qWait() -*/ - -/*! \fn void QTestEventList::simulate(QWidget *w) - - Simulates the events from the list one by one on the widget \a w. - For an example, please read the \l QTestEventList class documentation. -*/ - -/*! \fn void QTestEventList::addMousePress(Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay=-1) - - Add a mouse press to the list. The event will press the \a button with optional \a modifiers at the position \a pos with an optional \a delay. The default position is the center of the widget. - - \sa QTest::mousePress() -*/ -/*! \fn void QTestEventList::addMouseRelease(Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay=-1) - - Add a mouse release to the list. The event will release the \a button with optional \a modifiers at the position \a pos with an optional \a delay. The default position is the center of the widget. - - \sa QTest::mouseRelease() -*/ -/*! \fn void QTestEventList::addMouseClick(Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay=-1) - - Add a mouse click to the list. The event will click the \a button with optional \a modifiers at the position \a pos with an optional \a delay. The default position is the center of the widget. - - \sa QTest::mouseClick() -*/ -/*! \fn void QTestEventList::addMouseDClick(Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay=-1) - - Add a double mouse click to the list. The event will double click the \a button with optional \a modifiers at the position \a pos with an optional \a delay. The default position is the center of the widget. - - \sa QTest::mousePress() -*/ -/*! \fn void QTestEventList::addMouseMove(QPoint pos = QPoint(), int delay=-1) - - Adds a mouse move to the list. The event will move the mouse to the position \a pos. If a \a delay (in milliseconds) is set, the test will wait after moving the mouse. The default position is the center of the widget. - - \sa QTest::mousePress() -*/ - diff --git a/doc/src/qvarlengtharray.qdoc b/doc/src/qvarlengtharray.qdoc deleted file mode 100644 index ac6bb6e..0000000 --- a/doc/src/qvarlengtharray.qdoc +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QVarLengthArray - \brief The QVarLengthArray class provides a low-level variable-length array. - - \ingroup tools - \reentrant - - The C++ language doesn't support variable-length arrays on the stack. - For example, the following code won't compile: - - \snippet doc/src/snippets/code/doc_src_qvarlengtharray.qdoc 0 - - The alternative is to allocate the array on the heap (with - \c{new}): - - \snippet doc/src/snippets/code/doc_src_qvarlengtharray.qdoc 1 - - However, if myfunc() is called very frequently from the - application's inner loop, heap allocation can be a major source - of slowdown. - - QVarLengthArray is an attempt to work around this gap in the C++ - language. It allocates a certain number of elements on the stack, - and if you resize the array to a larger size, it automatically - uses the heap instead. Stack allocation has the advantage that - it is much faster than heap allocation. - - Example: - \snippet doc/src/snippets/code/doc_src_qvarlengtharray.qdoc 2 - - In the example above, QVarLengthArray will preallocate 1024 - elements on the stack and use them unless \c{n + 1} is greater - than 1024. If you omit the second template argument, - QVarLengthArray's default of 256 is used. - - QVarLengthArray's value type must be an \l{assignable data type}. - This covers most data types that are commonly used, but the - compiler won't let you, for example, store a QWidget as a value; - instead, store a QWidget *. - - QVarLengthArray, like QVector, provides a resizable array data - structure. The main differences between the two classes are: - - \list - \o QVarLengthArray's API is much more low-level. It provides no - iterators and lacks much of QVector's functionality. - - \o QVarLengthArray doesn't initialize the memory if the value is - a basic type. (QVector always does.) - - \o QVector uses \l{implicit sharing} as a memory optimization. - QVarLengthArray doesn't provide that feature; however, it - usually produces slightly better performance due to reduced - overhead, especially in tight loops. - \endlist - - In summary, QVarLengthArray is a low-level optimization class - that only makes sense in very specific cases. It is used a few - places inside Qt and was added to Qt's public API for the - convenience of advanced users. - - \sa QVector, QList, QLinkedList -*/ - -/*! \fn QVarLengthArray::QVarLengthArray(int size) - - Constructs an array with an initial size of \a size elements. - - If the value type is a primitive type (e.g., char, int, float) or - a pointer type (e.g., QWidget *), the elements are not - initialized. For other types, the elements are initialized with a - \l{default-constructed value}. -*/ - -/*! \fn QVarLengthArray::~QVarLengthArray() - - Destroys the array. -*/ - -/*! \fn int QVarLengthArray::size() const - - Returns the number of elements in the array. - - \sa isEmpty(), resize() -*/ - -/*! \fn int QVarLengthArray::count() const - - Same as size(). - - \sa isEmpty(), resize() -*/ - -/*! \fn bool QVarLengthArray::isEmpty() const - - Returns true if the array has size 0; otherwise returns false. - - \sa size(), resize() -*/ - -/*! \fn void QVarLengthArray::clear() - - Removes all the elements from the array. - - Same as resize(0). -*/ - -/*! \fn void QVarLengthArray::resize(int size) - - Sets the size of the array to \a size. If \a size is greater than - the current size, elements are added to the end. If \a size is - less than the current size, elements are removed from the end. - - If the value type is a primitive type (e.g., char, int, float) or - a pointer type (e.g., QWidget *), new elements are not - initialized. For other types, the elements are initialized with a - \l{default-constructed value}. - - \sa size() -*/ - -/*! \fn int QVarLengthArray::capacity() const - - Returns the maximum number of elements that can be stored in the - array without forcing a reallocation. - - The sole purpose of this function is to provide a means of fine - tuning QVarLengthArray's memory usage. In general, you will rarely ever - need to call this function. If you want to know how many items are - in the array, call size(). - - \sa reserve() -*/ - -/*! \fn void QVarLengthArray::reserve(int size) - - Attempts to allocate memory for at least \a size elements. If you - know in advance how large the array can get, you can call this - function and if you call resize() often, you are likely to get - better performance. If \a size is an underestimate, the worst - that will happen is that the QVarLengthArray will be a bit - slower. - - The sole purpose of this function is to provide a means of fine - tuning QVarLengthArray's memory usage. In general, you will - rarely ever need to call this function. If you want to change the - size of the array, call resize(). - - \sa capacity() -*/ - -/*! \fn T &QVarLengthArray::operator[](int i) - - Returns a reference to the item at index position \a i. - - \a i must be a valid index position in the array (i.e., 0 <= \a i - < size()). - - \sa data() -*/ - -/*! \fn const T &QVarLengthArray::operator[](int i) const - - \overload -*/ - - -/*! - \fn void QVarLengthArray::append(const T &t) - - Appends item \a t to the array, extending the array if necessary. - - \sa removeLast() -*/ - - -/*! - \fn inline void QVarLengthArray::removeLast() - \since 4.5 - - Decreases the size of the array by one. The allocated size is not changed. - - \sa append() -*/ - -/*! - \fn void QVarLengthArray::append(const T *buf, int size) - - Appends \a size amount of items referenced by \a buf to this array. -*/ - - -/*! \fn T *QVarLengthArray::data() - - Returns a pointer to the data stored in the array. The pointer can - be used to access and modify the items in the array. - - Example: - \snippet doc/src/snippets/code/doc_src_qvarlengtharray.qdoc 3 - - The pointer remains valid as long as the array isn't reallocated. - - This function is mostly useful to pass an array to a function - that accepts a plain C++ array. - - \sa constData(), operator[]() -*/ - -/*! \fn const T *QVarLengthArray::data() const - - \overload -*/ - -/*! \fn const T *QVarLengthArray::constData() const - - Returns a const pointer to the data stored in the array. The - pointer can be used to access the items in the array. The - pointer remains valid as long as the array isn't reallocated. - - This function is mostly useful to pass an array to a function - that accepts a plain C++ array. - - \sa data(), operator[]() -*/ - -/*! \fn QVarLengthArray &QVarLengthArray::operator=(const QVarLengthArray &other) - Assigns \a other to this array and returns a reference to this array. - */ - -/*! \fn QVarLengthArray::QVarLengthArray(const QVarLengthArray &other) - Constructs a copy of \a other. - */ - diff --git a/doc/src/qwaitcondition.qdoc b/doc/src/qwaitcondition.qdoc deleted file mode 100644 index ae94e35..0000000 --- a/doc/src/qwaitcondition.qdoc +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QWaitCondition - \brief The QWaitCondition class provides a condition variable for - synchronizing threads. - - \threadsafe - - \ingroup thread - \ingroup environment - - QWaitCondition allows a thread to tell other threads that some - sort of condition has been met. One or many threads can block - waiting for a QWaitCondition to set a condition with wakeOne() or - wakeAll(). Use wakeOne() to wake one randomly selected condition or - wakeAll() to wake them all. - - For example, let's suppose that we have three tasks that should - be performed whenever the user presses a key. Each task could be - split into a thread, each of which would have a - \l{QThread::run()}{run()} body like this: - - \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 0 - - Here, the \c keyPressed variable is a global variable of type - QWaitCondition. - - A fourth thread would read key presses and wake the other three - threads up every time it receives one, like this: - - \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 1 - - The order in which the three threads are woken up is undefined. - Also, if some of the threads are still in \c do_something() when - the key is pressed, they won't be woken up (since they're not - waiting on the condition variable) and so the task will not be - performed for that key press. This issue can be solved using a - counter and a QMutex to guard it. For example, here's the new - code for the worker threads: - - \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 2 - - Here's the code for the fourth thread: - - \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 3 - - The mutex is necessary because the results of two threads - attempting to change the value of the same variable - simultaneously are unpredictable. - - Wait conditions are a powerful thread synchronization primitive. - The \l{threads/waitconditions}{Wait Conditions} example shows how - to use QWaitCondition as an alternative to QSemaphore for - controlling access to a circular buffer shared by a producer - thread and a consumer thread. - - \sa QMutex, QSemaphore, QThread, {Wait Conditions Example} -*/ - -/*! - \fn QWaitCondition::QWaitCondition() - - Constructs a new wait condition object. -*/ - -/*! - \fn QWaitCondition::~QWaitCondition() - - Destroys the wait condition object. -*/ - -/*! - \fn void QWaitCondition::wakeOne() - - Wakes one thread waiting on the wait condition. The thread that - is woken up depends on the operating system's scheduling - policies, and cannot be controlled or predicted. - - If you want to wake up a specific thread, the solution is - typically to use different wait conditions and have different - threads wait on different conditions. - - \sa wakeAll() -*/ - -/*! - \fn void QWaitCondition::wakeAll() - - Wakes all threads waiting on the wait condition. The order in - which the threads are woken up depends on the operating system's - scheduling policies and cannot be controlled or predicted. - - \sa wakeOne() -*/ - -/*! - \fn bool QWaitCondition::wait(QMutex *mutex, unsigned long time) - - Releases the locked \a mutex and waits on the wait condition. The - \a mutex must be initially locked by the calling thread. If \a - mutex is not in a locked state, this function returns - immediately. If \a mutex is a recursive mutex, this function - returns immediately. The \a mutex will be unlocked, and the - calling thread will block until either of these conditions is met: - - \list - \o Another thread signals it using wakeOne() or wakeAll(). This - function will return true in this case. - \o \a time milliseconds has elapsed. If \a time is \c ULONG_MAX - (the default), then the wait will never timeout (the event - must be signalled). This function will return false if the - wait timed out. - \endlist - - The mutex will be returned to the same locked state. This - function is provided to allow the atomic transition from the - locked state to the wait state. - - \sa wakeOne(), wakeAll() -*/ - -/*! - \fn bool QWaitCondition::wait(QReadWriteLock *readWriteLock, unsigned long time) - \since 4.4 - - Releases the locked \a readWriteLock and waits on the wait - condition. The \a readWriteLock must be initially locked by the - calling thread. If \a readWriteLock is not in a locked state, this - function returns immediately. The \a readWriteLock must not be - locked recursively, otherwise this function will not release the - lock properly. The \a readWriteLock will be unlocked, and the - calling thread will block until either of these conditions is met: - - \list - \o Another thread signals it using wakeOne() or wakeAll(). This - function will return true in this case. - \o \a time milliseconds has elapsed. If \a time is \c ULONG_MAX - (the default), then the wait will never timeout (the event - must be signalled). This function will return false if the - wait timed out. - \endlist - - The \a readWriteLock will be returned to the same locked - state. This function is provided to allow the atomic transition - from the locked state to the wait state. - - \sa wakeOne(), wakeAll() -*/ -- cgit v0.12 From 1ef2f7fd3734fbae5fd4e18047f4ad06b217d850 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Thu, 30 Jul 2009 14:38:51 +0200 Subject: Doc - Beautifying documentation of autoMaximizeThreshold Reviewed-By: Thomas Hartmann --- src/gui/kernel/qapplication.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 109ceb1..c0d9957 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -1194,21 +1194,22 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis \since 4.4 \brief defines a threshold for auto maximizing widgets - The auto maximize threshold is only available as part of Qt for Windows CE. + \bold{The auto maximize threshold is only available as part of Qt for + Windows CE.} This property defines a threshold for the size of a window as a percentage of the screen size. If the minimum size hint of a window exceeds the - threshold, calling show() will then cause the window to be maximized + threshold, calling show() will cause the window to be maximized automatically. - Setting the threshold to be 100 or greater means that it will cause it to - always be maximized. Setting it to be 50 means that the widget is maximized - if the vertical minimum size hint is at least 50% of the vertical screen - size. + Setting the threshold to 100 or greater means that the widget will always + be maximized. Alternatively, setting the threshold to 50 means that the + widget will be maximized only if the vertical minimum size hint is at least + 50% of the vertical screen size. - If -1 is specified then this will disable the feature. + Setting the threshold to -1 disables the feature. - On Windows CE the default is -1 (i.e. it is disabled). + On Windows CE the default is -1 (i.e., it is disabled). On Windows Mobile the default is 40. */ -- cgit v0.12 From 91fe038eb280ef64f92a029f9247e657361c90f7 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Thu, 30 Jul 2009 15:00:24 +0200 Subject: Doc - Some more cleanups to beautify the documentation Reviewed-By: TrustMe --- src/gui/kernel/qapplication.cpp | 77 ++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index c0d9957..e210556 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -673,9 +673,9 @@ QApplication::QApplication(int &argc, char **argv, int _internal) On X11, the window system is initialized if \a GUIenabled is true. If \a GUIenabled is false, the application does not connect to the X server. - On Windows and Macintosh, currently the window system is always - initialized, regardless of the value of GUIenabled. This may change in - future versions of Qt. + On Windows and Mac OS, currently the window system is always initialized, + regardless of the value of GUIenabled. This may change in future versions + of Qt. The following example shows how to create an application that uses a graphical interface when available. @@ -1218,9 +1218,9 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis \since 4.5 \brief toggles automatic SIP (software input panel) visibility - The auto SIP property is only available as part of Qt for Windows CE. + \bold{The auto SIP property is only available as part of Qt for Windows CE.} - Set this property to true to automatically display the SIP when entering + Set this property to \c true to automatically display the SIP when entering widgets that accept keyboard input. This property only affects widgets with the WA_InputMethodEnabled attribute set. */ @@ -1518,7 +1518,7 @@ int QApplication::colorSpec() strategy. Use this option if your application uses buttons, menus, texts and pixmaps with few colors. With this option, the application uses system global colors. This works fine for most - applications under X11, but on Windows machines it may cause + applications under X11, but on the Windows platform, it may cause dithering of non-standard colors. \o QApplication::CustomColor. Use this option if your application needs a small number of custom colors. On X11, this option is the @@ -3514,12 +3514,12 @@ void QApplication::changeOverrideCursor(const QCursor &cursor) We recommend that you connect clean-up code to the \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your - application's \c{main()} function because on some platforms the - QApplication::exec() call may not return. For example, on Windows when the - user logs off, the system terminates the process after Qt closes all - top-level windows. Hence, there is no guarantee that the application will - have time to exit its event loop and execute code at the end of the - \c{main()} function after the QApplication::exec() call. + application's \c{main()} function. This is because, on some platforms the + QApplication::exec() call may not return. For example, on the Windows + platform, when the user logs off, the system terminates the process after Qt + closes all top-level windows. Hence, there is \e{no guarantee} that the + application will have time to exit its event loop and execute code at the + end of the \c{main()} function, after the QApplication::exec() call. \sa quitOnLastWindowClosed, quit(), exit(), processEvents(), QCoreApplication::exec() @@ -4763,7 +4763,7 @@ bool QApplication::keypadNavigationEnabled() On Mac OS X, this works more at the application level and will cause the application icon to bounce in the dock. - On Windows this causes the window's taskbar entry to flash for a time. If + On Windows, this causes the window's taskbar entry to flash for a time. If \a msec is zero, the flashing will stop and the taskbar entry will turn a different color (currently orange). @@ -4780,24 +4780,22 @@ bool QApplication::keypadNavigationEnabled() caret display. Usually the text cursor is displayed for half the cursor flash time, then hidden for the same amount of time, but this may vary. - The default value on X11 is 1000 milliseconds. On Windows, the control - panel value is used. Widgets should not cache this value since it may be - changed at any time by the user changing the global desktop settings. + The default value on X11 is 1000 milliseconds. On Windows, the + \gui{Control Panel} value is used and setting this property sets the cursor + flash time for all applications. - \note On Microsoft Windows, setting this property sets the cursor flash - time for all applications. + We recommend that widgets do not cache this value as it may change at any + time if the user changes the global desktop settings. */ /*! \property QApplication::doubleClickInterval - \brief the time limit in milliseconds that distinguishes a double click from two - consecutive mouse clicks + \brief the time limit in milliseconds that distinguishes a double click + from two consecutive mouse clicks - The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the - operating system's value is used. - - On Microsoft Windows, calling this function sets the double click interval - for all applications. + The default value on X11 is 400 milliseconds. On Windows and Mac OS, the + operating system's value is used. However, on Windows, calling this + function sets the double click interval for all applications. */ /*! @@ -4806,7 +4804,7 @@ bool QApplication::keypadNavigationEnabled() from two consecutive key presses \since 4.2 - The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the + The default value on X11 is 400 milliseconds. On Windows and Mac OS, the operating system's value is used. */ @@ -4871,7 +4869,7 @@ bool QApplication::keypadNavigationEnabled() You need not have a main widget; connecting lastWindowClosed() to quit() is an alternative. - For X11, this function also resizes and moves the main widget according + On X11, this function also resizes and moves the main widget according to the \e -geometry command-line option, so you should set the default geometry (using \l QWidget::setGeometry()) before calling setMainWidget(). @@ -4900,9 +4898,10 @@ bool QApplication::keypadNavigationEnabled() Application cursors are stored on an internal stack. setOverrideCursor() pushes the cursor onto the stack, and restoreOverrideCursor() pops the active cursor off the stack. changeOverrideCursor() changes the curently - active application override cursor. Every setOverrideCursor() must - eventually be followed by a corresponding restoreOverrideCursor(), - otherwise the stack will never be emptied. + active application override cursor. + + Every setOverrideCursor() must eventually be followed by a corresponding + restoreOverrideCursor(), otherwise the stack will never be emptied. Example: \snippet doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp 0 @@ -5083,19 +5082,19 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy) */ /*! \fn QDecoration* QApplication::qwsSetDecoration(const QString &decoration) - \overload + \overload - Requests a QDecoration object for \a decoration from the QDecorationFactory. + Requests a QDecoration object for \a decoration from the + QDecorationFactory. - The string must be one of the QDecorationFactory::keys(). Keys are - case insensitive. + The string must be one of the QDecorationFactory::keys(). Keys are case + insensitive. - A later call to the QApplication constructor will override the - requested style when a "-style" option is passed in as a commandline - parameter. + A later call to the QApplication constructor will override the requested + style when a "-style" option is passed in as a commandline parameter. - Returns 0 if an unknown \a decoration is passed, otherwise the QStyle object - returned is set as the application's GUI style. + Returns 0 if an unknown \a decoration is passed, otherwise the QStyle object + returned is set as the application's GUI style. */ /*! -- cgit v0.12 From e447e8a5356f5de4a6a62a28c0d21785b09b4cba Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Thu, 30 Jul 2009 15:12:27 +0200 Subject: When there is no alpha channel significantly improve the speed of blendTiled. Copy the first line from the texture to the destination and from then on reference that copy reducing cache misses. Also progressively copy larger sizes, reducing the amount of time spend figuring out what to copy. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 371 Reviewed-by: Samuel Rødal --- src/gui/painting/qdrawhelper.cpp | 72 ++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 979390a..b6603e4 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -4794,30 +4794,60 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTiled(int count, const QSpan *spans, void * if (sy < 0) sy += image_height; - while (length) { - int l = qMin(image_width - sx, length); - if (buffer_size < l) - l = buffer_size; - - DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x; - const SRC *src = (SRC*)data->texture.scanLine(sy) + sx; - if (modeSource && coverage == 255) { + if (modeSource && coverage == 255) { + // Copy the first texture block + length = image_width; + while (length) { + int l = qMin(image_width - sx, length); + if (buffer_size < l) + l = buffer_size; + DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x; + const SRC *src = (SRC*)data->texture.scanLine(sy) + sx; qt_memconvert(dest, src, l); - } else if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 && - (quintptr(dest) & 3) == (quintptr(src) & 3)) - { - blendUntransformed_dest24(dest, src, coverage, l); - } else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && - (quintptr(dest) & 3) == (quintptr(src) & 3)) - { - blendUntransformed_dest16(dest, src, coverage, l); - } else { - blendUntransformed_unaligned(dest, src, coverage, l); + length -= l; + sx = 0; } - x += l; - length -= l; - sx = 0; + // Now use the rasterBuffer as the source of the texture, + // We can now progressively copy larger blocks + // - Less cpu time in code figuring out what to copy + // We are dealing with one block of data + // - More likely to fit in the cache + // - can use memcpy + int copy_image_width = image_width; + length = spans->len - image_width; + DST *src = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x; + DST *dest = src + copy_image_width; + while (copy_image_width < length) { + qt_memconvert(dest, src, copy_image_width); + dest += copy_image_width; + length -= copy_image_width; + copy_image_width *= 2; + } + qt_memconvert(dest, src, length); + } else { + while (length) { + int l = qMin(image_width - sx, length); + if (buffer_size < l) + l = buffer_size; + DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x; + const SRC *src = (SRC*)data->texture.scanLine(sy) + sx; + if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 && + (quintptr(dest) & 3) == (quintptr(src) & 3)) + { + blendUntransformed_dest24(dest, src, coverage, l); + } else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && + (quintptr(dest) & 3) == (quintptr(src) & 3)) + { + blendUntransformed_dest16(dest, src, coverage, l); + } else { + blendUntransformed_unaligned(dest, src, coverage, l); + } + + x += l; + length -= l; + sx = 0; + } } ++spans; } -- cgit v0.12 From 1685f9968ea7b1e132df44c8aab3d03ad6cd5e12 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Thu, 30 Jul 2009 15:39:19 +0200 Subject: Doc - Fixed a broken link to the Apple Human Interface Guidelines document Task: 254724 Reviewed-By: TrustMe --- 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 a3964f7..4a900d6 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -716,7 +716,7 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti application examples} also provide menus using these classes. \sa QMenu, QShortcut, QAction, - {http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html}{Introduction to Apple Human Interface Guidelines}, + {http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGIntro/XHIGIntro.html}{Introduction to Apple Human Interface Guidelines}, {fowler}{GUI Design Handbook: Menu Bar}, {Menus Example} */ -- cgit v0.12 From 5aa46b1052b05d34cbfef175caaf941928520964 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 27 Jul 2009 13:20:14 +0200 Subject: Added support for 'vector-effect' in QtSvg. Task-number: 254040 Reviewed-by: Tor Arne --- src/svg/qsvghandler.cpp | 232 +++++++++++++++++++++++++++++++----------------- 1 file changed, 150 insertions(+), 82 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index f10b26f..b829a22 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -697,85 +697,152 @@ static void parseQPen(QPen &pen, QSvgNode *node, QString miterlimit = attributes.value(QLatin1String("stroke-miterlimit")).toString(); QString opacity = attributes.value(QLatin1String("stroke-opacity")).toString(); QString width = attributes.value(QLatin1String("stroke-width")).toString(); + QString vectorEffect = attributes.value(QLatin1String("vector-effect")).toString(); QString myId = someId(attributes); - if (!value.isEmpty() || !width.isEmpty()) { - if (value != QLatin1String("none")) { - if (!value.isEmpty()) { - if (node && value.startsWith(QLatin1String("url"))) { - value = value.remove(0, 3); - QSvgStyleProperty *style = styleFromUrl(node, value); - if (style) { - if (style->type() == QSvgStyleProperty::GRADIENT) { - QBrush b(*((QSvgGradientStyle*)style)->qgradient()); - pen.setBrush(b); - } else if (style->type() == QSvgStyleProperty::SOLID_COLOR) { - pen.setColor( - ((QSvgSolidColorStyle*)style)->qcolor()); - } - } else { - qWarning()<<"QSvgHandler::parsePen could not resolve property" << idFromUrl(value); - } - } else { - QColor color; - if (constructColor(value, opacity, color, handler)) - pen.setColor(color); - } - //since we could inherit stroke="none" - //we need to reset the style of our stroke to something - pen.setStyle(Qt::SolidLine); - } - if (!width.isEmpty()) { - QSvgHandler::LengthType lt; - qreal widthF = parseLength(width, lt, handler); - //### fixme - if (!widthF) { - pen.setStyle(Qt::NoPen); - return; - } - pen.setWidthF(widthF); - } - qreal penw = pen.widthF(); - - if (!linejoin.isEmpty()) { - if (linejoin == QLatin1String("miter")) - pen.setJoinStyle(Qt::SvgMiterJoin); - else if (linejoin == QLatin1String("round")) - pen.setJoinStyle(Qt::RoundJoin); - else if (linejoin == QLatin1String("bevel")) - pen.setJoinStyle(Qt::BevelJoin); - } - if (!miterlimit.isEmpty()) - pen.setMiterLimit(toDouble(miterlimit)); - - if (!linecap.isEmpty()) { - if (linecap == QLatin1String("butt")) - pen.setCapStyle(Qt::FlatCap); - else if (linecap == QLatin1String("round")) - pen.setCapStyle(Qt::RoundCap); - else if (linecap == QLatin1String("square")) - pen.setCapStyle(Qt::SquareCap); - } + QSvgStrokeStyle *inherited = + static_cast(node->parent()->styleProperty( + QSvgStyleProperty::STROKE)); - if (!dashArray.isEmpty()) { - const QChar *s = dashArray.constData(); - QVector dashes = parseNumbersList(s); - qreal *d = dashes.data(); - if (penw != 0) - for (int i = 0; i < dashes.size(); ++i) { - *d /= penw; - ++d; + bool stroke = false; + if (inherited) { + pen = inherited->qpen(); + stroke = inherited->strokePresent(); + } else { + pen = handler->defaultPen(); + } + + // stroke-opacity attribute handling + qreal strokeAlpha; + if (!opacity.isEmpty() && opacity != QLatin1String("inherit")) { + strokeAlpha = qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity))); + } else { + strokeAlpha = pen.color().alphaF(); + } + + //stroke attribute handling + if (!value.isEmpty() && value != QLatin1String("inherit")) { + if (value.startsWith(QLatin1String("url"))) { + value = value.remove(0, 3); + QSvgStyleProperty *style = styleFromUrl(node, value); + if (style) { + if (style->type() == QSvgStyleProperty::GRADIENT) { + QBrush b(*((QSvgGradientStyle*)style)->qgradient()); + pen.setBrush(b); + } else if (style->type() == QSvgStyleProperty::SOLID_COLOR) { + pen.setColor(((QSvgSolidColorStyle*)style)->qcolor()); } - pen.setDashPattern(dashes); + stroke = true; + } else { + qWarning() << "QSvgHandler::parsePen could not resolve property" << idFromUrl(value); } - if (!dashOffset.isEmpty()) { - pen.setDashOffset(toDouble(dashOffset)); + } else if (value == QLatin1String("none")) { + QColor color; + color.setAlphaF(strokeAlpha); + pen.setColor(color); + stroke = false; + } else { + QColor color; + if (resolveColor(value, color, handler)) { + color.setAlphaF(strokeAlpha); + pen.setColor(color); } + stroke = true; + } + } else { + QColor color = pen.color(); + color.setAlphaF(strokeAlpha); + pen.setColor(color); + } - } else { - pen.setStyle(Qt::NoPen); + //stroke-width handling + if (!width.isEmpty() && width != QLatin1String("inherit")) { + qreal widthF; + QSvgHandler::LengthType lt; + widthF = parseLength(width, lt, handler); + pen.setWidthF(widthF); + } + + //stroke-linejoin attribute handling + if (!linejoin.isEmpty()) { + if (linejoin == QLatin1String("miter")) + pen.setJoinStyle(Qt::SvgMiterJoin); + else if (linejoin == QLatin1String("round")) + pen.setJoinStyle(Qt::RoundJoin); + else if (linejoin == QLatin1String("bevel")) + pen.setJoinStyle(Qt::BevelJoin); + } + + //stroke-linecap attribute handling + if (!linecap.isEmpty()) { + if (linecap == QLatin1String("butt")) + pen.setCapStyle(Qt::FlatCap); + else if (linecap == QLatin1String("round")) + pen.setCapStyle(Qt::RoundCap); + else if (linecap == QLatin1String("square")) + pen.setCapStyle(Qt::SquareCap); + } + + //strok-dasharray attribute handling + qreal penw = pen.widthF(); + if (!dashArray.isEmpty() && dashArray != QLatin1String("inherit")) { + const QChar *s = dashArray.constData(); + QVector dashes = parseNumbersList(s); + qreal *d = dashes.data(); + if (penw != 0) + for (int i = 0; i < dashes.size(); ++i) { + *d /= penw; + ++d; + } + // if the dash count is odd the dashes should be duplicated + if (dashes.size() % 2 != 0) + dashes << QVector(dashes); + pen.setDashPattern(dashes); + } else if (inherited) { + QVector dashes(inherited->qpen().dashPattern()); + qreal *d = dashes.data(); + if (!penw) + penw = 1.0; + qreal inheritpenw = inherited->qpen().widthF(); + if (!inheritpenw) + inheritpenw = 1.0; + for ( int i = 0; i < dashes.size(); ++i) { + *d *= (inheritpenw/ penw); + ++d; } + pen.setDashPattern(dashes); } + + //stroke-dashoffset attribute handling + if (!dashOffset.isEmpty() && dashOffset != QLatin1String("inherit")) { + qreal doffset = toDouble(dashOffset); + if (penw != 0) + doffset /= penw; + pen.setDashOffset(doffset); + } else if (inherited) { + qreal doffset = pen.dashOffset(); + if (!penw) + penw = 1.0; + qreal inheritpenw = inherited->qpen().widthF(); + if (!inheritpenw) + inheritpenw = 1.0; + doffset *= (inheritpenw / penw); + pen.setDashOffset(doffset); + } + + //vector-effect attribute handling + if (!vectorEffect.isEmpty()) { + if (vectorEffect == QLatin1String("non-scaling-stroke")) + pen.setCosmetic(true); + else if (vectorEffect == QLatin1String("none")) + pen.setCosmetic(false); + } + + if (!miterlimit.isEmpty() && miterlimit != QLatin1String("inherit")) + pen.setMiterLimit(toDouble(miterlimit)); + + if (!stroke) + pen.setStyle(Qt::NoPen); } static QMatrix parseTransformationMatrix(const QString &value) @@ -917,18 +984,15 @@ static void parsePen(QSvgNode *node, QString miterlimit = attributes.value(QLatin1String("stroke-miterlimit")).toString(); QString opacity = attributes.value(QLatin1String("stroke-opacity")).toString(); QString width = attributes.value(QLatin1String("stroke-width")).toString(); + QString vectorEffect = attributes.value(QLatin1String("vector-effect")).toString(); QString myId = someId(attributes); //qDebug()<<"Node "<type()<<", attrs are "<(node->parent()->styleProperty( QSvgStyleProperty::STROKE)); @@ -961,8 +1025,7 @@ static void parsePen(QSvgNode *node, pen.setColor( ((QSvgSolidColorStyle*)style)->qcolor()); } - pen.setStyle(Qt::SolidLine); - stroke = true; + stroke = true; } else { qWarning() << "QSvgHandler::parsePen could not resolve property" << idFromUrl(value); } @@ -991,9 +1054,6 @@ static void parsePen(QSvgNode *node, QSvgHandler::LengthType lt; widthF = parseLength(width, lt, handler); pen.setWidthF(widthF); - } else if (inherited){ - qreal widthF = inherited->qpen().widthF(); - pen.setWidthF(widthF); } //stroke-linejoin attribute handling @@ -1064,6 +1124,14 @@ static void parsePen(QSvgNode *node, pen.setDashOffset(doffset); } + //vector-effect attribute handling + if (!vectorEffect.isEmpty()) { + if (vectorEffect == QLatin1String("non-scaling-stroke")) + pen.setCosmetic(true); + else if (vectorEffect == QLatin1String("none")) + pen.setCosmetic(false); + } + if (!miterlimit.isEmpty() && miterlimit != QLatin1String("inherit")) pen.setMiterLimit(toDouble(miterlimit)); -- cgit v0.12 From 54ed2a3db855aab8219f9588e241d3110bdddfb1 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Thu, 30 Jul 2009 14:33:41 +0200 Subject: Fixed font attribute inheritence, text and textArea elements in QtSvg. Text used to be formatted during the parsing of the SVG file, but because the text can be referenced by a 'use' element, the text formatting is not known at this point in time. Now, font attributes can be inherited from 'use' elements, and the text is formatted each time it is drawn. Reviewed-by: Tor Arne --- src/svg/qsvggraphics.cpp | 286 ++++++++-------- src/svg/qsvggraphics_p.h | 51 ++- src/svg/qsvghandler.cpp | 630 ++++++++--------------------------- src/svg/qsvgnode_p.h | 1 + src/svg/qsvgstyle.cpp | 126 ++++--- src/svg/qsvgstyle_p.h | 80 ++++- tests/arthur/data/1.2/textArea01.svg | 2 +- 7 files changed, 474 insertions(+), 702 deletions(-) diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp index e09f382..2be7559 100644 --- a/src/svg/qsvggraphics.cpp +++ b/src/svg/qsvggraphics.cpp @@ -266,21 +266,23 @@ void QSvgRect::draw(QPainter *p, QSvgExtraStates &states) } } +QSvgTspan * const QSvgText::LINEBREAK = 0; + QSvgText::QSvgText(QSvgNode *parent, const QPointF &coord) : QSvgNode(parent) , m_coord(coord) - , m_textAlignment(Qt::AlignLeft) - , m_scale(1) - , m_appendSpace(false) , m_type(TEXT) , m_size(0, 0) + , m_mode(Default) { - m_paragraphs.push_back(QString()); - m_formatRanges.push_back(QList()); } QSvgText::~QSvgText() { + for (int i = 0; i < m_tspans.size(); ++i) { + if (m_tspans[i] != LINEBREAK) + delete m_tspans[i]; + } } void QSvgText::setTextArea(const QSizeF &size) @@ -295,175 +297,173 @@ void QSvgText::draw(QPainter *p, QSvgExtraStates &states) { applyStyle(p, states); - QSvgFontStyle *fontStyle = static_cast( - styleProperty(QSvgStyleProperty::FONT)); - if (fontStyle && fontStyle->svgFont()) { - // SVG fonts not fully supported... - QString text = m_paragraphs.front(); - for (int i = 1; i < m_paragraphs.size(); ++i) { - text.append(QLatin1Char('\n')); - text.append(m_paragraphs[i]); - } - fontStyle->svgFont()->draw(p, m_coord, text, fontStyle->pointSize(), m_textAlignment); - revertStyle(p, states); - return; - } + // Force the font to have a size of 100 pixels to avoid truncation problems + // when the font is very small. + qreal scale = 100.0 / p->font().pointSizeF(); + Qt::Alignment alignment = states.textAnchor; - // Scale the font to its correct size. QTransform oldTransform = p->worldTransform(); - p->scale(1 / m_scale, 1 / m_scale); + p->scale(1 / scale, 1 / scale); qreal y = 0; bool initial = true; - qreal px = m_coord.x() * m_scale; - qreal py = m_coord.y() * m_scale; - QSizeF scaledSize = m_size * m_scale; + qreal px = m_coord.x() * scale; + qreal py = m_coord.y() * scale; + QSizeF scaledSize = m_size * scale; if (m_type == TEXTAREA) { - if (m_textAlignment == Qt::AlignHCenter) + if (alignment == Qt::AlignHCenter) px += scaledSize.width() / 2; - else if (m_textAlignment == Qt::AlignRight) + else if (alignment == Qt::AlignRight) px += scaledSize.width(); } QRectF bounds; if (m_size.height() != 0) - bounds = QRectF(0, 0, 1, scaledSize.height()); - - for (int i = 0; i < m_paragraphs.size(); ++i) { - QTextLayout tl(m_paragraphs[i]); - QTextOption op = tl.textOption(); - op.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); - tl.setTextOption(op); - tl.setAdditionalFormats(m_formatRanges[i]); - tl.beginLayout(); - forever { - QTextLine line = tl.createLine(); - if (!line.isValid()) - break; - - if (m_size.width() != 0) - line.setLineWidth(scaledSize.width()); - } - tl.endLayout(); - - bool endOfBoundsReached = false; - for (int i = 0; i < tl.lineCount(); ++i) { - QTextLine line = tl.lineAt(i); - - qreal x = 0; - if (m_textAlignment == Qt::AlignHCenter) - x -= line.naturalTextWidth() / 2; - else if (m_textAlignment == Qt::AlignRight) - x -= line.naturalTextWidth(); - - if (initial && m_type == TEXT) - y -= line.ascent(); - initial = false; - - line.setPosition(QPointF(x, y)); - if ((m_size.width() != 0 && line.naturalTextWidth() > scaledSize.width()) - || (m_size.height() != 0 && y + line.height() > scaledSize.height())) { - bounds.setHeight(y); - endOfBoundsReached = true; - break; + bounds = QRectF(0, py, 1, scaledSize.height()); // x and width are not used. + + bool appendSpace = false; + QVector paragraphs; + QStack formats; + QVector > formatRanges; + paragraphs.push_back(QString()); + formatRanges.push_back(QList()); + + for (int i = 0; i < m_tspans.size(); ++i) { + if (m_tspans[i] == LINEBREAK) { + if (m_type == TEXTAREA) { + if (paragraphs.back().isEmpty()) { + QFont font = p->font(); + font.setPixelSize(font.pointSizeF() * scale); + + QTextLayout::FormatRange range; + range.start = 0; + range.length = 1; + range.format.setFont(font); + formatRanges.back().append(range); + + paragraphs.back().append(QLatin1Char(' '));; + } + appendSpace = false; + paragraphs.push_back(QString()); + formatRanges.push_back(QList()); } + } else { + WhitespaceMode mode = m_tspans[i]->whitespaceMode(); + m_tspans[i]->applyStyle(p, states); - y += 1.1 * line.height(); - } - tl.draw(p, QPointF(px, py), QVector(), bounds); + QFont font = p->font(); + font.setPixelSize(font.pointSizeF() * scale); - if (endOfBoundsReached) - break; - } + QString newText(m_tspans[i]->text()); + newText.replace(QLatin1Char('\t'), QLatin1Char(' ')); + newText.replace(QLatin1Char('\n'), QLatin1Char(' ')); - p->setWorldTransform(oldTransform, false); - revertStyle(p, states); -} + bool prependSpace = !appendSpace && !m_tspans[i]->isTspan() && (mode == Default) && !paragraphs.back().isEmpty() && newText.startsWith(QLatin1Char(' ')); + if (appendSpace || prependSpace) + paragraphs.back().append(QLatin1Char(' ')); -void QSvgText::insertText(const QString &text, WhitespaceMode mode) -{ - bool isTSpan = (m_formats.count() == 2); - QString newText(text); - newText.replace(QLatin1Char('\t'), QLatin1Char(' ')); - newText.replace(QLatin1Char('\n'), QLatin1Char(' ')); + bool appendSpaceNext = (!m_tspans[i]->isTspan() && (mode == Default) && newText.endsWith(QLatin1Char(' '))); - bool prependSpace = !m_appendSpace && !isTSpan && (mode == Default) && !m_paragraphs.back().isEmpty() && newText.startsWith(QLatin1Char(' ')); - if (m_appendSpace || prependSpace) - m_paragraphs.back().append(QLatin1Char(' ')); + if (mode == Default) { + newText = newText.simplified(); + if (newText.isEmpty()) + appendSpaceNext = false; + } - bool appendSpaceNext = (!isTSpan && (mode == Default) && newText.endsWith(QLatin1Char(' '))); + QTextLayout::FormatRange range; + range.start = paragraphs.back().length(); + range.length = newText.length(); + range.format.setFont(font); + range.format.setTextOutline(p->pen()); + range.format.setForeground(p->brush()); + + if (appendSpace) { + Q_ASSERT(!formatRanges.back().isEmpty()); + ++formatRanges.back().back().length; + } else if (prependSpace) { + --range.start; + ++range.length; + } + formatRanges.back().append(range); - if (mode == Default) { - newText = newText.simplified(); - if (newText.isEmpty()) - appendSpaceNext = false; - } + appendSpace = appendSpaceNext; + paragraphs.back() += newText; - if (!m_formats.isEmpty()) { - QTextLayout::FormatRange range; - range.start = m_paragraphs.back().length(); - range.length = newText.length(); - range.format = m_formats.top(); - if (m_appendSpace) { - Q_ASSERT(!m_formatRanges.back().isEmpty()); - ++m_formatRanges.back().back().length; - } else if (prependSpace) { - --range.start; - ++range.length; + m_tspans[i]->revertStyle(p, states); } - m_formatRanges.back().append(range); } - m_appendSpace = appendSpaceNext; - m_paragraphs.back() += newText; -} - -void QSvgText::insertFormat(const QTextCharFormat &format) -{ - QTextCharFormat mergedFormat = format; - if (!m_formats.isEmpty()) { - mergedFormat = m_formats.top(); - mergedFormat.merge(format); - } - m_formats.push(mergedFormat); -} + if (states.svgFont) { + // SVG fonts not fully supported... + QString text = paragraphs.front(); + for (int i = 1; i < paragraphs.size(); ++i) { + text.append(QLatin1Char('\n')); + text.append(paragraphs[i]); + } + states.svgFont->draw(p, m_coord, text, p->font().pointSizeF() * scale, states.textAnchor); + } else { + for (int i = 0; i < paragraphs.size(); ++i) { + QTextLayout tl(paragraphs[i]); + QTextOption op = tl.textOption(); + op.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); + tl.setTextOption(op); + tl.setAdditionalFormats(formatRanges[i]); + tl.beginLayout(); + + forever { + QTextLine line = tl.createLine(); + if (!line.isValid()) + break; + if (m_size.width() != 0) + line.setLineWidth(scaledSize.width()); + } + tl.endLayout(); + + bool endOfBoundsReached = false; + for (int i = 0; i < tl.lineCount(); ++i) { + QTextLine line = tl.lineAt(i); + + qreal x = 0; + if (alignment == Qt::AlignHCenter) + x -= 0.5 * line.naturalTextWidth(); + else if (alignment == Qt::AlignRight) + x -= line.naturalTextWidth(); + + if (initial && m_type == TEXT) + y -= line.ascent(); + initial = false; + + line.setPosition(QPointF(x, y)); + + // Check if the current line fits into the bounding rectangle. + if ((m_size.width() != 0 && line.naturalTextWidth() > scaledSize.width()) + || (m_size.height() != 0 && y + line.height() > scaledSize.height())) { + // I need to set the bounds height to 'y-epsilon' to avoid drawing the current + // line. Since the font is scaled to 100 units, 1 should be a safe epsilon. + bounds.setHeight(y - 1); + endOfBoundsReached = true; + break; + } + + y += 1.1 * line.height(); + } + tl.draw(p, QPointF(px, py), QVector(), bounds); -void QSvgText::insertLineBreak() -{ - if (m_type == TEXTAREA) { - if (m_paragraphs.back().isEmpty()) - insertText(QLatin1String(" "), Preserve); - m_appendSpace = false; - m_paragraphs.push_back(QString()); - m_formatRanges.push_back(QList()); + if (endOfBoundsReached) + break; + } } -} -void QSvgText::popFormat() -{ - if (m_formats.count() > 1) - m_formats.pop(); -} - -qreal QSvgText::scale() const -{ - return m_scale; -} - -void QSvgText::setScale(qreal scale) -{ - m_scale = scale; -} - -const QTextCharFormat &QSvgText::topFormat() const -{ - return m_formats.top(); + p->setWorldTransform(oldTransform, false); + revertStyle(p, states); } -void QSvgText::setTextAlignment(const Qt::Alignment &alignment) +void QSvgText::addText(const QString &text) { - m_textAlignment = alignment; + m_tspans.append(new QSvgTspan(this, false)); + m_tspans.back()->setWhitespaceMode(m_mode); + m_tspans.back()->addText(text); } QSvgUse::QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *node) diff --git a/src/svg/qsvggraphics_p.h b/src/svg/qsvggraphics_p.h index 4a19c7e..345b90b 100644 --- a/src/svg/qsvggraphics_p.h +++ b/src/svg/qsvggraphics_p.h @@ -187,6 +187,8 @@ private: int m_rx, m_ry; }; +class QSvgTspan; + class QSvgText : public QSvgNode { public: @@ -202,26 +204,47 @@ public: virtual void draw(QPainter *p, QSvgExtraStates &states); virtual Type type() const; - void insertText(const QString &text, WhitespaceMode mode); - void insertFormat(const QTextCharFormat &format); - void insertLineBreak(); - void popFormat(); - void setTextAlignment(const Qt::Alignment &alignment); - const QTextCharFormat &topFormat() const; - qreal scale() const; - void setScale(qreal scale); + + void addTspan(QSvgTspan *tspan) {m_tspans.append(tspan);} + void addText(const QString &text); + void addLineBreak() {m_tspans.append(LINEBREAK);} + void setWhitespaceMode(WhitespaceMode mode) {m_mode = mode;} + //virtual QRectF bounds() const; private: + static QSvgTspan * const LINEBREAK; + QPointF m_coord; - QVector m_paragraphs; - QStack m_formats; - Qt::Alignment m_textAlignment; - QVector > m_formatRanges; - qreal m_scale; - bool m_appendSpace; + // 'm_tspans' is also used to store characters outside tspans and line breaks. + // If a 'm_tspan' item is null, it indicates a line break. + QVector m_tspans; + Type m_type; QSizeF m_size; + WhitespaceMode m_mode; +}; + +class QSvgTspan : public QSvgNode +{ +public: + // tspans are also used to store normal text, so the 'isProperTspan' is used to separate text from tspan. + QSvgTspan(QSvgNode *parent, bool isProperTspan = true) + : QSvgNode(parent), m_mode(QSvgText::Default), m_isTspan(isProperTspan) + { + } + ~QSvgTspan() { }; + virtual Type type() const {return TSPAN;} + virtual void draw(QPainter *, QSvgExtraStates &) {Q_ASSERT(!"Tspans should be drawn through QSvgText::draw().");} + void addText(const QString &text) {m_text += text;} + const QString &text() const {return m_text;} + bool isTspan() const {return m_isTspan;} + void setWhitespaceMode(QSvgText::WhitespaceMode mode) {m_mode = mode;} + QSvgText::WhitespaceMode whitespaceMode() const {return m_mode;} +private: + QString m_text; + QSvgText::WhitespaceMode m_mode; + bool m_isTspan; }; class QSvgUse : public QSvgNode diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index b829a22..73c8b01 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -70,6 +70,8 @@ QT_BEGIN_NAMESPACE +static const char *qt_inherit_text = "inherit"; +#define QT_INHERIT QLatin1String(qt_inherit_text) double qstrtod(const char *s00, char const **se, bool *ok); @@ -492,7 +494,7 @@ static bool resolveColor(const QString &colorStr, QColor &color, QSvgHandler *ha int(compo[2])); return true; } else if (colorStr == QLatin1String("inherited") || - colorStr == QLatin1String("inherit")) { + colorStr == QT_INHERIT) { return false; } else if (colorStr == QLatin1String("currentColor")) { color = handler->currentColor(); @@ -646,204 +648,47 @@ static void parseBrush(QSvgNode *node, QString opacity = attributes.value(QLatin1String("fill-opacity")).toString(); QString myId = someId(attributes); - QSvgFillStyle *prop = new QSvgFillStyle(0); + if (!value.isEmpty() || !fillRule.isEmpty() || !opacity.isEmpty()) { + QSvgFillStyle *prop = new QSvgFillStyle(0); - //fill-rule attribute handling - if (!fillRule.isEmpty() && fillRule != QLatin1String("inherit")) { - if (fillRule == QLatin1String("evenodd")) - prop->setFillRule(Qt::OddEvenFill); - else if (fillRule == QLatin1String("nonzero")) - prop->setFillRule(Qt::WindingFill); - } - - //fill-opacity atttribute handling - if (!opacity.isEmpty() && opacity != QLatin1String("inherit")) { - prop->setFillOpacity(qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity)))); - } - - //fill attribute handling - if ((!value.isEmpty()) && (value != QLatin1String("inherit")) ) { - if (value.startsWith(QLatin1String("url"))) { - value = value.remove(0, 3); - QSvgStyleProperty *style = styleFromUrl(node, value); - if (style) { - prop->setFillStyle(style); - } else { - QString id = idFromUrl(value); - prop->setGradientId(id); - prop->setGradientResolved(false); - } - } else if (value != QLatin1String("none")) { - QColor color; - if (resolveColor(value, color, handler)) - prop->setBrush(QBrush(color)); - } else { - prop->setBrush(QBrush(Qt::NoBrush)); + //fill-rule attribute handling + if (!fillRule.isEmpty() && fillRule != QT_INHERIT) { + if (fillRule == QLatin1String("evenodd")) + prop->setFillRule(Qt::OddEvenFill); + else if (fillRule == QLatin1String("nonzero")) + prop->setFillRule(Qt::WindingFill); } - } - node->appendStyleProperty(prop,myId); -} - - -static void parseQPen(QPen &pen, QSvgNode *node, - const QSvgAttributes &attributes, - QSvgHandler *handler) -{ - QString value = attributes.value(QLatin1String("stroke")).toString(); - QString dashArray = attributes.value(QLatin1String("stroke-dasharray")).toString(); - QString dashOffset = attributes.value(QLatin1String("stroke-dashoffset")).toString(); - QString linecap = attributes.value(QLatin1String("stroke-linecap")).toString(); - QString linejoin = attributes.value(QLatin1String("stroke-linejoin")).toString(); - QString miterlimit = attributes.value(QLatin1String("stroke-miterlimit")).toString(); - QString opacity = attributes.value(QLatin1String("stroke-opacity")).toString(); - QString width = attributes.value(QLatin1String("stroke-width")).toString(); - QString vectorEffect = attributes.value(QLatin1String("vector-effect")).toString(); - QString myId = someId(attributes); - QSvgStrokeStyle *inherited = - static_cast(node->parent()->styleProperty( - QSvgStyleProperty::STROKE)); - - bool stroke = false; - if (inherited) { - pen = inherited->qpen(); - stroke = inherited->strokePresent(); - } else { - pen = handler->defaultPen(); - } + //fill-opacity atttribute handling + if (!opacity.isEmpty() && opacity != QT_INHERIT) { + prop->setFillOpacity(qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity)))); + } - // stroke-opacity attribute handling - qreal strokeAlpha; - if (!opacity.isEmpty() && opacity != QLatin1String("inherit")) { - strokeAlpha = qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity))); - } else { - strokeAlpha = pen.color().alphaF(); - } - - //stroke attribute handling - if (!value.isEmpty() && value != QLatin1String("inherit")) { - if (value.startsWith(QLatin1String("url"))) { - value = value.remove(0, 3); - QSvgStyleProperty *style = styleFromUrl(node, value); - if (style) { - if (style->type() == QSvgStyleProperty::GRADIENT) { - QBrush b(*((QSvgGradientStyle*)style)->qgradient()); - pen.setBrush(b); - } else if (style->type() == QSvgStyleProperty::SOLID_COLOR) { - pen.setColor(((QSvgSolidColorStyle*)style)->qcolor()); + //fill attribute handling + if ((!value.isEmpty()) && (value != QT_INHERIT) ) { + if (value.startsWith(QLatin1String("url"))) { + value = value.remove(0, 3); + QSvgStyleProperty *style = styleFromUrl(node, value); + if (style) { + prop->setFillStyle(style); + } else { + QString id = idFromUrl(value); + prop->setGradientId(id); + prop->setGradientResolved(false); } - stroke = true; + } else if (value != QLatin1String("none")) { + QColor color; + if (resolveColor(value, color, handler)) + prop->setBrush(QBrush(color)); } else { - qWarning() << "QSvgHandler::parsePen could not resolve property" << idFromUrl(value); - } - } else if (value == QLatin1String("none")) { - QColor color; - color.setAlphaF(strokeAlpha); - pen.setColor(color); - stroke = false; - } else { - QColor color; - if (resolveColor(value, color, handler)) { - color.setAlphaF(strokeAlpha); - pen.setColor(color); + prop->setBrush(QBrush(Qt::NoBrush)); } - stroke = true; } - } else { - QColor color = pen.color(); - color.setAlphaF(strokeAlpha); - pen.setColor(color); - } - - //stroke-width handling - if (!width.isEmpty() && width != QLatin1String("inherit")) { - qreal widthF; - QSvgHandler::LengthType lt; - widthF = parseLength(width, lt, handler); - pen.setWidthF(widthF); - } - - //stroke-linejoin attribute handling - if (!linejoin.isEmpty()) { - if (linejoin == QLatin1String("miter")) - pen.setJoinStyle(Qt::SvgMiterJoin); - else if (linejoin == QLatin1String("round")) - pen.setJoinStyle(Qt::RoundJoin); - else if (linejoin == QLatin1String("bevel")) - pen.setJoinStyle(Qt::BevelJoin); - } - - //stroke-linecap attribute handling - if (!linecap.isEmpty()) { - if (linecap == QLatin1String("butt")) - pen.setCapStyle(Qt::FlatCap); - else if (linecap == QLatin1String("round")) - pen.setCapStyle(Qt::RoundCap); - else if (linecap == QLatin1String("square")) - pen.setCapStyle(Qt::SquareCap); - } - - //strok-dasharray attribute handling - qreal penw = pen.widthF(); - if (!dashArray.isEmpty() && dashArray != QLatin1String("inherit")) { - const QChar *s = dashArray.constData(); - QVector dashes = parseNumbersList(s); - qreal *d = dashes.data(); - if (penw != 0) - for (int i = 0; i < dashes.size(); ++i) { - *d /= penw; - ++d; - } - // if the dash count is odd the dashes should be duplicated - if (dashes.size() % 2 != 0) - dashes << QVector(dashes); - pen.setDashPattern(dashes); - } else if (inherited) { - QVector dashes(inherited->qpen().dashPattern()); - qreal *d = dashes.data(); - if (!penw) - penw = 1.0; - qreal inheritpenw = inherited->qpen().widthF(); - if (!inheritpenw) - inheritpenw = 1.0; - for ( int i = 0; i < dashes.size(); ++i) { - *d *= (inheritpenw/ penw); - ++d; - } - pen.setDashPattern(dashes); - } - - //stroke-dashoffset attribute handling - if (!dashOffset.isEmpty() && dashOffset != QLatin1String("inherit")) { - qreal doffset = toDouble(dashOffset); - if (penw != 0) - doffset /= penw; - pen.setDashOffset(doffset); - } else if (inherited) { - qreal doffset = pen.dashOffset(); - if (!penw) - penw = 1.0; - qreal inheritpenw = inherited->qpen().widthF(); - if (!inheritpenw) - inheritpenw = 1.0; - doffset *= (inheritpenw / penw); - pen.setDashOffset(doffset); - } - - //vector-effect attribute handling - if (!vectorEffect.isEmpty()) { - if (vectorEffect == QLatin1String("non-scaling-stroke")) - pen.setCosmetic(true); - else if (vectorEffect == QLatin1String("none")) - pen.setCosmetic(false); + node->appendStyleProperty(prop, myId); } +} - if (!miterlimit.isEmpty() && miterlimit != QLatin1String("inherit")) - pen.setMiterLimit(toDouble(miterlimit)); - if (!stroke) - pen.setStyle(Qt::NoPen); -} static QMatrix parseTransformationMatrix(const QString &value) { @@ -1006,14 +851,14 @@ static void parsePen(QSvgNode *node, // stroke-opacity attribute handling qreal strokeAlpha; - if (!opacity.isEmpty() && opacity != QLatin1String("inherit")) { + if (!opacity.isEmpty() && opacity != QT_INHERIT) { strokeAlpha = qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity))); } else { strokeAlpha = pen.color().alphaF(); } //stroke attribute handling - if (!value.isEmpty() && value != QLatin1String("inherit")) { + if (!value.isEmpty() && value != QT_INHERIT) { if (value.startsWith(QLatin1String("url"))) { value = value.remove(0, 3); QSvgStyleProperty *style = styleFromUrl(node, value); @@ -1049,7 +894,7 @@ static void parsePen(QSvgNode *node, } //stroke-width handling - if (!width.isEmpty() && width != QLatin1String("inherit")) { + if (!width.isEmpty() && width != QT_INHERIT) { qreal widthF; QSvgHandler::LengthType lt; widthF = parseLength(width, lt, handler); @@ -1078,7 +923,7 @@ static void parsePen(QSvgNode *node, //strok-dasharray attribute handling qreal penw = pen.widthF(); - if (!dashArray.isEmpty() && dashArray != QLatin1String("inherit")) { + if (!dashArray.isEmpty() && dashArray != QT_INHERIT) { const QChar *s = dashArray.constData(); QVector dashes = parseNumbersList(s); qreal *d = dashes.data(); @@ -1108,7 +953,7 @@ static void parsePen(QSvgNode *node, //stroke-dashoffset attribute handling - if (!dashOffset.isEmpty() && dashOffset != QLatin1String("inherit")) { + if (!dashOffset.isEmpty() && dashOffset != QT_INHERIT) { qreal doffset = toDouble(dashOffset); if (penw != 0) doffset /= penw; @@ -1132,7 +977,7 @@ static void parsePen(QSvgNode *node, pen.setCosmetic(false); } - if (!miterlimit.isEmpty() && miterlimit != QLatin1String("inherit")) + if (!miterlimit.isEmpty() && miterlimit != QT_INHERIT) pen.setMiterLimit(toDouble(miterlimit)); QSvgStrokeStyle *prop = new QSvgStrokeStyle(pen); @@ -1141,182 +986,84 @@ static void parsePen(QSvgNode *node, } } - -static bool parseQBrush(const QSvgAttributes &attributes, QSvgNode *node, - QBrush &brush, QSvgHandler *handler) -{ - QString value = attributes.value(QLatin1String("fill")).toString(); - QString opacity = attributes.value(QLatin1String("fill-opacity")).toString(); - - QColor color; - if (!value.isEmpty() || !opacity.isEmpty()) { - if (value.startsWith(QLatin1String("url"))) { - value = value.remove(0, 3); - QSvgStyleProperty *style = styleFromUrl(node, value); - if (style) { - switch (style->type()) { - case QSvgStyleProperty::FILL: - { - brush = static_cast(style)->qbrush(); - break; - } - case QSvgStyleProperty::SOLID_COLOR: - { - brush = QBrush(static_cast(style)->qcolor()); - break; - } - case QSvgStyleProperty::GRADIENT: - { - brush = QBrush(*static_cast(style)->qgradient()); - break; - } - default: - qWarning("Cannot use property \"%s\" as brush.", qPrintable(idFromUrl(value))); - } - } else { - qWarning("Couldn't resolve property: %s", qPrintable(idFromUrl(value))); - } - } else if (value != QLatin1String("none")) { - if (constructColor(value, opacity, color, handler)) { - brush.setStyle(Qt::SolidPattern); - brush.setColor(color); - } - } else { - brush = QBrush(Qt::NoBrush); - } - return true; - } - return false; -} - -static bool parseQFont(const QSvgAttributes &attributes, - QFont &font, qreal &fontSize, QSvgHandler *handler) +static void parseFont(QSvgNode *node, + const QSvgAttributes &attributes, + QSvgHandler *handler) { QString family = attributes.value(QLatin1String("font-family")).toString(); QString size = attributes.value(QLatin1String("font-size")).toString(); QString style = attributes.value(QLatin1String("font-style")).toString(); QString weight = attributes.value(QLatin1String("font-weight")).toString(); + QString variant = attributes.value(QLatin1String("font-variant")).toString(); + QString anchor = attributes.value(QLatin1String("text-anchor")).toString(); - if (!family.isEmpty() || !size.isEmpty() || - !style.isEmpty() || !weight.isEmpty()) { + if (family.isEmpty() && size.isEmpty() && style.isEmpty() && weight.isEmpty() && variant.isEmpty() && anchor.isEmpty()) + return; - if (!family.isEmpty()) { - font.setFamily(family.trimmed()); - } - if (!size.isEmpty()) { - if (size == QLatin1String("inherit")) { - //inherited already - } else { - QSvgHandler::LengthType dummy; // should always be pixel size - fontSize = parseLength(size, dummy, handler); - if (fontSize <= 0) - fontSize = 1; - } - font.setPixelSize(qMax(1, int(fontSize))); - } - if (!style.isEmpty()) { - if (style == QLatin1String("normal")) { - font.setStyle(QFont::StyleNormal); - } else if (style == QLatin1String("italic")) { - font.setStyle(QFont::StyleItalic); - } else if (style == QLatin1String("oblique")) { - font.setStyle(QFont::StyleOblique); - } else if (style == QLatin1String("inherit")) { - //inherited already - } - } - if (!weight.isEmpty()) { - bool ok = false; - int weightNum = weight.toInt(&ok); - if (ok) { - switch (weightNum) { - case 100: - case 200: - font.setWeight(QFont::Light); - break; - case 300: - case 400: - font.setWeight(QFont::Normal); - break; - case 500: - case 600: - font.setWeight(QFont::DemiBold); - break; - case 700: - case 800: - font.setWeight(QFont::Bold); - break; - case 900: - font.setWeight(QFont::Black); - break; - default: - break; - } - } else { - if (weight == QLatin1String("normal")) { - font.setWeight(QFont::Normal); - } else if (weight == QLatin1String("bold")) { - font.setWeight(QFont::Bold); - } else if (weight == QLatin1String("bolder")) { - font.setWeight(QFont::DemiBold); - } else if (weight == QLatin1String("lighter")) { - font.setWeight(QFont::Light); - } - } - } - // QFontInfo fi(font); - // font.setPointSize(fi.pointSize()); - return true; + QString id = someId(attributes); + QSvgTinyDocument *doc = node->document(); + QSvgFontStyle *fontStyle = 0; + if (!family.isEmpty()) { + QSvgFont *svgFont = doc->svgFont(family); + if (svgFont) + fontStyle = new QSvgFontStyle(svgFont, doc); } + if (!fontStyle) + fontStyle = new QSvgFontStyle; - return false; -} + if (!family.isEmpty() && family != QT_INHERIT) + fontStyle->setFamily(family.trimmed()); -static void parseFont(QSvgNode *node, - const QSvgAttributes &attributes, - QSvgHandler *handler) -{ - QFont font; - font.setPixelSize(12); - qreal fontSize = font.pixelSize(); - - QSvgFontStyle *inherited = - static_cast(node->styleProperty( - QSvgStyleProperty::FONT)); - if (!inherited) - inherited = - static_cast(node->parent()->styleProperty( - QSvgStyleProperty::FONT)); - if (inherited) { - font = inherited->qfont(); - fontSize = inherited->pointSize(); - } - // group or any container element can have only text-anchor and should - // be processed, because its children can inherit from it. - // So checking for text-anchor before parseQfont() - QString anchor = attributes.value(QLatin1String("text-anchor")).toString(); - if (parseQFont(attributes, font, fontSize, handler) || (!anchor.isEmpty())) { - QString myId = someId(attributes); - //QString anchor = attributes.value(QLatin1String("text-anchor")).toString(); - QSvgTinyDocument *doc = node->document(); - QSvgFontStyle *fontStyle = 0; - QString family = (font.family().isEmpty())?myId:font.family(); - if (!family.isEmpty()) { - QSvgFont *svgFont = doc->svgFont(family); - if (svgFont) { - fontStyle = new QSvgFontStyle(svgFont, doc); - fontStyle->setPointSize(fontSize); - } + if (!size.isEmpty() && size != QT_INHERIT) { + QSvgHandler::LengthType dummy; // should always be pixel size + fontStyle->setSize(parseLength(size, dummy, handler)); + } + + if (!style.isEmpty() && style != QT_INHERIT) { + if (style == QLatin1String("normal")) { + fontStyle->setStyle(QFont::StyleNormal); + } else if (style == QLatin1String("italic")) { + fontStyle->setStyle(QFont::StyleItalic); + } else if (style == QLatin1String("oblique")) { + fontStyle->setStyle(QFont::StyleOblique); } - if (!fontStyle) { - fontStyle = new QSvgFontStyle(font, node->document()); - fontStyle->setPointSize(fontSize); + } + + if (!weight.isEmpty() && weight != QT_INHERIT) { + bool ok = false; + int weightNum = weight.toInt(&ok); + if (ok) { + fontStyle->setWeight(weightNum); + } else { + if (weight == QLatin1String("normal")) { + fontStyle->setWeight(400); + } else if (weight == QLatin1String("bold")) { + fontStyle->setWeight(700); + } else if (weight == QLatin1String("bolder")) { + fontStyle->setWeight(QSvgFontStyle::BOLDER); + } else if (weight == QLatin1String("lighter")) { + fontStyle->setWeight(QSvgFontStyle::LIGHTER); + } } - if (!anchor.isEmpty()) - fontStyle->setTextAnchor(anchor); + } - node->appendStyleProperty(fontStyle, myId); + if (!variant.isEmpty() && variant != QT_INHERIT) { + if (variant == QLatin1String("normal")) + fontStyle->setVariant(QFont::MixedCase); + else if (variant == QLatin1String("small-caps")) + fontStyle->setVariant(QFont::SmallCaps); + } + + if (!anchor.isEmpty() && anchor != QT_INHERIT) { + if (anchor == QLatin1String("start")) + fontStyle->setTextAnchor(Qt::AlignLeft); + if (anchor == QLatin1String("middle")) + fontStyle->setTextAnchor(Qt::AlignHCenter); + else if (anchor == QLatin1String("end")) + fontStyle->setTextAnchor(Qt::AlignRight); } + + node->appendStyleProperty(fontStyle, id); } static void parseTransform(QSvgNode *node, @@ -1343,7 +1090,7 @@ static void parseVisibility(QSvgNode *node, QString value = attributes.value(QLatin1String("visibility")).toString(); QSvgNode *parent = node->parent(); - if (parent && (value.isEmpty() || value == QLatin1String("inherit"))) + if (parent && (value.isEmpty() || value == QT_INHERIT)) node->setVisible(parent->isVisible()); else if (value == QLatin1String("hidden") || value == QLatin1String("collapse")) { node->setVisible(false); @@ -1954,105 +1701,6 @@ static void cssStyleLookup(QSvgNode *node, parseStyle(node, attributes, handler); } -static bool parseDefaultTextStyle(QSvgNode *node, - const QXmlStreamAttributes &attributes, - bool initial, - QSvgHandler *handler) -{ - Q_ASSERT(node->type() == QSvgText::TEXT || node->type() == QSvgNode::TEXTAREA); - QSvgText *textNode = static_cast(node); - - QSvgAttributes attrs(attributes, handler); - - QString fontFamily = attrs.value(QString(), QLatin1String("font-family")).toString(); - - QString anchor = attrs.value(QString(), QLatin1String("text-anchor")).toString(); - - QSvgFontStyle *fontStyle = static_cast( - node->styleProperty(QSvgStyleProperty::FONT)); - if (fontStyle) { - QSvgTinyDocument *doc = fontStyle->doc(); - if (doc && fontStyle->svgFont()) { - cssStyleLookup(node, handler, handler->selector()); - parseStyle(node, attrs, handler); - return true; - } - } else if (!fontFamily.isEmpty()) { - QSvgTinyDocument *doc = node->document(); - QSvgFont *svgFont = doc->svgFont(fontFamily); - if (svgFont) { - cssStyleLookup(node, handler, handler->selector()); - parseStyle(node, attrs, handler); - return true; - } - } - - QTextCharFormat format; - QBrush brush(QColor(0, 0, 0)); - QFont font; - font.setPixelSize(12); - qreal fontSize = font.pixelSize(); - - if (!initial) { - font = textNode->topFormat().font(); - fontSize = font.pixelSize() / textNode->scale(); - brush = textNode->topFormat().foreground(); - } else { - QSvgFontStyle *fontStyle = static_cast( - node->styleProperty(QSvgStyleProperty::FONT)); - if (!fontStyle) - fontStyle = static_cast( - node->parent()->styleProperty(QSvgStyleProperty::FONT)); - if (fontStyle) { - font = fontStyle->qfont(); - fontSize = fontStyle->pointSize(); - if (anchor.isEmpty() || anchor == QLatin1String("inherit")) - anchor = fontStyle->textAnchor(); - } - - Qt::Alignment align = Qt::AlignLeft; - if (anchor == QLatin1String("middle")) - align = Qt::AlignHCenter; - else if (anchor == QLatin1String("end")) - align = Qt::AlignRight; - textNode->setTextAlignment(align); - - QSvgFillStyle *fillStyle = static_cast( - node->styleProperty(QSvgStyleProperty::FILL)); - if (fillStyle) - brush = fillStyle->qbrush(); - } - - if (parseQFont(attrs, font, fontSize, handler) || initial) { - if (initial) - textNode->setScale(100 / fontSize); - font.setPixelSize(qMax(1, int(fontSize * textNode->scale()))); - format.setFont(font); - } - - if (parseQBrush(attrs, node, brush, handler) || initial) { - if (brush.style() != Qt::NoBrush || initial) - format.setForeground(brush); - } - - QPen pen(Qt::NoPen); -// QSvgStrokeStyle *inherited = -// static_cast(node->parent()->styleProperty( -// QSvgStyleProperty::STROKE)); -// if (inherited) -// pen = inherited->qpen(); - parseQPen(pen, node, attrs, handler); - if (pen.style() != Qt::NoPen) { - format.setTextOutline(pen); - } - - parseTransform(node, attrs, handler); - - textNode->insertFormat(format); - - return true; -} - static inline QStringList stringToList(const QString &str) { QStringList lst = str.split(QLatin1Char(','), QString::SkipEmptyParts); @@ -2211,7 +1859,7 @@ static inline QSvgNode::DisplayMode displayStringToEnum(const QString &str) return QSvgNode::TableCaptionMode; } else if (str == QLatin1String("none")) { return QSvgNode::NoneMode; - } else if (str == QLatin1String("inherit")) { + } else if (str == QT_INHERIT) { return QSvgNode::InheritMode; } return QSvgNode::BlockMode; @@ -3175,7 +2823,6 @@ static QSvgNode *createSvgNode(QSvgNode *parent, node->setHeight(int(height), type == QSvgHandler::LT_PERCENT); } - if (!viewBoxStr.isEmpty()) { QStringList lst = viewBoxStr.split(QLatin1Char(' '), QString::SkipEmptyParts); if (lst.count() != 4) @@ -3225,7 +2872,7 @@ static bool parseTbreakNode(QSvgNode *parent, { if (parent->type() != QSvgNode::TEXTAREA) return false; - static_cast(parent)->insertLineBreak(); + static_cast(parent)->addLineBreak(); return true; } @@ -3240,12 +2887,6 @@ static QSvgNode *createTextNode(QSvgNode *parent, qreal nx = parseLength(x, type, handler); qreal ny = parseLength(y, type, handler); - //### not to pixels but to the default coordinate system - // and text should be already in the correct coordinate - // system here - //nx = convertToPixels(nx, true, type); - //ny = convertToPixels(ny, true, type); - QSvgNode *text = new QSvgText(parent, QPointF(nx, ny)); return text; } @@ -3264,6 +2905,13 @@ static QSvgNode *createTextAreaNode(QSvgNode *parent, return node; } +static QSvgNode *createTspanNode(QSvgNode *parent, + const QXmlStreamAttributes &, + QSvgHandler *) +{ + return new QSvgTspan(parent); +} + static bool parseTitleNode(QSvgNode *parent, const QXmlStreamAttributes &attributes, QSvgHandler *) @@ -3272,15 +2920,6 @@ static bool parseTitleNode(QSvgNode *parent, return true; } -static bool parseTspanNode(QSvgNode *parent, - const QXmlStreamAttributes &attributes, - QSvgHandler *handler) -{ - - cssStyleLookup(parent, handler, handler->selector()); - return parseDefaultTextStyle(parent, attributes, false, handler); -} - static QSvgNode *createUseNode(QSvgNode *parent, const QXmlStreamAttributes &attributes, QSvgHandler *handler) @@ -3394,6 +3033,7 @@ static FactoryMethod findGraphicsFactory(const QString &name) case 't': if (ref == QLatin1String("ext")) return createTextNode; if (ref == QLatin1String("extArea")) return createTextAreaNode; + if (ref == QLatin1String("span")) return createTspanNode; break; case 'u': if (ref == QLatin1String("se")) return createUseNode; @@ -3450,7 +3090,6 @@ static ParseMethod findUtilFactory(const QString &name) case 't': if (ref == QLatin1String("break")) return parseTbreakNode; if (ref == QLatin1String("itle")) return parseTitleNode; - if (ref == QLatin1String("span")) return parseTspanNode; break; default: break; @@ -3659,16 +3298,33 @@ bool QSvgHandler::startElement(const QString &localName, group->addChild(node, someId(attributes)); } break; + case QSvgNode::TEXT: + case QSvgNode::TEXTAREA: + if (node->type() == QSvgNode::TSPAN) { + static_cast(m_nodes.top())->addTspan(static_cast(node)); + } else { + qWarning("\'text\' or \'textArea\' element contains invalid element type."); + delete node; + node = 0; + } + break; default: - Q_ASSERT(!"not a grouping element is the parent"); + qWarning("Could not add child element to parent element because the types are incorrect."); + delete node; + node = 0; + break; } - parseCoreNode(node, attributes); - cssStyleLookup(node, this, m_selector); - if (node->type() != QSvgNode::TEXT && node->type() != QSvgNode::TEXTAREA) + if (node) { + parseCoreNode(node, attributes); + cssStyleLookup(node, this, m_selector); parseStyle(node, attributes, this); - else - parseDefaultTextStyle(node, attributes, true, this); + if (node->type() == QSvgNode::TEXT || node->type() == QSvgNode::TEXTAREA) { + static_cast(node)->setWhitespaceMode(m_whitespaceMode.top()); + } else if (node->type() == QSvgNode::TSPAN) { + static_cast(node)->setWhitespaceMode(m_whitespaceMode.top()); + } + } } } else if (ParseMethod method = findUtilFactory(localName)) { Q_ASSERT(!m_nodes.isEmpty()); @@ -3725,13 +3381,8 @@ bool QSvgHandler::endElement(const QStringRef &localName) return true; } - if (m_inStyle && localName == QLatin1String("style")) { + if (m_inStyle && localName == QLatin1String("style")) m_inStyle = false; - } else if (m_nodes.top()->type() == QSvgNode::TEXT || m_nodes.top()->type() == QSvgNode::TEXTAREA) { - QSvgText *node = static_cast(m_nodes.top()); - if (localName == QLatin1String("tspan")) - node->popFormat(); - } if (node == Graphics) { // Iterate through the m_renderers to resolve any unresolved gradients. @@ -3779,8 +3430,9 @@ bool QSvgHandler::characters(const QStringRef &str) return true; if (m_nodes.top()->type() == QSvgNode::TEXT || m_nodes.top()->type() == QSvgNode::TEXTAREA) { - QSvgText *node = static_cast(m_nodes.top()); - node->insertText(str.toString(), m_whitespaceMode.top()); + static_cast(m_nodes.top())->addText(str.toString()); + } else if (m_nodes.top()->type() == QSvgNode::TSPAN) { + static_cast(m_nodes.top())->addText(str.toString()); } return true; diff --git a/src/svg/qsvgnode_p.h b/src/svg/qsvgnode_p.h index f203ea7..315f228 100644 --- a/src/svg/qsvgnode_p.h +++ b/src/svg/qsvgnode_p.h @@ -86,6 +86,7 @@ public: RECT, TEXT, TEXTAREA, + TSPAN, USE, VIDEO }; diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index c3c0a68..3682f47 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -59,6 +59,9 @@ QT_BEGIN_NAMESPACE QSvgExtraStates::QSvgExtraStates() : fillOpacity(1.0) + , svgFont(0) + , textAnchor(Qt::AlignLeft) + , fontWeight(400) { } @@ -191,39 +194,94 @@ void QSvgViewportFillStyle::revert(QPainter *p, QSvgExtraStates &) } QSvgFontStyle::QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc) - : m_font(font), m_pointSize(24), m_doc(doc) -{ -} - -QSvgFontStyle::QSvgFontStyle(const QFont &font, QSvgTinyDocument *doc) - : m_font(0), m_pointSize(24), m_doc(doc), m_qfont(font) -{ -} - - -void QSvgFontStyle::setPointSize(qreal size) -{ - m_pointSize = size; -} - -qreal QSvgFontStyle::pointSize() const -{ - return m_pointSize; -} - -void QSvgFontStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &) -{ - if (!m_font) { - m_oldFont = p->font(); - p->setFont(m_qfont); + : m_svgFont(font) + , m_doc(doc) + , m_familySet(0) + , m_sizeSet(0) + , m_styleSet(0) + , m_variantSet(0) + , m_weightSet(0) + , m_textAnchorSet(0) +{ +} + +QSvgFontStyle::QSvgFontStyle() + : m_doc(0) + , m_svgFont(0) + , m_familySet(0) + , m_sizeSet(0) + , m_styleSet(0) + , m_variantSet(0) + , m_weightSet(0) + , m_textAnchorSet(0) +{ +} + +int QSvgFontStyle::SVGToQtWeight(int weight) { + switch (weight) { + case 100: + case 200: + return QFont::Light; + case 300: + case 400: + return QFont::Normal; + case 500: + case 600: + return QFont::DemiBold; + case 700: + case 800: + return QFont::Bold; + case 900: + return QFont::Black; + } + return QFont::Normal; +} + +void QSvgFontStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &states) +{ + m_oldQFont = p->font(); + m_oldSvgFont = states.svgFont; + m_oldTextAnchor = states.textAnchor; + m_oldWeight = states.fontWeight; + + if (m_textAnchorSet) + states.textAnchor = m_textAnchor; + + QFont font = m_oldQFont; + if (m_familySet) { + states.svgFont = m_svgFont; + font.setFamily(m_qfont.family()); + } + + if (m_sizeSet) + font.setPointSize(m_qfont.pointSizeF()); + + if (m_styleSet) + font.setStyle(m_qfont.style()); + + if (m_variantSet) + font.setCapitalization(m_qfont.capitalization()); + + if (m_weightSet) { + if (m_weight == BOLDER) { + states.fontWeight = qMin(states.fontWeight + 100, 900); + } else if (m_weight == LIGHTER) { + states.fontWeight = qMax(states.fontWeight - 100, 100); + } else { + states.fontWeight = m_weight; + } + font.setWeight(SVGToQtWeight(states.fontWeight)); } + + p->setFont(font); } -void QSvgFontStyle::revert(QPainter *p, QSvgExtraStates &) +void QSvgFontStyle::revert(QPainter *p, QSvgExtraStates &states) { - if (!m_font) { - p->setFont(m_oldFont); - } + p->setFont(m_oldQFont); + states.svgFont = m_oldSvgFont; + states.textAnchor = m_oldTextAnchor; + states.fontWeight = m_oldWeight; } QSvgStrokeStyle::QSvgStrokeStyle(const QPen &pen) @@ -799,16 +857,6 @@ QSvgStyleProperty::Type QSvgAnimateColor::type() const return ANIMATE_COLOR; } -QString QSvgFontStyle::textAnchor() const -{ - return m_textAnchor; -} - -void QSvgFontStyle::setTextAnchor(const QString &anchor) -{ - m_textAnchor = anchor; -} - QSvgOpacityStyle::QSvgOpacityStyle(qreal opacity) : m_opacity(opacity) { diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h index 70ecf5b..bd28bb6 100644 --- a/src/svg/qsvgstyle_p.h +++ b/src/svg/qsvgstyle_p.h @@ -141,7 +141,11 @@ private: struct QSvgExtraStates { QSvgExtraStates(); + qreal fillOpacity; + QSvgFont *svgFont; + Qt::Alignment textAnchor; + int fontWeight; }; class QSvgStyleProperty : public QSvgRefCounted @@ -307,41 +311,85 @@ private: class QSvgFontStyle : public QSvgStyleProperty { public: + static const int LIGHTER = -1; + static const int BOLDER = 1; + QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc); - QSvgFontStyle(const QFont &font, QSvgTinyDocument *doc); + QSvgFontStyle(); virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states); virtual void revert(QPainter *p, QSvgExtraStates &states); virtual Type type() const; - void setPointSize(qreal size); - qreal pointSize() const; + void setSize(qreal size) + { + // Store the _pixel_ size in the font. Since QFont::setPixelSize() only takes an int, call + // QFont::SetPointSize() instead. Set proper font size just before rendering. + m_qfont.setPointSize(size); + m_sizeSet = 1; + } - //### hack to avoid having a separate style element for text-anchor - QString textAnchor() const; - void setTextAnchor(const QString &anchor); + void setTextAnchor(Qt::Alignment anchor) + { + m_textAnchor = anchor; + m_textAnchorSet = 1; + } - QSvgFont * svgFont() const + void setFamily(const QString &family) { - return m_font; + m_qfont.setFamily(family); + m_familySet = 1; + } + + void setStyle(QFont::Style fontStyle) { + m_qfont.setStyle(fontStyle); + m_styleSet = 1; } - QSvgTinyDocument *doc() const + + void setVariant(QFont::Capitalization fontVariant) { - return m_doc; + m_qfont.setCapitalization(fontVariant); + m_variantSet = 1; } - const QFont & qfont() const + static int SVGToQtWeight(int weight); + + void setWeight(int weight) + { + m_weight = weight; + m_weightSet = 1; + } + + QSvgFont * svgFont() const + { + return m_svgFont; + } + + const QFont &qfont() const { return m_qfont; } + + QSvgTinyDocument *doc() const {return m_doc;} + private: - QSvgFont *m_font; - qreal m_pointSize; + QSvgFont *m_svgFont; QSvgTinyDocument *m_doc; + QFont m_qfont; - QString m_textAnchor; + int m_weight; + Qt::Alignment m_textAnchor; - QFont m_qfont; - QFont m_oldFont; + QSvgFont *m_oldSvgFont; + QFont m_oldQFont; + Qt::Alignment m_oldTextAnchor; + int m_oldWeight; + + unsigned m_familySet : 1; + unsigned m_sizeSet : 1; + unsigned m_styleSet : 1; + unsigned m_variantSet : 1; + unsigned m_weightSet : 1; + unsigned m_textAnchorSet : 1; }; class QSvgStrokeStyle : public QSvgStyleProperty diff --git a/tests/arthur/data/1.2/textArea01.svg b/tests/arthur/data/1.2/textArea01.svg index 79fcd0a..945c34c 100644 --- a/tests/arthur/data/1.2/textArea01.svg +++ b/tests/arthur/data/1.2/textArea01.svg @@ -6,5 +6,5 @@ height="300">Tomorrow, and tomorrow, and tomorrow; creeps in this petty pace from day to day, until the last syll­able of recorded time. And all our yesterdays have lighted fools the way to dusty death. - + -- cgit v0.12 From 20b6e316285efc8d8d46fee2dec13364187a64a9 Mon Sep 17 00:00:00 2001 From: kh Date: Thu, 30 Jul 2009 15:52:34 +0200 Subject: Fix autotests after QUrl change. Reviewed-by: kh --- tests/auto/auto.pro | 4 +-- tests/auto/qhelpenginecore/data/collection.qhc | Bin 10240 -> 10240 bytes tests/auto/qhelpenginecore/data/collection1.qhc | Bin 10240 -> 10240 bytes tests/auto/qhelpenginecore/data/linguist-3.3.8.qch | Bin 131072 -> 131072 bytes tests/auto/qhelpenginecore/data/qmake-3.3.8.qch | Bin 61440 -> 61440 bytes tests/auto/qhelpenginecore/data/qmake-4.3.0.qch | Bin 93184 -> 93184 bytes tests/auto/qhelpenginecore/data/test.qch | Bin 22528 -> 22528 bytes tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp | 40 ++++++++++----------- tests/auto/qhelpindexmodel/data/collection.qhc | Bin 10240 -> 10240 bytes tests/auto/qhelpindexmodel/data/collection1.qhc | Bin 10240 -> 10240 bytes tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch | Bin 131072 -> 131072 bytes tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch | Bin 61440 -> 61440 bytes tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch | Bin 93184 -> 93184 bytes tests/auto/qhelpindexmodel/data/test.qch | Bin 22528 -> 22528 bytes tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp | 6 ++-- 15 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 6f10922..b4a6600 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -159,9 +159,9 @@ SUBDIRS += _networkselftest \ qhash \ qheaderview \ qhelpcontentmodel \ -# qhelpenginecore \ + qhelpenginecore \ qhelpgenerator \ -# qhelpindexmodel \ + qhelpindexmodel \ qhelpprojectdata \ qhostaddress \ qhostinfo \ diff --git a/tests/auto/qhelpenginecore/data/collection.qhc b/tests/auto/qhelpenginecore/data/collection.qhc index 6fb8abb..bd2f37c 100644 Binary files a/tests/auto/qhelpenginecore/data/collection.qhc and b/tests/auto/qhelpenginecore/data/collection.qhc differ diff --git a/tests/auto/qhelpenginecore/data/collection1.qhc b/tests/auto/qhelpenginecore/data/collection1.qhc index 45acf33..de310ea 100644 Binary files a/tests/auto/qhelpenginecore/data/collection1.qhc and b/tests/auto/qhelpenginecore/data/collection1.qhc differ diff --git a/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch b/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch index 0b53cd8..ed9a89c 100644 Binary files a/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch and b/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch differ diff --git a/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch b/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch index a3ca18a..0e95c14 100644 Binary files a/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch and b/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch differ diff --git a/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch b/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch index 8f76134..337d7a1 100644 Binary files a/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch and b/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch differ diff --git a/tests/auto/qhelpenginecore/data/test.qch b/tests/auto/qhelpenginecore/data/test.qch index 8a8f7a1..06b789a 100644 Binary files a/tests/auto/qhelpenginecore/data/test.qch and b/tests/auto/qhelpenginecore/data/test.qch differ diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp index d62c8e5..f9aa653 100644 --- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp +++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp @@ -130,7 +130,7 @@ void tst_QHelpEngineCore::setCollectionFile() QStringList docs = help.registeredDocumentations(); QCOMPARE(docs.count(), 1); - QCOMPARE(docs.first(), QLatin1String("trolltech.com.1_0_0.test")); + QCOMPARE(docs.first(), QLatin1String("trolltech.com.1-0-0.test")); } void tst_QHelpEngineCore::copyCollectionFile() @@ -177,7 +177,7 @@ void tst_QHelpEngineCore::copyCollectionFile() i = 0; while (m_query->next()) { if (i == 0) { - QCOMPARE(m_query->value(0).toString(), QString("trolltech.com.3_3_8.qmake")); + QCOMPARE(m_query->value(0).toString(), QString("trolltech.com.3-3-8.qmake")); QCOMPARE(m_query->value(1).toString(), QString("data/qmake-3.3.8.qch")); } ++i; @@ -193,9 +193,9 @@ void tst_QHelpEngineCore::copyCollectionFile() void tst_QHelpEngineCore::namespaceName() { QCOMPARE(QHelpEngineCore::namespaceName(m_path + "/data/qmake-3.3.8.qch"), - QString("trolltech.com.3_3_8.qmake")); + QString("trolltech.com.3-3-8.qmake")); QCOMPARE(QHelpEngineCore::namespaceName(m_path + "/data/linguist-3.3.8.qch"), - QString("trolltech.com.3_3_8.linguist")); + QString("trolltech.com.3-3-8.linguist")); } void tst_QHelpEngineCore::registeredDocumentations() @@ -205,8 +205,8 @@ void tst_QHelpEngineCore::registeredDocumentations() QStringList docs = help.registeredDocumentations(); QCOMPARE(docs.count(), 3); QStringList lst; - lst << "trolltech.com.3_3_8.qmake" << "trolltech.com.4_3_0.qmake" - << "trolltech.com.1_0_0.test"; + lst << "trolltech.com.3-3-8.qmake" << "trolltech.com.4-3-0.qmake" + << "trolltech.com.1-0-0.test"; foreach (QString s, docs) lst.removeAll(s); QCOMPARE(lst.isEmpty(), true); @@ -236,7 +236,7 @@ void tst_QHelpEngineCore::registerDocumentation() } QSqlQuery query(db); query.exec("SELECT FilePath FROM NamespaceTable WHERE " - "Name=\'trolltech.com.3_3_8.linguist\'"); + "Name=\'trolltech.com.3-3-8.linguist\'"); if (query.next()) QCOMPARE(query.value(0).toString(), QString("linguist-3.3.8.qch")); @@ -251,7 +251,7 @@ void tst_QHelpEngineCore::unregisterDocumentation() QHelpEngineCore c(m_colFile); QCOMPARE(c.setupData(), true); QCOMPARE(c.registeredDocumentations().count(), 3); - c.unregisterDocumentation("trolltech.com.3_3_8.qmake"); + c.unregisterDocumentation("trolltech.com.3-3-8.qmake"); QCOMPARE(c.registeredDocumentations().count(), 2); QCOMPARE(c.unregisterDocumentation("noexisting"), false); } @@ -260,9 +260,9 @@ void tst_QHelpEngineCore::documentationFileName() { QHelpEngineCore c(m_colFile); QCOMPARE(c.setupData(), true); - QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.3_3_8.qmake")), + QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.3-3-8.qmake")), QString(m_path + "/data/qmake-3.3.8.qch")); - QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.1_0_0.test")), + QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.1-0-0.test")), QString(m_path + "/data/test.qch")); QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.empty")), QString()); @@ -337,7 +337,7 @@ void tst_QHelpEngineCore::filterAttributeSets() { QHelpEngineCore help(m_colFile, 0); QCOMPARE(help.setupData(), true); - QList lst = help.filterAttributeSets("trolltech.com.1_0_0.test"); + QList lst = help.filterAttributeSets("trolltech.com.1-0-0.test"); QCOMPARE(lst.count(), 2); QCOMPARE(lst.first().count(), 2); QCOMPARE((bool)lst.first().contains("filter1"), true); @@ -348,22 +348,22 @@ void tst_QHelpEngineCore::files() { QHelpEngineCore help(m_colFile, 0); QCOMPARE(help.setupData(), true); - QList lst = help.files("trolltech.com.4_3_0.qmake", + QList lst = help.files("trolltech.com.4-3-0.qmake", QStringList()); QCOMPARE(lst.count(), 16); - lst = help.files("trolltech.com.4_3_0.qmake", + lst = help.files("trolltech.com.4-3-0.qmake", QStringList(), "png"); QCOMPARE(lst.count(), 2); - lst = help.files("trolltech.com.4_3_0.qmake", + lst = help.files("trolltech.com.4-3-0.qmake", QStringList() << "qt", "html"); QCOMPARE(lst.count(), 13); - lst = help.files("trolltech.com.4_3_0.qmake", + lst = help.files("trolltech.com.4-3-0.qmake", QStringList() << "qt" << "qmake", "html"); QCOMPARE(lst.count(), 13); - lst = help.files("trolltech.com.4_3_0.qmake", + lst = help.files("trolltech.com.4-3-0.qmake", QStringList() << "qt" << "qmake" << "bla", "html"); QCOMPARE(lst.count(), 0); - lst = help.files("trolltech.com.4_3_0.qmake", + lst = help.files("trolltech.com.4-3-0.qmake", QStringList() << "qt" << "qmake", "foo"); QCOMPARE(lst.count(), 0); @@ -378,7 +378,7 @@ void tst_QHelpEngineCore::fileData() QCOMPARE(help.setupData(), true); QByteArray ba = help.fileData(QUrl("NotExisting")); QCOMPARE(ba.size(), 0); - ba = help.fileData(QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html")); + ba = help.fileData(QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html")); QTextStream s(ba, QIODevice::ReadOnly|QIODevice::Text); QFile f(m_path + "/data/test.html"); if (!f.open(QIODevice::ReadOnly|QIODevice::Text)) @@ -396,7 +396,7 @@ void tst_QHelpEngineCore::linksForIdentifier() QCOMPARE(map.contains("Test Manual"), true); QCOMPARE(map.count(), 1); QCOMPARE(map.value("Test Manual"), - QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo")); + QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo")); help.setCurrentFilter("Custom Filter 2"); map = help.linksForIdentifier("People::newton"); @@ -405,7 +405,7 @@ void tst_QHelpEngineCore::linksForIdentifier() QCOMPARE(map.contains("Fancy"), true); QCOMPARE(map.count(), 1); QCOMPARE(map.value("Fancy"), - QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/fancy.html#foobar")); + QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/fancy.html#foobar")); } void tst_QHelpEngineCore::customValue() diff --git a/tests/auto/qhelpindexmodel/data/collection.qhc b/tests/auto/qhelpindexmodel/data/collection.qhc index 6fb8abb..bd2f37c 100644 Binary files a/tests/auto/qhelpindexmodel/data/collection.qhc and b/tests/auto/qhelpindexmodel/data/collection.qhc differ diff --git a/tests/auto/qhelpindexmodel/data/collection1.qhc b/tests/auto/qhelpindexmodel/data/collection1.qhc index 45acf33..de310ea 100644 Binary files a/tests/auto/qhelpindexmodel/data/collection1.qhc and b/tests/auto/qhelpindexmodel/data/collection1.qhc differ diff --git a/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch b/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch index 0b53cd8..ed9a89c 100644 Binary files a/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch and b/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch differ diff --git a/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch b/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch index a3ca18a..0e95c14 100644 Binary files a/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch and b/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch differ diff --git a/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch b/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch index 8f76134..337d7a1 100644 Binary files a/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch and b/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch differ diff --git a/tests/auto/qhelpindexmodel/data/test.qch b/tests/auto/qhelpindexmodel/data/test.qch index 1d6c1a8..4ea9847 100644 Binary files a/tests/auto/qhelpindexmodel/data/test.qch and b/tests/auto/qhelpindexmodel/data/test.qch differ diff --git a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp index 9482def..3adb894 100644 --- a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp +++ b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp @@ -185,11 +185,11 @@ void tst_QHelpIndexModel::linksForIndex() QCOMPARE(map.count(), 2); QCOMPARE(map.contains("Test Manual"), true); QCOMPARE(map.value("Test Manual"), - QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo")); + QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo")); QCOMPARE(map.contains("Fancy"), true); QCOMPARE(map.value("Fancy"), - QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/fancy.html#foo")); + QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/fancy.html#foo")); map = m->linksForKeyword("foobar"); QCOMPARE(map.count(), 1); @@ -208,7 +208,7 @@ void tst_QHelpIndexModel::linksForIndex() QCOMPARE(map.count(), 1); QCOMPARE(map.contains("Test Manual"), true); QCOMPARE(map.value("Test Manual"), - QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo")); + QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo")); } QTEST_MAIN(tst_QHelpIndexModel) -- cgit v0.12 From 5e966d96419fb68ac1f9528e72f1083b32eecdbb Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 30 Jul 2009 15:44:57 +0200 Subject: Gestures: fixed install event filter bug made sure that we set the filter on the correct widget RevBy: denis --- src/gui/kernel/qgesture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index d53b419..1f98013 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -153,7 +153,7 @@ QGesture::QGesture(QObject *parent) : QObject(*new QGesturePrivate, parent) { if (parent) - installEventFilter(parent); + parent->installEventFilter(this); } /*! \internal @@ -162,7 +162,7 @@ QGesture::QGesture(QGesturePrivate &dd, QObject *parent) : QObject(dd, parent) { if (parent) - installEventFilter(parent); + parent->installEventFilter(this); } /*! -- cgit v0.12 From 3ae2cab9c8bd1790a00da2755ac036143a3a35f4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 30 Jul 2009 16:40:06 +0200 Subject: Fix compilation with xlC 7: operands to ?: must match. "../shared/qm.cpp", line 556.45: 1540-0207 (S) No common type found for operands with type "const char [7]" and "QByteArray". Reviewed-by: Trust Me --- tools/linguist/shared/qm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index 638e997..dc681f5 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -553,7 +553,7 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) //qDebug() << "NUMITEMS: " << numItems; QTextCodec *codec = QTextCodec::codecForName( - cd.m_codecForSource.isEmpty() ? "Latin1" : cd.m_codecForSource); + cd.m_codecForSource.isEmpty() ? QByteArray("Latin1") : cd.m_codecForSource); QTextCodec *utf8Codec = 0; if (codec->name() != "UTF-8") utf8Codec = QTextCodec::codecForName("UTF-8"); -- cgit v0.12 From 2ebebeebd3dacc7192f2f998d324d16bc8cba9fa Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 30 Jul 2009 12:21:22 +0200 Subject: fix infinite loop when meeting improper trId() --- tools/linguist/lupdate/cpp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 58e094b..21b230e 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -1676,7 +1676,9 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) case Tok_trid: if (!results->tor) goto case_default; - if (!sourcetext.isEmpty()) { + if (sourcetext.isEmpty()) { + yyTok = getToken(); + } else { if (!msgid.isEmpty()) qWarning("%s:%d: //= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n", qPrintable(yyFileName), yyLineNo); -- cgit v0.12 From 4c3cc938ed17e9b98bbdfc9a7e4c5a5b7efd4a3b Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Thu, 30 Jul 2009 16:59:02 +0200 Subject: Do not emit activated and close the popup when the item is not enabled. Autotest: included Merge-request: 378 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/util/qcompleter.cpp | 6 +++++- tests/auto/qcompleter/tst_qcompleter.cpp | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index bf1fa6a..a0a3756 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -824,6 +824,9 @@ void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted) Q_Q(QCompleter); QString completion; + if (!(index.flags() & Qt::ItemIsEnabled)) + return; + if (!index.isValid() || (!proxy->showAll && (index.row() >= proxy->engine->matchCount()))) { completion = prefix; } else { @@ -1102,7 +1105,8 @@ void QCompleter::setPopup(QAbstractItemView *popup) QObject::connect(popup, SIGNAL(clicked(QModelIndex)), this, SLOT(_q_complete(QModelIndex))); - QObject::connect(popup, SIGNAL(clicked(QModelIndex)), popup, SLOT(hide())); + QObject::connect(this, SIGNAL(activated(QModelIndex)), + popup, SLOT(hide())); QObject::connect(popup->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(_q_completionSelected(QItemSelection))); diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 0a9c16a..a65490d 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -138,6 +138,7 @@ private slots: void setters(); void dynamicSortOrder(); + void disabledItems(); // task-specific tests below me void task178797_activatedOnReturn(); @@ -147,7 +148,6 @@ private slots: void task253125_lineEditCompletion_data(); void task253125_lineEditCompletion(); - void task247560_keyboardNavigation(); private: @@ -1106,6 +1106,31 @@ void tst_QCompleter::dynamicSortOrder() QCOMPARE(completer.completionCount(), 12); } +void tst_QCompleter::disabledItems() +{ + QLineEdit lineEdit; + QStandardItemModel *model = new QStandardItemModel(&lineEdit); + QStandardItem *suggestions = new QStandardItem("suggestions"); + suggestions->setEnabled(false); + model->appendRow(suggestions); + model->appendRow(new QStandardItem("suggestions Enabled")); + QCompleter *completer = new QCompleter(model, &lineEdit); + QSignalSpy spy(completer, SIGNAL(activated(const QString &))); + lineEdit.setCompleter(completer); + lineEdit.show(); + + QTest::keyPress(&lineEdit, Qt::Key_S); + QTest::keyPress(&lineEdit, Qt::Key_U); + QAbstractItemView *view = lineEdit.completer()->popup(); + QVERIFY(view->isVisible()); + QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->visualRect(view->model()->index(0, 0)).center()); + QCOMPARE(spy.count(), 0); + QVERIFY(view->isVisible()); + QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->visualRect(view->model()->index(1, 0)).center()); + QCOMPARE(spy.count(), 1); + QVERIFY(!view->isVisible()); +} + void tst_QCompleter::task178797_activatedOnReturn() { QStringList words; -- cgit v0.12 From 85d90102acca3202c410b7af311f52e5d67dc716 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 30 Jul 2009 16:06:06 +0200 Subject: Autotest: fix crash caused by deleting a QSharedPointer The delete reply; was introduced by a conflicted merge in the VxWorks port. It should not have appeared. But take this opportunity to convert the two other uses of QNetworkReply* without lifetime management to QSharedPointer too. Reviewed-by: Markus Goetz --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 03b1474..adb9b54 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -513,10 +513,10 @@ public: QTcpSocket *active = new QTcpSocket(this); active->connectToHost("127.0.0.1", server.serverPort()); - if (!active->waitForConnected(10)) + if (!active->waitForConnected(100)) return false; - if (!server.waitForNewConnection(10)) + if (!server.waitForNewConnection(100)) return false; QTcpSocket *passive = server.nextPendingConnection(); passive->setParent(this); @@ -2642,8 +2642,6 @@ void tst_QNetworkReply::ioPutToFileFromProcess() QCOMPARE(file.size(), qint64(data.size())); QByteArray contents = file.readAll(); QCOMPARE(contents, data); - - delete reply; #endif } @@ -3827,7 +3825,7 @@ void tst_QNetworkReply::httpDownloadPerformance() HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); - QNetworkReply* reply = manager.get(request); + QNetworkReplyPtr reply = manager.get(request); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); HttpDownloadPerformanceClient client(reply); @@ -3840,8 +3838,6 @@ void tst_QNetworkReply::httpDownloadPerformance() qint64 elapsed = time.elapsed(); qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, " << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; - - delete reply; } #ifndef QT_NO_OPENSSL @@ -3872,7 +3868,7 @@ void tst_QNetworkReply::ignoreSslErrorsList() { QFETCH(QString, url); QNetworkRequest request(url); - QNetworkReply *reply = manager.get(request); + QNetworkReplyPtr reply = manager.get(request); QFETCH(QList, expectedSslErrors); reply->ignoreSslErrors(expectedSslErrors); @@ -3901,7 +3897,7 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot() { QFETCH(QString, url); QNetworkRequest request(url); - QNetworkReply *reply = manager.get(request); + QNetworkReplyPtr reply = manager.get(request); QFETCH(QList, expectedSslErrors); // store the errors to ignore them later in the slot connected below -- cgit v0.12 From 5d9f735289a787fd9ef4d7921374382424f880d7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 30 Jul 2009 16:23:52 +0200 Subject: Autotest: reorganise the HTTP performance tests --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 249 ++++++++++++------------- 1 file changed, 124 insertions(+), 125 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index adb9b54..4ebc316 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -223,8 +223,10 @@ private Q_SLOTS: void rateControl(); void downloadPerformance(); void uploadPerformance(); - void httpUploadPerformance(); void performanceControlRate(); + void httpUploadPerformance(); + void httpDownloadPerformance_data(); + void httpDownloadPerformance(); void downloadProgress_data(); void downloadProgress(); @@ -248,8 +250,6 @@ private Q_SLOTS: void authorizationError(); void httpConnectionCount(); - void httpDownloadPerformance_data(); - void httpDownloadPerformance(); #ifndef QT_NO_OPENSSL void ignoreSslErrorsList_data(); @@ -836,6 +836,92 @@ protected: } }; +class HttpDownloadPerformanceClient : QObject { + Q_OBJECT; + QIODevice *device; + public: + HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){ + connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); + } + + public slots: + void readyReadSlot() { + device->readAll(); + } + +}; + +class HttpDownloadPerformanceServer : QObject { + Q_OBJECT; + qint64 dataSize; + qint64 dataSent; + QTcpServer server; + QTcpSocket *client; + bool serverSendsContentLength; + bool chunkedEncoding; + +public: + HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0), + client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) { + server.listen(); + connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); + } + + int serverPort() { + return server.serverPort(); + } + +public slots: + + void newConnectionSlot() { + client = server.nextPendingConnection(); + client->setParent(this); + connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); + connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64))); + } + + void readyReadSlot() { + client->readAll(); + client->write("HTTP/1.0 200 OK\n"); + if (serverSendsContentLength) + client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii()); + if (chunkedEncoding) + client->write(QString("Transfer-Encoding: chunked\n").toAscii()); + client->write("Connection: close\n\n"); + } + + void bytesWrittenSlot(qint64 amount) { + Q_UNUSED(amount); + if (dataSent == dataSize && client) { + // close eventually + + // chunked encoding: we have to send a last "empty" chunk + if (chunkedEncoding) + client->write(QString("0\r\n\r\n").toAscii()); + + client->disconnectFromHost(); + server.close(); + client = 0; + return; + } + + // send data + if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) { + qint64 amount = qMin(qint64(16*1024), dataSize - dataSent); + QByteArray data(amount, '@'); + + if (chunkedEncoding) { + client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii()); + client->write(data.constData(), amount); + client->write(QString("\r\n").toAscii()); + } else { + client->write(data.constData(), amount); + } + + dataSent += amount; + } + } +}; tst_QNetworkReply::tst_QNetworkReply() @@ -3231,6 +3317,41 @@ void tst_QNetworkReply::performanceControlRate() << elapsedTime << "ms"; } +void tst_QNetworkReply::httpDownloadPerformance_data() +{ + QTest::addColumn("serverSendsContentLength"); + QTest::addColumn("chunkedEncoding"); + + QTest::newRow("Server sends no Content-Length") << false << false; + QTest::newRow("Server sends Content-Length") << true << false; + QTest::newRow("Server uses chunked encoding") << false << true; + +} + +void tst_QNetworkReply::httpDownloadPerformance() +{ + QFETCH(bool, serverSendsContentLength); + QFETCH(bool, chunkedEncoding); + + enum {UploadSize = 1000*1024*1024}; // 1000 MB + HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); + + QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + HttpDownloadPerformanceClient client(reply); + + QTime time; + time.start(); + QTestEventLoop::instance().enterLoop(40); + QVERIFY(!QTestEventLoop::instance().timeout()); + + qint64 elapsed = time.elapsed(); + qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, " + << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; +} + void tst_QNetworkReply::downloadProgress_data() { QTest::addColumn("loopCount"); @@ -3718,128 +3839,6 @@ void tst_QNetworkReply::httpConnectionCount() QCOMPARE(pendingConnectionCount, 6); } -class HttpDownloadPerformanceClient : QObject { - Q_OBJECT; - QIODevice *device; - public: - HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){ - connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - } - - public slots: - void readyReadSlot() { - device->readAll(); - } - -}; - -class HttpDownloadPerformanceServer : QObject { - Q_OBJECT; - qint64 dataSize; - qint64 dataSent; - QTcpServer server; - QTcpSocket *client; - bool serverSendsContentLength; - bool chunkedEncoding; - -public: - HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0), - client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) { - server.listen(); - connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); - } - - int serverPort() { - return server.serverPort(); - } - -public slots: - - void newConnectionSlot() { - client = server.nextPendingConnection(); - client->setParent(this); - connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64))); - } - - void readyReadSlot() { - client->readAll(); - client->write("HTTP/1.0 200 OK\n"); - if (serverSendsContentLength) - client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii()); - if (chunkedEncoding) - client->write(QString("Transfer-Encoding: chunked\n").toAscii()); - client->write("Connection: close\n\n"); - } - - void bytesWrittenSlot(qint64 amount) { - Q_UNUSED(amount); - if (dataSent == dataSize && client) { - // close eventually - - // chunked encoding: we have to send a last "empty" chunk - if (chunkedEncoding) - client->write(QString("0\r\n\r\n").toAscii()); - - client->disconnectFromHost(); - server.close(); - client = 0; - return; - } - - // send data - if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) { - qint64 amount = qMin(qint64(16*1024), dataSize - dataSent); - QByteArray data(amount, '@'); - - if (chunkedEncoding) { - client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii()); - client->write(data.constData(), amount); - client->write(QString("\r\n").toAscii()); - } else { - client->write(data.constData(), amount); - } - - dataSent += amount; - } - } -}; - -void tst_QNetworkReply::httpDownloadPerformance_data() -{ - QTest::addColumn("serverSendsContentLength"); - QTest::addColumn("chunkedEncoding"); - - QTest::newRow("Server sends no Content-Length") << false << false; - QTest::newRow("Server sends Content-Length") << true << false; - QTest::newRow("Server uses chunked encoding") << false << true; - -} - -void tst_QNetworkReply::httpDownloadPerformance() -{ - QFETCH(bool, serverSendsContentLength); - QFETCH(bool, chunkedEncoding); - - enum {UploadSize = 1000*1024*1024}; // 1000 MB - HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); - - QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); - QNetworkReplyPtr reply = manager.get(request); - - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - HttpDownloadPerformanceClient client(reply); - - QTime time; - time.start(); - QTestEventLoop::instance().enterLoop(40); - QVERIFY(!QTestEventLoop::instance().timeout()); - - qint64 elapsed = time.elapsed(); - qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, " - << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; -} - #ifndef QT_NO_OPENSSL void tst_QNetworkReply::ignoreSslErrorsList_data() { -- cgit v0.12 From 705a4811e3bdfddc4dbfe1499fe311c1fa3c5b38 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 30 Jul 2009 16:38:38 +0200 Subject: Autotest: reduce the amout of data transferred to 128 MB, otherwise the test wouldn't finish. Running under valgrind and slow operating systems, the transfer rate is only a couple of MB per second. As long as you can reach 3.2 MB/s now, it should still work Also, don't kill the thread, for any reason. That causes trouble. Reviewed-by: Markus Goetz --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 4ebc316..cfd3dd0 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -3267,7 +3267,7 @@ void tst_QNetworkReply::uploadPerformance() void tst_QNetworkReply::httpUploadPerformance() { - enum {UploadSize = 1000*1024*1024}; // 1000 MB + enum {UploadSize = 128*1024*1024}; // 128 MB ThreadedDataReaderHttpServer reader; FixedSizeDataGenerator generator(UploadSize); @@ -3289,7 +3289,7 @@ void tst_QNetworkReply::httpUploadPerformance() << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; reader.exit(); - reader.wait(3000); + reader.wait(); } @@ -3333,7 +3333,7 @@ void tst_QNetworkReply::httpDownloadPerformance() QFETCH(bool, serverSendsContentLength); QFETCH(bool, chunkedEncoding); - enum {UploadSize = 1000*1024*1024}; // 1000 MB + enum {UploadSize = 128*1024*1024}; // 128 MB HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); -- cgit v0.12 From 6a2621b6832dbdd349f77cf1f3242b4a6ba3c740 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 29 Jul 2009 14:33:25 +0200 Subject: Added an ability to remove size constraints from a widget. QWidget::setFixedSize() constrains the size of the widget, however there was no way to remove those constraints, so setting the constraints to QWIDGETSIZE_MAX will make the widget resizable again. Reviewed-by: Leonardo Sobral Cunha --- src/gui/kernel/qwidget.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index bca607c..8b8a853 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -3491,11 +3491,16 @@ bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh) minh = qMax(minh, 0); } createExtra(); - if (extra->minw == minw && extra->minh == minh) + int mw = minw, mh = minh; + if (mw == QWIDGETSIZE_MAX) + mw = 0; + if (mh == QWIDGETSIZE_MAX) + mh = 0; + if (extra->minw == mw && extra->minh == mh) return false; - extra->minw = minw; - extra->minh = minh; - extra->explicitMinSize = (minw ? Qt::Horizontal : 0) | (minh ? Qt::Vertical : 0); + extra->minw = mw; + extra->minh = mh; + extra->explicitMinSize = (mw ? Qt::Horizontal : 0) | (mh ? Qt::Vertical : 0); return true; } @@ -3555,7 +3560,8 @@ bool QWidgetPrivate::setMaximumSize_helper(int &maxw, int &maxh) return false; extra->maxw = maxw; extra->maxh = maxh; - extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) | (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0); + extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) | + (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0); return true; } @@ -3634,6 +3640,8 @@ void QWidget::setBaseSize(int basew, int baseh) This will override the default size constraints set by QLayout. + To remove constraints, set the size to QWIDGETSIZE_MAX. + Alternatively, if you want the widget to have a fixed size based on its contents, you can call QLayout::setSizeConstraint(QLayout::SetFixedSize); @@ -3675,7 +3683,8 @@ void QWidget::setFixedSize(int w, int h) else d->updateGeometry_helper(true); - resize(w, h); + if (w != QWIDGETSIZE_MAX || h != QWIDGETSIZE_MAX) + resize(w, h); } void QWidget::setMinimumWidth(int w) -- cgit v0.12 From f5a68dc15df4edb48e7bc41f9e918609b57f4356 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 29 Jul 2009 14:54:09 +0200 Subject: Added the windowflags manualtest which is based on the windowflags example. --- tests/manual/windowflags/controllerwindow.cpp | 263 ++++++++++++++++++++++++++ tests/manual/windowflags/controllerwindow.h | 115 +++++++++++ tests/manual/windowflags/main.cpp | 52 +++++ tests/manual/windowflags/previewwindow.cpp | 146 ++++++++++++++ tests/manual/windowflags/previewwindow.h | 81 ++++++++ tests/manual/windowflags/windowflags.pro | 5 + 6 files changed, 662 insertions(+) create mode 100644 tests/manual/windowflags/controllerwindow.cpp create mode 100644 tests/manual/windowflags/controllerwindow.h create mode 100644 tests/manual/windowflags/main.cpp create mode 100644 tests/manual/windowflags/previewwindow.cpp create mode 100644 tests/manual/windowflags/previewwindow.h create mode 100644 tests/manual/windowflags/windowflags.pro diff --git a/tests/manual/windowflags/controllerwindow.cpp b/tests/manual/windowflags/controllerwindow.cpp new file mode 100644 index 0000000..055ff40 --- /dev/null +++ b/tests/manual/windowflags/controllerwindow.cpp @@ -0,0 +1,263 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "controllerwindow.h" + +//! [0] +ControllerWindow::ControllerWindow() +{ + parentWindow = new QMainWindow; + parentWindow->setWindowTitle(tr("Preview parent window")); + QLabel *label = new QLabel(tr("Parent window")); + parentWindow->setCentralWidget(label); + + previewWindow = new PreviewWindow; + previewDialog = new PreviewDialog; + + createTypeGroupBox(); + createHintsGroupBox(); + + quitButton = new QPushButton(tr("&Quit")); + connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addStretch(); + bottomLayout->addWidget(quitButton); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(widgetTypeGroupBox); + mainLayout->addWidget(additionalOptionsGroupBox); + mainLayout->addWidget(typeGroupBox); + mainLayout->addWidget(hintsGroupBox); + mainLayout->addLayout(bottomLayout); + setLayout(mainLayout); + + setWindowTitle(tr("Window Flags")); + updatePreview(); +} + +void ControllerWindow::updatePreview() +{ + Qt::WindowFlags flags = 0; + + if (windowRadioButton->isChecked()) { + flags = Qt::Window; + } else if (dialogRadioButton->isChecked()) { + flags = Qt::Dialog; + } else if (sheetRadioButton->isChecked()) { + flags = Qt::Sheet; + } else if (drawerRadioButton->isChecked()) { + flags = Qt::Drawer; + } else if (popupRadioButton->isChecked()) { + flags = Qt::Popup; + } else if (toolRadioButton->isChecked()) { + flags = Qt::Tool; + } else if (toolTipRadioButton->isChecked()) { + flags = Qt::ToolTip; + } else if (splashScreenRadioButton->isChecked()) { + flags = Qt::SplashScreen; + } + + if (msWindowsFixedSizeDialogCheckBox->isChecked()) + flags |= Qt::MSWindowsFixedSizeDialogHint; + if (x11BypassWindowManagerCheckBox->isChecked()) + flags |= Qt::X11BypassWindowManagerHint; + if (framelessWindowCheckBox->isChecked()) + flags |= Qt::FramelessWindowHint; + if (windowTitleCheckBox->isChecked()) + flags |= Qt::WindowTitleHint; + if (windowSystemMenuCheckBox->isChecked()) + flags |= Qt::WindowSystemMenuHint; + if (windowMinimizeButtonCheckBox->isChecked()) + flags |= Qt::WindowMinimizeButtonHint; + if (windowMaximizeButtonCheckBox->isChecked()) + flags |= Qt::WindowMaximizeButtonHint; + if (windowCloseButtonCheckBox->isChecked()) + flags |= Qt::WindowCloseButtonHint; + if (windowContextHelpButtonCheckBox->isChecked()) + flags |= Qt::WindowContextHelpButtonHint; + if (windowShadeButtonCheckBox->isChecked()) + flags |= Qt::WindowShadeButtonHint; + if (windowStaysOnTopCheckBox->isChecked()) + flags |= Qt::WindowStaysOnTopHint; + if (windowStaysOnBottomCheckBox->isChecked()) + flags |= Qt::WindowStaysOnBottomHint; + if (customizeWindowHintCheckBox->isChecked()) + flags |= Qt::CustomizeWindowHint; + + previewWindow->hide(); + previewDialog->hide(); + QWidget *widget = 0; + if (previewWidgetButton->isChecked()) + widget = previewWindow; + else + widget = previewDialog; + + if (modalWindowCheckBox->isChecked()) { + parentWindow->show(); + widget->setWindowModality(Qt::WindowModal); + widget->setParent(parentWindow); + } else { + widget->setWindowModality(Qt::NonModal); + widget->setParent(0); + parentWindow->hide(); + } + + widget->setWindowFlags(flags); + + if (fixedSizeWindowCheckBox->isChecked()) { + widget->setFixedSize(300, 300); + } else { + widget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); + } + + QPoint pos = widget->pos(); + if (pos.x() < 0) + pos.setX(0); + if (pos.y() < 0) + pos.setY(0); + widget->move(pos); + widget->show(); +} + +void ControllerWindow::createTypeGroupBox() +{ + widgetTypeGroupBox = new QGroupBox(tr("Widget Type")); + previewWidgetButton = createRadioButton(tr("QWidget")); + previewWidgetButton->setChecked(true); + previewDialogButton = createRadioButton(tr("QDialog")); + QHBoxLayout *l = new QHBoxLayout; + l->addWidget(previewWidgetButton); + l->addWidget(previewDialogButton); + widgetTypeGroupBox->setLayout(l); + + additionalOptionsGroupBox = new QGroupBox(tr("Additional options")); + l = new QHBoxLayout; + modalWindowCheckBox = createCheckBox(tr("Modal window")); + fixedSizeWindowCheckBox = createCheckBox(tr("Fixed size window")); + l->addWidget(modalWindowCheckBox); + l->addWidget(fixedSizeWindowCheckBox); + additionalOptionsGroupBox->setLayout(l); + + typeGroupBox = new QGroupBox(tr("Type")); + + windowRadioButton = createRadioButton(tr("Window")); + dialogRadioButton = createRadioButton(tr("Dialog")); + sheetRadioButton = createRadioButton(tr("Sheet")); + drawerRadioButton = createRadioButton(tr("Drawer")); + popupRadioButton = createRadioButton(tr("Popup")); + toolRadioButton = createRadioButton(tr("Tool")); + toolTipRadioButton = createRadioButton(tr("Tooltip")); + splashScreenRadioButton = createRadioButton(tr("Splash screen")); + windowRadioButton->setChecked(true); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(windowRadioButton, 0, 0); + layout->addWidget(dialogRadioButton, 1, 0); + layout->addWidget(sheetRadioButton, 2, 0); + layout->addWidget(drawerRadioButton, 3, 0); + layout->addWidget(popupRadioButton, 0, 1); + layout->addWidget(toolRadioButton, 1, 1); + layout->addWidget(toolTipRadioButton, 2, 1); + layout->addWidget(splashScreenRadioButton, 3, 1); + typeGroupBox->setLayout(layout); +} +//! [5] + +//! [6] +void ControllerWindow::createHintsGroupBox() +{ + hintsGroupBox = new QGroupBox(tr("Hints")); + + msWindowsFixedSizeDialogCheckBox = + createCheckBox(tr("MS Windows fixed size dialog")); + x11BypassWindowManagerCheckBox = + createCheckBox(tr("X11 bypass window manager")); + framelessWindowCheckBox = createCheckBox(tr("Frameless window")); + windowTitleCheckBox = createCheckBox(tr("Window title")); + windowSystemMenuCheckBox = createCheckBox(tr("Window system menu")); + windowMinimizeButtonCheckBox = createCheckBox(tr("Window minimize button")); + windowMaximizeButtonCheckBox = createCheckBox(tr("Window maximize button")); + windowCloseButtonCheckBox = createCheckBox(tr("Window close button")); + windowContextHelpButtonCheckBox = + createCheckBox(tr("Window context help button")); + windowShadeButtonCheckBox = createCheckBox(tr("Window shade button")); + windowStaysOnTopCheckBox = createCheckBox(tr("Window stays on top")); + windowStaysOnBottomCheckBox = createCheckBox(tr("Window stays on bottom")); + customizeWindowHintCheckBox= createCheckBox(tr("Customize window")); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(msWindowsFixedSizeDialogCheckBox, 0, 0); + layout->addWidget(x11BypassWindowManagerCheckBox, 1, 0); + layout->addWidget(framelessWindowCheckBox, 2, 0); + layout->addWidget(windowTitleCheckBox, 3, 0); + layout->addWidget(windowSystemMenuCheckBox, 4, 0); + layout->addWidget(windowMinimizeButtonCheckBox, 0, 1); + layout->addWidget(windowMaximizeButtonCheckBox, 1, 1); + layout->addWidget(windowCloseButtonCheckBox, 2, 1); + layout->addWidget(windowContextHelpButtonCheckBox, 3, 1); + layout->addWidget(windowShadeButtonCheckBox, 4, 1); + layout->addWidget(windowStaysOnTopCheckBox, 5, 1); + layout->addWidget(windowStaysOnBottomCheckBox, 6, 1); + layout->addWidget(customizeWindowHintCheckBox, 5, 0); + hintsGroupBox->setLayout(layout); +} +//! [6] + +//! [7] +QCheckBox *ControllerWindow::createCheckBox(const QString &text) +{ + QCheckBox *checkBox = new QCheckBox(text); + connect(checkBox, SIGNAL(clicked()), this, SLOT(updatePreview())); + return checkBox; +} +//! [7] + +//! [8] +QRadioButton *ControllerWindow::createRadioButton(const QString &text) +{ + QRadioButton *button = new QRadioButton(text); + connect(button, SIGNAL(clicked()), this, SLOT(updatePreview())); + return button; +} +//! [8] diff --git a/tests/manual/windowflags/controllerwindow.h b/tests/manual/windowflags/controllerwindow.h new file mode 100644 index 0000000..3d315be --- /dev/null +++ b/tests/manual/windowflags/controllerwindow.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CONTROLLERWINDOW_H +#define CONTROLLERWINDOW_H + +#include + +#include "previewwindow.h" + +QT_BEGIN_NAMESPACE +class QCheckBox; +class QGroupBox; +class QLabel; +class QPushButton; +class QRadioButton; +class QMainWindow; +QT_END_NAMESPACE + +//! [0] +class ControllerWindow : public QWidget +{ + Q_OBJECT + +public: + ControllerWindow(); + +private slots: + void updatePreview(); + +private: + void createTypeGroupBox(); + void createHintsGroupBox(); + QCheckBox *createCheckBox(const QString &text); + QRadioButton *createRadioButton(const QString &text); + + QMainWindow *parentWindow; + PreviewWindow *previewWindow; + PreviewDialog *previewDialog; + + QGroupBox *widgetTypeGroupBox; + QGroupBox *additionalOptionsGroupBox; + QGroupBox *typeGroupBox; + QGroupBox *hintsGroupBox; + QPushButton *quitButton; + + QRadioButton *previewWidgetButton; + QRadioButton *previewDialogButton; + QCheckBox *modalWindowCheckBox; + QCheckBox *fixedSizeWindowCheckBox; + + QRadioButton *windowRadioButton; + QRadioButton *dialogRadioButton; + QRadioButton *sheetRadioButton; + QRadioButton *drawerRadioButton; + QRadioButton *popupRadioButton; + QRadioButton *toolRadioButton; + QRadioButton *toolTipRadioButton; + QRadioButton *splashScreenRadioButton; + + QCheckBox *msWindowsFixedSizeDialogCheckBox; + QCheckBox *x11BypassWindowManagerCheckBox; + QCheckBox *framelessWindowCheckBox; + QCheckBox *windowTitleCheckBox; + QCheckBox *windowSystemMenuCheckBox; + QCheckBox *windowMinimizeButtonCheckBox; + QCheckBox *windowMaximizeButtonCheckBox; + QCheckBox *windowCloseButtonCheckBox; + QCheckBox *windowContextHelpButtonCheckBox; + QCheckBox *windowShadeButtonCheckBox; + QCheckBox *windowStaysOnTopCheckBox; + QCheckBox *windowStaysOnBottomCheckBox; + QCheckBox *customizeWindowHintCheckBox; +}; +//! [0] + +#endif diff --git a/tests/manual/windowflags/main.cpp b/tests/manual/windowflags/main.cpp new file mode 100644 index 0000000..011ca3f --- /dev/null +++ b/tests/manual/windowflags/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "controllerwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + ControllerWindow controller; + controller.show(); + return app.exec(); +} diff --git a/tests/manual/windowflags/previewwindow.cpp b/tests/manual/windowflags/previewwindow.cpp new file mode 100644 index 0000000..796bdb9 --- /dev/null +++ b/tests/manual/windowflags/previewwindow.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "previewwindow.h" + +static QString windowFlagsToString(Qt::WindowFlags flags) +{ + QString text; + + Qt::WindowFlags type = (flags & Qt::WindowType_Mask); + if (type == Qt::Window) { + text = "Qt::Window"; + } else if (type == Qt::Dialog) { + text = "Qt::Dialog"; + } else if (type == Qt::Sheet) { + text = "Qt::Sheet"; + } else if (type == Qt::Drawer) { + text = "Qt::Drawer"; + } else if (type == Qt::Popup) { + text = "Qt::Popup"; + } else if (type == Qt::Tool) { + text = "Qt::Tool"; + } else if (type == Qt::ToolTip) { + text = "Qt::ToolTip"; + } else if (type == Qt::SplashScreen) { + text = "Qt::SplashScreen"; + } + + if (flags & Qt::MSWindowsFixedSizeDialogHint) + text += "\n| Qt::MSWindowsFixedSizeDialogHint"; + if (flags & Qt::X11BypassWindowManagerHint) + text += "\n| Qt::X11BypassWindowManagerHint"; + if (flags & Qt::FramelessWindowHint) + text += "\n| Qt::FramelessWindowHint"; + if (flags & Qt::WindowTitleHint) + text += "\n| Qt::WindowTitleHint"; + if (flags & Qt::WindowSystemMenuHint) + text += "\n| Qt::WindowSystemMenuHint"; + if (flags & Qt::WindowMinimizeButtonHint) + text += "\n| Qt::WindowMinimizeButtonHint"; + if (flags & Qt::WindowMaximizeButtonHint) + text += "\n| Qt::WindowMaximizeButtonHint"; + if (flags & Qt::WindowCloseButtonHint) + text += "\n| Qt::WindowCloseButtonHint"; + if (flags & Qt::WindowContextHelpButtonHint) + text += "\n| Qt::WindowContextHelpButtonHint"; + if (flags & Qt::WindowShadeButtonHint) + text += "\n| Qt::WindowShadeButtonHint"; + if (flags & Qt::WindowStaysOnTopHint) + text += "\n| Qt::WindowStaysOnTopHint"; + if (flags & Qt::CustomizeWindowHint) + text += "\n| Qt::CustomizeWindowHint"; + return text; +} + +PreviewWindow::PreviewWindow(QWidget *parent) + : QWidget(parent) +{ + textEdit = new QTextEdit; + textEdit->setReadOnly(true); + textEdit->setLineWrapMode(QTextEdit::NoWrap); + + closeButton = new QPushButton(tr("&Close")); + connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(textEdit); + layout->addWidget(closeButton); + setLayout(layout); + + setWindowTitle(tr("Preview ")); +} + +void PreviewWindow::setWindowFlags(Qt::WindowFlags flags) +{ + QWidget::setWindowFlags(flags); + + QString text = windowFlagsToString(flags); + textEdit->setPlainText(text); +} + +PreviewDialog::PreviewDialog(QWidget *parent) + : QDialog(parent) +{ + textEdit = new QTextEdit; + textEdit->setReadOnly(true); + textEdit->setLineWrapMode(QTextEdit::NoWrap); + + closeButton = new QPushButton(tr("&Close")); + connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(textEdit); + layout->addWidget(closeButton); + setLayout(layout); + + setWindowTitle(tr("Preview ")); +} + +void PreviewDialog::setWindowFlags(Qt::WindowFlags flags) +{ + QWidget::setWindowFlags(flags); + + QString text = windowFlagsToString(flags); + textEdit->setPlainText(text); +} diff --git a/tests/manual/windowflags/previewwindow.h b/tests/manual/windowflags/previewwindow.h new file mode 100644 index 0000000..90ed8ba --- /dev/null +++ b/tests/manual/windowflags/previewwindow.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PREVIEWWINDOW_H +#define PREVIEWWINDOW_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QPushButton; +class QTextEdit; +QT_END_NAMESPACE + +class PreviewWindow : public QWidget +{ + Q_OBJECT + +public: + PreviewWindow(QWidget *parent = 0); + + void setWindowFlags(Qt::WindowFlags flags); + +private: + QTextEdit *textEdit; + QPushButton *closeButton; +}; + +class PreviewDialog : public QDialog +{ + Q_OBJECT + +public: + PreviewDialog(QWidget *parent = 0); + + void setWindowFlags(Qt::WindowFlags flags); + +private: + QTextEdit *textEdit; + QPushButton *closeButton; +}; + +#endif diff --git a/tests/manual/windowflags/windowflags.pro b/tests/manual/windowflags/windowflags.pro new file mode 100644 index 0000000..1b45d0d --- /dev/null +++ b/tests/manual/windowflags/windowflags.pro @@ -0,0 +1,5 @@ +HEADERS = controllerwindow.h \ + previewwindow.h +SOURCES = controllerwindow.cpp \ + previewwindow.cpp \ + main.cpp -- cgit v0.12 From 989e195a4b7b0eb579dc4418dd47c2eca7e8b384 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 29 Jul 2009 15:34:31 +0200 Subject: Allow maximize button on the titlebar for a fixed size window On Windows we will add maximize button to the titlebar even if the window has a fixed size if the user explicitely asked for it by setting Qt::CustomizeWindowHint | Qt::WindowMaximizeButtonHint. Task-number: 250188 Reviewed-by: Leonardo Sobral Cunha --- src/gui/kernel/qwidget_win.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 46fa3be..455d06d 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -1524,6 +1524,11 @@ bool QWidgetPrivate::shouldShowMaximizeButton() { if (data.window_flags & Qt::MSWindowsFixedSizeDialogHint) return false; + // if the user explicitely asked for the maximize button, we try to add + // it even if the window has fixed size. + if (data.window_flags & Qt::CustomizeWindowHint && + data.window_flags & Qt::WindowMaximizeButtonHint) + return true; if (extra) { if ((extra->maxw && extra->maxw != QWIDGETSIZE_MAX && extra->maxw != QLAYOUTSIZE_MAX) || (extra->maxh && extra->maxh != QWIDGETSIZE_MAX && extra->maxh != QLAYOUTSIZE_MAX)) -- cgit v0.12 From 71961def3b006d042fb6f2d46e5f40d527553dc0 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 30 Jul 2009 17:03:53 +0200 Subject: Disabling the close button didn't work correctly Close button was enabled if the native window handle was created implicitely (for example by the setWindowTitle() function). Moved the code that enables of disables the close button to the place where we create native window handle. Task-number: 256360 Reviewed-by: trustme --- src/gui/kernel/qwidget_win.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 455d06d..2f230d7 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -467,6 +467,17 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO } } + if (topLevel) { + if (data.window_flags & Qt::CustomizeWindowHint + && data.window_flags & Qt::WindowTitleHint) { + HMENU systemMenu = GetSystemMenu((HWND)q->internalWinId(), FALSE); + if (data.window_flags & Qt::WindowCloseButtonHint) + EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED); + else + EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED); + } + } + q->setAttribute(Qt::WA_WState_Created); // accept move/resize events hd = 0; // no display context @@ -638,16 +649,6 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) || (!q->isWindow() && q->parentWidget() && q->parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))) q->setAttribute(Qt::WA_DropSiteRegistered, true); - - if (data.window_flags & Qt::CustomizeWindowHint - && data.window_flags & Qt::WindowTitleHint) { - HMENU systemMenu = GetSystemMenu((HWND)q->internalWinId(), FALSE); - if (data.window_flags & Qt::WindowCloseButtonHint) - EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED); - else - EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED); - } - #ifdef Q_WS_WINCE // Show borderless toplevel windows in tasklist & NavBar if (!parent) { -- cgit v0.12 From 9cbaefd4121ee082c402d5243f7ccb5e9d89456c Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 29 Jul 2009 15:34:31 +0200 Subject: Allow maximize button on the titlebar for a fixed size window On Windows we will add maximize button to the titlebar even if the window has a fixed size if the user explicitely asked for it by setting Qt::CustomizeWindowHint | Qt::WindowMaximizeButtonHint. Task-number: 250188 Reviewed-by: Leonardo Sobral Cunha --- src/gui/kernel/qwidget_win.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index f7ff2d0..13658fb 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -1558,6 +1558,11 @@ bool QWidgetPrivate::shouldShowMaximizeButton() { if (data.window_flags & Qt::MSWindowsFixedSizeDialogHint) return false; + // if the user explicitely asked for the maximize button, we try to add + // it even if the window has fixed size. + if (data.window_flags & Qt::CustomizeWindowHint && + data.window_flags & Qt::WindowMaximizeButtonHint) + return true; if (extra) { if ((extra->maxw && extra->maxw != QWIDGETSIZE_MAX && extra->maxw != QLAYOUTSIZE_MAX) || (extra->maxh && extra->maxh != QWIDGETSIZE_MAX && extra->maxh != QLAYOUTSIZE_MAX)) -- cgit v0.12 From 278a6fbb0eb953d02cef2567df130cbf5ea960bc Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 30 Jul 2009 17:29:01 +0200 Subject: Doc: there is no group of explicitly shared classes, only one class uses this. Explain the implications in the QWebHistoryItem documentation, and get rid of the "group". --- doc/src/groups.qdoc | 111 ----------------- doc/src/implicit-sharing.qdoc | 144 ++++++++++++++++++++++ src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.cpp | 15 ++- src/corelib/tools/qshareddata.cpp | 2 +- 4 files changed, 156 insertions(+), 116 deletions(-) create mode 100644 doc/src/implicit-sharing.qdoc diff --git a/doc/src/groups.qdoc b/doc/src/groups.qdoc index 731ac58..f7296a3 100644 --- a/doc/src/groups.qdoc +++ b/doc/src/groups.qdoc @@ -202,20 +202,6 @@ */ /*! - \group explicitly-shared - \ingroup groups - - \title Explicitly Shared Classes - \brief Classes that use explicit sharing to manage internal data. - - \keyword explicit sharing - \keyword explicitly shared - - Unlike many of Qt's data types, which use \l{implicit sharing}, these - classes use explicit sharing to manage internal data. -*/ - -/*! \group geomanagement \title Layout Classes \ingroup groups @@ -377,103 +363,6 @@ */ /*! - \group shared - \title Implicitly Shared Classes - \ingroup architecture - \ingroup groups - - \brief Classes that use reference counting for fast copying. - - \keyword implicit data sharing - \keyword implicit sharing - \keyword implicitly shared - \keyword reference counting - \keyword shared implicitly - \keyword shared classes - - Many C++ classes in Qt use implicit data sharing to maximize - resource usage and minimize copying. Implicitly shared classes are - both safe and efficient when passed as arguments, because only a - pointer to the data is passed around, and the data is copied only - if and when a function writes to it, i.e., \e {copy-on-write}. - - \tableofcontents - - \section1 Overview - - A shared class consists of a pointer to a shared data block that - contains a reference count and the data. - - When a shared object is created, it sets the reference count to 1. The - reference count is incremented whenever a new object references the - shared data, and decremented when the object dereferences the shared - data. The shared data is deleted when the reference count becomes - zero. - - \keyword deep copy - \keyword shallow copy - - When dealing with shared objects, there are two ways of copying an - object. We usually speak about \e deep and \e shallow copies. A deep - copy implies duplicating an object. A shallow copy is a reference - copy, i.e. just a pointer to a shared data block. Making a deep copy - can be expensive in terms of memory and CPU. Making a shallow copy is - very fast, because it only involves setting a pointer and incrementing - the reference count. - - Object assignment (with operator=()) for implicitly shared objects is - implemented using shallow copies. - - The benefit of sharing is that a program does not need to duplicate - data unnecessarily, which results in lower memory use and less copying - of data. Objects can easily be assigned, sent as function arguments, - and returned from functions. - - Implicit sharing takes place behind the scenes; the programmer - does not need to worry about it. Even in multithreaded - applications, implicit sharing takes place, as explained in - \l{Threads and Implicit Sharing}. - - \section1 Implicit Sharing in Detail - - Implicit sharing automatically detaches the object from a shared - block if the object is about to change and the reference count is - greater than one. (This is often called \e {copy-on-write} or - \e {value semantics}.) - - An implicitly shared class has total control of its internal data. In - any member functions that modify its data, it automatically detaches - before modifying the data. - - The QPen class, which uses implicit sharing, detaches from the shared - data in all member functions that change the internal data. - - Code fragment: - \snippet doc/src/snippets/code/doc_src_groups.qdoc 0 - - \section1 List of Classes - - The classes listed below automatically detach from common data if - an object is about to be changed. The programmer will not even - notice that the objects are shared. Thus you should treat - separate instances of them as separate objects. They will always - behave as separate objects but with the added benefit of sharing - data whenever possible. For this reason, you can pass instances - of these classes as arguments to functions by value without - concern for the copying overhead. - - Example: - \snippet doc/src/snippets/code/doc_src_groups.qdoc 1 - - In this example, \c p1 and \c p2 share data until QPainter::begin() - is called for \c p2, because painting a pixmap will modify it. - - \warning Do not copy an implicitly shared container (QMap, - QVector, etc.) while you are iterating over it using an non-const - \l{STL-style iterator}. -*/ - -/*! \group ssl \title Secure Sockets Layer (SSL) Classes \ingroup groups diff --git a/doc/src/implicit-sharing.qdoc b/doc/src/implicit-sharing.qdoc new file mode 100644 index 0000000..85630dc --- /dev/null +++ b/doc/src/implicit-sharing.qdoc @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* TODO: Move some of the documentation from QSharedDataPointer into this + document. */ + +/*! + \group shared + \title Implicitly Shared Classes + \ingroup architecture + \ingroup groups + + \brief Classes that use reference counting for fast copying. + + \keyword implicit data sharing + \keyword implicit sharing + \keyword implicitly shared + \keyword reference counting + \keyword shared implicitly + \keyword shared classes + + Many C++ classes in Qt use implicit data sharing to maximize + resource usage and minimize copying. Implicitly shared classes are + both safe and efficient when passed as arguments, because only a + pointer to the data is passed around, and the data is copied only + if and when a function writes to it, i.e., \e {copy-on-write}. + + \tableofcontents + + \section1 Overview + + A shared class consists of a pointer to a shared data block that + contains a reference count and the data. + + When a shared object is created, it sets the reference count to 1. The + reference count is incremented whenever a new object references the + shared data, and decremented when the object dereferences the shared + data. The shared data is deleted when the reference count becomes + zero. + + \keyword deep copy + \keyword shallow copy + + When dealing with shared objects, there are two ways of copying an + object. We usually speak about \e deep and \e shallow copies. A deep + copy implies duplicating an object. A shallow copy is a reference + copy, i.e. just a pointer to a shared data block. Making a deep copy + can be expensive in terms of memory and CPU. Making a shallow copy is + very fast, because it only involves setting a pointer and incrementing + the reference count. + + Object assignment (with operator=()) for implicitly shared objects is + implemented using shallow copies. + + The benefit of sharing is that a program does not need to duplicate + data unnecessarily, which results in lower memory use and less copying + of data. Objects can easily be assigned, sent as function arguments, + and returned from functions. + + Implicit sharing takes place behind the scenes; the programmer + does not need to worry about it. Even in multithreaded + applications, implicit sharing takes place, as explained in + \l{Threads and Implicit Sharing}. + + When implementing your own implicitly shared classes, use the + QSharedData and QSharedDataPointer classes. + + \section1 Implicit Sharing in Detail + + Implicit sharing automatically detaches the object from a shared + block if the object is about to change and the reference count is + greater than one. (This is often called \e {copy-on-write} or + \e {value semantics}.) + + An implicitly shared class has total control of its internal data. In + any member functions that modify its data, it automatically detaches + before modifying the data. + + The QPen class, which uses implicit sharing, detaches from the shared + data in all member functions that change the internal data. + + Code fragment: + \snippet doc/src/snippets/code/doc_src_groups.qdoc 0 + + + \section1 List of Classes + + The classes listed below automatically detach from common data if + an object is about to be changed. The programmer will not even + notice that the objects are shared. Thus you should treat + separate instances of them as separate objects. They will always + behave as separate objects but with the added benefit of sharing + data whenever possible. For this reason, you can pass instances + of these classes as arguments to functions by value without + concern for the copying overhead. + + Example: + \snippet doc/src/snippets/code/doc_src_groups.qdoc 1 + + In this example, \c p1 and \c p2 share data until QPainter::begin() + is called for \c p2, because painting a pixmap will modify it. + + \warning Do not copy an implicitly shared container (QMap, + QVector, etc.) while you are iterating over it using an non-const + \l{STL-style iterator}. +*/ diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.cpp index e5eb308..1c1c72a 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.cpp @@ -32,7 +32,6 @@ /*! \class QWebHistoryItem - \ingroup explicitly-shared \since 4.4 \brief The QWebHistoryItem class represents one item in the history of a QWebPage @@ -52,13 +51,17 @@ \row \o userData() \o The user specific data that was stored with the history item. \endtable - \note QWebHistoryItem objects are value based and \l{explicitly shared}. + \note QWebHistoryItem objects are value based, but \e{explicitly shared}. Changing + a QWebHistoryItem instance by calling setUserData() will change all copies of that + instance. \sa QWebHistory, QWebPage::history(), QWebHistoryInterface */ /*! - Constructs a history item from \a other. + Constructs a history item from \a other. The new item and \a other + will share their data, and modifying either this item or \a other will + modify both instances. */ QWebHistoryItem::QWebHistoryItem(const QWebHistoryItem &other) : d(other.d) @@ -66,7 +69,9 @@ QWebHistoryItem::QWebHistoryItem(const QWebHistoryItem &other) } /*! - Assigns the \a other history item to this. + Assigns the \a other history item to this. This item and \a other + will share their data, and modifying either this item or \a other will + modify both instances. */ QWebHistoryItem &QWebHistoryItem::operator=(const QWebHistoryItem &other) { @@ -163,6 +168,8 @@ QVariant QWebHistoryItem::userData() const \since 4.5 Stores user specific data \a userData with the history item. + + \note All copies of this item will be modified. \sa userData() */ diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp index 3cd37a7..6cd220c 100644 --- a/src/corelib/tools/qshareddata.cpp +++ b/src/corelib/tools/qshareddata.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE QSharedData is designed to be used with QSharedDataPointer or QExplicitlySharedDataPointer to implement custom \l{implicitly - shared} or \l {explicitly shared} classes. QSharedData provides + shared} or explicitly shared classes. QSharedData provides \l{thread-safe} reference counting. See QSharedDataPointer and QExplicitlySharedDataPointer for details. -- cgit v0.12 From 1dbd205e304d0f0819f558591def249bdceac9fa Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 30 Jul 2009 17:37:30 +0200 Subject: Coverty warnings --. This switch was missing a break. Reviewed-by:TrustMe --- src/gui/dialogs/qfilesystemmodel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index 4646012..73f2db5 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -880,6 +880,7 @@ QVariant QFileSystemModel::headerData(int section, Qt::Orientation orientation, pixmap.setAlphaChannel(pixmap.createAlphaMask()); return pixmap; } + break; case Qt::TextAlignmentRole: return Qt::AlignLeft; } -- cgit v0.12 From 6a5cabfa371c7daf7708e5f7aa1e90719cfe940d Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 30 Jul 2009 21:04:30 +0200 Subject: API documentation moved into the classes subdirectory --- doc/src/classes/qnamespace.qdoc | 2718 +++++++++++++++++++++++++++++++++++++++ doc/src/qnamespace.qdoc | 2718 --------------------------------------- 2 files changed, 2718 insertions(+), 2718 deletions(-) create mode 100644 doc/src/classes/qnamespace.qdoc delete mode 100644 doc/src/qnamespace.qdoc diff --git a/doc/src/classes/qnamespace.qdoc b/doc/src/classes/qnamespace.qdoc new file mode 100644 index 0000000..2d40fdd --- /dev/null +++ b/doc/src/classes/qnamespace.qdoc @@ -0,0 +1,2718 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \namespace Qt + \inmodule QtCore + + \brief The Qt namespace contains miscellaneous identifiers + used throughout the Qt library. + + \ingroup misc +*/ + +/*! + \enum Qt::Orientation + + This type is used to signify an object's orientation. + + \value Horizontal + \value Vertical + + Orientation is used with QScrollBar for example. +*/ + +/*! + \enum Qt::AlignmentFlag + + This enum type is used to describe alignment. It contains + horizontal and vertical flags that can be combined to produce + the required effect. + + The \l{TextElideMode} enum can also be used in many situations + to fine-tune the appearance of aligned text. + + The horizontal flags are: + + \value AlignLeft Aligns with the left edge. + \value AlignRight Aligns with the right edge. + \value AlignHCenter Centers horizontally in the available space. + \value AlignJustify Justifies the text in the available space. + \omitvalue AlignAuto + + The vertical flags are: + + \value AlignTop Aligns with the top. + \value AlignBottom Aligns with the bottom. + \value AlignVCenter Centers vertically in the available space. + + You can use only one of the horizontal flags at a time. There is + one two-dimensional flag: + + \value AlignCenter Centers in both dimensions. + + You can use at most one horizontal and one vertical flag at a + time. Qt::AlignCenter counts as both horizontal and vertical. + + Three enum values are useful in applications that can be run in + right-to-left mode: + + \value AlignAbsolute If the widget's layout direction is + Qt::RightToLeft (instead of Qt::LeftToRight, the default), + Qt::AlignLeft refers to the \e right edge and Qt::AlignRight + to the \e left edge. This is normally the desired behavior. + If you want Qt::AlignLeft to always mean "left" and + Qt::AlignRight to always mean "right", combine the flag with + Qt::AlignAbsolute. + \value AlignLeading Synonym for Qt::AlignLeft. + \value AlignTrailing Synonym for Qt::AlignRight. + + Masks: + + \value AlignHorizontal_Mask + \value AlignVertical_Mask + + Conflicting combinations of flags have undefined meanings. +*/ + +/*! + \enum Qt::ApplicationAttribute + + This enum describes attributes that change the behavior of + application-wide features. These are enabled and disabled using + QCoreApplication::setAttribute(), and can be tested for with + QCoreApplication::testAttribute(). + + \value AA_ImmediateWidgetCreation Ensures that widgets are created + as soon as they are constructed. By default, resources for + widgets are allocated on demand to improve efficiency and + minimize resource usage. Setting or clearing this attribute + affects widgets constructed after the change. Setting it + tells Qt to create toplevel windows immediately. + Therefore, if it is important to minimize resource + consumption, do not set this attribute. + + \value AA_MSWindowsUseDirect3DByDefault This value is obsolete and + has no effect. + + \value AA_DontShowIconsInMenus Actions with the Icon property won't be + shown in any menus unless specifically set by the + QAction::iconVisibleInMenu property. + + Menus that are currently open or menus already created in the native + Mac OS X menubar \e{may not} pick up a change in this attribute. Changes + in the QAction::iconVisibleInMenu property will always be picked up. + + \value AA_NativeWindows Ensures that widgets have native windows. + + \value AA_DontCreateNativeWidgetSiblings Ensures that siblings of native + widgets stay non-native unless specifically set by the + Qt::WA_NativeWindow attribute. + + \value AA_MacPluginApplication Stops the Qt mac application from doing + specific initializations that do not necessarily make sense when using Qt + to author a plugin. This includes avoiding loading our nib for the main + menu and not taking possession of the native menu bar. When setting this + attribute to true will also set the AA_DontUseNativeMenuBar attribute + to true. + + \value AA_DontUseNativeMenuBar All menubars created while this attribute is + set to true won't be used as a native menubar (e.g, the menubar at + the top of the main screen on Mac OS X or at the bottom in Windows CE). + + \value AA_MacDontSwapCtrlAndMeta On Mac OS X by default, Qt swaps the + Control and Meta (Command) keys (i.e., whenever Control is pressed, Qt + sends Meta and whenever Meta is pressed Control is sent. When this + attribute is true, Qt will not do the flip. QKeySequence::StandardShortcuts + will also flip accordingly (i.e., QKeySequence::Copy will be + Command+C on the keyboard regardless of the value set, though what is output for + QKeySequence::toString(QKeySequence::PortableText) will be different). + + \omitvalue AA_AttributeCount +*/ + +/*! + \enum Qt::MouseButton + + This enum type describes the different mouse buttons. + + \value NoButton The button state does not refer to any + button (see QMouseEvent::button()). + \value LeftButton The left button is pressed, or an event refers + to the left button. (The left button may be the right button on + left-handed mice.) + \value RightButton The right button. + \value MidButton The middle button. + \value XButton1 The first X button. + \value XButton2 The second X button. + + \omitvalue MouseButtonMask + + \sa KeyboardModifier Modifier +*/ + +/*! + \enum Qt::KeyboardModifier + + This enum describes the modifier keys. + + \value NoModifier No modifier key is pressed. + \value ShiftModifier A Shift key on the keyboard is pressed. + \value ControlModifier A Ctrl key on the keyboard is pressed. + \value AltModifier An Alt key on the keyboard is pressed. + \value MetaModifier A Meta key on the keyboard is pressed. + \value KeypadModifier A keypad button is pressed. + \value GroupSwitchModifier X11 only. A Mode_switch key on the keyboard is pressed. + + \omitvalue KeyboardModifierMask + + \note On Mac OS X, the \c ControlModifier value corresponds to + the Command keys on the Macintosh keyboard, and the \c MetaModifier value + corresponds to the Control keys. The \c KeypadModifier value will also be set + when an arrow key is pressed as the arrow keys are considered part of the + keypad. + + \note On Windows Keyboards, Qt::MetaModifier and Qt::Key_Meta are mapped + to the Windows key. + + \sa MouseButton Modifier +*/ + +/*! + \enum Qt::Modifier + + This enum provides shorter names for the keyboard modifier keys + supported by Qt. + + \bold{Note:} On Mac OS X, the \c CTRL value corresponds to + the Command keys on the Macintosh keyboard, and the \c META value + corresponds to the Control keys. + + \value SHIFT The Shift keys provided on all standard keyboards. + \value META The Meta keys. + \value CTRL The Ctrl keys. + \value ALT The normal Alt keys, but not keys like AltGr. + \value UNICODE_ACCEL The shortcut is specified as a Unicode code + point, not as a Qt Key. + \omitvalue MODIFIER_MASK + + \sa KeyboardModifier MouseButton +*/ + +/*! + \enum Qt::GlobalColor + + \raw HTML + + \endraw + + Qt's predefined QColor objects: + + \value white \raw HTML + White (#ffffff) + \endraw + \value black \raw HTML + Black (#000000) + \endraw + \value red \raw HTML + Red (#ff0000) + \endraw + \value darkRed \raw HTML + Dark red (#800000) + \endraw + \value green \raw HTML + Green (#00ff00) + \endraw + \value darkGreen \raw HTML + Dark green (#008000) + \endraw + \value blue \raw HTML + Blue (#0000ff) + \endraw + \value darkBlue \raw HTML + Dark blue (#000080) + \endraw + \value cyan \raw HTML + Cyan (#00ffff) + \endraw + \value darkCyan \raw HTML + Dark cyan (#008080) + \endraw + \value magenta \raw HTML + Magenta (#ff00ff) + \endraw + \value darkMagenta \raw HTML + Dark magenta (#800080) + \endraw + \value yellow \raw HTML + Yellow (#ffff00) + \endraw + \value darkYellow \raw HTML + Dark yellow (#808000) + \endraw + \value gray \raw HTML + Gray (#a0a0a4) + \endraw + \value darkGray \raw HTML + Dark gray (#808080) + \endraw + \value lightGray \raw HTML + Light gray (#c0c0c0) + \endraw + \value transparent a transparent black value (i.e., QColor(0, 0, 0, 0)) + \value color0 0 pixel value (for bitmaps) + \value color1 1 pixel value (for bitmaps) + + \sa QColor + +*/ + +/*! + \enum Qt::PenStyle + + This enum type defines the pen styles that can be drawn using + QPainter. The styles are: + + \table + \row + \o \inlineimage qpen-solid.png + \o \inlineimage qpen-dash.png + \o \inlineimage qpen-dot.png + \row + \o Qt::SolidLine + \o Qt::DashLine + \o Qt::DotLine + \row + \o \inlineimage qpen-dashdot.png + \o \inlineimage qpen-dashdotdot.png + \o \inlineimage qpen-custom.png + \row + \o Qt::DashDotLine + \o Qt::DashDotDotLine + \o Qt::CustomDashLine + \endtable + + \value NoPen no line at all. For example, QPainter::drawRect() + fills but does not draw any boundary line. + + \value SolidLine A plain line. + \value DashLine Dashes separated by a few pixels. + \value DotLine Dots separated by a few pixels. + \value DashDotLine Alternate dots and dashes. + \value DashDotDotLine One dash, two dots, one dash, two dots. + \value CustomDashLine A custom pattern defined using + QPainterPathStroker::setDashPattern(). + + \omitvalue MPenStyle + + \sa QPen +*/ + +/*! + \enum Qt::PenCapStyle + + This enum type defines the pen cap styles supported by Qt, i.e. + the line end caps that can be drawn using QPainter. + + \table + \row + \o \inlineimage qpen-square.png + \o \inlineimage qpen-flat.png + \o \inlineimage qpen-roundcap.png + \row + \o Qt::SquareCap + \o Qt::FlatCap + \o Qt::RoundCap + \endtable + + \value FlatCap a square line end that does not cover the end + point of the line. + \value SquareCap a square line end that covers the end point and + extends beyond it by half the line width. + \value RoundCap a rounded line end. + \omitvalue MPenCapStyle + + \sa QPen +*/ + +/*! + \enum Qt::PenJoinStyle + + This enum type defines the pen join styles supported by Qt, i.e. + which joins between two connected lines can be drawn using + QPainter. + + \table + \row + \o \inlineimage qpen-bevel.png + \o \inlineimage qpen-miter.png + \o \inlineimage qpen-roundjoin.png + \row + \o Qt::BevelJoin + \o Qt::MiterJoin + \o Qt::RoundJoin + \endtable + + \value MiterJoin The outer edges of the lines are extended to + meet at an angle, and this area is filled. + \value BevelJoin The triangular notch between the two lines is filled. + \value RoundJoin A circular arc between the two lines is filled. + \value SvgMiterJoin A miter join corresponding to the definition of + a miter join in the \l{SVG 1.2 Tiny} specification. + \omitvalue MPenJoinStyle + + \sa QPen +*/ + +/*! + \enum Qt::BrushStyle + + This enum type defines the brush styles supported by Qt, i.e. the + fill pattern of shapes drawn using QPainter. + + \image brush-styles.png Brush Styles + + \value NoBrush No brush pattern. + \value SolidPattern Uniform color. + \value Dense1Pattern Extremely dense brush pattern. + \value Dense2Pattern Very dense brush pattern. + \value Dense3Pattern Somewhat dense brush pattern. + \value Dense4Pattern Half dense brush pattern. + \value Dense5Pattern Somewhat sparse brush pattern. + \value Dense6Pattern Very sparse brush pattern. + \value Dense7Pattern Extremely sparse brush pattern. + \value HorPattern Horizontal lines. + \value VerPattern Vertical lines. + \value CrossPattern Crossing horizontal and vertical lines. + \value BDiagPattern Backward diagonal lines. + \value FDiagPattern Forward diagonal lines. + \value DiagCrossPattern Crossing diagonal lines. + \value LinearGradientPattern Linear gradient (set using a dedicated QBrush constructor). + \value ConicalGradientPattern Conical gradient (set using a dedicated QBrush constructor). + \value RadialGradientPattern Radial gradient (set using a dedicated QBrush constructor). + \value TexturePattern Custom pattern (see QBrush::setTexture()). + + \omitvalue CustomPattern + + \sa QBrush +*/ + +/*! + \enum Qt::TextFlag + + This enum type is used to define some modifier flags. Some of + these flags only make sense in the context of printing: + + \value TextSingleLine Treats all whitespace as spaces and prints just + one line. + \value TextDontClip If it's impossible to stay within the given bounds, + it prints outside. + \value TextExpandTabs Makes the U+0009 (ASCII tab) character move to + the next tab stop. + \value TextShowMnemonic Displays the string "\&P" as \underline{P} + (see QButton for an example). For an ampersand, use "\&\&". + \value TextWordWrap Breaks lines at appropriate points, e.g. at word + boundaries. + \value TextWrapAnywhere Breaks lines anywhere, even within words. + \value TextHideMnemonic Same as Qt::TextShowMnemonic but doesn't draw the underlines. + \value TextDontPrint Treat this text as "hidden" and don't print + it. + \value IncludeTrailingSpaces When this option is set, QTextLine::naturalTextWidth() and naturalTextRect() will + return a value that includes the width of trailing spaces in the text; otherwise + this width is excluded. + \value TextIncludeTrailingSpaces Same as IncludeTrailingSpaces + \value TextJustificationForced Ensures that text lines are justified. + + \omitvalue BreakAnywhere + \omitvalue DontClip + \omitvalue DontPrint + \omitvalue ExpandTabs + \omitvalue IncludeTrailingSpaces + \omitvalue NoAccel + \omitvalue ShowPrefix + \omitvalue SingleLine + \omitvalue WordBreak + \omitvalue TextForceLeftToRight + \omitvalue TextForceRightToLeft + + You can use as many modifier flags as you want, except that + Qt::TextSingleLine and Qt::TextWordWrap cannot be combined. + + Flags that are inappropriate for a given use are generally + ignored. +*/ + +/*! + \enum Qt::BGMode + + Background mode: + + \value TransparentMode + \value OpaqueMode +*/ + +/*! + \enum Qt::ConnectionType + + This enum describes the types of connection that can be used between signals and + slots. In particular, it determines whether a particular signal is delivered to a + slot immediately or queued for delivery at a later time. + + \omitvalue AutoCompatConnection + \value DirectConnection When emitted, the signal is immediately delivered to the slot. + \value QueuedConnection When emitted, the signal is queued until the event loop is + able to deliver it to the slot. + \value BlockingQueuedConnection + Same as QueuedConnection, except that the current thread blocks + until the slot has been delivered. This connection type should + only be used for receivers in a different thread. Note that misuse + of this type can lead to deadlocks in your application. + \value AutoConnection If the signal is emitted from the thread + in which the receiving object lives, the + slot is invoked directly, as with + Qt::DirectConnection; otherwise the + signal is queued, as with + Qt::QueuedConnection. + \value UniqueConnection Same as AutoConnection, but there will be a check that the signal is + not already connected to the same slot before connecting, otherwise, + the connection will fail. + This value was introduced in Qt 4.6. + + With queued connections, the parameters must be of types that are known to + Qt's meta-object system, because Qt needs to copy the arguments to store them + in an event behind the scenes. If you try to use a queued connection and + get the error message + + \snippet doc/src/snippets/code/doc_src_qnamespace.qdoc 0 + + call qRegisterMetaType() to register the data type before you + establish the connection. + + \sa {Thread Support in Qt}, QObject::connect(), qRegisterMetaType() +*/ + +/*! + \enum Qt::DateFormat + + \value TextDate The default Qt format, which includes the day and month name, + the day number in the month, and the year in full. The day and month names will + be short, localized names. This is basically equivalent to using the date format + string, "ddd MMM d yyyy". See QDate::toString() for more information. + + \value ISODate ISO 8601 extended format: either \c{YYYY-MM-DD} for dates or + \c{YYYY-MM-DDTHH:MM:SS} for combined dates and times. + + \value SystemLocaleShortDate The \l{QLocale::ShortFormat}{short format} used + by the \l{QLocale::system()}{operating system}. + + \value SystemLocaleLongDate The \l{QLocale::LongFormat}{long format} used + by the \l{QLocale::system()}{operating system}. + + \value DefaultLocaleShortDate The \l{QLocale::ShortFormat}{short format} specified + by the \l{QLocale::setDefault()}{application's locale}. + + \value DefaultLocaleLongDate The \l{QLocale::LongFormat}{long format} used + by the \l{QLocale::setDefault()}{application's locale}. + + \value SystemLocaleDate \e{This enum value is deprecated.} Use Qt::SystemLocaleShortDate + instead (or Qt::SystemLocaleLongDate if you want long dates). + + \value LocaleDate \e{This enum value is deprecated.} Use Qt::DefaultLocaleShortDate + instead (or Qt::DefaultLocaleLongDate if you want long dates). + + \value LocalDate \e{This enum value is deprecated.} Use Qt::SystemLocaleShortDate + instead (or Qt::SystemLocaleLongDate if you want long dates). + + \note For \c ISODate formats, each \c Y, \c M and \c D represents a single digit + of the year, month and day used to specify the date. Each \c H, \c M and \c S + represents a single digit of the hour, minute and second used to specify the time. + The presence of a literal \c T character is used to separate the date and time when + both are specified. +*/ + + +/*! + \enum Qt::TimeSpec + + \value LocalTime Locale dependent time (Timezones and Daylight Savings Time). + \value UTC Coordinated Universal Time, replaces Greenwich Mean Time. + \value OffsetFromUTC An offset in seconds from Coordinated Universal Time. +*/ + +/*! + \enum Qt::DayOfWeek + + \value Monday + \value Tuesday + \value Wednesday + \value Thursday + \value Friday + \value Saturday + \value Sunday +*/ + +/*! + \enum Qt::CaseSensitivity + + \value CaseInsensitive + \value CaseSensitive +*/ + +/*! + \enum Qt::ToolBarArea + + \value LeftToolBarArea + \value RightToolBarArea + \value TopToolBarArea + \value BottomToolBarArea + \value AllToolBarAreas + \value NoToolBarArea + + \omitvalue ToolBarArea_Mask +*/ + +/*! + \enum Qt::DockWidgetArea + + \value LeftDockWidgetArea + \value RightDockWidgetArea + \value TopDockWidgetArea + \value BottomDockWidgetArea + \value AllDockWidgetAreas + \value NoDockWidgetArea + + \omitvalue DockWidgetArea_Mask +*/ + +/*! + \enum Qt::BackgroundMode + + \compat + + \value FixedColor + \value FixedPixmap + \value NoBackground + \value PaletteForeground + \value PaletteButton + \value PaletteLight + \value PaletteMidlight + \value PaletteDark + \value PaletteMid + \value PaletteText + \value PaletteBrightText + \value PaletteBase + \value PaletteBackground + \value PaletteShadow + \value PaletteHighlight + \value PaletteHighlightedText + \value PaletteButtonText + \value PaletteLink + \value PaletteLinkVisited + \value X11ParentRelative +*/ + +/*! + \enum Qt::ImageConversionFlag + + The options marked "(default)" are set if no other values from + the list are included (since the defaults are zero): + + Color/Mono preference (ignored for QBitmap): + + \value AutoColor (default) - If the image has \link + QImage::depth() depth\endlink 1 and contains only + black and white pixels, the pixmap becomes monochrome. + \value ColorOnly The pixmap is dithered/converted to the + \link QPixmap::defaultDepth() native display depth\endlink. + \value MonoOnly The pixmap becomes monochrome. If necessary, + it is dithered using the chosen dithering algorithm. + + Dithering mode preference for RGB channels: + + \value DiffuseDither (default) - A high-quality dither. + \value OrderedDither A faster, more ordered dither. + \value ThresholdDither No dithering; closest color is used. + + Dithering mode preference for alpha channel: + + \value ThresholdAlphaDither (default) - No dithering. + \value OrderedAlphaDither A faster, more ordered dither. + \value DiffuseAlphaDither A high-quality dither. + \omitvalue NoAlpha + + Color matching versus dithering preference: + + \value PreferDither (default when converting to a pixmap) - Always dither + 32-bit images when the image is converted to 8 bits. + \value AvoidDither (default when converting for the purpose of saving to + file) - Dither 32-bit images only if the image has more than 256 + colors and it is being converted to 8 bits. + \omitvalue AutoDither + + \omitvalue ColorMode_Mask + \omitvalue Dither_Mask + \omitvalue AlphaDither_Mask + \omitvalue DitherMode_Mask + \omitvalue NoOpaqueDetection +*/ + +/*! \enum Qt::GUIStyle + + \compat + + \value WindowsStyle + \value MotifStyle + \value MacStyle + \value Win3Style + \value PMStyle +*/ + +/*! + \enum Qt::UIEffect + + This enum describes the available UI effects. + + By default, Qt will try to use the platform specific desktop + settings for each effect. Use the + QApplication::setDesktopSettingsAware() function (passing \c false + as argument) to prevent this, and the + QApplication::setEffectEnabled() to enable or disable a particular + effect. + + Note that all effects are disabled on screens running at less than + 16-bit color depth. + + \omitvalue UI_General + + \value UI_AnimateMenu Show animated menus. + \value UI_FadeMenu Show faded menus. + \value UI_AnimateCombo Show animated comboboxes. + \value UI_AnimateTooltip Show tooltip animations. + \value UI_FadeTooltip Show tooltip fading effects. + \value UI_AnimateToolBox Reserved + + \sa QApplication::setEffectEnabled(), QApplication::setDesktopSettingsAware() +*/ + +/*! \enum Qt::AspectRatioMode + + This enum type defines what happens to the aspect ratio when + scaling an rectangle. + + \image qimage-scaling.png + + \value IgnoreAspectRatio The size is scaled freely. The aspect + ratio is not preserved. + \value KeepAspectRatio The size is scaled to a rectangle as + large as possible inside a given + rectangle, preserving the aspect ratio. + \value KeepAspectRatioByExpanding The size is scaled to a + rectangle as small as possible + outside a given rectangle, + preserving the aspect ratio. + + \omitvalue ScaleFree + \omitvalue ScaleMin + \omitvalue ScaleMax + + \sa QSize::scale(), QImage::scaled() +*/ + +/*! \typedef Qt::ScaleMode + \compat + + Use Qt::AspectRatioMode instead. + + The enum values have been renamed as follows: + + \table + \row \i Old enum value \i New enum value + \row \i Qt::ScaleFree \i Qt::IgnoreAspectRatio + \row \i Qt::ScaleMin \i Qt::KeepAspectRatio + \row \i Qt::ScaleMax \i Qt::KeepAspectRatioByExpanding + \endtable +*/ + +/*! \enum Qt::TransformationMode + + This enum type defines whether image transformations (e.g., + scaling) should be smooth or not. + + \value FastTransformation The transformation is performed + quickly, with no smoothing. + \value SmoothTransformation The resulting image is transformed + using bilinear filtering. + + \sa QImage::scaled() +*/ + +/*! \enum Qt::Axis + + This enum type defines three values to represent the three + axes in the cartesian coordinate system. + + \value XAxis The X axis. + \value YAxis The Y axis. + \value ZAxis The Z axis. + + \sa QTransform::rotate(), QTransform::rotateRadians() + */ + +/*! + \enum Qt::WidgetAttribute + + \keyword widget attributes + + This enum type is used to specify various widget attributes. + Attributes are set and cleared with QWidget::setAttribute(), and + queried with QWidget::testAttribute(), although some have special + convenience functions which are mentioned below. + + \value WA_AcceptDrops Allows data from drag and drop operations + to be dropped onto the widget (see QWidget::setAcceptDrops()). + + \value WA_AlwaysShowToolTips Enables tooltips for inactive windows. + + \value WA_ContentsPropagated This flag is superfluous and + obsolete; it no longer has any effect. Since Qt 4.1, all widgets + that do not set WA_PaintOnScreen propagate their contents. + + \value WA_CustomWhatsThis Indicates that the widget wants to + continue operating normally in "What's This?" mode. This is set by the + widget's author. + + \value WA_DeleteOnClose Makes Qt delete this widget when the + widget has accepted the close event (see QWidget::closeEvent()). + + \value WA_Disabled Indicates that the widget is disabled, i.e. + it does not receive any mouse or keyboard events. There is also a + getter functions QWidget::isEnabled(). This is set/cleared by the + Qt kernel. + + \omitvalue WA_DropSiteRegistered + \omitvalue WA_ForceAcceptDrops + + \value WA_ForceDisabled Indicates that the widget is + explicitly disabled, i.e. it will remain disabled even when all + its ancestors are set to the enabled state. This implies + WA_Disabled. This is set/cleared by QWidget::setEnabled() and + QWidget::setDisabled(). + + \value WA_ForceUpdatesDisabled Indicates that updates are + explicitly disabled for the widget; i.e. it will remain disabled + even when all its ancestors are set to the updates-enabled state. + This implies WA_UpdatesDisabled. This is set/cleared by + QWidget::setUpdatesEnabled(). + + \value WA_GroupLeader + \e{This attribute has been deprecated.} Use QWidget::windowModality + instead. + + \value WA_Hover Forces Qt to generate paint events when the mouse + enters or leaves the widget. This feature is typically used when + implementing custom styles; see the \l{widgets/styles}{Styles} + example for details. + + \value WA_InputMethodEnabled Enables input methods for Asian languages. + Must be set when creating custom text editing widgets. + On Windows CE this flag can be used in addition to + QApplication::autoSipEnabled to automatically display the SIP when + entering a widget. + + \value WA_KeyboardFocusChange Set on a toplevel window when + the users changes focus with the keyboard (tab, backtab, or shortcut). + + \value WA_KeyCompression Enables key event compression if set, + and disables it if not set. By default key compression is off, so + widgets receive one key press event for each key press (or more, + since autorepeat is usually on). If you turn it on and your + program doesn't keep up with key input, Qt may try to compress key + events so that more than one character can be processed in each + event. + For example, a word processor widget might receive 2, 3 or more + characters in each QKeyEvent::text(), if the layout recalculation + takes too long for the CPU. + If a widget supports multiple character unicode input, it is + always safe to turn the compression on. + Qt performs key event compression only for printable characters. + Qt::Modifier keys, cursor movement keys, function keys and + miscellaneous action keys (e.g. Escape, Enter, Backspace, + PrintScreen) will stop key event compression, even if there are + more compressible key events available. + Platforms other than Mac and X11 do not support this compression, + in which case turning it on will have no effect. + This is set/cleared by the widget's author. + + \value WA_LayoutOnEntireRect Indicates that the widget + wants QLayout to operate on the entire QWidget::rect(), not only + on QWidget::contentsRect(). This is set by the widget's author. + + \value WA_LayoutUsesWidgetRect Ignore the layout item rect from the style + when laying out this widget with QLayout. This makes a difference in + QMacStyle and QPlastiqueStyle for some widgets. + + \value WA_MacNoClickThrough When a widget that has this attribute set + is clicked, and its window is inactive, the click will make the window + active but won't be seen by the widget. Typical use of this attribute + is on widgets with "destructive" actions, such as a "Delete" button. + WA_MacNoClickThrough also applies to all child widgets of the widget + that has it set. + + \value WA_MacOpaqueSizeGrip Indicates that the native Carbon size grip + should be opaque instead of transparent (the default). This attribute + is only applicable to Mac OS X and is set by the widget's author. + + \value WA_MacShowFocusRect Indicates that this widget should get a + QFocusFrame around it. Some widgets draw their own focus halo + regardless of this attribute. Not that the QWidget::focusPolicy + also plays the main role in whether something is given focus or + not, this only controls whether or not this gets the focus + frame. This attribute is only applicable to Mac OS X. + + \value WA_MacNormalSize Indicates the widget should have the + normal size for widgets in Mac OS X. This attribute is only + applicable to Mac OS X. + + \value WA_MacSmallSize Indicates the widget should have the small + size for widgets in Mac OS X. This attribute is only applicable to + Mac OS X. + + \value WA_MacMiniSize Indicates the widget should have the mini + size for widgets in Mac OS X. This attribute is only applicable to + Mac OS X. + + \value WA_MacVariableSize Indicates the widget can choose between + alternative sizes for widgets to avoid clipping. + This attribute is only applicable to Mac OS X. + + \value WA_MacBrushedMetal Indicates the widget should be drawn in + the brushed metal style as supported by the windowing system. This + attribute is only applicable to Mac OS X. + + \omitvalue WA_MacMetalStyle + + \value WA_Mapped Indicates that the widget is mapped on screen. + This is set/cleared by the Qt kernel. + + \value WA_MouseNoMask Makes the widget receive mouse events for + the entire widget regardless of the currently set mask, + overriding QWidget::setMask(). This is not applicable for + top-level windows. + + \value WA_MouseTracking Indicates that the widget has mouse + tracking enabled. See QWidget::mouseTracking. + + \value WA_Moved Indicates that the widget has an explicit + position. This is set/cleared by QWidget::move() and + by QWidget::setGeometry(). + + \value WA_MSWindowsUseDirect3D This value is obsolete and has no + effect. + + \value WA_NoBackground This value is obsolete. Use + WA_OpaquePaintEvent instead. + + \value WA_NoChildEventsForParent Indicates that the widget does + not want ChildAdded or ChildRemoved events sent to its + parent. This is rarely necessary but can help to avoid automatic + insertion widgets like splitters and layouts. This is set by a + widget's author. + + \value WA_NoChildEventsFromChildren Indicates that the widget does + not want to receive ChildAdded or ChildRemoved events sent from its + children. This is set by a widget's author. + + \value WA_NoMouseReplay Used for pop-up widgets. Indicates that the most + recent mouse press event should not be replayed when the pop-up widget + closes. The flag is set by the widget's author and cleared by the Qt kernel + every time the widget receives a new mouse event. + + \value WA_NoMousePropagation Prohibits mouse events from being propagated + to the widget's parent. This attribute is disabled by default. + + \value WA_TransparentForMouseEvents When enabled, this attribute disables + the delivery of mouse events to the widget and its children. Mouse events + are delivered to other widgets as if the widget and its children were not + present in the widget hierarchy; mouse clicks and other events effectively + "pass through" them. This attribute is disabled by default. + + \value WA_NoSystemBackground Indicates that the widget has no background, + i.e. when the widget receives paint events, the background is not + automatically repainted. \note Unlike WA_OpaquePaintEvent, newly exposed + areas are \bold never filled with the background (e.g., after showing a + window for the first time the user can see "through" it until the + application processes the paint events). This flag is set or cleared by the + widget's author. + + \value WA_OpaquePaintEvent Indicates that the widget paints all its pixels + when it receives a paint event. Thus, it is not required for operations + like updating, resizing, scrolling and focus changes to erase the widget + before generating paint events. The use of WA_OpaquePaintEvent provides a + small optimization by helping to reduce flicker on systems that do not + support double buffering and avoiding computational cycles necessary to + erase the background prior to painting. \note Unlike + WA_NoSystemBackground, WA_OpaquePaintEvent makes an effort to avoid + transparent window backgrounds. This flag is set or cleared by the widget's + author. + + \value WA_OutsideWSRange Indicates that the widget is outside + the valid range of the window system's coordinate system. A widget + outside the valid range cannot be mapped on screen. This is + set/cleared by the Qt kernel. + + \value WA_PaintOnScreen Indicates that the widget wants to draw directly + onto the screen. Widgets with this attribute set do not participate in + composition management, i.e. they cannot be semi-transparent or shine + through semi-transparent overlapping widgets. \note This flag is only + supported on X11 and it disables double buffering. On Qt for Embedded + Linux, the flag only works when set on a top-level widget and it relies on + support from the active screen driver. This flag is set or cleared by the + widget's author. To render outside of Qt's paint system, e.g., if you + require native painting primitives, you need to reimplement + QWidget::paintEngine() to return 0 and set this flag. + + \value WA_PaintOutsidePaintEvent Makes it possible to use QPainter to + paint on the widget outside \l{QWidget::paintEvent()}{paintEvent()}. This + flag is not supported on Windows, Mac OS X or Embedded Linux. We recommend + that you use it only when porting Qt 3 code to Qt 4. + + \value WA_PaintUnclipped Makes all painters operating on this widget + unclipped. Children of this widget or other widgets in front of it do not + clip the area the painter can paint on. This flag is only supported for + widgets with the WA_PaintOnScreen flag set. The preferred way to do this in + a cross platform way is to create a transparent widget that lies in front + of the other widgets. + + \value WA_PendingMoveEvent Indicates that a move event is pending, e.g., + when a hidden widget was moved. This flag is set or cleared by the Qt + kernel. + + \value WA_PendingResizeEvent Indicates that a resize event is pending, + e.g., when a hidden widget was resized. This flag is set or cleared by the + Qt kernel. + + \value WA_QuitOnClose Makes Qt quit the application when the last widget + with the attribute set has accepted closeEvent(). This behavior can be + modified with the QApplication::quitOnLastWindowClosed property. By default + this attribute is set for all widgets of type Qt::Window. + + \value WA_Resized Indicates that the widget has an explicit size. This flag + is set or cleared by QWidget::resize() and QWidget::setGeometry(). + + \value WA_RightToLeft Indicates that the layout direction for the widget + is right to left. + + \value WA_SetCursor Indicates that the widget has a cursor of its own. This + flag is set or cleared by QWidget::setCursor() and QWidget::unsetCursor(). + + \value WA_SetFont Indicates that the widget has a font of its own. This + flag is set or cleared by QWidget::setFont(). + + \value WA_SetPalette Indicates that the widget has a palette of its own. + This flag is set or cleared by QWidget::setPalette(). + + \value WA_SetStyle Indicates that the widget has a style of its own. This + flag is set or cleared by QWidget::setStyle(). + + \value WA_ShowModal \e{This attribute has been deprecated.} Use + QWidget::windowModality instead. + + \value WA_StaticContents Indicates that the widget contents are north-west + aligned and static. On resize, such a widget will receive paint events only + for parts of itself that are newly visible. This flag is set or cleared by + the widget's author. + + \value WA_StyleSheet Indicates that the widget is styled using a + \l{Qt Style Sheets}{style sheet}. + + \value WA_TranslucentBackground Indicates that the widget should have a + translucent background, i.e., any non-opaque regions of the widgets will be + translucent because the widget will have an alpha channel. Setting this + flag causes WA_NoSystemBackground to be set. On Windows the + widget also needs the Qt::FramelessWindowHint window flag to be set. + This flag is set or cleared by the widget's author. + + \value WA_UnderMouse Indicates that the widget is under the mouse cursor. + The value is not updated correctly during drag and drop operations. There + is also a getter function, QWidget::underMouse(). This flag is set or + cleared by the Qt kernel. + + \value WA_UpdatesDisabled Indicates that updates are blocked (including the + system background). This flag is set or cleared by the Qt kernel. + \warning This flag must \e never be set or cleared by the widget's author. + + \value WA_WindowModified Indicates that the window is marked as modified. + On some platforms this flag will do nothing, on others (including Mac OS X + and Windows) the window will take a modified appearance. This flag is set + or cleared by QWidget::setWindowModified(). + + \value WA_WindowPropagation Makes a toplevel window inherit font and + palette from its parent. + + \value WA_MacAlwaysShowToolWindow On Mac OS X, show the tool window even + when the application is not active. By default, all tool windows are + hidden when the application is inactive. + + \value WA_SetLocale Indicates the locale should be taken into consideration + in the widget. + + \value WA_StyledBackground Indicates the widget should be drawn using a + styled background. + + \value WA_ShowWithoutActivating Show the widget without making it active. + + \value WA_NativeWindow Indicates that a native window is created for the + widget. Enabling this flag will also force a native window for the widget's + ancestors unless Qt::WA_DontCreateNativeAncestors is set. + + \value WA_DontCreateNativeAncestors Indicates that the widget's ancestors + are kept non-native even though the widget itself is native. + + \value WA_X11NetWmWindowTypeDesktop Adds _NET_WM_WINDOW_TYPE_DESKTOP to the + window's _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This attribute + has no effect on non-X11 platforms. + + \value WA_X11NetWmWindowTypeDock Adds _NET_WM_WINDOW_TYPE_DOCK to the + window's _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This attribute + has no effect on non-X11 platforms. + + \value WA_X11NetWmWindowTypeToolBar Adds _NET_WM_WINDOW_TYPE_TOOLBAR to the + window's _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This attribute + has no effect on non-X11 platforms. \note Qt automaticaly sets this + attribute for QToolBar. + + \value WA_X11NetWmWindowTypeMenu Adds _NET_WM_WINDOW_TYPE_MENU to the + window's _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This attribute + has no effect on non-X11 platforms. \note Qt automatically sets this + attribute for QMenu when torn-off. + + \value WA_X11NetWmWindowTypeUtility Adds _NET_WM_WINDOW_TYPE_UTILITY to the + window's _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This attribute + has no effect on non-X11 platforms. \note Qt automatically sets this + attribute for the Qt::Tool window type. + + \value WA_X11NetWmWindowTypeSplash Adds _NET_WM_WINDOW_TYPE_SPLASH to the + window's _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This attribute + has no effect on non-X11 platforms. \note Qt automatically sets this + attribute for the Qt::SplashScreen window type. + + \value WA_X11NetWmWindowTypeDialog Adds _NET_WM_WINDOW_TYPE_DIALOG + to the window's _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This + attribute has no effect on non-X11 platforms. \note Qt automatically sets + this attribute for the Qt::Dialog and Qt::Sheet window types. + + \value WA_X11NetWmWindowTypeDropDownMenu Adds + _NET_WM_WINDOW_TYPE_DROPDOWN_MENU to the window's + _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This + attribute has no effect on non-X11 platforms. \note Qt + automatically sets this attribute for QMenus added to a QMenuBar. + + \value WA_X11NetWmWindowTypePopupMenu Adds _NET_WM_WINDOW_TYPE_POPUP_MENU + to the window's _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This attribute + has no effect on non-X11 platforms. \note Qt automatically sets this + attribute for QMenu. + + \value WA_X11NetWmWindowTypeToolTip Adds _NET_WM_WINDOW_TYPE_TOOLTIP to the + window's _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This attribute + has no effect on non-X11 platforms. \note Qt automatically sets this + attribute for the Qt::ToolTip window type. + + \value WA_X11NetWmWindowTypeNotification Adds + _NET_WM_WINDOW_TYPE_NOTIFICATION to the window's _NET_WM_WINDOW_TYPE X11 + window property. See http://standards.freedesktop.org/wm-spec/ for more + details. This attribute has no effect on non-X11 platforms. + + \value WA_X11NetWmWindowTypeCombo Adds _NET_WM_WINDOW_TYPE_COMBO + to the window's _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This attribute + has no effect on non-X11 platforms. \note Qt automatically sets this + attribute for the QComboBox pop-up. + + \value WA_X11NetWmWindowTypeDND Adds _NET_WM_WINDOW_TYPE_DND to + the window's _NET_WM_WINDOW_TYPE X11 window property. See + http://standards.freedesktop.org/wm-spec/ for more details. This attribute + has no effect on non-X11 platforms. \note Qt automatically sets this + attribute on the feedback widget used during a drag. + + \value WA_MacFrameworkScaled Enables resolution independence aware mode + on Mac when using Carbon. This attribute has no effect on Cocoa. + The attribute is off by default and can be enabled on a per-window basis. + + \value WA_AcceptTouchEvents Allows touch events (see QTouchEvent) + to be sent to the widget. Must be set on all widgets that can + handle touch events. Without this attribute set, events from a + touch device will be sent as mouse events. + + \value WA_TouchPadAcceptSingleTouchEvents Allows touchpad single + touch events to be sent to the widget. + + \omitvalue WA_SetLayoutDirection + \omitvalue WA_InputMethodTransparent + \omitvalue WA_WState_CompressKeys + \omitvalue WA_WState_ConfigPending + \omitvalue WA_WState_Created + \omitvalue WA_WState_DND + \omitvalue WA_WState_ExplicitShowHide + \omitvalue WA_WState_Hidden + \omitvalue WA_WState_InPaintEvent + \omitvalue WA_WState_OwnSizePolicy + \omitvalue WA_WState_Polished + \omitvalue WA_WState_Reparented + \omitvalue WA_WState_Visible + \omitvalue WA_SetWindowIcon + \omitvalue WA_PendingUpdate + \omitvalue WA_LaidOut + \omitvalue WA_GrabbedShortcut + \omitvalue WA_DontShowOnScreen + \omitvalue WA_InvalidSize + \omitvalue WA_ForceUpdatesDisabled + \omitvalue WA_NoX11EventCompression + \omitvalue WA_TintedBackground + \omitvalue WA_X11OpenGLOverlay + \omitvalue WA_CanHostQMdiSubWindowTitleBar + \omitvalue WA_AttributeCount + \omitvalue WA_StyleSheet + \omitvalue WA_X11BypassTransientForHint + \omitvalue WA_SetWindowModality + \omitvalue WA_WState_WindowOpacitySet + \omitvalue WA_WState_AcceptedTouchBeginEvent +*/ + +/*! \typedef Qt::HANDLE + + Platform-specific handle type for system objects. This is + equivalent to \c{void *} on Mac OS X and embedded Linux, + and to \c{unsigned long} on X11. On Windows it is the + DWORD returned by the Win32 function getCurrentThreadId(). + + \warning Using this type is not portable. +*/ + +/*! + \enum Qt::Key + + The key names used by Qt. + + \value Key_Escape + \value Key_Tab + \value Key_Backtab + \omitvalue Key_BackTab + \value Key_Backspace + \omitvalue Key_BackSpace + \value Key_Return + \value Key_Enter Typically located on the keypad. + \value Key_Insert + \value Key_Delete + \value Key_Pause + \value Key_Print + \value Key_SysReq + \value Key_Clear + \value Key_Home + \value Key_End + \value Key_Left + \value Key_Up + \value Key_Right + \value Key_Down + \value Key_PageUp + \omitvalue Key_Prior + \value Key_PageDown + \omitvalue Key_Next + \value Key_Shift + \value Key_Control On Mac OS X, this corresponds to the Command keys. + \value Key_Meta On Mac OS X, this corresponds to the Control keys. + On Windows keyboards, this key is mapped to the + Windows key. + \value Key_Alt + \value Key_AltGr On Windows, when the KeyDown event for this key is + sent, the Ctrl+Alt modifiers are also set. + \value Key_CapsLock + \value Key_NumLock + \value Key_ScrollLock + \value Key_F1 + \value Key_F2 + \value Key_F3 + \value Key_F4 + \value Key_F5 + \value Key_F6 + \value Key_F7 + \value Key_F8 + \value Key_F9 + \value Key_F10 + \value Key_F11 + \value Key_F12 + \value Key_F13 + \value Key_F14 + \value Key_F15 + \value Key_F16 + \value Key_F17 + \value Key_F18 + \value Key_F19 + \value Key_F20 + \value Key_F21 + \value Key_F22 + \value Key_F23 + \value Key_F24 + \value Key_F25 + \value Key_F26 + \value Key_F27 + \value Key_F28 + \value Key_F29 + \value Key_F30 + \value Key_F31 + \value Key_F32 + \value Key_F33 + \value Key_F34 + \value Key_F35 + \value Key_Super_L + \value Key_Super_R + \value Key_Menu + \value Key_Hyper_L + \value Key_Hyper_R + \value Key_Help + \value Key_Direction_L + \value Key_Direction_R + \value Key_Space + \value Key_Any + \value Key_Exclam + \value Key_QuoteDbl + \value Key_NumberSign + \value Key_Dollar + \value Key_Percent + \value Key_Ampersand + \value Key_Apostrophe + \value Key_ParenLeft + \value Key_ParenRight + \value Key_Asterisk + \value Key_Plus + \value Key_Comma + \value Key_Minus + \value Key_Period + \value Key_Slash + \value Key_0 + \value Key_1 + \value Key_2 + \value Key_3 + \value Key_4 + \value Key_5 + \value Key_6 + \value Key_7 + \value Key_8 + \value Key_9 + \value Key_Colon + \value Key_Semicolon + \value Key_Less + \value Key_Equal + \value Key_Greater + \value Key_Question + \value Key_At + \value Key_A + \value Key_B + \value Key_C + \value Key_D + \value Key_E + \value Key_F + \value Key_G + \value Key_H + \value Key_I + \value Key_J + \value Key_K + \value Key_L + \value Key_M + \value Key_N + \value Key_O + \value Key_P + \value Key_Q + \value Key_R + \value Key_S + \value Key_T + \value Key_U + \value Key_V + \value Key_W + \value Key_X + \value Key_Y + \value Key_Z + \value Key_BracketLeft + \value Key_Backslash + \value Key_BracketRight + \value Key_AsciiCircum + \value Key_Underscore + \value Key_QuoteLeft + \value Key_BraceLeft + \value Key_Bar + \value Key_BraceRight + \value Key_AsciiTilde + \value Key_nobreakspace + \value Key_exclamdown + \value Key_cent + \value Key_sterling + \value Key_currency + \value Key_yen + \value Key_brokenbar + \value Key_section + \value Key_diaeresis + \value Key_copyright + \value Key_ordfeminine + \value Key_guillemotleft + \value Key_notsign + \value Key_hyphen + \value Key_registered + \value Key_macron + \value Key_degree + \value Key_plusminus + \value Key_twosuperior + \value Key_threesuperior + \value Key_acute + \value Key_mu + \value Key_paragraph + \value Key_periodcentered + \value Key_cedilla + \value Key_onesuperior + \value Key_masculine + \value Key_guillemotright + \value Key_onequarter + \value Key_onehalf + \value Key_threequarters + \value Key_questiondown + \value Key_Agrave + \value Key_Aacute + \value Key_Acircumflex + \value Key_Atilde + \value Key_Adiaeresis + \value Key_Aring + \value Key_AE + \value Key_Ccedilla + \value Key_Egrave + \value Key_Eacute + \value Key_Ecircumflex + \value Key_Ediaeresis + \value Key_Igrave + \value Key_Iacute + \value Key_Icircumflex + \value Key_Idiaeresis + \value Key_ETH + \value Key_Ntilde + \value Key_Ograve + \value Key_Oacute + \value Key_Ocircumflex + \value Key_Otilde + \value Key_Odiaeresis + \value Key_multiply + \value Key_Ooblique + \value Key_Ugrave + \value Key_Uacute + \value Key_Ucircumflex + \value Key_Udiaeresis + \value Key_Yacute + \value Key_THORN + \value Key_ssharp + \omitvalue Key_agrave + \omitvalue Key_aacute + \omitvalue Key_acircumflex + \omitvalue Key_atilde + \omitvalue Key_adiaeresis + \omitvalue Key_aring + \omitvalue Key_ae + \omitvalue Key_ccedilla + \omitvalue Key_egrave + \omitvalue Key_eacute + \omitvalue Key_ecircumflex + \omitvalue Key_ediaeresis + \omitvalue Key_igrave + \omitvalue Key_iacute + \omitvalue Key_icircumflex + \omitvalue Key_idiaeresis + \omitvalue Key_eth + \omitvalue Key_ntilde + \omitvalue Key_ograve + \omitvalue Key_oacute + \omitvalue Key_ocircumflex + \omitvalue Key_otilde + \omitvalue Key_odiaeresis + \value Key_division + \omitvalue Key_oslash + \omitvalue Key_ugrave + \omitvalue Key_uacute + \omitvalue Key_ucircumflex + \omitvalue Key_udiaeresis + \omitvalue Key_yacute + \omitvalue Key_thorn + \value Key_ydiaeresis + \value Key_Multi_key + \value Key_Codeinput + \value Key_SingleCandidate + \value Key_MultipleCandidate + \value Key_PreviousCandidate + \value Key_Mode_switch + \value Key_Kanji + \value Key_Muhenkan + \value Key_Henkan + \value Key_Romaji + \value Key_Hiragana + \value Key_Katakana + \value Key_Hiragana_Katakana + \value Key_Zenkaku + \value Key_Hankaku + \value Key_Zenkaku_Hankaku + \value Key_Touroku + \value Key_Massyo + \value Key_Kana_Lock + \value Key_Kana_Shift + \value Key_Eisu_Shift + \value Key_Eisu_toggle + \value Key_Hangul + \value Key_Hangul_Start + \value Key_Hangul_End + \value Key_Hangul_Hanja + \value Key_Hangul_Jamo + \value Key_Hangul_Romaja + \value Key_Hangul_Jeonja + \value Key_Hangul_Banja + \value Key_Hangul_PreHanja + \value Key_Hangul_PostHanja + \value Key_Hangul_Special + \value Key_Dead_Grave + \value Key_Dead_Acute + \value Key_Dead_Circumflex + \value Key_Dead_Tilde + \value Key_Dead_Macron + \value Key_Dead_Breve + \value Key_Dead_Abovedot + \value Key_Dead_Diaeresis + \value Key_Dead_Abovering + \value Key_Dead_Doubleacute + \value Key_Dead_Caron + \value Key_Dead_Cedilla + \value Key_Dead_Ogonek + \value Key_Dead_Iota + \value Key_Dead_Voiced_Sound + \value Key_Dead_Semivoiced_Sound + \value Key_Dead_Belowdot + \value Key_Dead_Hook + \value Key_Dead_Horn + \value Key_Back + \value Key_Forward + \value Key_Stop + \value Key_Refresh + \value Key_VolumeDown + \value Key_VolumeMute + \value Key_VolumeUp + \value Key_BassBoost + \value Key_BassUp + \value Key_BassDown + \value Key_TrebleUp + \value Key_TrebleDown + \value Key_MediaPlay + \value Key_MediaStop + \value Key_MediaPrevious + \omitvalue Key_MediaPrev + \value Key_MediaNext + \value Key_MediaRecord + \value Key_HomePage + \value Key_Favorites + \value Key_Search + \value Key_Standby + \value Key_OpenUrl + \value Key_LaunchMail + \value Key_LaunchMedia + \value Key_Launch0 + \value Key_Launch1 + \value Key_Launch2 + \value Key_Launch3 + \value Key_Launch4 + \value Key_Launch5 + \value Key_Launch6 + \value Key_Launch7 + \value Key_Launch8 + \value Key_Launch9 + \value Key_LaunchA + \value Key_LaunchB + \value Key_LaunchC + \value Key_LaunchD + \value Key_LaunchE + \value Key_LaunchF + \value Key_MediaLast + \value Key_unknown + + \value Key_Call + \value Key_Context1 + \value Key_Context2 + \value Key_Context3 + \value Key_Context4 + \value Key_Flip + \value Key_Hangup + \value Key_No + \value Key_Select + \value Key_Yes + + \value Key_Execute + \value Key_Printer + \value Key_Play + \value Key_Sleep + \value Key_Zoom + \value Key_Cancel + + \sa QKeyEvent::key() +*/ + +/*! + \enum Qt::HitTestAccuracy + + This enum contains the types of accuracy that can be used by the + QTextDocument class when testing for mouse clicks on text documents. + + \value ExactHit The point at which input occurred must coincide + exactly with input-sensitive parts of the document. + \value FuzzyHit The point at which input occurred can lie close to + input-sensitive parts of the document. + + This enum is defined in the \c header file. +*/ + +/*! + \enum Qt::WhiteSpaceMode + + This enum describes the types of whitespace mode that are used by + the QTextDocument class to meet the requirements of different kinds + of textual information. + + \value WhiteSpaceNormal The whitespace mode used to display + normal word wrapped text in paragraphs. + \value WhiteSpacePre A preformatted text mode in which + whitespace is reproduced exactly. + \value WhiteSpaceNoWrap + + \omitvalue WhiteSpaceModeUndefined + + This enum is defined in the \c header file. +*/ + +/*! + \enum Qt::ButtonState_enum + \compat + \value ShiftButton + \value ControlButton + \value AltButton + \value MetaButton + \value Keypad + \value KeyButtonMask + + Use Qt::KeyboardModifier instead. +*/ + +/*! + \typedef Qt::ButtonState + \compat + + Use Qt::KeyboardModifier instead. +*/ + +/*! + \enum Qt::CheckState + + This enum describes the state of checkable items, controls, and widgets. + + \value Unchecked The item is unchecked. + \value PartiallyChecked The item is partially checked. Items in hierarchical models + may be partially checked if some, but not all, of their + children are checked. + \value Checked The item is checked. + + \sa QCheckBox, Qt::ItemFlags, Qt::ItemDataRole +*/ + + +/*! + \enum Qt::ToolButtonStyle + + The style of the tool button, describing how the button's text and + icon should be displayed. + + \value ToolButtonIconOnly Only display the icon. + \value ToolButtonTextOnly Only display the text. + \value ToolButtonTextBesideIcon The text appears beside the icon. + \value ToolButtonTextUnderIcon The text appears under the icon. + \value ToolButtonFollowStyle Follow the \l{QStyle::SH_ToolButtonStyle}{style}. +*/ + +/*! + \enum Qt::Corner + + This enum type specifies a corner in a rectangle: + + \value TopLeftCorner The top-left corner of the rectangle. + \value TopRightCorner The top-right corner of the rectangle. + \value BottomLeftCorner The bottom-left corner of the rectangle. + \value BottomRightCorner The bottom-right corner of the rectangle. + + \omitvalue TopLeft + \omitvalue TopRight + \omitvalue BottomLeft + \omitvalue BottomRight +*/ + +/*! + \enum Qt::ScrollBarPolicy + + This enum type describes the various modes of QAbstractScrollArea's scroll + bars. + + \value ScrollBarAsNeeded QAbstractScrollArea shows a scroll bar when the + content is too large to fit and not otherwise. This is the + default. + + \value ScrollBarAlwaysOff QAbstractScrollArea never shows a scroll bar. + + \value ScrollBarAlwaysOn QAbstractScrollArea always shows a scroll bar. + + (The modes for the horizontal and vertical scroll bars are + independent.) +*/ + +/*! + \enum Qt::ArrowType + + \value NoArrow + \value UpArrow + \value DownArrow + \value LeftArrow + \value RightArrow +*/ + +/*! + \enum Qt::FocusReason + + This enum specifies why the focus changed. It will be passed + through QWidget::setFocus and can be retrieved in the QFocusEvent + sent to the widget upon focus change. + + \value MouseFocusReason A mouse action occurred. + \value TabFocusReason The Tab key was pressed. + \value BacktabFocusReason A Backtab occurred. The input for this may + include the Shift or Control keys; + e.g. Shift+Tab. + \value ActiveWindowFocusReason The window system made this window either + active or inactive. + \value PopupFocusReason The application opened/closed a pop-up that + grabbed/released the keyboard focus. + \value ShortcutFocusReason The user typed a label's buddy shortcut + \value MenuBarFocusReason The menu bar took focus. + \value OtherFocusReason Another reason, usually application-specific. + + \omitvalue NoFocusReason + + \sa {Keyboard Focus} +*/ + +/*! + \enum Qt::WindowState + + \keyword window state + + This enum type is used to specify the current state of a top-level + window. + + The states are + + \value WindowNoState The window has no state set (in normal state). + \value WindowMinimized The window is minimized (i.e. iconified). + \value WindowMaximized The window is maximized with a frame around it. + \value WindowFullScreen The window fills the entire screen without any frame around it. + \value WindowActive The window is the active window, i.e. it has keyboard focus. + +*/ + +/*! + \enum Qt::ContextMenuPolicy + + This enum type defines the various policies a widget can have with + respect to showing a context menu. + + \value NoContextMenu the widget does not feature a context menu, + context menu handling is deferred to the widget's parent. + \value PreventContextMenu the widget does not feature a context + menu, and in contrast to \c NoContextMenu, the handling is \e not + deferred to the widget's parent. This means that all right mouse + button events are guaranteed to be delivered to the widget itself + through mousePressEvent(), and mouseReleaseEvent(). + \value DefaultContextMenu the widget's QWidget::contextMenuEvent() handler is called. + \value ActionsContextMenu the widget displays its QWidget::actions() as context menu. + \value CustomContextMenu the widget emits the QWidget::customContextMenuRequested() signal. +*/ + +/*! + \enum Qt::FocusPolicy + + This enum type defines the various policies a widget can have with + respect to acquiring keyboard focus. + + \value TabFocus the widget accepts focus by tabbing. + \value ClickFocus the widget accepts focus by clicking. + \value StrongFocus the widget accepts focus by both tabbing + and clicking. On Mac OS X this will also + be indicate that the widget accepts tab focus + when in 'Text/List focus mode'. + \value WheelFocus like Qt::StrongFocus plus the widget accepts + focus by using the mouse wheel. + \value NoFocus the widget does not accept focus. + +*/ + +/*! + \enum Qt::ShortcutContext + + For a QEvent::Shortcut event to occur, the shortcut's key sequence + must be entered by the user in a context where the shortcut is + active. The possible contexts are these: + + \value WidgetShortcut The shortcut is active when its + parent widget has focus. + \value WidgetWithChildrenShortcut The shortcut is active + when its parent widget, or any of its children has focus. + Children which are top-level widgets, except pop-ups, are + not affected by this shortcut context. + \value WindowShortcut The shortcut is active when its + parent widget is a logical subwidget of the + active top-level window. + \value ApplicationShortcut The shortcut is active when one of + the applications windows are active. +*/ + +/*! + \typedef Qt::WFlags + + Synonym for Qt::WindowFlags. +*/ + +/*! + \enum Qt::WindowType + + \keyword window flag + + This enum type is used to specify various window-system properties + for the widget. They are fairly unusual but necessary in a few + cases. Some of these flags depend on whether the underlying window + manager supports them. + + The main types are + + \value Widget This is the default type for QWidget. Widgets of + this type are child widgets if they have a parent, + and independent windows if they have no parent. + See also Qt::Window and Qt::SubWindow. + + \value Window Indicates that the widget is a window, usually + with a window system frame and a title bar, + irrespective of whether the widget has a parent or + not. Note that it is not possible to unset this + flag if the widget does not have a parent. + + \value Dialog Indicates that the widget is a window that should + be decorated as a dialog (i.e., typically no + maximize or minimize buttons in the title bar). + This is the default type for QDialog. If you want + to use it as a modal dialog, it should be launched + from another window, or have a parent and used + with the QWidget::windowModality property. If you make + it modal, the dialog will prevent other top-level + windows in the application from getting any input. + We refer to a top-level window that has a parent + as a \e secondary window. + + \value Sheet Indicates that the widget is a Macintosh sheet. + + \value Drawer Indicates that the widget is a Macintosh drawer. + + \value Popup Indicates that the widget is a pop-up top-level + window, i.e. that it is modal, but has a window + system frame appropriate for pop-up menus. + + \value Tool Indicates that the widget is a tool window. A tool + window is often a small window with a smaller than + usual title bar and decoration, typically used for + collections of tool buttons. It there is a parent, + the tool window will always be kept on top of it. + If there isn't a parent, you may consider using + Qt::WindowStaysOnTopHint as well. If the window + system supports it, a tool window can be decorated + with a somewhat lighter frame. It can also be + combined with Qt::FramelessWindowHint. + \br + \br + On Mac OS X, tool windows correspond to the + \l{http://developer.apple.com/documentation/Carbon/Conceptual/HandlingWindowsControls/hitb-wind_cont_concept/chapter_2_section_2.html}{Floating} + class of windows. This means that the window lives on a + level above normal windows; it impossible to put a normal + window on top of it. By default, tool windows will disappear + when the application is inactive. This can be controlled by + the Qt::WA_MacAlwaysShowToolWindow attribute. + + \value ToolTip Indicates that the widget is a tooltip. This is + used internally to implement + \l{QWidget::toolTip}{tooltips}. + + \value SplashScreen Indicates that the window is a splash screen. + This is the default type for QSplashScreen. + + \value Desktop Indicates that this widget is the desktop. This + is the type for QDesktopWidget. + + \value SubWindow Indicates that this widget is a sub-window, such + as a QMdiSubWindow widget. + + There are also a number of flags which you can use to customize + the appearance of top-level windows. These have no effect on other + windows: + + \value MSWindowsFixedSizeDialogHint Gives the window a thin dialog border on Windows. + This style is traditionally used for fixed-size dialogs. + + \value MSWindowsOwnDC Gives the window its own display + context on Windows. + + \value X11BypassWindowManagerHint Bypass the window + manager completely. This results in a borderless window + that is not managed at all (i.e., no keyboard input unless + you call QWidget::activateWindow() manually). + + \value FramelessWindowHint Produces a borderless window. + The user cannot move or resize a borderless window via the window + system. On X11, the result of the flag is dependent on the window manager and its + ability to understand Motif and/or NETWM hints. Most existing + modern window managers can handle this. + + The \c CustomizeWindowHint flag is used to enable customization of + the window controls. This flag must be set to allow the \c + WindowTitleHint, \c WindowSystemMenuHint, \c + WindowMinimizeButtonHint, \c WindowMaximizeButtonHint and \c + WindowCloseButtonHint flags to be changed. + + \value CustomizeWindowHint Turns off the default window title hints. + + \value WindowTitleHint Gives the window a title bar. + + \value WindowSystemMenuHint Adds a window system menu, and + possibly a close button (for example on Mac). If you need to hide + or show a close button, it is more portable to use \c + WindowCloseButtonHint. + + \value WindowMinimizeButtonHint Adds a minimize button. On + some platforms this implies Qt::WindowSystemMenuHint for it to work. + + \value WindowMaximizeButtonHint Adds a maximize button. On + some platforms this implies Qt::WindowSystemMenuHint for it to work. + + \value WindowMinMaxButtonsHint Adds a minimize and a maximize + button. On some platforms this implies Qt::WindowSystemMenuHint for it to work. + + \value WindowCloseButtonHint Adds a close button. On + some platforms this implies Qt::WindowSystemMenuHint for it + to work. + + \value WindowContextHelpButtonHint Adds a context help button to dialogs. + On some platforms this implies Qt::WindowSystemMenuHint for it to work. + + \value MacWindowToolBarButtonHint On Mac OS X adds a tool bar button (i.e., + the oblong button that is on the top right of windows that have toolbars. + + \value BypassGraphicsProxyWidget Prevents the window and its children from + automatically embedding themselves into a QGraphicsProxyWidget if the + parent widget is already embedded. You can set this flag if you + want your widget to always be a toplevel widget on the desktop, + regardless of whether the parent widget is embedded in a scene or + not. + + \value WindowShadeButtonHint + + \value WindowStaysOnTopHint Informs the window system that the + window should stay on top of all other windows. Note that + on some window managers on X11 you also have to pass + Qt::X11BypassWindowManagerHint for this flag to work + correctly. + + \value WindowStaysOnBottomHint Informs the window system that the + window should stay on bottom of all other windows. Note + that on X11 this hint will work only in window managers + that support _NET_WM_STATE_BELOW atom. If a window always + on the bottom has a parent, the parent will also be left on + the bottom. This window hint is currently not implemented + for Mac OS X. + + \value WindowOkButtonHint Adds an OK button to the window decoration of a dialog. + Only supported for Windows CE. + + \value WindowCancelButtonHint Adds a Cancel button to the window decoration of a dialog. + Only supported for Windows CE. + + \value WindowType_Mask A mask for extracting the window type + part of the window flags. + + Obsolete flags: + + \value WMouseNoMask Use Qt::WA_MouseNoMask instead. + \value WDestructiveClose Use Qt::WA_DeleteOnClose instead. + \value WStaticContents Use Qt::WA_StaticContents instead. + \value WGroupLeader No longer needed. + \value WShowModal Use QWidget::windowModality instead. + \value WNoMousePropagation Use Qt::WA_NoMousePropagation instead. + \value WType_TopLevel Use Qt::Window instead. + \value WType_Dialog Use Qt::Dialog instead. + \value WType_Popup Use Qt::Popup instead. + \value WType_Desktop Use Qt::Desktop instead. + \value WType_Mask Use Qt::WindowType_Mask instead. + + \value WStyle_Customize No longer needed. + \value WStyle_NormalBorder No longer needed. + \value WStyle_DialogBorder Use Qt::MSWindowsFixedSizeDialogHint instead. + \value WStyle_NoBorder Use Qt::FramelessWindowHint instead. + \value WStyle_Title Use Qt::WindowTitleHint instead. + \value WStyle_SysMenu Use Qt::WindowSystemMenuHint instead. + \value WStyle_Minimize Use Qt::WindowMinimizeButtonHint instead. + \value WStyle_Maximize Use Qt::WindowMaximizeButtonHint instead. + \value WStyle_MinMax Use Qt::WindowMinMaxButtonsHint instead. + \value WStyle_Tool Use Qt::Tool instead. + \value WStyle_StaysOnTop Use Qt::WindowStaysOnTopHint instead. + \value WStyle_ContextHelp Use Qt::WindowContextHelpButtonHint instead. + + \value WPaintDesktop No longer needed. + \value WPaintClever No longer needed. + + \value WX11BypassWM Use Qt::X11BypassWindowManagerHint instead. + \value WWinOwnDC Use Qt::MSWindowsOwnDC instead. + \value WMacSheet Use Qt::Sheet instead. + \value WMacDrawer Use Qt::Drawer instead. + + \value WStyle_Splash Use Qt::SplashScreen instead. + + \value WNoAutoErase No longer needed. + \value WRepaintNoErase No longer needed. + \value WNorthWestGravity Use Qt::WA_StaticContents instead. + \value WType_Modal Use Qt::Dialog and QWidget::windowModality instead. + \value WStyle_Dialog Use Qt::Dialog instead. + \value WStyle_NoBorderEx Use Qt::FramelessWindowHint instead. + \value WResizeNoErase No longer needed. + \value WMacNoSheet No longer needed. + + \sa QWidget::windowFlags, {Window Flags Example} +*/ + +/*! + \enum Qt::DropAction + + \value CopyAction Copy the data to the target. + \value MoveAction Move the data from the source to the target. + \value LinkAction Create a link from the source to the target. + \value ActionMask + \value IgnoreAction Ignore the action (do nothing with the data). + \value TargetMoveAction On Windows, this value is used when the ownership of the D&D data + should be taken over by the target application, + i.e., the source application should not delete + the data. + \br + On X11 this value is used to do a move. + \br + TargetMoveAction is not used on the Mac. +*/ + +#if defined(Q_OS_WIN) && defined(QT3_SUPPORT) +/*! + \enum Qt::WindowsVersion + \compat + + \value WV_32s + \value WV_95 + \value WV_98 + \value WV_Me + \value WV_DOS_based + \value WV_NT + \value WV_2000 + \value WV_XP + \value WV_2003 + \value WV_NT_based + \value WV_CE + \value WV_CENET + \value WV_CE_based + \value WV_CE_5 + \value WV_CE_6 +*/ +#endif + +#if defined(Q_OS_MAC) && defined(QT3_SUPPORT) +/*! + \enum Qt::MacintoshVersion + \compat + + \value MV_Unknown Use QSysInfo::MV_Unknown instead. + \value MV_9 Use QSysInfo::MV_9 instead. + \value MV_10_DOT_0 Use QSysInfo::MV_10_0 instead. + \value MV_10_DOT_1 Use QSysInfo::MV_10_1 instead. + \value MV_10_DOT_2 Use QSysInfo::MV_10_2 instead. + \value MV_10_DOT_3 Use QSysInfo::MV_10_3 instead. + \value MV_10_DOT_4 Use QSysInfo::MV_10_4 instead. + + \value MV_CHEETAH Use QSysInfo::MV_10_0 instead. + \value MV_PUMA Use QSysInfo::MV_10_1 instead. + \value MV_JAGUAR Use QSysInfo::MV_10_2 instead. + \value MV_PANTHER Use QSysInfo::MV_10_3 instead. + \value MV_TIGER Use QSysInfo::MV_10_4 instead. + + \sa QSysInfo::MacVersion +*/ +#endif + +/*! \typedef Qt::ToolBarDock + \compat + + Use Qt::Dock instead. +*/ + +/*! + \enum Qt::Dock + \compat + + Each dock window can be in one of the following positions: + + \value DockUnmanaged not managed by a Q3MainWindow. + + \value DockTornOff the dock window floats as its own top level + window which always stays on top of the main window. + + \value DockTop above the central widget, below the menu bar. + + \value DockBottom below the central widget, above the status bar. + + \value DockRight to the right of the central widget. + + \value DockLeft to the left of the central widget. + + \value DockMinimized the dock window is not shown (this is + effectively a 'hidden' dock area); the handles of all minimized + dock windows are drawn in one row below the menu bar. + + \omitvalue Bottom + \omitvalue Left + \omitvalue Minimized + \omitvalue Right + \omitvalue Top + \omitvalue TornOff + \omitvalue Unmanaged +*/ + +/*! + \enum Qt::AnchorAttribute + + An anchor has one or more of the following attributes: + + \value AnchorName the name attribute of the anchor. This attribute is + used when scrolling to an anchor in the document. + + \value AnchorHref the href attribute of the anchor. This attribute is + used when a link is clicked to determine what content to load. +*/ + +/*! + \enum Qt::SortOrder + + This enum describes how the items in a widget are sorted. + + \value AscendingOrder The items are sorted ascending e.g. starts with + 'AAA' ends with 'ZZZ' in Latin-1 locales + + \value DescendingOrder The items are sorted descending e.g. starts with + 'ZZZ' ends with 'AAA' in Latin-1 locales + + \omitvalue Ascending + \omitvalue Descending +*/ + +/*! + \enum Qt::ClipOperation + + \value NoClip This operation turns clipping off. + + \value ReplaceClip Replaces the current clip path/rect/region with + the one supplied in the function call. + + \value IntersectClip Intersects the current clip path/rect/region + with the one supplied in the function call. + + \value UniteClip Unites the current clip path/rect/region with the + one supplied in the function call. +*/ + +/*! + \enum Qt::ItemSelectionMode + + This enum is used in QGraphicsItem, QGraphicsScene and QGraphicsView to + specify how items are selected, or how to determine if a shapes and items + collide. + + \value ContainsItemShape The output list contains only items whose + \l{QGraphicsItem::shape()}{shape} is fully contained inside the + selection area. Items that intersect with the area's outline are + not included. + + \value IntersectsItemShape The output list contains both items whose + \l{QGraphicsItem::shape()}{shape} is fully contained inside the + selection area, and items that intersect with the area's + outline. This is a common mode for rubber band selection. + + \value ContainsItemBoundingRect The output list contains only items whose + \l{QGraphicsItem::boundingRect()}{bounding rectangle} is fully + contained inside the selection area. Items that intersect with the + area's outline are not included. + + \value IntersectsItemBoundingRect The output list contains both items + whose \l{QGraphicsItem::boundingRect()}{bounding rectangle} is + fully contained inside the selection area, and items that intersect + with the area's outline. This method is commonly used for + determining areas that need redrawing. + + \sa QGraphicsScene::items(), QGraphicsScene::collidingItems(), + QGraphicsView::items(), QGraphicsItem::collidesWithItem(), + QGraphicsItem::collidesWithPath() +*/ + +/*! + \enum Qt::FillRule + + Specifies which method should be used to fill the paths and polygons. + + \value OddEvenFill Specifies that the region is filled using the + odd even fill rule. With this rule, we determine whether a point + is inside the shape by using the following method. + Draw a horizontal line from the point to a location outside the shape, + and count the number of intersections. If the number of intersections + is an odd number, the point is inside the shape. This mode is the + default. + + \value WindingFill Specifies that the region is filled using the + non zero winding rule. With this rule, we determine whether a + point is inside the shape by using the following method. + Draw a horizontal line from the point to a location outside the shape. + Determine whether the direction of the line at each intersection point + is up or down. The winding number is determined by summing the + direction of each intersection. If the number is non zero, the point + is inside the shape. This fill mode can also in most cases be considered + as the intersection of closed shapes. +*/ + +/*! + \enum Qt::PaintUnit + + \compat + + \value PixelUnit + \value LoMetricUnit Obsolete + \value HiMetricUnit Obsolete + \value LoEnglishUnit Obsolete + \value HiEnglishUnit Obsolete + \value TwipsUnit Obsolete +*/ + +/*! + \enum Qt::TextFormat + + This enum is used in widgets that can display both plain text and + rich text, e.g. QLabel. It is used for deciding whether a text + string should be interpreted as one or the other. This is normally + done by passing one of the enum values to a setTextFormat() + function. + + \value PlainText The text string is interpreted as a plain text + string. + + \value RichText The text string is interpreted as a rich text + string. + + \value AutoText The text string is interpreted as for + Qt::RichText if Qt::mightBeRichText() returns true, otherwise + as Qt::PlainText. + + \value LogText A special, limited text format which is only used + by Q3TextEdit in an optimized mode. +*/ + +/*! + \enum Qt::CursorShape + + This enum type defines the various cursors that can be used. + + The standard arrow cursor is the default for widgets in a normal state. + + \value ArrowCursor \inlineimage cursor-arrow.png + The standard arrow cursor. + \value UpArrowCursor \inlineimage cursor-uparrow.png + An arrow pointing upwards toward the top of the screen. + \value CrossCursor \inlineimage cursor-cross.png + A crosshair cursor, typically used to help the + user accurately select a point on the screen. + \value WaitCursor \inlineimage cursor-wait.png + An hourglass or watch cursor, usually shown during + operations that prevent the user from interacting with + the application. + \value IBeamCursor \inlineimage cursor-ibeam.png + A caret or ibeam cursor, indicating that a widget can + accept and display text input. + \value SizeVerCursor \inlineimage cursor-sizev.png + A cursor used for elements that are used to vertically + resize top-level windows. + \value SizeHorCursor \inlineimage cursor-sizeh.png + A cursor used for elements that are used to horizontally + resize top-level windows. + \value SizeBDiagCursor \inlineimage cursor-sizeb.png + A cursor used for elements that are used to diagonally + resize top-level windows at their top-right and + bottom-left corners. + \value SizeFDiagCursor \inlineimage cursor-sizef.png + A cursor used for elements that are used to diagonally + resize top-level windows at their top-left and + bottom-right corners. + \value SizeAllCursor \inlineimage cursor-sizeall.png + A cursor used for elements that are used to resize + top-level windows in any direction. + \value BlankCursor A blank/invisible cursor, typically used when the cursor + shape needs to be hidden. + \value SplitVCursor \inlineimage cursor-vsplit.png + A cursor used for vertical splitters, indicating that + a handle can be dragged horizontally to adjust the use + of available space. + \value SplitHCursor \inlineimage cursor-hsplit.png + A cursor used for horizontal splitters, indicating that + a handle can be dragged vertically to adjust the use + of available space. + \value PointingHandCursor \inlineimage cursor-hand.png + A pointing hand cursor that is typically used for + clickable elements such as hyperlinks. + \value ForbiddenCursor \inlineimage cursor-forbidden.png + A slashed circle cursor, typically used during drag + and drop operations to indicate that dragged content + cannot be dropped on particular widgets or inside + certain regions. + \value OpenHandCursor \inlineimage cursor-openhand.png + A cursor representing an open hand, typically used to + indicate that the area under the cursor is the visible + part of a canvas that the user can click and drag in + order to scroll around. + \value ClosedHandCursor \inlineimage cursor-closedhand.png + A cursor representing a closed hand, typically used to + indicate that a dragging operation is in progress that + involves scrolling. + \value WhatsThisCursor \inlineimage cursor-whatsthis.png + An arrow with a question mark, typically used to indicate + the presence of What's This? help for a widget. + \value BusyCursor \inlineimage cursor-wait.png + An hourglass or watch cursor, usually shown during + operations that allow the user to interact with + the application while they are performed in the + background. + \value BitmapCursor + \omitvalue LastCursor + \omitvalue CustomCursor + + \omitvalue arrowCursor + \omitvalue upArrowCursor + \omitvalue crossCursor + \omitvalue waitCursor + \omitvalue ibeamCursor + \omitvalue sizeVerCursor + \omitvalue sizeHorCursor + \omitvalue sizeBDiagCursor + \omitvalue sizeFDiagCursor + \omitvalue sizeAllCursor + \omitvalue blankCursor + \omitvalue splitVCursor + \omitvalue splitHCursor + \omitvalue pointingHandCursor + \omitvalue forbiddenCursor + \omitvalue whatsThisCursor +*/ + +/*! + \typedef Qt::TextFlags + \compat + + Use Qt::TextFlag instead. +*/ + +/*! + \enum Qt::LayoutDirection + + Specifies the direction of Qt's layouts: + + \value LeftToRight Left-to-right layout. + \value RightToLeft Right-to-left layout. + + Right-to-left layouts are necessary for certain languages, + notably Arabic and Hebrew. + + \sa QApplication::setLayoutDirection(), QWidget::setLayoutDirection() +*/ + +/*! + \enum Qt::InputMethodQuery + + \value ImMicroFocus The rectangle covering the area of the input cursor in widget coordinates. + \value ImFont The currently used font for text input. + \value ImCursorPosition The logical position of the cursor within the text surrounding the input area (see ImSurroundingText). + If any text is selected, the position returned will be at the logical end of the + selection, even if the real cursor is located at the logical start. + \value ImSurroundingText The plain text around the input area, for example the current paragraph. + \value ImCurrentSelection The currently selected text. +*/ + +/*! + \enum Qt::ItemDataRole + + Each item in the model has a set of data elements associated with + it, each with its own role. The roles are used by the view to indicate + to the model which type of data it needs. + + The general purpose roles are: + + \value DisplayRole The key data to be rendered in the form of text. + \value DecorationRole The data to be rendered as a decoration in the form + of an icon. + \value EditRole The data in a form suitable for editing in an + editor. + \value ToolTipRole The data displayed in the item's tooltip. + \value StatusTipRole The data displayed in the status bar. + \value WhatsThisRole The data displayed for the item in "What's This?" + mode. + \value SizeHintRole The size hint for the item that will be supplied + to views. + + Roles describing appearance and meta data: + + \value FontRole The font used for items rendered with the default + delegate. + \value TextAlignmentRole The alignment of the text for items rendered with the + default delegate. + \value BackgroundRole The background brush used for items rendered with + the default delegate. + \value BackgroundColorRole This role is obsolete. Use BackgroundRole instead. + \value ForegroundRole The foreground brush (text color, typically) + used for items rendered with the default delegate. + \value TextColorRole This role is obsolete. Use ForegroundRole instead. + \value CheckStateRole This role is used to obtain the checked state of + an item (see \l Qt::CheckState). + + Accessibility roles: + + \value AccessibleTextRole The text to be used by accessibility + extensions and plugins, such as screen + readers. + \value AccessibleDescriptionRole A description of the item for accessibility + purposes. + + User roles: + + \value UserRole The first role that can be used for application-specific purposes. + + \omitvalue DisplayPropertyRole + \omitvalue DecorationPropertyRole + \omitvalue ToolTipPropertyRole + \omitvalue StatusTipPropertyRole + \omitvalue WhatsThisPropertyRole +*/ + +/*! + \enum Qt::ItemFlag + + This enum describes the properties of an item: + + \value NoItemFlags It does not have any properties set. + \value ItemIsSelectable It can be selected. + \value ItemIsEditable It can be edited. + \value ItemIsDragEnabled It can be dragged. + \value ItemIsDropEnabled It can be used as a drop target. + \value ItemIsUserCheckable It can be checked or unchecked by the user. + \value ItemIsEnabled The user can interact with the item. + \value ItemIsTristate The item is checkable with three separate states. + + Note that checkable items need to be given both a suitable set of flags + and an initial state, indicating whether the item is checked or not. + This is handled automatically for model/view components, but needs + to be explicitly set for instances of QListWidgetItem, QTableWidgetItem, + and QTreeWidgetItem. + + \sa QAbstractItemModel +*/ + +/*! + \enum Qt::MatchFlag + + This enum describes the type of matches that can be used when searching + for items in a model. + + \value MatchExactly Performs QVariant-based matching. + \value MatchFixedString Performs string-based matching. + String-based comparisons are case-insensitive unless the + \c MatchCaseSensitive flag is also specified. + \value MatchContains The search term is contained in the item. + \value MatchStartsWith The search term matches the start of the item. + \value MatchEndsWith The search term matches the end of the item. + \value MatchCaseSensitive The search is case sensitive. + \value MatchRegExp Performs string-based matching using a regular + expression as the search term. + \value MatchWildcard Performs string-based matching using a string with + wildcards as the search term. + \value MatchWrap Perform a search that wraps around, so that when + the search reaches the last item in the model, it begins again at + the first item and continues until all items have been examined. + \value MatchRecursive Searches the entire hierarchy. + + \sa QString::compare(), QRegExp +*/ + +/*! + \enum Qt::TextElideMode + + This enum specifies where the ellipsis should appear when + displaying texts that don't fit: + + \value ElideLeft The ellipsis should appear at the beginning of the text. + \value ElideRight The ellipsis should appear at the end of the text. + \value ElideMiddle The ellipsis should appear in the middle of the text. + \value ElideNone Ellipsis should NOT appear in the text. + + Qt::ElideMiddle is normally the most appropriate choice for URLs (e.g., + "\l{http://www.qtsoftware.com/careers/movingto/beijing/}{http://www.qtsof...ovingto/beijing/}"), + whereas Qt::ElideRight is appropriate + for other strings (e.g., + "\l{http://doc.trolltech.com/qq/qq09-mac-deployment.html}{Deploying Applications on Ma...}"). + + \sa QAbstractItemView::textElideMode, QFontMetrics::elidedText(), AlignmentFlag QTabBar::elideMode +*/ + +/*! + \enum Qt::WindowModality + + \keyword modal + + This enum specifies the behavior of a modal window. A modal window + is one that blocks input to other windows. Note that windows that + are children of a modal window are not blocked. + + The values are: + \value NonModal The window is not modal and does not block input to other windows. + \value WindowModal The window is modal to a single window hierarchy and blocks input to its parent window, all grandparent windows, and all siblings of its parent and grandparent windows. + \value ApplicationModal The window is modal to the application and blocks input to all windows. + + \sa QWidget::windowModality, QDialog +*/ + +/*! + \enum Qt::TextInteractionFlag + + This enum specifies how a text displaying widget reacts to user input. + + \value NoTextInteraction No interaction with the text is possible. + \value TextSelectableByMouse Text can be selected with the mouse and copied to the clipboard using + a context menu or standard keyboard shortcuts. + \value TextSelectableByKeyboard Text can be selected with the cursor keys on the keyboard. A text cursor is shown. + \value LinksAccessibleByMouse Links can be highlighted and activated with the mouse. + \value LinksAccessibleByKeyboard Links can be focused using tab and activated with enter. + \value TextEditable The text is fully editable. + + \value TextEditorInteraction The default for a text editor. + \value TextBrowserInteraction The default for QTextBrowser. +*/ + +/*! + \enum Qt::MaskMode + + This enum specifies the behavior of the + QPixmap::createMaskFromColor() and QImage::createMaskFromColor() + functions. + + \value MaskInColor Creates a mask where all pixels matching the given color are opaque. + \value MaskOutColor Creates a mask where all pixels matching the given color are transparent. +*/ + +/*! + \enum Qt::DockWidgetAreaSizes + \internal +*/ + +/*! + \enum Qt::ToolBarAreaSizes + \internal +*/ + +/*! + \enum Qt::EventPriority + + This enum can be used to specify event priorities. + + \value HighEventPriority Events with this priority are sent before + events with NormalEventPriority or LowEventPriority. + + \value NormalEventPriority Events with this priority are sent + after events with HighEventPriority, but before events with + LowEventPriority. + + \value LowEventPriority Events with this priority are sent after + events with HighEventPriority or NormalEventPriority. + + Note that these values are provided purely for convenience, since + event priorities can be any value between \c INT_MAX and \c + INT_MIN, inclusive. For example, you can define custom priorities + as being relative to each other: + + \snippet doc/src/snippets/code/doc_src_qnamespace.qdoc 1 + + \sa QCoreApplication::postEvent() +*/ +/*! + \enum Qt::SizeHint + \since 4.4 + + This enum is used by QGraphicsLayoutItem::sizeHint() + + \value MinimumSize is used to specify the minimum size of a graphics layout item. + \value PreferredSize is used to specify the preferred size of a graphics layout item. + \value MaximumSize is used to specify the maximum size of a graphics layout item. + \value MinimumDescent is used to specify the minimum descent of a text string in a graphics layout item. + \omitvalue NSizeHints + + \sa QGraphicsLayoutItem::sizeHint() +*/ + +/*! + \enum Qt::SizeMode + \since 4.4 + + This enum is used by QPainter::drawRoundedRect() and QPainterPath::addRoundedRect() + functions to specify the radii of rectangle corners with respect to the dimensions + of the bounding rectangles specified. + + \value AbsoluteSize Specifies the size using absolute measurements. + \value RelativeSize Specifies the size relative to the bounding rectangle, + typically using percentage measurements. +*/ + +/*! + \enum Qt::WindowFrameSection + \since 4.4 + + This enum is used to describe parts of a window frame. It is returned by + QGraphicsWidget::windowFrameSectionAt() to describe what section of the window + frame is under the mouse. + + \value NoSection + \value LeftSection + \value TopLeftSection + \value TopSection + \value TopRightSection + \value RightSection + \value BottomRightSection + \value BottomSection + \value BottomLeftSection + \value TitleBarArea + + \sa QGraphicsWidget::windowFrameEvent() + \sa QGraphicsWidget::paintWindowFrame() + \sa QGraphicsWidget::windowFrameSectionAt() + +*/ + +/*! + \enum Qt::TileRule + \since 4.6 + + This enum describes how to repeat or stretch the parts of an image + when drawing. + + \value Stretch Scale the image to fit to the available area. + + \value Repeat Tile the image until there is no more space. May crop + the last image. + + \value Round Like Repeat, but scales the images down to ensure that + the last image is not cropped. +*/ + +/*! + \enum Qt::Initialization + \internal +*/ + +/*! + \enum Qt::GestureState + \since 4.6 + + This enum type describes the state of a gesture. + + \omitvalue NoGesture + \value GestureStarted A continuous gesture has started. + \value GestureUpdated A gesture continues. + \value GestureFinished A gesture has finished. + + \sa QGesture +*/ diff --git a/doc/src/qnamespace.qdoc b/doc/src/qnamespace.qdoc deleted file mode 100644 index 2d40fdd..0000000 --- a/doc/src/qnamespace.qdoc +++ /dev/null @@ -1,2718 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \namespace Qt - \inmodule QtCore - - \brief The Qt namespace contains miscellaneous identifiers - used throughout the Qt library. - - \ingroup misc -*/ - -/*! - \enum Qt::Orientation - - This type is used to signify an object's orientation. - - \value Horizontal - \value Vertical - - Orientation is used with QScrollBar for example. -*/ - -/*! - \enum Qt::AlignmentFlag - - This enum type is used to describe alignment. It contains - horizontal and vertical flags that can be combined to produce - the required effect. - - The \l{TextElideMode} enum can also be used in many situations - to fine-tune the appearance of aligned text. - - The horizontal flags are: - - \value AlignLeft Aligns with the left edge. - \value AlignRight Aligns with the right edge. - \value AlignHCenter Centers horizontally in the available space. - \value AlignJustify Justifies the text in the available space. - \omitvalue AlignAuto - - The vertical flags are: - - \value AlignTop Aligns with the top. - \value AlignBottom Aligns with the bottom. - \value AlignVCenter Centers vertically in the available space. - - You can use only one of the horizontal flags at a time. There is - one two-dimensional flag: - - \value AlignCenter Centers in both dimensions. - - You can use at most one horizontal and one vertical flag at a - time. Qt::AlignCenter counts as both horizontal and vertical. - - Three enum values are useful in applications that can be run in - right-to-left mode: - - \value AlignAbsolute If the widget's layout direction is - Qt::RightToLeft (instead of Qt::LeftToRight, the default), - Qt::AlignLeft refers to the \e right edge and Qt::AlignRight - to the \e left edge. This is normally the desired behavior. - If you want Qt::AlignLeft to always mean "left" and - Qt::AlignRight to always mean "right", combine the flag with - Qt::AlignAbsolute. - \value AlignLeading Synonym for Qt::AlignLeft. - \value AlignTrailing Synonym for Qt::AlignRight. - - Masks: - - \value AlignHorizontal_Mask - \value AlignVertical_Mask - - Conflicting combinations of flags have undefined meanings. -*/ - -/*! - \enum Qt::ApplicationAttribute - - This enum describes attributes that change the behavior of - application-wide features. These are enabled and disabled using - QCoreApplication::setAttribute(), and can be tested for with - QCoreApplication::testAttribute(). - - \value AA_ImmediateWidgetCreation Ensures that widgets are created - as soon as they are constructed. By default, resources for - widgets are allocated on demand to improve efficiency and - minimize resource usage. Setting or clearing this attribute - affects widgets constructed after the change. Setting it - tells Qt to create toplevel windows immediately. - Therefore, if it is important to minimize resource - consumption, do not set this attribute. - - \value AA_MSWindowsUseDirect3DByDefault This value is obsolete and - has no effect. - - \value AA_DontShowIconsInMenus Actions with the Icon property won't be - shown in any menus unless specifically set by the - QAction::iconVisibleInMenu property. - - Menus that are currently open or menus already created in the native - Mac OS X menubar \e{may not} pick up a change in this attribute. Changes - in the QAction::iconVisibleInMenu property will always be picked up. - - \value AA_NativeWindows Ensures that widgets have native windows. - - \value AA_DontCreateNativeWidgetSiblings Ensures that siblings of native - widgets stay non-native unless specifically set by the - Qt::WA_NativeWindow attribute. - - \value AA_MacPluginApplication Stops the Qt mac application from doing - specific initializations that do not necessarily make sense when using Qt - to author a plugin. This includes avoiding loading our nib for the main - menu and not taking possession of the native menu bar. When setting this - attribute to true will also set the AA_DontUseNativeMenuBar attribute - to true. - - \value AA_DontUseNativeMenuBar All menubars created while this attribute is - set to true won't be used as a native menubar (e.g, the menubar at - the top of the main screen on Mac OS X or at the bottom in Windows CE). - - \value AA_MacDontSwapCtrlAndMeta On Mac OS X by default, Qt swaps the - Control and Meta (Command) keys (i.e., whenever Control is pressed, Qt - sends Meta and whenever Meta is pressed Control is sent. When this - attribute is true, Qt will not do the flip. QKeySequence::StandardShortcuts - will also flip accordingly (i.e., QKeySequence::Copy will be - Command+C on the keyboard regardless of the value set, though what is output for - QKeySequence::toString(QKeySequence::PortableText) will be different). - - \omitvalue AA_AttributeCount -*/ - -/*! - \enum Qt::MouseButton - - This enum type describes the different mouse buttons. - - \value NoButton The button state does not refer to any - button (see QMouseEvent::button()). - \value LeftButton The left button is pressed, or an event refers - to the left button. (The left button may be the right button on - left-handed mice.) - \value RightButton The right button. - \value MidButton The middle button. - \value XButton1 The first X button. - \value XButton2 The second X button. - - \omitvalue MouseButtonMask - - \sa KeyboardModifier Modifier -*/ - -/*! - \enum Qt::KeyboardModifier - - This enum describes the modifier keys. - - \value NoModifier No modifier key is pressed. - \value ShiftModifier A Shift key on the keyboard is pressed. - \value ControlModifier A Ctrl key on the keyboard is pressed. - \value AltModifier An Alt key on the keyboard is pressed. - \value MetaModifier A Meta key on the keyboard is pressed. - \value KeypadModifier A keypad button is pressed. - \value GroupSwitchModifier X11 only. A Mode_switch key on the keyboard is pressed. - - \omitvalue KeyboardModifierMask - - \note On Mac OS X, the \c ControlModifier value corresponds to - the Command keys on the Macintosh keyboard, and the \c MetaModifier value - corresponds to the Control keys. The \c KeypadModifier value will also be set - when an arrow key is pressed as the arrow keys are considered part of the - keypad. - - \note On Windows Keyboards, Qt::MetaModifier and Qt::Key_Meta are mapped - to the Windows key. - - \sa MouseButton Modifier -*/ - -/*! - \enum Qt::Modifier - - This enum provides shorter names for the keyboard modifier keys - supported by Qt. - - \bold{Note:} On Mac OS X, the \c CTRL value corresponds to - the Command keys on the Macintosh keyboard, and the \c META value - corresponds to the Control keys. - - \value SHIFT The Shift keys provided on all standard keyboards. - \value META The Meta keys. - \value CTRL The Ctrl keys. - \value ALT The normal Alt keys, but not keys like AltGr. - \value UNICODE_ACCEL The shortcut is specified as a Unicode code - point, not as a Qt Key. - \omitvalue MODIFIER_MASK - - \sa KeyboardModifier MouseButton -*/ - -/*! - \enum Qt::GlobalColor - - \raw HTML - - \endraw - - Qt's predefined QColor objects: - - \value white \raw HTML - White (#ffffff) - \endraw - \value black \raw HTML - Black (#000000) - \endraw - \value red \raw HTML - Red (#ff0000) - \endraw - \value darkRed \raw HTML - Dark red (#800000) - \endraw - \value green \raw HTML - Green (#00ff00) - \endraw - \value darkGreen \raw HTML - Dark green (#008000) - \endraw - \value blue \raw HTML - Blue (#0000ff) - \endraw - \value darkBlue \raw HTML - Dark blue (#000080) - \endraw - \value cyan \raw HTML - Cyan (#00ffff) - \endraw - \value darkCyan \raw HTML - Dark cyan (#008080) - \endraw - \value magenta \raw HTML - Magenta (#ff00ff) - \endraw - \value darkMagenta \raw HTML - Dark magenta (#800080) - \endraw - \value yellow \raw HTML - Yellow (#ffff00) - \endraw - \value darkYellow \raw HTML - Dark yellow (#808000) - \endraw - \value gray \raw HTML - Gray (#a0a0a4) - \endraw - \value darkGray \raw HTML - Dark gray (#808080) - \endraw - \value lightGray \raw HTML - Light gray (#c0c0c0) - \endraw - \value transparent a transparent black value (i.e., QColor(0, 0, 0, 0)) - \value color0 0 pixel value (for bitmaps) - \value color1 1 pixel value (for bitmaps) - - \sa QColor - -*/ - -/*! - \enum Qt::PenStyle - - This enum type defines the pen styles that can be drawn using - QPainter. The styles are: - - \table - \row - \o \inlineimage qpen-solid.png - \o \inlineimage qpen-dash.png - \o \inlineimage qpen-dot.png - \row - \o Qt::SolidLine - \o Qt::DashLine - \o Qt::DotLine - \row - \o \inlineimage qpen-dashdot.png - \o \inlineimage qpen-dashdotdot.png - \o \inlineimage qpen-custom.png - \row - \o Qt::DashDotLine - \o Qt::DashDotDotLine - \o Qt::CustomDashLine - \endtable - - \value NoPen no line at all. For example, QPainter::drawRect() - fills but does not draw any boundary line. - - \value SolidLine A plain line. - \value DashLine Dashes separated by a few pixels. - \value DotLine Dots separated by a few pixels. - \value DashDotLine Alternate dots and dashes. - \value DashDotDotLine One dash, two dots, one dash, two dots. - \value CustomDashLine A custom pattern defined using - QPainterPathStroker::setDashPattern(). - - \omitvalue MPenStyle - - \sa QPen -*/ - -/*! - \enum Qt::PenCapStyle - - This enum type defines the pen cap styles supported by Qt, i.e. - the line end caps that can be drawn using QPainter. - - \table - \row - \o \inlineimage qpen-square.png - \o \inlineimage qpen-flat.png - \o \inlineimage qpen-roundcap.png - \row - \o Qt::SquareCap - \o Qt::FlatCap - \o Qt::RoundCap - \endtable - - \value FlatCap a square line end that does not cover the end - point of the line. - \value SquareCap a square line end that covers the end point and - extends beyond it by half the line width. - \value RoundCap a rounded line end. - \omitvalue MPenCapStyle - - \sa QPen -*/ - -/*! - \enum Qt::PenJoinStyle - - This enum type defines the pen join styles supported by Qt, i.e. - which joins between two connected lines can be drawn using - QPainter. - - \table - \row - \o \inlineimage qpen-bevel.png - \o \inlineimage qpen-miter.png - \o \inlineimage qpen-roundjoin.png - \row - \o Qt::BevelJoin - \o Qt::MiterJoin - \o Qt::RoundJoin - \endtable - - \value MiterJoin The outer edges of the lines are extended to - meet at an angle, and this area is filled. - \value BevelJoin The triangular notch between the two lines is filled. - \value RoundJoin A circular arc between the two lines is filled. - \value SvgMiterJoin A miter join corresponding to the definition of - a miter join in the \l{SVG 1.2 Tiny} specification. - \omitvalue MPenJoinStyle - - \sa QPen -*/ - -/*! - \enum Qt::BrushStyle - - This enum type defines the brush styles supported by Qt, i.e. the - fill pattern of shapes drawn using QPainter. - - \image brush-styles.png Brush Styles - - \value NoBrush No brush pattern. - \value SolidPattern Uniform color. - \value Dense1Pattern Extremely dense brush pattern. - \value Dense2Pattern Very dense brush pattern. - \value Dense3Pattern Somewhat dense brush pattern. - \value Dense4Pattern Half dense brush pattern. - \value Dense5Pattern Somewhat sparse brush pattern. - \value Dense6Pattern Very sparse brush pattern. - \value Dense7Pattern Extremely sparse brush pattern. - \value HorPattern Horizontal lines. - \value VerPattern Vertical lines. - \value CrossPattern Crossing horizontal and vertical lines. - \value BDiagPattern Backward diagonal lines. - \value FDiagPattern Forward diagonal lines. - \value DiagCrossPattern Crossing diagonal lines. - \value LinearGradientPattern Linear gradient (set using a dedicated QBrush constructor). - \value ConicalGradientPattern Conical gradient (set using a dedicated QBrush constructor). - \value RadialGradientPattern Radial gradient (set using a dedicated QBrush constructor). - \value TexturePattern Custom pattern (see QBrush::setTexture()). - - \omitvalue CustomPattern - - \sa QBrush -*/ - -/*! - \enum Qt::TextFlag - - This enum type is used to define some modifier flags. Some of - these flags only make sense in the context of printing: - - \value TextSingleLine Treats all whitespace as spaces and prints just - one line. - \value TextDontClip If it's impossible to stay within the given bounds, - it prints outside. - \value TextExpandTabs Makes the U+0009 (ASCII tab) character move to - the next tab stop. - \value TextShowMnemonic Displays the string "\&P" as \underline{P} - (see QButton for an example). For an ampersand, use "\&\&". - \value TextWordWrap Breaks lines at appropriate points, e.g. at word - boundaries. - \value TextWrapAnywhere Breaks lines anywhere, even within words. - \value TextHideMnemonic Same as Qt::TextShowMnemonic but doesn't draw the underlines. - \value TextDontPrint Treat this text as "hidden" and don't print - it. - \value IncludeTrailingSpaces When this option is set, QTextLine::naturalTextWidth() and naturalTextRect() will - return a value that includes the width of trailing spaces in the text; otherwise - this width is excluded. - \value TextIncludeTrailingSpaces Same as IncludeTrailingSpaces - \value TextJustificationForced Ensures that text lines are justified. - - \omitvalue BreakAnywhere - \omitvalue DontClip - \omitvalue DontPrint - \omitvalue ExpandTabs - \omitvalue IncludeTrailingSpaces - \omitvalue NoAccel - \omitvalue ShowPrefix - \omitvalue SingleLine - \omitvalue WordBreak - \omitvalue TextForceLeftToRight - \omitvalue TextForceRightToLeft - - You can use as many modifier flags as you want, except that - Qt::TextSingleLine and Qt::TextWordWrap cannot be combined. - - Flags that are inappropriate for a given use are generally - ignored. -*/ - -/*! - \enum Qt::BGMode - - Background mode: - - \value TransparentMode - \value OpaqueMode -*/ - -/*! - \enum Qt::ConnectionType - - This enum describes the types of connection that can be used between signals and - slots. In particular, it determines whether a particular signal is delivered to a - slot immediately or queued for delivery at a later time. - - \omitvalue AutoCompatConnection - \value DirectConnection When emitted, the signal is immediately delivered to the slot. - \value QueuedConnection When emitted, the signal is queued until the event loop is - able to deliver it to the slot. - \value BlockingQueuedConnection - Same as QueuedConnection, except that the current thread blocks - until the slot has been delivered. This connection type should - only be used for receivers in a different thread. Note that misuse - of this type can lead to deadlocks in your application. - \value AutoConnection If the signal is emitted from the thread - in which the receiving object lives, the - slot is invoked directly, as with - Qt::DirectConnection; otherwise the - signal is queued, as with - Qt::QueuedConnection. - \value UniqueConnection Same as AutoConnection, but there will be a check that the signal is - not already connected to the same slot before connecting, otherwise, - the connection will fail. - This value was introduced in Qt 4.6. - - With queued connections, the parameters must be of types that are known to - Qt's meta-object system, because Qt needs to copy the arguments to store them - in an event behind the scenes. If you try to use a queued connection and - get the error message - - \snippet doc/src/snippets/code/doc_src_qnamespace.qdoc 0 - - call qRegisterMetaType() to register the data type before you - establish the connection. - - \sa {Thread Support in Qt}, QObject::connect(), qRegisterMetaType() -*/ - -/*! - \enum Qt::DateFormat - - \value TextDate The default Qt format, which includes the day and month name, - the day number in the month, and the year in full. The day and month names will - be short, localized names. This is basically equivalent to using the date format - string, "ddd MMM d yyyy". See QDate::toString() for more information. - - \value ISODate ISO 8601 extended format: either \c{YYYY-MM-DD} for dates or - \c{YYYY-MM-DDTHH:MM:SS} for combined dates and times. - - \value SystemLocaleShortDate The \l{QLocale::ShortFormat}{short format} used - by the \l{QLocale::system()}{operating system}. - - \value SystemLocaleLongDate The \l{QLocale::LongFormat}{long format} used - by the \l{QLocale::system()}{operating system}. - - \value DefaultLocaleShortDate The \l{QLocale::ShortFormat}{short format} specified - by the \l{QLocale::setDefault()}{application's locale}. - - \value DefaultLocaleLongDate The \l{QLocale::LongFormat}{long format} used - by the \l{QLocale::setDefault()}{application's locale}. - - \value SystemLocaleDate \e{This enum value is deprecated.} Use Qt::SystemLocaleShortDate - instead (or Qt::SystemLocaleLongDate if you want long dates). - - \value LocaleDate \e{This enum value is deprecated.} Use Qt::DefaultLocaleShortDate - instead (or Qt::DefaultLocaleLongDate if you want long dates). - - \value LocalDate \e{This enum value is deprecated.} Use Qt::SystemLocaleShortDate - instead (or Qt::SystemLocaleLongDate if you want long dates). - - \note For \c ISODate formats, each \c Y, \c M and \c D represents a single digit - of the year, month and day used to specify the date. Each \c H, \c M and \c S - represents a single digit of the hour, minute and second used to specify the time. - The presence of a literal \c T character is used to separate the date and time when - both are specified. -*/ - - -/*! - \enum Qt::TimeSpec - - \value LocalTime Locale dependent time (Timezones and Daylight Savings Time). - \value UTC Coordinated Universal Time, replaces Greenwich Mean Time. - \value OffsetFromUTC An offset in seconds from Coordinated Universal Time. -*/ - -/*! - \enum Qt::DayOfWeek - - \value Monday - \value Tuesday - \value Wednesday - \value Thursday - \value Friday - \value Saturday - \value Sunday -*/ - -/*! - \enum Qt::CaseSensitivity - - \value CaseInsensitive - \value CaseSensitive -*/ - -/*! - \enum Qt::ToolBarArea - - \value LeftToolBarArea - \value RightToolBarArea - \value TopToolBarArea - \value BottomToolBarArea - \value AllToolBarAreas - \value NoToolBarArea - - \omitvalue ToolBarArea_Mask -*/ - -/*! - \enum Qt::DockWidgetArea - - \value LeftDockWidgetArea - \value RightDockWidgetArea - \value TopDockWidgetArea - \value BottomDockWidgetArea - \value AllDockWidgetAreas - \value NoDockWidgetArea - - \omitvalue DockWidgetArea_Mask -*/ - -/*! - \enum Qt::BackgroundMode - - \compat - - \value FixedColor - \value FixedPixmap - \value NoBackground - \value PaletteForeground - \value PaletteButton - \value PaletteLight - \value PaletteMidlight - \value PaletteDark - \value PaletteMid - \value PaletteText - \value PaletteBrightText - \value PaletteBase - \value PaletteBackground - \value PaletteShadow - \value PaletteHighlight - \value PaletteHighlightedText - \value PaletteButtonText - \value PaletteLink - \value PaletteLinkVisited - \value X11ParentRelative -*/ - -/*! - \enum Qt::ImageConversionFlag - - The options marked "(default)" are set if no other values from - the list are included (since the defaults are zero): - - Color/Mono preference (ignored for QBitmap): - - \value AutoColor (default) - If the image has \link - QImage::depth() depth\endlink 1 and contains only - black and white pixels, the pixmap becomes monochrome. - \value ColorOnly The pixmap is dithered/converted to the - \link QPixmap::defaultDepth() native display depth\endlink. - \value MonoOnly The pixmap becomes monochrome. If necessary, - it is dithered using the chosen dithering algorithm. - - Dithering mode preference for RGB channels: - - \value DiffuseDither (default) - A high-quality dither. - \value OrderedDither A faster, more ordered dither. - \value ThresholdDither No dithering; closest color is used. - - Dithering mode preference for alpha channel: - - \value ThresholdAlphaDither (default) - No dithering. - \value OrderedAlphaDither A faster, more ordered dither. - \value DiffuseAlphaDither A high-quality dither. - \omitvalue NoAlpha - - Color matching versus dithering preference: - - \value PreferDither (default when converting to a pixmap) - Always dither - 32-bit images when the image is converted to 8 bits. - \value AvoidDither (default when converting for the purpose of saving to - file) - Dither 32-bit images only if the image has more than 256 - colors and it is being converted to 8 bits. - \omitvalue AutoDither - - \omitvalue ColorMode_Mask - \omitvalue Dither_Mask - \omitvalue AlphaDither_Mask - \omitvalue DitherMode_Mask - \omitvalue NoOpaqueDetection -*/ - -/*! \enum Qt::GUIStyle - - \compat - - \value WindowsStyle - \value MotifStyle - \value MacStyle - \value Win3Style - \value PMStyle -*/ - -/*! - \enum Qt::UIEffect - - This enum describes the available UI effects. - - By default, Qt will try to use the platform specific desktop - settings for each effect. Use the - QApplication::setDesktopSettingsAware() function (passing \c false - as argument) to prevent this, and the - QApplication::setEffectEnabled() to enable or disable a particular - effect. - - Note that all effects are disabled on screens running at less than - 16-bit color depth. - - \omitvalue UI_General - - \value UI_AnimateMenu Show animated menus. - \value UI_FadeMenu Show faded menus. - \value UI_AnimateCombo Show animated comboboxes. - \value UI_AnimateTooltip Show tooltip animations. - \value UI_FadeTooltip Show tooltip fading effects. - \value UI_AnimateToolBox Reserved - - \sa QApplication::setEffectEnabled(), QApplication::setDesktopSettingsAware() -*/ - -/*! \enum Qt::AspectRatioMode - - This enum type defines what happens to the aspect ratio when - scaling an rectangle. - - \image qimage-scaling.png - - \value IgnoreAspectRatio The size is scaled freely. The aspect - ratio is not preserved. - \value KeepAspectRatio The size is scaled to a rectangle as - large as possible inside a given - rectangle, preserving the aspect ratio. - \value KeepAspectRatioByExpanding The size is scaled to a - rectangle as small as possible - outside a given rectangle, - preserving the aspect ratio. - - \omitvalue ScaleFree - \omitvalue ScaleMin - \omitvalue ScaleMax - - \sa QSize::scale(), QImage::scaled() -*/ - -/*! \typedef Qt::ScaleMode - \compat - - Use Qt::AspectRatioMode instead. - - The enum values have been renamed as follows: - - \table - \row \i Old enum value \i New enum value - \row \i Qt::ScaleFree \i Qt::IgnoreAspectRatio - \row \i Qt::ScaleMin \i Qt::KeepAspectRatio - \row \i Qt::ScaleMax \i Qt::KeepAspectRatioByExpanding - \endtable -*/ - -/*! \enum Qt::TransformationMode - - This enum type defines whether image transformations (e.g., - scaling) should be smooth or not. - - \value FastTransformation The transformation is performed - quickly, with no smoothing. - \value SmoothTransformation The resulting image is transformed - using bilinear filtering. - - \sa QImage::scaled() -*/ - -/*! \enum Qt::Axis - - This enum type defines three values to represent the three - axes in the cartesian coordinate system. - - \value XAxis The X axis. - \value YAxis The Y axis. - \value ZAxis The Z axis. - - \sa QTransform::rotate(), QTransform::rotateRadians() - */ - -/*! - \enum Qt::WidgetAttribute - - \keyword widget attributes - - This enum type is used to specify various widget attributes. - Attributes are set and cleared with QWidget::setAttribute(), and - queried with QWidget::testAttribute(), although some have special - convenience functions which are mentioned below. - - \value WA_AcceptDrops Allows data from drag and drop operations - to be dropped onto the widget (see QWidget::setAcceptDrops()). - - \value WA_AlwaysShowToolTips Enables tooltips for inactive windows. - - \value WA_ContentsPropagated This flag is superfluous and - obsolete; it no longer has any effect. Since Qt 4.1, all widgets - that do not set WA_PaintOnScreen propagate their contents. - - \value WA_CustomWhatsThis Indicates that the widget wants to - continue operating normally in "What's This?" mode. This is set by the - widget's author. - - \value WA_DeleteOnClose Makes Qt delete this widget when the - widget has accepted the close event (see QWidget::closeEvent()). - - \value WA_Disabled Indicates that the widget is disabled, i.e. - it does not receive any mouse or keyboard events. There is also a - getter functions QWidget::isEnabled(). This is set/cleared by the - Qt kernel. - - \omitvalue WA_DropSiteRegistered - \omitvalue WA_ForceAcceptDrops - - \value WA_ForceDisabled Indicates that the widget is - explicitly disabled, i.e. it will remain disabled even when all - its ancestors are set to the enabled state. This implies - WA_Disabled. This is set/cleared by QWidget::setEnabled() and - QWidget::setDisabled(). - - \value WA_ForceUpdatesDisabled Indicates that updates are - explicitly disabled for the widget; i.e. it will remain disabled - even when all its ancestors are set to the updates-enabled state. - This implies WA_UpdatesDisabled. This is set/cleared by - QWidget::setUpdatesEnabled(). - - \value WA_GroupLeader - \e{This attribute has been deprecated.} Use QWidget::windowModality - instead. - - \value WA_Hover Forces Qt to generate paint events when the mouse - enters or leaves the widget. This feature is typically used when - implementing custom styles; see the \l{widgets/styles}{Styles} - example for details. - - \value WA_InputMethodEnabled Enables input methods for Asian languages. - Must be set when creating custom text editing widgets. - On Windows CE this flag can be used in addition to - QApplication::autoSipEnabled to automatically display the SIP when - entering a widget. - - \value WA_KeyboardFocusChange Set on a toplevel window when - the users changes focus with the keyboard (tab, backtab, or shortcut). - - \value WA_KeyCompression Enables key event compression if set, - and disables it if not set. By default key compression is off, so - widgets receive one key press event for each key press (or more, - since autorepeat is usually on). If you turn it on and your - program doesn't keep up with key input, Qt may try to compress key - events so that more than one character can be processed in each - event. - For example, a word processor widget might receive 2, 3 or more - characters in each QKeyEvent::text(), if the layout recalculation - takes too long for the CPU. - If a widget supports multiple character unicode input, it is - always safe to turn the compression on. - Qt performs key event compression only for printable characters. - Qt::Modifier keys, cursor movement keys, function keys and - miscellaneous action keys (e.g. Escape, Enter, Backspace, - PrintScreen) will stop key event compression, even if there are - more compressible key events available. - Platforms other than Mac and X11 do not support this compression, - in which case turning it on will have no effect. - This is set/cleared by the widget's author. - - \value WA_LayoutOnEntireRect Indicates that the widget - wants QLayout to operate on the entire QWidget::rect(), not only - on QWidget::contentsRect(). This is set by the widget's author. - - \value WA_LayoutUsesWidgetRect Ignore the layout item rect from the style - when laying out this widget with QLayout. This makes a difference in - QMacStyle and QPlastiqueStyle for some widgets. - - \value WA_MacNoClickThrough When a widget that has this attribute set - is clicked, and its window is inactive, the click will make the window - active but won't be seen by the widget. Typical use of this attribute - is on widgets with "destructive" actions, such as a "Delete" button. - WA_MacNoClickThrough also applies to all child widgets of the widget - that has it set. - - \value WA_MacOpaqueSizeGrip Indicates that the native Carbon size grip - should be opaque instead of transparent (the default). This attribute - is only applicable to Mac OS X and is set by the widget's author. - - \value WA_MacShowFocusRect Indicates that this widget should get a - QFocusFrame around it. Some widgets draw their own focus halo - regardless of this attribute. Not that the QWidget::focusPolicy - also plays the main role in whether something is given focus or - not, this only controls whether or not this gets the focus - frame. This attribute is only applicable to Mac OS X. - - \value WA_MacNormalSize Indicates the widget should have the - normal size for widgets in Mac OS X. This attribute is only - applicable to Mac OS X. - - \value WA_MacSmallSize Indicates the widget should have the small - size for widgets in Mac OS X. This attribute is only applicable to - Mac OS X. - - \value WA_MacMiniSize Indicates the widget should have the mini - size for widgets in Mac OS X. This attribute is only applicable to - Mac OS X. - - \value WA_MacVariableSize Indicates the widget can choose between - alternative sizes for widgets to avoid clipping. - This attribute is only applicable to Mac OS X. - - \value WA_MacBrushedMetal Indicates the widget should be drawn in - the brushed metal style as supported by the windowing system. This - attribute is only applicable to Mac OS X. - - \omitvalue WA_MacMetalStyle - - \value WA_Mapped Indicates that the widget is mapped on screen. - This is set/cleared by the Qt kernel. - - \value WA_MouseNoMask Makes the widget receive mouse events for - the entire widget regardless of the currently set mask, - overriding QWidget::setMask(). This is not applicable for - top-level windows. - - \value WA_MouseTracking Indicates that the widget has mouse - tracking enabled. See QWidget::mouseTracking. - - \value WA_Moved Indicates that the widget has an explicit - position. This is set/cleared by QWidget::move() and - by QWidget::setGeometry(). - - \value WA_MSWindowsUseDirect3D This value is obsolete and has no - effect. - - \value WA_NoBackground This value is obsolete. Use - WA_OpaquePaintEvent instead. - - \value WA_NoChildEventsForParent Indicates that the widget does - not want ChildAdded or ChildRemoved events sent to its - parent. This is rarely necessary but can help to avoid automatic - insertion widgets like splitters and layouts. This is set by a - widget's author. - - \value WA_NoChildEventsFromChildren Indicates that the widget does - not want to receive ChildAdded or ChildRemoved events sent from its - children. This is set by a widget's author. - - \value WA_NoMouseReplay Used for pop-up widgets. Indicates that the most - recent mouse press event should not be replayed when the pop-up widget - closes. The flag is set by the widget's author and cleared by the Qt kernel - every time the widget receives a new mouse event. - - \value WA_NoMousePropagation Prohibits mouse events from being propagated - to the widget's parent. This attribute is disabled by default. - - \value WA_TransparentForMouseEvents When enabled, this attribute disables - the delivery of mouse events to the widget and its children. Mouse events - are delivered to other widgets as if the widget and its children were not - present in the widget hierarchy; mouse clicks and other events effectively - "pass through" them. This attribute is disabled by default. - - \value WA_NoSystemBackground Indicates that the widget has no background, - i.e. when the widget receives paint events, the background is not - automatically repainted. \note Unlike WA_OpaquePaintEvent, newly exposed - areas are \bold never filled with the background (e.g., after showing a - window for the first time the user can see "through" it until the - application processes the paint events). This flag is set or cleared by the - widget's author. - - \value WA_OpaquePaintEvent Indicates that the widget paints all its pixels - when it receives a paint event. Thus, it is not required for operations - like updating, resizing, scrolling and focus changes to erase the widget - before generating paint events. The use of WA_OpaquePaintEvent provides a - small optimization by helping to reduce flicker on systems that do not - support double buffering and avoiding computational cycles necessary to - erase the background prior to painting. \note Unlike - WA_NoSystemBackground, WA_OpaquePaintEvent makes an effort to avoid - transparent window backgrounds. This flag is set or cleared by the widget's - author. - - \value WA_OutsideWSRange Indicates that the widget is outside - the valid range of the window system's coordinate system. A widget - outside the valid range cannot be mapped on screen. This is - set/cleared by the Qt kernel. - - \value WA_PaintOnScreen Indicates that the widget wants to draw directly - onto the screen. Widgets with this attribute set do not participate in - composition management, i.e. they cannot be semi-transparent or shine - through semi-transparent overlapping widgets. \note This flag is only - supported on X11 and it disables double buffering. On Qt for Embedded - Linux, the flag only works when set on a top-level widget and it relies on - support from the active screen driver. This flag is set or cleared by the - widget's author. To render outside of Qt's paint system, e.g., if you - require native painting primitives, you need to reimplement - QWidget::paintEngine() to return 0 and set this flag. - - \value WA_PaintOutsidePaintEvent Makes it possible to use QPainter to - paint on the widget outside \l{QWidget::paintEvent()}{paintEvent()}. This - flag is not supported on Windows, Mac OS X or Embedded Linux. We recommend - that you use it only when porting Qt 3 code to Qt 4. - - \value WA_PaintUnclipped Makes all painters operating on this widget - unclipped. Children of this widget or other widgets in front of it do not - clip the area the painter can paint on. This flag is only supported for - widgets with the WA_PaintOnScreen flag set. The preferred way to do this in - a cross platform way is to create a transparent widget that lies in front - of the other widgets. - - \value WA_PendingMoveEvent Indicates that a move event is pending, e.g., - when a hidden widget was moved. This flag is set or cleared by the Qt - kernel. - - \value WA_PendingResizeEvent Indicates that a resize event is pending, - e.g., when a hidden widget was resized. This flag is set or cleared by the - Qt kernel. - - \value WA_QuitOnClose Makes Qt quit the application when the last widget - with the attribute set has accepted closeEvent(). This behavior can be - modified with the QApplication::quitOnLastWindowClosed property. By default - this attribute is set for all widgets of type Qt::Window. - - \value WA_Resized Indicates that the widget has an explicit size. This flag - is set or cleared by QWidget::resize() and QWidget::setGeometry(). - - \value WA_RightToLeft Indicates that the layout direction for the widget - is right to left. - - \value WA_SetCursor Indicates that the widget has a cursor of its own. This - flag is set or cleared by QWidget::setCursor() and QWidget::unsetCursor(). - - \value WA_SetFont Indicates that the widget has a font of its own. This - flag is set or cleared by QWidget::setFont(). - - \value WA_SetPalette Indicates that the widget has a palette of its own. - This flag is set or cleared by QWidget::setPalette(). - - \value WA_SetStyle Indicates that the widget has a style of its own. This - flag is set or cleared by QWidget::setStyle(). - - \value WA_ShowModal \e{This attribute has been deprecated.} Use - QWidget::windowModality instead. - - \value WA_StaticContents Indicates that the widget contents are north-west - aligned and static. On resize, such a widget will receive paint events only - for parts of itself that are newly visible. This flag is set or cleared by - the widget's author. - - \value WA_StyleSheet Indicates that the widget is styled using a - \l{Qt Style Sheets}{style sheet}. - - \value WA_TranslucentBackground Indicates that the widget should have a - translucent background, i.e., any non-opaque regions of the widgets will be - translucent because the widget will have an alpha channel. Setting this - flag causes WA_NoSystemBackground to be set. On Windows the - widget also needs the Qt::FramelessWindowHint window flag to be set. - This flag is set or cleared by the widget's author. - - \value WA_UnderMouse Indicates that the widget is under the mouse cursor. - The value is not updated correctly during drag and drop operations. There - is also a getter function, QWidget::underMouse(). This flag is set or - cleared by the Qt kernel. - - \value WA_UpdatesDisabled Indicates that updates are blocked (including the - system background). This flag is set or cleared by the Qt kernel. - \warning This flag must \e never be set or cleared by the widget's author. - - \value WA_WindowModified Indicates that the window is marked as modified. - On some platforms this flag will do nothing, on others (including Mac OS X - and Windows) the window will take a modified appearance. This flag is set - or cleared by QWidget::setWindowModified(). - - \value WA_WindowPropagation Makes a toplevel window inherit font and - palette from its parent. - - \value WA_MacAlwaysShowToolWindow On Mac OS X, show the tool window even - when the application is not active. By default, all tool windows are - hidden when the application is inactive. - - \value WA_SetLocale Indicates the locale should be taken into consideration - in the widget. - - \value WA_StyledBackground Indicates the widget should be drawn using a - styled background. - - \value WA_ShowWithoutActivating Show the widget without making it active. - - \value WA_NativeWindow Indicates that a native window is created for the - widget. Enabling this flag will also force a native window for the widget's - ancestors unless Qt::WA_DontCreateNativeAncestors is set. - - \value WA_DontCreateNativeAncestors Indicates that the widget's ancestors - are kept non-native even though the widget itself is native. - - \value WA_X11NetWmWindowTypeDesktop Adds _NET_WM_WINDOW_TYPE_DESKTOP to the - window's _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. - - \value WA_X11NetWmWindowTypeDock Adds _NET_WM_WINDOW_TYPE_DOCK to the - window's _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. - - \value WA_X11NetWmWindowTypeToolBar Adds _NET_WM_WINDOW_TYPE_TOOLBAR to the - window's _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automaticaly sets this - attribute for QToolBar. - - \value WA_X11NetWmWindowTypeMenu Adds _NET_WM_WINDOW_TYPE_MENU to the - window's _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this - attribute for QMenu when torn-off. - - \value WA_X11NetWmWindowTypeUtility Adds _NET_WM_WINDOW_TYPE_UTILITY to the - window's _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this - attribute for the Qt::Tool window type. - - \value WA_X11NetWmWindowTypeSplash Adds _NET_WM_WINDOW_TYPE_SPLASH to the - window's _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this - attribute for the Qt::SplashScreen window type. - - \value WA_X11NetWmWindowTypeDialog Adds _NET_WM_WINDOW_TYPE_DIALOG - to the window's _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This - attribute has no effect on non-X11 platforms. \note Qt automatically sets - this attribute for the Qt::Dialog and Qt::Sheet window types. - - \value WA_X11NetWmWindowTypeDropDownMenu Adds - _NET_WM_WINDOW_TYPE_DROPDOWN_MENU to the window's - _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This - attribute has no effect on non-X11 platforms. \note Qt - automatically sets this attribute for QMenus added to a QMenuBar. - - \value WA_X11NetWmWindowTypePopupMenu Adds _NET_WM_WINDOW_TYPE_POPUP_MENU - to the window's _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this - attribute for QMenu. - - \value WA_X11NetWmWindowTypeToolTip Adds _NET_WM_WINDOW_TYPE_TOOLTIP to the - window's _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this - attribute for the Qt::ToolTip window type. - - \value WA_X11NetWmWindowTypeNotification Adds - _NET_WM_WINDOW_TYPE_NOTIFICATION to the window's _NET_WM_WINDOW_TYPE X11 - window property. See http://standards.freedesktop.org/wm-spec/ for more - details. This attribute has no effect on non-X11 platforms. - - \value WA_X11NetWmWindowTypeCombo Adds _NET_WM_WINDOW_TYPE_COMBO - to the window's _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this - attribute for the QComboBox pop-up. - - \value WA_X11NetWmWindowTypeDND Adds _NET_WM_WINDOW_TYPE_DND to - the window's _NET_WM_WINDOW_TYPE X11 window property. See - http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this - attribute on the feedback widget used during a drag. - - \value WA_MacFrameworkScaled Enables resolution independence aware mode - on Mac when using Carbon. This attribute has no effect on Cocoa. - The attribute is off by default and can be enabled on a per-window basis. - - \value WA_AcceptTouchEvents Allows touch events (see QTouchEvent) - to be sent to the widget. Must be set on all widgets that can - handle touch events. Without this attribute set, events from a - touch device will be sent as mouse events. - - \value WA_TouchPadAcceptSingleTouchEvents Allows touchpad single - touch events to be sent to the widget. - - \omitvalue WA_SetLayoutDirection - \omitvalue WA_InputMethodTransparent - \omitvalue WA_WState_CompressKeys - \omitvalue WA_WState_ConfigPending - \omitvalue WA_WState_Created - \omitvalue WA_WState_DND - \omitvalue WA_WState_ExplicitShowHide - \omitvalue WA_WState_Hidden - \omitvalue WA_WState_InPaintEvent - \omitvalue WA_WState_OwnSizePolicy - \omitvalue WA_WState_Polished - \omitvalue WA_WState_Reparented - \omitvalue WA_WState_Visible - \omitvalue WA_SetWindowIcon - \omitvalue WA_PendingUpdate - \omitvalue WA_LaidOut - \omitvalue WA_GrabbedShortcut - \omitvalue WA_DontShowOnScreen - \omitvalue WA_InvalidSize - \omitvalue WA_ForceUpdatesDisabled - \omitvalue WA_NoX11EventCompression - \omitvalue WA_TintedBackground - \omitvalue WA_X11OpenGLOverlay - \omitvalue WA_CanHostQMdiSubWindowTitleBar - \omitvalue WA_AttributeCount - \omitvalue WA_StyleSheet - \omitvalue WA_X11BypassTransientForHint - \omitvalue WA_SetWindowModality - \omitvalue WA_WState_WindowOpacitySet - \omitvalue WA_WState_AcceptedTouchBeginEvent -*/ - -/*! \typedef Qt::HANDLE - - Platform-specific handle type for system objects. This is - equivalent to \c{void *} on Mac OS X and embedded Linux, - and to \c{unsigned long} on X11. On Windows it is the - DWORD returned by the Win32 function getCurrentThreadId(). - - \warning Using this type is not portable. -*/ - -/*! - \enum Qt::Key - - The key names used by Qt. - - \value Key_Escape - \value Key_Tab - \value Key_Backtab - \omitvalue Key_BackTab - \value Key_Backspace - \omitvalue Key_BackSpace - \value Key_Return - \value Key_Enter Typically located on the keypad. - \value Key_Insert - \value Key_Delete - \value Key_Pause - \value Key_Print - \value Key_SysReq - \value Key_Clear - \value Key_Home - \value Key_End - \value Key_Left - \value Key_Up - \value Key_Right - \value Key_Down - \value Key_PageUp - \omitvalue Key_Prior - \value Key_PageDown - \omitvalue Key_Next - \value Key_Shift - \value Key_Control On Mac OS X, this corresponds to the Command keys. - \value Key_Meta On Mac OS X, this corresponds to the Control keys. - On Windows keyboards, this key is mapped to the - Windows key. - \value Key_Alt - \value Key_AltGr On Windows, when the KeyDown event for this key is - sent, the Ctrl+Alt modifiers are also set. - \value Key_CapsLock - \value Key_NumLock - \value Key_ScrollLock - \value Key_F1 - \value Key_F2 - \value Key_F3 - \value Key_F4 - \value Key_F5 - \value Key_F6 - \value Key_F7 - \value Key_F8 - \value Key_F9 - \value Key_F10 - \value Key_F11 - \value Key_F12 - \value Key_F13 - \value Key_F14 - \value Key_F15 - \value Key_F16 - \value Key_F17 - \value Key_F18 - \value Key_F19 - \value Key_F20 - \value Key_F21 - \value Key_F22 - \value Key_F23 - \value Key_F24 - \value Key_F25 - \value Key_F26 - \value Key_F27 - \value Key_F28 - \value Key_F29 - \value Key_F30 - \value Key_F31 - \value Key_F32 - \value Key_F33 - \value Key_F34 - \value Key_F35 - \value Key_Super_L - \value Key_Super_R - \value Key_Menu - \value Key_Hyper_L - \value Key_Hyper_R - \value Key_Help - \value Key_Direction_L - \value Key_Direction_R - \value Key_Space - \value Key_Any - \value Key_Exclam - \value Key_QuoteDbl - \value Key_NumberSign - \value Key_Dollar - \value Key_Percent - \value Key_Ampersand - \value Key_Apostrophe - \value Key_ParenLeft - \value Key_ParenRight - \value Key_Asterisk - \value Key_Plus - \value Key_Comma - \value Key_Minus - \value Key_Period - \value Key_Slash - \value Key_0 - \value Key_1 - \value Key_2 - \value Key_3 - \value Key_4 - \value Key_5 - \value Key_6 - \value Key_7 - \value Key_8 - \value Key_9 - \value Key_Colon - \value Key_Semicolon - \value Key_Less - \value Key_Equal - \value Key_Greater - \value Key_Question - \value Key_At - \value Key_A - \value Key_B - \value Key_C - \value Key_D - \value Key_E - \value Key_F - \value Key_G - \value Key_H - \value Key_I - \value Key_J - \value Key_K - \value Key_L - \value Key_M - \value Key_N - \value Key_O - \value Key_P - \value Key_Q - \value Key_R - \value Key_S - \value Key_T - \value Key_U - \value Key_V - \value Key_W - \value Key_X - \value Key_Y - \value Key_Z - \value Key_BracketLeft - \value Key_Backslash - \value Key_BracketRight - \value Key_AsciiCircum - \value Key_Underscore - \value Key_QuoteLeft - \value Key_BraceLeft - \value Key_Bar - \value Key_BraceRight - \value Key_AsciiTilde - \value Key_nobreakspace - \value Key_exclamdown - \value Key_cent - \value Key_sterling - \value Key_currency - \value Key_yen - \value Key_brokenbar - \value Key_section - \value Key_diaeresis - \value Key_copyright - \value Key_ordfeminine - \value Key_guillemotleft - \value Key_notsign - \value Key_hyphen - \value Key_registered - \value Key_macron - \value Key_degree - \value Key_plusminus - \value Key_twosuperior - \value Key_threesuperior - \value Key_acute - \value Key_mu - \value Key_paragraph - \value Key_periodcentered - \value Key_cedilla - \value Key_onesuperior - \value Key_masculine - \value Key_guillemotright - \value Key_onequarter - \value Key_onehalf - \value Key_threequarters - \value Key_questiondown - \value Key_Agrave - \value Key_Aacute - \value Key_Acircumflex - \value Key_Atilde - \value Key_Adiaeresis - \value Key_Aring - \value Key_AE - \value Key_Ccedilla - \value Key_Egrave - \value Key_Eacute - \value Key_Ecircumflex - \value Key_Ediaeresis - \value Key_Igrave - \value Key_Iacute - \value Key_Icircumflex - \value Key_Idiaeresis - \value Key_ETH - \value Key_Ntilde - \value Key_Ograve - \value Key_Oacute - \value Key_Ocircumflex - \value Key_Otilde - \value Key_Odiaeresis - \value Key_multiply - \value Key_Ooblique - \value Key_Ugrave - \value Key_Uacute - \value Key_Ucircumflex - \value Key_Udiaeresis - \value Key_Yacute - \value Key_THORN - \value Key_ssharp - \omitvalue Key_agrave - \omitvalue Key_aacute - \omitvalue Key_acircumflex - \omitvalue Key_atilde - \omitvalue Key_adiaeresis - \omitvalue Key_aring - \omitvalue Key_ae - \omitvalue Key_ccedilla - \omitvalue Key_egrave - \omitvalue Key_eacute - \omitvalue Key_ecircumflex - \omitvalue Key_ediaeresis - \omitvalue Key_igrave - \omitvalue Key_iacute - \omitvalue Key_icircumflex - \omitvalue Key_idiaeresis - \omitvalue Key_eth - \omitvalue Key_ntilde - \omitvalue Key_ograve - \omitvalue Key_oacute - \omitvalue Key_ocircumflex - \omitvalue Key_otilde - \omitvalue Key_odiaeresis - \value Key_division - \omitvalue Key_oslash - \omitvalue Key_ugrave - \omitvalue Key_uacute - \omitvalue Key_ucircumflex - \omitvalue Key_udiaeresis - \omitvalue Key_yacute - \omitvalue Key_thorn - \value Key_ydiaeresis - \value Key_Multi_key - \value Key_Codeinput - \value Key_SingleCandidate - \value Key_MultipleCandidate - \value Key_PreviousCandidate - \value Key_Mode_switch - \value Key_Kanji - \value Key_Muhenkan - \value Key_Henkan - \value Key_Romaji - \value Key_Hiragana - \value Key_Katakana - \value Key_Hiragana_Katakana - \value Key_Zenkaku - \value Key_Hankaku - \value Key_Zenkaku_Hankaku - \value Key_Touroku - \value Key_Massyo - \value Key_Kana_Lock - \value Key_Kana_Shift - \value Key_Eisu_Shift - \value Key_Eisu_toggle - \value Key_Hangul - \value Key_Hangul_Start - \value Key_Hangul_End - \value Key_Hangul_Hanja - \value Key_Hangul_Jamo - \value Key_Hangul_Romaja - \value Key_Hangul_Jeonja - \value Key_Hangul_Banja - \value Key_Hangul_PreHanja - \value Key_Hangul_PostHanja - \value Key_Hangul_Special - \value Key_Dead_Grave - \value Key_Dead_Acute - \value Key_Dead_Circumflex - \value Key_Dead_Tilde - \value Key_Dead_Macron - \value Key_Dead_Breve - \value Key_Dead_Abovedot - \value Key_Dead_Diaeresis - \value Key_Dead_Abovering - \value Key_Dead_Doubleacute - \value Key_Dead_Caron - \value Key_Dead_Cedilla - \value Key_Dead_Ogonek - \value Key_Dead_Iota - \value Key_Dead_Voiced_Sound - \value Key_Dead_Semivoiced_Sound - \value Key_Dead_Belowdot - \value Key_Dead_Hook - \value Key_Dead_Horn - \value Key_Back - \value Key_Forward - \value Key_Stop - \value Key_Refresh - \value Key_VolumeDown - \value Key_VolumeMute - \value Key_VolumeUp - \value Key_BassBoost - \value Key_BassUp - \value Key_BassDown - \value Key_TrebleUp - \value Key_TrebleDown - \value Key_MediaPlay - \value Key_MediaStop - \value Key_MediaPrevious - \omitvalue Key_MediaPrev - \value Key_MediaNext - \value Key_MediaRecord - \value Key_HomePage - \value Key_Favorites - \value Key_Search - \value Key_Standby - \value Key_OpenUrl - \value Key_LaunchMail - \value Key_LaunchMedia - \value Key_Launch0 - \value Key_Launch1 - \value Key_Launch2 - \value Key_Launch3 - \value Key_Launch4 - \value Key_Launch5 - \value Key_Launch6 - \value Key_Launch7 - \value Key_Launch8 - \value Key_Launch9 - \value Key_LaunchA - \value Key_LaunchB - \value Key_LaunchC - \value Key_LaunchD - \value Key_LaunchE - \value Key_LaunchF - \value Key_MediaLast - \value Key_unknown - - \value Key_Call - \value Key_Context1 - \value Key_Context2 - \value Key_Context3 - \value Key_Context4 - \value Key_Flip - \value Key_Hangup - \value Key_No - \value Key_Select - \value Key_Yes - - \value Key_Execute - \value Key_Printer - \value Key_Play - \value Key_Sleep - \value Key_Zoom - \value Key_Cancel - - \sa QKeyEvent::key() -*/ - -/*! - \enum Qt::HitTestAccuracy - - This enum contains the types of accuracy that can be used by the - QTextDocument class when testing for mouse clicks on text documents. - - \value ExactHit The point at which input occurred must coincide - exactly with input-sensitive parts of the document. - \value FuzzyHit The point at which input occurred can lie close to - input-sensitive parts of the document. - - This enum is defined in the \c header file. -*/ - -/*! - \enum Qt::WhiteSpaceMode - - This enum describes the types of whitespace mode that are used by - the QTextDocument class to meet the requirements of different kinds - of textual information. - - \value WhiteSpaceNormal The whitespace mode used to display - normal word wrapped text in paragraphs. - \value WhiteSpacePre A preformatted text mode in which - whitespace is reproduced exactly. - \value WhiteSpaceNoWrap - - \omitvalue WhiteSpaceModeUndefined - - This enum is defined in the \c header file. -*/ - -/*! - \enum Qt::ButtonState_enum - \compat - \value ShiftButton - \value ControlButton - \value AltButton - \value MetaButton - \value Keypad - \value KeyButtonMask - - Use Qt::KeyboardModifier instead. -*/ - -/*! - \typedef Qt::ButtonState - \compat - - Use Qt::KeyboardModifier instead. -*/ - -/*! - \enum Qt::CheckState - - This enum describes the state of checkable items, controls, and widgets. - - \value Unchecked The item is unchecked. - \value PartiallyChecked The item is partially checked. Items in hierarchical models - may be partially checked if some, but not all, of their - children are checked. - \value Checked The item is checked. - - \sa QCheckBox, Qt::ItemFlags, Qt::ItemDataRole -*/ - - -/*! - \enum Qt::ToolButtonStyle - - The style of the tool button, describing how the button's text and - icon should be displayed. - - \value ToolButtonIconOnly Only display the icon. - \value ToolButtonTextOnly Only display the text. - \value ToolButtonTextBesideIcon The text appears beside the icon. - \value ToolButtonTextUnderIcon The text appears under the icon. - \value ToolButtonFollowStyle Follow the \l{QStyle::SH_ToolButtonStyle}{style}. -*/ - -/*! - \enum Qt::Corner - - This enum type specifies a corner in a rectangle: - - \value TopLeftCorner The top-left corner of the rectangle. - \value TopRightCorner The top-right corner of the rectangle. - \value BottomLeftCorner The bottom-left corner of the rectangle. - \value BottomRightCorner The bottom-right corner of the rectangle. - - \omitvalue TopLeft - \omitvalue TopRight - \omitvalue BottomLeft - \omitvalue BottomRight -*/ - -/*! - \enum Qt::ScrollBarPolicy - - This enum type describes the various modes of QAbstractScrollArea's scroll - bars. - - \value ScrollBarAsNeeded QAbstractScrollArea shows a scroll bar when the - content is too large to fit and not otherwise. This is the - default. - - \value ScrollBarAlwaysOff QAbstractScrollArea never shows a scroll bar. - - \value ScrollBarAlwaysOn QAbstractScrollArea always shows a scroll bar. - - (The modes for the horizontal and vertical scroll bars are - independent.) -*/ - -/*! - \enum Qt::ArrowType - - \value NoArrow - \value UpArrow - \value DownArrow - \value LeftArrow - \value RightArrow -*/ - -/*! - \enum Qt::FocusReason - - This enum specifies why the focus changed. It will be passed - through QWidget::setFocus and can be retrieved in the QFocusEvent - sent to the widget upon focus change. - - \value MouseFocusReason A mouse action occurred. - \value TabFocusReason The Tab key was pressed. - \value BacktabFocusReason A Backtab occurred. The input for this may - include the Shift or Control keys; - e.g. Shift+Tab. - \value ActiveWindowFocusReason The window system made this window either - active or inactive. - \value PopupFocusReason The application opened/closed a pop-up that - grabbed/released the keyboard focus. - \value ShortcutFocusReason The user typed a label's buddy shortcut - \value MenuBarFocusReason The menu bar took focus. - \value OtherFocusReason Another reason, usually application-specific. - - \omitvalue NoFocusReason - - \sa {Keyboard Focus} -*/ - -/*! - \enum Qt::WindowState - - \keyword window state - - This enum type is used to specify the current state of a top-level - window. - - The states are - - \value WindowNoState The window has no state set (in normal state). - \value WindowMinimized The window is minimized (i.e. iconified). - \value WindowMaximized The window is maximized with a frame around it. - \value WindowFullScreen The window fills the entire screen without any frame around it. - \value WindowActive The window is the active window, i.e. it has keyboard focus. - -*/ - -/*! - \enum Qt::ContextMenuPolicy - - This enum type defines the various policies a widget can have with - respect to showing a context menu. - - \value NoContextMenu the widget does not feature a context menu, - context menu handling is deferred to the widget's parent. - \value PreventContextMenu the widget does not feature a context - menu, and in contrast to \c NoContextMenu, the handling is \e not - deferred to the widget's parent. This means that all right mouse - button events are guaranteed to be delivered to the widget itself - through mousePressEvent(), and mouseReleaseEvent(). - \value DefaultContextMenu the widget's QWidget::contextMenuEvent() handler is called. - \value ActionsContextMenu the widget displays its QWidget::actions() as context menu. - \value CustomContextMenu the widget emits the QWidget::customContextMenuRequested() signal. -*/ - -/*! - \enum Qt::FocusPolicy - - This enum type defines the various policies a widget can have with - respect to acquiring keyboard focus. - - \value TabFocus the widget accepts focus by tabbing. - \value ClickFocus the widget accepts focus by clicking. - \value StrongFocus the widget accepts focus by both tabbing - and clicking. On Mac OS X this will also - be indicate that the widget accepts tab focus - when in 'Text/List focus mode'. - \value WheelFocus like Qt::StrongFocus plus the widget accepts - focus by using the mouse wheel. - \value NoFocus the widget does not accept focus. - -*/ - -/*! - \enum Qt::ShortcutContext - - For a QEvent::Shortcut event to occur, the shortcut's key sequence - must be entered by the user in a context where the shortcut is - active. The possible contexts are these: - - \value WidgetShortcut The shortcut is active when its - parent widget has focus. - \value WidgetWithChildrenShortcut The shortcut is active - when its parent widget, or any of its children has focus. - Children which are top-level widgets, except pop-ups, are - not affected by this shortcut context. - \value WindowShortcut The shortcut is active when its - parent widget is a logical subwidget of the - active top-level window. - \value ApplicationShortcut The shortcut is active when one of - the applications windows are active. -*/ - -/*! - \typedef Qt::WFlags - - Synonym for Qt::WindowFlags. -*/ - -/*! - \enum Qt::WindowType - - \keyword window flag - - This enum type is used to specify various window-system properties - for the widget. They are fairly unusual but necessary in a few - cases. Some of these flags depend on whether the underlying window - manager supports them. - - The main types are - - \value Widget This is the default type for QWidget. Widgets of - this type are child widgets if they have a parent, - and independent windows if they have no parent. - See also Qt::Window and Qt::SubWindow. - - \value Window Indicates that the widget is a window, usually - with a window system frame and a title bar, - irrespective of whether the widget has a parent or - not. Note that it is not possible to unset this - flag if the widget does not have a parent. - - \value Dialog Indicates that the widget is a window that should - be decorated as a dialog (i.e., typically no - maximize or minimize buttons in the title bar). - This is the default type for QDialog. If you want - to use it as a modal dialog, it should be launched - from another window, or have a parent and used - with the QWidget::windowModality property. If you make - it modal, the dialog will prevent other top-level - windows in the application from getting any input. - We refer to a top-level window that has a parent - as a \e secondary window. - - \value Sheet Indicates that the widget is a Macintosh sheet. - - \value Drawer Indicates that the widget is a Macintosh drawer. - - \value Popup Indicates that the widget is a pop-up top-level - window, i.e. that it is modal, but has a window - system frame appropriate for pop-up menus. - - \value Tool Indicates that the widget is a tool window. A tool - window is often a small window with a smaller than - usual title bar and decoration, typically used for - collections of tool buttons. It there is a parent, - the tool window will always be kept on top of it. - If there isn't a parent, you may consider using - Qt::WindowStaysOnTopHint as well. If the window - system supports it, a tool window can be decorated - with a somewhat lighter frame. It can also be - combined with Qt::FramelessWindowHint. - \br - \br - On Mac OS X, tool windows correspond to the - \l{http://developer.apple.com/documentation/Carbon/Conceptual/HandlingWindowsControls/hitb-wind_cont_concept/chapter_2_section_2.html}{Floating} - class of windows. This means that the window lives on a - level above normal windows; it impossible to put a normal - window on top of it. By default, tool windows will disappear - when the application is inactive. This can be controlled by - the Qt::WA_MacAlwaysShowToolWindow attribute. - - \value ToolTip Indicates that the widget is a tooltip. This is - used internally to implement - \l{QWidget::toolTip}{tooltips}. - - \value SplashScreen Indicates that the window is a splash screen. - This is the default type for QSplashScreen. - - \value Desktop Indicates that this widget is the desktop. This - is the type for QDesktopWidget. - - \value SubWindow Indicates that this widget is a sub-window, such - as a QMdiSubWindow widget. - - There are also a number of flags which you can use to customize - the appearance of top-level windows. These have no effect on other - windows: - - \value MSWindowsFixedSizeDialogHint Gives the window a thin dialog border on Windows. - This style is traditionally used for fixed-size dialogs. - - \value MSWindowsOwnDC Gives the window its own display - context on Windows. - - \value X11BypassWindowManagerHint Bypass the window - manager completely. This results in a borderless window - that is not managed at all (i.e., no keyboard input unless - you call QWidget::activateWindow() manually). - - \value FramelessWindowHint Produces a borderless window. - The user cannot move or resize a borderless window via the window - system. On X11, the result of the flag is dependent on the window manager and its - ability to understand Motif and/or NETWM hints. Most existing - modern window managers can handle this. - - The \c CustomizeWindowHint flag is used to enable customization of - the window controls. This flag must be set to allow the \c - WindowTitleHint, \c WindowSystemMenuHint, \c - WindowMinimizeButtonHint, \c WindowMaximizeButtonHint and \c - WindowCloseButtonHint flags to be changed. - - \value CustomizeWindowHint Turns off the default window title hints. - - \value WindowTitleHint Gives the window a title bar. - - \value WindowSystemMenuHint Adds a window system menu, and - possibly a close button (for example on Mac). If you need to hide - or show a close button, it is more portable to use \c - WindowCloseButtonHint. - - \value WindowMinimizeButtonHint Adds a minimize button. On - some platforms this implies Qt::WindowSystemMenuHint for it to work. - - \value WindowMaximizeButtonHint Adds a maximize button. On - some platforms this implies Qt::WindowSystemMenuHint for it to work. - - \value WindowMinMaxButtonsHint Adds a minimize and a maximize - button. On some platforms this implies Qt::WindowSystemMenuHint for it to work. - - \value WindowCloseButtonHint Adds a close button. On - some platforms this implies Qt::WindowSystemMenuHint for it - to work. - - \value WindowContextHelpButtonHint Adds a context help button to dialogs. - On some platforms this implies Qt::WindowSystemMenuHint for it to work. - - \value MacWindowToolBarButtonHint On Mac OS X adds a tool bar button (i.e., - the oblong button that is on the top right of windows that have toolbars. - - \value BypassGraphicsProxyWidget Prevents the window and its children from - automatically embedding themselves into a QGraphicsProxyWidget if the - parent widget is already embedded. You can set this flag if you - want your widget to always be a toplevel widget on the desktop, - regardless of whether the parent widget is embedded in a scene or - not. - - \value WindowShadeButtonHint - - \value WindowStaysOnTopHint Informs the window system that the - window should stay on top of all other windows. Note that - on some window managers on X11 you also have to pass - Qt::X11BypassWindowManagerHint for this flag to work - correctly. - - \value WindowStaysOnBottomHint Informs the window system that the - window should stay on bottom of all other windows. Note - that on X11 this hint will work only in window managers - that support _NET_WM_STATE_BELOW atom. If a window always - on the bottom has a parent, the parent will also be left on - the bottom. This window hint is currently not implemented - for Mac OS X. - - \value WindowOkButtonHint Adds an OK button to the window decoration of a dialog. - Only supported for Windows CE. - - \value WindowCancelButtonHint Adds a Cancel button to the window decoration of a dialog. - Only supported for Windows CE. - - \value WindowType_Mask A mask for extracting the window type - part of the window flags. - - Obsolete flags: - - \value WMouseNoMask Use Qt::WA_MouseNoMask instead. - \value WDestructiveClose Use Qt::WA_DeleteOnClose instead. - \value WStaticContents Use Qt::WA_StaticContents instead. - \value WGroupLeader No longer needed. - \value WShowModal Use QWidget::windowModality instead. - \value WNoMousePropagation Use Qt::WA_NoMousePropagation instead. - \value WType_TopLevel Use Qt::Window instead. - \value WType_Dialog Use Qt::Dialog instead. - \value WType_Popup Use Qt::Popup instead. - \value WType_Desktop Use Qt::Desktop instead. - \value WType_Mask Use Qt::WindowType_Mask instead. - - \value WStyle_Customize No longer needed. - \value WStyle_NormalBorder No longer needed. - \value WStyle_DialogBorder Use Qt::MSWindowsFixedSizeDialogHint instead. - \value WStyle_NoBorder Use Qt::FramelessWindowHint instead. - \value WStyle_Title Use Qt::WindowTitleHint instead. - \value WStyle_SysMenu Use Qt::WindowSystemMenuHint instead. - \value WStyle_Minimize Use Qt::WindowMinimizeButtonHint instead. - \value WStyle_Maximize Use Qt::WindowMaximizeButtonHint instead. - \value WStyle_MinMax Use Qt::WindowMinMaxButtonsHint instead. - \value WStyle_Tool Use Qt::Tool instead. - \value WStyle_StaysOnTop Use Qt::WindowStaysOnTopHint instead. - \value WStyle_ContextHelp Use Qt::WindowContextHelpButtonHint instead. - - \value WPaintDesktop No longer needed. - \value WPaintClever No longer needed. - - \value WX11BypassWM Use Qt::X11BypassWindowManagerHint instead. - \value WWinOwnDC Use Qt::MSWindowsOwnDC instead. - \value WMacSheet Use Qt::Sheet instead. - \value WMacDrawer Use Qt::Drawer instead. - - \value WStyle_Splash Use Qt::SplashScreen instead. - - \value WNoAutoErase No longer needed. - \value WRepaintNoErase No longer needed. - \value WNorthWestGravity Use Qt::WA_StaticContents instead. - \value WType_Modal Use Qt::Dialog and QWidget::windowModality instead. - \value WStyle_Dialog Use Qt::Dialog instead. - \value WStyle_NoBorderEx Use Qt::FramelessWindowHint instead. - \value WResizeNoErase No longer needed. - \value WMacNoSheet No longer needed. - - \sa QWidget::windowFlags, {Window Flags Example} -*/ - -/*! - \enum Qt::DropAction - - \value CopyAction Copy the data to the target. - \value MoveAction Move the data from the source to the target. - \value LinkAction Create a link from the source to the target. - \value ActionMask - \value IgnoreAction Ignore the action (do nothing with the data). - \value TargetMoveAction On Windows, this value is used when the ownership of the D&D data - should be taken over by the target application, - i.e., the source application should not delete - the data. - \br - On X11 this value is used to do a move. - \br - TargetMoveAction is not used on the Mac. -*/ - -#if defined(Q_OS_WIN) && defined(QT3_SUPPORT) -/*! - \enum Qt::WindowsVersion - \compat - - \value WV_32s - \value WV_95 - \value WV_98 - \value WV_Me - \value WV_DOS_based - \value WV_NT - \value WV_2000 - \value WV_XP - \value WV_2003 - \value WV_NT_based - \value WV_CE - \value WV_CENET - \value WV_CE_based - \value WV_CE_5 - \value WV_CE_6 -*/ -#endif - -#if defined(Q_OS_MAC) && defined(QT3_SUPPORT) -/*! - \enum Qt::MacintoshVersion - \compat - - \value MV_Unknown Use QSysInfo::MV_Unknown instead. - \value MV_9 Use QSysInfo::MV_9 instead. - \value MV_10_DOT_0 Use QSysInfo::MV_10_0 instead. - \value MV_10_DOT_1 Use QSysInfo::MV_10_1 instead. - \value MV_10_DOT_2 Use QSysInfo::MV_10_2 instead. - \value MV_10_DOT_3 Use QSysInfo::MV_10_3 instead. - \value MV_10_DOT_4 Use QSysInfo::MV_10_4 instead. - - \value MV_CHEETAH Use QSysInfo::MV_10_0 instead. - \value MV_PUMA Use QSysInfo::MV_10_1 instead. - \value MV_JAGUAR Use QSysInfo::MV_10_2 instead. - \value MV_PANTHER Use QSysInfo::MV_10_3 instead. - \value MV_TIGER Use QSysInfo::MV_10_4 instead. - - \sa QSysInfo::MacVersion -*/ -#endif - -/*! \typedef Qt::ToolBarDock - \compat - - Use Qt::Dock instead. -*/ - -/*! - \enum Qt::Dock - \compat - - Each dock window can be in one of the following positions: - - \value DockUnmanaged not managed by a Q3MainWindow. - - \value DockTornOff the dock window floats as its own top level - window which always stays on top of the main window. - - \value DockTop above the central widget, below the menu bar. - - \value DockBottom below the central widget, above the status bar. - - \value DockRight to the right of the central widget. - - \value DockLeft to the left of the central widget. - - \value DockMinimized the dock window is not shown (this is - effectively a 'hidden' dock area); the handles of all minimized - dock windows are drawn in one row below the menu bar. - - \omitvalue Bottom - \omitvalue Left - \omitvalue Minimized - \omitvalue Right - \omitvalue Top - \omitvalue TornOff - \omitvalue Unmanaged -*/ - -/*! - \enum Qt::AnchorAttribute - - An anchor has one or more of the following attributes: - - \value AnchorName the name attribute of the anchor. This attribute is - used when scrolling to an anchor in the document. - - \value AnchorHref the href attribute of the anchor. This attribute is - used when a link is clicked to determine what content to load. -*/ - -/*! - \enum Qt::SortOrder - - This enum describes how the items in a widget are sorted. - - \value AscendingOrder The items are sorted ascending e.g. starts with - 'AAA' ends with 'ZZZ' in Latin-1 locales - - \value DescendingOrder The items are sorted descending e.g. starts with - 'ZZZ' ends with 'AAA' in Latin-1 locales - - \omitvalue Ascending - \omitvalue Descending -*/ - -/*! - \enum Qt::ClipOperation - - \value NoClip This operation turns clipping off. - - \value ReplaceClip Replaces the current clip path/rect/region with - the one supplied in the function call. - - \value IntersectClip Intersects the current clip path/rect/region - with the one supplied in the function call. - - \value UniteClip Unites the current clip path/rect/region with the - one supplied in the function call. -*/ - -/*! - \enum Qt::ItemSelectionMode - - This enum is used in QGraphicsItem, QGraphicsScene and QGraphicsView to - specify how items are selected, or how to determine if a shapes and items - collide. - - \value ContainsItemShape The output list contains only items whose - \l{QGraphicsItem::shape()}{shape} is fully contained inside the - selection area. Items that intersect with the area's outline are - not included. - - \value IntersectsItemShape The output list contains both items whose - \l{QGraphicsItem::shape()}{shape} is fully contained inside the - selection area, and items that intersect with the area's - outline. This is a common mode for rubber band selection. - - \value ContainsItemBoundingRect The output list contains only items whose - \l{QGraphicsItem::boundingRect()}{bounding rectangle} is fully - contained inside the selection area. Items that intersect with the - area's outline are not included. - - \value IntersectsItemBoundingRect The output list contains both items - whose \l{QGraphicsItem::boundingRect()}{bounding rectangle} is - fully contained inside the selection area, and items that intersect - with the area's outline. This method is commonly used for - determining areas that need redrawing. - - \sa QGraphicsScene::items(), QGraphicsScene::collidingItems(), - QGraphicsView::items(), QGraphicsItem::collidesWithItem(), - QGraphicsItem::collidesWithPath() -*/ - -/*! - \enum Qt::FillRule - - Specifies which method should be used to fill the paths and polygons. - - \value OddEvenFill Specifies that the region is filled using the - odd even fill rule. With this rule, we determine whether a point - is inside the shape by using the following method. - Draw a horizontal line from the point to a location outside the shape, - and count the number of intersections. If the number of intersections - is an odd number, the point is inside the shape. This mode is the - default. - - \value WindingFill Specifies that the region is filled using the - non zero winding rule. With this rule, we determine whether a - point is inside the shape by using the following method. - Draw a horizontal line from the point to a location outside the shape. - Determine whether the direction of the line at each intersection point - is up or down. The winding number is determined by summing the - direction of each intersection. If the number is non zero, the point - is inside the shape. This fill mode can also in most cases be considered - as the intersection of closed shapes. -*/ - -/*! - \enum Qt::PaintUnit - - \compat - - \value PixelUnit - \value LoMetricUnit Obsolete - \value HiMetricUnit Obsolete - \value LoEnglishUnit Obsolete - \value HiEnglishUnit Obsolete - \value TwipsUnit Obsolete -*/ - -/*! - \enum Qt::TextFormat - - This enum is used in widgets that can display both plain text and - rich text, e.g. QLabel. It is used for deciding whether a text - string should be interpreted as one or the other. This is normally - done by passing one of the enum values to a setTextFormat() - function. - - \value PlainText The text string is interpreted as a plain text - string. - - \value RichText The text string is interpreted as a rich text - string. - - \value AutoText The text string is interpreted as for - Qt::RichText if Qt::mightBeRichText() returns true, otherwise - as Qt::PlainText. - - \value LogText A special, limited text format which is only used - by Q3TextEdit in an optimized mode. -*/ - -/*! - \enum Qt::CursorShape - - This enum type defines the various cursors that can be used. - - The standard arrow cursor is the default for widgets in a normal state. - - \value ArrowCursor \inlineimage cursor-arrow.png - The standard arrow cursor. - \value UpArrowCursor \inlineimage cursor-uparrow.png - An arrow pointing upwards toward the top of the screen. - \value CrossCursor \inlineimage cursor-cross.png - A crosshair cursor, typically used to help the - user accurately select a point on the screen. - \value WaitCursor \inlineimage cursor-wait.png - An hourglass or watch cursor, usually shown during - operations that prevent the user from interacting with - the application. - \value IBeamCursor \inlineimage cursor-ibeam.png - A caret or ibeam cursor, indicating that a widget can - accept and display text input. - \value SizeVerCursor \inlineimage cursor-sizev.png - A cursor used for elements that are used to vertically - resize top-level windows. - \value SizeHorCursor \inlineimage cursor-sizeh.png - A cursor used for elements that are used to horizontally - resize top-level windows. - \value SizeBDiagCursor \inlineimage cursor-sizeb.png - A cursor used for elements that are used to diagonally - resize top-level windows at their top-right and - bottom-left corners. - \value SizeFDiagCursor \inlineimage cursor-sizef.png - A cursor used for elements that are used to diagonally - resize top-level windows at their top-left and - bottom-right corners. - \value SizeAllCursor \inlineimage cursor-sizeall.png - A cursor used for elements that are used to resize - top-level windows in any direction. - \value BlankCursor A blank/invisible cursor, typically used when the cursor - shape needs to be hidden. - \value SplitVCursor \inlineimage cursor-vsplit.png - A cursor used for vertical splitters, indicating that - a handle can be dragged horizontally to adjust the use - of available space. - \value SplitHCursor \inlineimage cursor-hsplit.png - A cursor used for horizontal splitters, indicating that - a handle can be dragged vertically to adjust the use - of available space. - \value PointingHandCursor \inlineimage cursor-hand.png - A pointing hand cursor that is typically used for - clickable elements such as hyperlinks. - \value ForbiddenCursor \inlineimage cursor-forbidden.png - A slashed circle cursor, typically used during drag - and drop operations to indicate that dragged content - cannot be dropped on particular widgets or inside - certain regions. - \value OpenHandCursor \inlineimage cursor-openhand.png - A cursor representing an open hand, typically used to - indicate that the area under the cursor is the visible - part of a canvas that the user can click and drag in - order to scroll around. - \value ClosedHandCursor \inlineimage cursor-closedhand.png - A cursor representing a closed hand, typically used to - indicate that a dragging operation is in progress that - involves scrolling. - \value WhatsThisCursor \inlineimage cursor-whatsthis.png - An arrow with a question mark, typically used to indicate - the presence of What's This? help for a widget. - \value BusyCursor \inlineimage cursor-wait.png - An hourglass or watch cursor, usually shown during - operations that allow the user to interact with - the application while they are performed in the - background. - \value BitmapCursor - \omitvalue LastCursor - \omitvalue CustomCursor - - \omitvalue arrowCursor - \omitvalue upArrowCursor - \omitvalue crossCursor - \omitvalue waitCursor - \omitvalue ibeamCursor - \omitvalue sizeVerCursor - \omitvalue sizeHorCursor - \omitvalue sizeBDiagCursor - \omitvalue sizeFDiagCursor - \omitvalue sizeAllCursor - \omitvalue blankCursor - \omitvalue splitVCursor - \omitvalue splitHCursor - \omitvalue pointingHandCursor - \omitvalue forbiddenCursor - \omitvalue whatsThisCursor -*/ - -/*! - \typedef Qt::TextFlags - \compat - - Use Qt::TextFlag instead. -*/ - -/*! - \enum Qt::LayoutDirection - - Specifies the direction of Qt's layouts: - - \value LeftToRight Left-to-right layout. - \value RightToLeft Right-to-left layout. - - Right-to-left layouts are necessary for certain languages, - notably Arabic and Hebrew. - - \sa QApplication::setLayoutDirection(), QWidget::setLayoutDirection() -*/ - -/*! - \enum Qt::InputMethodQuery - - \value ImMicroFocus The rectangle covering the area of the input cursor in widget coordinates. - \value ImFont The currently used font for text input. - \value ImCursorPosition The logical position of the cursor within the text surrounding the input area (see ImSurroundingText). - If any text is selected, the position returned will be at the logical end of the - selection, even if the real cursor is located at the logical start. - \value ImSurroundingText The plain text around the input area, for example the current paragraph. - \value ImCurrentSelection The currently selected text. -*/ - -/*! - \enum Qt::ItemDataRole - - Each item in the model has a set of data elements associated with - it, each with its own role. The roles are used by the view to indicate - to the model which type of data it needs. - - The general purpose roles are: - - \value DisplayRole The key data to be rendered in the form of text. - \value DecorationRole The data to be rendered as a decoration in the form - of an icon. - \value EditRole The data in a form suitable for editing in an - editor. - \value ToolTipRole The data displayed in the item's tooltip. - \value StatusTipRole The data displayed in the status bar. - \value WhatsThisRole The data displayed for the item in "What's This?" - mode. - \value SizeHintRole The size hint for the item that will be supplied - to views. - - Roles describing appearance and meta data: - - \value FontRole The font used for items rendered with the default - delegate. - \value TextAlignmentRole The alignment of the text for items rendered with the - default delegate. - \value BackgroundRole The background brush used for items rendered with - the default delegate. - \value BackgroundColorRole This role is obsolete. Use BackgroundRole instead. - \value ForegroundRole The foreground brush (text color, typically) - used for items rendered with the default delegate. - \value TextColorRole This role is obsolete. Use ForegroundRole instead. - \value CheckStateRole This role is used to obtain the checked state of - an item (see \l Qt::CheckState). - - Accessibility roles: - - \value AccessibleTextRole The text to be used by accessibility - extensions and plugins, such as screen - readers. - \value AccessibleDescriptionRole A description of the item for accessibility - purposes. - - User roles: - - \value UserRole The first role that can be used for application-specific purposes. - - \omitvalue DisplayPropertyRole - \omitvalue DecorationPropertyRole - \omitvalue ToolTipPropertyRole - \omitvalue StatusTipPropertyRole - \omitvalue WhatsThisPropertyRole -*/ - -/*! - \enum Qt::ItemFlag - - This enum describes the properties of an item: - - \value NoItemFlags It does not have any properties set. - \value ItemIsSelectable It can be selected. - \value ItemIsEditable It can be edited. - \value ItemIsDragEnabled It can be dragged. - \value ItemIsDropEnabled It can be used as a drop target. - \value ItemIsUserCheckable It can be checked or unchecked by the user. - \value ItemIsEnabled The user can interact with the item. - \value ItemIsTristate The item is checkable with three separate states. - - Note that checkable items need to be given both a suitable set of flags - and an initial state, indicating whether the item is checked or not. - This is handled automatically for model/view components, but needs - to be explicitly set for instances of QListWidgetItem, QTableWidgetItem, - and QTreeWidgetItem. - - \sa QAbstractItemModel -*/ - -/*! - \enum Qt::MatchFlag - - This enum describes the type of matches that can be used when searching - for items in a model. - - \value MatchExactly Performs QVariant-based matching. - \value MatchFixedString Performs string-based matching. - String-based comparisons are case-insensitive unless the - \c MatchCaseSensitive flag is also specified. - \value MatchContains The search term is contained in the item. - \value MatchStartsWith The search term matches the start of the item. - \value MatchEndsWith The search term matches the end of the item. - \value MatchCaseSensitive The search is case sensitive. - \value MatchRegExp Performs string-based matching using a regular - expression as the search term. - \value MatchWildcard Performs string-based matching using a string with - wildcards as the search term. - \value MatchWrap Perform a search that wraps around, so that when - the search reaches the last item in the model, it begins again at - the first item and continues until all items have been examined. - \value MatchRecursive Searches the entire hierarchy. - - \sa QString::compare(), QRegExp -*/ - -/*! - \enum Qt::TextElideMode - - This enum specifies where the ellipsis should appear when - displaying texts that don't fit: - - \value ElideLeft The ellipsis should appear at the beginning of the text. - \value ElideRight The ellipsis should appear at the end of the text. - \value ElideMiddle The ellipsis should appear in the middle of the text. - \value ElideNone Ellipsis should NOT appear in the text. - - Qt::ElideMiddle is normally the most appropriate choice for URLs (e.g., - "\l{http://www.qtsoftware.com/careers/movingto/beijing/}{http://www.qtsof...ovingto/beijing/}"), - whereas Qt::ElideRight is appropriate - for other strings (e.g., - "\l{http://doc.trolltech.com/qq/qq09-mac-deployment.html}{Deploying Applications on Ma...}"). - - \sa QAbstractItemView::textElideMode, QFontMetrics::elidedText(), AlignmentFlag QTabBar::elideMode -*/ - -/*! - \enum Qt::WindowModality - - \keyword modal - - This enum specifies the behavior of a modal window. A modal window - is one that blocks input to other windows. Note that windows that - are children of a modal window are not blocked. - - The values are: - \value NonModal The window is not modal and does not block input to other windows. - \value WindowModal The window is modal to a single window hierarchy and blocks input to its parent window, all grandparent windows, and all siblings of its parent and grandparent windows. - \value ApplicationModal The window is modal to the application and blocks input to all windows. - - \sa QWidget::windowModality, QDialog -*/ - -/*! - \enum Qt::TextInteractionFlag - - This enum specifies how a text displaying widget reacts to user input. - - \value NoTextInteraction No interaction with the text is possible. - \value TextSelectableByMouse Text can be selected with the mouse and copied to the clipboard using - a context menu or standard keyboard shortcuts. - \value TextSelectableByKeyboard Text can be selected with the cursor keys on the keyboard. A text cursor is shown. - \value LinksAccessibleByMouse Links can be highlighted and activated with the mouse. - \value LinksAccessibleByKeyboard Links can be focused using tab and activated with enter. - \value TextEditable The text is fully editable. - - \value TextEditorInteraction The default for a text editor. - \value TextBrowserInteraction The default for QTextBrowser. -*/ - -/*! - \enum Qt::MaskMode - - This enum specifies the behavior of the - QPixmap::createMaskFromColor() and QImage::createMaskFromColor() - functions. - - \value MaskInColor Creates a mask where all pixels matching the given color are opaque. - \value MaskOutColor Creates a mask where all pixels matching the given color are transparent. -*/ - -/*! - \enum Qt::DockWidgetAreaSizes - \internal -*/ - -/*! - \enum Qt::ToolBarAreaSizes - \internal -*/ - -/*! - \enum Qt::EventPriority - - This enum can be used to specify event priorities. - - \value HighEventPriority Events with this priority are sent before - events with NormalEventPriority or LowEventPriority. - - \value NormalEventPriority Events with this priority are sent - after events with HighEventPriority, but before events with - LowEventPriority. - - \value LowEventPriority Events with this priority are sent after - events with HighEventPriority or NormalEventPriority. - - Note that these values are provided purely for convenience, since - event priorities can be any value between \c INT_MAX and \c - INT_MIN, inclusive. For example, you can define custom priorities - as being relative to each other: - - \snippet doc/src/snippets/code/doc_src_qnamespace.qdoc 1 - - \sa QCoreApplication::postEvent() -*/ -/*! - \enum Qt::SizeHint - \since 4.4 - - This enum is used by QGraphicsLayoutItem::sizeHint() - - \value MinimumSize is used to specify the minimum size of a graphics layout item. - \value PreferredSize is used to specify the preferred size of a graphics layout item. - \value MaximumSize is used to specify the maximum size of a graphics layout item. - \value MinimumDescent is used to specify the minimum descent of a text string in a graphics layout item. - \omitvalue NSizeHints - - \sa QGraphicsLayoutItem::sizeHint() -*/ - -/*! - \enum Qt::SizeMode - \since 4.4 - - This enum is used by QPainter::drawRoundedRect() and QPainterPath::addRoundedRect() - functions to specify the radii of rectangle corners with respect to the dimensions - of the bounding rectangles specified. - - \value AbsoluteSize Specifies the size using absolute measurements. - \value RelativeSize Specifies the size relative to the bounding rectangle, - typically using percentage measurements. -*/ - -/*! - \enum Qt::WindowFrameSection - \since 4.4 - - This enum is used to describe parts of a window frame. It is returned by - QGraphicsWidget::windowFrameSectionAt() to describe what section of the window - frame is under the mouse. - - \value NoSection - \value LeftSection - \value TopLeftSection - \value TopSection - \value TopRightSection - \value RightSection - \value BottomRightSection - \value BottomSection - \value BottomLeftSection - \value TitleBarArea - - \sa QGraphicsWidget::windowFrameEvent() - \sa QGraphicsWidget::paintWindowFrame() - \sa QGraphicsWidget::windowFrameSectionAt() - -*/ - -/*! - \enum Qt::TileRule - \since 4.6 - - This enum describes how to repeat or stretch the parts of an image - when drawing. - - \value Stretch Scale the image to fit to the available area. - - \value Repeat Tile the image until there is no more space. May crop - the last image. - - \value Round Like Repeat, but scales the images down to ensure that - the last image is not cropped. -*/ - -/*! - \enum Qt::Initialization - \internal -*/ - -/*! - \enum Qt::GestureState - \since 4.6 - - This enum type describes the state of a gesture. - - \omitvalue NoGesture - \value GestureStarted A continuous gesture has started. - \value GestureUpdated A gesture continues. - \value GestureFinished A gesture has finished. - - \sa QGesture -*/ -- cgit v0.12 From 0ba7569ab7911bf65b6321ad65ac979d9d034c2b Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Thu, 30 Jul 2009 06:27:34 +0200 Subject: Docs: Improve QGraphicsTransform and subclasses Fix a few typos and add more descriptive documentation to the class itself and its subclasses. Reviewed-by: Volker Hilsheimer Reviewed-by: Martin Smith --- src/gui/graphicsview/qgraphicsitem.cpp | 163 ++++++---- src/gui/graphicsview/qgraphicsitem_p.h | 5 +- .../graphicsview/qgraphicsscenebsptreeindex.cpp | 9 +- src/gui/graphicsview/qgraphicstransform.cpp | 340 +++++++++++++-------- src/gui/graphicsview/qgraphicstransform.h | 1 + 5 files changed, 327 insertions(+), 191 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 5aae93e..75d6ead 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -135,38 +135,39 @@ \section1 Transformation - QGraphicsItem supports affine transformations in addition to its base - position, pos(). To change the item's transformation, you can pass - a transformation matrix to setTransform() - - Item transformations accumulate from parent to child, so if both a - parent and child item are rotated 90 degrees, the child's total - transformation will be 180 degrees. Similarly, if the item's - parent is scaled to 2x its original size, its children will also - be twice as large. An item's transformation does not affect its - own local geometry; all geometry functions (e.g., contains(), - update(), and all the mapping functions) still operate in local - coordinates. For convenience, QGraphicsItem provides the functions - sceneTransform(), which returns the item's total transformation + QGraphicsItem supports projective transformations in addition to its base + position, pos(). There are several ways to change an item's transformation. + For simple transformations, you can call either of the convenience + functions setRotation() or setScale(), or you can pass any transformation + matrix to setTransform(). For advanced transformation control you also have + the option of setting several combined transformations by calling + setTransformations(). + + Item transformations accumulate from parent to child, so if both a parent + and child item are rotated 90 degrees, the child's total transformation + will be 180 degrees. Similarly, if the item's parent is scaled to 2x its + original size, its children will also be twice as large. An item's + transformation does not affect its own local geometry; all geometry + functions (e.g., contains(), update(), and all the mapping functions) still + operate in local coordinates. For convenience, QGraphicsItem provides the + functions sceneTransform(), which returns the item's total transformation matrix (including its position and all parents' positions and - transformations), and scenePos(), which returns its position in - scene coordinates. To reset an item's matrix, call - resetTransform(). + transformations), and scenePos(), which returns its position in scene + coordinates. To reset an item's matrix, call resetTransform(). - Another way to apply transformation to an item is to use the , or - set the different transformation properties (transformOrigin, - x/y/zRotation, x/yScale, horizontal/verticalShear). Those - properties come in addition to the base transformation + Certain transformation operations produce a different outcome depending on + the order in which they are applied. For example, if you scale an + transform, and then rotate it, you may get a different result than if the + transform was rotated first. However, the order you set the transformation + properties on QGraphicsItem does not affect the resulting transformation; + QGraphicsItem always applies the properties in a fixed, defined order: - The order you set the transformation properties does not affect - the resulting transformation The resulting transformation is - always computed in the following order - - \code - [Origin] [Base] [RotateX] [RotateY] [RotateZ] [Shear] [Scale] [-Origin] - \endcode - - Where [Base] is the stransformation set by setTransform + \list + \o The item's base transform is applied (transform()) + \o The item's transformations list is applied in order (transformations()) + \o The item is rotated relative to its transform origin point (rotation(), transformOriginPoint()) + \o The item is scaled relative to its transform origin point (scale(), transformOriginPoint()) + \endlist \section1 Painting @@ -2969,11 +2970,10 @@ QMatrix QGraphicsItem::matrix() const Returns this item's transformation matrix. - Either the one set by setTransform, or the resulting transformation from - all the transfmation properties - - If no matrix or transformation property has been set, the - identity matrix is returned. + The transformation matrix is combined with the item's rotation(), scale() + and transformations() into a combined transformations for the item. + + The default transformation matrix is an identity matrix. \sa setTransform(), sceneTransform() */ @@ -2987,13 +2987,13 @@ QTransform QGraphicsItem::transform() const /*! \since 4.6 - Returns the rotation around the Z axis. - - The default is 0 + Returns the clockwise rotation, in degrees, around the Z axis. The default + value is 0 (i.e., the item is not rotated). - \warning The value doesn't take in account any rotation set with the setTransform() method. + The rotation is combined with the item's scale(), transform() and + transformations() to map the item's coordinate system to the parent item. - \sa setRotation(), {Transformations} + \sa setRotation(), transformOriginPoint(), {Transformations} */ qreal QGraphicsItem::rotation() const { @@ -3005,9 +3005,19 @@ qreal QGraphicsItem::rotation() const /*! \since 4.6 - Sets the rotation around the Z axis to \a angle degrees. + Sets the clockwise rotation \a angle, in degrees, around the Z axis. The + default value is 0 (i.e., the item is not rotated). Assigning a negative + value will rotate the item counter-clockwise. Normally the rotation angle + is in the range (-360, 360), but it's also possible to assign values + outside of this range (e.g., a rotation of 370 degrees is the same as a + rotation of 10 degrees). + + The item is rotated around its transform origin point, which by default + is (0, 0). You can select a different transformation origin by calling + setTransformOriginPoint(). - \warning The value doesn't take in account any rotation set with the setTransform() method. + The rotation is combined with the item's scale(), transform() and + transformations() to map the item's coordinate system to the parent item. \sa rotation(), setTransformOriginPoint(), {Transformations} */ @@ -3027,13 +3037,13 @@ void QGraphicsItem::setRotation(qreal angle) /*! \since 4.6 - Returns the scale factor of the item. + Returns the scale factor of the item. The default scale factor is 1.0 + (i.e., the item is not scaled). - The default is 1 + The scale is combined with the item's rotation(), transform() and + transformations() to map the item's coordinate system to the parent item. - \warning The value doesn't take in account any scaling set with the setTransform() method. - - \sa setScale(), {Transformations} + \sa setScale(), rotation(), {Transformations} */ qreal QGraphicsItem::scale() const { @@ -3045,9 +3055,17 @@ qreal QGraphicsItem::scale() const /*! \since 4.6 - Sets the scale factor of the item to \a factor. + Sets the scale \a factor of the item. The default scale factor is 1.0 + (i.e., the item is not scaled). A scale factor of 0.0 will collapse the + item to a single point. If you provide a negative scale factor, the + item will be flipped and mirrored (i.e., rotated 180 degrees). + + The item is scaled around its transform origin point, which by default + is (0, 0). You can select a different transformation origin by calling + setTransformOriginPoint(). - \warning The value doesn't take in account any scaling set with the setTransform() method. + The scale is combined with the item's rotation(), transform() and + transformations() to map the item's coordinate system to the parent item. \sa scale(), setTransformOriginPoint(), {Transformations} */ @@ -3068,9 +3086,17 @@ void QGraphicsItem::setScale(qreal factor) /*! \since 4.6 - returns list of graphics transformations on the item. + Returns a list of graphics transforms that currently apply to this item. - \sa scale(), setTransformOriginPoint(), {Transformations} + QGraphicsTransform is for applying and controlling a chain of individual + transformation operations on an item. It's particularily useful in + animations, where each transform operation needs to be interpolated + independently, or differently. + + The transformations are combined with the item's rotation(), scale() and + transform() to map the item's coordinate system to the parent item. + + \sa scale(), rotation(), transformOriginPoint(), {Transformations} */ QList QGraphicsItem::transformations() const { @@ -3082,7 +3108,20 @@ QList QGraphicsItem::transformations() const /*! \since 4.6 - Sets a list of graphics transformations on the item to \a transformations. + Sets a list of graphics \a transformations (QGraphicsTransform) that + currently apply to this item. + + If all you want is to rotate or scale an item, you should call setRotation() + or setScale() instead. If you want to set an arbitrary transformation on + an item, you can call setTransform(). + + QGraphicsTransform is for applying and controlling a chain of individual + transformation operations on an item. It's particularily useful in + animations, where each transform operation needs to be interpolated + independently, or differently. + + The transformations are combined with the item's rotation(), scale() and + transform() to map the item's coordinate system to the parent item. \sa scale(), setTransformOriginPoint(), {Transformations} */ @@ -3098,7 +3137,9 @@ void QGraphicsItem::setTransformations(const QList &transf d_ptr->dirtySceneTransform = 1; } - +/*! + \internal +*/ void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t) { if (!transformData) @@ -3432,7 +3473,9 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine) to map an item coordiate to a scene coordinate, or mapFromScene() to map from scene coordinates to item coordinates. - \warning using this function doesnt affect the value of the transformation properties + The transformation matrix is combined with the item's rotation(), scale() + and transformations() into a combined transformation that maps the item's + coordinate system to its parent. \sa transform(), setRotation(), setScale(), setTransformOriginPoint(), {The Graphics View Coordinate System}, {Transformations} */ @@ -3491,7 +3534,8 @@ void QGraphicsItem::resetTransform() /*! \obsolete - Use setZRotation() instead + + Use setRotation() instead Rotates the current item transformation \a angle degrees clockwise around its origin. To translate around an arbitrary point (x, y), you need to @@ -3501,8 +3545,6 @@ void QGraphicsItem::resetTransform() \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 6 - \warning using this functionhas no effect on the zRotation value - \sa setTransform(), transform(), scale(), shear(), translate() */ void QGraphicsItem::rotate(qreal angle) @@ -3512,6 +3554,7 @@ void QGraphicsItem::rotate(qreal angle) /*! \obsolete + Use setScale() instead Scales the current item transformation by (\a sx, \a sy) around its @@ -3522,8 +3565,6 @@ void QGraphicsItem::rotate(qreal angle) \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 7 - \warning using this function has no effect on the xScale or yScale value - \sa setTransform(), transform() */ void QGraphicsItem::scale(qreal sx, qreal sy) @@ -3533,11 +3574,10 @@ void QGraphicsItem::scale(qreal sx, qreal sy) /*! \obsolete - Use setShear instead. - Shears the current item transformation by (\a sh, \a sv). + Use setTransform() instead. - \warning using this function has no effect on the horizontalShear or verticalShear value + Shears the current item transformation by (\a sh, \a sv). \sa setTransform(), transform() */ @@ -3548,6 +3588,7 @@ void QGraphicsItem::shear(qreal sh, qreal sv) /*! \obsolete + Use setPos() or setTransformOriginPoint() instead. Translates the current item transformation by (\a dx, \a dy). diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index b8d98c1..5c3622b 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -468,7 +468,8 @@ public: QGraphicsItem *q_ptr; }; -struct QGraphicsItemPrivate::TransformData { +struct QGraphicsItemPrivate::TransformData +{ QTransform transform; qreal scale; qreal rotation; @@ -481,7 +482,7 @@ struct QGraphicsItemPrivate::TransformData { scale(1.0), rotation(0.0), xOrigin(0.0), yOrigin(0.0), onlyTransform(true) - {} + { } QTransform computedFullTransform(QTransform *postmultiplyTransform = 0) const { diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp index 3cb33d1..07d23b7 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp @@ -525,7 +525,7 @@ QGraphicsSceneBspTreeIndex::~QGraphicsSceneBspTreeIndex() } /*! - \reimp + \internal Clear the all the BSP index. */ void QGraphicsSceneBspTreeIndex::clear() @@ -566,7 +566,7 @@ void QGraphicsSceneBspTreeIndex::removeItem(QGraphicsItem *item) } /*! - \reimp + \internal Update the BSP when the \a item 's bounding rect has changed. */ void QGraphicsSceneBspTreeIndex::prepareBoundingRectChange(const QGraphicsItem *item) @@ -682,7 +682,7 @@ void QGraphicsSceneBspTreeIndex::setBspTreeDepth(int depth) } /*! - \reimp + \internal This method react to the \a rect change of the scene and reset the BSP tree index. @@ -695,11 +695,10 @@ void QGraphicsSceneBspTreeIndex::updateSceneRect(const QRectF &rect) } /*! - \reimp + \internal This method react to the \a change of the \a item and use the \a value to update the BSP tree if necessary. - */ void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value) { diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index b55d78e..890aff7 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -39,6 +39,43 @@ ** ****************************************************************************/ +/*! + \class QGraphicsTransform + \brief The QGraphicsTransform class is an abstract base class for building + advanced transformations on QGraphicsItems. + \since 4.6 + + As an alternative to QGraphicsItem::transform, QGraphicsTransform lets you + create and control advanced transformations that can be configured + independently using specialized properties. + + QGraphicsItem allows you to assign any number of QGraphicsTransform + instances to one QGraphicsItem. Each QGraphicsTransform is applied in + order, one at a time, to the QGraphicsItem it's assigned to. + + QGraphicsTransform is particularily useful for animations. Whereas + QGraphicsItem::setTransform() lets you assign any transform directly to an + item, there is no direct way to interpolate between two different + transformations (e.g., when transitioning between two states, each for + which the item has a different arbitrary transform assigned). Using + QGraphicsTransform you can interpolate the property values of each + independent transformation. The resulting operation is then combined into a + single transform which is applied to QGraphicsItem. + + If you want to create your own configurable transformation, you can create + a subclass of QGraphicsTransform (or any or the existing subclasses), and + reimplement the pure virtual applyTo() function, which takes a pointer to a + QTransform. Each operation you would like to apply should be exposed as + properties (e.g., customTransform->setVerticalShear(2.5)). Inside you + reimplementation of applyTo(), you can modify the provided transform + respectively. + + QGraphicsTransform can be used together with QGraphicsItem::setTransform(), + QGraphicsItem::setRotation(), and QGraphicsItem::setScale(). + + \sa QGraphicsItem::transform(), QGraphicsScale, QGraphicsRotation, QGraphicsRotation3D +*/ + #include "qgraphicstransform.h" #include "qgraphicsitem_p.h" #include "qgraphicstransform_p.h" @@ -51,7 +88,6 @@ QT_BEGIN_NAMESPACE - void QGraphicsTransformPrivate::setItem(QGraphicsItem *i) { if (item == i) @@ -77,15 +113,38 @@ void QGraphicsTransformPrivate::updateItem(QGraphicsItem *item) item->d_ptr->dirtySceneTransform = 1; } -void QGraphicsTransform::update() +/*! + Constructs a new QGraphicsTransform with the given \a parent. +*/ +QGraphicsTransform::QGraphicsTransform(QObject *parent) + : QObject(*new QGraphicsTransformPrivate, parent) +{ +} + +/*! + Destroys the graphics transform. +*/ +QGraphicsTransform::~QGraphicsTransform() { Q_D(QGraphicsTransform); - if (d->item) - d->updateItem(d->item); + d->setItem(0); +} + +/*! + \internal +*/ +QGraphicsTransform::QGraphicsTransform(QGraphicsTransformPrivate &p, QObject *parent) + : QObject(p, parent) +{ } /*! - returns this object as a QTransform. + Applies this transformation to an identity transform, and returns the + resulting transform. + + This is equivalent to passing an identity transform to applyTo(). + + \sa applyTo() */ QTransform QGraphicsTransform::transform() const { @@ -95,76 +154,65 @@ QTransform QGraphicsTransform::transform() const } /*! - \class QGraphicsTransform - \brief The QGraphicsTransform class is an abstract base class for tranformations on QGraphicsItems. - \since 4.6 - - The classes that inherit QGraphicsTransform express different types of transformations - that can be applied to graphics items. + \fn void QGraphicsTransform::applyTo(QTransform *transform) const - A list of these transformations can be applied to any graphics item. These - transformations are then easily modifyable and usable from e.g. within animations. + This pure virtual method has to be reimplemented in derived classes. - QGraphicsTransform is an abstract base class that is implemented by QGraphicsScale, - QGraphicsRotation and QGraphicsRotation3D. Subclasses have to implement the applyTo method. + It applies this transformation to \a transform. - \sa QGraphicsItem::transform(), QGraphicsScale, QGraphicsRotation, QGraphicsRotation3D + \sa QGraphicsItem::transform() */ /*! - Constructs a new QGraphicsTransform with \a parent. -*/ -QGraphicsTransform::QGraphicsTransform(QObject *parent) : - QObject(*new QGraphicsTransformPrivate, parent) -{ -} + Notifies that this transform operation has changed its parameters in such a + way that applyTo() will return a different result than before. -/*! - Destructs the graphics transform. + When implementing you own custom graphics transform, you must call this + function every time you change a parameter, to let QGraphicsItem know that + its transformation needs to be updated. + + \sa applyTo() */ -QGraphicsTransform::~QGraphicsTransform() +void QGraphicsTransform::update() { Q_D(QGraphicsTransform); - d->setItem(0); + if (d->item) + d->updateItem(d->item); } /*! - \internal -*/ -QGraphicsTransform::QGraphicsTransform(QGraphicsTransformPrivate &p, QObject *parent) - : QObject(p, parent) -{ -} - -/*! \fn void QGraphicsTransform::applyTo(QTransform *transform) const + \class QGraphicsScale + \brief The QGraphicsScale class provides a scale transformation. + \since 4.6 - This pure virtual method has to be reimplemented in derived classes. + QGraphicsScene provides certain parameters to help control how the scale + should be applied. - It applies this transformation to \a transform. -*/ + The origin is the point that the item is scaled from (i.e., it stays fixed + relative to the parent as the rest of the item grows). By default the + origin is QPointF(0, 0). + The two parameters xScale and yScale describe the scale factors to apply in + horizontal and vertical direction. They can take on any value, including 0 + (to collapse the item to a point) or negativate value. A negative xScale + value will mirror the item horizontally. A negative yScale value will flip + the item vertically. -/*! - \class QGraphicsScale - \brief The QGraphicsScale class provides a way to scale a graphics item in 2 dimensions. - \since 4.6 - - QGraphicsScale contains an \a origin around which the scaling happens, and two - scale factors, xScale and yScale, the x and one for the y axis. + \sa QGraphicsTransform, QGraphicsItem::setScale(), QTransform::scale() */ class QGraphicsScalePrivate : public QGraphicsTransformPrivate { public: QGraphicsScalePrivate() - : xScale(1), yScale(1) {} + : xScale(1), yScale(1) {} QPointF origin; qreal xScale; qreal yScale; }; /*! - Constructs a new graphics scale object with \a parent. + Constructs an empty QGraphicsScale object with the given \a parent. */ QGraphicsScale::QGraphicsScale(QObject *parent) : QGraphicsTransform(*new QGraphicsScalePrivate, parent) @@ -172,24 +220,26 @@ QGraphicsScale::QGraphicsScale(QObject *parent) } /*! - Destroys the object + Destroys the graphics scale. */ QGraphicsScale::~QGraphicsScale() { } /*! - \property QGraphicsScale::origin - The origin of the scale. All scaling will be done relative to this point. + \property QGraphicsScale::origin + \brief The QGraphicsScene class provides the origin of the scale. + + All scaling will be done relative to this point (i.e., this point + will stay fixed, relative to the parent, when the item is scaled). - The \a origin is in other words the fixed point for the transformation. + \sa xScale, yScale */ QPointF QGraphicsScale::origin() const { Q_D(const QGraphicsScale); return d->origin; } - void QGraphicsScale::setOrigin(const QPointF &point) { Q_D(QGraphicsScale); @@ -199,26 +249,21 @@ void QGraphicsScale::setOrigin(const QPointF &point) } /*! - \fn QGraphicsScale::originChanged() - - This signal is emitted whenever the origin of the object - changes. -*/ - -/*! - \property QGraphicsScale::xScale + \property QGraphicsScale::xScale + \brief the horizontal scale factor. - The scale factor in x direction. The x direction is - in the graphics items logical coordinates. + The scale factor can be any real number; the default value is 1.0. If you + set the factor to 0.0, the item will be collapsed to a single point. If you + provide a negative value, the item will be mirrored horizontally around its + origin. - \sa yScale + \sa yScale, origin */ qreal QGraphicsScale::xScale() const { Q_D(const QGraphicsScale); return d->xScale; } - void QGraphicsScale::setXScale(qreal scale) { Q_D(QGraphicsScale); @@ -230,19 +275,21 @@ void QGraphicsScale::setXScale(qreal scale) } /*! - \property QGraphicsScale::yScale + \property QGraphicsScale::yScale + \brief the vertical scale factor. - The scale factor in y direction. The y direction is - in the graphics items logical coordinates. + The scale factor can be any real number; the default value is 1.0. If you + set the factor to 0.0, the item will be collapsed to a single point. If you + provide a negative value, the item will be flipped vertically around its + origin. - \sa xScale + \sa xScale, origin */ qreal QGraphicsScale::yScale() const { Q_D(const QGraphicsScale); return d->yScale; } - void QGraphicsScale::setYScale(qreal scale) { Q_D(QGraphicsScale); @@ -254,14 +301,7 @@ void QGraphicsScale::setYScale(qreal scale) } /*! - \fn QGraphicsScale::scaleChanged() - - This signal is emitted whenever the xScale or yScale of the object - changes. -*/ - -/*! - \reimp + \reimp */ void QGraphicsScale::applyTo(QTransform *transform) const { @@ -272,12 +312,41 @@ void QGraphicsScale::applyTo(QTransform *transform) const } /*! - \class QGraphicsRotation - \brief The QGraphicsRotation class provides a way to rotate a graphics item in 2 dimensions. - \since 4.6 + \fn QGraphicsScale::originChanged() + + QGraphicsScale emits this signal when its origin changes. + + \sa QGraphicsScale::origin +*/ + +/*! + \fn QGraphicsScale::scaleChanged() + + This signal is emitted whenever the xScale or yScale of the object + changes. - QGraphicsRotation contains an \a origin around which the rotation happens, and one - angle in degrees describing the amount of the rotation. + \sa QGraphicsScale::xScale, QGraphicsScale::yScale +*/ + +/*! + \class QGraphicsRotation + \brief The QGraphicsRotation class provides a rotation transformation. + \since 4.6 + + QGraphicsRotation provides certain parameters to help control how the + rotation should be applied. + + The origin is the point that the item is rotated around (i.e., it stays + fixed relative to the parent as the rest of the item is rotated). By + default the origin is QPointF(0, 0). + + The angle property provides the number of degrees to rotate the item + clockwise around the origin. This value also be negative, indicating a + counter-clockwise rotation. For animation purposes it may also be useful to + provide rotation angles exceeding (-360, 360) degrees, for instance to + animate how an item rotates several times. + + \sa QGraphicsTransform, QGraphicsItem::setRotation(), QTransform::rotate() */ class QGraphicsRotationPrivate : public QGraphicsTransformPrivate @@ -291,7 +360,7 @@ public: }; /*! - Constructs a new graphics rotation with \a parent. + Constructs a new QGraphicsRotation with the given \a parent. */ QGraphicsRotation::QGraphicsRotation(QObject *parent) : QGraphicsTransform(*new QGraphicsRotationPrivate, parent) @@ -299,7 +368,7 @@ QGraphicsRotation::QGraphicsRotation(QObject *parent) } /*! - \internal + \internal */ QGraphicsRotation::QGraphicsRotation(QGraphicsRotationPrivate &p, QObject *parent) : QGraphicsTransform(p, parent) @@ -307,24 +376,26 @@ QGraphicsRotation::QGraphicsRotation(QGraphicsRotationPrivate &p, QObject *paren } /*! - Destructs the object + Destroys the graphics rotation. */ QGraphicsRotation::~QGraphicsRotation() { } /*! - \property QGraphicsRotation::origin - The origin around which this object will rotate the graphics item. + \property QGraphicsRotation::origin + \brief the origin of the rotation. - The \a origin is in other words the fixed point for the transformation. + All rotations will be done relative to this point (i.e., this point + will stay fixed, relative to the parent, when the item is rotated). + + \sa angle */ QPointF QGraphicsRotation::origin() const { Q_D(const QGraphicsRotation); return d->origin; } - void QGraphicsRotation::setOrigin(const QPointF &point) { Q_D(QGraphicsRotation); @@ -334,22 +405,22 @@ void QGraphicsRotation::setOrigin(const QPointF &point) } /*! - \fn QGraphicsRotation::originChanged() + \property QGraphicsRotation::angle + \brief the angle for clockwise rotation, in degrees. - This signal is emitted whenever the origin of the object - changes. -*/ + The angle can be any real number; the default value is 0.0. A value of 180 + will rotate 180 degrees, clockwise. If you provide a negative number, the + item will be rotated counter-clockwise. Normally the rotation angle will be + in the range (-360, 360), but you can also provide numbers outside of this + range (e.g., a angle of 370 degrees gives the same result as 10 degrees). -/*! - \property QGraphicsRotation::angle - The angle, in degrees, of the rotation. + \sa origin */ qreal QGraphicsRotation::angle() const { Q_D(const QGraphicsRotation); return d->angle; } - void QGraphicsRotation::setAngle(qreal angle) { Q_D(QGraphicsRotation); @@ -361,33 +432,50 @@ void QGraphicsRotation::setAngle(qreal angle) } /*! - \fn void QGraphicsRotation::angleChanged() - - This signal is emitted whenever the angle of the object - changes. -*/ - -/*! - \reimp + \reimp */ void QGraphicsRotation::applyTo(QTransform *t) const { Q_D(const QGraphicsRotation); - if(d->angle) { + if (d->angle) { t->translate(d->origin.x(), d->origin.y()); t->rotate(d->angle); t->translate(-d->origin.x(), -d->origin.y()); } } +/*! + \fn QGraphicsRotation::originChanged() + + This signal is emitted whenever the origin has changed. + + \sa QGraphicsRotation::origin +*/ /*! - \class QGraphicsRotation3D - \brief The QGraphicsRotation3D class provides a way to rotate a graphics item in 3 dimensions. - \since 4.6 + \fn void QGraphicsRotation::angleChanged() - In addition to the origin and angle of a simple QGraphicsRotation, QGraphicsRotation3D contains - also an axis that describes around which axis in space the rotation is supposed to happen. + This signal is emitted whenever the angle has changed. + + \sa QGraphicsRotation::angle +*/ + +/*! + \class QGraphicsRotation3D + \brief The QGraphicsRotation3D class provides rotation in 3 dimensions. + \since 4.6 + + QGraphicsRotation3D extends QGraphicsRotation with the ability to rotate + around a given axis. + + You can provide the desired axis by assigning a QVector3D to the axis + property. The angle property, which is provided by QGraphicsRotation, now + describes the number of degrees to rotate around this axis. + + By default the axis is (0, 0, 1), giving QGraphicsRotation3D the same + default behavior as QGraphicsRotation (i.e., rotation around the Z axis). + + \sa QGraphicsTransform, QGraphicsItem::setRotation(), QTransform::rotate() */ class QGraphicsRotation3DPrivate : public QGraphicsRotationPrivate @@ -399,7 +487,7 @@ public: }; /*! - Constructs a new 3D rotation with \a parent. + Constructs a new QGraphicsRotation3D with the given \a parent. */ QGraphicsRotation3D::QGraphicsRotation3D(QObject *parent) : QGraphicsRotation(*new QGraphicsRotation3DPrivate, parent) @@ -407,7 +495,7 @@ QGraphicsRotation3D::QGraphicsRotation3D(QObject *parent) } /*! - Destroys the object + Destroys the 3D graphics rotation. */ QGraphicsRotation3D::~QGraphicsRotation3D() { @@ -415,15 +503,22 @@ QGraphicsRotation3D::~QGraphicsRotation3D() /*! \property QGraphicsRotation3D::axis + \brief a rotation axis, specified by a vector in 3D space. + + This can be any axis in 3D space. By default the axis is (0, 0, 1), + which is aligned with the Z axis and provides the same behavior + for the rotation angle as QGraphicsRotation. If you provide another + axis, QGraphicsRotation3D will provide a transformation that rotates + around this axis. For example, if you would like to rotate an item + around its X axis, you could pass (1, 0, 0) as the axis. - A rotation axis is specified by a vector in 3D space. + \sa QTransform, QGraphicsRotation::angle */ QVector3D QGraphicsRotation3D::axis() { Q_D(QGraphicsRotation3D); return d->axis; } - void QGraphicsRotation3D::setAxis(const QVector3D &axis) { Q_D(QGraphicsRotation3D); @@ -431,17 +526,10 @@ void QGraphicsRotation3D::setAxis(const QVector3D &axis) update(); } -/*! - \fn void QGraphicsRotation3D::axisChanged() - - This signal is emitted whenever the axis of the object - changes. -*/ - -const qreal inv_dist_to_plane = 1. / 1024.; +static const qreal inv_dist_to_plane = 1. / 1024.; /*! - \reimp + \reimp */ void QGraphicsRotation3D::applyTo(QTransform *t) const { @@ -474,6 +562,12 @@ void QGraphicsRotation3D::applyTo(QTransform *t) const t->translate(-d->origin.x(), -d->origin.y()); } +/*! + \fn void QGraphicsRotation3D::axisChanged() + + This signal is emitted whenever the axis of the object changes. +*/ + #include "moc_qgraphicstransform.cpp" QT_END_NAMESPACE diff --git a/src/gui/graphicsview/qgraphicstransform.h b/src/gui/graphicsview/qgraphicstransform.h index b5d8d84..d7c07d0 100644 --- a/src/gui/graphicsview/qgraphicstransform.h +++ b/src/gui/graphicsview/qgraphicstransform.h @@ -70,6 +70,7 @@ protected Q_SLOTS: protected: QGraphicsTransform(QGraphicsTransformPrivate &p, QObject *parent); + private: friend class QGraphicsItem; friend class QGraphicsItemPrivate; -- cgit v0.12 From 56b6a5924008ab5cdbae36e9662eddba923acd5e Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 31 Jul 2009 08:50:07 +1000 Subject: Fixed corrupt testlogs on Windows and other places where vsnprintf is not C99-compliant. C99 says vsnprintf returns >= `size' when not enough memory was available. In practice, on Windows, glibc < 2.0.6, and probably plenty of other places it returns -1 instead. Reviewed-by: Rhys Weatherley --- src/testlib/qtestcase.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index e44be9c..1dae828 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -834,11 +834,12 @@ int qt_asprintf(char **str, const char *format, ...) res = qvsnprintf(*str, size, format, ap); va_end(ap); (*str)[size - 1] = '\0'; - if (res < size) { - // We succeeded or fatally failed + if (res >= 0 && res < size) { + // We succeeded break; } - // buffer wasn't big enough, try again + // buffer wasn't big enough, try again. + // Note, we're assuming that a result of -1 is always due to running out of space. size *= 2; if (size > MAXSIZE) { break; -- cgit v0.12 From 29202f033c87b5efe305e606805a26c59886875b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 29 Jul 2009 18:13:24 +1000 Subject: Add CONSTANT attribute to Q_PROPERTY() This will be used by the declarative module to determine if a property lacking a NOTIFY signal is truly constant, or just missing a NOTIFY signal. Reviewed-by: Roberto Raggi --- doc/src/properties.qdoc | 6 ++++++ doc/src/snippets/code/doc_src_properties.qdoc | 3 ++- src/corelib/kernel/qmetaobject.cpp | 29 ++++++++++++++++++++++++++- src/corelib/kernel/qmetaobject.h | 2 ++ src/tools/moc/generator.cpp | 7 ++++++- src/tools/moc/moc.cpp | 23 +++++++++++++++++++++ src/tools/moc/moc.h | 3 ++- tests/auto/qmetaobject/tst_qmetaobject.cpp | 17 ++++++++++++++++ 8 files changed, 86 insertions(+), 4 deletions(-) diff --git a/doc/src/properties.qdoc b/doc/src/properties.qdoc index 5490dd0..cac5016 100644 --- a/doc/src/properties.qdoc +++ b/doc/src/properties.qdoc @@ -122,6 +122,12 @@ editable property for (checkable) buttons. Note that QItemDelegate gets and sets a widget's \c USER property. + \o The presence of the \c CONSTANT attibute indicates that the property + value is constant. For a given object instance, the READ method of a + constant property must return the same value every time it is called. This + constant value may be different for different instances of the object. A + constant property cannot have a WRTE method or a NOTIFY signal. + \endlist The \c READ, \c WRITE, and \c RESET functions can be inherited. diff --git a/doc/src/snippets/code/doc_src_properties.qdoc b/doc/src/snippets/code/doc_src_properties.qdoc index 377cc9c..64e5377 100644 --- a/doc/src/snippets/code/doc_src_properties.qdoc +++ b/doc/src/snippets/code/doc_src_properties.qdoc @@ -7,7 +7,8 @@ Q_PROPERTY(type name [DESIGNABLE bool] [SCRIPTABLE bool] [STORED bool] - [USER bool]) + [USER bool] + [CONSTANT]) //! [0] diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 08cecaf..fee2da9 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -159,7 +159,9 @@ enum PropertyFlags { ResolveEditable = 0x00080000, User = 0x00100000, ResolveUser = 0x00200000, - Notify = 0x00400000 + Notify = 0x00400000, + Dynamic = 0x00800000, + Constant = 0x00000400 }; enum MethodFlags { @@ -2439,6 +2441,31 @@ bool QMetaProperty::isUser(const QObject *object) const } /*! + \internal +*/ +bool QMetaProperty::isDynamic() const +{ + if (!mobj) + return false; + int flags = mobj->d.data[handle + 2]; + return flags & Dynamic; +} + +/*! + Returns true if the property is constant; otherwise returns false. + + A property is constant if the \c{Q_PROPERTY()}'s \c CONSTANT attribute + is set. +*/ +bool QMetaProperty::isConstant() const +{ + if (!mobj) + return false; + int flags = mobj->d.data[handle + 2]; + return flags & Constant; +} + +/*! \obsolete Returns true if the property is editable for the given \a object; diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 000ba6e..73b52a9 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -187,6 +187,8 @@ public: bool isStored(const QObject *obj = 0) const; bool isEditable(const QObject *obj = 0) const; bool isUser(const QObject *obj = 0) const; + bool isDynamic() const; + bool isConstant() const; bool isFlagType() const; bool isEnumType() const; diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index b872dfd..e4086e6 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -66,7 +66,9 @@ enum PropertyFlags { ResolveEditable = 0x00080000, User = 0x00100000, ResolveUser = 0x00200000, - Notify = 0x00400000 + Notify = 0x00400000, + Dynamic = 0x00800000, + Constant = 0x00000400 }; enum MethodFlags { AccessPrivate = 0x00, @@ -597,6 +599,9 @@ void Generator::generateProperties() if (p.notifyId != -1) flags |= Notify; + if (p.constant) + flags |= Constant; + fprintf(out, " %4d, %4d, ", strreg(p.name), strreg(p.type)); diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 797595f..66012ca 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -908,6 +908,12 @@ void Moc::parseProperty(ClassDef *def) propDef.name = lexem(); while (test(IDENTIFIER)) { QByteArray l = lexem(); + + if (l[0] == 'C' && l == "CONSTANT") { + propDef.constant = true; + continue; + } + QByteArray v, v2; if (test(LPAREN)) { v = lexemUntil(RPAREN); @@ -963,6 +969,23 @@ void Moc::parseProperty(ClassDef *def) msg += " has no READ accessor function. The property will be invalid."; warning(msg.constData()); } + if (propDef.constant && !propDef.write.isNull()) { + QByteArray msg; + msg += "Property declaration "; + msg += propDef.name; + msg += " is both WRITEable and CONSTANT. CONSTANT will be ignored."; + propDef.constant = false; + warning(msg.constData()); + } + if (propDef.constant && !propDef.notify.isNull()) { + QByteArray msg; + msg += "Property declaration "; + msg += propDef.name; + msg += " is both NOTIFYable and CONSTANT. CONSTANT will be ignored."; + propDef.constant = false; + warning(msg.constData()); + } + if(!propDef.notify.isEmpty()) def->notifyableProperties++; diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 9fa9ac2..494d53e 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -115,9 +115,10 @@ struct FunctionDef struct PropertyDef { - PropertyDef():notifyId(-1), gspec(ValueSpec){} + PropertyDef():notifyId(-1), constant(false), gspec(ValueSpec){} QByteArray name, type, read, write, reset, designable, scriptable, editable, stored, user, notify; int notifyId; + bool constant; enum Specification { ValueSpec, ReferenceSpec, PointerSpec }; Specification gspec; bool stdCppSet() const { diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp index dea0ffb..f4cff2b 100644 --- a/tests/auto/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp @@ -108,6 +108,7 @@ class tst_QMetaObject : public QObject Q_PROPERTY(int value6 READ value6 NOTIFY value6Changed) Q_PROPERTY(MyStruct value7 READ value7 WRITE setVal7 NOTIFY value7Changed) Q_PROPERTY(int value8 READ value8 NOTIFY value8Changed) + Q_PROPERTY(int value9 READ value9 CONSTANT) public: enum EnumType { EnumType1 }; @@ -137,6 +138,8 @@ public: int value8() const { return 1; } + int value9() const { return 1; } + QList value4; QVariantList value5; @@ -159,6 +162,7 @@ private slots: void customPropertyType(); void checkScope(); void propertyNotify(); + void propertyConstant(); void stdSet(); void classInfo(); @@ -785,6 +789,19 @@ void tst_QMetaObject::propertyNotify() QCOMPARE(signal.signature(), (const char *)0); } +void tst_QMetaObject::propertyConstant() +{ + const QMetaObject *mo = metaObject(); + + QMetaProperty prop = mo->property(mo->indexOfProperty("value8")); + QVERIFY(prop.isValid()); + QVERIFY(!prop.isConstant()); + + prop = mo->property(mo->indexOfProperty("value9")); + QVERIFY(prop.isValid()); + QVERIFY(prop.isConstant()); +} + class ClassInfoTestObjectA : public QObject { Q_OBJECT -- cgit v0.12 From 7ebd2024f49bdaf798f0beaaa35946dfa890f276 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 16 Jul 2009 12:35:08 +1000 Subject: Add FINAL attribute to Q_PROPERTY() This will be used by the declarative module to optimize property bindings. Reviewed-by: Roberto Raggi --- doc/src/properties.qdoc | 5 +++++ doc/src/snippets/code/doc_src_properties.qdoc | 3 ++- src/corelib/kernel/qmetaobject.cpp | 17 ++++++++++++++++- src/corelib/kernel/qmetaobject.h | 1 + src/tools/moc/generator.cpp | 5 ++++- src/tools/moc/moc.cpp | 3 +++ src/tools/moc/moc.h | 3 ++- tests/auto/qmetaobject/tst_qmetaobject.cpp | 17 +++++++++++++++++ 8 files changed, 50 insertions(+), 4 deletions(-) diff --git a/doc/src/properties.qdoc b/doc/src/properties.qdoc index cac5016..2d03e91 100644 --- a/doc/src/properties.qdoc +++ b/doc/src/properties.qdoc @@ -128,6 +128,11 @@ constant value may be different for different instances of the object. A constant property cannot have a WRTE method or a NOTIFY signal. + \o The presence of the \c FINAL attribute indicates that the property + will not be overridden by a derived class. This can be used for performance + optimizations in some cases, but is not enforced by moc. Care must be taken + never to override a \c FINAL property. + \endlist The \c READ, \c WRITE, and \c RESET functions can be inherited. diff --git a/doc/src/snippets/code/doc_src_properties.qdoc b/doc/src/snippets/code/doc_src_properties.qdoc index 64e5377..3c9109f 100644 --- a/doc/src/snippets/code/doc_src_properties.qdoc +++ b/doc/src/snippets/code/doc_src_properties.qdoc @@ -8,7 +8,8 @@ Q_PROPERTY(type name [SCRIPTABLE bool] [STORED bool] [USER bool] - [CONSTANT]) + [CONSTANT] + [FINAL]) //! [0] diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index fee2da9..3b09061 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -161,7 +161,8 @@ enum PropertyFlags { ResolveUser = 0x00200000, Notify = 0x00400000, Dynamic = 0x00800000, - Constant = 0x00000400 + Constant = 0x00000400, + Final = 0x00000800 }; enum MethodFlags { @@ -2466,6 +2467,20 @@ bool QMetaProperty::isConstant() const } /*! + Returns true if the property is final; otherwise returns false. + + A property is final if the \c{Q_PROPERTY()}'s \c FINAL attribute + is set. +*/ +bool QMetaProperty::isFinal() const +{ + if (!mobj) + return false; + int flags = mobj->d.data[handle + 2]; + return flags & Final; +} + +/*! \obsolete Returns true if the property is editable for the given \a object; diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 73b52a9..bd47582 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -189,6 +189,7 @@ public: bool isUser(const QObject *obj = 0) const; bool isDynamic() const; bool isConstant() const; + bool isFinal() const; bool isFlagType() const; bool isEnumType() const; diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index e4086e6..fbc434d 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -68,7 +68,8 @@ enum PropertyFlags { ResolveUser = 0x00200000, Notify = 0x00400000, Dynamic = 0x00800000, - Constant = 0x00000400 + Constant = 0x00000400, + Final = 0x00000800 }; enum MethodFlags { AccessPrivate = 0x00, @@ -601,6 +602,8 @@ void Generator::generateProperties() if (p.constant) flags |= Constant; + if (p.final) + flags |= Final; fprintf(out, " %4d, %4d, ", strreg(p.name), diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 66012ca..aa11d0e 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -912,6 +912,9 @@ void Moc::parseProperty(ClassDef *def) if (l[0] == 'C' && l == "CONSTANT") { propDef.constant = true; continue; + } else if(l[0] == 'F' && l == "FINAL") { + propDef.final = true; + continue; } QByteArray v, v2; diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 494d53e..767f84e 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -115,10 +115,11 @@ struct FunctionDef struct PropertyDef { - PropertyDef():notifyId(-1), constant(false), gspec(ValueSpec){} + PropertyDef():notifyId(-1), constant(false), final(false), gspec(ValueSpec){} QByteArray name, type, read, write, reset, designable, scriptable, editable, stored, user, notify; int notifyId; bool constant; + bool final; enum Specification { ValueSpec, ReferenceSpec, PointerSpec }; Specification gspec; bool stdCppSet() const { diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp index f4cff2b..ac2858c 100644 --- a/tests/auto/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp @@ -109,6 +109,7 @@ class tst_QMetaObject : public QObject Q_PROPERTY(MyStruct value7 READ value7 WRITE setVal7 NOTIFY value7Changed) Q_PROPERTY(int value8 READ value8 NOTIFY value8Changed) Q_PROPERTY(int value9 READ value9 CONSTANT) + Q_PROPERTY(int value10 READ value10 FINAL) public: enum EnumType { EnumType1 }; @@ -140,6 +141,8 @@ public: int value9() const { return 1; } + int value10() const { return 1; } + QList value4; QVariantList value5; @@ -163,6 +166,7 @@ private slots: void checkScope(); void propertyNotify(); void propertyConstant(); + void propertyFinal(); void stdSet(); void classInfo(); @@ -802,6 +806,19 @@ void tst_QMetaObject::propertyConstant() QVERIFY(prop.isConstant()); } +void tst_QMetaObject::propertyFinal() +{ + const QMetaObject *mo = metaObject(); + + QMetaProperty prop = mo->property(mo->indexOfProperty("value10")); + QVERIFY(prop.isValid()); + QVERIFY(prop.isFinal()); + + prop = mo->property(mo->indexOfProperty("value9")); + QVERIFY(prop.isValid()); + QVERIFY(!prop.isFinal()); +} + class ClassInfoTestObjectA : public QObject { Q_OBJECT -- cgit v0.12 From 87239ef6438b50b2dfa7b6526a5e5cbe7d5598d5 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 10:18:05 +1000 Subject: extend the QObjectPrivate::connectedSignals bitfield to make space for all the required NOTIFY signals we need for QML bindings. An additional internal function QMetaObject::isConnected() allows to query the bits, or you use connectedSignals[0] if you know that the signal in question has a QMetaObject::indexOfSignal() < 32. Authored-by: mae Reviewed-by: Aaron Kennedy --- src/corelib/animation/qvariantanimation.cpp | 2 +- src/corelib/kernel/qobject.cpp | 77 +++++++++++++++++++++++------ src/corelib/kernel/qobject_p.h | 2 +- src/corelib/kernel/qobjectdefs.h | 3 ++ src/gui/graphicsview/qgraphicsitem.cpp | 2 +- src/gui/graphicsview/qgraphicsscene.cpp | 8 +-- 6 files changed, 72 insertions(+), 22 deletions(-) diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 48e5ec1..fdd98c2 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -267,7 +267,7 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress) localProgress); qSwap(currentValue, ret); q->updateCurrentValue(currentValue); - if ((connectedSignals & changedSignalMask) && currentValue != ret) { + if ((connectedSignals[0] & changedSignalMask) && currentValue != ret) { //the value has changed emit q->valueChanged(currentValue); } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 6503ab0..e5cc375 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -139,7 +139,8 @@ QObjectPrivate::QObjectPrivate(int version) receiveChildEvents = true; postedEvents = 0; extraData = 0; - connectedSignals = 0; + for (uint i = 0; i < (sizeof connectedSignals / sizeof connectedSignals[0]); ++i) + connectedSignals[i] = 0; inEventHandler = false; inThreadChangeEvent = false; deleteWatch = 0; @@ -2849,10 +2850,16 @@ bool QMetaObject::connect(const QObject *sender, int signal_index, s->d_func()->addConnection(signal_index, c); - if (signal_index < 0) - sender->d_func()->connectedSignals = ~0u; - else if (signal_index < 32) - sender->d_func()->connectedSignals |= (1 << signal_index); + if (signal_index < 0) { + for (uint i = 0; i < (sizeof sender->d_func()->connectedSignals + / sizeof sender->d_func()->connectedSignals[0] ); ++i) + sender->d_func()->connectedSignals[i] = ~0u; + } else if (signal_index < (int)sizeof sender->d_func()->connectedSignals * 8) { + uint n = (signal_index / (8 * sizeof sender->d_func()->connectedSignals[0])); + sender->d_func()->connectedSignals[n] |= (1 << (signal_index - n * 8 + * sizeof sender->d_func()->connectedSignals[0])); + } + return true; } @@ -3192,11 +3199,12 @@ void QMetaObject::activate(QObject *sender, int from_signal_index, int to_signal */ void QMetaObject::activate(QObject *sender, int signal_index, void **argv) { - if (signal_index < 32 + if (signal_index < (int)sizeof(sender->d_func()->connectedSignals) * 8 && !qt_signal_spy_callback_set.signal_begin_callback && !qt_signal_spy_callback_set.signal_end_callback) { - uint signal_mask = 1 << signal_index; - if ((sender->d_func()->connectedSignals & signal_mask) == 0) + uint n = (signal_index / (8 * sizeof sender->d_func()->connectedSignals[0])); + uint m = 1 << (signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]); + if ((sender->d_func()->connectedSignals[n] & m) == 0) // nothing connected to these signals, and no spy return; } @@ -3209,11 +3217,12 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign void **argv) { int signal_index = m->methodOffset() + local_signal_index; - if (signal_index < 32 + if (signal_index < (int)sizeof(sender->d_func()->connectedSignals) * 8 && !qt_signal_spy_callback_set.signal_begin_callback && !qt_signal_spy_callback_set.signal_end_callback) { - uint signal_mask = 1 << signal_index; - if ((sender->d_func()->connectedSignals & signal_mask) == 0) + uint n = (signal_index / (8 * sizeof sender->d_func()->connectedSignals[0])); + uint m = 1 << (signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]); + if ((sender->d_func()->connectedSignals[n] & m) == 0) // nothing connected to these signals, and no spy return; } @@ -3225,21 +3234,59 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign void QMetaObject::activate(QObject *sender, const QMetaObject *m, int from_local_signal_index, int to_local_signal_index, void **argv) { + Q_ASSERT(from_local_signal_index <= to_local_signal_index); int offset = m->methodOffset(); int from_signal_index = offset + from_local_signal_index; int to_signal_index = offset + to_local_signal_index; - if (to_signal_index < 32 + + if (to_signal_index < (int)sizeof(sender->d_func()->connectedSignals) * 8 && !qt_signal_spy_callback_set.signal_begin_callback && !qt_signal_spy_callback_set.signal_end_callback) { - uint signal_mask = (1 << (to_signal_index + 1)) - 1; - signal_mask ^= (1 << from_signal_index) - 1; - if ((sender->d_func()->connectedSignals & signal_mask) == 0) + + uint n = (from_signal_index / (8 * sizeof sender->d_func()->connectedSignals[0])); + uint m = 1 << (from_signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]); + uint nt = (to_signal_index / (8 * sizeof sender->d_func()->connectedSignals[0])); + uint mt = 1 << (to_signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]); + bool connected = false; + quint32 *connectedSignals = sender->d_func()->connectedSignals; + for (uint i = 0; !connected && i < (sizeof sender->d_func()->connectedSignals + / sizeof sender->d_func()->connectedSignals[0]); ++i) { + uint mask = 0; + if (i > n) + mask = ~0u; + else if (i == n) + mask = ~(m -1); + if (i > nt) + mask = 0; + else if (i == nt) + mask &= (mt << 1) - 1; + connected = connectedSignals[i] & mask; + } + if (!connected) // nothing connected to these signals, and no spy return; } activate(sender, from_signal_index, to_signal_index, argv); } +/*! \internal + + Returns true if the signal with index \a signal_index from object \a sender is connected. + Signals with indices above a certain range are always considered connected (see connectedSignals + in QObjectPrivate). If a signal spy is installed, all signals are considered connected. +*/ +bool QMetaObject::isConnected(QObject *sender, int signal_index) { + if (signal_index < (int)sizeof(sender->d_func()->connectedSignals) * 8 + && !qt_signal_spy_callback_set.signal_begin_callback + && !qt_signal_spy_callback_set.signal_end_callback) { + uint n = (signal_index / (8 * sizeof sender->d_func()->connectedSignals[0])); + uint m = 1 << (signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]); + if ((sender->d_func()->connectedSignals[n] & m) == 0) + // nothing connected to these signals, and no spy + return false; + } + return true; +} /***************************************************************************** Properties diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 07c397f..6a20040 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -140,7 +140,7 @@ public: QList propertyValues; }; ExtraData *extraData; - mutable quint32 connectedSignals; + mutable quint32 connectedSignals[2]; QString objectName; diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 9187765..300e9fa 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -334,6 +334,9 @@ struct Q_CORE_EXPORT QMetaObject static void activate(QObject *sender, int from_signal_index, int to_signal_index, void **argv); static void activate(QObject *sender, const QMetaObject *, int local_signal_index, void **argv); static void activate(QObject *sender, const QMetaObject *, int from_local_signal_index, int to_local_signal_index, void **argv); + + static bool isConnected(QObject *sender, int signal_index); + // internal guarded pointers static void addGuard(QObject **ptr); static void removeGuard(QObject **ptr); diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 5aae93e..3884af9 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -6462,7 +6462,7 @@ void QGraphicsItem::prepareGeometryChange() // if someone is connected to the changed signal or the scene has no views. // Note that this has to be done *after* markDirty to ensure that // _q_processDirtyItems is called before _q_emitUpdated. - if ((scenePrivate->connectedSignals & scenePrivate->changedSignalMask) + if ((scenePrivate->connectedSignals[0] & scenePrivate->changedSignalMask) || scenePrivate->views.isEmpty()) { if (d_ptr->hasTranslateOnlySceneTransform()) { d_ptr->scene->update(boundingRect().translated(d_ptr->sceneTransform.dx(), diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a846cf6..da4a347 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -344,7 +344,7 @@ void QGraphicsScenePrivate::_q_emitUpdated() // the optimization that items send updates directly to the views, but it // needs to happen in order to keep compatibility with the behavior from // Qt 4.4 and backward. - if (connectedSignals & changedSignalMask) { + if (connectedSignals[0] & changedSignalMask) { for (int i = 0; i < views.size(); ++i) { QGraphicsView *view = views.at(i); if (!view->d_func()->connectedToScene) { @@ -2899,7 +2899,7 @@ void QGraphicsScene::update(const QRectF &rect) // Check if anyone's connected; if not, we can send updates directly to // the views. Otherwise or if there are no views, use old behavior. - bool directUpdates = !(d->connectedSignals & d->changedSignalMask) && !d->views.isEmpty(); + bool directUpdates = !(d->connectedSignals[0] & d->changedSignalMask) && !d->views.isEmpty(); if (rect.isNull()) { d->updateAll = true; d->updatedRects.clear(); @@ -4477,7 +4477,7 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b if (removingItemFromScene) { // Note that this function can be called from the item's destructor, so // do NOT call any virtual functions on it within this block. - if ((connectedSignals & changedSignalMask) || views.isEmpty()) { + if ((connectedSignals[0] & changedSignalMask) || views.isEmpty()) { // This block of code is kept for compatibility. Since 4.5, by default // QGraphicsView does not connect the signal and we use the below // method of delivering updates. @@ -4623,7 +4623,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool // Process item. if (item->d_ptr->dirty || item->d_ptr->paintedViewBoundingRectsNeedRepaint) { - const bool useCompatUpdate = views.isEmpty() || (connectedSignals & changedSignalMask); + const bool useCompatUpdate = views.isEmpty() || (connectedSignals[0] & changedSignalMask); const QRectF itemBoundingRect = adjustedItemBoundingRect(item); if (useCompatUpdate && !itemIsUntransformable && qFuzzyIsNull(item->boundingRegionGranularity())) { -- cgit v0.12 From 46ca473d569b92cdfc567c2096b1c4af3ba68f80 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 10:52:40 +1000 Subject: Allow retrieval of interface IId from class type. This method is necessary for QML to support Qt interfaces, but probably shouldn't be used otherwise. Reviewed-by: Roberto Raggi --- src/corelib/kernel/qobject.h | 10 ++++++++++ tests/auto/qobject/tst_qobject.cpp | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 1fb216b..4715626 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -379,6 +379,9 @@ inline QList qFindChildren(const QObject *o, const QRegExp &re) #endif // Q_MOC_RUN +template inline const char * qobject_interface_iid() +{ return 0; } + template inline T qobject_cast_helper(QObject *object, T) { return static_cast(((T)0)->staticMetaObject.cast(object)); } @@ -395,6 +398,8 @@ inline T qobject_cast(const QObject *object) #ifndef Q_MOC_RUN # define Q_DECLARE_INTERFACE(IFace, IId) \ + template <> inline const char *qobject_interface_iid() \ + { return IId; } \ template <> inline IFace *qobject_cast_helper(QObject *object, IFace *) \ { return (IFace *)(object ? object->qt_metacast(IId) : 0); } \ template <> inline IFace *qobject_cast_helper(const QObject *object, IFace *) \ @@ -458,8 +463,13 @@ inline T qobject_cast(const QObject *object) } +template inline const char * qobject_interface_iid() +{ return 0; } + #ifndef Q_MOC_RUN # define Q_DECLARE_INTERFACE(IFace, IId) \ + template <> inline const char *qobject_interface_iid() \ + { return IId; } \ template <> inline IFace *qobject_cast(QObject *object) \ { return reinterpret_cast((object ? object->qt_metacast(IId) : 0)); } \ template <> inline IFace *qobject_cast(const QObject *object) \ diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 4f25af6..3df83d7 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -118,6 +118,7 @@ private slots: void connectToSender(); void qobjectConstCast(); void uniqConnection(); + void interfaceIid(); protected: }; @@ -2887,5 +2888,15 @@ void tst_QObject::uniqConnection() delete r2; } +void tst_QObject::interfaceIid() +{ + QCOMPARE(QByteArray(qobject_interface_iid()), + QByteArray(Bleh_iid)); + QCOMPARE(QByteArray(qobject_interface_iid()), + QByteArray("com.qtest.foobar")); + QCOMPARE(QByteArray(qobject_interface_iid()), + QByteArray()); +} + QTEST_MAIN(tst_QObject) #include "tst_qobject.moc" -- cgit v0.12 From 25d7123a0fce87673eb64afe405e310b08f721b9 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 11:04:03 +1000 Subject: Add non-threadsafe QGuard class Cherry pick of 4031c0f0613090d70cd1fcacfc5b8316b12eb14e Reviewed-by: Andreas --- src/corelib/kernel/kernel.pri | 6 +- src/corelib/kernel/qguard.cpp | 26 +++++++ src/corelib/kernel/qguard_p.h | 151 +++++++++++++++++++++++++++++++++++++++++ src/corelib/kernel/qobject.cpp | 18 ++++- src/corelib/kernel/qobject_p.h | 2 + 5 files changed, 200 insertions(+), 3 deletions(-) create mode 100644 src/corelib/kernel/qguard.cpp create mode 100644 src/corelib/kernel/qguard_p.h diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index 7177293..d30f294 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -32,7 +32,8 @@ HEADERS += \ kernel/qsharedmemory_p.h \ kernel/qsystemsemaphore.h \ kernel/qsystemsemaphore_p.h \ - kernel/qfunctions_p.h + kernel/qfunctions_p.h \ + kernel/qguard_p.h SOURCES += \ kernel/qabstracteventdispatcher.cpp \ @@ -54,7 +55,8 @@ SOURCES += \ kernel/qcoreglobaldata.cpp \ kernel/qsharedmemory.cpp \ kernel/qsystemsemaphore.cpp \ - kernel/qpointer.cpp + kernel/qpointer.cpp \ + kernel/qguard.cpp win32 { SOURCES += \ diff --git a/src/corelib/kernel/qguard.cpp b/src/corelib/kernel/qguard.cpp new file mode 100644 index 0000000..c61be00 --- /dev/null +++ b/src/corelib/kernel/qguard.cpp @@ -0,0 +1,26 @@ +#include "qguard_p.h" +#include + +void q_guard_addGuard(QGuard *g) +{ + QObjectPrivate *p = QObjectPrivate::get(g->o); + if (p->wasDeleted) { + qWarning("QGuard: cannot add guard to deleted object"); + g->o = 0; + return; + } + + g->next = p->objectGuards; + p->objectGuards = g; + g->prev = &p->objectGuards; + if (g->next) + g->next->prev = &g->next; +} + +void q_guard_removeGuard(QGuard *g) +{ + *g->prev = g->next; + g->next = 0; + g->prev = 0; +} + diff --git a/src/corelib/kernel/qguard_p.h b/src/corelib/kernel/qguard_p.h new file mode 100644 index 0000000..7236ed6 --- /dev/null +++ b/src/corelib/kernel/qguard_p.h @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGUARD_P_H +#define QGUARD_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#include "QtCore/qglobal.h" + +QT_BEGIN_NAMESPACE + +class QObject; +template +class QGuard +{ + QObject *o; + QGuard *next; + QGuard **prev; + friend void q_guard_addGuard(QGuard *); + friend void q_guard_removeGuard(QGuard *); + friend class QObjectPrivate; +public: + inline QGuard(); + inline QGuard(T *); + inline QGuard(const QGuard &); + inline virtual ~QGuard(); + + inline QGuard &operator=(const QGuard &o); + inline QGuard &operator=(T *); + + inline bool isNull() const + { return !o; } + + inline T* operator->() const + { return static_cast(const_cast(o)); } + inline T& operator*() const + { return *static_cast(const_cast(o)); } + inline operator T*() const + { return static_cast(const_cast(o)); } + inline T* data() const + { return static_cast(const_cast(o)); } + +protected: + virtual void objectDestroyed(T *) {} +}; + +void Q_CORE_EXPORT q_guard_addGuard(QGuard *); +void Q_CORE_EXPORT q_guard_removeGuard(QGuard *); + +template +QGuard::QGuard() +: o(0), next(0), prev(0) +{ +} + +template +QGuard::QGuard(T *g) +: o(g), next(0), prev(0) +{ + if (o) q_guard_addGuard(reinterpret_cast *>(this)); +} + +template +QGuard::QGuard(const QGuard &g) +: o(g.o), next(0), prev(0) +{ + if (o) q_guard_addGuard(reinterpret_cast *>(this)); +} + +template +QGuard::~QGuard() +{ + if (prev) q_guard_removeGuard(reinterpret_cast *>(this)); + o = 0; +} + +template +QGuard &QGuard::operator=(const QGuard &g) +{ + if (g.o != o) { + if (prev) + q_guard_removeGuard(reinterpret_cast *>(this)); + o = g.o; + if (o) q_guard_addGuard(reinterpret_cast *>(this)); + } + return *this; +} + +template +inline QGuard &QGuard::operator=(T *g) +{ + if (g != o) { + if (prev) + q_guard_removeGuard(reinterpret_cast *>(this)); + o = g; + if (o) q_guard_addGuard(reinterpret_cast *>(this)); + } + return *this; +} + +QT_END_NAMESPACE + +#endif // QGUARD_P_H diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index e5cc375..a1702d9 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -144,6 +144,7 @@ QObjectPrivate::QObjectPrivate(int version) inEventHandler = false; inThreadChangeEvent = false; deleteWatch = 0; + objectGuards = 0; hasGuards = false; } @@ -426,7 +427,22 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o) */ void QObjectPrivate::clearGuards(QObject *object) { - if (!QObjectPrivate::get(object)->hasGuards) + QObjectPrivate *priv = QObjectPrivate::get(object); + QGuard *guard = priv->objectGuards; + while (guard) { + guard->o = 0; + guard = guard->next; + } + while (priv->objectGuards) { + guard = priv->objectGuards; + guard->prev = 0; + if (guard->next) guard->next->prev = &priv->objectGuards; + priv->objectGuards = guard->next; + guard->next = 0; + guard->objectDestroyed(object); + } + + if (!priv->hasGuards) return; GuardHash *hash = guardHash(); if (hash) { diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 6a20040..335768c 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -60,6 +60,7 @@ #include "QtCore/qvector.h" #include "QtCore/qreadwritelock.h" #include "QtCore/qvariant.h" +#include "qguard_p.h" QT_BEGIN_NAMESPACE @@ -174,6 +175,7 @@ public: static void resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int deleteWatch); int *deleteWatch; + QGuard *objectGuards; static QObjectPrivate *get(QObject *o) { return o->d_func(); -- cgit v0.12 From 4238094aad5b3c9b5980bfa6c1ae83e02dc5b9bf Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 11:06:24 +1000 Subject: removing Q_CORE_EXPORT for q_guard_addGuard() and q_guard_removeGuard() I made the functions inline instead and moved them to qobject_p.h Authored-by: Thomas Hartmann Reviewed-by: Aaron Kennedy (cherry picked from commit fd27c5ac9670b56ccd60e8d8f6791237358f3633) --- src/corelib/kernel/kernel.pri | 3 +-- src/corelib/kernel/qguard.cpp | 26 -------------------------- src/corelib/kernel/qguard_p.h | 3 +-- src/corelib/kernel/qobject_p.h | 24 ++++++++++++++++++++++++ 4 files changed, 26 insertions(+), 30 deletions(-) delete mode 100644 src/corelib/kernel/qguard.cpp diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index d30f294..3493784 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -55,8 +55,7 @@ SOURCES += \ kernel/qcoreglobaldata.cpp \ kernel/qsharedmemory.cpp \ kernel/qsystemsemaphore.cpp \ - kernel/qpointer.cpp \ - kernel/qguard.cpp + kernel/qpointer.cpp win32 { SOURCES += \ diff --git a/src/corelib/kernel/qguard.cpp b/src/corelib/kernel/qguard.cpp deleted file mode 100644 index c61be00..0000000 --- a/src/corelib/kernel/qguard.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "qguard_p.h" -#include - -void q_guard_addGuard(QGuard *g) -{ - QObjectPrivate *p = QObjectPrivate::get(g->o); - if (p->wasDeleted) { - qWarning("QGuard: cannot add guard to deleted object"); - g->o = 0; - return; - } - - g->next = p->objectGuards; - p->objectGuards = g; - g->prev = &p->objectGuards; - if (g->next) - g->next->prev = &g->next; -} - -void q_guard_removeGuard(QGuard *g) -{ - *g->prev = g->next; - g->next = 0; - g->prev = 0; -} - diff --git a/src/corelib/kernel/qguard_p.h b/src/corelib/kernel/qguard_p.h index 7236ed6..cbc9cca 100644 --- a/src/corelib/kernel/qguard_p.h +++ b/src/corelib/kernel/qguard_p.h @@ -54,6 +54,7 @@ // #include "QtCore/qglobal.h" +#include "private/qobject_p.h" QT_BEGIN_NAMESPACE @@ -92,8 +93,6 @@ protected: virtual void objectDestroyed(T *) {} }; -void Q_CORE_EXPORT q_guard_addGuard(QGuard *); -void Q_CORE_EXPORT q_guard_removeGuard(QGuard *); template QGuard::QGuard() diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 335768c..7e3e97d 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -182,6 +182,30 @@ public: } }; +inline void q_guard_addGuard(QGuard *g) +{ + QObjectPrivate *p = QObjectPrivate::get(g->o); + if (p->wasDeleted) { + qWarning("QGuard: cannot add guard to deleted object"); + g->o = 0; + return; + } + + g->next = p->objectGuards; + p->objectGuards = g; + g->prev = &p->objectGuards; + if (g->next) + g->next->prev = &g->next; +} + +inline void q_guard_removeGuard(QGuard *g) +{ + if (g->next) g->next->prev = g->prev; + *g->prev = g->next; + g->next = 0; + g->prev = 0; +} + Q_DECLARE_TYPEINFO(QObjectPrivate::Connection, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QObjectPrivate::Sender, Q_MOVABLE_TYPE); -- cgit v0.12 From 1237ea8bac2f5fd055553b45eae296fd44abd3e8 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Mon, 27 Jul 2009 16:35:38 +0200 Subject: Fixed missing forward declarations, which made gcc fail to compile anything that included qobject.h Reviewed-by: Thomas Hartmann (cherry picked from commit cc287101308fa606eb4de2597b5309c8099654c3) --- src/corelib/kernel/qguard_p.h | 9 ++++++++- src/corelib/kernel/qobject_p.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qguard_p.h b/src/corelib/kernel/qguard_p.h index cbc9cca..6af01ac 100644 --- a/src/corelib/kernel/qguard_p.h +++ b/src/corelib/kernel/qguard_p.h @@ -54,7 +54,6 @@ // #include "QtCore/qglobal.h" -#include "private/qobject_p.h" QT_BEGIN_NAMESPACE @@ -93,6 +92,14 @@ protected: virtual void objectDestroyed(T *) {} }; +QT_END_NAMESPACE + +#include "private/qobject_p.h" + +QT_BEGIN_NAMESPACE + +inline void q_guard_addGuard(QGuard *); +inline void q_guard_removeGuard(QGuard *); template QGuard::QGuard() diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 7e3e97d..54c98ad 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -60,7 +60,7 @@ #include "QtCore/qvector.h" #include "QtCore/qreadwritelock.h" #include "QtCore/qvariant.h" -#include "qguard_p.h" +#include "private/qguard_p.h" QT_BEGIN_NAMESPACE -- cgit v0.12 From 13e3bbf2c46077f2b970bc6c0bc9850112b81cb7 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 11:52:53 +1000 Subject: Autotest for QGuard Reviewed-by: Andreas --- tests/auto/qguard/qguard.pro | 2 + tests/auto/qguard/tst_qguard.cpp | 350 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 352 insertions(+) create mode 100644 tests/auto/qguard/qguard.pro create mode 100644 tests/auto/qguard/tst_qguard.cpp diff --git a/tests/auto/qguard/qguard.pro b/tests/auto/qguard/qguard.pro new file mode 100644 index 0000000..f249dde --- /dev/null +++ b/tests/auto/qguard/qguard.pro @@ -0,0 +1,2 @@ +load(qttest_p4) +SOURCES += tst_qguard.cpp diff --git a/tests/auto/qguard/tst_qguard.cpp b/tests/auto/qguard/tst_qguard.cpp new file mode 100644 index 0000000..96d1b60 --- /dev/null +++ b/tests/auto/qguard/tst_qguard.cpp @@ -0,0 +1,350 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// NOTE: This is identical to the QPointer autotest + +#include + +#include +#include +#include +#include + +class tst_QGuard : public QObject +{ + Q_OBJECT +public: + tst_QGuard(); + ~tst_QGuard(); + + inline tst_QGuard *me() const + { return const_cast(this); } + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); +private slots: + void constructors(); + void destructor(); + void assignment_operators(); + void equality_operators(); + void isNull(); + void dereference_operators(); + void disconnect(); + void castDuringDestruction(); + void data() const; + void dataSignature() const; +}; + +tst_QGuard::tst_QGuard() +{ } + +tst_QGuard::~tst_QGuard() +{ } + +void tst_QGuard::initTestCase() +{ } + +void tst_QGuard::cleanupTestCase() +{ } + +void tst_QGuard::init() +{ } + +void tst_QGuard::cleanup() +{ } + +void tst_QGuard::constructors() +{ + QGuard p1; + QGuard p2(this); + QGuard p3(p2); + QCOMPARE(p1, QGuard(0)); + QCOMPARE(p2, QGuard(this)); + QCOMPARE(p3, QGuard(this)); +} + +void tst_QGuard::destructor() +{ + QObject *object = new QObject; + QGuard p = object; + QCOMPARE(p, QGuard(object)); + delete object; + QCOMPARE(p, QGuard(0)); +} + +void tst_QGuard::assignment_operators() +{ + QGuard p1; + QGuard p2; + + p1 = this; + p2 = p1; + + QCOMPARE(p1, QGuard(this)); + QCOMPARE(p2, QGuard(this)); + QCOMPARE(p1, QGuard(p2)); + + p1 = 0; + p2 = p1; + QCOMPARE(p1, QGuard(0)); + QCOMPARE(p2, QGuard(0)); + QCOMPARE(p1, QGuard(p2)); + + QObject *object = new QObject; + + p1 = object; + p2 = p1; + QCOMPARE(p1, QGuard(object)); + QCOMPARE(p2, QGuard(object)); + QCOMPARE(p1, QGuard(p2)); + + delete object; + QCOMPARE(p1, QGuard(0)); + QCOMPARE(p2, QGuard(0)); + QCOMPARE(p1, QGuard(p2)); +} + +void tst_QGuard::equality_operators() +{ + QGuard p1; + QGuard p2; + + QVERIFY(p1 == p2); + + QObject *object = 0; + QWidget *widget = 0; + + p1 = object; + QVERIFY(p1 == p2); + QVERIFY(p1 == object); + p2 = object; + QVERIFY(p2 == p1); + QVERIFY(p2 == object); + + p1 = this; + QVERIFY(p1 != p2); + p2 = p1; + QVERIFY(p1 == p2); + + // compare to zero + p1 = 0; + QVERIFY(p1 == 0); + QVERIFY(0 == p1); + QVERIFY(p2 != 0); + QVERIFY(0 != p2); + QVERIFY(p1 == object); + QVERIFY(object == p1); + QVERIFY(p2 != object); + QVERIFY(object != p2); + QVERIFY(p1 == widget); + QVERIFY(widget == p1); + QVERIFY(p2 != widget); + QVERIFY(widget != p2); +} + +void tst_QGuard::isNull() +{ + QGuard p1; + QVERIFY(p1.isNull()); + p1 = this; + QVERIFY(!p1.isNull()); + p1 = 0; + QVERIFY(p1.isNull()); +} + +void tst_QGuard::dereference_operators() +{ + QGuard p1 = this; + + QObject *object = p1->me(); + QVERIFY(object == this); + + QObject &ref = *p1; + QVERIFY(&ref == this); + + object = static_cast(p1); + QVERIFY(object == this); +} + +void tst_QGuard::disconnect() +{ + QGuard p1 = new QObject; + QVERIFY(!p1.isNull()); + p1->disconnect(); + QVERIFY(!p1.isNull()); + delete static_cast(p1); + QVERIFY(p1.isNull()); +} + +class ChildObject : public QObject +{ + QGuard guardedPointer; + +public: + ChildObject(QObject *parent) + : QObject(parent), guardedPointer(parent) + { } + ~ChildObject(); +}; + +ChildObject::~ChildObject() +{ + QCOMPARE(static_cast(guardedPointer), static_cast(0)); + QCOMPARE(qobject_cast(guardedPointer), static_cast(0)); +} + +class ChildWidget : public QWidget +{ + QGuard guardedPointer; + +public: + ChildWidget(QWidget *parent) + : QWidget(parent), guardedPointer(parent) + { } + ~ChildWidget(); +}; + +ChildWidget::~ChildWidget() +{ + QCOMPARE(static_cast(guardedPointer), static_cast(0)); + QCOMPARE(qobject_cast(guardedPointer), static_cast(0)); +} + +class DerivedChild; + +class DerivedParent : public QObject +{ + Q_OBJECT + + DerivedChild *derivedChild; + +public: + DerivedParent(); + ~DerivedParent(); +}; + +class DerivedChild : public QObject +{ + Q_OBJECT + + DerivedParent *parentPointer; + QGuard guardedParentPointer; + +public: + DerivedChild(DerivedParent *parent) + : QObject(parent), parentPointer(parent), guardedParentPointer(parent) + { } + ~DerivedChild(); +}; + +DerivedParent::DerivedParent() + : QObject() +{ + derivedChild = new DerivedChild(this); +} + +DerivedParent::~DerivedParent() +{ + delete derivedChild; +} + +DerivedChild::~DerivedChild() +{ + QCOMPARE(static_cast(guardedParentPointer), parentPointer); + QCOMPARE(qobject_cast(guardedParentPointer), parentPointer); +} + +void tst_QGuard::castDuringDestruction() +{ + { + QObject *parentObject = new QObject(); + (void) new ChildObject(parentObject); + delete parentObject; + } + + { + QWidget *parentWidget = new QWidget(); + (void) new ChildWidget(parentWidget); + delete parentWidget; + } + + { + delete new DerivedParent(); + } +} + +void tst_QGuard::data() const +{ + /* Check value of a default constructed object. */ + { + QGuard p; + QCOMPARE(p.data(), static_cast(0)); + } + + /* Check value of a default constructed object. */ + { + QObject *const object = new QObject(); + QGuard p(object); + QCOMPARE(p.data(), object); + } +} + +void tst_QGuard::dataSignature() const +{ + /* data() should be const. */ + { + const QGuard p; + p.data(); + } + + /* The return type should be T. */ + { + const QGuard p; + /* If the types differs, the QCOMPARE will fail to instansiate. */ + QCOMPARE(p.data(), static_cast(0)); + } +} + +QTEST_MAIN(tst_QGuard) +#include "tst_qguard.moc" -- cgit v0.12 From c257996dfdc87b9a9682d35419792730e477d3ac Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 12:05:11 +1000 Subject: Make setRoleNames() protected and improve docs. (cherry picked from commit 15be8a6b259a5cb4f528b1c765bfcddfc9edd044) Authored-by: Martin Jones Reviewed-by: mbm --- src/corelib/kernel/qabstractitemmodel.cpp | 42 +++++++++++++++++++++++++++++++ src/corelib/kernel/qabstractitemmodel.h | 4 +++ src/corelib/kernel/qabstractitemmodel_p.h | 5 +++- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 3d9263e..cd17076 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -467,6 +467,21 @@ QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel() return qEmptyModel(); } +const QHash &QAbstractItemModelPrivate::defaultRoleNames() +{ + static QHash roleNames; + if (roleNames.isEmpty()) { + roleNames[Qt::DisplayRole] = "display"; + roleNames[Qt::DecorationRole] = "decoration"; + roleNames[Qt::EditRole] = "edit"; + roleNames[Qt::ToolTipRole] = "toolTip"; + roleNames[Qt::StatusTipRole] = "statusTip"; + roleNames[Qt::WhatsThisRole] = "whatsThis"; + } + + return roleNames; +} + /*! \internal return true if \a value contains a numerical type @@ -1863,6 +1878,33 @@ QSize QAbstractItemModel::span(const QModelIndex &) const } /*! + Sets the model's role names to \a roleNames. + + This function is provided to allow mapping of role identifiers to + role property names in Declarative UI. This function must be called + before the model is used. Modifying the role names after the model + has been set may result in undefined behaviour. + + \sa roleNames() +*/ +void QAbstractItemModel::setRoleNames(const QHash &roleNames) +{ + Q_D(QAbstractItemModel); + d->roleNames = roleNames; +} + +/*! + Returns the model's role names. + + \sa setRoleNames +*/ +const QHash &QAbstractItemModel::roleNames() const +{ + Q_D(const QAbstractItemModel); + return d->roleNames; +} + +/*! Called to let the model know that it should submit whatever it has cached to the permanent storage. Typically used for row editing. diff --git a/src/corelib/kernel/qabstractitemmodel.h b/src/corelib/kernel/qabstractitemmodel.h index dc7d7bd..a6bbff4 100644 --- a/src/corelib/kernel/qabstractitemmodel.h +++ b/src/corelib/kernel/qabstractitemmodel.h @@ -220,6 +220,8 @@ public: Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const; virtual QSize span(const QModelIndex &index) const; + const QHash &roleNames() const; + #ifdef Q_NO_USING_KEYWORD inline QObject *parent() const { return QObject::parent(); } #else @@ -282,6 +284,8 @@ protected: void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to); QModelIndexList persistentIndexList() const; + void setRoleNames(const QHash &roleNames); + private: Q_DECLARE_PRIVATE(QAbstractItemModel) Q_DISABLE_COPY(QAbstractItemModel) diff --git a/src/corelib/kernel/qabstractitemmodel_p.h b/src/corelib/kernel/qabstractitemmodel_p.h index c047f95..6a29723 100644 --- a/src/corelib/kernel/qabstractitemmodel_p.h +++ b/src/corelib/kernel/qabstractitemmodel_p.h @@ -78,7 +78,7 @@ class Q_CORE_EXPORT QAbstractItemModelPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QAbstractItemModel) public: - QAbstractItemModelPrivate() : QObjectPrivate(), supportedDragActions(-1) {} + QAbstractItemModelPrivate() : QObjectPrivate(), supportedDragActions(-1), roleNames(defaultRoleNames()) {} void removePersistentIndexData(QPersistentModelIndexData *data); void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last); void rowsInserted(const QModelIndex &parent, int first, int last); @@ -144,6 +144,9 @@ public: } persistent; Qt::DropActions supportedDragActions; + + QHash roleNames; + static const QHash &defaultRoleNames(); }; QT_END_NAMESPACE -- cgit v0.12 From b859422e23a31af1cda5011883d8a25c934cea65 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 15:52:29 +1000 Subject: Make QAbstractItemModel default rolenames reentrant Reviewed-by: Martin Jones Reviewed-by: mbm --- src/corelib/kernel/qabstractitemmodel.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index cd17076..01440e4 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -467,19 +467,25 @@ QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel() return qEmptyModel(); } +namespace { + struct DefaultRoleNames : public QHash + { + DefaultRoleNames() { + (*this)[Qt::DisplayRole] = "display"; + (*this)[Qt::DecorationRole] = "decoration"; + (*this)[Qt::EditRole] = "edit"; + (*this)[Qt::ToolTipRole] = "toolTip"; + (*this)[Qt::StatusTipRole] = "statusTip"; + (*this)[Qt::WhatsThisRole] = "whatsThis"; + } + }; +} + +Q_GLOBAL_STATIC(DefaultRoleNames, q_defaultRoleNames); + const QHash &QAbstractItemModelPrivate::defaultRoleNames() { - static QHash roleNames; - if (roleNames.isEmpty()) { - roleNames[Qt::DisplayRole] = "display"; - roleNames[Qt::DecorationRole] = "decoration"; - roleNames[Qt::EditRole] = "edit"; - roleNames[Qt::ToolTipRole] = "toolTip"; - roleNames[Qt::StatusTipRole] = "statusTip"; - roleNames[Qt::WhatsThisRole] = "whatsThis"; - } - - return roleNames; + return *q_defaultRoleNames(); } /*! -- cgit v0.12 From 025dcc2bb9651708d456a5b1e5d2888e67d67bf4 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 16:04:47 +1000 Subject: Add a declarative data ptr to QObjectPrivate This data ptr does not increase the size of the QObject, as we take advantage of space otherwise only used during destruction. Reviewed-by: Andreas --- src/corelib/kernel/qobject.cpp | 8 ++++++++ src/corelib/kernel/qobject_p.h | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index a1702d9..b0ddd81 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -842,6 +842,14 @@ QObject::~QObject() d->eventFilters.clear(); + // As declarativeData is in a union with currentChildBeingDeleted, this must + // be done (and declarativeData set back to 0) before deleting children. + if(d->declarativeData) { + QDeclarativeData *dd = d->declarativeData; + d->declarativeData = 0; + dd->destroyed(this); + } + if (!d->children.isEmpty()) d->deleteChildren(); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 54c98ad..19df642 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -86,6 +86,13 @@ inline QObjectData::~QObjectData() {} enum { QObjectPrivateVersion = QT_VERSION }; +class QDeclarativeData +{ +public: + virtual ~QDeclarativeData() {} + virtual void destroyed(QObject *) {} +}; + class Q_CORE_EXPORT QObjectPrivate : public QObjectData { Q_DECLARE_PUBLIC(QObject) @@ -118,7 +125,10 @@ public: // object currently activating the object Sender *currentSender; - QObject *currentChildBeingDeleted; + union { + QObject *currentChildBeingDeleted; + QDeclarativeData *declarativeData; + }; bool isSender(const QObject *receiver, const char *signal) const; QObjectList receiverList(const char *signal) const; -- cgit v0.12 From 45c11a97a32170d0c6ab9265a102cc8d94fa63ee Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 16 Jun 2009 15:43:46 +0200 Subject: Fixing qml for QWidget support (crash) QWidget deletes its children in its own constructor so we have to cleanup before explicitly Reviewed-by: Aaron Kennedy (cherry picked from commit 59629ac728f2fdbc3047554d715e2f908b1844c4) --- src/gui/kernel/qwidget.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index bca607c..e24b7cb 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1375,6 +1375,12 @@ QWidget::~QWidget() // set all QPointers for this object to zero QObjectPrivate::clearGuards(this); + if(d->declarativeData) { + QDeclarativeData *dd = d->declarativeData; + d->declarativeData = 0; + dd->destroyed(this); + } + if (!d->children.isEmpty()) d->deleteChildren(); -- cgit v0.12 From b30a25280556599177b217f0e8ed3fbe4b11705d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 16:27:28 +1000 Subject: Add index methods to QMetaProperty and QMetaMethod Authored-by: Kent Hansen Reviewed-by: Aaron Kennedy --- src/corelib/kernel/qmetaobject.cpp | 20 ++++++++++++++++++++ src/corelib/kernel/qmetaobject.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 3b09061..611eff3 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1329,6 +1329,16 @@ int QMetaMethod::attributes() const } /*! + Returns this method's index. +*/ +int QMetaMethod::methodIndex() const +{ + if (!mobj) + return -1; + return ((handle - priv(mobj->d.data)->methodData) / 5) + mobj->methodOffset(); +} + +/*! Returns the access specification of this method (private, protected, or public). @@ -2043,6 +2053,16 @@ int QMetaProperty::userType() const } /*! + Returns this property's index. +*/ +int QMetaProperty::propertyIndex() const +{ + if (!mobj) + return -1; + return idx + mobj->propertyOffset(); +} + +/*! Returns true if the property's type is an enumeration value that is used as a flag; otherwise returns false. diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index bd47582..9f36106 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -69,6 +69,7 @@ public: MethodType methodType() const; enum Attributes { Compatibility = 0x1, Cloned = 0x2, Scriptable = 0x4 }; int attributes() const; + int methodIndex() const; inline const QMetaObject *enclosingMetaObject() const { return mobj; } @@ -178,6 +179,7 @@ public: const char *typeName() const; QVariant::Type type() const; int userType() const; + int propertyIndex() const; bool isReadable() const; bool isWritable() const; -- cgit v0.12 From f858dd8083e59eb918058694956cd3546fb303b2 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 16:44:02 +1000 Subject: Dynamic meta object support This is an internal API used by declarative. Authored-by: mae Reviewed-by: Aaron Kennedy --- src/corelib/kernel/qmetaobject.cpp | 55 +++++++++++++++++++++++++++----------- src/corelib/kernel/qobject.cpp | 9 ++++--- src/corelib/kernel/qobject.h | 1 + src/corelib/kernel/qobject_p.h | 8 ++++++ src/corelib/kernel/qobjectdefs.h | 2 ++ src/tools/moc/generator.cpp | 9 ++++--- 6 files changed, 62 insertions(+), 22 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 611eff3..fc17e00 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -182,6 +182,10 @@ enum MethodFlags { MethodScriptable = 0x40 }; +enum MetaObjectFlags { + DynamicMetaObject = 0x01 +}; + struct QMetaObjectPrivate { int revision; @@ -191,6 +195,7 @@ struct QMetaObjectPrivate int propertyCount, propertyData; int enumeratorCount, enumeratorData; int constructorCount, constructorData; + int flags; }; static inline const QMetaObjectPrivate *priv(const uint* data) @@ -280,6 +285,17 @@ int QMetaObject::static_metacall(Call cl, int idx, void **argv) const } /*! + \internal +*/ +int QMetaObject::metacall(QObject *object, Call cl, int idx, void **argv) +{ + if (QMetaObject *mo = object->d_ptr->metaObject) + return static_cast(mo)->metaCall(cl, idx, argv); + else + return object->qt_metacall(cl, idx, argv); +} + +/*! \fn const char *QMetaObject::className() const Returns the class name. @@ -699,6 +715,14 @@ int QMetaObject::indexOfProperty(const char *name) const } m = m->d.superdata; } + + if (i == -1 && priv(this->d.data)->revision >= 3 && (priv(this->d.data)->flags & DynamicMetaObject)){ + QAbstractDynamicMetaObject *me = + const_cast(static_cast(this)); + + i = me->createProperty(name, 0); + } + return i; } @@ -1538,7 +1562,7 @@ bool QMetaMethod::invoke(QObject *object, // recompute the methodIndex by reversing the arithmetic in QMetaObject::property() int methodIndex = ((handle - priv(mobj->d.data)->methodData) / 5) + mobj->methodOffset(); if (connectionType == Qt::DirectConnection) { - return object->qt_metacall(QMetaObject::InvokeMetaMethod, methodIndex, param) < 0; + return QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, methodIndex, param) < 0; } else { if (returnValue.data()) { qWarning("QMetaMethod::invoke: Unable to invoke methods with return values in " @@ -2174,9 +2198,8 @@ QVariant QMetaProperty::read(const QObject *object) const value = QVariant(t, (void*)0); argv[0] = value.data(); } - const_cast(object)->qt_metacall(QMetaObject::ReadProperty, - idx + mobj->propertyOffset(), - argv); + QMetaObject::metacall(const_cast(object), QMetaObject::ReadProperty, + idx + mobj->propertyOffset(), argv); if (status != -1) return value; @@ -2247,7 +2270,7 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const argv[0] = &v; else argv[0] = v.data(); - object->qt_metacall(QMetaObject::WriteProperty, idx + mobj->propertyOffset(), argv); + QMetaObject::metacall(object, QMetaObject::WriteProperty, idx + mobj->propertyOffset(), argv); return status; } @@ -2264,7 +2287,7 @@ bool QMetaProperty::reset(QObject *object) const if (!object || !mobj || !isResettable()) return false; void *argv[] = { 0 }; - object->qt_metacall(QMetaObject::ResetProperty, idx + mobj->propertyOffset(), argv); + QMetaObject::metacall(object, QMetaObject::ResetProperty, idx + mobj->propertyOffset(), argv); return true; } @@ -2378,8 +2401,8 @@ bool QMetaProperty::isDesignable(const QObject *object) const bool b = flags & Designable; if (object) { void *argv[] = { &b }; - const_cast(object)->qt_metacall(QMetaObject::QueryPropertyDesignable, - idx + mobj->propertyOffset(), argv); + QMetaObject::metacall(const_cast(object), QMetaObject::QueryPropertyDesignable, + idx + mobj->propertyOffset(), argv); } return b; @@ -2404,8 +2427,8 @@ bool QMetaProperty::isScriptable(const QObject *object) const bool b = flags & Scriptable; if (object) { void *argv[] = { &b }; - const_cast(object)->qt_metacall(QMetaObject::QueryPropertyScriptable, - idx + mobj->propertyOffset(), argv); + QMetaObject::metacall(const_cast(object), QMetaObject::QueryPropertyScriptable, + idx + mobj->propertyOffset(), argv); } return b; } @@ -2428,8 +2451,8 @@ bool QMetaProperty::isStored(const QObject *object) const bool b = flags & Stored; if (object) { void *argv[] = { &b }; - const_cast(object)->qt_metacall(QMetaObject::QueryPropertyStored, - idx + mobj->propertyOffset(), argv); + QMetaObject::metacall(const_cast(object), QMetaObject::QueryPropertyStored, + idx + mobj->propertyOffset(), argv); } return b; } @@ -2455,8 +2478,8 @@ bool QMetaProperty::isUser(const QObject *object) const bool b = flags & User; if (object) { void *argv[] = { &b }; - const_cast(object)->qt_metacall(QMetaObject::QueryPropertyUser, - idx + mobj->propertyOffset(), argv); + QMetaObject::metacall(const_cast(object), QMetaObject::QueryPropertyUser, + idx + mobj->propertyOffset(), argv); } return b; } @@ -2520,8 +2543,8 @@ bool QMetaProperty::isEditable(const QObject *object) const bool b = flags & Editable; if (object) { void *argv[] = { &b }; - const_cast(object)->qt_metacall(QMetaObject::QueryPropertyEditable, - idx + mobj->propertyOffset(), argv); + QMetaObject::metacall(const_cast(object), QMetaObject::QueryPropertyEditable, + idx + mobj->propertyOffset(), argv); } return b; } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index b0ddd81..ab91799 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -145,11 +145,13 @@ QObjectPrivate::QObjectPrivate(int version) inThreadChangeEvent = false; deleteWatch = 0; objectGuards = 0; + metaObject = 0; hasGuards = false; } QObjectPrivate::~QObjectPrivate() { + delete static_cast(metaObject); if (deleteWatch) *deleteWatch = 1; #ifndef QT_NO_USERDATA @@ -484,7 +486,7 @@ QMetaCallEvent::~QMetaCallEvent() */ int QMetaCallEvent::placeMetaCall(QObject *object) { - return object->qt_metacall(QMetaObject::InvokeMetaMethod, id_, args_); + return QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, id_, args_); } /*! @@ -3171,10 +3173,10 @@ void QMetaObject::activate(QObject *sender, int from_signal_index, int to_signal } #if defined(QT_NO_EXCEPTIONS) - receiver->qt_metacall(QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv); + metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv); #else try { - receiver->qt_metacall(QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv); + metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv); } catch (...) { locker.relock(); @@ -3917,6 +3919,7 @@ void qDeleteInEventHandler(QObject *o) delete o; } + QT_END_NAMESPACE #include "moc_qobject.cpp" diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 4715626..9169a90 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -109,6 +109,7 @@ public: uint hasGuards : 1; //true iff there is one or more QPointer attached to this object uint unused : 22; int postedEvents; + QMetaObject *metaObject; // assert dynamic }; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 19df642..e908753 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -256,6 +256,14 @@ private: void Q_CORE_EXPORT qDeleteInEventHandler(QObject *o); + +struct Q_CORE_EXPORT QAbstractDynamicMetaObject : public QMetaObject +{ + virtual ~QAbstractDynamicMetaObject() {} + virtual int metaCall(QMetaObject::Call, int _id, void **) { return _id; } + virtual int createProperty(const char *, const char *) { return -1; } +}; + QT_END_NAMESPACE #endif // QOBJECT_P_H diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 300e9fa..1ae46d5 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -431,6 +431,7 @@ struct Q_CORE_EXPORT QMetaObject }; int static_metacall(Call, int, void **) const; + static int metacall(QObject *, Call, int, void **); #ifdef QT3_SUPPORT QT3_SUPPORT const char *superClassName() const; @@ -442,6 +443,7 @@ struct Q_CORE_EXPORT QMetaObject const uint *data; const void *extradata; } d; + }; struct QMetaObjectExtraData diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index fbc434d..6df762d 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -205,10 +205,10 @@ void Generator::generateCode() QByteArray qualifiedClassNameIdentifier = cdef->qualified; qualifiedClassNameIdentifier.replace(':', '_'); - int index = 12; + int index = 13; fprintf(out, "static const uint qt_meta_data_%s[] = {\n", qualifiedClassNameIdentifier.constData()); fprintf(out, "\n // content:\n"); - fprintf(out, " %4d, // revision\n", 2); + fprintf(out, " %4d, // revision\n", 3); fprintf(out, " %4d, // classname\n", strreg(cdef->qualified)); fprintf(out, " %4d, %4d, // classinfo\n", cdef->classInfoList.count(), cdef->classInfoList.count() ? index : 0); index += cdef->classInfoList.count() * 2; @@ -228,6 +228,9 @@ void Generator::generateCode() fprintf(out, " %4d, %4d, // constructors\n", isConstructible ? cdef->constructorList.count() : 0, isConstructible ? index : 0); + fprintf(out, " %4d, // flags\n", 0); + + // // Build classinfo array // @@ -382,7 +385,7 @@ void Generator::generateCode() if (isQt || !cdef->hasQObject) return; - fprintf(out, "\nconst QMetaObject *%s::metaObject() const\n{\n return &staticMetaObject;\n}\n", + fprintf(out, "\nconst QMetaObject *%s::metaObject() const\n{\n return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;\n}\n", cdef->qualified.constData()); // // Generate smart cast function -- cgit v0.12 From 545a2e68b49fa648e85e6cca4df97badb89773bb Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 17:57:32 +1000 Subject: Export QTextControl This class is used in declarative. Reviewed-by: Andreas --- src/gui/text/qtextcontrol_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextcontrol_p.h b/src/gui/text/qtextcontrol_p.h index 872bcd5..eb0d749 100644 --- a/src/gui/text/qtextcontrol_p.h +++ b/src/gui/text/qtextcontrol_p.h @@ -83,7 +83,7 @@ class QAbstractScrollArea; class QEvent; class QTimerEvent; -class Q_AUTOTEST_EXPORT QTextControl : public QObject +class Q_GUI_EXPORT QTextControl : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QTextControl) -- cgit v0.12 From 048ac3827d103bfd08b4675c3ec783e10902f381 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 18:01:42 +1000 Subject: Add NOTIFY attribute to QAction properties Authored-by: Warwick Allison Reviewed-by: Henrik Hartz --- src/gui/kernel/qaction.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h index 133fab4..cb681c4 100644 --- a/src/gui/kernel/qaction.h +++ b/src/gui/kernel/qaction.h @@ -68,24 +68,24 @@ class Q_GUI_EXPORT QAction : public QObject Q_ENUMS(MenuRole) Q_ENUMS(Priority) - Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable) + Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY changed) Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) - Q_PROPERTY(QIcon icon READ icon WRITE setIcon) - Q_PROPERTY(QString text READ text WRITE setText) - Q_PROPERTY(QString iconText READ iconText WRITE setIconText) - Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip) - Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip) - Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis) - Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY changed) + Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY changed) + Q_PROPERTY(QString text READ text WRITE setText NOTIFY changed) + Q_PROPERTY(QString iconText READ iconText WRITE setIconText NOTIFY changed) + Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip NOTIFY changed) + Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip NOTIFY changed) + Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis NOTIFY changed) + Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed) #ifndef QT_NO_SHORTCUT - Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) - Q_PROPERTY(Qt::ShortcutContext shortcutContext READ shortcutContext WRITE setShortcutContext) - Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat) + Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut NOTIFY changed) + Q_PROPERTY(Qt::ShortcutContext shortcutContext READ shortcutContext WRITE setShortcutContext NOTIFY changed) + Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY changed) #endif - Q_PROPERTY(bool visible READ isVisible WRITE setVisible) - Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole) - Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY changed) + Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed) + Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed) Q_PROPERTY(Priority priority READ priority WRITE setPriority) public: -- cgit v0.12 From 8fca9052e72d1dc983443c3a8065f804bebf77e7 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 5 May 2009 15:27:04 +1000 Subject: QtScript must respect dynamic metaobject's when installed (cherry picked from commit f39ccc5ed802ee8461122b8b067c8faa9aae8f8a) Reviewed-by: Roberto Raggi --- src/script/qscriptextqobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/qscriptextqobject.cpp b/src/script/qscriptextqobject.cpp index 88fd007..3ea5963 100644 --- a/src/script/qscriptextqobject.cpp +++ b/src/script/qscriptextqobject.cpp @@ -736,7 +736,7 @@ static void callQtMethod(QScriptContextPrivate *context, QMetaMethod::MethodType meta->static_metacall(QMetaObject::CreateInstance, chosenIndex, params); } else { Q_ASSERT(thisQObject != 0); - thisQObject->qt_metacall(QMetaObject::InvokeMetaMethod, chosenIndex, params); + QMetaObject::metacall(thisQObject, QMetaObject::InvokeMetaMethod, chosenIndex, params); } if (scriptable) -- cgit v0.12 From 33e475e2f39b26327c60a52bc02ad50500ad7cbe Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 6 May 2009 15:10:56 +1000 Subject: Don't process input events while waiting for network response. (cherry picked from commit 4b84041c072325bd09bb7177d121330048133103) Reviewed-by: mbm --- src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp b/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp index 1cd84db..8019551 100644 --- a/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp +++ b/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp @@ -125,7 +125,7 @@ QNetworkReply *AccelTreeResourceLoader::load(const QUrl &uri, networkLoop.connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(error(QNetworkReply::NetworkError))); networkLoop.connect(reply, SIGNAL(finished()), SLOT(finished())); - if(networkLoop.exec()) + if(networkLoop.exec(QEventLoop::ExcludeUserInputEvents)) { const QString errorMessage(escape(reply->errorString())); -- cgit v0.12 From dee897be8d8a9bbb67f654cee89337af6db09872 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 31 Jul 2009 10:58:21 +1000 Subject: Reorder flag values in ascending order Reviewed-by: Roberto Raggi --- src/corelib/kernel/qmetaobject.cpp | 8 ++++---- src/tools/moc/generator.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index fc17e00..fb59b98 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -148,7 +148,9 @@ enum PropertyFlags { Resettable = 0x00000004, EnumOrFlag = 0x00000008, StdCppSet = 0x00000100, -// Override = 0x00000200, +// Override = 0x00000200, + Constant = 0x00000400, + Final = 0x00000800, Designable = 0x00001000, ResolveDesignable = 0x00002000, Scriptable = 0x00004000, @@ -160,9 +162,7 @@ enum PropertyFlags { User = 0x00100000, ResolveUser = 0x00200000, Notify = 0x00400000, - Dynamic = 0x00800000, - Constant = 0x00000400, - Final = 0x00000800 + Dynamic = 0x00800000 }; enum MethodFlags { diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 6df762d..dd31336 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -56,6 +56,8 @@ enum PropertyFlags { EnumOrFlag = 0x00000008, StdCppSet = 0x00000100, // Override = 0x00000200, + Constant = 0x00000400, + Final = 0x00000800, Designable = 0x00001000, ResolveDesignable = 0x00002000, Scriptable = 0x00004000, @@ -67,10 +69,9 @@ enum PropertyFlags { User = 0x00100000, ResolveUser = 0x00200000, Notify = 0x00400000, - Dynamic = 0x00800000, - Constant = 0x00000400, - Final = 0x00000800 + Dynamic = 0x00800000 }; + enum MethodFlags { AccessPrivate = 0x00, AccessProtected = 0x01, -- cgit v0.12 From 78085510b570d3d1a16339e7440172f0955798d1 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 31 Jul 2009 11:13:43 +1000 Subject: Remove isDynamic property flag Reviewed-by: Roberto Raggi --- src/corelib/kernel/qmetaobject.cpp | 14 +------------- src/corelib/kernel/qmetaobject.h | 1 - src/tools/moc/generator.cpp | 3 +-- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index fb59b98..9ff0bc1 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -161,8 +161,7 @@ enum PropertyFlags { ResolveEditable = 0x00080000, User = 0x00100000, ResolveUser = 0x00200000, - Notify = 0x00400000, - Dynamic = 0x00800000 + Notify = 0x00400000 }; enum MethodFlags { @@ -2485,17 +2484,6 @@ bool QMetaProperty::isUser(const QObject *object) const } /*! - \internal -*/ -bool QMetaProperty::isDynamic() const -{ - if (!mobj) - return false; - int flags = mobj->d.data[handle + 2]; - return flags & Dynamic; -} - -/*! Returns true if the property is constant; otherwise returns false. A property is constant if the \c{Q_PROPERTY()}'s \c CONSTANT attribute diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 9f36106..419fe06 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -189,7 +189,6 @@ public: bool isStored(const QObject *obj = 0) const; bool isEditable(const QObject *obj = 0) const; bool isUser(const QObject *obj = 0) const; - bool isDynamic() const; bool isConstant() const; bool isFinal() const; diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index dd31336..e3ce2ec 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -68,8 +68,7 @@ enum PropertyFlags { ResolveEditable = 0x00080000, User = 0x00100000, ResolveUser = 0x00200000, - Notify = 0x00400000, - Dynamic = 0x00800000 + Notify = 0x00400000 }; enum MethodFlags { -- cgit v0.12 From 52e52af114a9ebb2534de0573ee52550dfdd0130 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 31 Jul 2009 11:49:45 +1000 Subject: Update QAbstractItemModel following review Reviewed-by: mbm --- src/corelib/kernel/qabstractitemmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 01440e4..80da80e 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -481,11 +481,11 @@ namespace { }; } -Q_GLOBAL_STATIC(DefaultRoleNames, q_defaultRoleNames); +Q_GLOBAL_STATIC(DefaultRoleNames, qDefaultRoleNames) const QHash &QAbstractItemModelPrivate::defaultRoleNames() { - return *q_defaultRoleNames(); + return *qDefaultRoleNames(); } /*! -- cgit v0.12 From 4066cc8a2f2b824d1047913d863b4d3261dd2479 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 31 Jul 2009 09:09:47 +0200 Subject: Show open directory dialog for new gesture example RevBy: denis --- examples/gestures/imageviewer/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/gestures/imageviewer/main.cpp b/examples/gestures/imageviewer/main.cpp index 6bda418..cd1928b 100644 --- a/examples/gestures/imageviewer/main.cpp +++ b/examples/gestures/imageviewer/main.cpp @@ -81,6 +81,9 @@ int main(int argc, char *argv[]) if (QApplication::arguments().size() > 1) w.openDirectory(QApplication::arguments().at(1)); + else + w.openDirectory(QFileDialog::getExistingDirectory(0, "Select image folder")); + return app.exec(); } -- cgit v0.12 From 9c45d4daab2196b6418e7fb2be70f9e6d7a57799 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 31 Jul 2009 09:58:21 +0200 Subject: Cocoa with namespace breaks the build Added the needed macros around the classnames the way it should be done. Reviewed-by: Prasanth --- src/gui/kernel/qcocoaview_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index e3ec30a..2b83df9 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -324,7 +324,7 @@ extern "C" { return NSDragOperationNone; } else { // save the mouse position, used by draggingExited handler. - DnDParams *dndParams = [QCocoaView currentMouseEvent]; + DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]; dndParams->activeDragEnterPos = windowPoint; // send a drag move event immediately after a drag enter event (as per documentation). QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers); @@ -403,7 +403,7 @@ extern "C" { dragEnterSequence = -1; if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) { // try sending the leave event to the last view which accepted drag enter. - DnDParams *dndParams = [QCocoaView currentMouseEvent]; + DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]; NSView *candidateView = [[[self window] contentView] hitTest:dndParams->activeDragEnterPos]; if (candidateView && candidateView != self) return [candidateView draggingExited:sender]; -- cgit v0.12 From 65f6a08ba7d26405a9de683ea0806b400ba8b26d Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 31 Jul 2009 10:17:20 +0200 Subject: test that activation and this-object can be inherited from parent context --- tests/auto/qscriptcontext/tst_qscriptcontext.cpp | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index d96006d..3c9ea4c9 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -72,6 +72,7 @@ private slots: void scopeChain(); void pushAndPopScope(); void getSetActivationObject(); + void inheritActivationAndThisObject(); void toString(); }; @@ -689,6 +690,35 @@ void tst_QScriptContext::getSetActivationObject() } } +static QScriptValue myEval(QScriptContext *ctx, QScriptEngine *eng) +{ + QString code = ctx->argument(0).toString(); + ctx->setActivationObject(ctx->parentContext()->activationObject()); + ctx->setThisObject(ctx->parentContext()->thisObject()); + return eng->evaluate(code); +} + +void tst_QScriptContext::inheritActivationAndThisObject() +{ + QScriptEngine eng; + eng.globalObject().setProperty("myEval", eng.newFunction(myEval)); + { + QScriptValue ret = eng.evaluate("var a = 123; myEval('a')"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 123); + } + { + QScriptValue ret = eng.evaluate("(function() { return myEval('this'); }).call(Number)"); + QVERIFY(ret.isFunction()); + QVERIFY(ret.equals(eng.globalObject().property("Number"))); + } + { + QScriptValue ret = eng.evaluate("(function(a) { return myEval('a'); })(123)"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 123); + } +} + static QScriptValue parentContextToString(QScriptContext *ctx, QScriptEngine *) { return ctx->parentContext()->toString(); -- cgit v0.12 From 919ac1291c6e7d163b58679eae691f866b40f71b Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 30 Jul 2009 14:09:22 +0200 Subject: Compile on HP-UXi There is no monotonic clock support on HP-UXi at all, and the _POSIX_MONOTONIC_CLOCK macro is not defined at all (not even to -1). We handle this in the event dispatcher, but not in qcore_unix.cpp. Since the monotonic clock time code has moved, the define of _POSIX_MONOTONIC_CLOCK to -1 should also move. Reviewed-by: thiago --- src/corelib/kernel/qcore_unix_p.h | 4 ++++ src/corelib/kernel/qeventdispatcher_unix_p.h | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index dceb73a..69ebb05 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -323,6 +323,10 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options) #endif // Q_OS_VXWORKS +#if !defined(_POSIX_MONOTONIC_CLOCK) +# define _POSIX_MONOTONIC_CLOCK -1 +#endif + bool qt_gettime_is_monotonic(); timeval qt_gettime(); Q_CORE_EXPORT int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index 9c67c70..5e016d3 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -69,9 +69,6 @@ #endif QT_BEGIN_NAMESPACE -#if !defined(_POSIX_MONOTONIC_CLOCK) -# define _POSIX_MONOTONIC_CLOCK -1 -#endif // internal timer info struct QTimerInfo { -- cgit v0.12 From 18fbfdf0f774198e2e1277e064cc3a8eb9dbb29d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 31 Jul 2009 10:30:44 +0200 Subject: Fix compilation with xlC 7: operands to ?: must match. See 3ae2cab9c8bd1790a00da2755ac036143a3a35f4 for another similar fix. Reviewed-by: Trust Me --- tools/linguist/shared/po.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/linguist/shared/po.cpp b/tools/linguist/shared/po.cpp index 796d012..a6795cb 100644 --- a/tools/linguist/shared/po.cpp +++ b/tools/linguist/shared/po.cpp @@ -359,7 +359,7 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) const QChar quote = QLatin1Char('"'); const QChar newline = QLatin1Char('\n'); QTextStream in(&dev); - in.setCodec(cd.m_codecForSource.isEmpty() ? "UTF-8" : cd.m_codecForSource); + in.setCodec(cd.m_codecForSource.isEmpty() ? QByteArray("UTF-8") : cd.m_codecForSource); bool error = false; // format of a .po file entry: @@ -555,7 +555,7 @@ bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd) { bool ok = true; QTextStream out(&dev); - out.setCodec(cd.m_outputCodec.isEmpty() ? "UTF-8" : cd.m_outputCodec); + out.setCodec(cd.m_outputCodec.isEmpty() ? QByteArray("UTF-8") : cd.m_outputCodec); bool first = true; if (translator.messages().isEmpty() || !translator.messages().first().sourceText().isEmpty()) { -- cgit v0.12 From 1a7286691a74016a0577073275fc462aea2fe1bc Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 31 Jul 2009 11:07:13 +0200 Subject: Doc: Fixed a snippet bug in QFileInfo Task-number: 258371 Reviewed-by: Trust Me --- doc/src/snippets/code/src_corelib_io_qfileinfo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp b/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp index 2ab15ee..89b4f33 100644 --- a/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp +++ b/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp @@ -13,9 +13,9 @@ info1.size(); // returns 56201 info1.symLinkTarget(); // returns "/opt/pretty++/bin/untabify" QFileInfo info2(info1.symLinkTarget()); -info1.isSymLink(); // returns false -info1.absoluteFilePath(); // returns "/opt/pretty++/bin/untabify" -info1.size(); // returns 56201 +info2.isSymLink(); // returns false +info2.absoluteFilePath(); // returns "/opt/pretty++/bin/untabify" +info2.size(); // returns 56201 #endif //! [0] -- cgit v0.12 From 8a0a59e6776e1384f884e0f6e7ec6fe10f3be054 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 31 Jul 2009 11:28:34 +0200 Subject: remove const from QSignalEvent::sender* QObject::sender() does not return const QObject*, so neither should this API; it just forces you to const_cast for no good reason. --- src/corelib/statemachine/qsignalevent.h | 6 +++--- src/corelib/statemachine/qstatemachine.cpp | 4 ++-- src/corelib/statemachine/qstatemachine_p.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/statemachine/qsignalevent.h b/src/corelib/statemachine/qsignalevent.h index c09c5a3..b7ca61f 100644 --- a/src/corelib/statemachine/qsignalevent.h +++ b/src/corelib/statemachine/qsignalevent.h @@ -58,16 +58,16 @@ QT_MODULE(Core) class Q_CORE_EXPORT QSignalEvent : public QEvent { public: - QSignalEvent(const QObject *sender, int signalIndex, + QSignalEvent(QObject *sender, int signalIndex, const QList &arguments); ~QSignalEvent(); - inline const QObject *sender() const { return m_sender; } + inline QObject *sender() const { return m_sender; } inline int signalIndex() const { return m_signalIndex; } inline QList arguments() const { return m_arguments; } private: - const QObject *m_sender; + QObject *m_sender; int m_signalIndex; QList m_arguments; }; diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index a02480b..d89ad98 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1446,7 +1446,7 @@ void QStateMachinePrivate::unregisterEventTransition(QEventTransition *transitio } #endif -void QStateMachinePrivate::handleTransitionSignal(const QObject *sender, int signalIndex, +void QStateMachinePrivate::handleTransitionSignal(QObject *sender, int signalIndex, void **argv) { Q_ASSERT(connections[sender].at(signalIndex) != 0); @@ -2026,7 +2026,7 @@ QSignalEventGenerator::QSignalEventGenerator(QStateMachine *parent) Constructs a new QSignalEvent object with the given \a sender, \a signalIndex and \a arguments. */ -QSignalEvent::QSignalEvent(const QObject *sender, int signalIndex, +QSignalEvent::QSignalEvent(QObject *sender, int signalIndex, const QList &arguments) : QEvent(QEvent::Signal), m_sender(sender), m_signalIndex(signalIndex), m_arguments(arguments) diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index cae21aa..590cffe 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -147,7 +147,7 @@ public: #endif void unregisterTransition(QAbstractTransition *transition); void unregisterAllTransitions(); - void handleTransitionSignal(const QObject *sender, int signalIndex, + void handleTransitionSignal(QObject *sender, int signalIndex, void **args); void scheduleProcess(); -- cgit v0.12 From f12085f8a00957ed17c33e9d75e51dc74a3d2115 Mon Sep 17 00:00:00 2001 From: kh Date: Fri, 31 Jul 2009 12:02:46 +0200 Subject: Fix internal documentation after QUrl change. Reviewed-by: kh --- tools/assistant/tools/assistant/assistant.qch | Bin 368640 -> 368640 bytes tools/assistant/tools/assistant/doc/assistant.qhp | 2 +- tools/assistant/tools/assistant/helpviewer.cpp | 4 ++-- tools/assistant/tools/assistant/main.cpp | 2 +- tools/assistant/tools/assistant/mainwindow.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/assistant/tools/assistant/assistant.qch b/tools/assistant/tools/assistant/assistant.qch index 99687ed..3e66bd9 100644 Binary files a/tools/assistant/tools/assistant/assistant.qch and b/tools/assistant/tools/assistant/assistant.qch differ diff --git a/tools/assistant/tools/assistant/doc/assistant.qhp b/tools/assistant/tools/assistant/doc/assistant.qhp index 7a26101..7ea4cdd 100644 --- a/tools/assistant/tools/assistant/doc/assistant.qhp +++ b/tools/assistant/tools/assistant/doc/assistant.qhp @@ -1,7 +1,7 @@ assistant - com.trolltech.com.assistantinternal_1.0.0 + com.trolltech.com.assistantinternal-1.0.0 assistant.html diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 6799db3..5422bf46 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -306,7 +306,7 @@ void HelpViewer::setSource(const QUrl &url) loadFinished = false; if (url.toString() == QLatin1String("help")) { load(QUrl(QLatin1String("qthelp://com.trolltech.com." - "assistantinternal_1.0.0/assistant/assistant.html"))); + "assistantinternal-1.0.0/assistant/assistant.html"))); } else { load(url); } @@ -425,7 +425,7 @@ void HelpViewer::setSource(const QUrl &url) if (help) { QTextBrowser::setSource(QUrl(QLatin1String("qthelp://com.trolltech.com." - "assistantinternal_1.0.0/assistant/assistant.html"))); + "assistantinternal-1.0.0/assistant/assistant.html"))); } else { QTextBrowser::setSource(url); setHtml(tr("Error 404...


      " diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index 05355d9..a0a5a0d 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -306,7 +306,7 @@ int main(int argc, char *argv[]) } } - QLatin1String intern("com.trolltech.com.assistantinternal_"); + QLatin1String intern("com.trolltech.com.assistantinternal-"); foreach (const QString &doc, userDocs) { if (!callerDocs.contains(doc) && !doc.startsWith(intern)) user.unregisterDocumentation(doc); diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 7926020..0c1723c 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -274,7 +274,7 @@ bool MainWindow::initHelpDB() return false; bool assistantInternalDocRegistered = false; - QString intern(QLatin1String("com.trolltech.com.assistantinternal_")); + QString intern(QLatin1String("com.trolltech.com.assistantinternal-")); foreach (const QString &ns, m_helpEngine->registeredDocumentations()) { if (ns.startsWith(intern)) { intern = ns; -- cgit v0.12 From fbbd7f9a27216dc66a77a064179a4775ce9fb91e Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 31 Jul 2009 13:42:08 +0200 Subject: add private goToState() function to state machine Needed for Declarative UI integration. --- src/corelib/statemachine/qstatemachine.cpp | 96 ++++++++++++++++++++++++-- src/corelib/statemachine/qstatemachine_p.h | 8 ++- tests/auto/qstatemachine/tst_qstatemachine.cpp | 41 +++++++++++ 3 files changed, 138 insertions(+), 7 deletions(-) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index d89ad98..5aa5917 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -205,6 +205,7 @@ This is QStateMachinePrivate::QStateMachinePrivate() { state = NotRunning; + _startState = 0; processing = false; processingScheduled = false; stop = false; @@ -1146,6 +1147,20 @@ protected: } // namespace +QState *QStateMachinePrivate::startState() +{ + Q_Q(QStateMachine); + if (_startState == 0) + _startState = new StartState(q); + return _startState; +} + +void QStateMachinePrivate::removeStartState() +{ + delete _startState; + _startState = 0; +} + void QStateMachinePrivate::_q_start() { Q_Q(QStateMachine); @@ -1165,11 +1180,19 @@ void QStateMachinePrivate::_q_start() processingScheduled = true; // we call _q_process() below emit q->started(); - StartState *start = new StartState(rootState()); - QAbstractTransition *initialTransition = new InitialTransition(initial); - start->addTransition(initialTransition); - QList transitions; - transitions.append(initialTransition); + QState *start = startState(); + Q_ASSERT(start != 0); + + QList transitions = QStatePrivate::get(start)->transitions(); + + // If a transition has already been added, then we skip this step, as the + // initial transition in that case has been overridden. + if (transitions.isEmpty()) { + QAbstractTransition *initialTransition = new InitialTransition(initial); + start->addTransition(initialTransition); + transitions.append(initialTransition); + } + QEvent nullEvent(QEvent::None); executeTransitionContent(&nullEvent, transitions); QList enteredStates = enterStates(&nullEvent, transitions); @@ -1177,7 +1200,7 @@ void QStateMachinePrivate::_q_start() applyProperties(transitions, QList() << start, enteredStates); #endif - delete start; + removeStartState(); #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": initial configuration:" << configuration; @@ -1277,6 +1300,67 @@ void QStateMachinePrivate::scheduleProcess() QMetaObject::invokeMethod(q_func(), "_q_process", Qt::QueuedConnection); } +namespace { + +class GoToStateTransition : public QAbstractTransition +{ +public: + GoToStateTransition(QAbstractState *target) + : QAbstractTransition(QList() << target) {} +protected: + void onTransition(QEvent *) { deleteLater(); } + bool eventTest(QEvent *) { return true; } +}; + +} // namespace + +/*! + \internal + + Causes this state machine to unconditionally transition to the given + \a targetState. + + Provides a backdoor for using the state machine "imperatively"; i.e. rather + than defining explicit transitions, you drive the machine's execution by + calling this function. It breaks the whole integrity of the + transition-driven model, but is provided for pragmatic reasons. +*/ +void QStateMachinePrivate::goToState(QAbstractState *targetState) +{ + if (!targetState) { + qWarning("QStateMachine::goToState(): cannot go to null state"); + return; + } + + if (configuration.contains(targetState)) + return; + + QState *sourceState = 0; + if (state == Running) { + QSet::const_iterator it; + for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { + sourceState = qobject_cast(*it); + if (sourceState != 0) + break; + } + } else { + sourceState = startState(); + } + + Q_ASSERT(sourceState != 0); + // Reuse previous GoToStateTransition in case of several calls to + // goToState() in a row. + GoToStateTransition *trans = qFindChild(sourceState); + if (!trans) { + trans = new GoToStateTransition(targetState); + sourceState->addTransition(trans); + } else { + trans->setTargetState(targetState); + } + + scheduleProcess(); +} + void QStateMachinePrivate::registerTransitions(QAbstractState *state) { QState *group = qobject_cast(state); diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 590cffe..714a40b 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -79,7 +79,7 @@ class QAbstractAnimation; #endif class QStateMachine; -class QStateMachinePrivate : public QStatePrivate +class Q_AUTOTEST_EXPORT QStateMachinePrivate : public QStatePrivate { Q_DECLARE_PUBLIC(QStateMachine) public: @@ -116,6 +116,9 @@ public: QState *rootState() const; + QState *startState(); + void removeStartState(); + void microstep(QEvent *event, const QList &transitionList); bool isPreempted(const QAbstractState *s, const QSet &transitions) const; QSet selectTransitions(QEvent *event) const; @@ -138,6 +141,8 @@ public: static bool isDescendantOf(const QAbstractState *s, const QAbstractState *other); static QList properAncestors(const QAbstractState *s, const QState *upperBound); + void goToState(QAbstractState *targetState); + void registerTransitions(QAbstractState *state); void registerSignalTransition(QSignalTransition *transition); void unregisterSignalTransition(QSignalTransition *transition); @@ -162,6 +167,7 @@ public: #endif State state; + QState *_startState; bool processing; bool processingScheduled; bool stop; diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 7f4d9f5..32812e2 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -192,6 +192,7 @@ private slots: // void overrideDefaultTargetAnimationWithSource(); void nestedStateMachines(); + void goToState(); }; tst_QStateMachine::tst_QStateMachine() @@ -3900,5 +3901,45 @@ void tst_QStateMachine::nestedStateMachines() QTRY_COMPARE(finishedSpy.count(), 1); } +void tst_QStateMachine::goToState() +{ + QStateMachine machine; + QState *s1 = new QState(&machine); + QState *s2 = new QState(&machine); + machine.setInitialState(s1); + QSignalSpy startedSpy(&machine, SIGNAL(started())); + machine.start(); + QTRY_COMPARE(startedSpy.count(), 1); + + QStateMachinePrivate::get(&machine)->goToState(s2); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s2)); + + QStateMachinePrivate::get(&machine)->goToState(s2); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s2)); + + QStateMachinePrivate::get(&machine)->goToState(s1); + QStateMachinePrivate::get(&machine)->goToState(s2); + QStateMachinePrivate::get(&machine)->goToState(s1); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s2)); + + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + // go to state in group + QState *s2_1 = new QState(s2); + s2->setInitialState(s2_1); + QStateMachinePrivate::get(&machine)->goToState(s2_1); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 2); + QVERIFY(machine.configuration().contains(s2)); + QVERIFY(machine.configuration().contains(s2_1)); +} + QTEST_MAIN(tst_QStateMachine) #include "tst_qstatemachine.moc" -- cgit v0.12 From 18d9902a2c5650e48a33b09ef68596479e7cb9ff Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 31 Jul 2009 13:40:17 +0200 Subject: Fix compilation: add #include if placement new is used I'm not sure this is the proper fix, though. xlC 7 complains with: "/usr/vacpp/include/new", line 97.10: 1540-1298 (I) "void *operator new(size_t, void *) throw()" needs to be declared in the containing scope to be found by name lookup. Also add some calculations to the padding in the data structure. Reviewed-by: Trust Me --- src/corelib/tools/qcontiguouscache.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 0020d22..7221925 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -44,6 +44,7 @@ #include #include +#include QT_BEGIN_HEADER @@ -76,6 +77,12 @@ struct QContiguousCacheTypedData int start; int offset; uint sharable : 1; + // uint unused : 31; + + // total is 24 bytes (HP-UX aCC: 40 bytes) + // the next entry is already aligned to 8 bytes + // there will be an 8 byte gap here if T requires 16-byte alignment + // (such as long double on 64-bit platforms, __int128, __float128) T array[1]; }; -- cgit v0.12 From 991c2299078978d38692b3499580eb86d0ed7d9b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 31 Jul 2009 13:56:37 +0200 Subject: Revert "Small simplification of code in ItemViews (delegate)" This reverts commit 95560abfdd3a1755b69f238eff2954d164dff6a5. Fix comboboxes used as editor. isAncestor() stops at windows. we want to go tought the whole widget chain, including parent windows Use case: examples/itemviews/coloreditorfactory/coloreditorfactory Task-number: 259034 --- src/gui/itemviews/qitemdelegate.cpp | 9 ++++++--- src/gui/itemviews/qstyleditemdelegate.cpp | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index 336ca79..aff715c 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -1226,9 +1226,12 @@ bool QItemDelegate::eventFilter(QObject *object, QEvent *event) } else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow())) { //the Hide event will take care of he editors that are in fact complete dialogs if (!editor->isActiveWindow() || (QApplication::focusWidget() != editor)) { - if (editor->isAncestorOf(QApplication::focusWidget())) - return false; // don't worry about focus changes internally in the editor - + QWidget *w = QApplication::focusWidget(); + while (w) { // don't worry about focus changes internally in the editor + if (w == editor) + return false; + w = w->parentWidget(); + } #ifndef QT_NO_DRAGANDDROP // The window may lose focus during an drag operation. // i.e when dragging involves the taskbar on Windows. diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp index bd8fdac..7ec2afe 100644 --- a/src/gui/itemviews/qstyleditemdelegate.cpp +++ b/src/gui/itemviews/qstyleditemdelegate.cpp @@ -674,9 +674,12 @@ bool QStyledItemDelegate::eventFilter(QObject *object, QEvent *event) } else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow())) { //the Hide event will take care of he editors that are in fact complete dialogs if (!editor->isActiveWindow() || (QApplication::focusWidget() != editor)) { - if (editor->isAncestorOf(QApplication::focusWidget())) - return false; // don't worry about focus changes internally in the editor - + QWidget *w = QApplication::focusWidget(); + while (w) { // don't worry about focus changes internally in the editor + if (w == editor) + return false; + w = w->parentWidget(); + } #ifndef QT_NO_DRAGANDDROP // The window may lose focus during an drag operation. // i.e when dragging involves the taskbar on Windows. -- cgit v0.12 From 193b109814a0bbf4fc8b5d7bd8911c920194838d Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 31 Jul 2009 14:25:58 +0200 Subject: compile Broke on WinCE since QStateMachinePrivate is now using Q_AUTOTEST_EXPORT. --- src/corelib/statemachine/qstatemachine_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 714a40b..5d8c788 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -214,7 +214,7 @@ public: f_cloneEvent cloneEvent; }; - static Q_CORE_EXPORT const Handler *handler; + static const Handler *handler; }; QT_END_NAMESPACE -- cgit v0.12 From 7c4b1863495905c3486ea36e0d559f49c6f2ebb4 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 31 Jul 2009 14:33:30 +0200 Subject: Doc: fix warnings. --- src/corelib/kernel/qabstractitemmodel.cpp | 2 +- src/testlib/qtestcase.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 80da80e..bc95c60 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -1902,7 +1902,7 @@ void QAbstractItemModel::setRoleNames(const QHash &roleNames) /*! Returns the model's role names. - \sa setRoleNames + \sa setRoleNames() */ const QHash &QAbstractItemModel::roleNames() const { diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 1dae828..ac4ca83 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -818,6 +818,8 @@ void filter_unprintable(char *str) } } +/*! \internal + */ int qt_asprintf(char **str, const char *format, ...) { static const int MAXSIZE = 1024*1024*2; -- cgit v0.12 From c0f0e798e903c39d5f8b6dc6dd2abdfbcc8a7d93 Mon Sep 17 00:00:00 2001 From: ck Date: Fri, 31 Jul 2009 14:41:45 +0200 Subject: Assistant: Performance fixes for help generator's pattern matching. Reading a help project was unacceptably slow with pattern matching. Now we do it only for filenames that contain wildcard symbols. Also, we cache the results of QDir::entryList() calls. --- tools/assistant/lib/qhelpprojectdata.cpp | 43 ++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/tools/assistant/lib/qhelpprojectdata.cpp b/tools/assistant/lib/qhelpprojectdata.cpp index 55b4ea7..5df0426 100644 --- a/tools/assistant/lib/qhelpprojectdata.cpp +++ b/tools/assistant/lib/qhelpprojectdata.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,8 @@ private: void readFiles(); void raiseUnknownTokenError(); void addMatchingFiles(const QString &pattern); + + QMap dirEntriesCache; }; void QHelpProjectDataPrivate::raiseUnknownTokenError() @@ -265,14 +268,40 @@ void QHelpProjectDataPrivate::readFiles() // meaningful warning later. void QHelpProjectDataPrivate::addMatchingFiles(const QString &pattern) { + // The pattern matching is expensive, so we skip it if no + // wildcard symbols occur in the string. + if (!pattern.contains('?') && !pattern.contains('*') + && !pattern.contains('[') && !pattern.contains(']')) { + filterSectionList.last().addFile(pattern); + return; + } + QFileInfo fileInfo(rootPath + '/' + pattern); - const QStringList &matches = - fileInfo.dir().entryList(QStringList(fileInfo.fileName())); - for (QStringList::ConstIterator it = matches.constBegin(); - it != matches.constEnd(); - ++it) - filterSectionList.last().addFile(QFileInfo(pattern).dir().path() + '/' + *it); - if (matches.empty()) + const QDir &dir = fileInfo.dir(); + const QString &path = dir.canonicalPath(); + + // QDir::entryList() is expensive, so we cache the results. + QMap::ConstIterator it = dirEntriesCache.find(path); + const QStringList &entries = it != dirEntriesCache.constEnd() ? + it.value() : dir.entryList(QDir::Files); + if (it == dirEntriesCache.constEnd()) + dirEntriesCache.insert(path, entries); + + bool matchFound = false; +#ifdef Q_OS_WIN + Qt::CaseSensitivity cs = Qt::CaseInSensitive; +#else + Qt::CaseSensitivity cs = Qt::CaseSensitive; +#endif + QRegExp regExp(fileInfo.fileName(), cs, QRegExp::Wildcard); + foreach (const QString &file, entries) { + if (regExp.exactMatch(file)) { + matchFound = true; + filterSectionList.last(). + addFile(QFileInfo(pattern).dir().path() + '/' + file); + } + } + if (!matchFound) filterSectionList.last().addFile(pattern); } -- cgit v0.12 From 9d511567ece87258ab0bdc77f8c0ab62c075f454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 31 Jul 2009 14:52:29 +0200 Subject: Crash DirectFb plugin when resizing verticaly QRasterPaintEngine assumes device does not change size. Therefore create a new engine when resizing. Reviewed-by: Tom --- src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index a1009ac..8cddc76 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -209,7 +209,6 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) if (!dfbWindow) createWindow(); ::setGeometry(dfbWindow, oldRect, rect); - // ### do I need to release and get the surface again here? #endif break; case Offscreen: { @@ -227,7 +226,10 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) if (result != DFB_OK) DirectFBErrorFatal("QDirectFBWindowSurface::setGeometry()", result); } - + if (engine) { + delete engine; + engine = 0; + } QWSWindowSurface::setGeometry(rect); } -- cgit v0.12 From 7c56a5b3825de2372712b9f0087df868ca1fd157 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 30 Jul 2009 13:12:56 +0200 Subject: QCheckBox on an out-of-process server wont allow key & Focus rect is not drawn correctly. Depending on the type of server, QAxClientSite::TranslateAccelerator() needs to process the message differently. For ActiveQt based in-process-servers, only normal Qt event handling is required. For ActiveQt based out-of-process-servers, the message has to be forwarded and Qt event handling needs to continue. For all other type of servers, forward the message and stop Qt event processing. Styles use the WA_KeyboardFocusChange attribute set on the window to decide on drawing the focus rect. ActiveQt handles the VK_TAB key in the QAxServerBase::TranslateAcceleratorW(), the attibute is now set when focus is changed. Task-number: 253763 Reviewed-by: Volker Hilsheimer --- src/activeqt/container/qaxwidget.cpp | 40 ++++++++++++++- src/activeqt/control/qaxserverbase.cpp | 90 ++++++++++++++++++---------------- src/activeqt/shared/qaxtypes.h | 3 ++ 3 files changed, 90 insertions(+), 43 deletions(-) diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index ae468ef..19f00db 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -118,6 +118,8 @@ public: QSize minimumSizeHint() const; int qt_metacall(QMetaObject::Call, int isignal, void **argv); + void* qt_metacast(const char *clname); + inline QAxClientSite *clientSite() const { return axhost; @@ -478,7 +480,9 @@ bool axc_FilterProc(void *m) QAxWidget *ax = 0; QAxHostWidget *host = 0; while (!host && hwnd) { - host = qobject_cast(QWidget::find(hwnd)); + QWidget *widget = QWidget::find(hwnd); + if (widget && widget->inherits("QAxHostWidget")) + host = qobject_cast(widget); hwnd = ::GetParent(hwnd); } if (host) @@ -976,10 +980,34 @@ HRESULT WINAPI QAxClientSite::TransformCoords(POINTL* /*pPtlHimetric*/, POINTF* HRESULT WINAPI QAxClientSite::TranslateAccelerator(LPMSG lpMsg, DWORD /*grfModifiers*/) { - eventTranslated = false; if (lpMsg->message == WM_KEYDOWN && !lpMsg->wParam) return S_OK; + + bool ActiveQtDetected = false; + bool fromInProcServer = false; + LONG_PTR serverType = GetWindowLongPtr(lpMsg->hwnd, GWLP_USERDATA); + if (serverType == QAX_INPROC_SERVER) { + ActiveQtDetected = true; + fromInProcServer = true; + } else if (serverType == QAX_OUTPROC_SERVER) { + ActiveQtDetected = true; + fromInProcServer = false; + } + + eventTranslated = false; + if (!ActiveQtDetected || !fromInProcServer) { + // if the request is coming from an out-of-proc server or a non ActiveQt server, + // we send the message to the host window. This will make sure this key event + // comes to Qt for processing. SendMessage(host->winId(), lpMsg->message, lpMsg->wParam, lpMsg->lParam); + if (ActiveQtDetected && !fromInProcServer) { + // ActiveQt based servers will need further processing of the event + // (eg. key for a checkbox), so we return false. + return S_FALSE; + } + } + // ActiveQt based in-processes-servers will handle the event properly, so + // we dont need to send this key event to the host. return S_OK; } @@ -1617,6 +1645,14 @@ int QAxHostWidget::qt_metacall(QMetaObject::Call call, int isignal, void **argv) return -1; } +void* QAxHostWidget::qt_metacast(const char *clname) +{ + if (!clname) return 0; + if (!qstrcmp(clname,"QAxHostWidget")) + return static_cast(const_cast< QAxHostWidget*>(this)); + return QWidget::qt_metacast(clname); +} + QSize QAxHostWidget::sizeHint() const { return axhost ? axhost->sizeHint() : QWidget::sizeHint(); diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index d7a8e07..e482c60 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -3502,24 +3502,24 @@ Q_GUI_EXPORT int qt_translateKeyCode(int); HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg) { if (pMsg->message != WM_KEYDOWN || !isWidget) - return S_FALSE; + return S_FALSE; DWORD dwKeyMod = 0; if (::GetKeyState(VK_SHIFT) < 0) - dwKeyMod |= 1; // KEYMOD_SHIFT + dwKeyMod |= 1; // KEYMOD_SHIFT if (::GetKeyState(VK_CONTROL) < 0) - dwKeyMod |= 2; // KEYMOD_CONTROL + dwKeyMod |= 2; // KEYMOD_CONTROL if (::GetKeyState(VK_MENU) < 0) - dwKeyMod |= 4; // KEYMOD_ALT + dwKeyMod |= 4; // KEYMOD_ALT switch (LOWORD(pMsg->wParam)) { case VK_TAB: - if (isUIActive) { - bool shift = ::GetKeyState(VK_SHIFT) < 0; - bool giveUp = true; + if (isUIActive) { + bool shift = ::GetKeyState(VK_SHIFT) < 0; + bool giveUp = true; QWidget *curFocus = qt.widget->focusWidget(); if (curFocus) { - if (shift) { + if (shift) { if (!curFocus->isWindow()) { QWidget *nextFocus = curFocus->nextInFocusChain(); QWidget *prevFocus = 0; @@ -3537,9 +3537,10 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg) if (!topLevel) { giveUp = false; ((HackWidget*)curFocus)->focusNextPrevChild(false); + curFocus->window()->setAttribute(Qt::WA_KeyboardFocusChange); } } - } else { + } else { QWidget *nextFocus = curFocus; while (1) { nextFocus = nextFocus->nextInFocusChain(); @@ -3548,63 +3549,70 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg) if (nextFocus->focusPolicy() & Qt::TabFocus) { giveUp = false; ((HackWidget*)curFocus)->focusNextPrevChild(true); + curFocus->window()->setAttribute(Qt::WA_KeyboardFocusChange); break; } } - } + } + } + if (giveUp) { + HWND hwnd = ::GetParent(m_hWnd); + ::SetFocus(hwnd); + } else { + return S_OK; } - if (giveUp) { - HWND hwnd = ::GetParent(m_hWnd); - ::SetFocus(hwnd); - } else { - return S_OK; - } - } - break; + } + break; case VK_LEFT: case VK_RIGHT: case VK_UP: case VK_DOWN: - if (isUIActive) - return S_FALSE; - break; + if (isUIActive) + return S_FALSE; + break; default: - if (isUIActive && qt.widget->focusWidget()) { + if (isUIActive && qt.widget->focusWidget()) { int state = Qt::NoButton; - if (dwKeyMod & 1) - state |= Qt::ShiftModifier; - if (dwKeyMod & 2) - state |= Qt::ControlModifier; - if (dwKeyMod & 4) - state |= Qt::AltModifier; - - int key = pMsg->wParam; + if (dwKeyMod & 1) + state |= Qt::ShiftModifier; + if (dwKeyMod & 2) + state |= Qt::ControlModifier; + if (dwKeyMod & 4) + state |= Qt::AltModifier; + + int key = pMsg->wParam; if (!(key >= 'A' && key <= 'Z') && !(key >= '0' && key <= '9')) key = qt_translateKeyCode(pMsg->wParam); - QKeyEvent override(QEvent::ShortcutOverride, key, (Qt::KeyboardModifiers)state); - override.ignore(); - QApplication::sendEvent(qt.widget->focusWidget(), &override); - if (override.isAccepted()) - return S_FALSE; - } - break; + QKeyEvent override(QEvent::ShortcutOverride, key, (Qt::KeyboardModifiers)state); + override.ignore(); + QApplication::sendEvent(qt.widget->focusWidget(), &override); + if (override.isAccepted()) + return S_FALSE; + } + break; } if (!m_spClientSite) - return S_FALSE; + return S_FALSE; IOleControlSite *controlSite = 0; m_spClientSite->QueryInterface(IID_IOleControlSite, (void**)&controlSite); if (!controlSite) - return S_FALSE; - + return S_FALSE; + bool resetUserData = false; + // set server type in the user-data of the window. + LONG_PTR serverType = QAX_INPROC_SERVER; + if (qAxOutProcServer) + serverType = QAX_OUTPROC_SERVER; + LONG_PTR oldData = SetWindowLongPtr(pMsg->hwnd, GWLP_USERDATA, serverType); HRESULT hres = controlSite->TranslateAcceleratorW(pMsg, dwKeyMod); - controlSite->Release(); + // reset the user-data for the window. + SetWindowLongPtr(pMsg->hwnd, GWLP_USERDATA, oldData); return hres; } diff --git a/src/activeqt/shared/qaxtypes.h b/src/activeqt/shared/qaxtypes.h index 4f647a3..e3c7138 100644 --- a/src/activeqt/shared/qaxtypes.h +++ b/src/activeqt/shared/qaxtypes.h @@ -89,6 +89,9 @@ extern QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName extern bool QVariantToVoidStar(const QVariant &var, void *data, const QByteArray &typeName, uint type = 0); extern void clearVARIANT(VARIANT *var); +#define QAX_INPROC_SERVER (0x51540001) +#define QAX_OUTPROC_SERVER (0x51540002) + QT_END_NAMESPACE #endif // QT_NO_WIN_ACTIVEQT -- cgit v0.12 From ed6e0d67211938de7bcba844519d5bad8d2965b6 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 31 Jul 2009 15:30:12 +0200 Subject: Export symbol used in QtGui. Reviewed-by: Kent Hansen --- src/corelib/statemachine/qstatemachine_p.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 5d8c788..387e42e 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -214,7 +214,11 @@ public: f_cloneEvent cloneEvent; }; - static const Handler *handler; + static +#ifndef QT_BUILD_INTERNAL // otherwise Q_AUTOTEST_EXPORT exports it all + Q_CORE_EXPORT +#endif + const Handler *handler; }; QT_END_NAMESPACE -- cgit v0.12 From 2cadc571339d4abee6d7cfb0da08e3119d934524 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 31 Jul 2009 15:52:55 +0200 Subject: Doc: Use new APIs in example and correct documentation regarding replacement. --- doc/src/examples/collidingmice-example.qdoc | 4 ++-- examples/graphicsview/collidingmice/mouse.cpp | 4 ++-- src/gui/graphicsview/qgraphicsitem.cpp | 31 +++++++++++++++++++++++---- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/doc/src/examples/collidingmice-example.qdoc b/doc/src/examples/collidingmice-example.qdoc index 5b124f9..f627fbf 100644 --- a/doc/src/examples/collidingmice-example.qdoc +++ b/doc/src/examples/collidingmice-example.qdoc @@ -95,11 +95,11 @@ the global qrand() function which is a thread-safe version of the standard C++ rand() function. - Then we call the \l {QGraphicsItem::rotate()}{rotate()} function + Then we call the \l {QGraphicsItem::setRotation()}{setRotation()} function inherited from QGraphicsItem. Items live in their own local coordinate system. Their coordinates are usually centered around (0, 0), and this is also the center for all transformations. By - calling the item's \l {QGraphicsItem::rotate()}{rotate()} function + calling the item's \l {QGraphicsItem::setRotation()}{setRotation()} function we alter the direction in which the mouse will start moving. When the QGraphicsScene decides to advance the scene a frame it will call diff --git a/examples/graphicsview/collidingmice/mouse.cpp b/examples/graphicsview/collidingmice/mouse.cpp index c6a67b1..4cc29dd 100644 --- a/examples/graphicsview/collidingmice/mouse.cpp +++ b/examples/graphicsview/collidingmice/mouse.cpp @@ -64,7 +64,7 @@ Mouse::Mouse() : angle(0), speed(0), mouseEyeDirection(0), color(qrand() % 256, qrand() % 256, qrand() % 256) { - rotate(qrand() % (360 * 16)); + setRotation(qrand() % (360 * 16)); } //! [0] @@ -195,7 +195,7 @@ void Mouse::advance(int step) qreal dx = ::sin(angle) * 10; mouseEyeDirection = (qAbs(dx / 5) < 1) ? 0 : dx / 5; - rotate(dx); + setRotation(rotation() + dx); setPos(mapToParent(0, -(3 + sin(speed) * 3))); } //! [11] diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index eaf9896..a4eca4d 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3535,7 +3535,13 @@ void QGraphicsItem::resetTransform() /*! \obsolete - Use setRotation() instead + Use + + \code + setRotation(rotation() + angle); + \endcode + + instead. Rotates the current item transformation \a angle degrees clockwise around its origin. To translate around an arbitrary point (x, y), you need to @@ -3555,7 +3561,13 @@ void QGraphicsItem::rotate(qreal angle) /*! \obsolete - Use setScale() instead + Use + + \code + setTransform(QTransform::fromScale(sx, sy), true); + \encode + + instead. Scales the current item transformation by (\a sx, \a sy) around its origin. To scale from an arbitrary point (x, y), you need to combine @@ -3575,7 +3587,13 @@ void QGraphicsItem::scale(qreal sx, qreal sy) /*! \obsolete - Use setTransform() instead. + Use + + \code + setTransform(QTransform().shear(sh, sv), true); + \endcode + + instead. Shears the current item transformation by (\a sh, \a sv). @@ -3589,7 +3607,12 @@ void QGraphicsItem::shear(qreal sh, qreal sv) /*! \obsolete - Use setPos() or setTransformOriginPoint() instead. + Use setPos() or setTransformOriginPoint() instead. For identical + behavior, use + + \code + setTransform(QTransform::fromTranslate(dx, dy), true); + \endcode Translates the current item transformation by (\a dx, \a dy). -- cgit v0.12 From c6cdfcb02d74f726e79ead9f890f294587a7c63c Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 31 Jul 2009 15:55:41 +0200 Subject: Doc: Use new APIs in example and correct documentation regarding replacement. --- src/gui/graphicsview/qgraphicsitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index a4eca4d..a047e6a 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3565,7 +3565,7 @@ void QGraphicsItem::rotate(qreal angle) \code setTransform(QTransform::fromScale(sx, sy), true); - \encode + \endcode instead. -- cgit v0.12 From c57ed134a536c177d1774d9272ca187bdfb28e6b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 31 Jul 2009 16:16:01 +0200 Subject: Revert "Fix QFormLayout which allowed fields to be smaller that their minimum size" This reverts commit 244f5ee9c2c34ddee200e4d5cdc1345762a5901b. Valgrind complains about the label fields that are not inisialized yet, and indeed. They are initialized right after, and need the maxLabelWidth to be computed. This is a chicken and egg problem difficult to solve, so I rather revert the change as the bug is not critical --- src/gui/kernel/qformlayout.cpp | 6 +----- tests/auto/qformlayout/tst_qformlayout.cpp | 30 ------------------------------ 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/src/gui/kernel/qformlayout.cpp b/src/gui/kernel/qformlayout.cpp index 0b7656f..de33f93 100644 --- a/src/gui/kernel/qformlayout.cpp +++ b/src/gui/kernel/qformlayout.cpp @@ -689,16 +689,12 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) // are split. maxLabelWidth = 0; if (!wrapAllRows) { - int maxFieldMinWidth = 0; //the maximum minimum size of the field for (int i = 0; i < rr; ++i) { const QFormLayoutItem *label = m_matrix(i, 0); const QFormLayoutItem *field = m_matrix(i, 1); - if (label && field && label->sideBySide) + if (label && (label->sizeHint.width() + (field ? field->minSize.width() : 0) <= width)) maxLabelWidth = qMax(maxLabelWidth, label->sizeHint.width()); - if (field) - maxFieldMinWidth = qMax(maxFieldMinWidth, field->minSize.width() + field->sbsHSpace); } - maxLabelWidth = qMin(maxLabelWidth, width - maxFieldMinWidth); } else { maxLabelWidth = width; } diff --git a/tests/auto/qformlayout/tst_qformlayout.cpp b/tests/auto/qformlayout/tst_qformlayout.cpp index 74384a9..9806557 100644 --- a/tests/auto/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/qformlayout/tst_qformlayout.cpp @@ -125,7 +125,6 @@ private slots: Qt::Orientations expandingDirections() const; */ - void fieldMinimumSize(); }; tst_QFormLayout::tst_QFormLayout() @@ -906,35 +905,6 @@ void tst_QFormLayout::layoutAlone() QTest::qWait(500); } - -void tst_QFormLayout::fieldMinimumSize() -{ - //check that the field with is bigger than its minimumSizeHint for any size of the widget - // even if the label with is not fixed - QWidget w; - QFormLayout layout; - layout.setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); - w.setLayout(&layout); - QLabel label1("Here is a strange test case"); - label1.setWordWrap(true); - QLabel label2("Here is another label"); - label2.setWordWrap(true); - QLabel shortLabel("short"); - QLabel longLabel("Quite long label"); - layout.addRow(&label1, &shortLabel); - layout.addRow(&label2, &longLabel); - w.show(); - int width = w.size().width() + 9; - - do { - w.resize(width, w.size().height()); - layout.activate(); - QVERIFY(shortLabel.size().width() >= shortLabel.minimumSizeHint().width()); - QVERIFY(longLabel.size().width() >= longLabel.minimumSizeHint().width()); - width -= 3; - } while(width >= w.minimumSizeHint().width()); -} - QTEST_MAIN(tst_QFormLayout) #include "tst_qformlayout.moc" -- cgit v0.12 From 5aed3db0a4084f470769ad4b965001f17b878c79 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sat, 1 Aug 2009 12:04:25 +0200 Subject: Compilare necessus est --- tools/assistant/lib/qhelpprojectdata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assistant/lib/qhelpprojectdata.cpp b/tools/assistant/lib/qhelpprojectdata.cpp index 5df0426..9412f1c 100644 --- a/tools/assistant/lib/qhelpprojectdata.cpp +++ b/tools/assistant/lib/qhelpprojectdata.cpp @@ -289,7 +289,7 @@ void QHelpProjectDataPrivate::addMatchingFiles(const QString &pattern) bool matchFound = false; #ifdef Q_OS_WIN - Qt::CaseSensitivity cs = Qt::CaseInSensitive; + Qt::CaseSensitivity cs = Qt::CaseInsensitive; #else Qt::CaseSensitivity cs = Qt::CaseSensitive; #endif -- cgit v0.12 From 9ce6d885f4c141fabce1427ff776e02bdb6846ae Mon Sep 17 00:00:00 2001 From: Stian Sandvik Thomassen Date: Mon, 3 Aug 2009 09:47:56 +1000 Subject: Doc: Replaced QSet with QSet in QList::fromSet() example We don't implement qHash() for double, so let's not use QSet in the documentation. --- doc/src/snippets/code/src_corelib_tools_qlistdata.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp b/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp index 7d75e1b..3b9a756 100644 --- a/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp +++ b/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp @@ -190,10 +190,10 @@ QVector vect = list.toVector(); //! [23] -QSet set; -set << 20.0 << 30.0 << 40.0 << ... << 70.0; +QSet set; +set << 20 << 30 << 40 << ... << 70; -QList list = QList::fromSet(set); +QList list = QList::fromSet(set); qSort(list); //! [23] -- cgit v0.12 From c386e433ff9e55bcf65abf9eee665ad4237fbd33 Mon Sep 17 00:00:00 2001 From: Bill King Date: Mon, 3 Aug 2009 14:11:07 +1000 Subject: Fixes casing fails for databases that have variable casing support. --- .../qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index 1e23d3d..d836486 100644 --- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -930,13 +930,15 @@ void tst_QSqlRelationalTableModel::casing() QSqlQuery q(db); QVERIFY_SQL( q, exec("create table " + qTableName("CASETEST1", db.driver()).toUpper() + " (id int not null primary key, name varchar(20), title_key int, another_title_key int)")); + + if( !q.exec("create table " + qTableName("casetest1", db.driver()) + + " (ident int not null primary key, name varchar(20), title_key int)")) + QSKIP("The casing test for this database is irrelevant since this database does not treat different cases as separate entities", SkipAll); + QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(1, 'harry', 1, 2)")); QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(2, 'trond', 2, 1)")); QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(3, 'vohi', 1, 2)")); QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(4, 'boris', 2, 2)")); - - QVERIFY_SQL( q, exec("create table " + qTableName("casetest1", db.driver()) + - " (ident int not null primary key, name varchar(20), title_key int)")); QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(1, 'jerry', 1)")); QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(2, 'george', 2)")); QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(4, 'kramer', 2)")); -- cgit v0.12 From f083e9c9aa59790695136811181f5f455d1c9dad Mon Sep 17 00:00:00 2001 From: Bill King Date: Mon, 3 Aug 2009 14:21:06 +1000 Subject: Fix more database autotests. --- tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp | 6 ++++-- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp index 360c3b7..c449140 100644 --- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp +++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp @@ -546,7 +546,7 @@ void tst_Q3SqlCursor::unicode() else QFAIL( QString( "Strings differ at position %1: orig: %2, db: %3" ).arg( i ).arg( utf8str[ i ].unicode(), 0, 16 ).arg( res[ i ].unicode(), 0, 16 ) ); } - if(db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QDB2")) + if((db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QDB2")) && res != utf8str) QEXPECT_FAIL("", "See above message", Continue); QVERIFY( res == utf8str ); } @@ -722,7 +722,9 @@ void tst_Q3SqlCursor::updateNoPK() // Sqlite returns 2, don't ask why. QVERIFY(cur.update() != 0); QString expect = "update " + qTableName("qtestPK") + - " set id = 1 , name = NULL , num = NULL where " + qTableName("qtestPK") + ".id" + " set "+db.driver()->escapeIdentifier("id", QSqlDriver::FieldName)+" = 1 , " + +db.driver()->escapeIdentifier("name", QSqlDriver::FieldName)+" = NULL , " + +db.driver()->escapeIdentifier("num", QSqlDriver::FieldName)+" = NULL where " + qTableName("qtestPK") + ".id" " IS NULL and " + qTableName("qtestPK") + ".name IS NULL and " + qTableName("qtestPK") + ".num IS NULL"; if (!db.driver()->hasFeature(QSqlDriver::PreparedQueries)) { diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 025e895..ff62741 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -2009,8 +2009,8 @@ void tst_QSqlDatabase::mysql_multiselect() QVERIFY_SQL(q, exec("select version()")); QVERIFY_SQL(q, next()); QString version=tst_Databases::getMySqlVersion( db ); - int ver=version.section(QChar::fromLatin1('.'),0,1).toDouble(); - if (ver >= 4.1) + double ver=version.section(QChar::fromLatin1('.'),0,1).toDouble(); + if (ver < 4.1) QSKIP("Test requires MySQL >= 4.1", SkipSingle); QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtest") + "; SELECT * FROM " + qTableName("qtest"))); -- cgit v0.12 From 45005c68c6effa41108ef55cd10a84f5977f79a0 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 3 Aug 2009 09:19:31 +0200 Subject: Ensure that the dash offset is reset when using drawLines() When using drawLines() then the dash offset was remembering where it was on the previous line. This is not what the behaviour should be as it should be starting with the same offset for each line. Reviewed-by: Samuel --- src/gui/painting/qpaintengine_raster.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 69e490a..74456dd 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1736,6 +1736,8 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) const QLineF *lines = reinterpret_cast(path.points()); for (int i = 0; i < lineCount; ++i) { + if (path.shape() == QVectorPath::LinesHint) + dashOffset = s->lastPen.dashOffset(); if (lines[i].p1() == lines[i].p2()) { if (s->lastPen.capStyle() != Qt::FlatCap) { QPointF p = lines[i].p1(); @@ -3454,8 +3456,8 @@ void QRasterPaintEngine::drawLines(const QLine *lines, int lineCount) int m22 = int(s->matrix.m22()); int dx = qFloor(s->matrix.dx() + aliasedCoordinateDelta); int dy = qFloor(s->matrix.dy() + aliasedCoordinateDelta); - int dashOffset = int(s->lastPen.dashOffset()); for (int i=0; ilastPen.dashOffset()); if (s->flags.int_xform) { const QLine &l = lines[i]; int x1 = l.x1() * m11 + dx; @@ -3554,8 +3556,8 @@ void QRasterPaintEngine::drawLines(const QLineF *lines, int lineCount) ? LineDrawNormal : LineDrawIncludeLastPixel; - int dashOffset = int(s->lastPen.dashOffset()); for (int i=0; ilastPen.dashOffset()); QLineF line = (lines[i] * s->matrix).translated(aliasedCoordinateDelta, aliasedCoordinateDelta); const QRectF brect(QPointF(line.x1(), line.y1()), QPointF(line.x2(), line.y2())); -- cgit v0.12 From acd156649b1083aeeb400fe8fdbbf4e55ada4bed Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 3 Aug 2009 10:35:37 +0200 Subject: remove constructors that are not useful The constructors that take a list of target states produce hard-to-read code, and they're rarely useful in practice since 99% of transitions take a single target state; so it's better to enforce that setTarget{State,States}() be used instead. --- examples/animation/stickman/lifecycle.cpp | 6 +++-- src/corelib/statemachine/qabstracttransition.cpp | 22 ----------------- src/corelib/statemachine/qabstracttransition.h | 3 --- src/corelib/statemachine/qeventtransition.cpp | 30 ------------------------ src/corelib/statemachine/qeventtransition.h | 5 ---- src/corelib/statemachine/qsignaltransition.cpp | 15 ------------ src/corelib/statemachine/qsignaltransition.h | 3 --- src/corelib/statemachine/qstate.cpp | 6 +++-- src/corelib/statemachine/qstatemachine.cpp | 6 +++-- src/gui/statemachine/qkeyeventtransition.cpp | 13 ---------- src/gui/statemachine/qkeyeventtransition.h | 3 --- src/gui/statemachine/qmouseeventtransition.cpp | 15 ------------ src/gui/statemachine/qmouseeventtransition.h | 4 ---- tests/auto/qstate/tst_qstate.cpp | 5 ++-- tests/auto/qstatemachine/tst_qstatemachine.cpp | 30 ++++++++++-------------- 15 files changed, 28 insertions(+), 138 deletions(-) diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp index c761d87..700916d 100644 --- a/examples/animation/stickman/lifecycle.cpp +++ b/examples/animation/stickman/lifecycle.cpp @@ -56,8 +56,9 @@ public: { } KeyPressTransition(GraphicsView *receiver, Qt::Key key, QAbstractState *target) - : QSignalTransition(receiver, SIGNAL(keyPressed(int)), QList() << target), m_key(key) + : QSignalTransition(receiver, SIGNAL(keyPressed(int))), m_key(key) { + setTargetState(target); } virtual bool eventTest(QEvent *e) @@ -78,8 +79,9 @@ class LightningStrikesTransition: public QEventTransition { public: LightningStrikesTransition(QAbstractState *target) - : QEventTransition(this, QEvent::Timer, QList() << target) + : QEventTransition(this, QEvent::Timer) { + setTargetState(target); qsrand((uint)QDateTime::currentDateTime().toTime_t()); startTimer(1000); } diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp index 0004d3e..3248dcf 100644 --- a/src/corelib/statemachine/qabstracttransition.cpp +++ b/src/corelib/statemachine/qabstracttransition.cpp @@ -153,34 +153,12 @@ QAbstractTransition::QAbstractTransition(QState *sourceState) } /*! - Constructs a new QAbstractTransition object with the given \a targets and \a - sourceState. -*/ -QAbstractTransition::QAbstractTransition(const QList &targets, - QState *sourceState) - : QObject(*new QAbstractTransitionPrivate, sourceState) -{ - setTargetStates(targets); -} - -/*! - \internal -*/ -QAbstractTransition::QAbstractTransition(QAbstractTransitionPrivate &dd, - QState *parent) - : QObject(dd, parent) -{ -} - -/*! \internal */ QAbstractTransition::QAbstractTransition(QAbstractTransitionPrivate &dd, - const QList &targets, QState *parent) : QObject(dd, parent) { - setTargetStates(targets); } /*! diff --git a/src/corelib/statemachine/qabstracttransition.h b/src/corelib/statemachine/qabstracttransition.h index 9ba1f11..8ff3a6e 100644 --- a/src/corelib/statemachine/qabstracttransition.h +++ b/src/corelib/statemachine/qabstracttransition.h @@ -72,7 +72,6 @@ class Q_CORE_EXPORT QAbstractTransition : public QObject Q_PROPERTY(QList targetStates READ targetStates WRITE setTargetStates) public: QAbstractTransition(QState *sourceState = 0); - QAbstractTransition(const QList &targets, QState *sourceState = 0); virtual ~QAbstractTransition(); QState *sourceState() const; @@ -104,8 +103,6 @@ protected: protected: QAbstractTransition(QAbstractTransitionPrivate &dd, QState *parent); - QAbstractTransition(QAbstractTransitionPrivate &dd, - const QList &targets, QState *parent); private: Q_DISABLE_COPY(QAbstractTransition) diff --git a/src/corelib/statemachine/qeventtransition.cpp b/src/corelib/statemachine/qeventtransition.cpp index 3933981..813c960 100644 --- a/src/corelib/statemachine/qeventtransition.cpp +++ b/src/corelib/statemachine/qeventtransition.cpp @@ -153,22 +153,6 @@ QEventTransition::QEventTransition(QObject *object, QEvent::Type type, } /*! - Constructs a new QEventTransition object associated with events of the given - \a type for the given \a object. The transition has the given \a targets and - \a sourceState. -*/ -QEventTransition::QEventTransition(QObject *object, QEvent::Type type, - const QList &targets, - QState *sourceState) - : QAbstractTransition(*new QEventTransitionPrivate, targets, sourceState) -{ - Q_D(QEventTransition); - d->registered = false; - d->object = object; - d->eventType = type; -} - -/*! \internal */ QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QState *parent) @@ -190,20 +174,6 @@ QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object, } /*! - \internal -*/ -QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object, - QEvent::Type type, const QList &targets, - QState *parent) - : QAbstractTransition(dd, targets, parent) -{ - Q_D(QEventTransition); - d->registered = false; - d->object = object; - d->eventType = type; -} - -/*! Destroys this QObject event transition. */ QEventTransition::~QEventTransition() diff --git a/src/corelib/statemachine/qeventtransition.h b/src/corelib/statemachine/qeventtransition.h index b05ffef..0ebca19 100644 --- a/src/corelib/statemachine/qeventtransition.h +++ b/src/corelib/statemachine/qeventtransition.h @@ -62,8 +62,6 @@ class Q_CORE_EXPORT QEventTransition : public QAbstractTransition public: QEventTransition(QState *sourceState = 0); QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = 0); - QEventTransition(QObject *object, QEvent::Type type, - const QList &targets, QState *sourceState = 0); ~QEventTransition(); QObject *eventObject() const; @@ -82,9 +80,6 @@ protected: QEventTransition(QEventTransitionPrivate &dd, QState *parent); QEventTransition(QEventTransitionPrivate &dd, QObject *object, QEvent::Type type, QState *parent); - QEventTransition(QEventTransitionPrivate &dd, QObject *object, - QEvent::Type type, const QList &targets, - QState *parent); private: Q_DISABLE_COPY(QEventTransition) diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp index 389e513..7814699 100644 --- a/src/corelib/statemachine/qsignaltransition.cpp +++ b/src/corelib/statemachine/qsignaltransition.cpp @@ -159,21 +159,6 @@ QSignalTransition::QSignalTransition(QObject *sender, const char *signal, } /*! - Constructs a new signal transition associated with the given \a signal of - the given \a sender. The transition has the given \a targets and \a - sourceState. -*/ -QSignalTransition::QSignalTransition(QObject *sender, const char *signal, - const QList &targets, - QState *sourceState) - : QAbstractTransition(*new QSignalTransitionPrivate, targets, sourceState) -{ - Q_D(QSignalTransition); - d->sender = sender; - d->signal = signal; -} - -/*! Destroys this signal transition. */ QSignalTransition::~QSignalTransition() diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h index 69060ae..415751e 100644 --- a/src/corelib/statemachine/qsignaltransition.h +++ b/src/corelib/statemachine/qsignaltransition.h @@ -62,9 +62,6 @@ public: QSignalTransition(QState *sourceState = 0); QSignalTransition(QObject *sender, const char *signal, QState *sourceState = 0); - QSignalTransition(QObject *sender, const char *signal, - const QList &targets, - QState *sourceState = 0); ~QSignalTransition(); QObject *senderObject() const; diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index 2042288..09d0be0 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -339,7 +339,8 @@ QSignalTransition *QState::addTransition(QObject *sender, const char *signal, return 0; } } - QSignalTransition *trans = new QSignalTransition(sender, signal, QList() << target); + QSignalTransition *trans = new QSignalTransition(sender, signal); + trans->setTargetState(target); addTransition(trans); return trans; } @@ -351,7 +352,8 @@ class UnconditionalTransition : public QAbstractTransition { public: UnconditionalTransition(QAbstractState *target) - : QAbstractTransition(QList() << target) {} + : QAbstractTransition() + { setTargetState(target); } protected: void onTransition(QEvent *) {} bool eventTest(QEvent *) { return true; } diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 5aa5917..9cb1d4d 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1139,7 +1139,8 @@ class InitialTransition : public QAbstractTransition { public: InitialTransition(QAbstractState *target) - : QAbstractTransition(QList() << target) {} + : QAbstractTransition() + { setTargetState(target); } protected: virtual bool eventTest(QEvent *) { return true; } virtual void onTransition(QEvent *) {} @@ -1306,7 +1307,8 @@ class GoToStateTransition : public QAbstractTransition { public: GoToStateTransition(QAbstractState *target) - : QAbstractTransition(QList() << target) {} + : QAbstractTransition() + { setTargetState(target); } protected: void onTransition(QEvent *) { deleteLater(); } bool eventTest(QEvent *) { return true; } diff --git a/src/gui/statemachine/qkeyeventtransition.cpp b/src/gui/statemachine/qkeyeventtransition.cpp index 51b3ccc..21a0736 100644 --- a/src/gui/statemachine/qkeyeventtransition.cpp +++ b/src/gui/statemachine/qkeyeventtransition.cpp @@ -106,19 +106,6 @@ QKeyEventTransition::QKeyEventTransition(QObject *object, QEvent::Type type, } /*! - Constructs a new key event transition for events of the given \a type for - the given \a object, with the given \a key, \a targets and \a sourceState. -*/ -QKeyEventTransition::QKeyEventTransition(QObject *object, QEvent::Type type, - int key, const QList &targets, - QState *sourceState) - : QEventTransition(*new QKeyEventTransitionPrivate, object, type, targets, sourceState) -{ - Q_D(QKeyEventTransition); - d->transition = new QBasicKeyEventTransition(type, key); -} - -/*! Destroys this key event transition. */ QKeyEventTransition::~QKeyEventTransition() diff --git a/src/gui/statemachine/qkeyeventtransition.h b/src/gui/statemachine/qkeyeventtransition.h index f5e8de3..45ae684 100644 --- a/src/gui/statemachine/qkeyeventtransition.h +++ b/src/gui/statemachine/qkeyeventtransition.h @@ -62,9 +62,6 @@ public: QKeyEventTransition(QState *sourceState = 0); QKeyEventTransition(QObject *object, QEvent::Type type, int key, QState *sourceState = 0); - QKeyEventTransition(QObject *object, QEvent::Type type, int key, - const QList &targets, - QState *sourceState = 0); ~QKeyEventTransition(); int key() const; diff --git a/src/gui/statemachine/qmouseeventtransition.cpp b/src/gui/statemachine/qmouseeventtransition.cpp index 0cd096a..dbe50b3 100644 --- a/src/gui/statemachine/qmouseeventtransition.cpp +++ b/src/gui/statemachine/qmouseeventtransition.cpp @@ -112,21 +112,6 @@ QMouseEventTransition::QMouseEventTransition(QObject *object, QEvent::Type type, } /*! - Constructs a new mouse event transition for events of the given \a type for - the given \a object, with the given \a button, \a targets and \a - sourceState. -*/ -QMouseEventTransition::QMouseEventTransition(QObject *object, QEvent::Type type, - Qt::MouseButton button, - const QList &targets, - QState *sourceState) - : QEventTransition(*new QMouseEventTransitionPrivate, object, type, targets, sourceState) -{ - Q_D(QMouseEventTransition); - d->transition = new QBasicMouseEventTransition(type, button); -} - -/*! Destroys this mouse event transition. */ QMouseEventTransition::~QMouseEventTransition() diff --git a/src/gui/statemachine/qmouseeventtransition.h b/src/gui/statemachine/qmouseeventtransition.h index 73ae6c9..a56a554 100644 --- a/src/gui/statemachine/qmouseeventtransition.h +++ b/src/gui/statemachine/qmouseeventtransition.h @@ -63,10 +63,6 @@ public: QMouseEventTransition(QState *sourceState = 0); QMouseEventTransition(QObject *object, QEvent::Type type, Qt::MouseButton button, QState *sourceState = 0); - QMouseEventTransition(QObject *object, QEvent::Type type, - Qt::MouseButton button, - const QList &targets, - QState *sourceState = 0); ~QMouseEventTransition(); Qt::MouseButton button() const; diff --git a/tests/auto/qstate/tst_qstate.cpp b/tests/auto/qstate/tst_qstate.cpp index 78b9853..43ea7fe 100644 --- a/tests/auto/qstate/tst_qstate.cpp +++ b/tests/auto/qstate/tst_qstate.cpp @@ -250,8 +250,9 @@ class EventTestTransition: public QAbstractTransition { public: EventTestTransition(QEvent::Type type, QState *targetState) - : QAbstractTransition(QList() << targetState), m_type(type) - { + : QAbstractTransition(), m_type(type) + { + setTargetState(targetState); } protected: diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 32812e2..97115bb 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -226,7 +226,8 @@ class TestTransition : public QAbstractTransition { public: TestTransition(QAbstractState *target) - : QAbstractTransition(QList() << target) {} + : QAbstractTransition() + { setTargetState(target); } QList triggers; protected: virtual bool eventTest(QEvent *) { @@ -249,7 +250,8 @@ class EventTransition : public QAbstractTransition { public: EventTransition(QEvent::Type type, QAbstractState *target, QState *parent = 0) - : QAbstractTransition(QList() << target, parent), m_type(type) {} + : QAbstractTransition(parent), m_type(type) + { setTargetState(target); } protected: virtual bool eventTest(QEvent *e) { return (e->type() == m_type); @@ -1514,7 +1516,8 @@ class StringTransition : public QAbstractTransition { public: StringTransition(const QString &value, QAbstractState *target) - : QAbstractTransition(QList() << target), m_value(value) {} + : QAbstractTransition(), m_value(value) + { setTargetState(target); } protected: virtual bool eventTest(QEvent *e) @@ -1737,7 +1740,8 @@ public: : QSignalTransition(sourceState) {} TestSignalTransition(QObject *sender, const char *signal, QAbstractState *target) - : QSignalTransition(sender, signal, QList() << target) {} + : QSignalTransition(sender, signal) + { setTargetState(target); } QVariantList argumentsReceived() const { return m_args; } @@ -2022,20 +2026,15 @@ void tst_QStateMachine::signalTransitions() void tst_QStateMachine::eventTransitions() { QPushButton button; - for (int x = 0; x < 2; ++x) { + { QStateMachine machine; QState *s0 = new QState(&machine); QFinalState *s1 = new QFinalState(&machine); QMouseEventTransition *trans; - if (x == 0) { - trans = new QMouseEventTransition(&button, QEvent::MouseButtonPress, Qt::LeftButton); - QCOMPARE(trans->targetState(), (QAbstractState*)0); - trans->setTargetState(s1); - } else { - trans = new QMouseEventTransition(&button, QEvent::MouseButtonPress, - Qt::LeftButton, QList() << s1); - } + trans = new QMouseEventTransition(&button, QEvent::MouseButtonPress, Qt::LeftButton); + QCOMPARE(trans->targetState(), (QAbstractState*)0); + trans->setTargetState(s1); QCOMPARE(trans->eventType(), QEvent::MouseButtonPress); QCOMPARE(trans->button(), Qt::LeftButton); QCOMPARE(trans->targetState(), (QAbstractState*)s1); @@ -2071,7 +2070,7 @@ void tst_QStateMachine::eventTransitions() QTest::mousePress(&button2, Qt::LeftButton); QTRY_COMPARE(finishedSpy.count(), 4); } - for (int x = 0; x < 3; ++x) { + for (int x = 0; x < 2; ++x) { QStateMachine machine; QState *s0 = new QState(&machine); QFinalState *s1 = new QFinalState(&machine); @@ -2087,9 +2086,6 @@ void tst_QStateMachine::eventTransitions() } else if (x == 1) { trans = new QEventTransition(&button, QEvent::MouseButtonPress); trans->setTargetState(s1); - } else { - trans = new QEventTransition(&button, QEvent::MouseButtonPress, - QList() << s1); } QCOMPARE(trans->eventObject(), (QObject*)&button); QCOMPARE(trans->eventType(), QEvent::MouseButtonPress); -- cgit v0.12 From 34e272ae3b89237f5aa92a089fdd99b5682b238b Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 3 Aug 2009 10:44:15 +0200 Subject: export QStateMachinePrivate symbols 1) it's needed for the Declarative UI integration and 2) it hopefully fixes the build on Windows. --- src/corelib/statemachine/qstatemachine_p.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 387e42e..f0f74d6 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -79,7 +79,7 @@ class QAbstractAnimation; #endif class QStateMachine; -class Q_AUTOTEST_EXPORT QStateMachinePrivate : public QStatePrivate +class Q_CORE_EXPORT QStateMachinePrivate : public QStatePrivate { Q_DECLARE_PUBLIC(QStateMachine) public: @@ -214,11 +214,7 @@ public: f_cloneEvent cloneEvent; }; - static -#ifndef QT_BUILD_INTERNAL // otherwise Q_AUTOTEST_EXPORT exports it all - Q_CORE_EXPORT -#endif - const Handler *handler; + static const Handler *handler; }; QT_END_NAMESPACE -- cgit v0.12 From 4e693c01a62701f9376316a21b3d133a05dcc1e6 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 15 Jul 2009 09:07:37 +0200 Subject: Fix compilation of webkit with mingw --- mkspecs/features/moc.prf | 3 --- 1 file changed, 3 deletions(-) diff --git a/mkspecs/features/moc.prf b/mkspecs/features/moc.prf index 62d9092..c5af298 100644 --- a/mkspecs/features/moc.prf +++ b/mkspecs/features/moc.prf @@ -15,10 +15,7 @@ WIN_INCLUDETEMP= win32:count($$list($$INCPATH), 40, >) { INCLUDETEMP = $$MOC_DIR/mocinclude.tmp - # Remove any existing mocinclude.tmp when qmake runs WIN_INCLUDETEMP=$$INCLUDETEMP - WIN_INCLUDETEMP~=s,/,\,g - system($$QMAKE_DEL_FILE $$WIN_INCLUDETEMP > NUL 2>&1) EOC = $$escape_expand(\n\t) -- cgit v0.12 From 232346cb33bd99016ba4210a95eeca45d24bf1b7 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 30 Jul 2009 12:50:25 +0200 Subject: Add qglpixelbuffer_p.h to opengl.pro so Creator finds it Reviewed-By: Trustme --- src/opengl/opengl.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index c92b8cf..868484e 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -20,6 +20,7 @@ HEADERS += qgl.h \ qgl_p.h \ qglcolormap.h \ qglpixelbuffer.h \ + qglpixelbuffer_p.h \ qglframebufferobject.h \ qglextensions_p.h -- cgit v0.12 From fc34e1cbaeeaa54b15d28edfab16d5f302334f70 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 31 Jul 2009 17:30:11 +0200 Subject: Fix build on X11/EGL without XRender Reviewed-by: Trustme --- src/opengl/qgl_x11egl.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 5ab3647..ed9930f 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -299,6 +299,7 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, int matchingCount = 0; chosenVisualInfo = XGetVisualInfo(x11Info().display(), VisualIDMask, &vi, &matchingCount); if (chosenVisualInfo) { +#if !defined(QT_NO_XRENDER) if (useArgbVisual) { // Check to make sure the visual provided by EGL is ARGB XRenderPictFormat *format; @@ -312,8 +313,9 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, nativeVisualId, (int)qeglCtx->config()); vi.visualid = 0; } - } - else { + } else +#endif + { qDebug("Using opaque X Visual ID (%d) provided by EGL", (int)vi.visualid); vi = *chosenVisualInfo; } -- cgit v0.12 From f9f91a3ce45bb3ae0d1e47337791eaf373a0e734 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 31 Jul 2009 17:33:39 +0200 Subject: Make QEglProperties::setVisualFormat() read alpha for visual Reviewed-by: Trustme --- src/gui/egl/qegl_x11.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index be89efe..daaa4ba 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -125,7 +125,17 @@ void QEglProperties::setVisualFormat(const QX11Info *xinfo) setValue(EGL_RED_SIZE, countBits(visual->red_mask)); setValue(EGL_GREEN_SIZE, countBits(visual->green_mask)); setValue(EGL_BLUE_SIZE, countBits(visual->blue_mask)); - setValue(EGL_ALPHA_SIZE, 0); // XXX + + EGLint alphaBits = 0; +#if !defined(QT_NO_XRENDER) + XRenderPictFormat *format; + format = XRenderFindVisualFormat(xinfo->display(), visual); + if (format && (format->type == PictTypeDirect) && format->direct.alphaMask) { + alphaBits = countBits(format->direct.alphaMask); + qDebug("QEglProperties::setVisualFormat() - visual's alphaMask is %d", alphaBits); + } +#endif + setValue(EGL_ALPHA_SIZE, alphaBits); } extern const QX11Info *qt_x11Info(const QPaintDevice *pd); -- cgit v0.12 From 23045677bc466b91619495809c97001f341a3d6c Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Mon, 3 Aug 2009 11:45:27 +0200 Subject: Add a constructor to QEglProperties which takes an EGLConfig The constructor then extracts all the attributes from the config. Useful for dumping all the attributes for a particular config to qDebug(). --- src/gui/egl/qeglproperties.cpp | 14 ++++++++++++++ src/gui/egl/qeglproperties_p.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp index e0ae8a6..fefd070 100644 --- a/src/gui/egl/qeglproperties.cpp +++ b/src/gui/egl/qeglproperties.cpp @@ -46,12 +46,26 @@ QT_BEGIN_NAMESPACE #include #include +#include "qegl_p.h" + + // Initialize a property block. QEglProperties::QEglProperties() { props.append(EGL_NONE); } +QEglProperties::QEglProperties(EGLConfig cfg) +{ + props.append(EGL_NONE); + for (int name = 0x3020; name <= 0x304F; ++name) { + EGLint value; + if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::defaultDisplay(0), cfg, name, &value)) + setValue(name, value); + } + eglGetError(); // Clear the error state. +} + // Fetch the current value associated with a property. int QEglProperties::value(int name) const { diff --git a/src/gui/egl/qeglproperties_p.h b/src/gui/egl/qeglproperties_p.h index 81af4cd..bcdc657 100644 --- a/src/gui/egl/qeglproperties_p.h +++ b/src/gui/egl/qeglproperties_p.h @@ -107,6 +107,7 @@ class Q_GUI_EXPORT QEglProperties { public: QEglProperties(); + QEglProperties(EGLConfig); QEglProperties(const QEglProperties& other) : props(other.props) {} ~QEglProperties() {} -- cgit v0.12 From 1b469ac64cf81476436009aef66009c30335a01c Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Mon, 3 Aug 2009 11:54:33 +0200 Subject: Add EGL_BIND_TO_TEXTURE_RGBA to QEglProperties::reduceConfiguration() Now reduceConfiguration will add a new step of reduction which removes EGL_BIND_TO_TEXTURE_RGBA and replaces it with EGL_BIND_TO_TEXTURE_RGB. --- src/gui/egl/qeglproperties.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp index fefd070..358ebcc 100644 --- a/src/gui/egl/qeglproperties.cpp +++ b/src/gui/egl/qeglproperties.cpp @@ -229,12 +229,21 @@ bool QEglProperties::reduceConfiguration() removeValue(EGL_SAMPLES); return true; } - if (removeValue(EGL_ALPHA_SIZE)) + if (removeValue(EGL_ALPHA_SIZE)) { +#if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB) + if (removeValue(EGL_BIND_TO_TEXTURE_RGBA)) + setValue(EGL_BIND_TO_TEXTURE_RGB, TRUE); +#endif return true; + } if (removeValue(EGL_STENCIL_SIZE)) return true; if (removeValue(EGL_DEPTH_SIZE)) return true; +#if defined(EGL_BIND_TO_TEXTURE_RGB) + if (removeValue(EGL_BIND_TO_TEXTURE_RGB)) + return true; +#endif return false; } -- cgit v0.12 From 128717b171f01c82e5f0fb83f5923d4f7b9cfc10 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 31 Jul 2009 17:35:34 +0200 Subject: Remove currentChildBeingDeleted from QObjectPrivate. When a child is being deleted by its parent, the child should not notify the parent (of that which it already knows anyway). We did that by keeping a pointer to the child being deleted. Much simpler to simply orphan the child. Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qobject.cpp | 29 ++++++++++++----------------- src/corelib/kernel/qobject_p.h | 5 +---- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index ab91799..7bf209a 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -123,7 +123,7 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) } QObjectPrivate::QObjectPrivate(int version) - : threadData(0), currentSender(0), currentChildBeingDeleted(0), connectionLists(0), senders(0) + : threadData(0), currentSender(0), declarativeData(0), connectionLists(0), senders(0) { if (version != QObjectPrivateVersion) qFatal("Cannot mix incompatible Qt libraries"); @@ -1859,12 +1859,13 @@ void QObjectPrivate::deleteChildren() // don't use qDeleteAll as the destructor of the child might // delete siblings for (int i = 0; i < children.count(); ++i) { - currentChildBeingDeleted = children.at(i); + QObject *child = children.at(i); children[i] = 0; - delete currentChildBeingDeleted; + if (child) + child->d_func()->parent = 0; + delete child; } children.clear(); - currentChildBeingDeleted = 0; wasDeleted = reallyWasDeleted; } @@ -1875,20 +1876,14 @@ void QObjectPrivate::setParent_helper(QObject *o) return; if (parent) { QObjectPrivate *parentD = parent->d_func(); - if (parentD->wasDeleted && wasDeleted - && parentD->currentChildBeingDeleted == q) { - // don't do anything since QObjectPrivate::deleteChildren() already - // cleared our entry in parentD->children. + const int index = parentD->children.indexOf(q); + if (parentD->wasDeleted) { + parentD->children[index] = 0; } else { - const int index = parentD->children.indexOf(q); - if (parentD->wasDeleted) { - parentD->children[index] = 0; - } else { - parentD->children.removeAt(index); - if (sendChildEvents && parentD->receiveChildEvents) { - QChildEvent e(QEvent::ChildRemoved, q); - QCoreApplication::sendEvent(parent, &e); - } + parentD->children.removeAt(index); + if (sendChildEvents && parentD->receiveChildEvents) { + QChildEvent e(QEvent::ChildRemoved, q); + QCoreApplication::sendEvent(parent, &e); } } } diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index e908753..0b41c9a 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -125,10 +125,7 @@ public: // object currently activating the object Sender *currentSender; - union { - QObject *currentChildBeingDeleted; - QDeclarativeData *declarativeData; - }; + QDeclarativeData *declarativeData; bool isSender(const QObject *receiver, const char *signal) const; QObjectList receiverList(const char *signal) const; -- cgit v0.12 From 463df7e4a6dc7c11716e27ca5de9ebeb61940990 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 3 Aug 2009 13:18:36 +0200 Subject: Autotest: disable the pointer-tracking tests in 4.5 The functionality these tests tested was broken in 4.5 and has been disabled. Therefore, these tests simply cannot pass. It's fixed in 4.6. --- tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index a11164f..697473e 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -952,6 +952,7 @@ void tst_QSharedPointer::invalidConstructs_data() "QSharedPointer b;\n" "if (a + b) return;"; +#if QT_VERSION >= 0x040600 // two objects with the same pointer QTest::newRow("same-pointer") << &QTest::QExternalTest::tryRunFail @@ -965,6 +966,7 @@ void tst_QSharedPointer::invalidConstructs_data() << "Data *aData = new Data;\n" "QSharedPointer ptr1 = QSharedPointer(aData);" "ptr1 = QSharedPointer(aData);"; +#endif // any type of cast for unrelated types: // (we have no reinterpret_cast) -- cgit v0.12 From 1f61ac3f28e8d2a765d12dea0f364cdd8082b7e1 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 3 Aug 2009 13:30:03 +0200 Subject: Fixed warnings on phonon/ds9 with mingw (gcc 4) Reviewed-by: Trustme --- src/3rdparty/phonon/ds9/abstractvideorenderer.cpp | 4 ++-- src/3rdparty/phonon/ds9/fakesource.cpp | 2 +- src/3rdparty/phonon/ds9/iodevicereader.cpp | 2 +- src/3rdparty/phonon/ds9/mediagraph.cpp | 8 +++++--- src/3rdparty/phonon/ds9/mediaobject.cpp | 7 ++++--- src/3rdparty/phonon/ds9/qbasefilter.cpp | 7 ++++--- src/3rdparty/phonon/ds9/qmeminputpin.cpp | 7 ++++--- src/3rdparty/phonon/ds9/qpin.cpp | 8 ++++---- src/3rdparty/phonon/ds9/videorenderer_soft.cpp | 6 +++--- 9 files changed, 28 insertions(+), 23 deletions(-) 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/fakesource.cpp b/src/3rdparty/phonon/ds9/fakesource.cpp index a4d4640..4dce138 100644 --- a/src/3rdparty/phonon/ds9/fakesource.cpp +++ b/src/3rdparty/phonon/ds9/fakesource.cpp @@ -29,7 +29,7 @@ namespace Phonon namespace DS9 { static WAVEFORMATEX g_defaultWaveFormat = {WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0}; - static VIDEOINFOHEADER2 g_defaultVideoInfo = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, {sizeof(BITMAPINFOHEADER), 1, 1, 1, 0, 0, 0, 0, 0, 0, 0} }; + static 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)}; diff --git a/src/3rdparty/phonon/ds9/iodevicereader.cpp b/src/3rdparty/phonon/ds9/iodevicereader.cpp index 38c983b..a885a69 100644 --- a/src/3rdparty/phonon/ds9/iodevicereader.cpp +++ b/src/3rdparty/phonon/ds9/iodevicereader.cpp @@ -167,7 +167,7 @@ namespace Phonon oldSize = currentBufferSize(); } - DWORD bytesRead = qMin(currentBufferSize(), int(length)); + int bytesRead = qMin(currentBufferSize(), int(length)); { QWriteLocker locker(&m_lock); qMemCopy(buffer, m_buffer.data(), bytesRead); diff --git a/src/3rdparty/phonon/ds9/mediagraph.cpp b/src/3rdparty/phonon/ds9/mediagraph.cpp index 31a0622..7b10176 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), @@ -537,7 +539,7 @@ 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)); } } @@ -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 } } diff --git a/src/3rdparty/phonon/ds9/mediaobject.cpp b/src/3rdparty/phonon/ds9/mediaobject.cpp index df42011..10782c2 100644 --- a/src/3rdparty/phonon/ds9/mediaobject.cpp +++ b/src/3rdparty/phonon/ds9/mediaobject.cpp @@ -786,15 +786,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; } } } diff --git a/src/3rdparty/phonon/ds9/qbasefilter.cpp b/src/3rdparty/phonon/ds9/qbasefilter.cpp index 95cab92..c950c41 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; @@ -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; diff --git a/src/3rdparty/phonon/ds9/qmeminputpin.cpp b/src/3rdparty/phonon/ds9/qmeminputpin.cpp index dca99db..865b8af 100644 --- a/src/3rdparty/phonon/ds9/qmeminputpin.cpp +++ b/src/3rdparty/phonon/ds9/qmeminputpin.cpp @@ -137,7 +137,8 @@ namespace Phonon return E_POINTER; } - if (*alloc = memoryAllocator(true)) { + *alloc = memoryAllocator(true); + if (*alloc) { return S_OK; } @@ -294,7 +295,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 +325,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/qpin.cpp b/src/3rdparty/phonon/ds9/qpin.cpp index 68a4ec0..d14876b 100644 --- a/src/3rdparty/phonon/ds9/qpin.cpp +++ b/src/3rdparty/phonon/ds9/qpin.cpp @@ -91,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); @@ -145,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_parent(parent), m_flushing(false), m_refCount(1), m_connected(0), m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType), - m_flushing(false) + m_memAlloc(0) { Q_ASSERT(m_parent); m_parent->addPin(this); diff --git a/src/3rdparty/phonon/ds9/videorenderer_soft.cpp b/src/3rdparty/phonon/ds9/videorenderer_soft.cpp index 2112267..cf5ce96 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 @@ -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); -- cgit v0.12 From dd9bedfd5e2098781faea8fdebc919d65858f13c Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Mon, 3 Aug 2009 13:32:29 +0200 Subject: Warning -- Reviewed-by: TrustMe --- src/svg/qsvgstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index 3682f47..6ed3dc2 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -206,8 +206,8 @@ QSvgFontStyle::QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc) } QSvgFontStyle::QSvgFontStyle() - : m_doc(0) - , m_svgFont(0) + : m_svgFont(0) + , m_doc(0) , m_familySet(0) , m_sizeSet(0) , m_styleSet(0) -- cgit v0.12 From a7b422e7ea439f4ca4eb7159fa33f679311b4fe2 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Mon, 3 Aug 2009 13:40:56 +0200 Subject: Fix compilation and warning Reviewed-by: TrustMe --- demos/sub-attaq/custompropertyanimation.cpp | 2 +- demos/sub-attaq/states.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/demos/sub-attaq/custompropertyanimation.cpp b/demos/sub-attaq/custompropertyanimation.cpp index 9282f42..27a4eba 100644 --- a/demos/sub-attaq/custompropertyanimation.cpp +++ b/demos/sub-attaq/custompropertyanimation.cpp @@ -96,7 +96,7 @@ void CustomPropertyAnimation::updateState(QAbstractAnimation::State oldState, QA setKeyValues(values); } - if (animProp && !startValue().isValid() && currentTime() == 0 + if ((animProp && !startValue().isValid() && currentTime() == 0) || (currentTime() == duration() && currentLoop() == (loopCount() - 1))) { setStartValue(def); } diff --git a/demos/sub-attaq/states.cpp b/demos/sub-attaq/states.cpp index d63737f..d6c0b5a 100644 --- a/demos/sub-attaq/states.cpp +++ b/demos/sub-attaq/states.cpp @@ -269,9 +269,10 @@ void UpdateScoreState::onEntry(QEvent *e) /** Win transition */ UpdateScoreTransition::UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target) - : QSignalTransition(scene,SIGNAL(subMarineDestroyed(int)), QList() << target), + : QSignalTransition(scene,SIGNAL(subMarineDestroyed(int))), game(game), scene(scene) { + setTargetState(target); } bool UpdateScoreTransition::eventTest(QEvent *event) @@ -288,9 +289,10 @@ bool UpdateScoreTransition::eventTest(QEvent *event) /** Win transition */ WinTransition::WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target) - : QSignalTransition(scene,SIGNAL(allSubMarineDestroyed(int)), QList() << target), + : QSignalTransition(scene,SIGNAL(allSubMarineDestroyed(int))), game(game), scene(scene) { + setTargetState(target); } bool WinTransition::eventTest(QEvent *event) -- cgit v0.12 From ac55107752934d6a036474e17530492ae3c0a632 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 31 Jul 2009 21:45:59 +0200 Subject: Autotest: add a way to ensure that there are no safety-check pointers leaking In the future, it would be nice to split the autotest in multiple functions at every check(). --- src/corelib/tools/qsharedpointer.cpp | 23 ++++++++++++- tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 42 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 59dfffe..2ca612e 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -897,6 +897,7 @@ QT_BEGIN_NAMESPACE namespace QtSharedPointer { Q_CORE_EXPORT void internalSafetyCheckAdd(const volatile void *); Q_CORE_EXPORT void internalSafetyCheckRemove(const volatile void *); + Q_AUTOTEST_EXPORT void internalSafetyCheckCleanCheck(); } /*! @@ -961,6 +962,7 @@ void QtSharedPointer::internalSafetyCheckAdd2(const void *d_ptr, const volatile kp->dPointers.insert(d_ptr, data); kp->dataPointers.insert(ptr, d_ptr); + Q_ASSERT(kp->dPointers.size() == kp->dataPointers.size()); } /*! @@ -985,10 +987,29 @@ void QtSharedPointer::internalSafetyCheckRemove2(const void *d_ptr) Q_ASSERT(it2 != kp->dataPointers.end()); //qDebug("Removing d=%p value=%p", d_ptr, it->pointer); - + // remove entries kp->dataPointers.erase(it2); kp->dPointers.erase(it); + Q_ASSERT(kp->dPointers.size() == kp->dataPointers.size()); +} + +/*! + \internal + Called by the QSharedPointer autotest +*/ +void QtSharedPointer::internalSafetyCheckCleanCheck() +{ +# ifdef QT_BUILD_INTERNAL + KnownPointers *const kp = knownPointers(); + Q_ASSERT_X(kp, "internalSafetyCheckSelfCheck()", "Called after global statics deletion!"); + + if (kp->dPointers.size() != kp->dataPointers.size()) + qFatal("Internal consistency error: the number of pointers is not equal!"); + + if (!kp->dPointers.isEmpty()) + qFatal("Pointer cleaning failed: %d entries remaining", kp->dPointers.size()); +# endif } QT_END_NAMESPACE diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index e001eab..74f4507 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -44,6 +44,10 @@ #include "externaltests.h" #include +namespace QtSharedPointer { + Q_CORE_EXPORT void internalSafetyCheckCleanCheck(); +} + class tst_QSharedPointer: public QObject { Q_OBJECT @@ -71,6 +75,12 @@ private slots: void validConstructs(); void invalidConstructs_data(); void invalidConstructs(); + +public slots: + void cleanup() { check(); } + +public: + inline void check() { QtSharedPointer::internalSafetyCheckCleanCheck(); } }; class Data @@ -496,6 +506,7 @@ void tst_QSharedPointer::objectCast() QVERIFY(ptr == data); #endif } + check(); { const OtherObject *data = new OtherObject; @@ -523,6 +534,7 @@ void tst_QSharedPointer::objectCast() QVERIFY(ptr == data); #endif } + check(); { OtherObject *data = new OtherObject; @@ -564,6 +576,7 @@ void tst_QSharedPointer::objectCast() QVERIFY(otherptr.isNull()); #endif } + check(); } void tst_QSharedPointer::differentPointers() @@ -583,6 +596,7 @@ void tst_QSharedPointer::differentPointers() QVERIFY(baseptr == aData); QVERIFY(baseptr == aBase); } + check(); { DiffPtrDerivedData *aData = new DiffPtrDerivedData; @@ -597,6 +611,7 @@ void tst_QSharedPointer::differentPointers() QVERIFY(ptr == aBase); QVERIFY(baseptr == aData); } + check(); { DiffPtrDerivedData *aData = new DiffPtrDerivedData; @@ -613,6 +628,7 @@ void tst_QSharedPointer::differentPointers() QVERIFY(baseptr == aData); QVERIFY(baseptr == aBase); } + check(); } void tst_QSharedPointer::virtualBaseDifferentPointers() @@ -632,6 +648,7 @@ void tst_QSharedPointer::virtualBaseDifferentPointers() QVERIFY(baseptr == aData); QVERIFY(baseptr == aBase); } + check(); { VirtualDerived *aData = new VirtualDerived; @@ -648,6 +665,7 @@ void tst_QSharedPointer::virtualBaseDifferentPointers() QVERIFY(baseptr == aData); QVERIFY(baseptr == aBase); } + check(); } #ifndef QTEST_NO_RTTI @@ -814,6 +832,7 @@ void tst_QSharedPointer::constCorrectness() ptr = cvptr.constCast(); #endif } + check(); { Data *aData = new Data; @@ -827,6 +846,7 @@ void tst_QSharedPointer::constCorrectness() QCOMPARE(cptr.data(), aData); QCOMPARE(cptr.operator->(), aData); } + check(); } static int customDeleterFnCallCount; @@ -855,11 +875,13 @@ void tst_QSharedPointer::customDeleter() QSharedPointer ptr2(new Data, &Data::alsoDelete); QSharedPointer ptr3(new Data, &Data::virtualDelete); } + check(); { QSharedPointer ptr(new DerivedData, &Data::doDelete); QSharedPointer ptr2(new DerivedData, &Data::alsoDelete); QSharedPointer ptr3(new DerivedData, &Data::virtualDelete); } + check(); customDeleterFnCallCount = 0; { @@ -868,6 +890,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(customDeleterFnCallCount, 0); } QCOMPARE(customDeleterFnCallCount, 1); + check(); customDeleterFnCallCount = 0; { @@ -877,6 +900,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(customDeleterFnCallCount, 1); } QCOMPARE(customDeleterFnCallCount, 1); + check(); customDeleterFnCallCount = 0; { @@ -886,6 +910,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(customDeleterFnCallCount, 1); } QCOMPARE(customDeleterFnCallCount, 1); + check(); customDeleterFnCallCount = 0; { @@ -894,6 +919,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(customDeleterFnCallCount, 0); } QCOMPARE(customDeleterFnCallCount, 1); + check(); customDeleterFnCallCount = 0; { @@ -902,6 +928,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(customDeleterFnCallCount, 0); } QCOMPARE(customDeleterFnCallCount, 1); + check(); customDeleterFnCallCount = 0; { @@ -914,6 +941,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(customDeleterFnCallCount, 0); } QCOMPARE(customDeleterFnCallCount, 1); + check(); customDeleterFnCallCount = 0; { @@ -926,6 +954,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(customDeleterFnCallCount, 0); } QCOMPARE(customDeleterFnCallCount, 1); + check(); CustomDeleter dataDeleter; dataDeleter.callCount = 0; @@ -935,6 +964,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(dataDeleter.callCount, 0); } QCOMPARE(dataDeleter.callCount, 1); + check(); dataDeleter.callCount = 0; { @@ -944,6 +974,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(dataDeleter.callCount, 0); } QCOMPARE(dataDeleter.callCount, 1); + check(); dataDeleter.callCount = 0; { @@ -956,6 +987,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(dataDeleter.callCount, 0); } QCOMPARE(dataDeleter.callCount, 1); + check(); dataDeleter.callCount = 0; { @@ -964,6 +996,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(dataDeleter.callCount, 0); } QCOMPARE(dataDeleter.callCount, 1); + check(); CustomDeleter derivedDataDeleter; derivedDataDeleter.callCount = 0; @@ -976,6 +1009,7 @@ void tst_QSharedPointer::customDeleter() } QCOMPARE(dataDeleter.callCount, 0); QCOMPARE(derivedDataDeleter.callCount, 1); + check(); derivedDataDeleter.callCount = 0; dataDeleter.callCount = 0; @@ -992,6 +1026,7 @@ void tst_QSharedPointer::customDeleter() } QCOMPARE(dataDeleter.callCount, 1); QCOMPARE(derivedDataDeleter.callCount, 0); + check(); derivedDataDeleter.callCount = 0; dataDeleter.callCount = 0; @@ -1025,6 +1060,7 @@ void tst_QSharedPointer::creating() ptr.clear(); QCOMPARE(Data::destructorCounter, 1); } + check(); Data::generationCounter = Data::destructorCounter = 0; { @@ -1040,6 +1076,7 @@ void tst_QSharedPointer::creating() QVERIFY(d->weakref == 1); QVERIFY(d->strongref == 0); } + check(); Data::generationCounter = Data::destructorCounter = 0; DerivedData::derivedDestructorCounter = 0; @@ -1052,6 +1089,7 @@ void tst_QSharedPointer::creating() QCOMPARE(Data::destructorCounter, 1); QCOMPARE(DerivedData::derivedDestructorCounter, 1); } + check(); { QSharedPointer ptr = QSharedPointer::create(); @@ -1060,6 +1098,7 @@ void tst_QSharedPointer::creating() QCOMPARE(ptr.staticCast()->buffer[3]+0, 16-3); QCOMPARE(ptr.staticCast()->buffer[0]+0, 16); } + check(); { QSharedPointer ptr = QSharedPointer::create(); @@ -1069,6 +1108,7 @@ void tst_QSharedPointer::creating() QSharedPointer baseptr = ptr; QCOMPARE(baseptr->classLevel(), 4); } + check(); { QSharedPointer ptr = QSharedPointer::create(); @@ -1079,11 +1119,13 @@ void tst_QSharedPointer::creating() QVERIFY(qptr.isNull()); } + check(); { QSharedPointer ptr = QSharedPointer::create(); QCOMPARE(ptr->metaObject(), &OtherObject::staticMetaObject); } + check(); } void tst_QSharedPointer::validConstructs() -- cgit v0.12 From 9eb370bd519a8648905f8b3b869fac8e8be3ada5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 3 Aug 2009 14:10:00 +0200 Subject: Remove the need for internal API in QSharedPointer. That way, this code can be compiled with an earlier version of Qt and should still work in new ones. Reviewed-by: Trust Me --- src/corelib/tools/qsharedpointer_impl.h | 4 +- tests/auto/qsharedpointer/qsharedpointer.pro | 1 - tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 95 ++++++++++++++---------- 3 files changed, 56 insertions(+), 44 deletions(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index b8f4139..089c479 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -350,9 +350,7 @@ namespace QtSharedPointer { this->value = d && d->strongref ? actual : 0; } -#if defined(QT_BUILD_INTERNAL) - public: -#endif + protected: Data *d; private: diff --git a/tests/auto/qsharedpointer/qsharedpointer.pro b/tests/auto/qsharedpointer/qsharedpointer.pro index 90fde06..30c81cb 100644 --- a/tests/auto/qsharedpointer/qsharedpointer.pro +++ b/tests/auto/qsharedpointer/qsharedpointer.pro @@ -4,6 +4,5 @@ SOURCES += tst_qsharedpointer.cpp \ forwarddeclared.cpp QT = core DEFINES += SRCDIR=\\\"$$PWD/\\\" -requires(contains(QT_CONFIG,private_tests)) include(externaltests.pri) HEADERS += forwarddeclared.h diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 74f4507..1c2c60f 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -80,8 +80,23 @@ public slots: void cleanup() { check(); } public: - inline void check() { QtSharedPointer::internalSafetyCheckCleanCheck(); } + inline void check() + { +#ifdef QT_BUILD_INTERNAL + QtSharedPointer::internalSafetyCheckCleanCheck(); +#endif + } +}; + +template +class RefCountHack: public Base +{ +public: + using Base::d; }; +template static inline +QtSharedPointer::ExternalRefCountData *refCountData(const Base &b) +{ return static_cast *>(&b)->d; } class Data { @@ -166,8 +181,8 @@ void tst_QSharedPointer::basics() QVERIFY(! (ptr == otherData)); QVERIFY(! (otherData == ptr)); } - QVERIFY(!ptr.d || ptr.d->weakref == 1); - QVERIFY(!ptr.d || ptr.d->strongref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1); { // create another object: @@ -179,8 +194,8 @@ void tst_QSharedPointer::basics() // otherData is deleted here } - QVERIFY(!ptr.d || ptr.d->weakref == 1); - QVERIFY(!ptr.d || ptr.d->strongref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1); { // create a copy: @@ -196,8 +211,8 @@ void tst_QSharedPointer::basics() QCOMPARE(copy.data(), aData); QVERIFY(copy == aData); } - QVERIFY(!ptr.d || ptr.d->weakref == 1); - QVERIFY(!ptr.d || ptr.d->strongref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1); { // create a weak reference: @@ -228,8 +243,8 @@ void tst_QSharedPointer::basics() QVERIFY(strong == ptr); QCOMPARE(strong.data(), aData); } - QVERIFY(!ptr.d || ptr.d->weakref == 1); - QVERIFY(!ptr.d || ptr.d->strongref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1); // aData is deleted here } @@ -445,15 +460,15 @@ void tst_QSharedPointer::upCast() QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); { QWeakPointer derivedptr = qWeakPointerCast(baseptr); QVERIFY(baseptr == derivedptr); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); { QWeakPointer weakptr = baseptr; @@ -461,16 +476,16 @@ void tst_QSharedPointer::upCast() QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); { QSharedPointer derivedptr = baseptr.staticCast(); QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); } class OtherObject: public QObject @@ -680,8 +695,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); { QWeakPointer weakptr = baseptr; @@ -690,8 +705,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); @@ -699,8 +714,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); } void tst_QSharedPointer::dynamicCastDifferentPointers() @@ -715,8 +730,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); { QWeakPointer weakptr = baseptr; @@ -725,8 +740,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); @@ -734,8 +749,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); { Stuffing *nakedptr = dynamic_cast(baseptr.data()); @@ -760,8 +775,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); { QWeakPointer weakptr = baseptr; @@ -770,8 +785,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); @@ -779,8 +794,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); } void tst_QSharedPointer::dynamicCastFailure() @@ -792,15 +807,15 @@ void tst_QSharedPointer::dynamicCastFailure() QSharedPointer derivedptr = qSharedPointerDynamicCast(baseptr); QVERIFY(derivedptr.isNull()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); QVERIFY(derivedptr.isNull()); } - QCOMPARE(int(baseptr.d->weakref), 1); - QCOMPARE(int(baseptr.d->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref), 1); + QCOMPARE(int(refCountData(baseptr)->strongref), 1); } #endif @@ -1066,7 +1081,7 @@ void tst_QSharedPointer::creating() { QSharedPointer ptr = QSharedPointer::create(); QWeakPointer weakptr = ptr; - QtSharedPointer::ExternalRefCountData *d = ptr.d; + QtSharedPointer::ExternalRefCountData *d = refCountData(ptr); ptr.clear(); QVERIFY(ptr.isNull()); -- cgit v0.12 From 788a33f7a061552e3f9e5d2fe6cf7faad516892e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 31 Jul 2009 21:49:24 +0200 Subject: Cleanup old code in QSharedPointer We don't support MSVC 6.0 or MSVC .NET 2002, so all compilers we support can deal with member templates and partial template specialisation. Remove the #ifdef protecting the code that needed it. Also add some comments indicating the sizes of the structures. There is no padding necessary in most cases. Reviewed-By: Trust Me --- src/corelib/tools/qsharedpointer_impl.h | 34 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 089c479..aa71168 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -100,20 +100,22 @@ namespace QtSharedPointer { // used in debug mode to verify the reuse of pointers Q_CORE_EXPORT void internalSafetyCheckAdd2(const void *, const volatile void *); Q_CORE_EXPORT void internalSafetyCheckRemove2(const void *); - + template inline void executeDeleter(T *t, RetVal (Klass:: *memberDeleter)()) { (t->*memberDeleter)(); } template inline void executeDeleter(T *t, Deleter d) { d(t); } + template inline void normalDeleter(T *t) { delete t; } + + // this uses partial template specialization + // the only compilers that didn't support this were MSVC 6.0 and 2002 + template struct RemovePointer; + template struct RemovePointer { typedef T Type; }; + template struct RemovePointer > { typedef T Type; }; + template struct RemovePointer > { typedef T Type; }; - // - // Depending on its template parameter, QSharedPointer derives from either - // QtSharedPointer::InternalRefCount or from QtSharedPointer::ExternalRefCount. - // Both of these classes derive from QtSharedPointer::Basic, which provides common - // operations, - // template class Basic { @@ -168,6 +170,7 @@ namespace QtSharedPointer { virtual inline bool destroy() { return false; } }; + // sizeof(ExternalRefCount) = 12 (32-bit) / 16 (64-bit) template struct CustomDeleter @@ -177,6 +180,9 @@ namespace QtSharedPointer { inline CustomDeleter(T *p, Deleter d) : deleter(d), ptr(p) {} }; + // sizeof(CustomDeleter) = sizeof(Deleter) + sizeof(void*) + // for Deleter = function pointer: 8 (32-bit) / 16 (64-bit) + // for Deleter = PMF: 12 (32-bit) / 24 (64-bit) (GCC) struct ExternalRefCountWithDestroyFn: public ExternalRefCountData { @@ -190,6 +196,7 @@ namespace QtSharedPointer { inline bool destroy() { destroyer(this); return true; } inline void operator delete(void *ptr) { ::operator delete(ptr); } }; + // sizeof(ExternalRefCountWithDestroyFn) = 16 (32-bit) / 24 (64-bit) template struct ExternalRefCountWithCustomDeleter: public ExternalRefCountWithDestroyFn @@ -258,9 +265,9 @@ namespace QtSharedPointer { template class ExternalRefCount: public Basic { - typedef ExternalRefCountData Data; - typedef void (*DeleterFunction)(T *); protected: + typedef ExternalRefCountData Data; + inline void ref() const { d->weakref.ref(); d->strongref.ref(); } inline bool deref() { @@ -667,14 +674,6 @@ Q_INLINE_TEMPLATE QSharedPointer qSharedPointerObjectCast(const QWeakPointer< return qSharedPointerObjectCast(src.toStrongRef()); } -# ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION -namespace QtSharedPointer { - template struct RemovePointer; - template struct RemovePointer { typedef T Type; }; - template struct RemovePointer > { typedef T Type; }; - template struct RemovePointer > { typedef T Type; }; -} - template inline QSharedPointer::Type> qobject_cast(const QSharedPointer &src) @@ -687,7 +686,6 @@ qobject_cast(const QWeakPointer &src) { return qSharedPointerObjectCast::Type, T>(src); } -# endif #endif -- cgit v0.12 From 7e0b201285c712a3c98c848033bbd8e5ab75a590 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 1 Aug 2009 01:07:54 +0200 Subject: Don't forget to delete the deleter object too in QSharedPointer. Destructors have to be run for the subobjects we initialise. Reviewed-By: Bradley T. Hughes --- src/corelib/tools/qsharedpointer_impl.h | 3 +++ tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index aa71168..55aeb10 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -210,6 +210,9 @@ namespace QtSharedPointer { { Self *realself = static_cast(self); executeDeleter(realself->extra.ptr, realself->extra.deleter); + + // delete the deleter too + realself->extra.~Next(); } static inline Self *create(T *ptr, Deleter userDeleter) diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 1c2c60f..481377a 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -871,9 +871,14 @@ void customDeleterFn(Data *ptr) delete ptr; } +static int refcount; + template struct CustomDeleter { + CustomDeleter() { ++refcount; } + CustomDeleter(const CustomDeleter &) { ++refcount; } + ~CustomDeleter() { --refcount; } inline void operator()(T *ptr) { delete ptr; @@ -971,6 +976,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(customDeleterFnCallCount, 1); check(); + refcount = 0; CustomDeleter dataDeleter; dataDeleter.callCount = 0; { @@ -979,6 +985,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(dataDeleter.callCount, 0); } QCOMPARE(dataDeleter.callCount, 1); + QCOMPARE(refcount, 1); check(); dataDeleter.callCount = 0; @@ -989,6 +996,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(dataDeleter.callCount, 0); } QCOMPARE(dataDeleter.callCount, 1); + QCOMPARE(refcount, 1); check(); dataDeleter.callCount = 0; @@ -1002,6 +1010,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(dataDeleter.callCount, 0); } QCOMPARE(dataDeleter.callCount, 1); + QCOMPARE(refcount, 1); check(); dataDeleter.callCount = 0; @@ -1011,6 +1020,7 @@ void tst_QSharedPointer::customDeleter() QCOMPARE(dataDeleter.callCount, 0); } QCOMPARE(dataDeleter.callCount, 1); + QCOMPARE(refcount, 1); check(); CustomDeleter derivedDataDeleter; @@ -1024,6 +1034,7 @@ void tst_QSharedPointer::customDeleter() } QCOMPARE(dataDeleter.callCount, 0); QCOMPARE(derivedDataDeleter.callCount, 1); + QCOMPARE(refcount, 2); check(); derivedDataDeleter.callCount = 0; @@ -1041,6 +1052,7 @@ void tst_QSharedPointer::customDeleter() } QCOMPARE(dataDeleter.callCount, 1); QCOMPARE(derivedDataDeleter.callCount, 0); + QCOMPARE(refcount, 2); check(); derivedDataDeleter.callCount = 0; @@ -1058,6 +1070,7 @@ void tst_QSharedPointer::customDeleter() } QCOMPARE(dataDeleter.callCount, 0); QCOMPARE(derivedDataDeleter.callCount, 1); + QCOMPARE(refcount, 2); } void tst_QSharedPointer::creating() -- cgit v0.12 From 1c5cf2e3d6f091593aec237bbb527cb8cdb964c4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 31 Jul 2009 22:10:49 +0200 Subject: Change the pointer-tracking code to work everywhere. Currently, if you create a QSharedPointer in code with pointer-tracking, you must ensure it gets deleted in code with pointer-tracking, otherwise the internal safety tracker will be "leaking" objects. The pointers would never get removed. And if any new pointer happened to have the same pointer address (which happens quite often), the tracker code would promptly abort the application. With this change, the untracking of the pointer is scheduled by the same code that creates the tracking. This is done by "abusing" the custom deleter code: - for the QSharedPointer that used ExternalRefCountWithDestroyFn already, we intercept the call to the destroy function and call the untracking function - for a normal QSharedPointer, we use the "normalDeleter" function as custom deleter and chain up above Note: the autotest only *really* works in release mode. Otherwise functions don't get inlined and do get merged by the linker. Reviewed-By: Bradley T. Hughes --- src/corelib/tools/qsharedpointer_impl.h | 38 +++++++++++---- tests/auto/qsharedpointer/qsharedpointer.pro | 10 +++- tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 22 +++++++++ tests/auto/qsharedpointer/wrapper.cpp | 60 ++++++++++++++++++++++++ tests/auto/qsharedpointer/wrapper.h | 55 ++++++++++++++++++++++ 5 files changed, 173 insertions(+), 12 deletions(-) create mode 100644 tests/auto/qsharedpointer/wrapper.cpp create mode 100644 tests/auto/qsharedpointer/wrapper.h diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 55aeb10..b5daf5d 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -214,10 +214,19 @@ namespace QtSharedPointer { // delete the deleter too realself->extra.~Next(); } + static void safetyCheckDeleter(ExternalRefCountData *self) + { + internalSafetyCheckRemove2(self); + deleter(self); + } static inline Self *create(T *ptr, Deleter userDeleter) { +# ifdef QT_SHAREDPOINTER_TRACK_POINTERS + DestroyerFn destroy = &safetyCheckDeleter; +# else DestroyerFn destroy = &deleter; +# endif Self *d = static_cast(::operator new(sizeof(Self))); // initialize the two sub-objects @@ -244,10 +253,19 @@ namespace QtSharedPointer { static_cast(self); that->data.~T(); } + static void safetyCheckDeleter(ExternalRefCountData *self) + { + internalSafetyCheckRemove2(self); + deleter(self); + } static inline ExternalRefCountData *create(T **ptr) { +# ifdef QT_SHAREDPOINTER_TRACK_POINTERS + DestroyerFn destroy = &safetyCheckDeleter; +# else DestroyerFn destroy = &deleter; +# endif ExternalRefCountWithContiguousData *d = static_cast(::operator new(sizeof(ExternalRefCountWithContiguousData))); @@ -282,32 +300,34 @@ namespace QtSharedPointer { inline void internalConstruct(T *ptr) { - Basic::internalConstruct(ptr); +#ifdef QT_SHAREDPOINTER_TRACK_POINTERS + internalConstruct(ptr, normalDeleter); +#else Q_ASSERT(!d); if (ptr) d = new Data; -#ifdef QT_SHAREDPOINTER_TRACK_POINTERS - if (ptr) internalSafetyCheckAdd2(d, ptr); + internalFinishConstruction(ptr); #endif } template inline void internalConstruct(T *ptr, Deleter deleter) { - Basic::internalConstruct(ptr); Q_ASSERT(!d); if (ptr) d = ExternalRefCountWithCustomDeleter::create(ptr, deleter); -#ifdef QT_SHAREDPOINTER_TRACK_POINTERS - if (ptr) internalSafetyCheckAdd2(d, ptr); -#endif + internalFinishConstruction(ptr); } inline void internalCreate() { T *ptr; d = ExternalRefCountWithContiguousData::create(&ptr); + Basic::internalConstruct(ptr); + } + inline void internalFinishConstruction(T *ptr) + { Basic::internalConstruct(ptr); #ifdef QT_SHAREDPOINTER_TRACK_POINTERS if (ptr) internalSafetyCheckAdd2(d, ptr); @@ -327,9 +347,6 @@ namespace QtSharedPointer { inline void internalDestroy() { -#ifdef QT_SHAREDPOINTER_TRACK_POINTERS - internalSafetyCheckRemove2(d); -#endif if (!d->destroy()) delete this->value; } @@ -450,6 +467,7 @@ public: // now initialize the data new (result.data()) T(); + result.internalFinishConstruction(result.data()); return result; } }; diff --git a/tests/auto/qsharedpointer/qsharedpointer.pro b/tests/auto/qsharedpointer/qsharedpointer.pro index 30c81cb..1759323 100644 --- a/tests/auto/qsharedpointer/qsharedpointer.pro +++ b/tests/auto/qsharedpointer/qsharedpointer.pro @@ -1,8 +1,14 @@ load(qttest_p4) + SOURCES += tst_qsharedpointer.cpp \ forwarddeclaration.cpp \ - forwarddeclared.cpp + forwarddeclared.cpp \ + wrapper.cpp + +HEADERS += forwarddeclared.h \ + wrapper.h + QT = core DEFINES += SRCDIR=\\\"$$PWD/\\\" + include(externaltests.pri) -HEADERS += forwarddeclared.h diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 481377a..e259e87 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -44,6 +44,8 @@ #include "externaltests.h" #include +#include "wrapper.h" + namespace QtSharedPointer { Q_CORE_EXPORT void internalSafetyCheckCleanCheck(); } @@ -72,6 +74,7 @@ private slots: void constCorrectness(); void customDeleter(); void creating(); + void mixTrackingPointerCode(); void validConstructs(); void invalidConstructs_data(); void invalidConstructs(); @@ -1156,6 +1159,25 @@ void tst_QSharedPointer::creating() check(); } +void tst_QSharedPointer::mixTrackingPointerCode() +{ + { + // pointer created with tracking + // deleted in code without tracking + QSharedPointer ptr = QSharedPointer(new int(42)); + Wrapper w(ptr); + ptr.clear(); + } + check(); + + { + // pointer created without tracking + // deleted in code with tracking + Wrapper w = Wrapper::create(); + w.ptr.clear(); + } +} + void tst_QSharedPointer::validConstructs() { { diff --git a/tests/auto/qsharedpointer/wrapper.cpp b/tests/auto/qsharedpointer/wrapper.cpp new file mode 100644 index 0000000..7640e68 --- /dev/null +++ b/tests/auto/qsharedpointer/wrapper.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifdef QT_SHAREDPOINTER_TRACK_POINTERS +# undef QT_SHAREDPOINTER_TRACK_POINTERS +#endif +#include +#include "wrapper.h" + +Wrapper::Wrapper(const QSharedPointer &value) + : ptr(value) +{ +} + +Wrapper::~Wrapper() +{ +} + +Wrapper Wrapper::create() +{ + return Wrapper(QSharedPointer(new int(-47))); +} diff --git a/tests/auto/qsharedpointer/wrapper.h b/tests/auto/qsharedpointer/wrapper.h new file mode 100644 index 0000000..a888063 --- /dev/null +++ b/tests/auto/qsharedpointer/wrapper.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef WRAPPER_H +#define WRAPPER_H + +template class QSharedPointer; +class Wrapper +{ +public: + QSharedPointer ptr; + Wrapper(const QSharedPointer &); + ~Wrapper(); + + static Wrapper create(); +}; + +#endif // WRAPPER_H -- cgit v0.12 From b969da8cf65bdcc00007415caff2dc69a09257c7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 1 Aug 2009 11:32:50 +0200 Subject: Ensure that we never increase the strong reference count up from zero. Also add some thread stress tests to try and detect doing it wrong. Reviewed-By: Bradley T. Hughes --- src/corelib/tools/qsharedpointer_impl.h | 18 +++- tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 125 ++++++++++++++++++++++- 2 files changed, 138 insertions(+), 5 deletions(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index b5daf5d..9fa8df4 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -364,12 +364,22 @@ namespace QtSharedPointer { inline void internalSet(Data *o, T *actual) { if (d == o) return; - if (o && !o->strongref) - o = 0; if (o) { verifyReconstruction(actual); - o->weakref.ref(); - o->strongref.ref(); + + // increase the strongref, but never up from zero + register int tmp = o->strongref; + while (tmp > 0) { + // try to increment from "tmp" to "tmp + 1" + if (o->strongref.testAndSetRelaxed(tmp, tmp + 1)) + break; // succeeded + tmp = o->strongref; // failed, try again + } + + if (tmp) + o->weakref.ref(); + else + o = 0; } if (d && !deref()) delete d; diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index e259e87..210f3fa 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -41,11 +41,16 @@ #define QT_SHAREDPOINTER_TRACK_POINTERS #include "qsharedpointer.h" -#include "externaltests.h" #include +#include +#include +#include "externaltests.h" #include "wrapper.h" +#include +#include + namespace QtSharedPointer { Q_CORE_EXPORT void internalSafetyCheckCleanCheck(); } @@ -75,6 +80,8 @@ private slots: void customDeleter(); void creating(); void mixTrackingPointerCode(); + void threadStressTest_data(); + void threadStressTest(); void validConstructs(); void invalidConstructs_data(); void invalidConstructs(); @@ -1178,6 +1185,122 @@ void tst_QSharedPointer::mixTrackingPointerCode() } } +class ThreadData +{ + QAtomicInt * volatile ptr; +public: + ThreadData(QAtomicInt *p) : ptr(p) { } + ~ThreadData() { ++ptr; } + void ref() + { + // if we're called after the destructor, we'll crash + ptr->ref(); + } +}; + +class StrongThread: public QThread +{ +protected: + void run() + { + usleep(rand() % 2000); + ptr->ref(); + ptr.clear(); + } +public: + QSharedPointer ptr; +}; + +class WeakThread: public QThread +{ +protected: + void run() + { + usleep(rand() % 2000); + QSharedPointer ptr = weak; + if (ptr) + ptr->ref(); + ptr.clear(); + } +public: + QWeakPointer weak; +}; + +void tst_QSharedPointer::threadStressTest_data() +{ + QTest::addColumn("strongThreadCount"); + QTest::addColumn("weakThreadCount"); + + QTest::newRow("0+0") << 0 << 0; + QTest::newRow("1+0") << 1 << 0; + QTest::newRow("2+0") << 2 << 0; + QTest::newRow("10+0") << 10 << 0; + + QTest::newRow("0+1") << 0 << 1; + QTest::newRow("1+1") << 1 << 1; + + QTest::newRow("2+10") << 2 << 10; + QTest::newRow("5+10") << 5 << 10; + QTest::newRow("5+30") << 5 << 30; + + QTest::newRow("100+100") << 100 << 100; +} + +void tst_QSharedPointer::threadStressTest() +{ + QFETCH(int, strongThreadCount); + QFETCH(int, weakThreadCount); + + int guard1[128]; + QAtomicInt counter; + int guard2[128]; + + memset(guard1, 0, sizeof guard1); + memset(guard2, 0, sizeof guard2); + + for (int r = 0; r < 5; ++r) { + QVector allThreads(6 * qMax(strongThreadCount, weakThreadCount) + 3, 0); + QSharedPointer base = QSharedPointer(new ThreadData(&counter)); + counter = 0; + + // set the pointers + for (int i = 0; i < strongThreadCount; ++i) { + StrongThread *t = new StrongThread; + t->ptr = base; + allThreads[2 * i] = t; + } + for (int i = 0; i < weakThreadCount; ++i) { + WeakThread *t = new WeakThread; + t->weak = base; + allThreads[6 * i + 3] = t; + } + + base.clear(); + + srand(time(NULL)); + // start threads + for (int i = 0; i < allThreads.count(); ++i) + if (allThreads[i]) allThreads[i]->start(); + + // wait for them to finish + for (int i = 0; i < allThreads.count(); ++i) + if (allThreads[i]) allThreads[i]->wait(); + qDeleteAll(allThreads); + + // ensure the guards aren't touched + for (uint i = 0; i < sizeof guard1 / sizeof guard1[0]; ++i) + QVERIFY(!guard1[i]); + for (uint i = 0; i < sizeof guard2 / sizeof guard2[0]; ++i) + QVERIFY(!guard2[i]); + + // verify that the count is the right range + int minValue = strongThreadCount; + int maxValue = strongThreadCount + weakThreadCount; + QVERIFY(counter >= minValue); + QVERIFY(counter <= maxValue); + } +} + void tst_QSharedPointer::validConstructs() { { -- cgit v0.12 From bcbc297dfcf91a4113baa80378c4f4d67c2726d9 Mon Sep 17 00:00:00 2001 From: kh1 Date: Mon, 3 Aug 2009 14:25:53 +0200 Subject: Sync with QtCreator source, add's help startup options. Reviewed-by: kh --- tools/assistant/tools/assistant/centralwidget.cpp | 22 ++++ tools/assistant/tools/assistant/centralwidget.h | 3 +- tools/assistant/tools/assistant/mainwindow.cpp | 2 +- .../tools/assistant/preferencesdialog.cpp | 41 ++++--- .../assistant/tools/assistant/preferencesdialog.h | 12 ++- .../assistant/tools/assistant/preferencesdialog.ui | 118 +++++++++++++++++---- 6 files changed, 158 insertions(+), 40 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 00a8893..23562db 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -43,6 +43,7 @@ #include "helpviewer.h" #include "searchwidget.h" #include "mainwindow.h" +#include "preferencesdialog.h" #include #include @@ -423,6 +424,27 @@ void CentralWidget::setSource(const QUrl &url) tabWidget->setTabText(lastTabPage, quoteTabTitle(viewer->documentTitle())); } +void CentralWidget::setupWidget() +{ + int option = helpEngine->customValue(QLatin1String("StartOption"), + ShowLastPages).toInt(); + + if (option != ShowLastPages) { + QString homePage; + if (option == ShowHomePage) { + homePage = helpEngine->customValue(QLatin1String("defaultHomepage"), + QLatin1String("help")).toString(); + homePage = helpEngine->customValue(QLatin1String("homepage"), + homePage).toString(); + } + if (option == ShowBlankPage) + homePage = QLatin1String("about:blank"); + setSource(homePage); + } else { + setLastShownPages(); + } +} + void CentralWidget::setLastShownPages() { const QLatin1String key("LastShownPages"); diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index ca9caaf..f7ce1d5 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -111,7 +111,7 @@ public: CentralWidget(QHelpEngine *engine, MainWindow *parent); ~CentralWidget(); - void setLastShownPages(); + void setupWidget(); bool hasSelection() const; QUrl currentSource() const; QString currentTitle() const; @@ -188,6 +188,7 @@ private: void initPrinter(); QString quoteTabTitle(const QString &title) const; void highlightSearchTerms(); + void setLastShownPages(); private: int lastTabPage; diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 0c1723c..bc73b80 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -407,7 +407,7 @@ void MainWindow::insertLastPages() if (m_cmdLine->url().isValid()) m_centralWidget->setSource(m_cmdLine->url()); else - m_centralWidget->setLastShownPages(); + m_centralWidget->setupWidget(); if (m_cmdLine->search() == CmdLineParser::Activate) showSearch(); diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index fa70196..2b58c64 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -146,10 +146,13 @@ PreferencesDialog::~PreferencesDialog() emit updateBrowserFont(); } - if (!m_ui.homePageLineEdit->text().isEmpty()) { - key = QLatin1String("homepage"); - m_helpEngine->setCustomValue(key, m_ui.homePageLineEdit->text()); - } + QString homePage = m_ui.homePageLineEdit->text(); + if (homePage.isEmpty()) + homePage = QLatin1String("help"); + m_helpEngine->setCustomValue(QLatin1String("homepage"), homePage); + + int option = m_ui.helpStartComboBox->currentIndex(); + m_helpEngine->setCustomValue(QLatin1String("StartOption"), option); } void PreferencesDialog::showDialog() @@ -379,6 +382,8 @@ void PreferencesDialog::applyChanges() CentralWidget* widget = CentralWidget::instance(); for (int i = m_TabsToClose.count(); --i >= 0;) widget->closeTabAt(m_TabsToClose.at(i)); + if (widget->availableHelpViewer()== 0) + widget->setSource(QUrl(QLatin1String("about:blank"))); if (m_unregDocs.count()) { foreach (const QString &doc, m_unregDocs) @@ -483,22 +488,23 @@ void PreferencesDialog::updateOptionsPage() homepage = m_helpEngine->customValue(QLatin1String("defaultHomepage"), QLatin1String("help")).toString(); } - m_ui.homePageLineEdit->setText(homepage); - connect(m_ui.currentPageButton, SIGNAL(pressed()), this, - SLOT(currentHomepageChanged())); - connect(m_ui.restoreDefaultHomePageButton, SIGNAL(pressed()), this, - SLOT(restoreDefaultHomepage())); + + int option = m_helpEngine->customValue(QLatin1String("StartOption"), + ShowLastPages).toInt(); + m_ui.helpStartComboBox->setCurrentIndex(option); + + connect(m_ui.blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage())); + connect(m_ui.currentPageButton, SIGNAL(clicked()), this, SLOT(setCurrentPage())); + connect(m_ui.defaultPageButton, SIGNAL(clicked()), this, SLOT(setDefaultPage())); } -void PreferencesDialog::restoreDefaultHomepage() +void PreferencesDialog::setBlankPage() { - QString homepage = m_helpEngine->customValue(QLatin1String("defaultHomepage"), - QLatin1String("help")).toString(); - m_ui.homePageLineEdit->setText(homepage); + m_ui.homePageLineEdit->setText(QLatin1String("about:blank")); } -void PreferencesDialog::currentHomepageChanged() +void PreferencesDialog::setCurrentPage() { QString homepage = CentralWidget::instance()->currentSource().toString(); if (homepage.isEmpty()) @@ -507,4 +513,11 @@ void PreferencesDialog::currentHomepageChanged() m_ui.homePageLineEdit->setText(homepage); } +void PreferencesDialog::setDefaultPage() +{ + QString homepage = m_helpEngine->customValue(QLatin1String("defaultHomepage"), + QLatin1String("help")).toString(); + m_ui.homePageLineEdit->setText(homepage); +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/preferencesdialog.h b/tools/assistant/tools/assistant/preferencesdialog.h index 5b8ffe8..4471b5f 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.h +++ b/tools/assistant/tools/assistant/preferencesdialog.h @@ -50,6 +50,12 @@ QT_BEGIN_NAMESPACE class FontPanel; class QHelpEngineCore; +enum { + ShowHomePage = 0, + ShowBlankPage = 1, + ShowLastPages = 2 +}; + class PreferencesDialog : public QDialog { Q_OBJECT @@ -72,8 +78,10 @@ private slots: void appFontSettingChanged(int index); void browserFontSettingToggled(bool on); void browserFontSettingChanged(int index); - void restoreDefaultHomepage(); - void currentHomepageChanged(); + + void setBlankPage(); + void setCurrentPage(); + void setDefaultPage(); signals: void updateBrowserFont(); diff --git a/tools/assistant/tools/assistant/preferencesdialog.ui b/tools/assistant/tools/assistant/preferencesdialog.ui index d848b49..279084d 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.ui +++ b/tools/assistant/tools/assistant/preferencesdialog.ui @@ -6,7 +6,7 @@ 0 0 - 359 + 375 266 @@ -187,19 +187,90 @@ Options - + - + - Homepage + - + - + + + + 0 + 0 + + + + On help start: + + + + + + 0 + 0 + + + + + Show my home page + + + + + Show a blank page + + + + + Show my tabs from last session + + + + + + + + Qt::Horizontal + + + + 54 + 20 + + + + + + + + + + + + + + + + + Homepage + + + + + + + + + + + Qt::Horizontal @@ -213,22 +284,25 @@ - - - - - Current Page - - - - - - - Restore to default - - - - + + + Current Page + + + + + + + Blank Page + + + + + + + Restore to default + + -- cgit v0.12 From c1c52b5cd22655999a9abc6bce709e15b598d2c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 3 Aug 2009 14:31:10 +0200 Subject: Preserved fill rule for perspective mapped strokes in raster engine. Task-number: 254407 Reviewed-by: Gunnar --- src/gui/painting/qoutlinemapper.cpp | 2 ++ src/gui/painting/qtransform.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index 401fad9..d294378 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -225,6 +225,8 @@ void QOutlineMapper::endOutline() } } path = QTransform(m_m11, m_m12, m_m13, m_m21, m_m22, m_m23, m_dx, m_dy, m_m33).map(path); + if (!(m_outline.flags & QT_FT_OUTLINE_EVEN_ODD_FILL)) + path.setFillRule(Qt::WindingFill); uint old_txop = m_txop; m_txop = QTransform::TxNone; if (path.isEmpty()) diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index dcb8947..6a33928 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1459,6 +1459,7 @@ static QPainterPath mapProjective(const QTransform &transform, const QPainterPat if (path.elementCount() > 0 && lastMoveTo != last) lineTo_clipped(result, transform, last, lastMoveTo, needsMoveTo, false); + result.setFillRule(path.fillRule()); return result; } -- cgit v0.12 From 87432a42fba53ad910e8e21feb94e638f4ae17eb Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 3 Aug 2009 15:11:13 +0200 Subject: fixed broken integration of qwindowsurface_raster.cpp --- src/gui/painting/qwindowsurface_raster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index 330a33f..eddbfd2 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -149,7 +149,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi QRect br = rgn.boundingRect(); #ifndef Q_WS_WINCE - if (!qt_widget_private(window())->isOpaque && d->canUseLayeredWindow && window()->testAttribute(Qt::WA_TranslucentBackground)) { + if (!qt_widget_private(window())->isOpaque && window()->testAttribute(Qt::WA_TranslucentBackground)) { QRect r = window()->frameGeometry(); QPoint frameOffset = qt_widget_private(window())->frameStrut().topLeft(); QRect dirtyRect = br.translated(offset + frameOffset); -- cgit v0.12 From 6130b2137da4c4aa6f12c2fb4e99ef19ac008781 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Mon, 3 Aug 2009 15:40:55 +0200 Subject: Fix deadlock in the fsevents file watcher. I was making an assumption that one could call CFRunLoopStop and expect that the runloop would stop very soon afterwards. This is a bit naive and can result in situations where we end up running past and entering run again before everything is finished. We now make sure that we don't leave stop() until the we really have stopped the other thread. Reviewed-by: mbm --- src/corelib/io/qfilesystemwatcher_fsevents.cpp | 7 ++++++- src/corelib/io/qfilesystemwatcher_fsevents_p.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.cpp b/src/corelib/io/qfilesystemwatcher_fsevents.cpp index 3e0aee8..cb276b7 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.cpp +++ b/src/corelib/io/qfilesystemwatcher_fsevents.cpp @@ -422,9 +422,12 @@ void QFSEventsFileSystemWatcherEngine::fseventsCallback(ConstFSEventStreamRef , void QFSEventsFileSystemWatcherEngine::stop() { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + QMutexLocker locker(&mutex); stopFSStream(fsStream); - if (threadsRunLoop) + if (threadsRunLoop) { CFRunLoopStop(threadsRunLoop); + waitForStop.wait(&mutex); + } #endif } @@ -461,6 +464,8 @@ void QFSEventsFileSystemWatcherEngine::run() // immediately. CFRunLoopRun(); threadsRunLoop = 0; + QMutexLocker locker(&mutex); + waitForStop.wakeAll(); #endif } diff --git a/src/corelib/io/qfilesystemwatcher_fsevents_p.h b/src/corelib/io/qfilesystemwatcher_fsevents_p.h index 4770867..ffc0c68 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents_p.h +++ b/src/corelib/io/qfilesystemwatcher_fsevents_p.h @@ -114,6 +114,7 @@ private: CFRunLoopRef threadsRunLoop; QMutex mutex; QWaitCondition waitCondition; + QWaitCondition waitForStop; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 PathHash filePathInfoHash; PathHash dirPathInfoHash; -- cgit v0.12 From 28f94e1ef94f595bd8fa71005eaf3daf70731f72 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Mon, 3 Aug 2009 15:46:04 +0200 Subject: Wizard background images incorrect in Snow Leopard. We need to clear the QPixmap before the image is drawn using the CGContextDrawImage(). Reviewed-by: Norwegian Rock Cat --- src/gui/image/qpixmap_mac.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 45392f1..5568898 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -1178,6 +1178,7 @@ QPixmap QPixmap::fromMacCGImageRef(CGImageRef image) const size_t w = CGImageGetWidth(image), h = CGImageGetHeight(image); QPixmap ret(w, h); + ret.fill(Qt::transparent); CGRect rect = CGRectMake(0, 0, w, h); CGContextRef ctx = qt_mac_cg_context(&ret); qt_mac_drawCGImage(ctx, &rect, image); -- cgit v0.12 From 895757ded9c9b0a07163e84b155ef4c8a623d1a0 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Mon, 3 Aug 2009 15:57:44 +0200 Subject: Fix spelling error. --- config.tests/mac/defaultarch.test | 14 +++++++------- configure | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config.tests/mac/defaultarch.test b/config.tests/mac/defaultarch.test index 4502af7..80f244a 100755 --- a/config.tests/mac/defaultarch.test +++ b/config.tests/mac/defaultarch.test @@ -3,7 +3,7 @@ COMPILER=$1 VERBOSE=$2 WORKDIR=$3 -QT_MAC_DEFUALT_ARCH= +QT_MAC_DEFAULT_ARCH= touch defaultarch.c @@ -17,17 +17,17 @@ rm -f defaultarch.c defaultarch.o # detect our known archs. if echo "$FIlE_OUTPUT" | grep '\' > /dev/null 2>&1; then - QT_MAC_DEFUALT_ARCH=x86 # configure knows it as "x86" not "i386" + QT_MAC_DEFAULT_ARCH=x86 # configure knows it as "x86" not "i386" fi if echo "$FIlE_OUTPUT" | grep '\' > /dev/null 2>&1; then - QT_MAC_DEFUALT_ARCH=x86_64 + QT_MAC_DEFAULT_ARCH=x86_64 fi if echo "$FIlE_OUTPUT" | grep '\' > /dev/null 2>&1; then - QT_MAC_DEFUALT_ARCH=ppc + QT_MAC_DEFAULT_ARCH=ppc fi if echo "$FIlE_OUTPUT" | grep '\' > /dev/null 2>&1; then - QT_MAC_DEFUALT_ARCH=ppc64 + QT_MAC_DEFAULT_ARCH=ppc64 fi -[ "$VERBOSE" = "yes" ] && echo "setting QT_MAC_DEFUALT_ARCH to \"$QT_MAC_DEFUALT_ARCH\"" -export QT_MAC_DEFUALT_ARCH +[ "$VERBOSE" = "yes" ] && echo "setting QT_MAC_DEFAULT_ARCH to \"$QT_MAC_DEFAULT_ARCH\"" +export QT_MAC_DEFAULT_ARCH diff --git a/configure b/configure index 843d370..2f2e284 100755 --- a/configure +++ b/configure @@ -5712,12 +5712,12 @@ fi if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_ARCHS" == "" ]; then source "$mactests/defaultarch.test" "$TEST_COMPILER" "$OPT_VERBOSE" "$mactests" - if [ "$QT_MAC_DEFUALT_ARCH" == "x86_64" ]; then + if [ "$QT_MAC_DEFAULT_ARCH" == "x86_64" ]; then CFG_MAC_ARCHS=" x86" - elif [ "$QT_MAC_DEFUALT_ARCH" == "ppc64" ]; then + elif [ "$QT_MAC_DEFAULT_ARCH" == "ppc64" ]; then CFG_MAC_ARCHS=" ppc" else - CFG_MAC_ARCHS=" $QT_MAC_DEFUALT_ARCH" + CFG_MAC_ARCHS=" $QT_MAC_DEFAULT_ARCH" fi [ "$OPT_VERBOSE" == "yes" ] && echo "Setting Mac architechture to$CFG_MAC_ARCHS." -- cgit v0.12 From fb622fa47ef81dfa95b9351d87b3415b9e03a368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 3 Aug 2009 15:19:22 +0200 Subject: Fixed some perspective transform rendering bugs. The bugs were caused by not clipping to the near plane (w = 0) when mapping primitives with perspective tranfsorms. Task-id: 258961 Reviewed-by: Gunnar --- src/gui/painting/qdatabuffer_p.h | 17 ------ src/gui/painting/qoutlinemapper.cpp | 67 ++++------------------- src/gui/painting/qpaintengineex.cpp | 106 +++++++++++++++--------------------- src/gui/painting/qtransform.cpp | 47 ++++++++-------- 4 files changed, 82 insertions(+), 155 deletions(-) diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h index b568f43..275ec13 100644 --- a/src/gui/painting/qdatabuffer_p.h +++ b/src/gui/painting/qdatabuffer_p.h @@ -114,23 +114,6 @@ public: qSwap(buffer, other.buffer); } - inline void insertBlank(int pos, int count) { - Q_ASSERT(pos >= 0); - Q_ASSERT(pos < siz); - reserve(siz + count); - for (int i = siz - pos - 1; i >= 0; --i) - buffer[pos + count + i] = buffer[pos + i]; - siz += count; - } - - inline void removeAndShift(int pos, int count) { - Q_ASSERT(pos >= 0); - Q_ASSERT(pos < siz); - for (int i=pos; i 3) - m_element_types.insertBlank(t, segment.size() - 3); - else if (segment.size() < 3) - m_element_types.removeAndShift(t, 3 - segment.size()); - - for (QPolygonF::const_iterator it = segment.constBegin(); - it < segment.constEnd(); ++it, ++t) { - m_elements_dev << *it * matrix; - m_element_types.at(t) = QPainterPath::LineToElement; - } - i += 2; - } break; - default: - Q_ASSERT(false); - break; - } - } - element_count = m_elements_dev.size(); - } + const QVectorPath vp((qreal *)m_elements.data(), m_elements.size(), m_element_types.data()); + QPainterPath path = vp.convertToPainterPath(); + path = QTransform(m_m11, m_m12, m_m13, m_m21, m_m22, m_m23, m_dx, m_dy, m_m33).map(path); + uint old_txop = m_txop; + m_txop = QTransform::TxNone; + if (path.isEmpty()) + m_valid = false; + else + convertPath(path); + m_txop = old_txop; + return; } elements = m_elements_dev.data(); } if (m_round_coords) { // round coordinates to match outlines drawn with drawLine_midpoint_i - for (int i = 0; i < element_count; ++i) + for (int i = 0; i < m_elements.size(); ++i) elements[i] = QPointF(qFloor(elements[i].x() + aliasedCoordinateDelta), qFloor(elements[i].y() + aliasedCoordinateDelta)); } -#ifdef QT_DEBUG_CONVERT - for (int i=0; iactiveStroker->begin(d->strokeHandler); d->strokeHandler->types.reset(); d->strokeHandler->pts.reset(); @@ -430,13 +429,13 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin) flags |= QVectorPath::CurvedShapeHint; - // ### Perspective Xforms are currently not supported... qreal txscale = 1; if (!(pen.isCosmetic() || (qt_scaleForTransform(state()->matrix, &txscale) && txscale != 1))) { // We include cosmetic pens in this case to avoid having to // 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->begin(d->strokeHandler); if (types) { while (points < lastPoint) { switch (*types) { @@ -491,79 +490,64 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) const qreal strokeWidth = d->stroker.strokeWidth(); d->stroker.setStrokeWidth(strokeWidth * txscale); // For cosmetic pens we need a bit of trickery... We to process xform the input points - if (types) { - bool isProject = state()->matrix.type() >= QTransform::TxProject; - while (points < lastPoint) { - switch (*types) { - case QPainterPath::MoveToElement: { - QPointF pt = (*(QPointF *) points) * state()->matrix; - d->activeStroker->moveTo(pt.x(), pt.y()); - points += 2; - ++types; - break; - } - case QPainterPath::LineToElement: { - QPointF pt = (*(QPointF *) points) * state()->matrix; - d->activeStroker->lineTo(pt.x(), pt.y()); - points += 2; - ++types; - break; - } - case QPainterPath::CurveToElement: { - // Convert projective xformed curves to line - // segments so they can be transformed more - // accurately - if (isProject) { - // -1 access here is safe because there is - // always an element prior to the cubicTo, we - // just need the value.. - QPolygonF segment = - QBezier::fromPoints(*(((QPointF *) points) - 1), - *((QPointF *) points), - *(((QPointF *) points) + 1), - *(((QPointF *) points) + 2)).toPolygon(); - - for (QPolygonF::const_iterator it = segment.constBegin(); - it < segment.constEnd(); ++it) { - const QPointF pt = *it * state()->matrix; - d->activeStroker->lineTo(pt.x(), pt.y()); - } - } else { + if (state()->matrix.type() >= QTransform::TxProject) { + QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath()); + d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform()); + } else { + d->activeStroker->begin(d->strokeHandler); + if (types) { + while (points < lastPoint) { + switch (*types) { + case QPainterPath::MoveToElement: { + QPointF pt = (*(QPointF *) points) * state()->matrix; + d->activeStroker->moveTo(pt.x(), pt.y()); + points += 2; + ++types; + break; + } + case QPainterPath::LineToElement: { + QPointF pt = (*(QPointF *) points) * state()->matrix; + d->activeStroker->lineTo(pt.x(), pt.y()); + points += 2; + ++types; + break; + } + case QPainterPath::CurveToElement: { QPointF c1 = ((QPointF *) points)[0] * state()->matrix; QPointF c2 = ((QPointF *) points)[1] * state()->matrix; QPointF e = ((QPointF *) points)[2] * state()->matrix; d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y()); + points += 6; + types += 3; + flags |= QVectorPath::CurvedShapeHint; + break; + } + default: + break; } - points += 6; - types += 3; - flags |= QVectorPath::CurvedShapeHint; - break; } - default: - break; + if (path.hasImplicitClose()) { + QPointF pt = * ((QPointF *) path.points()) * state()->matrix; + d->activeStroker->lineTo(pt.x(), pt.y()); } - } - if (path.hasImplicitClose()) { - QPointF pt = * ((QPointF *) path.points()) * state()->matrix; - d->activeStroker->lineTo(pt.x(), pt.y()); - } - } else { - QPointF p = ((QPointF *)points)[0] * state()->matrix; - d->activeStroker->moveTo(p.x(), p.y()); - points += 2; - ++types; - while (points < lastPoint) { + } else { QPointF p = ((QPointF *)points)[0] * state()->matrix; - d->activeStroker->lineTo(p.x(), p.y()); + d->activeStroker->moveTo(p.x(), p.y()); points += 2; ++types; + while (points < lastPoint) { + QPointF p = ((QPointF *)points)[0] * state()->matrix; + d->activeStroker->lineTo(p.x(), p.y()); + points += 2; + ++types; + } + if (path.hasImplicitClose()) + d->activeStroker->lineTo(p.x(), p.y()); } - if (path.hasImplicitClose()) - d->activeStroker->lineTo(p.x(), p.y()); + d->activeStroker->end(); } - d->activeStroker->end(); d->stroker.setStrokeWidth(strokeWidth); QVectorPath strokePath(d->strokeHandler->pts.data(), d->strokeHandler->types.size(), diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index a322fe4..0a64e4e 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -48,6 +48,8 @@ #include "qvariant.h" #include +#include + QT_BEGIN_NAMESPACE #define Q_NEAR_CLIP 0.000001 @@ -1492,27 +1494,12 @@ static inline bool lineTo_clipped(QPainterPath &path, const QTransform &transfor static inline bool cubicTo_clipped(QPainterPath &path, const QTransform &transform, const QPointF &a, const QPointF &b, const QPointF &c, const QPointF &d, bool needsMoveTo) { - const QHomogeneousCoordinate ha = mapHomogeneous(transform, a); - const QHomogeneousCoordinate hb = mapHomogeneous(transform, b); - const QHomogeneousCoordinate hc = mapHomogeneous(transform, c); - const QHomogeneousCoordinate hd = mapHomogeneous(transform, d); - - if (ha.w < Q_NEAR_CLIP && hb.w < Q_NEAR_CLIP && hc.w < Q_NEAR_CLIP && hd.w < Q_NEAR_CLIP) - return false; + // Convert projective xformed curves to line + // segments so they can be transformed more accurately + QPolygonF segment = QBezier::fromPoints(a, b, c, d).toPolygon(); - if (ha.w >= Q_NEAR_CLIP && hb.w >= Q_NEAR_CLIP && hc.w >= Q_NEAR_CLIP && hd.w >= Q_NEAR_CLIP) { - if (needsMoveTo) - path.moveTo(ha.toPoint()); - - path.cubicTo(hb.toPoint(), hc.toPoint(), hd.toPoint()); - return true; - } - - if (lineTo_clipped(path, transform, a, b, needsMoveTo)) - needsMoveTo = false; - if (lineTo_clipped(path, transform, b, c, needsMoveTo)) - needsMoveTo = false; - if (lineTo_clipped(path, transform, c, d, needsMoveTo)) + for (int i = 0; i < segment.size() - 1; ++i) + if (lineTo_clipped(path, transform, segment.at(i), segment.at(i+1), needsMoveTo)) needsMoveTo = false; return !needsMoveTo; @@ -1793,6 +1780,14 @@ void QTransform::setMatrix(qreal m11, qreal m12, qreal m13, m_dirty = TxProject; } +static inline bool needsPerspectiveClipping(const QRectF &rect, const QTransform &transform) +{ + const qreal wx = qMin(transform.m13() * rect.left(), transform.m13() * rect.right()); + const qreal wy = qMin(transform.m23() * rect.top(), transform.m23() * rect.bottom()); + + return wx + wy + transform.m33() < Q_NEAR_CLIP; +} + QRect QTransform::mapRect(const QRect &rect) const { TransformationType t = inline_type(); @@ -1813,7 +1808,7 @@ QRect QTransform::mapRect(const QRect &rect) const y -= h; } return QRect(x, y, w, h); - } else { + } else if (t < TxProject || !needsPerspectiveClipping(rect, *this)) { // see mapToPolygon for explanations of the algorithm. qreal x = 0, y = 0; MAP(rect.left(), rect.top(), x, y); @@ -1837,6 +1832,10 @@ QRect QTransform::mapRect(const QRect &rect) const xmax = qMax(xmax, x); ymax = qMax(ymax, y); return QRect(qRound(xmin), qRound(ymin), qRound(xmax)-qRound(xmin), qRound(ymax)-qRound(ymin)); + } else { + QPainterPath path; + path.addRect(rect); + return map(path).boundingRect().toRect(); } } @@ -1879,7 +1878,7 @@ QRectF QTransform::mapRect(const QRectF &rect) const y -= h; } return QRectF(x, y, w, h); - } else { + } else if (t < TxProject || !needsPerspectiveClipping(rect, *this)) { qreal x = 0, y = 0; MAP(rect.x(), rect.y(), x, y); qreal xmin = x; @@ -1902,6 +1901,10 @@ QRectF QTransform::mapRect(const QRectF &rect) const xmax = qMax(xmax, x); ymax = qMax(ymax, y); return QRectF(xmin, ymin, xmax-xmin, ymax - ymin); + } else { + QPainterPath path; + path.addRect(rect); + return map(path).boundingRect(); } } -- cgit v0.12 From 3d5ffba1a183bbe3d930158e87f65f858b78559c Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Mon, 3 Aug 2009 17:18:44 +0200 Subject: Fix compile error on WinCE. Reviewed-by: TrustMe --- src/activeqt/container/qaxwidget.cpp | 4 ++++ src/activeqt/control/qaxserverbase.cpp | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index 19f00db..ff6bcb8 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -985,7 +985,11 @@ HRESULT WINAPI QAxClientSite::TranslateAccelerator(LPMSG lpMsg, DWORD /*grfModif bool ActiveQtDetected = false; bool fromInProcServer = false; +#ifdef GWLP_USERDATA LONG_PTR serverType = GetWindowLongPtr(lpMsg->hwnd, GWLP_USERDATA); +#else + LONG serverType = GetWindowLong(lpMsg->hwnd, GWL_USERDATA); +#endif if (serverType == QAX_INPROC_SERVER) { ActiveQtDetected = true; fromInProcServer = true; diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index e482c60..e7ddb47 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -3605,15 +3605,26 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg) return S_FALSE; bool resetUserData = false; // set server type in the user-data of the window. +#ifdef GWLP_USERDATA LONG_PTR serverType = QAX_INPROC_SERVER; +#else + LONG serverType = QAX_INPROC_SERVER; +#endif if (qAxOutProcServer) serverType = QAX_OUTPROC_SERVER; +#ifdef GWLP_USERDATA LONG_PTR oldData = SetWindowLongPtr(pMsg->hwnd, GWLP_USERDATA, serverType); +#else + LONG oldData = SetWindowLong(pMsg->hwnd, GWL_USERDATA, serverType); +#endif HRESULT hres = controlSite->TranslateAcceleratorW(pMsg, dwKeyMod); controlSite->Release(); // reset the user-data for the window. +#ifdef GWLP_USERDATA SetWindowLongPtr(pMsg->hwnd, GWLP_USERDATA, oldData); - +#else + SetWindowLong(pMsg->hwnd, GWL_USERDATA, oldData); +#endif return hres; } -- cgit v0.12 From 2076f150995e541308b1d8da936b3e12ab68b886 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 3 Aug 2009 17:20:16 +0200 Subject: Fixed "Hightlighted menu items not always selected" bug. Menu paintEvent was not called when the mouse cursor lied between the menu item area and the menu frame border. Task-number: 258920 Reviewed-by: olivier --- src/gui/widgets/qmenu.cpp | 2 +- tests/auto/qmenu/tst_qmenu.cpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 8eec0fc..0b85eec 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -2721,7 +2721,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) QAction *action = d->actionAt(e->pos()); if (!action) { - if (d->hasHadMouse && !rect().contains(e->pos())) + if (d->hasHadMouse) d->setCurrentAction(0); return; } else if(e->buttons()) { diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 1d19ffa..ec9c7b4 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -95,6 +95,7 @@ private slots: void task250673_activeMultiColumnSubMenuPosition(); void task256918_setFont(); void menuSizeHint(); + void task258920_mouseBorder(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -763,5 +764,40 @@ void tst_QMenu::menuSizeHint() QCOMPARE(resSize, menu.sizeHint()); } +class Menu258920 : public QMenu +{ + Q_OBJECT +public slots: + void paintEvent(QPaintEvent *e) + { + QMenu::paintEvent(e); + painted = true; + } + +public: + bool painted; +}; + +void tst_QMenu::task258920_mouseBorder() +{ + Menu258920 menu; + QAction *action = menu.addAction("test"); + + menu.popup(QPoint()); + QTest::qWait(100); + QRect actionRect = menu.actionGeometry(action); + QTest::mouseMove(&menu, actionRect.center()); + QTest::qWait(30); + QTest::mouseMove(&menu, actionRect.center() + QPoint(10, 0)); + QTest::qWait(30); + QCOMPARE(action, menu.activeAction()); + menu.painted = false; + QTest::mouseMove(&menu, QPoint(actionRect.center().x(), actionRect.bottom() + 1)); + QTest::qWait(30); + QCOMPARE(static_cast(0), menu.activeAction()); + QVERIFY(menu.painted); +} + + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" -- cgit v0.12 From acc9bc4d9dd3b7a1fef10fe88bfa753e515cdd3e Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 4 Aug 2009 10:59:02 +1000 Subject: Doc fixes Reviewed-by: TrustMe --- doc/src/properties.qdoc | 2 +- src/corelib/kernel/qabstractitemmodel.cpp | 4 ++++ src/corelib/kernel/qmetaobject.cpp | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/src/properties.qdoc b/doc/src/properties.qdoc index 2d03e91..d0a9ccc 100644 --- a/doc/src/properties.qdoc +++ b/doc/src/properties.qdoc @@ -126,7 +126,7 @@ value is constant. For a given object instance, the READ method of a constant property must return the same value every time it is called. This constant value may be different for different instances of the object. A - constant property cannot have a WRTE method or a NOTIFY signal. + constant property cannot have a WRITE method or a NOTIFY signal. \o The presence of the \c FINAL attribute indicates that the property will not be overridden by a derived class. This can be used for performance diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index bc95c60..5d5d4cc 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -1884,6 +1884,8 @@ QSize QAbstractItemModel::span(const QModelIndex &) const } /*! + \since 4.6 + Sets the model's role names to \a roleNames. This function is provided to allow mapping of role identifiers to @@ -1900,6 +1902,8 @@ void QAbstractItemModel::setRoleNames(const QHash &roleNames) } /*! + \since 4.6 + Returns the model's role names. \sa setRoleNames() diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 9ff0bc1..d43c5dd 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1352,6 +1352,8 @@ int QMetaMethod::attributes() const } /*! + \since 4.6 + Returns this method's index. */ int QMetaMethod::methodIndex() const @@ -2076,6 +2078,8 @@ int QMetaProperty::userType() const } /*! + \since 4.6 + Returns this property's index. */ int QMetaProperty::propertyIndex() const -- cgit v0.12 From c05a595cde1327edea3a72c6fa13d2351c02805d Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 4 Aug 2009 13:38:51 +1000 Subject: Fix obsolete license headers Reviewed-by: Trust Me --- doc/src/examples/frozencolumn.qdoc | 4 ++-- doc/src/qsqldatatype-table.qdoc | 4 ++-- examples/itemviews/frozencolumn/freezetablewidget.cpp | 4 ++-- examples/itemviews/frozencolumn/freezetablewidget.h | 5 ++--- examples/itemviews/frozencolumn/main.cpp | 5 ++--- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/doc/src/examples/frozencolumn.qdoc b/doc/src/examples/frozencolumn.qdoc index e5a3b59..9d89478 100644 --- a/doc/src/examples/frozencolumn.qdoc +++ b/doc/src/examples/frozencolumn.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/doc/src/qsqldatatype-table.qdoc b/doc/src/qsqldatatype-table.qdoc index 5ab6413..60c9dcf 100644 --- a/doc/src/qsqldatatype-table.qdoc +++ b/doc/src/qsqldatatype-table.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/itemviews/frozencolumn/freezetablewidget.cpp b/examples/itemviews/frozencolumn/freezetablewidget.cpp index 7a9a8df..4326763 100644 --- a/examples/itemviews/frozencolumn/freezetablewidget.cpp +++ b/examples/itemviews/frozencolumn/freezetablewidget.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the examples of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/itemviews/frozencolumn/freezetablewidget.h b/examples/itemviews/frozencolumn/freezetablewidget.h index 2abae47..f7b8e43 100644 --- a/examples/itemviews/frozencolumn/freezetablewidget.h +++ b/examples/itemviews/frozencolumn/freezetablewidget.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the examples of the Qt Toolkit. ** @@ -34,12 +34,11 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ - #ifndef FREEZETABLEWIDGET_H #define FREEZETABLEWIDGET_H diff --git a/examples/itemviews/frozencolumn/main.cpp b/examples/itemviews/frozencolumn/main.cpp index fdefd73..9f6a637 100644 --- a/examples/itemviews/frozencolumn/main.cpp +++ b/examples/itemviews/frozencolumn/main.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the examples of the Qt Toolkit. ** @@ -34,12 +34,11 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ - #include #include #include -- cgit v0.12 From 0b5511f621159a1a0a13650f94811a218e2c126a Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 4 Aug 2009 14:49:14 +1000 Subject: Fix obsolete license headers Reviewed-by: Trust Me --- mkspecs/unsupported/vxworks-ppc-dcc/qplatformdefs.h | 4 ++-- mkspecs/unsupported/vxworks-ppc-g++/qplatformdefs.h | 4 ++-- mkspecs/unsupported/vxworks-simpentium-dcc/qplatformdefs.h | 4 ++-- mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h | 4 ++-- src/corelib/arch/qatomic_vxworks.h | 2 +- src/corelib/kernel/qfunctions_vxworks.cpp | 4 ++-- src/corelib/kernel/qfunctions_vxworks.h | 2 +- src/gui/graphicsview/qgraphicstransform.cpp | 4 ++-- src/gui/widgets/qlinecontrol.cpp | 4 ++-- src/gui/widgets/qlineedit_p.cpp | 4 ++-- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mkspecs/unsupported/vxworks-ppc-dcc/qplatformdefs.h b/mkspecs/unsupported/vxworks-ppc-dcc/qplatformdefs.h index 4b0c24c..a1735d0 100644 --- a/mkspecs/unsupported/vxworks-ppc-dcc/qplatformdefs.h +++ b/mkspecs/unsupported/vxworks-ppc-dcc/qplatformdefs.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the qmake spec of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/mkspecs/unsupported/vxworks-ppc-g++/qplatformdefs.h b/mkspecs/unsupported/vxworks-ppc-g++/qplatformdefs.h index 4b0c24c..a1735d0 100644 --- a/mkspecs/unsupported/vxworks-ppc-g++/qplatformdefs.h +++ b/mkspecs/unsupported/vxworks-ppc-g++/qplatformdefs.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the qmake spec of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/mkspecs/unsupported/vxworks-simpentium-dcc/qplatformdefs.h b/mkspecs/unsupported/vxworks-simpentium-dcc/qplatformdefs.h index 4b0c24c..a1735d0 100644 --- a/mkspecs/unsupported/vxworks-simpentium-dcc/qplatformdefs.h +++ b/mkspecs/unsupported/vxworks-simpentium-dcc/qplatformdefs.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the qmake spec of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h b/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h index 90eb955..b3eefea 100644 --- a/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h +++ b/mkspecs/unsupported/vxworks-simpentium-g++/qplatformdefs.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the qmake spec of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/arch/qatomic_vxworks.h b/src/corelib/arch/qatomic_vxworks.h index 573a44d..b441210 100644 --- a/src/corelib/arch/qatomic_vxworks.h +++ b/src/corelib/arch/qatomic_vxworks.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qfunctions_vxworks.cpp b/src/corelib/kernel/qfunctions_vxworks.cpp index 6d5e7cc..def8f4c 100644 --- a/src/corelib/kernel/qfunctions_vxworks.cpp +++ b/src/corelib/kernel/qfunctions_vxworks.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtCore module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qfunctions_vxworks.h b/src/corelib/kernel/qfunctions_vxworks.h index cc98948..e31d495 100644 --- a/src/corelib/kernel/qfunctions_vxworks.h +++ b/src/corelib/kernel/qfunctions_vxworks.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index 890aff7..778cd94 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtDeclarative module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 106d8f2..f68d287 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp index 0e39304..f0ec8ad 100644 --- a/src/gui/widgets/qlineedit_p.cpp +++ b/src/gui/widgets/qlineedit_p.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v0.12 From 5fb4b30f96679d000086a49a2d25372421193a88 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 4 Aug 2009 14:57:36 +1000 Subject: Fixes failed queries when mysql auto-prepares Queries like "Show Index" etc, fail on mysql when automatically prepared due to a bug in several versions of mysql. Basically anything but a select query will fail. This fixes this by making the user explicitly prepare the query if they want to, and the blame then falls on them if they try and prepare a statement likely to fail. This fix also seems to result in a speedup for single-execution queries, possibly due to reduction in roundtrip communications. All autotests pass & behaviour conforms to documentation. Task-number: 252450, 246125 --- src/sql/drivers/mysql/qsql_mysql.cpp | 47 ++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index bd6f7b9..39ef1ef 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -85,11 +85,10 @@ public: #else tc(0), #endif - preparedQuerys(false), preparedQuerysEnabled(false) {} + preparedQuerysEnabled(false) {} MYSQL *mysql; QTextCodec *tc; - bool preparedQuerys; bool preparedQuerysEnabled; }; @@ -172,6 +171,7 @@ public: #if MYSQL_VERSION_ID >= 40108 , stmt(0), meta(0), inBinds(0), outBinds(0) #endif + , preparedQuery(false) { connect(dp, SIGNAL(destroyed()), this, SLOT(driverDestroyed())); } @@ -209,6 +209,9 @@ public: MYSQL_BIND *inBinds; MYSQL_BIND *outBinds; #endif + + bool preparedQuery; + private Q_SLOTS: void driverDestroyed() { driver = NULL; } }; @@ -399,7 +402,7 @@ QMYSQLResult::~QMYSQLResult() QVariant QMYSQLResult::handle() const { #if MYSQL_VERSION_ID >= 40108 - if(d->driver && d->driver->d->preparedQuerys) + if(d->preparedQuery) return d->meta ? qVariantFromValue(d->meta) : qVariantFromValue(d->stmt); else #endif @@ -454,9 +457,6 @@ void QMYSQLResult::cleanup() d->row = NULL; setAt(-1); setActive(false); - - if(d->driver) - d->driver->d->preparedQuerys = d->driver->d->preparedQuerysEnabled; } bool QMYSQLResult::fetch(int i) @@ -474,7 +474,7 @@ bool QMYSQLResult::fetch(int i) } if (at() == i) return true; - if (d->driver->d->preparedQuerys) { + if (d->preparedQuery) { #if MYSQL_VERSION_ID >= 40108 mysql_stmt_data_seek(d->stmt, i); @@ -507,7 +507,7 @@ bool QMYSQLResult::fetchNext() { if(!d->driver) return false; - if (d->driver->d->preparedQuerys) { + if (d->preparedQuery) { #if MYSQL_VERSION_ID >= 40108 if (mysql_stmt_fetch(d->stmt)) return false; @@ -534,7 +534,7 @@ bool QMYSQLResult::fetchLast() } my_ulonglong numRows; - if (d->driver->d->preparedQuerys) { + if (d->preparedQuery) { #if MYSQL_VERSION_ID >= 40108 numRows = mysql_stmt_num_rows(d->stmt); #else @@ -574,7 +574,7 @@ QVariant QMYSQLResult::data(int field) int fieldLength = 0; const QMYSQLResultPrivate::QMyField &f = d->fields.at(field); QString val; - if (d->driver->d->preparedQuerys) { + if (d->preparedQuery) { if (f.nullIndicator) return QVariant(f.type); @@ -634,7 +634,7 @@ QVariant QMYSQLResult::data(int field) case QVariant::ByteArray: { QByteArray ba; - if (d->driver->d->preparedQuerys) { + if (d->preparedQuery) { ba = QByteArray(f.outField, f.bufLength); } else { ba = QByteArray(d->row[field], fieldLength); @@ -651,7 +651,7 @@ QVariant QMYSQLResult::data(int field) bool QMYSQLResult::isNull(int field) { - if (d->driver->d->preparedQuerys) + if (d->preparedQuery) return d->fields.at(field).nullIndicator; else return d->row[field] == NULL; @@ -662,11 +662,9 @@ bool QMYSQLResult::reset (const QString& query) if (!driver() || !driver()->isOpen() || driver()->isOpenError() || !d->driver) return false; - if(d->driver->d->preparedQuerysEnabled && prepare(query)) { - d->driver->d->preparedQuerys = true; - return exec(); - } - d->driver->d->preparedQuerys = false; + d->preparedQuery = false; + + cleanup(); const QByteArray encQuery(fromUnicode(d->driver->d->tc, query)); if (mysql_real_query(d->driver->d->mysql, encQuery.data(), encQuery.length())) { @@ -699,7 +697,7 @@ bool QMYSQLResult::reset (const QString& query) int QMYSQLResult::size() { if (d->driver && isSelect()) - if (d->driver->d->preparedQuerys) + if (d->preparedQuery) #if MYSQL_VERSION_ID >= 40108 return mysql_stmt_num_rows(d->stmt); #else @@ -721,7 +719,7 @@ QVariant QMYSQLResult::lastInsertId() const if (!isActive() || !d->driver) return QVariant(); - if (d->driver->d->preparedQuerys) { + if (d->preparedQuery) { #if MYSQL_VERSION_ID >= 40108 quint64 id = mysql_stmt_insert_id(d->stmt); if (id) @@ -743,7 +741,7 @@ QSqlRecord QMYSQLResult::record() const return info; #if MYSQL_VERSION_ID >= 40108 - res = d->driver->d->preparedQuerys ? d->meta : d->result; + res = d->preparedQuery ? d->meta : d->result; #else res = d->result; #endif @@ -856,7 +854,7 @@ bool QMYSQLResult::prepare(const QString& query) return false; #if MYSQL_VERSION_ID >= 40108 cleanup(); - if (!d->driver->d->preparedQuerys) + if (!d->driver->d->preparedQuerysEnabled) return QSqlResult::prepare(query); int r; @@ -886,6 +884,7 @@ bool QMYSQLResult::prepare(const QString& query) } setSelect(d->bindInValues()); + d->preparedQuery = true; return true; #else return false; @@ -896,7 +895,7 @@ bool QMYSQLResult::exec() { if (!d->driver) return false; - if (!d->driver->d->preparedQuerys) + if (!d->preparedQuery) return QSqlResult::exec(); if (!d->stmt) return false; @@ -1338,9 +1337,6 @@ QSqlIndex QMYSQLDriver::primaryIndex(const QString& tablename) const if (!isOpen()) return idx; - prepQ = d->preparedQuerysEnabled; - d->preparedQuerysEnabled = false; - QSqlQuery i(createResult()); QString stmt(QLatin1String("show index from %1;")); QSqlRecord fil = record(tablename); @@ -1353,7 +1349,6 @@ QSqlIndex QMYSQLDriver::primaryIndex(const QString& tablename) const } } - d->preparedQuerysEnabled = prepQ; return idx; } -- cgit v0.12 From 745ecf9cf48bc718690fa8b2149eb6dbbb64fcc6 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 4 Aug 2009 15:40:15 +1000 Subject: Fix incorrect license headers. Reviewed-by: Trust Me --- src/corelib/tools/qbytedata_p.h | 12 +++++++++++- src/gui/embedded/qkbdqnx_qws.cpp | 10 +++++----- src/gui/embedded/qkbdqnx_qws.h | 10 +++++----- src/gui/embedded/qmouseqnx_qws.cpp | 10 +++++----- src/gui/embedded/qmouseqnx_qws.h | 10 +++++----- src/gui/embedded/qscreenqnx_qws.cpp | 10 +++++----- src/gui/embedded/qscreenqnx_qws.h | 10 +++++----- 7 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/corelib/tools/qbytedata_p.h b/src/corelib/tools/qbytedata_p.h index cc10ea2..f3724f6 100644 --- a/src/corelib/tools/qbytedata_p.h +++ b/src/corelib/tools/qbytedata_p.h @@ -42,8 +42,18 @@ #ifndef QBYTEDATA_H #define QBYTEDATA_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. +// +#include QT_BEGIN_NAMESPACE diff --git a/src/gui/embedded/qkbdqnx_qws.cpp b/src/gui/embedded/qkbdqnx_qws.cpp index 06163c7..089b868 100644 --- a/src/gui/embedded/qkbdqnx_qws.cpp +++ b/src/gui/embedded/qkbdqnx_qws.cpp @@ -6,11 +6,11 @@ ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser diff --git a/src/gui/embedded/qkbdqnx_qws.h b/src/gui/embedded/qkbdqnx_qws.h index c046c8d..fa3ae56 100644 --- a/src/gui/embedded/qkbdqnx_qws.h +++ b/src/gui/embedded/qkbdqnx_qws.h @@ -6,11 +6,11 @@ ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser diff --git a/src/gui/embedded/qmouseqnx_qws.cpp b/src/gui/embedded/qmouseqnx_qws.cpp index 98f8f06..59cd5be 100644 --- a/src/gui/embedded/qmouseqnx_qws.cpp +++ b/src/gui/embedded/qmouseqnx_qws.cpp @@ -6,11 +6,11 @@ ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser diff --git a/src/gui/embedded/qmouseqnx_qws.h b/src/gui/embedded/qmouseqnx_qws.h index a61562e..f8cad4a 100644 --- a/src/gui/embedded/qmouseqnx_qws.h +++ b/src/gui/embedded/qmouseqnx_qws.h @@ -6,11 +6,11 @@ ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser diff --git a/src/gui/embedded/qscreenqnx_qws.cpp b/src/gui/embedded/qscreenqnx_qws.cpp index 7101bc7..c79ee59 100644 --- a/src/gui/embedded/qscreenqnx_qws.cpp +++ b/src/gui/embedded/qscreenqnx_qws.cpp @@ -6,11 +6,11 @@ ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser diff --git a/src/gui/embedded/qscreenqnx_qws.h b/src/gui/embedded/qscreenqnx_qws.h index 837c061..30312fe 100644 --- a/src/gui/embedded/qscreenqnx_qws.h +++ b/src/gui/embedded/qscreenqnx_qws.h @@ -6,11 +6,11 @@ ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -- cgit v0.12 From e83f77cbc22be5e37de1e7a8ec2c55e66f7b51d9 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Tue, 4 Aug 2009 09:31:56 +0200 Subject: Build on snow leopard. Don't error out when building qmake, just let it build a 64-bit binary (even for carbon) RebBy: Richard Moe Gustavsen --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index f650bd2..e05c05d 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -279,7 +279,7 @@ namespace QT_NAMESPACE {} # endif #endif -#if defined(Q_OS_MAC64) && !defined(QT_MAC_USE_COCOA) +#if defined(Q_OS_MAC64) && !defined(QT_MAC_USE_COCOA) && !defined(QT_BUILD_QMAKE) #error "You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration." #endif -- cgit v0.12 From 4f7170d9d731234c65008b690a95a0e86d397db5 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Tue, 4 Aug 2009 08:15:21 +0200 Subject: Make Cocoa builds 64-bit by default on snow leopard. --- configure | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/configure b/configure index 2f2e284..095d040 100755 --- a/configure +++ b/configure @@ -5707,17 +5707,23 @@ if [ "$CFG_MAC_DWARF2" = "yes" ]; then QT_CONFIG="$QT_CONFIG dwarf2" fi -# Set the default arch. Select 32-bit/carbon if nothing else has -# been specified on the configure line. +# Set the default arch. +# Carbon builds: 32 bit x86/ppc. +# For "-cocoa" builds on snow leopard : compiler default (64-bit). +# For "-cocoa" builds on leopard : compiler default (32-bit). if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_ARCHS" == "" ]; then source "$mactests/defaultarch.test" "$TEST_COMPILER" "$OPT_VERBOSE" "$mactests" - if [ "$QT_MAC_DEFAULT_ARCH" == "x86_64" ]; then - CFG_MAC_ARCHS=" x86" - elif [ "$QT_MAC_DEFAULT_ARCH" == "ppc64" ]; then - CFG_MAC_ARCHS=" ppc" - else - CFG_MAC_ARCHS=" $QT_MAC_DEFAULT_ARCH" + if [ "$CFG_MAC_COCOA" != "yes" ]; then + if [ "$QT_MAC_DEFAULT_ARCH" == "x86_64" ]; then + CFG_MAC_ARCHS=" x86" + elif [ "$QT_MAC_DEFAULT_ARCH" == "ppc64" ]; then + CFG_MAC_ARCHS=" ppc" + else + CFG_MAC_ARCHS=" $QT_MAC_DEFAULT_ARCH" + fi + else + CFG_MAC_ARCHS=" $QT_MAC_DEFAULT_ARCH" fi [ "$OPT_VERBOSE" == "yes" ] && echo "Setting Mac architechture to$CFG_MAC_ARCHS." -- cgit v0.12 From 83a82f900aa63a350b66d90ed55f63ee77f20250 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Tue, 4 Aug 2009 09:31:56 +0200 Subject: Build on snow leopard. Don't error out when building qmake, just let it build a 64-bit binary (even for carbon) RebBy: Richard Moe Gustavsen --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 8263bae..c266ca0 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -279,7 +279,7 @@ namespace QT_NAMESPACE {} # endif #endif -#if defined(Q_OS_MAC64) && !defined(QT_MAC_USE_COCOA) +#if defined(Q_OS_MAC64) && !defined(QT_MAC_USE_COCOA) && !defined(QT_BUILD_QMAKE) #error "You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration." #endif -- cgit v0.12 From 1f0ea657d33b6851c1f3cb4becd77c63d4b720d8 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Tue, 4 Aug 2009 09:47:05 +0200 Subject: Remove the "preliminary support" warning for 10.6 Also make the "usupported on > 10.6" error a warning. No need to stop the build, the warning will be printed enough times. --- src/corelib/global/qglobal.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index c266ca0..18d5a9f 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -311,11 +311,8 @@ namespace QT_NAMESPACE {} # if !defined(MAC_OS_X_VERSION_10_6) # define MAC_OS_X_VERSION_10_6 MAC_OS_X_VERSION_10_5 + 1 # endif -# if (MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_6) -# warning "Support for this version of Mac OS X is still preliminary" -# endif # if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6) -# error "This version of Mac OS X is unsupported" +# warning "This version of Mac OS X is unsupported" # endif #endif -- cgit v0.12 From c96ed4426db7ae3287ee88b0ac7ffd2bd5070310 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 4 Aug 2009 09:43:14 +0200 Subject: Add support for pan gesture on mac (carbon and cocoa) --- src/gui/kernel/qstandardgestures.cpp | 64 ++++++++++++++++++++++++++++++++++++ src/gui/kernel/qstandardgestures_p.h | 6 ++++ 2 files changed, 70 insertions(+) diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index c8b11c5..1a88429 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -73,11 +73,17 @@ QPanGesture::QPanGesture(QWidget *parent) qAppPriv->widgetGestures[parent].pan = this; } #endif + +#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) + d_func()->panFinishedTimer = 0; +#endif } /*! \internal */ bool QPanGesture::event(QEvent *event) { + Q_D(QPanGesture); + #ifdef Q_WS_WIN QApplicationPrivate* getQApplicationPrivateInternal(); switch (event->type()) { @@ -93,6 +99,21 @@ bool QPanGesture::event(QEvent *event) break; } #endif + +#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) + if (event->type() == QEvent::Timer) { + const QTimerEvent *te = static_cast(event); + if (te->timerId() == d->panFinishedTimer) { + killTimer(d->panFinishedTimer); + d->panFinishedTimer = 0; + d->lastOffset = QSize(0, 0); + setState(Qt::GestureFinished); + emit triggered(); + setState(Qt::NoGesture); + } + } +#endif + return QObject::event(event); } @@ -133,6 +154,36 @@ bool QPanGesture::filterEvent(QEvent *event) emit triggered(); } } +#ifdef Q_OS_MAC + else if (event->type() == QEvent::Wheel) { + // On Mac, there is really no native panning gesture. Instead, a two + // finger pan is delivered as mouse wheel events. Otoh, on Windows, you + // either get mouse wheel events or pan events. We have decided to make this + // the Qt behaviour as well, meaning that on Mac, wheel + // events will be masked away when listening for pan events. +#ifndef QT_MAC_USE_COCOA + // In Carbon we receive neither touch-, nor pan gesture events. + // So we create pan gestures by converting wheel events. After all, this + // is how things are supposed to work on mac in the first place. + const QWheelEvent *wev = static_cast(event); + int offset = wev->delta() / -120; + d->lastOffset = wev->orientation() == Qt::Horizontal ? QSize(offset, 0) : QSize(0, offset); + + if (state() == Qt::NoGesture) { + setState(Qt::GestureStarted); + d->totalOffset = d->lastOffset; + } else { + setState(Qt::GestureUpdated); + d->totalOffset += d->lastOffset; + } + + killTimer(d->panFinishedTimer); + d->panFinishedTimer = startTimer(200); + emit triggered(); +#endif + return true; + } +#endif return false; } @@ -150,8 +201,13 @@ void QPanGesture::reset() */ QSize QPanGesture::totalOffset() const { +#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) + Q_D(const QPanGesture); + return d->totalOffset; +#else QPoint pt = pos() - startPos(); return QSize(pt.x(), pt.y()); +#endif } /*! @@ -162,8 +218,13 @@ QSize QPanGesture::totalOffset() const */ QSize QPanGesture::lastOffset() const { +#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) + Q_D(const QPanGesture); + return d->lastOffset; +#else QPoint pt = pos() - lastPos(); return QSize(pt.x(), pt.y()); +#endif } /*! @@ -252,3 +313,6 @@ void QTapAndHoldGesture::reset() } QT_END_NAMESPACE + +#include "moc_qstandardgestures.cpp" + diff --git a/src/gui/kernel/qstandardgestures_p.h b/src/gui/kernel/qstandardgestures_p.h index bb11c9f..0fd42bd 100644 --- a/src/gui/kernel/qstandardgestures_p.h +++ b/src/gui/kernel/qstandardgestures_p.h @@ -70,6 +70,12 @@ public: QPanGesturePrivate() { } QList touchPoints; + QSize totalOffset; + QSize lastOffset; + +#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) + int panFinishedTimer; +#endif }; class QTapAndHoldGesturePrivate : public QGesturePrivate -- cgit v0.12 From d2e03cc83b5dabc5fd1986a8b8119ff8f0d76179 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 4 Aug 2009 09:45:47 +0200 Subject: Modify imagewidget example so it works with new API --- examples/gestures/imageviewer/imagewidget.cpp | 46 +++++++++------------------ 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/examples/gestures/imageviewer/imagewidget.cpp b/examples/gestures/imageviewer/imagewidget.cpp index 717bb09..0b39997 100644 --- a/examples/gestures/imageviewer/imagewidget.cpp +++ b/examples/gestures/imageviewer/imagewidget.cpp @@ -100,7 +100,7 @@ void ImageWidget::paintEvent(QPaintEvent*) p.setPen(QPen(Qt::gray, 2)); p.drawEllipse(touchFeedback.position, 5, 5); if (touchFeedback.doubleTapped) { - p.setPen(QPen(Qt::gray, 2, Qt::DotLine)); + p.setPen(QPen(Qt::darkGray, 2, Qt::DotLine)); p.drawEllipse(touchFeedback.position, 15, 15); } else if (touchFeedback.tapAndHoldState != 0) { QPoint pts[8] = { @@ -159,51 +159,35 @@ void ImageWidget::gestureTriggered() touchFeedback.tapped = false; touchFeedback.doubleTapped = false; - QGesture *g = qobject_cast(sender()); if (sender() == panGesture) { + QPanGesture *pg = qobject_cast(sender()); if (zoomedIn) { - // usual panning #ifndef QT_NO_CURSOR - if (g->state() == Qt::GestureStarted) - setCursor(Qt::SizeAllCursor); - else - setCursor(Qt::ArrowCursor); + switch (pg->state()) { + case Qt::GestureStarted: + case Qt::GestureUpdated: + setCursor(Qt::SizeAllCursor); + break; + default: + setCursor(Qt::ArrowCursor); + } #endif - const int dx = g->pos().x() - g->lastPos().x(); - const int dy = g->pos().y() - g->lastPos().y(); - horizontalOffset += dx; - verticalOffset += dy; + horizontalOffset += pg->lastOffset().width(); + verticalOffset += pg->lastOffset().height(); update(); } else { // only slide gesture should be accepted - const QPanGesture *pg = static_cast(g); - if (g->state() == Qt::GestureFinished) { + if (pg->state() == Qt::GestureFinished) { touchFeedback.sliding = false; zoomed = rotated = false; - if (pg->totalOffset().width() > 0) { - qDebug() << "slide right"; + if (pg->totalOffset().width() > 0) goNextImage(); - } else { - qDebug() << "slide left"; + else goPrevImage(); - } updateImage(); } } feedbackFadeOutTimer.start(500, this); - } else if (sender() == tapAndHoldGesture) { - if (g->state() == Qt::GestureFinished) { - qDebug() << "tap and hold detected"; - touchFeedback.reset(); - update(); - - QMenu menu; - menu.addAction("Action 1"); - menu.addAction("Action 2"); - menu.addAction("Action 3"); - menu.exec(mapToGlobal(g->pos())); - } - feedbackFadeOutTimer.start(500, this); } } -- cgit v0.12 From 14f9cbbec204ba146205d12cb06577d41b5f974c Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 4 Aug 2009 10:00:01 +0200 Subject: Mac: Remove debug work output --- src/gui/painting/qregion_mac.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/painting/qregion_mac.cpp b/src/gui/painting/qregion_mac.cpp index 9b0e99f..6fe7805 100644 --- a/src/gui/painting/qregion_mac.cpp +++ b/src/gui/painting/qregion_mac.cpp @@ -173,7 +173,6 @@ RgnHandle QRegion::toQDRgnForUpdate_sys() const // detect overflow. Tested for use with HIViewSetNeedsDisplayInRegion // in QWidgetPrivate::update_sys(). enum { HIViewSetNeedsDisplayInRegionOverflow = 10000 }; // empirically determined conservative value - qDebug() << qt_r->x() << qt_r->y() << qt_r->right() << qt_r->bottom(); if (qt_r->right() > HIViewSetNeedsDisplayInRegionOverflow || qt_r->bottom() > HIViewSetNeedsDisplayInRegionOverflow) { qt_mac_dispose_rgn(tmp_rgn); qt_mac_dispose_rgn(rgnHandle); -- cgit v0.12 From d3c96863ec17a69c616bdcb12e6a99a874eba66d Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 3 Aug 2009 16:49:46 +0200 Subject: fix warnings on mingw (gcc4.4) basically reordering members initialization in constructors or fixing singed/unsigned checks. Reviewed-by: Trustme --- src/activeqt/container/qaxbase.cpp | 14 +++++++++----- src/activeqt/container/qaxwidget.cpp | 2 +- src/activeqt/shared/qaxtypes.cpp | 2 +- src/gui/painting/qregion_win.cpp | 4 ++-- src/gui/util/qcompleter.cpp | 2 +- src/opengl/qgl.cpp | 5 +++-- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp index 4fc9926..d602946 100644 --- a/src/activeqt/container/qaxbase.cpp +++ b/src/activeqt/container/qaxbase.cpp @@ -3204,12 +3204,12 @@ static const char qt_meta_stringdata_QAxBase[] = { }; static QMetaObject qaxobject_staticMetaObject = { - &QObject::staticMetaObject, qt_meta_stringdata_QAxBase, - qt_meta_data_QAxBase, 0 + { &QObject::staticMetaObject, qt_meta_stringdata_QAxBase, + qt_meta_data_QAxBase, 0 } }; static QMetaObject qaxwidget_staticMetaObject = { - &QWidget::staticMetaObject, qt_meta_stringdata_QAxBase, - qt_meta_data_QAxBase, 0 + { &QWidget::staticMetaObject, qt_meta_stringdata_QAxBase, + qt_meta_data_QAxBase, 0 } }; /*! @@ -3692,6 +3692,8 @@ int QAxBase::qt_metacall(QMetaObject::Call call, int id, void **v) case QMetaMethod::Slot: id = internalInvoke(call, id, v); break; + default: + break; } break; case QMetaObject::ReadProperty: @@ -3706,6 +3708,8 @@ int QAxBase::qt_metacall(QMetaObject::Call call, int id, void **v) case QMetaObject::QueryPropertyUser: id -= mo->propertyCount(); break; + default: + break; } Q_ASSERT(id < 0); return id; @@ -3905,7 +3909,7 @@ bool QAxBase::dynamicCallHelper(const char *name, void *inout, QList & else paramType = d->metaobj->paramType(normFunction, i, &out); - if (!parse && d->useMetaObject && var.type() == QVariant::String || var.type() == QVariant::ByteArray) { + if ((!parse && d->useMetaObject && var.type() == QVariant::String) || var.type() == QVariant::ByteArray) { int enumIndex =mo->indexOfEnumerator(paramType); if (enumIndex != -1) { QMetaEnum metaEnum =mo->enumerator(enumIndex); diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index ff6bcb8..e4c9d42 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -531,7 +531,7 @@ bool axc_FilterProc(void *m) } QAxClientSite::QAxClientSite(QAxWidget *c) -: ref(1), widget(c), host(0), eventTranslated(true) +: eventTranslated(true), ref(1), widget(c), host(0) { aggregatedObject = widget->createAggregate(); if (aggregatedObject) { diff --git a/src/activeqt/shared/qaxtypes.cpp b/src/activeqt/shared/qaxtypes.cpp index 49aa99c..63891c4 100644 --- a/src/activeqt/shared/qaxtypes.cpp +++ b/src/activeqt/shared/qaxtypes.cpp @@ -552,7 +552,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type int maxColumns = col.count(); if (maxColumns) { is2D = true; - SAFEARRAYBOUND rgsabound[2] = {0}; + SAFEARRAYBOUND rgsabound[2] = { {0} }; rgsabound[0].cElements = count; rgsabound[1].cElements = maxColumns; array = SafeArrayCreate(VT_VARIANT, 2, rgsabound); diff --git a/src/gui/painting/qregion_win.cpp b/src/gui/painting/qregion_win.cpp index 2d5e76b..8708461 100644 --- a/src/gui/painting/qregion_win.cpp +++ b/src/gui/painting/qregion_win.cpp @@ -57,7 +57,7 @@ HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, { const int tries = 10; for (int i = 0; i < tries; ++i) { - HRGN region; + HRGN region = 0; switch (type) { case QRegion::Rectangle: region = CreateRectRgn(left, top, right, bottom); @@ -96,7 +96,7 @@ QRegion qt_region_from_HRGN(HRGN rgn) QRegion region; RECT *r = reinterpret_cast(rd->Buffer); - for (int i = 0; i < rd->rdh.nCount; ++i) { + for (uint i = 0; i < rd->rdh.nCount; ++i) { QRect rect; rect.setCoords(r->left, r->top, r->right - 1, r->bottom - 1); ++r; diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index a0a3756..f4dd87c 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -772,7 +772,7 @@ QMatchData QUnsortedModelEngine::filter(const QString& part, const QModelIndex& /////////////////////////////////////////////////////////////////////////////// QCompleterPrivate::QCompleterPrivate() : widget(0), proxy(0), popup(0), cs(Qt::CaseSensitive), role(Qt::EditRole), column(0), - sorting(QCompleter::UnsortedModel), wrap(true), maxVisibleItems(7), eatFocusOut(true) + maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true) { } diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 48d09ce..0631df5 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4604,7 +4604,7 @@ QGLFormat QGLDrawable::format() const GLuint QGLDrawable::bindTexture(const QImage &image, GLenum target, GLint format) { - QGLTexture *texture; + QGLTexture *texture = 0; if (widget) texture = widget->d_func()->glcx->d_func()->bindTexture(image, target, format, true); else if (buffer) @@ -4620,7 +4620,7 @@ GLuint QGLDrawable::bindTexture(const QImage &image, GLenum target, GLint format GLuint QGLDrawable::bindTexture(const QPixmap &pixmap, GLenum target, GLint format) { - QGLTexture *texture; + QGLTexture *texture = 0; if (widget) texture = widget->d_func()->glcx->d_func()->bindTexture(pixmap, target, format, true, true); else if (buffer) @@ -4718,6 +4718,7 @@ void QGLShareRegister::removeShare(const QGLContext *context) { int count = it.value().removeAll(context); Q_ASSERT(count == 1); + Q_UNUSED(count); Q_ASSERT(it.value().size() != 0); if (it.value().size() == 1) -- cgit v0.12 From 549736341a2268e33159949e076e0629abeb838a Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Tue, 28 Jul 2009 15:55:28 +0200 Subject: Fixes selectionModel::hasSelection return value after model::reset After resetting the model, the selectionModel::hasSelection() of the view should return false. Fixed the corresponding autotest, which was wrong. Task-number: 256502 Reviewed-by: thierry --- src/gui/itemviews/qabstractitemview.cpp | 1 + tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 8b6b5cb..94569ec 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -960,6 +960,7 @@ void QAbstractItemView::reset() d->currentIndexSet = false; setState(NoState); setRootIndex(QModelIndex()); + d->selectionModel->reset(); } /*! diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index ae64e51..0541b46 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -1547,7 +1547,7 @@ void tst_QItemSelectionModel::resetModel() model.reset(); QVERIFY(view.selectionModel()->selection().isEmpty()); - QVERIFY(view.selectionModel()->hasSelection()); + QVERIFY(view.selectionModel()->hasSelection() == false); view.selectionModel()->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select); -- cgit v0.12 From baf3ec81ca5d5cd38b54dc853c12109956a98cb9 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 4 Aug 2009 11:16:01 +0200 Subject: QMenu now takes minimum width into account for the action rects The action now try to take advantage of the space given by a minimum width. Patch proposed initially by Aron Seigo and improved later on. Reviewed-by: Trustme --- src/gui/widgets/qmenu.cpp | 11 ++++++----- tests/auto/qmenu/tst_qmenu.cpp | 12 ++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 0b85eec..67bb10a 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -228,6 +228,10 @@ void QMenuPrivate::updateActionRects() const const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, 0, q), vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, 0, q), icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q); + const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); + + const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, 0, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); + const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin)); //for compatability now - will have to refactor this away.. tabWidth = 0; @@ -300,7 +304,7 @@ void QMenuPrivate::updateActionRects() const if (!sz.isEmpty()) { - max_column_width = qMax(max_column_width, sz.width()); + max_column_width = qMax(min_column_width, qMax(max_column_width, sz.width())); //wrapping if (!scroll && y+sz.height()+vmargin > dh - (style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q) * 2)) { @@ -316,7 +320,6 @@ void QMenuPrivate::updateActionRects() const max_column_width += tabWidth; //finally add in the tab width //calculate position - const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); const int base_y = vmargin + fw + topmargin + (scroll ? scroll->scrollOffset : 0) + (tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q) : 0); @@ -1703,9 +1706,7 @@ QSize QMenu::sizeHint() const QSize s; QStyleOption opt(0); - opt.rect = rect(); - opt.palette = palette(); - opt.state = QStyle::State_None; + opt.init(this); for (int i = 0; i < d->actionRects.count(); ++i) { const QRect &rect = d->actionRects.at(i); if (rect.isNull()) diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index ec9c7b4..6ba6466 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -96,6 +96,7 @@ private slots: void task256918_setFont(); void menuSizeHint(); void task258920_mouseBorder(); + void setFixedWidth(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -798,6 +799,17 @@ void tst_QMenu::task258920_mouseBorder() QVERIFY(menu.painted); } +void tst_QMenu::setFixedWidth() +{ + QMenu menu; + menu.addAction("action"); + menu.setFixedWidth(300); + //the sizehint should reflect the minimumwidth because the action will try to + //get as much space as possible + QCOMPARE(menu.sizeHint().width(), menu.minimumWidth()); +} + + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" -- cgit v0.12 From 54d5c7eae26c025015f08bf06d0f9268175317e8 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 4 Aug 2009 11:47:45 +0200 Subject: fix warning on MSVC --- src/gui/kernel/qstandardgestures.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 1a88429..c4820f0 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -82,8 +82,6 @@ QPanGesture::QPanGesture(QWidget *parent) /*! \internal */ bool QPanGesture::event(QEvent *event) { - Q_D(QPanGesture); - #ifdef Q_WS_WIN QApplicationPrivate* getQApplicationPrivateInternal(); switch (event->type()) { @@ -101,6 +99,7 @@ bool QPanGesture::event(QEvent *event) #endif #if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) + Q_D(QPanGesture); if (event->type() == QEvent::Timer) { const QTimerEvent *te = static_cast(event); if (te->timerId() == d->panFinishedTimer) { -- cgit v0.12 From dc0088949822f846983c9a2d8f7dca59433ec555 Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 4 Aug 2009 12:52:38 +0200 Subject: Assistant: Added search history. Task-number: 251278 Reviewed-by: kh --- tools/assistant/lib/qhelpsearchquerywidget.cpp | 295 ++++++++++++++++++++----- 1 file changed, 238 insertions(+), 57 deletions(-) diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp index 00444b1..110df4f 100644 --- a/tools/assistant/lib/qhelpsearchquerywidget.cpp +++ b/tools/assistant/lib/qhelpsearchquerywidget.cpp @@ -43,9 +43,12 @@ #include +#include #include #include +#include +#include #include #include #include @@ -60,8 +63,46 @@ class QHelpSearchQueryWidgetPrivate : public QObject Q_OBJECT private: + struct QueryHistory { + explicit QueryHistory() : curQuery(-1) {} + QList > queries; + int curQuery; + }; + + class CompleterModel : public QAbstractListModel + { + public: + explicit CompleterModel(QObject *parent) + : QAbstractListModel(parent) {} + + int rowCount(const QModelIndex &parent = QModelIndex()) const + { + return parent.isValid() ? 0 : termList.size(); + } + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const + { + if (!index.isValid() || index.row() >= termList.count()|| + (role != Qt::EditRole && role != Qt::DisplayRole)) + return QVariant(); + return termList.at(index.row()); + } + + void addTerm(const QString &term) + { + if (!termList.contains(term)) { + termList.append(term); + reset(); + } + } + + private: + QStringList termList; + }; + QHelpSearchQueryWidgetPrivate() - : QObject() + : QObject(), simpleSearch(true), + searchCompleter(new CompleterModel(this), this) { searchButton = 0; advancedSearchWidget = 0; @@ -136,11 +177,102 @@ private: return wordList; } + void saveQuery(const QList &query, QueryHistory &queryHist) + { + // We only add the query to the list if it is different from the last one. + bool insert = false; + if (queryHist.queries.empty()) + insert = true; + else { + const QList &lastQuery = queryHist.queries.last(); + if (lastQuery.size() != query.size()) { + insert = true; + } else { + for (int i = 0; i < query.size(); ++i) { + if (query.at(i).fieldName != lastQuery.at(i).fieldName + || query.at(i).wordList != lastQuery.at(i).wordList) { + insert = true; + break; + } + } + } + } + if (insert) { + queryHist.queries.append(query); + foreach (const QHelpSearchQuery &queryPart, query) { + static_cast(searchCompleter.model())-> + addTerm(queryPart.wordList.join(" ")); + } + } + } + + void nextOrPrevQuery(int maxOrMinIndex, int addend, + QToolButton *thisButton, QToolButton *otherButton) + { + QueryHistory *queryHist; + QList lineEdits; + if (simpleSearch) { + queryHist = &simpleQueries; + lineEdits << defaultQuery; + } else { + queryHist = &complexQueries; + lineEdits << allQuery << atLeastQuery << similarQuery + << withoutQuery << exactQuery; + } + foreach (QLineEdit *lineEdit, lineEdits) + lineEdit->clear(); + + // Otherwise, the respective button would be disabled. + Q_ASSERT(queryHist->curQuery != maxOrMinIndex); + + queryHist->curQuery += addend; + const QList &query = + queryHist->queries.at(queryHist->curQuery); + foreach (const QHelpSearchQuery &queryPart, query) { + QLineEdit *lineEdit; + switch (queryPart.fieldName) { + case QHelpSearchQuery::DEFAULT: + lineEdit = defaultQuery; + break; + case QHelpSearchQuery::ALL: + lineEdit = allQuery; + break; + case QHelpSearchQuery::ATLEAST: + lineEdit = atLeastQuery; + break; + case QHelpSearchQuery::FUZZY: + lineEdit = similarQuery; + break; + case QHelpSearchQuery::WITHOUT: + lineEdit = withoutQuery; + break; + case QHelpSearchQuery::PHRASE: + lineEdit = exactQuery; + break; + default: + Q_ASSERT(0); + } + lineEdit->setText(queryPart.wordList.join(" ")); + } + + if (queryHist->curQuery == maxOrMinIndex) + thisButton->setEnabled(false); + otherButton->setEnabled(true); + } + + void enableOrDisableToolButtons() + { + const QueryHistory &queryHist = + simpleSearch ? simpleQueries : complexQueries; + prevQueryButton->setEnabled(queryHist.curQuery > 0); + nextQueryButton->setEnabled(queryHist.curQuery < + queryHist.queries.size() - 1); + } + private slots: void showHideAdvancedSearch() { - bool hidden = advancedSearchWidget->isHidden(); - if (hidden) { + if (simpleSearch) { advancedSearchWidget->show(); showHideAdvancedSearchButton->setText((QLatin1String("-"))); } else { @@ -148,12 +280,86 @@ private slots: showHideAdvancedSearchButton->setText((QLatin1String("+"))); } - defaultQuery->setEnabled(!hidden); + simpleSearch = !simpleSearch; + defaultQuery->setEnabled(simpleSearch); + enableOrDisableToolButtons(); + } + + void searchRequested() + { + QList queryList; +#if !defined(QT_CLUCENE_SUPPORT) + queryList.append(QHelSearchQuery(QHelpSearchQuery::DEFAULT, + QStringList(defaultQuery->text()))); + +#else + if (defaultQuery->isEnabled()) { + queryList.append(QHelpSearchQuery(QHelpSearchQuery::DEFAULT, + buildTermList(escapeString(defaultQuery->text())))); + } else { + const QRegExp exp(QLatin1String("\\s+")); + QStringList lst = similarQuery->text().split(exp, QString::SkipEmptyParts); + if (!lst.isEmpty()) { + QStringList fuzzy; + foreach (const QString term, lst) + fuzzy += buildTermList(escapeString(term)); + queryList.append(QHelpSearchQuery(QHelpSearchQuery::FUZZY, fuzzy)); + } + + lst = withoutQuery->text().split(exp, QString::SkipEmptyParts); + if (!lst.isEmpty()) { + QStringList without; + foreach (const QString term, lst) + without.append(escapeString(term)); + queryList.append(QHelpSearchQuery(QHelpSearchQuery::WITHOUT, without)); + } + + if (!exactQuery->text().isEmpty()) { + QString phrase = exactQuery->text().remove(QLatin1Char('\"')); + phrase = escapeString(phrase.simplified()); + queryList.append(QHelpSearchQuery(QHelpSearchQuery::PHRASE, QStringList(phrase))); + } + + lst = allQuery->text().split(exp, QString::SkipEmptyParts); + if (!lst.isEmpty()) { + QStringList all; + foreach (const QString term, lst) + all.append(escapeString(term)); + queryList.append(QHelpSearchQuery(QHelpSearchQuery::ALL, all)); + } + + lst = atLeastQuery->text().split(exp, QString::SkipEmptyParts); + if (!lst.isEmpty()) { + QStringList atLeast; + foreach (const QString term, lst) + atLeast += buildTermList(escapeString(term)); + queryList.append(QHelpSearchQuery(QHelpSearchQuery::ATLEAST, atLeast)); + } + } +#endif + QueryHistory &queryHist = simpleSearch ? simpleQueries : complexQueries; + saveQuery(queryList, queryHist); + queryHist.curQuery = queryHist.queries.size() - 1; + if (queryHist.curQuery > 0) + prevQueryButton->setEnabled(true); + nextQueryButton->setEnabled(false); + } + + void nextQuery() + { + nextOrPrevQuery((simpleSearch ? simpleQueries : complexQueries).queries.size() - 1, + 1, nextQueryButton, prevQueryButton); + } + + void prevQuery() + { + nextOrPrevQuery(0, -1, prevQueryButton, nextQueryButton); } private: friend class QHelpSearchQueryWidget; + bool simpleSearch; QPushButton *searchButton; QWidget* advancedSearchWidget; QToolButton *showHideAdvancedSearchButton; @@ -163,6 +369,11 @@ private: QLineEdit *withoutQuery; QLineEdit *allQuery; QLineEdit *atLeastQuery; + QToolButton *nextQueryButton; + QToolButton *prevQueryButton; + QueryHistory simpleQueries; + QueryHistory complexQueries; + QCompleter searchCompleter; }; #include "qhelpsearchquerywidget.moc" @@ -199,13 +410,26 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent) QHBoxLayout* hBoxLayout = new QHBoxLayout(); QLabel *label = new QLabel(tr("Search for:"), this); d->defaultQuery = new QLineEdit(this); + d->defaultQuery->setCompleter(&d->searchCompleter); + d->prevQueryButton = new QToolButton(this); + d->prevQueryButton->setArrowType(Qt::LeftArrow); + d->prevQueryButton->setToolTip(tr("Previous search")); + d->prevQueryButton->setEnabled(false); + d->nextQueryButton = new QToolButton(this); + d->nextQueryButton->setArrowType(Qt::RightArrow); + d->nextQueryButton->setToolTip(tr("Next search")); + d->nextQueryButton->setEnabled(false); d->searchButton = new QPushButton(tr("Search"), this); hBoxLayout->addWidget(label); hBoxLayout->addWidget(d->defaultQuery); + hBoxLayout->addWidget(d->prevQueryButton); + hBoxLayout->addWidget(d->nextQueryButton); hBoxLayout->addWidget(d->searchButton); vLayout->addLayout(hBoxLayout); + connect(d->prevQueryButton, SIGNAL(clicked()), d, SLOT(prevQuery())); + connect(d->nextQueryButton, SIGNAL(clicked()), d, SLOT(nextQuery())); connect(d->searchButton, SIGNAL(clicked()), this, SIGNAL(search())); connect(d->defaultQuery, SIGNAL(returnPressed()), this, SIGNAL(search())); @@ -236,26 +460,31 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent) label = new QLabel(tr("words similar to:"), this); gLayout->addWidget(label, 0, 0); d->similarQuery = new QLineEdit(this); + d->similarQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->similarQuery, 0, 1); label = new QLabel(tr("without the words:"), this); gLayout->addWidget(label, 1, 0); d->withoutQuery = new QLineEdit(this); + d->withoutQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->withoutQuery, 1, 1); label = new QLabel(tr("with exact phrase:"), this); gLayout->addWidget(label, 2, 0); d->exactQuery = new QLineEdit(this); + d->exactQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->exactQuery, 2, 1); label = new QLabel(tr("with all of the words:"), this); gLayout->addWidget(label, 3, 0); d->allQuery = new QLineEdit(this); + d->allQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->allQuery, 3, 1); label = new QLabel(tr("with at least one of the words:"), this); gLayout->addWidget(label, 4, 0); d->atLeastQuery = new QLineEdit(this); + d->atLeastQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->atLeastQuery, 4, 1); vLayout->addWidget(d->advancedSearchWidget); @@ -269,6 +498,7 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent) connect(d->showHideAdvancedSearchButton, SIGNAL(clicked()), d, SLOT(showHideAdvancedSearch())); #endif + connect(this, SIGNAL(search()), d, SLOT(searchRequested())); } /*! @@ -285,59 +515,10 @@ QHelpSearchQueryWidget::~QHelpSearchQueryWidget() */ QList QHelpSearchQueryWidget::query() const { -#if !defined(QT_CLUCENE_SUPPORT) - QList queryList; - queryList.append(QHelpSearchQuery(QHelpSearchQuery::DEFAULT, - QStringList(d->defaultQuery->text()))); - - return queryList; -#else - QList queryList; - if (d->defaultQuery->isEnabled()) { - queryList.append(QHelpSearchQuery(QHelpSearchQuery::DEFAULT, - d->buildTermList(d->escapeString(d->defaultQuery->text())))); - } else { - const QRegExp exp(QLatin1String("\\s+")); - QStringList lst = d->similarQuery->text().split(exp, QString::SkipEmptyParts); - if (!lst.isEmpty()) { - QStringList fuzzy; - foreach (const QString term, lst) - fuzzy += d->buildTermList(d->escapeString(term)); - queryList.append(QHelpSearchQuery(QHelpSearchQuery::FUZZY, fuzzy)); - } - - lst = d->withoutQuery->text().split(exp, QString::SkipEmptyParts); - if (!lst.isEmpty()) { - QStringList without; - foreach (const QString term, lst) - without.append(d->escapeString(term)); - queryList.append(QHelpSearchQuery(QHelpSearchQuery::WITHOUT, without)); - } - - if (!d->exactQuery->text().isEmpty()) { - QString phrase = d->exactQuery->text().remove(QLatin1Char('\"')); - phrase = d->escapeString(phrase.simplified()); - queryList.append(QHelpSearchQuery(QHelpSearchQuery::PHRASE, QStringList(phrase))); - } - - lst = d->allQuery->text().split(exp, QString::SkipEmptyParts); - if (!lst.isEmpty()) { - QStringList all; - foreach (const QString term, lst) - all.append(d->escapeString(term)); - queryList.append(QHelpSearchQuery(QHelpSearchQuery::ALL, all)); - } - - lst = d->atLeastQuery->text().split(exp, QString::SkipEmptyParts); - if (!lst.isEmpty()) { - QStringList atLeast; - foreach (const QString term, lst) - atLeast += d->buildTermList(d->escapeString(term)); - queryList.append(QHelpSearchQuery(QHelpSearchQuery::ATLEAST, atLeast)); - } - } - return queryList; -#endif + const QHelpSearchQueryWidgetPrivate::QueryHistory &queryHist = + d->simpleSearch ? d->simpleQueries : d->complexQueries; + return queryHist.queries.isEmpty() ? + QList() : queryHist.queries.last(); } /*! \reimp -- cgit v0.12 From 232569c52844a4f661fe55001015ad5da5097ce7 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 4 Aug 2009 13:05:05 +0200 Subject: Fix ancestor flags that are not correctly update when reparenting. updateAncestorFlags was not reseting the flags if you change the parent that have for instance itemsClipChildrenToShape to a new one that doesn't have that flag. Task-number:258956 Reviewed-by:bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 23 ++++++++++++----------- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index aa37981..7b650d2 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -638,18 +638,19 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch return; } - // Inherit the enabled-state from our parents. - if ((parent && ((parent->d_ptr->ancestorFlags & flag) - || (int(parent->d_ptr->flags & childFlag) == childFlag) - || (childFlag == -1 && parent->d_ptr->handlesChildEvents)))) { - enabled = true; - ancestorFlags |= flag; - } - - // Top-level root items don't have any ancestors, so there are no - // ancestor flags either. - if (!parent) + if (parent) { + // Inherit the enabled-state from our parents. + if ((parent->d_ptr->ancestorFlags & flag) || (int(parent->d_ptr->flags & childFlag) == childFlag) || (childFlag == -1 && parent->d_ptr->handlesChildEvents)) { + enabled = true; + ancestorFlags |= flag; + } else { + ancestorFlags &= ~flag; + } + } else { + // Top-level root items don't have any ancestors, so there are no + // ancestor flags either. ancestorFlags = 0; + } } else { // Don't set or propagate the ancestor flag if it's already correct. if (((ancestorFlags & flag) && enabled) || (!(ancestorFlags & flag) && !enabled)) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 90c4636..ded8aca 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -665,6 +665,22 @@ void tst_QGraphicsItem::flags() QApplication::sendEvent(&scene, &event5); QCOMPARE(item->pos(), QPointF(10, 10)); } + { + QGraphicsItem* clippingParent = new QGraphicsRectItem; + clippingParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); + + QGraphicsItem* nonClippingParent = new QGraphicsRectItem; + nonClippingParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); + + QGraphicsItem* child = new QGraphicsRectItem(nonClippingParent); + QVERIFY(!child->isClipped()); + + child->setParentItem(clippingParent); + QVERIFY(child->isClipped()); + + child->setParentItem(nonClippingParent); + QVERIFY(!child->isClipped()); + } } void tst_QGraphicsItem::toolTip() -- cgit v0.12 From 40d7153ad17d6eca96cb4718486e8e2654b72f00 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 4 Aug 2009 13:30:00 +0200 Subject: qdoc: Added \annotated list command to qdoc3. Now you can put "\annotatedlist xxx" anywhere in a qdoc comment, and it will generate the class list for the xxx group at that location. xxx must be a group name. --- tools/qdoc3/atom.cpp | 2 ++ tools/qdoc3/atom.h | 1 + tools/qdoc3/cppcodeparser.cpp | 3 +++ tools/qdoc3/doc.cpp | 32 ++++++++++++++++++-------------- tools/qdoc3/htmlgenerator.cpp | 14 ++++++++++++++ tools/qdoc3/tree.cpp | 2 ++ 6 files changed, 40 insertions(+), 14 deletions(-) diff --git a/tools/qdoc3/atom.cpp b/tools/qdoc3/atom.cpp index a82a783..da32735 100644 --- a/tools/qdoc3/atom.cpp +++ b/tools/qdoc3/atom.cpp @@ -93,6 +93,7 @@ QString Atom::UPPERROMAN_ ("upperroman"); \value AbstractLeft \value AbstractRight + \value AnnotatedList \value AutoLink \value BaseName \value BriefLeft @@ -163,6 +164,7 @@ static const struct { } atms[] = { { "AbstractLeft", Atom::AbstractLeft }, { "AbstractRight", Atom::AbstractRight }, + { "AnnotatedList", Atom::AnnotatedList }, { "AutoLink", Atom::AutoLink }, { "BaseName", Atom::BaseName }, { "BriefLeft", Atom::BriefLeft }, diff --git a/tools/qdoc3/atom.h b/tools/qdoc3/atom.h index 6d5af0a..941ac70 100644 --- a/tools/qdoc3/atom.h +++ b/tools/qdoc3/atom.h @@ -58,6 +58,7 @@ class Atom enum Type { AbstractLeft, AbstractRight, + AnnotatedList, AutoLink, BaseName, BriefLeft, diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index 4563f65..562684b 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -1724,6 +1724,9 @@ bool CppCodeParser::matchProperty(InnerNode *parent) value = "?"; } + /* + Task 259071 requires work here. See gui/widgets/qdatetime.h, for example. + */ if (key == "READ") tre->addPropertyFunction(property, value, PropertyNode::Getter); else if (key == "WRITE") diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp index d5aca0e..e2f3525 100644 --- a/tools/qdoc3/doc.cpp +++ b/tools/qdoc3/doc.cpp @@ -73,20 +73,20 @@ struct Macro }; enum { - CMD_A, CMD_ABSTRACT, CMD_BADCODE, CMD_BASENAME, CMD_BOLD, - CMD_BRIEF, CMD_C, CMD_CAPTION, CMD_CHAPTER, CMD_CODE, - CMD_CODELINE, CMD_DOTS, CMD_ELSE, CMD_ENDABSTRACT, - CMD_ENDCHAPTER, CMD_ENDCODE, CMD_ENDFOOTNOTE, CMD_ENDIF, - CMD_ENDLEGALESE, CMD_ENDLINK, CMD_ENDLIST, CMD_ENDOMIT, - CMD_ENDPART, CMD_ENDQUOTATION, CMD_ENDRAW, CMD_ENDSECTION1, - CMD_ENDSECTION2, CMD_ENDSECTION3, CMD_ENDSECTION4, - CMD_ENDSIDEBAR, CMD_ENDTABLE, CMD_EXPIRE, CMD_FOOTNOTE, - CMD_GENERATELIST, CMD_GRANULARITY, CMD_HEADER, CMD_I, - CMD_IF, CMD_IMAGE, CMD_INCLUDE, CMD_INLINEIMAGE, CMD_INDEX, - CMD_KEYWORD, CMD_L, CMD_LEGALESE, CMD_LINK, CMD_LIST, - CMD_META, CMD_NEWCODE, CMD_O, CMD_OLDCODE, CMD_OMIT, - CMD_OMITVALUE, CMD_OVERLOAD, - CMD_PART, CMD_PRINTLINE, CMD_PRINTTO, + CMD_A, CMD_ABSTRACT, CMD_ANNOTATEDLIST, CMD_BADCODE, + CMD_BASENAME, CMD_BOLD, CMD_BRIEF, CMD_C, CMD_CAPTION, + CMD_CHAPTER, CMD_CODE, CMD_CODELINE, CMD_DOTS, CMD_ELSE, + CMD_ENDABSTRACT, CMD_ENDCHAPTER, CMD_ENDCODE, + CMD_ENDFOOTNOTE, CMD_ENDIF, CMD_ENDLEGALESE, CMD_ENDLINK, + CMD_ENDLIST, CMD_ENDOMIT, CMD_ENDPART, CMD_ENDQUOTATION, + CMD_ENDRAW, CMD_ENDSECTION1, CMD_ENDSECTION2, + CMD_ENDSECTION3, CMD_ENDSECTION4, CMD_ENDSIDEBAR, + CMD_ENDTABLE, CMD_EXPIRE, CMD_FOOTNOTE, CMD_GENERATELIST, + CMD_GRANULARITY, CMD_HEADER, CMD_I, CMD_IF, CMD_IMAGE, + CMD_INCLUDE, CMD_INLINEIMAGE, CMD_INDEX, CMD_KEYWORD, + CMD_L, CMD_LEGALESE, CMD_LINK, CMD_LIST, CMD_META, + CMD_NEWCODE, CMD_O, CMD_OLDCODE, CMD_OMIT, CMD_OMITVALUE, + CMD_OVERLOAD, CMD_PART, CMD_PRINTLINE, CMD_PRINTTO, CMD_PRINTUNTIL, CMD_QUOTATION, CMD_QUOTEFILE, CMD_QUOTEFROMFILE, CMD_QUOTEFUNCTION, CMD_RAW, CMD_ROW, CMD_SA, CMD_SECTION1, CMD_SECTION2, CMD_SECTION3, @@ -108,6 +108,7 @@ static struct { } cmds[] = { { "a", CMD_A, 0 }, { "abstract", CMD_ABSTRACT, 0 }, + { "annotatedlist", CMD_ANNOTATEDLIST, 0 }, { "badcode", CMD_BADCODE, 0 }, { "basename", CMD_BASENAME, 0 }, // ### don't document for now { "bold", CMD_BOLD, 0 }, @@ -723,6 +724,9 @@ void DocParser::parse(const QString& source, paraState = OutsidePara; // ### } break; + case CMD_ANNOTATEDLIST: + append(Atom::AnnotatedList, getArgument()); + break; case CMD_GENERATELIST: append(Atom::GeneratedList, getArgument()); break; diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 6590114..425c50b 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -537,6 +537,20 @@ int HtmlGenerator::generateAtom(const Atom *atom, out() << formattingRightMap()[atom->string()]; } break; + case Atom::AnnotatedList: + { + const FakeNode *fake = static_cast(relative); + if (fake && !fake->groupMembers().isEmpty()) { + QList values = tre->groups().values(atom->string()); + QMap nodeMap; + for (int i = 0; i < values.size(); ++i) { + const Node* n = values.at(i); + nodeMap.insert(n->name(),n); + } + generateAnnotatedList(fake, marker, nodeMap); + } + } + break; case Atom::GeneratedList: if (atom->string() == "annotatedclasses") { generateAnnotatedList(relative, marker, nonCompatClasses); diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp index e6dd084..d75af70 100644 --- a/tools/qdoc3/tree.cpp +++ b/tools/qdoc3/tree.cpp @@ -419,6 +419,8 @@ void Tree::addPropertyFunction(PropertyNode *property, } /*! + This function adds the \a node to the \a group. The group + can be listed anywhere using the \e{annotated list} command. */ void Tree::addToGroup(Node *node, const QString &group) { -- cgit v0.12 From e888ff9902f193b8797d7993cd7d43e76045dcc1 Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 4 Aug 2009 13:54:42 +0200 Subject: Assistant: Use non-GUI version of QApplication for command-line tasks. Task-number: 259136 Reviewed-by: kh --- tools/assistant/tools/assistant/main.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index a0a5a0d..4af2570 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -181,7 +181,21 @@ QString indexFilesFolder(const QString &collectionFile) int main(int argc, char *argv[]) { - QApplication a(argc, argv); + // First do a quick search for arguments that imply command-line mode. + const char * cmdModeArgs[] = { + "-help", "-register", "-unregister", "-remove-search-index" + }; + bool useGui = true; + for (int i = 1; i < argc; ++i) { + for (size_t j = 0; j < sizeof cmdModeArgs/sizeof *cmdModeArgs; ++j) { + if(strcmp(argv[i], cmdModeArgs[j]) == 0) { + useGui = false; + break; + } + } + } + + QApplication a(argc, argv, useGui); a.addLibraryPath(a.applicationDirPath() + QLatin1String("/plugins")); CmdLineParser cmd; -- cgit v0.12 From 2764dc0a0f4f8f6c87e716817ae99a7b57cdd23e Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 4 Aug 2009 14:13:57 +0200 Subject: Fix indentation. Reviewed-by:TrustMe --- src/gui/graphicsview/qgraphicsitem.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 7b650d2..40331fb 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -640,7 +640,9 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch if (parent) { // Inherit the enabled-state from our parents. - if ((parent->d_ptr->ancestorFlags & flag) || (int(parent->d_ptr->flags & childFlag) == childFlag) || (childFlag == -1 && parent->d_ptr->handlesChildEvents)) { + if ((parent->d_ptr->ancestorFlags & flag) + || (int(parent->d_ptr->flags & childFlag) == childFlag) + || (childFlag == -1 && parent->d_ptr->handlesChildEvents)) { enabled = true; ancestorFlags |= flag; } else { -- cgit v0.12 From 69c379451f496071c51542dab876d41916b62889 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 4 Aug 2009 14:19:12 +0200 Subject: have QPainter::begin() return false on null paint engine Reviewed-by: Samuel --- src/gui/painting/qpainter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 9c7a7fa..8192fb7 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1672,7 +1672,7 @@ bool QPainter::begin(QPaintDevice *pd) if (!d->engine) { qWarning("QPainter::begin: Paint device returned engine == 0, type: %d", pd->devType()); - return true; + return false; } // Slip a painter state into the engine before we do any other operations -- cgit v0.12 From b6275b9dd1a852c86b22b354bfae3c98c8191fda Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 4 Aug 2009 14:26:39 +0200 Subject: Animations: better handling of the timer It could be that if you start lots of animations, they would not be started at the same time and even have their first tick to late. So we needed to only transfer the started animation when receiving the start/stop timer tick. In addition, if the animation timer is already active we don't restart it. This would cause no animation to receive ticks if lots of them are started. --- src/corelib/animation/qabstractanimation.cpp | 30 ++++++---------------------- src/corelib/animation/qabstractanimation_p.h | 3 --- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index ced86d2..1d274c9 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -177,17 +177,6 @@ QUnifiedTimer *QUnifiedTimer::instance() return inst; } -void QUnifiedTimer::updateRecentlyStartedAnimations() -{ - if (animationsToStart.isEmpty()) - return; - - animations += animationsToStart; - updateTimer(); //we make sure we start the timer there - - animationsToStart.clear(); -} - void QUnifiedTimer::timerEvent(QTimerEvent *event) { //this is simply the time we last received a tick @@ -195,15 +184,16 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event) if (time.isValid()) lastTick = consistentTiming ? oldLastTick + timingInterval : time.elapsed(); - //we transfer the waiting animations into the "really running" state - updateRecentlyStartedAnimations(); if (event->timerId() == startStopAnimationTimer.timerId()) { startStopAnimationTimer.stop(); + //we transfer the waiting animations into the "really running" state + animations += animationsToStart; + animationsToStart.clear(); if (animations.isEmpty()) { animationTimer.stop(); time = QTime(); - } else { + } else if (!animationTimer.isActive()) { animationTimer.start(timingInterval, this); lastTick = 0; time.start(); @@ -219,27 +209,19 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event) } } -void QUnifiedTimer::updateTimer() -{ - //we delay the call to start and stop for the animation timer so that if you - //stop and start animations in batch you don't stop/start the timer too often. - if (!startStopAnimationTimer.isActive()) - startStopAnimationTimer.start(0, this); // we delay the actual start of the animation -} - void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation) { if (animations.contains(animation) ||animationsToStart.contains(animation)) return; animationsToStart << animation; - updateTimer(); + startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer } void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation) { animations.removeAll(animation); animationsToStart.removeAll(animation); - updateTimer(); + startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer } diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 0d8402e..b281aa2 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -135,11 +135,8 @@ public: protected: void timerEvent(QTimerEvent *); - void updateTimer(); private: - void updateRecentlyStartedAnimations(); - QBasicTimer animationTimer, startStopAnimationTimer; QTime time; int lastTick; -- cgit v0.12 From 30e3a39ca2e5e1204cc123dce2f2921d8fda620d Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 4 Aug 2009 15:03:15 +0200 Subject: QParallelAnimationGroup pause resume fixed If you resumed a parallel animation group, it would always restart (ie. stop and start) the animation which would reset its current time to 0 and trigger flickering. autotest included. Task-Number: 259102 --- src/corelib/animation/qparallelanimationgroup.cpp | 3 +- .../tst_qparallelanimationgroup.cpp | 33 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp index 5e4b0d2..8aa04a4 100644 --- a/src/corelib/animation/qparallelanimationgroup.cpp +++ b/src/corelib/animation/qparallelanimationgroup.cpp @@ -214,7 +214,8 @@ void QParallelAnimationGroup::updateState(QAbstractAnimation::State oldState, d->connectUncontrolledAnimations(); for (int i = 0; i < d->animations.size(); ++i) { QAbstractAnimation *animation = d->animations.at(i); - animation->stop(); + if (oldState == Stopped) + animation->stop(); animation->setDirection(d->direction); animation->start(); } diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index d7d6b88..16c58b0 100644 --- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -74,6 +74,7 @@ private slots: void loopCount_data(); void loopCount(); void autoAdd(); + void pauseResume(); }; tst_QParallelAnimationGroup::tst_QParallelAnimationGroup() @@ -828,5 +829,37 @@ void tst_QParallelAnimationGroup::autoAdd() QCOMPARE(group.duration(), 0); } +void tst_QParallelAnimationGroup::pauseResume() +{ + QParallelAnimationGroup group; + TestAnimation2 *anim = new TestAnimation2(250, &group); // 0, duration = 250; + QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); + QCOMPARE(group.duration(), 250); + group.start(); + QTest::qWait(100); + QCOMPARE(group.state(), QAnimationGroup::Running); + QCOMPARE(anim->state(), QAnimationGroup::Running); + QCOMPARE(spy.count(), 1); + spy.clear(); + const int currentTime = group.currentTime(); + QCOMPARE(anim->currentTime(), currentTime); + + group.pause(); + QCOMPARE(group.state(), QAnimationGroup::Paused); + QCOMPARE(group.currentTime(), currentTime); + QCOMPARE(anim->state(), QAnimationGroup::Paused); + QCOMPARE(anim->currentTime(), currentTime); + QCOMPARE(spy.count(), 1); + spy.clear(); + + group.resume(); + QCOMPARE(group.state(), QAnimationGroup::Running); + QCOMPARE(group.currentTime(), currentTime); + QCOMPARE(anim->state(), QAnimationGroup::Running); + QCOMPARE(anim->currentTime(), currentTime); + QCOMPARE(spy.count(), 1); +} + + QTEST_MAIN(tst_QParallelAnimationGroup) #include "tst_qparallelanimationgroup.moc" -- cgit v0.12 From b80a499764bf331880ff0c0d52670a419ec50feb Mon Sep 17 00:00:00 2001 From: jasplin Date: Tue, 4 Aug 2009 15:44:45 +0200 Subject: Added input hints to QGraphicsItem. This patch allows for input hints to be set on a QGraphicsItem. Input methods use such hints to define its appearance/behavior (e.g. to allow for numerical input only). Reviewed-by: ahanssen Task-number: 254493 --- doc/src/classes/qnamespace.qdoc | 24 ++++++++++++++++++ src/corelib/global/qnamespace.h | 16 ++++++++++++ src/gui/graphicsview/qgraphicsitem.cpp | 35 +++++++++++++++++++++++++- src/gui/graphicsview/qgraphicsitem.h | 3 +++ src/gui/graphicsview/qgraphicsitem_p.h | 4 ++- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 13 ++++++++++ 6 files changed, 93 insertions(+), 2 deletions(-) diff --git a/doc/src/classes/qnamespace.qdoc b/doc/src/classes/qnamespace.qdoc index 59e0a95..a49e079 100644 --- a/doc/src/classes/qnamespace.qdoc +++ b/doc/src/classes/qnamespace.qdoc @@ -2418,6 +2418,30 @@ */ /*! + \enum Qt::InputMethodHint + + \value ImhNone No hints. + \value ImhHiddenText Characters should be hidden, as is typically used when entering passwords. + This is automatically set when setting QLineEdit::echoMode to \c Password. + \value ImhNumbersOnly Only number input is allowed. + \value ImhUppercaseOnly Only upper case letter input is allowed. + \value ImhLowercaseOnly Only lower case letter input is allowed. + \value ImhNoAutoUppercase The input method should not try to automatically switch to upper case + when a sentence ends. + \value ImhPreferNumbers Numbers are preferred (but not required). + \value ImhPreferUppercase Upper case letters are preferred (but not required). + \value ImhPreferLowercase Lower case letters are preferred (but not required). + \value ImhNoPredictiveText Do not use predictive text (i.e. dictionary lookup) while typing. + \value ImhDialableCharactersOnly Only characters suitable for phone dialling are allowed. + + \note If several flags ending with \c Only are ORed together, the resulting character set will + consist of the union of the specified sets. For instance specifying \c ImhNumbersOnly and + \c ImhUppercaseOnly would yield a set consisting of numbers and uppercase letters. + + \sa QGraphicsItem::inputMethodHints() +*/ + +/*! \enum Qt::InputMethodQuery \value ImMicroFocus The rectangle covering the area of the input cursor in widget coordinates. diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 7770fd6..f172d77 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1406,6 +1406,21 @@ public: ImCurrentSelection }; + enum InputMethodHint { + ImhNone = 0x0, + ImhHiddenText = 0x1, + ImhNumbersOnly = 0x2, + ImhUppercaseOnly = 0x4, + ImhLowercaseOnly = 0x8, + ImhNoAutoUppercase = 0x10, + ImhPreferNumbers = 0x20, + ImhPreferUppercase = 0x40, + ImhPreferLowercase = 0x80, + ImhNoPredictiveText = 0x100, + ImhDialableCharactersOnly = 0x200 + }; + Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint) + enum ToolButtonStyle { ToolButtonIconOnly, ToolButtonTextOnly, @@ -1591,6 +1606,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::ItemFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MatchFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TextInteractionFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TouchPointStates) +Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::InputMethodHints) typedef bool (*qInternalCallback)(void **); diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index a047e6a..6a21e99 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -6384,7 +6384,7 @@ void QGraphicsItem::inputMethodEvent(QInputMethodEvent *event) surrounding text and reconversions. \a query specifies which property is queried. - \sa inputMethodEvent() + \sa inputMethodEvent(), QInputMethodEvent, QInputContext */ QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const { @@ -6400,6 +6400,39 @@ QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const } /*! + Returns the current input method hints of this item. + + Input method hints are only relevant for input items. + The hints are used by the input method to indicate how it should operate. + For example, if the Qt::ImhNumbersOnly flag is set, the input method may change + its visual components to reflect that only numbers can be entered. + + The effect may vary between input method implementations. + + \since 4.6 + + \sa setInputMethodHints(), inputMethodQuery(), QInputContext +*/ +Qt::InputMethodHints QGraphicsItem::inputMethodHints() const +{ + Q_D(const QGraphicsItem); + return d->imHints; +} + +/*! + Sets the current input method hints of this item to \a hints. + + \since 4.6 + + \sa inputMethodHints(), inputMethodQuery(), QInputContext +*/ +void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints) +{ + Q_D(QGraphicsItem); + d->imHints = hints; +} + +/*! This virtual function is called by QGraphicsItem to notify custom items that some part of the item's state changes. By reimplementing this function, your can react to a change, and in some cases, (depending on \a diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index b94fb97..f142b0f 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -375,6 +375,9 @@ public: QVariant data(int key) const; void setData(int key, const QVariant &value); + Qt::InputMethodHints inputMethodHints() const; + void setInputMethodHints(Qt::InputMethodHints hints); + enum { Type = 1, UserType = 65536 diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 5c3622b..805b554 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -126,6 +126,7 @@ public: depth(0), focusProxy(0), subFocusItem(0), + imHints(Qt::ImhNone), acceptedMouseButtons(0x1f), visible(1), explicitlyHidden(0), @@ -419,8 +420,9 @@ public: int depth; QGraphicsItem *focusProxy; QGraphicsItem *subFocusItem; + Qt::InputMethodHints imHints; - // Packed 32 bytes + // Packed 32 bits quint32 acceptedMouseButtons : 5; quint32 visible : 1; quint32 explicitlyHidden : 1; diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 7f6f322..ef3f0f8 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -169,6 +169,7 @@ private slots: void setParentItem(); void children(); void flags(); + void inputMethodHints(); void toolTip(); void visible(); void explicitlyVisible(); @@ -762,6 +763,18 @@ void tst_QGraphicsItem::flags() } } +class ImhTester : public QGraphicsItem +{ + QRectF boundingRect() const { return QRectF(); } + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {} +}; + +void tst_QGraphicsItem::inputMethodHints() +{ + ImhTester item; + QCOMPARE(item.inputMethodHints(), Qt::ImhNone); +} + void tst_QGraphicsItem::toolTip() { QString toolTip = "Qt rocks!"; -- cgit v0.12 From 69f0ba079899970aa53351a7d6b864f0a2bb8343 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 4 Aug 2009 16:04:55 +0200 Subject: Fix build on Harmattan --- src/gui/egl/qegl_x11.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index daaa4ba..6772592 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -39,15 +39,18 @@ ** ****************************************************************************/ +#include + +#include +#include +#include +#include + #include #include #include -#include #include "qegl_p.h" -#include -#include -#include QT_BEGIN_NAMESPACE -- cgit v0.12 From df373516909d4dc0dfe8149f4cbff17c9c9bfe54 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 4 Aug 2009 14:00:05 +0200 Subject: QHttpNetworkConnection: Moved channel slots to channel object Reviewed-by: Peter Hartmann --- src/network/access/qhttpnetworkconnection.cpp | 246 +-------------------- src/network/access/qhttpnetworkconnection_p.h | 30 +-- .../access/qhttpnetworkconnectionchannel.cpp | 214 ++++++++++++++++++ .../access/qhttpnetworkconnectionchannel_p.h | 25 +++ src/network/access/qhttpnetworkreply_p.h | 1 + 5 files changed, 249 insertions(+), 267 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 75ab837..d73cd67 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -87,58 +87,11 @@ QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate() delete []channels; } -void QHttpNetworkConnectionPrivate::connectSignals(QAbstractSocket *socket) -{ - Q_Q(QHttpNetworkConnection); - - QObject::connect(socket, SIGNAL(bytesWritten(qint64)), - q, SLOT(_q_bytesWritten(qint64)), - Qt::DirectConnection); - QObject::connect(socket, SIGNAL(connected()), - q, SLOT(_q_connected()), - Qt::DirectConnection); - QObject::connect(socket, SIGNAL(readyRead()), - q, SLOT(_q_readyRead()), - Qt::DirectConnection); - QObject::connect(socket, SIGNAL(disconnected()), - q, SLOT(_q_disconnected()), - Qt::DirectConnection); - QObject::connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), - q, SLOT(_q_error(QAbstractSocket::SocketError)), - Qt::DirectConnection); -#ifndef QT_NO_NETWORKPROXY - QObject::connect(socket, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), - q, SLOT(_q_proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), - Qt::DirectConnection); -#endif - -#ifndef QT_NO_OPENSSL - QSslSocket *sslSocket = qobject_cast(socket); - if (sslSocket) { - // won't be a sslSocket if encrypt is false - QObject::connect(sslSocket, SIGNAL(encrypted()), - q, SLOT(_q_encrypted()), - Qt::DirectConnection); - QObject::connect(sslSocket, SIGNAL(sslErrors(const QList&)), - q, SLOT(_q_sslErrors(const QList&)), - Qt::DirectConnection); - } -#endif -} - void QHttpNetworkConnectionPrivate::init() { - for (int i = 0; i < channelCount; ++i) { -#ifndef QT_NO_OPENSSL - if (encrypt) - channels[i].socket = new QSslSocket; - else - channels[i].socket = new QTcpSocket; -#else - channels[i].socket = new QTcpSocket; -#endif - - connectSignals(channels[i].socket); + for (int i = 0; i < channelCount; i++) { + channels[i].setConnection(this->q_func()); + channels[i].init(); } } @@ -406,7 +359,7 @@ bool QHttpNetworkConnectionPrivate::sendRequest(QAbstractSocket *socket) QNonContiguousByteDevice* uploadByteDevice = channels[i].request.uploadByteDevice(); if (uploadByteDevice) { // connect the signals so this function gets called again - QObject::connect(uploadByteDevice, SIGNAL(readyRead()), q, SLOT(_q_uploadDataReadyRead())); + QObject::connect(uploadByteDevice, SIGNAL(readyRead()), &channels[i], SLOT(_q_uploadDataReadyRead())); channels[i].bytesTotal = channels[i].request.contentLength(); } else { @@ -485,7 +438,7 @@ bool QHttpNetworkConnectionPrivate::sendRequest(QAbstractSocket *socket) { QNonContiguousByteDevice* uploadByteDevice = channels[i].request.uploadByteDevice(); if (uploadByteDevice) { - QObject::disconnect(uploadByteDevice, SIGNAL(readyRead()), q, SLOT(_q_uploadDataReadyRead())); + QObject::disconnect(uploadByteDevice, SIGNAL(readyRead()), &channels[i], SLOT(_q_uploadDataReadyRead())); } // 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 @@ -1004,11 +957,7 @@ void QHttpNetworkConnectionPrivate::unqueueAndSendRequest(QAbstractSocket *socke void QHttpNetworkConnectionPrivate::closeChannel(int channel) { - QAbstractSocket *socket = channels[channel].socket; - socket->blockSignals(true); - socket->close(); - socket->blockSignals(false); - channels[channel].state = QHttpNetworkConnectionChannel::IdleState; + channels[channel].close(); } void QHttpNetworkConnectionPrivate::resendCurrentRequest(QAbstractSocket *socket) @@ -1102,53 +1051,6 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) } -//private slots -void QHttpNetworkConnectionPrivate::_q_readyRead() -{ - Q_Q(QHttpNetworkConnection); - QAbstractSocket *socket = qobject_cast(q->sender()); - if (!socket) - return; // ### error - if (isSocketWaiting(socket) || isSocketReading(socket)) { - int i = indexOf(socket); - channels[i].state = QHttpNetworkConnectionChannel::ReadingState; - if (channels[i].reply) - receiveReply(socket, channels[i].reply); - } - // ### error -} - -void QHttpNetworkConnectionPrivate::_q_bytesWritten(qint64 bytes) -{ - Q_UNUSED(bytes); - Q_Q(QHttpNetworkConnection); - QAbstractSocket *socket = qobject_cast(q->sender()); - if (!socket) - return; // ### error - // bytes have been written to the socket. write even more of them :) - if (isSocketWriting(socket)) - sendRequest(socket); - // otherwise we do nothing -} - -void QHttpNetworkConnectionPrivate::_q_disconnected() -{ - Q_Q(QHttpNetworkConnection); - QAbstractSocket *socket = qobject_cast(q->sender()); - if (!socket) - return; // ### error - // read the available data before closing - int i = indexOf(socket); - if (isSocketWaiting(socket) || isSocketReading(socket)) { - channels[i].state = QHttpNetworkConnectionChannel::ReadingState; - if (channels[i].reply) - receiveReply(socket, channels[i].reply); - } else if (channels[i].state == QHttpNetworkConnectionChannel::IdleState && channels[i].resendCurrent) { - // re-sending request because the socket was in ClosingState - QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); - } - channels[i].state = QHttpNetworkConnectionChannel::IdleState; -} void QHttpNetworkConnectionPrivate::_q_startNextRequest() { @@ -1188,121 +1090,6 @@ void QHttpNetworkConnectionPrivate::_q_restartAuthPendingRequests() } } -void QHttpNetworkConnectionPrivate::_q_connected() -{ - Q_Q(QHttpNetworkConnection); - QAbstractSocket *socket = qobject_cast(q->sender()); - if (!socket) - return; // ### error - - // improve performance since we get the request sent by the kernel ASAP - socket->setSocketOption(QAbstractSocket::LowDelayOption, 1); - - int i = indexOf(socket); - // ### FIXME: if the server closes the connection unexpectedly, we shouldn't send the same broken request again! - //channels[i].reconnectAttempts = 2; - if (!channels[i].pendingEncrypt) { - channels[i].state = QHttpNetworkConnectionChannel::IdleState; - if (channels[i].reply) - sendRequest(socket); - else - closeChannel(i); - } -} - - -void QHttpNetworkConnectionPrivate::_q_error(QAbstractSocket::SocketError socketError) -{ - Q_Q(QHttpNetworkConnection); - QAbstractSocket *socket = qobject_cast(q->sender()); - if (!socket) - return; - bool send2Reply = false; - int i = indexOf(socket); - QNetworkReply::NetworkError errorCode = QNetworkReply::UnknownNetworkError; - - switch (socketError) { - case QAbstractSocket::HostNotFoundError: - errorCode = QNetworkReply::HostNotFoundError; - break; - case QAbstractSocket::ConnectionRefusedError: - errorCode = QNetworkReply::ConnectionRefusedError; - break; - case QAbstractSocket::RemoteHostClosedError: - // try to reconnect/resend before sending an error. - // while "Reading" the _q_disconnected() will handle this. - if (channels[i].state != QHttpNetworkConnectionChannel::IdleState && channels[i].state != QHttpNetworkConnectionChannel::ReadingState) { - if (channels[i].reconnectAttempts-- > 0) { - resendCurrentRequest(socket); - return; - } else { - send2Reply = true; - errorCode = QNetworkReply::RemoteHostClosedError; - } - } else { - return; - } - break; - case QAbstractSocket::SocketTimeoutError: - // try to reconnect/resend before sending an error. - if (channels[i].state == QHttpNetworkConnectionChannel::WritingState && (channels[i].reconnectAttempts-- > 0)) { - resendCurrentRequest(socket); - return; - } - send2Reply = true; - errorCode = QNetworkReply::TimeoutError; - break; - case QAbstractSocket::ProxyAuthenticationRequiredError: - errorCode = QNetworkReply::ProxyAuthenticationRequiredError; - break; - case QAbstractSocket::SslHandshakeFailedError: - errorCode = QNetworkReply::SslHandshakeFailedError; - break; - default: - // all other errors are treated as NetworkError - errorCode = QNetworkReply::UnknownNetworkError; - break; - } - QPointer that = q; - QString errorString = errorDetail(errorCode, socket); - if (send2Reply) { - if (channels[i].reply) { - channels[i].reply->d_func()->errorString = errorString; - // this error matters only to this reply - emit channels[i].reply->finishedWithError(errorCode, errorString); - } - // send the next request - QMetaObject::invokeMethod(that, "_q_startNextRequest", Qt::QueuedConnection); - } else { - // the failure affects all requests. - emit q->error(errorCode, errorString); - } - if (that) //signals make enter the event loop - closeChannel(i); -} - -#ifndef QT_NO_NETWORKPROXY -void QHttpNetworkConnectionPrivate::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth) -{ - Q_Q(QHttpNetworkConnection); - emit q->proxyAuthenticationRequired(proxy, auth, q); -} -#endif - -void QHttpNetworkConnectionPrivate::_q_uploadDataReadyRead() -{ - Q_Q(QHttpNetworkConnection); - // upload data emitted readyRead() - // find out which channel it is for - QObject *sender = q->sender(); - - for (int i = 0; i < channelCount; ++i) { - if (sender == channels[i].request.uploadByteDevice()) { - sendRequest(channels[i].socket); - break; - } - } -} QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 port, bool encrypt, QObject *parent) : QObject(*(new QHttpNetworkConnectionPrivate(hostName, port, encrypt)), parent) @@ -1397,27 +1184,6 @@ QNetworkProxy QHttpNetworkConnection::transparentProxy() const // SSL support below #ifndef QT_NO_OPENSSL -void QHttpNetworkConnectionPrivate::_q_encrypted() -{ - Q_Q(QHttpNetworkConnection); - QAbstractSocket *socket = qobject_cast(q->sender()); - if (!socket) - return; // ### error - int i = indexOf(socket); - channels[i].state = QHttpNetworkConnectionChannel::IdleState; - sendRequest(socket); -} - -void QHttpNetworkConnectionPrivate::_q_sslErrors(const QList &errors) -{ - Q_Q(QHttpNetworkConnection); - QAbstractSocket *socket = qobject_cast(q->sender()); - if (!socket) - return; - //QNetworkReply::NetworkError errorCode = QNetworkReply::ProtocolFailure; - emit q->sslErrors(errors); -} - QSslConfiguration QHttpNetworkConnectionPrivate::sslConfiguration(const QHttpNetworkReply &reply) const { if (!encrypt) diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index db6a140..48401d2 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -138,23 +138,10 @@ private: Q_DECLARE_PRIVATE(QHttpNetworkConnection) Q_DISABLE_COPY(QHttpNetworkConnection) friend class QHttpNetworkReply; + friend class QHttpNetworkConnectionChannel; - Q_PRIVATE_SLOT(d_func(), void _q_bytesWritten(qint64)) - Q_PRIVATE_SLOT(d_func(), void _q_readyRead()) - Q_PRIVATE_SLOT(d_func(), void _q_disconnected()) Q_PRIVATE_SLOT(d_func(), void _q_startNextRequest()) Q_PRIVATE_SLOT(d_func(), void _q_restartAuthPendingRequests()) - Q_PRIVATE_SLOT(d_func(), void _q_connected()) - Q_PRIVATE_SLOT(d_func(), void _q_error(QAbstractSocket::SocketError)) -#ifndef QT_NO_NETWORKPROXY - Q_PRIVATE_SLOT(d_func(), void _q_proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)) -#endif - Q_PRIVATE_SLOT(d_func(), void _q_uploadDataReadyRead()) - -#ifndef QT_NO_OPENSSL - Q_PRIVATE_SLOT(d_func(), void _q_encrypted()) - Q_PRIVATE_SLOT(d_func(), void _q_sslErrors(const QList&)) -#endif }; @@ -169,7 +156,6 @@ public: QHttpNetworkConnectionPrivate(const QString &hostName, quint16 port, bool encrypt); ~QHttpNetworkConnectionPrivate(); void init(); - void connectSignals(QAbstractSocket *socket); enum { ChunkSize = 4096 }; @@ -189,18 +175,8 @@ public: void copyCredentials(int fromChannel, QAuthenticator *auth, bool isProxy); // private slots - void _q_bytesWritten(qint64 bytes); // proceed sending - void _q_readyRead(); // pending data to read - void _q_disconnected(); // disconnected from host void _q_startNextRequest(); // send the next request from the queue void _q_restartAuthPendingRequests(); // send the currently blocked request - void _q_connected(); // start sending request - void _q_error(QAbstractSocket::SocketError); // error from socket -#ifndef QT_NO_NETWORKPROXY - void _q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); // from transparent proxy -#endif - - void _q_uploadDataReadyRead(); void createAuthorization(QAbstractSocket *socket, QHttpNetworkRequest &request); bool ensureConnection(QAbstractSocket *socket); @@ -237,8 +213,6 @@ public: inline bool expectContent(QHttpNetworkReply *reply); #ifndef QT_NO_OPENSSL - void _q_encrypted(); // start sending request (https) - void _q_sslErrors(const QList &errors); // ssl errors from the socket QSslConfiguration sslConfiguration(const QHttpNetworkReply &reply) const; #endif @@ -249,6 +223,8 @@ public: //The request queues QList highPriorityQueue; QList lowPriorityQueue; + + friend class QHttpNetworkConnectionChannel; }; diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index a04b530..6cd46fd 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -57,6 +57,220 @@ QT_BEGIN_NAMESPACE // TODO: Put channel specific stuff here so it does not polute qhttpnetworkconnection.cpp +void QHttpNetworkConnectionChannel::init() +{ +#ifndef QT_NO_OPENSSL + if (connection->d_func()->encrypt) + socket = new QSslSocket; + else + socket = new QTcpSocket; +#else + socket = new QTcpSocket; +#endif + + QObject::connect(socket, SIGNAL(bytesWritten(qint64)), + this, SLOT(_q_bytesWritten(qint64)), + Qt::DirectConnection); + QObject::connect(socket, SIGNAL(connected()), + this, SLOT(_q_connected()), + Qt::DirectConnection); + QObject::connect(socket, SIGNAL(readyRead()), + this, SLOT(_q_readyRead()), + Qt::DirectConnection); + QObject::connect(socket, SIGNAL(disconnected()), + this, SLOT(_q_disconnected()), + Qt::DirectConnection); + QObject::connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(_q_error(QAbstractSocket::SocketError)), + Qt::DirectConnection); +#ifndef QT_NO_NETWORKPROXY + QObject::connect(socket, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), + this, SLOT(_q_proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), + Qt::DirectConnection); +#endif + +#ifndef QT_NO_OPENSSL + QSslSocket *sslSocket = qobject_cast(socket); + if (sslSocket) { + // won't be a sslSocket if encrypt is false + QObject::connect(sslSocket, SIGNAL(encrypted()), + this, SLOT(_q_encrypted()), + Qt::DirectConnection); + QObject::connect(sslSocket, SIGNAL(sslErrors(const QList&)), + this, SLOT(_q_sslErrors(const QList&)), + Qt::DirectConnection); + } +#endif +} + + +void QHttpNetworkConnectionChannel::close() +{ + socket->blockSignals(true); + socket->close(); + socket->blockSignals(false); + state = QHttpNetworkConnectionChannel::IdleState; +} + + +//private slots +void QHttpNetworkConnectionChannel::_q_readyRead() +{ + if (!socket) + return; // ### error + if (connection->d_func()->isSocketWaiting(socket) || connection->d_func()->isSocketReading(socket)) { + state = QHttpNetworkConnectionChannel::ReadingState; + if (reply) + connection->d_func()->receiveReply(socket, reply); + } + // ### error +} + +void QHttpNetworkConnectionChannel::_q_bytesWritten(qint64 bytes) +{ + Q_UNUSED(bytes); + if (!socket) + return; // ### error + // bytes have been written to the socket. write even more of them :) + if (connection->d_func()->isSocketWriting(socket)) + connection->d_func()->sendRequest(socket); + // otherwise we do nothing +} + +void QHttpNetworkConnectionChannel::_q_disconnected() +{ + if (!socket) + return; // ### error + // read the available data before closing + if (connection->d_func()->isSocketWaiting(socket) || connection->d_func()->isSocketReading(socket)) { + state = QHttpNetworkConnectionChannel::ReadingState; + if (reply) + connection->d_func()->receiveReply(socket, reply); + } else if (state == QHttpNetworkConnectionChannel::IdleState && resendCurrent) { + // re-sending request because the socket was in ClosingState + QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); + } + state = QHttpNetworkConnectionChannel::IdleState; +} + + +void QHttpNetworkConnectionChannel::_q_connected() +{ + if (!socket) + return; // ### error + + // improve performance since we get the request sent by the kernel ASAP + socket->setSocketOption(QAbstractSocket::LowDelayOption, 1); + + // ### FIXME: if the server closes the connection unexpectedly, we shouldn't send the same broken request again! + //channels[i].reconnectAttempts = 2; + if (!pendingEncrypt) { + state = QHttpNetworkConnectionChannel::IdleState; + if (reply) + connection->d_func()->sendRequest(socket); + else + close(); + } +} + + +void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socketError) +{ + if (!socket) + return; + bool send2Reply = false; + QNetworkReply::NetworkError errorCode = QNetworkReply::UnknownNetworkError; + + switch (socketError) { + case QAbstractSocket::HostNotFoundError: + errorCode = QNetworkReply::HostNotFoundError; + break; + case QAbstractSocket::ConnectionRefusedError: + errorCode = QNetworkReply::ConnectionRefusedError; + break; + case QAbstractSocket::RemoteHostClosedError: + // try to reconnect/resend before sending an error. + // while "Reading" the _q_disconnected() will handle this. + if (state != QHttpNetworkConnectionChannel::IdleState && state != QHttpNetworkConnectionChannel::ReadingState) { + if (reconnectAttempts-- > 0) { + connection->d_func()->resendCurrentRequest(socket); + return; + } else { + send2Reply = true; + errorCode = QNetworkReply::RemoteHostClosedError; + } + } else { + return; + } + break; + case QAbstractSocket::SocketTimeoutError: + // try to reconnect/resend before sending an error. + if (state == QHttpNetworkConnectionChannel::WritingState && (reconnectAttempts-- > 0)) { + connection->d_func()->resendCurrentRequest(socket); + return; + } + send2Reply = true; + errorCode = QNetworkReply::TimeoutError; + break; + case QAbstractSocket::ProxyAuthenticationRequiredError: + errorCode = QNetworkReply::ProxyAuthenticationRequiredError; + break; + case QAbstractSocket::SslHandshakeFailedError: + errorCode = QNetworkReply::SslHandshakeFailedError; + break; + default: + // all other errors are treated as NetworkError + errorCode = QNetworkReply::UnknownNetworkError; + break; + } + QPointer that = connection; + QString errorString = connection->d_func()->errorDetail(errorCode, socket); + if (send2Reply) { + if (reply) { + reply->d_func()->errorString = errorString; + // this error matters only to this reply + emit reply->finishedWithError(errorCode, errorString); + } + // send the next request + QMetaObject::invokeMethod(that, "_q_startNextRequest", Qt::QueuedConnection); + } else { + // the failure affects all requests. + emit connection->error(errorCode, errorString); + } + if (that) //signal emission triggered event loop + close(); +} + +#ifndef QT_NO_NETWORKPROXY +void QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth) +{ + emit connection->proxyAuthenticationRequired(proxy, auth, connection); +} +#endif + +void QHttpNetworkConnectionChannel::_q_uploadDataReadyRead() +{ + connection->d_func()->sendRequest(socket); +} + +#ifndef QT_NO_OPENSSL +void QHttpNetworkConnectionChannel::_q_encrypted() +{ + if (!socket) + return; // ### error + state = QHttpNetworkConnectionChannel::IdleState; + connection->d_func()->sendRequest(socket); +} + +void QHttpNetworkConnectionChannel::_q_sslErrors(const QList &errors) +{ + if (!socket) + return; + //QNetworkReply::NetworkError errorCode = QNetworkReply::ProtocolFailure; + emit connection->sslErrors(errors); +} +#endif + QT_END_NAMESPACE #include "moc_qhttpnetworkconnectionchannel_p.cpp" diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h index cbabc67..013e7a5 100644 --- a/src/network/access/qhttpnetworkconnectionchannel_p.h +++ b/src/network/access/qhttpnetworkconnectionchannel_p.h @@ -80,6 +80,7 @@ QT_BEGIN_NAMESPACE class QHttpNetworkRequest; class QHttpNetworkReply; class QByteArray; +class QHttpNetworkConnection; class QHttpNetworkConnectionChannel : public QObject { Q_OBJECT @@ -117,7 +118,31 @@ public: #ifndef QT_NO_OPENSSL , ignoreAllSslErrors(false) #endif + , connection(0) {} + + void setConnection(QHttpNetworkConnection *c) {connection = c;} + QHttpNetworkConnection *connection; + + void init(); + void close(); + + protected slots: + void _q_bytesWritten(qint64 bytes); // proceed sending + void _q_readyRead(); // pending data to read + void _q_disconnected(); // disconnected from host + void _q_connected(); // start sending request + void _q_error(QAbstractSocket::SocketError); // error from socket +#ifndef QT_NO_NETWORKPROXY + void _q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); // from transparent proxy +#endif + + void _q_uploadDataReadyRead(); + +#ifndef QT_NO_OPENSSL + void _q_encrypted(); // start sending request (https) + void _q_sslErrors(const QList &errors); // ssl errors from the socket +#endif }; diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 575e824..a386b10 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -149,6 +149,7 @@ private: Q_DECLARE_PRIVATE(QHttpNetworkReply) friend class QHttpNetworkConnection; friend class QHttpNetworkConnectionPrivate; + friend class QHttpNetworkConnectionChannel; }; -- cgit v0.12 From 627c5c865d77cca1f0d6508f8facfe6c0bf4d363 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 4 Aug 2009 16:16:32 +0200 Subject: QNAM HTTP Code: Moved append() functions to the reply object Reviewed-by: TrustMe --- src/network/access/qhttpnetworkconnection.cpp | 35 +++------------------------ src/network/access/qhttpnetworkconnection_p.h | 4 --- src/network/access/qhttpnetworkreply.cpp | 30 +++++++++++++++++++++++ src/network/access/qhttpnetworkreply_p.h | 4 +++ 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index d73cd67..4c52545 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -129,35 +129,6 @@ bool QHttpNetworkConnectionPrivate::isSocketReading(QAbstractSocket *socket) con return (i != -1 && (channels[i].state & QHttpNetworkConnectionChannel::ReadingState)); } -void QHttpNetworkConnectionPrivate::appendUncompressedData(QHttpNetworkReply &reply, QByteArray &qba) -{ - reply.d_func()->responseData.append(qba); - - // clear the original! helps with implicit sharing and - // avoiding memcpy when the user is reading the data - qba.clear(); -} - -void QHttpNetworkConnectionPrivate::appendUncompressedData(QHttpNetworkReply &reply, QByteDataBuffer &data) -{ - reply.d_func()->responseData.append(data); - - // clear the original! helps with implicit sharing and - // avoiding memcpy when the user is reading the data - data.clear(); -} - -void QHttpNetworkConnectionPrivate::appendCompressedData(QHttpNetworkReply &reply, QByteDataBuffer &data) -{ - // Work in progress: Later we will directly use a list of QByteArray or a QRingBuffer - // instead of one QByteArray. - for(int i = 0; i < data.bufferCount(); i++) { - QByteArray &byteData = data[i]; - reply.d_func()->compressedData.append(byteData.constData(), byteData.size()); - } - data.clear(); -} - qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailable(const QHttpNetworkReply &reply) const { return reply.d_func()->responseData.byteAmount(); @@ -517,7 +488,7 @@ bool QHttpNetworkConnectionPrivate::expand(QAbstractSocket *socket, QHttpNetwork if (ret >= retCheck) { if (inflated.size()) { reply->d_func()->totalProgress += inflated.size(); - appendUncompressedData(*reply, inflated); + reply->d_func()->appendUncompressedReplyData(inflated); if (shouldEmitSignals(reply)) { // important: At the point of this readyRead(), inflated must be cleared, // else implicit sharing will trigger memcpy when the user is reading data! @@ -638,9 +609,9 @@ void QHttpNetworkConnectionPrivate::receiveReply(QAbstractSocket *socket, QHttpN bytes = reply->d_func()->readBody(socket, &byteDatas); if (bytes) { if (reply->d_func()->autoDecompress) - appendCompressedData(*reply, byteDatas); + reply->d_func()->appendCompressedReplyData(byteDatas); else - appendUncompressedData(*reply, byteDatas); + reply->d_func()->appendUncompressedReplyData(byteDatas); if (!reply->d_func()->autoDecompress) { reply->d_func()->totalProgress += bytes; diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index 48401d2..d6b0325 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -197,10 +197,6 @@ public: bool pendingAuthSignal; // there is an incomplete authentication signal bool pendingProxyAuthSignal; // there is an incomplete proxy authentication signal - void appendUncompressedData(QHttpNetworkReply &reply, QByteArray &qba); - void appendUncompressedData(QHttpNetworkReply &reply, QByteDataBuffer &data); - void appendCompressedData(QHttpNetworkReply &reply, QByteDataBuffer &data); - qint64 uncompressedBytesAvailable(const QHttpNetworkReply &reply) const; qint64 uncompressedBytesAvailableNextBlock(const QHttpNetworkReply &reply) const; qint64 compressedBytesAvailable(const QHttpNetworkReply &reply) const; diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index a623999..f40f7bf 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -687,6 +687,36 @@ qint64 QHttpNetworkReplyPrivate::getChunkSize(QIODevice *in, qint64 *chunkSize) return bytes; } +void QHttpNetworkReplyPrivate::appendUncompressedReplyData(QByteArray &qba) +{ + responseData.append(qba); + + // clear the original! helps with implicit sharing and + // avoiding memcpy when the user is reading the data + qba.clear(); +} + +void QHttpNetworkReplyPrivate::appendUncompressedReplyData(QByteDataBuffer &data) +{ + responseData.append(data); + + // clear the original! helps with implicit sharing and + // avoiding memcpy when the user is reading the data + data.clear(); +} + +void QHttpNetworkReplyPrivate::appendCompressedReplyData(QByteDataBuffer &data) +{ + // Work in progress: Later we will directly use a list of QByteArray or a QRingBuffer + // instead of one QByteArray. + for(int i = 0; i < data.bufferCount(); i++) { + QByteArray &byteData = data[i]; + compressedData.append(byteData.constData(), byteData.size()); + } + data.clear(); +} + + // SSL support below #ifndef QT_NO_OPENSSL diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index a386b10..fe49799 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -172,6 +172,10 @@ public: qint64 readReplyBodyChunked(QIODevice *in, QByteDataBuffer *out); qint64 getChunkSize(QIODevice *in, qint64 *chunkSize); + void appendUncompressedReplyData(QByteArray &qba); + void appendUncompressedReplyData(QByteDataBuffer &data); + void appendCompressedReplyData(QByteDataBuffer &data); + qint64 bytesAvailable() const; bool isChunked(); bool connectionCloseEnabled(); -- cgit v0.12 From fbee62af06ebe2c8cf6da1cc18a665c69c64eff7 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 3 Aug 2009 15:04:43 +0200 Subject: Renamed internal WinGesture event to NativeGesture. It will also be used on Mac, so it doesn't make sense to keep it windows specific. Reviewed-by: trustme --- src/corelib/kernel/qcoreevent.cpp | 2 +- src/corelib/kernel/qcoreevent.h | 2 +- src/gui/kernel/qapplication.cpp | 2 +- src/gui/kernel/qapplication_win.cpp | 10 +++++----- src/gui/kernel/qevent.cpp | 1 - src/gui/kernel/qevent_p.h | 13 +++++++++++-- src/gui/kernel/qwidget.cpp | 16 ++++++++-------- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index a682fad9..ff00c1c 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -269,7 +269,7 @@ QT_BEGIN_NAMESPACE \omitvalue FutureCallOut \omitvalue CocoaRequestModal \omitvalue Signal - \omitvalue WinGesture + \omitvalue NativeGesture */ /*! diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index 1d86f47..d941286 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -276,7 +276,7 @@ public: TouchUpdate = 195, TouchEnd = 196, - WinGesture = 197, + NativeGesture = 197, // Internal for platform gesture support // 512 reserved for Qt Jambi's MetaCall event // 513 reserved for Qt Jambi's DeleteOnMainThread event diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index e210556..c24ff49 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4052,7 +4052,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) touchEvent->setAccepted(eventAccepted); break; } - case QEvent::WinGesture: + case QEvent::NativeGesture: { // only propagate the first gesture event (after the GID_BEGIN) QWidget *w = static_cast(receiver); diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index d5c820c..3b5c0c3 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -3735,7 +3735,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg) alienWidget = 0; QWidget *widget = alienWidget ? alienWidget : this; - QWinGestureEvent event; + QNativeGestureEvent event; event.sequenceId = gi.dwSequenceID; event.position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y); if (bResult) { @@ -3744,13 +3744,13 @@ bool QETWidget::translateGestureEvent(const MSG &msg) // we are not interested in this type of event. break; case GID_END: - event.gestureType = QWinGestureEvent::GestureEnd; + event.gestureType = QNativeGestureEvent::GestureEnd; break; case GID_ZOOM: - event.gestureType = QWinGestureEvent::Pinch; + event.gestureType = QNativeGestureEvent::Pinch; break; case GID_PAN: - event.gestureType = QWinGestureEvent::Pan; + event.gestureType = QNativeGestureEvent::Pan; break; case GID_ROTATE: case GID_TWOFINGERTAP: @@ -3758,7 +3758,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg) default: break; } - if (event.gestureType != QWinGestureEvent::None) + if (event.gestureType != QNativeGestureEvent::None) qt_sendSpontaneousEvent(widget, &event); } else { DWORD dwErr = GetLastError(); diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index bc3633c..0fc36e7 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -49,7 +49,6 @@ #include "qmime.h" #include "qdnd_p.h" #include "qevent_p.h" -#include "qgesture.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index 67441ea..940e587 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -119,7 +119,7 @@ public: qreal pressure; }; -class QWinGestureEvent : public QEvent +class QNativeGestureEvent : public QEvent { public: enum Type { @@ -129,10 +129,19 @@ public: Pinch }; - QWinGestureEvent() : QEvent(QEvent::WinGesture), gestureType(None), sequenceId(0) { } + QNativeGestureEvent() + : QEvent(QEvent::NativeGesture), gestureType(None) +#ifdef Q_WS_WIN + , sequenceId(0) +#endif + { + } + Type gestureType; +#ifdef Q_WS_WIN QPoint position; ulong sequenceId; +#endif }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 43ac37d..5400146 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -7941,8 +7941,8 @@ bool QWidget::event(QEvent *event) break; } #ifdef Q_WS_WIN - case QEvent::WinGesture: { - QWinGestureEvent *ev = static_cast(event); + case QEvent::NativeGesture: { + QNativeGestureEvent *ev = static_cast(event); QApplicationPrivate *qAppPriv = qApp->d_func(); QApplicationPrivate::WidgetStandardGesturesMap::iterator it; it = qAppPriv->widgetGestures.find(this); @@ -7950,15 +7950,15 @@ bool QWidget::event(QEvent *event) Qt::GestureState state = Qt::GestureUpdated; if (qAppPriv->lastGestureId == 0) state = Qt::GestureStarted; - QWinGestureEvent::Type type = ev->gestureType; - if (ev->gestureType == QWinGestureEvent::GestureEnd) { - type = (QWinGestureEvent::Type)qAppPriv->lastGestureId; + QNativeGestureEvent::Type type = ev->gestureType; + if (ev->gestureType == QNativeGestureEvent::GestureEnd) { + type = (QNativeGestureEvent::Type)qAppPriv->lastGestureId; state = Qt::GestureFinished; } QGesture *gesture = 0; switch (type) { - case QWinGestureEvent::Pan: { + case QNativeGestureEvent::Pan: { QPanGesture *pan = it.value().pan; gesture = pan; if (state == Qt::GestureStarted) { @@ -7970,7 +7970,7 @@ bool QWidget::event(QEvent *event) gesture->setPos(ev->position); break; } - case QWinGestureEvent::Pinch: + case QNativeGestureEvent::Pinch: break; default: break; @@ -7984,7 +7984,7 @@ bool QWidget::event(QEvent *event) emit gesture->finished(); event->accept(); } - if (ev->gestureType == QWinGestureEvent::GestureEnd) { + if (ev->gestureType == QNativeGestureEvent::GestureEnd) { qAppPriv->lastGestureId = 0; } else { qAppPriv->lastGestureId = type; -- cgit v0.12 From 6e7a6478279a94a82af46e6814f113244aca46dd Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 3 Aug 2009 18:24:44 +0200 Subject: Moved the native window gesture handling code to the right place. --- src/gui/kernel/qapplication_win.cpp | 2 +- src/gui/kernel/qevent_p.h | 1 + src/gui/kernel/qstandardgestures.cpp | 124 +++++++++++++++++++++++++++++------ src/gui/kernel/qstandardgestures.h | 7 +- src/gui/kernel/qstandardgestures_p.h | 11 +++- src/gui/kernel/qwidget.cpp | 53 --------------- 6 files changed, 121 insertions(+), 77 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 3b5c0c3..2bded5c 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -3741,7 +3741,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg) if (bResult) { switch (gi.dwID) { case GID_BEGIN: - // we are not interested in this type of event. + event.gestureType = QNativeGestureEvent::GestureBegin; break; case GID_END: event.gestureType = QNativeGestureEvent::GestureEnd; diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index 940e587..92c4fc1 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -124,6 +124,7 @@ class QNativeGestureEvent : public QEvent public: enum Type { None, + GestureBegin, GestureEnd, Pan, Pinch diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index c4820f0..1fbfe15 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -45,9 +45,14 @@ #include #include #include +#include QT_BEGIN_NAMESPACE +#ifdef Q_WS_WIN +QApplicationPrivate* getQApplicationPrivateInternal(); +#endif + /*! \class QPanGesture \since 4.6 @@ -68,15 +73,10 @@ QPanGesture::QPanGesture(QWidget *parent) { #ifdef Q_WS_WIN if (parent) { - QApplicationPrivate* getQApplicationPrivateInternal(); QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal(); qAppPriv->widgetGestures[parent].pan = this; } #endif - -#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) - d_func()->panFinishedTimer = 0; -#endif } /*! \internal */ @@ -116,6 +116,62 @@ bool QPanGesture::event(QEvent *event) return QObject::event(event); } +bool QPanGesture::eventFilter(QObject *receiver, QEvent *event) +{ +#ifdef Q_WS_WIN + if (receiver->isWidgetType() && event->type() == QEvent::NativeGesture) { + QNativeGestureEvent *ev = static_cast(event); + QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal(); + QApplicationPrivate::WidgetStandardGesturesMap::iterator it; + it = qAppPriv->widgetGestures.find(static_cast(receiver)); + if (it == qAppPriv->widgetGestures.end()) + return false; + QPanGesture *gesture = it.value().pan; + if (!gesture) + return false; + Qt::GestureState nextState = state(); + switch(ev->gestureType) { + case QNativeGestureEvent::GestureBegin: + // next we might receive the first gesture update event, so we + // prepare for it. + setState(Qt::GestureStarted); + return false; + case QNativeGestureEvent::Pan: + nextState = Qt::GestureUpdated; + break; + case QNativeGestureEvent::GestureEnd: + if (state() != QNativeGestureEvent::Pan) + return false; // some other gesture has ended + setState(Qt::GestureFinished); + nextState = Qt::GestureFinished; + break; + default: + return false; + } + QPanGesturePrivate *d = gesture->d_func(); + if (state() == Qt::GestureStarted) { + d->lastPosition = ev->position; + d->lastOffset = d->totalOffset = QSize(); + } else { + d->lastOffset = QSize(ev->position.x() - d->lastPosition.x(), + ev->position.y() - d->lastPosition.y()); + d->totalOffset += d->lastOffset; + } + d->lastPosition = ev->position; + + if (state() == Qt::GestureStarted) + emit gesture->started(); + emit gesture->triggered(); + if (state() == Qt::GestureFinished) + emit gesture->finished(); + event->accept(); + gesture->setState(nextState); + return true; + } +#endif + return QGesture::eventFilter(receiver, event); +} + /*! \internal */ bool QPanGesture::filterEvent(QEvent *event) { @@ -124,28 +180,34 @@ bool QPanGesture::filterEvent(QEvent *event) return false; const QTouchEvent *ev = static_cast(event); if (event->type() == QEvent::TouchBegin) { - d->touchPoints = ev->touchPoints(); - const QPoint p = ev->touchPoints().at(0).pos().toPoint(); - setStartPos(p); - setLastPos(p); - setPos(p); - return false; + QTouchEvent::TouchPoint p = ev->touchPoints().at(0); + d->lastPosition = p.pos().toPoint(); + d->lastOffset = d->totalOffset = QSize(); } else if (event->type() == QEvent::TouchEnd) { if (state() != Qt::NoGesture) { setState(Qt::GestureFinished); - setLastPos(pos()); - setPos(ev->touchPoints().at(0).pos().toPoint()); + if (!ev->touchPoints().isEmpty()) { + QTouchEvent::TouchPoint p = ev->touchPoints().at(0); + const QPoint pos = p.pos().toPoint(); + const QPoint lastPos = p.lastPos().toPoint(); + const QPoint startPos = p.startPos().toPoint(); + d->lastOffset = QSize(pos.x() - lastPos.x(), pos.y() - lastPos.y()); + d->totalOffset = QSize(pos.x() - startPos.x(), pos.y() - startPos.y()); + } emit triggered(); emit finished(); } setState(Qt::NoGesture); reset(); } else if (event->type() == QEvent::TouchUpdate) { - d->touchPoints = ev->touchPoints(); - QPointF pt = d->touchPoints.at(0).pos() - d->touchPoints.at(0).startPos(); - setLastPos(pos()); - setPos(ev->touchPoints().at(0).pos().toPoint()); - if (pt.x() > 10 || pt.y() > 10 || pt.x() < -10 || pt.y() < -10) { + QTouchEvent::TouchPoint p = ev->touchPoints().at(0); + const QPoint pos = p.pos().toPoint(); + const QPoint lastPos = p.lastPos().toPoint(); + const QPoint startPos = p.startPos().toPoint(); + d->lastOffset = QSize(pos.x() - lastPos.x(), pos.y() - lastPos.y()); + d->totalOffset = QSize(pos.x() - startPos.x(), pos.y() - startPos.y()); + if (d->totalOffset.width() > 10 || d->totalOffset.height() > 10 || + d->totalOffset.width() < -10 || d->totalOffset.height() < -10) { if (state() == Qt::NoGesture) setState(Qt::GestureStarted); else @@ -190,7 +252,14 @@ bool QPanGesture::filterEvent(QEvent *event) void QPanGesture::reset() { Q_D(QPanGesture); - d->touchPoints.clear(); + d->lastOffset = d->totalOffset = QSize(); + d->lastPosition = QPoint(); +#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) + if (d->panFinishedTimer) { + killTimer(d->panFinishedTimer); + d->panFinishedTimer = 0; + } +#endif } /*! @@ -226,6 +295,23 @@ QSize QPanGesture::lastOffset() const #endif } +QPoint QPanGesture::startPos() const +{ + Q_D(const QPanGesture); + return d->startPos; +} +QPoint QPanGesture::lastPos() const +{ + Q_D(const QPanGesture); + return d->lastPos; +} + +QPoint QPanGesture::pos() const +{ + Q_D(const QPanGesture); + return d->pos; +} + /*! \class QTapAndHoldGesture \since 4.6 diff --git a/src/gui/kernel/qstandardgestures.h b/src/gui/kernel/qstandardgestures.h index 2234702..030aac8 100644 --- a/src/gui/kernel/qstandardgestures.h +++ b/src/gui/kernel/qstandardgestures.h @@ -70,11 +70,14 @@ public: QSize totalOffset() const; QSize lastOffset() const; + QPoint startPos() const; + QPoint lastPos() const; + QPoint pos() const; -protected: +private: bool event(QEvent *event); + bool eventFilter(QObject *receiver, QEvent *event); -private: friend class QWidget; }; diff --git a/src/gui/kernel/qstandardgestures_p.h b/src/gui/kernel/qstandardgestures_p.h index 0fd42bd..dd4fbc0 100644 --- a/src/gui/kernel/qstandardgestures_p.h +++ b/src/gui/kernel/qstandardgestures_p.h @@ -60,6 +60,8 @@ #include "qgesture.h" #include "qgesture_p.h" +#include "qstandardgestures.h" + QT_BEGIN_NAMESPACE class QPanGesturePrivate : public QGesturePrivate @@ -67,11 +69,16 @@ class QPanGesturePrivate : public QGesturePrivate Q_DECLARE_PUBLIC(QPanGesture) public: - QPanGesturePrivate() { } + QPanGesturePrivate() + { +#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) + panFinishedTimer = 0; +#endif + } - QList touchPoints; QSize totalOffset; QSize lastOffset; + QPoint lastPosition; #if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) int panFinishedTimer; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 5400146..765b26f 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -7940,59 +7940,6 @@ bool QWidget::event(QEvent *event) (void) QApplication::sendEvent(this, &mouseEvent); break; } -#ifdef Q_WS_WIN - case QEvent::NativeGesture: { - QNativeGestureEvent *ev = static_cast(event); - QApplicationPrivate *qAppPriv = qApp->d_func(); - QApplicationPrivate::WidgetStandardGesturesMap::iterator it; - it = qAppPriv->widgetGestures.find(this); - if (it != qAppPriv->widgetGestures.end()) { - Qt::GestureState state = Qt::GestureUpdated; - if (qAppPriv->lastGestureId == 0) - state = Qt::GestureStarted; - QNativeGestureEvent::Type type = ev->gestureType; - if (ev->gestureType == QNativeGestureEvent::GestureEnd) { - type = (QNativeGestureEvent::Type)qAppPriv->lastGestureId; - state = Qt::GestureFinished; - } - - QGesture *gesture = 0; - switch (type) { - case QNativeGestureEvent::Pan: { - QPanGesture *pan = it.value().pan; - gesture = pan; - if (state == Qt::GestureStarted) { - gesture->setStartPos(ev->position); - gesture->setLastPos(ev->position); - } else { - gesture->setLastPos(gesture->pos()); - } - gesture->setPos(ev->position); - break; - } - case QNativeGestureEvent::Pinch: - break; - default: - break; - } - if (gesture) { - gesture->setState(state); - if (state == Qt::GestureStarted) - emit gesture->started(); - emit gesture->triggered(); - if (state == Qt::GestureFinished) - emit gesture->finished(); - event->accept(); - } - if (ev->gestureType == QNativeGestureEvent::GestureEnd) { - qAppPriv->lastGestureId = 0; - } else { - qAppPriv->lastGestureId = type; - } - } - break; - } -#endif #ifndef QT_NO_PROPERTIES case QEvent::DynamicPropertyChange: { const QByteArray &propName = static_cast(event)->propertyName(); -- cgit v0.12 From 6b85ec8790aad8ac01c04f7e7bd4913d8cd8d104 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 3 Aug 2009 17:02:58 +0200 Subject: Removed the QTapAndHoldGesture Moved the gesture implementation to the imageviewer example as it cannot be fully implemented in a crossplatform way - for example on Windows tap and hold is a system gesture that is transparent to the application. Reviewed-by: trustme --- examples/gestures/imageviewer/imageviewer.pro | 11 +-- examples/gestures/imageviewer/imagewidget.cpp | 15 ++- examples/gestures/imageviewer/imagewidget.h | 4 +- .../gestures/imageviewer/tapandholdgesture.cpp | 97 ++++++++++++++++++++ examples/gestures/imageviewer/tapandholdgesture.h | 32 +++++++ src/gui/kernel/qstandardgestures.cpp | 101 ++++----------------- src/gui/kernel/qstandardgestures.h | 16 ---- src/gui/kernel/qstandardgestures_p.h | 14 --- 8 files changed, 167 insertions(+), 123 deletions(-) create mode 100644 examples/gestures/imageviewer/tapandholdgesture.cpp create mode 100644 examples/gestures/imageviewer/tapandholdgesture.h diff --git a/examples/gestures/imageviewer/imageviewer.pro b/examples/gestures/imageviewer/imageviewer.pro index 4c35dce..efbca00 100644 --- a/examples/gestures/imageviewer/imageviewer.pro +++ b/examples/gestures/imageviewer/imageviewer.pro @@ -1,12 +1,11 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Thu Sep 11 17:18:17 2008 -###################################################################### - TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += . # Input -HEADERS += imagewidget.h -SOURCES += imagewidget.cpp main.cpp +HEADERS += imagewidget.h \ + tapandholdgesture.h +SOURCES += imagewidget.cpp \ + tapandholdgesture.cpp \ + main.cpp diff --git a/examples/gestures/imageviewer/imagewidget.cpp b/examples/gestures/imageviewer/imagewidget.cpp index 0b39997..99889ed 100644 --- a/examples/gestures/imageviewer/imagewidget.cpp +++ b/examples/gestures/imageviewer/imagewidget.cpp @@ -65,7 +65,7 @@ ImageWidget::ImageWidget(QWidget *parent) panGesture = new QPanGesture(this); connect(panGesture, SIGNAL(triggered()), this, SLOT(gestureTriggered())); - tapAndHoldGesture = new QTapAndHoldGesture(this); + tapAndHoldGesture = new TapAndHoldGesture(this); connect(tapAndHoldGesture, SIGNAL(triggered()), this, SLOT(gestureTriggered())); } @@ -188,6 +188,19 @@ void ImageWidget::gestureTriggered() } } feedbackFadeOutTimer.start(500, this); + } else if (sender() == tapAndHoldGesture) { + if (tapAndHoldGesture->state() == Qt::GestureFinished) { + qDebug() << "tap and hold detected"; + touchFeedback.reset(); + update(); + + QMenu menu; + menu.addAction("Action 1"); + menu.addAction("Action 2"); + menu.addAction("Action 3"); + menu.exec(mapToGlobal(tapAndHoldGesture->pos())); + } + feedbackFadeOutTimer.start(500, this); } } diff --git a/examples/gestures/imageviewer/imagewidget.h b/examples/gestures/imageviewer/imagewidget.h index e12634d..d8d5f8d 100644 --- a/examples/gestures/imageviewer/imagewidget.h +++ b/examples/gestures/imageviewer/imagewidget.h @@ -48,6 +48,8 @@ #include +#include "tapandholdgesture.h" + class ImageWidget : public QWidget { Q_OBJECT @@ -79,7 +81,7 @@ private: void goToImage(int index); QPanGesture *panGesture; - QTapAndHoldGesture *tapAndHoldGesture; + TapAndHoldGesture *tapAndHoldGesture; QString path; QStringList files; diff --git a/examples/gestures/imageviewer/tapandholdgesture.cpp b/examples/gestures/imageviewer/tapandholdgesture.cpp new file mode 100644 index 0000000..c6f6779 --- /dev/null +++ b/examples/gestures/imageviewer/tapandholdgesture.cpp @@ -0,0 +1,97 @@ +#include "tapandholdgesture.h" + +#include + +/*! + \class TapAndHoldGesture + \since 4.6 + + \brief The TapAndHoldGesture class represents a Tap-and-Hold gesture, + providing additional information. +*/ + +const int TapAndHoldGesture::iterationCount = 40; +const int TapAndHoldGesture::iterationTimeout = 50; + +/*! + Creates a new Tap and Hold gesture handler object and marks it as a child + of \a parent. + + On some platforms like Windows there is a system-wide tap and hold gesture + that cannot be overriden, hence the gesture might never trigger and default + context menu will be shown instead. +*/ +TapAndHoldGesture::TapAndHoldGesture(QWidget *parent) + : QGesture(parent), iteration(0) +{ +} + +/*! \internal */ +bool TapAndHoldGesture::filterEvent(QEvent *event) +{ + if (!event->spontaneous()) + return false; + const QTouchEvent *ev = static_cast(event); + switch (event->type()) { + case QEvent::TouchBegin: { + if (timer.isActive()) + timer.stop(); + timer.start(TapAndHoldGesture::iterationTimeout, this); + const QPoint p = ev->touchPoints().at(0).pos().toPoint(); + position = p; + break; + } + case QEvent::TouchUpdate: + if (ev->touchPoints().size() == 1) { + const QPoint startPos = ev->touchPoints().at(0).startPos().toPoint(); + const QPoint pos = ev->touchPoints().at(0).pos().toPoint(); + if ((startPos - pos).manhattanLength() > 15) + reset(); + } else { + reset(); + } + break; + case QEvent::TouchEnd: + reset(); + break; + default: + break; + } + return false; +} + +/*! \internal */ +void TapAndHoldGesture::timerEvent(QTimerEvent *event) +{ + if (event->timerId() != timer.timerId()) + return; + if (iteration == TapAndHoldGesture::iterationCount) { + timer.stop(); + setState(Qt::GestureFinished); + emit triggered(); + } else { + setState(Qt::GestureStarted); + emit triggered(); + } + ++iteration; +} + +/*! \internal */ +void TapAndHoldGesture::reset() +{ + if (state() != Qt::NoGesture) + emit cancelled(); + setState(Qt::NoGesture); + timer.stop(); + iteration = 0; +} + +/*! + \property TapAndHoldGesture::pos + + \brief The position of the gesture. +*/ +QPoint TapAndHoldGesture::pos() const +{ + return position; +} diff --git a/examples/gestures/imageviewer/tapandholdgesture.h b/examples/gestures/imageviewer/tapandholdgesture.h new file mode 100644 index 0000000..711a1af --- /dev/null +++ b/examples/gestures/imageviewer/tapandholdgesture.h @@ -0,0 +1,32 @@ +#ifndef TAPANDHOLDGESTURE_H +#define TAPANDHOLDGESTURE_H + +#include +#include +#include + +class TapAndHoldGesture : public QGesture +{ + Q_OBJECT + Q_PROPERTY(QPoint pos READ pos) + +public: + TapAndHoldGesture(QWidget *parent); + + bool filterEvent(QEvent *event); + void reset(); + + QPoint pos() const; + +protected: + void timerEvent(QTimerEvent *event); + +private: + QBasicTimer timer; + int iteration; + QPoint position; + static const int iterationCount; + static const int iterationTimeout; +}; + +#endif // TAPANDHOLDGESTURE_H diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 1fbfe15..e4b9abb 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -295,106 +295,37 @@ QSize QPanGesture::lastOffset() const #endif } +/*! + \property QPanGesture::startPos + + \brief The start position of the gesture. +*/ QPoint QPanGesture::startPos() const { Q_D(const QPanGesture); return d->startPos; } + +/*! + \property QPanGesture::lastPos + + \brief The last recorded position of the gesture. +*/ QPoint QPanGesture::lastPos() const { Q_D(const QPanGesture); return d->lastPos; } -QPoint QPanGesture::pos() const -{ - Q_D(const QPanGesture); - return d->pos; -} - /*! - \class QTapAndHoldGesture - \since 4.6 - - \brief The QTapAndHoldGesture class represents a Tap-and-Hold gesture, - providing additional information. -*/ - -const int QTapAndHoldGesturePrivate::iterationCount = 40; -const int QTapAndHoldGesturePrivate::iterationTimeout = 50; - -/*! - Creates a new Tap and Hold gesture handler object and marks it as a child - of \a parent. + \property QPanGesture::pos - On some platforms like Windows there is a system-wide tap and hold gesture - that cannot be overriden, hence the gesture might never trigger and default - context menu will be shown instead. + \brief The current position of the gesture. */ -QTapAndHoldGesture::QTapAndHoldGesture(QWidget *parent) - : QGesture(*new QTapAndHoldGesturePrivate, parent) -{ -} - -/*! \internal */ -bool QTapAndHoldGesture::filterEvent(QEvent *event) -{ - Q_D(QTapAndHoldGesture); - if (!event->spontaneous()) - return false; - const QTouchEvent *ev = static_cast(event); - switch (event->type()) { - case QEvent::TouchBegin: { - if (d->timer.isActive()) - d->timer.stop(); - d->timer.start(QTapAndHoldGesturePrivate::iterationTimeout, this); - const QPoint p = ev->touchPoints().at(0).pos().toPoint(); - setStartPos(p); - setLastPos(p); - setPos(p); - break; - } - case QEvent::TouchUpdate: - if (ev->touchPoints().size() != 1) - reset(); - else if ((startPos() - ev->touchPoints().at(0).pos().toPoint()).manhattanLength() > 15) - reset(); - break; - case QEvent::TouchEnd: - reset(); - break; - default: - break; - } - return false; -} - -/*! \internal */ -void QTapAndHoldGesture::timerEvent(QTimerEvent *event) -{ - Q_D(QTapAndHoldGesture); - if (event->timerId() != d->timer.timerId()) - return; - if (d->iteration == QTapAndHoldGesturePrivate::iterationCount) { - d->timer.stop(); - setState(Qt::GestureFinished); - emit triggered(); - } else { - setState(Qt::GestureStarted); - emit triggered(); - } - ++d->iteration; -} - -/*! \internal */ -void QTapAndHoldGesture::reset() +QPoint QPanGesture::pos() const { - Q_D(QTapAndHoldGesture); - if (state() != Qt::NoGesture) - emit cancelled(); - setState(Qt::NoGesture); - d->timer.stop(); - d->iteration = 0; + Q_D(const QPanGesture); + return d->pos; } QT_END_NAMESPACE diff --git a/src/gui/kernel/qstandardgestures.h b/src/gui/kernel/qstandardgestures.h index 030aac8..c6f6d9b 100644 --- a/src/gui/kernel/qstandardgestures.h +++ b/src/gui/kernel/qstandardgestures.h @@ -81,22 +81,6 @@ private: friend class QWidget; }; -class QTapAndHoldGesturePrivate; -class Q_GUI_EXPORT QTapAndHoldGesture : public QGesture -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QTapAndHoldGesture) - -public: - QTapAndHoldGesture(QWidget *parent); - - bool filterEvent(QEvent *event); - void reset(); - -protected: - void timerEvent(QTimerEvent *event); -}; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/kernel/qstandardgestures_p.h b/src/gui/kernel/qstandardgestures_p.h index dd4fbc0..0fe24ee 100644 --- a/src/gui/kernel/qstandardgestures_p.h +++ b/src/gui/kernel/qstandardgestures_p.h @@ -85,20 +85,6 @@ public: #endif }; -class QTapAndHoldGesturePrivate : public QGesturePrivate -{ - Q_DECLARE_PUBLIC(QTapAndHoldGesture) - -public: - QTapAndHoldGesturePrivate() - : iteration(0) { } - - QBasicTimer timer; - int iteration; - static const int iterationCount; - static const int iterationTimeout; -}; - QT_END_NAMESPACE #endif // QSTANDARDGESTURES_P_H -- cgit v0.12 From 47c191d3c6b9c3fbe062068167888bed434ab6e2 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 4 Aug 2009 13:37:35 +0200 Subject: Removed the startPos/lastPos/pos from the gesture classes. It doesn't make much sense to have that low-level info neither in the base QGesture class, nor in the QPanGesture, as the latter one has offset properties instead. Reviewed-by: trustme --- src/gui/kernel/qgesture.cpp | 45 ------------------------------------ src/gui/kernel/qgesture.h | 14 ++--------- src/gui/kernel/qgesture_p.h | 11 --------- src/gui/kernel/qstandardgestures.cpp | 43 ---------------------------------- src/gui/kernel/qstandardgestures.h | 3 --- src/gui/widgets/qtextedit.cpp | 8 +++---- 6 files changed, 6 insertions(+), 118 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index 1f98013..32ac4f8 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -205,51 +205,6 @@ void QGesture::setState(Qt::GestureState state) } /*! - \property QGesture::startPos - - \brief The start position of the gesture (if relevant). -*/ -QPoint QGesture::startPos() const -{ - return d_func()->startPos; -} - -void QGesture::setStartPos(const QPoint &point) -{ - d_func()->startPos = point; -} - -/*! - \property QGesture::lastPos - - \brief The last recorded position of the gesture (if relevant). -*/ -QPoint QGesture::lastPos() const -{ - return d_func()->lastPos; -} - -void QGesture::setLastPos(const QPoint &point) -{ - d_func()->lastPos = point; -} - -/*! - \property QGesture::pos - - \brief The current position of the gesture (if relevant). -*/ -QPoint QGesture::pos() const -{ - return d_func()->pos; -} - -void QGesture::setPos(const QPoint &point) -{ - d_func()->pos = point; -} - -/*! Sets the \a graphicsItem the gesture is filtering events for. The gesture will install an event filter to the \a graphicsItem and diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index 1cd9cae..0735160 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -64,10 +64,6 @@ class Q_GUI_EXPORT QGesture : public QObject Q_PROPERTY(Qt::GestureState state READ state) - Q_PROPERTY(QPoint startPos READ startPos WRITE setStartPos) - Q_PROPERTY(QPoint lastPos READ lastPos WRITE setLastPos) - Q_PROPERTY(QPoint pos READ pos WRITE setPos) - public: explicit QGesture(QObject *parent = 0); ~QGesture(); @@ -80,19 +76,13 @@ public: virtual void reset(); Qt::GestureState state() const; - void setState(Qt::GestureState state); - - QPoint startPos() const; - void setStartPos(const QPoint &point); - QPoint lastPos() const; - void setLastPos(const QPoint &point); - QPoint pos() const; - void setPos(const QPoint &point); protected: QGesture(QGesturePrivate &dd, QObject *parent); bool eventFilter(QObject*, QEvent*); + void setState(Qt::GestureState state); + Q_SIGNALS: void started(); void triggered(); diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index 99f572f..56eaee7 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -73,22 +73,11 @@ public: { } - void init(const QPoint &startPos, const QPoint &lastPos, - const QPoint &pos) - { - this->startPos = startPos; - this->lastPos = lastPos; - this->pos = pos; - } QGraphicsItem *graphicsItem; QGraphicsItem *eventFilterProxyGraphicsItem; Qt::GestureState state; - - QPoint startPos; - QPoint lastPos; - QPoint pos; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index e4b9abb..4753416 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -269,13 +269,8 @@ void QPanGesture::reset() */ QSize QPanGesture::totalOffset() const { -#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) Q_D(const QPanGesture); return d->totalOffset; -#else - QPoint pt = pos() - startPos(); - return QSize(pt.x(), pt.y()); -#endif } /*! @@ -286,46 +281,8 @@ QSize QPanGesture::totalOffset() const */ QSize QPanGesture::lastOffset() const { -#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) Q_D(const QPanGesture); return d->lastOffset; -#else - QPoint pt = pos() - lastPos(); - return QSize(pt.x(), pt.y()); -#endif -} - -/*! - \property QPanGesture::startPos - - \brief The start position of the gesture. -*/ -QPoint QPanGesture::startPos() const -{ - Q_D(const QPanGesture); - return d->startPos; -} - -/*! - \property QPanGesture::lastPos - - \brief The last recorded position of the gesture. -*/ -QPoint QPanGesture::lastPos() const -{ - Q_D(const QPanGesture); - return d->lastPos; -} - -/*! - \property QPanGesture::pos - - \brief The current position of the gesture. -*/ -QPoint QPanGesture::pos() const -{ - Q_D(const QPanGesture); - return d->pos; } QT_END_NAMESPACE diff --git a/src/gui/kernel/qstandardgestures.h b/src/gui/kernel/qstandardgestures.h index c6f6d9b..c734fba 100644 --- a/src/gui/kernel/qstandardgestures.h +++ b/src/gui/kernel/qstandardgestures.h @@ -70,9 +70,6 @@ public: QSize totalOffset() const; QSize lastOffset() const; - QPoint startPos() const; - QPoint lastPos() const; - QPoint pos() const; private: bool event(QEvent *event); diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index e80df92..c095f5c 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -2625,12 +2625,12 @@ void QTextEditPrivate::_q_gestureTriggered() return; QScrollBar *hBar = q->horizontalScrollBar(); QScrollBar *vBar = q->verticalScrollBar(); - QPoint delta = g->pos() - (g->lastPos().isNull() ? g->pos() : g->lastPos()); + QSize delta = g->lastOffset(); if (!delta.isNull()) { if (QApplication::isRightToLeft()) - delta.rx() *= -1; - int newX = hBar->value() - delta.x(); - int newY = vBar->value() - delta.y(); + delta.rwidth() *= -1; + int newX = hBar->value() - delta.width(); + int newY = vBar->value() - delta.height(); hbar->setValue(newX); vbar->setValue(newY); } -- cgit v0.12 From 6d9143ebffc10a58d8d62e57e3378adae4af92cd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 4 Aug 2009 10:37:39 +0200 Subject: Don't try to make direct system calls on Linux. Accept that we cannot do everything, so users using outdated toolchains may have threading problems (leaking file descriptors). It's not like this is a recent problem anyway... Reviewed-By: Bradley T. Hughes --- src/corelib/kernel/qcore_unix.cpp | 73 --------------------------------------- src/corelib/kernel/qcore_unix_p.h | 34 +++++------------- src/network/socket/qnet_unix_p.h | 2 +- 3 files changed, 10 insertions(+), 99 deletions(-) diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index b57d385..efa9c6d 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -161,76 +161,3 @@ int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, } QT_END_NAMESPACE - -#ifdef Q_OS_LINUX -// Don't wait for libc to supply the calls we need -// Make syscalls directly - -# if defined(__GLIBC__) && (__GLIBC__ * 0x100 + __GLIBC_MINOR__) >= 0x0204 -// glibc 2.4 has syscall(...) -# include -# include -# else -// no syscall(...) -static inline int syscall(...) { errno = ENOSYS; return -1;} -# endif - -# ifndef __NR_dup3 -# if defined(__i386__) -# define __NR_dup3 330 -# define __NR_pipe2 331 -# elif defined(__x86_64__) -# define __NR_dup3 292 -# define __NR_pipe2 293 -# elif defined(__ia64__) -# define __NR_dup3 1316 -# define __NR_pipe2 1317 -# else -// set the syscalls to absurd numbers so that they'll cause ENOSYS errors -# warning "Please port the pipe2/dup3 code to this platform" -# define __NR_dup3 -1 -# define __NR_pipe2 -1 -# endif -# endif - -# if !defined(__NR_socketcall) && !defined(__NR_accept4) -# if defined(__x86_64__) -# define __NR_accept4 288 -# elif defined(__ia64__) -// not assigned yet to IA-64 -# define __NR_accept4 -1 -# else -// set the syscalls to absurd numbers so that they'll cause ENOSYS errors -# warning "Please port the accept4 code to this platform" -# define __NR_accept4 -1 -# endif -# endif - -QT_BEGIN_NAMESPACE -namespace QtLibcSupplement { - int pipe2(int pipes[], int flags) - { - return syscall(__NR_pipe2, pipes, flags); - } - - int dup3(int oldfd, int newfd, int flags) - { - return syscall(__NR_dup3, oldfd, newfd, flags); - } - - int accept4(int s, sockaddr *addr, QT_SOCKLEN_T *addrlen, int flags) - { -# if defined(__NR_socketcall) - // This platform uses socketcall() instead of raw syscalls - // the SYS_ACCEPT4 number is cross-platform: 18 - return syscall(__NR_socketcall, 18, &s); -# else - return syscall(__NR_accept4, s, addr, addrlen, flags); -# endif - - Q_UNUSED(addr); Q_UNUSED(addrlen); Q_UNUSED(flags); // they're actually used - } -} -QT_END_NAMESPACE -#endif // Q_OS_LINUX - diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 69ebb05..3bdd5ec 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -73,32 +73,16 @@ struct sockaddr; -#if defined(Q_OS_LINUX) && defined(__GLIBC__) && (__GLIBC__ * 0x100 + __GLIBC_MINOR__) >= 0x0204 -// Linux supports thread-safe FD_CLOEXEC +#if defined(Q_OS_LINUX) && defined(O_CLOEXEC) # define QT_UNIX_SUPPORTS_THREADSAFE_CLOEXEC 1 - -// add defines for the consts for Linux -# ifndef O_CLOEXEC -# define O_CLOEXEC 02000000 -# endif -# ifndef FD_DUPFD_CLOEXEC -# define F_DUPFD_CLOEXEC 1030 -# endif -# ifndef SOCK_CLOEXEC -# define SOCK_CLOEXEC O_CLOEXEC -# endif -# ifndef SOCK_NONBLOCK -# define SOCK_NONBLOCK O_NONBLOCK -# endif -# ifndef MSG_CMSG_CLOEXEC -# define MSG_CMSG_CLOEXEC 0x40000000 -# endif - QT_BEGIN_NAMESPACE namespace QtLibcSupplement { - Q_CORE_EXPORT int accept4(int, sockaddr *, QT_SOCKLEN_T *, int flags); - Q_CORE_EXPORT int dup3(int oldfd, int newfd, int flags); - Q_CORE_EXPORT int pipe2(int pipes[], int flags); + inline int accept4(int, sockaddr *, QT_SOCKLEN_T *, int) + { errno = ENOSYS; return -1; } + inline int dup3(int, int, int) + { errno = ENOSYS; return -1; } + inline int pipe2(int [], int ) + { errno = ENOSYS; return -1; } } QT_END_NAMESPACE using namespace QT_PREPEND_NAMESPACE(QtLibcSupplement); @@ -190,7 +174,7 @@ static inline int qt_safe_pipe(int pipefd[2], int flags = 0) #endif register int ret; -#if QT_UNIX_SUPPORTS_THREADSAFE_CLOEXEC +#if QT_UNIX_SUPPORTS_THREADSAFE_CLOEXEC && defined(O_CLOEXEC) // use pipe2 flags |= O_CLOEXEC; ret = ::pipe2(pipefd, flags); // pipe2 is Linux-specific and is documented not to return EINTR @@ -246,7 +230,7 @@ static inline int qt_safe_dup2(int oldfd, int newfd, int flags = FD_CLOEXEC) Q_ASSERT(flags == FD_CLOEXEC || flags == 0); register int ret; -#if QT_UNIX_SUPPORTS_THREADSAFE_CLOEXEC +#if QT_UNIX_SUPPORTS_THREADSAFE_CLOEXEC && defined(O_CLOEXEC) // use dup3 if (flags & FD_CLOEXEC) { EINTR_LOOP(ret, ::dup3(oldfd, newfd, O_CLOEXEC)); diff --git a/src/network/socket/qnet_unix_p.h b/src/network/socket/qnet_unix_p.h index f38c2fc..040b3ec 100644 --- a/src/network/socket/qnet_unix_p.h +++ b/src/network/socket/qnet_unix_p.h @@ -85,7 +85,7 @@ static inline int qt_safe_socket(int domain, int type, int protocol, int flags = Q_ASSERT((flags & ~O_NONBLOCK) == 0); register int fd; -#ifdef SOCK_CLOEXEC +#if defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK) int newtype = type | SOCK_CLOEXEC; if (flags & O_NONBLOCK) newtype |= SOCK_NONBLOCK; -- cgit v0.12 From 9081e1e65681aab1c1d8a913b1a493fe1d37e837 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 3 Aug 2009 18:43:54 +0200 Subject: Clean up old Jambi code: there's a way of getting the QObject d-pointer --- src/corelib/kernel/qobject.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 7bf209a..c989d15 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3897,19 +3897,12 @@ QDebug operator<<(QDebug dbg, const QObject *o) { Synonym for QList. */ -#ifdef QT_JAMBI_BUILD -class QDPtrAccessor : public QObject { -public: - QObjectData *d() const { return d_ptr; } -}; -#endif - void qDeleteInEventHandler(QObject *o) { #ifdef QT_JAMBI_BUILD if (!o) return; - ((QDPtrAccessor *) o)->d()->inEventHandler = false; + QObjectPrivate::get(o)->inEventHandler = false; #endif delete o; } -- cgit v0.12 From d6e7238903d381bf2c2c9f89c17085e714384e87 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 31 Jul 2009 18:46:11 +0200 Subject: Reorganise QObjectPrivate so that it's easier to tell what's in it. Also rename QDeclarativeData to QObjectDeletionNotification, since it has no relation to declarative UI. It's just notification of the object's deletion. Make the destructor non-inline and place it in qobject.cpp, so that the virtual table is emitted there and exported from QtCore. Also move the QObjectData destructor to qobject.cpp. This means you cannot create any class deriving directly from QObjectData outside QtCore, which is the intention anyways (it's a private class and only QObjectPrivate derives from it). Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qobject.cpp | 16 +++--- src/corelib/kernel/qobject_p.h | 113 +++++++++++++++++++++-------------------- src/gui/kernel/qwidget.cpp | 7 ++- 3 files changed, 66 insertions(+), 70 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index c989d15..1938012 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -122,8 +122,11 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) } } +QObjectData::~QObjectData() {} +QObjectDeletionNotification::~QObjectDeletionNotification() {} + QObjectPrivate::QObjectPrivate(int version) - : threadData(0), currentSender(0), declarativeData(0), connectionLists(0), senders(0) + : threadData(0), connectionLists(0), senders(0), currentSender(0), deletionNotification(0), objectGuards(0) { if (version != QObjectPrivateVersion) qFatal("Cannot mix incompatible Qt libraries"); @@ -144,7 +147,6 @@ QObjectPrivate::QObjectPrivate(int version) inEventHandler = false; inThreadChangeEvent = false; deleteWatch = 0; - objectGuards = 0; metaObject = 0; hasGuards = false; } @@ -767,6 +769,8 @@ QObject::~QObject() } emit destroyed(this); + if (d->deletionNotification) + d->deletionNotification->destroyed(this); { QMutexLocker locker(signalSlotLock(this)); @@ -844,14 +848,6 @@ QObject::~QObject() d->eventFilters.clear(); - // As declarativeData is in a union with currentChildBeingDeleted, this must - // be done (and declarativeData set back to 0) before deleting children. - if(d->declarativeData) { - QDeclarativeData *dd = d->declarativeData; - d->declarativeData = 0; - dd->destroyed(this); - } - if (!d->children.isEmpty()) d->deleteChildren(); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 0b41c9a..52b4658 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -82,63 +82,21 @@ void Q_CORE_EXPORT qt_register_signal_spy_callbacks(const QSignalSpyCallbackSet extern QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set; -inline QObjectData::~QObjectData() {} - enum { QObjectPrivateVersion = QT_VERSION }; -class QDeclarativeData +class Q_CORE_EXPORT QObjectDeletionNotification { public: - virtual ~QDeclarativeData() {} - virtual void destroyed(QObject *) {} + virtual ~QObjectDeletionNotification(); + virtual void destroyed(QObject *) = 0; }; +typedef QObjectDeletionNotification QDeclarativeData; // remove me when Declarative UI updates class Q_CORE_EXPORT QObjectPrivate : public QObjectData { Q_DECLARE_PUBLIC(QObject) public: - QObjectPrivate(int version = QObjectPrivateVersion); - virtual ~QObjectPrivate(); - -#ifdef QT3_SUPPORT - QList pendingChildInsertedEvents; - void sendPendingChildInsertedEvents(); - void removePendingChildInsertedEvents(QObject *child); -#else - // preserve binary compatibility with code compiled without Qt 3 support - QList unused; -#endif - - // id of the thread that owns the object - QThreadData *threadData; - void moveToThread_helper(); - void setThreadData_helper(QThreadData *currentData, QThreadData *targetData); - void _q_reregisterTimers(void *pointer); - - struct Sender - { - QObject *sender; - int signal; - int ref; - }; - // object currently activating the object - Sender *currentSender; - - QDeclarativeData *declarativeData; - - bool isSender(const QObject *receiver, const char *signal) const; - QObjectList receiverList(const char *signal) const; - QObjectList senderList() const; - - QList > eventFilters; - - void setParent_helper(QObject *); - - void deleteChildren(); - - static void clearGuards(QObject *); - struct ExtraData { #ifndef QT_NO_USERDATA @@ -147,12 +105,7 @@ public: QList propertyNames; QList propertyValues; }; - ExtraData *extraData; - mutable quint32 connectedSignals[2]; - - QString objectName; - // Note: you must hold the signalSlotLock() before accessing the lists below or calling the functions struct Connection { QObject *sender; @@ -167,11 +120,34 @@ public: }; typedef QList ConnectionList; - QObjectConnectionListVector *connectionLists; + struct Sender + { + QObject *sender; + int signal; + int ref; + }; + + + QObjectPrivate(int version = QObjectPrivateVersion); + virtual ~QObjectPrivate(); + void deleteChildren(); + + void setParent_helper(QObject *); + void moveToThread_helper(); + void setThreadData_helper(QThreadData *currentData, QThreadData *targetData); + void _q_reregisterTimers(void *pointer); + + bool isSender(const QObject *receiver, const char *signal) const; + QObjectList receiverList(const char *signal) const; + QObjectList senderList() const; + void addConnection(int signal, Connection *c); void cleanConnectionLists(); - Connection *senders; //linked list; +#ifdef QT3_SUPPORT + void sendPendingChildInsertedEvents(); + void removePendingChildInsertedEvents(QObject *child); +#endif static Sender *setCurrentSender(QObject *receiver, Sender *sender); @@ -180,13 +156,38 @@ public: Sender *previousSender); static int *setDeleteWatch(QObjectPrivate *d, int *newWatch); static void resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int deleteWatch); - - int *deleteWatch; - QGuard *objectGuards; + static void clearGuards(QObject *); static QObjectPrivate *get(QObject *o) { return o->d_func(); } + +public: + QString objectName; + ExtraData *extraData; // extra data set by the user + QThreadData *threadData; // id of the thread that owns the object + + QObjectConnectionListVector *connectionLists; + + Connection *senders; // linked list of connections connected to this object + Sender *currentSender; // object currently activating the object + mutable quint32 connectedSignals[2]; // 64-bit, so doesn't cause padding on 64-bit platforms + +#ifdef QT3_SUPPORT + QList pendingChildInsertedEvents; +#else + // preserve binary compatibility with code compiled without Qt 3 support + // ### why? + QList unused; +#endif + + QList > eventFilters; + + // these objects are all used to indicate that a QObject was deleted + // plus QPointer, which keeps a separate list + QObjectDeletionNotification *deletionNotification; + QGuard *objectGuards; + int *deleteWatch; }; inline void q_guard_addGuard(QGuard *g) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 765b26f..075f9c3 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1375,10 +1375,9 @@ QWidget::~QWidget() // set all QPointers for this object to zero QObjectPrivate::clearGuards(this); - if(d->declarativeData) { - QDeclarativeData *dd = d->declarativeData; - d->declarativeData = 0; - dd->destroyed(this); + if (d->deletionNotification) { + d->deletionNotification->destroyed(this); + d->deletionNotification = 0; // don't activate again in ~QObject } if (!d->children.isEmpty()) -- cgit v0.12 From a654df7aa466775b0f9a6e4b33319c228f5634b2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 3 Aug 2009 14:56:49 +0200 Subject: Add QWeakPointer::data, which thread-unsafely returns the tracked pointer This function allows one to retrieve the pointer out of a QWeakPointer without promoting it to QSharedPointer first. That means there are no guarantees that the object won't get deleted. Reviewed-by: Bradley T. Hughes --- src/corelib/tools/qsharedpointer.cpp | 76 ++++++++++++++++++++++++++++++++- src/corelib/tools/qsharedpointer_impl.h | 1 + 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 2ca612e..ef4dfac 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -128,7 +128,7 @@ To access the pointer that QWeakPointer is tracking, you must first create a QSharedPointer object and verify if the pointer - is null or not. + is null or not. See QWeakPointer::toStrongRef() for more information. \sa QSharedPointer */ @@ -210,6 +210,8 @@ If \tt T is a derived type of the template parameter of this class, QSharedPointer will perform an automatic cast. Otherwise, you will get a compiler error. + + \sa QWeakPointer::toStrongRef() */ /*! @@ -362,6 +364,8 @@ Returns a weak reference object that shares the pointer referenced by this object. + + \sa QWeakPointer::QWeakPointer(const QSharedPointer &) */ /*! @@ -478,10 +482,78 @@ */ /*! + \fn T *QWeakPointer::data() const + \since 4.6 + + Returns the value of the pointer being tracked by this QWeakPointer, + \b without ensuring that it cannot get deleted. To have that guarantee, + use toStrongRef(), which returns a QSharedPointer object. If this + function can determine that the pointer has already been deleted, it + returns 0. + + It is ok to obtain the value of the pointer and using that value itself, + like for example in debugging statements: + + \code + qDebug("Tracking %p", weakref.data()); + \endcode + + However, dereferencing the pointer is only allowed if you can guarantee + by external means that the pointer does not get deleted. For example, + if you can be certain that no other thread can delete it, nor the + functions that you may call. + + If that is the case, then the following code is valid: + + \code + // this pointer cannot be used in another thread + // so other threads cannot delete it + QWeakPointer weakref = obtainReference(); + + Object *obj = weakref.data(); + if (obj) { + // if the pointer wasn't deleted yet, we know it can't get + // deleted by our own code here nor the functions we call + otherFunction(obj); + } + \endcode + + Use this function with care. + + \sa isNull(), toStrongRef() +*/ + +/*! \fn QSharedPointer QWeakPointer::toStrongRef() const Promotes this weak reference to a strong one and returns a - QSharedPointer object holding that reference. + QSharedPointer object holding that reference. When promoting to + QSharedPointer, this function verifies if the object has been deleted + already or not. If it hasn't, this function increases the reference + count to the shared object, thus ensuring that it will not get + deleted. + + Since this function can fail to obtain a valid strong reference to the + shared object, you should always verify if the conversion succeeded, + by calling QSharedPointer::isNull() on the returned object. + + For example, the following code promotes a QWeakPointer that was held + to a strong reference and, if it succeeded, it prints the value of the + integer that was held: + + \code + QWeakPointer weakref; + + // ... + + QSharedPointer strong = weakref.toStrongRef(); + if (strong) + qDebug() << "The value is:" << *strong; + else + qDebug() << "The value has already been deleted"; + \endcode + + \sa QSharedPointer::QSharedPointer(const QWeakPointer &) */ /*! diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 9fa8df4..e8e3812 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -492,6 +492,7 @@ public: inline bool isNull() const { return d == 0 || d->strongref == 0 || value == 0; } inline operator RestrictedBool() const { return isNull() ? 0 : &QWeakPointer::value; } inline bool operator !() const { return isNull(); } + inline T *data() const { return d == 0 || d->strongref == 0 ? 0 : value; } inline QWeakPointer() : d(0), value(0) { } inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; } -- cgit v0.12 From 6e9d84fcadc07b8f11d9e0eb046c25152eba1235 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 4 Aug 2009 16:33:09 +0200 Subject: Added the license header to the example. --- .../gestures/imageviewer/tapandholdgesture.cpp | 41 ++++++++++++++++++++++ examples/gestures/imageviewer/tapandholdgesture.h | 41 ++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/examples/gestures/imageviewer/tapandholdgesture.cpp b/examples/gestures/imageviewer/tapandholdgesture.cpp index c6f6779..ff5284e 100644 --- a/examples/gestures/imageviewer/tapandholdgesture.cpp +++ b/examples/gestures/imageviewer/tapandholdgesture.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "tapandholdgesture.h" #include diff --git a/examples/gestures/imageviewer/tapandholdgesture.h b/examples/gestures/imageviewer/tapandholdgesture.h index 711a1af..e0d50b5 100644 --- a/examples/gestures/imageviewer/tapandholdgesture.h +++ b/examples/gestures/imageviewer/tapandholdgesture.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef TAPANDHOLDGESTURE_H #define TAPANDHOLDGESTURE_H -- cgit v0.12 From ed375675d4a4f6fd63edeb242e23c87b3de4be6f Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 21 Jul 2009 13:37:43 +0200 Subject: Fix: Gtk native dialogs do not repaint when zero-timers are used The problem was that our glib timers were given too high priority, effectively starving the Gtk event loop. By assigning our timer source, G_PRIORITY_DEFAULT_IDLE we ensure that all gtk+ events are handled first, thus allowing the native dialogs to respond and repaint properly. Task-number: 258433 Reviewed-by: bhughes --- src/corelib/kernel/qeventdispatcher_glib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp index 7610631..2bbe560 100644 --- a/src/corelib/kernel/qeventdispatcher_glib.cpp +++ b/src/corelib/kernel/qeventdispatcher_glib.cpp @@ -263,6 +263,7 @@ QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context) (void) new (&timerSource->timerList) QTimerInfoList(); timerSource->processEventsFlags = QEventLoop::AllEvents; g_source_set_can_recurse(&timerSource->source, true); + g_source_set_priority(&timerSource->source, G_PRIORITY_DEFAULT_IDLE); g_source_attach(&timerSource->source, mainContext); } -- cgit v0.12 From c9a449af8d17e493950a63ca3f8a22232968c47e Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 4 Aug 2009 16:54:07 +0200 Subject: Make file extension case insensitive with the Gtk+ file dialog The Qt dialog treats extension filters as case insensitive where the default behavior of the Gtk+ file dialog is to be case sensitive. The GtkFileFilter allows only simple glob syntax to be used so we basically rewrite the extension string from .xyz to .[xX][yY][zZ]. Task-number: 259155 Reviewed-by: joao --- src/gui/styles/gtksymbols.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp index be9b10a..b2c53f3 100644 --- a/src/gui/styles/gtksymbols.cpp +++ b/src/gui/styles/gtksymbols.cpp @@ -733,7 +733,24 @@ static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent, QGtk::gtk_file_filter_set_name(gtkFilter, qPrintable(name.isEmpty() ? extensions.join(QLS(", ")) : name)); foreach (const QString &fileExtension, extensions) { - QGtk::gtk_file_filter_add_pattern (gtkFilter, qPrintable(fileExtension)); + // Note Gtk file dialogs are by default case sensitive + // and only supports basic glob syntax so we + // rewrite .xyz to .[xX][yY][zZ] + QString caseInsensitive; + for (int i = 0 ; i < fileExtension.length() ; ++i) { + QChar ch = fileExtension.at(i); + if (ch.isLetter()) { + caseInsensitive.append( + QLatin1Char('[') + + ch.toLower() + + ch.toUpper() + + QLatin1Char(']')); + } else { + caseInsensitive.append(ch); + } + } + QGtk::gtk_file_filter_add_pattern (gtkFilter, qPrintable(caseInsensitive)); + } QGtk::gtk_file_chooser_add_filter((GtkFileChooser*)gtkFileChooser, gtkFilter); if (selectedFilter && (rawfilter == *selectedFilter)) -- cgit v0.12 From 31edb4d5a63b9b3c28cce1c4ca6eb99f62a09759 Mon Sep 17 00:00:00 2001 From: Matthew Cattell Date: Tue, 4 Aug 2009 16:45:46 +0200 Subject: qregext filter changed to support additional parameter/unicode changed the QRegExp filter back to the old form plus an additional piece to allow international characters. the new regular expression now allows a file type filter to contain a bracketed description prior to the filter set itself. 259105 Andy Shaw --- src/gui/dialogs/qfiledialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 8b4e1b1..1ec94b6 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -2838,7 +2838,8 @@ void QFileDialogPrivate::_q_goToDirectory(const QString &path) } const char *qt_file_dialog_filter_reg_exp = - "^([^()]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"; +"(\\W|[a-zA-Z0-9 -]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"; + // Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)" QStringList qt_clean_filter_list(const QString &filter) -- cgit v0.12 From 83ff02450ea74468fec441e632ddc2cfda2b251c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 4 Aug 2009 18:01:33 +0200 Subject: Revert "Remove currentChildBeingDeleted from QObjectPrivate." This reverts commit 128717b171f01c82e5f0fb83f5923d4f7b9cfc10. The change broke Alien because QWidget no longer has the native window handle in its own private. It needs to access the top-level window (or the one with the native handle) in order to perform some operations. The problem is that it needs to do that in the destructor. And we cleared the parent before the destructor was run. Technically speaking, reverting is the correct thing to do, since the parent *still* exists when the child is deleted. --- src/corelib/kernel/qobject.cpp | 29 +++++++++++++++++------------ src/corelib/kernel/qobject_p.h | 1 + 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 1938012..0801418 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -126,7 +126,7 @@ QObjectData::~QObjectData() {} QObjectDeletionNotification::~QObjectDeletionNotification() {} QObjectPrivate::QObjectPrivate(int version) - : threadData(0), connectionLists(0), senders(0), currentSender(0), deletionNotification(0), objectGuards(0) + : threadData(0), connectionLists(0), senders(0), currentSender(0), currentChildBeingDeleted(0), deletionNotification(0), objectGuards(0) { if (version != QObjectPrivateVersion) qFatal("Cannot mix incompatible Qt libraries"); @@ -1855,13 +1855,12 @@ void QObjectPrivate::deleteChildren() // don't use qDeleteAll as the destructor of the child might // delete siblings for (int i = 0; i < children.count(); ++i) { - QObject *child = children.at(i); + currentChildBeingDeleted = children.at(i); children[i] = 0; - if (child) - child->d_func()->parent = 0; - delete child; + delete currentChildBeingDeleted; } children.clear(); + currentChildBeingDeleted = 0; wasDeleted = reallyWasDeleted; } @@ -1872,14 +1871,20 @@ void QObjectPrivate::setParent_helper(QObject *o) return; if (parent) { QObjectPrivate *parentD = parent->d_func(); - const int index = parentD->children.indexOf(q); - if (parentD->wasDeleted) { - parentD->children[index] = 0; + if (parentD->wasDeleted && wasDeleted + && parentD->currentChildBeingDeleted == q) { + // don't do anything since QObjectPrivate::deleteChildren() already + // cleared our entry in parentD->children. } else { - parentD->children.removeAt(index); - if (sendChildEvents && parentD->receiveChildEvents) { - QChildEvent e(QEvent::ChildRemoved, q); - QCoreApplication::sendEvent(parent, &e); + const int index = parentD->children.indexOf(q); + if (parentD->wasDeleted) { + parentD->children[index] = 0; + } else { + parentD->children.removeAt(index); + if (sendChildEvents && parentD->receiveChildEvents) { + QChildEvent e(QEvent::ChildRemoved, q); + QCoreApplication::sendEvent(parent, &e); + } } } } diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 52b4658..a7f3a5a 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -182,6 +182,7 @@ public: #endif QList > eventFilters; + QObject *currentChildBeingDeleted; // these objects are all used to indicate that a QObject was deleted // plus QPointer, which keeps a separate list -- cgit v0.12 From a22f422b20299a501c307b21a6095ece87749124 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 4 Aug 2009 18:43:10 +0200 Subject: Restore the old name for QObjectDeletionNotification. If we're going to do changes to simplify some of the Declarative UI enablers, let's do them all at once. That way, the adaptation necessary happens only once, as opposed to every time we do the changes. I tried not to break by leaving a typedef, but obviously the QObjectPrivate member isn't affected by the typedef... Reviewed-by: Trust Me --- src/corelib/kernel/qobject.cpp | 8 ++++---- src/corelib/kernel/qobject_p.h | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 0801418..7e7dcaf 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -123,10 +123,10 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) } QObjectData::~QObjectData() {} -QObjectDeletionNotification::~QObjectDeletionNotification() {} +QDeclarativeData::~QDeclarativeData() {} QObjectPrivate::QObjectPrivate(int version) - : threadData(0), connectionLists(0), senders(0), currentSender(0), currentChildBeingDeleted(0), deletionNotification(0), objectGuards(0) + : threadData(0), connectionLists(0), senders(0), currentSender(0), currentChildBeingDeleted(0), declarativeData(0), objectGuards(0) { if (version != QObjectPrivateVersion) qFatal("Cannot mix incompatible Qt libraries"); @@ -769,8 +769,8 @@ QObject::~QObject() } emit destroyed(this); - if (d->deletionNotification) - d->deletionNotification->destroyed(this); + if (d->declarativeData) + d->declarativeData->destroyed(this); { QMutexLocker locker(signalSlotLock(this)); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index a7f3a5a..e58ee6c 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -84,13 +84,12 @@ extern QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set; enum { QObjectPrivateVersion = QT_VERSION }; -class Q_CORE_EXPORT QObjectDeletionNotification +class Q_CORE_EXPORT QDeclarativeData { public: - virtual ~QObjectDeletionNotification(); + virtual ~QDeclarativeData(); virtual void destroyed(QObject *) = 0; }; -typedef QObjectDeletionNotification QDeclarativeData; // remove me when Declarative UI updates class Q_CORE_EXPORT QObjectPrivate : public QObjectData { @@ -186,7 +185,7 @@ public: // these objects are all used to indicate that a QObject was deleted // plus QPointer, which keeps a separate list - QObjectDeletionNotification *deletionNotification; + QDeclarativeData *declarativeData; QGuard *objectGuards; int *deleteWatch; }; -- cgit v0.12 From 8e01aa83880bf9cc669106f1e219abd3b3fca186 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 4 Aug 2009 20:06:04 +0200 Subject: Fixed bug where Q[Styled]ItemDelegate edition wouldn't terminate when the item lost focus to an unrelated dialog. The tests against the active modal window was unnecessary. Task-number: 257859 Reviewed-by: olivier --- src/gui/itemviews/qitemdelegate.cpp | 7 +----- src/gui/itemviews/qstyleditemdelegate.cpp | 8 +------ tests/auto/qitemdelegate/tst_qitemdelegate.cpp | 33 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index aff715c..962ce54 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -1238,12 +1238,7 @@ bool QItemDelegate::eventFilter(QObject *object, QEvent *event) if (QDragManager::self() && QDragManager::self()->object != 0) return false; #endif - // Opening a modal dialog will start a new eventloop - // that will process the deleteLater event. - if (QApplication::activeModalWidget() - && !QApplication::activeModalWidget()->isAncestorOf(editor) - && qobject_cast(QApplication::activeModalWidget())) - return false; + emit commitData(editor); emit closeEditor(editor, NoHint); } diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp index 7ec2afe..8faf0be 100644 --- a/src/gui/itemviews/qstyleditemdelegate.cpp +++ b/src/gui/itemviews/qstyleditemdelegate.cpp @@ -686,13 +686,7 @@ bool QStyledItemDelegate::eventFilter(QObject *object, QEvent *event) if (QDragManager::self() && QDragManager::self()->object != 0) return false; #endif - // Opening a modal dialog will start a new eventloop - // that will process the deleteLater event. - QWidget *activeModalWidget = QApplication::activeModalWidget(); - if (activeModalWidget - && !activeModalWidget->isAncestorOf(editor) - && qobject_cast(activeModalWidget)) - return false; + emit commitData(editor); emit closeEditor(editor, NoHint); } diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp index 65dd86f..6714de3 100644 --- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp @@ -61,6 +61,7 @@ #include #include #include +#include Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint) @@ -230,6 +231,8 @@ private slots: void editorEvent(); void enterKey_data(); void enterKey(); + + void task257859_finalizeEdit(); }; @@ -1124,6 +1127,36 @@ void tst_QItemDelegate::enterKey() QCOMPARE(editor && editor->hasFocus(), expectedFocus); } +void tst_QItemDelegate::task257859_finalizeEdit() +{ + QStandardItemModel model; + model.appendRow(new QStandardItem()); + + QListView view; + view.setModel(&model); + view.show(); + QApplication::setActiveWindow(&view); + view.setFocus(); + QTest::qWait(30); + + QModelIndex index = model.index(0, 0); + view.edit(index); + QTest::qWait(30); + + QList lineEditors = qFindChildren(view.viewport()); + QCOMPARE(lineEditors.count(), 1); + + QPointer editor = lineEditors.at(0); + QCOMPARE(editor->hasFocus(), true); + + QDialog dialog; + QTimer::singleShot(100, &dialog, SLOT(close())); + dialog.exec(); + + QTest::qWait(10); + + QVERIFY(!editor); +} // ### _not_ covered: -- cgit v0.12 From 2843c97f5310f4636c933ced56570ab7db2b707e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 4 Aug 2009 21:05:35 +0200 Subject: Fix compilation after my last change to qobject_p.h I renamed deletionNotification back to its original name. I had forgotten that QWidget needed a similar change. Reviewed-by: Trust Me --- src/gui/kernel/qwidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 075f9c3..a827967 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1375,9 +1375,9 @@ QWidget::~QWidget() // set all QPointers for this object to zero QObjectPrivate::clearGuards(this); - if (d->deletionNotification) { - d->deletionNotification->destroyed(this); - d->deletionNotification = 0; // don't activate again in ~QObject + if (d->declarativeData) { + d->declarativeData->destroyed(this); + d->declarativeData = 0; // don't activate again in ~QObject } if (!d->children.isEmpty()) -- cgit v0.12 From a4ede01350b506c9908241f0b9002f560cc0949f Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 5 Aug 2009 13:21:00 +1000 Subject: Fixes casing issue in the PSQL driver. The record and primaryIndex functions don't take into account that psql treats different casing as different entities when enquoted. --- src/sql/drivers/psql/qsql_psql.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index c61c526..4fd0c11 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -940,7 +940,7 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const case QPSQLDriver::Version6: stmt = QLatin1String("select pg_att1.attname, int(pg_att1.atttypid), pg_cl.relname " "from pg_attribute pg_att1, pg_attribute pg_att2, pg_class pg_cl, pg_index pg_ind " - "where lower(pg_cl.relname) = '%1_pkey' " + "where pg_cl.relname = '%1_pkey' " "and pg_cl.oid = pg_ind.indexrelid " "and pg_att2.attrelid = pg_ind.indexrelid " "and pg_att1.attrelid = pg_ind.indrelid " @@ -951,7 +951,7 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const case QPSQLDriver::Version71: stmt = QLatin1String("select pg_att1.attname, pg_att1.atttypid::int, pg_cl.relname " "from pg_attribute pg_att1, pg_attribute pg_att2, pg_class pg_cl, pg_index pg_ind " - "where lower(pg_cl.relname) = '%1_pkey' " + "where pg_cl.relname = '%1_pkey' " "and pg_cl.oid = pg_ind.indexrelid " "and pg_att2.attrelid = pg_ind.indexrelid " "and pg_att1.attrelid = pg_ind.indrelid " @@ -1016,7 +1016,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " "int(pg_attribute.attrelid), pg_attribute.attnum " "from pg_class, pg_attribute " - "where lower(pg_class.relname) = '%1' " + "where pg_class.relname = '%1' " "and pg_attribute.attnum > 0 " "and pg_attribute.attrelid = pg_class.oid "); break; @@ -1025,7 +1025,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " "pg_attribute.attrelid::int, pg_attribute.attnum " "from pg_class, pg_attribute " - "where lower(pg_class.relname) = '%1' " + "where pg_class.relname = '%1' " "and pg_attribute.attnum > 0 " "and pg_attribute.attrelid = pg_class.oid "); break; @@ -1036,7 +1036,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const "from pg_class, pg_attribute " "left join pg_attrdef on (pg_attrdef.adrelid = " "pg_attribute.attrelid and pg_attrdef.adnum = pg_attribute.attnum) " - "where lower(pg_class.relname) = '%1' " + "where pg_class.relname = '%1' " "and pg_attribute.attnum > 0 " "and pg_attribute.attrelid = pg_class.oid " "order by pg_attribute.attnum "); -- cgit v0.12 From 7e8e53cded4622ac35ff115e26e074de6722d1a0 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 5 Aug 2009 13:38:44 +1000 Subject: Get more database tests working/passing. --- tests/auto/qsqldatabase/tst_databases.h | 12 +++++++++++- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 10 +++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h index 8ee74df..ad70471 100644 --- a/tests/auto/qsqldatabase/tst_databases.h +++ b/tests/auto/qsqldatabase/tst_databases.h @@ -219,7 +219,7 @@ public: // addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.nokia.troll.no", 3307 ); // addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.nokia.troll.no", 3308, "CLIENT_COMPRESS=1;CLIENT_SSL=1" ); // MySQL 4.1.1 // addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.nokia.troll.no", 3309, "CLIENT_COMPRESS=1;CLIENT_SSL=1" ); // MySQL 5.0.18 Linux -// addDb( "QMYSQL3", "testdb", "troll", "trond", "iceblink.nokia.troll.no" ); // MySQL 5.0.13 Windows +// addDb( "QMYSQL3", "testdb", "troll", "trond", "silence.nokia.troll.no" ); // MySQL 5.1.36 Windows // addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "mysql4-nokia.trolltech.com.au" ); // MySQL 4.1.22-2.el4 linux // addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "mysql5-nokia.trolltech.com.au" ); // MySQL 5.0.45-7.el5 linux @@ -481,6 +481,16 @@ public: return QString(); } + static QString getPSQLVersion( const QSqlDatabase &db ) + { + QSqlQuery q(db); + q.exec( "select version()" ); + if(q.next()) + return q.value( 0 ).toString(); + else + return QString(); + } + QStringList dbNames; int counter; }; diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index ff62741..de4fe8f 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -1057,6 +1057,7 @@ void tst_QSqlDatabase::recordMySQL() int major = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt(); int minor = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 1, 1 ).toInt(); int revision = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 2, 2 ).toInt(); + int vernum = (major << 16) + (minor << 8) + revision; #ifdef QT3_SUPPORT /* The below is broken in mysql below 5.0.15 @@ -1064,7 +1065,7 @@ void tst_QSqlDatabase::recordMySQL() specifically: Before MySQL 5.0.15, the pad value is space. Values are right-padded with space on insert, and trailing spaces are removed on select. */ - if ( major >5 || ( major == 5 && minor > 0) || ( major == 5 && minor == 0 && revision >= 15) ) { + if( vernum >= ((5 << 16) + 15) ) { bin10 = FieldDef("binary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abc "))); varbin10 = FieldDef("varbinary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abcv "))); } @@ -1594,6 +1595,11 @@ void tst_QSqlDatabase::bug_249059() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + QString version=tst_Databases::getPSQLVersion( db ); + double ver=version.section(QChar::fromLatin1('.'),0,1).toDouble(); + if (ver < 7.3) + QSKIP("Test requires PostgreSQL >= 7.3", SkipSingle); + QSqlQuery q(db); QString tableName = qTableName("bug_249059"); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (dt timestamp, t time)").arg(tableName))); @@ -2006,8 +2012,6 @@ void tst_QSqlDatabase::mysql_multiselect() CHECK_DATABASE(db); QSqlQuery q(db); - QVERIFY_SQL(q, exec("select version()")); - QVERIFY_SQL(q, next()); QString version=tst_Databases::getMySqlVersion( db ); double ver=version.section(QChar::fromLatin1('.'),0,1).toDouble(); if (ver < 4.1) -- cgit v0.12 From e7052de274f6a201be628441d144dbbef5868948 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Wed, 5 Aug 2009 14:26:56 +1000 Subject: Merge AudioServices into mainline. --- bin/syncqt | 1 + config.tests/unix/alsa/alsa.pro | 4 + config.tests/unix/alsa/alsatest.cpp | 6 + configure | 36 +- configure.exe | Bin 1896493 -> 1134080 bytes demos/qtdemo/xml/examples.xml | 5 + doc/src/examples-overview.qdoc | 11 + doc/src/examples.qdoc | 8 + doc/src/examples/audiodevices.qdoc | 54 ++ doc/src/examples/audioinput.qdoc | 54 ++ doc/src/examples/audiooutput.qdoc | 52 ++ examples/examples.pro | 1 + examples/multimedia/README | 34 + examples/multimedia/audio/audio.pro | 10 + .../multimedia/audio/audiodevices/audiodevices.cpp | 272 ++++++ .../multimedia/audio/audiodevices/audiodevices.h | 79 ++ .../multimedia/audio/audiodevices/audiodevices.pro | 12 + .../audio/audiodevices/audiodevicesbase.ui | 255 ++++++ examples/multimedia/audio/audiodevices/main.cpp | 55 ++ .../multimedia/audio/audioinput/audioinput.cpp | 376 +++++++++ examples/multimedia/audio/audioinput/audioinput.h | 144 ++++ .../multimedia/audio/audioinput/audioinput.pro | 12 + examples/multimedia/audio/audioinput/main.cpp | 55 ++ .../multimedia/audio/audiooutput/audiooutput.cpp | 280 +++++++ .../multimedia/audio/audiooutput/audiooutput.h | 112 +++ .../multimedia/audio/audiooutput/audiooutput.pro | 11 + examples/multimedia/audio/audiooutput/main.cpp | 56 ++ examples/multimedia/multimedia.pro | 8 + mkspecs/features/qt.prf | 3 +- src/corelib/global/qglobal.h | 14 + src/multimedia/audio/audio.pri | 56 ++ src/multimedia/audio/qaudio.cpp | 102 +++ src/multimedia/audio/qaudio.h | 71 ++ src/multimedia/audio/qaudio_mac.cpp | 142 ++++ src/multimedia/audio/qaudio_mac_p.h | 144 ++++ src/multimedia/audio/qaudiodevicefactory.cpp | 250 ++++++ src/multimedia/audio/qaudiodevicefactory_p.h | 100 +++ src/multimedia/audio/qaudiodeviceid.cpp | 168 ++++ src/multimedia/audio/qaudiodeviceid.h | 94 +++ src/multimedia/audio/qaudiodeviceid_p.h | 82 ++ src/multimedia/audio/qaudiodeviceinfo.cpp | 270 ++++++ src/multimedia/audio/qaudiodeviceinfo.h | 102 +++ src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 394 +++++++++ src/multimedia/audio/qaudiodeviceinfo_alsa_p.h | 113 +++ src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 357 ++++++++ src/multimedia/audio/qaudiodeviceinfo_mac_p.h | 97 +++ src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 378 +++++++++ src/multimedia/audio/qaudiodeviceinfo_win32_p.h | 108 +++ 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 | 335 ++++++++ src/multimedia/audio/qaudioformat.h | 103 +++ src/multimedia/audio/qaudioinput.cpp | 400 +++++++++ src/multimedia/audio/qaudioinput.h | 108 +++ src/multimedia/audio/qaudioinput_alsa_p.cpp | 688 +++++++++++++++ src/multimedia/audio/qaudioinput_alsa_p.h | 151 ++++ src/multimedia/audio/qaudioinput_mac_p.cpp | 930 +++++++++++++++++++++ src/multimedia/audio/qaudioinput_mac_p.h | 171 ++++ src/multimedia/audio/qaudioinput_win32_p.cpp | 540 ++++++++++++ src/multimedia/audio/qaudioinput_win32_p.h | 154 ++++ src/multimedia/audio/qaudiooutput.cpp | 403 +++++++++ src/multimedia/audio/qaudiooutput.h | 109 +++ src/multimedia/audio/qaudiooutput_alsa_p.cpp | 706 ++++++++++++++++ src/multimedia/audio/qaudiooutput_alsa_p.h | 159 ++++ src/multimedia/audio/qaudiooutput_mac_p.cpp | 700 ++++++++++++++++ src/multimedia/audio/qaudiooutput_mac_p.h | 171 ++++ src/multimedia/audio/qaudiooutput_win32_p.cpp | 502 +++++++++++ src/multimedia/audio/qaudiooutput_win32_p.h | 154 ++++ src/multimedia/multimedia.pro | 11 + src/plugins/audio/audio.pro | 3 + src/plugins/plugins.pro | 1 + src/src.pro | 4 + tests/auto/auto.pro | 4 + tests/auto/qaudiodeviceid/qaudiodeviceid.pro | 7 + tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp | 98 +++ tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro | 7 + .../auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp | 159 ++++ tests/auto/qaudioformat/qaudioformat.pro | 7 + tests/auto/qaudioformat/tst_qaudioformat.cpp | 180 ++++ tests/auto/qaudioinput/qaudioinput.pro | 7 + tests/auto/qaudioinput/tst_qaudioinput.cpp | 120 +++ tests/auto/qaudiooutput/4.wav | Bin 0 -> 5538 bytes tests/auto/qaudiooutput/qaudiooutput.pro | 12 + tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 156 ++++ tests/auto/tests.xml | 8 + tools/configure/configureapp.cpp | 15 + 88 files changed, 12950 insertions(+), 2 deletions(-) create mode 100644 config.tests/unix/alsa/alsa.pro create mode 100644 config.tests/unix/alsa/alsatest.cpp create mode 100644 doc/src/examples/audiodevices.qdoc create mode 100644 doc/src/examples/audioinput.qdoc create mode 100644 doc/src/examples/audiooutput.qdoc create mode 100644 examples/multimedia/README create mode 100644 examples/multimedia/audio/audio.pro create mode 100644 examples/multimedia/audio/audiodevices/audiodevices.cpp create mode 100644 examples/multimedia/audio/audiodevices/audiodevices.h create mode 100644 examples/multimedia/audio/audiodevices/audiodevices.pro create mode 100644 examples/multimedia/audio/audiodevices/audiodevicesbase.ui create mode 100644 examples/multimedia/audio/audiodevices/main.cpp create mode 100644 examples/multimedia/audio/audioinput/audioinput.cpp create mode 100644 examples/multimedia/audio/audioinput/audioinput.h create mode 100644 examples/multimedia/audio/audioinput/audioinput.pro create mode 100644 examples/multimedia/audio/audioinput/main.cpp create mode 100644 examples/multimedia/audio/audiooutput/audiooutput.cpp create mode 100644 examples/multimedia/audio/audiooutput/audiooutput.h create mode 100644 examples/multimedia/audio/audiooutput/audiooutput.pro create mode 100644 examples/multimedia/audio/audiooutput/main.cpp create mode 100644 examples/multimedia/multimedia.pro 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/qaudiodevicefactory.cpp create mode 100644 src/multimedia/audio/qaudiodevicefactory_p.h create mode 100644 src/multimedia/audio/qaudiodeviceid.cpp create mode 100644 src/multimedia/audio/qaudiodeviceid.h create mode 100644 src/multimedia/audio/qaudiodeviceid_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_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_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_win32_p.cpp create mode 100644 src/multimedia/audio/qaudiooutput_win32_p.h create mode 100644 src/multimedia/multimedia.pro create mode 100644 src/plugins/audio/audio.pro create mode 100644 tests/auto/qaudiodeviceid/qaudiodeviceid.pro create mode 100644 tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp create mode 100644 tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro create mode 100644 tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp create mode 100644 tests/auto/qaudioformat/qaudioformat.pro create mode 100644 tests/auto/qaudioformat/tst_qaudioformat.cpp create mode 100644 tests/auto/qaudioinput/qaudioinput.pro create mode 100644 tests/auto/qaudioinput/tst_qaudioinput.cpp create mode 100644 tests/auto/qaudiooutput/4.wav create mode 100644 tests/auto/qaudiooutput/qaudiooutput.pro create mode 100644 tests/auto/qaudiooutput/tst_qaudiooutput.cpp diff --git a/bin/syncqt b/bin/syncqt index 6c4de6a..589659f 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -43,6 +43,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", ); my %moduleheaders = ( # restrict the module headers to those found in relative path "QtWebKit" => "../WebKit/qt/Api", diff --git a/config.tests/unix/alsa/alsa.pro b/config.tests/unix/alsa/alsa.pro new file mode 100644 index 0000000..4931d38 --- /dev/null +++ b/config.tests/unix/alsa/alsa.pro @@ -0,0 +1,4 @@ +SOURCES = alsatest.cpp +LIBS+=-lasound +CONFIG -= qt dylib +mac:CONFIG -= app_bundle diff --git a/config.tests/unix/alsa/alsatest.cpp b/config.tests/unix/alsa/alsatest.cpp new file mode 100644 index 0000000..af2f5d9 --- /dev/null +++ b/config.tests/unix/alsa/alsatest.cpp @@ -0,0 +1,6 @@ +#include +int main(int argc,char **argv) +{ + return 0; +} + diff --git a/configure b/configure index 095d040..1d1f826 100755 --- a/configure +++ b/configure @@ -609,6 +609,7 @@ CFG_NOBUILD_PARTS="" CFG_RELEASE_QMAKE=no CFG_PHONON=auto CFG_PHONON_BACKEND=yes +CFG_MULTIMEDIA=yes CFG_SVG=yes CFG_WEBKIT=auto # (yes|no|auto) @@ -709,6 +710,7 @@ OPT_VERBOSE=no OPT_HELP= CFG_SILENT=no CFG_GRAPHICS_SYSTEM=default +CFG_ALSA=auto # initalize variables used for installation QT_INSTALL_PREFIX= @@ -848,7 +850,7 @@ while [ "$#" -gt 0 ]; do VAL=no ;; #Qt style yes options - -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xshape|-xinput|-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|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-svg|-webkit|-scripttools|-rpath|-force-pkg-config) + -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xshape|-xinput|-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|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-svg|-webkit|-scripttools|-rpath|-force-pkg-config) VAR=`echo $1 | sed "s,^-\(.*\),\1,"` VAL=yes ;; @@ -1976,6 +1978,13 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; + multimedia) + if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then + CFG_MULTIMEDIA="$VAL" + else + UNKNOWN_OPT=yes + fi + ;; *) UNKNOWN_OPT=yes ;; @@ -3152,6 +3161,7 @@ Usage: $relconf [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir [-no-optimized-qmake] [-optimized-qmake] [-no-xmlpatterns] [-xmlpatterns] [-no-phonon] [-phonon] [-no-phonon-backend] [-phonon-backend] [-no-openssl] [-openssl] [-openssl-linked] + [-no-multimedia] [-multimedia] [-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit] [-no-scripttools] [-scripttools] @@ -3292,6 +3302,9 @@ fi -no-phonon-backend.. Do not build the platform phonon plugin. + -phonon-backend..... Build the platform phonon plugin. + -no-multimedia ..... Do not build the multimedia module. + * -multimedia ........ Build the multimedia module. + -no-svg ............ Do not build the SVG module. + -svg ............... Build the SVG module. @@ -5664,6 +5677,14 @@ if [ "$CFG_PTMALLOC" != "no" ]; then QMakeVar add QMAKE_LFLAGS "$outpath/lib/libptmalloc3.a" fi +if [ "$CFG_ALSA" = "auto" ]; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/alsa "alsa" $L_FLAGS $I_FLAGS $l_FLAGS; then + CFG_ALSA=yes + else + CFG_ALSA=no + fi +fi + #------------------------------------------------------------------------------- # ask for all that hasn't been auto-detected or specified in the arguments #------------------------------------------------------------------------------- @@ -6104,6 +6125,10 @@ if [ "$CFG_EXCEPTIONS" != "no" ]; then QTCONFIG_CONFIG="$QTCONFIG_CONFIG exceptions" fi +if [ "$CFG_ALSA" = "yes" ]; then + QT_CONFIG="$QT_CONFIG alsa" +fi + # # Some Qt modules are too advanced in C++ for some old compilers # Detect here the platforms where they are known to work. @@ -6275,6 +6300,12 @@ else QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SCRIPTTOOLS" fi +if [ "$CFG_MULTIMEDIA" = "yes" ]; then + QT_CONFIG="$QT_CONFIG multimedia" +else + QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_MULTIMEDIA" +fi + if [ "$CFG_EXCEPTIONS" = "no" ]; then case "$COMPILER" in g++*) @@ -6776,6 +6807,7 @@ fi [ "$CFG_XFIXES" = "runtime" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_RUNTIME_XFIXES" [ "$CFG_XRANDR" = "runtime" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_RUNTIME_XRANDR" [ "$CFG_XINPUT" = "runtime" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_RUNTIME_XINPUT" +[ "$CFG_ALSA" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ALSA" # sort QCONFIG_FLAGS for neatness if we can [ '!' -z "$AWK" ] && QCONFIG_FLAGS=`echo $QCONFIG_FLAGS | $AWK '{ gsub(" ", "\n"); print }' | sort | uniq` @@ -7135,6 +7167,7 @@ echo "QtConcurrent code.... $CFG_CONCURRENT" echo "QtScriptTools module $CFG_SCRIPTTOOLS" echo "QtXmlPatterns module $CFG_XMLPATTERNS" echo "Phonon module ....... $CFG_PHONON" +echo "Multimedia module ... $CFG_MULTIMEDIA" echo "SVG module .......... $CFG_SVG" echo "WebKit module ....... $CFG_WEBKIT" echo "STL support ......... $CFG_STL" @@ -7285,6 +7318,7 @@ if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_FRAMEWORK" = "yes" ] && [ "$CFG_DEBUG" echo "NOTE: Mac OS X frameworks implicitly build debug and release Qt libraries." echo fi +echo "alsa support ........ $CFG_ALSA" echo sepath=`echo "$relpath" | sed -e 's/\\./\\\\./g'` diff --git a/configure.exe b/configure.exe index 322819e..cf5885a 100644 Binary files a/configure.exe and b/configure.exe differ diff --git a/demos/qtdemo/xml/examples.xml b/demos/qtdemo/xml/examples.xml index 006bfd0..1b0b533 100644 --- a/demos/qtdemo/xml/examples.xml +++ b/demos/qtdemo/xml/examples.xml @@ -154,6 +154,11 @@ + + + + + diff --git a/doc/src/examples-overview.qdoc b/doc/src/examples-overview.qdoc index 4313c43..3db4a45 100644 --- a/doc/src/examples-overview.qdoc +++ b/doc/src/examples-overview.qdoc @@ -238,6 +238,17 @@ These examples demonstrate the basic techniques used to take advantage of OpenGL in Qt applications. + \section1 \l{Qt Examples#Multimedia}{Multimedia} + + \l{Qt Examples#Multimedia} + + Qt provides low-level audio support on linux,windows and mac platforms by default and + an audio plugin API to allow developers to implement there own audio support for + custom devices and platforms. + + These examples demonstrate the basic techniques used to take advantage of + Audio API in Qt applications. + \section1 \l{Qt Examples#SQL}{SQL} \l{Qt Examples#SQL}{\inlineimage sql-examples.png diff --git a/doc/src/examples.qdoc b/doc/src/examples.qdoc index e85acd1..74a9bd8 100644 --- a/doc/src/examples.qdoc +++ b/doc/src/examples.qdoc @@ -255,6 +255,14 @@ \o \l{phonon/musicplayer}{Music Player}\raisedaster \endlist + \section1 Multimedia + + \list + \o \l{multimedia/audio/audiodevices}{Audio Devices}\raisedaster + \o \l{multimedia/audio/audiooutput}{Audio Output}\raisedaster + \o \l{multimedia/audio/audioinput}{Audio Input}\raisedaster + \endlist + \section1 Qt Designer \list diff --git a/doc/src/examples/audiodevices.qdoc b/doc/src/examples/audiodevices.qdoc new file mode 100644 index 0000000..3b8cdd8 --- /dev/null +++ b/doc/src/examples/audiodevices.qdoc @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example multimedia/audio/audiodevices + \title Audio Devices Example + + The Audio Devices example demonstrates the basic use of QAudioDeviceInfo class + provided with Qt. + + Qt provides the QAudioDeviceInfo class to enable audio querying within + a standard application user interface. + + This example allows you to browse audio devices available and try out different + configurations to see if they are supported. +*/ diff --git a/doc/src/examples/audioinput.qdoc b/doc/src/examples/audioinput.qdoc new file mode 100644 index 0000000..5dfe76e --- /dev/null +++ b/doc/src/examples/audioinput.qdoc @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example multimedia/audio/audioinput + \title AudioInput Example + + The Audio Input example demonstrates the basic use of QAudioInput class + provided with Qt. + + Qt provides the QAudioInput class to enable audio functionality within + a standard application user interface. + + This example uses a fast-fourier transform on the input audio from the microphone + and displays the output. +*/ diff --git a/doc/src/examples/audiooutput.qdoc b/doc/src/examples/audiooutput.qdoc new file mode 100644 index 0000000..9c8a75f --- /dev/null +++ b/doc/src/examples/audiooutput.qdoc @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example multimedia/audio/audiooutput + \title Audio Output Example + + The Audio Output example demonstrates the basic use of the QAudioOutput class + provided with Qt. + + This example provides a tone generator to supply continuous audio playback. + The first button allows pause and resume of the playback. + The second button allows toggling between push and pull modes of operation. +*/ diff --git a/examples/examples.pro b/examples/examples.pro index 5855e4f..e6cece9 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -26,6 +26,7 @@ SUBDIRS = \ multitouch \ gestures +contains(QT_CONFIG, multimedia):!static: SUBDIRS += multimedia contains(QT_CONFIG, phonon):!static: SUBDIRS += phonon contains(QT_CONFIG, webkit): SUBDIRS += webkit embedded:SUBDIRS += qws diff --git a/examples/multimedia/README b/examples/multimedia/README new file mode 100644 index 0000000..aa78e36 --- /dev/null +++ b/examples/multimedia/README @@ -0,0 +1,34 @@ + +The example launcher provided with Qt can be used to explore each of the +examples in this directory. + +Documentation for these examples can be found via the Tutorial and Examples +link in the main Qt documentation. + + +Finding the Qt Examples and Demos launcher +========================================== + +On Windows: + +The launcher can be accessed via the Windows Start menu. Select the menu +entry entitled "Qt Examples and Demos" entry in the submenu containing +the Qt tools. + +On Mac OS X: + +For the binary distribution, the qtdemo executable is installed in the +/Developer/Applications/Qt directory. For the source distribution, it is +installed alongside the other Qt tools on the path specified when Qt is +configured. + +On Unix/Linux: + +The qtdemo executable is installed alongside the other Qt tools on the path +specified when Qt is configured. + +On all platforms: + +The source code for the launcher can be found in the demos/qtdemo directory +in the Qt package. This example is built at the same time as the Qt libraries, +tools, examples, and demonstrations. diff --git a/examples/multimedia/audio/audio.pro b/examples/multimedia/audio/audio.pro new file mode 100644 index 0000000..c64bb34 --- /dev/null +++ b/examples/multimedia/audio/audio.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs +SUBDIRS = audioinput \ + audiooutput \ + audiodevices + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS audio.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio +INSTALLS += target sources diff --git a/examples/multimedia/audio/audiodevices/audiodevices.cpp b/examples/multimedia/audio/audiodevices/audiodevices.cpp new file mode 100644 index 0000000..2a3af98 --- /dev/null +++ b/examples/multimedia/audio/audiodevices/audiodevices.cpp @@ -0,0 +1,272 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include + +#include "audiodevices.h" + +AudioDevicesBase::AudioDevicesBase( QMainWindow *parent, Qt::WFlags f ) +{ + Q_UNUSED(parent) + Q_UNUSED(f) + setupUi( this ); +} + +AudioDevicesBase::~AudioDevicesBase() {} + + +AudioTest::AudioTest( QMainWindow *parent, Qt::WFlags f ) + : AudioDevicesBase( parent, f ) +{ + mode = QAudio::AudioOutput; + modeBox->addItem("Input"); + modeBox->addItem("Output"); + + connect(testButton,SIGNAL(clicked()),SLOT(test())); + connect(modeBox,SIGNAL(activated(int)),SLOT(modeChanged(int))); + connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); + connect(frequencyBox,SIGNAL(activated(int)),SLOT(freqChanged(int))); + connect(channelsBox,SIGNAL(activated(int)),SLOT(channelChanged(int))); + connect(codecsBox,SIGNAL(activated(int)),SLOT(codecChanged(int))); + connect(sampleSizesBox,SIGNAL(activated(int)),SLOT(sampleSizeChanged(int))); + connect(sampleTypesBox,SIGNAL(activated(int)),SLOT(sampleTypeChanged(int))); + connect(endianBox,SIGNAL(activated(int)),SLOT(endianChanged(int))); + + device = 0; + + modeBox->setCurrentIndex(0); + modeChanged(0); + deviceBox->setCurrentIndex(0); + deviceChanged(0); +} + +AudioTest::~AudioTest() +{ +} + +void AudioTest::test() +{ + // tries to set all the settings picked. + + if(device) { + if(device->isFormatSupported(settings)) { + logOutput->append("Success"); + nearestFreq->setText(""); + nearestChannel->setText(""); + nearestCodec->setText(""); + nearestSampleSize->setText(""); + nearestSampleType->setText(""); + nearestEndian->setText(""); + } else { + QAudioFormat nearest = device->nearestFormat(settings); + logOutput->append(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"); + } + } + } + else + logOutput->append("No Device"); +} + +void AudioTest::modeChanged(int idx) +{ + // mode has changed + if(idx == 0) + mode=QAudio::AudioInput; + else + mode=QAudio::AudioOutput; + + deviceBox->clear(); + QList devices = QAudioDeviceInfo::deviceList(mode); + for(int i = 0; i < devices.size(); ++i) { + deviceBox->addItem(QAudioDeviceInfo(devices.at(i)).deviceName(), qVariantFromValue(devices.at(i))); + } +} + +void AudioTest::deviceChanged(int idx) +{ + delete device; + device = 0; + + if (deviceBox->count() == 0) + return; + + // device has changed + deviceHandle = deviceBox->itemData(idx).value(); + device = new QAudioDeviceInfo(deviceHandle, this); + + frequencyBox->clear(); + QList freqz = device->supportedFrequencies(); + for(int i = 0; i < freqz.size(); ++i) + frequencyBox->addItem(QString("%1").arg(freqz.at(i))); + if(freqz.size()) + settings.setFrequency(freqz.at(0)); + + channelsBox->clear(); + QList chz = device->supportedChannels(); + for(int i = 0; i < chz.size(); ++i) + channelsBox->addItem(QString("%1").arg(chz.at(i))); + if(chz.size()) + settings.setChannels(chz.at(0)); + + codecsBox->clear(); + QStringList codecz = device->supportedCodecs(); + for(int i = 0; i < codecz.size(); ++i) + codecsBox->addItem(QString("%1").arg(codecz.at(i))); + if(codecz.size()) + settings.setCodec(codecz.at(0)); + // Add false to create failed condition! + codecsBox->addItem("audio/mpeg"); + + sampleSizesBox->clear(); + QList sampleSizez = device->supportedSampleSizes(); + for(int i = 0; i < sampleSizez.size(); ++i) + sampleSizesBox->addItem(QString("%1").arg(sampleSizez.at(i))); + if(sampleSizez.size()) + settings.setSampleSize(sampleSizez.at(0)); + + sampleTypesBox->clear(); + QList sampleTypez = device->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)); + } + + endianBox->clear(); + QList endianz = device->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; + } + } + if(endianz.size()) + settings.setByteOrder(endianz.at(0)); +} + +void AudioTest::freqChanged(int idx) +{ + // freq has changed + settings.setFrequency(frequencyBox->itemText(idx).toInt()); +} + +void AudioTest::channelChanged(int idx) +{ + settings.setChannels(channelsBox->itemText(idx).toInt()); +} + +void AudioTest::codecChanged(int idx) +{ + settings.setCodec(codecsBox->itemText(idx)); +} + +void AudioTest::sampleSizeChanged(int idx) +{ + settings.setSampleSize(sampleSizesBox->itemText(idx).toInt()); +} + +void AudioTest::sampleTypeChanged(int idx) +{ + switch(sampleTypesBox->itemText(idx).toInt()) { + case QAudioFormat::SignedInt: + settings.setSampleType(QAudioFormat::SignedInt); + break; + case QAudioFormat::UnSignedInt: + settings.setSampleType(QAudioFormat::UnSignedInt); + break; + case QAudioFormat::Float: + settings.setSampleType(QAudioFormat::Float); + } +} + +void AudioTest::endianChanged(int idx) +{ + switch(endianBox->itemText(idx).toInt()) { + case QAudioFormat::LittleEndian: + settings.setByteOrder(QAudioFormat::LittleEndian); + break; + case QAudioFormat::BigEndian: + settings.setByteOrder(QAudioFormat::BigEndian); + } +} + diff --git a/examples/multimedia/audio/audiodevices/audiodevices.h b/examples/multimedia/audio/audiodevices/audiodevices.h new file mode 100644 index 0000000..34a531b --- /dev/null +++ b/examples/multimedia/audio/audiodevices/audiodevices.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include + +#include "ui_audiodevicesbase.h" + +class AudioDevicesBase : public QMainWindow, public Ui::AudioDevicesBase +{ +public: + AudioDevicesBase( QMainWindow *parent = 0, Qt::WFlags f = 0 ); + virtual ~AudioDevicesBase(); +}; + +class AudioTest : public AudioDevicesBase +{ + Q_OBJECT +public: + AudioTest( QMainWindow *parent = 0, Qt::WFlags f = 0 ); + virtual ~AudioTest(); + + QAudioDeviceId deviceHandle; + QAudioDeviceInfo* device; + QAudioFormat settings; + QAudio::Mode mode; + +private slots: + void modeChanged(int idx); + void deviceChanged(int idx); + void freqChanged(int idx); + void channelChanged(int idx); + void codecChanged(int idx); + void sampleSizeChanged(int idx); + void sampleTypeChanged(int idx); + void endianChanged(int idx); + void test(); +}; + diff --git a/examples/multimedia/audio/audiodevices/audiodevices.pro b/examples/multimedia/audio/audiodevices/audiodevices.pro new file mode 100644 index 0000000..adc4890 --- /dev/null +++ b/examples/multimedia/audio/audiodevices/audiodevices.pro @@ -0,0 +1,12 @@ +HEADERS = audiodevices.h +SOURCES = audiodevices.cpp \ + main.cpp +FORMS += audiodevicesbase.ui + +QT += multimedia + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audiodevices +sources.files = $$SOURCES *.h $$RESOURCES $$FORMS audiodevices.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audiodevices +INSTALLS += target sources diff --git a/examples/multimedia/audio/audiodevices/audiodevicesbase.ui b/examples/multimedia/audio/audiodevices/audiodevicesbase.ui new file mode 100644 index 0000000..674f201 --- /dev/null +++ b/examples/multimedia/audio/audiodevices/audiodevicesbase.ui @@ -0,0 +1,255 @@ + + AudioDevicesBase + + + + 0 + 0 + 504 + 702 + + + + AudioDevicesBase + + + + + 0 + 28 + 504 + 653 + + + + + + 40 + 21 + 321 + 506 + + + + + + + + 1 + 0 + + + + Device + + + + + + + Mode + + + + + + + + + + + + + QFrame::Panel + + + QFrame::Raised + + + Actual Settings + + + Qt::AlignCenter + + + + + + + QFrame::Panel + + + QFrame::Raised + + + Nearest Settings + + + Qt::AlignCenter + + + + + + + Frequency + + + + + + + Frequency + + + + + + + + + + + + + Channels + + + + + + + Channel + + + + + + + + + + + + + Codecs + + + + + + + Codec + + + + + + + + + + + + + SampleSize + + + + + + + SampleSize + + + + + + + + + + + + + SampleType + + + + + + + SampleType + + + + + + + + + + + + + Endianess + + + + + + + Endianess + + + + + + + + + + + + + + 0 + 40 + + + + + + + + Test + + + + + + + + + + 0 + 0 + 504 + 28 + + + + + + + 0 + 681 + 504 + 21 + + + + + + + diff --git a/examples/multimedia/audio/audiodevices/main.cpp b/examples/multimedia/audio/audiodevices/main.cpp new file mode 100644 index 0000000..12e413e --- /dev/null +++ b/examples/multimedia/audio/audiodevices/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "audiodevices.h" + +int main(int argv, char **args) +{ + QApplication app(argv, args); + app.setApplicationName("Audio Device Test"); + + AudioTest audio; + audio.show(); + + return app.exec(); +} diff --git a/examples/multimedia/audio/audioinput/audioinput.cpp b/examples/multimedia/audio/audioinput/audioinput.cpp new file mode 100644 index 0000000..ae7d84c --- /dev/null +++ b/examples/multimedia/audio/audioinput/audioinput.cpp @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include +#include + +#include +#include +#include "audioinput.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +Spectrum::Spectrum(QObject* parent, QAudioInput* device, float* out) + :QIODevice( parent ) +{ + input = device; + output = out; + + unsigned int i; + + // Allocate sample buffer and initialize sin and cos lookup tables + fftState = (fft_state *) malloc (sizeof(fft_state)); + + for(i = 0; i < BUFFER_SIZE; i++) { + bitReverse[i] = reverseBits(i); + } + for(i = 0; i < BUFFER_SIZE / 2; i++) { + float j = 2 * M_PI * i / BUFFER_SIZE; + costable[i] = cos(j); + sintable[i] = sin(j); + } +} + +Spectrum::~Spectrum() +{ +} + +void Spectrum::start() +{ + open(QIODevice::WriteOnly); +} + +void Spectrum::stop() +{ + close(); +} + +qint64 Spectrum::readData(char *data, qint64 maxlen) +{ + Q_UNUSED(data) + Q_UNUSED(maxlen) + + return 0; +} + +qint64 Spectrum::writeData(const char *data, qint64 len) +{ + performFFT((sound_sample*)data); + emit update(); + + return len; +} + +int Spectrum::reverseBits(unsigned int initial) { + // BIT-REVERSE-COPY(a,A) + + unsigned int reversed = 0, loop; + for(loop = 0; loop < BUFFER_SIZE_LOG; loop++) { + reversed <<= 1; + reversed += (initial & 1); + initial >>= 1; + } + return reversed; +} + +void Spectrum::performFFT(const sound_sample *input) { + /* Convert to reverse bit order for FFT */ + prepFFT(input, fftState->real, fftState->imag); + + /* Calculate FFT */ + calcFFT(fftState->real, fftState->imag); + + /* Convert FFT to intensities */ + outputFFT(fftState->real, fftState->imag); +} + +void Spectrum::prepFFT(const sound_sample *input, float * re, float * im) { + unsigned int i; + float *realptr = re; + float *imagptr = im; + + /* Get input, in reverse bit order */ + for(i = 0; i < BUFFER_SIZE; i++) { + *realptr++ = input[bitReverse[i]]; + *imagptr++ = 0; + } +} + +void Spectrum::calcFFT(float * re, float * im) { + unsigned int i, j, k; + unsigned int exchanges; + float fact_real, fact_imag; + float tmp_real, tmp_imag; + unsigned int factfact; + + /* Set up some variables to reduce calculation in the loops */ + exchanges = 1; + factfact = BUFFER_SIZE / 2; + + /* divide and conquer method */ + for(i = BUFFER_SIZE_LOG; i != 0; i--) { + for(j = 0; j != exchanges; j++) { + fact_real = costable[j * factfact]; + fact_imag = sintable[j * factfact]; + for(k = j; k < BUFFER_SIZE; k += exchanges << 1) { + int k1 = k + exchanges; + tmp_real = fact_real * re[k1] - fact_imag * im[k1]; + tmp_imag = fact_real * im[k1] + fact_imag * re[k1]; + re[k1] = re[k] - tmp_real; + im[k1] = im[k] - tmp_imag; + re[k] += tmp_real; + im[k] += tmp_imag; + } + } + exchanges <<= 1; + factfact >>= 1; + } +} + +void Spectrum::outputFFT(const float * re, const float * im) { + const float *realptr = re; + const float *imagptr = im; + float *outputptr = output; + + float *endptr = output + BUFFER_SIZE / 2; + + /* Convert FFT to intensities */ + + while(outputptr <= endptr) { + *outputptr = (*realptr * *realptr) + (*imagptr * *imagptr); + outputptr++; realptr++; imagptr++; + } + *output /= 4; + *endptr /= 4; +} + + +RenderArea::RenderArea(QWidget *parent) + : QWidget(parent) +{ + setBackgroundRole(QPalette::Base); + setAutoFillBackground(true); + + samples = 0; + sampleSize = 0; + setMinimumHeight(30); + setMinimumWidth(200); +} + +void RenderArea::paintEvent(QPaintEvent * /* event */) +{ + QPainter painter(this); + + if(sampleSize == 0) + return; + + painter.setPen(Qt::red); + int max = 0; + for(int i=0;i max) + max = m; + } + int x1,y1,x2,y2; + + for(int i=0;i<10;i++) { + x1 = painter.viewport().left()+11; + y1 = painter.viewport().top()+10+i; + x2 = painter.viewport().right()-20-max; + y2 = painter.viewport().top()+10+i; + if(x2 < painter.viewport().left()+10) + x2 = painter.viewport().left()+10; + + painter.drawLine(QPoint(x1,y1),QPoint(x2,y2)); + } + + painter.setPen(Qt::black); + painter.drawRect(QRect(painter.viewport().left()+10, painter.viewport().top()+10, + painter.viewport().right()-20, painter.viewport().bottom()-20)); +} + +void RenderArea::spectrum(float* output, int size) +{ + samples = output; + sampleSize = size; + repaint(); +} + + +InputTest::InputTest() +{ + QWidget *window = new QWidget; + QVBoxLayout* layout = new QVBoxLayout; + + canvas = new RenderArea; + layout->addWidget(canvas); + + deviceBox = new QComboBox(this); + QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); + for(int i = 0; i < devices.size(); ++i) { + deviceBox->addItem(QAudioDeviceInfo(devices.at(i)).deviceName(), qVariantFromValue(devices.at(i))); + } + connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); + layout->addWidget(deviceBox); + + button = new QPushButton(this); + button->setText(tr("Click for Push Mode")); + connect(button,SIGNAL(clicked()),SLOT(toggleMode())); + layout->addWidget(button); + + button2 = new QPushButton(this); + button2->setText(tr("Click To Suspend")); + connect(button2,SIGNAL(clicked()),SLOT(toggleSuspend())); + layout->addWidget(button2); + + window->setLayout(layout); + setCentralWidget(window); + window->show(); + + buffer = new char[BUFFER_SIZE*10]; + output = new float[1024]; + + pullMode = true; + + format.setFrequency(8000); + format.setChannels(1); + format.setSampleSize(8); + format.setSampleType(QAudioFormat::UnSignedInt); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setCodec("audio/pcm"); + + audioInput = new QAudioInput(format,this); + connect(audioInput,SIGNAL(notify()),SLOT(status())); + connect(audioInput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); + spec = new Spectrum(this,audioInput,output); + connect(spec,SIGNAL(update()),SLOT(refreshDisplay())); + spec->start(); + audioInput->start(spec); +} + +InputTest::~InputTest() {} + +void InputTest::status() +{ + qWarning()<<"bytesReady = "<bytesReady()<<" bytes, clock = "<clock()<<"ms, totalTime = "<totalTime()/1000<<"ms"; +} + +void InputTest::readMore() +{ + if(!audioInput) + return; + qint64 len = audioInput->bytesReady(); + if(len > BUFFER_SIZE*10) + len = BUFFER_SIZE*10; + qint64 l = input->read(buffer,len); + if(l > 0) { + spec->write(buffer,l); + } +} + +void InputTest::toggleMode() +{ + // Change bewteen pull and push modes + audioInput->stop(); + + if(pullMode) { + button->setText(tr("Click for Push Mode")); + input = audioInput->start(0); + connect(input,SIGNAL(readyRead()),SLOT(readMore())); + pullMode = false; + } else { + button->setText(tr("Click for Pull Mode")); + pullMode = true; + audioInput->start(spec); + } +} + +void InputTest::toggleSuspend() +{ + // toggle suspend/resume + if(audioInput->state() == QAudio::SuspendState) { + qWarning()<<"status: Suspended, resume()"; + audioInput->resume(); + button2->setText("Click To Suspend"); + } else if (audioInput->state() == QAudio::ActiveState) { + qWarning()<<"status: Active, suspend()"; + audioInput->suspend(); + button2->setText("Click To Resume"); + } else if (audioInput->state() == QAudio::StopState) { + qWarning()<<"status: Stopped, resume()"; + audioInput->resume(); + button2->setText("Click To Suspend"); + } else if (audioInput->state() == QAudio::IdleState) { + qWarning()<<"status: IdleState"; + } +} + +void InputTest::state(QAudio::State state) +{ + qWarning()<<" state="<spectrum(output,256); + canvas->repaint(); +} + +void InputTest::deviceChanged(int idx) +{ + spec->stop(); + audioInput->stop(); + audioInput->disconnect(this); + delete audioInput; + + device = deviceBox->itemData(idx).value(); + audioInput = new QAudioInput(device, format, this); + connect(audioInput,SIGNAL(notify()),SLOT(status())); + connect(audioInput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); + spec->start(); + audioInput->start(spec); +} diff --git a/examples/multimedia/audio/audioinput/audioinput.h b/examples/multimedia/audio/audioinput/audioinput.h new file mode 100644 index 0000000..3a6b356 --- /dev/null +++ b/examples/multimedia/audio/audioinput/audioinput.h @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include + +#define BUFFER_SIZE_LOG 9 +#define BUFFER_SIZE (1 << BUFFER_SIZE_LOG) + +struct _struct_fft_state { + float real[BUFFER_SIZE]; + float imag[BUFFER_SIZE]; +}; +typedef _struct_fft_state fft_state; +typedef short int sound_sample; + +class Spectrum : public QIODevice +{ + Q_OBJECT +public: + Spectrum(QObject* parent, QAudioInput* device, float* out); + ~Spectrum(); + + void start(); + void stop(); + + qint64 readData(char *data, qint64 maxlen); + qint64 writeData(const char *data, qint64 len); + + QAudioInput* input; + float* output; + fft_state* fftState; + + unsigned int bitReverse[BUFFER_SIZE]; + float sintable[BUFFER_SIZE / 2]; + float costable[BUFFER_SIZE / 2]; + + void prepFFT (const sound_sample *input, float *re, float *im); + void calcFFT (float *re, float *im); + void outputFFT (const float *re, const float *im); + int reverseBits (unsigned int initial); + void performFFT (const sound_sample *input); + +signals: + void update(); +}; + + +class RenderArea : public QWidget +{ + Q_OBJECT + +public: + RenderArea(QWidget *parent = 0); + + void spectrum(float* output, int size); + +protected: + void paintEvent(QPaintEvent *event); + +private: + QPixmap pixmap; + + float* samples; + int sampleSize; +}; + +class InputTest : public QMainWindow +{ + Q_OBJECT +public: + InputTest(); + ~InputTest(); + + QAudioDeviceId device; + QAudioFormat format; + QAudioInput* audioInput; + Spectrum* spec; + QIODevice* input; + RenderArea* canvas; + + bool pullMode; + + QPushButton* button; + QPushButton* button2; + QComboBox* deviceBox; + + char* buffer; + float* output; + +private slots: + void refreshDisplay(); + void status(); + void readMore(); + void toggleMode(); + void toggleSuspend(); + void state(QAudio::State s); + void deviceChanged(int idx); +}; + diff --git a/examples/multimedia/audio/audioinput/audioinput.pro b/examples/multimedia/audio/audioinput/audioinput.pro new file mode 100644 index 0000000..d930750 --- /dev/null +++ b/examples/multimedia/audio/audioinput/audioinput.pro @@ -0,0 +1,12 @@ +HEADERS = audioinput.h +SOURCES = audioinput.cpp \ + main.cpp + +QT += multimedia + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audioinput +sources.files = $$SOURCES *.h $$RESOURCES $$FORMS audioinput.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audioinput +INSTALLS += target sources + diff --git a/examples/multimedia/audio/audioinput/main.cpp b/examples/multimedia/audio/audioinput/main.cpp new file mode 100644 index 0000000..64a9b04 --- /dev/null +++ b/examples/multimedia/audio/audioinput/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "audioinput.h" + +int main(int argv, char **args) +{ + QApplication app(argv, args); + app.setApplicationName("Audio Input Test"); + + InputTest input; + input.show(); + + return app.exec(); +} diff --git a/examples/multimedia/audio/audiooutput/audiooutput.cpp b/examples/multimedia/audio/audiooutput/audiooutput.cpp new file mode 100644 index 0000000..be26f19 --- /dev/null +++ b/examples/multimedia/audio/audiooutput/audiooutput.cpp @@ -0,0 +1,280 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include +#include "audiooutput.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +Generator::Generator(QObject *parent) + :QIODevice( parent ) +{ + finished = false; + buffer = new char[SECONDS*44100*4+1000]; + t=buffer; + len=fillData(t+4,450,SECONDS); /* left channel, 450Hz sine */ + len+=fillData(t+6,452,SECONDS); /* right channel, 452Hz sine */ + putLong(t,len); + putLong(buffer+4,len+8+16+8); + pos = 0; + total = len+8+16+8; +} + +Generator::~Generator() +{ + delete [] buffer; +} + +void Generator::start() +{ + open(QIODevice::ReadOnly); +} + +void Generator::stop() +{ + close(); +} + +int Generator::putShort(char *t, unsigned int value) +{ + *(unsigned char *)(t++)=value&255; + *(unsigned char *)(t)=(value/256)&255; + return 2; +} + +int Generator::putLong(char *t, unsigned int value) +{ + *(unsigned char *)(t++)=value&255; + *(unsigned char *)(t++)=(value/256)&255; + *(unsigned char *)(t++)=(value/(256*256))&255; + *(unsigned char *)(t)=(value/(256*256*256))&255; + return 4; +} + +int Generator::fillData(char *start, int frequency, int seconds) +{ + int i, len=0; + int value; + for(i=0; i 16384) + len = 16384; + + if(len < (SECONDS*44100*4+1000)-pos) { + // Normal + memcpy(data,t+pos,len); + pos+=len; + return len; + } else { + // Whats left and reset to start + qint64 left = (SECONDS*44100*4+1000)-pos; + memcpy(data,t+pos,left); + pos=0; + return left; + } +} + +qint64 Generator::writeData(const char *data, qint64 len) +{ + Q_UNUSED(data); + Q_UNUSED(len); + + return 0; +} + +AudioTest::AudioTest() +{ + QWidget *window = new QWidget; + QVBoxLayout* layout = new QVBoxLayout; + + deviceBox = new QComboBox(this); + QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + for(int i = 0; i < devices.size(); ++i) { + deviceBox->addItem(QAudioDeviceInfo(devices.at(i)).deviceName(), qVariantFromValue(devices.at(i))); + } + connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); + layout->addWidget(deviceBox); + + button = new QPushButton(this); + button->setText(tr("Click for Push Mode")); + connect(button,SIGNAL(clicked()),SLOT(toggle())); + layout->addWidget(button); + + button2 = new QPushButton(this); + button2->setText(tr("Click To Suspend")); + connect(button2,SIGNAL(clicked()),SLOT(togglePlay())); + layout->addWidget(button2); + + window->setLayout(layout); + setCentralWidget(window); + window->show(); + + buffer = new char[BUFFER_SIZE]; + + gen = new Generator(this); + + pullMode = true; + + timer = new QTimer(this); + connect(timer,SIGNAL(timeout()),SLOT(writeMore())); + + gen->start(); + + settings.setFrequency(44100); + settings.setChannels(2); + settings.setSampleSize(16); + settings.setCodec("audio/pcm"); + settings.setByteOrder(QAudioFormat::LittleEndian); + settings.setSampleType(QAudioFormat::SignedInt); + audioOutput = new QAudioOutput(settings,this); + connect(audioOutput,SIGNAL(notify()),SLOT(status())); + connect(audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); + + audioOutput->start(gen); +} + +AudioTest::~AudioTest() +{ + delete [] buffer; +} + +void AudioTest::deviceChanged(int idx) +{ + timer->stop(); + gen->stop(); + audioOutput->stop(); + audioOutput->disconnect(this); + delete audioOutput; + + device = deviceBox->itemData(idx).value(); + audioOutput = new QAudioOutput(device,settings,this); + connect(audioOutput,SIGNAL(notify()),SLOT(status())); + connect(audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); + gen->start(); + audioOutput->start(gen); +} + +void AudioTest::status() +{ + qWarning()<<"byteFree = "<bytesFree()<<" bytes, clock = "<clock()<<"ms, totalTime = "<totalTime()/1000<<"ms"; +} + +void AudioTest::writeMore() +{ + if(!audioOutput) + return; + + if(audioOutput->state() == QAudio::StopState) + return; + + int l; + int out; + + int chunks = audioOutput->bytesFree()/audioOutput->periodSize(); + while(chunks) { + l = gen->read(buffer,audioOutput->periodSize()); + if(l > 0) + out = output->write(buffer,l); + if(l != audioOutput->periodSize()) + break; + chunks--; + } +} + +void AudioTest::toggle() +{ + // Change between pull and push modes + + timer->stop(); + audioOutput->stop(); + + if (pullMode) { + button->setText("Click for Pull Mode"); + output = audioOutput->start(0); + pullMode = false; + timer->start(20); + } else { + button->setText("Click for Push Mode"); + pullMode = true; + audioOutput->start(gen); + } +} + +void AudioTest::togglePlay() +{ + // toggle suspend/resume + if(audioOutput->state() == QAudio::SuspendState) { + qWarning()<<"status: Suspended, resume()"; + audioOutput->resume(); + button2->setText("Click To Suspend"); + } else if (audioOutput->state() == QAudio::ActiveState) { + qWarning()<<"status: Active, suspend()"; + audioOutput->suspend(); + button2->setText("Click To Resume"); + } else if (audioOutput->state() == QAudio::StopState) { + qWarning()<<"status: Stopped, resume()"; + audioOutput->resume(); + button2->setText("Click To Suspend"); + } else if (audioOutput->state() == QAudio::IdleState) { + qWarning()<<"status: IdleState"; + } +} + +void AudioTest::state(QAudio::State state) +{ + qWarning()<<" state="< + +#define BUFFER_SIZE 32768 +#define SECONDS 3 + +#include +#include +#include +#include +#include +#include + +#include + +class Generator : public QIODevice +{ + Q_OBJECT +public: + Generator(QObject *parent); + ~Generator(); + + void start(); + void stop(); + + char *t; + int len; + int pos; + int total; + char *buffer; + bool finished; + int chunk_size; + + qint64 readData(char *data, qint64 maxlen); + qint64 writeData(const char *data, qint64 len); + +private: + int putShort(char *t, unsigned int value); + int putLong(char *t, unsigned int value); + int fillData(char *start, int frequency, int seconds); +}; + +class AudioTest : public QMainWindow +{ + Q_OBJECT +public: + AudioTest(); + ~AudioTest(); + + QAudioDeviceId device; + Generator* gen; + QAudioOutput* audioOutput; + QIODevice* output; + QTimer* timer; + QAudioFormat settings; + + bool pullMode; + char* buffer; + + QPushButton* button; + QPushButton* button2; + QComboBox* deviceBox; + +private slots: + void status(); + void writeMore(); + void toggle(); + void togglePlay(); + void state(QAudio::State s); + void deviceChanged(int idx); +}; + diff --git a/examples/multimedia/audio/audiooutput/audiooutput.pro b/examples/multimedia/audio/audiooutput/audiooutput.pro new file mode 100644 index 0000000..08f43ce --- /dev/null +++ b/examples/multimedia/audio/audiooutput/audiooutput.pro @@ -0,0 +1,11 @@ +HEADERS = audiooutput.h +SOURCES = audiooutput.cpp \ + main.cpp + +QT += multimedia + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audiooutput +sources.files = $$SOURCES *.h $$RESOURCES $$FORMS audiooutput.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audiooutput +INSTALLS += target sources diff --git a/examples/multimedia/audio/audiooutput/main.cpp b/examples/multimedia/audio/audiooutput/main.cpp new file mode 100644 index 0000000..fc319bd --- /dev/null +++ b/examples/multimedia/audio/audiooutput/main.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +#include "audiooutput.h" + +int main(int argv, char **args) +{ + QApplication app(argv, args); + app.setApplicationName("Audio Output Test"); + + AudioTest audio; + audio.show(); + + return app.exec(); +} diff --git a/examples/multimedia/multimedia.pro b/examples/multimedia/multimedia.pro new file mode 100644 index 0000000..ac78b15 --- /dev/null +++ b/examples/multimedia/multimedia.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs +SUBDIRS = audio + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multimedia +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS multimedia.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/multimedia +INSTALLS += target sources diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 1bac953..a03a313 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 = webkit phonon dbus testlib script scripttools svg qt3support sql xmlpatterns xml egl opengl openvg gui network core +TMPLIBS = multimedia webkit phonon 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 } @@ -152,6 +152,7 @@ for(QTLIB, $$list($$lower($$unique(QT)))) { else:isEqual(QTLIB, dbus):qlib = QtDBus else:isEqual(QTLIB, phonon):qlib = phonon else:isEqual(QTLIB, webkit):qlib = QtWebKit + else:isEqual(QTLIB, multimedia):qlib = QtMultimedia 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 18d5a9f..1711f16 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1173,6 +1173,11 @@ class QDataStream; # else # define Q_OPENGL_EXPORT Q_DECL_IMPORT # endif +# if defined(QT_BUILD_MULTIMEDIA_LIB) +# define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT +# else +# define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT +# endif # if defined(QT_BUILD_OPENVG_LIB) # define Q_OPENVG_EXPORT Q_DECL_EXPORT # else @@ -1217,6 +1222,7 @@ class QDataStream; # define Q_SVG_EXPORT Q_DECL_IMPORT # define Q_CANVAS_EXPORT Q_DECL_IMPORT # define Q_OPENGL_EXPORT Q_DECL_IMPORT +# define Q_MULTIMEDIA_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 @@ -1243,6 +1249,7 @@ class QDataStream; # define Q_NETWORK_EXPORT Q_DECL_EXPORT # define Q_SVG_EXPORT Q_DECL_EXPORT # define Q_OPENGL_EXPORT Q_DECL_EXPORT +# define Q_MULTIMEDIA_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 @@ -1256,6 +1263,7 @@ class QDataStream; # define Q_NETWORK_EXPORT # define Q_SVG_EXPORT # define Q_OPENGL_EXPORT +# define Q_MULTIMEDIA_EXPORT # define Q_XML_EXPORT # define Q_XMLPATTERNS_EXPORT # define Q_SCRIPT_EXPORT @@ -2305,12 +2313,14 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf(); #define QT_MODULE_DBUS 0x08000 #define QT_MODULE_SCRIPTTOOLS 0x10000 #define QT_MODULE_OPENVG 0x20000 +#define QT_MODULE_MULTIMEDIA 0x40000 /* Qt editions */ #define QT_EDITION_CONSOLE (QT_MODULE_CORE \ | QT_MODULE_NETWORK \ | QT_MODULE_SQL \ | QT_MODULE_SCRIPT \ + | QT_MODULE_MULTIMEDIA \ | QT_MODULE_XML \ | QT_MODULE_XMLPATTERNS \ | QT_MODULE_TEST \ @@ -2326,6 +2336,7 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf(); | QT_MODULE_OPENGL \ | QT_MODULE_OPENVG \ | QT_MODULE_SQL \ + | QT_MODULE_MULTIMEDIA \ | QT_MODULE_XML \ | QT_MODULE_XMLPATTERNS \ | QT_MODULE_SCRIPT \ @@ -2374,6 +2385,9 @@ QT_LICENSED_MODULE(OpenVG) #if (QT_EDITION & QT_MODULE_SQL) QT_LICENSED_MODULE(Sql) #endif +#if (QT_EDITION & QT_MODULE_MULTIMEDIA) +QT_LICENSED_MODULE(Multimedia) +#endif #if (QT_EDITION & QT_MODULE_XML) QT_LICENSED_MODULE(Xml) #endif diff --git a/src/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri new file mode 100644 index 0000000..3ddb23b --- /dev/null +++ b/src/multimedia/audio/audio.pri @@ -0,0 +1,56 @@ +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 \ + $$PWD/qaudiodeviceid.h \ + $$PWD/qaudiodeviceid_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 \ + $$PWD/qaudiodeviceid.cpp + +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 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: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 += -lasound + } + } +} diff --git a/src/multimedia/audio/qaudio.cpp b/src/multimedia/audio/qaudio.cpp new file mode 100644 index 0000000..5ba6493 --- /dev/null +++ b/src/multimedia/audio/qaudio.cpp @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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. + \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 SuspendState The audio device is in a suspended state, this state will only be entered + after suspend() is called. + \value StopState 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..b996cc6 --- /dev/null +++ b/src/multimedia/audio/qaudio.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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, SuspendState, StopState, 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..cfa7ca3 --- /dev/null +++ b/src/multimedia/audio/qaudio_mac.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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..8e2d522 --- /dev/null +++ b/src/multimedia/audio/qaudio_mac_p.h @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp new file mode 100644 index 0000000..35e9c91 --- /dev/null +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -0,0 +1,250 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include "qaudiodevicefactory_p.h" +#include "qaudiodeviceid_p.h" + +#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" +#endif + +QT_BEGIN_NAMESPACE + +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (QAudioEngineFactoryInterface_iid, QLatin1String("/audio"), Qt::CaseInsensitive)) + + +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 totalTime() const { return 0; } + qint64 clock() const { return 0; } + QAudio::Error error() const { return QAudio::OpenError; } + QAudio::State state() const { return QAudio::StopState; } + 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 totalTime() const { return 0; } + qint64 clock() const { return 0; } + QAudio::Error error() const { return QAudio::OpenError; } + QAudio::State state() const { return QAudio::StopState; } + QAudioFormat format() const { return QAudioFormat(); } +}; + +QList QAudioDeviceFactory::deviceList(QAudio::Mode mode) +{ + QList devices; +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + foreach (const QByteArray &handle, QAudioDeviceInfoPrivate::deviceList(mode)) + devices += createDeviceId(QLatin1String("builtin"), mode, handle); +#endif + QFactoryLoader* l = loader(); + + foreach (QString const& key, l->keys()) { + QAudioEngineFactoryInterface* plugin = qobject_cast(l->instance(key)); + if (plugin) { + foreach (QByteArray const& handle, plugin->deviceList(mode)) + devices += createDeviceId(key, mode, handle); + } + + delete plugin; + } + + return devices; +} + +QAudioDeviceId QAudioDeviceFactory::defaultInputDevice() +{ + QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); + + if (plugin) { + QList list = plugin->deviceList(QAudio::AudioInput); + if (list.size() > 0) + return createDeviceId(QLatin1String("default"), QAudio::AudioInput, list.at(0)); + } +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + return createDeviceId(QLatin1String("builtin"), QAudio::AudioInput, QAudioDeviceInfoPrivate::defaultInputDevice()); +#endif + return QAudioDeviceId(); +} + +QAudioDeviceId QAudioDeviceFactory::defaultOutputDevice() +{ + QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(QLatin1String("default"))); + + if (plugin) { + QList list = plugin->deviceList(QAudio::AudioOutput); + if (list.size() > 0) + return createDeviceId(QLatin1String("default"), QAudio::AudioOutput, list.at(0)); + } +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + return createDeviceId(QLatin1String("builtin"), QAudio::AudioOutput, QAudioDeviceInfoPrivate::defaultOutputDevice()); +#endif + return QAudioDeviceId(); +} + +QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(QAudioDeviceId const& id) +{ + if (id.isNull()) + return new QNullDeviceInfo(); +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + if (id.d->key == QLatin1String("builtin")) + return new QAudioDeviceInfoPrivate(id.d->handle, QAudio::Mode(id.d->mode)); +#endif + QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(id.d->key)); + + if (plugin) + return plugin->createDeviceInfo(id.d->handle, QAudio::Mode(id.d->mode)); + + return new QNullDeviceInfo(); +} + +QAbstractAudioInput* QAudioDeviceFactory::createDefaultInputDevice(QAudioFormat const &format) +{ + return createInputDevice(defaultInputDevice(), format); +} + +QAbstractAudioOutput* QAudioDeviceFactory::createDefaultOutputDevice(QAudioFormat const &format) +{ + return createOutputDevice(defaultOutputDevice(), format); +} + +QAbstractAudioInput* QAudioDeviceFactory::createInputDevice(QAudioDeviceId const& id, QAudioFormat const &format) +{ + if (id.isNull()) + return new QNullInputDevice(); +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + if (id.d->key == QLatin1String("builtin")) { + if(!defaultInputDevice().isNull()) + return new QAudioInputPrivate(id.d->handle, format); + else + return new QNullInputDevice(); + } +#endif + QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance((id.d->key))); + + if (plugin) + return plugin->createInput(id.d->handle, format); + + return new QNullInputDevice(); +} + +QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceId const& id, QAudioFormat const &format) +{ + if (id.isNull()) + return new QNullOutputDevice(); +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + if (id.d->key == QLatin1String("builtin")) { + if(!defaultOutputDevice().isNull()) + return new QAudioOutputPrivate(id.d->handle, format); + else + return new QNullOutputDevice(); + } +#endif + QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(id.d->key)); + + if (plugin) + return plugin->createOutput(id.d->handle, format); + + return new QNullOutputDevice(); +} + +QAudioDeviceId QAudioDeviceFactory::createDeviceId(QString const& key, int mode, QByteArray const& handle) +{ + return QAudioDeviceId(new QAudioDeviceIdPrivate(key, mode, handle)); +} + +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..a8e2b28 --- /dev/null +++ b/src/multimedia/audio/qaudiodevicefactory_p.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QAbstractAudioInput; +class QAbstractAudioOutput; + + +class QAudioDeviceFactory +{ +public: + static QList deviceList(QAudio::Mode mode); + + static QAudioDeviceId defaultInputDevice(); + static QAudioDeviceId defaultOutputDevice(); + + static QAbstractAudioDeviceInfo* audioDeviceInfo(QAudioDeviceId const &device); + + static QAbstractAudioInput* createDefaultInputDevice(QAudioFormat const &format); + static QAbstractAudioOutput* createDefaultOutputDevice(QAudioFormat const &format); + + static QAbstractAudioInput* createInputDevice(QAudioDeviceId const &device, QAudioFormat const &format); + static QAbstractAudioOutput* createOutputDevice(QAudioDeviceId const &device, QAudioFormat const &format); + + static QAbstractAudioInput* createNullInput(); + static QAbstractAudioOutput* createNullOutput(); + + static QAudioDeviceId createDeviceId(QString const& key, int mode, QByteArray const& handle); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIODEVICEFACTORY_P_H + diff --git a/src/multimedia/audio/qaudiodeviceid.cpp b/src/multimedia/audio/qaudiodeviceid.cpp new file mode 100644 index 0000000..21a9cd8 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceid.cpp @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include +#include "qaudiodeviceid_p.h" + + +QT_BEGIN_NAMESPACE + +/*! + \class QAudioDeviceId + \brief The QAudioDeviceId class provides means for identifying a unique input or output device on a system. + + \inmodule QtMultimedia + \ingroup multimedia + \since 4.6 + + \sa QAudioDeviceInfo, QAudioOutput, QAudioInput +*/ + +/*! + Construct a new null QAudioDeviceId. +*/ + +QAudioDeviceId::QAudioDeviceId() +{ +} + +/*! + Copy the QAudDeviceId referenced by \a other. +*/ + +QAudioDeviceId::QAudioDeviceId(const QAudioDeviceId &other): + d(other.d) +{ +} + +/*! + Destroy the QAudioDeviceId. +*/ + +QAudioDeviceId::~QAudioDeviceId() +{ +} + +/*! + Make a copy of the \a other QAudioDeviceId. +*/ + +QAudioDeviceId& QAudioDeviceId::operator=(const QAudioDeviceId &other) +{ + d = other.d; + return *this; +} + +/*! + Compare with the \a other QAudioDeviceId, return true if they are the same; + otherwise false. +*/ + +bool QAudioDeviceId::operator==(const QAudioDeviceId &other) const +{ + return (d.constData() == 0 && other.d.constData() == 0) || + (d.constData() != 0 && other.d.constData() != 0 && + d->key == other.d->key && d->mode == other.d->mode && d->handle == other.d->handle); +} + +/*! + Compare with the \a other QAudioDeviceId, return false if they are the same; + otherwise true. +*/ + +bool QAudioDeviceId::operator!=(const QAudioDeviceId &other) const +{ + return !(*this == other); +} + +/*! + Returns true if this is not a valid QAudioDeviceId; otherwise false. +*/ + +bool QAudioDeviceId::isNull() const +{ + return d.constData() == 0; +} + +/*! + \internal +*/ + +QAudioDeviceId::QAudioDeviceId(QAudioDeviceIdPrivate* data): + d(data) +{ +} + +/*! + \internal +*/ + +QAudioDeviceIdPrivate::QAudioDeviceIdPrivate(QString const& k, int m, QByteArray const& h): + key(k), mode(m), handle(h) +{ +} + +#ifndef QT_NO_DATASTREAM +Q_MULTIMEDIA_EXPORT QDataStream &operator<<(QDataStream &s, const QAudioDeviceId &id) +{ + s << id.d->key << id.d->mode << id.d->handle; + return s; +} + +Q_MULTIMEDIA_EXPORT QDataStream &operator>>(QDataStream &s, QAudioDeviceId &id) +{ + QString key; + int mode; + QByteArray handle; + + s >> key >> mode >> handle; + id = QAudioDeviceId(new QAudioDeviceIdPrivate(key, mode, handle)); + + return s; +} +#endif + + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceid.h b/src/multimedia/audio/qaudiodeviceid.h new file mode 100644 index 0000000..f9188d3 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceid.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QAUDIODEVICEID_H +#define QAUDIODEVICEID_H + +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAudioDeviceFactory; +class QAudioDeviceIdPrivate; + +class Q_MULTIMEDIA_EXPORT QAudioDeviceId +{ + friend class QAudioDeviceFactory; + friend Q_MULTIMEDIA_EXPORT QDataStream &operator<<(QDataStream&, const QAudioDeviceId&); + friend Q_MULTIMEDIA_EXPORT QDataStream &operator>>(QDataStream&, QAudioDeviceId&); + +public: + QAudioDeviceId(); + QAudioDeviceId(const QAudioDeviceId &other); + ~QAudioDeviceId(); + + QAudioDeviceId& operator=(const QAudioDeviceId &other); + bool operator==(const QAudioDeviceId &id) const; + bool operator!=(const QAudioDeviceId &id) const; + + bool isNull() const; + +private: + QAudioDeviceId(QAudioDeviceIdPrivate *data); + + QSharedDataPointer d; +}; + +#ifndef QT_NO_DATASTREAM +Q_MULTIMEDIA_EXPORT QDataStream &operator<<(QDataStream&, const QAudioDeviceId&); +Q_MULTIMEDIA_EXPORT QDataStream &operator>>(QDataStream&, QAudioDeviceId&); +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + +Q_DECLARE_METATYPE(QAudioDeviceId); + + +#endif // QAUDIODEVICEID_H diff --git a/src/multimedia/audio/qaudiodeviceid_p.h b/src/multimedia/audio/qaudiodeviceid_p.h new file mode 100644 index 0000000..3034574 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceid_p.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 QAUDIODEVICEIDPRIVATE_H +#define QAUDIODEVICEIDPRIVATE_H + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAudioDeviceIdPrivate : public QSharedData +{ +public: + QAudioDeviceIdPrivate(QString const& k, int m, QByteArray const& h); + + QString key; + int mode; + QByteArray handle; +}; + + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIODEVICEIDPRIVATE_H diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp new file mode 100644 index 0000000..c1895d7 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -0,0 +1,270 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaudiodevicefactory_p.h" +#include +#include + + +QT_BEGIN_NAMESPACE + +/*! + \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(), supportedChannels(), supportedCodecs(), + supportedFrequencies(), 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(). + + A QAudioDeviceInfo is constructed with a QAudioDeviceId, which is + an identifier for a physical device. It is used by Qt to construct + classes that communicate with the device--such as + QAudioDeviceInfo, QAudioInput, and QAudioOutput. The static + functions defaultInputDevice(), defaultOutputDevice(), and + deviceList() let you get a hold of the ids for all available + devices. You fetch ids based on whether you will use the device + for input or output; this is specified by the QAudio::Mode enum. + The QAudioDeviceId returned are only valid for the QAudio::Mode. + + For instance: + + \code + foreach(QAudioDeviceId audioId, QAudioDeviceInfo::deviceList(QAudio::AudioOutput)) { + QAudioDeviceInfo info(audioId); + qDebug() << "Device name: " << info.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, QAudioDeviceId +*/ + +/*! + Construct a new audio device info and attach it to \a parent. + Using the audio device with the specified \a id. +*/ + +QAudioDeviceInfo::QAudioDeviceInfo(const QAudioDeviceId &id, QObject *parent): + QObject(parent) +{ + d = QAudioDeviceFactory::audioDeviceInfo(id); +} + +/*! + Destroy this audio device info. +*/ + +QAudioDeviceInfo::~QAudioDeviceInfo() +{ + delete d; +} + +/*! + 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 d->deviceName(); +} + +/*! + Returns true if \a settings are supported by the audio device of this QAudioDeviceInfo. +*/ + +bool QAudioDeviceInfo::isFormatSupported(const QAudioFormat &settings) const +{ + return d->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 d->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 d->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 d->codecList(); +} + +/*! + Returns a list of supported frequencies. +*/ + +QList QAudioDeviceInfo::supportedFrequencies() const +{ + return d->frequencyList(); +} + +/*! + Returns a list of supported channels. +*/ + +QList QAudioDeviceInfo::supportedChannels() const +{ + return d->channelsList(); +} + +/*! + Returns a list of supported sample sizes. +*/ + +QList QAudioDeviceInfo::supportedSampleSizes() const +{ + return d->sampleSizeList(); +} + +/*! + Returns a list of supported byte orders. +*/ + +QList QAudioDeviceInfo::supportedByteOrders() const +{ + return d->byteOrderList(); +} + +/*! + Returns a list of supported sample types. +*/ + +QList QAudioDeviceInfo::supportedSampleTypes() const +{ + return d->sampleTypeList(); +} + +/*! + Returns the name of the default input audio device. + All platform and audio plugin implementations provide a default audio device to use. +*/ + +QAudioDeviceId 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. +*/ + +QAudioDeviceId QAudioDeviceInfo::defaultOutputDevice() +{ + return QAudioDeviceFactory::defaultOutputDevice(); +} + +/*! + Returns a list of audio devices that support \a mode. +*/ + +QList QAudioDeviceInfo::deviceList(QAudio::Mode mode) +{ + return QAudioDeviceFactory::deviceList(mode); +} + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h new file mode 100644 index 0000000..444a00a --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QAUDIODEVICEINFO_H +#define QAUDIODEVICEINFO_H + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAbstractAudioDeviceInfo; + +class Q_MULTIMEDIA_EXPORT QAudioDeviceInfo : public QObject +{ + Q_OBJECT + +public: + explicit QAudioDeviceInfo(const QAudioDeviceId &id, QObject *parent = 0); + ~QAudioDeviceInfo(); + + 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 supportedChannels() const; + QList supportedSampleSizes() const; + QList supportedByteOrders() const; + QList supportedSampleTypes() const; + + static QAudioDeviceId defaultInputDevice(); + static QAudioDeviceId defaultOutputDevice(); + + static QList deviceList(QAudio::Mode mode); + +private: + Q_DISABLE_COPY(QAudioDeviceInfo) + + QAbstractAudioDeviceInfo* d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#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..fe45f82 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -0,0 +1,394 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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" + +QAudioDeviceInfoPrivate::QAudioDeviceInfoPrivate(QByteArray dev, QAudio::Mode mode) +{ + handle = 0; + + device = QLatin1String(dev); + this->mode = mode; +} + +QAudioDeviceInfoPrivate::~QAudioDeviceInfoPrivate() +{ + close(); +} + +bool QAudioDeviceInfoPrivate::isFormatSupported(const QAudioFormat& format) const +{ + return testSettings(format); +} + +QAudioFormat QAudioDeviceInfoPrivate::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(tr("audio/pcm")); + } else { + nearest.setFrequency(8000); + nearest.setChannels(1); + nearest.setSampleType(QAudioFormat::SignedInt); + nearest.setSampleSize(8); + nearest.setCodec(tr("audio/pcm")); + } + return nearest; +} + +QAudioFormat QAudioDeviceInfoPrivate::nearestFormat(const QAudioFormat& format) const +{ + if(testSettings(format)) + return format; + else + return preferredFormat(); +} + +QString QAudioDeviceInfoPrivate::deviceName() const +{ + return device; +} + +QStringList QAudioDeviceInfoPrivate::codecList() +{ + updateLists(); + return codecz; +} + +QList QAudioDeviceInfoPrivate::frequencyList() +{ + updateLists(); + return freqz; +} + +QList QAudioDeviceInfoPrivate::channelsList() +{ + updateLists(); + return channelz; +} + +QList QAudioDeviceInfoPrivate::sampleSizeList() +{ + updateLists(); + return sizez; +} + +QList QAudioDeviceInfoPrivate::byteOrderList() +{ + updateLists(); + return byteOrderz; +} + +QList QAudioDeviceInfoPrivate::sampleTypeList() +{ + updateLists(); + return typez; +} + +bool QAudioDeviceInfoPrivate::open() +{ + int err = 0; + QString dev = device; + if(!dev.contains(tr("default"))) { + int idx = snd_card_get_index(dev.toLocal8Bit().constData()); + dev = QString(tr("hw:%1,0")).arg(idx); + } + 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 QAudioDeviceInfoPrivate::close() +{ + if(handle) + snd_pcm_close(handle); + handle = 0; +} + +bool QAudioDeviceInfoPrivate::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; + + // open() + if(!dev.contains(tr("default"))) { + int idx = snd_card_get_index(dev.toLocal8Bit().constData()); + dev = QString(tr("hw:%1,0")).arg(idx); + } + 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 ); + + // For now, just accept only audio/pcm codec + if(!format.codec().startsWith(tr("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 QAudioDeviceInfoPrivate::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(tr("audio/pcm")); + close(); +} + +QList QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) +{ + QAudio::Mode _m; + QList devices; + QByteArray filter; + QString dir; + + // 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; + + while (*n != NULL) { + _m = QAudio::AudioOutput; + name = snd_device_name_get_hint(*n, "NAME"); + descr = snd_device_name_get_hint(*n, "DESC"); + io = snd_device_name_get_hint(*n, "IOID"); + dir = QString::fromUtf8(io); + if((name != NULL) && (descr != NULL) && ((io == NULL) || (dir.length() ==filter.length()))) { + if(dir.length() == 5) + _m = QAudio::AudioInput; + if(io == NULL) + _m = mode; + + QString str = tr(name); + + if(str.contains(tr("default"))) { + int pos = str.indexOf(tr("="),0); + devices.append(str.mid(pos+1).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"); + if(mode == QAudio::AudioInput) { + filter.append("Input"); + } else { + filter.append("Output"); + } + } + + return devices; +} + +QByteArray QAudioDeviceInfoPrivate::defaultInputDevice() +{ + QList devices = deviceList(QAudio::AudioInput); + if(devices.size() == 0) + return QByteArray(); + + return QByteArray("default"); +} + +QByteArray QAudioDeviceInfoPrivate::defaultOutputDevice() +{ + QList devices = deviceList(QAudio::AudioOutput); + if(devices.size() == 0) + return QByteArray(); + + return QByteArray("default"); +} + + diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h new file mode 100644 index 0000000..3ac9239 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 + +const unsigned int MAX_SAMPLE_RATES = 5; +const unsigned int SAMPLE_RATES[] = + { 8000, 11025, 22050, 44100, 48000 }; + +class QAudioDeviceInfoPrivate : public QAbstractAudioDeviceInfo +{ + Q_OBJECT +public: + QAudioDeviceInfoPrivate(QByteArray dev,QAudio::Mode mode); + ~QAudioDeviceInfoPrivate(); + + 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 deviceList(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; +}; + +#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..c94e0c4 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -0,0 +1,357 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 + + +QAudioDeviceInfoPrivate::QAudioDeviceInfoPrivate(QByteArray const& handle, QAudio::Mode) +{ + QDataStream ds(handle); + quint32 did, tm; + + ds >> did >> tm >> name; + deviceId = AudioDeviceID(did); + mode = QAudio::Mode(tm); +} + +bool QAudioDeviceInfoPrivate::isFormatSupported(const QAudioFormat& format) const +{ + return format.codec() == QString::fromLatin1("audio/pcm"); +} + +QAudioFormat QAudioDeviceInfoPrivate::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 QAudioDeviceInfoPrivate::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 QAudioDeviceInfoPrivate::deviceName() const +{ + return name; +} + +QStringList QAudioDeviceInfoPrivate::codecList() +{ + return QStringList() << QString::fromLatin1("audio/pcm"); +} + +QList QAudioDeviceInfoPrivate::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 QAudioDeviceInfoPrivate::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 QAudioDeviceInfoPrivate::sampleSizeList() +{ + return QList() << 8 << 16 << 24 << 32 << 64; +} + +QList QAudioDeviceInfoPrivate::byteOrderList() +{ + return QList() << QAudioFormat::LittleEndian << QAudioFormat::BigEndian; +} + +QList QAudioDeviceInfoPrivate::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 QAudioDeviceInfoPrivate::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 QAudioDeviceInfoPrivate::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 QAudioDeviceInfoPrivate::deviceList(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..ee593de --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 QAudioDeviceInfoPrivate : public QAbstractAudioDeviceInfo +{ +public: + AudioDeviceID deviceId; + QString name; + QAudio::Mode mode; + + QAudioDeviceInfoPrivate(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 deviceList(QAudio::Mode mode); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QDEVICEINFO_MAC_P_H diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp new file mode 100644 index 0000000..1a1995a --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -0,0 +1,378 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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" + +// 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 + + +QAudioDeviceInfoPrivate::QAudioDeviceInfoPrivate(QByteArray dev, QAudio::Mode mode) +{ + device = QLatin1String(dev); + this->mode = mode; +} + +QAudioDeviceInfoPrivate::~QAudioDeviceInfoPrivate() +{ + close(); +} + +bool QAudioDeviceInfoPrivate::isFormatSupported(const QAudioFormat& format) const +{ + return testSettings(format); +} + +QAudioFormat QAudioDeviceInfoPrivate::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(tr("audio/pcm")); + } else { + nearest.setFrequency(11025); + nearest.setChannels(1); + nearest.setSampleType(QAudioFormat::SignedInt); + nearest.setSampleSize(8); + nearest.setCodec(tr("audio/pcm")); + } + return nearest; +} + +QAudioFormat QAudioDeviceInfoPrivate::nearestFormat(const QAudioFormat& format) const +{ + if(testSettings(format)) + return format; + else + return preferredFormat(); +} + +QString QAudioDeviceInfoPrivate::deviceName() const +{ + return device; +} + +QStringList QAudioDeviceInfoPrivate::codecList() +{ + updateLists(); + return codecz; +} + +QList QAudioDeviceInfoPrivate::frequencyList() +{ + updateLists(); + return freqz; +} + +QList QAudioDeviceInfoPrivate::channelsList() +{ + updateLists(); + return channelz; +} + +QList QAudioDeviceInfoPrivate::sampleSizeList() +{ + updateLists(); + return sizez; +} + +QList QAudioDeviceInfoPrivate::byteOrderList() +{ + updateLists(); + return byteOrderz; +} + +QList QAudioDeviceInfoPrivate::sampleTypeList() +{ + updateLists(); + return typez; +} + + +bool QAudioDeviceInfoPrivate::open() +{ + return true; +} + +void QAudioDeviceInfoPrivate::close() +{ +} + +bool QAudioDeviceInfoPrivate::testSettings(const QAudioFormat& format) const +{ + // Set nearest to closest settings that do work. + // See if what is in settings will work (return value). + + bool testChannel = false; + bool testCodec = false; + bool testFreq = false; + + int err = 0; + + // For now, just accept only audio/pcm codec + if(!format.codec().startsWith(tr("audio/pcm"))) { + err=-1; + } else + testCodec = true; + + if(err>=0 && format.channels() != -1) { + testChannel = true; + } + + if(err>=0 && format.frequency() != -1) { + testFreq = true; + } + + if(err == 0) { + // settings work + return true; + } + return false; +} + +void QAudioDeviceInfoPrivate::updateLists() +{ + // redo all lists based on current settings + bool base = false; + bool match = false; + DWORD fmt = NULL; + QString tmp; + + if(device.compare(tr("default")) == 0) + base = true; + + if(mode == QAudio::AudioOutput) { + WAVEOUTCAPS woc; + unsigned long iNumDevs,i; + iNumDevs = waveOutGetNumDevs(); + for(i=0;i QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) +{ + Q_UNUSED(mode) + + QList devices; + + devices.append("default"); + + if(mode == QAudio::AudioOutput) { + WAVEOUTCAPS woc; + unsigned long iNumDevs,i; + iNumDevs = waveOutGetNumDevs(); + for(i=0;i +#include +#include +#include + +#include +#include + + +const unsigned int MAX_SAMPLE_RATES = 5; +const unsigned int SAMPLE_RATES[] = { 8000, 11025, 22050, 44100, 48000 }; + +class QAudioDeviceInfoPrivate : public QAbstractAudioDeviceInfo +{ + Q_OBJECT + +public: + QAudioDeviceInfoPrivate(QByteArray dev,QAudio::Mode mode); + ~QAudioDeviceInfoPrivate(); + + 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 deviceList(QAudio::Mode); + +private: + QAudio::Mode mode; + QString device; + QAudioFormat nearest; + QList freqz; + QList channelz; + QList sizez; + QList byteOrderz; + QStringList codecz; + QList typez; +}; + +#endif diff --git a/src/multimedia/audio/qaudioengine.cpp b/src/multimedia/audio/qaudioengine.cpp new file mode 100644 index 0000000..930977e --- /dev/null +++ b/src/multimedia/audio/qaudioengine.cpp @@ -0,0 +1,343 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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::totalTime() const + Returns the amount of audio data processed since start() was called in milliseconds. +*/ + +/*! + \fn virtual qint64 QAbstractAudioOutput::clock() 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::totalTime() const + Returns the amount of audio data processed since start() was called in milliseconds. +*/ + +/*! + \fn virtual qint64 QAbstractAudioInput::clock() 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..b0aa762 --- /dev/null +++ b/src/multimedia/audio/qaudioengine.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 totalTime() const = 0; + virtual qint64 clock() 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 totalTime() const = 0; + virtual qint64 clock() 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..6e39004 --- /dev/null +++ b/src/multimedia/audio/qaudioengineplugin.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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..8eab2d7 --- /dev/null +++ b/src/multimedia/audio/qaudioengineplugin.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 deviceList(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 deviceList(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..6632c63 --- /dev/null +++ b/src/multimedia/audio/qaudioformat.cpp @@ -0,0 +1,335 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + + +QT_BEGIN_NAMESPACE + + +class QAudioFormatPrivate : public QSharedData +{ +public: + QAudioFormatPrivate() + { + frequency = -1; + channels = -1; + sampleSize = -1; + byteOrder = QAudioFormat::Endian(QSysInfo::ByteOrder); + sampleType = QAudioFormat::Unknown; + } + + 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 Frequency + \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) + \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. +*/ + +/*! + Construct a new audio format. + + Values are initialized as follows: + \list + \o frequency() = -1 + \o channels() = -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 any of the parameters are invalid. +*/ + +bool QAudioFormat::isNull() const +{ + return d->frequency == -1 && d->channels == -1 && + d->sampleSize == -1 && + d->byteOrder == QAudioFormat::Endian(QSysInfo::ByteOrder) && + d->sampleType == QAudioFormat::Unknown && + d->codec.isNull(); +} + +/*! + Sets the frequency to \a frequency. +*/ + +void QAudioFormat::setFrequency(int frequency) +{ + d->frequency = frequency; +} + +/*! + Returns the current frequency value. +*/ + +int QAudioFormat::frequency() const +{ + return d->frequency; +} + +/*! + Sets the channels to \a channels. +*/ + +void QAudioFormat::setChannels(int channels) +{ + d->channels = channels; +} + +/*! + Returns the current channel value. +*/ + +int QAudioFormat::channels() const +{ + return d->channels; +} + +/*! + Sets the sampleSize to \a sampleSize. +*/ + +void QAudioFormat::setSampleSize(int sampleSize) +{ + d->sampleSize = sampleSize; +} + +/*! + Returns the current sampleSize value. +*/ + +int QAudioFormat::sampleSize() const +{ + return d->sampleSize; +} + +/*! + Sets the codec to \a codec. + + \sa QAudioDeviceInfo::supportedCodecs() +*/ + +void QAudioFormat::setCodec(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..c740969 --- /dev/null +++ b/src/multimedia/audio/qaudioformat.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 isNull() const; + + void setFrequency(int frequency); + int frequency() const; + + void setChannels(int channels); + int channels() const; + + void setSampleSize(int sampleSize); + int sampleSize() const; + + void setCodec(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..17cacc6 --- /dev/null +++ b/src/multimedia/audio/qaudioinput.cpp @@ -0,0 +1,400 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 QAudioDeviceId. 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 QAudioDeviceId 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; + 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); + + QAudioInput *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(); + } + \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 totalTime() + 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 clock() 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. + + \sa QAudioOutput, QAudioDeviceInfo +*/ + +/*! + 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 \a id of the audio input device is used with the input + \a format parameters. +*/ + +QAudioInput::QAudioInput(const QAudioDeviceId &id, const QAudioFormat &format, QObject *parent): + QObject(parent) +{ + d = QAudioDeviceFactory::createInputDevice(id, 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. + 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. + All that is required is to open the QIODevice. + + /sa QIODevice +*/ + +QIODevice* QAudioInput::start(QIODevice* device) +{ + /* + PULL MODE (valid QIODevice) + -If currently not StopState, stop + -If previous start was push mode, delete internal QIODevice. + -open audio input. + If ok, NoError and ActiveState, else OpenError and StopState. + -emit stateChanged() + -return device + + PUSH MODE (device = 0) + -If currently not StopState, stop + -If no internal QIODevice, create one. + -open audio input. + -If ok, NoError and IdleState, else OpenError and StopState + -emit stateChanged() + -return internal QIODevice + */ + return d->start(device); +} + +/*! + Returns the QAudioFormat being used. +*/ + +QAudioFormat QAudioInput::format() const +{ + return d->format(); +} + +/*! + Stops the audio input. +*/ + +void QAudioInput::stop() +{ + /* + -If StopState, return + -set to StopState + -detach from audio device + -emit stateChanged() + */ + d->stop(); +} + +/*! + Drops all audio data in the buffers, resets buffers to zero. +*/ + +void QAudioInput::reset() +{ + /* + -drop all buffered audio, set buffers to zero. + -call stop() + */ + d->reset(); +} + +/*! + Stops processing audio data, preserving buffered audio data. +*/ + +void QAudioInput::suspend() +{ + /* + -If not ActiveState|IdleState, return + -stop processing audio, saving all buffered audio data + -set NoError and SuspendState + -emit stateChanged() + */ + d->suspend(); +} + +/*! + Resumes processing audio data after a suspend(). +*/ + +void QAudioInput::resume() +{ + /* + -If SuspendState, return + -resume audio + -(PULL MODE): set ActiveState, NoError + -(PUSH MODE): set IdleState, NoError + -kick start audio if needed + -emit stateChanged() + */ + 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. +*/ + +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 resolution of the timer is platform specific. +*/ + +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::totalTime() const +{ + return d->totalTime(); +} + +/*! + Returns the microseconds since start() was called, including time in Idle and + Suspend states. +*/ + +qint64 QAudioInput::clock() const +{ + return d->clock(); +} + +/*! + 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..b0f1aed --- /dev/null +++ b/src/multimedia/audio/qaudioinput.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 QAudioDeviceId &id, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + ~QAudioInput(); + + QAudioFormat format() const; + + QIODevice* start(QIODevice *device = 0); + 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 totalTime() const; + qint64 clock() 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..6f00469 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -0,0 +1,688 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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" + +//#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::StopState; + audioSource = 0; + pullMode = true; + resuming = false; + + QStringList list1 = QString(tr(device)).split(tr(":")); + m_device = QByteArray(list1.at(0).toLocal8Bit().constData()); + + 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 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::StopState) + close(); + + if(!pullMode && audioSource) { + delete audioSource; + } + + if(device) { + //set to pull mode + pullMode = true; + audioSource = device; + } else { + //set to push mode + pullMode = false; + 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::StopState) + return; + + deviceState = QAudio::StopState; + + close(); + emit stateChanged(deviceState); +} + +bool QAudioInputPrivate::open() +{ +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()<start(period_time*chunks/2000); + + errorState = QAudio::NoError; + deviceState = QAudio::ActiveState; + + totalTimeValue = 0; + + return true; +} + +void QAudioInputPrivate::close() +{ + deviceState = QAudio::StopState; + 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) + 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 QAudioInputPrivate::read(char* data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + // Read in some audio data and write it to QIODevice, pull mode + if ( !handle ) + return 0; + + bytesAvailable = bytesReady(); + + 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()<<"PULL: 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::StopState; + emit stateChanged(deviceState); + } else if(l == 0) { + errorState = QAudio::NoError; + deviceState = QAudio::IdleState; + } else { + totalTimeValue += snd_pcm_bytes_to_frames(handle, err)*1000000/settings.frequency(); + resuming = false; + errorState = QAudio::NoError; + deviceState = QAudio::ActiveState; + } + return l; + } + return 0; +} + +void QAudioInputPrivate::resume() +{ + if(deviceState == QAudio::SuspendState) { + 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(buffer_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 = ms; +} + +int QAudioInputPrivate::notifyInterval() const +{ + return intervalTime; +} + +qint64 QAudioInputPrivate::totalTime() const +{ + return totalTimeValue; +} + +void QAudioInputPrivate::suspend() +{ + if(deviceState == QAudio::ActiveState||resuming) { + timer->stop(); + deviceState = QAudio::SuspendState; + emit stateChanged(deviceState); + } +} + +void QAudioInputPrivate::userFeed() +{ + if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState) + return; +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()<(audioSource); + a->trigger(); + } + bytesAvailable = bytesReady(); + + if(deviceState != QAudio::ActiveState) + return true; + + if(timeStamp.elapsed() > intervalTime && intervalTime > 50) { + emit notify(); + timeStamp.restart(); + } + return true; +} + +qint64 QAudioInputPrivate::clock() const +{ + if(!handle) + return 0; + + if(deviceState != QAudio::ActiveState) + return 0; + + snd_pcm_status_t* status; + snd_pcm_status_alloca(&status); + + snd_timestamp_t t1,t2; + if( snd_pcm_status(handle, status) >= 0) { + snd_pcm_status_get_tstamp(status,&t1); + snd_pcm_status_get_trigger_tstamp(status,&t2); + t1.tv_sec-=t2.tv_sec; + + signed long l = (signed long)t1.tv_usec - (signed long)t2.tv_usec; + if(l < 0) { + t1.tv_sec--; + l = -l; + l %= 1000000; + } + return ((t1.tv_sec * 1000)+l/1000); + } else + return 0; +} + +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) +{ + // push mode, user read() called + if((audioDevice->state() != QAudio::ActiveState) && !audioDevice->resuming) + return 0; + + int readFrames; + int count=0, err = 0; + + while(count < 5) { + int frames = snd_pcm_bytes_to_frames(audioDevice->handle, len); + readFrames = snd_pcm_readi(audioDevice->handle, data, frames); + if (readFrames >= 0) { + err = snd_pcm_frames_to_bytes(audioDevice->handle, readFrames); +#ifdef DEBUG_AUDIO + qDebug()<errorState = QAudio::IOError; + err = 0; + break; + } else { + if(readFrames == -EPIPE) { + audioDevice->errorState = QAudio::UnderrunError; + err = snd_pcm_prepare(audioDevice->handle); + } else if(readFrames == -ESTRPIPE) { + err = snd_pcm_prepare(audioDevice->handle); + } + if(err != 0) break; + } + count++; + } + if(err > 0 && readFrames > 0) { + audioDevice->totalTimeValue += readFrames*1000/audioDevice->settings.frequency()*1000; + audioDevice->deviceState = QAudio::ActiveState; + return err; + } + return 0; +} + +qint64 InputPrivate::writeData(const char* data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + return 0; +} + +void InputPrivate::trigger() +{ + emit readyRead(); +} + diff --git a/src/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/audio/qaudioinput_alsa_p.h new file mode 100644 index 0000000..21c8064 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_alsa_p.h @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 + +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 totalTime() const; + qint64 clock() 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; + QTime timeStamp; + 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; +}; + +#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..5400c85 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -0,0 +1,930 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 "qaudio_mac_p.h" +#include "qaudioinput_mac_p.h" + + +QT_BEGIN_NAMESPACE + + +namespace +{ + +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; + } + +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_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 (inputFormat.mSampleRate != outputFormat.mSampleRate) { + 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) + { + 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 { + isOpen = false; + audioDeviceId = AudioDeviceID(did); + audioUnit = 0; + startTime = 0; + totalFrames = 0; + audioBuffer = 0; + internalBufferSize = default_buffer_size; + clockFrequency = AudioGetHostClockFrequency() / 1000; + errorCode = QAudio::NoError; + stateCode = QAudio::StopState; + + intervalTimer = new QTimer(this); + intervalTimer->setInterval(1000); + connect(intervalTimer, SIGNAL(timeout()), SIGNAL(notify())); + } +} + +QAudioInputPrivate::~QAudioInputPrivate() +{ + close(); +} + +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: Unabled 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: Unabled 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 + streamFormat = toAudioStreamBasicDescription(audioFormat); + + size = sizeof(deviceFormat); + if (AudioUnitGetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 1, + &deviceFormat, + &size) != noErr) { + qWarning() << "QAudioInput: Unable to retrieve device format"; + return false; + } + + // If the device frequency is different to the requested use a converter + if (deviceFormat.mSampleRate != streamFormat.mSampleRate) { + AudioUnitSetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Output, + 1, + &deviceFormat, + sizeof(streamFormat)); + } + else { + AudioUnitSetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Output, + 1, + &streamFormat, + sizeof(streamFormat)); + } + + // 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.mSampleRate / deviceFormat.mSampleRate) * + streamFormat.mBytesPerFrame; + if (internalBufferSize < periodSizeBytes * 2) + internalBufferSize = periodSizeBytes * 2; + else + internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; + + audioBuffer = new QAudioInputBuffer(internalBufferSize, + periodSizeBytes, + deviceFormat, + streamFormat, + this); + + audioIO = new 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 (!open()) { + stateCode = QAudio::StopState; + errorCode = QAudio::OpenError; + return audioIO; + } + + reset(); + audioBuffer->reset(); + audioBuffer->setFlushDevice(op); + + if (op == 0) + op = audioIO; + + // Start + startTime = AudioGetCurrentHostTime(); + totalFrames = 0; + + audioThreadStart(); + + return op; +} + +void QAudioInputPrivate::stop() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StopState) { + audioThreadStop(); + audioBuffer->flush(true); + + errorCode = QAudio::NoError; + stateCode = QAudio::StopState; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioInputPrivate::reset() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StopState) { + audioThreadStop(); + + errorCode = QAudio::NoError; + stateCode = QAudio::StopState; + 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::SuspendState; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioInputPrivate::resume() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::SuspendState) { + 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) +{ + intervalTimer->setInterval(milliSeconds); +} + +int QAudioInputPrivate::notifyInterval() const +{ + return intervalTimer->interval(); +} + +qint64 QAudioInputPrivate::totalTime() const +{ + return totalFrames * 1000000 / audioFormat.frequency(); +} + +qint64 QAudioInputPrivate::clock() const +{ + 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::StopState; + QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); + } +} + +void QAudioInputPrivate::startTimers() +{ + audioBuffer->startFlushTimer(); + 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..98ef9ce --- /dev/null +++ b/src/multimedia/audio/qaudioinput_mac_p.h @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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; + +namespace +{ +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; + QAudioInputBuffer* audioBuffer; + QMutex mutex; + QWaitCondition threadFinished; + QAtomicInt audioThreadState; + QTimer* intervalTimer; + AudioStreamBasicDescription streamFormat; + AudioStreamBasicDescription deviceFormat; + + 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 totalTime() const; + qint64 clock() const; + + QAudio::Error error() const; + QAudio::State state() const; + + void audioThreadStart(); + void audioThreadStop(); + + void audioDeviceStop(); + void audioDeviceFull(); + void audioDeviceError(); + + void startTimers(); + void stopTimers(); + +signals: + void stateChanged(QAudio::State); + void notify(); + +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_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp new file mode 100644 index 0000000..e5b6e0d --- /dev/null +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -0,0 +1,540 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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" + +//#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::StopState; + audioSource = 0; + pullMode = true; + resuming = false; + + connect(this,SIGNAL(processMore()),SLOT(deviceReady())); + + InitializeCriticalSection(&waveInCriticalSection); +} + +QAudioInputPrivate::~QAudioInputPrivate() +{ + close(); + DeleteCriticalSection(&waveInCriticalSection); +} + +void 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; + + switch(uMsg) { + case WIM_OPEN: + break; + case WIM_DATA: + EnterCriticalSection(&waveInCriticalSection); + if(qAudio->waveFreeBlockCount > 0) + qAudio->waveFreeBlockCount--; + LeaveCriticalSection(&waveInCriticalSection); + qAudio->feedback(); + break; + case WIM_CLOSE: + 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) +{ + 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::StopState) + close(); + + if(!pullMode && audioSource) { + delete audioSource; + } + + if(device) { + //set to pull mode + pullMode = true; + audioSource = device; + } else { + //set to push mode + pullMode = false; + 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::StopState) + return; + + deviceState = QAudio::StopState; + + 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) { + if(pullMode) { + l = audioSource->write(waveBlocks[header].lpData, + waveBlocks[header].dwBytesRecorded); +#ifdef DEBUG_AUDIO + qDebug()<<"IN: "<= buffer_size/period_size) + header = 0; + p+=l; + + if(!pullMode) { + if(l+period_size > len && waveFreeBlockCount == buffer_size/period_size) + done = true; + } else { + if(waveFreeBlockCount == buffer_size/period_size) + done = true; + } + written+=l; + } +#ifdef DEBUG_AUDIO + qDebug()<<"read in len="<(audioSource); + a->trigger(); + } + if(deviceState != QAudio::ActiveState) + return true; + + if(timeStamp.elapsed() > intervalTime && intervalTime > 50) { + emit notify(); + timeStamp.restart(); + } + return true; +} + +qint64 QAudioInputPrivate::clock() const +{ + if(deviceState != QAudio::ActiveState) + return 0; + + return timeStampOpened.elapsed(); +} + +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) + 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(); +} + diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h new file mode 100644 index 0000000..32464f0 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_win32_p.h @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 + + +static CRITICAL_SECTION waveInCriticalSection; + +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 totalTime() const; + qint64 clock() 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; + QTime timeStampOpened; + qint64 totalTimeValue; + bool pullMode; + bool resuming; + WAVEFORMATEX wfx; + HWAVEIN hWaveIn; + MMRESULT result; + WAVEHDR* waveBlocks; + volatile int waveFreeBlockCount; + int waveCurrentBlock; + + static void 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; +}; + +#endif diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp new file mode 100644 index 0000000..785da61 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -0,0 +1,403 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 QAudioDeviceId. 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; + 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); + + QAudioOutput *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(); + } + } + \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, clock() 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. + + If an error is encountered state changes to QAudio::StopState. + + \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 \a id of the audio output device is used with the output + \a format parameters. +*/ + +QAudioOutput::QAudioOutput(const QAudioDeviceId &id, const QAudioFormat &format, QObject *parent): + QObject(parent) +{ + d = QAudioDeviceFactory::createOutputDevice(id, 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. + 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. + All that is required is to open the QIODevice. + + /sa QIODevice +*/ + +QIODevice* QAudioOutput::start(QIODevice* device) +{ + /* + PULL MODE (valid QIODevice) + -If currently not StopState, stop. + -If previous start was push mode, delete internal QIODevice. + -open audio output. + -If ok, NoError and ActiveState, else OpenError and StopState + -emit stateChanged() + -return device + + PUSH MODE (device = 0) + -If currently not StopState, stop. + -If no internal QIODevice, create one. + -open audio output. + -If ok, NoError and IdleState, else OpenError and StopState + -emit stateChanged() + -return internal QIODevice + */ + return d->start(device); +} + +/*! + Stops the audio output. +*/ + +void QAudioOutput::stop() +{ + /* + -If StopState, return + -set to StopState + -detach from audio device + -emit stateChanged() + */ + d->stop(); +} + +/*! + Drops all audio data in the buffers, resets buffers to zero. +*/ + +void QAudioOutput::reset() +{ + /* + -drop all buffered audio, set buffers to zero. + -call stop() + */ + d->reset(); +} + +/*! + Stops processing audio data, preserving buffered audio data. +*/ + +void QAudioOutput::suspend() +{ + /* + -If not ActiveState|IdleState, return + -stop processing audio, saving all buffered audio data + -set NoError and SuspendState + -emit stateChanged() + */ + d->suspend(); +} + +/*! + Resumes processing audio data after a suspend(). +*/ + +void QAudioOutput::resume() +{ + /* + -If SuspendState, return + -resume audio + -(PULL MODE): set ActiveState, NoError + -(PUSH MODE): set IdleState, NoError + -kick start audio if needed + -emit stateChanged() + */ + d->resume(); +} + +/*! + Returns the free space available in bytes in the audio buffer. +*/ + +int QAudioOutput::bytesFree() const +{ + /* + -If not ActiveState|IdleState, return 0 + -return space available in audio buffer in bytes + */ + 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 resolution of the timer is platform specific. +*/ + +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::totalTime() const +{ + return d->totalTime(); +} + +/*! + Returns the microseconds since start() was called, including time in Idle and + Suspend states. +*/ + +qint64 QAudioOutput::clock() const +{ + return d->clock(); +} + +/*! + 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..95e28ea --- /dev/null +++ b/src/multimedia/audio/qaudiooutput.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 QAudioDeviceId &id, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + ~QAudioOutput(); + + QAudioFormat format() const; + + QIODevice* start(QIODevice *device = 0); + 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 totalTime() const; + qint64 clock() 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..d41c449 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -0,0 +1,706 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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" + +//#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::StopState; + audioSource = 0; + pullMode = true; + resuming = false; + opened = false; + + QStringList list1 = QString(tr(device)).split(tr(":")); + m_device = QByteArray(list1.at(0).toLocal8Bit().constData()); + + 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::StopState) + deviceState = QAudio::StopState; + + 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::StopState) + return; + deviceState = QAudio::StopState; + close(); + emit stateChanged(deviceState); +} + +bool QAudioOutputPrivate::open() +{ + if(opened) + return true; + +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()<start(period_time/1000); + + errorState = QAudio::NoError; + totalTimeValue = 0; + opened = true; + + return true; +} + +void QAudioOutputPrivate::close() +{ + deviceState = QAudio::StopState; + 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*1000000/settings.frequency(); + resuming = false; + errorState = QAudio::NoError; + deviceState = QAudio::ActiveState; + return snd_pcm_frames_to_bytes( handle, err ); + } else + err = xrun_recovery(err); + + if(err < 0) { + close(); + errorState = QAudio::FatalError; + deviceState = QAudio::StopState; + emit stateChanged(deviceState); + } + return 0; +} + +int QAudioOutputPrivate::periodSize() const +{ + return period_size; +} + +void QAudioOutputPrivate::setBufferSize(int value) +{ + if(deviceState == QAudio::StopState) + buffer_size = value; +} + +int QAudioOutputPrivate::bufferSize() const +{ + return buffer_size; +} + +void QAudioOutputPrivate::setNotifyInterval(int ms) +{ + intervalTime = ms; +} + +int QAudioOutputPrivate::notifyInterval() const +{ + return intervalTime; +} + +qint64 QAudioOutputPrivate::totalTime() const +{ + return totalTimeValue; +} + +void QAudioOutputPrivate::resume() +{ + if(deviceState == QAudio::SuspendState) { + 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; + if(pullMode) + deviceState = QAudio::ActiveState; + else + deviceState = QAudio::IdleState; + + 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::SuspendState; + errorState = QAudio::NoError; + emit stateChanged(deviceState); + } +} + +void QAudioOutputPrivate::userFeed() +{ + if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState) + 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(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: + 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 = default_buffer_size; + clockFrequency = AudioGetHostClockFrequency() / 1000; + errorCode = QAudio::NoError; + stateCode = QAudio::StopState; + 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 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 (!open()) { + stateCode = QAudio::StopState; + 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(); + + return op; +} + +void QAudioOutputPrivate::stop() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StopState) { + audioThreadDrain(); + + stateCode = QAudio::StopState; + errorCode = QAudio::NoError; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioOutputPrivate::reset() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StopState) { + audioThreadStop(); + + stateCode = QAudio::StopState; + 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::SuspendState; + errorCode = QAudio::NoError; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioOutputPrivate::resume() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::SuspendState) { + 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::StopState) + internalBufferSize = bs; +} + +int QAudioOutputPrivate::bufferSize() const +{ + return internalBufferSize; +} + +void QAudioOutputPrivate::setNotifyInterval(int milliSeconds) +{ + intervalTimer->setInterval(milliSeconds); +} + +int QAudioOutputPrivate::notifyInterval() const +{ + return intervalTimer->interval(); +} + +qint64 QAudioOutputPrivate::totalTime() const +{ + return totalFrames * 1000000 / audioFormat.frequency(); +} + +qint64 QAudioOutputPrivate::clock() const +{ + 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::StopState; + QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); + } +} + +void QAudioOutputPrivate::startTimers() +{ + audioBuffer->startFillTimer(); + 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..c85cab4 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_mac_p.h @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 +{ +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; + 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 totalTime() const; + qint64 clock() 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(); + +signals: + void stateChanged(QAudio::State); + void notify(); + +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_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp new file mode 100644 index 0000000..f681936 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -0,0 +1,502 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 + +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::StopState; + audioSource = 0; + pullMode = true; + InitializeCriticalSection(&waveOutCriticalSection); +} + +QAudioOutputPrivate::~QAudioOutputPrivate() +{ + close(); + DeleteCriticalSection(&waveOutCriticalSection); +} + +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; + + switch(uMsg) { + case WOM_OPEN: + qAudio->feedback(); + break; + case WOM_CLOSE: + return; + case WOM_DONE: + EnterCriticalSection(&waveOutCriticalSection); + qAudio->waveFreeBlockCount++; + if(qAudio->waveFreeBlockCount >= qAudio->buffer_size/qAudio->period_size) + qAudio->waveFreeBlockCount = qAudio->buffer_size/qAudio->period_size; + LeaveCriticalSection(&waveOutCriticalSection); + 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) +{ + HeapFree(GetProcessHeap(), 0, blockArray); +} + +QAudioFormat QAudioOutputPrivate::format() const +{ + return settings; +} + +QIODevice* QAudioOutputPrivate::start(QIODevice* device) +{ + if(deviceState != QAudio::StopState) + 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::StopState) + return; + deviceState = QAudio::StopState; + close(); + if(!pullMode && audioSource) { + delete audioSource; + audioSource = 0; + } + emit stateChanged(deviceState); +} + +bool QAudioOutputPrivate::open() +{ +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()<> 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) { + if(waveFreeBlockCount==0) + break; + + 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)); + + EnterCriticalSection(&waveOutCriticalSection); + waveFreeBlockCount--; + LeaveCriticalSection(&waveOutCriticalSection); +#ifdef DEBUG_AUDIO + qDebug("write out l=%d, waveFreeBlockCount=%d", + current->dwBufferLength,waveFreeBlockCount); +#endif + totalTimeValue += current->dwBufferLength + /(settings.channels()*(settings.sampleSize()/8)) + *1000000/settings.frequency();; + waveCurrentBlock++; + waveCurrentBlock %= buffer_size/period_size; + current = &waveBlocks[waveCurrentBlock]; + current->dwUser = 0; + } + return (len-l); +} + +void QAudioOutputPrivate::resume() +{ + if(deviceState == QAudio::SuspendState) { + deviceState = QAudio::ActiveState; + errorState = QAudio::NoError; + waveOutRestart(hWaveOut); + QTimer::singleShot(10, this, SLOT(feedback())); + emit stateChanged(deviceState); + } +} + +void QAudioOutputPrivate::suspend() +{ + if(deviceState == QAudio::ActiveState) { + waveOutPause(hWaveOut); + deviceState = QAudio::SuspendState; + 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(pullMode) { + int i = 0; + int chunks = bytesAvailable/period_size; +#ifdef DEBUG_AUDIO + qDebug()<<"deviceReady() avail="< +#include +#include +#include + +#include +#include + + +class tst_QAudioDeviceId : public QObject +{ + Q_OBJECT + +public: + tst_QAudioDeviceId(QObject* parent=0) : QObject(parent) {} + +private slots: + void checkNull(); + void checkEquality(); +}; + +void tst_QAudioDeviceId::checkNull() +{ + // Default constructed is null. + QAudioDeviceId deviceId0; + QVERIFY(deviceId0.isNull()); + + // Null is transferred + QAudioDeviceId deviceId1(deviceId0); + QVERIFY(deviceId1.isNull()); +} + +void tst_QAudioDeviceId::checkEquality() +{ + QAudioDeviceId deviceId0; + QAudioDeviceId deviceId1; + + // Null ids are equivalent + QVERIFY(deviceId0 == deviceId1); + QVERIFY(!(deviceId0 != deviceId1)); + + deviceId1 = QAudioDeviceInfo::defaultOutputDevice(); + + // Different + QVERIFY(deviceId0 != deviceId1); + QVERIFY(!(deviceId0 == deviceId1)); + + // Same + deviceId0 = deviceId1; + + QVERIFY(deviceId0 == deviceId1); + QVERIFY(!(deviceId0 != deviceId1)); +} + +QTEST_MAIN(tst_QAudioDeviceId) + +#include "tst_qaudiodeviceid.moc" diff --git a/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro b/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro new file mode 100644 index 0000000..695987c --- /dev/null +++ b/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro @@ -0,0 +1,7 @@ +load(qttest_p4) + +DEFINES += SRCDIR=\\\"$$PWD/\\\" + +SOURCES += tst_qaudiodeviceinfo.cpp + +QT = core multimedia diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp new file mode 100644 index 0000000..c2cd97e --- /dev/null +++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include + +#include +#include + + +class tst_QAudioDeviceInfo : public QObject +{ + Q_OBJECT +public: + tst_QAudioDeviceInfo(QObject* parent=0) : QObject(parent) {} + +private slots: + void checkAvailableDefaultInput(); + void checkAvailableDefaultOutput(); + void outputList(); + void codecs(); + void channels(); + void sampleSizes(); + void byteOrders(); + void sampleTypes(); + void frequencies(); + void isformat(); + void preferred(); + void nearest(); + +private: + QAudioDeviceInfo* device; +}; + +void tst_QAudioDeviceInfo::checkAvailableDefaultInput() +{ + QVERIFY(!QAudioDeviceInfo::defaultInputDevice().isNull()); +} + +void tst_QAudioDeviceInfo::checkAvailableDefaultOutput() +{ + QVERIFY(!QAudioDeviceInfo::defaultOutputDevice().isNull()); +} + +void tst_QAudioDeviceInfo::outputList() +{ + QList devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + QVERIFY(devices.size() > 0); + device = new QAudioDeviceInfo(devices.at(0), this); +} + +void tst_QAudioDeviceInfo::codecs() +{ + QStringList avail = device->supportedCodecs(); + QVERIFY(avail.size() > 0); +} + +void tst_QAudioDeviceInfo::channels() +{ + QList avail = device->supportedChannels(); + QVERIFY(avail.size() > 0); +} + +void tst_QAudioDeviceInfo::sampleSizes() +{ + QList avail = device->supportedSampleSizes(); + QVERIFY(avail.size() > 0); +} + +void tst_QAudioDeviceInfo::byteOrders() +{ + QList avail = device->supportedByteOrders(); + QVERIFY(avail.size() > 0); +} + +void tst_QAudioDeviceInfo::sampleTypes() +{ + QList avail = device->supportedSampleTypes(); + QVERIFY(avail.size() > 0); +} + +void tst_QAudioDeviceInfo::frequencies() +{ + QList avail = device->supportedFrequencies(); + QVERIFY(avail.size() > 0); +} + +void tst_QAudioDeviceInfo::isformat() +{ + QAudioFormat format; + format.setFrequency(44100); + format.setChannels(2); + format.setSampleType(QAudioFormat::SignedInt); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setSampleSize(16); + format.setCodec("audio/pcm"); + + // Should always be true for these format + QVERIFY(device->isFormatSupported(format)); +} + +void tst_QAudioDeviceInfo::preferred() +{ + QAudioFormat format = device->preferredFormat(); + QVERIFY(format.frequency() == 44100); + QVERIFY(format.channels() == 2); +} + +void tst_QAudioDeviceInfo::nearest() +{ + QAudioFormat format1, format2; + format1.setFrequency(8000); + format2 = device->nearestFormat(format1); + QVERIFY(format2.frequency() == 44100); +} + +QTEST_MAIN(tst_QAudioDeviceInfo) + +#include "tst_qaudiodeviceinfo.moc" diff --git a/tests/auto/qaudioformat/qaudioformat.pro b/tests/auto/qaudioformat/qaudioformat.pro new file mode 100644 index 0000000..78962d7 --- /dev/null +++ b/tests/auto/qaudioformat/qaudioformat.pro @@ -0,0 +1,7 @@ +load(qttest_p4) + +DEFINES += SRCDIR=\\\"$$PWD/\\\" + +SOURCES += tst_qaudioformat.cpp + +QT = core multimedia diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp new file mode 100644 index 0000000..bcfc78f --- /dev/null +++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include + +#include +#include + + +class tst_QAudioFormat : public QObject +{ + Q_OBJECT + +public: + tst_QAudioFormat(QObject* parent=0) : QObject(parent) {} + +private slots: + void checkNull(); + void checkFrequency(); + void checkChannels(); + void checkSampleSize(); + void checkCodec(); + void checkByteOrder(); + void checkSampleType(); + void checkEquality(); + void checkAssignment(); +}; + +void tst_QAudioFormat::checkNull() +{ + // Default constructed QAudioFormat is null. + QAudioFormat audioFormat0; + QVERIFY(audioFormat0.isNull()); + + // Null is transferred + QAudioFormat audioFormat1(audioFormat0); + QVERIFY(audioFormat1.isNull()); + + // Null is voided on activity + audioFormat0.setFrequency(44100); + QVERIFY(!audioFormat0.isNull()); +} + +void tst_QAudioFormat::checkFrequency() +{ + QAudioFormat audioFormat; + audioFormat.setFrequency(44100); + QVERIFY(audioFormat.frequency() == 44100); +} + +void tst_QAudioFormat::checkChannels() +{ + QAudioFormat audioFormat; + audioFormat.setChannels(2); + QVERIFY(audioFormat.channels() == 2); +} + +void tst_QAudioFormat::checkSampleSize() +{ + QAudioFormat audioFormat; + audioFormat.setSampleSize(16); + QVERIFY(audioFormat.sampleSize() == 16); +} + +void tst_QAudioFormat::checkCodec() +{ + QAudioFormat audioFormat; + audioFormat.setCodec(QString::fromLatin1("audio/pcm")); + QVERIFY(audioFormat.codec() == QString::fromLatin1("audio/pcm")); +} + +void tst_QAudioFormat::checkByteOrder() +{ + QAudioFormat audioFormat; + audioFormat.setByteOrder(QAudioFormat::LittleEndian); + QVERIFY(audioFormat.byteOrder() == QAudioFormat::LittleEndian); +} + +void tst_QAudioFormat::checkSampleType() +{ + QAudioFormat audioFormat; + audioFormat.setSampleType(QAudioFormat::SignedInt); + QVERIFY(audioFormat.sampleType() == QAudioFormat::SignedInt); +} + +void tst_QAudioFormat::checkEquality() +{ + QAudioFormat audioFormat0; + QAudioFormat audioFormat1; + + // Null formats are equivalent + QVERIFY(audioFormat0 == audioFormat1); + QVERIFY(!(audioFormat0 != audioFormat1)); + + // on filled formats + audioFormat0.setFrequency(8000); + audioFormat0.setChannels(1); + audioFormat0.setSampleSize(8); + audioFormat0.setCodec("audio/pcm"); + audioFormat0.setByteOrder(QAudioFormat::LittleEndian); + audioFormat0.setSampleType(QAudioFormat::UnSignedInt); + + audioFormat1.setFrequency(8000); + audioFormat1.setChannels(1); + audioFormat1.setSampleSize(8); + audioFormat1.setCodec("audio/pcm"); + audioFormat1.setByteOrder(QAudioFormat::LittleEndian); + audioFormat1.setSampleType(QAudioFormat::UnSignedInt); + + QVERIFY(audioFormat0 == audioFormat1); + QVERIFY(!(audioFormat0 != audioFormat1)); + + audioFormat0.setFrequency(44100); + QVERIFY(audioFormat0 != audioFormat1); + QVERIFY(!(audioFormat0 == audioFormat1)); +} + +void tst_QAudioFormat::checkAssignment() +{ + QAudioFormat audioFormat0; + QAudioFormat audioFormat1; + + audioFormat0.setFrequency(8000); + audioFormat0.setChannels(1); + audioFormat0.setSampleSize(8); + audioFormat0.setCodec("audio/pcm"); + audioFormat0.setByteOrder(QAudioFormat::LittleEndian); + audioFormat0.setSampleType(QAudioFormat::UnSignedInt); + + audioFormat1 = audioFormat0; + QVERIFY(audioFormat1 == audioFormat0); + + QAudioFormat audioFormat2(audioFormat0); + QVERIFY(audioFormat2 == audioFormat0); +} + +QTEST_MAIN(tst_QAudioFormat) + +#include "tst_qaudioformat.moc" diff --git a/tests/auto/qaudioinput/qaudioinput.pro b/tests/auto/qaudioinput/qaudioinput.pro new file mode 100644 index 0000000..8a03749 --- /dev/null +++ b/tests/auto/qaudioinput/qaudioinput.pro @@ -0,0 +1,7 @@ +load(qttest_p4) + +DEFINES += SRCDIR=\\\"$$PWD/\\\" + +SOURCES += tst_qaudioinput.cpp + +QT = core multimedia diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp new file mode 100644 index 0000000..6e16320 --- /dev/null +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + + +class tst_QAudioInput : public QObject +{ + Q_OBJECT +public: + tst_QAudioInput(QObject* parent=0) : QObject(parent) {} + +private slots: + void initTestCase(); + void settings(); + void notifyInterval(); + void pullFile(); + +private: + QAudioFormat format; + QAudioInput* audio; +}; + +void tst_QAudioInput::initTestCase() +{ + format.setFrequency(8000); + format.setChannels(1); + format.setSampleSize(8); + format.setCodec("audio/pcm"); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setSampleType(QAudioFormat::UnSignedInt); + + audio = new QAudioInput(format, this); +} + +void tst_QAudioInput::settings() +{ + QAudioFormat f = audio->format(); + + QVERIFY(format.channels() == f.channels()); + QVERIFY(format.frequency() == f.frequency()); + QVERIFY(format.sampleSize() == f.sampleSize()); + QVERIFY(format.codec() == f.codec()); + QVERIFY(format.byteOrder() == f.byteOrder()); + QVERIFY(format.sampleType() == f.sampleType()); +} + +void tst_QAudioInput::notifyInterval() +{ + QVERIFY(audio->notifyInterval() == 1000); // Default + + audio->setNotifyInterval(500); + QVERIFY(audio->notifyInterval() == 500); // Custom + + audio->setNotifyInterval(1000); // reset +} + +void tst_QAudioInput::pullFile() +{ + QFile filename(SRCDIR "test.raw"); + filename.open( QIODevice::WriteOnly | QIODevice::Truncate ); + + QSignalSpy readSignal(audio, SIGNAL(notify())); + audio->start(&filename); + + QTest::qWait(5000); + + QVERIFY(readSignal.count() > 0); + QVERIFY(audio->totalTime() > 0); + + audio->stop(); + filename.close(); +} + +QTEST_MAIN(tst_QAudioInput) + +#include "tst_qaudioinput.moc" diff --git a/tests/auto/qaudiooutput/4.wav b/tests/auto/qaudiooutput/4.wav new file mode 100644 index 0000000..e31b0609 Binary files /dev/null and b/tests/auto/qaudiooutput/4.wav differ diff --git a/tests/auto/qaudiooutput/qaudiooutput.pro b/tests/auto/qaudiooutput/qaudiooutput.pro new file mode 100644 index 0000000..6c07c64 --- /dev/null +++ b/tests/auto/qaudiooutput/qaudiooutput.pro @@ -0,0 +1,12 @@ +load(qttest_p4) + +DEFINES += SRCDIR=\\\"$$PWD/\\\" + +SOURCES += tst_qaudiooutput.cpp + +QT = core multimedia + +wince*: { + deploy.sources += 4.wav + DEPLOYMENT = deploy +} diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp new file mode 100644 index 0000000..0f94faa --- /dev/null +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + + +#include +#include +#include +#include +#include +#include + + +class tst_QAudioOutput : public QObject +{ + Q_OBJECT +public: + tst_QAudioOutput(QObject* parent=0) : QObject(parent) {} + +private slots: + void initTestCase(); + void settings(); + void notifyInterval(); + void pullFile(); + void pushFile(); + +private: + QAudioFormat format; + QAudioOutput* audio; +}; + +void tst_QAudioOutput::initTestCase() +{ + format.setFrequency(8000); + format.setChannels(1); + format.setSampleSize(8); + format.setCodec("audio/pcm"); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setSampleType(QAudioFormat::UnSignedInt); + + audio = new QAudioOutput(format, this); +} + +void tst_QAudioOutput::settings() +{ + QAudioFormat f = audio->format(); + + QVERIFY(format.channels() == f.channels()); + QVERIFY(format.frequency() == f.frequency()); + QVERIFY(format.sampleSize() == f.sampleSize()); + QVERIFY(format.codec() == f.codec()); + QVERIFY(format.byteOrder() == f.byteOrder()); + QVERIFY(format.sampleType() == f.sampleType()); +} + +void tst_QAudioOutput::notifyInterval() +{ + QVERIFY(audio->notifyInterval() == 1000); // Default + + audio->setNotifyInterval(500); + QVERIFY(audio->notifyInterval() == 500); // Custom + + audio->setNotifyInterval(1000); // reset +} + +void tst_QAudioOutput::pullFile() +{ + QFile filename(SRCDIR "4.wav"); + QVERIFY(filename.exists()); + filename.open(QIODevice::ReadOnly); + + QSignalSpy readSignal(audio, SIGNAL(notify())); + audio->setNotifyInterval(100); + audio->start(&filename); + + QTestEventLoop::instance().enterLoop(1); + // 4.wav is a little less than 700ms, so notify should fire 6 times! + QVERIFY(readSignal.count() >= 6); + QVERIFY(audio->totalTime() == 692250); + + audio->stop(); + filename.close(); +} + +void tst_QAudioOutput::pushFile() +{ + QFile filename(SRCDIR "4.wav"); + QVERIFY(filename.exists()); + filename.open(QIODevice::ReadOnly); + + const qint64 fileSize = filename.size(); + + QIODevice* feed = audio->start(0); + + char* buffer = new char[fileSize]; + filename.read(buffer, fileSize); + + qint64 counter=0; + qint64 written=0; + while(written < fileSize) { + written+=feed->write(buffer+written,fileSize-written); + QTest::qWait(20); + counter++; + } + QTestEventLoop::instance().enterLoop(1); + + QVERIFY(written == fileSize); + QVERIFY(audio->totalTime() == 692250); + + audio->stop(); + filename.close(); + delete [] buffer; + delete audio; +} + +QTEST_MAIN(tst_QAudioOutput) + +#include "tst_qaudiooutput.moc" diff --git a/tests/auto/tests.xml b/tests/auto/tests.xml index a5386b2..ccfc380 100644 --- a/tests/auto/tests.xml +++ b/tests/auto/tests.xml @@ -271,6 +271,10 @@ + + + + @@ -676,6 +680,10 @@ + + + + diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index c938919..f32e7dc 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -245,6 +245,7 @@ Configure::Configure( int& argc, char** argv ) dictionary[ "XMLPATTERNS" ] = "auto"; dictionary[ "PHONON" ] = "auto"; dictionary[ "PHONON_BACKEND" ] = "yes"; + dictionary[ "MULTIMEDIA" ] = "yes"; dictionary[ "DIRECTSHOW" ] = "no"; dictionary[ "WEBKIT" ] = "auto"; dictionary[ "PLUGIN_MANIFESTS" ] = "yes"; @@ -843,6 +844,10 @@ void Configure::parseCmdLine() dictionary[ "XMLPATTERNS" ] = "no"; } else if( configCmdLine.at(i) == "-xmlpatterns" ) { dictionary[ "XMLPATTERNS" ] = "yes"; + } else if( configCmdLine.at(i) == "-no-multimedia" ) { + dictionary[ "MULTIMEDIA" ] = "no"; + } else if( configCmdLine.at(i) == "-multimedia" ) { + dictionary[ "MULTIMEDIA" ] = "yes"; } else if( configCmdLine.at(i) == "-no-phonon" ) { dictionary[ "PHONON" ] = "no"; } else if( configCmdLine.at(i) == "-phonon" ) { @@ -1425,6 +1430,7 @@ bool Configure::displayHelp() "[-no-openssl] [-no-dbus] [-dbus] [-dbus-linked] [-platform ]\n" "[-qtnamespace ] [-qtlibinfix ] [-no-phonon]\n" "[-phonon] [-no-phonon-backend] [-phonon-backend]\n" + "[-no-multimedia] [-multimedia]\n" "[-no-webkit] [-webkit]\n" "[-no-scripttools] [-scripttools]\n" "[-graphicssystem raster|opengl]\n\n", 0, 7); @@ -1599,6 +1605,8 @@ bool Configure::displayHelp() desc("PHONON", "yes", "-phonon", "Compile the Phonon module (Phonon is built if a decent C++ compiler is used.)"); desc("PHONON_BACKEND","no", "-no-phonon-backend","Do not compile the platform-specific Phonon backend-plugin"); desc("PHONON_BACKEND","yes","-phonon-backend", "Compile in the platform-specific Phonon backend-plugin"); + desc("MULTIMEDIA", "no", "-no-multimedia", "Do not compile the multimedia module"); + desc("MULTIMEDIA", "yes","-multimedia", "Compile in multimedia module"); 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("SCRIPTTOOLS", "no", "-no-scripttools", "Do not build the QtScriptTools module."); @@ -1867,6 +1875,8 @@ bool Configure::checkAvailability(const QString &part) if (!findFile("msdmo.lib")) cout << "msdmo.lib not found" << endl; if (!findFile("d3d9.h")) cout << "d3d9.h not found" << endl; } + } else if (part == "MULTIMEDIA") { + available = true; } else if (part == "WEBKIT") { available = (dictionary.value("QMAKESPEC") == "win32-msvc2005") || (dictionary.value("QMAKESPEC") == "win32-msvc2008") || (dictionary.value("QMAKESPEC") == "win32-g++"); } else if (part == "SCRIPTTOOLS") { @@ -2302,6 +2312,9 @@ void Configure::generateOutputVars() qtConfig += "phonon-backend"; } + if (dictionary["MULTIMEDIA"] == "yes") + qtConfig += "multimedia"; + if (dictionary["WEBKIT"] == "yes") qtConfig += "webkit"; @@ -2662,6 +2675,7 @@ void Configure::generateConfigfiles() if(dictionary["IPV6"] == "no") qconfigList += "QT_NO_IPV6"; if(dictionary["WEBKIT"] == "no") qconfigList += "QT_NO_WEBKIT"; if(dictionary["PHONON"] == "no") qconfigList += "QT_NO_PHONON"; + if(dictionary["MULTIMEDIA"] == "no") qconfigList += "QT_NO_MULTIMEDIA"; if(dictionary["XMLPATTERNS"] == "no") qconfigList += "QT_NO_XMLPATTERNS"; if(dictionary["SCRIPTTOOLS"] == "no") qconfigList += "QT_NO_SCRIPTTOOLS"; @@ -2920,6 +2934,7 @@ void Configure::displayConfig() cout << "QtDBus support.............." << dictionary[ "DBUS" ] << endl; cout << "QtXmlPatterns support......." << dictionary[ "XMLPATTERNS" ] << endl; cout << "Phonon support.............." << dictionary[ "PHONON" ] << endl; + cout << "Multimedia support.........." << dictionary[ "MULTIMEDIA" ] << endl; cout << "WebKit support.............." << dictionary[ "WEBKIT" ] << endl; cout << "QtScriptTools support......." << dictionary[ "SCRIPTTOOLS" ] << endl; cout << "Graphics System............." << dictionary[ "GRAPHICS_SYSTEM" ] << endl; -- cgit v0.12 From bedfccd293740b00b7cc9f212c119433a4d82d12 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 5 Aug 2009 07:35:40 +0200 Subject: Compile fix (QGraphicsItem::setXRotation was removed). a6ea9ce6990003856ecadcca8ce9ddf37949363d removed this function; the benchmark was not updated. Reviewed-by: TrustMe --- tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp index d072d08..42f2e6b 100644 --- a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp @@ -34,7 +34,6 @@ private slots: void shear(); void translate(); void setRotation(); - void setRotationXYZ(); }; tst_QGraphicsItem::tst_QGraphicsItem() @@ -150,18 +149,7 @@ void tst_QGraphicsItem::setRotation() QGraphicsItem *item = scene.addRect(QRectF(0, 0, 100, 100)); QBENCHMARK { - item->setXRotation(45); - item->transform(); // prevent lazy optimizing - } -} - -void tst_QGraphicsItem::setRotationXYZ() -{ - QGraphicsScene scene; - QGraphicsItem *item = scene.addRect(QRectF(0, 0, 100, 100)); - - QBENCHMARK { - item->setRotation(45, 45, 45); + item->setRotation(45); item->transform(); // prevent lazy optimizing } } -- cgit v0.12 From b0470cd7553d26e73929bf9719eea9f49aeb6824 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 5 Aug 2009 08:16:59 +0200 Subject: Add benchmarks for QGraphicsItem::setParenItem(). Ensure we test simple and deep constructs of setParentItem(). These benchmarks don't cover slowness in ancestor flag updating. QVariant is already identified as a contributor to this slowness, as is updating of the depth value (a deep tree crawl). Reviewed-by: Aaron Kennedy --- tests/benchmarks/qgraphicsitem/qgraphicsitem.pro | 1 - .../benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp | 26 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/qgraphicsitem/qgraphicsitem.pro b/tests/benchmarks/qgraphicsitem/qgraphicsitem.pro index c8fc07b..726bb96 100644 --- a/tests/benchmarks/qgraphicsitem/qgraphicsitem.pro +++ b/tests/benchmarks/qgraphicsitem/qgraphicsitem.pro @@ -3,4 +3,3 @@ TEMPLATE = app TARGET = tst_qgraphicsitem SOURCES += tst_qgraphicsitem.cpp - diff --git a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp index 42f2e6b..62a5b5c 100644 --- a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp @@ -25,6 +25,8 @@ public slots: void cleanup(); private slots: + void setParentItem(); + void setParentItem_deep(); void setPos_data(); void setPos(); void setTransform_data(); @@ -52,6 +54,30 @@ void tst_QGraphicsItem::cleanup() { } +void tst_QGraphicsItem::setParentItem() +{ + QBENCHMARK { + QGraphicsRectItem rect; + QGraphicsRectItem *childRect = new QGraphicsRectItem; + childRect->setParentItem(&rect); + } +} + +void tst_QGraphicsItem::setParentItem_deep() +{ + QBENCHMARK { + QGraphicsRectItem rect; + QGraphicsRectItem *lastRect = ▭ + for (int i = 0; i < 10; ++i) { + QGraphicsRectItem *childRect = new QGraphicsRectItem; + childRect->setParentItem(lastRect); + lastRect = childRect; + } + QGraphicsItem *first = rect.children().first(); + first->setParentItem(0); + } +} + void tst_QGraphicsItem::setPos_data() { QTest::addColumn("pos"); -- cgit v0.12 From b008dfbd67176948f6fdf830dc99d23a538a6b9c Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 5 Aug 2009 08:45:44 +0200 Subject: Add benchmark for deleting an item with many children. Task-number: 229124 Reviewed-by: TrustMe --- tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp index 62a5b5c..ee27ebe 100644 --- a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp @@ -27,6 +27,7 @@ public slots: private slots: void setParentItem(); void setParentItem_deep(); + void deleteItemWithManyChildren(); void setPos_data(); void setPos(); void setTransform_data(); @@ -78,6 +79,16 @@ void tst_QGraphicsItem::setParentItem_deep() } } +void tst_QGraphicsItem::deleteItemWithManyChildren() +{ + QBENCHMARK { + QGraphicsRectItem *rect = new QGraphicsRectItem; + for (int i = 0; i < 1000; ++i) + new QGraphicsRectItem(rect); + delete rect; + } +} + void tst_QGraphicsItem::setPos_data() { QTest::addColumn("pos"); -- cgit v0.12 From 83c76bb2d1eeca2003720d243ef656aa241a3d49 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 5 Aug 2009 10:27:44 +0200 Subject: qdoc: Removed the "No such group" qdoc error. This error was printed if you used a \ingroup xxx, but there was no \group xxx anywhere. Now we will stop using the \group command, but we will retain the \ingroup command for use with the \annotatedlist command. --- tools/qdoc3/tree.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp index d75af70..f832062 100644 --- a/tools/qdoc3/tree.cpp +++ b/tools/qdoc3/tree.cpp @@ -575,10 +575,12 @@ void Tree::resolveGroups() if (fake && fake->subType() == Node::Group) { fake->addGroupMember(i.value()); } +#if 0 else { if (prevGroup != i.key()) i.value()->doc().location().warning(tr("No such group '%1'").arg(i.key())); } +#endif prevGroup = i.key(); } -- cgit v0.12 From a3cb29b310f3d8b4de919bb19d98ae93edde7c85 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 5 Aug 2009 11:01:12 +0200 Subject: sequential animation group: add autotest for pause/resume --- .../tst_qsequentialanimationgroup.cpp | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 97ff04b..744ba52 100644 --- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -88,6 +88,7 @@ private slots: void currentAnimationWithZeroDuration(); void insertAnimation(); void clearAnimations(); + void pauseResume(); }; tst_QSequentialAnimationGroup::tst_QSequentialAnimationGroup() @@ -1644,5 +1645,40 @@ void tst_QSequentialAnimationGroup::clearAnimations() QCOMPARE(group.state(), QAbstractAnimation::Running); } +void tst_QSequentialAnimationGroup::pauseResume() +{ + QObject dummy; + dummy.setProperty("foo", 0); + QParallelAnimationGroup group; + QPropertyAnimation *anim = new QPropertyAnimation(&dummy, "foo", &group); + anim->setDuration(250); + anim->setEndValue(250); + QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); + QCOMPARE(group.duration(), 250); + group.start(); + QTest::qWait(100); + QCOMPARE(group.state(), QAnimationGroup::Running); + QCOMPARE(anim->state(), QAnimationGroup::Running); + QCOMPARE(spy.count(), 1); + spy.clear(); + const int currentTime = group.currentTime(); + QCOMPARE(anim->currentTime(), currentTime); + + group.pause(); + QCOMPARE(group.state(), QAnimationGroup::Paused); + QCOMPARE(group.currentTime(), currentTime); + QCOMPARE(anim->state(), QAnimationGroup::Paused); + QCOMPARE(anim->currentTime(), currentTime); + QCOMPARE(spy.count(), 1); + spy.clear(); + + group.resume(); + QCOMPARE(group.state(), QAnimationGroup::Running); + QCOMPARE(group.currentTime(), currentTime); + QCOMPARE(anim->state(), QAnimationGroup::Running); + QCOMPARE(anim->currentTime(), currentTime); + QCOMPARE(spy.count(), 1); +} + QTEST_MAIN(tst_QSequentialAnimationGroup) #include "tst_qsequentialanimationgroup.moc" -- cgit v0.12 From bcf41cf9dbe9921bb50b8cf2fcdcd9884e94412f Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 5 Aug 2009 11:03:55 +0200 Subject: Make \annotatedlist work also in pages that are not \group pages. The command right now only lists the classes in the group, in alphabetical order. Not ideal for integrating into overviews, where the list should be ordered by relevance. --- tools/qdoc3/htmlgenerator.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 425c50b..6b15f96 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -539,16 +539,13 @@ int HtmlGenerator::generateAtom(const Atom *atom, break; case Atom::AnnotatedList: { - const FakeNode *fake = static_cast(relative); - if (fake && !fake->groupMembers().isEmpty()) { - QList values = tre->groups().values(atom->string()); - QMap nodeMap; - for (int i = 0; i < values.size(); ++i) { - const Node* n = values.at(i); - nodeMap.insert(n->name(),n); - } - generateAnnotatedList(fake, marker, nodeMap); + QList values = tre->groups().values(atom->string()); + QMap nodeMap; + for (int i = 0; i < values.size(); ++i) { + const Node* n = values.at(i); + nodeMap.insert(n->name(),n); } + generateAnnotatedList(relative, marker, nodeMap); } break; case Atom::GeneratedList: -- cgit v0.12 From e3e1ea6c52473f120f8baee57e189ddc1c8671cb Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 5 Aug 2009 11:11:37 +0200 Subject: QMenu: fix a crash depending on styles We were calling pixelMetric and sizeFromContents with a NULL styleoption That crashes on mac and might also with other styles. --- src/gui/widgets/qmenu.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 67bb10a..05426a0 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -225,13 +225,17 @@ void QMenuPrivate::updateActionRects() const dh = popupGeometry(QApplication::desktop()->screenNumber(q)).height(), y = 0; QStyle *style = q->style(); - const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, 0, q), - vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, 0, q), - icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q); - const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); - - const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, 0, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); + QStyleOption opt; + opt.init(q); + const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q), + vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q), + 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.. tabWidth = 0; @@ -307,7 +311,7 @@ void QMenuPrivate::updateActionRects() const max_column_width = qMax(min_column_width, qMax(max_column_width, sz.width())); //wrapping if (!scroll && - y+sz.height()+vmargin > dh - (style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q) * 2)) { + y+sz.height()+vmargin > dh - (deskFw * 2)) { ncols++; y = vmargin; } @@ -322,7 +326,7 @@ void QMenuPrivate::updateActionRects() const //calculate position const int base_y = vmargin + fw + topmargin + (scroll ? scroll->scrollOffset : 0) + - (tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q) : 0); + tearoffHeight; int x = hmargin + fw + leftmargin; y = base_y; @@ -331,7 +335,7 @@ void QMenuPrivate::updateActionRects() const if (rect.isNull()) continue; if (!scroll && - y+rect.height() > dh - (style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q) * 2)) { + y+rect.height() > dh - deskFw * 2) { x += max_column_width + hmargin; y = base_y; } -- cgit v0.12 From c379e151adc9c781f8f1e3d33cf68b3137868185 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 5 Aug 2009 11:11:52 +0200 Subject: cetest: add support for cetcpsync (our simple ActiveSync replacement) Reviewed-By: mauricek --- .../qtestlib/wince/cetest/cetcpsyncconnection.cpp | 198 +++++++++++++++++++++ tools/qtestlib/wince/cetest/cetcpsyncconnection.h | 82 +++++++++ tools/qtestlib/wince/cetest/cetest.pro | 19 +- tools/qtestlib/wince/cetest/deployment.cpp | 2 + tools/qtestlib/wince/cetest/main.cpp | 11 +- 5 files changed, 305 insertions(+), 7 deletions(-) create mode 100644 tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp create mode 100644 tools/qtestlib/wince/cetest/cetcpsyncconnection.h diff --git a/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp new file mode 100644 index 0000000..bebcd1c --- /dev/null +++ b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp @@ -0,0 +1,198 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "CeTcpSyncConnection.h" +#include +#include +#include + +extern void debugOutput(const QString& text, int level); + +CeTcpSyncConnection::CeTcpSyncConnection() + : AbstractRemoteConnection() + , connected(false) +{ +} + +CeTcpSyncConnection::~CeTcpSyncConnection() +{ + if (isConnected()) + disconnect(); +} + +bool CeTcpSyncConnection::connect(QVariantList&) +{ + // We connect with each command, so this is always true + // The command itself will fail then + if (system("cetcpsync noop") != 0) + return false; + connected = true; + return true; +} + +void CeTcpSyncConnection::disconnect() +{ + connected = false; +} + +bool CeTcpSyncConnection::isConnected() const +{ + return connected; +} + +inline QString boolToString(bool b) +{ + return b ? "true" : "false"; +} + +static bool fileTimeFromString(FILETIME& ft, const QString& str) +{ + int idx = str.indexOf("*"); + if (idx <= 0) + return false; + bool ok; + ft.dwLowDateTime = str.left(idx).toULong(&ok); + if (!ok) + return false; + ft.dwHighDateTime = str.mid(idx+1).toULong(&ok); + return ok; +} + +static QString fileTimeToString(FILETIME& ft) +{ + return QString::number(ft.dwLowDateTime) + "*" + QString::number(ft.dwHighDateTime); +} + +bool CeTcpSyncConnection::copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists) +{ + QString cmd = "cetcpsync copyFileToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(failIfExists); + return system(qPrintable(cmd)) == 0; +} + +bool CeTcpSyncConnection::copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive) +{ + QString cmd = "cetcpsync copyDirectoryToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(recursive); + return system(qPrintable(cmd)) == 0; +} + +bool CeTcpSyncConnection::copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists) +{ + QString cmd = "cetcpsync copyFileFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(failIfExists); + return system(qPrintable(cmd)) == 0; +} + +bool CeTcpSyncConnection::copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive) +{ + QString cmd = "cetcpsync copyDirectoryFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(recursive); + return system(qPrintable(cmd)) == 0; +} + +bool CeTcpSyncConnection::copyFile(const QString &srcFile, const QString &destFile, bool failIfExists) +{ + QString cmd = "cetcpsync copyFile \"" + srcFile + "\" \"" + destFile + "\" " + boolToString(failIfExists); + return system(qPrintable(cmd)) == 0; +} + +bool CeTcpSyncConnection::copyDirectory(const QString &srcDirectory, const QString &destDirectory, + bool recursive) +{ + QString cmd = "cetcpsync copyDirectory \"" + srcDirectory + "\" \"" + destDirectory + "\" " + boolToString(recursive); + return system(qPrintable(cmd)) == 0; +} + +bool CeTcpSyncConnection::deleteFile(const QString &fileName) +{ + QString cmd = "cetcpsync deleteFile \"" + fileName + "\""; + return system(qPrintable(cmd)) == 0; +} + +bool CeTcpSyncConnection::deleteDirectory(const QString &directory, bool recursive, bool failIfContentExists) +{ + QString cmd = "cetcpsync deleteDirectory \"" + directory + "\" " + boolToString(recursive) + " " + boolToString(failIfContentExists); + return system(qPrintable(cmd)) == 0; +} + +bool CeTcpSyncConnection::execute(QString program, QString arguments, int timeout, int *returnValue) +{ + QString cmd = "cetcpsync execute \"" + program + "\" \"" + arguments + "\" " + QString::number(timeout); + int exitCode = system(qPrintable(cmd)); + if (returnValue) + *returnValue = exitCode; + return true; +} + +bool CeTcpSyncConnection::createDirectory(const QString &path, bool deleteBefore) +{ + QString cmd = "cetcpsync createDirectory \"" + path + "\" " + boolToString(deleteBefore); + return system(qPrintable(cmd)) == 0; +} + +bool CeTcpSyncConnection::timeStampForLocalFileTime(FILETIME* fTime) const +{ + QString cmd = "cetcpsync timeStampForLocalFileTime " + fileTimeToString(*fTime) + " >filetime.txt"; + if (system(qPrintable(cmd)) != 0) + return false; + + QFile file("filetime.txt"); + if (!file.open(QIODevice::ReadOnly)) + return false; + + bool result = fileTimeFromString(*fTime, file.readLine()); + file.close(); + file.remove(); + return result; +} + +bool CeTcpSyncConnection::fileCreationTime(const QString &fileName, FILETIME* deviceCreationTime) const +{ + QString cmd = "cetcpsync fileCreationTime \"" + fileName + "\" >filetime.txt"; + if (system(qPrintable(cmd)) != 0) + return false; + + QFile file("filetime.txt"); + if (!file.open(QIODevice::ReadOnly)) + return false; + + bool result = fileTimeFromString(*deviceCreationTime, file.readLine()); + file.close(); + file.remove(); + return result; +} diff --git a/tools/qtestlib/wince/cetest/cetcpsyncconnection.h b/tools/qtestlib/wince/cetest/cetcpsyncconnection.h new file mode 100644 index 0000000..1ef8423 --- /dev/null +++ b/tools/qtestlib/wince/cetest/cetcpsyncconnection.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CETCPSYNC_REMOTECONNECTION_H +#define CETCPSYNC_REMOTECONNECTION_H + +#include "remoteconnection.h" + +class CeTcpSyncConnection : public AbstractRemoteConnection +{ +public: + CeTcpSyncConnection(); + virtual ~CeTcpSyncConnection(); + + bool connect(QVariantList &list = QVariantList()); + void disconnect(); + bool isConnected() const; + + // These functions are designed for transfer between desktop and device + // Caution: deviceDest path has to be device specific (eg. no drive letters for CE) + bool copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists = false); + bool copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive = true); + bool copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists = false); + bool copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive = true); + + bool timeStampForLocalFileTime(FILETIME*) const; + bool fileCreationTime(const QString &fileName, FILETIME*) const; + + // These functions only work on files existing on the device + bool copyFile(const QString&, const QString&, bool failIfExists = false); + bool copyDirectory(const QString&, const QString&, bool recursive = true); + bool deleteFile(const QString&); + bool deleteDirectory(const QString&, bool recursive = true, bool failIfContentExists = false); + bool moveFile(const QString&, const QString&, bool FailIfExists = false); + bool moveDirectory(const QString&, const QString&, bool recursive = true); + + bool createDirectory(const QString&, bool deleteBefore=false); + + bool execute(QString program, QString arguments = QString(), int timeout = -1, int *returnValue = NULL); +private: + bool connected; +}; + +#endif diff --git a/tools/qtestlib/wince/cetest/cetest.pro b/tools/qtestlib/wince/cetest/cetest.pro index d66fa33..c6eba7f 100644 --- a/tools/qtestlib/wince/cetest/cetest.pro +++ b/tools/qtestlib/wince/cetest/cetest.pro @@ -28,20 +28,27 @@ DEPENDPATH += $$QT_BUILD_TREE/src/corelib/tools $$QT_BUILD_TREE/src/corelib/io # Input HEADERS += \ remoteconnection.h \ - activesyncconnection.h \ deployment.h SOURCES += \ remoteconnection.cpp \ - activesyncconnection.cpp \ deployment.cpp \ main.cpp -win32-msvc*:LIBS += ole32.lib advapi32.lib rapi.lib +win32-msvc*:LIBS += ole32.lib advapi32.lib + +isEmpty(QT_CE_RAPI_INC) { + DEFINES += QT_CETEST_NO_ACTIVESYNC + HEADERS += cetcpsyncconnection.h + SOURCES += cetcpsyncconnection.cpp +} else { + HEADERS += activesyncconnection.h + SOURCES += activesyncconnection.cpp + win32-msvc*:LIBS += rapi.lib + INCLUDEPATH += $$QT_CE_RAPI_INC + LIBS += -L$$QT_CE_RAPI_LIB +} include(qmake_include.pri) include(bootstrapped.pri) include($$QT_SOURCE_TREE/src/script/script.pri) - -INCLUDEPATH += $$QT_CE_RAPI_INC -LIBS += -L$$QT_CE_RAPI_LIB diff --git a/tools/qtestlib/wince/cetest/deployment.cpp b/tools/qtestlib/wince/cetest/deployment.cpp index 68f0197..c64ae26 100644 --- a/tools/qtestlib/wince/cetest/deployment.cpp +++ b/tools/qtestlib/wince/cetest/deployment.cpp @@ -168,6 +168,7 @@ void DeploymentHandler::initQtDeploy(QMakeProject *project, DeploymentList &depl } } +#ifndef QT_CETEST_NO_ACTIVESYNC // QtRemote deployment. We always deploy to \Windows if (!project->values("QMAKE_LIBDIR").isEmpty()) { QString remoteLibName = QLatin1String("QtRemote.dll"); @@ -177,6 +178,7 @@ void DeploymentHandler::initQtDeploy(QMakeProject *project, DeploymentList &depl else debugOutput(QString::fromLatin1("Could not find QtRemote. Might not be able to launch target executable"),0); } +#endif // C-runtime deployment QString runtime = project->values("QT_CE_C_RUNTIME").join(QLatin1String(" ")); diff --git a/tools/qtestlib/wince/cetest/main.cpp b/tools/qtestlib/wince/cetest/main.cpp index 782f6d9..e0e475c 100644 --- a/tools/qtestlib/wince/cetest/main.cpp +++ b/tools/qtestlib/wince/cetest/main.cpp @@ -39,7 +39,12 @@ ** ****************************************************************************/ -#include "activesyncconnection.h" +#ifdef QT_CETEST_NO_ACTIVESYNC +# include "cetcpsyncconnection.h" +#else +# include "activesyncconnection.h" +#endif + #include "deployment.h" #include #include @@ -290,7 +295,11 @@ int main(int argc, char **argv) projectDeploymentList.append(CopyItem(TestConfiguration::localExecutable , TestConfiguration::remoteExecutable)); // deploy +#ifdef QT_CETEST_NO_ACTIVESYNC + CeTcpSyncConnection connection; +#else ActiveSyncConnection connection; +#endif if (!connection.connect()) { cout << "Error: Could not connect to device!" << endl; return -1; -- cgit v0.12 From ad8247fcbe7d7e3e3c0227d54f6abc2ef6160f9b Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 5 Aug 2009 11:33:22 +0200 Subject: initial revision of cetcpsyncserver cetcpsync is our simple ActiveSync replacement for Windows CE devices. This is the server which has to run on the device. Reviewed-By: mauricek --- .../wince/cetcpsyncserver/cetcpsyncserver.pro | 17 + tools/qtestlib/wince/cetcpsyncserver/commands.cpp | 646 +++++++++++++++++++++ tools/qtestlib/wince/cetcpsyncserver/commands.h | 292 ++++++++++ .../wince/cetcpsyncserver/connectionmanager.cpp | 138 +++++ .../wince/cetcpsyncserver/connectionmanager.h | 83 +++ tools/qtestlib/wince/cetcpsyncserver/main.cpp | 63 ++ .../wince/cetcpsyncserver/transfer_global.h | 159 +++++ 7 files changed, 1398 insertions(+) create mode 100644 tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro create mode 100644 tools/qtestlib/wince/cetcpsyncserver/commands.cpp create mode 100644 tools/qtestlib/wince/cetcpsyncserver/commands.h create mode 100644 tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp create mode 100644 tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h create mode 100644 tools/qtestlib/wince/cetcpsyncserver/main.cpp create mode 100644 tools/qtestlib/wince/cetcpsyncserver/transfer_global.h diff --git a/tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro b/tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro new file mode 100644 index 0000000..bd01d2d --- /dev/null +++ b/tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro @@ -0,0 +1,17 @@ +TEMPLATE = app +TARGET = cetcpsyncsvr +DEPENDPATH += . +QT -= gui +QT += network + +CONFIG += console + +HEADERS += \ + connectionmanager.h \ + commands.h \ + transfer_global.h + +SOURCES += \ + connectionmanager.cpp \ + commands.cpp \ + main.cpp diff --git a/tools/qtestlib/wince/cetcpsyncserver/commands.cpp b/tools/qtestlib/wince/cetcpsyncserver/commands.cpp new file mode 100644 index 0000000..64869c4 --- /dev/null +++ b/tools/qtestlib/wince/cetcpsyncserver/commands.cpp @@ -0,0 +1,646 @@ +#include "commands.h" +#include +#include +#include +#include + +#ifdef Q_OS_WINCE +#include +#endif + +///////////////////////////////////////////////////// +// Abstract Command Implementation // +///////////////////////////////////////////////////// +AbstractCommand::AbstractCommand() +: m_socket(0) +{ +} + +AbstractCommand::~AbstractCommand() +{ +} + +void AbstractCommand::reportSuccess() +{ + m_socket->write(COMMAND_SUCCESS, strlen(COMMAND_SUCCESS)); + m_socket->waitForBytesWritten(); +} + +void AbstractCommand::reportError() +{ + m_socket->write(COMMAND_ERROR, strlen(COMMAND_ERROR)); + m_socket->waitForBytesWritten(); +} + +void AbstractCommand::dataReceived(QByteArray&) +{ + debugOutput(1, "AbstractCommand::dataReceived NOT SUPPOSED TO BE HERE"); +} + +void AbstractCommand::commandFinished() +{ + debugOutput(1, "AbstractCommand::commandFinished()NOT SUPPOSED TO BE HERE"); +} + +void AbstractCommand::setSocket(QTcpSocket* socket) +{ + debugOutput(0, "AbstractCommand::setSocket()"); + Q_ASSERT(socket); + m_socket = socket; + connect(m_socket, SIGNAL(readyRead()), this, SLOT(_readData())); + reportSuccess(); +} + +QTcpSocket* AbstractCommand::socket() +{ + return m_socket; +} + +void AbstractCommand::_readData() +{ + QByteArray arr = m_socket->readAll(); + dataReceived(arr); +} + +void AbstractCommand::_disconnect() +{ +} + +///////////////////////////////////////////////////// +// Create File Command Implementation // +///////////////////////////////////////////////////// +CreateFileCommand::CreateFileCommand() +: m_dataCount(0) +{ + debugOutput(0, "CreateFileCommand::CreateFileCommand"); + m_options.fileSize= -1; +} + +CreateFileCommand::~CreateFileCommand() +{ + debugOutput(0, "CreateFileCommand::~CreateFileCommand"); + if (m_file.isOpen()) { + fprintf(stderr, "****************FILE IS STILL OPENED AND HAVENT FINISHED WRITING**********************\n"); + fprintf(stderr, "Current: %d Expected: %d\n", m_dataCount , m_options.fileSize); + m_file.close(); + } +} + +void CreateFileCommand::dataReceived(QByteArray &data) +{ + bool successful = true; + // If we haven't received the options yet + if (m_options.fileSize == -1) { + CreateFileOptions* opt = (CreateFileOptions*) data.data(); + memcpy(&m_options , opt , sizeof(CreateFileOptions)); + + if (QFileInfo(QString::fromLatin1(m_options.fileName)).exists()) { + if (m_options.overwriteExisting) { +#ifdef Q_OS_WINCE + SetFileAttributes(QFileInfo(m_options.fileName).absoluteFilePath().utf16(), FILE_ATTRIBUTE_NORMAL); +#endif + QFile::remove(m_options.fileName); + } else + successful = false; + } + m_file.setFileName(QString::fromLatin1(m_options.fileName)); + if (!m_file.open(QIODevice::WriteOnly)) + successful = false; + else + debugOutput(3, QString::fromLatin1("Creating file: %1").arg(m_options.fileName)); + } else { // write buffer on disc + if (!m_file.isOpen()) + return; + m_file.write(data); + m_dataCount += data.size(); + if (m_dataCount >= m_options.fileSize) { + // We do not care about more data than announced + m_file.close(); + } + } + + if (successful) + reportSuccess(); + else + reportError(); +} + +void CreateFileCommand::commandFinished() +{ + debugOutput(0, "CreateFileCommand::commandFinished"); +#ifdef Q_OS_WIN + // We need to set the file attributes for intelligent time comparisons + QString tmpFile = QString::fromLatin1(m_options.fileName); + HANDLE handle = CreateFile(tmpFile.utf16(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + if (handle != INVALID_HANDLE_VALUE) { + SetFileTime(handle, &(m_options.fileTime), NULL, NULL); + CloseHandle(handle); + } + SetFileAttributes(tmpFile.utf16(), m_options.fileAttributes); +#endif +} + +///////////////////////////////////////////////////// +// Create Directory Command Implementation // +///////////////////////////////////////////////////// +CreateDirectoryCommand::CreateDirectoryCommand() + : AbstractCommand() +{ + debugOutput(0, "CreateDirectoryCommand::CreateDirectoryCommand"); +} + +CreateDirectoryCommand::~CreateDirectoryCommand() +{ + debugOutput(0, "CreateDirectoryCommand::~CreateDirectoryCommand()"); +} + +void CreateDirectoryCommand::dataReceived(QByteArray &data) +{ + debugOutput(0, "CreateDirectoryCommand::dataReceived()"); + CreateDirectoryOptions* options = (CreateDirectoryOptions*) data.data(); + debugOutput(3, QString::fromLatin1("Creating directory: %1").arg(options->dirName)); + bool success = true; + QDir dir; + if (options->recursively) + success = dir.mkpath(options->dirName); + else + success = dir.mkdir(options->dirName); + + if (success) + reportSuccess(); + else + reportError(); +} + +void CreateDirectoryCommand::commandFinished() +{ + debugOutput(0, "CreateDirectoryCommand::commandFinished()"); +} + +///////////////////////////////////////////////////// +// Copy File Command Implementation // +///////////////////////////////////////////////////// +CopyFileCommand::CopyFileCommand() + : AbstractCommand() +{ + debugOutput(0, "CopyFileCommand::CopyFileCommand()"); +} + +CopyFileCommand::~CopyFileCommand() +{ + debugOutput(0, "CopyFileCommand::~CopyFileCommand()"); +} + +void CopyFileCommand::dataReceived(QByteArray &data) +{ + debugOutput(0, "CopyFileCommand::dataReceived()"); + CopyFileOptions* options = (CopyFileOptions*) data.data(); + debugOutput(3, QString::fromLatin1("Copy File: %1 -> %2").arg(options->from).arg(options->to)); + bool success = true; + if (QFileInfo(options->to).exists()) { + if (options->overwriteExisting) + QFile::remove(options->to); + else + success = false; + } + if (success) + if (!QFile::copy(options->from , options->to)) + success = false; + + if (success) + reportSuccess(); + else + reportError(); +} + +void CopyFileCommand::commandFinished() +{ + debugOutput(0, "CopyFileCommand::commandFinished()"); +} + +///////////////////////////////////////////////////// +// Copy Directory Command Implementation // +///////////////////////////////////////////////////// +CopyDirectoryCommand::CopyDirectoryCommand() + : AbstractCommand() +{ + debugOutput(0, "CopyDirectoryCommand::CopyDirectoryCommand()"); +} + +CopyDirectoryCommand::~CopyDirectoryCommand() +{ + debugOutput(0, "CopyDirectoryCommand::~CopyDirectoryCommand()"); +} + +void CopyDirectoryCommand::dataReceived(QByteArray &data) +{ + debugOutput(0, "CopyDirectoryCommand::dataReceived()"); + CopyDirectoryOptions* options = (CopyDirectoryOptions*) data.data(); + debugOutput(3, QString::fromLatin1("Copy Directory: %1 %2").arg(options->from).arg(options->to)); + if (copyDir(QLatin1String(options->from) , QLatin1String(options->to) , options->recursive)) + reportSuccess(); + else + reportError(); +} + +void CopyDirectoryCommand::commandFinished() +{ + debugOutput(0, "CopyDirectoryCommand::commandFinished()"); +} + +bool CopyDirectoryCommand::copyDir(const QString &from, const QString &to, bool recursive) +{ + QDir().mkpath(to); + QDir sourceDir(from); + QDir destDir(to); + QStringList entries = sourceDir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); + foreach (QString item , entries) { + QString itemFrom = sourceDir.absoluteFilePath(item); + QString itemTo = destDir.absoluteFilePath(item); + if (QFileInfo(item).isDir()) { + if (recursive && !copyDir(itemFrom, itemTo, recursive)) + return false; + } else { + if (!QFile::copy(itemFrom, itemTo)) + return false; + } + } + return true; +} + +///////////////////////////////////////////////////// +// Delete File Command Implementation // +///////////////////////////////////////////////////// +DeleteFileCommand::DeleteFileCommand() + : AbstractCommand() +{ + debugOutput(0, "DeleteFileCommand::DeleteFileCommand()"); +} + +DeleteFileCommand::~DeleteFileCommand() +{ + debugOutput(0, "DeleteFileCommand::~DeleteFileCommand()"); +} + +void DeleteFileCommand::dataReceived(QByteArray &data) +{ + debugOutput(0, "DeleteFileCommand::dataReceived()"); + DeleteFileOptions* options = (DeleteFileOptions*) data.data(); + debugOutput(3, QString::fromLatin1("Delete File: %1").arg(options->fileName)); + bool success = true; + QFile file(options->fileName); + if (file.exists()) { +#ifdef Q_OS_WINCE + SetFileAttributes(QFileInfo(options->fileName).absoluteFilePath().utf16(), FILE_ATTRIBUTE_NORMAL); +#endif + success = file.remove(); + } else + success = false; + + if (success) + reportSuccess(); + else + reportError(); +} + +void DeleteFileCommand::commandFinished() +{ + debugOutput(0, "DeleteFileCommand::commandFinished()"); +} + +///////////////////////////////////////////////////// +// Delete Directory Command Implementation // +///////////////////////////////////////////////////// +DeleteDirectoryCommand::DeleteDirectoryCommand() + : AbstractCommand() +{ + debugOutput(0, "DeleteDirectoryCommand::DeleteDirectoryCommand()"); +} + +DeleteDirectoryCommand::~DeleteDirectoryCommand() +{ + debugOutput(0, "DeleteDirectoryCommand::~DeleteDirectoryCommand()"); +} + +void DeleteDirectoryCommand::dataReceived(QByteArray &data) +{ + debugOutput(0, "DeleteDirectoryCommand::dataReceived()"); + DeleteDirectoryOptions* options = (DeleteDirectoryOptions*) data.data(); + debugOutput(3, QString::fromLatin1("Delete directory: %1").arg(options->dirName)); + if (deleteDirectory(QLatin1String(options->dirName), options->recursive, options->failIfContentExists)) + reportSuccess(); + else + reportError(); +} + +void DeleteDirectoryCommand::commandFinished() +{ + debugOutput(0, "DeleteDirectoryCommand::commandFinished()"); +} + +bool DeleteDirectoryCommand::deleteDirectory(const QString &dirName, bool recursive, bool failIfContentExists) +{ + QDir dir(dirName); + if (!dir.exists()) + return false; + + QStringList itemList = dir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); + if (itemList.size() > 0 && failIfContentExists) + return false; + + foreach (QString item, itemList) { + QString itemName = dir.absoluteFilePath(item); + if (QFileInfo(itemName).isDir()) { + if (recursive && !deleteDirectory(itemName, recursive, failIfContentExists)) + return false; + } else { + if (!dir.remove(item)) + return false; + } + } + QString lastName = dir.dirName(); + dir.cdUp(); + dir.rmpath(lastName); + return true; +} + +///////////////////////////////////////////////////// +// Execute Command Implementation // +///////////////////////////////////////////////////// +ExecuteCommand::ExecuteCommand() + : AbstractCommand() + , m_argumentCount(0) + , m_timeout(-1) +{ + debugOutput(0, "ExecuteCommand::ExecuteCommand()"); +} + +ExecuteCommand::~ExecuteCommand() +{ + debugOutput(0, "ExecuteCommand::~ExecuteCommand()"); +} + +void ExecuteCommand::dataReceived(QByteArray &data) +{ + debugOutput(0, "ExecuteCommand::dataReceived()"); + + if (m_argumentCount == 0) { + ExecuteOptions* options = (ExecuteOptions*) data.data(); + if (!QFileInfo(options->appName).exists()) { + debugOutput(1, "Error execute: application does not exist"); + reportError(); + return; + } + + m_program = QLatin1String(options->appName); + m_argumentCount = options->argumentsCount; + m_waitFinished = options->waitForFinished; + m_timeout = options->timeout; + if (m_argumentCount == 0) + m_argumentCount = -1; // to trigger startup on next receive + reportSuccess(); + } else if (m_arguments.size() < m_argumentCount) { + m_arguments += data; + reportSuccess(); + } else { // do the execution + if (data == COMMAND_SUCCESS) + _doExecute(); + } +} + +void ExecuteCommand::_doExecute() +{ + debugOutput(0, "ExecuteCommand::_doExecute()"); + debugOutput(3, QString::fromLatin1("Execute: %1 %2").arg(m_program).arg(m_arguments.join(" "))); + if (m_waitFinished) { + QProcess process; + process.start(m_program, m_arguments); + if (process.waitForFinished(m_timeout) == false || process.exitCode() < 0) + reportError(); + else + reportSuccess(); + } else { + if (QProcess::startDetached(m_program, m_arguments)) + reportSuccess(); + else + reportError(); + } +} +void ExecuteCommand::commandFinished() +{ + debugOutput(0,"ExecuteCommand::commandFinished()"); +} + +///////////////////////////////////////////////////// +// Read File Implementation // +///////////////////////////////////////////////////// +ReadFileCommand::ReadFileCommand() + : AbstractCommand() + , m_currentPos(0) +{ + debugOutput(0, "ReadFileCommand::ReadFileCommand()"); + m_fileName.clear(); +} + +ReadFileCommand::~ReadFileCommand() +{ + debugOutput(0, "ReadFileCommand::~ReadFileCommand()"); + if (m_file.isOpen()) + m_file.close(); +} + +void ReadFileCommand::dataReceived(QByteArray &data) +{ + debugOutput(0, "ReadFileCommand::dataReceived()"); + if (m_fileName.isEmpty()) { + ReadFileOptions* option = (ReadFileOptions*) data.data(); + m_fileName = QLatin1String(option->fileName); + QFileInfo info(m_fileName); + m_file.setFileName(m_fileName); + ReadFileReply reply; + if (!info.exists() || !info.isFile() || !m_file.open(QIODevice::ReadOnly)) + reply.fileValid = false; + else + reply.fileValid = true; + reply.fileSize = info.size(); + m_fileSize = reply.fileSize; + socket()->write((char*) &reply, sizeof(reply)); + debugOutput(3, QString::fromLatin1("Reading file: %1").arg(m_fileName)); + } else { + QTcpSocket* sock = socket(); // design failure??? + if (data != COMMAND_SUCCESS || m_currentPos >= m_fileSize) { + sock->disconnectFromHost(); + return; + } + const int bufferSize = 1024; + QByteArray buffer = m_file.read(bufferSize); + m_currentPos += buffer.size(); + sock->write(buffer); + sock->waitForBytesWritten(); + } +} + +void ReadFileCommand::commandFinished() +{ + debugOutput(0, "ReadFileCommand::commandFinished()"); +} + +///////////////////////////////////////////////////// +// Read Directory Implementation // +///////////////////////////////////////////////////// +ReadDirectoryCommand::ReadDirectoryCommand() + : AbstractCommand() + , m_iterator(0) +{ + debugOutput(0, "ReadDirectoryCommand::ReadDirectoryCommand"); + m_dirName.clear(); +} + +ReadDirectoryCommand::~ReadDirectoryCommand() +{ + debugOutput(0, "ReadDirectoryCommand::~ReadDirectoryCommand()"); + delete m_iterator; +} + +void ReadDirectoryCommand::dataReceived(QByteArray &data) +{ + debugOutput(0, "ReadDirectoryCommand::dataReceived()"); + QTcpSocket* sock = socket(); + if (m_dirName.isEmpty()) { + ReadDirectoryOptions* option = (ReadDirectoryOptions*) data.data(); + QFileInfo info(QLatin1String(option->dirName)); + debugOutput(3, QString::fromLatin1("Reading Directory entries: %1").arg(option->dirName)); + ReadDirectoryReply reply; + if (!info.exists() || !info.isDir()) { + reply.itemCount = -1; + reply.entryValid = false; + } else { + m_dirName = QLatin1String(option->dirName); + m_dir.setPath(m_dirName); + m_iterator = new QDirIterator(m_dir); + reply.itemCount = m_dir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot).size(); + reply.entryValid = true; + } + sock->write((char*) &reply, sizeof(reply)); + sock->waitForBytesWritten(); + } else { + if (data != COMMAND_SUCCESS) { + qDebug() << "Something went wrong in the meantime"; + return; + } + ReadDirectoryItem reply; + if (m_iterator->hasNext()) { + m_iterator->next(); + QFileInfo info = m_iterator->fileInfo(); + strcpy(reply.name, qPrintable(info.absoluteFilePath())); + reply.isDirectory = info.isDir(); + if (!reply.isDirectory) + reply.size = info.size(); + } + reply.hasMore = m_iterator->hasNext(); + sock->write((char*) &reply, sizeof(reply)); + sock->waitForBytesWritten(); + } +} + +void ReadDirectoryCommand::commandFinished() +{ + debugOutput(0, "ReadDirectoryCommand::commandFinished()"); +} + +///////////////////////////////////////////////////// +// File Time Implementation // +///////////////////////////////////////////////////// +FileTimeCommand::FileTimeCommand() + : AbstractCommand() +{ + debugOutput(0, "FileTimeCommand::FileTimeCommand()"); +} + +FileTimeCommand::~FileTimeCommand() +{ + debugOutput(0, "FileTimeCommand::~FileTimeCommand()"); +} + +void FileTimeCommand::dataReceived(QByteArray &data) +{ + debugOutput(0, "FileTimeCommand::dataReceived()"); + FileTimeOptions* option = (FileTimeOptions*) data.data(); + + FILETIME resultTime; + resultTime.dwLowDateTime = -1; + resultTime.dwHighDateTime = -1; + +#ifdef Q_OS_WIN + QString fileName = QLatin1String(option->fileName); + HANDLE deviceHandle = CreateFile(fileName.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); + debugOutput(3, QString::fromLatin1("Asking FileTime: %1").arg(fileName)); + if (deviceHandle != INVALID_HANDLE_VALUE) { + FILETIME deviceCreationTime; + if (GetFileTime(deviceHandle, &deviceCreationTime, NULL, NULL)) { + resultTime = deviceCreationTime; + } + CloseHandle(deviceHandle); + } +#endif + QTcpSocket* sock = socket(); + sock->write((char*) &resultTime, sizeof(resultTime)); + sock->waitForBytesWritten(); +} + +void FileTimeCommand::commandFinished() +{ + debugOutput(0, "FileTimeCommand::commandFinished()"); +} + +///////////////////////////////////////////////////// +// Time Stamp Implementation // +///////////////////////////////////////////////////// +TimeStampCommand::TimeStampCommand() + : AbstractCommand() +{ + debugOutput(0, "TimeStampCommand::TimeStampCommand()"); +} + +TimeStampCommand::~TimeStampCommand() +{ + debugOutput(0, "TimeStampCommand::~TimeStampCommand()"); +} + +void TimeStampCommand::dataReceived(QByteArray &data) +{ + debugOutput(0, "TimeStampCommand::dataReceived()"); + FILETIME resultTime; + resultTime.dwLowDateTime = -1; + resultTime.dwHighDateTime = -1; + +#ifdef Q_OS_WIN + FILETIME stampTime = *((FILETIME*)data.data()); + + QString tmpFile = QString::fromLatin1("\\qt_tmp_ftime_convert"); + HANDLE remoteHandle = CreateFile(tmpFile.utf16(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); + if (remoteHandle != INVALID_HANDLE_VALUE) { + if (!SetFileTime(remoteHandle, &stampTime, NULL, NULL)) { + CloseHandle(remoteHandle); + } else { + CloseHandle(remoteHandle); + remoteHandle = CreateFile(tmpFile.utf16(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); + if (remoteHandle != INVALID_HANDLE_VALUE) { + if (GetFileTime(remoteHandle, &stampTime, NULL, NULL)) + resultTime = stampTime; + CloseHandle(remoteHandle); + DeleteFile(tmpFile.utf16()); + } + } + } + debugOutput(3, QString::fromLatin1("Asking TimeStamp")); +#endif + QTcpSocket* sock = socket(); + sock->write((char*) &resultTime, sizeof(resultTime)); + sock->waitForBytesWritten(); +} + +void TimeStampCommand::commandFinished() +{ + debugOutput(0, "TimeStampCommand::commandFinished()"); +} diff --git a/tools/qtestlib/wince/cetcpsyncserver/commands.h b/tools/qtestlib/wince/cetcpsyncserver/commands.h new file mode 100644 index 0000000..356c1aa --- /dev/null +++ b/tools/qtestlib/wince/cetcpsyncserver/commands.h @@ -0,0 +1,292 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef COMMANDS_INCL +#define COMMANDS_INCL + +#include "transfer_global.h" + +#include +#include +#include +#include +#include +#include + +// debug output +#define DEBUG_LEVEL 2 +inline void debugOutput(int level, const char* text) +{ + if (level >= DEBUG_LEVEL) + qDebug() << text; +} + +inline void debugOutput(int level, const QString &text) +{ + if (level >= DEBUG_LEVEL) + qDebug() << text; +} +// Basic abtract command class +class AbstractCommand : public QObject +{ + Q_OBJECT +public: + AbstractCommand(); + virtual ~AbstractCommand(); + + void setSocket(QTcpSocket*); + QTcpSocket* socket(); + + void reportSuccess(); + void reportError(); + +public slots: + virtual void dataReceived(QByteArray&); + virtual void commandFinished(); + +private slots: + void _readData(); + void _disconnect(); + +private: + QTcpSocket* m_socket; +}; + +// File Creation class +class CreateFileCommand : public AbstractCommand +{ + Q_OBJECT +public: + CreateFileCommand(); + ~CreateFileCommand(); + +public slots: + void dataReceived(QByteArray&); + void commandFinished(); + +private: + CreateFileOptions m_options; + QFile m_file; + int m_dataCount; +}; + +inline AbstractCommand* instCreateFile() { return new CreateFileCommand(); } + +// Directory Creation class +class CreateDirectoryCommand : public AbstractCommand +{ + Q_OBJECT +public: + CreateDirectoryCommand(); + ~CreateDirectoryCommand(); + +public slots: + void dataReceived(QByteArray&); + void commandFinished(); +}; +inline AbstractCommand* instCreateDirectory() { return new CreateDirectoryCommand(); } + +// File copy class +class CopyFileCommand : public AbstractCommand +{ + Q_OBJECT +public: + CopyFileCommand(); + ~CopyFileCommand(); + +public slots: + void dataReceived(QByteArray&); + void commandFinished(); +}; +inline AbstractCommand* instCopyFile() { return new CopyFileCommand(); } + +// Copy directory class +class CopyDirectoryCommand : public AbstractCommand +{ + Q_OBJECT +public: + CopyDirectoryCommand(); + ~CopyDirectoryCommand(); + +public slots: + void dataReceived(QByteArray&); + void commandFinished(); +private: + bool copyDir(const QString &from, const QString &to, bool recursive); +}; +inline AbstractCommand* instCopyDirectory() { return new CopyDirectoryCommand(); } + +// Delete File class +class DeleteFileCommand : public AbstractCommand +{ + Q_OBJECT +public: + DeleteFileCommand(); + ~DeleteFileCommand(); +public slots: + void dataReceived(QByteArray&); + void commandFinished(); +}; +inline AbstractCommand* instDeleteFile() { return new DeleteFileCommand(); } + +// Delete Directory class +class DeleteDirectoryCommand : public AbstractCommand +{ + Q_OBJECT +public: + DeleteDirectoryCommand(); + ~DeleteDirectoryCommand(); +public slots: + void dataReceived(QByteArray&); + void commandFinished(); +private: + bool deleteDirectory(const QString &dirName, bool recursive, bool failIfContentExists); +}; +inline AbstractCommand* instDeleteDirectory() { return new DeleteDirectoryCommand(); } + +// Execute application class +class ExecuteCommand : public AbstractCommand +{ + Q_OBJECT +public: + ExecuteCommand(); + ~ExecuteCommand(); +public slots: + void dataReceived(QByteArray&); + void commandFinished(); +private: + void _doExecute(); + QString m_program; + QStringList m_arguments; + int m_argumentCount; + bool m_waitFinished; + int m_timeout; +}; +inline AbstractCommand* instExecution() { return new ExecuteCommand(); } + +// Read File class +class ReadFileCommand : public AbstractCommand +{ + Q_OBJECT +public: + ReadFileCommand(); + ~ReadFileCommand(); +public slots: + void dataReceived(QByteArray&); + void commandFinished(); +private: + QString m_fileName; + QFile m_file; + qint64 m_currentPos; + qint64 m_fileSize; +}; +inline AbstractCommand* instReadFile() { return new ReadFileCommand(); } + +// Read Directory class +class ReadDirectoryCommand : public AbstractCommand +{ + Q_OBJECT +public: + ReadDirectoryCommand(); + ~ReadDirectoryCommand(); +public slots: + void dataReceived(QByteArray&); + void commandFinished(); +private: + QString m_dirName; + QDir m_dir; + QDirIterator* m_iterator; +}; +inline AbstractCommand* instReadDirectory() { return new ReadDirectoryCommand(); } + +// Read File Time class +class FileTimeCommand : public AbstractCommand +{ + Q_OBJECT +public: + FileTimeCommand(); + ~FileTimeCommand(); +public slots: + void dataReceived(QByteArray&); + void commandFinished(); +}; +inline AbstractCommand* instFileTime() { return new FileTimeCommand(); } + +// Time stamp class +class TimeStampCommand : public AbstractCommand +{ + Q_OBJECT +public: + TimeStampCommand(); + ~TimeStampCommand(); +public slots: + void dataReceived(QByteArray&); + void commandFinished(); +}; +inline AbstractCommand* instTimeStamp() { return new TimeStampCommand(); } + +// Access part +typedef AbstractCommand* (*instantiator)(); + +struct CommandInfo +{ + CommandInfo(const QString &name, instantiator func) : commandName(name) , commandFunc(func) { } + QString commandName; + instantiator commandFunc; +}; + +inline QList availableCommands() +{ + QList list; + list.append(CommandInfo(QLatin1String(COMMAND_CREATE_FILE), instCreateFile)); + list.append(CommandInfo(QLatin1String(COMMAND_CREATE_DIRECTORY), instCreateDirectory)); + list.append(CommandInfo(QLatin1String(COMMAND_COPY_FILE), instCopyFile)); + list.append(CommandInfo(QLatin1String(COMMAND_COPY_DIRECTORY), instCopyDirectory)); + list.append(CommandInfo(QLatin1String(COMMAND_DELETE_FILE), instDeleteFile)); + list.append(CommandInfo(QLatin1String(COMMAND_DELETE_DIRECTORY), instDeleteDirectory)); + list.append(CommandInfo(QLatin1String(COMMAND_EXECUTE), instExecution)); + list.append(CommandInfo(QLatin1String(COMMAND_READ_FILE), instReadFile)); + list.append(CommandInfo(QLatin1String(COMMAND_READ_DIRECTORY), instReadDirectory)); + list.append(CommandInfo(QLatin1String(COMMAND_FILE_TIME), instFileTime)); + list.append(CommandInfo(QLatin1String(COMMAND_TIME_STAMP), instTimeStamp)); + return list; +} + +#endif diff --git a/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp new file mode 100644 index 0000000..901cd12 --- /dev/null +++ b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "connectionmanager.h" +#include "commands.h" +#include + +ConnectionManager::ConnectionManager() + : QObject() + , m_server(0) +{ + debugOutput(0, "ConnectionManager::ConnectionManager()"); +} + +ConnectionManager::~ConnectionManager() +{ + debugOutput(0, "ConnectionManager::~ConnectionManager()"); + cleanUp(); +} + +bool ConnectionManager::init() +{ + debugOutput(0, "ConnectionManager::init()"); + debugOutput(3, "Initializing server..."); + cleanUp(); + m_server = new QTcpServer(this); + connect(m_server, SIGNAL(newConnection()), this, SLOT(newConnection())); + bool result = m_server->listen(QHostAddress::Any, SERVER_PORT); + if (!result) + debugOutput(3, QString::fromLatin1(" Error: Server start failed:") + m_server->errorString()); + debugOutput(3, " Waiting for action"); + return result; +} + +void ConnectionManager::cleanUp() +{ + debugOutput(0, "ConnectionManager::cleanUp()"); + + if (m_server) { + debugOutput(1, "Removing server instance..."); + disconnect(m_server, SIGNAL(newConnection()), this, SLOT(newConnection())); + delete m_server; + m_server = 0; + } +} + +void ConnectionManager::newConnection() +{ + debugOutput(0, "ConnectionManager::newConnection()"); + + QTcpSocket* connection = m_server->nextPendingConnection(); + if (!connection) { + debugOutput(3, "Received connection has empty socket"); + return; + } + debugOutput(0, QString::fromLatin1(" received a connection: %1").arg((int) connection)); + new Connection(connection); +} + +Connection::Connection(QTcpSocket *socket) + : QObject() + , m_connection(socket) + , m_command(0) +{ + connect(m_connection, SIGNAL(readyRead()), this, SLOT(receiveCommand())); + connect(m_connection, SIGNAL(disconnected()), this, SLOT(closedConnection())); +} + +Connection::~Connection() +{ + if (m_command) { + m_command->commandFinished(); + delete m_command; + m_command = 0; + } + delete m_connection; +} + +void Connection::receiveCommand() +{ + QByteArray arr = m_connection->readAll(); + debugOutput(1, QString::fromLatin1("Command received: ") + (arr)); + QList commands = availableCommands(); + for(QList::iterator it = commands.begin(); it != commands.end(); ++it) { + if (it->commandName == QString::fromLatin1(arr)) { + debugOutput(1, "Found command in list"); + disconnect(m_connection, SIGNAL(readyRead()), this, SLOT(receiveCommand())); + AbstractCommand* command = (*it).commandFunc(); + command->setSocket(m_connection); + m_command = command; + return; + } + } + debugOutput(2, QString::fromLatin1("Unknown command received: ") + (arr)); +} + +void Connection::closedConnection() +{ + debugOutput(0, "connection being closed..."); + this->deleteLater(); +} diff --git a/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h new file mode 100644 index 0000000..21183ac --- /dev/null +++ b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CONNECTION_MANAGER_INCL +#define CONNECTION_MANAGER_INCL + +#include "transfer_global.h" +#include "commands.h" + +#include +#include + +class Connection : public QObject +{ + Q_OBJECT +public: + Connection(QTcpSocket* socket); + ~Connection(); + +public slots: + void receiveCommand(); + void closedConnection(); + +private: + QTcpSocket* m_connection; + AbstractCommand* m_command; +}; + +class ConnectionManager : public QObject +{ + Q_OBJECT +public: + ConnectionManager(); + ~ConnectionManager(); + + bool init(); + +public slots: + void cleanUp(); + void newConnection(); + +private: + QTcpServer* m_server; +}; + +#endif diff --git a/tools/qtestlib/wince/cetcpsyncserver/main.cpp b/tools/qtestlib/wince/cetcpsyncserver/main.cpp new file mode 100644 index 0000000..19d38ea --- /dev/null +++ b/tools/qtestlib/wince/cetcpsyncserver/main.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "connectionmanager.h" + +#include +#include + +void messageOutput(QtMsgType type, const char *msg) +{ + switch(type) { + case QtDebugMsg: fprintf(stderr, "Debug: %s\n", msg); break; + case QtWarningMsg: fprintf(stderr, "Warning: %s\n", msg); break; + default: fprintf(stderr, "Some Msg: %s\n", msg); break; + } +} + +int main(int argc, char **argv) +{ + qInstallMsgHandler(messageOutput); + + QCoreApplication app(argc, argv); + ConnectionManager manager; + manager.init(); + return app.exec(); +} diff --git a/tools/qtestlib/wince/cetcpsyncserver/transfer_global.h b/tools/qtestlib/wince/cetcpsyncserver/transfer_global.h new file mode 100644 index 0000000..5b6ff23 --- /dev/null +++ b/tools/qtestlib/wince/cetcpsyncserver/transfer_global.h @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TRANSFER_GLOBAL_H +#define TRANSFER_GLOBAL_H + +#include +#ifdef Q_OS_WIN +#include +#endif + +#define SERVER_PORT 12145 + +#define MAX_NAME_LENGTH 512 +#define MAX_ARGUMENTS 10 + +// Defines for commands sent/received +#define COMMAND_CREATE_FILE "CREATEFILE" +#define COMMAND_CREATE_DIRECTORY "CREATEDIR" +#define COMMAND_COPY_FILE "COPYFILE" +#define COMMAND_COPY_DIRECTORY "COPYDIR" +#define COMMAND_DELETE_FILE "DELETEFILE" +#define COMMAND_DELETE_DIRECTORY "DELETEDIR" +#define COMMAND_EXECUTE "EXECUTE" +#define COMMAND_QUIT_SERVER "QUIT" +#define COMMAND_FILE_TIME "FILETIME" +#define COMMAND_TIME_STAMP "TIMESTAMP" + +// Report back commands +#define COMMAND_SUCCESS "SUCCESS" +#define COMMAND_ERROR "ERROR" + +// Defines for commands that send data back to requester +#define COMMAND_READ_FILE "READFILE" +#define COMMAND_READ_DIRECTORY "READDIR" + +#include +// Option-Structures for commands + +struct CreateFileOptions +{ + char fileName[MAX_NAME_LENGTH]; +#ifdef Q_OS_WIN + FILETIME fileTime; + DWORD fileAttributes; +#endif + int fileSize; + bool overwriteExisting; +}; + +struct CreateDirectoryOptions +{ + char dirName[MAX_NAME_LENGTH]; + bool recursively; // in case of \foo\bar create \foo if it does not exist +}; + +struct CopyFileOptions +{ + char from[MAX_NAME_LENGTH]; + char to[MAX_NAME_LENGTH]; + bool overwriteExisting; +}; + +struct CopyDirectoryOptions +{ + char from[MAX_NAME_LENGTH]; + char to[MAX_NAME_LENGTH]; + bool recursive; +}; + +struct DeleteFileOptions +{ + char fileName[MAX_NAME_LENGTH]; +}; + +struct DeleteDirectoryOptions +{ + char dirName[MAX_NAME_LENGTH]; + bool recursive; + bool failIfContentExists; +}; + +struct ExecuteOptions +{ + char appName[MAX_NAME_LENGTH]; + int argumentsCount; + bool waitForFinished; + int timeout; +}; + +struct ReadFileOptions +{ + char fileName[MAX_NAME_LENGTH]; +}; + +struct ReadFileReply +{ + qint64 fileSize; + bool fileValid; +}; + +struct ReadDirectoryOptions +{ + char dirName[MAX_NAME_LENGTH]; +}; + +struct ReadDirectoryItem +{ + char name[MAX_NAME_LENGTH]; + qint64 size; + bool isDirectory; + bool hasMore; +}; + +#define FileTimeOptions ReadFileOptions + +struct ReadDirectoryReply +{ + bool entryValid; + int itemCount; // might change during iteration +}; +#endif -- cgit v0.12 From a34ec3bf9d6077bdc62cb48e116751788996fd99 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 5 Aug 2009 11:34:48 +0200 Subject: initial revision of cetcpsync This is the desktop client for communicating with a Windows CE device that runs the cetcpsync server. Reviewed-By: mauricek --- tools/qtestlib/wince/cetcpsync/cetcpsync.pro | 22 + tools/qtestlib/wince/cetcpsync/main.cpp | 191 +++++++ .../wince/cetcpsync/qtcesterconnection.cpp | 551 +++++++++++++++++++++ .../qtestlib/wince/cetcpsync/qtcesterconnection.h | 86 ++++ .../qtestlib/wince/cetcpsync/remoteconnection.cpp | 65 +++ tools/qtestlib/wince/cetcpsync/remoteconnection.h | 81 +++ 6 files changed, 996 insertions(+) create mode 100644 tools/qtestlib/wince/cetcpsync/cetcpsync.pro create mode 100644 tools/qtestlib/wince/cetcpsync/main.cpp create mode 100644 tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp create mode 100644 tools/qtestlib/wince/cetcpsync/qtcesterconnection.h create mode 100644 tools/qtestlib/wince/cetcpsync/remoteconnection.cpp create mode 100644 tools/qtestlib/wince/cetcpsync/remoteconnection.h diff --git a/tools/qtestlib/wince/cetcpsync/cetcpsync.pro b/tools/qtestlib/wince/cetcpsync/cetcpsync.pro new file mode 100644 index 0000000..d1d7c99 --- /dev/null +++ b/tools/qtestlib/wince/cetcpsync/cetcpsync.pro @@ -0,0 +1,22 @@ +TARGET = cetcpsync +DESTDIR = ../../../../bin +CONFIG += console +CONFIG -= app_bundle +QT += network +QT -= gui +TEMPLATE = app + +build_all:!build_pass { + CONFIG -= build_all + CONFIG += release +} + +INCLUDEPATH += ../cetcpsyncserver + +SOURCES += main.cpp \ + remoteconnection.cpp \ + qtcesterconnection.cpp + +HEADERS += \ + remoteconnection.h \ + qtcesterconnection.h diff --git a/tools/qtestlib/wince/cetcpsync/main.cpp b/tools/qtestlib/wince/cetcpsync/main.cpp new file mode 100644 index 0000000..73c7350 --- /dev/null +++ b/tools/qtestlib/wince/cetcpsync/main.cpp @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "qtcesterconnection.h" + +using namespace std; + +static void showUsage() +{ + cout << "cetcpsync is meant to be used by cetest internally." << endl + << "For usage instructions remoteconnection.h could be useful." << endl; +} + +const int debugLevel = 0; +void debugOutput(const QString& text, int level) +{ + if (level <= debugLevel) + cout << qPrintable(text) << endl; +} + +class Exception +{ +public: + Exception(const QString& msg = QString()) + : m_message(msg) + {} + + QString message() { return m_message; } + +protected: + QString m_message; +}; + +class TooFewParametersException : public Exception +{ +public: + TooFewParametersException(const QLatin1String& cmd, int expectedParameterCount) + { + m_message = QLatin1String("Command ") + cmd + QLatin1String(" needs at least "); + m_message.append(QString::number(expectedParameterCount)); + m_message.append(QLatin1String(" parameters.")); + } +}; + +static void fileTimeFromString(FILETIME& ft, const QString& str) +{ + int idx = str.indexOf("*"); + if (idx <= 0) + return; + ft.dwLowDateTime = str.left(idx).toULong(); + ft.dwHighDateTime = str.mid(idx+1).toULong(); +} + +static QString fileTimeToString(FILETIME& ft) +{ + return QString::number(ft.dwLowDateTime) + "*" + QString::number(ft.dwHighDateTime); +} + +static int execCommand(const QLatin1String& cmd, int argc, char* argv[]) +{ + int retval = 0; + bool success = true; + QtCesterConnection connection; + if (cmd == "copyFileToDevice") { + if (argc < 3) + throw TooFewParametersException(cmd, 3); + success = connection.copyFileToDevice(argv[0], argv[1], argv[2] == "true"); + } else if (cmd == "copyDirectoryToDevice") { + if (argc < 3) + throw TooFewParametersException(cmd, 3); + success = connection.copyDirectoryToDevice(argv[0], argv[1], argv[2] == "true"); + } else if (cmd == "copyFileFromDevice") { + if (argc < 3) + throw TooFewParametersException(cmd, 3); + success = connection.copyFileFromDevice(argv[0], argv[1], argv[2] == "true"); + } else if (cmd == "copyDirectoryFromDevice") { + if (argc < 3) + throw TooFewParametersException(cmd, 3); + success = connection.copyDirectoryFromDevice(argv[0], argv[1], argv[2] == "true"); + } else if (cmd == "timeStampForLocalFileTime") { + if (argc < 1) + throw TooFewParametersException(cmd, 1); + FILETIME ft; + fileTimeFromString(ft, argv[0]); + success = connection.timeStampForLocalFileTime(&ft); + if (success) + cout << qPrintable(fileTimeToString(ft)); + } else if (cmd == "fileCreationTime") { + if (argc < 1) + throw TooFewParametersException(cmd, 1); + FILETIME ft; + success = connection.fileCreationTime(argv[0], &ft); + if (success) + cout << qPrintable(fileTimeToString(ft)); + } else if (cmd == "copyFile") { + if (argc < 3) + throw TooFewParametersException(cmd, 3); + success = connection.copyFile(argv[0], argv[1], argv[2] == "true"); + } else if (cmd == "copyDirectory") { + if (argc < 3) + throw TooFewParametersException(cmd, 3); + success = connection.copyDirectory(argv[0], argv[1], argv[2] == "true"); + } else if (cmd == "deleteFile") { + if (argc < 1) + throw TooFewParametersException(cmd, 1); + success = connection.deleteFile(argv[0]); + } else if (cmd == "deleteDirectory") { + if (argc < 3) + throw TooFewParametersException(cmd, 3); + success = connection.deleteDirectory(argv[0], argv[1] == "true", argv[2] == "true"); + } else if (cmd == "moveFile") { + if (argc < 3) + throw TooFewParametersException(cmd, 3); + success = connection.moveFile(argv[0], argv[1], argv[2] == "true"); + } else if (cmd == "moveDirectory") { + if (argc < 3) + throw TooFewParametersException(cmd, 3); + success = connection.moveDirectory(argv[0], argv[1], argv[2] == "true"); + } else if (cmd == "createDirectory") { + if (argc < 2) + throw TooFewParametersException(cmd, 2); + success = connection.createDirectory(argv[0], argv[1] == "true"); + } else if (cmd == "execute") { + if (argc < 3) + throw TooFewParametersException(cmd, 3); + int timeout = QString(argv[2]).toInt(); + success = connection.execute(argv[0], argv[1], timeout, &retval); + } else if (cmd == "noop") { + // do nothing :) + success = true; + } else { + throw Exception("unknown command"); + } + + return success ? retval : 1; +} + +int main(int argc, char *argv[]) +{ + if (argc <= 1) { + showUsage(); + return 0; + } + + QLatin1String param(argv[1]); + int result = 1; + try { + result = execCommand(param, argc - 2, argv + 2); + } catch (Exception e) { + cerr << "Error: " << qPrintable(e.message()); + } + return result; +} diff --git a/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp new file mode 100644 index 0000000..4a8ae2b --- /dev/null +++ b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp @@ -0,0 +1,551 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qtcesterconnection.h" +#include +#include +#include +#include +#include +#include + +extern void debugOutput(const QString& text, int level); + +#pragma warning(disable:4996) + +#define END_ERROR(s, a) \ + if(a) qDebug() << a; \ + _freeSocket(s); \ + return false; + +QtCesterConnection::QtCesterConnection() + : AbstractRemoteConnection() +{ +} + +QtCesterConnection::~QtCesterConnection() +{ +} + +bool QtCesterConnection::connect(QVariantList&) +{ + // We connect with each command, so this is always true + // The command itself will fail then + connected = true; + return true; +} + +void QtCesterConnection::disconnect() +{ + connected = false; +} + +bool QtCesterConnection::isConnected() const +{ + return connected; +} + +bool QtCesterConnection::copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists) +{ + debugOutput( qPrintable(QString::fromLatin1("Copy File: %1 -> %2").arg(localSource).arg(deviceDest)),0); + QFile localFile(localSource); + QFileInfo info(localSource); + if (!localFile.exists() || !localFile.open(QIODevice::ReadOnly)) { + qDebug() << "Could not open File!"; + return false; + } + + QTcpSocket* socket = 0; + if (!_initCommand(socket, COMMAND_CREATE_FILE)) { + END_ERROR(socket, "Could not initialized command"); + } + + CreateFileOptions option; + strcpy(option.fileName, qPrintable(deviceDest)); +#ifdef Q_OS_WIN + // Copy FileTime for update verification + FILETIME creationTime, accessTime, writeTime; + HANDLE localHandle = CreateFile(localSource.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); + if (localHandle != INVALID_HANDLE_VALUE) { + if (GetFileTime(localHandle, &creationTime, &accessTime, &writeTime)) { + LocalFileTimeToFileTime(&writeTime, &writeTime); + option.fileTime = writeTime; + } + CloseHandle(localHandle); + } + DWORD attributes = GetFileAttributes(localSource.utf16()); + if (attributes != -1 ) + option.fileAttributes = attributes; +#endif + option.fileSize = info.size(); + option.overwriteExisting = !failIfExists; + + if (!_sendData(socket, (char*) &option, sizeof(option))) { + END_ERROR(socket, "Could not send options..."); + } + + if (!_checkResult(socket)) { + END_ERROR(socket, "Server did not accept configuration"); + } + + int bytesWritten = 0; + const int bufferSize = 1024; + QByteArray data; + while (bytesWritten < option.fileSize) { + data = localFile.read(bufferSize); + bytesWritten += data.size(); +#ifdef Q_OS_WIN + wprintf( L"%s -> %s (%d / %d) %d %%\r", localSource.utf16() , deviceDest.utf16(), + bytesWritten , option.fileSize, (100*bytesWritten)/option.fileSize ); +#endif + if (!_sendData(socket, data.constData(), data.size())) { + END_ERROR(socket, "Error during file transfer"); + } + if (!_checkResult(socket)) { + END_ERROR(socket, "Got some strange result"); + } + } +#ifdef Q_OS_WIN + wprintf( L"\n"); // We should jump to next line... +#endif + if (bytesWritten != option.fileSize) { + END_ERROR(socket, "Did not send sufficient data"); + } + _freeSocket(socket); + return true; +} + +bool QtCesterConnection::copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive) +{ + QTcpSocket* socket = NULL; + QFileInfo info(localSource); + if (!info.exists() || !info.isDir()) { + END_ERROR(socket, "Input directory invalid"); + } + + createDirectory(deviceDest, true); + QDir dir(localSource); + QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); + foreach(QFileInfo item, list) { + QString targetName = deviceDest + QLatin1String("\\") + item.fileName(); + if (item.isDir()) { + if (recursive) { + if (!copyDirectoryToDevice(item.absoluteFilePath() , targetName, recursive)) + return false; + } + } else { + if (!copyFileToDevice(item.absoluteFilePath(), targetName)) + return false; + } + } + return true; +} + +bool QtCesterConnection::copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists) +{ + QFile targetFile(localDest); + QTcpSocket* socket = 0; + if (targetFile.exists() && failIfExists) { + END_ERROR(socket, "Local file not supposed to be overwritten"); + } + + if (!targetFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { + END_ERROR(socket, "Could not open local file for writing"); + } + + if (!_initCommand(socket, COMMAND_READ_FILE)) { + END_ERROR(socket, "Could not establish connection"); + } + + ReadFileOptions option; + strcpy(option.fileName, qPrintable(deviceSource)); + if (!_sendData(socket, (char*) &option, sizeof(option))) { + END_ERROR(socket, "Could not send options"); + } + + QByteArray data; + if (!_receiveData(socket, data)) { + END_ERROR(socket, "Did not receive any data"); + } + + ReadFileReply* reply = (ReadFileReply*) data.data(); + if (!reply->fileValid) { + END_ERROR(socket, "Requested file invalid"); + } + + int fileSize = reply->fileSize; + int currentSize = 0; + // ### TODO: make a little bit more error-prone + do { + _sendData(socket, COMMAND_SUCCESS, strlen(COMMAND_SUCCESS)); + _receiveData(socket, data); + currentSize += data.size(); + targetFile.write(data); + } while(currentSize < fileSize); + + _freeSocket(socket); + targetFile.close(); + return true; +} + +bool QtCesterConnection::copyDirectoryFromDevice(const QString& /*deviceSource*/ + , const QString& /*localDest*/ + , bool /*recursive*/) +{ + qDebug() << "To be implemented!! Should not be needed for autotest system"; + exit(-1); + return false; +} + +bool QtCesterConnection::copyFile(const QString &srcFile, const QString &destFile, bool failIfExists) +{ + QTcpSocket* socket = 0; + if (!_initCommand(socket, COMMAND_COPY_FILE)) { + END_ERROR(socket, "Could not establish connection for copy"); + } + + CopyFileOptions option; + strcpy(option.from, qPrintable(srcFile)); + strcpy(option.to, qPrintable(destFile)); + option.overwriteExisting = !failIfExists; + if (!_sendData(socket, (char*) &option, sizeof(option))) { + END_ERROR(socket, "Could not send copy options"); + } + + if (!_checkResult(socket)) { + END_ERROR(socket, "Copy failed"); + } + + _freeSocket(socket); + return true; +} + +bool QtCesterConnection::copyDirectory(const QString &srcDirectory, const QString &destDirectory, + bool recursive) +{ + QTcpSocket* socket = 0; + if (!_initCommand(socket, COMMAND_COPY_DIRECTORY)) { + END_ERROR(socket, "Could not establish connection for dir copy"); + } + + CopyDirectoryOptions option; + strcpy(option.from, qPrintable(srcDirectory)); + strcpy(option.to, qPrintable(destDirectory)); + option.recursive = recursive; + if (!_sendData(socket, (char*) &option, sizeof(option))) { + END_ERROR(socket, "Could not send dir copy options"); + } + + if (!_checkResult(socket)) { + END_ERROR(socket, "Dir Copy failed"); + } + + _freeSocket(socket); + return true; +} + +bool QtCesterConnection::deleteFile(const QString &fileName) +{ + QTcpSocket* socket = 0; + if (!_initCommand(socket, COMMAND_DELETE_FILE)) { + END_ERROR(socket, "Could not establish connection for file deletion"); + } + + DeleteFileOptions option; + strcpy(option.fileName, qPrintable(fileName)); + if (!_sendData(socket, (char*) &option, sizeof(option))) { + END_ERROR(socket, "Could not send file options"); + } + + if (!_checkResult(socket)) { + END_ERROR(socket, "File Deletion failed"); + } + + _freeSocket(socket); + return true; +} + +bool QtCesterConnection::deleteDirectory(const QString &directory, bool recursive, bool failIfContentExists) +{ + QTcpSocket* socket = 0; + if (!_initCommand(socket, COMMAND_DELETE_DIRECTORY)) { + END_ERROR(socket, "Could not establish connection for dir deletion"); + } + + DeleteDirectoryOptions option; + strcpy(option.dirName, qPrintable(directory)); + option.recursive = recursive; + option.failIfContentExists = failIfContentExists; + if (!_sendData(socket, (char*) &option, sizeof(option))) { + END_ERROR(socket, "Could not send dir options"); + } + + if (!_checkResult(socket)) { + // we do not write an error as this will fail a lot on recursive. + END_ERROR(socket, 0); + } + + _freeSocket(socket); + return true; +} + +bool QtCesterConnection::execute(QString program, + QString arguments, + int timeout, + int *returnValue) +{ + QTcpSocket* socket = 0; + if (!_initCommand(socket, COMMAND_EXECUTE)) { + END_ERROR(socket, "Could not establish connection for dir deletion"); + } + + ExecuteOptions options; + strcpy(options.appName, qPrintable(program)); + QStringList argList = arguments.split(QLatin1Char(' ')); + options.argumentsCount = qMin(argList.size(), MAX_ARGUMENTS); + options.waitForFinished = true; + options.timeout = timeout; + if (!_sendData(socket, (char*) &options, sizeof(options))) { + END_ERROR(socket, "Could not send dir options"); + } + if (!_checkResult(socket)) { + END_ERROR(socket, "Did not receive an answer"); + } + + for (int i=0; i < options.argumentsCount; ++i) { + char someData[MAX_NAME_LENGTH]; + strcpy(someData, qPrintable(argList[i])); + if (!_sendData(socket, someData, MAX_NAME_LENGTH)) { + END_ERROR(socket, "Could not send argument"); + } + if (!_checkResult(socket)) { + END_ERROR(socket, "Failure in argument send"); + } + } + + // trigger the startup + if (!_sendData(socket, COMMAND_SUCCESS, strlen(COMMAND_SUCCESS))) { + END_ERROR(socket, "Could not trigger startup"); + } + + const int waitTime = 60 * 60 * 1000; + if (!socket->waitForReadyRead(waitTime)) { + END_ERROR(socket, "Process timed out"); + } + + QByteArray result = socket->readAll(); + if (result != COMMAND_SUCCESS) { + if (returnValue) + *returnValue = -1; // just some at least + END_ERROR(socket, "Application did not start or returned error"); + } + + if (returnValue) + *returnValue = 0; + _freeSocket(socket); + return true; +} + +bool QtCesterConnection::createDirectory(const QString &path, bool deleteBefore) +{ + if (deleteBefore) + deleteDirectory(path, true, true); + + QTcpSocket* socket = 0; + if (!_initCommand(socket, COMMAND_CREATE_DIRECTORY)) { + END_ERROR(socket, "Could not establish connection for dir creation"); + } + + CreateDirectoryOptions option; + strcpy(option.dirName, qPrintable(path)); + option.recursively = true; + if (!_sendData(socket, (char*) &option, sizeof(option))) { + END_ERROR(socket, "Could not send dir options"); + } + + if (!_checkResult(socket)) { + END_ERROR(socket, "Dir creation failed"); + } + + _freeSocket(socket); + return true; +} + +bool QtCesterConnection::timeStampForLocalFileTime(FILETIME* fTime) const +{ + if (!fTime) + return false; + + FILETIME copyTime = *fTime; + LocalFileTimeToFileTime(©Time, ©Time); + + QTcpSocket* socket = 0; + if (!_initCommand(socket, COMMAND_TIME_STAMP)) { + END_ERROR(socket, "Could not establish time stamp connection"); + } + + if (!_sendData(socket, (char*) ©Time, sizeof(copyTime))) { + END_ERROR(socket, "Could not send stamp time"); + } + + QByteArray data; + if (!_receiveData(socket, data)) { + END_ERROR(socket, "Did not receive time stamp or connection interrupted"); + } + + copyTime = *((FILETIME*)data.data()); + if (copyTime.dwLowDateTime == -1 && copyTime.dwHighDateTime == -1) { + END_ERROR(socket, "remote Time stamp failed!"); + } + + *fTime = copyTime; + _freeSocket(socket); + return true; +} + +bool QtCesterConnection::fileCreationTime(const QString &fileName, FILETIME* deviceCreationTime) const +{ + if (!deviceCreationTime) + return false; + + QTcpSocket* socket = 0; + if (!_initCommand(socket, COMMAND_FILE_TIME)) { + END_ERROR(socket, "Could not establish connection for file time access"); + } + + FileTimeOptions option; + strcpy(option.fileName, qPrintable(fileName)); + if (!_sendData(socket, (char*) &option, sizeof(option))) { + END_ERROR(socket, "Could not send file time name"); + } + + QByteArray data; + if (!_receiveData(socket, data)) { + END_ERROR(socket, "File Time request failed"); + } + + FILETIME* resultTime = (FILETIME*) data.data(); + if (resultTime->dwLowDateTime == -1 && resultTime->dwHighDateTime == -1) { + END_ERROR(socket, 0); + debugOutput("Could not access file time", 0); + } + + *deviceCreationTime = *resultTime; + _freeSocket(socket); + return true; +} + +bool QtCesterConnection::_createSocket(QTcpSocket*& result) const +{ + QTcpSocket* sock = new QTcpSocket(); + QByteArray ipAddress = qgetenv("DEVICE_IP"); + if (ipAddress.isEmpty()) { + qWarning("Error: You need to have DEVICE_IP set"); + exit(0); + } + sock->connectToHost(QHostAddress(QString(ipAddress)), 12145); + + if (!sock->waitForConnected()) { + qDebug() << "connection timeout..."; + result = NULL; + return false; + } + result = sock; + return true; +} + +void QtCesterConnection::_freeSocket(QTcpSocket*& sock) const +{ + if (!sock) + return; + if (sock->state() == QAbstractSocket::ConnectedState) { + sock->disconnectFromHost(); + // seems like no need to wait + //sock->waitForDisconnected(); + } + delete sock; + sock = NULL; +#ifdef Q_OS_WIN + Sleep(100); +#endif +} + +bool QtCesterConnection::_initCommand(QTcpSocket*& sock, const char* command) const +{ + QTcpSocket* socket = NULL; + if (!_createSocket(socket)) { + END_ERROR(socket, "Could not connect to server"); + } + + if (!_sendData(socket, command, strlen(command)) || + !_checkResult(socket)) { + END_ERROR(socket, "Cound not send command"); + } + sock = socket; + return true; +} + +bool QtCesterConnection::_sendData(QTcpSocket*& sock, const char* data, int dataSize) const +{ + int amount = sock->write(data, dataSize); + if (amount != dataSize) { + fprintf(stderr, "*******COULD NOT SEND ENOUGH DATA*************\n"); + } + return sock->waitForBytesWritten(); +} + +bool QtCesterConnection::_receiveData(QTcpSocket*& sock, QByteArray& data) const +{ + if (!sock->waitForReadyRead()) { + qDebug() << "did not receive any data"; + return false; + } + data = sock->readAll(); + return true; +} + +bool QtCesterConnection::_checkResult(QTcpSocket*& sock) const +{ + QByteArray response; + if (!_receiveData(sock, response) || response != COMMAND_SUCCESS) + return false; + return true; +} + diff --git a/tools/qtestlib/wince/cetcpsync/qtcesterconnection.h b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.h new file mode 100644 index 0000000..d7b8393 --- /dev/null +++ b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef ACTIVESYNC_REMOTECONNECTION_H +#define ACTIVESYNC_REMOTECONNECTION_H + +#include "remoteconnection.h" + +class QTcpSocket; + +class QtCesterConnection : public AbstractRemoteConnection +{ +public: + QtCesterConnection(); + virtual ~QtCesterConnection(); + + bool connect(QVariantList &list = QVariantList()); + void disconnect(); + bool isConnected() const; + + // These functions are designed for transfer between desktop and device + // Caution: deviceDest path has to be device specific (eg. no drive letters for CE) + bool copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists = false); + bool copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive = true); + bool copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists = false); + bool copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive = true); + + bool timeStampForLocalFileTime(FILETIME*) const; + bool fileCreationTime(const QString &fileName, FILETIME*) const; + + // These functions only work on files existing on the device + bool copyFile(const QString&, const QString&, bool failIfExists = false); + bool copyDirectory(const QString&, const QString&, bool recursive = true); + bool deleteFile(const QString&); + bool deleteDirectory(const QString&, bool recursive = true, bool failIfContentExists = false); + bool createDirectory(const QString&, bool deleteBefore=false); + + bool execute(QString program, QString arguments = QString(), int timeout = -1, int *returnValue = NULL); +private: + bool _createSocket(QTcpSocket*&) const; + void _freeSocket(QTcpSocket*&) const; + bool _initCommand(QTcpSocket*&, const char*) const; + bool _sendData(QTcpSocket*&, const char* data, int dataSize) const; + bool _receiveData(QTcpSocket*&, QByteArray&) const; + bool _checkResult(QTcpSocket*&) const; + bool connected; +}; + +#endif diff --git a/tools/qtestlib/wince/cetcpsync/remoteconnection.cpp b/tools/qtestlib/wince/cetcpsync/remoteconnection.cpp new file mode 100644 index 0000000..b197c5c --- /dev/null +++ b/tools/qtestlib/wince/cetcpsync/remoteconnection.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "remoteconnection.h" + +AbstractRemoteConnection::AbstractRemoteConnection() +{ +} + +AbstractRemoteConnection::~AbstractRemoteConnection() +{ +} + +// Slow but should be ok... +bool AbstractRemoteConnection::moveFile(const QString &src, const QString &dest, bool FailIfExists) +{ + bool result = copyFile(src, dest, FailIfExists); + deleteFile(src); + return result; +} + +// Slow but should be ok... +bool AbstractRemoteConnection::moveDirectory(const QString &src, const QString &dest, bool recursive) +{ + bool result = copyDirectory(src, dest, true); + deleteDirectory(src, recursive); + return result; +} diff --git a/tools/qtestlib/wince/cetcpsync/remoteconnection.h b/tools/qtestlib/wince/cetcpsync/remoteconnection.h new file mode 100644 index 0000000..fae6f7f --- /dev/null +++ b/tools/qtestlib/wince/cetcpsync/remoteconnection.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef REMOTECONNECTION_H +#define REMOTECONNECTION_H + +#include +#include +#include +class AbstractRemoteConnection +{ +public: + AbstractRemoteConnection(); + virtual ~AbstractRemoteConnection(); + + virtual bool connect(QVariantList&) = 0; + virtual void disconnect() = 0; + virtual bool isConnected() const = 0; + + // These functions are designed for transfer between desktop and device + // Caution: deviceDest path has to be device specific (eg. no drive letters for CE) + virtual bool copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists = false) = 0; + virtual bool copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive = true) = 0; + virtual bool copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists = false) = 0; + virtual bool copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive = true) = 0; + + // For "intelligent deployment" we need to investigate on filetimes on the device + virtual bool timeStampForLocalFileTime(FILETIME*) const = 0; + virtual bool fileCreationTime(const QString &fileName, FILETIME*) const = 0; + + // These functions only work on files existing on the device + virtual bool copyFile(const QString&, const QString&, bool failIfExists = false) = 0; + virtual bool copyDirectory(const QString&, const QString&, bool recursive = true) = 0; + virtual bool deleteFile(const QString&) = 0; + virtual bool deleteDirectory(const QString&, bool recursive = true, bool failIfContentExists = false) = 0; + bool moveFile(const QString&, const QString&, bool FailIfExists = false); + bool moveDirectory(const QString&, const QString&, bool recursive = true); + + virtual bool createDirectory(const QString&, bool deleteBefore=false) = 0; + + virtual bool execute(QString program, QString arguments = QString(), int timeout = -1, int *returnValue = NULL) = 0; +}; + +#endif -- cgit v0.12 From f78bd88cbb8fd4c32e487eed716f089b6f5cfe28 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 5 Aug 2009 12:58:39 +0200 Subject: Workaround a crash in qdoc. Caused by an odd number of classes it seems. --- tools/qdoc3/htmlgenerator.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 6b15f96..df63138 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -2097,6 +2097,11 @@ void HtmlGenerator::generateCompactList(const Node *relative, currentOffsetInParagraph[i] = 0; } + if (currentParagraphNo[i] >= NumParagraphs) { + qDebug() << "### Internal error ###" << __FILE__ << __LINE__; + currentParagraphNo[i] = NumParagraphs - 1; + } + out() << ""; if (currentOffsetInParagraph[i] == 0) { // start a new paragraph -- cgit v0.12 From 0002516329cbbf5fb0b677835353bf7ccd4e425f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 5 Aug 2009 13:01:02 +0200 Subject: missing license header added in cetcpsyncsvr Reviewed-by: TrustMe --- tools/qtestlib/wince/cetcpsyncserver/commands.cpp | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tools/qtestlib/wince/cetcpsyncserver/commands.cpp b/tools/qtestlib/wince/cetcpsyncserver/commands.cpp index 64869c4..0c4d3bc 100644 --- a/tools/qtestlib/wince/cetcpsyncserver/commands.cpp +++ b/tools/qtestlib/wince/cetcpsyncserver/commands.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include "commands.h" #include #include -- cgit v0.12 From 770ce0a8cd7493e3be3e7accf7133778336c6f5d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 5 Aug 2009 13:02:18 +0200 Subject: small cleanup in cetest Reviewed-by: TrustMe --- .../qtestlib/wince/cetest/cetcpsyncconnection.cpp | 31 +++++++++++----------- tools/qtestlib/wince/cetest/cetest.pro | 4 +-- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp index bebcd1c..f00d2b8 100644 --- a/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp +++ b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp @@ -44,6 +44,7 @@ #include #include +static const QString ceTcpSyncProgram = ceTcpSyncProgram + ""; extern void debugOutput(const QString& text, int level); CeTcpSyncConnection::CeTcpSyncConnection() @@ -62,7 +63,7 @@ bool CeTcpSyncConnection::connect(QVariantList&) { // We connect with each command, so this is always true // The command itself will fail then - if (system("cetcpsync noop") != 0) + if (system(ceTcpSyncProgram + " noop") != 0) return false; connected = true; return true; @@ -103,56 +104,56 @@ static QString fileTimeToString(FILETIME& ft) bool CeTcpSyncConnection::copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists) { - QString cmd = "cetcpsync copyFileToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(failIfExists); + QString cmd = ceTcpSyncProgram + " copyFileToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(failIfExists); return system(qPrintable(cmd)) == 0; } bool CeTcpSyncConnection::copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive) { - QString cmd = "cetcpsync copyDirectoryToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(recursive); + QString cmd = ceTcpSyncProgram + " copyDirectoryToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(recursive); return system(qPrintable(cmd)) == 0; } bool CeTcpSyncConnection::copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists) { - QString cmd = "cetcpsync copyFileFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(failIfExists); + QString cmd = ceTcpSyncProgram + " copyFileFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(failIfExists); return system(qPrintable(cmd)) == 0; } bool CeTcpSyncConnection::copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive) { - QString cmd = "cetcpsync copyDirectoryFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(recursive); + QString cmd = ceTcpSyncProgram + " copyDirectoryFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(recursive); return system(qPrintable(cmd)) == 0; } bool CeTcpSyncConnection::copyFile(const QString &srcFile, const QString &destFile, bool failIfExists) { - QString cmd = "cetcpsync copyFile \"" + srcFile + "\" \"" + destFile + "\" " + boolToString(failIfExists); + QString cmd = ceTcpSyncProgram + " copyFile \"" + srcFile + "\" \"" + destFile + "\" " + boolToString(failIfExists); return system(qPrintable(cmd)) == 0; } bool CeTcpSyncConnection::copyDirectory(const QString &srcDirectory, const QString &destDirectory, bool recursive) { - QString cmd = "cetcpsync copyDirectory \"" + srcDirectory + "\" \"" + destDirectory + "\" " + boolToString(recursive); + QString cmd = ceTcpSyncProgram + " copyDirectory \"" + srcDirectory + "\" \"" + destDirectory + "\" " + boolToString(recursive); return system(qPrintable(cmd)) == 0; } bool CeTcpSyncConnection::deleteFile(const QString &fileName) { - QString cmd = "cetcpsync deleteFile \"" + fileName + "\""; + QString cmd = ceTcpSyncProgram + " deleteFile \"" + fileName + "\""; return system(qPrintable(cmd)) == 0; } bool CeTcpSyncConnection::deleteDirectory(const QString &directory, bool recursive, bool failIfContentExists) { - QString cmd = "cetcpsync deleteDirectory \"" + directory + "\" " + boolToString(recursive) + " " + boolToString(failIfContentExists); + QString cmd = ceTcpSyncProgram + " deleteDirectory \"" + directory + "\" " + boolToString(recursive) + " " + boolToString(failIfContentExists); return system(qPrintable(cmd)) == 0; } bool CeTcpSyncConnection::execute(QString program, QString arguments, int timeout, int *returnValue) { - QString cmd = "cetcpsync execute \"" + program + "\" \"" + arguments + "\" " + QString::number(timeout); + QString cmd = ceTcpSyncProgram + " execute \"" + program + "\" \"" + arguments + "\" " + QString::number(timeout); int exitCode = system(qPrintable(cmd)); if (returnValue) *returnValue = exitCode; @@ -161,17 +162,17 @@ bool CeTcpSyncConnection::execute(QString program, QString arguments, int timeou bool CeTcpSyncConnection::createDirectory(const QString &path, bool deleteBefore) { - QString cmd = "cetcpsync createDirectory \"" + path + "\" " + boolToString(deleteBefore); + QString cmd = ceTcpSyncProgram + " createDirectory \"" + path + "\" " + boolToString(deleteBefore); return system(qPrintable(cmd)) == 0; } bool CeTcpSyncConnection::timeStampForLocalFileTime(FILETIME* fTime) const { - QString cmd = "cetcpsync timeStampForLocalFileTime " + fileTimeToString(*fTime) + " >filetime.txt"; + QString cmd = ceTcpSyncProgram + " timeStampForLocalFileTime " + fileTimeToString(*fTime) + " >qt_cetcpsyncdata.txt"; if (system(qPrintable(cmd)) != 0) return false; - QFile file("filetime.txt"); + QFile file("qt_cetcpsyncdata.txt"); if (!file.open(QIODevice::ReadOnly)) return false; @@ -183,11 +184,11 @@ bool CeTcpSyncConnection::timeStampForLocalFileTime(FILETIME* fTime) const bool CeTcpSyncConnection::fileCreationTime(const QString &fileName, FILETIME* deviceCreationTime) const { - QString cmd = "cetcpsync fileCreationTime \"" + fileName + "\" >filetime.txt"; + QString cmd = ceTcpSyncProgram + " fileCreationTime \"" + fileName + "\" >qt_cetcpsyncdata.txt"; if (system(qPrintable(cmd)) != 0) return false; - QFile file("filetime.txt"); + QFile file("qt_cetcpsyncdata.txt"); if (!file.open(QIODevice::ReadOnly)) return false; diff --git a/tools/qtestlib/wince/cetest/cetest.pro b/tools/qtestlib/wince/cetest/cetest.pro index c6eba7f..a6b79da 100644 --- a/tools/qtestlib/wince/cetest/cetest.pro +++ b/tools/qtestlib/wince/cetest/cetest.pro @@ -35,7 +35,7 @@ SOURCES += \ deployment.cpp \ main.cpp -win32-msvc*:LIBS += ole32.lib advapi32.lib +LIBS += ole32.lib advapi32.lib isEmpty(QT_CE_RAPI_INC) { DEFINES += QT_CETEST_NO_ACTIVESYNC @@ -44,7 +44,7 @@ isEmpty(QT_CE_RAPI_INC) { } else { HEADERS += activesyncconnection.h SOURCES += activesyncconnection.cpp - win32-msvc*:LIBS += rapi.lib + LIBS += rapi.lib INCLUDEPATH += $$QT_CE_RAPI_INC LIBS += -L$$QT_CE_RAPI_LIB } -- cgit v0.12 From 0ba2e3c4fa088a5467279cf851b2b49697ccad5c Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 5 Aug 2009 13:14:16 +0200 Subject: Re-enable the use of Common Item Dialog This was disabled by patch bf305bc2e488ad4f08c49767246f31a81218991e Reviewed-by: Thomas Hartmann --- src/gui/dialogs/qfiledialog_win.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index 9bf82c3..c542ff0 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -59,7 +59,9 @@ #endif #include - +#if !defined(Q_WS_WINCE) +#include +#endif #include #if defined(__IFileDialog_INTERFACE_DEFINED__) \ -- cgit v0.12 From b4f1f4de1a0df7028440faaff146ac1560dc6169 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 5 Aug 2009 13:17:39 +0200 Subject: MainWindow: fixed an update issue when moving a separator A non painted (ie. garbage) area could appear if you had a fixed size dock widget and you moved the separator. The previous place where the separator was painted was not updated --- src/gui/widgets/qmainwindowlayout.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 3936a67..55afa70 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -1988,6 +1988,9 @@ void QMainWindowLayout::timerEvent(QTimerEvent *e) if (movingSeparatorOrigin == movingSeparatorPos) return; + //when moving the separator, we need to update the previous position + parentWidget()->update(layoutState.dockAreaLayout.separatorRegion()); + layoutState = savedState; layoutState.dockAreaLayout.separatorMove(movingSeparator, movingSeparatorOrigin, movingSeparatorPos); -- cgit v0.12 From ca2a9d87d81095f6ff7b821e3d8cbe120a6d9b23 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 5 Aug 2009 13:13:33 +0200 Subject: Fix regressions introduced by 31edb4d5a63b9b3c28cce1c4ca6eb99f62a09759 The commit 31edb4d5a63b9b3c28cce1c4ca6eb99f62a09759 introduced regressions in filters which breaks the mac native dialog, the non native dialog with HideNameFilterDetails activated. Task-number:259105 Reviewed-by:olivier Reviewed-by:prasanth --- src/gui/dialogs/qfiledialog.cpp | 14 ++++++---- src/gui/dialogs/qfiledialog_win.cpp | 2 ++ tests/auto/qfiledialog/tst_qfiledialog.cpp | 43 ++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 1ec94b6..f000033 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -394,6 +394,9 @@ QList QFileDialog::sidebarUrls() const static const qint32 QFileDialogMagic = 0xbe; +const char *qt_file_dialog_filter_reg_exp = +"^(.*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"; + /*! \since 4.3 Saves the state of the dialog's layout, history and current directory. @@ -984,8 +987,13 @@ void QFileDialog::setNameFilters(const QStringList &filters) if (testOption(HideNameFilterDetails)) { QStringList strippedFilters; + QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp)); for (int i = 0; i < cleanedFilters.count(); ++i) { - strippedFilters.append(cleanedFilters[i].mid(0, cleanedFilters[i].indexOf(QLatin1String(" (")))); + QString filterName; + int index = r.indexIn(cleanedFilters[i]); + if (index >= 0) + filterName = r.cap(1); + strippedFilters.append(filterName.simplified()); } d->qFileDialogUi->fileTypeCombo->addItems(strippedFilters); } else { @@ -2837,10 +2845,6 @@ void QFileDialogPrivate::_q_goToDirectory(const QString &path) } } -const char *qt_file_dialog_filter_reg_exp = -"(\\W|[a-zA-Z0-9 -]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"; - - // Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)" QStringList qt_clean_filter_list(const QString &filter) { diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index c542ff0..02469b2 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -443,6 +443,8 @@ static bool qt_win_set_IFileDialogOptions(IFileDialog *pfd, QString subfilter = *it; if (!subfilter.isEmpty()) { offsets<