diff options
47 files changed, 837 insertions, 248 deletions
diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp index 4021352..f8ca8ea 100644 --- a/demos/qmediaplayer/mediaplayer.cpp +++ b/demos/qmediaplayer/mediaplayer.cpp @@ -266,6 +266,9 @@ MediaPlayer::MediaPlayer(const QString &filePath, fileMenu = new QMenu(this); QAction *openFileAction = fileMenu->addAction(tr("Open &File...")); QAction *openUrlAction = fileMenu->addAction(tr("Open &Location...")); + QAction *const openLinkAction = fileMenu->addAction(tr("Open &RAM File...")); + + connect(openLinkAction, SIGNAL(triggered(bool)), this, SLOT(openRamFile())); fileMenu->addSeparator(); QMenu *aspectMenu = fileMenu->addMenu(tr("&Aspect ratio")); @@ -835,6 +838,51 @@ void MediaPlayer::openUrl() } } +/*! + \since 4.6 + */ +void MediaPlayer::openRamFile() +{ + QSettings settings; + settings.beginGroup(QLatin1String("BrowserMainWindow")); + + const QStringList fileNameList(QFileDialog::getOpenFileNames(this, + QString(), + settings.value("openRamFile").toString(), + QLatin1String("RAM files (*.ram)"))); + + if (fileNameList.isEmpty()) + return; + + QFile linkFile; + QList<QUrl> list; + QByteArray sourceURL; + for (int i = 0; i < fileNameList.count(); i++ ) { + linkFile.setFileName(fileNameList[i]); + if (linkFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + while (!linkFile.atEnd()) { + sourceURL = linkFile.readLine().trimmed(); + if (!sourceURL.isEmpty()) { + const QUrl url(QUrl::fromEncoded(sourceURL)); + if (url.isValid()) + list.append(url); + } + } + linkFile.close(); + } + } + + if (!list.isEmpty()) { + m_MediaObject.setCurrentSource(Phonon::MediaSource(list[0])); + m_MediaObject.play(); + for (int i = 1; i < list.count(); i++) + m_MediaObject.enqueue(Phonon::MediaSource(list[i])); + } + + forwardButton->setEnabled(!m_MediaObject.queue().isEmpty()); + settings.setValue("openRamFile", fileNameList[0]); +} + void MediaPlayer::finished() { } diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h index a1c3d92..a8f18f0 100644 --- a/demos/qmediaplayer/mediaplayer.h +++ b/demos/qmediaplayer/mediaplayer.h @@ -107,6 +107,7 @@ private slots: void showContextMenu(const QPoint &); void bufferStatus(int percent); void openUrl(); + void openRamFile(); void configureEffect(); void hasVideoChanged(bool); diff --git a/demos/qmediaplayer/qmediaplayer.pro b/demos/qmediaplayer/qmediaplayer.pro index 2f15c28..9407a81 100644 --- a/demos/qmediaplayer/qmediaplayer.pro +++ b/demos/qmediaplayer/qmediaplayer.pro @@ -32,4 +32,6 @@ symbian { DEPLOYMENT += addFiles include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + TARGET.CAPABILITY="NetworkServices" } diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 736fa66..887c96f 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -73,6 +73,8 @@ New features * Support for getting return arguments in remote method invocation via QMetaMethod::invokeMethod. + - The QtScript module is now based on the 3rdparty JavaScriptCore library. It + is only available under the LGPL or a compatible license. Optimizations ------------- diff --git a/doc/src/deployment/deployment.qdoc b/doc/src/deployment/deployment.qdoc index ea841f9..6a1760e 100644 --- a/doc/src/deployment/deployment.qdoc +++ b/doc/src/deployment/deployment.qdoc @@ -1491,7 +1491,13 @@ \o Accessibility for Qt3Support is deployed if the application uses the Qt3Support module. \endlist - macdeployqt supports the following options: + \note If you want a 3rd party library to be included in your + application bundle, then you must add an excplicit lib entry for + that library to your application's .pro file. Otherwise, the + \c macdeployqt tool will not copy the 3rd party .dylib into the + bundle. + + \c macdeployqt supports the following options: \list \o -no-plugins: Skip plugin deployment \o -dmg : Create a .dmg disk image diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index b5dc03d..e951804 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -794,6 +794,7 @@ \o \l{opengl/framebufferobject2}{Framebuffer Object 2} \o \l{opengl/grabber}{Grabber} \o \l{opengl/hellogl}{Hello GL}\raisedaster + \o \l{opengl/hellogl_es}{Hello GL - ported to Windows CE}\raisedaster \o \l{opengl/overpainting}{Overpainting}\raisedaster \o \l{opengl/pbuffers}{Pixel Buffers} \o \l{opengl/pbuffers2}{Pixel Buffers 2} diff --git a/doc/src/getting-started/known-issues.qdoc b/doc/src/getting-started/known-issues.qdoc index 3c92257..b8c2192 100644 --- a/doc/src/getting-started/known-issues.qdoc +++ b/doc/src/getting-started/known-issues.qdoc @@ -61,27 +61,33 @@ \section2 Installing the Source Package on Unix systems + \list + \o If you download a Zip source package, you will need to convert Windows-style line endings (CR/LF) to Unix-style line-endings (LF) when you uncompress the package. To do this, give the "-a" option when you run the "unzip' command. - - If you fail to supply the "-a" option when unzipping the package, you + + \o If you fail to supply the "-a" option when unzipping the package, you will see the following error message when you attempt to execute the configure command: "bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory" + \endlist \section2 Installing on Mac OS X 10.6 "Snow Leopard" + \list + \o Performing a new install of the Qt 4.6 beta on Snow Leopard triggers a bug in the installer that causes the install to fail. Updating an existing Qt installation works fine. - There are two workarounds, either disable spotlight for the target + \o There are two workarounds, either disable spotlight for the target drive during the install, or do a custom install where you deselect documentation and examples. Run the installer again as a full install to get the documentation and examples installed. + \endlist \section1 Issues with Third Party Software @@ -107,6 +113,7 @@ \section2 Windows \list + \o When using version 6.14.11.6921 of the NVIDIA drivers for the GeForce 6600 GT under Windows XP, Qt applications which use drag and drop will display reduced size drag and drop icons when run alongside @@ -122,14 +129,21 @@ \o A bug in the Firebird database can cause an application to crash when \c{fbembed.dll} is unloaded. The bug is fixed in version 2.5. + \o On Windows 7, resizing windows is slower than on Vista/Xp. This is because + the gesture initialization process (required for native gesture support) + currently calls winId() on widgets, which causes whole widget hierarchies + to use native window handles. This slows down resizing. + \endlist \section2 Mac OS X \list + \o If a sheet is opened for a given window, clicking the title bar of that window will cause it to flash. This behavior has been reported to Apple (bug number 5827676). + \endlist \section2 Symbian diff --git a/doc/src/howtos/HWacceleration.qdoc b/doc/src/howtos/HWacceleration.qdoc new file mode 100644 index 0000000..80db740 --- /dev/null +++ b/doc/src/howtos/HWacceleration.qdoc @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page HWAcc_rendering.html + \title Using hardware acceleration on embedded platforms. + + \ingroup best-practices + + \section1 Abstract + This document describes how to use hardware acceleration for fast + rendering on embedded platforms supported by Qt. In short, it explains + how the graphics pipeline works. Since there might be differences to + how the APIs are being used on different embedded platforms, a table + links to documentation dedicated to platform specific documentation + for each supported hardware acceleration API. + + \input platforms/emb-hardwareacceleration.qdocinc + + \section1 Supported platforms + Since there might be differences to how the APIs are being used on + the different embedded platforms, this table provides you with links to + pages dedicated to platform specific documentation for each + supported hardware acceleration API. Click the API link for the + platform to go the correct documentation. + + \table + \header + \o Operating System + \o {3,1} Hardware Acceleration Platform + \row + \o \bold {Windows CE} + \o \l {Qt for Windows CE and OpenGL ES}{OpenGL ES} + \o \l {Qt for Windows CE and OpenVG}{OpenVG} + \o + \row + \o \bold {Embedded Linux} + \o \l {Qt for Embedded Linux and OpenGL}{OpenGL ES} + \o \l {Qt for Embedded Linux and OpenVG}{OpenVG} + \o \l {Qt for Embedded Linux and DirectFB}{DirectFB} + \row + \o \bold {Symbian Platform} + \o {3,1} \e {There are currently no support for hardware + acceleration.} + \endtable +\omit + \section1 Examples using hardware acceleration on embedded platforms. + + \table + \header + \o Embedded Platform + \o Example + \row + \o Windows CE + \row + \o Embedded Linux + \endtable +\endomit + + + +*/ diff --git a/doc/src/platforms/emb-HwAcc-LinuxEmbedded.qdoc b/doc/src/platforms/emb-HwAcc-LinuxEmbedded.qdoc index 9c18d87..a9bd167 100644 --- a/doc/src/platforms/emb-HwAcc-LinuxEmbedded.qdoc +++ b/doc/src/platforms/emb-HwAcc-LinuxEmbedded.qdoc @@ -49,23 +49,57 @@ \ingroup qt-embedded-linux - \input platforms/emb-hardwareacceleration.qdocinc + \input platforms/emb-hardwareacceleration.qdocinc -\section1 Supported Hardware Accelerated Graphics APIs + \section1 Windowing on Embedded Linux with Hardware Accelerated Graphics -This list shows which Hardware Accelerated Graphics APIs currently -supported by Qt. + Qt for Embedded Linux includes its own windowing system, QWS. QWS was + designed in 1999, well before graphics acceleration was available for + embedded devices. It does a great job providing a lightweight window + manager including all the expected functionality such as arbitrary + windows that can be moved, resized, minimized, etc. Getting QWS to work + with GPUs is very challenging, particularly with OpenGL and OpenVG + because there is no standard way in Linux to share textures across + processes. Some silicon vendors provide private APIs to allow texture + sharing, others do not. These limitations are documented under the + sections describing each type of accelerated hardware APIs. The simplest + most generic support for accelerated graphics is a full screen single + process single window. - \table - \header - \o Supported Hardware Accelerated Graphics APIs - \row - \o \l {Qt for Embedded Linux and OpenGL}{OpenGL ES} - \row - \o \l {Qt for Embedded Linux and OpenVG}{OpenVG} - \row - \o \l {Qt for Embedded Linux and DirectFB}{DirectFB} - \endtable + \section2 General options + \list + \o QWS, not accelerated, allows arbitrary windowing with multiple + processes drawing on the screen. + \o X11 with an accelerated X11 driver provided by the silicon + vendor. Like QWS, this allows arbitrary windows with multiple + processes drawing on the screen. Our experience is that there is + some overhead from X11 which will adversely affect framerates. + Additionally, our experience is that the drivers from silicon + vendors are still maturing. + \o Full screen single process single window. This will always work. + Some additional capabilities are available and are documented in + the acceleration specific API sections. + \endlist + + \section1 Supported Hardware Accelerated Graphics APIs + + This table shows which Hardware Accelerated Graphics APIs currently + supported by Qt. + + \table + \header + \o Supported APIs + \o API Version + \row + \o \l {Qt for Embedded Linux and OpenGL}{OpenGL ES} + \o 1.x and 2.x + \row + \o \l {Qt for Embedded Linux and OpenVG}{OpenVG } + \o 1.1 + \row + \o \l {Qt for Embedded Linux and DirectFB}{DirectFB} + \o 2.0 + \endtable */ diff --git a/doc/src/platforms/emb-HwAcc-WinCE.qdoc b/doc/src/platforms/emb-HwAcc-WinCE.qdoc index 66b6948..b7789f1 100644 --- a/doc/src/platforms/emb-HwAcc-WinCE.qdoc +++ b/doc/src/platforms/emb-HwAcc-WinCE.qdoc @@ -47,7 +47,6 @@ \title Qt for Windows CE Hardware Accelerated Graphics \ingroup qtce - \input platforms/emb-hardwareacceleration.qdocinc \section1 Supported Hardware Accelerated Graphics APIs diff --git a/doc/src/platforms/emb-hardwareacceleration.qdocinc b/doc/src/platforms/emb-hardwareacceleration.qdocinc index 3851628..fb00e09 100644 --- a/doc/src/platforms/emb-hardwareacceleration.qdocinc +++ b/doc/src/platforms/emb-hardwareacceleration.qdocinc @@ -1,129 +1,140 @@ - -\section1 Hardware Acceleration - -When designing applications for embedded devices the choice often stands -between graphics effects and performance. On most devices, you cannot have -both simply because the hardware needed for such operations just is not -there. Still a growing number of devices use hardware dedicated to graphics -operations to improve performance. - -Using graphics acceleration hardware is more power efficient than using the -CPU. The reason for this is that the CPU might require a clock speed that -is up to 20 times higher than the GPU, achieving the same results. E.g. a -typical hardware accelerated mobile graphics unit can rasterize one or two -bilinear texture fetches in one cycle, while a software implementation -takes easily more than 20 cycles. Graphics hardware generally have a much -lower clock speed and memory bandwidth and different level of acceleration -than desktop GPUs. One example is that many GPUs leave out transformation -and lighting from the graphics pipeline and only implements rasterization. - -So the key to write good applications for devices is therefore to limit the -wow factor down to what the target hardware can handle, and to take -advantage of any graphics dedicated hardware. Qt provides several ways to -both render advanced effects on the screen and speed up your application -using hardware accelerated graphics. - -\tableofcontents - -\section2 Qt for Embedded Graphics pipeline - -Qt uses QPainter for all graphics operations. By using the same API -regardless of platform, the code can be reused on different devices. -QPainter use different paint engines implemented in the QPaintEngine API to -do the actual painting. - -The QPaintEngine API provides paint engines for each window system and -painting framework supported by Qt. In regards to Qt for Embedded, this -also includes implementations for OpenGL ES versions 1.1 and 2.0, as well -as OpenVG and DirectFB(Embedded Linux only). - -By using one of these paint engines, you will be able to improve the -graphics performance of your Qt application. However, if the graphics -operations used are not supported, this might as well be a trap, slowing -down your application significantly. This all depends on what kind of -graphics operations that are supported by the target devices hardware -configuration. - -\image platformHWAcc.png - -The paint engine will direct all graphics operations supported by the -devices hardware to the GPU, and from there they are sent to the -framebuffer. Unsupported graphics operations falls back to the -QRasterPaintEngine and are handled by the CPU before sent to the -framebuffer. In the end, the operating system sends the paint updates off -to the screen/display. The fallback operation is quite expensive in regards -to memory consumption, and should be avoided. - -\section2 Hardware configuration requirements - -Before implementing any application using hardware acceleration, it is wise -to get an overview of what kind of hardware accelerated graphics operations -that are available for the target device. - -\note On devices with no hardware acceleration, Qt will use -QRasterPaintEngine, which handles the acceleration using software. On -devices supporting OpenGL ES, OpenVG or DirectFB(not supported by Windows -CE), Qt will use the -respective paint engines to accelerate painting. However, hardware -configurations that only support a limited set of hardware acceleration -features, might slow the application graphics down rather than speeding it -up when using unsupported operations that must fall back to the raster -engine. - -\section3 Different architectures - -Based on the architecture used in a device we can make a recommendation on -which hardware acceleration techniques to use. There are mainly two -different architectures on embedded devices. These are devices with a -Unified Memory Architecture (UMA), and devices with dedicated graphics -memory. Generally, high-end devices will have dedicated graphics memory. -Low-end devices will just use system memory, sometimes reserving a memory -region and sometimes not. - -In addition to this, we can categorize the devices into five types based on -the different graphics operations supported by their hardware. - -\list 1 - \o No support for graphics acceleration. - \o Support for blitter and alpha blending. - \o Support for path based 2D vector graphics. - \o Support for fixed function 3D graphics. - \o Support for programmable 3D graphics. -\endlist - -Based on these characteristics the table below recommends which paint -engines to use with the different types of hardware configurations. - -\section3 Recommended use of hardware acceleration based on hardware - - \table - \header - \o Type - \o UMA - \o Non-UMA - \row - \o \bold {None} - \o Qt Raster Engine - \o Qt Raster Engine - \row - \o \bold {Blitter} - \o DirectFB - \o DirectFB - \row - \o \bold {2D Vector} - \o OpenVG - \o OpenVG - \row - \o \bold {Fixed 3D} - \o OpenGL (ES) 1.x - \o OpenGL (ES) 1.x - \row - \o \bold {Programmable 3D} - \o OpenGL (ES) 2.x - \o OpenGL (ES) 2.x - - \endtable - -\note Since the DirectFB API is quite primitive, the raster paint engine -handles most of the operations. -\note Blitter and Alpha blending is currently not supported on Windows CE. + \section1 Hardware Acceleration + + When designing applications for embedded devices there is often a + compromise between graphics effects and performance. On most + devices, you cannot have both simply because the hardware needed + for such operations just is not there. With a growing number of + devices that use hardware dedicated to graphics operations there is + less need to compromise. + + In addition to enabling dynamic graphics effects, there are two + other benefits to using graphics acceleration. One is that graphics + acceleration hardware is more power efficient than using the CPU. + The reason for this is that the CPU might require a clock speed + that is up to 20 times higher than the GPU, achieving the same + results. E.g. a typical hardware accelerated mobile graphics unit + can rasterize one or two bilinear texture fetches in one cycle, + while a software implementation takes easily more than 20 cycles. + Typical \e {System-on-a-chip} (SoC) graphics hardware generally have + a much lower clock speed and memory bandwidth, and different level + of acceleration than desktop GPUs. One example is that many GPUs + leave out transformation and lighting from the graphics pipeline + and only implements rasterization. + + Another reason to use a GPU is to offload the main CPU, either for + power saving or to perform other operations in parallel. Often + drawing speed with a GPU is not that much faster than a CPU but + the clear benefit of using the GPU is to free up the CPU to perform + other tasks which can be used to create a more responsive use + experience. + + The key to writing good applications for devices is therefore to + limit the wow factor down to what the target hardware can handle, + and to take advantage of any graphics dedicated hardware. Qt + provides several ways to both render advanced effects on the screen + and speed up your application using hardware accelerated graphics. + + \tableofcontents + + \section2 Qt for Embedded Graphics pipeline + + Qt uses QPainter for all graphics operations. By using the same API + regardless of platform, the code can be reused on different devices. + QPainter use different paint engines implemented in the QPaintEngine API to + do the actual painting. + + The QPaintEngine API provides paint engines for each window system and + painting framework supported by Qt. In regards to Qt for Embedded, this + also includes implementations for OpenGL ES versions 1.1 and 2.0, as well + as OpenVG and DirectFB(Embedded Linux only). + + By using one of these paint engines, you will be able to improve the + graphics performance of your Qt application. However, if the graphics + operations used are not supported, this might as well be a trap, slowing + down your application significantly. This all depends on what kind of + graphics operations that are supported by the target devices hardware + configuration. + + \image platformHWAcc.png + + The paint engine will direct all graphics operations supported by the + devices hardware to the GPU, and from there they are sent to the + framebuffer. Unsupported graphics operations falls back to the + QRasterPaintEngine and are handled by the CPU before sent to the + framebuffer. In the end, the operating system sends the paint updates off + to the screen/display. The fallback operation is quite expensive in regards + to memory consumption, and should be avoided. + + \section2 Hardware configuration requirements + + Before implementing any application using hardware acceleration, it is wise + to get an overview of what kind of hardware accelerated graphics operations + that are available for the target device. + + \note On devices with no hardware acceleration, Qt will use + QRasterPaintEngine, which handles the acceleration using software. On + devices supporting OpenGL ES, OpenVG or DirectFB(not supported by Windows + CE), Qt will use the + respective paint engines to accelerate painting. However, hardware + configurations that only support a limited set of hardware acceleration + features, might slow the application graphics down rather than speeding it + up when using unsupported operations that must fall back to the raster + engine. + + \section3 Different architectures + + Based on the architecture used in a device we can make a recommendation on + which hardware acceleration techniques to use. There are mainly two + different architectures on embedded devices. These are devices with a + Unified Memory Architecture (UMA), and devices with dedicated graphics + memory. Generally, high-end devices will have dedicated graphics memory. + Low-end devices will just use system memory, sometimes reserving a memory + region and sometimes not. + + In addition to this, we can categorize the devices into five types based on + the different graphics operations supported by their hardware. + + \list 1 + \o No support for graphics acceleration. + \o Support for blitter and alpha blending. + \o Support for path based 2D vector graphics. + \o Support for fixed function 3D graphics. + \o Support for programmable 3D graphics. + \endlist + + Based on these characteristics the table below recommends which paint + engines to use with the different types of hardware configurations. + + \section3 Recommended use of hardware acceleration based on hardware + + \table + \header + \o Type + \o UMA + \o Non-UMA + \row + \o \bold {None} + \o Qt Raster Engine + \o Qt Raster Engine + \row + \o \bold {Blitter} + \o DirectFB + \o DirectFB + \row + \o \bold {2D Vector} + \o OpenVG + \o OpenVG + \row + \o \bold {Fixed 3D} + \o OpenGL (ES) 1.x + \o OpenGL (ES) 1.x + \row + \o \bold {Programmable 3D} + \o OpenGL (ES) 2.x + \o OpenGL (ES) 2.x + \endtable + + \note Since the DirectFB API is quite primitive, the raster paint engine + handles most of the operations. + + \note Blitter and Alpha blending is currently not supported on Windows CE. diff --git a/doc/src/platforms/platform-notes.qdoc b/doc/src/platforms/platform-notes.qdoc index 68015a6..85b9ff8 100644 --- a/doc/src/platforms/platform-notes.qdoc +++ b/doc/src/platforms/platform-notes.qdoc @@ -515,11 +515,8 @@ In addition, there exists a backend for the Helix framework. However, due to it not shipping with Qt, its availability depends on the Symbian platform in use. If available, it is loaded in preference over the MMF - plugin. The Helix plugin requires Symbian signed capabilities. If the - application does not have those capabilities, the MMF plugin, if present on - the device, will be loaded instead. The capabilities the Helix backend - requires are AllFiles, DiskAdmin and MultimediaDD. - + plugin. If the Helix plugin fails to load, the MMF plugin, if present on + the device, will be loaded instead. */ /*! diff --git a/examples/webkit/framecapture/framecapture.cpp b/examples/webkit/framecapture/framecapture.cpp index 2c2e11b..ef49e93 100644 --- a/examples/webkit/framecapture/framecapture.cpp +++ b/examples/webkit/framecapture/framecapture.cpp @@ -59,6 +59,7 @@ void FrameCapture::load(const QUrl &url, const QString &outputFileName) m_page.mainFrame()->load(url); m_page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); m_page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + m_page.setViewportSize(QSize(1024, 768)); } void FrameCapture::printProgress(int percent) @@ -81,41 +82,36 @@ void FrameCapture::saveResult(bool ok) return; } - // save each internal frame in different image files - int frameCounter = 0; - foreach(QWebFrame *frame, m_page.mainFrame()->childFrames()) { - QString fileName(m_fileName); - int index = m_fileName.lastIndexOf('.'); - fileName = fileName.insert(index, "_frame" + QString::number(++frameCounter)); + // save each frame in different image files + saveFrame(m_page.mainFrame()); - frame->setClipRenderToViewport(false); + emit finished(); +} - QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied); - image.fill(Qt::transparent); +void FrameCapture::saveFrame(QWebFrame *frame) +{ + static int frameCounter = 0; - saveFrame(frame, image, fileName); + QString fileName(m_fileName); + if (frameCounter) { + int index = m_fileName.lastIndexOf('.'); + fileName = fileName.insert(index, "_frame" + QString::number(frameCounter)); } - // save the main frame - m_page.setViewportSize(m_page.mainFrame()->contentsSize()); - QImage image(m_page.mainFrame()->contentsSize(), QImage::Format_ARGB32_Premultiplied); + QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied); image.fill(Qt::transparent); - saveFrame(m_page.mainFrame(), image, m_fileName); - - emit finished(); -} -void FrameCapture::saveFrame(QWebFrame *frame, QImage image, QString fileName) -{ QPainter painter(&image); painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::TextAntialiasing, true); painter.setRenderHint(QPainter::SmoothPixmapTransform, true); - - frame->render(&painter); - + frame->documentElement().render(&painter); painter.end(); image.save(fileName); + + ++frameCounter; + foreach(QWebFrame *childFrame, frame->childFrames()) + saveFrame(childFrame); } diff --git a/examples/webkit/framecapture/framecapture.h b/examples/webkit/framecapture/framecapture.h index 9de9c43..7a6d5f3 100644 --- a/examples/webkit/framecapture/framecapture.h +++ b/examples/webkit/framecapture/framecapture.h @@ -64,7 +64,7 @@ private: QString m_fileName; int m_percent; - void saveFrame(QWebFrame *frame, QImage image, QString fileName); + void saveFrame(QWebFrame *frame); }; #endif diff --git a/examples/webkit/framecapture/main.cpp b/examples/webkit/framecapture/main.cpp index 050947a..65c0026 100644 --- a/examples/webkit/framecapture/main.cpp +++ b/examples/webkit/framecapture/main.cpp @@ -63,7 +63,7 @@ int main(int argc, char * argv[]) return 0; } - QUrl url = QWebView::guessUrlFromString(QString::fromLatin1(argv[1])); + QUrl url = QUrl::fromUserInput(QString::fromLatin1(argv[1])); QString fileName = QString::fromLatin1(argv[2]); QApplication a(argc, argv); diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp index 4fd5833..c7eae64 100644 --- a/qmake/generators/symbian/symmake_sbsv2.cpp +++ b/qmake/generators/symbian/symmake_sbsv2.cpp @@ -376,7 +376,10 @@ void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t t << "START EXTENSION s60/mifconv" << endl; QFileInfo iconInfo = fileInfo(icon); - QString iconPath = iconInfo.path(); + + QFileInfo bldinf(project->values("MAKEFILE").first()); + QString iconPath = bldinf.dir().relativeFilePath(iconInfo.path()); + QString iconFile = iconInfo.baseName(); QFileInfo iconTargetInfo = fileInfo(iconTargetFile); diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 05e6fab..35737b3 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -1254,7 +1254,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla // undefined behavior. Otherwise, let mmap have its say. if (doStat() && (QT_OFF_T(size) > st.st_size - QT_OFF_T(offset))) - return 0; + qWarning("QFSFileEngine::map: Mapping a file beyond its size is not portable"); int access = 0; if (openMode & QIODevice::ReadOnly) access |= PROT_READ; diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index b84961f..0e5a2de 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1157,6 +1157,10 @@ QByteArray QIODevice::readLine(qint64 maxSize) // If resize fails or maxSize == 0, read incrementally if (maxSize == 0) maxSize = INT_MAX; + + // The first iteration needs to leave an extra byte for the terminating null + result.resize(1); + qint64 readResult; do { result.resize(int(qMin(maxSize, result.size() + QIODEVICE_BUFFERSIZE))); @@ -1164,7 +1168,7 @@ QByteArray QIODevice::readLine(qint64 maxSize) if (readResult > 0 || readBytes == 0) readBytes += readResult; } while (readResult == QIODEVICE_BUFFERSIZE - && result[int(readBytes)] != '\n'); + && result[int(readBytes - 1)] != '\n'); } else readBytes = readLine(result.data(), result.size()); diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 1260d47..95602d9 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -154,6 +154,15 @@ QObjectPrivate::QObjectPrivate(int version) hasGuards = false; } +#ifdef Q_CC_INTEL +/* Workaround for a bug in win32-icc where it seems to inline ~QObjectPrivate too aggressive. + When icc compiles QtGui, it inlines ~QObjectPrivate so that it would generate a call to + ~QObjectData. However, ~QObjectData is not exported from QtCore, so it does not link. + See also QTBUG-5145 for info on how this manifested itself. + */ +# pragma auto_inline(off) +#endif + QObjectPrivate::~QObjectPrivate() { delete static_cast<QAbstractDynamicMetaObject*>(metaObject); @@ -165,6 +174,9 @@ QObjectPrivate::~QObjectPrivate() delete extraData; #endif } +#ifdef Q_CC_INTEL +# pragma auto_inline(on) +#endif int *QObjectPrivate::setDeleteWatch(QObjectPrivate *d, int *w) { diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index fb67278..a6f5992 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -1272,7 +1272,6 @@ void QGraphicsAnchorLayoutPrivate::createLayoutEdges() addAnchor_helper(layout, Qt::AnchorLeft, layout, Qt::AnchorRight, data); data->maxSize = QWIDGETSIZE_MAX; - data->skipInPreferred = 1; // Save a reference to layout vertices layoutFirstVertex[Horizontal] = internalVertex(layout, Qt::AnchorLeft); @@ -1284,7 +1283,6 @@ void QGraphicsAnchorLayoutPrivate::createLayoutEdges() addAnchor_helper(layout, Qt::AnchorTop, layout, Qt::AnchorBottom, data); data->maxSize = QWIDGETSIZE_MAX; - data->skipInPreferred = 1; // Save a reference to layout vertices layoutFirstVertex[Vertical] = internalVertex(layout, Qt::AnchorTop); @@ -2271,13 +2269,21 @@ QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutCentralVertex[orient]); } else { layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutLastVertex[orient]); + } - // If maxSize is less then "infinite", that means there are other anchors - // grouped together with this one. We can't ignore its maximum value so we - // set back the variable to NULL to prevent the continue condition from being - // satisfied in the loop below. - if (layoutEdge->maxSize < QWIDGETSIZE_MAX) - layoutEdge = 0; + // If maxSize is less then "infinite", that means there are other anchors + // grouped together with this one. We can't ignore its maximum value so we + // set back the variable to NULL to prevent the continue condition from being + // satisfied in the loop below. + const qreal expectedMax = layoutCentralVertex[orient] ? QWIDGETSIZE_MAX / 2 : QWIDGETSIZE_MAX; + qreal actualMax; + if (layoutEdge->from == layoutFirstVertex[orient]) { + actualMax = layoutEdge->maxSize; + } else { + actualMax = -layoutEdge->minSize; + } + if (actualMax != expectedMax) { + layoutEdge = 0; } // For each variable, create constraints based on size hints @@ -2700,7 +2706,9 @@ bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList<QSimplexConstraint // for (int i = 0; i < variables.size(); ++i) { AnchorData *ad = variables.at(i); - if (ad->skipInPreferred) + + // The layout original structure anchors are not relevant in preferred size calculation + if (ad->isLayoutAnchor) continue; QSimplexVariable *grower = new QSimplexVariable; diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 2b365fb..8529e2e 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -124,8 +124,7 @@ struct AnchorData : public QSimplexVariable { : QSimplexVariable(), from(0), to(0), minSize(0), prefSize(0), maxSize(0), sizeAtMinimum(0), sizeAtPreferred(0), - sizeAtMaximum(0), item(0), - graphicsAnchor(0), skipInPreferred(0), + sizeAtMaximum(0), item(0), graphicsAnchor(0), type(Normal), isLayoutAnchor(false), isCenterAnchor(false), orientation(0), dependency(Independent) {} @@ -169,7 +168,6 @@ struct AnchorData : public QSimplexVariable { QGraphicsLayoutItem *item; QGraphicsAnchor *graphicsAnchor; - uint skipInPreferred : 1; uint type : 2; // either Normal, Sequential or Parallel uint isLayoutAnchor : 1; // if this anchor is an internal layout anchor uint isCenterAnchor : 1; diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index e4ea2e9..3b43ab6 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/image/qnativeimage.cpp @@ -178,6 +178,8 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /* if (ok) { xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0); xshminfo.shmaddr = xshmimg->data; + if (shmctl(xshminfo.shmid, IPC_RMID, 0) == -1) + qWarning() << "Error while marking the shared memory segment to be destroyed"; ok = (xshminfo.shmaddr != (char*)-1); if (ok) image = QImage((uchar *)xshmimg->data, width, height, systemFormat()); diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index 5df8481..6f0fba6 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -1913,7 +1913,6 @@ void QHeaderView::initializeSections(int start, int end) Q_ASSERT(start >= 0); Q_ASSERT(end >= 0); - d->executePostedLayout(); d->invalidateCachedSizeHint(); if (end + 1 < d->sectionCount) { @@ -1939,11 +1938,25 @@ void QHeaderView::initializeSections(int start, int end) d->sectionCount = end + 1; if (!d->logicalIndices.isEmpty()) { - d->logicalIndices.resize(d->sectionCount); - d->visualIndices.resize(d->sectionCount); - for (int i = start; i < d->sectionCount; ++i){ - d->logicalIndices[i] = i; - d->visualIndices[i] = i; + if (oldCount <= d->sectionCount) { + d->logicalIndices.resize(d->sectionCount); + d->visualIndices.resize(d->sectionCount); + for (int i = oldCount; i < d->sectionCount; ++i) { + d->logicalIndices[i] = i; + d->visualIndices[i] = i; + } + } else { + int j = 0; + for (int i = 0; i < oldCount; ++i) { + int v = d->logicalIndices.at(i); + if (v < d->sectionCount) { + d->logicalIndices[j] = v; + d->visualIndices[v] = j; + j++; + } + } + d->logicalIndices.resize(d->sectionCount); + d->visualIndices.resize(d->sectionCount); } } diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index a16d1f8..72eedad 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -1451,7 +1451,7 @@ Qt::DropAction QDragManager::drag(QDrag *o) [image release]; dragPrivate()->executed_action = Qt::IgnoreAction; object = 0; - Qt::DropAction performedAction(qt_mac_mapNSDragOperation(dndParams.performedAction)); + Qt::DropAction performedAction(qt_mac_mapNSDragOperation(qMacDnDParams()->performedAction)); // do post drag processing, if required. if(performedAction != Qt::IgnoreAction) { // check if the receiver points us to a file location. diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 048325c..523dd18 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1767,6 +1767,12 @@ void QTextDocument::print(QPrinter *printer) const fromPage = qMax(1, fromPage); toPage = qMin(doc->pageCount(), toPage); + if (toPage < fromPage) { + // if the user entered a page range outside the actual number + // of printable pages, just return + return; + } + if (printer->pageOrder() == QPrinter::LastPageFirst) { int tmp = fromPage; fromPage = toPage; diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp index cb46791..8834373 100644 --- a/src/gui/widgets/qabstractbutton.cpp +++ b/src/gui/widgets/qabstractbutton.cpp @@ -165,7 +165,7 @@ QAbstractButtonPrivate::QAbstractButtonPrivate(QSizePolicy::ControlType type) shortcutId(0), #endif checkable(false), checked(false), autoRepeat(false), autoExclusive(false), - down(false), blockRefresh(false), + down(false), blockRefresh(false), pressed(false), #ifndef QT_NO_BUTTONGROUP group(0), #endif @@ -1090,6 +1090,7 @@ void QAbstractButton::mousePressEvent(QMouseEvent *e) } if (hitButton(e->pos())) { setDown(true); + d->pressed = true; repaint(); //flush paint event before invoking potentially expensive operation QApplication::flush(); d->emitPressed(); @@ -1103,6 +1104,8 @@ void QAbstractButton::mousePressEvent(QMouseEvent *e) void QAbstractButton::mouseReleaseEvent(QMouseEvent *e) { Q_D(QAbstractButton); + d->pressed = false; + if (e->button() != Qt::LeftButton) { e->ignore(); return; @@ -1127,7 +1130,7 @@ void QAbstractButton::mouseReleaseEvent(QMouseEvent *e) void QAbstractButton::mouseMoveEvent(QMouseEvent *e) { Q_D(QAbstractButton); - if (!(e->buttons() & Qt::LeftButton)) { + if (!(e->buttons() & Qt::LeftButton) || !d->pressed) { e->ignore(); return; } diff --git a/src/gui/widgets/qabstractbutton_p.h b/src/gui/widgets/qabstractbutton_p.h index be7c022..d86163b 100644 --- a/src/gui/widgets/qabstractbutton_p.h +++ b/src/gui/widgets/qabstractbutton_p.h @@ -77,6 +77,7 @@ public: uint autoExclusive :1; uint down :1; uint blockRefresh :1; + uint pressed : 1; #ifndef QT_NO_BUTTONGROUP QButtonGroup* group; diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index e50de02..40cfe1a 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -1486,7 +1486,8 @@ bool QMenuBar::event(QEvent *e) break; case QEvent::ShortcutOverride: { QKeyEvent *kev = static_cast<QKeyEvent*>(e); - if (kev->key() == Qt::Key_Escape) { + //we only filter out escape if there is a current action + if (kev->key() == Qt::Key_Escape && d->currentAction) { e->accept(); return true; } diff --git a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro index 158633d..9687908 100644 --- a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro +++ b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro @@ -2,6 +2,8 @@ TEMPLATE = subdirs # We just want to export the sqlite3 binaries for Symbian for platforms that do not have them. -!exists($${EPOCROOT}epoc32/release/armv5/lib/sqlite3.dso) { - BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip" +symbian { + !exists($${EPOCROOT}epoc32/release/armv5/lib/sqlite3.dso) { + BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip" + } } diff --git a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp index 158451a..d99723e 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp @@ -47,12 +47,21 @@ int main(int argc, char **argv) { QApplication a(argc, argv); + QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); + QWidget w; QLabel label1(QObject::tr("abc", "ascii"), &w); QLabel label2(QObject::tr("æøå", "utf-8"), &w); + QLabel label2a(QObject::tr("\303\246\303\270\303\245", "utf-8 oct"), &w); + QLabel label3(QObject::trUtf8("Für Élise", "trUtf8"), &w); + QLabel label3a(QObject::trUtf8("F\303\274r \303\211lise", "trUtf8 oct"), &w); -// I would expect the following to work !? -// QLabel label3(QObject::trUtf8("F\374r \310lise", "trUtf8"), &w); + QBoxLayout *ly = new QVBoxLayout(&w); + ly->addWidget(&label1); + ly->addWidget(&label2); + ly->addWidget(&label2a); + ly->addWidget(&label3); + ly->addWidget(&label3a); w.show(); return a.exec(); diff --git a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result index bc0d9bb..711bf02 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result @@ -5,16 +5,34 @@ <context> <name>QObject</name> <message> - <location filename="main.cpp" line="51"/> + <location filename="main.cpp" line="53"/> <source>abc</source> <comment>ascii</comment> <translation type="unfinished"></translation> </message> <message> - <location filename="main.cpp" line="52"/> + <location filename="main.cpp" line="54"/> <source>æøå</source> <comment>utf-8</comment> <translation type="unfinished"></translation> </message> + <message> + <location filename="main.cpp" line="55"/> + <source>æøå</source> + <comment>utf-8 oct</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="56"/> + <source>Für Élise</source> + <comment>trUtf8</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="57"/> + <source>Für Élise</source> + <comment>trUtf8 oct</comment> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result index 91da744..6ee369a 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result @@ -6,7 +6,7 @@ <name>QObject</name> <message> <location filename="main.cpp" line="61"/> - <source>Á</source> + <source>Б</source> <translation type="unfinished"></translation> </message> </context> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp index abb8b89..98b491c 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp @@ -49,9 +49,11 @@ public: void doFoo() { tr("random ascii only"); - tr("this contains an umlaut ü"); + tr("this contains an umlaut ü literally"); + tr("this contains an umlaut \xfc ü escaped"); trUtf8("random ascii only in utf8"); - trUtf8("umlaut \xfc ü in utf8"); + trUtf8("umlaut ü ü in literal utf8"); + trUtf8("umlaut \303\274 ü in escaped utf8"); } }; diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result index 26eb245..d548e24 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result @@ -11,17 +11,27 @@ </message> <message> <location filename="main.cpp" line="52"/> - <source>this contains an umlaut ü &uuml;</source> + <source>this contains an umlaut ü &uuml; literally</source> <translation type="unfinished"></translation> </message> <message> <location filename="main.cpp" line="53"/> + <source>this contains an umlaut ü &uuml; escaped</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="54"/> <source>random ascii only in utf8</source> <translation type="unfinished"></translation> </message> <message utf8="true"> - <location filename="main.cpp" line="54"/> - <source>umlaut ü &uuml; in utf8</source> + <location filename="main.cpp" line="55"/> + <source>umlaut ü &uuml; in literal utf8</source> + <translation type="unfinished"></translation> + </message> + <message utf8="true"> + <location filename="main.cpp" line="56"/> + <source>umlaut ü &uuml; in escaped utf8</source> <translation type="unfinished"></translation> </message> </context> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp index abb8b89..cd93539 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp @@ -49,9 +49,10 @@ public: void doFoo() { tr("random ascii only"); - tr("this contains an umlaut ü"); + tr("this contains an umlaut ü literally"); + tr("this contains an umlaut \303\274 ü escaped, really in utf-8"); trUtf8("random ascii only in utf8"); - trUtf8("umlaut \xfc ü in utf8"); + trUtf8("umlaut \303\274 ü in escaped utf8"); } }; diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result index e27c157..6728a25 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result @@ -11,17 +11,22 @@ </message> <message> <location filename="main.cpp" line="52"/> - <source>this contains an umlaut ü &uuml;</source> + <source>this contains an umlaut ü &uuml; literally</source> <translation type="unfinished"></translation> </message> <message> <location filename="main.cpp" line="53"/> - <source>random ascii only in utf8</source> + <source>this contains an umlaut ü &uuml; escaped, really in utf-8</source> <translation type="unfinished"></translation> </message> <message> <location filename="main.cpp" line="54"/> - <source>umlaut ü &uuml; in utf8</source> + <source>random ascii only in utf8</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="55"/> + <source>umlaut ü &uuml; in escaped utf8</source> <translation type="unfinished"></translation> </message> </context> diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 2ad024f..e2f87b8 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -86,6 +86,8 @@ private slots: void parallelSimplificationOfCenter(); void simplificationVsRedundance(); void spacingPersistency(); + void snakeParallelWithLayout(); + void parallelToHalfLayout(); }; class RectWidget : public QGraphicsWidget @@ -1892,5 +1894,87 @@ void tst_QGraphicsAnchorLayout::spacingPersistency() QCOMPARE(anchor->spacing(), 30.0); } +/* + Test whether a correct preferred size is set when a "snake" sequence is in parallel with the + layout or half of the layout. The tricky thing here is that all items on the snake should + keep their preferred sizes. +*/ +void tst_QGraphicsAnchorLayout::snakeParallelWithLayout() +{ + QSizeF min(10, 20); + QSizeF pref(50, 20); + QSizeF max(100, 20); + + QGraphicsWidget *a = createItem(max, max, max, "A"); + QGraphicsWidget *b = createItem(min, pref, max, "B"); + QGraphicsWidget *c = createItem(max, max, max, "C"); + + QGraphicsWidget parent; + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&parent); + l->setContentsMargins(0, 0, 0, 0); + l->setSpacing(0); + + // First we'll do the case in parallel with the entire layout... + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorRight); + l->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft); + l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight); + + l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop); + l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); + l->addAnchor(c, Qt::AnchorBottom, l, Qt::AnchorBottom); + + parent.resize(l->effectiveSizeHint(Qt::PreferredSize)); + + // Note that A and C are fixed in the maximum size + QCOMPARE(l->geometry(), QRectF(QPointF(0, 0), QSizeF(150, 60))); + QCOMPARE(a->geometry(), QRectF(QPointF(0, 0), max)); + QCOMPARE(b->geometry(), QRectF(QPointF(50, 20), pref)); + QCOMPARE(c->geometry(), QRectF(QPointF(50, 40), max)); + + // Then, we change the "snake" to be in parallel with half of the layout + delete l->anchor(c, Qt::AnchorRight, l, Qt::AnchorRight); + l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorHorizontalCenter); + + parent.resize(l->effectiveSizeHint(Qt::PreferredSize)); + + QCOMPARE(l->geometry(), QRectF(QPointF(0, 0), QSizeF(300, 60))); + QCOMPARE(a->geometry(), QRectF(QPointF(0, 0), max)); + QCOMPARE(b->geometry(), QRectF(QPointF(50, 20), pref)); + QCOMPARE(c->geometry(), QRectF(QPointF(50, 40), max)); +} + +/* + Avoid regression where the sizeHint constraints would not be + created for a parallel anchor that included the first layout half +*/ +void tst_QGraphicsAnchorLayout::parallelToHalfLayout() +{ + QGraphicsWidget *a = createItem(); + + QGraphicsWidget w; + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&w); + l->setContentsMargins(10, 10, 10, 10); + + l->addAnchors(l, a, Qt::Vertical); + + QGraphicsAnchor *anchor; + anchor = l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + anchor->setSpacing(5); + anchor = l->addAnchor(l, Qt::AnchorHorizontalCenter, a, Qt::AnchorRight); + anchor->setSpacing(-5); + + const QSizeF minimumSizeHint = w.effectiveSizeHint(Qt::MinimumSize); + const QSizeF preferredSizeHint = w.effectiveSizeHint(Qt::PreferredSize); + const QSizeF maximumSizeHint = w.effectiveSizeHint(Qt::MaximumSize); + + const QSizeF overhead = QSizeF(10 + 5 + 5, 10) * 2; + + QCOMPARE(minimumSizeHint, QSizeF(200, 100) + overhead); + QCOMPARE(preferredSizeHint, QSizeF(300, 100) + overhead); + QCOMPARE(maximumSizeHint, QSizeF(400, 100) + overhead); +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp index c13e829..a8e7461 100644 --- a/tests/auto/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/qheaderview/tst_qheaderview.cpp @@ -43,6 +43,7 @@ #include <QtTest/QtTest> #include <QStandardItemModel> #include <QStringListModel> +#include <QSortFilterProxyModel> #include <qabstractitemmodel.h> #include <qapplication.h> @@ -188,6 +189,7 @@ private slots: void task236450_hidden_data(); void task236450_hidden(); void task248050_hideRow(); + void QTBUG6058_reset(); protected: QHeaderView *view; @@ -1947,5 +1949,49 @@ void tst_QHeaderView::task248050_hideRow() } +//returns 0 if everything is fine. +static int checkHeaderViewOrder(QHeaderView *view, const QVector<int> &expected) +{ + if (view->count() != expected.count()) + return 1; + + for (int i = 0; i < expected.count(); i++) { + if (view->logicalIndex(i) != expected.at(i)) + return i + 10; + if (view->visualIndex(expected.at(i)) != i) + return i + 100; + } + return 0; +} + + +void tst_QHeaderView::QTBUG6058_reset() +{ + QStringListModel model1( QStringList() << "0" << "1" << "2" << "3" << "4" << "5" ); + QStringListModel model2( QStringList() << "a" << "b" << "c" ); + QSortFilterProxyModel proxy; + + QHeaderView view(Qt::Vertical); + view.setModel(&proxy); + view.show(); + QTest::qWait(20); + + proxy.setSourceModel(&model1); + QApplication::processEvents(); + view.swapSections(0,2); + view.swapSections(1,4); + QApplication::processEvents(); + QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 4 << 0 << 3 << 1 << 5) , 0); + + proxy.setSourceModel(&model2); + QApplication::processEvents(); + QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 ) , 0); + + proxy.setSourceModel(&model1); + QApplication::processEvents(); + QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 << 3 << 4 << 5 ) , 0); +} + + QTEST_MAIN(tst_QHeaderView) #include "tst_qheaderview.moc" diff --git a/tests/auto/qiodevice/tst_qiodevice.cpp b/tests/auto/qiodevice/tst_qiodevice.cpp index 056ad6a..84fd8ad 100644 --- a/tests/auto/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/qiodevice/tst_qiodevice.cpp @@ -77,6 +77,9 @@ private slots: void readLine_data(); void readLine(); + + void readLine2_data(); + void readLine2(); }; // Testing get/set functions @@ -453,5 +456,114 @@ void tst_QIODevice::readLine() QCOMPARE(line.size(), linelen); } +void tst_QIODevice::readLine2_data() +{ + QTest::addColumn<QByteArray>("line"); + + QTest::newRow("1024 - 4") << QByteArray(1024 - 4, 'x'); + QTest::newRow("1024 - 3") << QByteArray(1024 - 3, 'x'); + QTest::newRow("1024 - 2") << QByteArray(1024 - 2, 'x'); + QTest::newRow("1024 - 1") << QByteArray(1024 - 1, 'x'); + QTest::newRow("1024" ) << QByteArray(1024 , 'x'); + QTest::newRow("1024 + 1") << QByteArray(1024 + 1, 'x'); + QTest::newRow("1024 + 2") << QByteArray(1024 + 2, 'x'); + + QTest::newRow("4096 - 4") << QByteArray(4096 - 4, 'x'); + QTest::newRow("4096 - 3") << QByteArray(4096 - 3, 'x'); + QTest::newRow("4096 - 2") << QByteArray(4096 - 2, 'x'); + QTest::newRow("4096 - 1") << QByteArray(4096 - 1, 'x'); + QTest::newRow("4096" ) << QByteArray(4096 , 'x'); + QTest::newRow("4096 + 1") << QByteArray(4096 + 1, 'x'); + QTest::newRow("4096 + 2") << QByteArray(4096 + 2, 'x'); + + QTest::newRow("8192 - 4") << QByteArray(8192 - 4, 'x'); + QTest::newRow("8192 - 3") << QByteArray(8192 - 3, 'x'); + QTest::newRow("8192 - 2") << QByteArray(8192 - 2, 'x'); + QTest::newRow("8192 - 1") << QByteArray(8192 - 1, 'x'); + QTest::newRow("8192" ) << QByteArray(8192 , 'x'); + QTest::newRow("8192 + 1") << QByteArray(8192 + 1, 'x'); + QTest::newRow("8192 + 2") << QByteArray(8192 + 2, 'x'); + + QTest::newRow("16384 - 4") << QByteArray(16384 - 4, 'x'); + QTest::newRow("16384 - 3") << QByteArray(16384 - 3, 'x'); + QTest::newRow("16384 - 2") << QByteArray(16384 - 2, 'x'); + QTest::newRow("16384 - 1") << QByteArray(16384 - 1, 'x'); + QTest::newRow("16384" ) << QByteArray(16384 , 'x'); + QTest::newRow("16384 + 1") << QByteArray(16384 + 1, 'x'); + QTest::newRow("16384 + 2") << QByteArray(16384 + 2, 'x'); + + QTest::newRow("20000") << QByteArray(20000, 'x'); + + QTest::newRow("32768 - 4") << QByteArray(32768 - 4, 'x'); + QTest::newRow("32768 - 3") << QByteArray(32768 - 3, 'x'); + QTest::newRow("32768 - 2") << QByteArray(32768 - 2, 'x'); + QTest::newRow("32768 - 1") << QByteArray(32768 - 1, 'x'); + QTest::newRow("32768" ) << QByteArray(32768 , 'x'); + QTest::newRow("32768 + 1") << QByteArray(32768 + 1, 'x'); + QTest::newRow("32768 + 2") << QByteArray(32768 + 2, 'x'); + + QTest::newRow("40000") << QByteArray(40000, 'x'); +} + +void tst_QIODevice::readLine2() +{ + QFETCH(QByteArray, line); + + int length = line.size(); + + QByteArray data("First line.\r\n"); + data.append(line); + data.append("\r\n"); + data.append(line); + data.append("\r\n"); + data.append("\r\n0123456789"); + + { + QBuffer buffer(&data); + buffer.open(QIODevice::ReadOnly); + + buffer.seek(0); + QByteArray temp; + temp.resize(64536); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(13)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 2)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 2)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(2)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(10)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(-1)); + + buffer.seek(0); + QCOMPARE(buffer.readLine().size(), 13); + QCOMPARE(buffer.readLine().size(), length + 2); + QCOMPARE(buffer.readLine().size(), length + 2); + QCOMPARE(buffer.readLine().size(), 2); + QCOMPARE(buffer.readLine().size(), 10); + QVERIFY(buffer.readLine().isNull()); + } + + { + QBuffer buffer(&data); + buffer.open(QIODevice::ReadOnly | QIODevice::Text); + + buffer.seek(0); + QByteArray temp; + temp.resize(64536); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(12)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 1)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 1)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(1)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(10)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(-1)); + + buffer.seek(0); + QCOMPARE(buffer.readLine().size(), 12); + QCOMPARE(buffer.readLine().size(), length + 1); + QCOMPARE(buffer.readLine().size(), length + 1); + QCOMPARE(buffer.readLine().size(), 1); + QCOMPARE(buffer.readLine().size(), 10); + QVERIFY(buffer.readLine().isNull()); + } +} + QTEST_MAIN(tst_QIODevice) #include "tst_qiodevice.moc" diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 605b3e3..602da61 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -1898,7 +1898,7 @@ void tst_QListView::taskQTBUG_5877_skippingItemInPageDownUp() QTest::qWaitForWindowShown(&vu); int itemHeight = vu.visualRect(model.index(0, 0)).height(); - int visibleRowCount = vu.height() / itemHeight; + int visibleRowCount = vu.viewport()->height() / itemHeight; int scrolledRowCount = visibleRowCount - 1; for (int i = 0; i < currentItemIndexes.size(); ++i) { diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp index 4291c3e..320cd8d 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -167,6 +167,7 @@ private slots: void task223138_triggered(); void task256322_highlight(); void menubarSizeHint(); + void taskQTBUG4965_escapeEaten(); #if defined(QT3_SUPPORT) void indexBasedInsertion_data(); @@ -1664,6 +1665,27 @@ void tst_QMenuBar::menubarSizeHint() QCOMPARE(resSize, mb.sizeHint()); } +void tst_QMenuBar::taskQTBUG4965_escapeEaten() +{ + QMenuBar menubar; + QMenu menu("menu1"); + QAction *first = menubar.addMenu(&menu); + menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC")); + menubar.show(); + menubar.setActiveWindow(); + QTest::qWaitForWindowShown(&menubar); + menubar.setActiveAction(first); + QTRY_VERIFY(menu.isVisible()); + QCOMPARE(menubar.activeAction(), first); + QTest::keyClick(0, Qt::Key_Escape); + QVERIFY(!menu.isVisible()); + QTRY_VERIFY(menubar.hasFocus()); + QCOMPARE(menubar.activeAction(), first); + QTest::keyClick(0, Qt::Key_Escape); + QVERIFY(!menubar.activeAction()); + QTest::keyClick(0, Qt::Key_Escape); //now the action should be triggered + QTRY_VERIFY(!menubar.isVisible()); +} #if defined(QT3_SUPPORT) void tst_QMenuBar::indexBasedInsertion_data() diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index 7807761..5f3de7b 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -46,6 +46,8 @@ #include <QtCore/QString> #include <QtCore/QStringList> +#include <iostream> + static int usage(const QStringList &args) { Q_UNUSED(args); @@ -55,7 +57,7 @@ static int usage(const QStringList &args) foreach (Translator::FileFormat format, Translator::registeredFileFormats()) loaders += line.arg(format.extension, -5).arg(format.description); - qWarning("%s", qPrintable(QString(QLatin1String("\nUsage:\n" + std::cerr << qPrintable(QString(QLatin1String("\nUsage:\n" " lconvert [options] <infile> [<infile>...]\n\n" "lconvert is part of Qt's Linguist tool chain. It can be used as a\n" "stand-alone tool to convert and filter translation data files.\n" @@ -117,7 +119,7 @@ static int usage(const QStringList &args) " 0 on success\n" " 1 on command line parse failures\n" " 2 on read failures\n" - " 3 on write failures\n")).arg(loaders))); + " 3 on write failures\n")).arg(loaders)); return 1; } diff --git a/tools/linguist/linguist/messageeditor.cpp b/tools/linguist/linguist/messageeditor.cpp index 616bb26..a7cc636 100644 --- a/tools/linguist/linguist/messageeditor.cpp +++ b/tools/linguist/linguist/messageeditor.cpp @@ -407,10 +407,12 @@ QTextEdit *MessageEditor::activeTranslation() const { if (m_currentNumerus < 0) return 0; - foreach (QTextEdit *te, m_editors[m_currentModel].transTexts[m_currentNumerus]->getEditors()) + const QList<FormatTextEdit *> &editors = + m_editors[m_currentModel].transTexts[m_currentNumerus]->getEditors(); + foreach (QTextEdit *te, editors) if (te->hasFocus()) return te; - return 0; // This cannot happen + return editors.first(); } QTextEdit *MessageEditor::activeOr1stTranslation() const diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 443abd0..857233e 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -306,7 +306,6 @@ private: // the string to read from and current position in the string QTextCodec *yySourceCodec; - bool yySourceIsUnicode; QString yyInStr; const ushort *yyInPtr; @@ -353,7 +352,6 @@ void CppParser::setInput(const QString &in) yyInStr = in; yyFileName = QString(); yySourceCodec = 0; - yySourceIsUnicode = true; yyForceUtf8 = true; } @@ -362,7 +360,6 @@ void CppParser::setInput(QTextStream &ts, const QString &fileName) yyInStr = ts.readAll(); yyFileName = fileName; yySourceCodec = ts.codec(); - yySourceIsUnicode = yySourceCodec->name().startsWith("UTF-"); yyForceUtf8 = false; } @@ -1430,24 +1427,24 @@ QString CppParser::transcode(const QString &str, bool utf8) { static const char tab[] = "abfnrtv"; static const char backTab[] = "\a\b\f\n\r\t\v"; - const QString in = (!utf8 || yySourceIsUnicode) - ? str : QString::fromUtf8(yySourceCodec->fromUnicode(str).data()); - QString out; + // This function has to convert back to bytes, as C's \0* sequences work at that level. + const QByteArray in = yyForceUtf8 ? str.toUtf8() : tor->codec()->fromUnicode(str); + QByteArray out; out.reserve(in.length()); for (int i = 0; i < in.length();) { - ushort c = in[i++].unicode(); + uchar c = in[i++]; if (c == '\\') { if (i >= in.length()) break; - c = in[i++].unicode(); + c = in[i++]; if (c == '\n') continue; if (c == 'x') { QByteArray hex; - while (i < in.length() && isxdigit((c = in[i].unicode()))) { + while (i < in.length() && isxdigit((c = in[i]))) { hex += c; i++; } @@ -1456,7 +1453,7 @@ QString CppParser::transcode(const QString &str, bool utf8) QByteArray oct; int n = 0; oct += c; - while (n < 2 && i < in.length() && (c = in[i].unicode()) >= '0' && c < '8') { + while (n < 2 && i < in.length() && (c = in[i]) >= '0' && c < '8') { i++; n++; oct += c; @@ -1464,13 +1461,14 @@ QString CppParser::transcode(const QString &str, bool utf8) out += oct.toUInt(0, 8); } else { const char *p = strchr(tab, c); - out += QChar(QLatin1Char(!p ? c : backTab[p - tab])); + out += !p ? c : backTab[p - tab]; } } else { out += c; } } - return out; + return (utf8 || yyForceUtf8) ? QString::fromUtf8(out.constData(), out.length()) + : tor->codec()->toUnicode(out); } void CppParser::recordMessage( @@ -2150,9 +2148,9 @@ void loadCPP(Translator &translator, const QStringList &filenames, ConversionDat QTextStream ts(&file); ts.setCodec(codec); ts.setAutoDetectUnicode(true); - if (ts.codec()->name() == "UTF-16") - translator.setCodecName("System"); parser.setInput(ts, filename); + if (cd.m_outputCodec.isEmpty() && ts.codec()->name() == "UTF-16") + translator.setCodecName("System"); Translator *tor = new Translator; tor->setCodecName(translator.codecName()); parser.setTranslator(tor); diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index bdaec4f..9a9af68 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -54,13 +54,20 @@ #include <QtCore/QStringList> #include <QtCore/QTextCodec> +#include <iostream> + static QString m_defaultExtensions; -static void printOut(const QString & out) +static void printErr(const QString & out) { qWarning("%s", qPrintable(out)); } +static void printOut(const QString & out) +{ + std::cerr << qPrintable(out); +} + static void recursiveFileInfoList(const QDir &dir, const QSet<QString> &nameFilters, QDir::Filters filter, QFileInfoList *fileinfolist) @@ -137,7 +144,7 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil cd.m_sortContexts = !(options & NoSort); if (QFile(fileName).exists()) { if (!tor.load(fileName, cd, QLatin1String("auto"))) { - printOut(cd.error()); + printErr(cd.error()); *fail = true; continue; } @@ -197,11 +204,11 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil out.normalizeTranslations(cd); if (!cd.errors().isEmpty()) { - printOut(cd.error()); + printErr(cd.error()); cd.clearErrors(); } if (!out.save(fileName, cd, QLatin1String("auto"))) { - printOut(cd.error()); + printErr(cd.error()); *fail = true; } } @@ -494,6 +501,7 @@ int main(int argc, char **argv) if (!tmp.isEmpty() && !tmp.first().isEmpty()) { codecForTr = tmp.first().toLatin1(); fetchedTor.setCodecName(codecForTr); + cd.m_outputCodec = codecForTr; } tmp = variables.value("CODECFORSRC"); if (!tmp.isEmpty() && !tmp.first().isEmpty()) { diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 05fc6e5..8a071d3 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -67,7 +67,7 @@ QString QObject::tr(const char *sourceText, const char *, int n) #endif Translator::Translator() : - m_codecName("ISO-8859-1"), + m_codec(QTextCodec::codecForName("ISO-8859-1")), m_locationsType(AbsoluteLocations) { } @@ -713,12 +713,17 @@ void Translator::setCodecName(const QByteArray &name) if (!codec) { if (!name.isEmpty()) qWarning("No QTextCodec for %s available. Using Latin1\n", name.constData()); - m_codecName = "ISO-8859-1"; + m_codec = QTextCodec::codecForName("ISO-8859-1"); } else { - m_codecName = codec->name(); + m_codec = codec; } } +QByteArray Translator::codecName() const +{ + return m_codec->name(); +} + void Translator::dump() const { for (int i = 0; i != messageCount(); ++i) diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index f29317b..353cf9d 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -97,7 +97,7 @@ public: public: QString m_defaultContext; QByteArray m_codecForSource; // CPP, PO & QM specific - QByteArray m_outputCodec; // PO specific + QByteArray m_outputCodec; // CPP & PO specific QString m_unTrPrefix; // QM specific QString m_sourceFileName; QString m_targetFileName; @@ -151,7 +151,8 @@ public: void reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose); void setCodecName(const QByteArray &name); - QByteArray codecName() const { return m_codecName; } + QByteArray codecName() const; + QTextCodec *codec() const { return m_codec; } QString languageCode() const { return m_language; } QString sourceLanguageCode() const { return m_sourceLanguage; } @@ -211,7 +212,7 @@ private: typedef QList<TranslatorMessage> TMM; // int stores the sequence position. TMM m_messages; - QByteArray m_codecName; + QTextCodec *m_codec; LocationsType m_locationsType; // A string beginning with a 2 or 3 letter language code (ISO 639-1 |